@comitor/ui 3.17.1 → 3.17.3

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 CHANGED
@@ -359,7 +359,7 @@ https://design-system.comitor.ai/foundations/colors
359
359
 
360
360
  Mỗi bản publish đi qua cùng một chuỗi cổng (`prepublishOnly` nối chúng lại): typecheck → build →
361
361
  `verify:directives` → `smoke:entries` → `check:exports` → `test:nav-active` → `test:grid-contract`
362
- → `test:grid-render` → `test:editor-markdown` → `test:gantt-tree` → `test:a11y-gate` → `lint:a11y` → `lint:palettes`. Những cổng đáng để người dùng gói biết là chúng tồn tại:
362
+ → `test:grid-render` → `test:editor-markdown` → `test:gantt-tree` → `test:dom-render` → `test:a11y-gate` → `lint:a11y` → `lint:palettes`. Những cổng đáng để người dùng gói biết là chúng tồn tại:
363
363
 
364
364
  - **`lint:a11y` — hợp đồng màu.** Quét **toàn bộ** `src/**/*.{ts,tsx}` theo QUY TẮC (không theo danh
365
365
  sách phát hiện) và đối chiếu với `styles.css`: token TÔ NỀN đem làm màu chữ/icon/viền là sai
@@ -384,7 +384,8 @@ Mỗi bản publish đi qua cùng một chuỗi cổng (`prepublishOnly` nối c
384
384
  file `dist/` tương ứng phải mở đầu y hệt (thiếu file build cũng tính là hỏng), và không hằng dữ
385
385
  liệu thuần nào được kẹt trong file client (§4.2).
386
386
  - **`smoke:entries`** nạp cả 9 entry bằng Node ESM thuần, qua đúng `exports` map (§3) — và sau đó quét `dist` tìm
387
- class mẫu Tailwind có giá trị giữ chỗ (từ `3.17.1`), thứ mà Tailwind của app đọc thành CSS hỏng.
387
+ class mẫu Tailwind có giá trị giữ chỗ (từ `3.17.1`), thứ mà Tailwind của app đọc thành CSS hỏng. Từ `3.17.2` nó còn
388
+ phân giải cả 9 entry theo điều kiện `require` — đường webpack đi khi app nạp một entry bằng `next/dynamic`.
388
389
  - **`test:editor-markdown`** — markdown là định dạng LƯU của `MarkdownEditor`, nên phép đo là tài liệu →
389
390
  markdown → tài liệu phải ra đúng tài liệu ban đầu, trên CHÍNH lược đồ trong `dist/`. Lỗi loại này không lộ
390
391
  ra lúc gõ mà ở lần mở sau. Trên lược đồ gốc của Tiptap (chưa vá) cổng trượt 16/46 — [docs/editor.md](docs/editor.md) §5.
@@ -393,6 +394,9 @@ Mỗi bản publish đi qua cùng một chuỗi cổng (`prepublishOnly` nối c
393
394
  - **`test:gantt-tree`** (từ `3.12.0`) — toán NGÀY của `Gantt` (lệch một ngày không ném, chỉ vẽ thanh lệch một
394
395
  ô: cuối tháng, năm nhuận, đầu tuần), luật vi phạm phụ thuộc, đường đi của mũi tên, hợp đồng `moveTreeItems`
395
396
  của `TreeView` (index tính SAU khi gỡ mục đang chuyển), cộng dồn, đánh số, và render server của ba tầng mới.
397
+ - **`test:dom-render`** (từ `3.17.3`) — render PHÍA CLIENT trên `happy-dom`: mount rồi ĐỔI prop trên cùng root.
398
+ Mọi cổng khác render server một lượt, nên mù với lỗi "đúng lúc đầu, sai sau một lần đổi" — ca sinh ra nó là ô
399
+ avatar rỗng khi đổi từ workspace có logo sang workspace không logo. Không thay cho trình duyệt thật.
396
400
  - **`test:a11y-gate`** tự kiểm chính cổng màu (cổng còn bắt đủ không); **`test:nav-active`** khoá
397
401
  toàn bộ luật active matching của sidebar dưới dạng hàm thuần (§4.1).
398
402
  - **`test:grid-render`** render THẬT `DataGrid` bằng `react-dom/server` rồi soi HTML ra được. Nó
@@ -4,7 +4,23 @@ import * as React from 'react';
4
4
  type AvatarProps = React.ComponentProps<typeof AvatarPrimitive.Root>;
5
5
  type AvatarImageProps = React.ComponentProps<typeof AvatarPrimitive.Image>;
6
6
  type AvatarFallbackProps = React.ComponentProps<typeof AvatarPrimitive.Fallback>;
7
- declare function Avatar({ className, ...props }: AvatarProps): React.JSX.Element;
7
+ /**
8
+ * ⚠ Khác Radix gốc: Root được dựng lại khi `AvatarImage` con TRỰC TIẾP xuất hiện/biến mất.
9
+ *
10
+ * Radix giữ `imageLoadingStatus` ở Root, và `AvatarImage` khi unmount KHÔNG trả nó về `"idle"`. Khuôn
11
+ * `{url ? <AvatarImage src={url} /> : null}` trên một avatar được TÁI DÙNG (đổi workspace, đổi người)
12
+ * vì vậy kẹt ở `"loaded"`: ảnh đã gỡ mà `AvatarFallback` không render — ô rỗng, không lỗi. Tải lại
13
+ * trang thì đúng, HTML server cũng đúng, nên chỉ lộ ra sau một lần đổi prop (3.17.3, đo ở
14
+ * Comitor.Account; cổng `test:dom-render` khoá lại).
15
+ *
16
+ * `key` theo việc CÓ ảnh hay không (không theo `src`): đổi ảnh A → ảnh B thì Radix đã tự về
17
+ * `"loading"`, dựng lại là thừa. Đọc ở render từ chính `children` — không effect, không state, nên
18
+ * StrictMode không lặp. Chỉ thấy `AvatarImage` của gói nằm thẳng trong `children` (kể cả mảng);
19
+ * bọc nó trong component riêng thì tự gắn `key` lên `<Avatar>`. Cùng lý do, `<Avatar>` viết thẳng trong
20
+ * Server Component KHÔNG được che: RSC đổi kiểu `AvatarImage` thành tham chiếu lazy nên phép so kiểu
21
+ * hụt (như `lib/collect-item-elements`) — chỗ đó cũng tự gắn `key`.
22
+ */
23
+ declare function Avatar({ className, children, ...props }: AvatarProps): React.JSX.Element;
8
24
  declare function AvatarImage({ className, ...props }: AvatarImageProps): React.JSX.Element;
9
25
  declare function AvatarFallback({ className, ...props }: AvatarFallbackProps): React.JSX.Element;
10
26
 
@@ -1,15 +1,21 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import * as AvatarPrimitive from "@radix-ui/react-avatar";
4
+ import * as React from "react";
4
5
  import { cn } from "../../lib/cn.js";
5
- function Avatar({ className, ...props }) {
6
+ function Avatar({ className, children, ...props }) {
7
+ const hasImage = React.Children.toArray(children).some(
8
+ (child) => React.isValidElement(child) && child.type === AvatarImage
9
+ );
6
10
  return /* @__PURE__ */ jsx(
7
11
  AvatarPrimitive.Root,
8
12
  {
9
13
  "data-slot": "avatar",
10
14
  className: cn("relative flex size-8 shrink-0 overflow-hidden rounded-full", className),
11
- ...props
12
- }
15
+ ...props,
16
+ children
17
+ },
18
+ hasImage ? "image" : "no-image"
13
19
  );
14
20
  }
15
21
  function AvatarImage({ className, ...props }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ui/avatar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as AvatarPrimitive from \"@radix-ui/react-avatar\";\nimport type * as React from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\nexport type AvatarProps = React.ComponentProps<typeof AvatarPrimitive.Root>;\nexport type AvatarImageProps = React.ComponentProps<typeof AvatarPrimitive.Image>;\nexport type AvatarFallbackProps = React.ComponentProps<typeof AvatarPrimitive.Fallback>;\n\nfunction Avatar({ className, ...props }: AvatarProps) {\n return (\n <AvatarPrimitive.Root\n data-slot=\"avatar\"\n className={cn(\"relative flex size-8 shrink-0 overflow-hidden rounded-full\", className)}\n {...props}\n />\n );\n}\n\nfunction AvatarImage({ className, ...props }: AvatarImageProps) {\n return (\n <AvatarPrimitive.Image data-slot=\"avatar-image\" className={cn(\"aspect-square size-full\", className)} {...props} />\n );\n}\n\nfunction AvatarFallback({ className, ...props }: AvatarFallbackProps) {\n return (\n <AvatarPrimitive.Fallback\n data-slot=\"avatar-fallback\"\n className={cn(\"bg-muted flex size-full items-center justify-center rounded-full\", className)}\n {...props}\n />\n );\n}\n\nexport { Avatar, AvatarFallback, AvatarImage };\n"],"mappings":";AAYI;AAVJ,YAAY,qBAAqB;AAEjC,SAAS,UAAU;AAMnB,SAAS,OAAO,EAAE,WAAW,GAAG,MAAM,GAAgB;AACpD,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,8DAA8D,SAAS;AAAA,MACpF,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAqB;AAC9D,SACE,oBAAC,gBAAgB,OAAhB,EAAsB,aAAU,gBAAe,WAAW,GAAG,2BAA2B,SAAS,GAAI,GAAG,OAAO;AAEpH;AAEA,SAAS,eAAe,EAAE,WAAW,GAAG,MAAM,GAAwB;AACpE,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,oEAAoE,SAAS;AAAA,MAC1F,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/ui/avatar.tsx"],"sourcesContent":["\"use client\";\n\nimport * as AvatarPrimitive from \"@radix-ui/react-avatar\";\nimport * as React from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\nexport type AvatarProps = React.ComponentProps<typeof AvatarPrimitive.Root>;\nexport type AvatarImageProps = React.ComponentProps<typeof AvatarPrimitive.Image>;\nexport type AvatarFallbackProps = React.ComponentProps<typeof AvatarPrimitive.Fallback>;\n\n/**\n * ⚠ Khác Radix gốc: Root được dựng lại khi `AvatarImage` con TRỰC TIẾP xuất hiện/biến mất.\n *\n * Radix giữ `imageLoadingStatus` ở Root, và `AvatarImage` khi unmount KHÔNG trả nó về `\"idle\"`. Khuôn\n * `{url ? <AvatarImage src={url} /> : null}` trên một avatar được TÁI DÙNG (đổi workspace, đổi người)\n * vì vậy kẹt ở `\"loaded\"`: ảnh đã gỡ mà `AvatarFallback` không render — ô rỗng, không lỗi. Tải lại\n * trang thì đúng, HTML server cũng đúng, nên chỉ lộ ra sau một lần đổi prop (3.17.3, đo ở\n * Comitor.Account; cổng `test:dom-render` khoá lại).\n *\n * `key` theo việc CÓ ảnh hay không (không theo `src`): đổi ảnh A → ảnh B thì Radix đã tự về\n * `\"loading\"`, dựng lại là thừa. Đọc ở render từ chính `children` — không effect, không state, nên\n * StrictMode không lặp. Chỉ thấy `AvatarImage` của gói nằm thẳng trong `children` (kể cả mảng);\n * bọc nó trong component riêng thì tự gắn `key` lên `<Avatar>`. Cùng lý do, `<Avatar>` viết thẳng trong\n * Server Component KHÔNG được che: RSC đổi kiểu `AvatarImage` thành tham chiếu lazy nên phép so kiểu\n * hụt (như `lib/collect-item-elements`) — chỗ đó cũng tự gắn `key`.\n */\nfunction Avatar({ className, children, ...props }: AvatarProps) {\n const hasImage = React.Children.toArray(children).some(\n (child) => React.isValidElement(child) && child.type === AvatarImage\n );\n return (\n <AvatarPrimitive.Root\n key={hasImage ? \"image\" : \"no-image\"}\n data-slot=\"avatar\"\n className={cn(\"relative flex size-8 shrink-0 overflow-hidden rounded-full\", className)}\n {...props}\n >\n {children}\n </AvatarPrimitive.Root>\n );\n}\n\nfunction AvatarImage({ className, ...props }: AvatarImageProps) {\n return (\n <AvatarPrimitive.Image data-slot=\"avatar-image\" className={cn(\"aspect-square size-full\", className)} {...props} />\n );\n}\n\nfunction AvatarFallback({ className, ...props }: AvatarFallbackProps) {\n return (\n <AvatarPrimitive.Fallback\n data-slot=\"avatar-fallback\"\n className={cn(\"bg-muted flex size-full items-center justify-center rounded-full\", className)}\n {...props}\n />\n );\n}\n\nexport { Avatar, AvatarFallback, AvatarImage };\n"],"mappings":";AA+BI;AA7BJ,YAAY,qBAAqB;AACjC,YAAY,WAAW;AACvB,SAAS,UAAU;AAsBnB,SAAS,OAAO,EAAE,WAAW,UAAU,GAAG,MAAM,GAAgB;AAC9D,QAAM,WAAW,MAAM,SAAS,QAAQ,QAAQ,EAAE;AAAA,IAChD,CAAC,UAAU,MAAM,eAAe,KAAK,KAAK,MAAM,SAAS;AAAA,EAC3D;AACA,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MAEC,aAAU;AAAA,MACV,WAAW,GAAG,8DAA8D,SAAS;AAAA,MACpF,GAAG;AAAA,MAEH;AAAA;AAAA,IALI,WAAW,UAAU;AAAA,EAM5B;AAEJ;AAEA,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAqB;AAC9D,SACE,oBAAC,gBAAgB,OAAhB,EAAsB,aAAU,gBAAe,WAAW,GAAG,2BAA2B,SAAS,GAAI,GAAG,OAAO;AAEpH;AAEA,SAAS,eAAe,EAAE,WAAW,GAAG,MAAM,GAAwB;AACpE,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,oEAAoE,SAAS;AAAA,MAC1F,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comitor/ui",
3
- "version": "3.17.1",
3
+ "version": "3.17.3",
4
4
  "description": "Comitor design system — Shadcn/UI tùy biến theo brand Comitor + component dùng chung cho hệ sinh thái SaaS (Tasks, Chat, CRM, HR…)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,39 +32,48 @@
32
32
  "exports": {
33
33
  ".": {
34
34
  "types": "./dist/index.d.ts",
35
- "import": "./dist/index.js"
35
+ "import": "./dist/index.js",
36
+ "default": "./dist/index.js"
36
37
  },
37
38
  "./shell": {
38
39
  "types": "./dist/shell/index.d.ts",
39
- "import": "./dist/shell/index.js"
40
+ "import": "./dist/shell/index.js",
41
+ "default": "./dist/shell/index.js"
40
42
  },
41
43
  "./chart": {
42
44
  "types": "./dist/chart/index.d.ts",
43
- "import": "./dist/chart/index.js"
45
+ "import": "./dist/chart/index.js",
46
+ "default": "./dist/chart/index.js"
44
47
  },
45
48
  "./data-grid": {
46
49
  "types": "./dist/data-grid/index.d.ts",
47
- "import": "./dist/data-grid/index.js"
50
+ "import": "./dist/data-grid/index.js",
51
+ "default": "./dist/data-grid/index.js"
48
52
  },
49
53
  "./uploader": {
50
54
  "types": "./dist/uploader/index.d.ts",
51
- "import": "./dist/uploader/index.js"
55
+ "import": "./dist/uploader/index.js",
56
+ "default": "./dist/uploader/index.js"
52
57
  },
53
58
  "./editor": {
54
59
  "types": "./dist/editor/index.d.ts",
55
- "import": "./dist/editor/index.js"
60
+ "import": "./dist/editor/index.js",
61
+ "default": "./dist/editor/index.js"
56
62
  },
57
63
  "./chat": {
58
64
  "types": "./dist/chat/index.d.ts",
59
- "import": "./dist/chat/index.js"
65
+ "import": "./dist/chat/index.js",
66
+ "default": "./dist/chat/index.js"
60
67
  },
61
68
  "./form": {
62
69
  "types": "./dist/form.d.ts",
63
- "import": "./dist/form.js"
70
+ "import": "./dist/form.js",
71
+ "default": "./dist/form.js"
64
72
  },
65
73
  "./tokens": {
66
74
  "types": "./dist/tokens.d.ts",
67
- "import": "./dist/tokens.js"
75
+ "import": "./dist/tokens.js",
76
+ "default": "./dist/tokens.js"
68
77
  },
69
78
  "./styles.css": "./styles.css",
70
79
  "./package.json": "./package.json"
@@ -82,10 +91,11 @@
82
91
  "test:grid-render": "node scripts/check-data-grid-render.mjs",
83
92
  "test:editor-markdown": "node scripts/check-editor-markdown.mjs",
84
93
  "test:gantt-tree": "node scripts/check-gantt-tree.mjs",
94
+ "test:dom-render": "node scripts/check-dom-render.mjs",
85
95
  "verify:directives": "node scripts/verify-directives.mjs",
86
96
  "smoke:entries": "node scripts/smoke-entries.mjs",
87
97
  "check:exports": "publint --strict && attw --pack . --profile esm-only --exclude-entrypoints styles.css",
88
- "prepublishOnly": "pnpm run typecheck && pnpm run test:i18n && pnpm run build && pnpm run verify:directives && pnpm run smoke:entries && pnpm run check:exports && pnpm run test:nav-active && pnpm run test:grid-contract && pnpm run test:grid-render && pnpm run test:editor-markdown && pnpm run test:gantt-tree && pnpm run test:a11y-gate && pnpm run lint:a11y && pnpm run lint:palettes",
98
+ "prepublishOnly": "pnpm run typecheck && pnpm run test:i18n && pnpm run build && pnpm run verify:directives && pnpm run smoke:entries && pnpm run check:exports && pnpm run test:nav-active && pnpm run test:grid-contract && pnpm run test:grid-render && pnpm run test:editor-markdown && pnpm run test:gantt-tree && pnpm run test:dom-render && pnpm run test:a11y-gate && pnpm run lint:a11y && pnpm run lint:palettes",
89
99
  "test:grid-contract": "node scripts/check-grid-contract.mjs",
90
100
  "test:i18n": "node scripts/check-i18n.mjs --self-test && node scripts/check-i18n.mjs"
91
101
  },
@@ -257,6 +267,7 @@
257
267
  "@types/react-dom": "^19.0.0",
258
268
  "@uppy/core": "^6.0.0",
259
269
  "@uppy/xhr-upload": "^6.0.0",
270
+ "happy-dom": "^21.0.4",
260
271
  "highlight.js": "^11.11.1",
261
272
  "lowlight": "^3.3.0",
262
273
  "lucide-react": "^1.41.0",