@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
|
@@ -101,10 +101,32 @@ declare const progressTrackVariants: (props?: ({
|
|
|
101
101
|
declare const progressBarVariants: (props?: ({
|
|
102
102
|
tone?: "default" | "destructive" | "warning" | "success" | null | undefined;
|
|
103
103
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
104
|
+
declare const progressSizeVariants: (props?: ({
|
|
105
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
106
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
107
|
+
declare const progressFillVariants: (props?: ({
|
|
108
|
+
fill?: "neutral" | "scale-0" | "scale-1" | "scale-2" | "chart-1" | "chart-2" | "chart-3" | "chart-4" | "chart-5" | null | undefined;
|
|
109
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
104
110
|
/** Tông của thanh — xem chú thích ở trên về việc vì sao `warning` phải kèm vạch chéo. */
|
|
105
111
|
type ProgressTone = NonNullable<VariantProps<typeof progressBarVariants>["tone"]>;
|
|
112
|
+
type ProgressSize = "sm" | "default" | "lg";
|
|
113
|
+
type ProgressLevel = 0 | 1 | 2;
|
|
114
|
+
type ProgressColor = "chart-1" | "chart-2" | "chart-3" | "chart-4" | "chart-5" | "neutral";
|
|
115
|
+
interface ProgressMarker {
|
|
116
|
+
/** Vị trí, cùng đơn vị với `value` (0…`max`). */
|
|
117
|
+
at: number;
|
|
118
|
+
label?: React.ReactNode;
|
|
119
|
+
/** Dòng phụ dưới nhãn. */
|
|
120
|
+
sub?: React.ReactNode;
|
|
121
|
+
/** Đã chạm mốc — nhãn tô bằng bậc chữ thương hiệu. */
|
|
122
|
+
reached?: boolean;
|
|
123
|
+
}
|
|
106
124
|
interface ProgressProps extends React.ComponentProps<typeof ProgressPrimitive.Root>, VariantProps<typeof progressBarVariants> {
|
|
125
|
+
size?: ProgressSize;
|
|
126
|
+
level?: ProgressLevel;
|
|
127
|
+
color?: ProgressColor;
|
|
128
|
+
markers?: readonly ProgressMarker[];
|
|
107
129
|
}
|
|
108
|
-
declare function Progress({ className, value, max, tone, ...props }: ProgressProps): React.JSX.Element;
|
|
130
|
+
declare function Progress({ className, value, max, tone, size, level, color, markers, ...props }: ProgressProps): React.JSX.Element;
|
|
109
131
|
|
|
110
|
-
export { Progress, type ProgressProps, type ProgressTone, progressBarVariants, progressTrackVariants };
|
|
132
|
+
export { Progress, type ProgressColor, type ProgressLevel, type ProgressMarker, type ProgressProps, type ProgressSize, type ProgressTone, progressBarVariants, progressFillVariants, progressSizeVariants, progressTrackVariants };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { cn } from "../../lib/cn.js";
|
|
@@ -26,21 +26,60 @@ const progressBarVariants = cva("h-full w-full flex-1 transition-transform durat
|
|
|
26
26
|
},
|
|
27
27
|
defaultVariants: { tone: "default" }
|
|
28
28
|
});
|
|
29
|
+
const progressSizeVariants = cva("", {
|
|
30
|
+
variants: {
|
|
31
|
+
size: {
|
|
32
|
+
sm: "h-1.5",
|
|
33
|
+
default: "h-2",
|
|
34
|
+
lg: "h-4"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
defaultVariants: { size: "default" }
|
|
38
|
+
});
|
|
39
|
+
const progressFillVariants = cva("h-full w-full flex-1 transition-transform duration-150 ease-out", {
|
|
40
|
+
variants: {
|
|
41
|
+
fill: {
|
|
42
|
+
"scale-0": "bg-scale-0",
|
|
43
|
+
"scale-1": "bg-scale-1",
|
|
44
|
+
"scale-2": "bg-scale-2",
|
|
45
|
+
"chart-1": "bg-chart-1",
|
|
46
|
+
"chart-2": "bg-chart-2",
|
|
47
|
+
"chart-3": "bg-chart-3",
|
|
48
|
+
"chart-4": "bg-chart-4",
|
|
49
|
+
"chart-5": "bg-chart-5",
|
|
50
|
+
neutral: "bg-muted-foreground"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
29
54
|
const DEFAULT_MAX = 100;
|
|
30
55
|
function clampValue(value, max) {
|
|
31
56
|
if (typeof value !== "number" || !Number.isFinite(value)) return value;
|
|
32
57
|
return Math.min(Math.max(value, 0), max);
|
|
33
58
|
}
|
|
34
|
-
|
|
59
|
+
const LEVEL_FILL = { 0: "scale-0", 1: "scale-1", 2: "scale-2" };
|
|
60
|
+
function Progress({
|
|
61
|
+
className,
|
|
62
|
+
value,
|
|
63
|
+
max,
|
|
64
|
+
tone = "default",
|
|
65
|
+
size = "default",
|
|
66
|
+
level,
|
|
67
|
+
color,
|
|
68
|
+
markers,
|
|
69
|
+
...props
|
|
70
|
+
}) {
|
|
35
71
|
const validMax = typeof max === "number" && max > 0 ? max : DEFAULT_MAX;
|
|
36
72
|
const clamped = clampValue(value, validMax);
|
|
37
73
|
const percent = typeof clamped === "number" && Number.isFinite(clamped) ? clamped / validMax * 100 : 0;
|
|
38
|
-
|
|
74
|
+
const fill = level !== void 0 ? LEVEL_FILL[level] : color;
|
|
75
|
+
const root = /* @__PURE__ */ jsx(
|
|
39
76
|
ProgressPrimitive.Root,
|
|
40
77
|
{
|
|
41
78
|
"data-slot": "progress",
|
|
42
|
-
"data-tone": tone,
|
|
43
|
-
|
|
79
|
+
"data-tone": fill ? void 0 : tone,
|
|
80
|
+
"data-level": level,
|
|
81
|
+
"data-color": color,
|
|
82
|
+
className: cn(progressTrackVariants({ tone }), fill && "bg-muted", progressSizeVariants({ size }), className),
|
|
44
83
|
value: clamped,
|
|
45
84
|
max,
|
|
46
85
|
...props,
|
|
@@ -48,16 +87,52 @@ function Progress({ className, value, max, tone = "default", ...props }) {
|
|
|
48
87
|
ProgressPrimitive.Indicator,
|
|
49
88
|
{
|
|
50
89
|
"data-slot": "progress-indicator",
|
|
51
|
-
className: progressBarVariants({ tone }),
|
|
90
|
+
className: fill ? progressFillVariants({ fill }) : progressBarVariants({ tone }),
|
|
52
91
|
style: { transform: `translateX(-${100 - percent}%)` }
|
|
53
92
|
}
|
|
54
93
|
)
|
|
55
94
|
}
|
|
56
95
|
);
|
|
96
|
+
if (!markers?.length) return root;
|
|
97
|
+
const at = (m) => `${Math.min(Math.max(m.at, 0), validMax) / validMax * 100}%`;
|
|
98
|
+
const labelled = markers.some((m) => m.label !== void 0 || m.sub !== void 0);
|
|
99
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "progress-markers", className: "w-full", children: [
|
|
100
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
101
|
+
root,
|
|
102
|
+
markers.map((m, i) => /* @__PURE__ */ jsx(
|
|
103
|
+
"span",
|
|
104
|
+
{
|
|
105
|
+
"aria-hidden": "true",
|
|
106
|
+
"data-slot": "progress-marker",
|
|
107
|
+
className: "pointer-events-none absolute -top-0.75 -bottom-0.75 w-0.5 -translate-x-1/2 rounded-full bg-foreground opacity-55",
|
|
108
|
+
style: { left: at(m) }
|
|
109
|
+
},
|
|
110
|
+
`${i}-${m.at}`
|
|
111
|
+
))
|
|
112
|
+
] }),
|
|
113
|
+
labelled ? /* @__PURE__ */ jsx("div", { className: "relative mt-1.75 h-8.5", children: markers.map((m, i) => /* @__PURE__ */ jsxs(
|
|
114
|
+
"span",
|
|
115
|
+
{
|
|
116
|
+
"data-reached": m.reached || void 0,
|
|
117
|
+
className: cn(
|
|
118
|
+
"absolute -translate-x-1/2 text-center text-[11.5px] font-[620] whitespace-nowrap tabular-nums text-muted-foreground",
|
|
119
|
+
m.reached && "text-link-ink"
|
|
120
|
+
),
|
|
121
|
+
style: { left: at(m) },
|
|
122
|
+
children: [
|
|
123
|
+
m.label,
|
|
124
|
+
m.sub !== void 0 ? /* @__PURE__ */ jsx("span", { className: "block text-[10.5px] font-[520] text-muted-foreground", children: m.sub }) : null
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
`${i}-${m.at}`
|
|
128
|
+
)) }) : null
|
|
129
|
+
] });
|
|
57
130
|
}
|
|
58
131
|
export {
|
|
59
132
|
Progress,
|
|
60
133
|
progressBarVariants,
|
|
134
|
+
progressFillVariants,
|
|
135
|
+
progressSizeVariants,
|
|
61
136
|
progressTrackVariants
|
|
62
137
|
};
|
|
63
138
|
//# sourceMappingURL=progress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/progress.tsx"],"sourcesContent":["\"use client\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\n/**\n * Progress (Radix) — thanh tiến trình xác định (`value` 0…`max`, `max` mặc định 100).\n * Bỏ trống `value` để về trạng thái indeterminate của Radix (thanh đứng yên ở 0);\n * animation cho indeterminate là việc của app.\n *\n * ─ THANH VẼ THEO `value / max`, VÀ THANH VỚI `aria-*` NÓI CÙNG MỘT CON SỐ ─\n * Radix đọc `max` để dựng `aria-valuemax` và `aria-valuetext` (`round(value / max · 100)%`). Trước\n * `3.3.3` phần đã chạy lại vẽ bằng `100 - value` — bỏ qua `max` —, nên `max={30} value={24}` vẽ 24%\n * trong khi trình đọc màn hình đọc 80%: hai người nhìn cùng một control nhận hai con số.\n *\n * Nay cả hai đi từ MỘT giá trị: `value` được KẸP vào `[0, max]` rồi mới giao cho Radix (`max` không\n * phải số dương → 100, đúng luật Radix). Kẹp chứ không coi là indeterminate, vì ca vượt ngưỡng hay\n * gặp nhất là CÓ Ý: hạn mức dùng 120% phải là thanh ĐẦY, không phải thanh rỗng. Trước `3.3.3` ca đó\n * tình cờ đã đầy (`translateX(--20%)` là CSS vô hiệu) nhưng Radix coi `value` sai → không có\n * `aria-valuetext`, kèm lỗi console; nay thanh vẫn đầy VÀ trình đọc màn hình đọc \"100%\". Nói rõ là\n * đã vượt (bao nhiêu, làm gì tiếp) vẫn là việc của chữ cạnh thanh và `tone`, không của thanh.\n *\n * ─ ⛔ ĐỪNG ĐỔI TÔNG `default` SANG MÀU ĐẬM HƠN (chốt 2026-11-01) ─\n * 3.13.0 đổi thanh sang `gold-600` / rãnh `gold-100` để qua tương phản ở bảng mặc định; trên giao diện thật thanh nâu\n * sẫm nặng hơn mọi thứ quanh nó và bị trả về đây ở 3.13.1. Mức 1,73:1 (thanh ⇄ nền) / 1,55:1 (thanh ⇄ rãnh) ở bảng\n * MẶC ĐỊNH là ĐÃ CHẤP NHẬN — bỏ qua phép đo tương phản cho phần tô này. Cần rõ hơn thì chữ cạnh thanh, `tone`, hoặc\n * bảng tương phản cao (`data-contrast=\"high\"`, nơi các số đo bên dưới đạt). Xem CLAUDE.md, mục màu.\n *\n * ─ MÀU: `--primary-ink`, KHÔNG PHẢI `--primary` ─\n * Phần đã chạy là thông tin thị giác (WCAG 1.4.11, 3:1) và phải nổi trên CẢ nền trang lẫn phần\n * rãnh còn lại. `bg-primary` gold #E8B824 ở light chỉ **1,86:1** với nền trắng và **1,64:1** với\n * rãnh `bg-primary/20` — thanh 8px vàng nhạt trên nền trắng gần như không thấy. Bậc ink của\n * brand đạt cả hai phía ở cả hai theme:\n *\n * đã chạy ⇄ nền trang : 6,51:1 (light) · 12,67:1 (dark) ✓\n * đã chạy ⇄ rãnh `/20` : 4,85:1 (light) · 7,97:1 (dark) ✓\n * (tệ nhất khi rãnh nằm trên --muted: 4,54:1 · 6,52:1 ✓)\n *\n * ─ RÃNH: TINT `/20` GIỮ NGUYÊN, NHƯNG PHẢI CÓ VIỀN `--control-edge` ─\n * Bản trước chỉ có tint: rãnh ⇄ nền trang mới **1,34:1** (light) và **1,59–1,66:1** (dark), tức\n * KHÔNG nhìn thấy mốc 100% — ở `value` nhỏ không đọc được TỈ LỆ, ở `value=0` cả control biến mất.\n * Cách sửa hiển nhiên (đổi rãnh sang `bg-control-edge` như Slider/Switch) lại hỏng chỗ khác:\n * `--primary-ink` ⇄ `--control-edge` chỉ **1,70:1** (light) / **2,57:1** (dark), mà Progress\n * KHÔNG có núm nên ranh giới đã-chạy/chưa-chạy là thứ DUY NHẤT mang giá trị — mất nó là mất\n * thông tin. Với nền trang trắng không tồn tại cặp màu nào vừa ≥3:1 với nhau vừa ≥3:1 với nền\n * (chứng minh trong chú thích của `Slider`), nên hai ràng buộc phải tách ra hai lớp:\n *\n * khoanh vùng control → `border-control-edge` ⇄ nền trang : 3,83:1 (light) · 4,94:1 (dark) ✓\n * ⇄ --muted : 3,58:1 · 4,21:1 ✓\n * đọc tỉ lệ → đã chạy ⇄ rãnh `/20` : 4,85:1 · 7,97:1 ✓\n *\n * Đây đúng vai trò hợp đồng đặt cho `--control-edge` (styles.css §RANH GIỚI): \"khi nền control\n * trong suốt/nhạt thì VIỀN là thứ duy nhất khoanh vùng\".\n *\n * ─ TÔNG: BỐN GIÁ TRỊ, VÀ `warning` KHÔNG ĐƯỢC PHÉP CHỈ LÀ MỘT MÀU KHÁC ─\n * `tone` đổi CẢ phần đã chạy lẫn rãnh sang cùng một bậc ink, nên tỉ lệ đọc-được giữ nguyên cấu\n * trúc của bản mặc định. Đo trên ba bề mặt (`--background`, `--card`, `--muted`), tệ nhất mỗi cột.\n *\n * ⚠ Cột \"light\"/\"dark\" dưới đây là **bảng TƯƠNG PHẢN CAO** — đúng bảng mà cổng màu đo, và lý do\n * ghi ở đầu `scripts/a11y/tailwind.mjs`. Ở bảng mặc định (bản duyệt comitor-ds) `--primary-ink`\n * chính là `--primary` gold #E8B824, nên tông `default` chỉ được 1,73:1 với nền và 1,55:1 với\n * rãnh: đó là con số của BẢN DUYỆT, không phải lỗi của component — đổi nó là đổi bảng màu.\n *\n * tông đã chạy ⇄ nền trang đã chạy ⇄ rãnh cùng tông /20\n * default 6,09:1 (light) 10,80 (dark) 4,54:1 (light) 6,52:1 (dark) ✓\n * success 6,09:1 9,25 4,55:1 5,88:1 ✓\n * warning 6,09:1 10,52 4,54:1 6,47:1 ✓\n * destructive 6,68:1 5,82 4,85:1 4,25:1 ✓\n *\n * ⚠ NHƯNG `warning` KHÔNG phân biệt được với `default` BẰNG MÀU, và đó là số đo chứ không phải\n * cảm tính. Đo `--warning-ink` ⇄ `--primary-ink` trên cả BỐN bảng màu của gói:\n *\n * light (mặc định) #7A5800 ⇄ #E8B824 3,51:1 ✓\n * light (tương phản cao) #7A5800 ⇄ #7A5800 1,00:1 ✗ CÙNG MỘT HEX\n * dark (mặc định) #F2C94C ⇄ #F5D060 1,06:1 ✗\n * dark (tương phản cao) #FACC15 ⇄ #F5D060 1,03:1 ✗\n *\n * Ba trên bốn bảng màu cho ra hai thanh trông y hệt nhau. Đây KHÔNG sửa được ở tầng token: brand\n * của Comitor là gold, warning là yellow — cùng một sắc. Muốn tách hai bậc ink ra 3:1 thì một\n * trong hai phải rời khỏi vùng đọc-được: với nền trắng, chữ đạt 4,5:1 đòi độ chói ≤ 0,183, mà\n * cách `--gold-500` (0,111) đúng 3:1 thì phải ≤ 0,004 (gần như đen) hoặc ≥ 0,433 (quá sáng để\n * làm chữ). Hai ràng buộc không giao nhau — không có hex nào thoả cả hai.\n *\n * Nên tông `warning` nói bằng thứ KHÔNG PHẢI MÀU: `hazard-stripes` (khai ở styles.css) khoét\n * những rãnh chéo xuyên phần đã chạy để nền rãnh lộ ra. Ranh giới vạch ⇄ rãnh chính là cặp\n * \"đã chạy ⇄ rãnh\" đã đo ở bảng trên (4,54:1 light · 6,47:1 dark ✓), nên vạch KHÔNG thêm màu nào\n * và không cần đo thêm. Đây đúng là WCAG 1.4.1: tín hiệu không được chỉ nằm ở màu — bản vạch còn\n * đọc ra ở chế độ xám, chỗ mà mọi khác biệt sắc độ đều biến mất.\n *\n * ⚠ Vì vậy: KHÔNG được \"đơn giản hoá\" `warning` xuống còn mỗi `bg-warning-ink`. Bỏ vạch đi là\n * API đổi tông mà không đổi được gì ở ba trên bốn bảng màu — chỗ gọi tưởng đã cảnh báo, người\n * dùng không thấy gì. Cùng lý do đó, ĐỪNG thêm tông thứ năm nào nữa mà chưa đo lại bảng trên.\n *\n * Vạch chỉ là cách nói \"sắp chạm ngưỡng\" trên chính cái thanh; nó KHÔNG thay được một câu chữ.\n * Chỗ nào cần nói rõ ngưỡng là bao nhiêu và làm gì tiếp thì vẫn phải có `Alert`/`StatusPill` hoặc\n * một dòng `text-warning-ink` cạnh thanh.\n */\n\n/*\n * HAI `cva`, không phải hai bảng `Record`.\n *\n * Không phải chuyện phong cách: cổng màu (`scripts/check-contrast.mjs`) chỉ bóc chuỗi lớp từ ba\n * chỗ — thuộc tính `className`, `cva(base, { variants })`, và đối số TRỰC TIẾP của `cn()`. Class\n * nằm trong một `Record` rồi đi vào `cn()` qua biến là VÔ HÌNH với cổng: nó không báo lỗi, nó\n * lặng lẽ không đo — và miễn trừ của rãnh sẽ thành \"ruỗng\", đúng thứ cổng coi là nơi giấu lỗi.\n * Dạng `cva` cho cổng thấy cả base lẫn từng lá biến thể.\n */\nconst progressTrackVariants = cva(\"border-control-edge relative h-2 w-full overflow-hidden rounded-full border\", {\n variants: {\n tone: {\n default: \"bg-primary-ink/20\",\n success: \"bg-success-ink/20\",\n warning: \"bg-warning-ink/20\",\n destructive: \"bg-destructive-ink/20\"\n }\n },\n defaultVariants: { tone: \"default\" }\n});\n\nconst progressBarVariants = cva(\"h-full w-full flex-1 transition-transform duration-150 ease-out\", {\n variants: {\n tone: {\n default: \"bg-primary-ink\",\n success: \"bg-success-ink\",\n // `hazard-stripes` là PHẦN BẮT BUỘC của tông này, không phải trang trí — xem chú thích đầu file.\n warning: \"bg-warning-ink hazard-stripes\",\n destructive: \"bg-destructive-ink\"\n }\n },\n defaultVariants: { tone: \"default\" }\n});\n\n/** Tông của thanh — xem chú thích ở trên về việc vì sao `warning` phải kèm vạch chéo. */\nexport type ProgressTone = NonNullable<VariantProps<typeof progressBarVariants>[\"tone\"]>;\n\nexport interface ProgressProps\n extends React.ComponentProps<typeof ProgressPrimitive.Root>,\n VariantProps<typeof progressBarVariants> {}\n\n/** Mặc định của Radix — `max` không hợp lệ thì Radix cũng rơi về đúng số này cho `aria-*`. */\nconst DEFAULT_MAX = 100;\n\n/**\n * Kẹp `value` vào `[0, max]` — giá trị DUY NHẤT mà cả thanh lẫn Radix (`aria-*`) đọc (xem chú thích\n * đầu file). Không phải số hữu hạn (`null`, `undefined`, `NaN`) thì giữ nguyên: Radix coi là\n * indeterminate và thanh đứng ở 0.\n */\nfunction clampValue(value: number | null | undefined, max: number): number | null | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return value;\n return Math.min(Math.max(value, 0), max);\n}\n\nfunction Progress({ className, value, max, tone = \"default\", ...props }: ProgressProps) {\n const validMax = typeof max === \"number\" && max > 0 ? max : DEFAULT_MAX;\n const clamped = clampValue(value, validMax);\n const percent = typeof clamped === \"number\" && Number.isFinite(clamped) ? (clamped / validMax) * 100 : 0;\n\n return (\n <ProgressPrimitive.Root\n data-slot=\"progress\"\n data-tone={tone}\n className={cn(progressTrackVariants({ tone }), className)}\n value={clamped}\n max={max}\n {...props}\n >\n <ProgressPrimitive.Indicator\n data-slot=\"progress-indicator\"\n className={progressBarVariants({ tone })}\n style={{ transform: `translateX(-${100 - percent}%)` }}\n />\n </ProgressPrimitive.Root>\n );\n}\n\nexport { Progress, progressBarVariants, progressTrackVariants };\n"],"mappings":";AAwKM;AAtKN,YAAY,uBAAuB;AACnC,SAAS,WAA8B;AAEvC,SAAS,UAAU;AAwGnB,MAAM,wBAAwB,IAAI,+EAA+E;AAAA,EAC/G,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,UAAU;AACrC,CAAC;AAED,MAAM,sBAAsB,IAAI,mEAAmE;AAAA,EACjG,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,SAAS;AAAA;AAAA,MAET,SAAS;AAAA,MACT,aAAa;AAAA,IACf;AAAA,EACF;AAAA,EACA,iBAAiB,EAAE,MAAM,UAAU;AACrC,CAAC;AAUD,MAAM,cAAc;AAOpB,SAAS,WAAW,OAAkC,KAAwC;AAC5F,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACjE,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,GAAG;AACzC;AAEA,SAAS,SAAS,EAAE,WAAW,OAAO,KAAK,OAAO,WAAW,GAAG,MAAM,GAAkB;AACtF,QAAM,WAAW,OAAO,QAAQ,YAAY,MAAM,IAAI,MAAM;AAC5D,QAAM,UAAU,WAAW,OAAO,QAAQ;AAC1C,QAAM,UAAU,OAAO,YAAY,YAAY,OAAO,SAAS,OAAO,IAAK,UAAU,WAAY,MAAM;AAEvG,SACE;AAAA,IAAC,kBAAkB;AAAA,IAAlB;AAAA,MACC,aAAU;AAAA,MACV,aAAW;AAAA,MACX,WAAW,GAAG,sBAAsB,EAAE,KAAK,CAAC,GAAG,SAAS;AAAA,MACxD,OAAO;AAAA,MACP;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,QAAC,kBAAkB;AAAA,QAAlB;AAAA,UACC,aAAU;AAAA,UACV,WAAW,oBAAoB,EAAE,KAAK,CAAC;AAAA,UACvC,OAAO,EAAE,WAAW,eAAe,MAAM,OAAO,KAAK;AAAA;AAAA,MACvD;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/progress.tsx"],"sourcesContent":["\"use client\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\n/**\n * Progress (Radix) — thanh tiến trình xác định (`value` 0…`max`, `max` mặc định 100).\n * Bỏ trống `value` để về trạng thái indeterminate của Radix (thanh đứng yên ở 0);\n * animation cho indeterminate là việc của app.\n *\n * ─ THANH VẼ THEO `value / max`, VÀ THANH VỚI `aria-*` NÓI CÙNG MỘT CON SỐ ─\n * Radix đọc `max` để dựng `aria-valuemax` và `aria-valuetext` (`round(value / max · 100)%`). Trước\n * `3.3.3` phần đã chạy lại vẽ bằng `100 - value` — bỏ qua `max` —, nên `max={30} value={24}` vẽ 24%\n * trong khi trình đọc màn hình đọc 80%: hai người nhìn cùng một control nhận hai con số.\n *\n * Nay cả hai đi từ MỘT giá trị: `value` được KẸP vào `[0, max]` rồi mới giao cho Radix (`max` không\n * phải số dương → 100, đúng luật Radix). Kẹp chứ không coi là indeterminate, vì ca vượt ngưỡng hay\n * gặp nhất là CÓ Ý: hạn mức dùng 120% phải là thanh ĐẦY, không phải thanh rỗng. Trước `3.3.3` ca đó\n * tình cờ đã đầy (`translateX(--20%)` là CSS vô hiệu) nhưng Radix coi `value` sai → không có\n * `aria-valuetext`, kèm lỗi console; nay thanh vẫn đầy VÀ trình đọc màn hình đọc \"100%\". Nói rõ là\n * đã vượt (bao nhiêu, làm gì tiếp) vẫn là việc của chữ cạnh thanh và `tone`, không của thanh.\n *\n * ─ ⛔ ĐỪNG ĐỔI TÔNG `default` SANG MÀU ĐẬM HƠN (chốt 2026-11-01) ─\n * 3.13.0 đổi thanh sang `gold-600` / rãnh `gold-100` để qua tương phản ở bảng mặc định; trên giao diện thật thanh nâu\n * sẫm nặng hơn mọi thứ quanh nó và bị trả về đây ở 3.13.1. Mức 1,73:1 (thanh ⇄ nền) / 1,55:1 (thanh ⇄ rãnh) ở bảng\n * MẶC ĐỊNH là ĐÃ CHẤP NHẬN — bỏ qua phép đo tương phản cho phần tô này. Cần rõ hơn thì chữ cạnh thanh, `tone`, hoặc\n * bảng tương phản cao (`data-contrast=\"high\"`, nơi các số đo bên dưới đạt). Xem CLAUDE.md, mục màu.\n *\n * ─ MÀU: `--primary-ink`, KHÔNG PHẢI `--primary` ─\n * Phần đã chạy là thông tin thị giác (WCAG 1.4.11, 3:1) và phải nổi trên CẢ nền trang lẫn phần\n * rãnh còn lại. `bg-primary` gold #E8B824 ở light chỉ **1,86:1** với nền trắng và **1,64:1** với\n * rãnh `bg-primary/20` — thanh 8px vàng nhạt trên nền trắng gần như không thấy. Bậc ink của\n * brand đạt cả hai phía ở cả hai theme:\n *\n * đã chạy ⇄ nền trang : 6,51:1 (light) · 12,67:1 (dark) ✓\n * đã chạy ⇄ rãnh `/20` : 4,85:1 (light) · 7,97:1 (dark) ✓\n * (tệ nhất khi rãnh nằm trên --muted: 4,54:1 · 6,52:1 ✓)\n *\n * ─ RÃNH: TINT `/20` GIỮ NGUYÊN, NHƯNG PHẢI CÓ VIỀN `--control-edge` ─\n * Bản trước chỉ có tint: rãnh ⇄ nền trang mới **1,34:1** (light) và **1,59–1,66:1** (dark), tức\n * KHÔNG nhìn thấy mốc 100% — ở `value` nhỏ không đọc được TỈ LỆ, ở `value=0` cả control biến mất.\n * Cách sửa hiển nhiên (đổi rãnh sang `bg-control-edge` như Slider/Switch) lại hỏng chỗ khác:\n * `--primary-ink` ⇄ `--control-edge` chỉ **1,70:1** (light) / **2,57:1** (dark), mà Progress\n * KHÔNG có núm nên ranh giới đã-chạy/chưa-chạy là thứ DUY NHẤT mang giá trị — mất nó là mất\n * thông tin. Với nền trang trắng không tồn tại cặp màu nào vừa ≥3:1 với nhau vừa ≥3:1 với nền\n * (chứng minh trong chú thích của `Slider`), nên hai ràng buộc phải tách ra hai lớp:\n *\n * khoanh vùng control → `border-control-edge` ⇄ nền trang : 3,83:1 (light) · 4,94:1 (dark) ✓\n * ⇄ --muted : 3,58:1 · 4,21:1 ✓\n * đọc tỉ lệ → đã chạy ⇄ rãnh `/20` : 4,85:1 · 7,97:1 ✓\n *\n * Đây đúng vai trò hợp đồng đặt cho `--control-edge` (styles.css §RANH GIỚI): \"khi nền control\n * trong suốt/nhạt thì VIỀN là thứ duy nhất khoanh vùng\".\n *\n * ─ TÔNG: BỐN GIÁ TRỊ, VÀ `warning` KHÔNG ĐƯỢC PHÉP CHỈ LÀ MỘT MÀU KHÁC ─\n * `tone` đổi CẢ phần đã chạy lẫn rãnh sang cùng một bậc ink, nên tỉ lệ đọc-được giữ nguyên cấu\n * trúc của bản mặc định. Đo trên ba bề mặt (`--background`, `--card`, `--muted`), tệ nhất mỗi cột.\n *\n * ⚠ Cột \"light\"/\"dark\" dưới đây là **bảng TƯƠNG PHẢN CAO** — đúng bảng mà cổng màu đo, và lý do\n * ghi ở đầu `scripts/a11y/tailwind.mjs`. Ở bảng mặc định (bản duyệt comitor-ds) `--primary-ink`\n * chính là `--primary` gold #E8B824, nên tông `default` chỉ được 1,73:1 với nền và 1,55:1 với\n * rãnh: đó là con số của BẢN DUYỆT, không phải lỗi của component — đổi nó là đổi bảng màu.\n *\n * tông đã chạy ⇄ nền trang đã chạy ⇄ rãnh cùng tông /20\n * default 6,09:1 (light) 10,80 (dark) 4,54:1 (light) 6,52:1 (dark) ✓\n * success 6,09:1 9,25 4,55:1 5,88:1 ✓\n * warning 6,09:1 10,52 4,54:1 6,47:1 ✓\n * destructive 6,68:1 5,82 4,85:1 4,25:1 ✓\n *\n * ⚠ NHƯNG `warning` KHÔNG phân biệt được với `default` BẰNG MÀU, và đó là số đo chứ không phải\n * cảm tính. Đo `--warning-ink` ⇄ `--primary-ink` trên cả BỐN bảng màu của gói:\n *\n * light (mặc định) #7A5800 ⇄ #E8B824 3,51:1 ✓\n * light (tương phản cao) #7A5800 ⇄ #7A5800 1,00:1 ✗ CÙNG MỘT HEX\n * dark (mặc định) #F2C94C ⇄ #F5D060 1,06:1 ✗\n * dark (tương phản cao) #FACC15 ⇄ #F5D060 1,03:1 ✗\n *\n * Ba trên bốn bảng màu cho ra hai thanh trông y hệt nhau. Đây KHÔNG sửa được ở tầng token: brand\n * của Comitor là gold, warning là yellow — cùng một sắc. Muốn tách hai bậc ink ra 3:1 thì một\n * trong hai phải rời khỏi vùng đọc-được: với nền trắng, chữ đạt 4,5:1 đòi độ chói ≤ 0,183, mà\n * cách `--gold-500` (0,111) đúng 3:1 thì phải ≤ 0,004 (gần như đen) hoặc ≥ 0,433 (quá sáng để\n * làm chữ). Hai ràng buộc không giao nhau — không có hex nào thoả cả hai.\n *\n * Nên tông `warning` nói bằng thứ KHÔNG PHẢI MÀU: `hazard-stripes` (khai ở styles.css) khoét\n * những rãnh chéo xuyên phần đã chạy để nền rãnh lộ ra. Ranh giới vạch ⇄ rãnh chính là cặp\n * \"đã chạy ⇄ rãnh\" đã đo ở bảng trên (4,54:1 light · 6,47:1 dark ✓), nên vạch KHÔNG thêm màu nào\n * và không cần đo thêm. Đây đúng là WCAG 1.4.1: tín hiệu không được chỉ nằm ở màu — bản vạch còn\n * đọc ra ở chế độ xám, chỗ mà mọi khác biệt sắc độ đều biến mất.\n *\n * ⚠ Vì vậy: KHÔNG được \"đơn giản hoá\" `warning` xuống còn mỗi `bg-warning-ink`. Bỏ vạch đi là\n * API đổi tông mà không đổi được gì ở ba trên bốn bảng màu — chỗ gọi tưởng đã cảnh báo, người\n * dùng không thấy gì. Cùng lý do đó, ĐỪNG thêm tông thứ năm nào nữa mà chưa đo lại bảng trên.\n *\n * Vạch chỉ là cách nói \"sắp chạm ngưỡng\" trên chính cái thanh; nó KHÔNG thay được một câu chữ.\n * Chỗ nào cần nói rõ ngưỡng là bao nhiêu và làm gì tiếp thì vẫn phải có `Alert`/`StatusPill` hoặc\n * một dòng `text-warning-ink` cạnh thanh.\n */\n\n/*\n * HAI `cva`, không phải hai bảng `Record`.\n *\n * Không phải chuyện phong cách: cổng màu (`scripts/check-contrast.mjs`) chỉ bóc chuỗi lớp từ ba\n * chỗ — thuộc tính `className`, `cva(base, { variants })`, và đối số TRỰC TIẾP của `cn()`. Class\n * nằm trong một `Record` rồi đi vào `cn()` qua biến là VÔ HÌNH với cổng: nó không báo lỗi, nó\n * lặng lẽ không đo — và miễn trừ của rãnh sẽ thành \"ruỗng\", đúng thứ cổng coi là nơi giấu lỗi.\n * Dạng `cva` cho cổng thấy cả base lẫn từng lá biến thể.\n */\nconst progressTrackVariants = cva(\"border-control-edge relative h-2 w-full overflow-hidden rounded-full border\", {\n variants: {\n tone: {\n default: \"bg-primary-ink/20\",\n success: \"bg-success-ink/20\",\n warning: \"bg-warning-ink/20\",\n destructive: \"bg-destructive-ink/20\"\n }\n },\n defaultVariants: { tone: \"default\" }\n});\n\nconst progressBarVariants = cva(\"h-full w-full flex-1 transition-transform duration-150 ease-out\", {\n variants: {\n tone: {\n default: \"bg-primary-ink\",\n success: \"bg-success-ink\",\n // `hazard-stripes` là PHẦN BẮT BUỘC của tông này, không phải trang trí — xem chú thích đầu file.\n warning: \"bg-warning-ink hazard-stripes\",\n destructive: \"bg-destructive-ink\"\n }\n },\n defaultVariants: { tone: \"default\" }\n});\n\n/*\n * 3.19.0 — CỠ, THANG BA BẬC, MÀU PHÂN LOẠI, MỐC.\n *\n * `size`: `sm` 6px · `default` 8px (như cũ) · `lg` 16px (thanh ngày của bản mẫu Imagtor v4 `.track`).\n *\n * `level` (0 | 1 | 2) thay tông bằng THANG MỘT SẮC `--scale-*` — mức của CÙNG một đại lượng (chưa tới mốc 1 · qua mốc\n * 1 · qua mốc 2; v4 `.fill.b0/.b1/.b2`). `color` (`chart-1`…`chart-5` | `neutral`) tô theo THỰC THỂ (đội, khách…;\n * v4 `--o1…--o6`). Cả hai đặt rãnh lên `--muted` (v4 `--track`) và vẫn giữ viền `--control-edge` khoanh vùng control\n * như mọi tông. Thứ tự ưu tiên: `level` → `color` → `tone`.\n *\n * ⚠ Ở `level`/`color`, ranh giới đã chạy ⇄ rãnh KHÔNG được bảo đảm 3:1 như bốn tông (bậc 0 là tint nhạt cố ý) — giá trị\n * phải được nói bằng chữ cạnh thanh, hoặc bằng `markers`. Đừng dùng hai prop này cho thanh mà con số chỉ nằm trên thanh.\n *\n * `markers`: vạch dọc ngay trên thanh ở `at` (cùng đơn vị với `value`, theo `max`), nhãn tuỳ chọn bên dưới (11,5px,\n * dòng phụ 10,5px); `reached` tô nhãn bằng bậc chữ thương hiệu (`--link-ink`). Vạch là `--foreground` mờ 55% — phi văn\n * bản, nằm trên rãnh/phần đã chạy. Có `markers` thì `Progress` bọc thêm MỘT `<div>` ngoài Root; `className` vẫn vào\n * Root.\n */\nconst progressSizeVariants = cva(\"\", {\n variants: {\n size: {\n sm: \"h-1.5\",\n default: \"h-2\",\n lg: \"h-4\"\n }\n },\n defaultVariants: { size: \"default\" }\n});\n\nconst progressFillVariants = cva(\"h-full w-full flex-1 transition-transform duration-150 ease-out\", {\n variants: {\n fill: {\n \"scale-0\": \"bg-scale-0\",\n \"scale-1\": \"bg-scale-1\",\n \"scale-2\": \"bg-scale-2\",\n \"chart-1\": \"bg-chart-1\",\n \"chart-2\": \"bg-chart-2\",\n \"chart-3\": \"bg-chart-3\",\n \"chart-4\": \"bg-chart-4\",\n \"chart-5\": \"bg-chart-5\",\n neutral: \"bg-muted-foreground\"\n }\n }\n});\n\n/** Tông của thanh — xem chú thích ở trên về việc vì sao `warning` phải kèm vạch chéo. */\nexport type ProgressTone = NonNullable<VariantProps<typeof progressBarVariants>[\"tone\"]>;\nexport type ProgressSize = \"sm\" | \"default\" | \"lg\";\nexport type ProgressLevel = 0 | 1 | 2;\nexport type ProgressColor = \"chart-1\" | \"chart-2\" | \"chart-3\" | \"chart-4\" | \"chart-5\" | \"neutral\";\n\nexport interface ProgressMarker {\n /** Vị trí, cùng đơn vị với `value` (0…`max`). */\n at: number;\n label?: React.ReactNode;\n /** Dòng phụ dưới nhãn. */\n sub?: React.ReactNode;\n /** Đã chạm mốc — nhãn tô bằng bậc chữ thương hiệu. */\n reached?: boolean;\n}\n\nexport interface ProgressProps\n extends React.ComponentProps<typeof ProgressPrimitive.Root>,\n VariantProps<typeof progressBarVariants> {\n size?: ProgressSize;\n level?: ProgressLevel;\n color?: ProgressColor;\n markers?: readonly ProgressMarker[];\n}\n\n/** Mặc định của Radix — `max` không hợp lệ thì Radix cũng rơi về đúng số này cho `aria-*`. */\nconst DEFAULT_MAX = 100;\n\n/**\n * Kẹp `value` vào `[0, max]` — giá trị DUY NHẤT mà cả thanh lẫn Radix (`aria-*`) đọc (xem chú thích\n * đầu file). Không phải số hữu hạn (`null`, `undefined`, `NaN`) thì giữ nguyên: Radix coi là\n * indeterminate và thanh đứng ở 0.\n */\nfunction clampValue(value: number | null | undefined, max: number): number | null | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return value;\n return Math.min(Math.max(value, 0), max);\n}\n\nconst LEVEL_FILL = { 0: \"scale-0\", 1: \"scale-1\", 2: \"scale-2\" } as const;\n\nfunction Progress({\n className,\n value,\n max,\n tone = \"default\",\n size = \"default\",\n level,\n color,\n markers,\n ...props\n}: ProgressProps) {\n const validMax = typeof max === \"number\" && max > 0 ? max : DEFAULT_MAX;\n const clamped = clampValue(value, validMax);\n const percent = typeof clamped === \"number\" && Number.isFinite(clamped) ? (clamped / validMax) * 100 : 0;\n const fill = level !== undefined ? LEVEL_FILL[level] : color;\n\n const root = (\n <ProgressPrimitive.Root\n data-slot=\"progress\"\n data-tone={fill ? undefined : tone}\n data-level={level}\n data-color={color}\n className={cn(progressTrackVariants({ tone }), fill && \"bg-muted\", progressSizeVariants({ size }), className)}\n value={clamped}\n max={max}\n {...props}\n >\n <ProgressPrimitive.Indicator\n data-slot=\"progress-indicator\"\n className={fill ? progressFillVariants({ fill }) : progressBarVariants({ tone })}\n style={{ transform: `translateX(-${100 - percent}%)` }}\n />\n </ProgressPrimitive.Root>\n );\n\n if (!markers?.length) return root;\n const at = (m: ProgressMarker) => `${(Math.min(Math.max(m.at, 0), validMax) / validMax) * 100}%`;\n const labelled = markers.some((m) => m.label !== undefined || m.sub !== undefined);\n return (\n <div data-slot=\"progress-markers\" className=\"w-full\">\n <div className=\"relative\">\n {root}\n {markers.map((m, i) => (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: hai mốc có thể trùng `at`; vị trí trong mảng là danh tính\n key={`${i}-${m.at}`}\n aria-hidden=\"true\"\n data-slot=\"progress-marker\"\n className=\"pointer-events-none absolute -top-0.75 -bottom-0.75 w-0.5 -translate-x-1/2 rounded-full bg-foreground opacity-55\"\n style={{ left: at(m) }}\n />\n ))}\n </div>\n {labelled ? (\n <div className=\"relative mt-1.75 h-8.5\">\n {markers.map((m, i) => (\n <span\n // biome-ignore lint/suspicious/noArrayIndexKey: hai mốc có thể trùng `at`; vị trí trong mảng là danh tính\n key={`${i}-${m.at}`}\n data-reached={m.reached || undefined}\n className={cn(\n \"absolute -translate-x-1/2 text-center text-[11.5px] font-[620] whitespace-nowrap tabular-nums text-muted-foreground\",\n m.reached && \"text-link-ink\"\n )}\n style={{ left: at(m) }}\n >\n {m.label}\n {m.sub !== undefined ? (\n <span className=\"block text-[10.5px] font-[520] text-muted-foreground\">{m.sub}</span>\n ) : null}\n </span>\n ))}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport { Progress, progressBarVariants, progressFillVariants, progressSizeVariants, progressTrackVariants };\n"],"mappings":"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","names":[]}
|
|
@@ -10,15 +10,29 @@ type TableProps = React.ComponentProps<"table"> & {
|
|
|
10
10
|
variant?: "default" | "striped";
|
|
11
11
|
/** Alias tiện dụng của `variant="striped"`. */
|
|
12
12
|
striped?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Mật độ (3.19.0). `"compact"` = bảng nằm trong thân thẻ: tiêu đề 10,5px không nền, KHÔNG khung viền (trừ khi truyền
|
|
15
|
+
* `bordered`); cỡ chữ, đệm và chiều cao dòng theo token `--table-compact-*` (bộ green: `.dt` của bản mẫu Imagtor v4 —
|
|
16
|
+
* chữ 13px, dòng 46px). Các phần con đọc qua `data-density` của `<table>`.
|
|
17
|
+
*/
|
|
18
|
+
density?: "default" | "compact";
|
|
19
|
+
/** Khung viền bo góc quanh bảng — mặc định có, trừ `density="compact"` (bảng nằm thẳng trong thân thẻ). */
|
|
20
|
+
bordered?: boolean;
|
|
13
21
|
};
|
|
14
22
|
type TableHeaderProps = React.ComponentProps<"thead">;
|
|
15
23
|
type TableBodyProps = React.ComponentProps<"tbody">;
|
|
16
24
|
type TableFooterProps = React.ComponentProps<"tfoot">;
|
|
17
25
|
type TableRowProps = React.ComponentProps<"tr">;
|
|
18
|
-
type TableHeadProps = React.ComponentProps<"th"
|
|
19
|
-
|
|
26
|
+
type TableHeadProps = React.ComponentProps<"th"> & {
|
|
27
|
+
/** Cột số (3.19.0): canh phải + chữ số đều bề ngang. */
|
|
28
|
+
numeric?: boolean;
|
|
29
|
+
};
|
|
30
|
+
type TableCellProps = React.ComponentProps<"td"> & {
|
|
31
|
+
/** Ô số (3.19.0): canh phải + chữ số đều bề ngang — đi cùng `TableHead numeric`. */
|
|
32
|
+
numeric?: boolean;
|
|
33
|
+
};
|
|
20
34
|
type TableCaptionProps = React.ComponentProps<"caption">;
|
|
21
|
-
declare function Table({ className, variant, striped, ...props }: TableProps): React.JSX.Element;
|
|
35
|
+
declare function Table({ className, variant, striped, density, bordered, ...props }: TableProps): React.JSX.Element;
|
|
22
36
|
declare function TableHeader({ className, ...props }: TableHeaderProps): React.JSX.Element;
|
|
23
37
|
declare function TableBody({ className, ...props }: TableBodyProps): React.JSX.Element;
|
|
24
38
|
declare function TableFooter({ className, ...props }: TableFooterProps): React.JSX.Element;
|
|
@@ -33,8 +47,8 @@ declare function TableFooter({ className, ...props }: TableFooterProps): React.J
|
|
|
33
47
|
* của `DataTable` (`bg-inherit`) cũng nhận nền đặc này, không trong mờ.
|
|
34
48
|
*/
|
|
35
49
|
declare function TableRow({ className, ...props }: TableRowProps): React.JSX.Element;
|
|
36
|
-
declare function TableHead({ className, ...props }: TableHeadProps): React.JSX.Element;
|
|
37
|
-
declare function TableCell({ className, ...props }: TableCellProps): React.JSX.Element;
|
|
50
|
+
declare function TableHead({ className, numeric, ...props }: TableHeadProps): React.JSX.Element;
|
|
51
|
+
declare function TableCell({ className, numeric, ...props }: TableCellProps): React.JSX.Element;
|
|
38
52
|
declare function TableCaption({ className, ...props }: TableCaptionProps): React.JSX.Element;
|
|
39
53
|
|
|
40
54
|
export { Table, TableBody, type TableBodyProps, TableCaption, type TableCaptionProps, TableCell, type TableCellProps, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TableHeader, type TableHeaderProps, type TableProps, TableRow, type TableRowProps };
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../../lib/cn.js";
|
|
4
|
-
function Table({ className, variant = "default", striped, ...props }) {
|
|
4
|
+
function Table({ className, variant = "default", striped, density = "default", bordered, ...props }) {
|
|
5
|
+
const framed = bordered ?? density !== "compact";
|
|
5
6
|
const isStriped = striped || variant === "striped";
|
|
6
|
-
return /* @__PURE__ */ jsx(
|
|
7
|
-
"
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"div",
|
|
8
9
|
{
|
|
9
|
-
"data-slot": "table",
|
|
10
|
-
className: cn(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
"data-slot": "table-container",
|
|
11
|
+
className: cn("w-full overflow-auto", framed && "rounded-xl border border-border"),
|
|
12
|
+
children: /* @__PURE__ */ jsx(
|
|
13
|
+
"table",
|
|
14
|
+
{
|
|
15
|
+
"data-slot": "table",
|
|
16
|
+
"data-density": density,
|
|
17
|
+
className: cn(
|
|
18
|
+
"group/table w-full caption-bottom text-sm data-[density=compact]:text-(length:--table-compact-text)",
|
|
19
|
+
isStriped && "[&_tbody_tr:nth-child(even)]:bg-table-row-stripe [&_tbody_tr:nth-child(even):hover]:bg-table-row-hover",
|
|
20
|
+
className
|
|
21
|
+
),
|
|
22
|
+
...props
|
|
23
|
+
}
|
|
24
|
+
)
|
|
16
25
|
}
|
|
17
|
-
)
|
|
26
|
+
);
|
|
18
27
|
}
|
|
19
28
|
function TableHeader({ className, ...props }) {
|
|
20
|
-
return /* @__PURE__ */ jsx(
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
"thead",
|
|
31
|
+
{
|
|
32
|
+
"data-slot": "table-header",
|
|
33
|
+
className: cn("bg-muted/60 border-b border-border group-data-[density=compact]/table:bg-transparent", className),
|
|
34
|
+
...props
|
|
35
|
+
}
|
|
36
|
+
);
|
|
21
37
|
}
|
|
22
38
|
function TableBody({ className, ...props }) {
|
|
23
39
|
return /* @__PURE__ */ jsx("tbody", { "data-slot": "table-body", className: cn("[&_tr:last-child]:border-0", className), ...props });
|
|
@@ -45,26 +61,30 @@ function TableRow({ className, ...props }) {
|
|
|
45
61
|
}
|
|
46
62
|
);
|
|
47
63
|
}
|
|
48
|
-
function TableHead({ className, ...props }) {
|
|
64
|
+
function TableHead({ className, numeric = false, ...props }) {
|
|
49
65
|
return /* @__PURE__ */ jsx(
|
|
50
66
|
"th",
|
|
51
67
|
{
|
|
52
68
|
"data-slot": "table-head",
|
|
53
69
|
className: cn(
|
|
54
70
|
"h-(--table-head-h) px-4 text-left align-middle text-xs font-bold tracking-[0.08em] uppercase text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
71
|
+
"group-data-[density=compact]/table:h-auto group-data-[density=compact]/table:px-2.25 group-data-[density=compact]/table:py-(--table-compact-head-py) group-data-[density=compact]/table:text-[10.5px] group-data-[density=compact]/table:leading-normal group-data-[density=compact]/table:font-[650] group-data-[density=compact]/table:tracking-[0.06em]",
|
|
72
|
+
numeric && "text-right tabular-nums",
|
|
55
73
|
className
|
|
56
74
|
),
|
|
57
75
|
...props
|
|
58
76
|
}
|
|
59
77
|
);
|
|
60
78
|
}
|
|
61
|
-
function TableCell({ className, ...props }) {
|
|
79
|
+
function TableCell({ className, numeric = false, ...props }) {
|
|
62
80
|
return /* @__PURE__ */ jsx(
|
|
63
81
|
"td",
|
|
64
82
|
{
|
|
65
83
|
"data-slot": "table-cell",
|
|
66
84
|
className: cn(
|
|
67
85
|
"px-4 py-(--row-py) align-middle text-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
86
|
+
"group-data-[density=compact]/table:h-(--table-compact-row-h) group-data-[density=compact]/table:px-2.25 group-data-[density=compact]/table:py-(--table-compact-cell-py) group-data-[density=compact]/table:tabular-nums",
|
|
87
|
+
numeric && "text-right tabular-nums",
|
|
68
88
|
className
|
|
69
89
|
),
|
|
70
90
|
...props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ui/table.tsx"],"sourcesContent":["\"use client\";\n\nimport type * as React from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\n/**\n * Table — bảng cơ bản, đã bọc sẵn khung cuộn ngang + viền bo `rounded-xl`.\n * `variant=\"striped\"` (hoặc `striped`) tô nền xen kẽ cho hàng chẵn.\n *\n * Đây là primitive tĩnh: sort / chọn dòng / ghim cột nằm ở composite `DataTable`.\n */\n\nexport type TableProps = React.ComponentProps<\"table\"> & {\n variant?: \"default\" | \"striped\";\n /** Alias tiện dụng của `variant=\"striped\"`. */\n striped?: boolean;\n};\nexport type TableHeaderProps = React.ComponentProps<\"thead\">;\nexport type TableBodyProps = React.ComponentProps<\"tbody\">;\nexport type TableFooterProps = React.ComponentProps<\"tfoot\">;\nexport type TableRowProps = React.ComponentProps<\"tr\">;\nexport type TableHeadProps = React.ComponentProps<\"th\"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/table.tsx"],"sourcesContent":["\"use client\";\n\nimport type * as React from \"react\";\nimport { cn } from \"../../lib/cn.js\";\n\n/**\n * Table — bảng cơ bản, đã bọc sẵn khung cuộn ngang + viền bo `rounded-xl`.\n * `variant=\"striped\"` (hoặc `striped`) tô nền xen kẽ cho hàng chẵn.\n *\n * Đây là primitive tĩnh: sort / chọn dòng / ghim cột nằm ở composite `DataTable`.\n */\n\nexport type TableProps = React.ComponentProps<\"table\"> & {\n variant?: \"default\" | \"striped\";\n /** Alias tiện dụng của `variant=\"striped\"`. */\n striped?: boolean;\n /**\n * Mật độ (3.19.0). `\"compact\"` = bảng nằm trong thân thẻ: tiêu đề 10,5px không nền, KHÔNG khung viền (trừ khi truyền\n * `bordered`); cỡ chữ, đệm và chiều cao dòng theo token `--table-compact-*` (bộ green: `.dt` của bản mẫu Imagtor v4 —\n * chữ 13px, dòng 46px). Các phần con đọc qua `data-density` của `<table>`.\n */\n density?: \"default\" | \"compact\";\n /** Khung viền bo góc quanh bảng — mặc định có, trừ `density=\"compact\"` (bảng nằm thẳng trong thân thẻ). */\n bordered?: boolean;\n};\nexport type TableHeaderProps = React.ComponentProps<\"thead\">;\nexport type TableBodyProps = React.ComponentProps<\"tbody\">;\nexport type TableFooterProps = React.ComponentProps<\"tfoot\">;\nexport type TableRowProps = React.ComponentProps<\"tr\">;\nexport type TableHeadProps = React.ComponentProps<\"th\"> & {\n /** Cột số (3.19.0): canh phải + chữ số đều bề ngang. */\n numeric?: boolean;\n};\nexport type TableCellProps = React.ComponentProps<\"td\"> & {\n /** Ô số (3.19.0): canh phải + chữ số đều bề ngang — đi cùng `TableHead numeric`. */\n numeric?: boolean;\n};\nexport type TableCaptionProps = React.ComponentProps<\"caption\">;\n\nfunction Table({ className, variant = \"default\", striped, density = \"default\", bordered, ...props }: TableProps) {\n const framed = bordered ?? density !== \"compact\";\n const isStriped = striped || variant === \"striped\";\n return (\n <div\n data-slot=\"table-container\"\n className={cn(\"w-full overflow-auto\", framed && \"rounded-xl border border-border\")}\n >\n <table\n data-slot=\"table\"\n data-density={density}\n className={cn(\n \"group/table w-full caption-bottom text-sm data-[density=compact]:text-(length:--table-compact-text)\",\n isStriped &&\n \"[&_tbody_tr:nth-child(even)]:bg-table-row-stripe [&_tbody_tr:nth-child(even):hover]:bg-table-row-hover\",\n className\n )}\n {...props}\n />\n </div>\n );\n}\n\nfunction TableHeader({ className, ...props }: TableHeaderProps) {\n return (\n <thead\n data-slot=\"table-header\"\n className={cn(\"bg-muted/60 border-b border-border group-data-[density=compact]/table:bg-transparent\", className)}\n {...props}\n />\n );\n}\n\nfunction TableBody({ className, ...props }: TableBodyProps) {\n return <tbody data-slot=\"table-body\" className={cn(\"[&_tr:last-child]:border-0\", className)} {...props} />;\n}\n\nfunction TableFooter({ className, ...props }: TableFooterProps) {\n return (\n <tfoot\n data-slot=\"table-footer\"\n className={cn(\"bg-muted/40 border-t border-border font-medium [&>tr]:last:border-b-0\", className)}\n {...props}\n />\n );\n}\n\n/**\n * TableRow — dòng bảng. Trạng thái ĐÃ CHỌN (`data-state=\"selected\"`) là nền `--accent` — đúng bậc tint\n * TRẠNG THÁI mà DataGrid tô cho dòng đã chọn (`data-grid-row.tsx`), để hai bảng của gói nói cùng một thứ.\n * Không có vạch viền: dấu mang thông tin là ô checkbox đã tích (DataTable `selectable`), tint chỉ để nhận\n * ra dòng — 1,07:1 với `--card`, cố ý nhạt để chữ trong dòng vẫn đọc tốt.\n *\n * Nền tô trên TỪNG Ô (`*:`) chứ không trên `<tr>`: sọc của `striped` khai ở cấp `<table>` với độ đặc tả\n * (0,2,2) và thắng mọi class trên `<tr>`, nên tô ở `<tr>` thì dòng chọn ở hàng CHẴN không hiện gì. Ô ghim\n * của `DataTable` (`bg-inherit`) cũng nhận nền đặc này, không trong mờ.\n */\nfunction TableRow({ className, ...props }: TableRowProps) {\n return (\n <tr\n data-slot=\"table-row\"\n className={cn(\n \"border-b border-border transition-colors hover:bg-table-row-hover data-[state=selected]:*:bg-accent\",\n className\n )}\n {...props}\n />\n );\n}\n\nfunction TableHead({ className, numeric = false, ...props }: TableHeadProps) {\n return (\n <th\n data-slot=\"table-head\"\n className={cn(\n \"h-(--table-head-h) px-4 text-left align-middle text-xs font-bold tracking-[0.08em] uppercase text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]\",\n \"group-data-[density=compact]/table:h-auto group-data-[density=compact]/table:px-2.25 group-data-[density=compact]/table:py-(--table-compact-head-py) group-data-[density=compact]/table:text-[10.5px] group-data-[density=compact]/table:leading-normal group-data-[density=compact]/table:font-[650] group-data-[density=compact]/table:tracking-[0.06em]\",\n numeric && \"text-right tabular-nums\",\n className\n )}\n {...props}\n />\n );\n}\n\nfunction TableCell({ className, numeric = false, ...props }: TableCellProps) {\n return (\n <td\n data-slot=\"table-cell\"\n className={cn(\n \"px-4 py-(--row-py) align-middle text-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]\",\n \"group-data-[density=compact]/table:h-(--table-compact-row-h) group-data-[density=compact]/table:px-2.25 group-data-[density=compact]/table:py-(--table-compact-cell-py) group-data-[density=compact]/table:tabular-nums\",\n numeric && \"text-right tabular-nums\",\n className\n )}\n {...props}\n />\n );\n}\n\nfunction TableCaption({ className, ...props }: TableCaptionProps) {\n return (\n <caption data-slot=\"table-caption\" className={cn(\"mt-4 text-sm text-muted-foreground\", className)} {...props} />\n );\n}\n\nexport { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };\n"],"mappings":";AA+CM;AA5CN,SAAS,UAAU;AAoCnB,SAAS,MAAM,EAAE,WAAW,UAAU,WAAW,SAAS,UAAU,WAAW,UAAU,GAAG,MAAM,GAAe;AAC/G,QAAM,SAAS,YAAY,YAAY;AACvC,QAAM,YAAY,WAAW,YAAY;AACzC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,wBAAwB,UAAU,iCAAiC;AAAA,MAEjF;AAAA,QAAC;AAAA;AAAA,UACC,aAAU;AAAA,UACV,gBAAc;AAAA,UACd,WAAW;AAAA,YACT;AAAA,YACA,aACE;AAAA,YACF;AAAA,UACF;AAAA,UACC,GAAG;AAAA;AAAA,MACN;AAAA;AAAA,EACF;AAEJ;AAEA,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAqB;AAC9D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,wFAAwF,SAAS;AAAA,MAC9G,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,UAAU,EAAE,WAAW,GAAG,MAAM,GAAmB;AAC1D,SAAO,oBAAC,WAAM,aAAU,cAAa,WAAW,GAAG,8BAA8B,SAAS,GAAI,GAAG,OAAO;AAC1G;AAEA,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAqB;AAC9D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,yEAAyE,SAAS;AAAA,MAC/F,GAAG;AAAA;AAAA,EACN;AAEJ;AAYA,SAAS,SAAS,EAAE,WAAW,GAAG,MAAM,GAAkB;AACxD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,UAAU,EAAE,WAAW,UAAU,OAAO,GAAG,MAAM,GAAmB;AAC3E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,UAAU,EAAE,WAAW,UAAU,OAAO,GAAG,MAAM,GAAmB;AAC3E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,SAAS,aAAa,EAAE,WAAW,GAAG,MAAM,GAAsB;AAChE,SACE,oBAAC,aAAQ,aAAU,iBAAgB,WAAW,GAAG,sCAAsC,SAAS,GAAI,GAAG,OAAO;AAElH;","names":[]}
|
|
@@ -1273,7 +1273,18 @@ function TimePickerInput(props) {
|
|
|
1273
1273
|
disabled: isDisabled,
|
|
1274
1274
|
readOnly: isReadOnly,
|
|
1275
1275
|
className: cn(
|
|
1276
|
-
|
|
1276
|
+
/*
|
|
1277
|
+
* ⚠ Khác thượng nguồn (3.18.1): `min-h-6 min-w-6` — mỗi ô (giờ, phút, giây, buổi) là một vùng
|
|
1278
|
+
* bấm tối thiểu 24×24px (WCAG 2.5.8, Lighthouse `target-size`). Trước đó ô cao bằng vùng nội
|
|
1279
|
+
* dung của khung — `h-9` 36px trừ viền 2×1px trừ `py-2` 2×8px = 18px — và rộng đúng `2ch`
|
|
1280
|
+
* (~17,7px ở 14px), nên comitor-ds đo được "Minute" 17,7×18px, "AM/PM" 22,1×18px (`2,5ch`),
|
|
1281
|
+
* lại sát nhau (`gap-0.5` = 2px) nên không được miễn theo khoảng cách. `min-width` thắng
|
|
1282
|
+
* `width` inline, nên `--time-picker-*-input-width` vẫn quyết bề rộng khi nó lớn hơn 24px (nhãn
|
|
1283
|
+
* buổi dài). Chữ giữ nguyên cỡ và nằm giữa ô (`text-center`); ô 24px nằm gọn trong 34px bên
|
|
1284
|
+
* trong viền (dư 5px mỗi phía, tràn vào `py-2` chứ không đẩy khung) — khung vẫn `h-9`, bằng
|
|
1285
|
+
* `Input`. `test:dom-render` khoá hai lớp này.
|
|
1286
|
+
*/
|
|
1287
|
+
"inline-flex h-full min-h-6 min-w-6 items-center justify-center border-0 bg-transparent text-center text-base md:text-sm tabular-nums transition-colors outline-none focus:bg-transparent disabled:cursor-not-allowed disabled:opacity-50",
|
|
1277
1288
|
className
|
|
1278
1289
|
),
|
|
1279
1290
|
style: { width: segmentWidth, ...style },
|
|
@@ -1304,7 +1315,14 @@ function TimePickerTrigger(props) {
|
|
|
1304
1315
|
className: cn(
|
|
1305
1316
|
// ⚠ Khác thượng nguồn: thêm viền focus theo khuôn `Button` của gói — bản gốc không có kiểu
|
|
1306
1317
|
// focus nào, và viền mặc định của trình duyệt bị lớp nền `outline-ring/50` pha còn gold 50%.
|
|
1307
|
-
|
|
1318
|
+
// ⚠ Khác thượng nguồn (3.18.1): `min-h-6 min-w-6 justify-center` — vùng bấm 24×24px như ô
|
|
1319
|
+
// (WCAG 2.5.8), trước đó đúng bằng icon 16px và chỉ đạt nhờ khoảng trống bên trái; khung hẹp
|
|
1320
|
+
// đẩy ô buổi sát vào là hết miễn. `-mr-1` (4px) bù phần đệm mới: glyph 16px giữa ô 24px thụt
|
|
1321
|
+
// 4px, kéo nút vào `px-3` 4px thì glyph vẫn cách mép viền 12px — đúng mốc của
|
|
1322
|
+
// `Select`/`DatePicker`. CHỈ khi vẽ icon mặc định: `children` của app (chữ, icon cỡ khác) không
|
|
1323
|
+
// có phần thụt 4px đó, kéo vào là lệch về phía viền.
|
|
1324
|
+
children == null && "-mr-1",
|
|
1325
|
+
"ml-auto flex min-h-6 min-w-6 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 disabled:pointer-events-none [&>svg:not([class*='size-'])]:size-4",
|
|
1308
1326
|
className
|
|
1309
1327
|
),
|
|
1310
1328
|
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1855,7 +1873,9 @@ function TimePickerClear(props) {
|
|
|
1855
1873
|
...clearProps,
|
|
1856
1874
|
className: cn(
|
|
1857
1875
|
// Viền focus theo khuôn `Button` — xem `TimePickerTrigger`.
|
|
1858
|
-
|
|
1876
|
+
// ⚠ Khác thượng nguồn (3.18.1): `min-h-6 min-w-6` — vùng bấm 24×24px như ô và nút mở (WCAG
|
|
1877
|
+
// 2.5.8); bản gốc cao đúng dòng chữ `text-sm`, 20px.
|
|
1878
|
+
"inline-flex min-h-6 min-w-6 items-center justify-center rounded-sm text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
1859
1879
|
className
|
|
1860
1880
|
),
|
|
1861
1881
|
onClick,
|