@comitor/ui 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/ui/tags-input.d.ts +10 -2
- package/dist/components/ui/tags-input.js +34 -8
- package/dist/components/ui/tags-input.js.map +1 -1
- package/dist/data-grid/use-data-grid.d.ts +2 -2
- package/dist/i18n/namespaces/tags-input.d.ts +7 -1
- package/dist/i18n/namespaces/tags-input.js +4 -2
- package/dist/i18n/namespaces/tags-input.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -243,7 +243,7 @@ riêng kèm demo, bảng prop và cạm bẫy của nó:
|
|
|
243
243
|
|
|
244
244
|
| Tầng | Là gì | Trang |
|
|
245
245
|
|---|---|---|
|
|
246
|
-
| **Tier 1 — primitive** · 82 file · `@comitor/ui` | shadcn/ui style `new-york`, đã tùy biến token theo brand Comitor — cộng 18 component port từ Dice UI ở `2.1.0`: `Kanban`, `Stepper`, `Timeline`, `TimePicker`, `TagsInput`, `Mention`, `ActionBar`, `PhoneInput`, `MaskInput`, `Rating`, `CircularProgress`, `Banner`, `ResponsiveDialog`, `Tour`, `KeyValue`, `Cropper`, `ScrollSpy`, `BadgeOverflow`; và ba ở `3.15.0`: `ColorPicker` (nhập màu làm DỮ LIỆU — mã màu nền khách yêu cầu, không phải màu giao diện), `ColorSwatch` (ô hiện một màu đã lưu), `CompareSlider` (so ảnh trước/sau). Từ `4.4.0`: **`ContextMenuContent filter`** / **`DropdownMenuContent filter`** — ô gõ lọc mục ở đầu menu (lọc không dấu theo chữ + `keywords`, mục khớp đầu tô sẵn và Enter chạy nó, gõ trên mục là gõ vào ô, Esc xoá chữ rồi mới đóng; khung thành `role="dialog"` bọc `role="menu"`) | https://design-system.comitor.ai/components · vì sao chọn chúng, và mọi chỗ đã đổi so với thượng nguồn: [docs/diceui.md](docs/diceui.md) |
|
|
246
|
+
| **Tier 1 — primitive** · 82 file · `@comitor/ui` | shadcn/ui style `new-york`, đã tùy biến token theo brand Comitor — cộng 18 component port từ Dice UI ở `2.1.0`: `Kanban`, `Stepper`, `Timeline`, `TimePicker`, `TagsInput`, `Mention`, `ActionBar`, `PhoneInput`, `MaskInput`, `Rating`, `CircularProgress`, `Banner`, `ResponsiveDialog`, `Tour`, `KeyValue`, `Cropper`, `ScrollSpy`, `BadgeOverflow`; và ba ở `3.15.0`: `ColorPicker` (nhập màu làm DỮ LIỆU — mã màu nền khách yêu cầu, không phải màu giao diện), `ColorSwatch` (ô hiện một màu đã lưu), `CompareSlider` (so ảnh trước/sau). Từ `4.4.0`: **`ContextMenuContent filter`** / **`DropdownMenuContent filter`** — ô gõ lọc mục ở đầu menu (lọc không dấu theo chữ + `keywords`, mục khớp đầu tô sẵn và Enter chạy nó, gõ trên mục là gõ vào ô, Esc xoá chữ rồi mới đóng; khung thành `role="dialog"` bọc `role="menu"`). Từ `4.8.0`: `TagsInput` đọc thẻ đang tô bằng ← / → qua một vùng `role="status"` gắn sẵn («react, nhấn Backspace để xoá» — prop `highlightedLabel`) | https://design-system.comitor.ai/components · vì sao chọn chúng, và mọi chỗ đã đổi so với thượng nguồn: [docs/diceui.md](docs/diceui.md) |
|
|
247
247
|
| **Tier 2 — composite** · 61 file · `@comitor/ui` | Giá trị thật của gói: pattern lặp ở mọi app, ghép từ nhiều primitive (`DataTable`, `PageHeader`, `Combobox`, `DatePicker`, `StatCard`…). Từ `4.7.0`: trạng thái chỉ-bằng-hình đọc được bằng trình đọc màn hình — `DataTable` `isRowActive` ghi `aria-current` (`activeRowAriaCurrent` chọn giá trị) và `getRowLabel` đặt tên ô chọn theo bản ghi, **`ListRow current`** (hàng đang mở), chữ ẩn «đã chọn» cạnh ✓ trong `Combobox` / `MultiCombobox`, hướng của `DeltaBadge` / `StatCard delta`. Từ `4.5.0`: **`BreadcrumbMenu`** (ô chọn nằm trong đường dẫn — «Cycles › [CV ▾] › Cycle 2»; `PageHeaderBreadcrumbItem.menu` để `PageHeader` tự vẽ) · **`ListRowHeader`** (dòng tiêu đề cột cùng khung với `ListRow`, `ListRowMeta` cùng `hideBelow` rụng cùng lúc) · **`ListRowChip`** / **`ListRowChipButton`** (chip gọn 20px trên hàng: nhãn, dự án, chu kỳ). Từ `4.4.0`: **`ContextMenuPropertyPicker`** / **`DropdownMenuPropertyPicker`** (bảng chọn thuộc tính làm MENU CON — «Trạng thái ›» mang sẵn giá trị, chọn xong đóng cả menu; lọc được từ ô của menu cha theo tên giá trị) · **`DetailPanelTabs`** (dải tab «tên … ◔ % / tổng» của bảng chi tiết, nhớ tab theo `storageKey`) · `PropertyPickerPanel` nhận `query` điều khiển. Từ `4.3.0` — khuôn màn làm việc của bộ thiết kế Comitor Tasks: **`PropertyPicker`** (bảng chọn thuộc tính: popover neo tại chỗ qua `anchor`, hộp giữa màn hình, hay thân trần `PropertyPickerPanel` làm bước lồng của bảng lệnh; lọc không dấu, phím một ký tự, ✓, dòng chặn kèm lý do, chọn nhiều, `⌫` quay lại) · **`AnchoredPopover`** (popover neo vào phần tử có sẵn, không sở hữu nút mở) · **`PropertyButton`** (nút thuộc tính không nhãn «icon + giá trị», dáng `row` / `chip` / `responsive`, tên trường ở tooltip và tên trợ năng) · **`ListRow`** + `ListRowSelect` / `ListRowTitle` / `ListRowMeta` + **`ListGroup`** (hàng danh sách một dòng, cao theo `--list-item-py`, thuộc tính rụng theo bề rộng hàng; tiêu đề nhóm gập được) · **`DetailPanel`** + `useDetailPanel` / `DetailPanelToggle` / `DetailPanelSection` / `DetailPanelStat` (bảng chi tiết bên phải: cột từ `lg`, ngăn trượt dưới `lg`, nhớ đóng / mở, `⌘I`) · **`SettingsPage`** + `SettingsSection` / `SettingsCard` / `SettingsRow` / `SettingsLinkRow` / `SettingsNote` / `SettingsScopeSelect` (trang cài đặt hai kiểu bề rộng, thẻ gồm hàng — file tĩnh, dùng được trong Server Component) · khuôn hành động AI tại chỗ **`useAiAction`** + `AiActionButton` / `AiActionRunning` / `AiActionStopped` / `AiActionPreview` / `AiGeneratedNotice` / `AiActionError`; `CommandPalette` thêm `context` (dòng ngữ cảnh), `step` (bước lồng), `inputHint`, `onTab`, `CommandPaletteItem.keepOpen`. Từ `4.2.0`: **`IconButton`** — nút chỉ có icon, `label` vừa là `aria-label` vừa là tooltip (rê chuột và focus bàn phím), kèm gợi ý phím tuỳ chọn; dùng thay `<Button size="icon" title=…>` — trừ nút ⋯ mở menu, nút đó không cần tooltip. Từ `3.7.0`: phím tắt chuỗi `useKeySequences` + bảng `?` `KeyboardShortcutsDialog`. Từ `3.12.0`: **`Gantt`** — trục thời gian / Gantt cho cả lộ trình dự án lẫn việc (thanh theo ngày, mũi tên phụ thuộc, kéo dời/giãn, bàn phím, vạch hôm nay, ngày nghỉ, đường găng, 5 bậc ngày→năm, ảo hoá) và **`TreeView`** — cây dàn ý cho WBS (Tab/Shift+Tab/Alt+↑↓, kéo thả đổi cha, số hiệu `1.2.3`, cột cộng dồn, ảo hoá; lõi Headless Tree). Cả hai CONTROLLED: dữ liệu ra qua callback, gói không giữ nghiệp vụ. Từ `3.19.0` — khối của bảng điều khiển (bản mẫu Imagtor v4): `StatCardGroup` (hàng KPI dính liền), `Metric`, `CalendarHeatmap` + `HeatLegend`, `HeatMatrix`, `RankBarList`, `DeltaBadge`, `UrgencyText`, `RatingStars` (chỉ đọc), `Text` + `SectionLabel` (chữ nhỏ theo vai trò), `CategorySwatch`; cùng prop mới trên primitive: `Card size="sm"`, `StatCard variant/size`, `Item variant="flush"`/`align`, `ItemMedia tone`, `Progress size/level/color/markers`, `Alert variant="success"`/`size="sm"`, `StatusPill` `pill`/`soft-dot`/`text-dot`, `Badge variant="muted"`/`shape="pill"`, `Table density`/`bordered`, `TableHead`/`TableCell numeric`, `EmptyState tone` (tiêu đề tuỳ chọn). Từ `3.20.0`: **`SegmentedControl`** — thanh chọn một trong vài lựa chọn dạng viên thuốc, nhãn đầu tuỳ chọn, nút `aria-pressed` (thanh "Đang là" của Imagtor); `DropdownMenuLabel variant="section"` (nhãn mục chữ HOA nhỏ). Từ `3.21.0`: `variant="ghost"` trên `Combobox`, `MultiCombobox`, `DatePicker`, `DateRangePicker` (và primitive `Input`, `SelectTrigger`) — ô không viền lúc nghỉ cho bảng thuộc tính sửa tại chỗ. Từ `3.22.0`: `PageHeader variant="compact"` + `titleActions` — đầu trang một dòng (đường dẫn › tiêu đề › nút) cho trang một bản ghi | https://design-system.comitor.ai/composites · [docs/gantt.md](docs/gantt.md) · [docs/tree-view.md](docs/tree-view.md) |
|
|
248
248
|
| **Tier 3 — shell** · 40 file · `@comitor/ui/shell` | Khung ứng dụng workspace × app — hoặc app thường không có workspace, mang logo + tên của chính nó qua `brand` / `AppBrand` (từ `3.15.0`); app một khối nhiều phân hệ bày phân hệ theo bốn kiểu `moduleLayout` — `grouped` · `rail` (`ModuleRail`) · `switcher` (`ModuleSwitcher`) · `tabs` (`ModuleTabs`), số của mục/phân hệ qua `NavBadge` (từ `3.16.0`): sidebar, header, theme, bốn trục hiển thị (tương phản · mật độ · cỡ chữ · bộ màu theme — `PaletteProvider` + `PalettePicker` từ `3.15.0`). `AppShell` tự có skip link (WCAG 2.4.1) từ `3.7.0`; `DisplayPrefsSeedScript` gieo mặc định hiển thị của tài khoản trước lượt sơn đầu. Từ `3.20.0`: `SidebarAccountButton` — khối tài khoản ở đáy thanh bên (avatar + tên + dòng nổi bật + dòng phụ; thu gọn chỉ avatar), làm `DropdownMenuTrigger asChild` cho menu của app. Từ `4.0.0`: khung KHÔNG thanh trên (`AppShell header="none"`), dải ứng dụng chỉ-icon (`appLayout="rail"`, `AppRail`), nút ở đỉnh thanh bên (`Sidebar topActions` + `SidebarActionButton`), `MobileMenuTrigger` cho thanh của màn, mục mở danh sách nổi (`NavItem.childrenAs: "menu"`) và chế độ mục lục (`navScope`, `NavScopePanel`). Từ `4.3.0`: `NavItem.keywords` (ô lọc mục lục khớp cả từ khoá phụ) và `NavItem.onSelect` (mục dạng hành động — một `<button>` mở hộp thay vì điều hướng). Từ `4.6.0`: `NavGroup.onReorder` — kéo đổi chỗ mục của một nhóm ngay trên thanh bên (chuột, nhấn giữ trên màn chạm, bàn phím Space · ↑↓ · Enter · Esc, lời xướng cho trình đọc màn hình ở namespace `navReorder`), `NavItem.reorderable` cho mục cố định; app nhận thứ tự mới và tự lưu | https://design-system.comitor.ai/shell |
|
|
249
249
|
| **chart** · 4 file · `@comitor/ui/chart` | Lớp shadcn bọc recharts, cùng ba bản dựng sẵn theo brand. ⚠ Ba wrapper `Comitor*Chart` **mặc định TẮT** hiệu ứng vẽ dần (`isAnimationActive = false`) — bật lại là biểu đồ kẹt ở khung đầu: có trục, có lưới, KHÔNG có dữ liệu. Mặc định đó KHÔNG áp cho `<ChartContainer>` + recharts do app tự lắp | https://design-system.comitor.ai/components/chart |
|
|
@@ -12,8 +12,16 @@ import * as React from 'react';
|
|
|
12
12
|
* Phần lõi (bàn phím, dán, sửa tại chỗ, input ẩn cho form) là gói headless `@diceui/tags-input`;
|
|
13
13
|
* file này chỉ phủ style theo token của Comitor.
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
interface TagsInputProps extends React.ComponentProps<typeof TagsInputPrimitive.Root> {
|
|
16
|
+
/**
|
|
17
|
+
* Câu vùng sống đọc khi một thẻ được tô bằng bàn phím — mặc định khoá `highlightedLabel` của
|
|
18
|
+
* namespace `tagsInput` («react, press Backspace to remove»). HÀM vì giá trị thẻ chèn vào câu.
|
|
19
|
+
*
|
|
20
|
+
* ⚠ Thêm so với thượng nguồn (4.8.0) — xem `TagsInputHighlightContext`.
|
|
21
|
+
*/
|
|
22
|
+
highlightedLabel?: (value: string) => string;
|
|
23
|
+
}
|
|
24
|
+
declare function TagsInput({ className, dir: dirProp, children, highlightedLabel: highlightedLabelProp, ...props }: TagsInputProps): React.JSX.Element;
|
|
17
25
|
type TagsInputLabelProps = React.ComponentProps<typeof TagsInputPrimitive.Label>;
|
|
18
26
|
declare function TagsInputLabel({ className, ...props }: TagsInputLabelProps): React.JSX.Element;
|
|
19
27
|
type TagsInputListProps = React.ComponentProps<"div">;
|
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as TagsInputPrimitive from "@diceui/tags-input";
|
|
4
4
|
import { useDirection } from "@radix-ui/react-direction";
|
|
5
5
|
import { X } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
6
7
|
import { useComitorMessages } from "../../i18n/locale-provider.js";
|
|
7
8
|
import { cn } from "../../lib/cn.js";
|
|
8
|
-
|
|
9
|
+
const TagsInputHighlightContext = React.createContext(null);
|
|
10
|
+
function TagsInput({
|
|
11
|
+
className,
|
|
12
|
+
dir: dirProp,
|
|
13
|
+
children,
|
|
14
|
+
highlightedLabel: highlightedLabelProp,
|
|
15
|
+
...props
|
|
16
|
+
}) {
|
|
9
17
|
const dir = useDirection(dirProp);
|
|
10
|
-
|
|
18
|
+
const t = useComitorMessages("tagsInput");
|
|
19
|
+
const highlightedLabel = highlightedLabelProp ?? t.highlightedLabel;
|
|
20
|
+
const [highlighted, setHighlighted] = React.useState(null);
|
|
21
|
+
return /* @__PURE__ */ jsx(TagsInputHighlightContext.Provider, { value: setHighlighted, children: /* @__PURE__ */ jsx(
|
|
11
22
|
TagsInputPrimitive.Root,
|
|
12
23
|
{
|
|
13
24
|
"data-slot": "tags-input",
|
|
14
25
|
dir,
|
|
15
26
|
className: cn("flex w-full flex-col gap-2", className),
|
|
16
|
-
...props
|
|
27
|
+
...props,
|
|
28
|
+
children: (context) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
typeof children === "function" ? children(context) : children,
|
|
30
|
+
/* @__PURE__ */ jsx("span", { role: "status", "data-slot": "tags-input-status", className: "sr-only", children: highlighted === null ? "" : highlightedLabel(highlighted) })
|
|
31
|
+
] })
|
|
17
32
|
}
|
|
18
|
-
);
|
|
33
|
+
) });
|
|
19
34
|
}
|
|
20
35
|
function TagsInputLabel({ className, ...props }) {
|
|
21
36
|
return /* @__PURE__ */ jsx(
|
|
@@ -81,10 +96,20 @@ function TagsInputInput({ className, ...props }) {
|
|
|
81
96
|
}
|
|
82
97
|
);
|
|
83
98
|
}
|
|
99
|
+
function TagsInputItemFrame({ value, ...props }) {
|
|
100
|
+
const setHighlighted = React.useContext(TagsInputHighlightContext);
|
|
101
|
+
const isHighlighted = props["data-highlighted"] !== void 0;
|
|
102
|
+
React.useEffect(() => {
|
|
103
|
+
if (!isHighlighted || !setHighlighted) return;
|
|
104
|
+
setHighlighted(value);
|
|
105
|
+
return () => setHighlighted((current) => current === value ? null : current);
|
|
106
|
+
}, [isHighlighted, value, setHighlighted]);
|
|
107
|
+
return /* @__PURE__ */ jsx("div", { ...props });
|
|
108
|
+
}
|
|
84
109
|
function TagsInputItem({ className, children, deleteLabel: deleteLabelProp, ...props }) {
|
|
85
110
|
const t = useComitorMessages("tagsInput");
|
|
86
111
|
const deleteLabel = deleteLabelProp ?? t.deleteLabel;
|
|
87
|
-
return /* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
88
113
|
TagsInputPrimitive.Item,
|
|
89
114
|
{
|
|
90
115
|
"data-slot": "tags-input-item",
|
|
@@ -101,7 +126,8 @@ function TagsInputItem({ className, children, deleteLabel: deleteLabelProp, ...p
|
|
|
101
126
|
className
|
|
102
127
|
),
|
|
103
128
|
...props,
|
|
104
|
-
|
|
129
|
+
asChild: true,
|
|
130
|
+
children: /* @__PURE__ */ jsxs(TagsInputItemFrame, { value: props.value, children: [
|
|
105
131
|
/* @__PURE__ */ jsx(TagsInputPrimitive.ItemText, { className: "truncate", children }),
|
|
106
132
|
/* @__PURE__ */ jsx(
|
|
107
133
|
TagsInputPrimitive.ItemDelete,
|
|
@@ -113,7 +139,7 @@ function TagsInputItem({ className, children, deleteLabel: deleteLabelProp, ...p
|
|
|
113
139
|
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "size-3.5" })
|
|
114
140
|
}
|
|
115
141
|
)
|
|
116
|
-
]
|
|
142
|
+
] })
|
|
117
143
|
}
|
|
118
144
|
);
|
|
119
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/tags-input.tsx"],"sourcesContent":["\"use client\";\n\n/*\n * Port từ Dice UI (https://diceui.com/docs/components/tags-input) — MIT, © 2024 Sadman Sakib.\n * Giữ nguyên cấu trúc thượng nguồn để còn đối chiếu ngược được; mọi chỗ đổi đều có chú thích.\n */\n\nimport * as TagsInputPrimitive from \"@diceui/tags-input\";\nimport { useDirection } from \"@radix-ui/react-direction\";\nimport { X } from \"lucide-react\";\nimport type * as React from \"react\";\nimport { useComitorMessages } from \"../../i18n/locale-provider.js\";\nimport { cn } from \"../../lib/cn.js\";\n\n/**\n * TagsInput — ô nhập THẺ TỰ DO: gõ chữ rồi Enter (hoặc gõ dấu phân cách) để thành một thẻ.\n * Dùng cho nhãn tự đặt trên task / bản ghi CRM, danh sách người nhận email.\n *\n * ⚠ KHÁC `MultiCombobox`: `MultiCombobox` chọn nhiều giá trị từ một danh sách CỐ ĐỊNH; TagsInput\n * nhận giá trị người dùng TỰ GÕ, không có danh sách gợi ý. Đừng gộp hai thứ — giá trị hợp lệ\n * của chúng khác nhau về bản chất (có trong tập ⇄ bất kỳ chuỗi nào qua được `onValidate`).\n *\n * Phần lõi (bàn phím, dán, sửa tại chỗ, input ẩn cho form) là gói headless `@diceui/tags-input`;\n * file này chỉ phủ style theo token của Comitor.\n */\ntype TagsInputProps = React.ComponentProps<typeof TagsInputPrimitive.Root>;\n\nfunction TagsInput({ className, dir: dirProp, ...props }: TagsInputProps) {\n /*\n * ⚠ Khác thượng nguồn: `@diceui/shared` có `useDirection` RIÊNG, đọc một `DirectionContext` mà\n * gói không xuất ra — nên `DirectionProvider` của Radix (nguồn hướng chữ của mọi component khác\n * trong gói, vd `Rating`) không tới được nó, và app RTL thấy ô thẻ vẫn chạy LTR. Đọc hướng từ\n * Radix rồi truyền xuống bằng prop `dir` (prop của app vẫn thắng).\n */\n const dir = useDirection(dirProp);\n\n return (\n <TagsInputPrimitive.Root\n data-slot=\"tags-input\"\n dir={dir}\n // ⚠ Khác thượng nguồn: bản gốc ghim `w-[380px]` (kích thước của trang demo). Primitive của\n // gói luôn `w-full` như `Input` — bề rộng là việc của bố cục bên ngoài.\n className={cn(\"flex w-full flex-col gap-2\", className)}\n {...props}\n />\n );\n}\n\ntype TagsInputLabelProps = React.ComponentProps<typeof TagsInputPrimitive.Label>;\n\nfunction TagsInputLabel({ className, ...props }: TagsInputLabelProps) {\n return (\n <TagsInputPrimitive.Label\n data-slot=\"tags-input-label\"\n className={cn(\n /*\n * ⚠ Khác thượng nguồn: `peer-disabled:` của bản gốc không bao giờ khớp — nhãn đứng TRƯỚC ô\n * nhập, mà `peer-*` chỉ nhìn anh em đứng trước. Trạng thái vô hiệu nằm ở `data-disabled` của\n * gốc `TagsInput`, nên đọc bằng `in-data-disabled:`. Mức mờ theo `Label` của gói (50).\n */\n \"text-sm leading-none font-medium in-data-disabled:cursor-not-allowed in-data-disabled:opacity-50\",\n className\n )}\n {...props}\n />\n );\n}\n\ntype TagsInputListProps = React.ComponentProps<\"div\">;\n\nfunction TagsInputList({ className, ...props }: TagsInputListProps) {\n return (\n <div\n data-slot=\"tags-input-list\"\n className={cn(\n /*\n * Khung này là \"ô nhập\" mà người dùng nhìn thấy (thẻ + ô gõ nằm chung), nên nó mặc đúng bộ\n * viền của `Input`: `border-input` lúc nghỉ, đậm lên `--control-edge-strong` khi rê chuột,\n * `--primary-ink` + vòng `ring/50` khi có focus BÊN TRONG. Số đo ở chú thích đầu `input.tsx`.\n *\n * ⚠ Khác thượng nguồn:\n * · `focus-within:ring-1 ring-ring` → khuôn focus của `Input` (ring-2 ring/50 + viền ink).\n * · rê chuột lúc đang focus KHÔNG được đè viền focus: `focus-within` xếp TRƯỚC `hover`\n * trong thứ tự biến thể của Tailwind v4, nên hover phải kèm `not-focus-within`.\n * · `disabled:` trên một `<div>` không bao giờ khớp → `has-[input:disabled]:` (gốc vô\n * hiệu thì gói đặt `disabled` THẬT lên ô gõ bên trong). Chọn `:disabled` gốc của HTML\n * chứ không `data-disabled` vì đó là trạng thái mà WCAG 1.4.3/1.4.11 miễn trừ — và là\n * trạng thái duy nhất cổng màu nhận ra là \"vô hiệu\".\n * · `min-h-10 py-2` → `min-h-9 py-1.5`: cao đúng `h-9` của `Input` khi chưa có thẻ, để\n * đứng cạnh các ô khác trong cùng một form không lệch dòng.\n */\n \"flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-1.5 text-base md:text-sm text-foreground transition-colors duration-150 ease-out hover:not-focus-within:border-control-edge-strong focus-within:border-primary-ink focus-within:ring-2 focus-within:ring-ring/50 has-[input:disabled]:cursor-not-allowed has-[input:disabled]:bg-muted has-[input:disabled]:opacity-50\",\n className\n )}\n {...props}\n />\n );\n}\n\ntype TagsInputInputProps = React.ComponentProps<typeof TagsInputPrimitive.Input>;\n\nfunction TagsInputInput({ className, ...props }: TagsInputInputProps) {\n return (\n <TagsInputPrimitive.Input\n data-slot=\"tags-input-input\"\n className={cn(\n // ⚠ Khác thượng nguồn: `min-w-0` — ô gõ là mục flex co giãn; thiếu nó thì chiều rộng tối thiểu\n // nội tại của `<input>` đẩy hàng thẻ xuống dòng sớm.\n // ⚠ Khác thượng nguồn: `leading-5` — khung cao theo nội dung, chưa có thẻ thì dòng của ô gõ quyết\n // định chiều cao (CLAUDE.md § Quy ước bắt buộc giữ › \"Cỡ chữ ô nhập\").\n \"min-w-0 flex-1 bg-transparent leading-5 outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )}\n {...props}\n />\n );\n}\n\ninterface TagsInputItemProps extends React.ComponentProps<typeof TagsInputPrimitive.Item> {\n /**\n * Tên cho trình đọc màn hình của nút xoá thẻ — mặc định khoá `deleteLabel` của namespace\n * `tagsInput` (`ComitorLocaleProvider`).\n *\n * ⚠ Thêm so với thượng nguồn. Nút xoá chỉ có một icon ✕; gói headless đặt cho nó\n * `aria-labelledby` trỏ vào CHỮ của thẻ, nên trình đọc màn hình đọc \"react, nút\" — nghe như\n * một nút mang tên thẻ chứ không phải nút xoá thẻ. Là HÀM vì giá trị thẻ chèn vào giữa câu.\n */\n deleteLabel?: (value: string) => string;\n}\n\nfunction TagsInputItem({ className, children, deleteLabel: deleteLabelProp, ...props }: TagsInputItemProps) {\n const t = useComitorMessages(\"tagsInput\");\n const deleteLabel = deleteLabelProp ?? t.deleteLabel;\n return (\n <TagsInputPrimitive.Item\n data-slot=\"tags-input-item\"\n /*\n * ⚠ Khác thượng nguồn (a11y): gói đặt `aria-labelledby` lên thẻ — một `<div>` KHÔNG có role,\n * mà ARIA 1.2 CẤM đặt tên cho vai trò `generic` (axe: `aria-prohibited-attr`). Chữ của thẻ đã\n * nằm ngay bên trong nên gỡ đi không mất gì.\n */\n aria-labelledby={undefined}\n className={cn(\n /*\n * Viền thẻ là viền TRANG TRÍ (`--border`, mặc định của `@layer base`): thẻ không phải một\n * control — control là nút ✕ bên trong. Thẻ đang được chọn bằng bàn phím tô\n * `bg-accent`/`text-accent-foreground`, cùng cặp với mục đang sáng của `CommandItem`.\n * ⚠ Khác thượng nguồn: `ring-1 ring-ring` lúc sửa tại chỗ → khuôn `ring-2 ring-ring/50`\n * của gói; `px-2.5 py-1` → `px-2 py-0.5` để thẻ lọt khung cao `h-9`.\n */\n \"inline-flex max-w-[calc(100%-8px)] items-center gap-1.5 rounded border bg-transparent px-2 py-0.5 text-sm focus:outline-hidden data-disabled:cursor-not-allowed data-disabled:opacity-50 data-editable:select-none data-editing:bg-transparent data-editing:ring-2 data-editing:ring-ring/50 [&:not([data-editing])]:pr-1 [&[data-highlighted]:not([data-editing])]:bg-accent [&[data-highlighted]:not([data-editing])]:text-accent-foreground\",\n className\n )}\n {...props}\n >\n <TagsInputPrimitive.ItemText className=\"truncate\">{children}</TagsInputPrimitive.ItemText>\n <TagsInputPrimitive.ItemDelete\n /*\n * ⚠ Khác thượng nguồn (a11y):\n * · Tên nút: gói đặt `aria-labelledby` = chữ của thẻ (xem `deleteLabel`). `aria-labelledby`\n * THẮNG `aria-label` trong phép tính tên, nên phải gỡ nó ra (props của ta được trải SAU\n * props của gói, nên `undefined` ở đây xoá được thuộc tính).\n * · `tabIndex`: gói đặt `disabled ? undefined : -1` — tức ngược: nút ĐANG dùng được thì\n * ra khỏi thứ tự Tab (đúng thiết kế: bàn phím xoá thẻ bằng ←/Backspace/Delete từ ô gõ),\n * còn nút VÔ HIỆU thì lại lọt VÀO thứ tự Tab, nhận focus mà bấm không làm gì. Ghim -1\n * cho cả hai trạng thái; trình đọc màn hình ở chế độ duyệt vẫn bấm được nút.\n */\n aria-labelledby={undefined}\n aria-label={deleteLabel(props.value)}\n tabIndex={-1}\n className=\"size-4 shrink-0 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100\"\n >\n <X aria-hidden=\"true\" className=\"size-3.5\" />\n </TagsInputPrimitive.ItemDelete>\n </TagsInputPrimitive.Item>\n );\n}\n\ntype TagsInputClearProps = React.ComponentProps<typeof TagsInputPrimitive.Clear>;\n\n/**\n * Nút xoá hết thẻ. Không có nội dung mặc định (đúng thượng nguồn) — app tự đặt chữ/icon bên\n * trong; nếu chỉ đặt icon thì PHẢI kèm `aria-label` (vd \"Xoá tất cả thẻ\").\n */\nfunction TagsInputClear({ ...props }: TagsInputClearProps) {\n return <TagsInputPrimitive.Clear data-slot=\"tags-input-clear\" {...props} />;\n}\n\nexport {\n TagsInput,\n TagsInputClear,\n type TagsInputClearProps,\n TagsInputInput,\n type TagsInputInputProps,\n TagsInputItem,\n type TagsInputItemProps,\n TagsInputLabel,\n type TagsInputLabelProps,\n TagsInputList,\n type TagsInputListProps,\n type TagsInputProps\n};\n"],"mappings":";AAqCI,cAiGA,YAjGA;AA9BJ,YAAY,wBAAwB;AACpC,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,UAAU;AAenB,SAAS,UAAU,EAAE,WAAW,KAAK,SAAS,GAAG,MAAM,GAAmB;AAOxE,QAAM,MAAM,aAAa,OAAO;AAEhC,SACE;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACC,aAAU;AAAA,MACV;AAAA,MAGA,WAAW,GAAG,8BAA8B,SAAS;AAAA,MACpD,GAAG;AAAA;AAAA,EACN;AAEJ;AAIA,SAAS,eAAe,EAAE,WAAW,GAAG,MAAM,GAAwB;AACpE,SACE;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAIA,SAAS,cAAc,EAAE,WAAW,GAAG,MAAM,GAAuB;AAClE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAiBT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAIA,SAAS,eAAe,EAAE,WAAW,GAAG,MAAM,GAAwB;AACpE,SACE;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,QAKT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAcA,SAAS,cAAc,EAAE,WAAW,UAAU,aAAa,iBAAiB,GAAG,MAAM,GAAuB;AAC1G,QAAM,IAAI,mBAAmB,WAAW;AACxC,QAAM,cAAc,mBAAmB,EAAE;AACzC,SACE;AAAA,IAAC,mBAAmB;AAAA,IAAnB;AAAA,MACC,aAAU;AAAA,MAMV,mBAAiB;AAAA,MACjB,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAQT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,4BAAC,mBAAmB,UAAnB,EAA4B,WAAU,YAAY,UAAS;AAAA,QAC5D;AAAA,UAAC,mBAAmB;AAAA,UAAnB;AAAA,YAWC,mBAAiB;AAAA,YACjB,cAAY,YAAY,MAAM,KAAK;AAAA,YACnC,UAAU;AAAA,YACV,WAAU;AAAA,YAEV,8BAAC,KAAE,eAAY,QAAO,WAAU,YAAW;AAAA;AAAA,QAC7C;AAAA;AAAA;AAAA,EACF;AAEJ;AAQA,SAAS,eAAe,EAAE,GAAG,MAAM,GAAwB;AACzD,SAAO,oBAAC,mBAAmB,OAAnB,EAAyB,aAAU,oBAAoB,GAAG,OAAO;AAC3E;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/tags-input.tsx"],"sourcesContent":["\"use client\";\n\n/*\n * Port từ Dice UI (https://diceui.com/docs/components/tags-input) — MIT, © 2024 Sadman Sakib.\n * Giữ nguyên cấu trúc thượng nguồn để còn đối chiếu ngược được; mọi chỗ đổi đều có chú thích.\n */\n\nimport * as TagsInputPrimitive from \"@diceui/tags-input\";\nimport { useDirection } from \"@radix-ui/react-direction\";\nimport { X } from \"lucide-react\";\nimport * as React from \"react\";\nimport { useComitorMessages } from \"../../i18n/locale-provider.js\";\nimport { cn } from \"../../lib/cn.js\";\n\n/**\n * TagsInput — ô nhập THẺ TỰ DO: gõ chữ rồi Enter (hoặc gõ dấu phân cách) để thành một thẻ.\n * Dùng cho nhãn tự đặt trên task / bản ghi CRM, danh sách người nhận email.\n *\n * ⚠ KHÁC `MultiCombobox`: `MultiCombobox` chọn nhiều giá trị từ một danh sách CỐ ĐỊNH; TagsInput\n * nhận giá trị người dùng TỰ GÕ, không có danh sách gợi ý. Đừng gộp hai thứ — giá trị hợp lệ\n * của chúng khác nhau về bản chất (có trong tập ⇄ bất kỳ chuỗi nào qua được `onValidate`).\n *\n * Phần lõi (bàn phím, dán, sửa tại chỗ, input ẩn cho form) là gói headless `@diceui/tags-input`;\n * file này chỉ phủ style theo token của Comitor.\n */\ninterface TagsInputProps extends React.ComponentProps<typeof TagsInputPrimitive.Root> {\n /**\n * Câu vùng sống đọc khi một thẻ được tô bằng bàn phím — mặc định khoá `highlightedLabel` của\n * namespace `tagsInput` («react, press Backspace to remove»). HÀM vì giá trị thẻ chèn vào câu.\n *\n * ⚠ Thêm so với thượng nguồn (4.8.0) — xem `TagsInputHighlightContext`.\n */\n highlightedLabel?: (value: string) => string;\n}\n\n/**\n * ⚠ Khác thượng nguồn (a11y, 4.8.0): thẻ đang tô bằng ← / → (hoặc Backspace lần đầu) chỉ được báo\n * bằng nền `bg-accent`. Tiêu điểm vẫn nằm ở ô gõ, gói headless không dùng `aria-activedescendant` và\n * không có vùng sống, nên người dùng trình đọc màn hình bấm Backspace lần hai là xoá một thẻ mình\n * chưa nghe thấy. `aria-current` mà gói đặt lên thẻ thì không gì đọc: tiêu điểm không bao giờ tới thẻ.\n *\n * Cách báo: một vùng `role=\"status\"` gắn SẴN trong gốc (có mặt trước khi chữ đổi — vùng sống chèn\n * vào cùng lúc với chữ thì nhiều trình đọc bỏ qua), đọc «{thẻ}, nhấn Backspace để xoá».\n * Vì sao KHÔNG `aria-activedescendant` trên ô gõ: phần tử nó trỏ tới phải là con cháu (hoặc được\n * `aria-owns`) của ô, mà thẻ là ANH EM của ô; thẻ lại là `div` không vai trò, và trình đọc chỉ theo\n * `aria-activedescendant` đáng tin ở `combobox` / `listbox` / `grid` — tức phải dựng lại cả DOM của\n * gói thành một `listbox`, lệch thượng nguồn xa hơn nhiều.\n *\n * Trạng thái \"đang tô\" nằm trong context RIÊNG của gói (không xuất ra). Đường đọc nó: `Item` render\n * với `asChild`, nên `data-highlighted` của gói tới khung `TagsInputItemFrame` dưới dạng PROP; khung\n * báo lên gốc qua context này. Ngoài `TagsInput` (thẻ dựng thẳng trên `@diceui/tags-input`) context\n * là `null` và khung không làm gì.\n */\nconst TagsInputHighlightContext = React.createContext<React.Dispatch<React.SetStateAction<string | null>> | null>(null);\n\nfunction TagsInput({\n className,\n dir: dirProp,\n children,\n highlightedLabel: highlightedLabelProp,\n ...props\n}: TagsInputProps) {\n /*\n * ⚠ Khác thượng nguồn: `@diceui/shared` có `useDirection` RIÊNG, đọc một `DirectionContext` mà\n * gói không xuất ra — nên `DirectionProvider` của Radix (nguồn hướng chữ của mọi component khác\n * trong gói, vd `Rating`) không tới được nó, và app RTL thấy ô thẻ vẫn chạy LTR. Đọc hướng từ\n * Radix rồi truyền xuống bằng prop `dir` (prop của app vẫn thắng).\n */\n const dir = useDirection(dirProp);\n const t = useComitorMessages(\"tagsInput\");\n const highlightedLabel = highlightedLabelProp ?? t.highlightedLabel;\n const [highlighted, setHighlighted] = React.useState<string | null>(null);\n\n return (\n <TagsInputHighlightContext.Provider value={setHighlighted}>\n <TagsInputPrimitive.Root\n data-slot=\"tags-input\"\n dir={dir}\n // ⚠ Khác thượng nguồn: bản gốc ghim `w-[380px]` (kích thước của trang demo). Primitive của\n // gói luôn `w-full` như `Input` — bề rộng là việc của bố cục bên ngoài.\n className={cn(\"flex w-full flex-col gap-2\", className)}\n {...props}\n >\n {/* Gói nhận `children` là node HOẶC hàm `({ value })` — luôn truyền hàm để vùng sống đứng cạnh cả hai dạng. */}\n {(context) => (\n <>\n {typeof children === \"function\" ? children(context) : children}\n {/* `sr-only` là `absolute` nên không chiếm khe `gap` của gốc `flex-col`. */}\n <span role=\"status\" data-slot=\"tags-input-status\" className=\"sr-only\">\n {highlighted === null ? \"\" : highlightedLabel(highlighted)}\n </span>\n </>\n )}\n </TagsInputPrimitive.Root>\n </TagsInputHighlightContext.Provider>\n );\n}\n\ntype TagsInputLabelProps = React.ComponentProps<typeof TagsInputPrimitive.Label>;\n\nfunction TagsInputLabel({ className, ...props }: TagsInputLabelProps) {\n return (\n <TagsInputPrimitive.Label\n data-slot=\"tags-input-label\"\n className={cn(\n /*\n * ⚠ Khác thượng nguồn: `peer-disabled:` của bản gốc không bao giờ khớp — nhãn đứng TRƯỚC ô\n * nhập, mà `peer-*` chỉ nhìn anh em đứng trước. Trạng thái vô hiệu nằm ở `data-disabled` của\n * gốc `TagsInput`, nên đọc bằng `in-data-disabled:`. Mức mờ theo `Label` của gói (50).\n */\n \"text-sm leading-none font-medium in-data-disabled:cursor-not-allowed in-data-disabled:opacity-50\",\n className\n )}\n {...props}\n />\n );\n}\n\ntype TagsInputListProps = React.ComponentProps<\"div\">;\n\nfunction TagsInputList({ className, ...props }: TagsInputListProps) {\n return (\n <div\n data-slot=\"tags-input-list\"\n className={cn(\n /*\n * Khung này là \"ô nhập\" mà người dùng nhìn thấy (thẻ + ô gõ nằm chung), nên nó mặc đúng bộ\n * viền của `Input`: `border-input` lúc nghỉ, đậm lên `--control-edge-strong` khi rê chuột,\n * `--primary-ink` + vòng `ring/50` khi có focus BÊN TRONG. Số đo ở chú thích đầu `input.tsx`.\n *\n * ⚠ Khác thượng nguồn:\n * · `focus-within:ring-1 ring-ring` → khuôn focus của `Input` (ring-2 ring/50 + viền ink).\n * · rê chuột lúc đang focus KHÔNG được đè viền focus: `focus-within` xếp TRƯỚC `hover`\n * trong thứ tự biến thể của Tailwind v4, nên hover phải kèm `not-focus-within`.\n * · `disabled:` trên một `<div>` không bao giờ khớp → `has-[input:disabled]:` (gốc vô\n * hiệu thì gói đặt `disabled` THẬT lên ô gõ bên trong). Chọn `:disabled` gốc của HTML\n * chứ không `data-disabled` vì đó là trạng thái mà WCAG 1.4.3/1.4.11 miễn trừ — và là\n * trạng thái duy nhất cổng màu nhận ra là \"vô hiệu\".\n * · `min-h-10 py-2` → `min-h-9 py-1.5`: cao đúng `h-9` của `Input` khi chưa có thẻ, để\n * đứng cạnh các ô khác trong cùng một form không lệch dòng.\n */\n \"flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-1.5 text-base md:text-sm text-foreground transition-colors duration-150 ease-out hover:not-focus-within:border-control-edge-strong focus-within:border-primary-ink focus-within:ring-2 focus-within:ring-ring/50 has-[input:disabled]:cursor-not-allowed has-[input:disabled]:bg-muted has-[input:disabled]:opacity-50\",\n className\n )}\n {...props}\n />\n );\n}\n\ntype TagsInputInputProps = React.ComponentProps<typeof TagsInputPrimitive.Input>;\n\nfunction TagsInputInput({ className, ...props }: TagsInputInputProps) {\n return (\n <TagsInputPrimitive.Input\n data-slot=\"tags-input-input\"\n className={cn(\n // ⚠ Khác thượng nguồn: `min-w-0` — ô gõ là mục flex co giãn; thiếu nó thì chiều rộng tối thiểu\n // nội tại của `<input>` đẩy hàng thẻ xuống dòng sớm.\n // ⚠ Khác thượng nguồn: `leading-5` — khung cao theo nội dung, chưa có thẻ thì dòng của ô gõ quyết\n // định chiều cao (CLAUDE.md § Quy ước bắt buộc giữ › \"Cỡ chữ ô nhập\").\n \"min-w-0 flex-1 bg-transparent leading-5 outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )}\n {...props}\n />\n );\n}\n\ninterface TagsInputItemFrameProps extends React.ComponentProps<\"div\"> {\n value: string;\n /** Gói đặt `\"\"` khi thẻ đang được tô, `undefined` khi không — tới đây qua `asChild` của `Item`. */\n \"data-highlighted\"?: string;\n}\n\n/**\n * Khung DOM của thẻ (thay cho `Primitive.div` của gói khi `Item` chạy `asChild`). Nhận đủ prop gói\n * định đặt lên `div` (id, `data-*`, handler con trỏ, `ref`) và trải nguyên xuống; việc thêm duy nhất là\n * báo thẻ đang tô lên vùng sống của `TagsInput`.\n *\n * Effect chứ không gọi trong render: hai thẻ đổi lượt tô (A thôi, B được tô) commit CÙNG một lượt, và\n * React chạy mọi cleanup trước mọi setup — nên A xoá rồi B ghi, kết quả là B dù thứ tự thẻ thế nào.\n * Cleanup chỉ xoá khi giá trị còn là của chính thẻ này (updater thuần — StrictMode gọi hai lần vô hại).\n */\nfunction TagsInputItemFrame({ value, ...props }: TagsInputItemFrameProps) {\n const setHighlighted = React.useContext(TagsInputHighlightContext);\n const isHighlighted = props[\"data-highlighted\"] !== undefined;\n React.useEffect(() => {\n if (!isHighlighted || !setHighlighted) return;\n setHighlighted(value);\n return () => setHighlighted((current) => (current === value ? null : current));\n }, [isHighlighted, value, setHighlighted]);\n return <div {...props} />;\n}\n\ninterface TagsInputItemProps extends React.ComponentProps<typeof TagsInputPrimitive.Item> {\n /**\n * Tên cho trình đọc màn hình của nút xoá thẻ — mặc định khoá `deleteLabel` của namespace\n * `tagsInput` (`ComitorLocaleProvider`).\n *\n * ⚠ Thêm so với thượng nguồn. Nút xoá chỉ có một icon ✕; gói headless đặt cho nó\n * `aria-labelledby` trỏ vào CHỮ của thẻ, nên trình đọc màn hình đọc \"react, nút\" — nghe như\n * một nút mang tên thẻ chứ không phải nút xoá thẻ. Là HÀM vì giá trị thẻ chèn vào giữa câu.\n */\n deleteLabel?: (value: string) => string;\n}\n\nfunction TagsInputItem({ className, children, deleteLabel: deleteLabelProp, ...props }: TagsInputItemProps) {\n const t = useComitorMessages(\"tagsInput\");\n const deleteLabel = deleteLabelProp ?? t.deleteLabel;\n return (\n <TagsInputPrimitive.Item\n data-slot=\"tags-input-item\"\n /*\n * ⚠ Khác thượng nguồn (a11y): gói đặt `aria-labelledby` lên thẻ — một `<div>` KHÔNG có role,\n * mà ARIA 1.2 CẤM đặt tên cho vai trò `generic` (axe: `aria-prohibited-attr`). Chữ của thẻ đã\n * nằm ngay bên trong nên gỡ đi không mất gì.\n */\n aria-labelledby={undefined}\n className={cn(\n /*\n * Viền thẻ là viền TRANG TRÍ (`--border`, mặc định của `@layer base`): thẻ không phải một\n * control — control là nút ✕ bên trong. Thẻ đang được chọn bằng bàn phím tô\n * `bg-accent`/`text-accent-foreground`, cùng cặp với mục đang sáng của `CommandItem`.\n * ⚠ Khác thượng nguồn: `ring-1 ring-ring` lúc sửa tại chỗ → khuôn `ring-2 ring-ring/50`\n * của gói; `px-2.5 py-1` → `px-2 py-0.5` để thẻ lọt khung cao `h-9`.\n */\n \"inline-flex max-w-[calc(100%-8px)] items-center gap-1.5 rounded border bg-transparent px-2 py-0.5 text-sm focus:outline-hidden data-disabled:cursor-not-allowed data-disabled:opacity-50 data-editable:select-none data-editing:bg-transparent data-editing:ring-2 data-editing:ring-ring/50 [&:not([data-editing])]:pr-1 [&[data-highlighted]:not([data-editing])]:bg-accent [&[data-highlighted]:not([data-editing])]:text-accent-foreground\",\n className\n )}\n {...props}\n // ⚠ Khác thượng nguồn (4.8.0): `asChild` để `data-highlighted` của gói tới khung dưới dạng prop —\n // xem `TagsInputHighlightContext`. Khung render đúng một `div` như bản gốc, nên DOM không đổi.\n asChild\n >\n <TagsInputItemFrame value={props.value}>\n <TagsInputPrimitive.ItemText className=\"truncate\">{children}</TagsInputPrimitive.ItemText>\n <TagsInputPrimitive.ItemDelete\n /*\n * ⚠ Khác thượng nguồn (a11y):\n * · Tên nút: gói đặt `aria-labelledby` = chữ của thẻ (xem `deleteLabel`). `aria-labelledby`\n * THẮNG `aria-label` trong phép tính tên, nên phải gỡ nó ra (props của ta được trải SAU\n * props của gói, nên `undefined` ở đây xoá được thuộc tính).\n * · `tabIndex`: gói đặt `disabled ? undefined : -1` — tức ngược: nút ĐANG dùng được thì\n * ra khỏi thứ tự Tab (đúng thiết kế: bàn phím xoá thẻ bằng ←/Backspace/Delete từ ô gõ),\n * còn nút VÔ HIỆU thì lại lọt VÀO thứ tự Tab, nhận focus mà bấm không làm gì. Ghim -1\n * cho cả hai trạng thái; trình đọc màn hình ở chế độ duyệt vẫn bấm được nút.\n */\n aria-labelledby={undefined}\n aria-label={deleteLabel(props.value)}\n tabIndex={-1}\n className=\"size-4 shrink-0 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100\"\n >\n <X aria-hidden=\"true\" className=\"size-3.5\" />\n </TagsInputPrimitive.ItemDelete>\n </TagsInputItemFrame>\n </TagsInputPrimitive.Item>\n );\n}\n\ntype TagsInputClearProps = React.ComponentProps<typeof TagsInputPrimitive.Clear>;\n\n/**\n * Nút xoá hết thẻ. Không có nội dung mặc định (đúng thượng nguồn) — app tự đặt chữ/icon bên\n * trong; nếu chỉ đặt icon thì PHẢI kèm `aria-label` (vd \"Xoá tất cả thẻ\").\n */\nfunction TagsInputClear({ ...props }: TagsInputClearProps) {\n return <TagsInputPrimitive.Clear data-slot=\"tags-input-clear\" {...props} />;\n}\n\nexport {\n TagsInput,\n TagsInputClear,\n type TagsInputClearProps,\n TagsInputInput,\n type TagsInputInputProps,\n TagsInputItem,\n type TagsInputItemProps,\n TagsInputLabel,\n type TagsInputLabelProps,\n TagsInputList,\n type TagsInputListProps,\n type TagsInputProps\n};\n"],"mappings":"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","names":[]}
|
|
@@ -131,7 +131,7 @@ declare function useDataGrid<TData>({ data, columns, rowHeight: rowHeightProp, o
|
|
|
131
131
|
pasteDialog: PasteDialogState;
|
|
132
132
|
onRowAdd: ((event?: React.MouseEvent<HTMLDivElement>) => Promise<void>) | undefined;
|
|
133
133
|
adjustLayout: boolean;
|
|
134
|
-
locale:
|
|
134
|
+
locale: {
|
|
135
135
|
grid: {
|
|
136
136
|
label: string;
|
|
137
137
|
addRow: string;
|
|
@@ -410,7 +410,7 @@ declare function useDataGrid<TData>({ data, columns, rowHeight: rowHeightProp, o
|
|
|
410
410
|
shortcuts: string;
|
|
411
411
|
};
|
|
412
412
|
};
|
|
413
|
-
} | undefined;
|
|
413
|
+
} | "en" | "vi" | undefined;
|
|
414
414
|
};
|
|
415
415
|
|
|
416
416
|
export { type UseDataGridProps, useDataGrid };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
/** Chữ của `TagsInputItem`. */
|
|
1
|
+
/** Chữ của `TagsInput` / `TagsInputItem`. */
|
|
2
2
|
interface TagsInputMessages {
|
|
3
3
|
/**
|
|
4
4
|
* Tên cho trình đọc màn hình của nút xoá thẻ — prop `deleteLabel`. HÀM vì giá trị thẻ chèn vào
|
|
5
5
|
* giữa câu.
|
|
6
6
|
*/
|
|
7
7
|
deleteLabel: (value: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Câu vùng sống của `TagsInput` đọc khi một thẻ được tô bằng ← / → / Backspace (4.8.0) — prop
|
|
10
|
+
* `highlightedLabel`. Tiêu điểm vẫn ở ô gõ, nên đây là cách DUY NHẤT người dùng trình đọc màn hình
|
|
11
|
+
* biết phím Backspace kế tiếp sẽ xoá thẻ nào. HÀM vì giá trị thẻ chèn vào câu.
|
|
12
|
+
*/
|
|
13
|
+
highlightedLabel: (value: string) => string;
|
|
8
14
|
}
|
|
9
15
|
declare const tagsInputEn: TagsInputMessages;
|
|
10
16
|
declare const tagsInputVi: TagsInputMessages;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const tagsInputEn = {
|
|
2
|
-
deleteLabel: (value) => `Remove ${value}
|
|
2
|
+
deleteLabel: (value) => `Remove ${value}`,
|
|
3
|
+
highlightedLabel: (value) => `${value}, press Backspace to remove`
|
|
3
4
|
};
|
|
4
5
|
const tagsInputVi = {
|
|
5
|
-
deleteLabel: (value) => `Xo\xE1 th\u1EBB ${value}
|
|
6
|
+
deleteLabel: (value) => `Xo\xE1 th\u1EBB ${value}`,
|
|
7
|
+
highlightedLabel: (value) => `${value}, nh\u1EA5n Backspace \u0111\u1EC3 xo\xE1`
|
|
6
8
|
};
|
|
7
9
|
export {
|
|
8
10
|
tagsInputEn,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/i18n/namespaces/tags-input.ts"],"sourcesContent":["/** Chữ của `TagsInputItem`. */\nexport interface TagsInputMessages {\n /**\n * Tên cho trình đọc màn hình của nút xoá thẻ — prop `deleteLabel`. HÀM vì giá trị thẻ chèn vào\n * giữa câu.\n */\n deleteLabel: (value: string) => string;\n}\n\nexport const tagsInputEn: TagsInputMessages = {\n deleteLabel: (value) => `Remove ${value}`\n};\n\nexport const tagsInputVi: TagsInputMessages = {\n deleteLabel: (value) => `Xoá thẻ ${value}
|
|
1
|
+
{"version":3,"sources":["../../../src/i18n/namespaces/tags-input.ts"],"sourcesContent":["/** Chữ của `TagsInput` / `TagsInputItem`. */\nexport interface TagsInputMessages {\n /**\n * Tên cho trình đọc màn hình của nút xoá thẻ — prop `deleteLabel`. HÀM vì giá trị thẻ chèn vào\n * giữa câu.\n */\n deleteLabel: (value: string) => string;\n /**\n * Câu vùng sống của `TagsInput` đọc khi một thẻ được tô bằng ← / → / Backspace (4.8.0) — prop\n * `highlightedLabel`. Tiêu điểm vẫn ở ô gõ, nên đây là cách DUY NHẤT người dùng trình đọc màn hình\n * biết phím Backspace kế tiếp sẽ xoá thẻ nào. HÀM vì giá trị thẻ chèn vào câu.\n */\n highlightedLabel: (value: string) => string;\n}\n\nexport const tagsInputEn: TagsInputMessages = {\n deleteLabel: (value) => `Remove ${value}`,\n highlightedLabel: (value) => `${value}, press Backspace to remove`\n};\n\nexport const tagsInputVi: TagsInputMessages = {\n deleteLabel: (value) => `Xoá thẻ ${value}`,\n highlightedLabel: (value) => `${value}, nhấn Backspace để xoá`\n};\n"],"mappings":"AAeO,MAAM,cAAiC;AAAA,EAC5C,aAAa,CAAC,UAAU,UAAU,KAAK;AAAA,EACvC,kBAAkB,CAAC,UAAU,GAAG,KAAK;AACvC;AAEO,MAAM,cAAiC;AAAA,EAC5C,aAAa,CAAC,UAAU,mBAAW,KAAK;AAAA,EACxC,kBAAkB,CAAC,UAAU,GAAG,KAAK;AACvC;","names":[]}
|
package/package.json
CHANGED