# chatty-menu-item

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

## Key rules

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

One row of a chatty-menu. The host is the menuitem (role and roving tabindex on the host, so the menu owns its items in the same tree); Enter and Space activate it as a click. Class `ChattyMenuItem`.

### Attributes

| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `disabled` | `disabled` | `boolean` | `false` | Skipped by the arrow keys and ignores activation; still announced as unavailable. |

### Properties

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

Not declared in the manifest.

### Events

| Name | Detail type | Description |
| --- | --- | --- |
| `click` | `MouseEvent` | Activation by pointer, Enter or Space; blocked while disabled. |

### Slots

| Name | Description |
| --- | --- |
| default | Row label. |
| `icon` | Leading icon. |

### Parts

| Name | Description |
| --- | --- |
| `base` | Row box. |
| `icon` | Icon wrapper. |
| `label` | Label wrapper. |

### CSS custom properties

| Name | Default | Description |
| --- | --- | --- |
| `--chatty-menu-item-padding` | – | Row padding. |

## 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: ví dụ giữ context cha cần thiết từ story có sẵn.

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {
  IconDots,
  IconHeadset,
  IconPaperclip,
  IconSmile,
  IconStar
} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-menu prototype chatty-ui ports from (chatty-ui/src/elements/menu.js, menu-item.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/menu.js';
import '@avada/chatty-ui/elements/menu-item.js';

export function Standard() {
  return html`
    <chatty-menu open style="margin-block-end: 220px">
      <button
        slot="trigger"
        type="button"
        aria-label="More"
        style="display:inline-grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid var(--chatty-color-border);border-radius:999px;background:var(--chatty-color-bg-surface);color:var(--chatty-color-text);cursor:pointer"
      >
        ${IconDots({size: 16})}
      </button>
      <chatty-menu-item>${IconHeadset({slot: 'icon', size: 16})}Talk to a person</chatty-menu-item>
      <chatty-menu-item>${IconStar({slot: 'icon', size: 16})}Rate this chat</chatty-menu-item>
      <chatty-menu-item>${IconPaperclip({slot: 'icon', size: 16})}Upload file</chatty-menu-item>
      <chatty-menu-item>${IconSmile({slot: 'icon', size: 16})}Emoji</chatty-menu-item>
    </chatty-menu>
  `;
}
```

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 {
  IconDots,
  IconHeadset,
  IconPaperclip,
  IconSmile,
  IconStar
} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-menu prototype chatty-ui ports from (chatty-ui/src/elements/menu.js, menu-item.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/menu.js';
import '@avada/chatty-ui/elements/menu-item.js';

export function States() {
  return html`
    <chatty-menu open style="margin-block-end: 180px">
      <button
        slot="trigger"
        type="button"
        aria-label="More"
        style="display:inline-grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid var(--chatty-color-border);border-radius:999px;background:var(--chatty-color-bg-surface);color:var(--chatty-color-text);cursor:pointer"
      >
        ${IconDots({size: 16})}
      </button>
      <chatty-menu-item>Talk to a person</chatty-menu-item>
      <chatty-menu-item disabled>Rate this chat</chatty-menu-item>
      <chatty-menu-item>Emoji</chatty-menu-item>
    </chatty-menu>
  `;
}
```

## 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 {
  IconDots,
  IconHeadset,
  IconPaperclip,
  IconSmile,
  IconStar
} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-menu prototype chatty-ui ports from (chatty-ui/src/elements/menu.js, menu-item.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/menu.js';
import '@avada/chatty-ui/elements/menu-item.js';

export function Standard() {
  return html`
    <chatty-menu open style="margin-block-end: 220px">
      <button
        slot="trigger"
        type="button"
        aria-label="More"
        style="display:inline-grid;place-items:center;width:32px;height:32px;padding:0;border:1px solid var(--chatty-color-border);border-radius:999px;background:var(--chatty-color-bg-surface);color:var(--chatty-color-text);cursor:pointer"
      >
        ${IconDots({size: 16})}
      </button>
      <chatty-menu-item>${IconHeadset({slot: 'icon', size: 16})}Talk to a person</chatty-menu-item>
      <chatty-menu-item>${IconStar({slot: 'icon', size: 16})}Rate this chat</chatty-menu-item>
      <chatty-menu-item>${IconPaperclip({slot: 'icon', size: 16})}Upload file</chatty-menu-item>
      <chatty-menu-item>${IconSmile({slot: 'icon', size: 16})}Emoji</chatty-menu-item>
    </chatty-menu>
  `;
}
```

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

## Keyboard

| Key | Action |
| --- | --- |
| Enter / Space | Activate the enabled item. |

### Source

- chatty-ui/custom-elements.json
