# Chatty UI
Dùng cùng một hệ thống quy tắc để thiết kế AI Mode, Classic và admin inbox.
## Key rules
- Giữ 1 primary action trong mỗi view.
- Chuyển storefront sang mobile ở chiều rộng ≤899px.
- Dành hit target ≥44px cho control trên mobile.
- Giữ secondary text đạt contrast ≥4.5:1 trên nền sáng nhất.
## Overview
Example — Ba tầng tài liệu và ba bề mặt Chatty; chọn một tầng để mở trang bắt đầu.
```jsx
import React from 'react';
export function Overview() {
return (
AI ModeThread và composer trên storefront. Nguồn: QA storefront, cắt từ
ảnh desktop.
ClassicPanel chat gọn. Nguồn: preview Product recommendation của guide.
Admin InboxWorkspace xử lý hội thoại. Nguồn: bản chụp Inbox có chú
thích vùng.
Đi từ quy tắc đến control rồi tới luồng. Ba bề mặt dùng chung ngôn ngữ thiết kế, giữ bố cục
riêng.
);
}
```
## Start here
| Area | Use |
| --- | --- |
| [Brand](https://chatty-ui-research.avada-tesla-chatty.workers.dev/brand/) | Logo, màu và luật cho ấn phẩm Chatty. |
| [Foundations](https://chatty-ui-research.avada-tesla-chatty.workers.dev/foundations/typography/) | Chọn type role, kích thước và hệ thống token. |
| [Components](https://chatty-ui-research.avada-tesla-chatty.workers.dev/components/button/) | Chọn variant, state và cách đặt label. |
| [Patterns](https://chatty-ui-research.avada-tesla-chatty.workers.dev/patterns/waiting-streaming/) | Ghép component thành luồng chờ và trả lời. |
## For agents
Đọc [llms.txt](https://chatty-ui-research.avada-tesla-chatty.workers.dev/llms.txt) để chọn tài liệu hoặc [llms-full.txt](https://chatty-ui-research.avada-tesla-chatty.workers.dev/llms-full.txt) để lấy toàn bộ quy tắc. Dùng Copy Markdown trên mỗi trang để lấy nội dung sạch.
## Surface
| Surface | Scope |
| --- | --- |
| AI Mode | Trải nghiệm mua sắm trên storefront. |
| Classic | Chat widget truyền thống trên storefront. |
| admin inbox | Hội thoại và công cụ của merchant. |
- Chatty UI team decision
- [Target size](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html)
- [Contrast](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html)
---
# Brand
Nhận diện thương hiệu Chatty cho ấn phẩm marketing: logo, màu, chữ, icon, hình.
Không phải token sản phẩm. UI sản phẩm dùng [Foundations](https://chatty-ui-research.avada-tesla-chatty.workers.dev/foundations/colour-elevation/).
Nguồn: Figma Chatty-branding-2025, bản agent 2026-11-16. Owner: Thu Le (PMM).
[Download brand kit (.zip)](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-chatty-brand-kit.zip?v=1795057388)
## Logo
| Light | Navy | Dark gradient | Light gradient |
| --- | --- | --- | --- |
|  |  |  |  |
| Light icon | Navy icon | Dark gradient icon | Light gradient icon |
| --- | --- | --- | --- |
|  |  |  |  |
- Logo là bong bóng chat có 2 "mắt". Có 2 dạng: **icon** (chỉ bong bóng, dùng cho app icon, favicon, chỗ nhỏ) và **full logo** (bong bóng + chữ "chatty").
- Logo luôn nằm trên cùng, không bị pattern hay ảnh che.
- Không đổi màu logo ngoài các bản có sẵn. Không kéo méo, không thêm bóng, không thêm viền.
- Nền ảnh blog mặc định đã có sẵn logo, không chèn thêm logo thứ hai.
| Background | File | Download |
| --- | --- | --- |
| Trắng | `logo/logo-blue-white-bg.png`, `logo/icon-blue-white-bg.png` | [logo-blue-white-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-blue-white-bg.png?v=1795057545), [icon-blue-white-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-icon-blue-white-bg.png?v=1795057520) |
| Trắng, cần bản đen | `logo/logo-black-white-bg.png` | [logo-black-white-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-black-white-bg.png?v=1795057536) |
| Navy đặc | `logo/logo-white-blue-bg.png`, `logo/icon-white-blue-bg.png` | [logo-white-blue-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-white-blue-bg.png?v=1795057565), [icon-white-blue-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-icon-white-blue-bg.png?v=1795057528) |
| Gradient tối | `logo/logo-white-dark-gradient-bg.png`, `logo/icon-white-gradient-bg.png` | [logo-white-dark-gradient-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-white-dark-gradient-bg.png?v=1795057570), [icon-white-gradient-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-icon-white-gradient-bg.png?v=1795057532) |
| Gradient sáng | `logo/logo-blue-light-gradient-bg.png`, `logo/icon-dark-gradient-bg.png` | [logo-blue-light-gradient-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-blue-light-gradient-bg.png?v=1795057541), [icon-dark-gradient-bg.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-icon-dark-gradient-bg.png?v=1795057524) |
| Trong suốt, đặt lên nền tuỳ ý | `logo/logo-navy-transparent.png`, `logo/logo-navy-transparent-hires.png`, `logo/logo-white-transparent.png` | [logo-navy-transparent.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-navy-transparent.png?v=1795057557), [logo-navy-transparent-hires.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-navy-transparent-hires.png?v=1795057552), [logo-white-transparent.png](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-white-transparent.png?v=1795057573) |
| Web | `logo/logo-website.webp` | [logo-website.webp](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-logo-website.webp?v=1795057561) |
Do: Logo nằm trên cùng, trên nền đặc.
Don't: Đổi màu, kéo méo, thêm bóng, thêm viền hoặc để pattern che logo.
Vùng trống và kích thước tối thiểu chưa được chép. Xem Not yet defined.
Nguồn: [brand-kit: brand-guidelines.agent.md §5](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
## Colour
### Palette
| Token | HEX | Role |
| --- | --- | --- |
| Navy (Primary/Blue/500) | `#06038D` | Màu chính. Chữ tiêu đề, nền tối, logo, CTA chính |
| Light navy (Primary/Blue/50) | `#E6E6F4` | Nền nhạt, card, hover |
| Yellow (Primary/Yellow/500) | `#FBC80B` | Điểm nhấn, highlight, số payoff, khung khoanh |
| Purple (Secondary/Purple/500) | `#5750FE` | Màu phụ. Điểm nhấn chữ, link, primary UI (light mode) |
| Black | `#000000` | Icon preset đen |
| Gray | `#A2A2A2` | Màu accent của icon, vạch chia |
| White | `#FFFFFF` | Nền sạch, chữ trên nền tối |
| Neutral light | `#ECEDF1` | Nền phụ, card |
**Màu ngoài token được phép:**
| Context | Colour | Scope |
| --- | --- | --- |
| Only in aurora | `#4F49E7` | Đốm tím của nền aurora, chỉ dùng trong aurora. |
| Product UI dark mode | `#7570F8` | Primary tím cho dark mode trong UI sản phẩm. Light mode vẫn `#5750FE`. |
**Cách phối:**
- Chữ trên nền sáng dùng navy, không dùng xám trung tính (kiểu `#52526B`).
- Chữ vàng chìm trên nền trắng thì đổi sang navy, không thêm viền.
- Pain hoặc mất mát: dùng tím hoặc navy đậm. Payoff: dùng vàng.
**Cấm:** đỏ (kể cả cho "lỗi", "mất tiền"), pastel (mint, peach, lavender), palette 3D stock, trộn màu kiểu oklch ra hồng đỏ.
```css
:root {
--chatty-navy: #06038d;
--chatty-navy-50: #e6e6f4;
--chatty-yellow: #fbc80b;
--chatty-purple: #5750fe;
--chatty-purple-dark-mode: #7570f8;
--chatty-aurora-purple: #4f49e7;
--chatty-black: #000000;
--chatty-gray: #a2a2a2;
--chatty-white: #ffffff;
--chatty-neutral: #ecedf1;
}
```
### Contrast
Tỉ lệ tính từ độ chói tương đối sRGB theo WCAG, làm tròn hai chữ số.
| Colour | On white | On navy | Text use |
| --- | --- | --- | --- |
| Navy `#06038D` | 14.94:1 | 1.00:1 | Có trên nền sáng |
| Light navy `#E6E6F4` | 1.24:1 | 12.09:1 | Có trên navy |
| Yellow `#FBC80B` | 1.57:1 | 9.51:1 | Không trên nền sáng. Trên navy được |
| Purple `#5750FE` | 5.27:1 | 2.83:1 | Có trên trắng. Không trên navy |
| Black `#000000` | 21.00:1 | 1.41:1 | Có trên trắng |
| Gray `#A2A2A2` | 2.55:1 | 5.85:1 | Không trên nền sáng, chỉ accent icon và vạch chia |
| White `#FFFFFF` | 1.00:1 | 14.94:1 | Có trên navy |
| Neutral light `#ECEDF1` | 1.17:1 | 12.77:1 | Có trên navy |
Purple dark mode `#7570F8`: 3.87:1 trên trắng, 4.47:1 trên `#161B22`. Không dùng làm chữ thường trên các nền này.
### Aurora
Nguồn: hero chatty.net, component `PageAuroraBg.tsx`.
- Nền trắng.
- Đốm vàng `#FBC80B` góc trên trái, đốm tím `#4F49E7` góc dưới phải. Đốm là hình hữu cơ, không phải hình tròn.
- Blur khoảng 170 tới 194px.
- Lớp noise: SVG `feTurbulence type="fractalNoise" baseFrequency="0.4" numOctaves="3"`, opacity 0.2.
- Đáy fade về trắng.
- Chữ trên aurora: navy, điểm nhấn tím.
### Site backgrounds
Nền trắng + `radial-gradient` vàng `rgba(251,200,11,.30)` ở một góc + `radial-gradient` tím `rgba(87,80,254,.22)` ở góc đối diện. Không tô gradient đậm phủ kín card.
### Gradients
| Name | CSS | Use |
| --- | --- | --- |
| Navy depth | `linear-gradient(180deg, #06038D 40%, #030077 91%)` | Nền banner tối, hero tối |
| Yellow to Purple | `linear-gradient(180deg, #FBC80B 0%, #5750FE 100%)` | Chỉ cho icon preset gradient hoặc mảng nhỏ. **Không phủ kín nền** |
| Grey to Navy fade | `linear-gradient(180deg, rgba(217,217,217,0) 0%, #06038D 100%)` | Phủ mờ lên ảnh |
| Navy deep | `linear-gradient(180deg, #06038D 0%, #02005D 100%)` | Card mascot, section tối |
### Blur
| Scale | Use |
| --- | --- |
| 20px | Bóng nhẹ |
| 55px | Glow phần tử |
| 200px | Glow nền nhỏ |
| 500px | Glow nền lớn |
| 700 tới 1089px | Mesh hero |
Dùng 1 trong các mức: 20px (bóng nhẹ), 55px (glow phần tử), 200px (glow nền nhỏ), 500px (glow nền lớn), 700 tới 1089px (mesh hero). Blur từ 500px chỉ dùng cho hero và landing, không dùng cho ảnh social nhỏ hơn 1080x1080.
### Avoid
- Gradient tự chế, góc 135deg nhiều stop, radial vàng "glow góc" kiểu template.
- Nền navy phẳng cho ảnh social (Thu đã bác). Nền social dùng aurora, nền sáng hoặc nền tối có noise.
- Hạt sáng, sao, chấm bay. Ảnh nền AI sinh. Ảnh stock người mẫu cười cầm laptop.
Nguồn: [brand-kit: brand-guidelines.agent.md §2](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
Nguồn: [brand-kit: brand-guidelines.agent.md §3](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
## Typography
```clash
Chat. Smile. Buy.
Aa Bb 0123
```

Ảnh từ Figma 2025. Clash Grotesk và Inter trong ảnh là luật cũ, đã được General Sans thay thế trong bản agent.
```general-sans
Chatty recommends the right product.
Chatty adds it to the cart.
Chatty brings shoppers back.
```
| Role | Font | Weight |
| --- | --- | --- |
| Tiêu đề, số lớn | Clash Display | 500 Medium (ưu tiên), 600 Semibold, 700 Bold cho hero |
| Mọi chữ còn lại: body, nhãn, caption, nút | General Sans | 400, 500, 600 |
- Tối đa 2 font mỗi ấn phẩm.
- **Inter đã bỏ.** Bản 2025 ghi Inter và Clash Grotesk cho body. Luật mới là General Sans.
- Không set body bằng Clash Display. Clash chỉ dành cho tiêu đề.
- Thu thấy Clash Semibold hơi thô. Mặc định dùng Medium.
- **Tiếng Việt:** Clash Display thiếu toàn bộ nguyên âm có dấu (ơ, ư, ạ, ế...). Chữ tiếng Việt không được set Clash. General Sans chưa kiểm đủ dấu, nên dùng Inter hoặc `system-ui` cho tiếng Việt.
- **Trang chatty.net (trang chủ):** Clash chỉ cho H1. H2, số lớn, CTA, footer dùng General Sans 600, `letter-spacing: -0.03em`.
- Cấm: Google Sans, Poppins, Montserrat, Roboto, Open Sans, font viết tay, serif trang trí.
- Nguồn font: Fontshare (license miễn phí cả dùng thương mại). File: `chatty.net/public/fonts/`.
```css
font-family: "Clash Display", system-ui, sans-serif; /* tiêu đề tiếng Anh */
font-family: "General Sans", system-ui, sans-serif; /* body */
```
Tiếng Việt: Clash Display thiếu nguyên âm có dấu. Chữ tiếng Việt dùng Inter hoặc system-ui.
Don't: Chữ “Chào bạn” bằng Clash sẽ rơi về font dự phòng.
Nguồn: [brand-kit: brand-guidelines.agent.md §4](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
## Icons

Ảnh từ Figma. Chờ SVG để có lưới icon tải riêng.
- Kiểu: **filled 2D, 2 tông** (1 màu chính + 1 màu accent). Không line-art outline, không bóng, không 3D, không gloss. Góc bo mềm. ViewBox 80x80.
- 3 preset, không tự đổi màu:
| Preset | Colours | Use |
| --- | --- | --- |
| Gradient | Yellow `#FBC80B` + Purple `#5750FE` | Chỗ cần nổi bật, CTA, tính năng quan trọng |
| Đen xám | Black `#000000` + Gray `#A2A2A2` | Nền sáng, bối cảnh trung tính |
| Trắng xám | White `#FFFFFF` + Gray `#A2A2A2` | Nền tối, nhất là navy |
- Một màn hình hoặc một ấn phẩm chỉ dùng 1 preset.
- Bộ icon hiện có: cart-check, bag, discount-tag, store, box, gift, tag-arrow, chat, scan. Xem `icons.png`.
- Cấm: icon Flaticon gradient, Iconscout 3D, Freepik 3D, icon do AI sinh.
Nguồn: [brand-kit: brand-guidelines.agent.md §6](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
## Illustration
**Bong bóng chat** (lấy từ logo) là yếu tố chính. Dùng nhiều hình dạng và cỡ cho sinh động, nhưng phải cùng một họ. Xem `illustrative-elements.png`.
**Pattern động** (`custom-dynamic.png`):
- Dùng icon mắt và bong bóng chat làm pattern.
- Trong sản phẩm số, pattern dùng nhẹ, không hiện trọn hình.
- Pattern mắt giữ trừu tượng và làm mờ.
- Logo luôn đặt trên pattern.
**Minh hoạ tính năng** (`illustrating-functionality.png`):
- Màu chính là vàng, navy, trắng. Vàng kéo mắt, navy và trắng tạo khung.
- Bố cục gọn, ít phần tử, để tính năng là trọng tâm.
- Dùng cho widget chat, AI trả lời, product card...
- Ảnh UI nguồn nhỏ thì dựng lại bằng HTML/CSS cho nét, không phóng ảnh chụp.
**Tính năng + thông điệp** (`illustrating-functionality-messaging.png`):
- Ghép banner, ảnh, ad copy với minh hoạ tính năng. Minh hoạ là trọng tâm.
- Dùng cho campaign, social ads, banner. Có thể trộn ảnh người thật với UI sản phẩm.
**Mockup khung chat Chatty** (đặt trên nền Chatty):
- Khách bên trái: avatar tròn nhỏ, bong bóng tím nhạt `#C9C7FB`, chữ đen.
- Chatty bên phải: bong bóng xám nhạt `#EEEEF3`, chữ đen, avatar `logo/icon-white-gradient-bg.png`, dưới avatar ghi "Chatty AI" màu navy.
- Khung trắng, bo góc lớn, bóng nhẹ.
**Widget đặt trên store của khách** (preview, demo, dựng lại store): để trung tính. Không logo Chatty, không tím Chatty, chữ gần đen `#111`, nhãn bot là " assistant".
**Sticker:** được dùng nhưng không trẻ con. Font đi kèm vẫn phải chắc, chuyên nghiệp.

Ảnh Figma 2025 có sao lấp lánh; luật 2026 cấm sao (mục 8). Dùng bong bóng, bỏ sao.



### AI slop
Thu đã bác các kiểu dưới đây trên ấn phẩm thật. Gặp là sửa.
| Don't | Do |
| --- | --- |
| Pill, chip, bong bóng bọc tiêu đề hoặc nhãn ("FREE GUIDE", "STEP 1", "After Black Friday") | Chữ trơn, navy, không nền |
| Nhãn IN HOA cỡ nhỏ giãn chữ ("REASON 01", "ASSISTED REVENUE") | Viết thường kiểu câu ("Assisted revenue"). Đánh số thì viết số bằng font tiêu đề |
| Gạch chân hoặc marker vàng dưới số | Nhấn bằng cỡ chữ, màu, khoảng trống |
| Vòng elip vẽ tay để khoanh | Khung chữ nhật bo góc vàng `#FBC80B` (bo không quá 12px trên ảnh blog) |
| Chữ có viền (`-webkit-text-stroke`) | Chữ phẳng, cần nổi thì đổi màu nền hoặc màu chữ |
| Em dash (U+2014) và middle dot (U+00B7) | Tách câu, dấu phẩy, dấu hai chấm, hoặc " - " |
| Thẻ kính, sao 3D, số hình cầu, halo tròn to | Phẳng, 2D |
| Accent bar ngắn kèm nhãn kiểu editorial | Bỏ |
| Nhiều chữ nhỏ: dòng nguồn, chú thích phụ, nhãn "sample" | Mỗi ảnh 1 điểm nhìn. Nguồn để ở caption |
| Mọi loại bài dùng y một bố cục | Mỗi loại bài có bố cục riêng |
| Mockup điện thoại có viền đen dày, tai thỏ, camera, nghiêng 3D | Màn trắng bo góc khoảng 52px, viền trong `#E6E6F4` 2px, máy đứng thẳng |
Lấy cảm hứng từ mẫu bên ngoài chỉ ở mức bố cục và phối cảnh. Không lấy chất liệu (kính, glow, sao).
Nguồn: [brand-kit: brand-guidelines.agent.md §7](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
Nguồn: [brand-kit: brand-guidelines.agent.md §8](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
## Voice
**Tagline thương hiệu:** "The #1 AI Sales Agent for eCommerce". Dòng "The AI-first chat platform built for eCommerce sales" đã bỏ, không dùng.
**Câu giới thiệu 25 chữ (dùng sẵn):**
> Chatty is the AI sales agent for Shopify stores. It recommends the right product, adds it to the cart and brings shoppers back, so you sell more.
**Cách gọi:**
- Chatty là **AI sales agent**, không phải chatbot. Phép thử: thay "Chatty" bằng "a chatbot" mà câu vẫn đúng thì câu đó chưa định vị.
- Động từ chính là việc bán: recommends, adds to cart, brings shoppers back. Không lấy "answers questions" làm động từ chính.
- Người của merchant gọi là "your team", không gọi "human agents".
**Giọng:** Clear, Modern, Friendly, Approachable, Simple, Trustworthy.
- Rõ, hiện đại: bố cục thoáng, không nhồi chữ.
- Thân thiện, dễ gần: bong bóng chat, mascot, sticker (không trẻ con).
- Đơn giản, đáng tin: font tiêu đề chắc, số có nguồn.
**Câu khẩu hiệu phụ:** "Chat. Smile. Buy."
Nguồn: [brand-kit: brand-guidelines.agent.md §1](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
## Not yet defined
Các trang dưới đây có trong Figma nhưng chưa chép. Gặp việc cần các phần này thì hỏi Thu, không tự đặt luật.
- Brand look & feel (trang moodboard tổng)
- Partnership: đặt logo Chatty cạnh logo đối tác
- Photography: ảnh nên dùng và ảnh không nên dùng
- Logo: vùng trống tối thiểu, kích thước tối thiểu
Hỏi Thu Le trước khi đặt luật.
Nguồn: [brand-kit: brand-guidelines.agent.md §10](https://cdn.shopify.com/s/files/1/0959/0128/6675/files/guide-20261119-brand-guidelines.agent.md?v=1795057578).
---
# Ad referral
Thẻ nguồn quảng cáo của tin nhắn trong inbox.
## Key rules
- Thẻ chỉ render khi có dữ liệu quảng cáo.
- Element `chatty-ad-referral` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Hiển thị ngữ cảnh quảng cáo của hội thoại.
### Use instead
| Component | Use when |
| --- | --- |
| `AdReferralBlock` | Hiển thị ngữ cảnh quảng cáo của hội thoại. |
| `button` | Caller sở hữu tương tác liên quan. |
## Live preview
Example (Standard) — Card chỉ có caption, và card có thumbnail, link bài đăng và chi tiết thu gọn.
```html
Summer collection Explore our collection
Canvas tote bag Carry everything, every day.
```
Example (Standard) — Card đã mở rộng: caption đầy đủ và ảnh chi tiết.
```html
Canvas tote bag Carry everything, every day.
```
Example (Current (React), being replaced) — Thẻ thật với dữ liệu cục bộ, không có media ngoài.
```jsx
import React from 'react';
import {AdReferralBlock} from '@assets/pages/InboxManagement/v2/blocks/AdReferralBlock.jsx';
import '@assets/pages/InboxManagement/v2/styles.scss';
export function Card() {
return text}} />;
}
```
## Standard
Example (Standard) — Card chỉ có caption, và card có thumbnail, link bài đăng và chi tiết thu gọn.
```html
Summer collection Explore our collection
Canvas tote bag Carry everything, every day.
```
Prototype (cùng `ad-referral.styles.js`) là chuẩn: chatty-ui port 1:1, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Caption, thumbnail và phần chi tiết (media, sản phẩm) đi qua slot. Chưa inbox dùng element thật; mục Admin bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-ad-referral` | @avada/chatty-ui/elements/ad-referral.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `heading` | string | `''` | Nhãn kênh, ví dụ Facebook ad, Instagram ad, Clicked your ad. |
| attribute | `href` | string | `''` | URL bài đăng; chỉ http(s), URL khác thì ẩn link. |
| attribute | `link-label` | string | `'View post'` | Chữ của link bài đăng. |
| attribute | `toggle-label` | string | `'Ad details'` | Tên truy cập của nút mở rộng. |
| attribute | `expanded` | boolean | `false` | Mở caption đầy đủ và phần chi tiết; ẩn thumbnail. |
| event | `toggle` | Event | – | expanded đổi từ nút mở rộng. |
| event | `click` | MouseEvent | – | Kích hoạt native của nút mở rộng. |
| slot | default | – | – | Caption: tiêu đề và nội dung quảng cáo. |
| slot | `thumb` | – | – | Thumbnail, ẩn khi mở rộng. |
| slot | `details` | – | – | Media và sản phẩm, hiện khi mở rộng. |
| part | `base` | – | – | Khung card. |
| part | `label` | – | – | Nhãn kênh. |
| part | `link` | – | – | Link bài đăng. |
| part | `caption` | – | – | Caption bị kẹp khi thu gọn. |
| part | `toggle` | – | – | Nút mở rộng; chỉ hiện khi có chi tiết hoặc caption bị kẹp. |
| part | `details` | – | – | Vùng chi tiết. |
| css-property | `--chatty-ad-referral-radius` | – | – | Bo góc. |
| css-property | `--chatty-ad-referral-background` | – | – | Nền. |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `AdReferralBlock` | @assets/pages/InboxManagement/v2/blocks/AdReferralBlock.jsx | .inbox-v2 |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Thumbnail tùy chọn, nhãn, nội dung, nút mở rộng và media. |
### Placement / order
| Context | Order |
| --- | --- |
| Caller | Theo thứ tự markup của component. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `block` | object | adReferral và i18n | Caller | Không có adReferral thì trả null. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Component | Theo nội dung | 8px | 8px | Theo token | body-small | Nút native | Grid fit-content |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Nền | Theo style inbox | Theo style inbox | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Mở rộng | Có media hoặc caption bị cắt | Hiện chi tiết khi nhấn. | aria-expanded |
### Behaviour
| Interaction | Result |
| --- | --- |
| Toggle | Đổi expanded và dừng sự kiện hàng. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Ad details | Ad details | Nhãn nút mở rộng |
### Source
| File | Evidence |
| --- | --- |
| | Public API |
| | Markup |
| | Caller |
## Do / Don't
Do: dùng API của surface hiện tại.
Don't: thay hành động của caller bằng hành vi giả định.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin | Nút có tên Ad details và aria-expanded | Nút native nhận Tab, Enter, Space | Không có live region | Theo style inbox |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Admin | Thẻ React trong thread của inbox | Not available — new build follows Target. Registry block của `chatty-message` (đợt C) ánh xạ block `ad-referral` sang element `chatty-ad-referral`, không có tag `chatty-block-*` riêng; dữ liệu đi qua property, không qua attribute; block không biết thì ẩn. | [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) |
| Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-ad-referral` từ mục Standard rồi chuyển caller từng surface. | |
```
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# Answer error
Thông báo lỗi an toàn cho khách và hành động Retry do host xử lý.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `AnswerError` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import {AnswerError} from '@avada/chatty-ui/canonical/AnswerError.jsx';
export function Retry({surface}) {
const [retried, setRetried] = useState(false);
return (
);
}
```
Example (Standard) — Availability fixture: online, offline, break, holiday và null (không có dot).
```js
import '@avada/chatty-ui/tokens/tokens.css';
// Standard: the chatty-avatar prototype chatty-ui ports from (chatty-ui/src/elements/avatar.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/avatar.js';
export function Status() {
return html`${['online', 'offline', 'break', 'holiday', null].map(status => html`S`)}`;
}
```
## Standard
Example (Standard) — Element chatty-avatar: size sm, md, lg với chữ viết tắt và ảnh.
```html
ALALAL
```
Prototype (cùng `avatar.styles.js` và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Chưa surface nào dùng element thật; các mục theo surface bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-avatar` | @avada/chatty-ui/elements/avatar.js |
### API
`status`: online / offline / break / holiday hoặc null (mặc định). Dot 9px ở góc avatar, màu từ STATUS_DOT_COLOR của React; null không render node. Host cấp availability đã resolve.
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `size` | sm, md, lg | `'md'` | Kích thước khung; md bằng khung mặc định của React. |
| attribute | `label` | string | `''` | Tên truy cập khi slot là chữ viết tắt; ảnh dùng alt của img. |
| attribute | `status` | online, offline, break, holiday, null | null | Availability; null ẩn dot. |
| part | `status` | – | – | Dot availability ở góc. |
| slot | default | – | – | img (cover) hoặc chữ viết tắt, icon fallback. |
| part | `base` | – | – | Khung tròn. |
| css-property | `--chatty-avatar-size` | – | – | Kích thước khung; thắng size. |
| css-property | `--chatty-avatar-radius` | – | – | Bo góc; mặc định tròn. |
| css-property | `--chatty-avatar-background` | – | – | Nền fallback sau chữ viết tắt. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Avatar` | @avada/chatty-ui | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
| `AvatarFallback` | @avada/chatty-ui | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
| `AvatarImage` | @avada/chatty-ui | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Root `div` của `Avatar`, nhận `className`, `style` và props khác. |
| 2 | `img` của `AvatarImage` hoặc `img` do caller đặt trực tiếp. |
| 3 | `AvatarFallback`: `div` căn giữa chữ hoặc số, đặt trong `Avatar`. |
### Placement / order
| Context | Order |
| --- | --- |
| Nhóm ảnh đơn hàng | Với mỗi sản phẩm: `Avatar` chứa `img`, rồi wrapper badge tuyệt đối ở top -4px, right -4px chứa `Avatar` số lượng. |
| Nhóm ảnh đơn hàng | Tối đa 4 ảnh; nếu nhiều hơn, hiện 3 ảnh rồi link `more` mở toàn bộ. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `className` | string | CSS classes | undefined | Áp lên root `Avatar`. |
| `style` | object | CSS declarations | undefined | Gộp sau style mặc định nên ghi đè được kích thước. |
| `src` | string | URL ảnh | undefined | Chỉ có trên `AvatarImage`. |
| `alt` | string | Chuỗi mô tả hoặc rỗng | undefined | Chỉ có trên `AvatarImage`; caller đặt tên sản phẩm hoặc chuỗi rỗng. |
| `variant` | string | rounded | Caller | Caller truyền `variant` nhưng `Avatar` chỉ chuyển nó vào `div` qua props. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| default | `height: 36` | Không có | Không khai báo | `50%` | `fontSize: '0.875rem'`, `fontWeight: 500` | Không tương tác | Không có override theo viewport |
| Order container | `height: 36` (không override) | Không có | 12px giữa các item | 8px | Không có chữ | Không tương tác | `!important` trong scope popup |
| Order quantity badge | 16px | Không có | Không khai báo | `50%` (inherit từ default) | `heading-small`; `font-size: inherit` | Không tương tác | `!important` trong scope popup |
| Order badge wrapper | 20px | Không có | Không khai báo | `50%` | Không có chữ | Không tương tác | Vị trí tuyệt đối top -4px, right -4px |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Container border | `border` | 1px solid #e3e3e3 | `border-color`: transparent |
| Badge fill | `background-color` | #707070 | #6c6c6c |
| Badge text | `color` | white | white |
| Badge wrapper fill | `background` | white | #433f3f |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Default | Render | `overflow: hidden`; `flexShrink: 0` giữ khung tròn không bị co. | Không thêm ARIA trên root |
| Dark | Theme | Container viền transparent; badge và wrapper đổi nền theo Tokens. | Không thêm ARIA |
| Image | Có `alt` | `AvatarImage` giữ `aspectRatio: '1/1'`, chiều cao và rộng 100%. | `alt` do caller đặt |
### Behaviour
| Interaction | Result |
| --- | --- |
| Ảnh lỗi | Không có state tải hoặc lỗi; `AvatarImage` và `AvatarFallback` là hai phần tử độc lập, caller quyết định hiển thị. |
| Click | Không có handler; root là `div`. |
| Số lượng | Caller truyền `quantity` làm nội dung của `AvatarFallback`. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Tên sản phẩm | Caller-owned | `alt` của `img` (`title`), rỗng khi thiếu |
| Số lượng | Caller-owned | `AvatarFallback` (`quantity`) |
### Source
| File | Evidence |
| --- | --- |
| | API và style mặc định |
| | Caller duy nhất của Classic |
| | Override trong scope popup |
## Do / Don't
Do: đặt `alt` bằng tên sản phẩm và để `AvatarFallback` giữ số lượng.
Don't: dùng root `Avatar` như nút; nó là `div` không có handler hay role.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | `div` không role; tên đến từ `alt` của `img` do caller | Không focusable; không có handler | Không có | Chữ `white` trên nền #707070; không có dòng nguồn nào chứng minh tỉ lệ nên không nêu |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-avatar` từ mục Standard rồi chuyển caller từng surface; Inbox Target đọc token chatty-ui literal theo giá trị 2.0 sau phase 1b; ảnh có thể là `chatty-image` đặt vào slot để lo fallback. | |
| Admin | Component Inbox đúng Target chưa ship | Not available — new build follows Target. **Avatar**: 20/28/36px; initials và 6 màu theo tên; ảnh lỗi về initials; Online dot và Channel badge; logo shop radius avatar. Dùng ở 8, 5, 10 và Details khách. Không dùng component Polaris trong Inbox; giữ App Bridge cho phần khung embedded. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
```

Ảnh Target từ mock; các trạng thái chưa xuất hiện trong ảnh vẫn là yêu cầu triển khai, không claim đã ship.
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# Badge
Nhãn ngắn của kit chung; Knowledge files bọc nó bằng class và data-tone riêng.
## Key rules
- Dùng `Badge` với `variant="outline"` và class `kb-ide__badge`; màu theo `data-tone`.
- CSS trang khai báo chữ 11px, weight 500, bo 4px, padding 1px 5px.
- `Badge` là `div` không tương tác; nghĩa của status phải nằm trong chữ, không chỉ trong màu.
- Element `chatty-badge` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Dùng cho nhãn status ngắn cạnh một đối tượng. Không dùng làm nút và không nhét câu dài. Wrapper `KnowledgeBadge` có trong source nhưng hiện chưa có file nào import nó; các nhãn đang hiện trong màn Knowledge files gọi Polaris `Badge`.
### Use instead
| Component | Use when |
| --- | --- |
| `Badge` | Nhãn status của kit chung, dùng class trang cho màu. |
| `Badge` | Màn Knowledge files hiện gọi Polaris `Badge` với `tone`, không phải kit. |
## Live preview
Example (Standard) — Element chatty-badge: variant, size và tone; token admin, không màu merchant.
```html
NewDraftCovered3OpenFailedSyncedPendingActiveNot covered
```
Example (Standard) — Element chatty-badge size sm viền như nhãn Knowledge files.
```html
DraftCoveredPendingNot covered
```
Example (Current (React), being replaced) — Badge outline với class Knowledge files; dữ liệu cục bộ.
```jsx
import React from 'react';
import {Badge} from '@avada/chatty-ui/components/badge.js';
export function Status() {
return
Covered99+
;
}
```
## Standard
Example (Standard) — Element chatty-badge: variant, size và tone; token admin, không màu merchant.
```html
NewDraftCovered3OpenFailedSyncedPendingActiveNot covered
```
Prototype (cùng `badge.styles.js` và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Chưa surface nào dùng element thật; các mục theo surface bên dưới mô tả React đang chạy. Knowledge files vẫn chuyển sang Polaris theo Target; preview admin-kb chỉ để xem element dưới token admin.
### Element
| Element | Module |
| --- | --- |
| `chatty-badge` | @avada/chatty-ui/elements/badge.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `variant` | primary, secondary, tertiary | `'primary'` | primary nền tone đặc, secondary nền nhạt, tertiary chỉ viền. |
| attribute | `tone` | neutral, critical, success, caution | `'neutral'` | Ý nghĩa màu; chữ trong badge vẫn phải tự nói status. |
| attribute | `size` | sm, md, lg | `'md'` | Cỡ chữ và padding. |
| slot | default | – | – | Chữ của badge. |
| part | `base` | – | – | Khung pill. |
| css-property | `--chatty-badge-background` | – | – | Nền theo variant và tone. |
| css-property | `--chatty-badge-color` | – | – | Màu chữ theo variant và tone. |
| css-property | `--chatty-badge-radius` | – | – | Bo góc; mặc định pill. |
## Admin · Knowledge files
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Badge` | @avada/chatty-ui/components/badge.js | .kb-ide-page > .kb-ide |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Root `div` của `Badge` mang class kit, `className` và props. |
| 2 | Nội dung `children` trong root; caller cấp chữ. |
### Placement / order
| Context | Order |
| --- | --- |
| Wrapper trang | `KnowledgeBadge` render một `Badge` duy nhất với `children`; không có icon. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `variant` | string | default, secondary, destructive, outline, success, warning | `default` | KnowledgeBadge luôn truyền `outline`. |
| `size` | string | sm, default, lg | `default` | KnowledgeBadge không truyền size. |
| `className` | string | CSS classes | undefined | Gộp cuối; trang truyền `kb-ide__badge`. |
| `data-tone` | attribute | error, conflict, warning, pending, partial, audited, covered, draft | Không có | Trang đổi màu theo attribute; component chuyển qua props. |
| `children` | ReactNode | Chữ của caller | undefined | Không giới hạn độ dài hay định dạng số. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| kit sm | Theo nội dung | `chatty:px-2` / `chatty:py-0.5` | Không khai báo | `chatty:rounded-full` | `chatty:text-xs` | Không tương tác | Class theo `size` |
| kit default | Theo nội dung | `chatty:px-2.5` / `chatty:py-0.5` | Không khai báo | `chatty:rounded-full` | `chatty:text-sm` | Không tương tác | Class theo `size` |
| kit lg | Theo nội dung | `chatty:px-3` / `chatty:py-1` | Không khai báo | `chatty:rounded-full` | `chatty:text-base` | Không tương tác | Class theo `size` |
| Knowledge files page | `line-height: 1.5` | 1px 5px | Không khai báo | 4px | `font-size: 11px`; weight 500 | Không tương tác | Rule không có media query |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Base text | `--p-color-text-secondary` | #616161 | No Dark skin |
| Base fill | `--p-color-bg-surface-secondary` | #f7f7f7 | No Dark skin |
| Base border | `--p-color-border-secondary` | #ebebeb | No Dark skin |
| error / conflict text | `--p-color-text-critical` | #8e0b21 | No Dark skin |
| error / conflict fill | `--p-color-bg-surface-critical` | #fee8eb | No Dark skin |
| error / conflict border | `--p-color-border-critical-secondary` | #8e0b21 | No Dark skin |
| warning / pending / partial text | `--p-color-text-caution` | #4f4700 | No Dark skin |
| warning / pending / partial fill | `--p-color-bg-surface-caution` | #fff8db | No Dark skin |
| warning / pending / partial border | `--p-color-border-caution-secondary` | Không khai báo trong Polaris 13.9.5 | No Dark skin |
| audited / covered text | `--p-color-text-success` | #014b40 | No Dark skin |
| audited / covered fill | `--p-color-bg-surface-success` | #cdfed4 | No Dark skin |
| audited / covered border | `--p-color-border-success-secondary` | Không khai báo trong Polaris 13.9.5 | No Dark skin |
| draft text | `--p-color-text-link` | #005bd3 | No Dark skin |
| draft fill | `--p-color-bg-surface-info` | #eaf4ff | No Dark skin |
| draft border | `--p-color-border-info-secondary` | Không khai báo trong Polaris 13.9.5 | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Base | Không có `data-tone` | Màu theo Tokens dòng Base | Không thêm ARIA |
| error / conflict | `data-tone` = error hoặc conflict | Chữ, nền, viền theo Tokens | `data-tone` attribute |
| warning / pending / partial | `data-tone` = warning, pending hoặc partial | Chữ, nền, viền theo Tokens | `data-tone` attribute |
| audited / covered | `data-tone` = audited hoặc covered | Chữ, nền, viền theo Tokens | `data-tone` attribute |
| draft | `data-tone` = draft | Chữ, nền, viền theo Tokens | `data-tone` attribute |
### Behaviour
| Interaction | Result |
| --- | --- |
| Chữ dài | Rule trang có `width: fit-content` và `flex-shrink: 0`; không có cắt dòng riêng. |
| Focus | Kit có class focus ring cho root; root là div, caller không thêm tabindex trong wrapper. |
| Count | Component không giới hạn hay định dạng số; `children` hiển thị nguyên. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller label | Caller-owned | `children` của wrapper |
### Source
| File | Evidence |
| --- | --- |
| | API và class kit |
| | Wrapper trang |
| | Style và tone |
## Do / Don't
Do: viết status bằng chữ ngắn và để `data-tone` chỉ làm tăng nhận biết.
Don't: dùng màu làm dấu hiệu duy nhất; không biến `Badge` thành nút.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin · Knowledge files | div không role; tên là chữ children | Không focusable, không có handler | Không có | Base Measured(#616161 / #f7f7f7 = 5.78:1); error Measured(#8e0b21 / #fee8eb = 8.09:1); warning Measured(#4f4700 / #fff8db = 8.82:1); covered Measured(#014b40 / #cdfed4 = 8.99:1); draft Measured(#005bd3 / #eaf4ff = 5.49:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Admin · Knowledge files | Viền của tone warning, covered và draft dùng token không khai báo trong Polaris 13.9.5 | Not in code yet — build with the body values. Dùng token viền có khai báo `--p-color-border-caution`, `--p-color-border-success`, `--p-color-border-info`; giữ border 1px solid và radius 4px, không đổi chữ hay nền. | |
| Admin · Knowledge files | Badge của kit chung trong Knowledge files | Not available — new build follows Target. Knowledge files không dùng `chatty-*`: chuyển sang Polaris `Badge`, vì trang admin ngoài inbox giữ Polaris. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-badge` từ mục Standard rồi chuyển caller từng surface; Inbox Target dùng token chatty-ui literal theo giá trị 2.0; gỡ wrapper hiện tại ở phase 1b trước khi chuyển caller. | |
| Admin | Component Inbox đúng Target chưa ship | Not available — new build follows Target. **Badge**: neutral/caution; info/success/warning/critical; progress complete/partial/incomplete; 20px, radius tag 6px, badge-label 12px/18px w500. Dùng ở Return customer (10), order badges (15), Verified, Change request, Resolved. Không dùng component Polaris trong Inbox; giữ App Bridge cho phần khung embedded. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
```

Ảnh Target từ mock; các trạng thái chưa xuất hiện trong ảnh vẫn là yêu cầu triển khai, không claim đã ship.
- [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements)
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# Banner / callout
Target cho Inbox thuần chatty-ui; owner hiện tại là HandoffCard, chưa phải component dùng chung mới.
## Key rules
- Admin: phần Current chỉ chỉ ra owner đang dùng; component Inbox dùng chung theo thiết kế nằm ở Target.
- Admin: ảnh preview là thiết kế, không chứng minh API hoặc hành vi đã ship.
## Use when / Avoid
Dùng để triển khai Banner / callout của Inbox theo Target. Không import tên component Target chưa tồn tại; không coi owner cục bộ là API dùng chung.
### Use instead
| Component | Use when |
| --- | --- |
| HandoffCard | Owner hiện tại của vùng tương ứng; chưa phải Target dùng chung |
| Input | Ô nhập thô của kit, chưa có đủ wrapper Target |
## Live preview
Example — Target: ảnh chụp mock, xem trạng thái và vùng dùng trong Target; chưa phải implementation.
```jsx
import React from 'react';
function Design({asset,name}) { return Target · thiết kế mock, chưa phải implementation. Ảnh không chứng minh mọi trạng thái yêu cầu đã có.; }
export function Banner() { return ; }
```
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `HandoffCard` | import HandoffCard from '@assets/pages/InboxManagement/Parts/ConverstionDetail/HandoffCard.js'; | Owner cục bộ hiện tại; chưa có scope dùng chung cho component Target |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Owner hiện tại: HandoffCard; component dùng chung mới chưa có |
### Placement / order
| Context | Order |
| --- | --- |
| Inbox | Theo caller hiện tại; vị trí của component mới nằm ở Target |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | API dùng chung mới chưa có; không tái đặt API của owner |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Not available | Not available | Chưa có state contract dùng chung theo Target | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Current owner | Theo logic cục bộ; contract mới xem Target |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Not available | Not available | Nhãn do caller hiện tại quản lý |
### Source
| File | Evidence |
| --- | --- |
| | Owner hiện tại; không chứng minh component Target đã có |
## Do / Don't
Do: giữ ranh giới giữa code hiện tại và Target khi triển khai.
Don't: bịa import hoặc dùng ảnh thiết kế làm bằng chứng API đã ship.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin | Owner hiện tại quản lý | Not available cho component dùng chung mới | Not available | Chưa đo cho component Target |
## Target
```target
| Surface | Now | Target |
| --- | --- | --- |
| Admin | Owner HandoffCard có trong source; component dùng chung đúng Target chưa có | Not available — new build follows Target. **Banner / callout**: tone warning/info; icon; action; bản strip cho thanh mỏng. Dùng ở Hand-off card (27), Language bar (33), Handover bar. Giá trị 2.0 qua token chatty-ui literal; phase 1b gỡ wrapper Polaris trước khi chuyển caller. |
```
Ảnh chỉ chứng minh phần được vẽ trong mock; các trạng thái liệt kê là yêu cầu triển khai, không claim ảnh hoặc code đã có đủ.
---
# Button
Chọn đúng API và giá trị đang chạy cho Classic, AI Mode, Admin và Knowledge files.
## Key rules
- Classic: action chính trong chat dùng `Button` + `Avada-Faqs_Primary-Button` và `Spinner` từ đường import của caller; xem Import / element.
- AI Mode: dùng native button với CSS kit; class, kích thước và trạng thái nằm trong bảng AI Mode.
- Admin: Polaris ngoài Inbox; Inbox dùng chatty-ui Target 2.0.
- Admin · Knowledge files: shared `Button` chịu stylesheet của trang; kích thước đọc ở bảng riêng.
- Element `chatty-button` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy, Target giữ thay đổi dự kiến.
## Use when / Avoid
Dùng hành động có kết quả rõ ràng. Điều hướng trong nội dung dùng Link; thao tác chỉ có biểu tượng cần tên truy cập. Mỗi surface có owner riêng, không đổi API theo tên nhìn giống nhau.
### Use instead
| Component | Use when |
| --- | --- |
| `Button` | Action của Classic hoặc Knowledge files; không phải API Polaris. |
| `a` | Điều hướng khi href có giá trị; disabled native không áp lên anchor. |
| `button` | AI Mode CSS kit, không import shared Button. |
| `Button` | Admin gọi Polaris, ví dụ WidgetModeCard dùng tertiary. |
## Live preview
Example (Standard) — Ma trận variant, size và tone theo surface.
```html
Button variants and sizes
SendCancelSkipView orderSmallLargeDeleteConfirm
```
Example (Standard) — Disabled, loading, link và nhãn truy cập của element.
```html
```
Example (Standard) — Ma trận variant, size và tone theo surface.
```html
Button variants and sizes
SendCancelSkipView orderSmallLargeDeleteConfirm
```
Example (Standard) — Disabled, loading, link và nhãn truy cập của element.
```html
```
Example (Standard) — Ma trận variant, size và tone theo surface.
```html
Button variants and sizes
SendCancelSkipView orderSmallLargeDeleteConfirm
```
Example (Standard) — Disabled, loading, link và nhãn truy cập của element.
```html
```
Example (Current (React), being replaced) — Variants và sizes theo API; default in-chat dùng màu merchant.
```jsx
import React from 'react';
import {Button, Spinner} from '@assets/components/ui';
import '@scripttag/v1/MuiComponents/EmailTranscript.scss';
export function Catalogue() {
return (
);
}
```
Example (Current (React), being replaced) — Idle, loading và email rỗng; JSX được trích đúng caller EmailTranscript.
```jsx
import {Button, Typography, Spinner} from '@assets/components/ui';
```
Example (Current (React), being replaced) — Các variant và size CSS kit trong một grid.
```jsx
import React from 'react';
import '@scripttag/v2/ui/control.scss';
export function Catalogue() {
return (
);
}
```
Example (Current (React), being replaced) — Hover/focus, disabled và loading class.
```jsx
import React from 'react';
import '@scripttag/v2/ui/control.scss';
export function States() {
return (
);
}
```
Example (Current (React), being replaced) — Các variant và size Polaris trong một grid.
```jsx
import React from 'react';
import {AppProvider, Button} from '@shopify/polaris';
function ButtonTarget() {
return
Inbox Target preview and states
Target Button: primary, secondary, tertiary, plain; tone critical; hover, pressed, focus, disabled, loading; slot icon và slot kbd. Admin 28px, radius action full; token chatty-ui theo giá trị 2.0. Dùng ở Assign to me / Resolve / Reopen (32), Send (13), filter pill (7), Done (24), Good/Needs fix.
Ảnh mock chỉ chứng minh phần đã vẽ, không phải API đã ship. Mẫu giá trị Light/Dark ở Colour & elevation.
);
}
```
Example (Current (React), being replaced) — Disabled, selected, loading, disclosure và URL.
```jsx
import React from 'react';
import {AppProvider, Button} from '@shopify/polaris';
function ButtonTarget() {
return
Inbox Target preview and states
Target Button: primary, secondary, tertiary, plain; tone critical; hover, pressed, focus, disabled, loading; slot icon và slot kbd. Admin 28px, radius action full; token chatty-ui theo giá trị 2.0. Dùng ở Assign to me / Resolve / Reopen (32), Send (13), filter pill (7), Done (24), Good/Needs fix.
Ảnh mock chỉ chứng minh phần đã vẽ, không phải API đã ship. Mẫu giá trị Light/Dark ở Colour & elevation.
;
}
export function States() {
return (
);
}
```
Example (Current (React), being replaced) — Shared variants và sizes dưới override Knowledge files.
```jsx
import React, {useState} from 'react';
import {Button} from '@avada/chatty-ui/components/button.js';
export function Catalogue() {
return (
;
}
```
Example (Current (React), being replaced) — Kết quả trong widget Classic.
```jsx
import React from 'react';
import {CartNotice} from '@avada/chatty-ui/primitives/CartNotice.jsx';
export function Catalogue({surface}) {
return
;
}
```
Example (Current (React), being replaced) — Kết quả chỉ đọc trong inbox.
```jsx
import React from 'react';
import {CartNotice} from '@avada/chatty-ui/primitives/CartNotice.jsx';
export function Catalogue({surface}) {
return
);
}
```
## Standard
Example (Standard) — Element chatty-chip: variant, size và nút xoá; token admin, không màu merchant.
```html
ShippingReturnsSelectedOrdersWebsite
```
Prototype (cùng `chip.styles.js` và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Chưa surface nào dùng element thật; các mục theo surface bên dưới mô tả React đang chạy. Knowledge files vẫn chuyển sang Polaris theo Target; preview admin-kb chỉ để xem element dưới token admin.
### Element
| Element | Module |
| --- | --- |
| `chatty-chip` | @avada/chatty-ui/elements/chip.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `variant` | secondary, tertiary | `'tertiary'` | tertiary viền (mặc định), secondary nền là trạng thái chọn. |
| attribute | `size` | sm, md | `'md'` | Cỡ chữ và padding. |
| attribute | `removable` | boolean | `false` | Thêm nút xoá ở cuối chip. |
| attribute | `remove-label` | string | `'Remove'` | Tên truy cập của nút xoá. |
| event | `chatty-remove` | `CustomEvent` | – | Nút xoá được kích hoạt; host tự gỡ chip. |
| event | `click` | MouseEvent | – | Click native, retarget về host; nút xoá còn bắn chatty-remove. |
| slot | default | – | – | Chữ của chip. |
| slot | `remove-icon` | – | – | Thay glyph × mặc định của nút xoá. |
| part | `base` | – | – | Khung pill. |
| part | `label` | – | – | Vùng chứa chữ. |
| part | `remove` | – | – | Nút xoá native. |
| css-property | `--chatty-chip-background` | – | – | Nền theo variant. |
| css-property | `--chatty-chip-color` | – | – | Màu chữ. |
| css-property | `--chatty-chip-radius` | – | – | Bo góc; mặc định pill. |
## Admin · Knowledge files
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Chip` | @avada/chatty-ui/components/chip.js | .kb-ide-page .kb-ide\_\_active-filters |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Root `div` của Chip, mang class kit và props. |
| 2 | Nội dung `children` trong root. |
| 3 | Nút xoá `button` chỉ có khi truyền `onDelete`; mặc định hiện ×. |
### Placement / order
| Context | Order |
| --- | --- |
| Explorer filter | Một `Chip` cho mỗi bộ lọc đang bật, theo thứ tự activeFilters; cả khối chỉ render khi có ít nhất một bộ lọc. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `variant` | string | filled, outlined | `filled` | Explorer truyền `outlined`. |
| `size` | string | small, medium | `medium` | Explorer truyền `small`. |
| `color` | string | default, khác default | `default` | Chỉ đổi fill của `filled`; `outlined` bỏ qua. |
| `onDelete` | function | Handler | undefined | Có giá trị thì render nút xoá. |
| `deleteIcon` | ReactNode | Icon của caller | undefined | Thay ký tự ×. |
| `deleteLabel` | string | Tên truy cập của nút xoá | `Remove` | Chuyển vào `aria-label`. |
| `className` | string | CSS classes | undefined | Gộp cuối. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| kit small | Theo nội dung | `chatty:px-2` / `chatty:py-1` | `chatty:gap-1` | `chatty:rounded-full` | `chatty:text-xs` | Nút xoá `chatty:h-4` × `chatty:w-4` | Class theo `size` |
| kit medium | Theo nội dung | `chatty:px-3` / `chatty:py-1` | `chatty:gap-1` | `chatty:rounded-full` | `chatty:text-sm` | Nút xoá `chatty:h-4` × `chatty:w-4` | Class theo `size` |
| Knowledge files chip | Theo nội dung | 2px 6px | 4px giữa các chip | 8px | `font-size: 11px` | Không tương tác trên thân chip | Rule `.kb-ide__active-filters > div` |
| Knowledge files remove | 16px × 16px | 0 | Không khai báo | Không khai báo | Theo chip | 16px × 16px | Rule `.kb-ide__active-filters button` |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Chip text | `--p-color-text` | #303030 | No Dark skin |
| Chip fill | `--p-color-bg-fill-secondary` | #f1f1f1 | No Dark skin |
| Remove glyph | `--p-color-text-secondary` | #616161 | No Dark skin |
| Focus ring | `--p-color-border-focus` | #005bd3 | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Default | Render | Chip: fill và chữ theo Tokens, `border: 0`; nút xoá `border: 0` | Không thêm ARIA trên root |
| Remove hover | pointer | Kit khai báo `hover:chatty:bg-black/10`; trang khai báo `--p-color-bg-surface-hover` cho button hover | Native |
| Remove focus-visible | keyboard | outline 2px, offset 2px (`outline-offset`) | Native focus |
| Remove disabled | Không có prop | Trang có rule cho button disabled nhưng Chip không truyền disabled xuống nút xoá | Not available |
| Selected / pressed | Không có prop | Not available | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Xoá | `onDelete` của Explorer đặt bộ lọc về false hoặc chuỗi rỗng. |
| Nhiều chip | Container `flex-wrap: wrap`, khoảng cách 4px, margin-top 8px. |
| Chữ dài | Không có clamp hay cắt dòng cho label; container chỉ wrap giữa các chip. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Remove … filter | Remove ${filterLabels[key]} filter | `deleteLabel` của Explorer |
| Remove | Remove | Mặc định của `deleteLabel` |
| Nhãn bộ lọc | Caller-owned | Nội dung chip do Explorer ghép |
### Source
| File | Evidence |
| --- | --- |
| | API và class kit |
| | Caller duy nhất |
| | Style chip trong Explorer |
## Do / Don't
Do: đặt `deleteLabel` nêu rõ bộ lọc sẽ bị gỡ.
Don't: gắn onClick vào thân `Chip`; root là `div`, không có keyboard.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin · Knowledge files | Root div không role; nút xoá là `button` có `aria-label` từ `deleteLabel` | Thân không focus; nút xoá Tab và Enter/Space native | Không có | Text Measured(#303030 / #f1f1f1 = 11.69:1); remove glyph Measured(#616161 / #f1f1f1 = 5.48:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Admin · Knowledge files | Chip của kit chung làm chip lọc | Not available — new build follows Target. Knowledge files không dùng `chatty-*`: chuyển sang Polaris, vì trang admin ngoài inbox giữ Polaris. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-chip` từ mục Standard rồi chuyển caller từng surface; Inbox Target dùng token chatty-ui literal theo giá trị 2.0; gỡ wrapper hiện tại ở phase 1b trước khi chuyển caller. | |
```
- [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements)
---
# Composer / input
Input một dòng của Classic: ba size, trạng thái error và disabled, tên truy cập do caller nối.
## Key rules
- Classic: dùng `Input` với `size` small, medium hoặc large; chiều cao lấy từ `chatty:h-8`, `chatty:h-10`, `chatty:h-12`.
- Classic: `Input` không render label và không render message lỗi; caller nối `htmlFor`/`id` và `aria-describedby`.
- Classic: `error` chỉ đổi viền sang `chatty:border-destructive`; caller thêm `aria-invalid` và thông báo.
- Classic: PopupBody vẽ focus-visible cho input bằng outline 2px; chữ input giữ role mobile 18px; tối đa 500px có sàn 16px.
- `Input` là field một giá trị; vùng soạn tin nhiều dòng không dùng component này.
## Use when / Avoid
Dùng cho dữ liệu một dòng như email hoặc tên. Không dùng placeholder làm label duy nhất. Vùng soạn tin và textarea là build riêng, không phải `Input`.
### Use instead
| Component | Use when |
| --- | --- |
| `Input` | Field một dòng; Classic FormField dùng cho trường form. |
| `textarea` | Field nhiều dòng; FormField dùng native textarea riêng. |
## Live preview
Example — Input thật: large, error, read-only và disabled.
```jsx
import React from 'react';
import {Input} from '@avada/chatty-ui/components/input.js';
export function Fields() {
return (
Enter a valid email address.
);
}
```
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Input` | @avada/chatty-ui | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Native `input`; `type` mặc định là text. |
| 2 | Label và message lỗi do caller đặt ngoài component. |
### Placement / order
| Context | Order |
| --- | --- |
| Form chiến dịch | FormField render `Input` với `placeholder`; label không nằm trong `Input`. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `size` | string | small, medium, large | `medium` | Chọn height và padding ngang. |
| `type` | string | HTML input type | `text` | Chuyển vào native input. |
| `error` | boolean | true, false | `false` | Đổi viền sang destructive. |
| `disabled` | boolean | true, false | `false` | Thêm `chatty:bg-muted` khi disabled. |
| `className` | string | CSS classes | undefined | Gộp cuối danh sách class. |
| `props` | attributes | Native attrs, handlers, ARIA | Caller | Spread vào input; caller đặt tên truy cập. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| small | Derived(32px = h-8 × 4px) | Derived(12px = px-3 × 4px) | Không khai báo | 8px (`chatty:rounded-md`) | input-value Derived(15px = type(input-value, desktop, size)) / Derived(22px = type(input-value, desktop, line)); weight 400 | Native box | Mobile role Derived(18px = type(input-value, mobile, size)) / Derived(24px = type(input-value, mobile, line)); tối đa 500px có sàn 16px, không giảm role |
| medium | Derived(40px = h-10 × 4px) | Derived(12px = px-3 × 4px) | Không khai báo | 8px (`chatty:rounded-md`) | input-value Derived(15px = type(input-value, desktop, size)) / Derived(22px = type(input-value, desktop, line)); weight 400 | Native box | Mobile role Derived(18px = type(input-value, mobile, size)) / Derived(24px = type(input-value, mobile, line)); tối đa 500px có sàn 16px, không giảm role |
| large | Derived(48px = h-12 × 4px) | Derived(16px = px-4 × 4px) | Không khai báo | 8px (`chatty:rounded-md`) | input-value Derived(15px = type(input-value, desktop, size)) / Derived(22px = type(input-value, desktop, line)); weight 400 | Native box | Mobile role Derived(18px = type(input-value, mobile, size)) / Derived(24px = type(input-value, mobile, line)); tối đa 500px có sàn 16px, không giảm role |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Background | `--chatty-background` | #ffffff | Merchant `--faqsBgColor` |
| Text | `--chatty-foreground` | #0f172a | Merchant `--faqsTextColor` |
| Placeholder | `--chatty-muted-foreground` | #64748b | Merchant `--faqsTextColorSecondary` |
| Border | `--chatty-border` | #e2e8f0 | #e2e8f0 |
| Error border | `--chatty-destructive` | #ef4444 | #ef4444 |
| Disabled fill | `--chatty-muted` | #f1f5f9 | #f1f5f9 |
| Focus ring | `--chatty-ring` | Merchant `--faqsTextColor`, fallback #303030 | Merchant `--faqsTextColor`, fallback #eee |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Default | render | `chatty:border-border`, `chatty:bg-background` | Không thêm ARIA |
| Hover | pointer | Nền giữ `--chatty-background`; Input không có viền hover riêng | Native |
| Focus-visible | keyboard | outline 2px solid `--chatty-ring`, offset 2px | Native focus |
| Error | `error` true | `chatty:border-destructive` | Caller đặt aria-invalid |
| Disabled | `disabled` | `chatty:disabled:opacity-50`, `chatty:disabled:cursor-not-allowed`, `chatty:bg-muted` | Native disabled |
| Read-only | readOnly attribute | Không có style riêng; giá trị vẫn đọc và chọn được | Native readonly |
### Behaviour
| Interaction | Result |
| --- | --- |
| Keyboard | Native input nhận gõ và Tab; disabled bị loại khỏi Tab. |
| Màn hình hẹp | Tối đa 500px: dùng max(16px, var(--chatty-type-input-value-size, 16px)) để giữ role và tránh iOS phóng to. |
| Lỗi | `error` chỉ đổi viền; message và ARIA do caller cấp. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Placeholder | Caller-owned | `placeholder` truyền từ FormField |
| Label / lỗi | Caller-owned | Ngoài component |
### Source
| File | Evidence |
| --- | --- |
| | API và element |
| | Token và focus Classic |
| | Caller |
## Do / Don't
Do: nối label bằng `htmlFor` và `id`; lỗi nối bằng `aria-describedby`.
Don't: chỉ đổi màu viền để báo lỗi.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | `input` native; tên từ label của caller | Tab vào field; outline 2px offset 2px khi focus-visible | Caller-owned | Text Measured(#0f172a / #ffffff = 17.85:1); border Measured(#e2e8f0 / #ffffff = 1.23:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Classic | Viền mặc định `--chatty-border` đo thấp hơn 3:1 trên nền trắng | Not in code yet — build with the body values. Viền field đạt 3:1 với nền thật; đo lại trên palette merchant. | [WCAG — non text contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html) |
| Classic | `error` chỉ đổi màu viền | Not in code yet — build with the body values. Thêm message lỗi gắn aria-describedby và aria-invalid khi error true. | [WCAG — error identification](https://www.w3.org/WAI/WCAG22/Understanding/error-identification.html) |
| Classic | Input React một dòng | Not available — new build follows Target. Element (dự kiến): `chatty-text-field`, form-associated (`setFormValue`, `setValidity`); nhãn qua attribute `label` hoặc slot `label`, slot `help`; part `control`; input đặt trong shadow, nếu autofill hỏng thì cho `` ở light DOM. | [MDN: ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) |
```
- [WCAG — non text contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html)
- [WCAG — error identification](https://www.w3.org/WAI/WCAG22/Understanding/error-identification.html)
- [MDN: ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
---
# Composer
Draft tin nhắn có attachment, gửi bằng Enter và event tới host.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `Composer` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function Compose() {
return (
{}}>
);
}
```
Example (Current (React), being replaced) — Classic reply renderer đang ship; dữ liệu fixture cục bộ.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function ClassicReply() {
return (
);
}
```
Example (Current (React), being replaced) — ChatThread V2 thật, cùng caller với waiting-streaming.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function StorefrontThread() {
const [ready] = useState(() => {
chatStore.setState({
loadedId: 'guide-conversation',
conversation: {id: 'guide-conversation'},
awaitingReply: false,
statusText: '',
messages: [
{
id: 'question',
senderType: 'customer',
text: 'Which bag works for everyday trips?',
blocks: [],
createdAt: new Date('2026-01-15T10:00:00Z'),
},
{
...message,
senderName: 'Assistant',
createdAt: new Date('2026-01-15T10:01:00Z'),
blocks: [],
},
],
});
return true;
});
return ready ? (
) : null;
}
```
## Standard
`send(text)` gửi suggestion text; bỏ tham số để gửi draft hiện tại. Slot `toolbar` chứa action prefill hoặc gợi ý do host quản lý.
Example (Standard) — Element prototype với token trung tính.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/composer.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent = `Sent: ${event.detail.text}`;
}}
>
event.currentTarget.closest('chatty-composer').send('Track my order')}
>Track my order
`;
}
```
Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A.
Enter gửi, Shift+Enter xuống dòng; IME composition không gửi. Event `chatty-send` có `{text, attachments}`, bubbles và composed; preventDefault giữ draft. Form reset khôi phục value ban đầu. Input font đủ lớn cho iOS.
Textarea tự cao tối đa 5 dòng rồi cuộn. Send là icon button cùng hàng; click Send trả focus về textarea. `.sending` giữ draft, làm mờ và đặt aria-busy; host clear `.value` sau khi gửi thành công. `.disabled` dành cho trạng thái không cho tương tác.
### Element
| Element | Module |
| --- | --- |
| `chatty-composer` | @avada/chatty-ui/elements/composer.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `value` | string | `''` | Draft text and form value. |
| attribute | `name` | string | `'message'` | Name used by the enclosing form. |
| attribute | `label` | string | `'Message'` | Accessible input label. |
| attribute | `send-label` | string | `'Send'` | Translated send button text. |
| attribute | `placeholder` | string | `'Write a message…'` | Optional draft hint. |
| attribute | `disabled` | boolean | `false` | Prevents edits and submission while pending. |
| attribute | `sending` | boolean | `false` | Host-owned send in progress; retains and dims the draft without dropping focus. |
| event | `chatty-send` | CustomEvent<{text: string, attachments: Array}> | Not available | Nonempty submission; cancel to retain the draft. |
| event | `click` | MouseEvent | Not available | Native send button click. |
| slot | `toolbar` | Not available | Not available | Suggestion and prefill actions before the typing row. |
| slot | `attachments` | Not available | Not available | Selected attachment previews. |
| part | `base` | Not available | Not available | Composer container. |
| part | `control` | Not available | Not available | Textarea. |
| part | `send` | Not available | Not available | Send button. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `WidgetTextRenderer` | | WidgetTextRenderer |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 8px 12px self; 7px 12px peer | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ChatThread` | import ChatThread from '@scripttag/v2/views/ChatThread.jsx'; | ChatThread |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 10px 15px | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## Admin
Not available — React component tương ứng không có trong surface này; không dựng preview giả.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| Not available | Not available | Not available |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Not available |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Not available |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Not available | Not available |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Not available | Not available | Not available |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation shown in Current. |
## Do / Don't
Do: giữ host làm owner của dữ liệu.
Don't: gửi lại chỉ vì element render.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Named textarea | Enter send; Shift+Enter newline; IME retained | Not available | See neutral token preview |
| AI Mode | Named textarea | Enter send; Shift+Enter newline; IME retained | Not available | See neutral token preview |
| Admin | Named textarea | Enter send; Shift+Enter newline; IME retained | Not available | See neutral token preview |
---
# Contact form
Thu thập thông tin liên hệ, kiểm tra field trước khi host lưu.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `ContactComposer` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import {ContactComposer} from '@avada/chatty-ui/canonical/ContactComposer.jsx';
export function Form() {
const [values, setValues] = useState({email: '', firstName: '', phone: ''});
const [status, setStatus] = useState('');
return (
text}
description="Where can we reply?"
privacy="Your email is used to reply to this conversation."
autoFocus={false}
onChange={(key, value) => setValues(previous => ({...previous, [key]: value}))}
onSubmit={() => setStatus('Contact details validated locally. No message was sent.')}
onSkip={() => setStatus('Anonymous chat selected locally.')}
/>
{status}
);
}
```
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import {ContactComposer} from '@avada/chatty-ui/canonical/ContactComposer.jsx';
export function Form() {
const [values, setValues] = useState({email: '', firstName: '', phone: ''});
const [status, setStatus] = useState('');
return (
text}
description="Where can we reply?"
privacy="Your email is used to reply to this conversation."
autoFocus={false}
onChange={(key, value) => setValues(previous => ({...previous, [key]: value}))}
onSubmit={() => setStatus('Contact details validated locally. No message was sent.')}
onSkip={() => setStatus('Anonymous chat selected locally.')}
/>
{status}
);
}
```
## Standard
Example (Standard) — Element prototype với token trung tính.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/contact-form.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent =
`Received: ${event.detail.values.email}`;
}}
>
Your email is used to reply to this conversation.
`;
}
```
Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A. Surface chưa có React tương ứng ghi Not available bên dưới.
Gán `.fields`, `.values`, `.required` và `.strings`. `chatty-submit` mang `{values}` sau native validation; host đặt `loading` và `error`. Field lỗi đầu nhận focus. Email phải có domain với dấu chấm; phone chỉ nhận ký tự số, dấu cộng đầu, khoảng trắng, dấu ngoặc, dấu chấm và dấu gạch nối, với số chữ số theo rule của widget. `.strings.invalidEmail` và `.strings.invalidPhone` dịch lỗi tương ứng. Slot privacy giữ giải thích dùng dữ liệu.
Standard cố ý dùng nhãn field hiện rõ và nút Continue có chữ thay layout composer chỉ có placeholder của React. Cách này giữ accessible name khi đã nhập và giúp nhận biết field bắt buộc; khi port cần giữ nhãn, không đổi về placeholder-only. Field bắt buộc có dấu *. Required/semantic errors dùng `.strings` và aria-invalid; host error dùng critical. Pending giữ focus với read-only/aria-disabled và spinner.
### Element
| Element | Module |
| --- | --- |
| `chatty-contact-form` | @avada/chatty-ui/elements/contact-form.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `fields` | array | `['email']` | Ordered field names or descriptors (key, label, type, required, payloadKey). |
| attribute | `description` | string | `'Where can we reply?'` | Form purpose shown before the fields. |
| attribute | `loading` | boolean | `false` | Keeps fields focusable and read-only while the host request is pending. |
| attribute | `skippable` | boolean | `false` | Shows the anonymous option. |
| attribute | `error` | string | `''` | Host request error. |
| event | `chatty-submit` | CustomEvent<{values: Object}> | Not available | Valid contact values. |
| event | `chatty-skip` | CustomEvent<{}> | Not available | Anonymous chat requested. |
| event | `click` | MouseEvent | Not available | Native contact action click. |
| slot | `privacy` | Not available | Not available | Privacy explanation under contact fields. |
| part | `base` | Not available | Not available | Contact form. |
| part | `error` | Not available | Not available | Critical host error. |
| part | `submit` | Not available | Not available | Submit button. |
## Classic
Token values dưới đây là fallback cục bộ; theme của caller có thể override.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ContactComposer` | @avada/chatty-ui/canonical/ContactComposer.jsx | ContactComposer |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | ContactComposer |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `fields` | See source | Caller supplied | See source | Enabled contact fields |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Field base | min-height 52px | 6px 9px 6px 14px | 10px | 28px | input-value | Native input box | Base CSS; caller may override |
| Grouped field | min-height 44px | 0 6px 0 12px | 8px | 17px | input-value | 44px | Multiple enabled fields |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Field text | `--chatty-contact-fg` | Fallback #1f1f1f | Fallback #1f1f1f |
| Field fill | `--chatty-contact-bg` | Fallback #f2f2f2 | Fallback #f2f2f2 |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Loading | loading prop | Controls disabled | aria-busy |
| Invalid | Field validation | Invalid field state | aria-invalid |
### Behaviour
| Interaction | Result |
| --- | --- |
| Submit | Validates contact fields before onSubmit |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | ContactComposer |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## AI Mode
Token values dưới đây là fallback cục bộ; theme của caller có thể override.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ContactComposer` | @avada/chatty-ui/canonical/ContactComposer.jsx | ContactComposer |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | ContactComposer |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `fields` | See source | Caller supplied | See source | Enabled contact fields |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Field base | min-height 52px | 6px 9px 6px 14px | 10px | 28px | input-value | Native input box | Base CSS; caller may override |
| Grouped field | min-height 44px | 0 6px 0 12px | 8px | 17px | input-value | 44px | Multiple enabled fields |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Field text | `--chatty-contact-fg` | Fallback #1f1f1f | Fallback #1f1f1f |
| Field fill | `--chatty-contact-bg` | Fallback #f2f2f2 | Fallback #f2f2f2 |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Loading | loading prop | Controls disabled | aria-busy |
| Invalid | Field validation | Invalid field state | aria-invalid |
### Behaviour
| Interaction | Result |
| --- | --- |
| Submit | Validates contact fields before onSubmit |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | ContactComposer |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## Do / Don't
Do: giữ host làm owner của dữ liệu.
Don't: gửi lại chỉ vì element render.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Named form | Enter submits; invalid field receives focus | Not available | See neutral token preview |
| AI Mode | Named form | Enter submits; invalid field receives focus | Not available | See neutral token preview |
---
# Date/time presets
Target cho Inbox thuần chatty-ui; owner hiện tại là InsertReminderDatePopup, chưa phải component dùng chung mới.
## Key rules
- Admin: phần Current chỉ chỉ ra owner đang dùng; component Inbox dùng chung theo thiết kế nằm ở Target.
- Admin: ảnh preview là thiết kế, không chứng minh API hoặc hành vi đã ship.
## Use when / Avoid
Dùng để triển khai Date/time presets của Inbox theo Target. Không import tên component Target chưa tồn tại; không coi owner cục bộ là API dùng chung.
### Use instead
| Component | Use when |
| --- | --- |
| InsertReminderDatePopup | Owner hiện tại của vùng tương ứng; chưa phải Target dùng chung |
| Input | Ô nhập thô của kit, chưa có đủ wrapper Target |
## Live preview
Example — Target: ảnh chụp mock, xem trạng thái và vùng dùng trong Target; chưa phải implementation.
```jsx
import React from 'react';
function Design({asset,name}) { return Target · thiết kế mock, chưa phải implementation. Ảnh không chứng minh mọi trạng thái yêu cầu đã có.; }
export function DateTime() { return ; }
```
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `InsertReminderDatePopup` | import InsertReminderDatePopup from '@assets/pages/InboxManagement/Parts/Reminder/InsertReminderDatePopup.js'; | Owner cục bộ hiện tại; chưa có scope dùng chung cho component Target |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Owner hiện tại: InsertReminderDatePopup; component dùng chung mới chưa có |
### Placement / order
| Context | Order |
| --- | --- |
| Inbox | Theo caller hiện tại; vị trí của component mới nằm ở Target |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | API dùng chung mới chưa có; không tái đặt API của owner |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Not available | Not available | Chưa có state contract dùng chung theo Target | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Current owner | Theo logic cục bộ; contract mới xem Target |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Not available | Not available | Nhãn do caller hiện tại quản lý |
### Source
| File | Evidence |
| --- | --- |
| | Owner hiện tại; không chứng minh component Target đã có |
## Do / Don't
Do: giữ ranh giới giữa code hiện tại và Target khi triển khai.
Don't: bịa import hoặc dùng ảnh thiết kế làm bằng chứng API đã ship.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin | Owner hiện tại quản lý | Not available cho component dùng chung mới | Not available | Chưa đo cho component Target |
## Target
```target
| Surface | Now | Target |
| --- | --- | --- |
| Admin | Owner InsertReminderDatePopup có trong source; component dùng chung đúng Target chưa có | Not available — new build follows Target. **Date/time presets**: preset 1 giờ, ngày mai, tuần sau; giờ tuỳ chọn. Dùng ở Snooze và Reminder. Giá trị 2.0 qua token chatty-ui literal; phase 1b gỡ wrapper Polaris trước khi chuyển caller. |
```
Ảnh chỉ chứng minh phần được vẽ trong mock; các trạng thái liệt kê là yêu cầu triển khai, không claim ảnh hoặc code đã có đủ.
---
# Divider
Hairline chung ở Classic; mốc ngày trong chat là pill riêng ở AI Mode và Admin.
## Key rules
- Classic: `Divider` là hairline; caller ghi đè như height 0.88px hoặc margin 16px 0.
- AI Mode: mỗi ngày một pill role separator; pill nổi đang đọc dùng `--shadow-2`.
- Admin: `MessageFrame` tạo pill ngày với role separator và aria-label là ngày.
- Classic: `Divider` có children chỉ vẽ hai hairline; mốc ngày là pill riêng của AI Mode và Admin.
- Element `chatty-divider` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Dùng hairline để tách khối nội dung; dùng day pill khi chuyển ngày trong hội thoại. Classic không có day pill trong source. Không chèn mốc ngày cho trạng thái chờ tạm thời: MessageFrame bỏ pill khi message có block loading hoặc reasoning.
### Use instead
| Component | Use when |
| --- | --- |
| `Divider` | Hairline giữa hai khối của Classic. |
| `div` | Day pill AI Mode do thread tạo khi sang ngày mới. |
| `MessageFrame` | Day pill của Admin; ngày khác `previousDated` thì thêm một pill. |
## Live preview
Example (Standard) — Element chatty-divider: hairline ngang, có chữ và dọc.
```html
Today
```
Example (Standard) — Element chatty-divider: hairline ngang, có chữ và dọc.
```html
Today
```
Example (Standard) — Element chatty-divider: hairline ngang, có chữ và dọc.
```html
Today
```
Example (Current (React), being replaced) — Divider chung của kit: ngang, margin của caller, có children và dọc.
```jsx
import React from 'react';
import {Divider} from '@avada/chatty-ui';
import '@scripttag/v2/views/ChatPage.scss';
export function Catalogue() {
return (
Horizontal
Caller margin
With children
Label
Vertical
);
}
```
Example (Standard) — Element day pill; variant="pill", cùng anatomy với React bên dưới.
```html
Today
```
Example (Current (React), being replaced) — Day pill AI Mode; JSX được trích đúng caller trong thread.
```jsx
import {formatDayDivider} from '@avada/chatty-ui/canonical/timeFormat.js';
/**
* Day boundary pill above the first message of a calendar day.
* @param {Date|string} date
*/
function DayDivider({date}) {
const labels = useTimeLabels();
const label = formatDayDivider(date, {labels, locale: getTimeLocale()});
if (!label) return null;
return (
{label}
);
}
```
Example (Standard) — Element day pill của Admin (light).
```html
Today
```
Example (Current (React), being replaced) — Day pill Admin; JSX được trích đúng markup trong MessageFrame.
```jsx
import {MESSAGE_CLUSTER_GAP_MS, SENDER_TYPES} from '@avada/chat-core/protocol';
const divider = showDivider && (
{formatDayDivider(vm.createdAt, timeOpts)}
);
```
## Standard
Example (Standard) — Element chatty-divider: hairline ngang, có chữ và dọc.
```html
Today
```
Prototype (cùng `divider.styles.js` và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Chưa surface nào dùng element thật; các mục theo surface bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-divider` | @avada/chatty-ui/elements/divider.js |
### API
`variant="pill"` tạo day pill ở AI Mode và Admin; mặc định `line` giữ hairline hiện tại. Classic pill: N/A.
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `variant` | line, pill | `'line'` | Hairline hoặc day pill ngang. |
| attribute | `orientation` | horizontal, vertical | `'horizontal'` | Hairline ngang hoặc dọc. |
| attribute | `label` | string | `''` | Tên truy cập của separator, ví dụ ngày. |
| slot | default | – | – | Chữ tuỳ chọn nằm giữa hai hairline (chỉ ngang). |
| part | `base` | – | – | Khung separator. |
| part | `label` | – | – | Vùng chứa chữ khi slot có nội dung. |
| css-property | `--chatty-divider-color` | – | – | Màu hairline. |
| css-property | `--chatty-divider-spacing` | – | – | Margin quanh divider (block khi ngang, inline khi dọc). |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Divider` | @avada/chatty-ui | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Không có children: một `div` là đường kẻ. |
| 2 | Có children: hai hairline `chatty:flex-1` hai bên một khối chữ `chatty:px-3`. |
### Placement / order
| Context | Order |
| --- | --- |
| Tracking card | `Divider` nằm giữa hai `CardContent`, margin do caller đặt. |
| Question detail | `Divider` đứng giữa tiêu đề câu hỏi và nội dung trả lời. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `orientation` | string | horizontal, vertical | `horizontal` | Đổi class kích thước và hướng của đường kẻ. |
| `children` | ReactNode | Chữ hoặc node | undefined | Truthy thì đổi sang anatomy hai hairline kèm label. |
| `className` | string | CSS classes | undefined | Gộp cuối. |
| `style` | object | CSS declarations | Caller | Đi qua props vào root `div`. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| horizontal | `chatty:h-px` | Không có | Không khai báo | Không khai báo | Không có chữ | Không tương tác | Không override theo viewport |
| vertical | `chatty:h-full` | Không có | Không khai báo | Không khai báo | Không có chữ | Không tương tác | `orientation` |
| với children | Theo nội dung | `chatty:px-3` | Không khai báo | Không khai báo | `chatty:text-sm` | Không tương tác | `children` truthy |
| Caller Tracking card | Theo class | Margin 16px 0 | Không khai báo | Không khai báo | Không có chữ | Không tương tác | Style inline của caller |
| Caller Question | 0.88px | Không có | Không khai báo | Không khai báo | Không có chữ | Không tương tác | Style inline của caller |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Line colour | `--chatty-border` | #e2e8f0 | #e2e8f0 |
| Label colour | `--chatty-muted-foreground` | #64748b | Merchant secondary text (`--faqsTextColorSecondary`) |
| Question line | `--faqsBorderColor` | Màu merchant của caller | Màu merchant của caller |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Default | Render | Một cạnh `chatty:border-t` (ngang) hoặc `chatty:border-l` (dọc) | Không thêm role hay ARIA |
### Behaviour
| Interaction | Result |
| --- | --- |
| Children | Có children thì thay đường kẻ đơn bằng hai hairline và khối chữ ở giữa. |
| Classic | Hai caller hiện tại không truyền children; chỉ dùng hairline. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller label | Caller-owned | `children` (nếu có) |
### Source
| File | Evidence |
| --- | --- |
| | API và class kit |
| | Caller hairline |
| | Caller hairline |
## AI Mode
Code React đang ship làm phẳng nhãn ngày trên mobile và coarse pointer; chuẩn `chatty-divider variant="pill"` của guide giữ pill ở mọi viewport.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| div.chatty-chat-time-divider | ChatThread.jsx (hàm cục bộ, không export) | .chatty-ai-mode[data-theme] |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Wrapper `chatty-chat-time-divider` có role separator và `aria-label`. |
| 2 | Một `spanchatty-chat-time-divider-label` là pill; không có hairline hai bên. |
| 3 | Pill nổi `chatty-chat-day-float` ẩn mặc định, nhận nhãn từ `useStickyDayDivider`. |
### Placement / order
| Context | Order |
| --- | --- |
| Thread | Day pill đứng trước tin đầu tiên của mỗi ngày; pill nổi nằm trên thread. |
| Thread cuối | Hàng đầu hoặc ngay sau pill không thêm margin trên. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `date` | Date / string | Thời điểm của message | Caller | Thiếu nhãn thì render null (`label`). |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Divider row | Theo nội dung | `var(--chatty-space-300) 0`; mobile 8px theo block | Không khai báo | Không khai báo | Theo label | Không tương tác | Mobile hoặc con trỏ thô |
| Pill | Theo nội dung | `var(--chatty-space-100) var(--chatty-space-300)`; mobile 0 | Không khai báo | 30px (`--radius-pill`); mobile 0 | heading-small Derived(14px = type(heading-small, desktop, size)) / Derived(20px = type(heading-small, desktop, line)) desktop, mobile Derived(15px = type(heading-small, mobile, size)) / Derived(22px = type(heading-small, mobile, line)) weight 600 | Không tương tác | Mobile hoặc con trỏ thô |
| Pill nổi | Theo nội dung | Như pill | Không khai báo | 30px (`--radius-pill`) | Như pill | Không tương tác | Vị trí tuyệt đối top 24px |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Pill border | `--glass-edge` | rgba(20,19,24,0.08) | rgba(255,255,255,0.12) |
| Pill fill | `--bg-elevated` | #fbfaf7 | #1c1b1f |
| Pill text | `--vib-2` | rgba(20,19,24,0.74) | rgba(255,255,255,0.74) |
| Pill radius | `--radius-pill` | 30px | Same |
| Float shadow | `--shadow-2` | `var(--chatty-shadow-2)` | `var(--chatty-shadow-2)` |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Inline pill | Tin đầu tiên của một ngày | Pill theo Sizes và Tokens; `box-shadow: none` | `role="separator"`, `aria-label` là ngày |
| Pill nổi hiện | Thread cuộn qua nhóm ngày | Pill nổi top 24px, `box-shadow: var(--shadow-2)` | Không thêm ARIA trong source |
| Pill nổi ẩn | Chưa có nhãn hoặc thread không active | Thuộc tính hidden đặt `display: none` | `hidden` |
| Mobile hoặc con trỏ thô | Viewport mobile hoặc media query | Ẩn pill nổi; label không nền, viền hay shadow | Không đổi |
### Behaviour
| Interaction | Result |
| --- | --- |
| Nhãn ngày | `formatDayDivider` trả Today, Yesterday, tên thứ hoặc ngày dài theo khoảng cách từ hôm nay. |
| Label dài | `overflow-wrap: anywhere` và `max-inline-size: 100%` cho phép pill xuống dòng. |
| Sticky | `useStickyDayDivider` đặt nhãn và vị trí chuyển giao cho pill nổi. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Today | today | Nhãn mặc định của time labels |
| Yesterday | yesterday | Nhãn mặc định của time labels |
### Source
| File | Evidence |
| --- | --- |
| | Day pill của thread |
| | Style pill và pill nổi |
| | Nhãn ngày |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `MessageFrame` | @avada/chatty-ui/canonical/MessageFrame.jsx | .inbox-v2 |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Wrapper `chatty-time-divider` có role separator và `aria-label` là ngày. |
| 2 | Một `spanchatty-time-divider__label`; không có hairline. |
### Placement / order
| Context | Order |
| --- | --- |
| Frame | Pill đứng trước container của message; message ngay sau pill bỏ margin trên. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `previousDated` | object | Message ngày trước | `prev` | Ngày khác (`toDateString`) thì thêm pill. |
| `hideDayDividers` | boolean | true / false | undefined | True thì không thêm pill. |
| `timeLabels` | object | Nhãn Today, Yesterday | Nhãn mặc định | Truyền vào `formatDayDivider`. |
| `locale` | string | BCP 47 | undefined | Truyền vào `formatDayDivider`. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Divider row | Theo nội dung | `var(--chatty-space-300, 12px) 0` | Không khai báo | Không khai báo | Theo pill | Không tương tác | Không có media query riêng |
| Pill | Theo nội dung | `var(--chatty-space-100, 4px) var(--chatty-space-300, 12px)` | Không khai báo | `var(--chatty-radius-pill, 9999px)` | `--chatty-type-heading-small-size`; weight 500 | Không tương tác | Role admin đổi ở `(max-width: 47.9975em)` |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Pill border | `--chatty-color-border` | Fallback #e3e3e3 | No Dark skin |
| Pill fill | `--chatty-color-bg-surface-raised` | Fallback #fff | No Dark skin |
| Pill text | `--chatty-color-text-secondary` | Fallback #616161 | No Dark skin |
| Pill radius | `--chatty-radius-pill` | Fallback 9999px | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Pill | Ngày khác `previousDated` | Pill theo Sizes và Tokens; `box-shadow: none` | `role="separator"`, `aria-label` là ngày |
| Hàng đầu | Pill là phần tử đầu | `padding-block-start: 0` | Không thêm ARIA |
| Ẩn | Message có block loading / reasoning | Không render pill để status tạm không tạo ranh giới ngày | Không có |
### Behaviour
| Interaction | Result |
| --- | --- |
| Nhãn ngày | `formatDayDivider` trả Today, Yesterday, tên thứ hoặc ngày dài theo khoảng cách từ hôm nay. |
| Thread rỗng | Widget preview truyền `hideDayDividers` khi chưa có message. |
| Pill nổi | Trong widget preview, `.chatty-day-float` nổi top `var(--chatty-space-600)`. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Today | today | Nhãn mặc định của time labels |
| Yesterday | yesterday | Nhãn mặc định của time labels |
### Source
| File | Evidence |
| --- | --- |
| | Điều kiện và markup pill |
| | Style pill |
| | Nhãn ngày |
## Do / Don't
Do: Classic dùng Divider làm hairline; AI Mode và Admin dùng đúng một pill cho mỗi ngày.
Don't: dùng Divider có children làm mốc ngày; nó vẽ hai hairline và không có role separator.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | `div` không role; label (nếu có) là chữ của caller | Không focusable | Không có | Label Light Measured(#64748b / #ffffff = 4.76:1) |
| AI Mode | `role="separator"`, `aria-label` là ngày | Không focusable | Không có | Light Measured(rgba(20,19,24,0.74) / #fbfaf7 = 7.79:1); Dark Measured(rgba(255,255,255,0.74) / #1c1b1f = 9.81:1) |
| Admin | `role="separator"`, `aria-label` là ngày | Không focusable | Không có | Fallback Measured(#616161 / #ffffff = 6.19:1) |
## Target
```target
| Surface | Now | Target |
| --- | --- | --- |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-divider` từ mục Standard rồi chuyển caller từng surface; AI Mode mobile và coarse pointer sẽ theo pill của guide; Inbox Target dùng token chatty-ui literal theo giá trị 2.0; gỡ wrapper hiện tại ở phase 1b trước khi chuyển caller. |
```
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# Email continue form
Biểu mẫu gửi hội thoại hiện tại qua email để tiếp tục trò chuyện.
## Key rules
- AI Mode: form dùng email của hội thoại nếu đã có; nếu không thì yêu cầu khách nhập.
- Element `chatty-email-continue` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Dùng khi khách tiếp tục cùng hội thoại qua email.
### Use instead
| Component | Use when |
| --- | --- |
| `EmailContinueForm` | Gửi hội thoại để khách tiếp tục qua email. |
| `FormField` | Field email trong form khi hội thoại chưa có email. |
## Live preview
Example (Standard) — Email đã có hiện dạng chữ, và ô nhập khi chưa có email.
```html
```
Example (Standard) — Đang gửi, gửi lỗi và biên nhận sau khi gửi.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-email-continue prototype chatty-ui ports from (chatty-ui/src/elements/email-continue.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/email-continue.js';
export function States() {
return html`
${IconCheck({slot: 'icon'})}
`;
}
```
Example (Current (React), being replaced) — Form thật dùng dữ liệu cục bộ; dịch vụ gửi được mock.
```jsx
import React from 'react';
import {EmailContinueForm} from '@scripttag/v2/components/EmailContinue/EmailContinueForm.jsx';
export function Form() {
return {}} />;
}
```
## Standard
Example (Standard) — Email đã có hiện dạng chữ, và ô nhập khi chưa có email.
```html
```
Prototype (cùng `email-continue.styles.js`) là chuẩn: chatty-ui port 1:1, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Element kiểm định dạng email rồi phát `chatty-submit`; host gửi email và đặt `loading`, `sent-to` hoặc `failed`. Nhãn đi qua property `.strings`. Chưa surface nào dùng element thật; mục AI Mode bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-email-continue` | @avada/chatty-ui/elements/email-continue.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `email` | string | `''` | Email đã có trên hội thoại; hiện dạng chữ thay cho ô nhập. |
| attribute | `value` | string | `''` | Giá trị điền sẵn của ô nhập. |
| attribute | `loading` | boolean | `false` | Đang gửi: nút hiện spinner, chặn gửi lặp. |
| attribute | `failed` | boolean | `false` | Hiện thông báo gửi lỗi (role alert). |
| attribute | `sent-to` | string | `''` | Email đã gửi tới; card đổi thành biên nhận. |
| event | `chatty-submit` | CustomEvent<{email: string}> | – | Gửi với email hợp lệ (nút Send hoặc Enter trong ô nhập). |
| slot | `icon` | – | – | Icon check của biên nhận. |
| part | `base` | – | – | Card, hoặc biên nhận sau khi gửi. |
| part | `title` | – | – | Tiêu đề card. |
| part | `input` | – | – | Ô nhập email. |
| part | `error` | – | – | Lỗi định dạng hoặc lỗi gửi. |
| css-property | `--chatty-email-continue-radius` | – | – | Bo góc card. |
| css-property | `--chatty-email-continue-background` | – | – | Nền card. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `EmailContinueForm` | @scripttag/v2/components/EmailContinue/EmailContinueForm.jsx | .chatty-ai-mode |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | ChatFormCard chứa title và lead. |
| 2 | Email đã biết hoặc FormField nhập email. |
| 3 | Nút Send và thông báo lỗi khi cần. |
### Placement / order
| Context | Order |
| --- | --- |
| Form | Title và lead, email, lỗi nếu có, rồi action. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `conversation` | object | Hội thoại hiện tại | Caller | Email hiện có được ưu tiên. |
| `onFallback` | function | Callback | Caller | Gọi khi server yêu cầu mailto. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Form | Theo ChatFormCard | Theo ChatFormCard | Theo ChatFormCard | Theo ChatFormCard | Theo form | Nút native | Caller đặt trong panel |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Form | Theo ChatFormCard | Theo scope | Theo scope |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Invalid | Email không hợp lệ | FormField nhận error. | Theo FormField |
| Submitting | Đang gửi | Field và action disabled. | Native disabled |
| Failed | Request lỗi | Thông báo lỗi hiện dưới field. | role alert |
| Sent | Server thành công | FormDone hiện địa chỉ nhận. | Theo FormDone |
### Behaviour
| Interaction | Result |
| --- | --- |
| Submit | Chặn gửi lặp, kiểm tra email rồi gọi dịch vụ. |
| Fallback | Khi server yêu cầu mailto, gọi callback. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Continue as email | Continue as email | Tiêu đề form |
| Email | Email | Nhãn field |
| Send | Send | Action |
| Transcript email failure | Transcript email failure | Lỗi gửi |
### Source
| File | Evidence |
| --- | --- |
| | API, trạng thái và markup |
| | Style form |
## Do / Don't
Do: dùng email hiện có của hội thoại khi có.
Don't: gửi lặp trong lúc request đang chạy.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| AI Mode | Field email có label; lỗi gửi role alert | Field nhận autoFocus; Enter submit; nút native | Lỗi gửi là alert | Theo scope form |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| AI Mode | Form React | Not available — new build follows Target. Control dùng `chatty-text-field` và `chatty-buttontype=submit`; composite thuộc `chatty-contact-form` (dự kiến), gửi qua actions của chat-core. | [MDN: ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) |
| AI Mode | Component React theo surface | Not available — new build follows Target. Port `chatty-email-continue` từ mục Standard rồi chuyển caller từng surface. | |
```
- .chatty-email-continue
- [MDN: ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
---
# Icon button
Nút chỉ có biểu tượng của Classic: ba size vuông, năm màu, tên truy cập do caller cấp.
## Key rules
- Classic: dùng `IconButton` với `size` small, medium hoặc large; kích thước vuông lấy từ `chatty:h-8 chatty:w-8`, `chatty:h-10 chatty:w-10`, `chatty:h-12 chatty:w-12`.
- Classic: luôn truyền `aria-label`; component không có copy mặc định.
- Classic: caller muốn vùng bấm lớn hơn thì ghi đè bằng `className` như `chatty:h-11 chatty:w-11` (emoji trong ChatPage).
- Classic: inline style đặt `outline: none` nên focus chỉ còn `chatty:focus-visible:ring-2`.
- Element `chatty-icon-button` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Dùng khi hành động có biểu tượng quen thuộc như đóng hoặc emoji. Dùng Button khi biểu tượng chưa tự giải thích kết quả. Không dùng cho điều hướng nội dung trong câu trả lời; đó là việc của link.
### Use instead
| Component | Use when |
| --- | --- |
| `IconButton` | Thao tác chỉ có biểu tượng, cần tên truy cập. |
| `Button` | Hành động có nhãn chữ hoặc cần variant fill của kit. |
## Live preview
Example (Standard) — Element chatty-icon-button: size sm, md, lg và tone; nhãn truy cập qua label.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {
ArrowUpIcon,
IconClose,
IconExternalLink,
IconTrash
} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-icon-button prototype chatty-ui ports from (chatty-ui/src/elements/icon-button.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/icon-button.js';
export function Standard() {
return html`
${IconClose({size: 20})}${IconClose({size: 20})}${ArrowUpIcon({size: 20})}${IconTrash({size: 20})}
`;
}
```
Example (Standard) — Disabled và link của element.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {
ArrowUpIcon,
IconClose,
IconExternalLink,
IconTrash
} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-icon-button prototype chatty-ui ports from (chatty-ui/src/elements/icon-button.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/icon-button.js';
export function States() {
return html`
${IconClose({size: 20})}${IconExternalLink({size: 20})}
`;
}
```
Example (Current (React), being replaced) — Ba size và năm màu của API `IconButton`.
```jsx
import React from 'react';
import {IconButton} from '@avada/chatty-ui/components/icon-button.js';
import {CloseIcon} from '@avada/chatty-ui/icons/CloseIcon.js';
export function Catalogue() {
return
;
}
```
Example (Current (React), being replaced) — Idle và disabled của `IconButton` small.
```jsx
import React from 'react';
import {IconButton} from '@avada/chatty-ui/components/icon-button.js';
import {CloseIcon} from '@avada/chatty-ui/icons/CloseIcon.js';
export function States() {
return
;
}
```
## Standard
Example (Standard) — Element chatty-icon-button: size sm, md, lg và tone; nhãn truy cập qua label.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {
ArrowUpIcon,
IconClose,
IconExternalLink,
IconTrash
} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-icon-button prototype chatty-ui ports from (chatty-ui/src/elements/icon-button.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/icon-button.js';
export function Standard() {
return html`
${IconClose({size: 20})}${IconClose({size: 20})}${ArrowUpIcon({size: 20})}${IconTrash({size: 20})}
`;
}
```
Prototype (cùng `icon-button.styles.js` và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Chưa surface nào dùng element thật; các mục theo surface bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-icon-button` | @avada/chatty-ui/elements/icon-button.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `tone` | neutral, critical, success, caution | `'neutral'` | Màu icon theo ý nghĩa; giá trị lạ quay về neutral. |
| attribute | `size` | sm, md, lg | `'md'` | Kích thước ô vuông, cùng ba bậc của React. |
| attribute | `disabled` | boolean | `false` | Chặn kích hoạt, vẫn nhận focus và báo aria-disabled. |
| attribute | `href` | string | `''` | URL http, https, mailto hoặc tel thì render link; URL khác bị bỏ. |
| attribute | `label` | string | `''` | Tên truy cập; bắt buộc vì nội dung chỉ là icon. |
| event | `click` | MouseEvent | – | Kích hoạt native; bị chặn khi disabled. |
| slot | default | – | – | Icon (SVG hoặc chatty-icon). |
| part | `base` | – | – | Control native (button hoặc a). |
| css-property | `--chatty-icon-button-size` | – | – | Kích thước ô vuông; thắng size. |
| css-property | `--chatty-icon-button-color` | – | – | Màu icon theo tone. |
| css-property | `--chatty-icon-button-radius` | – | – | Bo góc. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `IconButton` | @avada/chatty-ui | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Tag native a hoặc button, chọn bằng `href`. |
| 2 | `children` là biểu tượng do caller cấp. |
### Placement / order
| Context | Order |
| --- | --- |
| Emoji trong chat | Caller đặt `IconButton` emoji trước vùng gửi; id `Insert-Emoji-button`, `chatty:h-11 chatty:w-11`. |
| Primitive | Component nhận `children`, không tự tạo hàng nhiều nút. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `size` | string | small, medium, large | `medium` | Chọn width và height vuông. |
| `color` | string | default, primary, secondary, error, inherit | `default` | Chọn màu chữ và nền hover. |
| `disabled` | boolean | true, false | undefined | Chỉ chuyển cho native button; nhánh `href` bỏ qua. |
| `href` | string | URL | undefined | Truthy đổi Tag thành a và thêm `chatty:no-underline`. |
| `className` | string | CSS classes | undefined | Gộp cuối, ghi đè size qua tailwind-merge. |
| `style` | object | CSS declarations | undefined | Merge sau `background: 'none'`, `border: 'none'`, `outline: 'none'`. |
| `children` | ReactNode | Biểu tượng | undefined | Không có glyph mặc định. |
| `props` | attributes | Native attrs, handlers, ARIA attributes | Caller | Spread vào Tag; tên truy cập do caller đặt. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| small | Derived(32px = h-8 × 4px) | Không khai báo | Không khai báo | 8px (`chatty:rounded-md`) | Không có chữ | Native box | Không override theo viewport |
| medium | Derived(40px = h-10 × 4px) | Không khai báo | Không khai báo | 8px (`chatty:rounded-md`) | Không có chữ | Native box | Không override theo viewport |
| large | Derived(48px = h-12 × 4px) | Không khai báo | Không khai báo | 8px (`chatty:rounded-md`) | Không có chữ | Native box | Không override theo viewport |
| Emoji caller | Derived(44px = h-11 × 4px) | Không khai báo | Không khai báo | 8px (`chatty:rounded-md`) | Không có chữ | Native box | `className` ghi đè size small |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text default | `--chatty-foreground` | #0f172a | Merchant `--faqsTextColor` |
| Text secondary | `--chatty-muted-foreground` | #64748b | Merchant `--faqsTextColorSecondary` |
| Text primary | `--chatty-primary` | #6366f1 | #6366f1 |
| Text error | `--chatty-destructive` | #ef4444 | #ef4444 |
| Hover fill | `--chatty-muted` | #f1f5f9 | #f1f5f9 |
| Focus ring | `--chatty-ring` | Merchant `--faqsTextColor`, fallback #303030 | Merchant `--faqsTextColor`, fallback #eee |
| Radius | `--chatty-radius-md` | 8px | 8px |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Hover default | pointer | `hover:chatty:bg-muted` | Không thêm ARIA |
| Hover primary | pointer | `hover:chatty:bg-primary/10` | Không thêm ARIA |
| Hover error | pointer | `hover:chatty:bg-destructive/10` | Không thêm ARIA |
| Focus-visible | keyboard | `chatty:focus-visible:ring-2`; inline `outline: 'none'` che outline | Native focus |
| Disabled | `disabled` | `chatty:disabled:opacity-50`, `chatty:disabled:pointer-events-none` | Native disabled chỉ trên button |
| Loading | caller | Not available built-in | Caller aria-busy |
### Behaviour
| Interaction | Result |
| --- | --- |
| Keyboard | Native button nhận Enter/Space; anchor nhận Enter. |
| Link | `href` đổi sang anchor; `disabled` không áp lên anchor. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Emoji | Emoji | `aria-label` của emoji caller |
| Caller label | Caller-owned | Tên truy cập do caller đặt |
### Source
| File | Evidence |
| --- | --- |
| | API và element |
| | Caller emoji |
| | Classic token override |
## Do / Don't
Do: truyền `aria-label` mô tả thao tác và dùng một size trong cùng hàng.
Don't: dùng `IconButton` cho điều hướng trong nội dung; để `href` thay anchor link.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Native button hoặc anchor; tên từ `aria-label` | Button Enter/Space; anchor Enter; focus ring khi focus-visible | Caller-owned | Default Measured(#0f172a / #ffffff = 17.85:1); secondary Measured(#64748b / #ffffff = 4.76:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Classic | Size small là 32px; hit target không mở rộng | Not in code yet — build with the body values. Caller trên mobile truyền `chatty:h-11 chatty:w-11` để đạt 44px. | [WCAG — target size enhanced](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html) |
| Classic | Inline `outline: 'none'` che outline native | Not in code yet — build with the body values. Giữ ring khi focus-visible và đo tương phản của ring với nền thật. | [WCAG — focus appearance](https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance.html) |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-icon-button` từ mục Standard rồi chuyển caller từng surface; Inbox Target dùng token chatty-ui literal theo giá trị 2.0; gỡ wrapper hiện tại ở phase 1b trước khi chuyển caller. | |
```
- [WCAG — target size enhanced](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html)
- [WCAG — focus appearance](https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance.html)
- [WAI-ARIA APG — button](https://www.w3.org/WAI/ARIA/apg/patterns/button/)
---
# Resting launcher
Nút mở panel AI Mode dùng chung markup cho cold và full app.
## Key rules
- Launcher gọi action do caller truyền.
- Element `chatty-launcher` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Mở panel hoặc giỏ từ trạng thái resting.
### Use instead
| Component | Use when |
| --- | --- |
| `LauncherChrome` | Mở panel hoặc giỏ từ trạng thái resting. |
| `RestingSearchBar` | Caller sở hữu tương tác liên quan. |
## Live preview
Example (Standard) — Pill resting có chấm online, và pill có nút giỏ với badge số món.
```html
Ask a question
Ask a question
```
Example (Current (React), being replaced) — Launcher thật với hành động cục bộ.
```jsx
import React from 'react';
import {LauncherChrome} from '@scripttag/v2/components/LauncherChrome.jsx';
import {ButtonIcon} from '@scripttag/v2/icons/buttonIcon.jsx';
import IconBag from '@scripttag/v2/icons/IconBag.jsx';
import {SearchPlaceholder} from '@scripttag/v2/components/SearchBar/SearchPlaceholder.jsx';
import '@scripttag/v2/styles/glass.scss';
import '@scripttag/v2/components/SearchBar/SearchBar.scss';
// The resting skin hangs off `.chatty-ai-mode.state-resting` (and the bag off `.has-bag`), which
// AIModeWidgetRoot sets on the widget root; the frame root has neither, so the story adds them.
const resting = node => node?.closest('[data-surface]')?.classList.add('state-resting', 'has-bag');
export function Resting() {
return
;
}
```
## Standard
Example (Standard) — Pill resting có chấm online, và pill có nút giỏ với badge số món.
```html
Ask a question
Ask a question
```
Prototype (cùng `launcher.styles.js`) là chuẩn: chatty-ui port 1:1, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Trigger mở panel và nút giỏ là hai button anh em (React lồng button trong role button). Icon trợ lý, icon giỏ và câu mời đi qua slot. Chưa surface nào dùng element thật; mục AI Mode bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-launcher` | @avada/chatty-ui/elements/launcher.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `label` | string | `''` | Tên truy cập của trigger, ví dụ Open Chatty. |
| attribute | `bag` | boolean | `false` | Hiện nút giỏ; giỏ xác nhận rỗng thì bỏ. |
| attribute | `count` | number | `0` | Số món trong giỏ; badge hiện khi lớn hơn 0 và có trần hiển thị. |
| attribute | `bag-label` | string | `'Shopping bag'` | Tên nút giỏ khi count bằng 0. |
| attribute | `count-label` | string | `'{count} items in cart'` | Tên nút giỏ khi count lớn hơn 0; `{count}` được thay. |
| attribute | `live` | boolean | `false` | Chấm online trên orb. |
| event | `chatty-open` | CustomEvent<{target: 'panel' , 'bag'}> | – | Trigger (target panel) hoặc nút giỏ (target bag) được kích hoạt. |
| event | `chatty-preload` | CustomEvent<{}> | – | Lần đầu rê chuột vào hoặc focus; host tải panel trước. |
| event | `click` | MouseEvent | – | Kích hoạt native của trigger hoặc nút giỏ. |
| slot | default | – | – | Câu mời, ví dụ Ask a question. |
| slot | `icon` | – | – | Icon trợ lý trong orb. |
| slot | `bag-icon` | – | – | Icon giỏ. |
| part | `base` | – | – | Khung pill. |
| part | `trigger` | – | – | Button mở panel; vùng bấm phủ cả pill trừ nút giỏ. |
| part | `orb` | – | – | Orb trợ lý. |
| part | `bag` | – | – | Nút giỏ. |
| part | `count` | – | – | Badge số món. |
| css-property | `--chatty-launcher-width` | – | – | Bề rộng pill. |
| css-property | `--chatty-launcher-background` | – | – | Nền pill. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `LauncherChrome` | @scripttag/v2/components/LauncherChrome.jsx | .chatty-ai-mode |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Trigger, icon, placeholder và nút giỏ. |
### Placement / order
| Context | Order |
| --- | --- |
| Caller | Theo thứ tự markup của component. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `assistantName` | string | Tên trợ lý | Caller | Dùng trong nhãn mở panel. |
| `preview` | boolean | true, false | false | Bản xem tĩnh cho preview preset ở admin: trigger không role, nhãn, handler; giỏ là span. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Component | Theo caller | Theo caller | Theo caller | Theo caller | Theo caller | Nút native và trigger | Style từ SearchBar |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Nền | Theo scope | Theo scope | Theo scope |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Giỏ có hàng | bagCount lớn hơn 0 | Hiện badge số lượng. | aria-label theo số lượng |
### Behaviour
| Interaction | Result |
| --- | --- |
| Mở panel | Click trigger gọi action; click nút giỏ truyền bag. |
| Cold takeover | Khi full app đã sẵn sàng, chuyển lại biến và focus cho panel tương ứng. |
| Cold icon | Icon upload dùng ảnh; nếu không thì dùng Glyph do caller truyền. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Shopping bag | Shopping bag | Nhãn giỏ rỗng |
### Source
| File | Evidence |
| --- | --- |
| | Public API |
| | Markup |
| | Caller |
## Do / Don't
Do: dùng API của surface hiện tại.
Don't: thay hành động của caller bằng hành vi giả định.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| AI Mode | Trigger role button có tên; nút giỏ có aria-label | Caller xử lý phím cho trigger; giỏ là nút native, trừ bản preview | Không có live region | Theo scope |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| AI Mode | Markup React dùng chung cho cold và full app | Not available — new build follows Target. Launcher thuộc gốc surface `chatty-ai-mode` (dự kiến); host giữ `#chatty-ai-mode-root` và `.chatty-ai-mode` ở light DOM để `customCss` chỉnh vị trí vẫn ăn. | [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) |
| AI Mode | Component React theo surface | Not available — new build follows Target. Port `chatty-launcher` từ mục Standard rồi chuyển caller từng surface. | |
```
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# Link
Link trong câu trả lời là anchor do Markdown renderer tạo; màu đến từ biến `--chatty-link` của từng surface.
## Key rules
- Classic: link Markdown dùng `--chatty-link` (merchant `--faqsTextColor`), fallback #303030 Light, #eee Dark.
- AI Mode: `--chatty-link` trỏ về `--link`, và `--link` bằng `--vib-1` ở cả hai theme.
- Admin: bubble inbox đặt `--chatty-link` từ `--chatty-color-text-link`; ngoài scope dùng fallback #2563eb.
- Mọi anchor Markdown đều gạch chân bằng inline style và mở tab mới; scheme ngoài allowlist bị đổi thành fragment an toàn.
- Element `chatty-link` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Dùng anchor Markdown cho điều hướng trong nội dung câu trả lời. Thao tác đổi trạng thái (gửi, lưu) dùng Button. Không có component Link độc lập trong chatty-ui: đừng import một tên như vậy.
### Use instead
| Component | Use when |
| --- | --- |
| `Markdown` | Câu trả lời có link; renderer tạo anchor. |
| `Button` | Hành động có kết quả rõ ràng; truyền `href` thì Button render anchor theo kit đó. |
## Live preview
Example (Standard) — Element chatty-link: link ngoài, mailto và fragment.
```html
Delivery policyEmail usYour orders
```
Example (Standard) — Cùng tab và scheme không an toàn render chữ thường.
```html
FAQ in the same tabUnsafe scheme renders text
```
Example (Standard) — Element chatty-link: link ngoài, mailto và fragment.
```html
Delivery policyEmail usYour orders
```
Example (Standard) — Cùng tab và scheme không an toàn render chữ thường.
```html
FAQ in the same tabUnsafe scheme renders text
```
Example (Standard) — Element chatty-link: link ngoài, mailto và fragment.
```html
Delivery policyEmail usYour orders
```
Example (Standard) — Cùng tab và scheme không an toàn render chữ thường.
```html
FAQ in the same tabUnsafe scheme renders text
```
Example (Current (React), being replaced) — Markdown thật trong scope AI Mode.
```jsx
import React from 'react';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
export function Answer() {
return ;
}
```
Example (Current (React), being replaced) — Markdown thật trong frame Admin; `--chatty-link` chưa được frame đặt nên anchor dùng fallback.
```jsx
import React from 'react';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
export function Answer() {
return ;
}
```
Example (Current (React), being replaced) — Markdown thật với link; anchor lấy màu từ `--chatty-link` của Classic.
```jsx
import React from 'react';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
export function Answer() {
return ;
}
```
## Standard
Example (Standard) — Element chatty-link: link ngoài, mailto và fragment.
```html
Delivery policyEmail usYour orders
```
Prototype (cùng `link.styles.js` và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Chưa surface nào dùng element thật; các mục theo surface bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-link` | @avada/chatty-ui/elements/link.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `href` | string | `''` | URL http, https, mailto, tel, tương đối hoặc fragment; scheme khác render chữ thường. |
| attribute | `target` | _blank, _self | `''` | Để trống thì link ngoài origin mở tab mới với rel noopener noreferrer. |
| event | `click` | MouseEvent | – | Kích hoạt native. |
| slot | default | – | – | Chữ link ở light DOM để index và dịch được. |
| part | `base` | – | – | Anchor native. |
| css-property | `--chatty-link-color` | – | – | Màu chữ và gạch chân. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Markdown` | @avada/chatty-ui/primitives | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Native `a` có `href`, tạo từ cú pháp link hoặc URL trần. |
| 2 | Label là nội dung inline của link trong Markdown. |
### Placement / order
| Context | Order |
| --- | --- |
| Câu trả lời sản phẩm | `Markdown` đặt trong `ProductDetail__QuestionAnswer`; link nằm trong dòng văn bản. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `text` | string | Markdown | empty | Chứa cú pháp link, URL trần hoặc email. |
| `className` | string | CSS classes | undefined | Áp lên div bao ngoài, không lên anchor. |
| `onLinkClick` | function | href, event | undefined | Gọi khi link được theo bằng click hoặc middle click. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Inline | Theo dòng | Không khai báo | Không khai báo | Không khai báo | Kế thừa chữ cha | Native inline box | Không override theo viewport |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Link color | `--chatty-link` | Merchant `--faqsTextColor`, fallback #303030 | Merchant `--faqsTextColor`, fallback #eee |
| Underline | `textDecoration` | underline | underline |
| Underline thickness / offset | inline style | 1px / 2px | 1px / 2px |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Default | render | `--chatty-link` color, underline | Native link |
| Hover | pointer | Không có rule riêng trong Markdown | Native |
| Focus-visible | keyboard | Không có rule riêng trong Markdown; browser vẽ outline | Native focus |
| Unsafe scheme | href ngoài allowlist | `href` thành `#` | Native link |
### Behaviour
| Interaction | Result |
| --- | --- |
| Link ngoài | `target="_blank"` và `rel="noopener noreferrer"`. |
| Deep link | Href trong `DEEP_LINK` gọi `window.ChattyJS.openWidget` thay vì mở tab. |
| Link tracking | `onLinkClick` nhận href; mặc định không theo dõi. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Link label | Caller-owned | Nội dung do câu trả lời cung cấp |
### Source
| File | Evidence |
| --- | --- |
| | Allowlist, deep link, API |
| | Anchor render |
| | `linkStyle` |
| | Classic `--chatty-link` |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Markdown` | @avada/chatty-ui/primitives | .chatty-ai-mode[data-theme] |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Native `a` từ `Markdown`, trong `.aimode-chat`. |
| 2 | Rule `a` của thread lặp lại màu và gạch chân. |
### Placement / order
| Context | Order |
| --- | --- |
| Tin nhắn chat | `Markdown` render nội dung tin nhắn, bọc trong `ClampFade`. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `text` | string | Markdown | empty | Nội dung đã làm mượt khi streaming. |
| `onLinkClick` | function | href, event | undefined | Caller truyền để theo dõi link trong câu trả lời. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Inline | Theo dòng | Không khai báo | Không khai báo | Không khai báo | Kế thừa chữ cha | Native inline box | Không override theo viewport |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Link color | `--chatty-link` | `var(--link)` | `var(--link)` |
| Link role | `--link` | `var(--vib-1)` | `var(--vib-1)` |
| Text | `--vib-1` | rgba(20,19,24,0.94) | rgba(255,255,255,0.96) |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Default | render | `--link` color, underline 1px, offset 2px | Native link |
| Hover | pointer | Không có rule riêng | Native |
### Behaviour
| Interaction | Result |
| --- | --- |
| Link ngoài | `target="_blank"` và `rel="noopener noreferrer"`. |
| Sync màu | Markdown đặt màu inline nên `--chatty-link` và `a` phải khớp nhau. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Link label | Caller-owned | Nội dung do câu trả lời cung cấp |
### Source
| File | Evidence |
| --- | --- |
| | Biến link của AI Mode |
| | Caller Markdown |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Markdown` | @avada/chatty-ui/primitives | .inbox-v2 |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Native `a` từ `Markdown` trong class `chatty-text--markdown`. |
### Placement / order
| Context | Order |
| --- | --- |
| Tin nhắn bot | Bot `markdown` render bằng `Markdown`; tin khác dùng `TextRenderer`. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `text` | string | Markdown | empty | Caller truyền text của tin nhắn. |
| `className` | string | CSS classes | Caller | Caller truyền `chatty-text chatty-text--markdown`. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Inline | Theo dòng | Không khai báo | Không khai báo | Không khai báo | Kế thừa chữ cha | Native inline box | Không override theo viewport |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Link color | `--chatty-link` | `var(--chatty-color-text-link, #005bd3)` trong bubble self | No Dark skin |
| Text link | `--chatty-color-text-link` | `--p-color-text-link`; fallback #005bd3 | No Dark skin |
| Fallback | `--chatty-link` | #2563eb khi biến không được đặt | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Default | render | `--chatty-link` color, underline | Native link |
### Behaviour
| Interaction | Result |
| --- | --- |
| Link ngoài | `target="_blank"` và `rel="noopener noreferrer"`. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Link label | Caller-owned | Nội dung do tin nhắn cung cấp |
### Source
| File | Evidence |
| --- | --- |
| | Scope và màu link của bubble |
| | Caller Markdown |
## Do / Don't
Do (Current (React), being replaced) — Viết link có nghĩa trong câu; giữ gạch chân mặc định của anchor.
```jsx
import React from 'react';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
export function Answer() {
return ;
}
```
Don't: dựa vào màu để khách nhận ra link; bỏ gạch chân.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | `a` có href, tên từ label | Native Tab/Enter; không focus ring riêng | Caller-owned | Merchant color; fallback Measured(#303030 / #ffffff = 13.20:1) |
| AI Mode | `a` có href, tên từ label | Native Tab/Enter; không focus ring riêng | Caller-owned | Phụ thuộc `--vib-1` trên nền glass |
| Admin | `a` có href, tên từ label | Native Tab/Enter; focus-visible của `.inbox-v2` | Caller-owned | Measured(#005bd3 / #f7f7f7 = 5.70:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| AI Mode | Link dùng `--vib-1` cùng màu chữ thường, chỉ khác bằng gạch chân | Not in code yet — build with the body values. Giữ gạch chân 100% link; không bỏ gạch chân khi đổi màu. | [WCAG — use of color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-link` từ mục Standard cho link điều khiển; link trong câu trả lời do `chatty-markdown` render, màu qua `--chatty-markdown-link-color` và `::part(link)`; Inbox Target dùng token chatty-ui literal theo giá trị 2.0; gỡ wrapper hiện tại ở phase 1b trước khi chuyển caller. | |
```
- [WCAG — use of color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html)
- [MDN: ::part()](https://developer.mozilla.org/en-US/docs/Web/CSS/::part)
---
# Markdown
Markdown an toàn, giữ block ổn định khi câu trả lời đang streaming.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `Markdown` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function MarkdownText() {
return ;
}
```
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function MarkdownText() {
return ;
}
```
## Standard
Example (Standard) — Element prototype với token trung tính.
```html
```
Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A. Surface chưa có React tương ứng ghi Not available bên dưới.
Parser giữ HTML thành chữ, chỉ cho phép navigation protocol an toàn. Renderer dựng template tree; không chèn HTML thô. Khi streaming, `animate` giữ delimiter chưa đóng. Hỗ trợ heading, list, quote, code, link và hard break của widget.
### Element
| Element | Module |
| --- | --- |
| `chatty-markdown` | @avada/chatty-ui/elements/markdown.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `text` | string | `''` | Markdown source; HTML is displayed literally. |
| attribute | `animate` | boolean | `false` | Holds unfinished inline delimiters during a stream. |
| part | `base` | Not available | Not available | Markdown document. |
| part | `link` | Not available | Not available | Safe navigation link. |
| css-property | `--chatty-markdown-link` | Not available | Not available | Link ink. |
| css-property | `--chatty-markdown-code-background` | Not available | Not available | Code background. |
## Classic
Token values dưới đây là fallback cục bộ; theme của caller có thể override.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Markdown` | @avada/chatty-ui/primitives/Markdown.js | Markdown |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Markdown |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `text` | See source | Caller supplied | See source | Markdown source |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Paragraph | Content | Not available | Bottom margin 0.75em | Not available | Inherited | Not available | Text flow |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Inline code fill | `--chatty-muted` | Fallback #f4f4f5 | Fallback #f4f4f5 |
| Link ink | `--chatty-link` | Fallback #2563eb | Fallback #2563eb |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Streaming | animate prop | Unfinished inline markup held | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render text | Escaped React tree |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | Markdown |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## AI Mode
Token values dưới đây là fallback cục bộ; theme của caller có thể override.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Markdown` | @avada/chatty-ui/primitives/Markdown.js | Markdown |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Markdown |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `text` | See source | Caller supplied | See source | Markdown source |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Paragraph | Content | Not available | Bottom margin 0.75em | Not available | Inherited | Not available | Text flow |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Inline code fill | `--chatty-muted` | Fallback #f4f4f5 | Fallback #f4f4f5 |
| Link ink | `--chatty-link` | Fallback #2563eb | Fallback #2563eb |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Streaming | animate prop | Unfinished inline markup held | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render text | Escaped React tree |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | Markdown |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## Admin
Not available — React component tương ứng không có trong surface này; không dựng preview giả.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| Not available | Not available | Not available |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Not available |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Not available |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Not available | Not available |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Not available | Not available | Not available |
### Source
| File | Evidence |
| --- | --- |
| | Shared React owner; no corresponding surface preview. |
## Do / Don't
Do: giữ host làm owner của dữ liệu.
Don't: gửi lại chỉ vì element render.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Native content semantics | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
| AI Mode | Native content semantics | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
| Admin | Native content semantics | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
---
# Menu / popover
Menu hành động phụ của composer AI Mode: mở, điều hướng bằng phím và đóng đúng chỗ.
## Key rules
- Dùng `ComposerMenu` cho hành động phụ quanh composer; đây là menu riêng của AI Mode, chưa có menu dùng chung.
- Panel dùng `role="menu"`, mỗi dòng dùng `role="menuitem"`; trigger giữ `aria-haspopup="menu"` và `aria-expanded`.
- Arrow Up / Arrow Down di chuyển giữa các dòng; Esc đóng menu và trả focus về trigger.
- Dòng menu dùng padding 9px 12px và role `body-medium`; trạng thái hover và focus-visible đều dùng `--fill-2`.
- Element `chatty-menu` ở mục Standard là chuẩn chatty-ui port theo; mục AI Mode mô tả component React đang chạy.
## Use when / Avoid
Dùng cho danh sách hành động ngắn quanh composer. Classic và Admin chưa có menu hành động dùng chung trong code. Nội dung dài hoặc cần vùng đọc riêng dùng Sidebar; panel chứa form không gán `role="menu"`.
### Use instead
| Component | Use when |
| --- | --- |
| `ComposerMenu` | Hành động phụ của composer: nói chuyện với người, đánh giá, tải tệp, emoji. |
| `PopoverPanel` | Panel nổi theo portal dùng chung với EmojiPicker; caller truyền `role`. |
| `Sidebar` | Nội dung dài hoặc cần header, thân cuộn riêng; xem trang Sheet / sidebar. |
## Live preview
Example (Standard) — Element chatty-menu đang mở: dòng có icon, token chuẩn, không màu merchant.
```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`
${IconHeadset({slot: 'icon', size: 16})}Talk to a person${IconStar({slot: 'icon', size: 16})}Rate this chat${IconPaperclip({slot: 'icon', size: 16})}Upload file${IconSmile({slot: 'icon', size: 16})}Emoji
`;
}
```
Example (Standard) — Dòng disabled bị mũi tên bỏ qua và không kích hoạt.
```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`
Talk to a personRate this chatEmoji
`;
}
```
Example (Standard) — Element chatty-popover: panel nổi dùng chung, ví dụ lưới emoji.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {IconSmile} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-popover prototype chatty-ui ports from (chatty-ui/src/elements/popover.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/popover.js';
export function Standard() {
return html`
`;
}
```
Example (Current (React), being replaced) — Trigger, panel với đủ bốn dòng và trạng thái lỗi đánh giá của ComposerMenu.
```jsx
import React, {useEffect, useRef} from 'react';
import {ComposerMenu} from '@scripttag/v2/components/SearchBar/ComposerMenu.jsx';
import '@scripttag/v2/ui/launcher.scss';
const nextFrame = () => new Promise(resolve => requestAnimationFrame(resolve));
async function until(read) {
for (let frame = 0; frame < 120; frame += 1) {
const value = read();
if (value) return value;
await nextFrame();
}
return null;
}
// The real menu opens on a click. The guide clicks the real trigger, and keeps that click from
// reaching the document so a menu opened earlier is not closed as an outside click.
async function openMenu(trigger) {
const panels = document.querySelectorAll('[role="menu"]').length;
const container = document.getElementById('root');
const stop = event => event.stopPropagation();
container.addEventListener('click', stop);
trigger.click();
container.removeEventListener('click', stop);
return until(() => {
const open = document.querySelectorAll('[role="menu"]');
return open.length > panels ? open[open.length - 1] : null;
});
}
const specimen = {display: 'flex', justifyContent: 'flex-end', alignItems: 'flex-end', minHeight: 210};
export function Catalogue() {
const grid = useRef(null);
useEffect(() => {
// An opened menu moves focus into itself; in an iframe that scrolls the guide page behind it. This frame only shows the menus, so keep focus changes from scrolling the parent.
const focus = HTMLElement.prototype.focus;
HTMLElement.prototype.focus = function (options) {
focus.call(this, {...options, preventScroll: true});
};
const [, opened, failing] = grid.current.querySelectorAll('.aimode-composer-menu-btn');
openMenu(opened)
.then(() => openMenu(failing))
.then(panel =>
[...panel.querySelectorAll('[role="menuitem"]')]
.find(row => row.textContent === 'Rate this chat')
?.click()
);
}, []);
return (
Trigger
Open panel
Rating error
);
}
```
## Standard
Example (Standard) — Element chatty-menu đang mở: dòng có icon, token chuẩn, không màu merchant.
```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`
${IconHeadset({slot: 'icon', size: 16})}Talk to a person${IconStar({slot: 'icon', size: 16})}Rate this chat${IconPaperclip({slot: 'icon', size: 16})}Upload file${IconSmile({slot: 'icon', size: 16})}Emoji
`;
}
```
Prototype (cùng `menu-item.js` cho từng dòng, `popover.js` mà menu kế thừa, các file styles và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. `chatty-popover` là panel nổi dùng chung (ví dụ lưới emoji); `chatty-menu` thêm role menu và điều hướng bằng mũi tên. Chưa surface nào dùng element thật; mục AI Mode bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-menu` | @avada/chatty-ui/elements/menu.js |
| `chatty-menu-item` | @avada/chatty-ui/elements/menu-item.js |
| `chatty-popover` | @avada/chatty-ui/elements/popover.js |
### API
| Element | Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- | --- |
| chatty-menu | attribute | `open` | boolean | `false` | Menu đang mở; trigger cũng mở và đóng nó. |
| chatty-menu | attribute | `placement` | top, bottom | `'bottom'` | Mở phía dưới hoặc phía trên trigger; tự lật khi phía đó hết chỗ. |
| chatty-menu | attribute | `label` | string | `''` | Tên truy cập của panel menu. |
| chatty-menu | event | `toggle` | ToggleEvent | – | Menu mở hoặc đóng; newState là open hoặc closed. |
| chatty-menu | slot | default | – | – | Các dòng chatty-menu-item. |
| chatty-menu | slot | `trigger` | – | – | Control mở menu; nhận aria-haspopup menu và aria-expanded. |
| chatty-menu | part | `base` | – | – | Panel menu trong top layer. |
| chatty-menu | css-property | `--chatty-popover-min-width` | – | – | Chiều rộng tối thiểu của panel. |
| chatty-menu | css-property | `--chatty-popover-padding` | – | – | Padding của panel. |
| chatty-menu-item | attribute | `disabled` | boolean | `false` | Chặn kích hoạt; mũi tên bỏ qua dòng này và báo aria-disabled. |
| chatty-menu-item | event | `click` | MouseEvent | – | Kích hoạt bằng chuột, Enter hoặc Space; bị chặn khi disabled. |
| chatty-menu-item | slot | default | – | – | Nhãn của dòng. |
| chatty-menu-item | slot | `icon` | – | – | Icon đứng trước nhãn. |
| chatty-menu-item | part | `base` | – | – | Khung dòng. |
| chatty-menu-item | part | `icon` | – | – | Vùng chứa icon. |
| chatty-menu-item | part | `label` | – | – | Vùng chứa nhãn. |
| chatty-menu-item | css-property | `--chatty-menu-item-padding` | – | – | Padding của dòng. |
| chatty-popover | attribute | `open` | boolean | `false` | Panel đang mở; trigger cũng mở và đóng nó. |
| chatty-popover | attribute | `placement` | top, bottom | `'bottom'` | Mở phía dưới hoặc phía trên trigger; tự lật khi phía đó hết chỗ. |
| chatty-popover | attribute | `label` | string | `''` | Tên truy cập của panel. |
| chatty-popover | event | `toggle` | ToggleEvent | – | Panel mở hoặc đóng; newState là open hoặc closed. |
| chatty-popover | slot | default | – | – | Nội dung panel. |
| chatty-popover | slot | `trigger` | – | – | Control mở panel; nhận aria-haspopup và aria-expanded. |
| chatty-popover | part | `base` | – | – | Panel trong top layer. |
| chatty-popover | css-property | `--chatty-popover-min-width` | – | – | Chiều rộng tối thiểu của panel. |
| chatty-popover | css-property | `--chatty-popover-padding` | – | – | Padding của panel. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ComposerMenu` | | .chatty-ai-mode[data-theme]; portal .aimode-composer-menu-portal |
| `PopoverPanel` | | .chatty-ai-mode[data-theme]; portal .aimode-composer-menu-portal |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Trigger: native `button` với icon dots. |
| 2 | Portal wrapper `chatty-ai-mode` gắn theme và `--aimode-vw`. |
| 3 | Panel `chatty-glass-regular chatty-popover` mang `role="menu"`. |
| 4 | Thông báo lỗi `role="alert"`, chỉ hiện khi gửi yêu cầu đánh giá thất bại. |
| 5 | Dòng `role="menuitem"`: icon rồi label. |
### Placement / order
| Context | Order |
| --- | --- |
| Vị trí composer | `isComposerTop` false thì panel mở lên trên và dùng animation đi xuống; composer ở slot trên thì panel mở xuống. |
| Thứ tự dòng | Talk to a person, Rate this chat, Upload file, Emoji; ba dòng đầu chỉ hiện khi caller hoặc store cho phép. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `isComposerTop` | boolean | true / false | false | Composer ở slot trên thì panel mở xuống. |
| `canAttach` | boolean | true / false | false | Hiện dòng Upload file. |
| `canTalkToPerson` | boolean | true / false | false | Hiện dòng Talk to a person. |
| `onAttach` | Function | Handler | no-op | Gọi khi Upload file được kích hoạt. |
| `onEmoji` | Function | Handler | no-op | Gọi khi Emoji được kích hoạt. |
| `onTalkToPerson` | Function | Handler | no-op | Gọi khi Talk to a person được kích hoạt. |
| `onOpen` | Function | Handler | no-op | Gọi ngay trước khi menu mở để popover anh em đóng trước. |
| `triggerRef` | object | ref ngoài | ref nội bộ | Cho popover anh em neo vào cùng trigger. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Trigger | `--icon-btn-size` 32px | Theo icon-btn | Không khai báo | Theo icon-btn | Không có chữ | Native box | Không override theo viewport |
| Panel | Theo nội dung | 6px | Không khai báo | 18px (`--radius-lg`) | Không có chữ | Theo dòng | width max-content; min-width 200px; max-width trừ 24px so với `--aimode-vw` |
| Dòng | Theo padding và line-height của role | 9px 12px | 8px | 14px (`--radius-md`) | `body-medium`: Derived(15px = type(body-medium, desktop, size)) / Derived(22px = type(body-medium, desktop, line)) desktop, Derived(17px = type(body-medium, mobile, size)) / Derived(24px = type(body-medium, mobile, line)) mobile; weight 400 | Native box, rộng 100% | JS .is-mobile khi width ≤899px; hoặc media (hover: none) and (pointer: coarse), kể cả landscape >899px |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Panel fill | `--glass-tint-regular` | rgba(251,250,247,0.94) | rgba(24,23,28,0.94) |
| Panel edge | `--glass-edge` | rgba(20,19,24,0.08) | rgba(255,255,255,0.12) |
| Label | `--vib-1` | rgba(20,19,24,0.94) | rgba(255,255,255,0.96) |
| Icon | `--vib-3` | rgba(20,19,24,0.62) | rgba(255,255,255,0.62) |
| Hover / focus fill | `--fill-2` | rgba(20,19,24,0.07) below 900px; rgba(255,255,255,0.65) at min-width 900px | rgba(255,255,255,0.1) |
| Row transition | `--dur-1`; `--ease` | Derived(150ms = duration(150)); cubic-bezier(0.2,0.8,0,1) | Same |
| Panel entrance | `--dur-2`; `--ease` | Derived(200ms = duration(200)); cubic-bezier(0.2,0.8,0,1) | Same |
| Layer | `--aimode-popover-z` | 2147483601 | 2147483601 |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Closed | `open` false | Chỉ trigger hiển thị. | `aria-expanded={open}` |
| Open | Bấm trigger | Panel mở lên: translateY(6px) scale(0.97) và opacity về 1; mở xuống: translateY(-6px) scale(0.97); thời gian `--dur-2`. | `aria-haspopup="menu"`; `role="menu"` |
| Row hover | pointer | Nền `--fill-2`. | Native |
| Row focus-visible | keyboard | Nền `--fill-2`; `outline: none`, không có vòng focus riêng. | `tabIndex={-1}`, focus bằng script |
| Row disabled | `disabled` khi đang gửi yêu cầu đánh giá | Không có rule visual riêng trong CSS của menu; browser vẽ trạng thái disabled mặc định. | native `disabled` |
| Error | `ratingFailed` true | Hiện dòng chữ lỗi phía trên các dòng. | `role="alert"` |
### Behaviour
| Interaction | Result |
| --- | --- |
| Mở menu | Gọi `onOpen` rồi mở; khi panel đã có vị trí, dòng `menuitem` đầu tiên nhận focus nếu focus chưa nằm trong panel. |
| Arrow keys | Arrow Down và Arrow Up chuyển focus giữa các dòng, vòng tròn qua helper `focusRovingItem`. |
| Escape | Esc trên panel hoặc trên trigger đóng menu và trả focus về trigger, không đóng widget. |
| Click ngoài | Đóng menu, không trả focus. |
| Kích hoạt dòng | Talk to a person và Emoji đóng menu rồi trả focus về trigger; Upload file đóng menu và không trả focus để không tranh với hộp thoại chọn tệp. |
| Rate this chat | Gửi yêu cầu một lần; thành công thì đóng và trả focus, thất bại thì giữ menu mở và hiện lỗi. |
| Vị trí | Panel render vào `document.body` qua portal, vị trí do `usePortalAnchor` tính. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| More | More | `aria-label` của trigger |
| Talk to a person | Talk to a person | Label dòng |
| Rate this chat | Rate this chat | Label dòng |
| Upload file | Upload file | Label dòng |
| Emoji | Emoji | Label dòng |
| Something went wrong. Please try again. | Something went wrong. Please try again. | Thông báo lỗi |
### Source
| File | Evidence |
| --- | --- |
| | Component, roving focus và các dòng |
| | Kích thước, trạng thái và animation |
| | Portal và panel |
## Do / Don't
Do: cho Arrow keys di chuyển giữa các dòng và Esc trả focus về trigger.
Don't: không để danh sách chỉ nhận click hoặc để trigger mất focus khi menu đóng.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| AI Mode | Trigger `button` có `aria-haspopup="menu"` và tên "More"; panel `role="menu"`; dòng `role="menuitem"`. | Dòng dùng `tabIndex={-1}`; Arrow Up / Arrow Down di chuyển; Esc đóng và trả focus về trigger. | `role="alert"` cho lỗi đánh giá | Đọc `--vib-1` trên `--glass-tint-regular` trong scope owning; nền glass trong suốt nên tỉ lệ phụ thuộc trang. |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| AI Mode | Dòng focus-visible chỉ đổi nền `--fill-2`; `outline: none`. | Not in code yet — build with the body values. Thêm chỉ báo focus không chỉ dựa vào màu nền, ví dụ vòng 2px quanh dòng đang focus. | [WCAG — focus visible](https://www.w3.org/WAI/WCAG22/Understanding/focus-visible.html) |
| AI Mode | Menu React của composer | Not available — new build follows Target. Port `chatty-menu`, `chatty-menu-item` và `chatty-popover` từ mục Standard; panel ở top layer qua Popover API, không portal ra `document.body`. | |
| Admin | Component Inbox đúng Target chưa ship | Not available — new build follows Target. **Popover + Menu**: neo trigger; tự lật; focus trap; Esc; bấm ngoài đóng; section/icon/destructive/phím tắt; Arrow Up/Down. Dùng ở ⋮ Thread header, Assignee, Snooze, Translate, View switcher (18), Shop switcher (4), User menu (5). Không dùng component Polaris trong Inbox; giữ App Bridge cho phần khung embedded. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
```

Ảnh Target từ mock; các trạng thái chưa xuất hiện trong ảnh vẫn là yêu cầu triển khai, không claim đã ship.
- [WCAG — focus visible](https://www.w3.org/WAI/WCAG22/Understanding/focus-visible.html)
- [WAI-ARIA APG — menu button](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/)
---
# Message
Khung tin nhắn canonical với nhóm sender, rich block và slot metadata.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `MessageFrame` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function Message() {
return (
);
}
```
Example (Current (React), being replaced) — Classic reply renderer đang ship; dữ liệu fixture cục bộ.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function ClassicReply() {
return (
);
}
```
Example (Current (React), being replaced) — ChatThread V2 thật, cùng caller với waiting-streaming.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function StorefrontThread() {
const [ready] = useState(() => {
chatStore.setState({
loadedId: 'guide-conversation',
conversation: {id: 'guide-conversation'},
awaitingReply: false,
statusText: '',
messages: [
{
id: 'question',
senderType: 'customer',
text: 'Which bag works for everyday trips?',
blocks: [],
createdAt: new Date('2026-01-15T10:00:00Z'),
},
{
...message,
senderName: 'Assistant',
createdAt: new Date('2026-01-15T10:01:00Z'),
blocks: [],
},
],
});
return true;
});
return ready ? (
) : null;
}
```
## Standard
Example (Standard) — Element prototype với token trung tính.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/message.js';
const message = {
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
};
export function Standard() {
return html``;
}
```
Example (Standard) — Standard: Admin viewer keeps customer messages on the leading side.
```js
import '@avada/chatty-ui/tokens/admin.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/message.js';
const message = {
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
};
export function StandardAdmin() {
return html``;
}
```
Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A.
`self-types` nhận JSON array, hoặc gán `.selfTypes`; `null` dùng `viewer-type`. Inbox truyền `["agent", "bot"]` để AI, Auto và agent cùng phía self; badge chỉ ghi nguồn gốc. Admin dùng tên sender cho cả nhãn và aria.
Gán property `.store` với `getState()` và `subscribe(listener)`; thay mảng messages theo immutable update và giữ reference các message chưa đổi. `.message`, `.prev`, `.next` hỗ trợ row độc lập. Thread dùng ID để giữ node khi prepend; group chỉ đổi khi sender, thời gian hoặc layout đổi.
Registry mặc định nhận product, products, suggestions, cart-confirmation, loading và reasoning; tin chỉ có type lạ được ẩn. Products giữ shape `{type:'products', data:{products, messageId}}`, nằm trước text và chiếm cả cột ở AI Mode. Registry nhận tag string hoặc `{tag, beforeText, wide}`. Suggestions phát `chatty-suggest` để host gọi composer `send(text)`; action Add to cart phát `chatty-add-to-cart`, host tự cập nhật store. Receipt dùng `data.receipts` (giữ đọc `receipt` hoặc `receipts` cũ) như React. `.registry` là registry riêng của consumer, map type sang tag tin cậy. `.message.blocks` giữ dữ liệu block; adapter product nhận title, price và image, rồi ghép product-card có sẵn.
Example (Standard) — Product block adapter dùng cùng product-card, không tự dựng card mới.
```html
```
Mặc định meta là giờ locale, full datetime ở time/title; chỉ pending/failed có status đã dịch qua `.strings`. Peer run đầu có sender. `layout=centered` dành cho activity không có bubble.
Example (Standard) — Activity row canh giữa: Agent joined.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/message.js';
const message = {
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
};
export function Centered() {
return html``;
}
```
### Element
| Element | Module |
| --- | --- |
| `chatty-message` | @avada/chatty-ui/elements/message.js |
| `chatty-block-product` | @avada/chatty-ui/elements/chatty-block-product.js |
### API
| Element | Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- | --- |
| `chatty-message` | attribute | `message` | Object , null | `null` | Canonical message; keep untouched message references stable. |
| `chatty-message` | attribute | `message-id` | string | `''` | Stable ID selected from store.messages. |
| `chatty-message` | attribute | `viewer-type` | string | `'customer'` | Sender type displayed on the trailing side. |
| `chatty-message` | attribute | `surface` | string | `''` | Visual surface; inferred from the consumer theme root. |
| `chatty-message` | attribute | `locale` | string | `'en'` | Locale used for clocks and full datetimes. |
| `chatty-message` | slot | default | Not available | Not available | Additional block content. |
| `chatty-message` | slot | `sender` | Not available | Not available | Readable sender at the start of a run. |
| `chatty-message` | slot | `badge` | Not available | Not available | Sender badge. |
| `chatty-message` | slot | `meta` | Not available | Not available | Metadata after the message. |
| `chatty-message` | slot | `actions` | Not available | Not available | Message actions. |
| `chatty-message` | part | `base` | Not available | Not available | Message row. |
| `chatty-message` | part | `bubble` | Not available | Not available | Message text. |
| `chatty-message` | part | `blocks` | Not available | Not available | Rich blocks below the bubble. |
| `chatty-message` | part | `sender` | Not available | Not available | Sender label and badge. |
| `chatty-message` | part | `meta` | Not available | Not available | Metadata wrapper. |
| `chatty-message` | part | `actions` | Not available | Not available | Actions wrapper. |
| `chatty-message` | css-property | `--chatty-message-radius` | Not available | Not available | Bubble radius. |
| `chatty-block-product` | attribute | `block` | object | `{}` | Product block with title, price and optional image. |
| `chatty-block-product` | event | `chatty-open` | CustomEvent<{}> | Not available | Product activation forwarded by the card. |
| `chatty-block-product` | part | `base` | Not available | Not available | Product block container. |
| `chatty-message` | attribute | `self-types` | Array , null | `null` | Sender types on the trailing side; null falls back to viewerType. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `WidgetTextRenderer` | | WidgetTextRenderer |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 8px 12px self; 7px 12px peer | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ChatThread` | import ChatThread from '@scripttag/v2/views/ChatThread.jsx'; | ChatThread |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 10px 15px | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `MessageFrame` | @avada/chatty-ui/canonical/MessageFrame.jsx | MessageFrame |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | MessageFrame |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `vm` | See source | Caller supplied | See source | Canonical message |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Rendered | Props supplied | See source | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Patch vm | Renders sender, text and blocks |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | MessageFrame |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## Do / Don't
Do: giữ host làm owner của dữ liệu.
Don't: gửi lại chỉ vì element render.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Native content semantics | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
| AI Mode | Native content semantics | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
| Admin | Native content semantics | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
---
# Pre-chat
Lời mời nhận email và biên nhận dưới câu trả lời gốc.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `PreChatPrompt` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function PreChat() {
return text} onOpen={() => {}} onSkip={() => {}} />;
}
```
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function PreChat() {
return text} onOpen={() => {}} onSkip={() => {}} />;
}
```
## Standard
Example (Standard) — Element prototype với token trung tính.
```html
```
Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A. Surface chưa có React tương ứng ghi Not available bên dưới.
Example (Standard) — Saved-email receipt là state riêng, không đặt cạnh invitation.
```html
```
### Element
| Element | Module |
| --- | --- |
| `chatty-pre-chat` | @avada/chatty-ui/elements/pre-chat.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `email` | string | `''` | Saved email; a receipt replaces the invitation when present. |
| attribute | `label` | string | `'Get replies by email'` | Translated invitation. |
| attribute | `skip-label` | string | `'Chat anonymously'` | Translated anonymous option. |
| attribute | `confirmation` | string | `'Replies will also go to {{email}}'` | Translated receipt template; {{email}} marks the saved email. |
| attribute | `skippable` | boolean | `false` | Shows the anonymous option. |
| event | `chatty-open` | CustomEvent<{}> | Not available | Opens contact collection. |
| event | `chatty-skip` | CustomEvent<{}> | Not available | Requests anonymous chat. |
| event | `click` | MouseEvent | Not available | Native invitation button click. |
| part | `base` | Not available | Not available | Contact invitation. |
## Classic
Token values dưới đây là fallback cục bộ; theme của caller có thể override.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `PreChatPrompt` | @avada/chatty-ui/canonical/PreChatPrompt.jsx | PreChatPrompt |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | PreChatPrompt |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `email` | See source | Caller supplied | See source | Saved contact email |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Invitation button | min-height 44px | 12px | 6px | 999px | button-label | 44px | Wrap with available width |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Invitation ink | `--chatty-contact-fg` | Fallback #1f1f1f | Fallback #1f1f1f |
| Invitation fill | `--chatty-contact-chip` | Fallback #fff | Fallback #fff |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Invitation | No saved email | Email and anonymous actions | Native buttons |
| Saved | Email exists | Saved email receipt | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Open / Skip | Calls onOpen or onSkip |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | PreChatPrompt |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## AI Mode
Token values dưới đây là fallback cục bộ; theme của caller có thể override.
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `PreChatPrompt` | @avada/chatty-ui/canonical/PreChatPrompt.jsx | PreChatPrompt |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | PreChatPrompt |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `email` | See source | Caller supplied | See source | Saved contact email |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Invitation button | min-height 44px | 12px | 6px | 999px | button-label | 44px | Wrap with available width |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Invitation ink | `--chatty-contact-fg` | Fallback #1f1f1f | Fallback #1f1f1f |
| Invitation fill | `--chatty-contact-chip` | Fallback #fff | Fallback #fff |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Invitation | No saved email | Email and anonymous actions | Native buttons |
| Saved | Email exists | Saved email receipt | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Open / Skip | Calls onOpen or onSkip |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | PreChatPrompt |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## Do / Don't
Do: giữ host làm owner của dữ liệu.
Don't: gửi lại chỉ vì element render.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Native content semantics | Tab to action; Enter or Space activates | Not available | See neutral token preview |
| AI Mode | Native content semantics | Tab to action; Enter or Space activates | Not available | See neutral token preview |
---
# Product card
Thẻ sản phẩm trong chat: AI Mode và Classic có renderer riêng, cùng thứ tự ảnh, tên, giá, hành động.
## Key rules
- AI Mode: `ProductCard` từ `@scripttag/v2/ui/ProductCard.jsx`; card rộng 184px, ảnh 4 / 5 `contain`, tên tối đa 2 dòng.
- Classic: dùng `ProductCard` default export của ChatbotProductsMessage; card rộng 205px, ảnh 4 / 5 `contain`.
- AI Mode: hover chuột dùng `--chatty-shadow-card-hover`; cảm ứng giữ shadow nghỉ, nhấn xuống scale(0.98).
- Classic: tên và giá dùng `body-medium`, giá weight 600; ảnh và nút "View similar" là hai `button` riêng.
- Hai surface không chung component React; chuẩn port là `chatty-product-card` (Standard).
## Use when / Avoid
Dùng cho đối tượng có ảnh, tên và giá trong hội thoại. Admin chưa có product card riêng trong code. Khi dữ liệu sản phẩm lỗi, dùng text thay vì card rỗng.
### Use instead
| Component | Use when |
| --- | --- |
| `ProductCard` | AI Mode: caller truyền `product`, `onOpen` và `action`. |
| `ProductCard` | Classic: default export nhận `product`, `removedBubblingEvents`, `isFromFindSimilar`, `wizard`. |
| `AddToCartButton` | AI Mode: nút thêm vào giỏ trình bày sẵn, caller sở hữu lời gọi giỏ hàng. |
## Live preview
Example (Standard) — Hàng card layout inset: giá so sánh kèm badge giảm giá secondary "−25%" và sao lẻ, card đã chọn có pill Selected, card hết hàng; nút thẳng hàng ở đáy.
```html
Canvas tote bag
4.6 (128)
−25%Add to cart
Selected
Ceramic mug
Add to cart
Wool cap
Sold out
```
Example (Standard) — Đang thêm giỏ kèm lỗi ở footer, và skeleton cùng hộp card.
```html
Canvas tote bag
AddingCould not add to cart
```
Example (Standard) — Layout flush của Classic: ảnh tràn mép dưới góc card, khối chữ có padding, badge giảm giá, card hết hàng.
```html
Canvas tote bag
4.6 (128)
−25%Add to cart
Wool cap
Sold out
```
Example (Standard) — Đang thêm giỏ kèm lỗi ở footer, và skeleton cùng hộp card.
```html
Canvas tote bag
AddingCould not add to cart
```
Example (Current (React), being replaced) — Card đã tải có giá và giá so sánh, card đã chọn, hết hàng và skeleton.
```jsx
import React, {useState} from 'react';
import {ChatProductCarousel} from '@scripttag/v2/views/chat/ChatProductCarousel.jsx';
import {ChatNavigationContext} from '@scripttag/v2/views/chat/chatNavigationContext.js';
import {selectionStore} from '@scripttag/v2/stores/selectionStore.js';
import {ProductCard} from '@scripttag/v2/ui/ProductCard.jsx';
import ChatbotProductsMessage from '@scripttag/v1/Parts/InsertProduct/ChatbotProductsMessage/ChatbotProductsMessage.js';
import {
WidgetChatStateProvider,
createWidgetChatStateStore
} from '@scripttag/v1/WidgetChatState.js';
import {t} from '@scripttag/v2/helpers/i18n.js';
// PercentOffBadge's screen-reader phrase uses this class on both surfaces; the widget roots load it,
// the story does not mount them.
import '@scripttag/v1/Parts/InsertProduct/offerA11y.scss';
const variant = id => [`Default Title: ${id}`];
const products = [
{
productId: 'gid://shopify/Product/101',
title: 'Canvas tote bag',
url: 'https://shop.example/products/canvas-tote',
image: '/fixtures/tote.svg',
imageAlt: 'Canvas tote bag',
availableForSale: true,
currency: 'USD',
prices: ['$24.00'],
compareAtPrices: ['$32.00'],
variantOptions: variant('1001')
},
{
productId: 'gid://shopify/Product/102',
title: 'Ceramic mug',
url: 'https://shop.example/products/ceramic-mug',
image: '/fixtures/mug.svg',
imageAlt: 'Ceramic mug',
availableForSale: true,
currency: 'USD',
prices: ['$18.00'],
compareAtPrices: [],
variantOptions: variant('1002')
},
{
productId: 'gid://shopify/Product/103',
title: 'Wool cap',
url: 'https://shop.example/products/wool-cap',
image: '/fixtures/cap.svg',
imageAlt: 'Wool cap',
availableForSale: false,
currency: 'USD',
prices: ['$28.00'],
compareAtPrices: [],
variantOptions: variant('1003')
}
];
function AiCatalogue() {
selectionStore.setState({
selected: [{handle: 'ceramic-mug', title: 'Ceramic mug', image: '/fixtures/mug.svg'}]
});
return (
Carousel: loaded, selected, sold out
Skeleton
);
}
// Classic reads its translator from the widget chat state, whose default echoes the phrase without
// interpolating {{value}}; the live widget installs the real one.
const classicState = createWidgetChatStateStore({
i18n: Object.assign((...args) => t(...args), {locale: 'en'})
});
function ClassicCatalogue() {
return (
Compare-at price, in stock, sold out
);
}
export function Catalogue() {
const [surface, setSurface] = useState(null);
const ref = node => {
const found = node?.closest('[data-surface]')?.dataset.surface;
if (found && found !== surface) setSurface(found);
};
return (
{surface === 'classic' ? : surface ? : null}
);
}
```
Example (Current (React), being replaced) — Card Classic có giá so sánh, nút thêm vào giỏ bị vô hiệu và thông báo lỗi.
```jsx
import React, {useState} from 'react';
import {ChatProductCarousel} from '@scripttag/v2/views/chat/ChatProductCarousel.jsx';
import {ChatNavigationContext} from '@scripttag/v2/views/chat/chatNavigationContext.js';
import {selectionStore} from '@scripttag/v2/stores/selectionStore.js';
import {ProductCard} from '@scripttag/v2/ui/ProductCard.jsx';
import ChatbotProductsMessage from '@scripttag/v1/Parts/InsertProduct/ChatbotProductsMessage/ChatbotProductsMessage.js';
import {
WidgetChatStateProvider,
createWidgetChatStateStore
} from '@scripttag/v1/WidgetChatState.js';
import {t} from '@scripttag/v2/helpers/i18n.js';
// PercentOffBadge's screen-reader phrase uses this class on both surfaces; the widget roots load it,
// the story does not mount them.
import '@scripttag/v1/Parts/InsertProduct/offerA11y.scss';
const variant = id => [`Default Title: ${id}`];
const products = [
{
productId: 'gid://shopify/Product/101',
title: 'Canvas tote bag',
url: 'https://shop.example/products/canvas-tote',
image: '/fixtures/tote.svg',
imageAlt: 'Canvas tote bag',
availableForSale: true,
currency: 'USD',
prices: ['$24.00'],
compareAtPrices: ['$32.00'],
variantOptions: variant('1001')
},
{
productId: 'gid://shopify/Product/102',
title: 'Ceramic mug',
url: 'https://shop.example/products/ceramic-mug',
image: '/fixtures/mug.svg',
imageAlt: 'Ceramic mug',
availableForSale: true,
currency: 'USD',
prices: ['$18.00'],
compareAtPrices: [],
variantOptions: variant('1002')
},
{
productId: 'gid://shopify/Product/103',
title: 'Wool cap',
url: 'https://shop.example/products/wool-cap',
image: '/fixtures/cap.svg',
imageAlt: 'Wool cap',
availableForSale: false,
currency: 'USD',
prices: ['$28.00'],
compareAtPrices: [],
variantOptions: variant('1003')
}
];
function AiCatalogue() {
selectionStore.setState({
selected: [{handle: 'ceramic-mug', title: 'Ceramic mug', image: '/fixtures/mug.svg'}]
});
return (
Carousel: loaded, selected, sold out
Skeleton
);
}
// Classic reads its translator from the widget chat state, whose default echoes the phrase without
// interpolating {{value}}; the live widget installs the real one.
const classicState = createWidgetChatStateStore({
i18n: Object.assign((...args) => t(...args), {locale: 'en'})
});
function ClassicCatalogue() {
return (
Compare-at price, in stock, sold out
);
}
export function Catalogue() {
const [surface, setSurface] = useState(null);
const ref = node => {
const found = node?.closest('[data-surface]')?.dataset.surface;
if (found && found !== surface) setSurface(found);
};
return (
{surface === 'classic' ? : surface ? : null}
);
}
```
## Standard
Example (Standard) — Thread AI Mode có năm sản phẩm, rating, giá so sánh và trạng thái sold out; arrows desktop, dots touch.
```html
Canvas tote bag
4.6 (128)
−25%Add to cart
Ceramic mug
4.8 (54)
Add to cart
Wool cap
Sold out
Natural canvas tote bag large
Add to cart
Everyday ceramic mug
Add to cart
```
Example (Standard) — Panel Classic có năm sản phẩm; arrows desktop, dots touch. Classic dark: Standard dùng nền tối; widget đang ship khối trắng.
```html
Canvas tote bag
4.6 (128)
−25%Add to cart
Ceramic mug
4.8 (54)
Add to cart
Wool cap
Sold out
Natural canvas tote bag large
Add to cart
Everyday ceramic mug
Add to cart
```
Prototype Product card và style đi kèm là chuẩn: package được port 1:1 từ prototype, và manifest phần tử được sinh từ cùng nguồn. Ảnh, tên, đánh giá, badge giảm giá và nút đi vào qua slot (`chatty-image`, `chatty-rating`, `chatty-badge`, `chatty-button`); giá truyền dạng chuỗi đã format. Classic dùng `layout="flush"`. Chưa surface nào dùng element thật; các mục AI Mode và Classic bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-product-card` | @avada/chatty-ui/elements/product-card.js |
### API
`chatty-product-row` (cùng module product-card.js) bọc các card trong default slot; ẩn scrollbar; fine pointer desktop dùng prev/next (AI Mode hiện khi hover hoặc focus trong hàng; Classic luôn hiện khi cuộn tiếp được), touch hoặc mobile dùng dots khi tràn. `surface="classic"` trượt một card + gap 8px, AI Mode trượt 80% viewport; arrow biến mất ở đầu/cuối, RTL đảo hướng, reduced-motion cuộn ngay. `strings` đặt nhãn previous/next. Arrow nhận focus; ArrowLeft/ArrowRight và Home/End vẫn cuộn hàng. Hàng giữ title hai dòng để giá thẳng hàng; card ngoài hàng chỉ chiếm số dòng title thực tế.
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `price` | string | `''` | Giá đã format, ví dụ `$24`; rỗng thì ẩn hàng giá. |
| attribute | `compare-at-price` | string | `''` | Giá so sánh đã format, gạch ngang trước giá. |
| attribute | `label` | string | `''` | Tên truy cập của vùng mở chi tiết; rỗng thì lấy chữ bên trong. |
| attribute | `layout` | inset, flush | `'inset'` | inset (AI Mode): card có padding, ảnh bo góc; flush (Classic): ảnh tràn mép dưới góc card, chữ nằm trong khối có padding. |
| attribute | `selected` | boolean | `false` | Viền màu accent khi sản phẩm đã chọn; đi kèm pill ở slot overlay. |
| attribute | `skeleton` | boolean | `false` | Render khung chờ cùng hộp với card đã tải, aria-hidden. |
| event | `chatty-open` | CustomEvent<{}> | – | Bấm, Enter hoặc Space trên vùng mở chi tiết; phím trên action không kích hoạt. |
| slot | default | – | – | Tên sản phẩm, bị kẹp dòng. |
| slot | `media` | – | – | Ảnh sản phẩm, thường là `chatty-image` với fit contain. |
| slot | `overlay` | – | – | Nội dung nằm trên ảnh, ví dụ pill đã chọn. |
| slot | `rating` | – | – | Đánh giá sao, thường là `chatty-rating` readonly. |
| slot | `badge` | – | – | Dấu hiệu giảm giá cạnh giá, thường là `chatty-badge variant="secondary" size="sm"`. |
| slot | `action` | – | – | Action dưới vùng mở chi tiết, thường là nút thêm vào giỏ. |
| slot | `footer` | – | – | Hàng cuối cho thông báo lỗi thêm giỏ. |
| part | `base` | – | – | Khung card. |
| part | `open` | – | – | Vùng mở chi tiết (role button). |
| part | `media` | – | – | Vùng chứa ảnh. |
| part | `name` | – | – | Vùng chứa tên. |
| part | `price` | – | – | Hàng giá. |
| css-property | `--chatty-product-card-radius` | – | – | Bo góc card. |
| css-property | `--chatty-product-card-background` | – | – | Nền card. |
| css-property | `--chatty-product-card-media-radius` | – | – | Bo góc ảnh. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ProductCard` | @scripttag/v2/ui/ProductCard.jsx | .chatty-ai-mode[data-theme] |
| `AddToCartButton` | @scripttag/v2/ui/ProductCard.jsx | .chatty-ai-mode[data-theme] |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Vùng mở chi tiết `chatty-product-card-link` với `role="button"` và `tabIndex={0}`. |
| 2 | Media `chatty-product-card-media` chứa ảnh và slot `overlay`. |
| 3 | Tên `chatty-product-card-name` kẹp 2 dòng bằng `chatty-clamp-2`. |
| 4 | Đánh giá sao `chatty-product-card-rating`, chỉ khi có dữ liệu. |
| 5 | Hàng giá `chatty-product-card-price` với giá so sánh `chatty-price-compare` rồi giá. |
| 6 | Slot `action` dưới vùng mở chi tiết, chỉ hiện khi `canShowAction`. |
| 7 | Slot `footer` cuối card cho thông báo lỗi. |
### Placement / order
| Context | Order |
| --- | --- |
| Carousel chat | Mỗi card rộng 184px, `flex: 0 0 184px`, theo hàng trong track; width do carousel đặt, không do card. |
| Trong card | Ảnh, tên, đánh giá, giá, rồi `action`, rồi `footer`; `overlay` nằm trên ảnh. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `product` | object | id, handle, name, img, imageAlt, price, compareAtPrice, pricing, availableForSale | Caller | Trường đã sẵn sàng hiển thị; `id` dùng tra đánh giá. |
| `onOpen` | Function | Handler nhận trigger của card | Caller | Gọi khi bấm hoặc nhấn Enter / Space trên vùng chi tiết. |
| `action` | any | Node, thường là AddToCartButton | Caller | Render dưới khối thông tin. |
| `footer` | any | Node | Caller | Render cuối cùng, dưới action. |
| `overlay` | any | Node | Caller | Render trên ảnh. |
| `selected` | boolean | true / false | false | Thêm class `is-selected`. |
| `index` | number | Vị trí trong danh sách | 0 | Đặt `--i` cho stagger khi vào. |
| `cardRef` | object | ref | Caller | Chuyển tới root để fly-to-cart tìm ảnh. |
| `className` | string | CSS classes | Caller | Gộp vào root. |
| `skeleton` | boolean | true / false | false | Render placeholder cùng hộp với card đã tải. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Card | Theo nội dung | 10px | 8px | 20px (`--radius-card`) | Không có chữ | Cả vùng chi tiết | width 184px do carousel đặt |
| Media | Theo aspect-ratio 4 / 5 | Không khai báo | Không khai báo | 14px | Không có chữ | Thuộc vùng chi tiết | Không override theo viewport |
| Tên | Tối thiểu 2 dòng của line-height | Không khai báo | Không khai báo | Không khai báo | `body-medium`: Derived(15px = type(body-medium, desktop, size)) / Derived(22px = type(body-medium, desktop, line)) desktop, Derived(17px = type(body-medium, mobile, size)) / Derived(24px = type(body-medium, mobile, line)) mobile; weight 400 | Thuộc vùng chi tiết | JS .is-mobile khi width ≤899px; hoặc media (hover: none) and (pointer: coarse), kể cả landscape >899px |
| Giá | Theo line-height của role | Không khai báo | 6px | Không khai báo | `body-medium`: Derived(15px = type(body-medium, desktop, size)) / Derived(22px = type(body-medium, desktop, line)) desktop, Derived(17px = type(body-medium, mobile, size)) / Derived(24px = type(body-medium, mobile, line)) mobile; weight 600 | Thuộc vùng chi tiết | Cùng breakpoint với Tên |
| Giá so sánh | Theo line-height của role | Không khai báo | Không khai báo | Không khai báo | `body-small`: Derived(14px = type(body-small, desktop, size)) / Derived(20px = type(body-small, desktop, line)) desktop, Derived(15px = type(body-small, mobile, size)) / Derived(22px = type(body-small, mobile, line)) mobile; gạch ngang | Thuộc vùng chi tiết | Cùng breakpoint với Tên |
| Action | Theo nút `chatty-btn` | padding-block 6px | Không khai báo | Theo nút | `button-label`: Derived(14px = type(button-label, desktop, size)) / Derived(18px = type(button-label, desktop, line)) desktop, Derived(17px = type(button-label, mobile, size)) / Derived(24px = type(button-label, mobile, line)) mobile | Native box, `chatty-btn--block` | Mobile đổi sang `chip-label`: Derived(14px = type(chip-label, desktop, size)) / Derived(18px = type(chip-label, desktop, line)) |
| Pill chọn | height/min-height 28px | var(--chatty-space-300) | Theo token | 16px | `chip-label`: Derived(14px = type(chip-label, desktop, size)) / Derived(18px = type(chip-label, desktop, line)) | Mobile mở rộng tới 44px bằng `::before` inset -8px | Desktop hiện khi hover; mobile hiện sẵn |
| Skeleton | Action 32px | Không khai báo | Không khai báo | Action 10px; bone 6px | Không có chữ | Không tương tác | Giá rộng 45% và cao 1.8em |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Nền card | `--bg-elevated` | #fbfaf7, kèm `--shadow-1` | Theo `chatty-surface` |
| Nền khi hover | `--fill-hover` | Không đổi nền; dùng shadow | rgba(255,255,255,0.14) |
| Shadow hover | `--chatty-shadow-card-hover` | 0 0 0 1px rgb(0 0 0 / 0.06), 0 2px 4px rgb(0 0 0 / 0.06), 0 4px 12px -4px rgb(0 0 0 / 0.18) | 0 0 0 1px rgb(255 255 255 / 0.12), 0 2px 4px rgb(0 0 0 / 0.3), 0 4px 12px -4px rgb(0 0 0 / 0.54) |
| Tên | `--vib-1` | rgba(20,19,24,0.94) | rgba(255,255,255,0.96) |
| Giá so sánh | `--vib-3` | rgba(20,19,24,0.62) | rgba(255,255,255,0.62) |
| Viền khi đã chọn | `--accent` | Merchant --faqsBtnPopupColor, fallback #8b7be8 | Same definition |
| Vòng focus | `--chatty-color-border-focus` | `--vib-1`: rgba(20,19,24,0.94) | `--vib-1`: rgba(255,255,255,0.96) |
| Lỗi | `--danger` | #ef4444 | #ef4444 |
| Chuyển động hover | `--chatty-motion-duration-250` | 250ms cho transform; 150ms cho shadow và nền | Same |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Rest | Mặc định | `box-shadow: var(--chatty-shadow-1)`. | Không thêm ARIA |
| Hover | pointer có hover và pointer fine | translateY(-2px); `--chatty-shadow-card-hover`; ảnh scale(1.03); tên gạch chân. | Không thêm ARIA |
| Focus-within | Focus trong card | Touch hoặc mobile dùng `--chatty-shadow-1` và không transform. | Không thêm ARIA |
| Focus-visible | keyboard trên vùng chi tiết | outline 2px solid `--chatty-color-border-focus`, offset 2px. | `role="button"`, `tabIndex={0}` |
| Touch active | hover: none hoặc pointer: coarse | scale(0.98); nền `color-mix(in srgb, currentColor 12%, transparent)`; thời gian `--chatty-motion-duration-100`. | Không thêm ARIA |
| Selected | `selected` true | `border-color` là `--accent`. | Class `is-selected` |
| Skeleton | `skeleton` true | Class `chatty-product-card--skeleton`; không pointer, không animation, cùng hộp card. | `aria-hidden="true"` |
| In stock / sold out | `availableForSale` true / false | Thêm class `is-in-stock` hoặc `is-sold-out`; nút action do caller vô hiệu bằng `soldOut`. | Native `disabled` trên nút action |
| Adding | status ADDING của `AddToCartButton` | Class `is-loading`; nút vô hiệu để chặn bấm lặp. | `aria-busy` |
| Reduced motion | `prefers-reduced-motion: reduce` | `animation: none`; transform none; ảnh không phóng khi hover. | Không thêm ARIA |
### Behaviour
| Interaction | Result |
| --- | --- |
| Mở chi tiết | Bấm, hoặc Enter / Space khi focus nằm trên chính vùng chi tiết, gọi `onOpen`. |
| Hiện action | Slot `action` chỉ render khi `canAddToCart` trả true theo `pricing`, khách ẩn giá và `legacyPricing`. |
| Tên dài | Kẹp 2 dòng; chiều cao tối thiểu bằng 2 line-height của role. |
| Hết hàng | Card chỉ đặt class theo `availableForSale`; caller sở hữu nút vô hiệu và tra cứu tồn kho khi chưa biết. |
| Lỗi thêm giỏ | Caller truyền thông báo vào `footer`; class `chatty-product-card-error` dùng `--danger` và role `body-small`. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| View product | View product | `aria-label` vùng chi tiết, ghép với tên |
| Added to cart | Added to cart | `successLabel` của `AddToCartFeedback` |
| Add to cart | Add to cart | Nhãn nút khi idle |
| Sold out | Sold out | Nhãn nút khi hết hàng |
| Added | Added | Nhãn trạng thái đã thêm |
| Try again | Try again | Nhãn trạng thái lỗi |
| Tên, giá | Caller-owned | Dữ liệu `product`, không có chuỗi mặc định |
### Source
| File | Evidence |
| --- | --- |
| | API, anatomy và action |
| | Kích thước, trạng thái và theme |
| | Media canvas và hover |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ProductCard` | import ProductCard from '@scripttag/v1/Parts/InsertProduct/ChatbotProductsMessage/ProductCard.js'; | .Avada-Faqs_Popup[data-theme] .Avada-Faq_ChatbotProduct-Message_Card |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Root `Card` với class `Avada-Faq_ChatbotProduct-Message_Card`. |
| 2 | Vùng ảnh `Avada-ProductCard-ImageContainer` với `button` mở chi tiết. |
| 3 | Nút overlay "View similar", anh em của nút ảnh để không lồng button. |
| 4 | Khối thông tin `Avada-ProductCard-Info`. |
| 5 | Tên là thẻ `a` mở tab mới. |
| 6 | Đánh giá sao, chỉ khi có dữ liệu. |
| 7 | Giá qua `WithheldPrice`, kèm giá so sánh khi có. |
| 8 | Nút `Button` thêm vào giỏ trong tooltip wrapper. |
| 9 | Thông báo lỗi `role="alert"`. |
### Placement / order
| Context | Order |
| --- | --- |
| Carousel chat | ChatbotProductsMessage render một `ProductCard` cho mỗi sản phẩm; mỗi card rộng 205px, `flex: 0 0 205px`. |
| Trong card | Ảnh (overlay "View similar" ở góc phải dưới), tên, đánh giá, giá, rồi nút thêm vào giỏ; lỗi nằm cuối. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `product` | object | imageUrl, title, price, comparePrice, link, productId, availableForSale | Caller | Card đọc widget và store của Classic. |
| `removedBubblingEvents` | object | Handlers | Caller | Spread vào `Card`. |
| `isFromFindSimilar` | boolean | true / false | Caller | Ghi nhận hoạt động khi bấm tên từ danh sách tương tự. |
| `wizard` | boolean | true / false | false | Xem trước trong wizard: nút còn hiện nhưng bấm không làm gì. |
| `availableForSale` | boolean | true / false | false | Quyết định nút thêm vào giỏ và tooltip hết hàng. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Card | height auto | Không khai báo | Không khai báo | 14px | Không có chữ | Theo phần tử con | width 205px; border 1px; margin-bottom 2px |
| Media | Theo aspect-ratio 4 / 5 | Không khai báo | Không khai báo | 14px | Không có chữ | Nút ảnh phủ kín vùng ảnh | Không override theo viewport |
| Overlay | Theo nội dung | 6px; hover 6px 12px | 6px khi hover | 10px | `button-label`: Derived(14px = type(button-label, desktop, size)) / Derived(18px = type(button-label, desktop, line)) desktop, Derived(17px = type(button-label, mobile, size)) / Derived(24px = type(button-label, mobile, line)) mobile; icon 18px | Native box | Chữ mở rộng tới max-width 120px khi hover hoặc focus-visible |
| Thông tin | Theo nội dung | 10px 12px 12px | 10px | Không khai báo | Không có chữ | Không tương tác | Không override theo viewport |
| Tên | Kẹp 2 dòng | Không khai báo | 4px | Không khai báo | `body-medium`: Derived(15px = type(body-medium, desktop, size)) / Derived(22px = type(body-medium, desktop, line)) desktop, Derived(17px = type(body-medium, mobile, size)) / Derived(24px = type(body-medium, mobile, line)) mobile; weight 400 | Thẻ `a` theo dòng chữ | JS mobile class; `mobileMaxWidth` 899px |
| Giá | min-height 20.02px | Không khai báo | 4px 6px | Không khai báo | `body-medium`: Derived(15px = type(body-medium, desktop, size)) / Derived(22px = type(body-medium, desktop, line)) desktop, Derived(17px = type(body-medium, mobile, size)) / Derived(24px = type(body-medium, mobile, line)) mobile; weight 600 | Không tương tác | Cùng breakpoint với Tên |
| Giá so sánh | Theo line-height của role | margin-right 8px | Không khai báo | Không khai báo | `body-small`: Derived(14px = type(body-small, desktop, size)) / Derived(20px = type(body-small, desktop, line)) desktop, Derived(15px = type(body-small, mobile, size)) / Derived(22px = type(body-small, mobile, line)) mobile; gạch ngang | Không tương tác | Cùng breakpoint với Tên |
| Thêm vào giỏ | Theo nội dung | 10px 12px; mobile 6px 12px | Không khai báo | 10px | `button-label`: Derived(14px = type(button-label, desktop, size)) / Derived(18px = type(button-label, desktop, line)) desktop, Derived(17px = type(button-label, mobile, size)) / Derived(24px = type(button-label, mobile, line)) mobile | Native box, rộng 100% | Class `Avada-ProductCard-AddToCartButton-Mobile` khi `isMobile` |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Chữ card | `color` | #232323 | #ffffff |
| Nền card | `background` | rgba(255,255,255,0.75) | transparent |
| Viền card | `border` | #f2f2f2 | #303030 |
| Nền khối thông tin | `background-color` | #ffffff | #303030 |
| Nút thêm vào giỏ | `background-color`; `color` | Nền #ffffff; chữ #232323; hover nền #f8f9ff | Nền #ffffff; chữ #232323; hover nền #f8f9ff |
| Nút overlay | `background-color`; `color` | Nền #ffffff; chữ #303030 | Nền #232323; chữ #ffffff |
| Giá so sánh | `color` | #000000bf | rgba(255,255,255,0.6) |
| Vòng focus | `--chatty-color-border-focus` | Fallback #232323 | Fallback #232323 |
| Lỗi | `--danger` | Fallback #b42318 | Fallback #b42318 |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Hover card | pointer có hover và pointer fine | translateY(-2px); `--chatty-shadow-card-hover`; ảnh scale(1.03); tên gạch chân. | Không thêm ARIA |
| Touch active | hover: none hoặc pointer: coarse | scale(0.98); nền `color-mix(in srgb, currentColor 12%, transparent)`. | Không thêm ARIA |
| Focus-visible ảnh | keyboard | outline 2px solid; outline-offset -3px để vòng nằm trong vùng ảnh bị cắt. | `aria-label` "View product details" + tên |
| Focus-visible overlay | keyboard | outline 2px solid; offset 2px; nhãn mở rộng như hover. | `aria-label` "View similar" + tên |
| Focus-visible tên | keyboard | outline 2px solid currentColor; offset 2px; radius 4px. | Thẻ `a` native |
| Focus-visible giỏ | keyboard | outline 2px solid; offset 2px. | `aria-label` "Add to cart" + tên |
| Giỏ vô hiệu | `!availableForSale` hoặc đang thêm | opacity 0.5; tooltip "Out of stock" khi hết hàng. | native `disabled` |
| Đang thêm | `isBusy` | Hiện `Spinner` small trước nhãn; nút vô hiệu để chặn bấm lặp. | `aria-busy` |
| Lỗi thêm giỏ | `addError` có giá trị | Dòng chữ lỗi dưới nút, role `body-small`, màu `--danger`. | `role="alert"` |
| Reduced motion | `prefers-reduced-motion: reduce` | transform none trên card, hover và active. | Không thêm ARIA |
### Behaviour
| Interaction | Result |
| --- | --- |
| Bấm ảnh | Mở chi tiết ngay trong chat qua `setProduct`; nếu tắt chi tiết hoặc cần báo giá thì mở link ở tab mới; không làm gì khi `wizard` hoặc khối chat box. |
| Bấm tên | Thẻ `a` mở tab mới với `noopener noreferrer`; `wizard` chặn điều hướng. |
| View similar | Gửi tin nhắn chat yêu cầu sản phẩm tương tự và ghi nhận hoạt động; vô hiệu khi `wizard`; ẩn trong quản trị. |
| Thêm vào giỏ | Sản phẩm một biến thể và lô bằng 1 thì thêm trực tiếp; còn lại mở bộ chọn giỏ hàng; báo giá hoặc quản trị thì không thêm. |
| Giá bị ẩn | `WithheldPrice` quyết định hiển thị theo `pricing`, `priceHidden` và `isAdmin`; thiếu `price` thì không render hàng giá. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| View product details | View product details | `aria-label` nút ảnh, ghép với tên |
| View similar | View similar | Nhãn nút overlay |
| Add to cart | Add to cart | Nhãn nút giỏ |
| Added to cart | Added to cart | `successLabel` sau khi thêm |
| Out of stock | Out of stock | Tooltip khi hết hàng |
| Could not add to cart | Could not add to cart | Thông báo lỗi thêm giỏ |
### Source
| File | Evidence |
| --- | --- |
| | API, anatomy và hành vi |
| | Kích thước, màu và trạng thái |
| | Media canvas và hover |
## Do / Don't
Do: giữ thứ tự ảnh, tên, giá, rồi một hành động chính cho mỗi sản phẩm.
Don't: không kéo giãn card đơn trong carousel hoặc đặt button lồng trong button mở chi tiết.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| AI Mode | Vùng chi tiết `role="button"` có `aria-label` "View product" ghép với tên; skeleton `aria-hidden="true"`. | `tabIndex={0}`; Enter và Space chỉ kích hoạt khi focus nằm trên chính vùng chi tiết. | Không có live region trong card | Đọc `--vib-1` trên nền card trong owning scope; nền Dark theo `chatty-surface` nên chưa đo ở đây. |
| Classic | Nút ảnh, overlay và giỏ có `aria-label` ghép tên sản phẩm; tên là thẻ `a`; ảnh dùng `alt` hoặc tiêu đề. | Nút ảnh và overlay là anh em, không lồng; mỗi phần tử có outline 2px khi focus-visible. | `role="alert"` cho lỗi thêm giỏ | Chữ trên khối thông tin: Light Measured(#232323 / #ffffff = 15.72:1); Dark Measured(#ffffff / #303030 = 13.20:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Classic | Chiều rộng card Classic là 205px, khác 184px của AI Mode. | Not in code yet — build with the body values. Thống nhất chiều rộng carousel về 184px nếu hai surface cần cùng nhịp hiển thị. | |
| AI Mode | Hit target của pill chọn trên desktop là min-height 32px. | Not in code yet — build with the body values. Mở rộng vùng bấm lên 44px như mobile đã làm bằng `::before`. | [WCAG — target size enhanced](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html) |
| AI Mode · Classic | Hai renderer React riêng | Not available — new build follows Target. Element (dự kiến): `chatty-product-card` gộp hai renderer; property `.product`; slot `actions`; event `chatty-add-to-cart` (`bubbles` + `composed`). | [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) |
```
- [WCAG — target size enhanced](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html)
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# Select / combobox
Target cho Inbox thuần chatty-ui; owner hiện tại là MemberSelector, chưa phải component dùng chung mới.
## Key rules
- Admin: phần Current chỉ chỉ ra owner đang dùng; component Inbox dùng chung theo thiết kế nằm ở Target.
- Admin: ảnh preview là thiết kế, không chứng minh API hoặc hành vi đã ship.
## Use when / Avoid
Dùng để triển khai Select / combobox của Inbox theo Target. Không import tên component Target chưa tồn tại; không coi owner cục bộ là API dùng chung.
### Use instead
| Component | Use when |
| --- | --- |
| MemberSelector | Owner hiện tại của vùng tương ứng; chưa phải Target dùng chung |
| Input | Ô nhập thô của kit, chưa có đủ wrapper Target |
## Live preview
Example — Target: ảnh chụp mock, xem trạng thái và vùng dùng trong Target; chưa phải implementation.
```jsx
import React from 'react';
function Design({asset,name}) { return Target · thiết kế mock, chưa phải implementation. Ảnh không chứng minh mọi trạng thái yêu cầu đã có.; }
export function SelectCombobox() { return ; }
```
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `MemberSelector` | import MemberSelector from '@assets/pages/InboxManagement/Parts/ConverstionDetail/MemberSelector.js'; | Owner cục bộ hiện tại; chưa có scope dùng chung cho component Target |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Owner hiện tại: MemberSelector; component dùng chung mới chưa có |
### Placement / order
| Context | Order |
| --- | --- |
| Inbox | Theo caller hiện tại; vị trí của component mới nằm ở Target |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | API dùng chung mới chưa có; không tái đặt API của owner |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Not available | Not available | Chưa có state contract dùng chung theo Target | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Current owner | Theo logic cục bộ; contract mới xem Target |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Not available | Not available | Nhãn do caller hiện tại quản lý |
### Source
| File | Evidence |
| --- | --- |
| | Owner hiện tại; không chứng minh component Target đã có |
## Do / Don't
Do: giữ ranh giới giữa code hiện tại và Target khi triển khai.
Don't: bịa import hoặc dùng ảnh thiết kế làm bằng chứng API đã ship.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin | Owner hiện tại quản lý | Not available cho component dùng chung mới | Not available | Chưa đo cho component Target |
## Target
```target
| Surface | Now | Target |
| --- | --- | --- |
| Admin | Owner MemberSelector có trong source; component dùng chung đúng Target chưa có | Not available — new build follows Target. **Select / combobox**: trigger dạng pill; ô tìm danh sách agent; chọn một; dấu check ở mục được chọn. Dùng ở All channels, Anyone, Newest first (7); chip Assignee. Giá trị 2.0 qua token chatty-ui literal; phase 1b gỡ wrapper Polaris trước khi chuyển caller. |
```
Ảnh chỉ chứng minh phần được vẽ trong mock; các trạng thái liệt kê là yêu cầu triển khai, không claim ảnh hoặc code đã có đủ.
---
# Sheet / sidebar
Sidebar của AI Mode: cột phải trên desktop, slide-over trên mobile, giữ focus và trả focus về nơi mở.
## Key rules
- Dùng `Sidebar` qua `SidebarHost`: mỗi lúc chỉ một sidebar, nội dung đăng ký trong `SIDEBAR_REGISTRY`.
- Desktop là cột phải rộng 430px, không có nền chắn; mobile (≤899px) là slide-over phủ cả widget và có scrim.
- Header cao 52px gồm tiêu đề và nút đóng; panel mobile dùng `--radius-panel`.
- Esc đóng, Tab bị giữ trong sidebar, focus vào nút đóng khi mở và trả về nơi mở khi đóng xong.
- Element `chatty-sheet` ở mục Standard là chuẩn chatty-ui port theo; mục AI Mode mô tả component React đang chạy.
## Use when / Avoid
Dùng cho chi tiết sản phẩm, đơn hàng hoặc giỏ hàng cần vùng đọc riêng mà vẫn giữ hội thoại. Classic và Admin chưa có sidebar dùng chung trong code. Danh sách hành động ngắn dùng menu; tray hành động theo lựa chọn ở đáy panel mobile dùng SelectionSheet.
### Use instead
| Component | Use when |
| --- | --- |
| `Sidebar` | Chi tiết sản phẩm, đơn hàng hoặc giỏ hàng cần cột riêng; chỉ AI Mode. |
| `SelectionSheet` | Tray hành động cho sản phẩm đã chọn, cố định ở đáy panel và chỉ mobile. |
| `ComposerMenu` | Danh sách hành động ngắn quanh composer; xem trang Menu / popover. |
| `Modal` | Dialog overlay cấp thấp của kit có focus trap và Esc; không phải sidebar. |
## Live preview
Example (Standard) — Element chatty-sheet layout column: cột phải cạnh hội thoại.
```html
Classic leather boot
Full-grain leather, a cushioned insole and a rubber sole. Free returns within 30 days.
```
Example (Standard) — Layout overlay: trượt lên phủ widget, có scrim và tay nắm.
```html
Your bag
2 items · $148.00
```
Example (Current (React), being replaced) — Sidebar thật mở với tiêu đề, nút đóng và thân nội dung: nút Desktop của preview hiện cột phải, nút Mobile hiện slide-over có handle, nút giỏ hàng và scrim.
```jsx
import React, {useRef} from 'react';
import {Sidebar} from '@scripttag/v2/components/Sidebar/Sidebar.jsx';
import {useIsMobileViewport} from '@scripttag/v2/hooks/useIsMobileViewport.js';
// Defines --aimode-sidebar-open-width (430px) on .chatty-ai-mode; the widget loads it with the panel.
import '@scripttag/v2/components/Panel.scss';
const Title = () => 'Order #1042';
const noop = () => {};
function Body() {
return
Body content
;
}
// The frame follows the page's Desktop / Mobile switch: wider than 899px it is the desktop right column, otherwise the real slide-over. The frame root already carries .chatty-ai-mode and .is-mobile, so the specimen only supplies the positioned box the widget root would be.
export function Catalogue() {
const ref = useRef(null);
const isMobile = useIsMobileViewport(ref);
return (
);
}
```
## Standard
Example (Standard) — Element chatty-sheet layout column: cột phải cạnh hội thoại.
```html
Classic leather boot
Full-grain leather, a cushioned insole and a rubber sole. Free returns within 30 days.
```
Prototype (cùng `sheet.styles.js` và , dùng `FocusController`) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Sheet không lên top layer: overlay chỉ phủ tổ tiên có position (widget), không phủ cả trang của merchant. Layout column không modal (role complementary): Tab đi ra composer và thread được. Chỉ overlay là modal (role dialog, aria-modal) và giữ Tab bên trong. Hai layout đều chuyển focus tới nút đóng khi mở và đóng bằng Esc. Chưa có kéo để đóng nên element không vẽ tay nắm. Chưa surface nào dùng element thật; mục AI Mode bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-sheet` | @avada/chatty-ui/elements/sheet.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `open` | boolean | `false` | Sheet đang mở; mở sau khi gắn vào trang thì chuyển focus tới nút đóng. Sheet mở sẵn lúc gắn vẫn có Esc và trap nhưng không lấy focus. |
| attribute | `layout` | column, overlay | `'column'` | column là cột phải cạnh hội thoại, không modal; overlay trượt lên phủ tổ tiên có position, kèm scrim, modal và giữ Tab. |
| attribute | `label` | string | `''` | Tên truy cập; để trống thì lấy từ slot heading. |
| attribute | `close-label` | string | `'Close'` | Tên truy cập của nút đóng. |
| event | `click` | MouseEvent | – | Click native của nút đóng, nổi ra ngoài shadow root. |
| event | `chatty-close` | CustomEvent<{reason: escape, backdrop, close-button}> | – | Yêu cầu đóng (escape, backdrop hoặc close-button); preventDefault giữ sheet mở. |
| slot | default | – | – | Thân sheet. |
| slot | `heading` | – | – | Tiêu đề; đặt tên cho sheet khi label trống. |
| slot | `actions` | – | – | Control ở header, đứng trước nút đóng. |
| slot | `close-icon` | – | – | Icon của nút đóng; mặc định là dấu nhân. |
| part | `base` | – | – | Khung sheet (role complementary; dialog ở layout overlay). |
| part | `scrim` | – | – | Nền chắn của layout overlay. |
| part | `header` | – | – | Hàng tiêu đề. |
| part | `close` | – | – | Nút đóng. |
| part | `body` | – | – | Vùng chứa thân. |
| css-property | `--chatty-sheet-width` | – | – | Chiều rộng cột ở layout column. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Sidebar` | @scripttag/v2/components/Sidebar/Sidebar.jsx | .chatty-ai-mode[data-theme] .chatty-sidebar |
| `SidebarHost` | @scripttag/v2/components/Sidebar/SidebarHost.jsx | .chatty-ai-mode[data-theme] .chatty-sidebar |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Scrim `chatty-sidebar-scrim`, `aria-hidden="true"`, chỉ hiện trên mobile. |
| 2 | Container `chatty-sidebar` với `role="dialog"` và `aria-modal="true"`. |
| 3 | Handle kéo `chatty-sidebar-handle`, chỉ hiện trên mobile. |
| 4 | Header: tiêu đề `chatty-sidebar-title` và nhóm `chatty-sidebar-actions`. |
| 5 | Nút đóng với `aria-label` Close; nút giỏ hàng chỉ khi `showBag`. |
| 6 | Thân `chatty-sidebar-body` chứa `children`, caller tự cuộn trong view của mình. |
### Placement / order
| Context | Order |
| --- | --- |
| Desktop | Cột phải trong lưới panel, không có nền chắn; panel mở rộng thêm 430px khi `has-sidebar`. |
| Mobile | Slide-over gắn ở root widget, phủ cả widget kể cả vùng composer; kích thước widget không đổi. |
| Trong sidebar | Handle, header (tiêu đề rồi nhóm nút giỏ hàng và đóng), thân. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `open` | boolean | true / false | Caller | Điều khiển class mở, `inert` và focus. |
| `title` | component | Component không props | Caller | Render trong header. |
| `titlePhase` | string | pha swap của view | rest | Chọn class `chatty-view-` cho tiêu đề. |
| `showBag` | boolean | true / false | Caller | Icon giỏ hàng trong header, chỉ hiển thị trên mobile. |
| `onClose` | Function | Handler | Caller | Gọi từ nút đóng, scrim, Esc và kéo handle. |
| `onExited` | Function | Handler | Caller | Gọi một lần sau khi animation thoát kết thúc. |
| `children` | ReactNode | Nội dung view | Caller | Render trong thân sidebar. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Cột desktop | 100% của panel | Không khai báo | Không khai báo | Không khai báo | Không có chữ | Theo nội dung | width 430px qua `--aimode-sidebar-open-width`; border-left 1px |
| Header | 52px | 0 theo `--chatty-layout-inset` | Không khai báo | Không khai báo | Theo tiêu đề | Theo nút | border-bottom 1px |
| Tiêu đề | Theo line-height của role | Không khai báo | 6px | Không khai báo | `heading-large`: Derived(17px = type(heading-large, desktop, size)) / Derived(24px = type(heading-large, desktop, line)) desktop, Derived(19px = type(heading-large, mobile, size)) / Derived(26px = type(heading-large, mobile, line)) mobile; weight 600 | Không tương tác | JS .is-mobile khi width ≤899px; hoặc media (hover: none) and (pointer: coarse), kể cả landscape >899px |
| Nhóm nút | Theo nút | Không khai báo | 4px | Không khai báo | Không có chữ | Theo nút | Không override theo viewport |
| Slide-over mobile | inset 0, phủ cả widget | Không khai báo | Không khai báo | 28px (`--radius-panel`) | Không có chữ | Cả widget | `.is-mobile` khi width ≤899px |
| Handle mobile | 4px (thanh) | 6px 0 14px | Không khai báo | 2px | Không có chữ | Rộng min(140px, 36%) | Chỉ `.is-mobile`; kéo xuống để đóng |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Cạnh cột và header | `--glass-edge` | rgba(20,19,24,0.08) | rgba(255,255,255,0.12) |
| Tiêu đề | `--vib-1` | rgba(20,19,24,0.94) | rgba(255,255,255,0.96) |
| Thanh handle | `--vib-3` | rgba(20,19,24,0.62) | rgba(255,255,255,0.62) |
| Handle khi kéo | `--accent` | Merchant --faqsBtnPopupColor, fallback #8b7be8 | Same definition |
| Nền slide-over mobile | `--glass-opaque-regular` | rgb(250,249,246) | rgb(24,23,28) |
| Scrim mobile | `rgb(0 0 0 / 0.4)` | rgb(0 0 0 / 0.4) | rgb(0 0 0 / 0.4) |
| Mở slide-over | `--chatty-motion-sheet-in` | Derived(400ms = duration(400)) | Same |
| Đóng slide-over | `--chatty-motion-sheet-out` | Derived(250ms = duration(250)) | Same |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Closed | `open` false | Bị `inert`; mobile: translateY(100%), scrim opacity 0. | `inert` |
| Open | `open` true, sau hai frame | Class `is-open`; mobile: translateY(0), thời gian `--chatty-motion-sheet-in`, scrim opacity 1. | `role="dialog"`, `aria-modal="true"` |
| Dragging | Kéo handle trên mobile | Handle rộng 48px, nền `--accent`. | `aria-hidden="true"` trên handle |
| Reduced motion | `prefers-reduced-motion: reduce` | Chỉ chuyển opacity trong 150ms; transform none; chưa mở opacity 0, mở opacity 1. | Không thêm ARIA |
### Behaviour
| Interaction | Result |
| --- | --- |
| Mở | Ghi nhớ phần tử đang focus làm opener rồi focus nút đóng ở frame kế tiếp. |
| Tab | Giữ focus trong sidebar: Tab ở phần tử cuối quay về đầu, Shift+Tab ở đầu quay về cuối. |
| Esc | Gọi `onClose`. |
| Scrim và kéo handle | Bấm scrim gọi `onClose`; kéo handle xuống gọi `onClose` qua `useDragToDismiss`; cả hai chỉ có trên mobile. |
| Đóng xong | Chờ `transitionend` của transform hoặc opacity, rồi trả focus về opener và gọi `onExited` đúng một lần. |
| Chọn view | `SidebarHost` render một sidebar đang hoạt động theo `SIDEBAR_REGISTRY` (bag, product-detail, order-detail) và chuyển view bằng fade-through. |
| Nút giỏ hàng | `showBag` bật khi view không phải giỏ hàng; nút chỉ hiển thị ở mobile. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Close | Close | `aria-label` của nút đóng |
| Shopping bag | Shopping bag | Nhãn nút giỏ hàng trong header |
| Your cart | Your cart | Tiêu đề view giỏ hàng |
### Source
| File | Evidence |
| --- | --- |
| | Cấu trúc, focus, Esc và thoát |
| | Kích thước, mobile và motion |
| | Host và registry |
## Do / Don't
Do: giữ tiêu đề, nút đóng và thân nội dung cuộn ổn định giữa các view.
Don't: không mở hai sidebar cùng lúc hoặc đặt nút đóng ngoài header.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| AI Mode | Container `role="dialog"` và `aria-modal="true"`; chưa gán tên từ tiêu đề; nút đóng tên "Close". | Focus vào nút đóng khi mở; Tab bị giữ trong sidebar; Esc đóng; focus trả về opener sau khi thoát. | Không có live region trong Sidebar | Mobile, tiêu đề `--vib-1` trên `--glass-opaque-regular`: Light Measured(rgba(20,19,24,0.94) / rgb(250,249,246) = 15.23:1); Dark Measured(rgba(255,255,255,0.96) / rgb(24,23,28) = 16.46:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| AI Mode | Container có `role="dialog"` nhưng chưa có tên truy cập từ tiêu đề. | Not in code yet — build with the body values. Gắn `aria-labelledby` từ container tới phần tử tiêu đề để dialog có tên. | [WAI-ARIA APG — dialog modal](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/) |
| AI Mode | Sidebar React, slide-over trên mobile | Not available — new build follows Target. Port `chatty-sheet` từ mục Standard: layout column trên desktop (không modal), overlay trên mobile (modal, trap); Esc và restore focus qua `FocusController`. Kéo để đóng chưa có nên element không vẽ tay nắm. | |
```
- [WAI-ARIA APG — dialog modal](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/)
---
# Skeleton / loading
Giữ chỗ đúng hình dạng nội dung cuối khi chờ dữ liệu; chỉ Classic dùng Skeleton của kit.
## Key rules
- Dùng `Skeleton` khi biết hình dạng cuối; truyền `width` và `height` bằng kích thước cuối để không đổi bố cục.
- Animation mặc định là `pulse`; `animation={false}` cho bản tĩnh, `wave` thực chất là bounce.
- Component không tự đặt aria-hidden, vùng status hay xử lý reduced motion: caller phải thêm.
- AI Mode có class CSS riêng và admin dùng skeleton của Polaris; chỉ Classic import `Skeleton` của kit (xem Use instead).
- Element `chatty-skeleton` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Dùng khi biết kích thước nội dung cuối, ví dụ lưới GIF đang tải. Không dùng thay empty state hay chỉ báo AI đang xử lý. Surface khác dùng owner riêng của surface đó.
### Use instead
| Component | Use when |
| --- | --- |
| `Skeleton` | Classic: bone giữ chỗ cho lưới GIF khi loading. |
| `chatty-skeleton` | AI Mode: class CSS cho bone, không import `Skeleton`. |
| `SkeletonBodyText` | Admin · Knowledge files: dùng Polaris, không dùng `Skeleton`. |
## Live preview
Example (Standard) — Element chatty-skeleton: circle, text, rect và bản tĩnh; bone aria-hidden.
```html
```
Example (Current (React), being replaced) — Skeleton circular, text và rectangular static dùng props thật.
```jsx
import React from 'react';
import {Skeleton} from '@avada/chatty-ui/components/skeleton.js';
export function Shapes() {
return
Loading content
Avatar, text and static card
;
}
```
## Standard
Example (Standard) — Element chatty-skeleton: circle, text, rect và bản tĩnh; bone aria-hidden.
```html
```
Prototype (cùng `skeleton.styles.js` và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Chưa surface nào dùng element thật; các mục theo surface bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-skeleton` | @avada/chatty-ui/elements/skeleton.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `shape` | rect, text, circle | `'rect'` | Hình bone: khối, dòng chữ hoặc tròn. |
| attribute | `animation` | pulse, none | `'pulse'` | pulse hoặc none; reduced motion luôn tắt pulse. |
| part | `base` | – | – | Khối bone. |
| css-property | `--chatty-skeleton-width` | – | – | Chiều rộng; mặc định full. |
| css-property | `--chatty-skeleton-height` | – | – | Chiều cao; text và circle có mặc định riêng. |
| css-property | `--chatty-skeleton-color` | – | – | Màu bone. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Skeleton` | @avada/chatty-ui | .chatty-widget > #Avada-FAQ_Widget > .Avada-Faqs_Popup |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Một `div` rỗng, ref forward, nhận `className`, `style` và props. |
### Placement / order
| Context | Order |
| --- | --- |
| GIFPicker | Khi loading, caller render 8 `Skeleton` trong container lưới thay cho ảnh GIF. |
| Primitive | Component không sở hữu nhóm bone hay status; caller quyết định số lượng và vị trí. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `variant` | string | text, circular, rectangular | `rectangular` | Chọn hình dạng bone. |
| `width` | string / number | CSS width | Không có | Vào inline style khi có giá trị. |
| `height` | string / number | CSS height | Không có | Vào inline style khi có giá trị. |
| `animation` | string / false | pulse, wave, false | `pulse` | `wave` map sang utility bounce; false bỏ animation. |
| `className` | string | CSS classes | Không có | Gộp cuối danh sách class. |
| `props` | attributes | aria-_, data-_, handlers | Caller | Spread vào thẻ div, kể cả aria-hidden. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| text | Derived(16px = h-4 × 4px) | Không có | Caller | `chatty:rounded`; giá trị không khai báo trong config | Không có chữ | Không tương tác | Không override theo viewport |
| circular | Theo `height` của caller | Không có | Caller | `chatty:rounded-full` = 9999px | Không có chữ | Không tương tác | Không override theo viewport |
| rectangular | Theo `height` của caller | Không có | Caller | `chatty:rounded-md` = 8px | Không có chữ | Không tương tác | Không override theo viewport |
| Ô GIFPicker | 80px | Không có | 4px | Theo variant mặc định rectangular | Không có chữ | Không tương tác | Rộng `calc(25% - 4px)` mỗi ô |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Fill | `--chatty-muted` | #f1f5f9 | Same; popup chỉ override `--chatty-muted-foreground` |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Pulse | `animation` pulse | Thêm utility `chatty:animate-pulse` | Không thêm ARIA |
| Wave | `animation` wave | Thêm utility `chatty:animate-bounce`, không phải shimmer | Không thêm ARIA |
| Static | `animation` false | Không thêm class animation | Không thêm ARIA |
| Reduced motion | Không có handler | Not available: component không đọc prefers-reduced-motion | Caller chọn `animation` false |
| Loading semantics | Caller truyền props | Not available: component không đặt role, aria-busy hay aria-hidden | Caller truyền qua props |
### Behaviour
| Interaction | Result |
| --- | --- |
| Đổi kích thước | Bone giữ `width` / `height` inline; caller phải khớp với nội dung cuối để tránh nhảy bố cục. |
| GIFPicker | Caller không truyền `width`, `height` hay aria; kích thước đến từ CSS của container lưới. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller-owned | Caller-owned | Component không render chữ; status do caller. |
### Source
| File | Evidence |
| --- | --- |
| | API và class |
| | Caller Classic |
| | Kích thước ô lưới |
## Do / Don't
Do: truyền `width` và `height` bằng kích thước cuối của nội dung.
Don't: dựa vào `Skeleton` để tự ẩn khỏi trình đọc màn hình hoặc tự dừng chuyển động.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | div không có role; caller truyền aria-hidden qua props | Không nhận focus | Component không có; GIFPicker cũng không đặt | Không có chữ; nền bone lấy từ token muted, đo theo nền merchant |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Classic | `Skeleton` không tự đặt aria-hidden và không đọc prefers-reduced-motion | Not in code yet — build with the body values. Mặc định `aria-hidden="true"` trên bone, giữ nguyên width/height và radius đã đo; khi `prefers-reduced-motion: reduce` thì bỏ animation như `animation={false}`; caller đặt một vùng status và aria-busy; không có tương tác hay disabled; trạng thái bình thường trở lại khi dữ liệu về và bone được gỡ. | [WCAG — pause stop hide](https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html) |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-skeleton` từ mục Standard rồi chuyển caller từng surface; Inbox Target dùng token chatty-ui literal theo giá trị 2.0; gỡ wrapper hiện tại ở phase 1b trước khi chuyển caller. | |
```
- [WCAG — pause stop hide](https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html)
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# Surface
Shell giữ header, conversation viewport và composer trong một khung.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `CanonicalSurface` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function Surface() {
return (
Conversation}
/>
);
}
```
Example (Current (React), being replaced) — Classic reply renderer đang ship; dữ liệu fixture cục bộ.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function ClassicReply() {
return (
);
}
```
Example (Current (React), being replaced) — ChatThread V2 thật, cùng caller với waiting-streaming.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function StorefrontThread() {
const [ready] = useState(() => {
chatStore.setState({
loadedId: 'guide-conversation',
conversation: {id: 'guide-conversation'},
awaitingReply: false,
statusText: '',
messages: [
{
id: 'question',
senderType: 'customer',
text: 'Which bag works for everyday trips?',
blocks: [],
createdAt: new Date('2026-01-15T10:00:00Z'),
},
{
...message,
senderName: 'Assistant',
createdAt: new Date('2026-01-15T10:01:00Z'),
blocks: [],
},
],
});
return true;
});
return ready ? (
) : null;
}
```
## Standard
Example (Standard) — Element prototype với token trung tính.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/surface.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function Standard() {
return html`Store assistant`;
}
```
Example (Standard) — Standard: Admin viewer keeps customer messages on the leading side.
```js
import '@avada/chatty-ui/tokens/admin.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/surface.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function StandardAdmin() {
return html`Store assistant`;
}
```
Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A.
`self-types` nhận JSON array, hoặc gán `.selfTypes`; `null` dùng `viewer-type`. Inbox truyền `["agent", "bot"]` để AI, Auto và agent cùng phía self; badge chỉ ghi nguồn gốc. Admin dùng tên sender cho cả nhãn và aria.
Gán `.store` với `getState()` và `subscribe(listener)`; thread chọn danh sách ID/ngày, mỗi message chọn slice riêng. Host giữ reference các message chưa đổi; slot cho phép ghép UI trực tiếp khi chưa có store.
Viewport mở tại đáy và theo tin mới. Khi shopper cuộn lên, giữ vị trí và hiện New messages; `.newMessagesLabel` dịch nhãn. Slot `empty` hiện khi store không có tin; `.renderMessage` truyền xuống thread.
Example (Standard) — Greeting trong slot empty của store rỗng.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/surface.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function Empty() {
return html`Store assistant
How can we help?
Ask about products, delivery or your order.
`;
}
```
Example (Standard) — Admin dùng viewer agent.
```js
import '@avada/chatty-ui/tokens/admin.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/surface.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function EmptyAdmin() {
return html`Store assistant
How can we help?
Ask about products, delivery or your order.
`;
}
```
### Element
| Element | Module |
| --- | --- |
| `chatty-surface` | @avada/chatty-ui/elements/surface.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `label` | string | `'Conversation'` | Accessible conversation name. |
| attribute | `viewer-type` | string | `'customer'` | Sender type displayed on the trailing side. |
| attribute | `new-messages-label` | string | `'New messages'` | Translated action shown when updates arrive while reading older messages. |
| slot | default | Not available | Not available | Thread or other conversation content; defaults to a store-backed thread. |
| slot | `empty` | Not available | Not available | Greeting or empty state when the store has no messages. |
| slot | `header` | Not available | Not available | Persistent header. |
| slot | `footer` | Not available | Not available | Composer or contact step. |
| part | `base` | Not available | Not available | Surface shell. |
| part | `header` | Not available | Not available | Header wrapper. |
| part | `viewport` | Not available | Not available | Scrolling conversation viewport. |
| part | `new-messages` | Not available | Not available | Jump to the latest messages. |
| part | `footer` | Not available | Not available | Footer wrapper. |
| css-property | `--chatty-surface-height` | Not available | Not available | Shell height. |
| css-property | `--chatty-surface-footer-inset` | Not available | `0px` | Additional footer clearance. |
| attribute | `self-types` | Array , null | `null` | Sender types on the trailing side; null falls back to viewerType. |
Đặt `--chatty-surface-footer-inset` trên surface để chừa khoảng trống cho composer khi bàn phím mở; mặc định `0px`.
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `WidgetTextRenderer` | | WidgetTextRenderer |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 8px 12px self; 7px 12px peer | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ChatThread` | import ChatThread from '@scripttag/v2/views/ChatThread.jsx'; | ChatThread |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 10px 15px | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `CanonicalSurface` | @avada/chatty-ui/canonical/Surface.jsx | CanonicalSurface |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | CanonicalSurface |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `store` | See source | Caller supplied | See source | Canonical runtime store |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Rendered | Props supplied | See source | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Patch store | Per-message subscriptions |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | CanonicalSurface |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## Do / Don't
Do: giữ host làm owner của dữ liệu.
Don't: gửi lại chỉ vì element render.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Named conversation region | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
| AI Mode | Named conversation region | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
| Admin | Named conversation region | Native links and actions remain keyboard accessible | Not available | See neutral token preview |
---
# Tabs / segmented
Tabs đổi panel cùng cấp: Classic tra cứu đơn, composer inbox Chat / Note / Reminder và Knowledge files dùng Tabs của kit.
## Key rules
- Classic: TrackingTab có hai tab, gạch chân `--faqsBrandColor`, activation automatic.
- Admin: tab Chat / Note / Reminder của composer, activation manual.
- Admin · Knowledge files: `Tabs` + `TabsTrigger` cao 40px, không xử lý phím mũi tên.
- Element `chatty-tabs` ở mục Standard là chuẩn cho Classic và inbox; Knowledge files chuyển sang Polaris.
## Use when / Avoid
Dùng khi các lựa chọn cùng cấp và đổi panel trong cùng ngữ cảnh, ví dụ Test / Problems / Outline. Không dùng tabs cho bước tuần tự hay hành động một lần. Segmented control chưa có component riêng.
### Use instead
| Component | Use when |
| --- | --- |
| `Tabs` | Đổi panel bên phải Knowledge files: Test, Problems, Outline. |
| `TabsTrigger` | Hàng file đang mở trong editor, mỗi tab kèm nút đóng. |
| `handleTabKeyDown` | Caller cần mũi tên, Home, End: Classic TrackingTab và admin inbox đã gắn. |
## Live preview
Example (Standard) — Element chatty-tabs gạch chân, activation automatic; token Classic.
```html
TestProblemsOutlineAsk a question to test this file.No problems found.Headings of the file.
```
Example (Standard) — Kiểu segmented, activation manual và tab disabled; token Classic.
```html
DetailsTrackingReturnsItems and totals.In transit, arriving Friday.No returns.
```
Example (Standard) — Element chatty-tabs gạch chân, activation automatic; token admin.
```html
TestProblemsOutlineAsk a question to test this file.No problems found.Headings of the file.
```
Example (Standard) — Kiểu segmented, activation manual và tab disabled; token admin.
```html
DetailsTrackingReturnsItems and totals.In transit, arriving Friday.No returns.
```
Example (Current (React), being replaced) — Tablist của TrackingTab: hai tab, activation automatic; JSX lấy từ caller TrackingTab.
```jsx
import {typeRole} from '@avada/chatty-ui/styles/typeRole';
import {handleTabKeyDown} from '@avada/chatty-ui/components/tabKeyboard.js';
className="Avada-Faqs_TrackTab-tabs"
```
Example (Current (React), being replaced) — Tablist Chat / Note / Reminder của composer inbox, activation manual; JSX lấy từ caller ChatBox.
```jsx
import {handleTabKeyDown} from '@avada/chatty-ui/components/tabKeyboard.js';
onKeyDown={event => handleTabKeyDown(event, {activation: 'manual'})}
/**
* Render a composer tab whose keyboard focus is independent of its selected mode.
* @param {Object} tab
* @param {boolean} selected
* @param {number} tabIndex
* @param {Function} onFocus
* @param {Function} onChange
*/
function MessageTab({tab, selected, tabIndex, onFocus, onChange}) {
return (
);
}
```
Example (Current (React), being replaced) — Chọn Test, Problems hoặc Outline; tab dùng CSS của Knowledge files.
```jsx
import React, {useState} from 'react';
import {Tabs, TabsList, TabsTrigger} from '@avada/chatty-ui/components/tabs.js';
export function Panels() {
const [selected, setSelected] = useState('run');
return
{['run', 'problems', 'outline'].map(value => (
setSelected(value)}>
{value === 'run' ? 'Test' : value === 'problems' ? 'Problems' : 'Outline'}
))}
{selected} panel
;
}
```
## Standard
Example (Standard) — Element chatty-tabs gạch chân, activation automatic; token Classic.
```html
TestProblemsOutlineAsk a question to test this file.No problems found.Headings of the file.
```
Prototype (cùng `tab.js`, `tab-panel.js`, các file styles và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Tab và panel là con light DOM của `chatty-tabs`, ghép theo thứ tự, để aria-controls và aria-labelledby nằm cùng tree. Knowledge files vẫn chuyển sang Polaris theo Target; element dành cho Classic và inbox.
### Element
| Element | Module |
| --- | --- |
| `chatty-tabs` | @avada/chatty-ui/elements/tabs.js |
| `chatty-tab` | @avada/chatty-ui/elements/tab.js |
| `chatty-tab-panel` | @avada/chatty-ui/elements/tab-panel.js |
### API
| Element | Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- | --- |
| chatty-tabs | attribute | `activation` | automatic, manual | `'automatic'` | automatic chọn tab khi di chuyển bằng mũi tên; manual chờ Enter, Space hoặc click. |
| chatty-tabs | attribute | `segmented` | boolean | `false` | Kiểu segmented: nền chung và tab đang chọn nổi lên, không gạch chân. |
| chatty-tabs | attribute | `label` | string | `''` | Tên truy cập của tablist. |
| chatty-tabs | attribute | `selected-index` | number | `0` | Vị trí tab đang chọn, tính từ 0. |
| chatty-tabs | event | `change` | Event | – | Tab đang chọn đổi do người dùng; đọc selectedIndex. |
| chatty-tabs | slot | default | – | – | Các chatty-tab-panel, theo thứ tự tab. |
| chatty-tabs | slot | `tab` | – | – | Các chatty-tab; chatty-tab tự gán vào slot này. |
| chatty-tabs | part | `base` | – | – | Hàng tablist. |
| chatty-tabs | css-property | `--chatty-tabs-height` | – | – | Chiều cao hàng tab. |
| chatty-tabs | css-property | `--chatty-tab-indicator` | – | – | Màu gạch chân tab đang chọn; mặc định màu chữ, tách khỏi token focus ring. |
| chatty-tab | attribute | `disabled` | boolean | `false` | Không chọn được; mũi tên bỏ qua tab này và báo aria-disabled. |
| chatty-tab | attribute | `selected` | boolean | `false` | Do chatty-tabs đặt theo selected-index; dùng cho style. |
| chatty-tab | slot | default | – | – | Nhãn tab. |
| chatty-tab | slot | `end` | – | – | Nội dung đứng sau nhãn, ví dụ số đếm hoặc nút đóng. |
| chatty-tab | part | `base` | – | – | Khung tab. |
| chatty-tab | part | `end` | – | – | Vùng chứa slot end. |
| chatty-tab-panel | slot | default | – | – | Nội dung panel. |
| chatty-tab-panel | part | `base` | – | – | Khung panel. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `TrackingTab` | import TrackingTab from '@scripttag/v1/MuiPages/TrackingTab.js' | .Avada-Faqs_Popup .Avada-Faqs_TrackTab-container |
| `handleTabKeyDown` | @avada/chatty-ui/components/tabKeyboard.js | Gắn lên tablist của TrackingTab |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Tablist: div `Avada-Faqs_TrackTab-tabs` có role tablist, `display: flex`. |
| 2 | Tab: native button `Avada-Faqs_TrackTab-tab` có role tab, aria-selected và tabIndex. |
| 3 | Gạch chân: viền dưới 2px của chính button, không có indicator riêng. |
| 4 | Vùng nội dung: field và radio ngay sau tablist, không có role tabpanel. |
### Placement / order
| Context | Order |
| --- | --- |
| TrackingTab | Tablist đứng đầu container (flex column, cách 16px): Order number rồi Tracking number, sau đó field của tab đang chọn. |
| Hiện tablist | Chỉ render khi linkStrategy khác default và không phải luồng template chỉ có một form. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `aria-selected` | boolean | true / false | `selectedTab === 0` ở tab đầu | Tab chưa chọn mờ theo selector aria-selected false. |
| `tabIndex` | number | 0 / -1 | 0 ở tab đang chọn | Chỉ tab đang chọn nằm trong thứ tự Tab. |
| `disabled` | boolean | `loading` | false khi chưa tra cứu | Khoá cả hai tab trong lúc tra cứu. |
| `selectedTab` | state | 0 / 1 | `useState(0)` | Khôi phục từ `trackSelectedTab` trong storage. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Tablist `Avada-Faqs_TrackTab-tabs` | Theo nội dung | Không khai báo | Không khai báo | Không khai báo | Không có chữ trực tiếp | Không tương tác | `display: flex`, hai tab chia đều |
| Tab `Avada-Faqs_TrackTab-tab` | Theo padding và line-height | `6px 0` | Không khai báo | Không khai báo | button-label: Derived(14px = type(button-label, desktop, size)) / Derived(18px = type(button-label, desktop, line)) desktop → Derived(17px = type(button-label, mobile, size)) / Derived(24px = type(button-label, mobile, line)) mobile; weight 500 | Rộng 50%, `flex: 1` | Role mobile khi mobileMaxWidth 899px |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Chữ tab | `--faqsTextColor` | Merchant; fallback #944ecf | Theo `--faqsTextColor` |
| Gạch chân đang chọn | `--faqsBrandColor` | Merchant; fallback #944ecf | #ffffff |
| Gạch chân chưa chọn | `border-bottom` | `2px solid transparent` | rgba(255, 255, 255, 0.15) |
| Focus ring | `--chatty-ring` | Fallback #303030 | Fallback #eee |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Chưa chọn | `selectedTab` khác index | opacity 0.6; viền dưới 2px trong suốt | aria-selected false, tabIndex -1 |
| Đang chọn | `selectedTab` khớp index | Thêm class `Avada-Faqs_TrackTab-tab--active`: viền dưới `--faqsBrandColor` (fallback #944ecf) | aria-selected true, tabIndex 0 |
| Dark | data-theme dark | Viền dưới 2px rgba(255, 255, 255, 0.15); đang chọn 2px #ffffff | Không đổi |
| Focus-visible | keyboard | outline 2px `--chatty-ring`, `outline-offset: 2px` | Native focus |
| Disabled | `loading` true | Không có style riêng cho tab | Native disabled |
### Behaviour
| Interaction | Result |
| --- | --- |
| Chọn tab | `handleTabChange` bỏ qua khi `loading`; lưu `trackSelectedTab`, xoá lỗi và giá trị field. |
| Mũi tên / Home / End | activation automatic: chuyển focus rồi click tab mới; RTL đảo chiều mũi tên. |
| Khôi phục | Khi mount đọc `trackSelectedTab` từ storage nếu linkStrategy khác default. |
| Nhãn dài | `white-space: nowrap`; không clamp. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Order number | Order number | Tab đầu của TrackingTab |
| Tracking number | Tracking number | Tab thứ hai của TrackingTab |
### Source
| File | Evidence |
| --- | --- |
| | Markup tablist và state chọn |
| | Skin Light của tab |
| | Skin Dark của tab |
| | Phím mũi tên, Home, End |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ChatBox` | import ChatBox from '@assets/pages/InboxManagement/Parts/ChatBox/ChatBox.js' | .Avada-Faqs__Chat-Box__TabMode |
| `handleTabKeyDown` | @avada/chatty-ui/components/tabKeyboard.js | Gắn lên tablist của composer |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Hàng `Avada-Faqs__Chat-Box__TabMode`: tablist, spacer và nút AI. |
| 2 | Tablist: div có role tablist, cao 30px. |
| 3 | `MessageTab`: native button `Avada-Faqs__MessageTab` có role tab và aria-selected. |
| 4 | Editor Tiptap dưới hàng tab, không có role tabpanel. |
### Placement / order
| Context | Order |
| --- | --- |
| Composer | Chat, Note, Reminder trong tablist; sau đó spacer, AIOptimize và SuggestReply cùng hàng (flex, cách 16px). |
| Compact composer | Mode button thường, không có role tab; chọn mode thì mở composer đầy đủ. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `tab` | object | label, value, props | Không có | label là nhãn; props spread lên button. |
| `selected` | boolean | true / false | Không có | Chuyển thành `aria-selected`. |
| `tabIndex` | number | 0 / -1 | Không có | ChatBox truyền 0 cho tab `focusedMessageTab`, tách khỏi tab đang chọn. |
| `onFocus` | function | Handler | Không có | Ghi lại tab đang focus. |
| `onChange` | function | (event, value) | Không có | Click gọi `onChange(e, tab.value)`. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Tablist | 30px | Không khai báo | Không khai báo | Không khai báo | Không có chữ trực tiếp | Không tương tác | Flex, căn giữa theo chiều dọc |
| Tab `Avada-Faqs__MessageTab` | Theo padding và line-height | `4px 12px` | Không khai báo | 4px | body-medium: Derived(13px = type(body-medium, admin, desktop, size)) / Derived(20px = type(body-medium, admin, desktop, line)) desktop; weight 400, đang chọn 500 | Native box | Hàng `Avada-Faqs__Chat-Box__TabMode` wrap khi hẹp |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Chữ tab | `--chatty-color-text` | Fallback #303030 | No Dark skin |
| Nền đang chọn | `--chatty-color-bg-surface-secondary` | Fallback #f7f7f7 | No Dark skin |
| Gạch chân đang chọn | `--chatty-color-text` | Fallback #303030 | No Dark skin |
| Nền hover | `--chatty-color-bg` | Fallback #f1f1f1 | No Dark skin |
| Focus ring | `--p-color-border-focus` | Fallback #005bd3 | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Chưa chọn | `selected` false | Nền trong suốt; viền dưới 2px trong suốt; weight 400 | aria-selected false |
| Đang chọn | `selected` true | Nền `--chatty-color-bg-surface-secondary` (#f7f7f7); viền dưới `--chatty-color-text`; weight 500 | aria-selected true |
| Hover | pointer | Nền `--chatty-color-bg` (#f1f1f1) | Native |
| Focus-visible | keyboard | outline 2px `--p-color-border-focus` (#005bd3), `outline-offset: 1px` | Native focus |
### Behaviour
| Interaction | Result |
| --- | --- |
| Chọn tab | Click gọi `handleChangeTab`: đổi messageTab, bật note khi chọn Note, bỏ tin đang sửa. |
| Mũi tên / Home / End | activation manual: chỉ chuyển focus, `focusedMessageTab` theo onFocus; Enter hoặc Space bấm button để chọn. |
| Đổi panel | Không có tabpanel; editor mount lại theo `key={messageTab}`, placeholder lấy từ `getTabText`. |
| Tab disabled | Phím bỏ qua tab disabled hoặc aria-disabled true. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Chat | Chat | Tab trả lời khách |
| Note | Note | Tab ghi chú nội bộ |
| Reminder | Reminder | Tab đặt nhắc việc |
### Source
| File | Evidence |
| --- | --- |
| | Markup tab |
| | Tablist và handler phím |
| | Skin tab của composer |
| | Phím mũi tên, Home, End |
## Admin · Knowledge files
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Tabs` + `TabsList` + `TabsTrigger` | @avada/chatty-ui/components | .kb-ide-page > .kb-ide |
| `TabsContent` | @avada/chatty-ui/components | Import có sẵn nhưng RightPanel không render |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | `Tabs`: wrapper div, class `kb-ide__right-tabs`. |
| 2 | `TabsList`: div có role tablist, class `kb-ide__right-header`. |
| 3 | `TabsTrigger`: native button có role tab và aria-selected. |
| 4 | Vùng panel: div `kb-ide__right-scroll` do caller render, không dùng TabsContent. |
### Placement / order
| Context | Order |
| --- | --- |
| RightPanel | Ba trigger theo thứ tự run, problems, outline, rồi vùng panel của tab đang chọn. |
| Editor header | Mỗi tab file là một entry: `TabsTrigger` rồi nút đóng; không có panel liên kết trong component. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `active` | boolean | true / false | Không có | `TabsTrigger` chuyển thành `aria-selected` và chọn class đang chọn. |
| `className` | string | CSS classes | Không có | Gộp cuối trên `Tabs`, TabsList, TabsTrigger và TabsContent. |
| `children` | ReactNode | Caller content | Không có | Render trong element của từng component. |
| `props` | attributes | Native attrs, onClick, aria-\*, disabled | Caller | Spread vào element; caller tự truyền id, aria-controls, onKeyDown. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| TabsList `kb-ide__right-header` | 40px | 0 / 8px | Không khai báo | 0 | Không có chữ trực tiếp | Không tương tác | Selector của page ghi đè utility của kit |
| TabsTrigger trong `kb-ide__right-header` | 40px | `0 10px` | Không khai báo | 0 | 13px | Native box 40px | Selector button role tab thắng utility |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Fill của tab | `background: 0 0` | Trong suốt | No Dark skin |
| Chữ tab chưa chọn | `--p-color-text-secondary` | #616161 | No Dark skin |
| Chữ tab đang chọn | `--p-color-text` | #303030 | No Dark skin |
| Gạch chân đang chọn | `--p-color-border-focus` | #005bd3 | No Dark skin |
| Nền header | `--p-color-bg-surface` | #ffffff | No Dark skin |
| Viền dưới header | `--p-color-border-secondary` | #ebebeb | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Chưa chọn | `active` false | Chữ `--p-color-text-secondary`; viền dưới 2px trong suốt | `aria-selected` false |
| Đang chọn | `active` true | Chữ `--p-color-text`; viền dưới `--p-color-border-focus`; không đổi fill | `aria-selected` true |
| Hover | pointer, không disabled | Fill `--p-color-bg-surface-hover` (#f7f7f7) theo rule button của page | Native |
| Focus-visible | keyboard | Rule của page: outline 2px, offset 2px (`outline-offset`); trigger còn có utility `chatty:focus-visible:ring-2` | Native focus |
| Disabled | `disabled` do caller truyền | opacity 0.48, cursor not-allowed (`0.48`) | Native disabled |
### Behaviour
| Interaction | Result |
| --- | --- |
| Chọn tab | Caller giữ state và đổi `active` qua `onClick`; component không tự quản lý selection. |
| Mũi tên / Home / End | Not available trong `Tabs`; RightPanel không truyền onKeyDown, handleTabKeyDown chỉ có ở caller khác. |
| Nối panel | `TabsContent` có role tabpanel nhưng không tự đặt id hay aria-labelledby; RightPanel dùng div thay thế. |
| Nhãn dài | `whitespace-nowrap` trên trigger; không có clamp hay cuộn riêng ở RightPanel. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Test | Test | Tab run của RightPanel, namespace ai-assistant |
| Problems | Problems | Tab problems của RightPanel |
| Outline | Outline | Tab outline của RightPanel |
| Close file | Close file | Nút đóng cạnh tab file trong editor header |
| Unsaved edits | Unsaved edits | Dấu chấm trên tab file đang sửa |
### Source
| File | Evidence |
| --- | --- |
| | API và class của kit |
| | Caller tab Test / Problems / Outline |
| | Skin tab của page |
## Do / Don't
Do: giữ state chọn ở caller và đặt `active` đúng một trigger.
Don't: dùng Tabs của kit cho segmented control hay giả định Tabs tự xử lý phím mũi tên và nối panel.
## Accessibility
Classic: chữ và gạch chân theo màu merchant `--faqsTextColor`, `--faqsBrandColor`, nên không có cặp màu cố định để đo.
Admin: tỷ lệ đo trên nền tab `--chatty-color-bg-surface-secondary` và `--chatty-color-bg`; admin chỉ có Light.
Admin · Knowledge files: tỷ lệ đo trên nền header `--p-color-bg-surface`; admin chỉ có Light.
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | role tablist và tab; tên tab từ nhãn i18n; tablist không có tên; không có tabpanel | Mũi tên trái, phải, Home, End chuyển focus và chọn ngay (automatic); tabIndex roving 0 / -1; outline 2px `--chatty-ring` khi focus-visible | Không có | Theo màu merchant; tab chưa chọn opacity 0.6; không đo cặp cố định |
| Admin | role tablist và tab; tên từ nhãn Chat / Note / Reminder; tablist không có tên; không có tabpanel | Mũi tên, Home, End chỉ chuyển focus (manual); Enter hoặc Space chọn qua click native; outline 2px `--p-color-border-focus`, offset 1px | Không có | Đang chọn Measured(#303030 / #f7f7f7 = 12.32:1); hover Measured(#303030 / #f1f1f1 = 11.69:1); focus ring Measured(#005bd3 / #f7f7f7 = 5.70:1) |
| Admin · Knowledge files | role tablist, tab, tabpanel; tên tab từ `children`; aria-selected theo active | Mỗi tab là button riêng trong thứ tự Tab; không có mũi tên, Home, End; outline 2px khi focus-visible | Không có | Đang chọn Measured(#303030 / #ffffff = 13.20:1); chưa chọn Measured(#616161 / #ffffff = 6.19:1); gạch chân Measured(#005bd3 / #ffffff = 6.11:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Admin · Knowledge files | RightPanel không gắn handler phím; Tabs không xử lý mũi tên | Not in code yet — build with the body values. Gắn `onKeyDown={event => handleTabKeyDown(event, {activation: 'manual'})}` lên TabsList của RightPanel như ChatBox; giữ nguyên chiều cao 40px và gạch chân; Home/End/mũi tên chuyển focus, Enter hoặc Space chọn tab. | [WAI-ARIA APG — tabs](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) |
| Admin · Knowledge files | RightPanel dùng div thay `TabsContent`, trigger không có aria-controls | Not in code yet — build with the body values. Render `TabsContent` có id, nối trigger bằng aria-controls và panel bằng aria-labelledby; không đổi layout hiện tại. | [WAI-ARIA APG — tabs](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/) |
| Admin · Knowledge files | Tabs của kit chung | Not available — new build follows Target. Knowledge files không dùng `chatty-*`: chuyển sang Polaris `Tabs`, vì trang admin ngoài inbox giữ Polaris. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
| Classic | TrackingTab tự dựng tablist bằng button, không có tabpanel | Not available — new build follows Target. Port `chatty-tabs`, `chatty-tab` và `chatty-tab-panel` từ mục Standard; tab và panel là con light DOM để quan hệ ARIA bằng ID nằm cùng tree scope. | |
| Admin | MessageTab trong ChatBox tự dựng tablist, không có tabpanel | Not available — new build follows Target. Port `chatty-tabs` với activation manual cho composer inbox; giữ Chat, Note, Reminder và nối panel bằng chatty-tab-panel. | |
```
- [WAI-ARIA APG — tabs](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/)
- [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements)
---
# Tag input
Target cho Inbox thuần chatty-ui; owner hiện tại là Tags, chưa phải component dùng chung mới.
## Key rules
- Admin: phần Current chỉ chỉ ra owner đang dùng; component Inbox dùng chung theo thiết kế nằm ở Target.
- Admin: ảnh preview là thiết kế, không chứng minh API hoặc hành vi đã ship.
## Use when / Avoid
Dùng để triển khai Tag input của Inbox theo Target. Không import tên component Target chưa tồn tại; không coi owner cục bộ là API dùng chung.
### Use instead
| Component | Use when |
| --- | --- |
| Tags | Owner hiện tại của vùng tương ứng; chưa phải Target dùng chung |
| Input | Ô nhập thô của kit, chưa có đủ wrapper Target |
## Live preview
Example — Target: ảnh chụp mock, xem trạng thái và vùng dùng trong Target; chưa phải implementation.
```jsx
import React from 'react';
function Design({asset,name}) { return Target · thiết kế mock, chưa phải implementation. Ảnh không chứng minh mọi trạng thái yêu cầu đã có.; }
export function TagInput() { return ; }
```
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Tags` | import Tags from '@assets/pages/InboxManagement/Parts/ConverstionDetail/Tags.js'; | Owner cục bộ hiện tại; chưa có scope dùng chung cho component Target |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Owner hiện tại: Tags; component dùng chung mới chưa có |
### Placement / order
| Context | Order |
| --- | --- |
| Inbox | Theo caller hiện tại; vị trí của component mới nằm ở Target |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | API dùng chung mới chưa có; không tái đặt API của owner |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Not available | Not available | Chưa có state contract dùng chung theo Target | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Current owner | Theo logic cục bộ; contract mới xem Target |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Not available | Not available | Nhãn do caller hiện tại quản lý |
### Source
| File | Evidence |
| --- | --- |
| | Owner hiện tại; không chứng minh component Target đã có |
## Do / Don't
Do: giữ ranh giới giữa code hiện tại và Target khi triển khai.
Don't: bịa import hoặc dùng ảnh thiết kế làm bằng chứng API đã ship.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin | Owner hiện tại quản lý | Not available cho component dùng chung mới | Not available | Chưa đo cho component Target |
## Target
```target
| Surface | Now | Target |
| --- | --- | --- |
| Admin | Owner Tags có trong source; component dùng chung đúng Target chưa có | Not available — new build follows Target. **Tag input**: chip xoá được; ô nhập; gợi ý; Enter để thêm. Dùng ở Tags trong Details section (15). Giá trị 2.0 qua token chatty-ui literal; phase 1b gỡ wrapper Polaris trước khi chuyển caller. |
```
Ảnh minh hoạ chip và Add tag ở đúng vùng; hành vi nhập, gợi ý và Enter vẫn là Target. Ảnh chỉ chứng minh phần được vẽ trong mock; các trạng thái liệt kê là yêu cầu triển khai, không claim ảnh hoặc code đã có đủ.
---
# Text field
Target cho Inbox thuần chatty-ui; owner hiện tại là Note, chưa phải component dùng chung mới.
## Key rules
- Admin: phần Current chỉ chỉ ra owner đang dùng; component Inbox dùng chung theo thiết kế nằm ở Target.
- Admin: ảnh preview là thiết kế, không chứng minh API hoặc hành vi đã ship.
## Use when / Avoid
Dùng để triển khai Text field của Inbox theo Target. Không import tên component Target chưa tồn tại; không coi owner cục bộ là API dùng chung.
### Use instead
| Component | Use when |
| --- | --- |
| Note | Owner hiện tại của vùng tương ứng; chưa phải Target dùng chung |
| Input | Ô nhập thô của kit, chưa có đủ wrapper Target |
## Live preview
Example — Target: ảnh chụp mock, xem trạng thái và vùng dùng trong Target; chưa phải implementation.
```jsx
import React from 'react';
function Design({asset,name}) { return Target · thiết kế mock, chưa phải implementation. Ảnh không chứng minh mọi trạng thái yêu cầu đã có.; }
export function TextField() { return ; }
```
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `Note` | import Note from '@assets/pages/InboxManagement/Parts/ConverstionDetail/Note.js'; | Owner cục bộ hiện tại; chưa có scope dùng chung cho component Target |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Owner hiện tại: Note; component dùng chung mới chưa có |
### Placement / order
| Context | Order |
| --- | --- |
| Inbox | Theo caller hiện tại; vị trí của component mới nằm ở Target |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | API dùng chung mới chưa có; không tái đặt API của owner |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Not available | Not available | Chưa có state contract dùng chung theo Target | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Current owner | Theo logic cục bộ; contract mới xem Target |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Not available | Not available | Nhãn do caller hiện tại quản lý |
### Source
| File | Evidence |
| --- | --- |
| | Owner hiện tại; không chứng minh component Target đã có |
## Do / Don't
Do: giữ ranh giới giữa code hiện tại và Target khi triển khai.
Don't: bịa import hoặc dùng ảnh thiết kế làm bằng chứng API đã ship.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Admin | Owner hiện tại quản lý | Not available cho component dùng chung mới | Not available | Chưa đo cho component Target |
## Target
```target
| Surface | Now | Target |
| --- | --- | --- |
| Admin | Owner Note có trong source; component dùng chung đúng Target chưa có | Not available — new build follows Target. **Text field**: label; help; error; textarea. Dùng ở Add task (Checklist); form Customize. Giá trị 2.0 qua token chatty-ui literal; phase 1b gỡ wrapper Polaris trước khi chuyển caller. |
```
Ảnh chỉ minh hoạ ô tìm có trong mock; wrapper label/help/error và textarea cho các vùng Target chưa được chứng minh bởi ảnh. Ảnh chỉ chứng minh phần được vẽ trong mock; các trạng thái liệt kê là yêu cầu triển khai, không claim ảnh hoặc code đã có đủ.
---
# Thread
Danh sách tin nhắn theo ID, ngăn cách theo ngày và chọn store slice.
## Key rules
- Element prototype là chuẩn để chatty-ui port theo.
- Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
## Use when / Avoid
Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.
### Use instead
| Component | Use when |
| --- | --- |
| `CanonicalSurface` | Implementation React đang chạy. |
| Element prototype | Consumer chuyển sang custom element. |
## Live preview
Example (Current (React), being replaced) — Component React thật; dữ liệu fixture, không gửi request.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function Surface() {
return (
Conversation}
/>
);
}
```
Example (Current (React), being replaced) — Classic reply renderer đang ship; dữ liệu fixture cục bộ.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function ClassicReply() {
return (
);
}
```
Example (Current (React), being replaced) — ChatThread V2 thật, cùng caller với waiting-streaming.
```jsx
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';
const message = {
id: 'guide-reply',
senderType: 'bot',
text: 'The **canvas tote** is lightweight.',
status: 'sent',
createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};
export function StorefrontThread() {
const [ready] = useState(() => {
chatStore.setState({
loadedId: 'guide-conversation',
conversation: {id: 'guide-conversation'},
awaitingReply: false,
statusText: '',
messages: [
{
id: 'question',
senderType: 'customer',
text: 'Which bag works for everyday trips?',
blocks: [],
createdAt: new Date('2026-01-15T10:00:00Z'),
},
{
...message,
senderName: 'Assistant',
createdAt: new Date('2026-01-15T10:01:00Z'),
blocks: [],
},
],
});
return true;
});
return ready ? (
) : null;
}
```
## Standard
Example (Standard) — Element prototype với token trung tính.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/thread.js';
import '@avada/chatty-ui/elements/rating.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function Standard() {
return html``;
}
```
Example (Standard) — Standard: Admin viewer keeps customer messages on the leading side.
```js
import '@avada/chatty-ui/tokens/admin.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/thread.js';
import '@avada/chatty-ui/elements/rating.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function StandardAdmin() {
return html``;
}
```
Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A.
`self-types` nhận JSON array, hoặc gán `.selfTypes`; `null` dùng `viewer-type`. Inbox truyền `["agent", "bot"]` để AI, Auto và agent cùng phía self; badge chỉ ghi nguồn gốc. Admin dùng tên sender cho cả nhãn và aria.
Gán `.store` với `getState()` và `subscribe(listener)`; thread chọn danh sách ID/ngày, mỗi message chọn slice riêng. Host giữ reference các message chưa đổi; slot cho phép ghép UI trực tiếp khi chưa có store.
`.renderMessage(message)` trả object `{sender, badge, meta, actions}` chứa trusted Lit content; callback chạy trong row slice nên patch không render siblings. Chọn callback thay registry thứ hai để caller ghép rating/badge từ element có sẵn; không nhận HTML từ message.
Example (Standard) — Store-backed thread với rating trên bot reply.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/thread.js';
import '@avada/chatty-ui/elements/rating.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function Feedback() {
return html`
message.senderType === 'bot'
? {
actions: html``,
badge: html`AI`,
}
: {}}
>`;
}
```
Example (Standard) — Admin dùng viewer agent.
```js
import '@avada/chatty-ui/tokens/admin.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/thread.js';
import '@avada/chatty-ui/elements/rating.js';
export const messages = [
{
id: 'question',
senderType: 'customer',
senderName: 'Customer',
text: 'Which bag works for everyday trips?',
status: 'sent',
createdAt: '2026-01-15T10:00:00Z',
},
{
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
},
{
id: 'detail',
senderType: 'bot',
senderName: 'Assistant',
text: 'The wide straps make it comfortable to carry.',
status: 'sent',
createdAt: '2026-01-15T10:02:00Z',
blocks: [{type: 'product', title: 'Canvas tote', price: '$24', image: 'https://chatty-ui-research.avada-tesla-chatty.workers.dev/fixtures/tote.svg'}],
},
{
id: 'followup',
senderType: 'customer',
text: 'Does it come in other colors?',
status: 'sent',
createdAt: '2026-01-16T10:00:00Z',
},
{
id: 'agent',
senderType: 'agent',
senderName: 'Alex',
text: 'Yes, we also have navy and natural.',
status: 'sent',
createdAt: '2026-01-16T10:01:00Z',
},
];
export const fixtures = {
store: (items = messages) => {
let state = {messages: items};
const listeners = new Set();
return {
getState: () => state,
subscribe(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
},
setMessages(messages) {
state = {messages};
listeners.forEach((listener) => listener());
},
};
},
};
export function FeedbackAdmin() {
return html`
message.senderType === 'bot'
? {
actions: html``,
badge: html`AI`,
}
: {}}
>`;
}
```
### Element
| Element | Module |
| --- | --- |
| `chatty-thread` | @avada/chatty-ui/elements/thread.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `label` | string | `'Conversation'` | Accessible conversation name. |
| attribute | `viewer-type` | string | `'customer'` | Sender type on the trailing side. |
| attribute | `locale` | string | `'en'` | Locale used for calendar labels. |
| slot | default | Not available | Not available | Direct messages when no store is supplied. |
| part | `base` | Not available | Not available | Conversation log. |
| attribute | `self-types` | Array , null | `null` | Sender types on the trailing side; null falls back to viewerType. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `WidgetTextRenderer` | | WidgetTextRenderer |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 8px 12px self; 7px 12px peer | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `ChatThread` | import ChatThread from '@scripttag/v2/views/ChatThread.jsx'; | ChatThread |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Reply text and conversation rows |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Customer question before bot reply |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| Text / messages | Object | Caller supplied | See source | Fixture supplies local conversation |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Bubble | Content | 10px 15px | 3px grouped; 14px runs | 18px; 6px tail | body-medium: 15px/22px desktop, 17px/24px mobile | Not available | 80% maximum; AI bot answer unboxed |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Text | `--chatty-color-text` | Theme text | Theme text |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| New reply | Store update | Appended row | Conversation log |
### Behaviour
| Interaction | Result |
| --- | --- |
| Render | Shared widget implementation, frozen local fixture |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller supplied | Not available | Message text |
### Source
| File | Evidence |
| --- | --- |
| | Shipping storefront renderer used in Current preview. |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `CanonicalSurface` | @avada/chatty-ui/canonical/Surface.jsx | CanonicalSurface |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | CanonicalSurface |
### Placement / order
| Context | Order |
| --- | --- |
| Conversation | Caller supplies surrounding content |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `store` | See source | Caller supplied | See source | Canonical runtime store |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Not available | Not available | Not available | Not available | Not available | Not available | Not available | Not available |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Not available | Not available | Not available | Not available |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Rendered | Props supplied | See source | Not available |
### Behaviour
| Interaction | Result |
| --- | --- |
| Patch messages | Keyed message rows |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Caller translated | Not available | CanonicalSurface |
### Source
| File | Evidence |
| --- | --- |
| | Owning React implementation. |
## Do / Don't
Do: giữ host làm owner của dữ liệu.
Don't: gửi lại chỉ vì element render.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Conversation log | Native links and actions remain keyboard accessible | Polite additions only | See neutral token preview |
| AI Mode | Conversation log | Native links and actions remain keyboard accessible | Polite additions only | See neutral token preview |
| Admin | Conversation log | Native links and actions remain keyboard accessible | Polite additions only | See neutral token preview |
---
# Toast / confirmation
CartConfirmation là receipt riêng trong thread của AI Mode và inbox; không phải toast.
## Key rules
- AI Mode: `CartConfirmation` có thể render một dòng hoặc nhóm dòng; View cart gọi `onViewCart` của caller.
- AI Mode: ảnh 80px × 64px, nhãn body-small, quantity và giá cùng một dòng.
- Admin: inbox dùng cùng `CartConfirmation` nhưng không truyền `onViewCart` cho viewer admin nên không có View cart.
- Receipt nằm trong thread và không tự biến mất; hiệu ứng quantity có thời gian riêng.
- Element `chatty-toast` ở mục Standard là chuẩn cho thông báo tạm thời của storefront; receipt trong thread không dùng toast.
## Use when / Avoid
Dùng sau khi hệ thống xác nhận thêm giỏ thành công. Không ghép xác nhận vào văn bản AI và không dùng cho phản hồi tạm thời: receipt nằm lại trong thread. Classic dùng cùng block cho khách.
### Use instead
| Component | Use when |
| --- | --- |
| `CartConfirmation` | AI Mode: receipt trong danh sách tin nhắn, có View cart. |
| `CartConfirmation` | Admin inbox: cùng receipt, không có View cart cho viewer admin. |
## Live preview
Example (Standard) — Element chatty-toast: neutral có action, success và critical; token chuẩn.
```html
Message deletedUndoAdded to cartCouldn't send. Check your connection and try again.
```
Example (Standard) — Element chatty-toast trên Classic.
```html
Message deletedUndoAdded to cartCouldn't send. Check your connection and try again.
```
Example (Current (React), being replaced) — Snackbar của ChatPage (useSnackbar contained): nền --chatty-tooltip-bg, chữ trắng; token inverse lấy từ đây.
```jsx
import useSnackbar from '@assets/hooks/useSnackbar';
const {toast, handleOpenToast} = useSnackbar({contained: true});
import {Snackbar} from '@assets/components/ui';
/**
* One toast slot; each open may set its own display time.
* @param {string} vertical
* @param {string} horizontal
* @param {Object} style
* @param {string} className
* @param {boolean} contained anchor to the chat panel instead of the viewport
* @returns {{toast: JSX.Element, handleOpenToast: (content: *, autoHideDuration?: number) => void}}
*/
export default function useSnackbar({
vertical = 'bottom',
horizontal = 'center',
style = {},
className,
contained = false
} = {}) {
const [open, setOpen] = useState(false);
const [content, setContent] = useState('');
const [autoHideDuration, setAutoHideDuration] = useState(DEFAULT_AUTO_HIDE_MS);
const handleOpenToast = (content, duration = DEFAULT_AUTO_HIDE_MS) => {
setOpen(true);
setContent(content);
setAutoHideDuration(duration);
};
// Stable because Snackbar restarts its auto-hide timer whenever onClose changes, and callers re-render often.
const handleCloseToast = useCallback((_, reason) => {
if (reason !== 'clickaway') {
setOpen(false);
setContent('');
}
}, []);
const toast = useMemo(() => {
return (
{content}
);
}, [open, content, autoHideDuration, style, className, contained]);
return {
toast,
handleOpenToast
};
}
```
Example (Current (React), being replaced) — Chỉ để so sánh: receipt thêm giỏ, không phải toast; xem trang Cart confirmation. AI Mode có View cart.
```jsx
import React, {useState} from 'react';
import {CartConfirmation} from '@avada/chatty-ui/primitives/CartConfirmation.jsx';
export function Receipt({surface}) {
const [opened, setOpened] = useState(false);
return
;
}
```
Example (Current (React), being replaced) — Chỉ để so sánh: receipt thêm giỏ, không phải toast; xem trang Cart confirmation. Inbox chỉ đọc, không có View cart.
```jsx
import React, {useState} from 'react';
import {CartConfirmation} from '@avada/chatty-ui/primitives/CartConfirmation.jsx';
export function Receipt({surface}) {
const [opened, setOpened] = useState(false);
return
;
}
```
Example (Current (React), being replaced) — Chỉ để so sánh: receipt thêm giỏ, không phải toast; xem trang Cart confirmation. Khách có View cart.
```jsx
import React, {useState} from 'react';
import {CartConfirmation} from '@avada/chatty-ui/primitives/CartConfirmation.jsx';
export function Receipt({surface}) {
const [opened, setOpened] = useState(false);
return
;
}
```
## Standard
Example (Standard) — Element chatty-toast: neutral có action, success và critical; token chuẩn.
```html
Message deletedUndoAdded to cartCouldn't send. Check your connection and try again.
```
Prototype (cùng `toast.styles.js` và ) là chuẩn cho thông báo tạm thời của storefront: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Receipt thêm giỏ trong thread không phải toast; nó là `chatty-cart-confirmation` ở trang Cart confirmation. Admin giữ App Bridge toast. Chưa surface nào dùng element thật; các mục bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-toast` | @avada/chatty-ui/elements/toast.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `open` | boolean | `false` | Toast đang hiện. |
| attribute | `tone` | neutral, critical, success, caution | `'neutral'` | Ý nghĩa của thông báo: icon đầu dòng màu chữ inverse (không dựa riêng vào màu); critical đổi role sang alert. |
| attribute | `duration` | number | `6000` | Tự đóng sau số ms này; 0 giữ lại; tạm dừng khi hover hoặc focus. |
| attribute | `close-label` | string | `'Close'` | Tên truy cập của nút đóng. |
| event | `click` | MouseEvent | – | Click native của nút đóng, nổi ra ngoài shadow root. |
| event | `chatty-close` | CustomEvent<{reason: timeout, close-button}> | – | Yêu cầu đóng (timeout hoặc close-button); preventDefault giữ toast. |
| slot | default | – | – | Nội dung thông báo. |
| slot | `action` | – | – | Một action tuỳ chọn, ví dụ Undo. |
| slot | `close-icon` | – | – | Icon của nút đóng; mặc định là dấu nhân. |
| part | `base` | – | – | Khung toast. |
| part | `icon` | – | – | Icon đầu dòng theo tone (critical, success, caution); neutral không có. |
| part | `message` | – | – | Vùng chứa thông báo. |
| part | `action` | – | – | Vùng chứa action. |
| part | `close` | – | – | Nút đóng. |
| css-property | `--chatty-toast-background` | – | – | Nền toast. |
| css-property | `--chatty-toast-color` | – | – | Màu chữ toast. |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `CartConfirmation` | @avada/chatty-ui/primitives/CartConfirmation.jsx | .chatty-ai-mode (token màu và type) |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | section có class chatty-cart-confirmation và aria-label từ translate. |
| 2 | Nhãn đầu card, một dòng, chiếm cả hai cột. |
| 3 | Ảnh `img` tùy chọn, alt rỗng; ẩn khi thiếu thumbnail hoặc ảnh lỗi. |
| 4 | Body: title, variant tùy chọn, dòng quantity cùng giá. |
| 5 | Nút View cart tùy chọn, chỉ có khi truyền `onViewCart`. |
### Placement / order
| Context | Order |
| --- | --- |
| Message list | ChatMessage render receipt trong div có data-message-id, thay cho bubble khi message mang cartConfirmation. |
| Trong card | Nhãn, ảnh, rồi body theo thứ tự title, variant, quantity và giá, cuối cùng View cart; khi không có ảnh body chiếm cả hai cột. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `receipt` | object | Dữ liệu một cart-line | Bắt buộc | Component không render (null) khi readCartConfirmation không trả line hợp lệ. |
| `receipts` | array | Nhiều cart-line | undefined | Khi có dòng hợp lệ, render grouped receipt. |
| `showAll` | boolean | true / false | false | Hiện tất cả dòng grouped; mặc định chỉ ba dòng nếu có hơn bốn. |
| `formatMoney` | function | (linePrice, currency) trả chuỗi | Bắt buộc | Kết quả nằm trong `bdi` cạnh quantity. |
| `translate` | function | Hàm dịch theo key | Bắt buộc | Dùng cho nhãn, quantity và View cart. |
| `onViewCart` | function | Click handler | undefined | Truthy mới render nút View cart. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Card | Theo nội dung | 16px (fallback `--chatty-space-400`) | 12px (fallback `--chatty-space-300`) | 20px | body-medium: Derived(15px = type(body-medium, desktop, size)) / Derived(22px = type(body-medium, desktop, line)) desktop, Derived(17px = type(body-medium, mobile, size)) / Derived(24px = type(body-medium, mobile, line)) mobile | Không tương tác | Grid 64px + `minmax(0, 1fr)`; width `min(100%, 360px)` |
| Nhãn, variant, dòng quantity | Theo nội dung | Không có | 4px | Không có | body-small: Derived(14px = type(body-small, desktop, size)) / Derived(20px = type(body-small, desktop, line)) desktop, Derived(15px = type(body-small, mobile, size)) / Derived(22px = type(body-small, mobile, line)) mobile | Không tương tác | Cùng role trên mọi viewport của surface |
| Ảnh | 80px | Không có | Không có | 10px | Không có chữ | Không tương tác | Rộng 64px, `object-fit` cover |
| View cart desktop | min 40px | 8px / 0 | Không khai báo | 6px | Kế thừa `font: inherit` | min 40px | Mặc định |
| View cart mobile | min 44px | Như View cart desktop | Không khai báo | Như View cart desktop | Kế thừa | min 44px | max-width 899px hoặc root mobile của surface |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Card fill | `--chatty-color-bg-surface` | #f6f4f0 | #131215 |
| Text | `--chatty-color-text` | rgba(20,19,24,0.94) | rgba(255,255,255,0.96) |
| Variant text | `--chatty-color-text-secondary` | rgba(20,19,24,0.74) | rgba(255,255,255,0.74) |
| Border | `--chatty-color-border` | rgba(20,19,24,0.08) | rgba(255,255,255,0.12) |
| Ảnh nền | `--chatty-color-bg-surface-secondary` | #f7f7f7 fallback | #f7f7f7 fallback |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Có ảnh | thumbnail hợp lệ | Cột ảnh 64px; ảnh 80px | `img` alt rỗng, trang trí |
| Không ảnh | thiếu thumbnail hoặc `onError` | Thêm class `chatty-cart-confirmation--no-media`; body chiếm cả hai cột | Không đổi |
| Hover View cart | pointer | Gạch chân 2px (từ 1px) | Native button |
| Active View cart | pointer down | Gạch chân 3px | Native button |
| Focus-visible View cart | keyboard | outline 2px solid currentColor, offset 2px | Native focus |
| Không có View cart | `onViewCart` undefined | Nút không render | Không đổi |
### Behaviour
| Interaction | Result |
| --- | --- |
| Click View cart | Gọi `onViewCart` của caller; component không tự mở giỏ. |
| Receipt không hợp lệ | Component trả null, không có card rỗng. |
| Tiêu đề dài | `overflow-wrap` anywhere trong body; giá `white-space` nowrap. |
| Grouped | Tối đa bốn dòng hiện đầy đủ; nếu nhiều hơn, hiện ba dòng và số còn lại. Admin có thể hiện tất cả. |
| Quantity thay đổi | Hiệu ứng đánh dấu kết thúc sau 600ms; reduced motion tắt animation. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Added to cart | Added to cart | Nhãn card và aria-label; caller truyền `t` |
| Quantity in cart | Quantity in cart | Dòng quantity |
| View cart | View cart | Nút View cart |
### Source
| File | Evidence |
| --- | --- |
| | API và DOM |
| | Kích thước và token |
| | Caller AI Mode |
| | Token màu AI Mode |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `CartConfirmation` | @avada/chatty-ui/primitives/CartConfirmation.jsx | .Avada-Faqs_Popup |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | section có class chatty-cart-confirmation và aria-label từ translate. |
| 2 | Nhãn đầu card, một dòng, chiếm cả hai cột. |
| 3 | Ảnh `img` tùy chọn, alt rỗng; ẩn khi thiếu thumbnail hoặc ảnh lỗi. |
| 4 | Body: title, variant tùy chọn, dòng quantity cùng giá. |
| 5 | Nút View cart tùy chọn, chỉ có khi truyền `onViewCart`. |
### Placement / order
| Context | Order |
| --- | --- |
| Inbox block | widgetRegistry gắn block cart-confirmation; khách có thể mở giỏ qua View cart. |
| Trong card | Nhãn, ảnh, rồi body theo thứ tự title, variant, quantity và giá, cuối cùng View cart; khi không có ảnh body chiếm cả hai cột. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `receipt` | object | Dữ liệu một cart-line | Bắt buộc | Component không render (null) khi readCartConfirmation không trả line hợp lệ. |
| `receipts` | array | Nhiều cart-line | undefined | Khi có dòng hợp lệ, render grouped receipt. |
| `showAll` | boolean | true / false | false | Hiện tất cả dòng grouped; mặc định chỉ ba dòng nếu có hơn bốn. |
| `formatMoney` | function | (linePrice, currency) trả chuỗi | Bắt buộc | Kết quả nằm trong `bdi` cạnh quantity. |
| `translate` | function | Hàm dịch theo key | Bắt buộc | Dùng cho nhãn, quantity và View cart. |
| `onViewCart` | function | Click handler | undefined | Truthy mới render nút View cart. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Card | Theo nội dung | 16px (fallback `--chatty-space-400`) | 12px (fallback `--chatty-space-300`) | 12px | body-medium: Derived(15px = type(body-medium, desktop, size)) / Derived(22px = type(body-medium, desktop, line)) desktop, Derived(17px = type(body-medium, mobile, size)) / Derived(24px = type(body-medium, mobile, line)) mobile | Không tương tác | Grid 64px + `minmax(0, 1fr)`; width `min(100%, 360px)` |
| Nhãn, variant, dòng quantity | Theo nội dung | Không có | 4px | Không có | body-small: Derived(14px = type(body-small, desktop, size)) / Derived(20px = type(body-small, desktop, line)) desktop, Derived(15px = type(body-small, mobile, size)) / Derived(22px = type(body-small, mobile, line)) mobile | Không tương tác | Cùng role trên mọi viewport của surface |
| Ảnh | 80px | Không có | Không có | 10px | Không có chữ | Không tương tác | Rộng 64px, `object-fit` cover |
| View cart desktop | min 40px | 8px / 0 | Không khai báo | 6px | Kế thừa `font: inherit` | min 40px | Mặc định |
| View cart mobile | min 44px | Như View cart desktop | Không khai báo | Như View cart desktop | Kế thừa | min 44px | max-width 899px hoặc root mobile của surface |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Card fill | `--chatty-color-bg-surface` | #fff fallback | Theo scope |
| Text | `--chatty-color-text` | #303030 fallback | Theo scope |
| Variant text | `--chatty-color-text-secondary` | #616161 fallback | Theo scope |
| Border | `--chatty-color-border` | #e3e3e3 fallback | Theo scope |
| Ảnh nền | `--chatty-color-bg-surface-secondary` | #f7f7f7 fallback | Theo scope |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Có ảnh | thumbnail hợp lệ | Cột ảnh 64px; ảnh 80px | `img` alt rỗng, trang trí |
| Không ảnh | thiếu thumbnail hoặc `onError` | Thêm class `chatty-cart-confirmation--no-media`; body chiếm cả hai cột | Không đổi |
| Hover View cart | pointer | Gạch chân 2px (từ 1px) | Native button |
| Active View cart | pointer down | Gạch chân 3px | Native button |
| Focus-visible View cart | keyboard | outline 2px solid currentColor, offset 2px | Native focus |
| Không có View cart | `onViewCart` undefined | Nút không render | Không đổi |
### Behaviour
| Interaction | Result |
| --- | --- |
| Click View cart | Gọi `onViewCart` của caller; component không tự mở giỏ. |
| Receipt không hợp lệ | Component trả null, không có card rỗng. |
| Tiêu đề dài | `overflow-wrap` anywhere trong body; giá `white-space` nowrap. |
| Grouped | Tối đa bốn dòng hiện đầy đủ; nếu nhiều hơn, hiện ba dòng và số còn lại. Admin có thể hiện tất cả. |
| Quantity thay đổi | Hiệu ứng đánh dấu kết thúc sau 600ms; reduced motion tắt animation. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Added to cart | Added to cart | Nhãn card và aria-label; caller truyền `i18n` |
| Quantity in cart | Quantity in cart | Dòng quantity |
| View cart | View cart | Nút View cart cho khách |
### Source
| File | Evidence |
| --- | --- |
| | API và DOM |
| | Kích thước và token |
| | Caller inbox |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `CartConfirmation` | @avada/chatty-ui/primitives/CartConfirmation.jsx | .inbox-v2 |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | section có class chatty-cart-confirmation và aria-label từ translate. |
| 2 | Nhãn đầu card, một dòng, chiếm cả hai cột. |
| 3 | Ảnh `img` tùy chọn, alt rỗng; ẩn khi thiếu thumbnail hoặc ảnh lỗi. |
| 4 | Body: title, variant tùy chọn, dòng quantity cùng giá. |
| 5 | Nút View cart tùy chọn, chỉ có khi truyền `onViewCart`. |
### Placement / order
| Context | Order |
| --- | --- |
| Inbox block | widgetRegistry gắn block cart-confirmation; viewer admin nhận receipt không có View cart. |
| Trong card | Nhãn, ảnh, rồi body theo thứ tự title, variant, quantity và giá, cuối cùng View cart; khi không có ảnh body chiếm cả hai cột. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `receipt` | object | Dữ liệu một cart-line | Bắt buộc | Component không render (null) khi readCartConfirmation không trả line hợp lệ. |
| `receipts` | array | Nhiều cart-line | undefined | Khi có dòng hợp lệ, render grouped receipt. |
| `showAll` | boolean | true / false | false | Hiện tất cả dòng grouped; mặc định chỉ ba dòng nếu có hơn bốn. |
| `formatMoney` | function | (linePrice, currency) trả chuỗi | Bắt buộc | Kết quả nằm trong `bdi` cạnh quantity. |
| `translate` | function | Hàm dịch theo key | Bắt buộc | Dùng cho nhãn, quantity và View cart. |
| `onViewCart` | function | Click handler | undefined | Truthy mới render nút View cart. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Card | Theo nội dung | 16px (fallback `--chatty-space-400`) | 12px (fallback `--chatty-space-300`) | 20px | body-medium: Derived(13px = type(body-medium, admin, desktop, size)) / Derived(20px = type(body-medium, admin, desktop, line)) desktop, Derived(15px = type(body-medium, admin, mobile, size)) / Derived(22px = type(body-medium, admin, mobile, line)) mobile | Không tương tác | Grid 64px + `minmax(0, 1fr)`; width `min(100%, 360px)` |
| Nhãn, variant, dòng quantity | Theo nội dung | Không có | 4px | Không có | body-small: Derived(12px = type(body-small, admin, desktop, size)) / Derived(18px = type(body-small, admin, desktop, line)) desktop, Derived(13px = type(body-small, admin, mobile, size)) / Derived(20px = type(body-small, admin, mobile, line)) mobile | Không tương tác | Cùng role trên mọi viewport của surface |
| Ảnh | 80px | Không có | Không có | 10px | Không có chữ | Không tương tác | Rộng 64px, `object-fit` cover |
| View cart desktop | min 40px | 8px / 0 | Không khai báo | 6px | Kế thừa `font: inherit` | min 40px | Mặc định |
| View cart mobile | min 44px | Như View cart desktop | Không khai báo | Như View cart desktop | Kế thừa | min 44px | max-width 899px hoặc root mobile của surface |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Card fill | `--chatty-color-bg-surface` | #fff fallback | No Dark skin |
| Text | `--chatty-color-text` | #303030 fallback | No Dark skin |
| Variant text | `--chatty-color-text-secondary` | #616161 fallback | No Dark skin |
| Border | `--chatty-color-border` | #e3e3e3 fallback | No Dark skin |
| Ảnh nền | `--chatty-color-bg-surface-secondary` | #f7f7f7 fallback | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Có ảnh | thumbnail hợp lệ | Cột ảnh 64px; ảnh 80px | `img` alt rỗng, trang trí |
| Không ảnh | thiếu thumbnail hoặc `onError` | Thêm class `chatty-cart-confirmation--no-media`; body chiếm cả hai cột | Không đổi |
| Hover View cart | pointer | Gạch chân 2px (từ 1px) | Native button |
| Active View cart | pointer down | Gạch chân 3px | Native button |
| Focus-visible View cart | keyboard | outline 2px solid currentColor, offset 2px | Native focus |
| Không có View cart | `onViewCart` undefined | Nút không render | Không đổi |
### Behaviour
| Interaction | Result |
| --- | --- |
| Click View cart | Gọi `onViewCart` của caller; component không tự mở giỏ. |
| Receipt không hợp lệ | Component trả null, không có card rỗng. |
| Tiêu đề dài | `overflow-wrap` anywhere trong body; giá `white-space` nowrap. |
| Grouped | Tối đa bốn dòng hiện đầy đủ; nếu nhiều hơn, hiện ba dòng và số còn lại. Admin có thể hiện tất cả. |
| Quantity thay đổi | Hiệu ứng đánh dấu kết thúc sau 600ms; reduced motion tắt animation. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Added to cart | Added to cart | Nhãn card và aria-label; caller truyền `i18n` |
| Quantity in cart | Quantity in cart | Dòng quantity |
| View cart | View cart | Không render cho viewer admin |
### Source
| File | Evidence |
| --- | --- |
| | API và DOM |
| | Kích thước và token |
| | Caller inbox |
## Do / Don't
Do: hiện receipt sau khi server xác nhận và truyền `onViewCart` chỉ khi người xem sở hữu giỏ.
Don't: báo thành công trước khi có xác nhận, hoặc dựng toast nổi thay cho receipt.
## Accessibility
Contrast đo trên nền card; admin chỉ có Light.
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| AI Mode | Receipt một dòng có aria-label "Added to cart"; ảnh alt rỗng | View cart là native button, outline 2px khi focus-visible | CartThreadStatus thông báo receipt mới qua polite live region | Light text Measured(rgba(20,19,24,0.94) / #f6f4f0 = 14.65:1), variant Measured(rgba(20,19,24,0.74) / #f6f4f0 = 7.58:1); Dark text Measured(rgba(255,255,255,0.96) / #131215 = 17.20:1), variant Measured(rgba(255,255,255,0.74) / #131215 = 10.42:1) |
| Classic | Receipt một dòng có aria-label và ảnh alt rỗng | View cart là nút native | Caller sở hữu thông báo | Theo scope |
| Admin | Receipt một dòng có aria-label "Added to cart"; ảnh alt rỗng | Không có View cart cho viewer admin; còn lại như AI Mode | Không có | Text Measured(#303030 / #ffffff = 13.20:1); variant Measured(#616161 / #ffffff = 6.19:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| AI Mode · Classic | CartConfirmation React trong thread | Not available — new build follows Target. Receipt dùng `chatty-cart-confirmation`; thông báo tạm thời port `chatty-toast` từ mục Standard, chỉ cho storefront. | |
| Admin | Receipt trong thread của inbox | Not available — new build follows Target. Toast của admin giữ App Bridge `shopify.toast`; receipt trong thread dùng `chatty-cart-confirmation`. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
```
- [WCAG — status messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html)
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
- [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements)
---
# Tooltip
Nhắc lại tên hoặc giải thích ngắn cho control; chỉ Classic có HtmlTooltip đang chạy.
## Key rules
- Bọc trigger bằng `HtmlTooltip`; tooltip mở khi chuột vào và đóng khi chuột ra, không mở bằng focus.
- Trigger luôn có tên riêng (`aria-label` hoặc text); tooltip chỉ là lời nhắc, không thay label.
- Tooltip là một dòng, 12px, nền `#fff` (hoặc `#000` khi `isLightMode` false).
- AI Mode, Admin và Admin · Knowledge files không import `HtmlTooltip`; xem Use when / Avoid.
- Element `chatty-tooltip` ở mục Standard là chuẩn chatty-ui port theo; mục Classic mô tả component React đang chạy.
## Use when / Avoid
Dùng cho icon quen thuộc hoặc label bị rút gọn trong widget Classic. Không đặt hướng dẫn bắt buộc, link hay nút trong tooltip: nội dung không nhận pointer và không có điều khiển bàn phím. AI Mode và admin chưa có tooltip dùng chung; nếu cần, xem Target.
### Use instead
| Component | Use when |
| --- | --- |
| `HtmlTooltip` | Nhắc tên icon-only action trong Classic message action. |
| `HtmlTooltip` | Giải thích trạng thái hết hàng trên action của product card. |
| `Button` | Thao tác cần tương tác: dùng Button, không nhúng action vào tooltip. |
## Live preview
Example (Standard) — Element chatty-tooltip đang hiện, phía dưới và phía trên trigger; token chuẩn.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {IconSmile} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-tooltip prototype chatty-ui ports from (chatty-ui/src/elements/tooltip.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/tooltip.js';
export function Standard() {
return html`
EmojiOut of stock
`;
}
```
Example (Current (React), being replaced) — Hover More actions để hiện tooltip; focus không mở tooltip.
```jsx
import React from 'react';
import {HtmlTooltip} from '@avada/chatty-ui/widget/Parts/HtmlTooltip.js';
import {IconButton} from '@avada/chatty-ui/components/icon-button.js';
import {MoreHorizIcon} from '@avada/chatty-ui/icons/MoreHorizIcon.js';
export function Label() {
return ;
}
```
## Standard
Example (Standard) — Element chatty-tooltip đang hiện, phía dưới và phía trên trigger; token chuẩn.
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {IconSmile} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-tooltip prototype chatty-ui ports from (chatty-ui/src/elements/tooltip.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/tooltip.js';
export function Standard() {
return html`
EmojiOut of stock
`;
}
```
Prototype (cùng `tooltip.styles.js`, và ) là chuẩn: chatty-ui port 1:1 các file này, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Element hiện khi hover chuột sau `delay` hoặc ngay khi focus bàn phím, ẩn khi rời, blur, bấm, cuộn hoặc Escape; bong bóng chỉ nhắc lại tên nên ẩn với công nghệ hỗ trợ. Bong bóng không có viền (shadow-2 đã có vòng 1px), chữ body-x-small 13/16 weight 450 theo HtmlTooltip. Chưa surface nào dùng element thật; mục Classic bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-tooltip` | @avada/chatty-ui/elements/tooltip.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `open` | boolean | `false` | Tooltip đang hiện; hover, focus bàn phím và Escape đổi giá trị này. |
| attribute | `placement` | top, bottom | `'bottom'` | Hiện dưới hoặc trên trigger; tự lật khi hết chỗ. |
| attribute | `delay` | number | `350` | Thời gian chờ (ms) trước khi hiện khi hover chuột. |
| slot | default | – | – | Control kích hoạt; giữ tên truy cập riêng. |
| slot | `content` | – | – | Chữ của tooltip. |
| part | `base` | – | – | Bong bóng tooltip trong top layer. |
| css-property | `--chatty-tooltip-max-width` | – | – | Chiều rộng tối đa trước khi chữ xuống dòng. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `HtmlTooltip` | @avada/chatty-ui/widget/Parts/HtmlTooltip | Wrapper `div` của chính component; không dùng portal |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Wrapper `div` inline-flex, position relative, bọc trigger (`children`). |
| 2 | Bong bóng `div` absolute chứa `title`, chỉ render khi mở và có title. |
### Placement / order
| Context | Order |
| --- | --- |
| Placement mặc định | `bottom`: dưới trigger, căn giữa, cách 4px. |
| Các placement khác | `top`, `left`, `right`, `bottom-start`, `bottom-end`, `top-start`, `top-end`, mỗi hướng cách 4px. |
| Message action | Emoji `top`, Reply to `left`, Download `top`; mỗi tooltip bọc một icon. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `title` | node | Nội dung dòng tooltip | Không có | Không render nếu rỗng. |
| `placement` | string | Các giá trị ở Placement / order | `bottom` | Giá trị lạ rơi về nhánh `default` cùng kiểu `bottom`. |
| `isLightMode` | boolean | true / false | `true` | Chọn màu nền, màu chữ và bóng. |
| `open` | boolean | true / false | Không có | Boolean chuyển sang chế độ controlled, bỏ qua hover. |
| `className` | string | CSS class | Không có | Gắn vào wrapper. |
| `style` | object | CSS declarations | Không có | Trộn sau `position` và `display` của wrapper. |
| `children` | ReactNode | Trigger | Không có | Render trước bong bóng. |
| `PopperProps` | object | Caller truyền | Không có | Caller MessageAction truyền prop này nhưng component không khai báo nên bị bỏ qua. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Một kích thước | Theo nội dung | `4px 8px` | Cách trigger 4px qua margin placement | 8px | 12px; fontWeight 450 | `pointerEvents` none, không nhận pointer | Không có override theo viewport |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Nền | `backgroundColor` | #fff | #000 |
| Chữ | `color` | #000 | #fff |
| Bóng | `boxShadow` | 0 2px 8px rgba(0,0,0,0.15) | `none` |
| Lớp | `zIndex` | 999999 | 999999 |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Hover mở | `onMouseEnter` trên wrapper | Bong bóng hiện khi `visible` true | Không có role, id hay aria-describedby |
| Hover đóng | `onMouseLeave` trên wrapper | Bong bóng bị gỡ khỏi DOM | Không thêm ARIA |
| Controlled | `open` là boolean | Hiện theo `open`; handler hover không đổi state | Không thêm ARIA |
| Focus | Không có handler | Not available: không có onFocus / onBlur, focus không mở tooltip | Trigger tự giữ tên riêng |
| Touch / Escape | Không có handler | Not available: không có long-press hay phím Escape | Không thêm ARIA |
### Behaviour
| Interaction | Result |
| --- | --- |
| Dòng đơn | `whiteSpace` nowrap: không xuống dòng; caller tự giữ title ngắn. |
| Pointer | `pointerEvents` none: bong bóng không chặn click vào trigger. |
| Ẩn khi mở picker | Caller Emoji dùng `open` để ẩn tooltip khi picker mở. |
| Tooltip rỗng | Product card truyền `title` undefined khi còn hàng nên không có bong bóng. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Emoji | Emoji | Tooltip của nút emoji |
| Reply to | Reply to | Tooltip của nút trả lời |
| Download | Download | Tooltip của nút tải xuống |
| Out of stock | Out of stock | Tooltip action product card khi hết hàng |
### Source
| File | Evidence |
| --- | --- |
| | API, handlers và style inline |
| | Caller message action |
## Do / Don't
Do: giữ tên riêng cho trigger và giữ `title` ngắn, một dòng.
Don't: dùng tooltip thay label cho action khó đoán, hoặc đặt link và nút trong tooltip.
## Accessibility
Contrast đo trên màu inline của component; theme của merchant không đổi hai màu này.
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Bong bóng không có role, id hay aria-describedby; trigger giữ tên riêng | Hover mở tooltip; focus bàn phím không mở và không có Escape | Không có | Light Measured(#000000 / #ffffff = 21.00:1); `isLightMode` false Measured(#ffffff / #000000 = 21.00:1) |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Classic | Focus bàn phím không mở tooltip; không có Escape | Not in code yet — build with the body values. Thêm `onFocus` / `onBlur` trên wrapper để mở và đóng, giữ nguyên kích thước và vị trí; thêm `id` cho bong bóng cùng `role="tooltip"`, nối trigger bằng `aria-describedby`; Escape đóng tooltip; trạng thái bình thường trở lại khi blur hoặc Escape. | [WCAG — content on hover or focus](https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html) |
| Classic | HtmlTooltip React | Not available — new build follows Target. Port `chatty-tooltip` từ mục Standard; bong bóng ở top layer qua Popover API, mở bằng focus bàn phím và đóng bằng Escape. | |
| Admin | Component Inbox đúng Target chưa ship | Not available — new build follows Target. **Tooltip**: token 2.0: 12px/16px, nền inverse, radius element; mở bằng hover/focus và đóng bằng Esc. Dùng ở Composer tools và nút icon. Không dùng component Polaris trong Inbox; giữ App Bridge cho phần khung embedded. | [Shopify: Built for Shopify requirements](https://shopify.dev/docs/apps/launch/built-for-shopify/requirements) |
```

Ảnh mock đang hiển thị Insert product với chữ 12/18 và radius 6px. Target Inbox là 12/16 và radius element 8px như mẫu giá trị dưới đây; hover/focus/Escape vẫn là yêu cầu triển khai, không claim ảnh chứng minh đã ship.
Example (Current (React), being replaced) — Mẫu giá trị Target Inbox: chữ 12/16, nền inverse và radius element 8px; fixture tĩnh, không phải component đang chạy.
```jsx
import React from 'react';
export function Values() {
return
Target Inbox · mẫu giá trị tĩnh, chưa phải implementation.
Insert product
12/16 · inverse · radius element 8px
;
}
```
- [WCAG — content on hover or focus](https://www.w3.org/WAI/WCAG22/Understanding/content-on-hover-or-focus.html)
- [WAI-ARIA APG — tooltip](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/)
---
# Voice player
Điều khiển phát và transcript của tin nhắn thoại.
## Key rules
- Kiểm tra nguồn trước khi truyền vào player.
- Element `chatty-voice-player` ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
## Use when / Avoid
Dùng cho tệp thoại trong luồng tin nhắn.
### Use instead
| Component | Use when |
| --- | --- |
| `VoicePlayer` | Phát audio đã được caller kiểm tra. |
| `FileCard` | Không phát được và cần hiển thị tệp dự phòng. |
## Live preview
Example (Standard) — Element chatty-voice-player chưa có src: độ dài tạm 0:42, control bị vô hiệu như preview React.
```html
```
Example (Standard) — Element chatty-voice-player chưa có src: độ dài tạm 0:42, control bị vô hiệu như preview React.
```html
```
Example (Standard) — Element chatty-voice-player chưa có src: độ dài tạm 0:42, control bị vô hiệu như preview React.
```html
```
Example (Current (React), being replaced) — Player thật chưa có nguồn audio; không gọi mạng.
```jsx
import React from 'react';
import {AppProvider, Button} from '@shopify/polaris';
import {VoicePlayer} from '@avada/chatty-ui/components';
const source = '';
// Stand-in for DownloadIcon: @shopify/polaris-icons is not in the guide lockfile.
const DownloadIcon = () => (
);
function StorefrontVoicePlayer() {
return (
);
}
function AdminVoicePlayer() {
return (
}
labels={{
play: 'Play voice message',
pause: 'Pause voice message',
seek: 'Seek voice message',
download: 'Download voice message',
speed: 'Playback speed',
position: (current, duration) => `Played ${current} of ${duration}`
}}
/>
);
}
export function Catalogue({surface}) {
if (surface === 'admin') return ;
return ;
}
```
Example (Current (React), being replaced) — Player Admin với nhãn và control tải xuống của inbox.
```jsx
import React from 'react';
import {AppProvider, Button} from '@shopify/polaris';
import {VoicePlayer} from '@avada/chatty-ui/components';
const source = '';
// Stand-in for DownloadIcon: @shopify/polaris-icons is not in the guide lockfile.
const DownloadIcon = () => (
);
function StorefrontVoicePlayer() {
return (
);
}
function AdminVoicePlayer() {
return (
}
labels={{
play: 'Play voice message',
pause: 'Pause voice message',
seek: 'Seek voice message',
download: 'Download voice message',
speed: 'Playback speed',
position: (current, duration) => `Played ${current} of ${duration}`
}}
/>
);
}
export function Catalogue({surface}) {
if (surface === 'admin') return ;
return ;
}
```
Example (Current (React), being replaced) — Player AI Mode thật, không có control tải xuống.
```jsx
import React from 'react';
import {AppProvider, Button} from '@shopify/polaris';
import {VoicePlayer} from '@avada/chatty-ui/components';
const source = '';
// Stand-in for DownloadIcon: @shopify/polaris-icons is not in the guide lockfile.
const DownloadIcon = () => (
);
function StorefrontVoicePlayer() {
return (
);
}
function AdminVoicePlayer() {
return (
}
labels={{
play: 'Play voice message',
pause: 'Pause voice message',
seek: 'Seek voice message',
download: 'Download voice message',
speed: 'Playback speed',
position: (current, duration) => `Played ${current} of ${duration}`
}}
/>
);
}
export function Catalogue({surface}) {
if (surface === 'admin') return ;
return ;
}
```
## Standard
Example (Standard) — Element chatty-voice-player chưa có src: độ dài tạm 0:42, control bị vô hiệu như preview React.
```html
```
Prototype (cùng `voice-player.styles.js`) là chuẩn: chatty-ui port 1:1, và `chatty-ui/custom-elements.json` sinh từ chính prototype. Nhãn đi qua property `.strings`; icon tải về đi qua slot. Chưa surface nào dùng element thật; các mục Classic, AI Mode và Admin bên dưới mô tả React đang chạy.
### Element
| Element | Module |
| --- | --- |
| `chatty-voice-player` | @avada/chatty-ui/elements/voice-player.js |
### API
| Kind | Name | Type | Default | Description |
| --- | --- | --- | --- | --- |
| attribute | `src` | string | `''` | URL audio đã kiểm; rỗng thì các control bị vô hiệu. |
| attribute | `duration` | number | `0` | Độ dài tạm (giây) tới khi audio báo độ dài thật. |
| attribute | `download` | string | `''` | Tên file; có giá trị và có src thì hiện link tải. |
| event | `play` | Event | – | Bắt đầu phát. |
| event | `pause` | Event | – | Dừng hoặc phát hết. |
| event | `click` | MouseEvent | – | Kích hoạt native của nút play, tốc độ. |
| slot | `download-icon` | – | – | Icon của link tải. |
| part | `base` | – | – | Hàng player. |
| part | `play` | – | – | Nút play/pause. |
| part | `track` | – | – | Vùng thanh tua; mũi tên trái/phải tua, Space/Enter phát hoặc dừng. |
| part | `time` | – | – | Thời gian đã phát / độ dài. |
| part | `speed` | – | – | Nút tốc độ, đổi vòng qua các mức. |
| part | `download` | – | – | Link tải. |
| css-property | `--chatty-voice-player-background` | – | – | Nền. |
| css-property | `--chatty-voice-player-color` | – | – | Màu icon và chữ. |
| css-property | `--chatty-voice-player-border-color` | – | – | Màu viền. |
| css-property | `--chatty-voice-player-track` | – | – | Màu phần chưa phát và nền nút tốc độ. |
## Classic
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `VoicePlayer` | @avada/chatty-ui/components | `.Avada-Faqs_Popup` |
| Voice message audio | — | `.Avada-Faqs_Popup` |
| `.Avada-Faq-VoiceMessage` | — | `.Avada-Faq-VoiceMessage` |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Audio ẩn và nút play. |
| 2 | Thanh seek, thời gian, tốc độ và download. |
### Placement / order
| Context | Order |
| --- | --- |
| Voice player | Play, track, timing rồi download. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `src` | string | URL audio đã kiểm tra | Caller | Thiếu nguồn thì nút và seek disabled. |
| `durationSec` | number | Thời lượng dự phòng | 0 | Thay bằng thời lượng đo được. |
| `labels` | object | Nhãn điều khiển | Caller | Cung cấp tên accessible. |
| `downloadControl` | node hoặc false | Control của surface | Caller | False ẩn download. |
| `file` | object | URL và metadata | Caller | Wrapper chỉ truyền URL an toàn vào player. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Player | Tối thiểu 46px; 58px ở mobile/coarse pointer | 6px | 6px | 14px | Kế thừa | Play 32px | Rộng 280px, tối đa theo container |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Foreground | `--voice-player-foreground` | Theo caller | Theo caller |
| Background | `--voice-player-background` | Theo caller | Theo caller |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Không nguồn | src rỗng | Play và seek disabled. | Native disabled |
| Đang phát | playing | Icon và nhãn chuyển sang pause. | aria-label từ caller |
### Behaviour
| Interaction | Result |
| --- | --- |
| Seek bằng phím | Trái hoặc phải tua 5 giây; Enter và Space đổi trạng thái phát. |
| Speed | Chuyển lần lượt giữa các tốc độ. |
| Không phát được | Hiện phản hồi lỗi hoặc trạng thái transcript của wrapper. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Play | Play | Nhãn play do wrapper truyền. |
| Pause | Pause | Nhãn pause do wrapper truyền. |
### Source
| File | Evidence |
| --- | --- |
| | Player API và hành vi |
| | Layout và focus |
| | Lazy import Classic |
| | Caller Classic từ voice block Widget v2 |
| | Props và feedback Classic |
| | Width và minimum height Classic |
## AI Mode
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `VoicePlayer` | @avada/chatty-ui/components | `.chatty-ai-mode` |
| Voice message bubble | — | `.chatty-ai-mode` |
| `.chatty-voice-message` | — | `.chatty-voice-message` |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Audio ẩn và nút play. |
| 2 | Thanh seek, thời gian, tốc độ và download. |
### Placement / order
| Context | Order |
| --- | --- |
| Voice player | Play, track, timing rồi download. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `src` | string | URL audio an toàn | Caller | Wrapper chỉ truyền URL đã kiểm tra. |
| `durationSec` | number | Thời lượng từ file | Caller | Chuyển tiếp vào player. |
| `downloadControl` | false | `false` | `false` | AI Mode ẩn download. |
| `labels` | object | Play, Pause, Seek, Playback speed, position | Caller | Nhãn lấy từ i18n của AI Mode. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Player | Tối thiểu 46px; 58px ở mobile/coarse pointer | 6px | 6px | 14px | Kế thừa | Play 32px | Rộng 280px, tối đa theo container |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Foreground | `--voice-player-foreground` | `var(--vib-1)` | `var(--vib-1)` |
| Background | `--voice-player-background` | `var(--surface-opaque)` | `var(--surface-opaque)` |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Không nguồn | URL không an toàn hoặc thiếu | Không render player; file thường là fallback khi có file. | Không đổi |
| Đang phát | playing | Icon và nhãn chuyển sang pause. | aria-label từ caller |
### Behaviour
| Interaction | Result |
| --- | --- |
| Seek bằng phím | Trái hoặc phải tua 5 giây; Enter và Space đổi trạng thái phát. |
| Speed | Chuyển lần lượt giữa các tốc độ. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Play | Play | Nhãn play do caller truyền. |
| Pause | Pause | Nhãn pause do caller truyền. |
### Source
| File | Evidence |
| --- | --- |
| | Lazy import AI Mode |
| | Caller, props và fallback AI Mode |
| | Caller của attachment block |
| | Player API và hành vi |
## Admin
### Import / element
| Component / element | Import / file | Scope root |
| --- | --- | --- |
| `VoicePlayer` | @avada/chatty-ui/components | .inbox-v2 |
| `VoiceMessageAudio` | @assets/pages/InboxManagement/v2/blocks/VoiceMessageAudio.jsx | .inbox-v2 |
### Anatomy
| Part | Element |
| --- | --- |
| 1 | Audio ẩn và nút play. |
| 2 | Thanh seek, thời gian, tốc độ và download. |
### Placement / order
| Context | Order |
| --- | --- |
| Voice player | Play, track, timing rồi download. |
### Props
| Prop | Type | Values | Default | Notes |
| --- | --- | --- | --- | --- |
| `src` | string | URL audio đã kiểm tra | Caller | Thiếu nguồn thì nút và seek disabled. |
| `durationSec` | number | Thời lượng dự phòng | 0 | Thay bằng thời lượng đo được. |
| `labels` | object | Nhãn điều khiển | Caller | Cung cấp tên accessible. |
| `downloadControl` | node hoặc false | Control của surface | Caller | False ẩn download. |
| `file` | object | URL và metadata | Caller | Wrapper kiểm tra nguồn. |
### Sizes
| Size | Height | Padding | Gap | Radius | Font role (px/rem) | Hit target | Breakpoint / mechanism |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Player | Theo nội dung | 6px | 6px | 14px | Kế thừa | Play 32px | Rộng theo container |
| Inbox wrapper | Theo nội dung | Framed 8px 12px | 4px | Theo bubble | body-medium khi framed | Theo player | Rộng 320px, tối đa theo container |
### Tokens
| Part | Token | Light | Dark |
| --- | --- | --- | --- |
| Foreground | `--voice-player-foreground` | Theo caller | No Dark skin |
| Background | `--voice-player-background` | Theo caller | No Dark skin |
### States
| State | Trigger | Visual change (values) | ARIA/attribute |
| --- | --- | --- | --- |
| Không nguồn | src rỗng | Play và seek disabled. | Native disabled |
| Đang phát | playing | Icon và nhãn chuyển sang pause. | aria-label từ caller |
### Behaviour
| Interaction | Result |
| --- | --- |
| Seek bằng phím | Trái hoặc phải tua 5 giây; Enter và Space đổi trạng thái phát. |
| Speed | Chuyển lần lượt giữa các tốc độ. |
| Không phát được | Wrapper có thể hiện file dự phòng. |
### Copy
| String | i18n key | Where |
| --- | --- | --- |
| Play voice message | Play voice message | Nhãn play do wrapper truyền. |
| Pause voice message | Pause voice message | Nhãn pause do wrapper truyền. |
### Source
| File | Evidence |
| --- | --- |
| | Player API và hành vi |
| | Layout và focus |
| | Kiểm tra nguồn và caller |
## Do / Don't
Do: truyền nhãn điều khiển theo ngôn ngữ của caller.
Don't: bỏ qua bước kiểm tra nguồn audio.
## Accessibility
| Surface | Role / name | Keyboard / focus | Live region | Contrast pair / ratio |
| --- | --- | --- | --- | --- |
| Classic | Play button và slider có nhãn từ caller | Tab, Enter, Space và phím mũi tên | Không có live region | Theo token caller |
| Admin | Play button và slider có nhãn từ caller | Tab, Enter, Space và phím mũi tên | Không có live region | Theo token caller |
## Target
```target
| Surface | Now | Target | Source |
| --- | --- | --- | --- |
| Classic · AI Mode · Admin | VoicePlayer React | Not available — new build follows Target. Element (dự kiến): `chatty-voice-player` đọc attribute `src`, giữ trạng thái phát nội bộ, event `play` / `pause`. | [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) |
| Classic · AI Mode · Admin | Component React theo surface | Not available — new build follows Target. Port `chatty-voice-player` từ mục Standard rồi chuyển caller từng surface. | |
```
- [MDN: Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
---
# chatty-ad-referral
API chuẩn của element chatty-ad-referral, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-ad-referral` khai báo 5 attribute, 0 property không có attribute, 2 event, 3 slot, 6 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/ad-referral.js` là define `chatty-ad-referral`; 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
The ad a customer came from, as a preview card above their first bubble in the inbox. The caption clamps to two lines; the chevron expands the caption and the details (media, product). Class `ChattyAdReferral`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `heading` | `heading` | `string` | `''` | Channel label, e.g. `Facebook ad`, `Instagram ad`, `Clicked your ad`. |
| `href` | `href` | `string` | `''` | Public post URL; http(s) only, otherwise the link is hidden. |
| `link-label` | `linkLabel` | `string` | `'View post'` | Text of the view-post link. |
| `toggle-label` | `toggleLabel` | `string` | `'Ad details'` | Accessible name of the chevron. |
| `expanded` | `expanded` | `boolean` | `false` | Shows the full caption and the details; hides the thumbnail. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `toggle` | `Event` | `expanded` changed from the chevron. |
| `click` | `MouseEvent` | Native activation of the toggle. |
### Slots
| Name | Description |
| --- | --- |
| default | Caption: ad title and body. |
| `thumb` | 48px thumbnail, hidden while expanded. |
| `details` | Media and product shown while expanded. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Card container. |
| `label` | Channel label, e.g. `Facebook ad`. |
| `link` | View-post link. |
| `caption` | Clamped caption. |
| `toggle` | Expand button. |
| `details` | Expanded details wrapper. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-ad-referral-radius` | – | Corner radius. |
| `--chatty-ad-referral-background` | – | Background. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/ad-referral.js';
```
```html
Summer collection Explore our collection
Canvas tote bag Carry everything, every day.
```
## 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
Summer collection Explore our collection
Canvas tote bag Carry everything, every day.
```
Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
```html
Canvas tote bag Carry everything, every day.
```
## 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
Summer collection Explore our collection
Canvas tote bag Carry everything, every day.
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `label` | chatty-ui/custom-elements.json |
| 3 | CSS part `link` | chatty-ui/custom-elements.json |
| 4 | CSS part `caption` | chatty-ui/custom-elements.json |
| 5 | CSS part `toggle` | chatty-ui/custom-elements.json |
| 6 | CSS part `details` | chatty-ui/custom-elements.json |
## Keyboard
| Key | Action |
| --- | --- |
| Enter / Space | Toggle details; Enter follows the link. |
### Source
- chatty-ui/custom-elements.json
---
# 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
```
## 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
```
## 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
```
| 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
---
# chatty-avatar
API chuẩn của element chatty-avatar, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-avatar` khai báo 3 attribute, 0 property không có attribute, 0 event, 1 slot, 2 part và 3 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/avatar.js` là define `chatty-avatar`; 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
A fixed round frame for an image, initials or a small icon passed through the slot. Class `ChattyAvatar`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `size` | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Frame size: 24, 36 or 48px; md matches the React default. |
| `label` | `label` | `string` | `''` | Accessible name for initials (role img); for an image use the img alt instead. |
| `status` | `status` | `'online' \| 'offline' \| 'break' \| 'holiday' \| null` | `null` | Availability resolved by the host; null hides the presence mark. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
Not declared in the manifest.
### Slots
| Name | Description |
| --- | --- |
| default | An img (cover-fitted) or fallback initials/icon. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Round frame. |
| `status` | Availability dot; absent when status is null. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-avatar-size` | – | Frame width and height; overrides size. |
| `--chatty-avatar-radius` | – | Corner radius; round by default. |
| `--chatty-avatar-background` | – | Fallback background behind initials. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/avatar.js';
```
```html
ALALAL
```
## 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
ALALAL
```
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';
// Standard: the chatty-avatar prototype chatty-ui ports from (chatty-ui/src/elements/avatar.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/avatar.js';
export function Status() {
return html`${['online', 'offline', 'break', 'holiday', null].map(status => html`S`)}`;
}
```
## 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
ALALAL
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `status` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-badge
API chuẩn của element chatty-badge, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-badge` khai báo 3 attribute, 0 property không có attribute, 0 event, 1 slot, 1 part và 3 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/badge.js` là define `chatty-badge`; 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
A short, non-interactive status label; the meaning lives in the text, the tone only repeats it. Class `ChattyBadge`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `variant` | `variant` | `'primary' \| 'secondary' \| 'tertiary'` | `'primary'` | primary = solid tone fill, secondary = subtle fill, tertiary = outline. |
| `tone` | `tone` | `'neutral' \| 'critical' \| 'success' \| 'caution'` | `'neutral'` | Colour by meaning; the text must still state the status. |
| `size` | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | sm is the admin 20px badge; md and lg grow text and padding. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
Not declared in the manifest.
### Slots
| Name | Description |
| --- | --- |
| default | Label text. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Pill box. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-badge-background` | – | Background scoped by variant and tone. |
| `--chatty-badge-color` | – | Text colour scoped by variant and tone. |
| `--chatty-badge-radius` | – | Corner radius. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/badge.js';
```
```html
NewDraftCovered3OpenFailedSyncedPendingActiveNot covered
```
## 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
NewDraftCovered3OpenFailedSyncedPendingActiveNot covered
```
Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
```html
DraftCoveredPendingNot covered
```
## 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
NewDraftCovered3OpenFailedSyncedPendingActiveNot covered
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-block-answer-error
API chuẩn của element chatty-block-answer-error, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-answer-error` khai báo 1 attribute, 0 property không có attribute, 1 event, 0 slot, 0 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-answer-error.js` là define `chatty-block-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
Opt-in in-message answer error; retry remains owned by the host. Class `ChattyBlockAnswerError`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Canonical data.loading blocks repeated retries. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-retry` | `CustomEvent<{}>` | Answer retry 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 '@avada/chatty-ui/elements/chatty-block-answer-error.js';
```
```html
```
## 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
```
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-answer-error.js';
export function States() {
return html``;
}
```
## 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
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | Element host `chatty-block-answer-error` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-block-cart-confirmation
API chuẩn của element chatty-block-cart-confirmation, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-cart-confirmation` khai báo 1 attribute, 1 property không có attribute, 1 event, 0 slot, 1 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-cart-confirmation.js` là define `chatty-block-cart-confirmation`; 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
Canonical cart lines adapted to the existing grouped receipt. Class `ChattyBlockCartConfirmation`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Canonical data.receipts (legacy receipts/receipt accepted) with title, quantity, linePrice, currency and optional variant/thumbnail. |
### Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `strings` | `object` | `{}` | Translated receipt heading and quantity labels. |
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-view-cart` | `CustomEvent<{}>` | Host-owned bag requested. |
### Slots
Not declared in the manifest.
### Parts
| Name | Description |
| --- | --- |
| `base` | Grouped receipt. |
### CSS custom properties
Not declared in the manifest.
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/chatty-block-cart-confirmation.js';
```
```html
```
## 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
```
## 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
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# 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``;
}
```
## 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``;
}
```
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`
`;
}
```
## 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``;
}
```
| 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
---
# chatty-block-contact-methods
API chuẩn của element chatty-block-contact-methods, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-contact-methods` khai báo 1 attribute, 0 property không có attribute, 1 event, 0 slot, 0 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-contact-methods.js` là define `chatty-block-contact-methods`; 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 Classic contact entry list; the host selects the next contact step. Class `ChattyBlockContactMethods`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Canonical data.methods containing id and label. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-contact` | `CustomEvent<{method: string}>` | Chosen contact method. |
### 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-methods.js';
export function Standard() {
return html``;
}
```
## 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-methods.js';
export function Standard() {
return html``;
}
```
## 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-methods.js';
export function Standard() {
return html``;
}
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | Element host `chatty-block-contact-methods` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-block-email-verify
API chuẩn của element chatty-block-email-verify, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-email-verify` khai báo 1 attribute, 1 property không có attribute, 1 event, 0 slot, 2 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-email-verify.js` là define `chatty-block-email-verify`; 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 order email verification with one scoped error shared by description and announcement. Class `ChattyBlockEmailVerify`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Canonical data with number, loading, mismatch and translated mismatchText. |
### Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `email` | `string` | `''` | Current email draft, retained after mismatch. |
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-verify` | `CustomEvent<{email: string, number: string}>` | Valid email to verify. |
### Slots
Not declared in the manifest.
### Parts
| Name | Description |
| --- | --- |
| `control` | Email input. |
| `error` | Single mismatch announcement below the field. |
### 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-email-verify.js';
export function Standard() {
return html``;
}
```
## 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-email-verify.js';
export function Standard() {
return html``;
}
```
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-email-verify.js';
export function States() {
return html`
`;
}
```
## 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-email-verify.js';
export function Standard() {
return html``;
}
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `control` | chatty-ui/custom-elements.json |
| 2 | CSS part `error` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-block-product
API chuẩn của element chatty-block-product, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-product` khai báo 1 attribute, 0 property không có attribute, 1 event, 0 slot, 1 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-product.js` là define `chatty-block-product`; 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
Canonical product data adapted to the existing product card. Class `ChattyBlockProduct`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Product block with title, price and optional image. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-open` | `CustomEvent<{}>` | Product activation forwarded by the card. |
### Slots
Not declared in the manifest.
### Parts
| Name | Description |
| --- | --- |
| `base` | Product block container. |
### CSS custom properties
Not declared in the manifest.
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/chatty-block-product.js';
```
```html
```
## 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
```
## 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
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-block-products
API chuẩn của element chatty-block-products, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-products` khai báo 1 attribute, 1 property không có attribute, 1 event, 0 slot, 1 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-products.js` là define `chatty-block-products`; 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
React products block adapted to the house carousel and card action slot. Class `ChattyBlockProducts`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Canonical data.products and messageId; products carry cartState (loading/added/error), cartError, available and formatted compareAtPrice. |
### Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `strings` | `object` | `{}` | Translated carousel and action labels. |
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-add-to-cart` | `CustomEvent<{product: Object, messageId: string}>` | Host-owned cart mutation requested. |
### Slots
Not declared in the manifest.
### Parts
| Name | Description |
| --- | --- |
| `base` | Full-column carousel. |
### 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-products.js';
export function Standard() {
return html`
`;
}
```
## 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-products.js';
export function Standard() {
return html`
`;
}
```
## 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-products.js';
export function Standard() {
return html`
`;
}
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-block-suggestions
API chuẩn của element chatty-block-suggestions, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-suggestions` khai báo 1 attribute, 0 property không có attribute, 1 event, 0 slot, 1 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chatty-block-suggestions.js` là define `chatty-block-suggestions`; 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
Host-owned suggestion text; connect chatty-suggest to composer.send(text). Class `ChattyBlockSuggestions`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Suggestion block with data.suggestions text strings; data.layout row stacks conversation starters. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-suggest` | `CustomEvent<{text: string}>` | Suggestion selected by pointer or keyboard. |
### Slots
Not declared in the manifest.
### Parts
| Name | Description |
| --- | --- |
| `base` | Wrapping suggestion actions. |
### 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-suggestions.js';
import '@avada/chatty-ui/elements/composer.js';
export function Standard() {
return html`
`;
}
```
## 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-suggestions.js';
import '@avada/chatty-ui/elements/composer.js';
export function Standard() {
return html`
`;
}
```
## 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-suggestions.js';
import '@avada/chatty-ui/elements/composer.js';
export function Standard() {
return html`
`;
}
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-block-survey
API chuẩn của element chatty-block-survey, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-block-survey` khai báo 1 attribute, 0 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-survey.js` là define `chatty-block-survey`; 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 canonical survey adapter; submission and skipping bubble to the host. Class `ChattyBlockSurvey`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `block` | `block` | `object` | `{}` | Canonical data with rating, comment, busy, submitted and error. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-submit` | `CustomEvent<{rating: number, comment: string}>` | Host-owned rating save. |
| `chatty-skip` | `CustomEvent<{}>` | Host-owned survey dismissal. |
### 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 '@avada/chatty-ui/elements/chatty-block-survey.js';
```
```html
```
## 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
```
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-survey.js';
export function States() {
return html`
`;
}
```
## 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
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | Element host `chatty-block-survey` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-button
API chuẩn của element chatty-button, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-button` khai báo 8 attribute, 0 property không có attribute, 1 event, 3 slot, 4 part và 10 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/button.js` là define `chatty-button`; 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
A form-associated action or link with an inherited semantic theme. Class `ChattyButton`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `variant` | `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'plain'` | `'secondary'` | Visual emphasis of the action. |
| `tone` | `tone` | `'neutral' \| 'critical' \| 'success' \| 'caution'` | `'neutral'` | Semantic action tone. |
| `size` | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Control size. |
| `disabled` | `disabled` | `boolean` | `false` | Blocks activation while keeping the control focusable. |
| `loading` | `loading` | `boolean` | `false` | Shows progress and blocks activation. |
| `href` | `href` | `string` | `''` | Link destination; only http, https, mailto and tel are allowed. |
| `label` | `label` | `string` | `''` | Accessible name; defaults to the slotted label. |
| `type` | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Form activation behavior. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `click` | `MouseEvent` | Native activation; detail is the native click count. |
### Slots
| Name | Description |
| --- | --- |
| default | Button label. |
| `start` | Leading content. |
| `end` | Trailing content. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Native interactive control. |
| `label` | Label content. |
| `start` | Leading content wrapper. |
| `end` | Trailing content wrapper. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-button-radius` | – | Corner radius. |
| `--chatty-button-plain-bg-hover` | – | Plain hover/pressed fill; inherits tertiary fill when unset. |
| `--chatty-button-plain-decoration-hover` | – | Plain interaction decoration; inherits base decoration when unset. |
| `--chatty-button-plain-focus-radius` | – | Plain focus radius; inherits the base radius when unset. |
| `--chatty-button-background` | – | Background scoped by variant and tone. |
| `--chatty-button-color` | – | Text colour scoped by variant and tone. |
| `--chatty-button-border-color` | – | Border colour scoped by variant and tone. |
| `--chatty-button-height` | – | Control height; Classic uses a fixed box. |
| `--chatty-button-padding-inline` | – | Inline padding. |
| `--chatty-button-width` | `auto` | Control width; `100%` fills the container. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/button.js';
```
```html
Send
```
## 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
Send
```
Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
```html
Button variants and sizes
SendCancelSkipView orderSmallLargeDeleteConfirm
```
Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
```html
```
## 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
Send
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `label` | chatty-ui/custom-elements.json |
| 3 | CSS part `start` | chatty-ui/custom-elements.json |
| 4 | CSS part `end` | chatty-ui/custom-elements.json |
## Keyboard
| Key | Action |
| --- | --- |
| Enter / Space | Activate the action or link. |
### Source
- chatty-ui/custom-elements.json
---
# chatty-card
API chuẩn của element chatty-card, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-card` khai báo 0 attribute, 0 property không có attribute, 0 event, 3 slot, 4 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/card.js` là define `chatty-card`; 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
A raised surface grouping related content. Header and footer rows collapse when nothing is slotted into them. Not interactive: put a link or button inside for actions. Class `ChattyCard`.
### Attributes
Not declared in the manifest.
### Properties
Not declared in the manifest.
### Events
Not declared in the manifest.
### Slots
| Name | Description |
| --- | --- |
| default | Card body. |
| `header` | Title and subtitle row. |
| `footer` | Actions row. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Card box. |
| `header` | Header wrapper. |
| `body` | Body wrapper. |
| `footer` | Footer wrapper. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-card-padding` | – | Inner padding of every row. |
| `--chatty-card-radius` | – | Corner radius. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/card.js';
import '@avada/chatty-ui/elements/button.js';
```
```html
Order #1024
Placed on 12 Nov · 2 items · Shipped
Track orderView detailsA body-only card: header and footer rows collapse when empty.
```
## 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
Order #1024
Placed on 12 Nov · 2 items · Shipped
Track orderView detailsA body-only card: header and footer rows collapse when empty.
```
## 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
Order #1024
Placed on 12 Nov · 2 items · Shipped
Track orderView detailsA body-only card: header and footer rows collapse when empty.
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `header` | chatty-ui/custom-elements.json |
| 3 | CSS part `body` | chatty-ui/custom-elements.json |
| 4 | CSS part `footer` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-carousel-dots
API chuẩn của element chatty-carousel-dots, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-carousel-dots` khai báo 2 attribute, 0 property không có attribute, 0 event, 0 slot, 3 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/carousel-dots.js` là define `chatty-carousel-dots`; 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
Decorative position marks under a carousel: `count` dots, the one at `active` stretched. Hidden from assistive technology; the carousel itself names the position and owns the controls. Class `ChattyCarouselDots`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `count` | `count` | `number` | `0` | Number of dots (slides). |
| `active` | `active` | `number` | `0` | Zero-based index of the current slide; it draws the wide dot. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
Not declared in the manifest.
### Slots
Not declared in the manifest.
### Parts
| Name | Description |
| --- | --- |
| `base` | Dot row. |
| `dot` | Each dot; the active one also has part active. |
| `active` | The active dot. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-carousel-dots-color` | – | Dot ink; inactive dots mix it at 24%. |
| `--chatty-carousel-dots-active-width` | – | Width of the active dot. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/carousel-dots.js';
```
```html
```
## 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
```
## 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
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `dot` | chatty-ui/custom-elements.json |
| 3 | CSS part `active` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-cart-confirmation
API chuẩn của element chatty-cart-confirmation, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-cart-confirmation` khai báo 6 attribute, 0 property không có attribute, 0 event, 6 slot, 4 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/cart-confirmation.js` là define `chatty-cart-confirmation`; 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
Receipt for one cart line or a group added together, with quantity pulses and an optional view-cart action. Class `ChattyCartConfirmation`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `heading` | `heading` | `string` | `'Added to cart'` | Heading and accessible name of the receipt. |
| `grouped` | `grouped` | `boolean` | `false` | One receipt for the cart-confirmation children in the items slot. |
| `show-all` | `showAll` | `boolean` | `false` | Show every grouped line (admin history); storefront shows three when there are more than four. |
| `quantity` | `quantity` | `number \| undefined` | `undefined` | quantity now in the cart |
| `quantity-label` | `quantityLabel` | `string` | `'Quantity in cart'` | Label before the quantity, e.g. `Quantity in cart`. |
| `price` | `price` | `string` | `''` | Formatted line price, e.g. `$48.00`. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
Not declared in the manifest.
### Slots
| Name | Description |
| --- | --- |
| default | Product title for a single-line receipt. |
| `items` | Cart confirmation lines added together; use grouped with this slot. |
| `more` | Localized overflow summary when more than four lines are collapsed. |
| `media` | Thumbnail, 64 × 80 for a single receipt or 40 × 50 in a group; omit for text-only. |
| `detail` | Variant line, e.g. `Size M / Blue`. |
| `action` | View-cart action, usually a plain `chatty-button`. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Receipt section. |
| `label` | Heading line. |
| `media` | Thumbnail wrapper. |
| `line` | Quantity and price row. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-cart-confirmation-radius` | – | Corner radius. |
| `--chatty-cart-confirmation-background` | – | Background. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/cart-confirmation.js';
import '@avada/chatty-ui/elements/button.js';
```
```html
Canvas tote bag
Natural / LargeView cartCeramic mug
```
## 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
Canvas tote bag
Natural / LargeView cartCeramic mug
```
Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
```html
Canvas tote bagNatural / LargeCeramic mugWool capLinen scarfLeather walletand 2 more products — view in cartView cart
```
## 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
Canvas tote bag
Natural / LargeView cartCeramic mug
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `label` | chatty-ui/custom-elements.json |
| 3 | CSS part `media` | chatty-ui/custom-elements.json |
| 4 | CSS part `line` | chatty-ui/custom-elements.json |
## Keyboard
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-cart-notice
API chuẩn của element chatty-cart-notice, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-cart-notice` khai báo 2 attribute, 0 property không có attribute, 0 event, 4 slot, 3 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/cart-notice.js` là define `chatty-cart-notice`; 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
Cart outcome without a readable quantity or price: added, or could not add with a reason. Class `ChattyCartNotice`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `tone` | `tone` | `'success' \| 'critical'` | `'success'` | success = added, critical = could not add |
| `heading` | `heading` | `string` | `''` | Heading; empty uses `Added to cart` or `Could not add to cart` by tone. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
Not declared in the manifest.
### Slots
| Name | Description |
| --- | --- |
| default | Product title. |
| `icon` | 20px status icon (check when added, alert when failed). |
| `detail` | Failure reason, e.g. `Sold out`. |
| `action` | View-cart action, usually a plain `chatty-button`; only for an added notice. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Notice section. |
| `icon` | Icon wrapper. |
| `label` | Heading line. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-cart-notice-radius` | – | Corner radius. |
| `--chatty-cart-notice-background` | – | Background. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import {IconAlertCircle, IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-cart-notice prototype chatty-ui ports from (chatty-ui/src/elements/cart-notice.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/cart-notice.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
${IconCheck({slot: 'icon'})} Cotton shirt
View cart
${IconAlertCircle({slot: 'icon'})} Cotton shirt
Sold out
`;
}
```
## 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 {IconAlertCircle, IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-cart-notice prototype chatty-ui ports from (chatty-ui/src/elements/cart-notice.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/cart-notice.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
${IconCheck({slot: 'icon'})} Cotton shirt
View cart
${IconAlertCircle({slot: 'icon'})} Cotton shirt
Sold out
`;
}
```
## 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 {IconAlertCircle, IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-cart-notice prototype chatty-ui ports from (chatty-ui/src/elements/cart-notice.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/cart-notice.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
${IconCheck({slot: 'icon'})} Cotton shirt
View cart
${IconAlertCircle({slot: 'icon'})} Cotton shirt
Sold out
`;
}
```
| 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
No element-specific keys.
### Source
- chatty-ui/custom-elements.json
---
# chatty-checkbox
API chuẩn của element chatty-checkbox, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-checkbox` khai báo 8 attribute, 0 property không có attribute, 1 event, 1 slot, 3 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/checkbox.js` là define `chatty-checkbox`; 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
A form-associated checkbox with its own label; submits value while checked. Class `ChattyCheckbox`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `checked` | `checked` | `boolean` | `false` | Checked state; the checked attribute is the default restored by form reset. |
| `disabled` | `disabled` | `boolean` | `false` | Disables the box; not submitted. |
| `required` | `required` | `boolean` | `false` | Must be checked for the form to be valid. |
| `name` | `name` | `string` | `''` | Form field name. |
| `value` | `value` | `string` | `'on'` | Submitted value while checked. |
| `label` | `label` | `string` | `''` | Label text when the default slot is empty. |
| `label-hidden` | `labelHidden` | `boolean` | `false` | Hides the label visually; it stays the accessible name. |
| `size` | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Box size: 16, 20 or 24px. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `change` | `Event` | Checked state changed by the user, re-dispatched from the host. |
### Slots
| Name | Description |
| --- | --- |
| default | Label content; falls back to the label attribute. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Label wrapper (box and text). |
| `control` | Native checkbox input. |
| `label` | Label text. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-checkbox-size` | – | Box size; overrides size. |
| `--chatty-checkbox-checked-color` | – | Box fill while checked; defaults to the accent. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/checkbox.js';
```
```html
Subscribe to updates
```
## 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
Subscribe to updates
```
Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
```html
```
## 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
Subscribe to updates
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `control` | chatty-ui/custom-elements.json |
| 3 | CSS part `label` | chatty-ui/custom-elements.json |
## Keyboard
| Key | Action |
| --- | --- |
| Space | Toggle the checkbox. |
### Source
- chatty-ui/custom-elements.json
---
# chatty-chip
API chuẩn của element chatty-chip, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-chip` khai báo 4 attribute, 0 property không có attribute, 2 event, 2 slot, 3 part và 3 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/chip.js` là define `chatty-chip`; 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
A compact value pill (an active filter); removable chips add a remove button. Class `ChattyChip`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `variant` | `variant` | `'secondary' \| 'tertiary'` | `'tertiary'` | tertiary = outlined (default, suggestions and filters); secondary = filled, the selected look. |
| `size` | `size` | `'sm' \| 'md'` | `'md'` | sm is the admin 20px tag; md is the storefront chip. |
| `removable` | `removable` | `boolean` | `false` | Adds a remove button that fires chatty-remove. |
| `remove-label` | `removeLabel` | `string` | `'Remove'` | Accessible name of the remove button. |
### Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-remove` | `CustomEvent` | The remove button was activated; the host removes the chip. |
| `click` | `MouseEvent` | Native click, retargeted to the host; the remove button also fires chatty-remove. |
### Slots
| Name | Description |
| --- | --- |
| default | Chip text. |
| `remove-icon` | Replaces the default × glyph of the remove button. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Pill box. |
| `label` | Text wrapper. |
| `remove` | Native remove button. |
### CSS custom properties
| Name | Default | Description |
| --- | --- | --- |
| `--chatty-chip-background` | – | Background scoped by variant (secondary = filled, the selected look). |
| `--chatty-chip-color` | – | Text colour. |
| `--chatty-chip-radius` | – | Corner radius. |
## Usage
```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/chip.js';
```
```html
ShippingReturnsSelectedOrdersWebsite
```
## 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
ShippingReturnsSelectedOrdersWebsite
```
Example (Standard) — Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
```html
PDFWebsiteCovered
```
## 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
ShippingReturnsSelectedOrdersWebsite
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `label` | chatty-ui/custom-elements.json |
| 3 | CSS part `remove` | chatty-ui/custom-elements.json |
## Keyboard
| Key | Action |
| --- | --- |
| Enter / Space | Activate the remove button when removable. |
### Source
- chatty-ui/custom-elements.json
---
# chatty-composer
API chuẩn của element chatty-composer, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-composer` khai báo 7 attribute, 1 property không có attribute, 2 event, 2 slot, 3 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/composer.js` là define `chatty-composer`; 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
Form-associated chat input; the host owns sending and attachment upload. Class `ChattyComposer`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `value` | `value` | `string` | `''` | Draft text and form value. |
| `name` | `name` | `string` | `'message'` | Name used by the enclosing form. |
| `label` | `label` | `string` | `'Message'` | Accessible input label. |
| `send-label` | `sendLabel` | `string` | `'Send'` | Translated send button text. |
| `placeholder` | `placeholder` | `string` | `'Write a message…'` | Optional draft hint. |
| `disabled` | `disabled` | `boolean` | `false` | Prevents edits and submission while pending. |
| `sending` | `sending` | `boolean` | `false` | Host-owned send in progress; retains and dims the draft without dropping focus. |
### Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `attachments` | `array` | `[]` | Attachment descriptors supplied by the host. |
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-send` | `CustomEvent<{text: string, attachments: Array}>` | Nonempty submission; cancel to retain the draft. |
| `click` | `MouseEvent` | Native send button click. |
### Slots
| Name | Description |
| --- | --- |
| `toolbar` | Suggestion or prefill actions before the typing row. |
| `attachments` | Selected attachment previews. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Composer container. |
| `control` | Textarea. |
| `send` | Send button. |
### 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/composer.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent = `Sent: ${event.detail.text}`;
}}
>
event.currentTarget.closest('chatty-composer').send('Track my order')}
>Track my order
`;
}
```
## 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/composer.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent = `Sent: ${event.detail.text}`;
}}
>
event.currentTarget.closest('chatty-composer').send('Track my order')}
>Track my order
`;
}
```
## 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/composer.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent = `Sent: ${event.detail.text}`;
}}
>
event.currentTarget.closest('chatty-composer').send('Track my order')}
>Track my order
`;
}
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `control` | chatty-ui/custom-elements.json |
| 3 | CSS part `send` | chatty-ui/custom-elements.json |
## Keyboard
| Key | Action |
| --- | --- |
| Enter | Send a nonempty draft; IME composition does not send. |
| Shift+Enter | Insert a new line. |
### Source
- chatty-ui/custom-elements.json
---
# chatty-contact-form
API chuẩn của element chatty-contact-form, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-contact-form` khai báo 5 attribute, 4 property không có attribute, 3 event, 1 slot, 3 part và 0 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/contact-form.js` là define `chatty-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
Validates contact details locally; the host owns persistence and pending state. Class `ChattyContactForm`.
### Attributes
| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `fields` | `fields` | `array` | `['email']` | Ordered field names or descriptors; payloadKey defaults to key. Descriptors have key, label, optional type (text/email/tel/textarea), required, payloadKey and placeholder. |
| `description` | `description` | `string` | `'Where can we reply?'` | Form purpose shown before the fields. |
| `loading` | `loading` | `boolean` | `false` | Keeps fields focusable and read-only while the host request is pending. |
| `skippable` | `skippable` | `boolean` | `false` | Shows the anonymous option. |
| `error` | `error` | `string` | `''` | Host request error. |
### Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `values` | `object` | `{}` | Contact values keyed by each field’s payloadKey. |
| `required` | `object` | `{email: true}` | Per-field required flags. |
| `strings` | `object` | `{ email: 'Email address', name: 'Name', phone: 'Phone number', submit: 'Continue', skip: 'Chat anonymously', invalidEmail: 'Enter a valid email address.', invalidPhone: 'Enter a valid phone number.', requiredEmail: 'Enter your email address.', requiredName: 'Enter your name.', requiredPhone: 'Enter your phone number.', requiredField: 'Complete this field.' }` | Translated field, action and validation labels. |
| `skipping` | `boolean` | `false` | Host-owned anonymous request pending; blocks repeated submit and skip. |
### Events
| Name | Detail type | Description |
| --- | --- | --- |
| `chatty-submit` | `CustomEvent<{values: Object}>` | Valid contact values. |
| `chatty-skip` | `CustomEvent<{}>` | Anonymous chat requested. |
| `click` | `MouseEvent` | Native contact action click. |
### Slots
| Name | Description |
| --- | --- |
| `privacy` | Privacy explanation under contact fields. |
### Parts
| Name | Description |
| --- | --- |
| `base` | Contact form. |
| `error` | Inline field or host error. |
| `submit` | Submit button. |
### 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/contact-form.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent =
`Received: ${event.detail.values.email}`;
}}
>
Your email is used to reply to this conversation.
`;
}
```
## 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/contact-form.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent =
`Received: ${event.detail.values.email}`;
}}
>
Your email is used to reply to this conversation.
`;
}
```
## 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/contact-form.js';
export function Standard() {
return html`
{
event.currentTarget.querySelector('[role=status]').textContent =
`Received: ${event.detail.values.email}`;
}}
>
Your email is used to reply to this conversation.
`;
}
```
| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |
| 2 | CSS part `error` | chatty-ui/custom-elements.json |
| 3 | CSS part `submit` | chatty-ui/custom-elements.json |
## Keyboard
| Key | Action |
| --- | --- |
| Enter | Validate and submit the contact fields; IME composition does not submit. |
### Source
- chatty-ui/custom-elements.json
---
# chatty-dialog
API chuẩn của element chatty-dialog, sinh từ custom-elements.json của prototype trong guide.
## Key rules
- `chatty-dialog` khai báo 3 attribute, 0 property không có attribute, 2 event, 4 slot, 5 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/dialog.js` là define `chatty-dialog`; 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
A modal dialog on the native `