@comitor/ui 3.18.0 → 3.19.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 +16 -5
- package/dist/components/composite/delta-badge.d.ts +21 -0
- package/dist/components/composite/delta-badge.js +29 -0
- package/dist/components/composite/delta-badge.js.map +1 -0
- package/dist/components/composite/empty-state.d.ts +8 -2
- package/dist/components/composite/empty-state.js +14 -2
- package/dist/components/composite/empty-state.js.map +1 -1
- package/dist/components/composite/heat-scale.d.ts +57 -0
- package/dist/components/composite/heat-scale.js +105 -0
- package/dist/components/composite/heat-scale.js.map +1 -0
- package/dist/components/composite/page-container.js +11 -1
- package/dist/components/composite/page-container.js.map +1 -1
- package/dist/components/composite/page-header.js +10 -5
- package/dist/components/composite/page-header.js.map +1 -1
- package/dist/components/composite/rank-bar-list.d.ts +38 -0
- package/dist/components/composite/rank-bar-list.js +41 -0
- package/dist/components/composite/rank-bar-list.js.map +1 -0
- package/dist/components/composite/rating-stars.d.ts +25 -0
- package/dist/components/composite/rating-stars.js +41 -0
- package/dist/components/composite/rating-stars.js.map +1 -0
- package/dist/components/composite/stat-card.d.ts +40 -2
- package/dist/components/composite/stat-card.js +76 -4
- package/dist/components/composite/stat-card.js.map +1 -1
- package/dist/components/composite/status-pill.d.ts +6 -1
- package/dist/components/composite/status-pill.js +49 -0
- package/dist/components/composite/status-pill.js.map +1 -1
- package/dist/components/composite/text.d.ts +41 -0
- package/dist/components/composite/text.js +86 -0
- package/dist/components/composite/text.js.map +1 -0
- package/dist/components/composite/urgency-text.d.ts +20 -0
- package/dist/components/composite/urgency-text.js +28 -0
- package/dist/components/composite/urgency-text.js.map +1 -0
- package/dist/components/ui/accordion.d.ts +3 -0
- package/dist/components/ui/accordion.js +3 -0
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/alert.d.ts +3 -2
- package/dist/components/ui/alert.js +38 -4
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/avatar.js +4 -1
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/badge.d.ts +3 -2
- package/dist/components/ui/badge.js +46 -28
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/button.js +4 -4
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/card.d.ts +15 -26
- package/dist/components/ui/card.js +64 -11
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +10 -1
- package/dist/components/ui/collapsible.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js +3 -3
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/item.d.ts +11 -4
- package/dist/components/ui/item.js +73 -10
- package/dist/components/ui/item.js.map +1 -1
- package/dist/components/ui/progress.d.ts +24 -2
- package/dist/components/ui/progress.js +81 -6
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/table.d.ts +19 -5
- package/dist/components/ui/table.js +34 -14
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/time-picker.js +23 -3
- package/dist/components/ui/time-picker.js.map +1 -1
- package/dist/data-grid/data-grid-row-height-menu.js +4 -1
- package/dist/data-grid/data-grid-row-height-menu.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/use-has-mounted.d.ts +3 -0
- package/dist/lib/use-has-mounted.js +12 -0
- package/dist/lib/use-has-mounted.js.map +1 -0
- package/dist/shell/app-header.d.ts +17 -1
- package/dist/shell/app-header.js +88 -37
- package/dist/shell/app-header.js.map +1 -1
- package/dist/shell/comitor-lockup.d.ts +3 -2
- package/dist/shell/comitor-lockup.js.map +1 -1
- package/dist/shell/header-tool.d.ts +12 -0
- package/dist/shell/header-tool.js +5 -0
- package/dist/shell/header-tool.js.map +1 -0
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.js +1 -0
- package/dist/shell/index.js.map +1 -1
- package/dist/shell/module-switcher.d.ts +7 -1
- package/dist/shell/module-switcher.js +51 -9
- package/dist/shell/module-switcher.js.map +1 -1
- package/dist/shell/notifications-button.d.ts +6 -1
- package/dist/shell/notifications-button.js +20 -2
- package/dist/shell/notifications-button.js.map +1 -1
- package/dist/shell/shell-context.d.ts +13 -1
- package/dist/shell/shell-context.js +21 -3
- package/dist/shell/shell-context.js.map +1 -1
- package/dist/shell/sidebar-group.js +8 -7
- package/dist/shell/sidebar-group.js.map +1 -1
- package/dist/shell/sidebar-menu-item.js +39 -11
- package/dist/shell/sidebar-menu-item.js.map +1 -1
- package/dist/shell/sidebar.d.ts +18 -1
- package/dist/shell/sidebar.js +29 -9
- package/dist/shell/sidebar.js.map +1 -1
- package/dist/shell/theme-toggle.js +2 -0
- package/dist/shell/theme-toggle.js.map +1 -1
- package/dist/tokens.d.ts +36 -9
- package/dist/tokens.js +21 -8
- package/dist/tokens.js.map +1 -1
- package/package.json +1 -1
- package/styles.css +442 -13
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const STAR_SIZE: {
|
|
5
|
+
readonly xs: "size-[11px]";
|
|
6
|
+
readonly sm: "size-[13px]";
|
|
7
|
+
readonly md: "size-[17px]";
|
|
8
|
+
readonly lg: "size-5";
|
|
9
|
+
};
|
|
10
|
+
interface RatingStarsProps extends Omit<ComponentProps<"span">, "children"> {
|
|
11
|
+
/** Điểm 0…`max`; sao thứ i "bật" khi `value ≥ i` (v4 làm tròn xuống — không nửa sao). */
|
|
12
|
+
value: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
size?: keyof typeof STAR_SIZE;
|
|
15
|
+
/** Tên trợ năng ("4,5 trên 5 sao") — câu của app, theo ngôn ngữ của app. Gói không có câu mặc định. */
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Năm sao CHỈ ĐỂ ĐỌC (3.19.0, bản mẫu Imagtor v4 `.stars`). Bản cho người dùng CHẤM là `Rating` (Tier 1).
|
|
20
|
+
* Sao bật tô đặc `--warning-ink` (v4 `--warn`; bậc ink vì icon là phi văn bản trên nền trang, và token tô nền `--warning`
|
|
21
|
+
* không được làm màu icon — hợp đồng §1), sao tắt là viền `--muted-foreground`. Tĩnh.
|
|
22
|
+
*/
|
|
23
|
+
declare function RatingStars({ value, max, size, label, className, ...props }: RatingStarsProps): React.JSX.Element;
|
|
24
|
+
|
|
25
|
+
export { RatingStars, type RatingStarsProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Star } from "lucide-react";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
const STAR_SIZE = {
|
|
5
|
+
xs: "size-[11px]",
|
|
6
|
+
sm: "size-[13px]",
|
|
7
|
+
md: "size-[17px]",
|
|
8
|
+
lg: "size-5"
|
|
9
|
+
};
|
|
10
|
+
function RatingStars({ value, max = 5, size = "sm", label, className, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"span",
|
|
13
|
+
{
|
|
14
|
+
role: "img",
|
|
15
|
+
"aria-label": label,
|
|
16
|
+
"data-slot": "rating-stars",
|
|
17
|
+
className: cn("inline-flex items-center gap-px", className),
|
|
18
|
+
...props,
|
|
19
|
+
children: Array.from({ length: max }, (_, i) => {
|
|
20
|
+
const on = value >= i + 1;
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
Star,
|
|
23
|
+
{
|
|
24
|
+
"aria-hidden": "true",
|
|
25
|
+
"data-on": on || void 0,
|
|
26
|
+
className: cn(
|
|
27
|
+
"shrink-0",
|
|
28
|
+
STAR_SIZE[size],
|
|
29
|
+
on ? "fill-current text-warning-ink" : "fill-transparent text-muted-foreground"
|
|
30
|
+
)
|
|
31
|
+
},
|
|
32
|
+
i
|
|
33
|
+
);
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
RatingStars
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=rating-stars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/composite/rating-stars.tsx"],"sourcesContent":["import { Star } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\nconst STAR_SIZE = {\n xs: \"size-[11px]\",\n sm: \"size-[13px]\",\n md: \"size-[17px]\",\n lg: \"size-5\"\n} as const;\n\nexport interface RatingStarsProps extends Omit<ComponentProps<\"span\">, \"children\"> {\n /** Điểm 0…`max`; sao thứ i \"bật\" khi `value ≥ i` (v4 làm tròn xuống — không nửa sao). */\n value: number;\n max?: number;\n size?: keyof typeof STAR_SIZE;\n /** Tên trợ năng (\"4,5 trên 5 sao\") — câu của app, theo ngôn ngữ của app. Gói không có câu mặc định. */\n label: string;\n}\n\n/**\n * Năm sao CHỈ ĐỂ ĐỌC (3.19.0, bản mẫu Imagtor v4 `.stars`). Bản cho người dùng CHẤM là `Rating` (Tier 1).\n * Sao bật tô đặc `--warning-ink` (v4 `--warn`; bậc ink vì icon là phi văn bản trên nền trang, và token tô nền `--warning`\n * không được làm màu icon — hợp đồng §1), sao tắt là viền `--muted-foreground`. Tĩnh.\n */\nexport function RatingStars({ value, max = 5, size = \"sm\", label, className, ...props }: RatingStarsProps) {\n return (\n <span\n role=\"img\"\n aria-label={label}\n data-slot=\"rating-stars\"\n className={cn(\"inline-flex items-center gap-px\", className)}\n {...props}\n >\n {Array.from({ length: max }, (_, i) => {\n const on = value >= i + 1;\n return (\n <Star\n // biome-ignore lint/suspicious/noArrayIndexKey: số sao cố định, vị trí là danh tính\n key={i}\n aria-hidden=\"true\"\n data-on={on || undefined}\n className={cn(\n \"shrink-0\",\n STAR_SIZE[size],\n on ? \"fill-current text-warning-ink\" : \"fill-transparent text-muted-foreground\"\n )}\n />\n );\n })}\n </span>\n );\n}\n"],"mappings":"AAqCU;AArCV,SAAS,YAAY;AAErB,SAAS,UAAU;AAEnB,MAAM,YAAY;AAAA,EAChB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAgBO,SAAS,YAAY,EAAE,OAAO,MAAM,GAAG,OAAO,MAAM,OAAO,WAAW,GAAG,MAAM,GAAqB;AACzG,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,aAAU;AAAA,MACV,WAAW,GAAG,mCAAmC,SAAS;AAAA,MACzD,GAAG;AAAA,MAEH,gBAAM,KAAK,EAAE,QAAQ,IAAI,GAAG,CAAC,GAAG,MAAM;AACrC,cAAM,KAAK,SAAS,IAAI;AACxB,eACE;AAAA,UAAC;AAAA;AAAA,YAGC,eAAY;AAAA,YACZ,WAAS,MAAM;AAAA,YACf,WAAW;AAAA,cACT;AAAA,cACA,UAAU,IAAI;AAAA,cACd,KAAK,kCAAkC;AAAA,YACzC;AAAA;AAAA,UAPK;AAAA,QAQP;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -55,12 +55,50 @@ interface StatCardProps extends Omit<ComponentProps<"div">, "title"> {
|
|
|
55
55
|
footer?: ReactNode;
|
|
56
56
|
/** Đang tải → khung xương thay cho số liệu */
|
|
57
57
|
loading?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Khung (3.19.0). `"card"` (mặc định) = thẻ viền bo góc như trước. `"tile"` = ô của `StatCardGroup` (không viền, không
|
|
60
|
+
* bo góc — nhóm vẽ khung chung và vạch 1px giữa các ô; bản mẫu Imagtor v4 `.kpic`). `"plain"` = chỉ nhãn + số, không
|
|
61
|
+
* nền, không đệm — ô của một lưới chỉ số nhỏ trong thân thẻ (v4 `.qgrid`).
|
|
62
|
+
*/
|
|
63
|
+
variant?: StatCardVariant;
|
|
64
|
+
/** Cỡ số liệu (3.19.0): `"md"` theo token `--stat-value-*`, `"sm"` 22px — chỉ số phụ trong thân thẻ. */
|
|
65
|
+
size?: "md" | "sm";
|
|
58
66
|
}
|
|
67
|
+
type StatCardVariant = "card" | "tile" | "plain";
|
|
59
68
|
/**
|
|
60
69
|
* Thẻ KPI: nhãn + số liệu lớn + biến động + sparkline tuỳ chọn.
|
|
61
70
|
*
|
|
62
71
|
* Số liệu dùng `tabular-nums` để cột số không nhảy khi cập nhật realtime. Tĩnh → RSC-safe.
|
|
63
72
|
*/
|
|
64
|
-
declare function StatCard({ label, value, icon: Icon, tone, delta, sparkline, footer, loading, className, ...props }: StatCardProps): React.JSX.Element;
|
|
73
|
+
declare function StatCard({ label, value, icon: Icon, tone, delta, sparkline, footer, loading, variant, size, className, ...props }: StatCardProps): React.JSX.Element;
|
|
74
|
+
interface StatCardGroupProps extends ComponentProps<"div"> {
|
|
75
|
+
/** Số cột khi khung chứa ≥ 900px (2 cột từ 520px, 1 cột dưới đó — đo theo KHUNG CHỨA, không theo màn hình). */
|
|
76
|
+
columns?: 2 | 3 | 4;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Hàng KPI dính liền (3.19.0, bản mẫu Imagtor v4 `.kpirow`): MỘT khung bo góc, các ô `StatCard variant="tile"` cách
|
|
80
|
+
* nhau vạch 1px (`gap-px` trên nền `--border`). Tự là `@container`, nên số liệu `cqw` của token `--stat-value-size`
|
|
81
|
+
* (bộ green) co theo bề rộng hàng.
|
|
82
|
+
*
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <StatCardGroup>
|
|
85
|
+
* <StatCard variant="tile" label="Job hôm nay" value="128" footer="+12 so với hôm qua" />
|
|
86
|
+
* …
|
|
87
|
+
* </StatCardGroup>
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function StatCardGroup({ columns, className, children, ...props }: StatCardGroupProps): React.JSX.Element;
|
|
91
|
+
interface MetricProps extends Omit<ComponentProps<"span">, "children"> {
|
|
92
|
+
value: ReactNode;
|
|
93
|
+
/** Đơn vị/chú thích đứng sau số, cùng đường chân chữ ("phút", "/ 750"). */
|
|
94
|
+
unit?: ReactNode;
|
|
95
|
+
/** `"md"` theo token `--stat-value-*` (cùng cỡ số của `StatCard`), `"sm"` 24px. */
|
|
96
|
+
size?: "md" | "sm";
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Con số lớn rời (3.19.0, bản mẫu Imagtor v4 `.bignum`) — cùng kiểu chữ với số của `StatCard`, không khung.
|
|
100
|
+
* Tĩnh → RSC-safe.
|
|
101
|
+
*/
|
|
102
|
+
declare function Metric({ value, unit, size, className, ...props }: MetricProps): React.JSX.Element;
|
|
65
103
|
|
|
66
|
-
export { StatCard, type StatCardDelta, type StatCardDeltaDirection, type StatCardProps, type StatCardTone, statCardIconVariants };
|
|
104
|
+
export { Metric, type MetricProps, StatCard, type StatCardDelta, type StatCardDeltaDirection, StatCardGroup, type StatCardGroupProps, type StatCardProps, type StatCardTone, type StatCardVariant, statCardIconVariants };
|
|
@@ -48,24 +48,43 @@ function StatCard({
|
|
|
48
48
|
sparkline,
|
|
49
49
|
footer,
|
|
50
50
|
loading = false,
|
|
51
|
+
variant = "card",
|
|
52
|
+
size = "md",
|
|
51
53
|
className,
|
|
52
54
|
...props
|
|
53
55
|
}) {
|
|
56
|
+
const framed = variant === "card";
|
|
54
57
|
const DeltaIcon = delta ? deltaIcons[delta.direction] : void 0;
|
|
55
58
|
return /* @__PURE__ */ jsxs(
|
|
56
59
|
"div",
|
|
57
60
|
{
|
|
58
61
|
"data-slot": "stat-card",
|
|
59
|
-
|
|
62
|
+
"data-variant": variant,
|
|
63
|
+
className: cn(
|
|
64
|
+
variant === "card" && "rounded-xl border border-border bg-card p-5",
|
|
65
|
+
variant === "tile" && "bg-card px-4.5 py-4",
|
|
66
|
+
variant === "plain" && "min-w-0",
|
|
67
|
+
className
|
|
68
|
+
),
|
|
60
69
|
...props,
|
|
61
70
|
children: [
|
|
62
71
|
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
63
72
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
64
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-
|
|
73
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-(length:--stat-label-size) leading-(--stat-label-leading) font-(--stat-label-weight) text-(--text-secondary)", children: label }),
|
|
65
74
|
loading ? /* @__PURE__ */ jsx(Skeleton, { className: "mt-2 h-7 w-24" }) : (
|
|
66
75
|
/* `font-bold` theo bản duyệt. `tabular-nums` là khoản gói thêm và giữ lại: chữ số
|
|
67
76
|
đều bề ngang thì một hàng bốn thẻ không nhảy khi số đổi. */
|
|
68
|
-
/* @__PURE__ */ jsx(
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
"p",
|
|
79
|
+
{
|
|
80
|
+
className: cn(
|
|
81
|
+
variant === "tile" ? "mt-(--stat-tile-value-gap)" : "mt-1",
|
|
82
|
+
"font-(--stat-value-weight) tabular-nums text-foreground",
|
|
83
|
+
size === "sm" ? "text-[22px] leading-none tracking-[-0.03em]" : "text-(length:--stat-value-size) leading-(--stat-value-leading) tracking-(--stat-value-tracking)"
|
|
84
|
+
),
|
|
85
|
+
children: value
|
|
86
|
+
}
|
|
87
|
+
)
|
|
69
88
|
)
|
|
70
89
|
] }),
|
|
71
90
|
Icon && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: statCardIconVariants({ tone }), children: /* @__PURE__ */ jsx(Icon, { className: "size-3.5" }) })
|
|
@@ -76,13 +95,66 @@ function StatCard({
|
|
|
76
95
|
delta.label && /* @__PURE__ */ jsx("span", { className: "font-normal text-muted-foreground", children: delta.label })
|
|
77
96
|
] }),
|
|
78
97
|
sparkline && /* @__PURE__ */ jsx("div", { className: "mt-3 h-10", children: sparkline }),
|
|
79
|
-
footer && /* @__PURE__ */ jsx("div", { className: "mt-3 border-t border-border pt-2 text-xs text-muted-foreground", children: footer })
|
|
98
|
+
footer && (framed ? /* @__PURE__ */ jsx("div", { className: "mt-3 border-t border-border pt-2 text-xs text-muted-foreground", children: footer }) : /* @__PURE__ */ jsx(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
className: cn(
|
|
102
|
+
variant === "tile" ? "mt-(--stat-tile-foot-gap)" : "mt-2.5",
|
|
103
|
+
"text-[11.5px] text-muted-foreground"
|
|
104
|
+
),
|
|
105
|
+
children: footer
|
|
106
|
+
}
|
|
107
|
+
))
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const STAT_GROUP_COLUMNS = {
|
|
113
|
+
2: "@min-[520px]:grid-cols-2",
|
|
114
|
+
3: "@min-[520px]:grid-cols-2 @min-[900px]:grid-cols-3",
|
|
115
|
+
4: "@min-[520px]:grid-cols-2 @min-[900px]:grid-cols-4"
|
|
116
|
+
};
|
|
117
|
+
function StatCardGroup({ columns = 4, className, children, ...props }) {
|
|
118
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "stat-card-group", className: cn("@container", className), ...props, children: /* @__PURE__ */ jsx(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
className: cn(
|
|
122
|
+
"grid grid-cols-1 gap-px overflow-hidden rounded-xl border-(length:--stat-group-border) border-border bg-border shadow-(--stat-group-shadow)",
|
|
123
|
+
STAT_GROUP_COLUMNS[columns]
|
|
124
|
+
),
|
|
125
|
+
children
|
|
126
|
+
}
|
|
127
|
+
) });
|
|
128
|
+
}
|
|
129
|
+
function Metric({ value, unit, size = "md", className, ...props }) {
|
|
130
|
+
return /* @__PURE__ */ jsxs(
|
|
131
|
+
"span",
|
|
132
|
+
{
|
|
133
|
+
"data-slot": "metric",
|
|
134
|
+
className: cn("inline-flex items-baseline gap-1.75 whitespace-nowrap", className),
|
|
135
|
+
...props,
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
"span",
|
|
139
|
+
{
|
|
140
|
+
className: cn(
|
|
141
|
+
"font-(--stat-value-weight) tabular-nums text-foreground",
|
|
142
|
+
size === "sm" ? "text-2xl tracking-[-0.03em]" : "text-(length:--stat-value-size) tracking-(--stat-value-tracking)",
|
|
143
|
+
// SAU lớp cỡ chữ: tailwind-merge coi `text-<cỡ>` là đè `leading-*` đứng trước nó.
|
|
144
|
+
"leading-none"
|
|
145
|
+
),
|
|
146
|
+
children: value
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
unit ? /* @__PURE__ */ jsx("span", { className: "text-[12.5px] text-muted-foreground", children: unit }) : null
|
|
80
150
|
]
|
|
81
151
|
}
|
|
82
152
|
);
|
|
83
153
|
}
|
|
84
154
|
export {
|
|
155
|
+
Metric,
|
|
85
156
|
StatCard,
|
|
157
|
+
StatCardGroup,
|
|
86
158
|
statCardIconVariants
|
|
87
159
|
};
|
|
88
160
|
//# sourceMappingURL=stat-card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/composite/stat-card.tsx"],"sourcesContent":["import { cva, type VariantProps } from \"class-variance-authority\";\nimport { ArrowDownRight, ArrowUpRight, Minus } from \"lucide-react\";\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { cn } from \"../../lib/cn.js\";\nimport { Skeleton } from \"../ui/skeleton.js\";\nimport type { IconComponent } from \"./empty-state.js\";\n\n/**\n * Ô icon của StatCard, tô theo tone token (không hex).\n *\n * Icon là thành phần PHI VĂN BẢN → ngưỡng WCAG 1.4.11 là 3:1 so với nền tint mà nó đứng lên.\n * Màu icon vì thế phải là bậc `--x-ink`, không phải token tô nền `--x`: `text-success` trên\n * `bg-success/15` chỉ được **2,69:1 ✗** ở light (dark thì 7,44:1 — mỗi theme hỏng một nửa là\n * dấu hiệu dùng sai vai trò token). Đo lại sau khi đổi, trên tint đã trộn với `--card`:\n *\n * success 5,60:1 (L) · 7,44:1 (D) · info 5,54:1 (L) · 7,12:1 (D)\n * warning 5,93:1 (L) · 7,19:1 (D) · destructive 5,76:1 (L) · 5,71:1 (D)\n * default 4,89:1 (L) · 5,31:1 (D) · primary 5,77:1 (L) · 7,26:1 (D)\n * app 6,14:1 (L) · 9,61:1 (D)\n * ⚠ `primary` đo trên bảng TƯƠNG PHẢN CAO. Ở bảng MẶC ĐỊNH `--primary-ink` = `--primary` (từ 0.3.0) nên\n * icon gold trên tint gold đo 1,64:1 — dưới ngưỡng CÓ CHỦ Ý: màu thương hiệu, bản duyệt giữ gold sáng. Đừng\n * \"sửa\" bằng một bậc vàng tối; ai cần tương phản bật bảng tương phản cao.\n *\n * `warning` bỏ cặp `text-gold-500 dark:text-warning`: `--warning-ink` đúng bằng `--gold-500` ở\n * light và `--yellow` ở dark, nên một class là đủ.\n */\n/*\n * Hình học của ô icon lấy theo mẫu StatCards ở mục **Patterns** của comitor-ds:\n * `p-1.5` quanh icon 14px + `rounded-lg` — tức ô ~28px, KHÔNG phải 36px với `rounded-md`.\n */\nexport const statCardIconVariants = cva(\"flex size-7 shrink-0 items-center justify-center rounded-lg\", {\n variants: {\n tone: {\n default: \"bg-muted text-muted-foreground\",\n // Đi theo `--primary`, không phải thang `gold-*` chôn cứng. Bản cũ\n // `bg-gold-100 text-gold-600 dark:bg-gold-500/25 dark:text-gold-100` đạt tương phản\n // (7,77:1 L · 11,85:1 D) nhưng đóng băng màu: app đổi brand thì ô icon vẫn vàng, và phải\n // viết hai lớp `dark:` vì thang gold không có bản dark. Token đạt 5,77:1 (L) · 7,26:1 (D) ở bảng\n // tương phản cao; bảng mặc định chỉ 1,64:1 (xem chú thích đầu file).\n primary: \"bg-primary/20 text-primary-ink\",\n success: \"bg-success/15 text-success-ink\",\n warning: \"bg-warning/20 text-warning-ink\",\n destructive: \"bg-destructive/15 text-destructive-ink\",\n info: \"bg-info/15 text-info-ink\",\n // Icon app đứng trên tint của CHÍNH nó → phải là bậc ink, đúng như năm tone trên.\n // `text-app-accent` (gold #E8B824) trên `bg-app-accent/10` (trộn ra #FDF8E9) chỉ 1,75:1 ✗.\n // `text-foreground` như bản trước thì ĐỌC được (17,81:1) nhưng bỏ mất màu app — tức là bỏ\n // mất đúng thứ tone này sinh ra để nói. `text-app-accent-ink`: 6,14:1 (L) · 9,61:1 (D) ✓\n // — hợp đồng §5, cùng lối chữa với AppLauncher.\n app: \"bg-app-accent/10 text-app-accent-ink\"\n }\n },\n defaultVariants: {\n tone: \"default\"\n }\n});\n\nexport type StatCardTone = NonNullable<VariantProps<typeof statCardIconVariants>[\"tone\"]>;\n\nexport type StatCardDeltaDirection = \"up\" | \"down\" | \"flat\";\n\nexport interface StatCardDelta {\n /** Nội dung hiển thị, vd \"+12,5%\" hoặc \"3 việc\" */\n value: ReactNode;\n direction: StatCardDeltaDirection;\n /**\n * Tăng là TỐT hay XẤU — mặc định \"positive-up\" (tăng = tốt).\n *\n * Cần thiết vì có chỉ số ngược chiều: số ticket quá hạn tăng là xấu, tỷ lệ rời bỏ giảm là tốt.\n * Tô màu theo hướng mũi tên một cách máy móc sẽ nói dối người đọc.\n */\n polarity?: \"positive-up\" | \"positive-down\" | \"neutral\";\n /** Chú thích sau con số, vd \"so với tuần trước\" */\n label?: ReactNode;\n}\n\nexport interface StatCardProps extends Omit<ComponentProps<\"div\">, \"title\"> {\n /** Nhãn chỉ số, vd \"Việc đang mở\" */\n label: ReactNode;\n value: ReactNode;\n icon?: IconComponent;\n tone?: StatCardTone;\n delta?: StatCardDelta;\n /** Slot biểu đồ mini (sparkline) — package không ép thư viện biểu đồ nào */\n sparkline?: ReactNode;\n /** Dòng chú thích dưới cùng */\n footer?: ReactNode;\n /** Đang tải → khung xương thay cho số liệu */\n loading?: boolean;\n}\n\nconst deltaIcons: Record<StatCardDeltaDirection, IconComponent> = {\n up: ArrowUpRight,\n down: ArrowDownRight,\n flat: Minus\n};\n\n/**\n * Màu của delta = hướng × cực tính, không phải chỉ hướng.\n *\n * Dòng biến động là CHỮ (12px, `text-xs`) đứng trên `bg-card` → ngưỡng AA 4,5:1, và phải đạt ở\n * cả hai theme. Token tô nền không làm được việc đó: `text-success` chỉ 3,13:1 ở light còn\n * `text-destructive` chỉ 3,53:1 ở dark — mỗi theme hỏng một nửa. Bậc ink đạt cả hai:\n * success 6,52:1 (L) / 10,19:1 (D) · destructive 7,15:1 (L) / 6,42:1 (D) · muted-foreground\n * 5,23:1 (L) / 5,86:1 (D).\n */\nfunction deltaToneClass({ direction, polarity = \"positive-up\" }: StatCardDelta): string {\n if (direction === \"flat\" || polarity === \"neutral\") return \"text-muted-foreground\";\n const isGood = polarity === \"positive-up\" ? direction === \"up\" : direction === \"down\";\n return isGood ? \"text-success-ink\" : \"text-destructive-ink\";\n}\n\n/**\n * Thẻ KPI: nhãn + số liệu lớn + biến động + sparkline tuỳ chọn.\n *\n * Số liệu dùng `tabular-nums` để cột số không nhảy khi cập nhật realtime. Tĩnh → RSC-safe.\n */\nexport function StatCard({\n label,\n value,\n icon: Icon,\n tone = \"default\",\n delta,\n sparkline,\n footer,\n loading = false,\n className,\n ...props\n}: StatCardProps) {\n const DeltaIcon = delta ? deltaIcons[delta.direction] : undefined;\n\n return (\n <div\n data-slot=\"stat-card\"\n /*\n * `p-5`, và KHÔNG có đổ bóng — đúng mẫu StatCards ở mục Patterns của comitor-ds\n * (`rounded-xl border border-border bg-card p-5`). Bản trước dùng `p-4 shadow-card`; trên\n * một hàng bốn thẻ thì bóng đó nổi rõ và làm lưới thẻ nặng hơn bản duyệt.\n */\n className={cn(\"rounded-xl border border-border bg-card p-5\", className)}\n {...props}\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0 flex-1\">\n {/* `text-xs font-medium` theo bản duyệt, không phải `text-sm` thường. */}\n <p className=\"truncate text-xs font-medium text-muted-foreground\">{label}</p>\n {loading ? (\n <Skeleton className=\"mt-2 h-7 w-24\" />\n ) : (\n /* `font-bold` theo bản duyệt. `tabular-nums` là khoản gói thêm và giữ lại: chữ số\n đều bề ngang thì một hàng bốn thẻ không nhảy khi số đổi. */\n <p className=\"mt-1 text-2xl font-bold tabular-nums leading-tight text-foreground\">{value}</p>\n )}\n </div>\n {Icon && (\n <span aria-hidden=\"true\" className={statCardIconVariants({ tone })}>\n <Icon className=\"size-3.5\" />\n </span>\n )}\n </div>\n\n {/*\n * Dòng biến động nằm NGOÀI hàng hai cột ở trên, và đó là chủ ý.\n *\n * Ô icon chỉ cao 28px trong khi nhãn + số liệu đã cao ~46px, nên dòng này luôn rơi xuống\n * DƯỚI icon — nhưng hồi nó còn nằm trong cột trái thì nó vẫn bị bó theo bề rộng của cột đó\n * (147px trên thẻ 229px) và bỏ không phần dưới ô icon. Hệ quả nhìn thấy được: \"↗ +3 việc so\n * với tuần trước\" cần 171px nên nó vỡ đôi, mà vỡ theo kiểu tệ nhất — hai `<span>` là flex\n * item nên mỗi cái tự co về min-content rồi xuống dòng BÊN TRONG, ra thành hai cột lệch\n * \"+3 / việc\" và \"so với tuần / trước\". Đưa ra ngoài là dòng này được cả 189px, vừa một dòng.\n *\n * `flex-wrap` + `whitespace-nowrap` ở phần số là lưới an toàn cho thẻ hẹp hơn nữa: hết chỗ\n * thì chú thích xuống hàng NGUYÊN CỤM, không còn chuyện tách \"+3\" khỏi \"việc\".\n */}\n {delta && !loading && DeltaIcon && (\n <p className={cn(\"mt-1 flex flex-wrap items-center gap-x-1 text-xs font-medium\", deltaToneClass(delta))}>\n <DeltaIcon aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n <span className=\"whitespace-nowrap tabular-nums\">{delta.value}</span>\n {delta.label && <span className=\"font-normal text-muted-foreground\">{delta.label}</span>}\n </p>\n )}\n\n {sparkline && <div className=\"mt-3 h-10\">{sparkline}</div>}\n {footer && <div className=\"mt-3 border-t border-border pt-2 text-xs text-muted-foreground\">{footer}</div>}\n </div>\n );\n}\n"],"mappings":"AA+IQ,SAEE,KAFF;AA/IR,SAAS,WAA8B;AACvC,SAAS,gBAAgB,cAAc,aAAa;AAEpD,SAAS,UAAU;AACnB,SAAS,gBAAgB;AA0BlB,MAAM,uBAAuB,IAAI,+DAA+D;AAAA,EACrG,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMN,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AAoCD,MAAM,aAA4D;AAAA,EAChE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AACR;AAWA,SAAS,eAAe,EAAE,WAAW,WAAW,cAAc,GAA0B;AACtF,MAAI,cAAc,UAAU,aAAa,UAAW,QAAO;AAC3D,QAAM,SAAS,aAAa,gBAAgB,cAAc,OAAO,cAAc;AAC/E,SAAO,SAAS,qBAAqB;AACvC;AAOO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,GAAG;AACL,GAAkB;AAChB,QAAM,YAAY,QAAQ,WAAW,MAAM,SAAS,IAAI;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MAMV,WAAW,GAAG,+CAA+C,SAAS;AAAA,MACrE,GAAG;AAAA,MAEJ;AAAA,6BAAC,SAAI,WAAU,0CACb;AAAA,+BAAC,SAAI,WAAU,kBAEb;AAAA,gCAAC,OAAE,WAAU,sDAAsD,iBAAM;AAAA,YACxE,UACC,oBAAC,YAAS,WAAU,iBAAgB;AAAA;AAAA;AAAA,cAIpC,oBAAC,OAAE,WAAU,sEAAsE,iBAAM;AAAA;AAAA,aAE7F;AAAA,UACC,QACC,oBAAC,UAAK,eAAY,QAAO,WAAW,qBAAqB,EAAE,KAAK,CAAC,GAC/D,8BAAC,QAAK,WAAU,YAAW,GAC7B;AAAA,WAEJ;AAAA,QAeC,SAAS,CAAC,WAAW,aACpB,qBAAC,OAAE,WAAW,GAAG,gEAAgE,eAAe,KAAK,CAAC,GACpG;AAAA,8BAAC,aAAU,eAAY,QAAO,WAAU,qBAAoB;AAAA,UAC5D,oBAAC,UAAK,WAAU,kCAAkC,gBAAM,OAAM;AAAA,UAC7D,MAAM,SAAS,oBAAC,UAAK,WAAU,qCAAqC,gBAAM,OAAM;AAAA,WACnF;AAAA,QAGD,aAAa,oBAAC,SAAI,WAAU,aAAa,qBAAU;AAAA,QACnD,UAAU,oBAAC,SAAI,WAAU,kEAAkE,kBAAO;AAAA;AAAA;AAAA,EACrG;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/composite/stat-card.tsx"],"sourcesContent":["import { cva, type VariantProps } from \"class-variance-authority\";\nimport { ArrowDownRight, ArrowUpRight, Minus } from \"lucide-react\";\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { cn } from \"../../lib/cn.js\";\nimport { Skeleton } from \"../ui/skeleton.js\";\nimport type { IconComponent } from \"./empty-state.js\";\n\n/**\n * Ô icon của StatCard, tô theo tone token (không hex).\n *\n * Icon là thành phần PHI VĂN BẢN → ngưỡng WCAG 1.4.11 là 3:1 so với nền tint mà nó đứng lên.\n * Màu icon vì thế phải là bậc `--x-ink`, không phải token tô nền `--x`: `text-success` trên\n * `bg-success/15` chỉ được **2,69:1 ✗** ở light (dark thì 7,44:1 — mỗi theme hỏng một nửa là\n * dấu hiệu dùng sai vai trò token). Đo lại sau khi đổi, trên tint đã trộn với `--card`:\n *\n * success 5,60:1 (L) · 7,44:1 (D) · info 5,54:1 (L) · 7,12:1 (D)\n * warning 5,93:1 (L) · 7,19:1 (D) · destructive 5,76:1 (L) · 5,71:1 (D)\n * default 4,89:1 (L) · 5,31:1 (D) · primary 5,77:1 (L) · 7,26:1 (D)\n * app 6,14:1 (L) · 9,61:1 (D)\n * ⚠ `primary` đo trên bảng TƯƠNG PHẢN CAO. Ở bảng MẶC ĐỊNH `--primary-ink` = `--primary` (từ 0.3.0) nên\n * icon gold trên tint gold đo 1,64:1 — dưới ngưỡng CÓ CHỦ Ý: màu thương hiệu, bản duyệt giữ gold sáng. Đừng\n * \"sửa\" bằng một bậc vàng tối; ai cần tương phản bật bảng tương phản cao.\n *\n * `warning` bỏ cặp `text-gold-500 dark:text-warning`: `--warning-ink` đúng bằng `--gold-500` ở\n * light và `--yellow` ở dark, nên một class là đủ.\n */\n/*\n * Hình học của ô icon lấy theo mẫu StatCards ở mục **Patterns** của comitor-ds:\n * `p-1.5` quanh icon 14px + `rounded-lg` — tức ô ~28px, KHÔNG phải 36px với `rounded-md`.\n */\nexport const statCardIconVariants = cva(\"flex size-7 shrink-0 items-center justify-center rounded-lg\", {\n variants: {\n tone: {\n default: \"bg-muted text-muted-foreground\",\n // Đi theo `--primary`, không phải thang `gold-*` chôn cứng. Bản cũ\n // `bg-gold-100 text-gold-600 dark:bg-gold-500/25 dark:text-gold-100` đạt tương phản\n // (7,77:1 L · 11,85:1 D) nhưng đóng băng màu: app đổi brand thì ô icon vẫn vàng, và phải\n // viết hai lớp `dark:` vì thang gold không có bản dark. Token đạt 5,77:1 (L) · 7,26:1 (D) ở bảng\n // tương phản cao; bảng mặc định chỉ 1,64:1 (xem chú thích đầu file).\n primary: \"bg-primary/20 text-primary-ink\",\n success: \"bg-success/15 text-success-ink\",\n warning: \"bg-warning/20 text-warning-ink\",\n destructive: \"bg-destructive/15 text-destructive-ink\",\n info: \"bg-info/15 text-info-ink\",\n // Icon app đứng trên tint của CHÍNH nó → phải là bậc ink, đúng như năm tone trên.\n // `text-app-accent` (gold #E8B824) trên `bg-app-accent/10` (trộn ra #FDF8E9) chỉ 1,75:1 ✗.\n // `text-foreground` như bản trước thì ĐỌC được (17,81:1) nhưng bỏ mất màu app — tức là bỏ\n // mất đúng thứ tone này sinh ra để nói. `text-app-accent-ink`: 6,14:1 (L) · 9,61:1 (D) ✓\n // — hợp đồng §5, cùng lối chữa với AppLauncher.\n app: \"bg-app-accent/10 text-app-accent-ink\"\n }\n },\n defaultVariants: {\n tone: \"default\"\n }\n});\n\nexport type StatCardTone = NonNullable<VariantProps<typeof statCardIconVariants>[\"tone\"]>;\n\nexport type StatCardDeltaDirection = \"up\" | \"down\" | \"flat\";\n\nexport interface StatCardDelta {\n /** Nội dung hiển thị, vd \"+12,5%\" hoặc \"3 việc\" */\n value: ReactNode;\n direction: StatCardDeltaDirection;\n /**\n * Tăng là TỐT hay XẤU — mặc định \"positive-up\" (tăng = tốt).\n *\n * Cần thiết vì có chỉ số ngược chiều: số ticket quá hạn tăng là xấu, tỷ lệ rời bỏ giảm là tốt.\n * Tô màu theo hướng mũi tên một cách máy móc sẽ nói dối người đọc.\n */\n polarity?: \"positive-up\" | \"positive-down\" | \"neutral\";\n /** Chú thích sau con số, vd \"so với tuần trước\" */\n label?: ReactNode;\n}\n\nexport interface StatCardProps extends Omit<ComponentProps<\"div\">, \"title\"> {\n /** Nhãn chỉ số, vd \"Việc đang mở\" */\n label: ReactNode;\n value: ReactNode;\n icon?: IconComponent;\n tone?: StatCardTone;\n delta?: StatCardDelta;\n /** Slot biểu đồ mini (sparkline) — package không ép thư viện biểu đồ nào */\n sparkline?: ReactNode;\n /** Dòng chú thích dưới cùng */\n footer?: ReactNode;\n /** Đang tải → khung xương thay cho số liệu */\n loading?: boolean;\n /**\n * Khung (3.19.0). `\"card\"` (mặc định) = thẻ viền bo góc như trước. `\"tile\"` = ô của `StatCardGroup` (không viền, không\n * bo góc — nhóm vẽ khung chung và vạch 1px giữa các ô; bản mẫu Imagtor v4 `.kpic`). `\"plain\"` = chỉ nhãn + số, không\n * nền, không đệm — ô của một lưới chỉ số nhỏ trong thân thẻ (v4 `.qgrid`).\n */\n variant?: StatCardVariant;\n /** Cỡ số liệu (3.19.0): `\"md\"` theo token `--stat-value-*`, `\"sm\"` 22px — chỉ số phụ trong thân thẻ. */\n size?: \"md\" | \"sm\";\n}\n\nexport type StatCardVariant = \"card\" | \"tile\" | \"plain\";\n\nconst deltaIcons: Record<StatCardDeltaDirection, IconComponent> = {\n up: ArrowUpRight,\n down: ArrowDownRight,\n flat: Minus\n};\n\n/**\n * Màu của delta = hướng × cực tính, không phải chỉ hướng.\n *\n * Dòng biến động là CHỮ (12px, `text-xs`) đứng trên `bg-card` → ngưỡng AA 4,5:1, và phải đạt ở\n * cả hai theme. Token tô nền không làm được việc đó: `text-success` chỉ 3,13:1 ở light còn\n * `text-destructive` chỉ 3,53:1 ở dark — mỗi theme hỏng một nửa. Bậc ink đạt cả hai:\n * success 6,52:1 (L) / 10,19:1 (D) · destructive 7,15:1 (L) / 6,42:1 (D) · muted-foreground\n * 5,23:1 (L) / 5,86:1 (D).\n */\nfunction deltaToneClass({ direction, polarity = \"positive-up\" }: StatCardDelta): string {\n if (direction === \"flat\" || polarity === \"neutral\") return \"text-muted-foreground\";\n const isGood = polarity === \"positive-up\" ? direction === \"up\" : direction === \"down\";\n return isGood ? \"text-success-ink\" : \"text-destructive-ink\";\n}\n\n/**\n * Thẻ KPI: nhãn + số liệu lớn + biến động + sparkline tuỳ chọn.\n *\n * Số liệu dùng `tabular-nums` để cột số không nhảy khi cập nhật realtime. Tĩnh → RSC-safe.\n */\nexport function StatCard({\n label,\n value,\n icon: Icon,\n tone = \"default\",\n delta,\n sparkline,\n footer,\n loading = false,\n variant = \"card\",\n size = \"md\",\n className,\n ...props\n}: StatCardProps) {\n const framed = variant === \"card\";\n const DeltaIcon = delta ? deltaIcons[delta.direction] : undefined;\n\n return (\n <div\n data-slot=\"stat-card\"\n /*\n * `p-5`, và KHÔNG có đổ bóng — đúng mẫu StatCards ở mục Patterns của comitor-ds\n * (`rounded-xl border border-border bg-card p-5`). Bản trước dùng `p-4 shadow-card`; trên\n * một hàng bốn thẻ thì bóng đó nổi rõ và làm lưới thẻ nặng hơn bản duyệt.\n */\n data-variant={variant}\n className={cn(\n variant === \"card\" && \"rounded-xl border border-border bg-card p-5\",\n variant === \"tile\" && \"bg-card px-4.5 py-4\",\n variant === \"plain\" && \"min-w-0\",\n className\n )}\n {...props}\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0 flex-1\">\n {/* `text-xs font-medium` theo bản duyệt, không phải `text-sm` thường. */}\n {/* Cỡ/độ đậm theo token `--stat-label-*` (3.19.0): mặc định ĐÚNG `text-xs font-medium` cũ; green 12,5px/540.\n `--text-secondary` mặc định trùng `--muted-foreground`. */}\n <p className=\"truncate text-(length:--stat-label-size) leading-(--stat-label-leading) font-(--stat-label-weight) text-(--text-secondary)\">\n {label}\n </p>\n {loading ? (\n <Skeleton className=\"mt-2 h-7 w-24\" />\n ) : (\n /* `font-bold` theo bản duyệt. `tabular-nums` là khoản gói thêm và giữ lại: chữ số\n đều bề ngang thì một hàng bốn thẻ không nhảy khi số đổi. */\n <p\n className={cn(\n variant === \"tile\" ? \"mt-(--stat-tile-value-gap)\" : \"mt-1\",\n \"font-(--stat-value-weight) tabular-nums text-foreground\",\n size === \"sm\"\n ? \"text-[22px] leading-none tracking-[-0.03em]\"\n : \"text-(length:--stat-value-size) leading-(--stat-value-leading) tracking-(--stat-value-tracking)\"\n )}\n >\n {value}\n </p>\n )}\n </div>\n {Icon && (\n <span aria-hidden=\"true\" className={statCardIconVariants({ tone })}>\n <Icon className=\"size-3.5\" />\n </span>\n )}\n </div>\n\n {/*\n * Dòng biến động nằm NGOÀI hàng hai cột ở trên, và đó là chủ ý.\n *\n * Ô icon chỉ cao 28px trong khi nhãn + số liệu đã cao ~46px, nên dòng này luôn rơi xuống\n * DƯỚI icon — nhưng hồi nó còn nằm trong cột trái thì nó vẫn bị bó theo bề rộng của cột đó\n * (147px trên thẻ 229px) và bỏ không phần dưới ô icon. Hệ quả nhìn thấy được: \"↗ +3 việc so\n * với tuần trước\" cần 171px nên nó vỡ đôi, mà vỡ theo kiểu tệ nhất — hai `<span>` là flex\n * item nên mỗi cái tự co về min-content rồi xuống dòng BÊN TRONG, ra thành hai cột lệch\n * \"+3 / việc\" và \"so với tuần / trước\". Đưa ra ngoài là dòng này được cả 189px, vừa một dòng.\n *\n * `flex-wrap` + `whitespace-nowrap` ở phần số là lưới an toàn cho thẻ hẹp hơn nữa: hết chỗ\n * thì chú thích xuống hàng NGUYÊN CỤM, không còn chuyện tách \"+3\" khỏi \"việc\".\n */}\n {delta && !loading && DeltaIcon && (\n <p className={cn(\"mt-1 flex flex-wrap items-center gap-x-1 text-xs font-medium\", deltaToneClass(delta))}>\n <DeltaIcon aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n <span className=\"whitespace-nowrap tabular-nums\">{delta.value}</span>\n {delta.label && <span className=\"font-normal text-muted-foreground\">{delta.label}</span>}\n </p>\n )}\n\n {sparkline && <div className=\"mt-3 h-10\">{sparkline}</div>}\n {footer &&\n (framed ? (\n <div className=\"mt-3 border-t border-border pt-2 text-xs text-muted-foreground\">{footer}</div>\n ) : (\n <div\n className={cn(\n variant === \"tile\" ? \"mt-(--stat-tile-foot-gap)\" : \"mt-2.5\",\n \"text-[11.5px] text-muted-foreground\"\n )}\n >\n {footer}\n </div>\n ))}\n </div>\n );\n}\n\nconst STAT_GROUP_COLUMNS = {\n 2: \"@min-[520px]:grid-cols-2\",\n 3: \"@min-[520px]:grid-cols-2 @min-[900px]:grid-cols-3\",\n 4: \"@min-[520px]:grid-cols-2 @min-[900px]:grid-cols-4\"\n} as const;\n\nexport interface StatCardGroupProps extends ComponentProps<\"div\"> {\n /** Số cột khi khung chứa ≥ 900px (2 cột từ 520px, 1 cột dưới đó — đo theo KHUNG CHỨA, không theo màn hình). */\n columns?: 2 | 3 | 4;\n}\n\n/**\n * Hàng KPI dính liền (3.19.0, bản mẫu Imagtor v4 `.kpirow`): MỘT khung bo góc, các ô `StatCard variant=\"tile\"` cách\n * nhau vạch 1px (`gap-px` trên nền `--border`). Tự là `@container`, nên số liệu `cqw` của token `--stat-value-size`\n * (bộ green) co theo bề rộng hàng.\n *\n * ```tsx\n * <StatCardGroup>\n * <StatCard variant=\"tile\" label=\"Job hôm nay\" value=\"128\" footer=\"+12 so với hôm qua\" />\n * …\n * </StatCardGroup>\n * ```\n */\nexport function StatCardGroup({ columns = 4, className, children, ...props }: StatCardGroupProps) {\n return (\n <div data-slot=\"stat-card-group\" className={cn(\"@container\", className)} {...props}>\n <div\n className={cn(\n \"grid grid-cols-1 gap-px overflow-hidden rounded-xl border-(length:--stat-group-border) border-border bg-border shadow-(--stat-group-shadow)\",\n STAT_GROUP_COLUMNS[columns]\n )}\n >\n {children}\n </div>\n </div>\n );\n}\n\nexport interface MetricProps extends Omit<ComponentProps<\"span\">, \"children\"> {\n value: ReactNode;\n /** Đơn vị/chú thích đứng sau số, cùng đường chân chữ (\"phút\", \"/ 750\"). */\n unit?: ReactNode;\n /** `\"md\"` theo token `--stat-value-*` (cùng cỡ số của `StatCard`), `\"sm\"` 24px. */\n size?: \"md\" | \"sm\";\n}\n\n/**\n * Con số lớn rời (3.19.0, bản mẫu Imagtor v4 `.bignum`) — cùng kiểu chữ với số của `StatCard`, không khung.\n * Tĩnh → RSC-safe.\n */\nexport function Metric({ value, unit, size = \"md\", className, ...props }: MetricProps) {\n return (\n <span\n data-slot=\"metric\"\n className={cn(\"inline-flex items-baseline gap-1.75 whitespace-nowrap\", className)}\n {...props}\n >\n <span\n className={cn(\n \"font-(--stat-value-weight) tabular-nums text-foreground\",\n size === \"sm\"\n ? \"text-2xl tracking-[-0.03em]\"\n : \"text-(length:--stat-value-size) tracking-(--stat-value-tracking)\",\n // SAU lớp cỡ chữ: tailwind-merge coi `text-<cỡ>` là đè `leading-*` đứng trước nó.\n \"leading-none\"\n )}\n >\n {value}\n </span>\n {unit ? <span className=\"text-[12.5px] text-muted-foreground\">{unit}</span> : null}\n </span>\n );\n}\n"],"mappings":"AAkKQ,SAIE,KAJF;AAlKR,SAAS,WAA8B;AACvC,SAAS,gBAAgB,cAAc,aAAa;AAEpD,SAAS,UAAU;AACnB,SAAS,gBAAgB;AA0BlB,MAAM,uBAAuB,IAAI,+DAA+D;AAAA,EACrG,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMN,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,MAAM;AAAA,EACR;AACF,CAAC;AA8CD,MAAM,aAA4D;AAAA,EAChE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,MAAM;AACR;AAWA,SAAS,eAAe,EAAE,WAAW,WAAW,cAAc,GAA0B;AACtF,MAAI,cAAc,UAAU,aAAa,UAAW,QAAO;AAC3D,QAAM,SAAS,aAAa,gBAAgB,cAAc,OAAO,cAAc;AAC/E,SAAO,SAAS,qBAAqB;AACvC;AAOO,SAAS,SAAS;AAAA,EACvB;AAAA,EACA;AAAA,EACA,MAAM;AAAA,EACN,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AAAA,EACP;AAAA,EACA,GAAG;AACL,GAAkB;AAChB,QAAM,SAAS,YAAY;AAC3B,QAAM,YAAY,QAAQ,WAAW,MAAM,SAAS,IAAI;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MAMV,gBAAc;AAAA,MACd,WAAW;AAAA,QACT,YAAY,UAAU;AAAA,QACtB,YAAY,UAAU;AAAA,QACtB,YAAY,WAAW;AAAA,QACvB;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,6BAAC,SAAI,WAAU,0CACb;AAAA,+BAAC,SAAI,WAAU,kBAIb;AAAA,gCAAC,OAAE,WAAU,8HACV,iBACH;AAAA,YACC,UACC,oBAAC,YAAS,WAAU,iBAAgB;AAAA;AAAA;AAAA,cAIpC;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAW;AAAA,oBACT,YAAY,SAAS,+BAA+B;AAAA,oBACpD;AAAA,oBACA,SAAS,OACL,gDACA;AAAA,kBACN;AAAA,kBAEC;AAAA;AAAA,cACH;AAAA;AAAA,aAEJ;AAAA,UACC,QACC,oBAAC,UAAK,eAAY,QAAO,WAAW,qBAAqB,EAAE,KAAK,CAAC,GAC/D,8BAAC,QAAK,WAAU,YAAW,GAC7B;AAAA,WAEJ;AAAA,QAeC,SAAS,CAAC,WAAW,aACpB,qBAAC,OAAE,WAAW,GAAG,gEAAgE,eAAe,KAAK,CAAC,GACpG;AAAA,8BAAC,aAAU,eAAY,QAAO,WAAU,qBAAoB;AAAA,UAC5D,oBAAC,UAAK,WAAU,kCAAkC,gBAAM,OAAM;AAAA,UAC7D,MAAM,SAAS,oBAAC,UAAK,WAAU,qCAAqC,gBAAM,OAAM;AAAA,WACnF;AAAA,QAGD,aAAa,oBAAC,SAAI,WAAU,aAAa,qBAAU;AAAA,QACnD,WACE,SACC,oBAAC,SAAI,WAAU,kEAAkE,kBAAO,IAExF;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT,YAAY,SAAS,8BAA8B;AAAA,cACnD;AAAA,YACF;AAAA,YAEC;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EAEN;AAEJ;AAEA,MAAM,qBAAqB;AAAA,EACzB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAmBO,SAAS,cAAc,EAAE,UAAU,GAAG,WAAW,UAAU,GAAG,MAAM,GAAuB;AAChG,SACE,oBAAC,SAAI,aAAU,mBAAkB,WAAW,GAAG,cAAc,SAAS,GAAI,GAAG,OAC3E;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,mBAAmB,OAAO;AAAA,MAC5B;AAAA,MAEC;AAAA;AAAA,EACH,GACF;AAEJ;AAcO,SAAS,OAAO,EAAE,OAAO,MAAM,OAAO,MAAM,WAAW,GAAG,MAAM,GAAgB;AACrF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,yDAAyD,SAAS;AAAA,MAC/E,GAAG;AAAA,MAEJ;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA,SAAS,OACL,gCACA;AAAA;AAAA,cAEJ;AAAA,YACF;AAAA,YAEC;AAAA;AAAA,QACH;AAAA,QACC,OAAO,oBAAC,UAAK,WAAU,uCAAuC,gBAAK,IAAU;AAAA;AAAA;AAAA,EAChF;AAEJ;","names":[]}
|
|
@@ -17,7 +17,12 @@ interface StatusPillProps<T extends string = string> extends Omit<ComponentProps
|
|
|
17
17
|
/** Nhãn thay thế khi `value` không có trong `configs` */
|
|
18
18
|
fallbackLabel?: string;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* `pill` / `soft-dot` / `text-dot` (3.19.0, bản mẫu Imagtor v4 `.tag`): `pill` = nền tint như `soft` nhưng bo TRÒN,
|
|
22
|
+
* chữ 11,5px/580, đệm 3,5 × 10px; `soft-dot` = `pill` kèm chấm `currentColor` 5,5px ở đầu; `text-dot` = chữ MÀU của
|
|
23
|
+
* tone kèm chấm, không nền (trạng thái nằm trong dòng chữ — "● trong ca").
|
|
24
|
+
*/
|
|
25
|
+
type StatusPillVariant = "soft" | "outline" | "dot" | "pill" | "soft-dot" | "text-dot";
|
|
21
26
|
/**
|
|
22
27
|
* Chip trạng thái tô theo StatusConfig của app (màu lấy từ token, không hex).
|
|
23
28
|
*
|
|
@@ -26,6 +26,55 @@ function StatusPill({
|
|
|
26
26
|
label
|
|
27
27
|
] });
|
|
28
28
|
}
|
|
29
|
+
if (variant === "pill" || variant === "soft-dot") {
|
|
30
|
+
return /* @__PURE__ */ jsxs(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
"data-slot": "status-pill",
|
|
34
|
+
"data-variant": variant,
|
|
35
|
+
className: cn(
|
|
36
|
+
"inline-flex items-center gap-1.25 whitespace-nowrap rounded-full px-2.5 py-[3.5px] text-[11.5px] leading-normal font-[580]",
|
|
37
|
+
config?.bgColor ?? "bg-muted",
|
|
38
|
+
config?.textColor ?? "text-muted-foreground",
|
|
39
|
+
className
|
|
40
|
+
),
|
|
41
|
+
...props,
|
|
42
|
+
children: [
|
|
43
|
+
variant === "soft-dot" ? /* @__PURE__ */ jsx(
|
|
44
|
+
"span",
|
|
45
|
+
{
|
|
46
|
+
"aria-hidden": "true",
|
|
47
|
+
className: "size-[5.5px] shrink-0 rounded-full",
|
|
48
|
+
style: { backgroundColor: "currentColor" }
|
|
49
|
+
}
|
|
50
|
+
) : null,
|
|
51
|
+
label
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (variant === "text-dot") {
|
|
57
|
+
return /* @__PURE__ */ jsxs(
|
|
58
|
+
"span",
|
|
59
|
+
{
|
|
60
|
+
"data-slot": "status-pill",
|
|
61
|
+
"data-variant": variant,
|
|
62
|
+
className: cn(base, "px-0 py-0", config?.textColor ?? "text-muted-foreground", className),
|
|
63
|
+
...props,
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
"span",
|
|
67
|
+
{
|
|
68
|
+
"aria-hidden": "true",
|
|
69
|
+
className: "size-1.5 shrink-0 rounded-full",
|
|
70
|
+
style: { backgroundColor: "currentColor" }
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
label
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
29
78
|
if (variant === "outline") {
|
|
30
79
|
return /* @__PURE__ */ jsx(
|
|
31
80
|
"span",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/composite/status-pill.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cn } from \"../../lib/cn.js\";\nimport type { StatusConfig } from \"./status-config.js\";\nimport { getStatusConfig } from \"./status-config.js\";\n\nexport interface StatusPillProps<T extends string = string> extends Omit<ComponentProps<\"span\">, \"children\"> {\n /** Toàn bộ bảng trạng thái của app */\n configs: readonly StatusConfig<T>[];\n /** Trạng thái cần hiển thị */\n value: T | null | undefined;\n /** Dùng shortLabel nếu có (bảng hẹp) */\n short?: boolean;\n /**\n * \"soft\" = nền tint (mặc định), \"outline\" = chỉ viền + chữ, \"dot\" = chấm màu + chữ thường (chấm\n * tô bằng `dotColor` của tone nếu có, không thì bằng màu chữ của tone)\n */\n variant?: StatusPillVariant;\n /** Nhãn thay thế khi `value` không có trong `configs` */\n fallbackLabel?: string;\n}\n\nexport type StatusPillVariant = \"soft\" | \"outline\" | \"dot\";\n\n/**\n * Chip trạng thái tô theo StatusConfig của app (màu lấy từ token, không hex).\n *\n * Tĩnh hoàn toàn → dùng được trong React Server Component (bảng danh sách render phía server).\n * Trạng thái lạ (dữ liệu cũ, enum mới ở backend) KHÔNG bị nuốt: vẫn hiện nhãn ở tone neutral.\n */\nexport function StatusPill<T extends string = string>({\n configs,\n value,\n short = false,\n variant = \"soft\",\n fallbackLabel,\n className,\n ...props\n}: StatusPillProps<T>) {\n const config = getStatusConfig(configs, value);\n const label = config ? (short ? (config.shortLabel ?? config.label) : config.label) : (fallbackLabel ?? value ?? \"—\");\n\n const base = \"inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2 py-0.5 text-xs font-medium\";\n\n if (variant === \"dot\") {\n // Tone có `dotColor` (hiện chỉ `severe`): chấm tô bằng token TÔ NỀN đó — đã đo 3:1 với nền trang,\n // vì ở cỡ 6px bậc ink (đủ tối cho CHỮ) đọc ra một đốm xỉn. Tone không khai thì giữ NGUYÊN phần tử\n // cũ: chấm lấy `currentColor` của bậc ink trong `textColor`.\n // Hai nhánh JSX tách hẳn chứ không gắn thuộc tính style theo điều kiện: style không phải object\n // literal là chỗ im lặng duy nhất của cổng tương phản (docs/hop-dong-mau.md §8, \"Còn lại\" mục 1).\n return (\n <span data-slot=\"status-pill\" className={cn(base, \"px-0 text-foreground\", className)} {...props}>\n {config?.dotColor ? (\n <span aria-hidden=\"true\" className={cn(\"size-1.5 shrink-0 rounded-full\", config.dotColor)} />\n ) : (\n <span\n aria-hidden=\"true\"\n className={cn(\"size-1.5 shrink-0 rounded-full\", config ? config.textColor : \"text-muted-foreground\")}\n style={{ backgroundColor: \"currentColor\" }}\n />\n )}\n {label}\n </span>\n );\n }\n\n if (variant === \"outline\") {\n return (\n <span\n data-slot=\"status-pill\"\n className={cn(\n base,\n \"border bg-transparent\",\n // Lui về `border-muted-foreground` chứ KHÔNG phải `border-border`: ở biến thể này nền\n // trong suốt nên viền là thứ DUY NHẤT khoanh vùng chip → ngưỡng 3:1. `--border` là bậc\n // TRANG TRÍ, chỉ 1,16:1 (L) · 1,17:1 (D) so với nền trang ✗. `--muted-foreground` đạt\n // 5,23:1 (L) · 6,24:1 (D) và khớp đúng màu chữ lui bên dưới.\n config?.borderColor ?? \"border-muted-foreground\",\n config?.textColor ?? \"text-muted-foreground\",\n className\n )}\n {...props}\n >\n {label}\n </span>\n );\n }\n\n return (\n <span\n data-slot=\"status-pill\"\n className={cn(base, config?.bgColor ?? \"bg-muted\", config?.textColor ?? \"text-muted-foreground\", className)}\n {...props}\n >\n {label}\n </span>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/composite/status-pill.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\";\nimport { cn } from \"../../lib/cn.js\";\nimport type { StatusConfig } from \"./status-config.js\";\nimport { getStatusConfig } from \"./status-config.js\";\n\nexport interface StatusPillProps<T extends string = string> extends Omit<ComponentProps<\"span\">, \"children\"> {\n /** Toàn bộ bảng trạng thái của app */\n configs: readonly StatusConfig<T>[];\n /** Trạng thái cần hiển thị */\n value: T | null | undefined;\n /** Dùng shortLabel nếu có (bảng hẹp) */\n short?: boolean;\n /**\n * \"soft\" = nền tint (mặc định), \"outline\" = chỉ viền + chữ, \"dot\" = chấm màu + chữ thường (chấm\n * tô bằng `dotColor` của tone nếu có, không thì bằng màu chữ của tone)\n */\n variant?: StatusPillVariant;\n /** Nhãn thay thế khi `value` không có trong `configs` */\n fallbackLabel?: string;\n}\n\n/**\n * `pill` / `soft-dot` / `text-dot` (3.19.0, bản mẫu Imagtor v4 `.tag`): `pill` = nền tint như `soft` nhưng bo TRÒN,\n * chữ 11,5px/580, đệm 3,5 × 10px; `soft-dot` = `pill` kèm chấm `currentColor` 5,5px ở đầu; `text-dot` = chữ MÀU của\n * tone kèm chấm, không nền (trạng thái nằm trong dòng chữ — \"● trong ca\").\n */\nexport type StatusPillVariant = \"soft\" | \"outline\" | \"dot\" | \"pill\" | \"soft-dot\" | \"text-dot\";\n\n/**\n * Chip trạng thái tô theo StatusConfig của app (màu lấy từ token, không hex).\n *\n * Tĩnh hoàn toàn → dùng được trong React Server Component (bảng danh sách render phía server).\n * Trạng thái lạ (dữ liệu cũ, enum mới ở backend) KHÔNG bị nuốt: vẫn hiện nhãn ở tone neutral.\n */\nexport function StatusPill<T extends string = string>({\n configs,\n value,\n short = false,\n variant = \"soft\",\n fallbackLabel,\n className,\n ...props\n}: StatusPillProps<T>) {\n const config = getStatusConfig(configs, value);\n const label = config ? (short ? (config.shortLabel ?? config.label) : config.label) : (fallbackLabel ?? value ?? \"—\");\n\n const base = \"inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2 py-0.5 text-xs font-medium\";\n\n if (variant === \"dot\") {\n // Tone có `dotColor` (hiện chỉ `severe`): chấm tô bằng token TÔ NỀN đó — đã đo 3:1 với nền trang,\n // vì ở cỡ 6px bậc ink (đủ tối cho CHỮ) đọc ra một đốm xỉn. Tone không khai thì giữ NGUYÊN phần tử\n // cũ: chấm lấy `currentColor` của bậc ink trong `textColor`.\n // Hai nhánh JSX tách hẳn chứ không gắn thuộc tính style theo điều kiện: style không phải object\n // literal là chỗ im lặng duy nhất của cổng tương phản (docs/hop-dong-mau.md §8, \"Còn lại\" mục 1).\n return (\n <span data-slot=\"status-pill\" className={cn(base, \"px-0 text-foreground\", className)} {...props}>\n {config?.dotColor ? (\n <span aria-hidden=\"true\" className={cn(\"size-1.5 shrink-0 rounded-full\", config.dotColor)} />\n ) : (\n <span\n aria-hidden=\"true\"\n className={cn(\"size-1.5 shrink-0 rounded-full\", config ? config.textColor : \"text-muted-foreground\")}\n style={{ backgroundColor: \"currentColor\" }}\n />\n )}\n {label}\n </span>\n );\n }\n\n if (variant === \"pill\" || variant === \"soft-dot\") {\n return (\n <span\n data-slot=\"status-pill\"\n data-variant={variant}\n className={cn(\n \"inline-flex items-center gap-1.25 whitespace-nowrap rounded-full px-2.5 py-[3.5px] text-[11.5px] leading-normal font-[580]\",\n config?.bgColor ?? \"bg-muted\",\n config?.textColor ?? \"text-muted-foreground\",\n className\n )}\n {...props}\n >\n {variant === \"soft-dot\" ? (\n <span\n aria-hidden=\"true\"\n className=\"size-[5.5px] shrink-0 rounded-full\"\n style={{ backgroundColor: \"currentColor\" }}\n />\n ) : null}\n {label}\n </span>\n );\n }\n\n if (variant === \"text-dot\") {\n return (\n <span\n data-slot=\"status-pill\"\n data-variant={variant}\n className={cn(base, \"px-0 py-0\", config?.textColor ?? \"text-muted-foreground\", className)}\n {...props}\n >\n <span\n aria-hidden=\"true\"\n className=\"size-1.5 shrink-0 rounded-full\"\n style={{ backgroundColor: \"currentColor\" }}\n />\n {label}\n </span>\n );\n }\n\n if (variant === \"outline\") {\n return (\n <span\n data-slot=\"status-pill\"\n className={cn(\n base,\n \"border bg-transparent\",\n // Lui về `border-muted-foreground` chứ KHÔNG phải `border-border`: ở biến thể này nền\n // trong suốt nên viền là thứ DUY NHẤT khoanh vùng chip → ngưỡng 3:1. `--border` là bậc\n // TRANG TRÍ, chỉ 1,16:1 (L) · 1,17:1 (D) so với nền trang ✗. `--muted-foreground` đạt\n // 5,23:1 (L) · 6,24:1 (D) và khớp đúng màu chữ lui bên dưới.\n config?.borderColor ?? \"border-muted-foreground\",\n config?.textColor ?? \"text-muted-foreground\",\n className\n )}\n {...props}\n >\n {label}\n </span>\n );\n }\n\n return (\n <span\n data-slot=\"status-pill\"\n className={cn(base, config?.bgColor ?? \"bg-muted\", config?.textColor ?? \"text-muted-foreground\", className)}\n {...props}\n >\n {label}\n </span>\n );\n}\n"],"mappings":"AAuDM,SAEI,KAFJ;AAtDN,SAAS,UAAU;AAEnB,SAAS,uBAAuB;AA+BzB,SAAS,WAAsC;AAAA,EACpD;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuB;AACrB,QAAM,SAAS,gBAAgB,SAAS,KAAK;AAC7C,QAAM,QAAQ,SAAU,QAAS,OAAO,cAAc,OAAO,QAAS,OAAO,QAAU,iBAAiB,SAAS;AAEjH,QAAM,OAAO;AAEb,MAAI,YAAY,OAAO;AAMrB,WACE,qBAAC,UAAK,aAAU,eAAc,WAAW,GAAG,MAAM,wBAAwB,SAAS,GAAI,GAAG,OACvF;AAAA,cAAQ,WACP,oBAAC,UAAK,eAAY,QAAO,WAAW,GAAG,kCAAkC,OAAO,QAAQ,GAAG,IAE3F;AAAA,QAAC;AAAA;AAAA,UACC,eAAY;AAAA,UACZ,WAAW,GAAG,kCAAkC,SAAS,OAAO,YAAY,uBAAuB;AAAA,UACnG,OAAO,EAAE,iBAAiB,eAAe;AAAA;AAAA,MAC3C;AAAA,MAED;AAAA,OACH;AAAA,EAEJ;AAEA,MAAI,YAAY,UAAU,YAAY,YAAY;AAChD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,gBAAc;AAAA,QACd,WAAW;AAAA,UACT;AAAA,UACA,QAAQ,WAAW;AAAA,UACnB,QAAQ,aAAa;AAAA,UACrB;AAAA,QACF;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,sBAAY,aACX;AAAA,YAAC;AAAA;AAAA,cACC,eAAY;AAAA,cACZ,WAAU;AAAA,cACV,OAAO,EAAE,iBAAiB,eAAe;AAAA;AAAA,UAC3C,IACE;AAAA,UACH;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,MAAI,YAAY,YAAY;AAC1B,WACE;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,gBAAc;AAAA,QACd,WAAW,GAAG,MAAM,aAAa,QAAQ,aAAa,yBAAyB,SAAS;AAAA,QACvF,GAAG;AAAA,QAEJ;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,eAAY;AAAA,cACZ,WAAU;AAAA,cACV,OAAO,EAAE,iBAAiB,eAAe;AAAA;AAAA,UAC3C;AAAA,UACC;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,MAAI,YAAY,WAAW;AACzB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,WAAW;AAAA,UACT;AAAA,UACA;AAAA;AAAA;AAAA;AAAA;AAAA,UAKA,QAAQ,eAAe;AAAA,UACvB,QAAQ,aAAa;AAAA,UACrB;AAAA,QACF;AAAA,QACC,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,MAAM,QAAQ,WAAW,YAAY,QAAQ,aAAa,yBAAyB,SAAS;AAAA,MACzG,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
4
|
+
import { VariantProps } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
declare const textVariants: (props?: ({
|
|
7
|
+
size?: "inherit" | "xs" | "sm" | "md" | null | undefined;
|
|
8
|
+
tone?: "primary" | "default" | "destructive" | "warning" | "success" | "inherit" | "secondary" | "muted" | "info" | "severe" | null | undefined;
|
|
9
|
+
weight?: "normal" | "medium" | "bold" | "inherit" | "semibold" | null | undefined;
|
|
10
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
11
|
+
type TextTone = NonNullable<VariantProps<typeof textVariants>["tone"]>;
|
|
12
|
+
interface TextProps extends Omit<ComponentProps<"span">, "ref">, VariantProps<typeof textVariants> {
|
|
13
|
+
/** Thẻ HTML (mặc định `span`). */
|
|
14
|
+
as?: "span" | "p" | "div";
|
|
15
|
+
/** Chữ số đều bề ngang (`tabular-nums`) — mã, số, giờ. */
|
|
16
|
+
numeric?: boolean;
|
|
17
|
+
/** Một dòng, cắt bằng dấu "…". Cần bề rộng giới hạn từ cha (hay `max-w-*`). */
|
|
18
|
+
truncate?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare function Text({ as, size, tone, weight, numeric, truncate, className, ...props }: TextProps): React.JSX.Element;
|
|
21
|
+
interface SectionLabelProps extends Omit<ComponentProps<"h4">, "ref"> {
|
|
22
|
+
/** Thẻ tiêu đề (mặc định `h4` — mục con trong một thẻ có `h3`). */
|
|
23
|
+
as?: "h3" | "h4" | "h5" | "div";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Nhãn mục CHỮ HOA trong thân thẻ (3.19.0, v4 `.dw-sec`): 10,5px/660, giãn 0,07em, đệm trên 18px · dưới 8px.
|
|
27
|
+
* ⚠ v4 tô `--ink-4` (≈ 2,9:1 — dưới AA); ở đây là `--muted-foreground` (AA).
|
|
28
|
+
*/
|
|
29
|
+
declare function SectionLabel({ as, className, ...props }: SectionLabelProps): React.JSX.Element;
|
|
30
|
+
/** Ô màu PHÂN LOẠI của biểu đồ — `chart-1`…`chart-5` (thứ tự series của `@comitor/ui/chart`) hoặc `neutral`. */
|
|
31
|
+
type CategorySlot = 1 | 2 | 3 | 4 | 5 | "neutral";
|
|
32
|
+
interface CategorySwatchProps extends Omit<ComponentProps<"span">, "children" | "slot"> {
|
|
33
|
+
slot: CategorySlot;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Ô vuông 8px tô màu phân loại (3.19.0) — màu của một THỰC THỂ (đội, khách) đứng trước tên nó. Trang trí đi kèm chữ
|
|
37
|
+
* (`aria-hidden`): tên bên cạnh mới mang thông tin, nên ô không chịu ngưỡng 3:1 của một dấu đứng một mình.
|
|
38
|
+
*/
|
|
39
|
+
declare function CategorySwatch({ slot, className, ...props }: CategorySwatchProps): React.JSX.Element;
|
|
40
|
+
|
|
41
|
+
export { type CategorySlot, CategorySwatch, type CategorySwatchProps, SectionLabel, type SectionLabelProps, Text, type TextProps, type TextTone, textVariants };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
const textVariants = cva("", {
|
|
5
|
+
variants: {
|
|
6
|
+
size: {
|
|
7
|
+
inherit: "",
|
|
8
|
+
/** 11,5px — v4 `.cs2`. */
|
|
9
|
+
xs: "text-[11.5px]",
|
|
10
|
+
/** 12,5px — v4 `.cs`. */
|
|
11
|
+
sm: "text-[12.5px]",
|
|
12
|
+
md: "text-sm"
|
|
13
|
+
},
|
|
14
|
+
tone: {
|
|
15
|
+
default: "text-foreground",
|
|
16
|
+
secondary: "text-(--text-secondary)",
|
|
17
|
+
muted: "text-muted-foreground",
|
|
18
|
+
primary: "text-brand-600 dark:text-brand-100",
|
|
19
|
+
success: "text-success-ink",
|
|
20
|
+
warning: "text-warning-ink",
|
|
21
|
+
severe: "text-severe-ink",
|
|
22
|
+
destructive: "text-destructive-ink",
|
|
23
|
+
info: "text-info-ink",
|
|
24
|
+
inherit: ""
|
|
25
|
+
},
|
|
26
|
+
weight: {
|
|
27
|
+
inherit: "",
|
|
28
|
+
normal: "font-normal",
|
|
29
|
+
medium: "font-medium",
|
|
30
|
+
semibold: "font-semibold",
|
|
31
|
+
bold: "font-bold"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: { size: "inherit", tone: "inherit", weight: "inherit" }
|
|
35
|
+
});
|
|
36
|
+
function Text({ as = "span", size, tone, weight, numeric, truncate, className, ...props }) {
|
|
37
|
+
const Comp = as;
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
Comp,
|
|
40
|
+
{
|
|
41
|
+
"data-slot": "text",
|
|
42
|
+
className: cn(textVariants({ size, tone, weight }), numeric && "tabular-nums", truncate && "truncate", className),
|
|
43
|
+
...props
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function SectionLabel({ as = "h4", className, ...props }) {
|
|
48
|
+
const Comp = as;
|
|
49
|
+
return /* @__PURE__ */ jsx(
|
|
50
|
+
Comp,
|
|
51
|
+
{
|
|
52
|
+
"data-slot": "section-label",
|
|
53
|
+
className: cn(
|
|
54
|
+
"pt-4.5 pb-2 text-[10.5px] font-[660] tracking-[0.07em] text-muted-foreground uppercase first:pt-0",
|
|
55
|
+
className
|
|
56
|
+
),
|
|
57
|
+
...props
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const CATEGORY_SWATCH = {
|
|
62
|
+
1: "bg-chart-1",
|
|
63
|
+
2: "bg-chart-2",
|
|
64
|
+
3: "bg-chart-3",
|
|
65
|
+
4: "bg-chart-4",
|
|
66
|
+
5: "bg-chart-5",
|
|
67
|
+
neutral: "bg-muted-foreground"
|
|
68
|
+
};
|
|
69
|
+
function CategorySwatch({ slot, className, ...props }) {
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
"data-slot": "category-swatch",
|
|
75
|
+
className: cn("inline-block size-2 shrink-0 rounded-[2px]", CATEGORY_SWATCH[slot], className),
|
|
76
|
+
...props
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
CategorySwatch,
|
|
82
|
+
SectionLabel,
|
|
83
|
+
Text,
|
|
84
|
+
textVariants
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/composite/text.tsx"],"sourcesContent":["import { cva, type VariantProps } from \"class-variance-authority\";\nimport type { ComponentProps } from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\n/*\n * Chữ nhỏ có VAI TRÒ (3.19.0) — dòng phụ, mã job, chữ có tone trong thân thẻ của bảng điều khiển (bản mẫu Imagtor v4\n * `.cs`, `.cs2`, `.jid`, `.d-crit`…). Gói mọi màu chữ vào TOKEN VAI TRÒ để app khỏi rải `text-[11.5px]\n * text-muted-foreground` khắp nơi:\n * tone `secondary` = `--text-secondary` (chữ phụ ĐẬM — mặc định trùng `--muted-foreground`),\n * `muted` = `--muted-foreground`, các tone trạng thái = bậc `--x-ink` (đã đo AA trên nền trang ở mọi bảng),\n * `primary` = cặp chữ thương hiệu của `STATUS_TONES.primary` (`brand-600` / tối `brand-100`).\n * Tĩnh → RSC-safe.\n */\nexport const textVariants = cva(\"\", {\n variants: {\n size: {\n inherit: \"\",\n /** 11,5px — v4 `.cs2`. */\n xs: \"text-[11.5px]\",\n /** 12,5px — v4 `.cs`. */\n sm: \"text-[12.5px]\",\n md: \"text-sm\"\n },\n tone: {\n default: \"text-foreground\",\n secondary: \"text-(--text-secondary)\",\n muted: \"text-muted-foreground\",\n primary: \"text-brand-600 dark:text-brand-100\",\n success: \"text-success-ink\",\n warning: \"text-warning-ink\",\n severe: \"text-severe-ink\",\n destructive: \"text-destructive-ink\",\n info: \"text-info-ink\",\n inherit: \"\"\n },\n weight: {\n inherit: \"\",\n normal: \"font-normal\",\n medium: \"font-medium\",\n semibold: \"font-semibold\",\n bold: \"font-bold\"\n }\n },\n defaultVariants: { size: \"inherit\", tone: \"inherit\", weight: \"inherit\" }\n});\n\nexport type TextTone = NonNullable<VariantProps<typeof textVariants>[\"tone\"]>;\n\nexport interface TextProps extends Omit<ComponentProps<\"span\">, \"ref\">, VariantProps<typeof textVariants> {\n /** Thẻ HTML (mặc định `span`). */\n as?: \"span\" | \"p\" | \"div\";\n /** Chữ số đều bề ngang (`tabular-nums`) — mã, số, giờ. */\n numeric?: boolean;\n /** Một dòng, cắt bằng dấu \"…\". Cần bề rộng giới hạn từ cha (hay `max-w-*`). */\n truncate?: boolean;\n}\n\nexport function Text({ as = \"span\", size, tone, weight, numeric, truncate, className, ...props }: TextProps) {\n const Comp = as;\n return (\n <Comp\n data-slot=\"text\"\n className={cn(textVariants({ size, tone, weight }), numeric && \"tabular-nums\", truncate && \"truncate\", className)}\n {...props}\n />\n );\n}\n\nexport interface SectionLabelProps extends Omit<ComponentProps<\"h4\">, \"ref\"> {\n /** Thẻ tiêu đề (mặc định `h4` — mục con trong một thẻ có `h3`). */\n as?: \"h3\" | \"h4\" | \"h5\" | \"div\";\n}\n\n/**\n * Nhãn mục CHỮ HOA trong thân thẻ (3.19.0, v4 `.dw-sec`): 10,5px/660, giãn 0,07em, đệm trên 18px · dưới 8px.\n * ⚠ v4 tô `--ink-4` (≈ 2,9:1 — dưới AA); ở đây là `--muted-foreground` (AA).\n */\nexport function SectionLabel({ as = \"h4\", className, ...props }: SectionLabelProps) {\n const Comp = as;\n return (\n <Comp\n data-slot=\"section-label\"\n className={cn(\n \"pt-4.5 pb-2 text-[10.5px] font-[660] tracking-[0.07em] text-muted-foreground uppercase first:pt-0\",\n className\n )}\n {...props}\n />\n );\n}\n\n/** Ô màu PHÂN LOẠI của biểu đồ — `chart-1`…`chart-5` (thứ tự series của `@comitor/ui/chart`) hoặc `neutral`. */\nexport type CategorySlot = 1 | 2 | 3 | 4 | 5 | \"neutral\";\n\nconst CATEGORY_SWATCH = {\n 1: \"bg-chart-1\",\n 2: \"bg-chart-2\",\n 3: \"bg-chart-3\",\n 4: \"bg-chart-4\",\n 5: \"bg-chart-5\",\n neutral: \"bg-muted-foreground\"\n} as const;\n\nexport interface CategorySwatchProps extends Omit<ComponentProps<\"span\">, \"children\" | \"slot\"> {\n slot: CategorySlot;\n}\n\n/**\n * Ô vuông 8px tô màu phân loại (3.19.0) — màu của một THỰC THỂ (đội, khách) đứng trước tên nó. Trang trí đi kèm chữ\n * (`aria-hidden`): tên bên cạnh mới mang thông tin, nên ô không chịu ngưỡng 3:1 của một dấu đứng một mình.\n */\nexport function CategorySwatch({ slot, className, ...props }: CategorySwatchProps) {\n return (\n <span\n aria-hidden=\"true\"\n data-slot=\"category-swatch\"\n className={cn(\"inline-block size-2 shrink-0 rounded-[2px]\", CATEGORY_SWATCH[slot], className)}\n {...props}\n />\n );\n}\n"],"mappings":"AA4DI;AA5DJ,SAAS,WAA8B;AAEvC,SAAS,UAAU;AAWZ,MAAM,eAAe,IAAI,IAAI;AAAA,EAClC,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,SAAS;AAAA;AAAA,MAET,IAAI;AAAA;AAAA,MAEJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,WAAW;AAAA,MACX,OAAO;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,WAAW,MAAM,WAAW,QAAQ,UAAU;AACzE,CAAC;AAaM,SAAS,KAAK,EAAE,KAAK,QAAQ,MAAM,MAAM,QAAQ,SAAS,UAAU,WAAW,GAAG,MAAM,GAAc;AAC3G,QAAM,OAAO;AACb,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,aAAa,EAAE,MAAM,MAAM,OAAO,CAAC,GAAG,WAAW,gBAAgB,YAAY,YAAY,SAAS;AAAA,MAC/G,GAAG;AAAA;AAAA,EACN;AAEJ;AAWO,SAAS,aAAa,EAAE,KAAK,MAAM,WAAW,GAAG,MAAM,GAAsB;AAClF,QAAM,OAAO;AACb,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAKA,MAAM,kBAAkB;AAAA,EACtB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,SAAS;AACX;AAUO,SAAS,eAAe,EAAE,MAAM,WAAW,GAAG,MAAM,GAAwB;AACjF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,aAAU;AAAA,MACV,WAAW,GAAG,8CAA8C,gBAAgB,IAAI,GAAG,SAAS;AAAA,MAC3F,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { IconComponent } from './empty-state.js';
|
|
4
|
+
|
|
5
|
+
type UrgencyLevel = "critical" | "warning" | "none";
|
|
6
|
+
interface UrgencyTextProps extends ComponentProps<"span"> {
|
|
7
|
+
level: UrgencyLevel;
|
|
8
|
+
/**
|
|
9
|
+
* Icon đứng trước chữ. Bỏ trống = `TriangleAlert` ở `critical`, không icon ở mức khác; `null` = không bao giờ.
|
|
10
|
+
* Màu mức gấp không chỉ nằm ở màu: `critical` có icon + chữ đậm (WCAG 1.4.1).
|
|
11
|
+
*/
|
|
12
|
+
icon?: IconComponent | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Chữ theo mức GẤP (3.19.0, bản mẫu Imagtor v4 `.due` + `.d-crit`/`.d-warn`) — hạn giao, thời hạn: `critical` =
|
|
16
|
+
* `--destructive-ink` 620, `warning` = `--warning-ink` 580, `none` = màu kế thừa. Chữ số đều bề ngang. Tĩnh.
|
|
17
|
+
*/
|
|
18
|
+
declare function UrgencyText({ level, icon, className, children, ...props }: UrgencyTextProps): React.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { type UrgencyLevel, UrgencyText, type UrgencyTextProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TriangleAlert } from "lucide-react";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
function UrgencyText({ level, icon, className, children, ...props }) {
|
|
5
|
+
const Icon = icon === void 0 ? level === "critical" ? TriangleAlert : void 0 : icon ?? void 0;
|
|
6
|
+
return /* @__PURE__ */ jsxs(
|
|
7
|
+
"span",
|
|
8
|
+
{
|
|
9
|
+
"data-slot": "urgency-text",
|
|
10
|
+
"data-level": level,
|
|
11
|
+
className: cn(
|
|
12
|
+
"inline-flex items-center gap-1.25 whitespace-nowrap tabular-nums",
|
|
13
|
+
level === "critical" && "font-[620] text-destructive-ink",
|
|
14
|
+
level === "warning" && "font-[580] text-warning-ink",
|
|
15
|
+
className
|
|
16
|
+
),
|
|
17
|
+
...props,
|
|
18
|
+
children: [
|
|
19
|
+
Icon ? /* @__PURE__ */ jsx(Icon, { "aria-hidden": "true", className: "size-3.25 shrink-0 [stroke-width:2.1]" }) : null,
|
|
20
|
+
children
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
UrgencyText
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=urgency-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/composite/urgency-text.tsx"],"sourcesContent":["import { TriangleAlert } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { cn } from \"../../lib/cn.js\";\nimport type { IconComponent } from \"./empty-state.js\";\n\nexport type UrgencyLevel = \"critical\" | \"warning\" | \"none\";\n\nexport interface UrgencyTextProps extends ComponentProps<\"span\"> {\n level: UrgencyLevel;\n /**\n * Icon đứng trước chữ. Bỏ trống = `TriangleAlert` ở `critical`, không icon ở mức khác; `null` = không bao giờ.\n * Màu mức gấp không chỉ nằm ở màu: `critical` có icon + chữ đậm (WCAG 1.4.1).\n */\n icon?: IconComponent | null;\n}\n\n/**\n * Chữ theo mức GẤP (3.19.0, bản mẫu Imagtor v4 `.due` + `.d-crit`/`.d-warn`) — hạn giao, thời hạn: `critical` =\n * `--destructive-ink` 620, `warning` = `--warning-ink` 580, `none` = màu kế thừa. Chữ số đều bề ngang. Tĩnh.\n */\nexport function UrgencyText({ level, icon, className, children, ...props }: UrgencyTextProps) {\n const Icon = icon === undefined ? (level === \"critical\" ? TriangleAlert : undefined) : (icon ?? undefined);\n return (\n <span\n data-slot=\"urgency-text\"\n data-level={level}\n className={cn(\n \"inline-flex items-center gap-1.25 whitespace-nowrap tabular-nums\",\n level === \"critical\" && \"font-[620] text-destructive-ink\",\n level === \"warning\" && \"font-[580] text-warning-ink\",\n className\n )}\n {...props}\n >\n {Icon ? <Icon aria-hidden=\"true\" className=\"size-3.25 shrink-0 [stroke-width:2.1]\" /> : null}\n {children}\n </span>\n );\n}\n"],"mappings":"AAuBI,SAWU,KAXV;AAvBJ,SAAS,qBAAqB;AAE9B,SAAS,UAAU;AAkBZ,SAAS,YAAY,EAAE,OAAO,MAAM,WAAW,UAAU,GAAG,MAAM,GAAqB;AAC5F,QAAM,OAAO,SAAS,SAAa,UAAU,aAAa,gBAAgB,SAAc,QAAQ;AAChG,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,cAAY;AAAA,MACZ,WAAW;AAAA,QACT;AAAA,QACA,UAAU,cAAc;AAAA,QACxB,UAAU,aAAa;AAAA,QACvB;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,eAAO,oBAAC,QAAK,eAAY,QAAO,WAAU,yCAAwC,IAAK;AAAA,QACvF;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|