@comitor/ui 3.17.2 → 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
@@ -394,6 +394,9 @@ Mỗi bản publish đi qua cùng một chuỗi cổng (`prepublishOnly` nối c
394
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
395
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`
396
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.
397
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á
398
401
  toàn bộ luật active matching của sidebar dưới dạng hàm thuần (§4.1).
399
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.2",
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",
@@ -91,10 +91,11 @@
91
91
  "test:grid-render": "node scripts/check-data-grid-render.mjs",
92
92
  "test:editor-markdown": "node scripts/check-editor-markdown.mjs",
93
93
  "test:gantt-tree": "node scripts/check-gantt-tree.mjs",
94
+ "test:dom-render": "node scripts/check-dom-render.mjs",
94
95
  "verify:directives": "node scripts/verify-directives.mjs",
95
96
  "smoke:entries": "node scripts/smoke-entries.mjs",
96
97
  "check:exports": "publint --strict && attw --pack . --profile esm-only --exclude-entrypoints styles.css",
97
- "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",
98
99
  "test:grid-contract": "node scripts/check-grid-contract.mjs",
99
100
  "test:i18n": "node scripts/check-i18n.mjs --self-test && node scripts/check-i18n.mjs"
100
101
  },
@@ -266,6 +267,7 @@
266
267
  "@types/react-dom": "^19.0.0",
267
268
  "@uppy/core": "^6.0.0",
268
269
  "@uppy/xhr-upload": "^6.0.0",
270
+ "happy-dom": "^21.0.4",
269
271
  "highlight.js": "^11.11.1",
270
272
  "lowlight": "^3.3.0",
271
273
  "lucide-react": "^1.41.0",