# chatty-block-contact-form

API chuẩn của element chatty-block-contact-form, sinh từ custom-elements.json của prototype trong guide.

## Key rules

- `chatty-block-contact-form` khai báo 1 attribute, 1 property không có attribute, 2 event, 0 slot, 0 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-contact-form.js` là define `chatty-block-contact-form`; chunk chỉ import element nó dùng. Prototype chuẩn:  trong guide.
- Đổi tên attribute, event, slot, part hay CSS custom property là đổi API: diff của custom-elements.json phải có trong 1 MR.

## Overview

Opt-in in-message contact step; the host owns submission and stage changes. Class `ChattyBlockContactForm`.

### Attributes

| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Canonical data with fields, values, loading, skipping, submitted, skippable and first-field focus. |

### Properties

Attributes also expose the properties listed in the Property column above.

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `strings` | `object` | `{}` | Translated contact and submitted labels. |

### Events

| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-submit` | `CustomEvent<{values: Object}>` | Valid fields to persist. |
| `chatty-skip` | `CustomEvent<{}>` | Anonymous contact requested. |

### Slots

Not declared in the manifest.

### Parts

Not declared in the manifest.

### CSS custom properties

Not declared in the manifest.

## Usage

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/chatty-block-contact-form.js';
export function Standard() {
  return html`<chatty-block-contact-form style="display:block;width:100%;max-width:360px" .block=${{data:{fields:['email','name'],skippable:true}}}></chatty-block-contact-form>`;
}
```

## Live preview

Component thật dùng cùng story với trang component; dữ liệu mẫu nằm trong frame cục bộ.

Example (Standard) — Default: trạng thái mặc định và nội dung mẫu của element.

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/chatty-block-contact-form.js';
export function Standard() {
  return html`<chatty-block-contact-form style="display:block;width:100%;max-width:360px" .block=${{data:{fields:['email','name'],skippable:true}}}></chatty-block-contact-form>`;
}
```

Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/chatty-block-contact-form.js';
export function States() {
  return html`<div style="display:flex;flex-wrap:wrap;gap:20px;width:100%">
    <chatty-block-contact-form style="display:block;flex:1;min-width:220px" .block=${{data:{loading:true,values:{email:'you@example.com'}}}}></chatty-block-contact-form>
    <chatty-block-contact-form style="display:block;flex:1;min-width:220px" .block=${{data:{submitted:true}}}></chatty-block-contact-form>
  </div>`;
}
```

## Anatomy

Số trong hình khớp bảng bên dưới. Phần chỉ hiện ở state khác được ghi Not shown; ví dụ không thêm phần tử giả.

Example (Standard) — Anatomy: một instance mặc định riêng, có khoảng trống quanh các phần được đánh số.

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/chatty-block-contact-form.js';
export function Standard() {
  return html`<chatty-block-contact-form style="display:block;width:100%;max-width:360px" .block=${{data:{fields:['email','name'],skippable:true}}}></chatty-block-contact-form>`;
}
```

| Part | Element | Source |
| --- | --- | --- |
| 1 | Element host `chatty-block-contact-form` | chatty-ui/custom-elements.json |

## Keyboard

No element-specific keys.

### Source

- chatty-ui/custom-elements.json
