# chatty-answer-error

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

## Key rules

- `chatty-answer-error` khai báo 3 attribute, 1 property không có attribute, 2 event, 0 slot, 2 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/answer-error.js` là define `chatty-answer-error`; 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

Customer-safe answer error with a host-owned retry action. Class `ChattyAnswerError`.

### Attributes

| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `label` | `label` | `string` | `'Something went wrong while preparing the answer.'` | Translated safe error message. |
| `retry-label` | `retryLabel` | `string` | `'Try again'` | Translated retry action. |
| `disabled` | `disabled` | `boolean` | `false` | Disables retry independently of pending progress. |

### Properties

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

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `loading` | `boolean` | `false` | Pending retry keeps the same focusable button while blocking repeated activation. |

### Events

| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-retry` | `CustomEvent<{}>` | Requests another answer attempt. |
| `click` | `MouseEvent` | Native retry button click. |

### Slots

Not declared in the manifest.

### Parts

| Name | Description |
| --- | --- |
| `base` | Error alert. |
| `retry` | Retry button. |

### CSS custom properties

Not declared in the manifest.

## Usage

```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/answer-error.js';
```

```html
<chatty-answer-error></chatty-answer-error> 
```

## 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.

```html
<chatty-answer-error></chatty-answer-error> 
```

## 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ố.

```html
<chatty-answer-error></chatty-answer-error> 
```

| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `retry` | chatty-ui/custom-elements.json |

## Keyboard

| Key | Action |
| --- | --- |
| Enter / Space | Activate retry when available. |

### Source

- chatty-ui/custom-elements.json
