@craftzbay/ui 0.10.0 → 0.11.1
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 +18 -12
- package/dist-lib/__tests__/helpers/color.d.ts +9 -0
- package/dist-lib/__tests__/helpers/theme.d.ts +18 -0
- package/dist-lib/components/ui/Accordion.js +18 -7
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.d.ts +16 -0
- package/dist-lib/components/ui/Alert.js +47 -34
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Avatar.d.ts +1 -1
- package/dist-lib/components/ui/Avatar.js +45 -47
- package/dist-lib/components/ui/Avatar.js.map +1 -1
- package/dist-lib/components/ui/Badge.d.ts +3 -1
- package/dist-lib/components/ui/Badge.js +24 -15
- package/dist-lib/components/ui/Badge.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.d.ts +2 -0
- package/dist-lib/components/ui/Breadcrumbs.js +46 -28
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.d.ts +5 -3
- package/dist-lib/components/ui/Button.js +59 -45
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.d.ts +1 -1
- package/dist-lib/components/ui/Calendar.js +87 -59
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.d.ts +2 -0
- package/dist-lib/components/ui/Card.js +48 -67
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.d.ts +6 -6
- package/dist-lib/components/ui/Carousel.js +133 -102
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.d.ts +49 -10
- package/dist-lib/components/ui/Chart.js +415 -181
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +42 -28
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.d.ts +2 -0
- package/dist-lib/components/ui/Combobox.js +142 -111
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.d.ts +6 -3
- package/dist-lib/components/ui/CommandPalette.js +92 -87
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.d.ts +7 -2
- package/dist-lib/components/ui/ContextMenu.js +77 -62
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DataGrid.d.ts +17 -4
- package/dist-lib/components/ui/DataGrid.js +65 -50
- package/dist-lib/components/ui/DataGrid.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +118 -99
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.d.ts +94 -40
- package/dist-lib/components/ui/DesignSystemProvider.js +111 -55
- package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
- package/dist-lib/components/ui/Dialog.d.ts +18 -3
- package/dist-lib/components/ui/Dialog.js +105 -80
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.d.ts +17 -2
- package/dist-lib/components/ui/Drawer.js +89 -55
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +14 -9
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/EmptyState.d.ts +2 -0
- package/dist-lib/components/ui/EmptyState.js +30 -16
- package/dist-lib/components/ui/EmptyState.js.map +1 -1
- package/dist-lib/components/ui/ErrorState.d.ts +13 -2
- package/dist-lib/components/ui/ErrorState.js +44 -23
- package/dist-lib/components/ui/ErrorState.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.js +59 -56
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/Form.d.ts +15 -2
- package/dist-lib/components/ui/Form.js +97 -71
- package/dist-lib/components/ui/Form.js.map +1 -1
- package/dist-lib/components/ui/Icon.d.ts +1 -1
- package/dist-lib/components/ui/Icon.js +20 -14
- package/dist-lib/components/ui/Icon.js.map +1 -1
- package/dist-lib/components/ui/IconButton.d.ts +2 -2
- package/dist-lib/components/ui/IconButton.js +28 -20
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.d.ts +3 -1
- package/dist-lib/components/ui/Input.js +102 -79
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/Kbd.js +1 -1
- package/dist-lib/components/ui/Kbd.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +121 -107
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +67 -62
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +14 -14
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/Progress.d.ts +3 -3
- package/dist-lib/components/ui/Progress.js +77 -72
- package/dist-lib/components/ui/Progress.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.d.ts +1 -1
- package/dist-lib/components/ui/RadioGroup.js +69 -52
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/RelativeTime.d.ts +19 -0
- package/dist-lib/components/ui/RelativeTime.js +31 -0
- package/dist-lib/components/ui/RelativeTime.js.map +1 -0
- package/dist-lib/components/ui/ScrollArea.d.ts +9 -1
- package/dist-lib/components/ui/ScrollArea.js +43 -27
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.d.ts +6 -1
- package/dist-lib/components/ui/Select.js +79 -71
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Separator.js +1 -1
- package/dist-lib/components/ui/Separator.js.map +1 -1
- package/dist-lib/components/ui/Sheet.d.ts +9 -0
- package/dist-lib/components/ui/Sheet.js +69 -46
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.d.ts +12 -9
- package/dist-lib/components/ui/Sidebar.js +152 -109
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Skeleton.d.ts +13 -2
- package/dist-lib/components/ui/Skeleton.js +15 -14
- package/dist-lib/components/ui/Skeleton.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +41 -29
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +23 -22
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Spinner.js +18 -6
- package/dist-lib/components/ui/Spinner.js.map +1 -1
- package/dist-lib/components/ui/Stepper.d.ts +6 -0
- package/dist-lib/components/ui/Stepper.js +71 -48
- package/dist-lib/components/ui/Stepper.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +46 -43
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.d.ts +33 -5
- package/dist-lib/components/ui/Table.js +141 -119
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +50 -48
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +45 -45
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +65 -54
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Timeline.js +39 -35
- package/dist-lib/components/ui/Timeline.js.map +1 -1
- package/dist-lib/components/ui/Toast.js +44 -57
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/Tooltip.d.ts +4 -1
- package/dist-lib/components/ui/Tooltip.js +24 -22
- package/dist-lib/components/ui/Tooltip.js.map +1 -1
- package/dist-lib/components/ui/TopNav.d.ts +7 -3
- package/dist-lib/components/ui/TopNav.js +39 -22
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.d.ts +15 -10
- package/dist-lib/components/ui/Tree.js +82 -79
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/hooks/use-debounce.d.ts +19 -0
- package/dist-lib/hooks/use-debounce.js +36 -0
- package/dist-lib/hooks/use-debounce.js.map +1 -0
- package/dist-lib/hooks/use-delayed-loading.d.ts +21 -0
- package/dist-lib/hooks/use-delayed-loading.js +20 -0
- package/dist-lib/hooks/use-delayed-loading.js.map +1 -0
- package/dist-lib/hooks/use-field-ids.d.ts +2 -1
- package/dist-lib/hooks/use-field-ids.js +9 -9
- package/dist-lib/hooks/use-field-ids.js.map +1 -1
- package/dist-lib/hooks/use-media-query.d.ts +3 -1
- package/dist-lib/hooks/use-media-query.js +16 -12
- package/dist-lib/hooks/use-media-query.js.map +1 -1
- package/dist-lib/hooks/use-modifier-key.d.ts +13 -0
- package/dist-lib/hooks/use-modifier-key.js +19 -0
- package/dist-lib/hooks/use-modifier-key.js.map +1 -0
- package/dist-lib/hooks/use-toast.d.ts +7 -2
- package/dist-lib/hooks/use-toast.js +61 -30
- package/dist-lib/hooks/use-toast.js.map +1 -1
- package/dist-lib/icons/index.d.ts +9 -0
- package/dist-lib/icons/index.js +148 -130
- package/dist-lib/icons/index.js.map +1 -1
- package/dist-lib/illustrations/index.d.ts +1 -0
- package/dist-lib/illustrations/index.js +15 -6
- package/dist-lib/illustrations/index.js.map +1 -1
- package/dist-lib/index.d.ts +6 -0
- package/dist-lib/index.js +280 -260
- package/dist-lib/index.js.map +1 -1
- package/dist-lib/lib/format.d.ts +65 -0
- package/dist-lib/lib/format.js +95 -0
- package/dist-lib/lib/format.js.map +1 -0
- package/dist-lib/lib/return-focus.d.ts +11 -0
- package/dist-lib/lib/return-focus.js +12 -0
- package/dist-lib/lib/return-focus.js.map +1 -0
- package/dist-lib/lib/strings.d.ts +62 -1
- package/dist-lib/lib/strings.js +75 -19
- package/dist-lib/lib/strings.js.map +1 -1
- package/dist-lib/lib/strings.mn.js +50 -5
- package/dist-lib/lib/strings.mn.js.map +1 -1
- package/dist-lib/styles.css +1 -1
- package/dist-lib/theme.css +141 -78
- package/package.json +11 -4
|
@@ -1,253 +1,487 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { cn as
|
|
5
|
-
|
|
2
|
+
import { jsx as s, jsxs as $, Fragment as U } from "react/jsx-runtime";
|
|
3
|
+
import { useId as oe, useState as K, useRef as ae, useCallback as se, useEffect as ie, useLayoutEffect as ce } from "react";
|
|
4
|
+
import { cn as w } from "../../lib/utils.js";
|
|
5
|
+
import { useStrings as X } from "../../hooks/use-strings.js";
|
|
6
|
+
import { formatString as z } from "../../lib/strings.js";
|
|
7
|
+
import { Skeleton as le } from "./Skeleton.js";
|
|
8
|
+
const Ie = {
|
|
9
|
+
summary: ({ name: e, count: n, min: r, max: t, lastX: o, lastY: a }) => `${e}: ${n} points, min ${r}, max ${t}, last ${o}: ${a}`,
|
|
10
|
+
point: (e, n, r) => `${e ? `${e} — ` : ""}${n}: ${r}`,
|
|
11
|
+
series: (e, n) => `${e}, ${n} points. Use arrow keys to move between points.`
|
|
12
|
+
};
|
|
13
|
+
function V(e) {
|
|
14
|
+
return {
|
|
15
|
+
summary: ({ name: n, count: r, min: t, max: o, lastX: a, lastY: i }) => z(e.summary, { name: n, count: r, min: t, max: o, x: a, y: i }),
|
|
16
|
+
point: (n, r, t) => (n ? `${n} — ` : "") + z(e.point, { x: r, y: t }),
|
|
17
|
+
series: (n, r) => z(e.seriesNav, { name: n, count: r })
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const q = [
|
|
6
21
|
"var(--chart-1)",
|
|
7
22
|
"var(--chart-2)",
|
|
8
23
|
"var(--chart-3)",
|
|
9
24
|
"var(--chart-4)",
|
|
10
25
|
"var(--chart-5)",
|
|
11
26
|
"var(--chart-6)"
|
|
12
|
-
],
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
], de = 600, S = 6;
|
|
28
|
+
function ue() {
|
|
29
|
+
const e = ae(null), [n, r] = K(0);
|
|
30
|
+
return (typeof window > "u" ? ie : ce)(() => {
|
|
31
|
+
const o = e.current;
|
|
32
|
+
if (!o) return;
|
|
33
|
+
const a = () => r(o.clientWidth);
|
|
34
|
+
if (a(), typeof ResizeObserver > "u") return;
|
|
35
|
+
const i = new ResizeObserver(a);
|
|
36
|
+
return i.observe(o), () => i.disconnect();
|
|
37
|
+
}, []), { ref: e, width: n || de };
|
|
38
|
+
}
|
|
39
|
+
const he = 5;
|
|
40
|
+
function fe(e) {
|
|
41
|
+
const n = Math.abs(e), r = (t, o) => `${(Math.round(t * 10) / 10).toString()}${o}`;
|
|
42
|
+
return n >= 1e9 ? r(e / 1e9, "B") : n >= 1e6 ? r(e / 1e6, "M") : n >= 1e3 ? r(e / 1e3, "K") : Number.isInteger(e) ? String(e) : (Math.round(e * 100) / 100).toString();
|
|
43
|
+
}
|
|
44
|
+
function me(e) {
|
|
45
|
+
if (e <= 0) return 1;
|
|
46
|
+
const r = 10 ** Math.floor(Math.log10(e)), t = e / r;
|
|
47
|
+
return (t <= 1 ? 1 : t <= 2 ? 2 : t <= 2.5 ? 2.5 : t <= 5 ? 5 : 10) * r;
|
|
48
|
+
}
|
|
49
|
+
function xe(e, n, r = he) {
|
|
50
|
+
n === e && (n = e + 1);
|
|
51
|
+
const t = me((n - e) / Math.max(1, r - 1)), o = Math.floor(e / t) * t, a = Math.ceil(n / t) * t, i = [];
|
|
52
|
+
for (let c = a; c >= o - t / 2; c -= t) i.push(Number(c.toFixed(10)));
|
|
53
|
+
return { min: o, max: a, ticks: i };
|
|
54
|
+
}
|
|
55
|
+
function J(e, n) {
|
|
56
|
+
return n && n.length ? n : [{ data: e ?? [] }];
|
|
57
|
+
}
|
|
58
|
+
const k = (e) => typeof e == "number";
|
|
59
|
+
function Q(e, n = !0) {
|
|
60
|
+
const r = e.flatMap((f) => f.data.map((u) => u.y).filter(k)), t = n ? Math.min(0, ...r) : Math.min(...r), o = Math.max(...r, n ? 1 : -1 / 0), { min: a, max: i, ticks: c } = xe(
|
|
61
|
+
Number.isFinite(t) ? t : 0,
|
|
62
|
+
o === -1 / 0 ? 1 : o
|
|
63
|
+
);
|
|
64
|
+
return { min: a, max: i, range: i - a || 1, ticks: c };
|
|
65
|
+
}
|
|
66
|
+
function Z(e, n, r, t, o) {
|
|
67
|
+
const a = n - S * 2, i = r - S * 2;
|
|
68
|
+
return { sx: (u) => e <= 1 ? S + a / 2 : S + u / (e - 1) * a, sy: (u) => S + i - (u - t) / o * i };
|
|
69
|
+
}
|
|
70
|
+
function G(e) {
|
|
71
|
+
if (e.length === 0) return "";
|
|
72
|
+
if (e.length < 3) return e.map((r, t) => `${t ? "L" : "M"}${r[0]},${r[1]}`).join(" ");
|
|
73
|
+
let n = `M${e[0][0]},${e[0][1]}`;
|
|
74
|
+
for (let r = 0; r < e.length - 1; r++) {
|
|
75
|
+
const t = e[r - 1] ?? e[r], o = e[r], a = e[r + 1], i = e[r + 2] ?? a, c = o[0] + (a[0] - t[0]) / 6, f = o[1] + (a[1] - t[1]) / 6, u = a[0] - (i[0] - o[0]) / 6, l = a[1] - (i[1] - o[1]) / 6;
|
|
76
|
+
n += ` C${c.toFixed(1)},${f.toFixed(1)} ${u.toFixed(1)},${l.toFixed(1)} ${a[0].toFixed(1)},${a[1].toFixed(1)}`;
|
|
35
77
|
}
|
|
36
78
|
return n;
|
|
37
79
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
80
|
+
function pe(e, n, r) {
|
|
81
|
+
const t = [];
|
|
82
|
+
let o = [];
|
|
83
|
+
return e.forEach((a, i) => {
|
|
84
|
+
k(a.y) ? o.push([n(i), r(a.y)]) : o.length && (t.push(o), o = []);
|
|
85
|
+
}), o.length && t.push(o), t;
|
|
86
|
+
}
|
|
87
|
+
const Y = (e, n, r) => e.name ?? z(r.series, { n: n + 1 });
|
|
88
|
+
function ye(e, n, r) {
|
|
89
|
+
return e.map((t, o) => {
|
|
90
|
+
const a = t.data.map((f) => f.y).filter(k), i = Y(t, o, n);
|
|
91
|
+
if (!a.length) return `${i}: ${n.noData}`;
|
|
92
|
+
const c = [...t.data].reverse().find((f) => k(f.y));
|
|
93
|
+
return r.summary({
|
|
94
|
+
name: i,
|
|
95
|
+
count: a.length,
|
|
96
|
+
min: Math.min(...a),
|
|
97
|
+
max: Math.max(...a),
|
|
98
|
+
lastX: c == null ? void 0 : c.x,
|
|
99
|
+
lastY: (c == null ? void 0 : c.y) ?? void 0
|
|
100
|
+
});
|
|
44
101
|
}).join(". ");
|
|
45
102
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
return /* @__PURE__ */
|
|
49
|
-
const
|
|
50
|
-
return /* @__PURE__ */
|
|
103
|
+
function ee({ width: e, height: n, lines: r }) {
|
|
104
|
+
const t = n - S * 2, o = Math.max(1, r);
|
|
105
|
+
return /* @__PURE__ */ s("g", { "aria-hidden": !0, children: Array.from({ length: o + 1 }, (a, i) => {
|
|
106
|
+
const c = S + i / o * t;
|
|
107
|
+
return /* @__PURE__ */ s(
|
|
51
108
|
"line",
|
|
52
109
|
{
|
|
53
110
|
x1: 0,
|
|
54
|
-
x2:
|
|
55
|
-
y1:
|
|
56
|
-
y2:
|
|
111
|
+
x2: e,
|
|
112
|
+
y1: c,
|
|
113
|
+
y2: c,
|
|
57
114
|
stroke: "var(--color-border)",
|
|
58
115
|
strokeWidth: 1,
|
|
59
|
-
vectorEffect: "non-scaling-stroke",
|
|
60
116
|
opacity: 0.6
|
|
61
117
|
},
|
|
62
|
-
|
|
118
|
+
i
|
|
63
119
|
);
|
|
64
120
|
}) });
|
|
65
121
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
{ length: _ },
|
|
69
|
-
(r, a) => n - (n - t) * a / (_ - 1)
|
|
70
|
-
);
|
|
71
|
-
return /* @__PURE__ */ i(
|
|
122
|
+
function ge({ ticks: e }) {
|
|
123
|
+
return /* @__PURE__ */ s(
|
|
72
124
|
"div",
|
|
73
125
|
{
|
|
74
126
|
"aria-hidden": !0,
|
|
75
|
-
className: "tabular text-foreground-subtle pointer-events-none flex shrink-0 flex-col justify-between py-
|
|
76
|
-
children: e.map((
|
|
127
|
+
className: "tabular text-foreground-subtle pointer-events-none flex shrink-0 flex-col justify-between py-1.5 pr-1.5 text-right text-xs",
|
|
128
|
+
children: e.map((n, r) => /* @__PURE__ */ s("span", { className: "leading-none", children: fe(n) }, r))
|
|
77
129
|
}
|
|
78
130
|
);
|
|
79
131
|
}
|
|
80
|
-
function
|
|
81
|
-
return
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
n && n !==
|
|
132
|
+
function be({ first: e, last: n }) {
|
|
133
|
+
return e ? /* @__PURE__ */ $("div", { "aria-hidden": !0, className: "text-foreground-subtle flex justify-between text-xs", children: [
|
|
134
|
+
/* @__PURE__ */ s("span", { children: String(e.x) }),
|
|
135
|
+
n && n !== e && /* @__PURE__ */ s("span", { children: String(n.x) })
|
|
84
136
|
] }) : null;
|
|
85
137
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
138
|
+
function ve({
|
|
139
|
+
id: e,
|
|
140
|
+
all: n,
|
|
141
|
+
name: r,
|
|
142
|
+
visible: t,
|
|
143
|
+
t: o
|
|
144
|
+
}) {
|
|
145
|
+
var f;
|
|
146
|
+
const a = Math.max(...n.map((u) => u.data.length)), i = ((f = n.find((u) => u.data.length === a)) == null ? void 0 : f.data) ?? [], c = /* @__PURE__ */ $(
|
|
147
|
+
"table",
|
|
148
|
+
{
|
|
149
|
+
id: e,
|
|
150
|
+
"data-chart-table": !0,
|
|
151
|
+
className: w(t && "tabular text-foreground-muted mt-2 w-full text-left text-xs"),
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ s("caption", { className: w(t && "text-foreground-subtle pb-1 text-left"), children: z(o.tableCaption, { name: r ?? "" }).trim() }),
|
|
154
|
+
/* @__PURE__ */ s("thead", { children: /* @__PURE__ */ $("tr", { children: [
|
|
155
|
+
/* @__PURE__ */ s("th", { scope: "col", className: w(t && "border-border border-b py-1 pr-3 font-medium"), children: "x" }),
|
|
156
|
+
n.map((u, l) => /* @__PURE__ */ s(
|
|
157
|
+
"th",
|
|
158
|
+
{
|
|
159
|
+
scope: "col",
|
|
160
|
+
className: w(t && "border-border border-b py-1 pr-3 font-medium"),
|
|
161
|
+
children: Y(u, l, o)
|
|
162
|
+
},
|
|
163
|
+
l
|
|
164
|
+
))
|
|
165
|
+
] }) }),
|
|
166
|
+
/* @__PURE__ */ s("tbody", { children: i.map((u, l) => /* @__PURE__ */ $("tr", { children: [
|
|
167
|
+
/* @__PURE__ */ s("th", { scope: "row", className: w(t && "py-0.5 pr-3 font-normal"), children: String(u.x) }),
|
|
168
|
+
n.map((d, m) => {
|
|
169
|
+
var h, y;
|
|
170
|
+
return /* @__PURE__ */ s("td", { className: w(t && "py-0.5 pr-3"), children: k((h = d.data[l]) == null ? void 0 : h.y) ? String((y = d.data[l]) == null ? void 0 : y.y) : "—" }, m);
|
|
171
|
+
})
|
|
172
|
+
] }, l)) })
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
return t ? c : /* @__PURE__ */ s("div", { className: "sr-only", children: c });
|
|
177
|
+
}
|
|
178
|
+
function te({
|
|
179
|
+
caption: e,
|
|
88
180
|
ariaLabel: n,
|
|
89
|
-
title:
|
|
90
|
-
|
|
91
|
-
height:
|
|
92
|
-
width:
|
|
93
|
-
className:
|
|
94
|
-
showAxis:
|
|
95
|
-
|
|
96
|
-
xFirst:
|
|
97
|
-
xLast:
|
|
98
|
-
|
|
181
|
+
title: r,
|
|
182
|
+
all: t,
|
|
183
|
+
height: o,
|
|
184
|
+
width: a,
|
|
185
|
+
className: i,
|
|
186
|
+
showAxis: c,
|
|
187
|
+
ticks: f,
|
|
188
|
+
xFirst: u,
|
|
189
|
+
xLast: l,
|
|
190
|
+
tableFallback: d,
|
|
191
|
+
showTableToggle: m,
|
|
192
|
+
state: h,
|
|
193
|
+
labels: y,
|
|
194
|
+
children: E
|
|
99
195
|
}) {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
196
|
+
const g = X().chart, x = oe().replace(/:/g, ""), I = `chart-cap-${x}`, F = `chart-title-${x}`, C = `chart-desc-${x}`, O = `chart-table-${x}`, v = n ?? r, [p, M] = K(!1), { ref: P, width: A } = ue(), N = $e(t, g, y);
|
|
197
|
+
process.env.NODE_ENV !== "production" && !v && !e && console.warn(
|
|
198
|
+
"[craftzbay/ui] Chart: provide `caption`, `aria-label`, or `title` so the chart has an accessible name."
|
|
199
|
+
);
|
|
200
|
+
const L = (d || p) && !h, R = h === "loading" ? /* @__PURE__ */ $("div", { role: "status", "aria-label": g.loading, style: { height: o }, className: "w-full", children: [
|
|
201
|
+
/* @__PURE__ */ s(le, { style: { height: o }, className: "w-full" }),
|
|
202
|
+
/* @__PURE__ */ s("span", { className: "sr-only", children: g.loading })
|
|
203
|
+
] }) : h ? /* @__PURE__ */ s(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
role: h === "error" ? "alert" : "status",
|
|
207
|
+
style: { height: o },
|
|
208
|
+
className: "text-foreground-subtle flex w-full items-center justify-center text-sm",
|
|
209
|
+
children: h === "error" ? g.error : g.empty
|
|
210
|
+
}
|
|
211
|
+
) : null;
|
|
212
|
+
return /* @__PURE__ */ $("figure", { className: w("flex flex-col gap-1.5", i), style: { width: a }, children: [
|
|
213
|
+
e && /* @__PURE__ */ s("figcaption", { id: I, className: "text-foreground-muted text-xs", children: e }),
|
|
214
|
+
R ?? /* @__PURE__ */ $(U, { children: [
|
|
215
|
+
/* @__PURE__ */ $("div", { className: "flex", children: [
|
|
216
|
+
c && /* @__PURE__ */ s(ge, { ticks: f }),
|
|
217
|
+
/* @__PURE__ */ s("div", { ref: P, className: "min-w-0 flex-1", children: /* @__PURE__ */ $(
|
|
218
|
+
"svg",
|
|
219
|
+
{
|
|
220
|
+
viewBox: `0 0 ${A} ${o}`,
|
|
221
|
+
width: A,
|
|
222
|
+
height: o,
|
|
223
|
+
role: "group",
|
|
224
|
+
"aria-labelledby": e ? I : v ? F : void 0,
|
|
225
|
+
"aria-describedby": C,
|
|
226
|
+
className: "block max-w-full overflow-visible",
|
|
227
|
+
children: [
|
|
228
|
+
v && /* @__PURE__ */ s("title", { id: F, children: v }),
|
|
229
|
+
/* @__PURE__ */ s("desc", { id: C, children: ye(t, g, y) }),
|
|
230
|
+
E({ width: A, ...N })
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
) })
|
|
234
|
+
] }),
|
|
235
|
+
c && /* @__PURE__ */ s(be, { first: u, last: l }),
|
|
236
|
+
/* @__PURE__ */ s("span", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true", children: N.announcement })
|
|
123
237
|
] }),
|
|
124
|
-
|
|
238
|
+
m && !h && /* @__PURE__ */ s(
|
|
239
|
+
"button",
|
|
240
|
+
{
|
|
241
|
+
type: "button",
|
|
242
|
+
onClick: () => M((W) => !W),
|
|
243
|
+
"aria-expanded": p,
|
|
244
|
+
"aria-controls": L ? O : void 0,
|
|
245
|
+
className: w(
|
|
246
|
+
"text-foreground-subtle hover:text-foreground self-start rounded-sm text-xs underline-offset-2 outline-none hover:underline",
|
|
247
|
+
"focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2"
|
|
248
|
+
),
|
|
249
|
+
children: p ? g.hideTable : g.viewAsTable
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
L && /* @__PURE__ */ s(
|
|
253
|
+
ve,
|
|
254
|
+
{
|
|
255
|
+
id: O,
|
|
256
|
+
all: t,
|
|
257
|
+
name: v ?? (typeof e == "string" ? e : void 0),
|
|
258
|
+
visible: p,
|
|
259
|
+
t: g
|
|
260
|
+
}
|
|
261
|
+
)
|
|
125
262
|
] });
|
|
126
263
|
}
|
|
127
|
-
function
|
|
128
|
-
|
|
264
|
+
function $e(e, n, r) {
|
|
265
|
+
const [t, o] = K(null), [a, i] = K(""), c = se(
|
|
266
|
+
(l, d) => {
|
|
267
|
+
const m = e[l], h = m == null ? void 0 : m.data[d];
|
|
268
|
+
!h || !k(h.y) || (o({ series: l, index: d }), i(r.point(m.name, h.x, h.y)));
|
|
269
|
+
},
|
|
270
|
+
[e, r]
|
|
271
|
+
), f = (l) => e[l].data.map((d, m) => k(d.y) ? m : -1).filter((d) => d >= 0);
|
|
272
|
+
return { active: t, announcement: a, seriesProps: (l) => ({
|
|
273
|
+
tabIndex: 0,
|
|
274
|
+
role: "group",
|
|
275
|
+
"aria-label": r.series(Y(e[l], l, n), f(l).length),
|
|
276
|
+
// Focus ring comes from theme.css `[data-chart-series]:focus-visible`
|
|
277
|
+
// (CSS outline — Tailwind's box-shadow ring does not paint on SVG <g>).
|
|
278
|
+
"data-chart-series": !0,
|
|
279
|
+
className: w(
|
|
280
|
+
"[&:focus-visible_[data-active]]:stroke-[var(--ring)] [&:focus-visible_[data-active]]:stroke-[3px]"
|
|
281
|
+
),
|
|
282
|
+
onFocus: () => {
|
|
283
|
+
const d = f(l);
|
|
284
|
+
d.length && c(l, (t == null ? void 0 : t.series) === l ? t.index : d[d.length - 1]);
|
|
285
|
+
},
|
|
286
|
+
onBlur: () => {
|
|
287
|
+
o(null), i("");
|
|
288
|
+
},
|
|
289
|
+
onKeyDown: (d) => {
|
|
290
|
+
const m = f(l);
|
|
291
|
+
if (!m.length) return;
|
|
292
|
+
const h = (t == null ? void 0 : t.series) === l ? m.indexOf(t.index) : m.length - 1;
|
|
293
|
+
let y = h;
|
|
294
|
+
if (d.key === "ArrowRight" || d.key === "ArrowUp") y = Math.min(m.length - 1, h + 1);
|
|
295
|
+
else if (d.key === "ArrowLeft" || d.key === "ArrowDown") y = Math.max(0, h - 1);
|
|
296
|
+
else if (d.key === "Home") y = 0;
|
|
297
|
+
else if (d.key === "End") y = m.length - 1;
|
|
298
|
+
else return;
|
|
299
|
+
d.preventDefault(), c(l, m[y]);
|
|
300
|
+
}
|
|
301
|
+
}) };
|
|
302
|
+
}
|
|
303
|
+
function Me({
|
|
304
|
+
x: e,
|
|
305
|
+
y: n,
|
|
306
|
+
color: r,
|
|
307
|
+
label: t,
|
|
308
|
+
always: o,
|
|
309
|
+
active: a
|
|
310
|
+
}) {
|
|
311
|
+
return /* @__PURE__ */ s(
|
|
312
|
+
"circle",
|
|
313
|
+
{
|
|
314
|
+
cx: e,
|
|
315
|
+
cy: n,
|
|
316
|
+
r: 3.5,
|
|
317
|
+
fill: r,
|
|
318
|
+
"data-active": a || void 0,
|
|
319
|
+
className: w(!o && !a && "opacity-0 hover:opacity-100"),
|
|
320
|
+
children: /* @__PURE__ */ s("title", { children: t })
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
function Ne({
|
|
325
|
+
data: e,
|
|
129
326
|
series: n,
|
|
130
|
-
colors:
|
|
131
|
-
height:
|
|
132
|
-
width:
|
|
133
|
-
caption:
|
|
134
|
-
"aria-label":
|
|
135
|
-
title:
|
|
136
|
-
grid:
|
|
137
|
-
showAxis:
|
|
327
|
+
colors: r = q,
|
|
328
|
+
height: t = 160,
|
|
329
|
+
width: o = "100%",
|
|
330
|
+
caption: a,
|
|
331
|
+
"aria-label": i,
|
|
332
|
+
title: c,
|
|
333
|
+
grid: f = !0,
|
|
334
|
+
showAxis: u = !0,
|
|
335
|
+
tableFallback: l = !0,
|
|
336
|
+
showTableToggle: d,
|
|
337
|
+
state: m,
|
|
338
|
+
labels: h,
|
|
138
339
|
className: y
|
|
139
340
|
}) {
|
|
140
|
-
const
|
|
141
|
-
return /* @__PURE__ */
|
|
142
|
-
|
|
341
|
+
const E = X().chart, g = { ...V(E), ...h }, x = J(e, n), { min: I, range: F, ticks: C } = Q(x), O = Math.max(...x.map((p) => p.data.length)), v = x[0].data;
|
|
342
|
+
return /* @__PURE__ */ s(
|
|
343
|
+
te,
|
|
143
344
|
{
|
|
144
|
-
caption:
|
|
145
|
-
ariaLabel:
|
|
146
|
-
title:
|
|
147
|
-
|
|
148
|
-
height:
|
|
149
|
-
width:
|
|
345
|
+
caption: a,
|
|
346
|
+
ariaLabel: i,
|
|
347
|
+
title: c,
|
|
348
|
+
all: x,
|
|
349
|
+
height: t,
|
|
350
|
+
width: o,
|
|
150
351
|
className: y,
|
|
151
|
-
showAxis:
|
|
152
|
-
|
|
153
|
-
xFirst:
|
|
154
|
-
xLast:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
352
|
+
showAxis: u,
|
|
353
|
+
ticks: C,
|
|
354
|
+
xFirst: v[0],
|
|
355
|
+
xLast: v[v.length - 1],
|
|
356
|
+
tableFallback: l,
|
|
357
|
+
showTableToggle: d,
|
|
358
|
+
state: m,
|
|
359
|
+
labels: g,
|
|
360
|
+
children: ({ width: p, active: M, seriesProps: P }) => /* @__PURE__ */ $(U, { children: [
|
|
361
|
+
f && /* @__PURE__ */ s(ee, { width: p, height: t, lines: C.length - 1 }),
|
|
362
|
+
x.map((A, N) => {
|
|
363
|
+
const L = r[N % r.length], { sx: R, sy: W } = Z(O, p, t, I, F), D = pe(A.data, R, W), H = D.map(G).join(" "), j = W(Math.max(I, 0)), T = D.map(
|
|
364
|
+
(b) => `${G(b)} L${b[b.length - 1][0].toFixed(1)},${j.toFixed(1)} L${b[0][0].toFixed(1)},${j.toFixed(1)} Z`
|
|
365
|
+
).join(" "), B = A.data.map((b) => k(b.y)).lastIndexOf(!0);
|
|
366
|
+
return /* @__PURE__ */ $("g", { ...P(N), children: [
|
|
367
|
+
T && /* @__PURE__ */ s("path", { d: T, fill: L, fillOpacity: 0.08 }),
|
|
368
|
+
/* @__PURE__ */ s(
|
|
162
369
|
"path",
|
|
163
370
|
{
|
|
164
|
-
d:
|
|
371
|
+
d: H,
|
|
165
372
|
fill: "none",
|
|
166
|
-
stroke:
|
|
373
|
+
stroke: L,
|
|
167
374
|
strokeWidth: 2,
|
|
168
375
|
strokeLinecap: "round",
|
|
169
|
-
strokeLinejoin: "round"
|
|
170
|
-
vectorEffect: "non-scaling-stroke"
|
|
376
|
+
strokeLinejoin: "round"
|
|
171
377
|
}
|
|
172
378
|
),
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
379
|
+
A.data.map(
|
|
380
|
+
(b, _) => k(b.y) ? /* @__PURE__ */ s(
|
|
381
|
+
Me,
|
|
382
|
+
{
|
|
383
|
+
x: R(_),
|
|
384
|
+
y: W(b.y),
|
|
385
|
+
color: L,
|
|
386
|
+
always: _ === B,
|
|
387
|
+
active: (M == null ? void 0 : M.series) === N && M.index === _,
|
|
388
|
+
label: g.point(A.name, b.x, b.y)
|
|
389
|
+
},
|
|
390
|
+
_
|
|
391
|
+
) : null
|
|
183
392
|
)
|
|
184
|
-
] },
|
|
393
|
+
] }, N);
|
|
185
394
|
})
|
|
186
|
-
]
|
|
395
|
+
] })
|
|
187
396
|
}
|
|
188
397
|
);
|
|
189
398
|
}
|
|
190
|
-
function
|
|
191
|
-
return /* @__PURE__ */
|
|
399
|
+
function Ce(e) {
|
|
400
|
+
return /* @__PURE__ */ s(Ne, { ...e });
|
|
192
401
|
}
|
|
193
|
-
function
|
|
194
|
-
data:
|
|
402
|
+
function We({
|
|
403
|
+
data: e,
|
|
195
404
|
series: n,
|
|
196
|
-
colors:
|
|
197
|
-
height:
|
|
198
|
-
width:
|
|
199
|
-
caption:
|
|
200
|
-
"aria-label":
|
|
201
|
-
title:
|
|
202
|
-
grid:
|
|
203
|
-
showAxis:
|
|
405
|
+
colors: r = q,
|
|
406
|
+
height: t = 160,
|
|
407
|
+
width: o = "100%",
|
|
408
|
+
caption: a,
|
|
409
|
+
"aria-label": i,
|
|
410
|
+
title: c,
|
|
411
|
+
grid: f = !0,
|
|
412
|
+
showAxis: u = !0,
|
|
413
|
+
tableFallback: l = !0,
|
|
414
|
+
showTableToggle: d,
|
|
415
|
+
state: m,
|
|
416
|
+
labels: h,
|
|
204
417
|
className: y
|
|
205
418
|
}) {
|
|
206
|
-
const
|
|
207
|
-
return /* @__PURE__ */
|
|
208
|
-
|
|
419
|
+
const E = X().chart, g = { ...V(E), ...h }, x = J(e, n), I = Math.max(...x.map((p) => p.data.length)), { min: F, range: C, ticks: O } = Q(x), v = x[0].data;
|
|
420
|
+
return /* @__PURE__ */ s(
|
|
421
|
+
te,
|
|
209
422
|
{
|
|
210
|
-
caption:
|
|
211
|
-
ariaLabel:
|
|
212
|
-
title:
|
|
213
|
-
|
|
214
|
-
height:
|
|
215
|
-
width:
|
|
423
|
+
caption: a,
|
|
424
|
+
ariaLabel: i,
|
|
425
|
+
title: c,
|
|
426
|
+
all: x,
|
|
427
|
+
height: t,
|
|
428
|
+
width: o,
|
|
216
429
|
className: y,
|
|
217
|
-
showAxis:
|
|
218
|
-
|
|
430
|
+
showAxis: u,
|
|
431
|
+
ticks: O,
|
|
219
432
|
xFirst: v[0],
|
|
220
433
|
xLast: v[v.length - 1],
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
434
|
+
tableFallback: l,
|
|
435
|
+
showTableToggle: d,
|
|
436
|
+
state: m,
|
|
437
|
+
labels: g,
|
|
438
|
+
children: ({ width: p, active: M, seriesProps: P }) => {
|
|
439
|
+
const N = (p - S * 2) / Math.max(1, I), L = N * 0.62, R = Math.max(2, L / x.length), { sy: W } = Z(I, p, t, F, C), D = W(Math.min(Math.max(0, F), F + C));
|
|
440
|
+
return /* @__PURE__ */ $(U, { children: [
|
|
441
|
+
f && /* @__PURE__ */ s(ee, { width: p, height: t, lines: O.length - 1 }),
|
|
442
|
+
F < 0 && /* @__PURE__ */ s(
|
|
443
|
+
"line",
|
|
444
|
+
{
|
|
445
|
+
"aria-hidden": !0,
|
|
446
|
+
x1: 0,
|
|
447
|
+
x2: p,
|
|
448
|
+
y1: D,
|
|
449
|
+
y2: D,
|
|
450
|
+
stroke: "var(--color-border-strong)",
|
|
451
|
+
strokeWidth: 1
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
x.map((H, j) => /* @__PURE__ */ s("g", { ...P(j), children: H.data.map((T, B) => {
|
|
455
|
+
if (!k(T.y)) return null;
|
|
456
|
+
const b = W(T.y), _ = S + B * N + (N - L) / 2 + j * R, ne = g.point(H.name, T.x, T.y), re = (M == null ? void 0 : M.series) === j && M.index === B;
|
|
457
|
+
return /* @__PURE__ */ s(
|
|
227
458
|
"rect",
|
|
228
459
|
{
|
|
229
|
-
x:
|
|
230
|
-
y:
|
|
231
|
-
width:
|
|
232
|
-
height: Math.
|
|
233
|
-
fill:
|
|
460
|
+
x: _,
|
|
461
|
+
y: Math.min(D, b),
|
|
462
|
+
width: R,
|
|
463
|
+
height: Math.abs(D - b),
|
|
464
|
+
fill: r[j % r.length],
|
|
234
465
|
rx: 2,
|
|
466
|
+
"data-active": re || void 0,
|
|
235
467
|
className: "transition-opacity hover:opacity-80",
|
|
236
|
-
children: /* @__PURE__ */
|
|
468
|
+
children: /* @__PURE__ */ s("title", { children: ne })
|
|
237
469
|
},
|
|
238
|
-
|
|
470
|
+
B
|
|
239
471
|
);
|
|
240
|
-
})
|
|
241
|
-
)
|
|
242
|
-
|
|
472
|
+
}) }, j))
|
|
473
|
+
] });
|
|
474
|
+
}
|
|
243
475
|
}
|
|
244
476
|
);
|
|
245
477
|
}
|
|
246
478
|
export {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
479
|
+
Ce as AreaChart,
|
|
480
|
+
We as BarChart,
|
|
481
|
+
q as DEFAULT_CHART_COLORS,
|
|
482
|
+
Ne as LineChart,
|
|
483
|
+
fe as abbreviateNumber,
|
|
484
|
+
Ie as defaultChartLabels,
|
|
485
|
+
xe as niceTicks
|
|
252
486
|
};
|
|
253
487
|
//# sourceMappingURL=Chart.js.map
|