@runlume/admin-ui 0.1.0 → 0.2.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.en.md +6 -13
- package/README.md +5 -11
- package/dist-package/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist-package/admin-ui.cjs +1 -0
- package/dist-package/admin-ui.d.ts +41 -1
- package/dist-package/admin-ui.d.ts.map +1 -1
- package/dist-package/admin-ui.js +79 -0
- package/dist-package/components/calendar.cjs +1 -0
- package/dist-package/components/calendar.d.ts +13 -0
- package/dist-package/components/calendar.d.ts.map +1 -0
- package/dist-package/components/calendar.js +91 -0
- package/dist-package/components/cascader.cjs +1 -0
- package/dist-package/components/cascader.d.ts +19 -0
- package/dist-package/components/cascader.d.ts.map +1 -0
- package/dist-package/components/cascader.js +85 -0
- package/dist-package/components/charts.cjs +1 -0
- package/dist-package/components/charts.d.ts +80 -0
- package/dist-package/components/charts.d.ts.map +1 -0
- package/dist-package/components/charts.js +374 -0
- package/dist-package/components/code-block.cjs +1 -0
- package/dist-package/components/code-block.d.ts +7 -0
- package/dist-package/components/code-block.d.ts.map +1 -0
- package/dist-package/components/code-block.js +47 -0
- package/dist-package/components/column-chart.cjs +1 -0
- package/dist-package/components/column-chart.d.ts +18 -0
- package/dist-package/components/column-chart.d.ts.map +1 -0
- package/dist-package/components/column-chart.js +89 -0
- package/dist-package/components/combobox.cjs +1 -0
- package/dist-package/components/combobox.d.ts +24 -0
- package/dist-package/components/combobox.d.ts.map +1 -0
- package/dist-package/components/combobox.js +111 -0
- package/dist-package/components/confirm-dialog.cjs +1 -0
- package/dist-package/components/confirm-dialog.d.ts +17 -0
- package/dist-package/components/confirm-dialog.d.ts.map +1 -0
- package/dist-package/components/confirm-dialog.js +44 -0
- package/dist-package/components/count-to.cjs +1 -0
- package/dist-package/components/count-to.d.ts +13 -0
- package/dist-package/components/count-to.d.ts.map +1 -0
- package/dist-package/components/count-to.js +36 -0
- package/dist-package/components/cursor-pagination.cjs +1 -0
- package/dist-package/components/cursor-pagination.d.ts +11 -0
- package/dist-package/components/cursor-pagination.d.ts.map +1 -0
- package/dist-package/components/cursor-pagination.js +39 -0
- package/dist-package/components/data-table.cjs +1 -0
- package/dist-package/components/data-table.d.ts +69 -0
- package/dist-package/components/data-table.d.ts.map +1 -0
- package/dist-package/components/data-table.js +377 -0
- package/dist-package/components/descriptions.cjs +1 -0
- package/dist-package/components/descriptions.d.ts +16 -0
- package/dist-package/components/descriptions.d.ts.map +1 -0
- package/dist-package/components/descriptions.js +28 -0
- package/dist-package/components/editable-table.cjs +1 -0
- package/dist-package/components/editable-table.d.ts +27 -0
- package/dist-package/components/editable-table.d.ts.map +1 -0
- package/dist-package/components/editable-table.js +212 -0
- package/dist-package/components/filter-presets.cjs +1 -0
- package/dist-package/components/filter-presets.d.ts +11 -0
- package/dist-package/components/filter-presets.d.ts.map +1 -0
- package/dist-package/components/filter-presets.js +17 -0
- package/dist-package/components/fixed-bar.cjs +1 -0
- package/dist-package/components/fixed-bar.d.ts +11 -0
- package/dist-package/components/fixed-bar.d.ts.map +1 -0
- package/dist-package/components/fixed-bar.js +18 -0
- package/dist-package/components/image-preview.cjs +1 -0
- package/dist-package/components/image-preview.d.ts +14 -0
- package/dist-package/components/image-preview.d.ts.map +1 -0
- package/dist-package/components/image-preview.js +166 -0
- package/dist-package/components/layout-container.cjs +1 -0
- package/dist-package/components/layout-container.d.ts +17 -0
- package/dist-package/components/layout-container.d.ts.map +1 -0
- package/dist-package/components/layout-container.js +85 -0
- package/dist-package/components/mention.cjs +1 -0
- package/dist-package/components/mention.d.ts +20 -0
- package/dist-package/components/mention.d.ts.map +1 -0
- package/dist-package/components/mention.js +126 -0
- package/dist-package/components/multi-select.cjs +1 -0
- package/dist-package/components/multi-select.d.ts +17 -0
- package/dist-package/components/multi-select.d.ts.map +1 -0
- package/dist-package/components/multi-select.js +126 -0
- package/dist-package/components/multi-step-loader.cjs +1 -0
- package/dist-package/components/multi-step-loader.d.ts +18 -0
- package/dist-package/components/multi-step-loader.d.ts.map +1 -0
- package/dist-package/components/multi-step-loader.js +38 -0
- package/dist-package/components/page-button.cjs +1 -0
- package/dist-package/components/page-button.d.ts +6 -0
- package/dist-package/components/page-button.d.ts.map +1 -0
- package/dist-package/components/page-button.js +24 -0
- package/dist-package/components/page-pager.cjs +1 -0
- package/dist-package/components/page-pager.d.ts +11 -0
- package/dist-package/components/page-pager.d.ts.map +1 -0
- package/dist-package/components/page-pager.js +51 -0
- package/dist-package/components/page.cjs +1 -0
- package/dist-package/components/page.d.ts +34 -0
- package/dist-package/components/page.d.ts.map +1 -0
- package/dist-package/components/page.js +208 -0
- package/dist-package/components/pagination-bar.cjs +1 -0
- package/dist-package/components/pagination-bar.d.ts +8 -0
- package/dist-package/components/pagination-bar.d.ts.map +1 -0
- package/dist-package/components/pagination-bar.js +23 -0
- package/dist-package/components/password-strength.cjs +1 -0
- package/dist-package/components/password-strength.d.ts +11 -0
- package/dist-package/components/password-strength.d.ts.map +1 -0
- package/dist-package/components/password-strength.js +70 -0
- package/dist-package/components/rate.cjs +1 -0
- package/dist-package/components/rate.d.ts +13 -0
- package/dist-package/components/rate.d.ts.map +1 -0
- package/dist-package/components/rate.js +56 -0
- package/dist-package/components/resizable-panel.cjs +1 -0
- package/dist-package/components/resizable-panel.d.ts +15 -0
- package/dist-package/components/resizable-panel.d.ts.map +1 -0
- package/dist-package/components/resizable-panel.js +56 -0
- package/dist-package/components/search-filters.cjs +1 -0
- package/dist-package/components/search-filters.d.ts +31 -0
- package/dist-package/components/search-filters.d.ts.map +1 -0
- package/dist-package/components/search-filters.js +110 -0
- package/dist-package/components/sortable-list.cjs +1 -0
- package/dist-package/components/sortable-list.d.ts +14 -0
- package/dist-package/components/sortable-list.d.ts.map +1 -0
- package/dist-package/components/sortable-list.js +48 -0
- package/dist-package/components/sparkline.cjs +1 -0
- package/dist-package/components/sparkline.d.ts +11 -0
- package/dist-package/components/sparkline.d.ts.map +1 -0
- package/dist-package/components/sparkline.js +50 -0
- package/dist-package/components/status-badge.cjs +1 -0
- package/dist-package/components/status-badge.d.ts +4 -0
- package/dist-package/components/status-badge.d.ts.map +1 -0
- package/dist-package/components/status-badge.js +28 -0
- package/dist-package/components/steps.cjs +1 -0
- package/dist-package/components/steps.d.ts +15 -0
- package/dist-package/components/steps.d.ts.map +1 -0
- package/dist-package/components/steps.js +41 -0
- package/dist-package/components/storage-box.cjs +1 -0
- package/dist-package/components/storage-box.d.ts +19 -0
- package/dist-package/components/storage-box.d.ts.map +1 -0
- package/dist-package/components/storage-box.js +153 -0
- package/dist-package/components/table-cell-overflow.cjs +1 -0
- package/dist-package/components/table-cell-overflow.d.ts +5 -0
- package/dist-package/components/table-cell-overflow.d.ts.map +1 -0
- package/dist-package/components/table-cell-overflow.js +31 -0
- package/dist-package/components/table-toolbar.cjs +1 -0
- package/dist-package/components/table-toolbar.d.ts +5 -0
- package/dist-package/components/table-toolbar.d.ts.map +1 -0
- package/dist-package/components/table-toolbar.js +11 -0
- package/dist-package/components/timeline.cjs +1 -0
- package/dist-package/components/timeline.d.ts +14 -0
- package/dist-package/components/timeline.d.ts.map +1 -0
- package/dist-package/components/timeline.js +40 -0
- package/dist-package/components/transfer.cjs +1 -0
- package/dist-package/components/transfer.d.ts +18 -0
- package/dist-package/components/transfer.d.ts.map +1 -0
- package/dist-package/components/transfer.js +98 -0
- package/dist-package/components/tree-table.cjs +1 -0
- package/dist-package/components/tree-table.d.ts +23 -0
- package/dist-package/components/tree-table.d.ts.map +1 -0
- package/dist-package/components/tree-table.js +53 -0
- package/dist-package/components/tree.cjs +1 -0
- package/dist-package/components/tree.d.ts +36 -0
- package/dist-package/components/tree.d.ts.map +1 -0
- package/dist-package/components/tree.js +204 -0
- package/dist-package/components/trend.cjs +1 -0
- package/dist-package/components/trend.d.ts +19 -0
- package/dist-package/components/trend.d.ts.map +1 -0
- package/dist-package/components/trend.js +18 -0
- package/dist-package/components/ui/alert-dialog.cjs +1 -0
- package/dist-package/components/ui/alert-dialog.js +57 -0
- package/dist-package/components/ui/alert.cjs +1 -0
- package/dist-package/components/ui/alert.js +63 -0
- package/dist-package/components/ui/avatar.cjs +1 -0
- package/dist-package/components/ui/avatar.js +27 -0
- package/dist-package/components/ui/badge.cjs +1 -0
- package/dist-package/components/ui/badge.js +40 -0
- package/dist-package/components/ui/breadcrumb.cjs +1 -0
- package/dist-package/components/ui/breadcrumb.js +70 -0
- package/dist-package/components/ui/button.cjs +1 -0
- package/dist-package/components/ui/button.js +58 -0
- package/dist-package/components/ui/card.cjs +1 -0
- package/dist-package/components/ui/card.js +55 -0
- package/dist-package/components/ui/checkbox.cjs +1 -0
- package/dist-package/components/ui/checkbox.js +19 -0
- package/dist-package/components/ui/collapsible.cjs +1 -0
- package/dist-package/components/ui/collapsible.js +32 -0
- package/dist-package/components/ui/context-menu.cjs +1 -0
- package/dist-package/components/ui/context-menu.js +46 -0
- package/dist-package/components/ui/date-input.cjs +1 -0
- package/dist-package/components/ui/date-input.js +183 -0
- package/dist-package/components/ui/date-range-input.cjs +1 -0
- package/dist-package/components/ui/date-range-input.js +209 -0
- package/dist-package/components/ui/date-time-input.cjs +1 -0
- package/dist-package/components/ui/date-time-input.js +23 -0
- package/dist-package/components/ui/dialog.cjs +1 -0
- package/dist-package/components/ui/dialog.js +189 -0
- package/dist-package/components/ui/dropdown-menu.cjs +1 -0
- package/dist-package/components/ui/dropdown-menu.js +124 -0
- package/dist-package/components/ui/file-upload.cjs +1 -0
- package/dist-package/components/ui/file-upload.js +160 -0
- package/dist-package/components/ui/hover-card.cjs +1 -0
- package/dist-package/components/ui/hover-card.js +28 -0
- package/dist-package/components/ui/input-otp.cjs +1 -0
- package/dist-package/components/ui/input-otp.js +33 -0
- package/dist-package/components/ui/input.cjs +1 -0
- package/dist-package/components/ui/input.js +65 -0
- package/dist-package/components/ui/kbd.cjs +1 -0
- package/dist-package/components/ui/kbd.js +20 -0
- package/dist-package/components/ui/label.cjs +1 -0
- package/dist-package/components/ui/label.js +14 -0
- package/dist-package/components/ui/native-select.cjs +1 -0
- package/dist-package/components/ui/native-select.js +125 -0
- package/dist-package/components/ui/number-field.cjs +1 -0
- package/dist-package/components/ui/number-field.js +50 -0
- package/dist-package/components/ui/progress.cjs +1 -0
- package/dist-package/components/ui/progress.js +28 -0
- package/dist-package/components/ui/radio-group.cjs +1 -0
- package/dist-package/components/ui/radio-group.js +27 -0
- package/dist-package/components/ui/scroll-area.cjs +1 -0
- package/dist-package/components/ui/scroll-area.js +25 -0
- package/dist-package/components/ui/select.cjs +1 -0
- package/dist-package/components/ui/select.js +23 -0
- package/dist-package/components/ui/separator.cjs +1 -0
- package/dist-package/components/ui/separator.js +17 -0
- package/dist-package/components/ui/sheet.cjs +1 -0
- package/dist-package/components/ui/sheet.js +86 -0
- package/dist-package/components/ui/sidebar.cjs +1 -0
- package/dist-package/components/ui/sidebar.js +350 -0
- package/dist-package/components/ui/skeleton.cjs +1 -0
- package/dist-package/components/ui/skeleton.js +12 -0
- package/dist-package/components/ui/slider.cjs +1 -0
- package/dist-package/components/ui/slider.js +36 -0
- package/dist-package/components/ui/switch.cjs +1 -0
- package/dist-package/components/ui/switch.js +14 -0
- package/dist-package/components/ui/table.cjs +1 -0
- package/dist-package/components/ui/table.js +66 -0
- package/dist-package/components/ui/tabs.cjs +1 -0
- package/dist-package/components/ui/tabs.js +47 -0
- package/dist-package/components/ui/tag-variants.cjs +1 -0
- package/dist-package/components/ui/tag-variants.js +15 -0
- package/dist-package/components/ui/tag.cjs +1 -0
- package/dist-package/components/ui/tag.js +31 -0
- package/dist-package/components/ui/textarea.cjs +1 -0
- package/dist-package/components/ui/textarea.js +13 -0
- package/dist-package/components/ui/time-input.cjs +1 -0
- package/dist-package/components/ui/time-input.js +89 -0
- package/dist-package/components/ui/tooltip.cjs +1 -0
- package/dist-package/components/ui/tooltip.js +35 -0
- package/dist-package/hooks/use-mobile.cjs +1 -0
- package/dist-package/hooks/use-mobile.js +11 -0
- package/dist-package/lib/dialog-focus.cjs +1 -0
- package/dist-package/lib/dialog-focus.js +10 -0
- package/dist-package/lib/metrics.cjs +1 -0
- package/dist-package/lib/metrics.d.ts +18 -0
- package/dist-package/lib/metrics.d.ts.map +1 -0
- package/dist-package/lib/metrics.js +22 -0
- package/dist-package/lib/pager.cjs +1 -0
- package/dist-package/lib/pager.d.ts +8 -0
- package/dist-package/lib/pager.d.ts.map +1 -0
- package/dist-package/lib/pager.js +18 -0
- package/dist-package/lib/password.cjs +1 -0
- package/dist-package/lib/password.d.ts +14 -0
- package/dist-package/lib/password.d.ts.map +1 -0
- package/dist-package/lib/password.js +34 -0
- package/dist-package/lib/presets.cjs +1 -0
- package/dist-package/lib/presets.d.ts +25 -0
- package/dist-package/lib/presets.d.ts.map +1 -0
- package/dist-package/lib/presets.js +48 -0
- package/dist-package/lib/range.cjs +1 -0
- package/dist-package/lib/range.js +57 -0
- package/dist-package/lib/storage-key.cjs +1 -0
- package/dist-package/lib/storage-key.d.ts +2 -0
- package/dist-package/lib/storage-key.d.ts.map +1 -0
- package/dist-package/lib/storage-key.js +6 -0
- package/dist-package/lib/table-prefs.cjs +1 -0
- package/dist-package/lib/table-prefs.d.ts +17 -0
- package/dist-package/lib/table-prefs.d.ts.map +1 -0
- package/dist-package/lib/table-prefs.js +64 -0
- package/dist-package/lib/tree.cjs +1 -0
- package/dist-package/lib/tree.d.ts +37 -0
- package/dist-package/lib/tree.d.ts.map +1 -0
- package/dist-package/lib/tree.js +57 -0
- package/dist-package/lib/use-ui-translation.cjs +1 -0
- package/dist-package/lib/use-ui-translation.d.ts +15 -0
- package/dist-package/lib/use-ui-translation.d.ts.map +1 -0
- package/dist-package/lib/use-ui-translation.js +65 -0
- package/dist-package/lib/utils.cjs +1 -0
- package/dist-package/lib/utils.js +8 -0
- package/dist-package/styles.css +1 -1
- package/package.json +25 -15
- package/dist-package/index.js +0 -12212
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { cn as e } from "../lib/utils.js";
|
|
2
|
+
import { sparklinePath as t } from "../lib/metrics.js";
|
|
3
|
+
import { useId as n, useState as r } from "react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/charts.tsx
|
|
6
|
+
function o({ values: t, label: n, height: r = 32, className: a }) {
|
|
7
|
+
let o = Math.max(...t, 1);
|
|
8
|
+
return /* @__PURE__ */ i("svg", {
|
|
9
|
+
role: "img",
|
|
10
|
+
"aria-label": n,
|
|
11
|
+
viewBox: `0 0 ${t.length * 4} ${r}`,
|
|
12
|
+
className: e("w-full", a),
|
|
13
|
+
style: { height: r },
|
|
14
|
+
children: t.map((e, t) => {
|
|
15
|
+
let n = e / o * (r - 2);
|
|
16
|
+
return /* @__PURE__ */ i("rect", {
|
|
17
|
+
x: t * 4,
|
|
18
|
+
y: r - n,
|
|
19
|
+
width: 2.6,
|
|
20
|
+
height: n,
|
|
21
|
+
rx: 1,
|
|
22
|
+
fill: "var(--primary)",
|
|
23
|
+
opacity: .35 + e / o * .65
|
|
24
|
+
}, t);
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function s({ value: e, max: t = 100, label: n, size: r = 96, tone: o = "var(--primary)" }) {
|
|
29
|
+
let s = t > 0 ? Math.min(100, Math.max(0, e / t * 100)) : 0, c = r / 2 - 8, l = 2 * Math.PI * c;
|
|
30
|
+
return /* @__PURE__ */ a("div", {
|
|
31
|
+
className: "relative inline-flex items-center justify-center",
|
|
32
|
+
style: {
|
|
33
|
+
width: r,
|
|
34
|
+
height: r
|
|
35
|
+
},
|
|
36
|
+
children: [/* @__PURE__ */ a("svg", {
|
|
37
|
+
role: "img",
|
|
38
|
+
"aria-label": n,
|
|
39
|
+
width: r,
|
|
40
|
+
height: r,
|
|
41
|
+
className: "-rotate-90",
|
|
42
|
+
children: [/* @__PURE__ */ i("circle", {
|
|
43
|
+
cx: r / 2,
|
|
44
|
+
cy: r / 2,
|
|
45
|
+
r: c,
|
|
46
|
+
fill: "none",
|
|
47
|
+
stroke: "var(--border)",
|
|
48
|
+
strokeWidth: 8
|
|
49
|
+
}), /* @__PURE__ */ i("circle", {
|
|
50
|
+
cx: r / 2,
|
|
51
|
+
cy: r / 2,
|
|
52
|
+
r: c,
|
|
53
|
+
fill: "none",
|
|
54
|
+
stroke: o,
|
|
55
|
+
strokeWidth: 8,
|
|
56
|
+
strokeLinecap: "round",
|
|
57
|
+
strokeDasharray: l,
|
|
58
|
+
strokeDashoffset: l * (1 - s / 100),
|
|
59
|
+
className: "transition-[stroke-dashoffset] duration-500"
|
|
60
|
+
})]
|
|
61
|
+
}), /* @__PURE__ */ a("span", {
|
|
62
|
+
className: "absolute text-sm font-semibold tabular-nums",
|
|
63
|
+
children: [Math.round(s), "%"]
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function c({ series: o, labels: s, height: c = 160, className: l }) {
|
|
68
|
+
let u = n(), [d, f] = r(), p = o.flatMap((e) => e.values), m = Math.max(...p, 1), h = Math.min(...p, 0), g = (e) => c - 16 - (e - h) / (m - h || 1) * (c - 32);
|
|
69
|
+
return /* @__PURE__ */ a("div", {
|
|
70
|
+
className: e("space-y-2", l),
|
|
71
|
+
children: [/* @__PURE__ */ a("svg", {
|
|
72
|
+
role: "img",
|
|
73
|
+
"aria-label": o.map((e) => e.name).join(" / "),
|
|
74
|
+
viewBox: `0 0 480 ${c}`,
|
|
75
|
+
className: "w-full",
|
|
76
|
+
style: { height: c },
|
|
77
|
+
onMouseLeave: () => f(void 0),
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ i("defs", { children: /* @__PURE__ */ a("linearGradient", {
|
|
80
|
+
id: u,
|
|
81
|
+
x1: "0",
|
|
82
|
+
y1: "0",
|
|
83
|
+
x2: "0",
|
|
84
|
+
y2: "1",
|
|
85
|
+
children: [/* @__PURE__ */ i("stop", {
|
|
86
|
+
offset: "0%",
|
|
87
|
+
stopColor: "var(--primary)",
|
|
88
|
+
stopOpacity: "0.25"
|
|
89
|
+
}), /* @__PURE__ */ i("stop", {
|
|
90
|
+
offset: "100%",
|
|
91
|
+
stopColor: "var(--primary)",
|
|
92
|
+
stopOpacity: "0"
|
|
93
|
+
})]
|
|
94
|
+
}) }),
|
|
95
|
+
[
|
|
96
|
+
0,
|
|
97
|
+
1,
|
|
98
|
+
2,
|
|
99
|
+
3
|
|
100
|
+
].map((e) => /* @__PURE__ */ i("line", {
|
|
101
|
+
x1: 0,
|
|
102
|
+
x2: 480,
|
|
103
|
+
y1: 16 + e * (c - 32) / 3,
|
|
104
|
+
y2: 16 + e * (c - 32) / 3,
|
|
105
|
+
stroke: "var(--border)",
|
|
106
|
+
strokeDasharray: "2 6"
|
|
107
|
+
}, e)),
|
|
108
|
+
o.map((e, n) => {
|
|
109
|
+
let r = e.values.map((t, n) => ({
|
|
110
|
+
x: n / Math.max(1, e.values.length - 1) * 480,
|
|
111
|
+
y: g(t)
|
|
112
|
+
}));
|
|
113
|
+
return /* @__PURE__ */ a("g", { children: [
|
|
114
|
+
n === 0 && /* @__PURE__ */ i("path", {
|
|
115
|
+
d: `${t(r, !0)} L480 ${c} L0 ${c} Z`,
|
|
116
|
+
fill: `url(#${u})`
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ i("path", {
|
|
119
|
+
d: t(r, !0),
|
|
120
|
+
fill: "none",
|
|
121
|
+
stroke: e.tone ?? (n === 0 ? "var(--primary)" : "var(--info)"),
|
|
122
|
+
strokeWidth: 2,
|
|
123
|
+
strokeLinecap: "round"
|
|
124
|
+
}),
|
|
125
|
+
r.map((t, r) => /* @__PURE__ */ i("circle", {
|
|
126
|
+
cx: t.x,
|
|
127
|
+
cy: t.y,
|
|
128
|
+
r: d === r ? 4 : 2.5,
|
|
129
|
+
fill: e.tone ?? (n === 0 ? "var(--primary)" : "var(--info)")
|
|
130
|
+
}, r))
|
|
131
|
+
] }, e.name);
|
|
132
|
+
}),
|
|
133
|
+
s.map((e, t) => /* @__PURE__ */ a("g", { children: [/* @__PURE__ */ i("rect", {
|
|
134
|
+
x: t / Math.max(1, s.length - 1) * 480 - 16,
|
|
135
|
+
y: 0,
|
|
136
|
+
width: 32,
|
|
137
|
+
height: c,
|
|
138
|
+
fill: "transparent",
|
|
139
|
+
onMouseEnter: () => f(t)
|
|
140
|
+
}), /* @__PURE__ */ i("text", {
|
|
141
|
+
x: t / Math.max(1, s.length - 1) * 480,
|
|
142
|
+
y: c - 2,
|
|
143
|
+
textAnchor: "middle",
|
|
144
|
+
className: "fill-muted-foreground text-[10px]",
|
|
145
|
+
children: e
|
|
146
|
+
})] }, e))
|
|
147
|
+
]
|
|
148
|
+
}), /* @__PURE__ */ i("ul", {
|
|
149
|
+
className: "flex flex-wrap items-center gap-3 text-xs text-muted-foreground",
|
|
150
|
+
children: o.map((e, t) => /* @__PURE__ */ a("li", {
|
|
151
|
+
className: "flex items-center gap-1.5",
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ i("span", {
|
|
154
|
+
"aria-hidden": "true",
|
|
155
|
+
className: "size-2 rounded-full",
|
|
156
|
+
style: { background: e.tone ?? (t === 0 ? "var(--primary)" : "var(--info)") }
|
|
157
|
+
}),
|
|
158
|
+
e.name,
|
|
159
|
+
d !== void 0 && /* @__PURE__ */ i("span", {
|
|
160
|
+
className: "tabular-nums text-foreground",
|
|
161
|
+
children: e.values[d]?.toLocaleString("zh-CN")
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
}, e.name))
|
|
165
|
+
})]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function l({ items: t, label: n, className: r }) {
|
|
169
|
+
let o = Math.max(...t.map((e) => e.value), 1);
|
|
170
|
+
return /* @__PURE__ */ i("ul", {
|
|
171
|
+
"aria-label": n,
|
|
172
|
+
className: e("space-y-3", r),
|
|
173
|
+
children: t.map((e) => /* @__PURE__ */ a("li", {
|
|
174
|
+
className: "space-y-1",
|
|
175
|
+
children: [/* @__PURE__ */ a("div", {
|
|
176
|
+
className: "flex items-center justify-between text-sm",
|
|
177
|
+
children: [/* @__PURE__ */ i("span", {
|
|
178
|
+
className: "truncate",
|
|
179
|
+
children: e.name
|
|
180
|
+
}), /* @__PURE__ */ i("span", {
|
|
181
|
+
className: "tabular-nums text-muted-foreground",
|
|
182
|
+
children: e.value.toLocaleString("zh-CN")
|
|
183
|
+
})]
|
|
184
|
+
}), /* @__PURE__ */ i("div", {
|
|
185
|
+
className: "h-2 overflow-hidden rounded-full bg-muted",
|
|
186
|
+
children: /* @__PURE__ */ i("div", {
|
|
187
|
+
className: "h-full rounded-full bg-primary/70",
|
|
188
|
+
style: { width: `${e.value / o * 100}%` }
|
|
189
|
+
})
|
|
190
|
+
})]
|
|
191
|
+
}, e.name))
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function u({ rows: t, columns: n, values: r, label: o, className: s }) {
|
|
195
|
+
return /* @__PURE__ */ i("div", {
|
|
196
|
+
className: e("overflow-x-auto", s),
|
|
197
|
+
children: /* @__PURE__ */ a("table", {
|
|
198
|
+
"aria-label": o,
|
|
199
|
+
className: "w-full border-separate border-spacing-1 text-xs",
|
|
200
|
+
children: [/* @__PURE__ */ i("thead", { children: /* @__PURE__ */ a("tr", { children: [/* @__PURE__ */ i("th", {}), n.map((e) => /* @__PURE__ */ i("th", {
|
|
201
|
+
className: "font-normal text-muted-foreground",
|
|
202
|
+
children: e
|
|
203
|
+
}, e))] }) }), /* @__PURE__ */ i("tbody", { children: t.map((e, t) => /* @__PURE__ */ a("tr", { children: [/* @__PURE__ */ i("th", {
|
|
204
|
+
scope: "row",
|
|
205
|
+
className: "pr-2 text-right font-normal text-muted-foreground",
|
|
206
|
+
children: e
|
|
207
|
+
}), n.map((n, a) => {
|
|
208
|
+
let o = r[t]?.[a] ?? 0;
|
|
209
|
+
return /* @__PURE__ */ i("td", { children: /* @__PURE__ */ i("span", {
|
|
210
|
+
title: `${e} ${n} · ${Math.round(o * 100)}%`,
|
|
211
|
+
className: "block h-6 rounded",
|
|
212
|
+
style: { background: o === 0 ? "var(--muted)" : `color-mix(in oklab, var(--primary) ${Math.round(o * 100)}%, transparent)` }
|
|
213
|
+
}) }, n);
|
|
214
|
+
})] }, e)) })]
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function d({ axes: t, series: n, size: r = 220, className: o }) {
|
|
219
|
+
let s = r / 2, c = s - 34, l = (e, n) => {
|
|
220
|
+
let r = Math.PI * 2 * e / t.length - Math.PI / 2;
|
|
221
|
+
return [s + Math.cos(r) * c * n, s + Math.sin(r) * c * n];
|
|
222
|
+
};
|
|
223
|
+
return /* @__PURE__ */ a("div", {
|
|
224
|
+
className: e("flex flex-wrap items-center gap-4", o),
|
|
225
|
+
children: [/* @__PURE__ */ a("svg", {
|
|
226
|
+
role: "img",
|
|
227
|
+
"aria-label": n.map((e) => e.name).join(" / "),
|
|
228
|
+
width: r,
|
|
229
|
+
height: r,
|
|
230
|
+
children: [
|
|
231
|
+
[
|
|
232
|
+
.25,
|
|
233
|
+
.5,
|
|
234
|
+
.75,
|
|
235
|
+
1
|
|
236
|
+
].map((e) => /* @__PURE__ */ i("polygon", {
|
|
237
|
+
points: t.map((t, n) => l(n, e).join(",")).join(" "),
|
|
238
|
+
fill: "none",
|
|
239
|
+
stroke: "var(--border)"
|
|
240
|
+
}, e)),
|
|
241
|
+
t.map((e, t) => {
|
|
242
|
+
let [n, r] = l(t, 1), [o, c] = l(t, 1.16);
|
|
243
|
+
return /* @__PURE__ */ a("g", { children: [/* @__PURE__ */ i("line", {
|
|
244
|
+
x1: s,
|
|
245
|
+
y1: s,
|
|
246
|
+
x2: n,
|
|
247
|
+
y2: r,
|
|
248
|
+
stroke: "var(--border)"
|
|
249
|
+
}), /* @__PURE__ */ i("text", {
|
|
250
|
+
x: o,
|
|
251
|
+
y: c,
|
|
252
|
+
textAnchor: "middle",
|
|
253
|
+
dominantBaseline: "middle",
|
|
254
|
+
className: "fill-muted-foreground text-[10px]",
|
|
255
|
+
children: e
|
|
256
|
+
})] }, e);
|
|
257
|
+
}),
|
|
258
|
+
n.map((e, t) => {
|
|
259
|
+
let n = e.tone ?? (t === 0 ? "var(--primary)" : "var(--info)");
|
|
260
|
+
return /* @__PURE__ */ i("polygon", {
|
|
261
|
+
points: e.values.map((e, t) => l(t, e).join(",")).join(" "),
|
|
262
|
+
fill: `color-mix(in oklab, ${n} 18%, transparent)`,
|
|
263
|
+
stroke: n,
|
|
264
|
+
strokeWidth: 2
|
|
265
|
+
}, e.name);
|
|
266
|
+
})
|
|
267
|
+
]
|
|
268
|
+
}), /* @__PURE__ */ i("ul", {
|
|
269
|
+
className: "space-y-1 text-xs text-muted-foreground",
|
|
270
|
+
children: n.map((e, t) => /* @__PURE__ */ a("li", {
|
|
271
|
+
className: "flex items-center gap-2",
|
|
272
|
+
children: [/* @__PURE__ */ i("span", {
|
|
273
|
+
"aria-hidden": "true",
|
|
274
|
+
className: "size-2 rounded-full",
|
|
275
|
+
style: { background: e.tone ?? (t === 0 ? "var(--primary)" : "var(--info)") }
|
|
276
|
+
}), e.name]
|
|
277
|
+
}, e.name))
|
|
278
|
+
})]
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function f({ stages: t, className: n }) {
|
|
282
|
+
let r = Math.max(...t.map((e) => e.value), 1);
|
|
283
|
+
return /* @__PURE__ */ i("ul", {
|
|
284
|
+
"aria-label": "转化漏斗",
|
|
285
|
+
className: e("space-y-2", n),
|
|
286
|
+
children: t.map((e, n) => {
|
|
287
|
+
let o = e.value / r * 100, s = t[n - 1]?.value, c = s ? Math.round(e.value / s * 100) : 100;
|
|
288
|
+
return /* @__PURE__ */ a("li", {
|
|
289
|
+
className: "flex items-center gap-3",
|
|
290
|
+
children: [
|
|
291
|
+
/* @__PURE__ */ i("span", {
|
|
292
|
+
className: "w-20 shrink-0 truncate text-xs text-muted-foreground",
|
|
293
|
+
children: e.name
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ i("span", {
|
|
296
|
+
className: "min-w-0 flex-1",
|
|
297
|
+
children: /* @__PURE__ */ i("span", {
|
|
298
|
+
className: "flex h-7 items-center justify-end rounded bg-primary/70 pr-2 text-xs font-medium text-primary-foreground",
|
|
299
|
+
style: { width: `${Math.max(o, 6)}%` },
|
|
300
|
+
children: e.value.toLocaleString("zh-CN")
|
|
301
|
+
})
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ i("span", {
|
|
304
|
+
className: "w-12 shrink-0 text-right text-xs tabular-nums text-muted-foreground",
|
|
305
|
+
children: n === 0 ? "—" : `${c}%`
|
|
306
|
+
})
|
|
307
|
+
]
|
|
308
|
+
}, e.name);
|
|
309
|
+
})
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function p({ rows: t, days: n, today: r, className: o }) {
|
|
313
|
+
let s = n.length * 40;
|
|
314
|
+
return /* @__PURE__ */ i("div", {
|
|
315
|
+
className: e("overflow-x-auto", o),
|
|
316
|
+
children: /* @__PURE__ */ a("div", {
|
|
317
|
+
className: "min-w-max",
|
|
318
|
+
children: [/* @__PURE__ */ a("div", {
|
|
319
|
+
className: "flex text-[10px] text-muted-foreground",
|
|
320
|
+
children: [/* @__PURE__ */ i("span", { className: "w-28 shrink-0" }), /* @__PURE__ */ i("div", {
|
|
321
|
+
className: "relative",
|
|
322
|
+
style: { width: s },
|
|
323
|
+
children: n.map((e, t) => /* @__PURE__ */ i("span", {
|
|
324
|
+
className: "absolute -translate-x-1/2 text-center",
|
|
325
|
+
style: { left: t * 40 + 20 },
|
|
326
|
+
children: e
|
|
327
|
+
}, e))
|
|
328
|
+
})]
|
|
329
|
+
}), /* @__PURE__ */ i("ul", {
|
|
330
|
+
"aria-label": "任务排期",
|
|
331
|
+
className: "mt-3 space-y-2",
|
|
332
|
+
children: t.map((e) => /* @__PURE__ */ a("li", {
|
|
333
|
+
className: "flex items-center",
|
|
334
|
+
children: [/* @__PURE__ */ i("span", {
|
|
335
|
+
className: "w-28 shrink-0 truncate pr-2 text-xs",
|
|
336
|
+
children: e.name
|
|
337
|
+
}), /* @__PURE__ */ a("div", {
|
|
338
|
+
className: "relative h-6",
|
|
339
|
+
style: { width: s },
|
|
340
|
+
children: [
|
|
341
|
+
n.map((e, t) => /* @__PURE__ */ i("span", {
|
|
342
|
+
"aria-hidden": "true",
|
|
343
|
+
className: "absolute inset-y-0 border-l border-border/60",
|
|
344
|
+
style: { left: t * 40 }
|
|
345
|
+
}, e)),
|
|
346
|
+
/* @__PURE__ */ i("span", {
|
|
347
|
+
className: "absolute top-1 h-4 rounded",
|
|
348
|
+
style: {
|
|
349
|
+
left: e.start * 40 + 2,
|
|
350
|
+
width: Math.max(e.span * 40 - 4, 8),
|
|
351
|
+
background: `color-mix(in oklab, ${e.tone ?? "var(--primary)"} 35%, transparent)`
|
|
352
|
+
},
|
|
353
|
+
children: /* @__PURE__ */ i("span", {
|
|
354
|
+
className: "block h-full rounded",
|
|
355
|
+
style: {
|
|
356
|
+
width: `${e.progress ?? 100}%`,
|
|
357
|
+
background: e.tone ?? "var(--primary)"
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
}),
|
|
361
|
+
r !== void 0 && r >= 0 && r < n.length && /* @__PURE__ */ i("span", {
|
|
362
|
+
"aria-hidden": "true",
|
|
363
|
+
className: "absolute inset-y-0 w-px bg-danger",
|
|
364
|
+
style: { left: r * 40 + 20 }
|
|
365
|
+
})
|
|
366
|
+
]
|
|
367
|
+
})]
|
|
368
|
+
}, e.name))
|
|
369
|
+
})]
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
export { l as BarList, s as DonutChart, f as FunnelChart, p as GanttChart, u as Heatmap, c as LineChart, o as MiniBars, d as RadarChart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../lib/utils.cjs"),t=require("./ui/button.cjs"),n=require("../lib/use-ui-translation.cjs");let r=require("react"),i=require("lucide-react"),a=require("react/jsx-runtime"),o=require("sonner");function s({code:s,title:c,className:l}){let{t:u}=n.useUiTranslation(),[d,f]=(0,r.useState)(!1);async function p(){try{await navigator.clipboard.writeText(s),f(!0),o.toast.success(u(`copied`)),window.setTimeout(()=>f(!1),1500)}catch{o.toast.error(u(`copyFailed`))}}return(0,a.jsxs)(`div`,{"data-slot":`code-block`,className:e.cn(`relative overflow-hidden rounded-lg border bg-muted/40`,l),children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-1.5`,children:[(0,a.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,children:c??`code`}),(0,a.jsx)(t.Button,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":u(`copy`),onClick:p,children:d?(0,a.jsx)(i.Check,{"aria-hidden":`true`,className:`size-3.5`}):(0,a.jsx)(i.Copy,{"aria-hidden":`true`,className:`size-3.5`})})]}),(0,a.jsx)(`pre`,{className:`overflow-x-auto px-3 py-2.5 text-xs leading-6`,children:(0,a.jsx)(`code`,{className:`font-mono`,children:s})})]})}exports.CodeBlock=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAOA,6BAA6B;AAC7B,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BAiCA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { cn as e } from "../lib/utils.js";
|
|
2
|
+
import { Button as t } from "./ui/button.js";
|
|
3
|
+
import { useUiTranslation as n } from "../lib/use-ui-translation.js";
|
|
4
|
+
import { useState as r } from "react";
|
|
5
|
+
import { Check as i, Copy as a } from "lucide-react";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { toast as c } from "sonner";
|
|
8
|
+
//#region src/components/code-block.tsx
|
|
9
|
+
function l({ code: l, title: u, className: d }) {
|
|
10
|
+
let { t: f } = n(), [p, m] = r(!1);
|
|
11
|
+
async function h() {
|
|
12
|
+
try {
|
|
13
|
+
await navigator.clipboard.writeText(l), m(!0), c.success(f("copied")), window.setTimeout(() => m(!1), 1500);
|
|
14
|
+
} catch {
|
|
15
|
+
c.error(f("copyFailed"));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ s("div", {
|
|
19
|
+
"data-slot": "code-block",
|
|
20
|
+
className: e("relative overflow-hidden rounded-lg border bg-muted/40", d),
|
|
21
|
+
children: [/* @__PURE__ */ s("div", {
|
|
22
|
+
className: "flex items-center justify-between gap-3 border-b px-3 py-1.5",
|
|
23
|
+
children: [/* @__PURE__ */ o("span", {
|
|
24
|
+
className: "truncate font-mono text-xs text-muted-foreground",
|
|
25
|
+
children: u ?? "code"
|
|
26
|
+
}), /* @__PURE__ */ o(t, {
|
|
27
|
+
type: "button",
|
|
28
|
+
variant: "ghost",
|
|
29
|
+
size: "icon-sm",
|
|
30
|
+
"aria-label": f("copy"),
|
|
31
|
+
onClick: h,
|
|
32
|
+
children: o(p ? i : a, {
|
|
33
|
+
"aria-hidden": "true",
|
|
34
|
+
className: "size-3.5"
|
|
35
|
+
})
|
|
36
|
+
})]
|
|
37
|
+
}), /* @__PURE__ */ o("pre", {
|
|
38
|
+
className: "overflow-x-auto px-3 py-2.5 text-xs leading-6",
|
|
39
|
+
children: /* @__PURE__ */ o("code", {
|
|
40
|
+
className: "font-mono",
|
|
41
|
+
children: l
|
|
42
|
+
})
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { l as CodeBlock };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../lib/utils.cjs");let t=require("react"),n=require("react/jsx-runtime");function r({data:r,label:i,height:a=220,tone:o=`var(--primary)`,valueSuffix:s=``,showAverage:c=!0,className:l}){let[u,d]=(0,t.useState)(),f={top:16,right:12,bottom:26,left:40},p=640-f.left-f.right,m=a-f.top-f.bottom,h=Math.max(...r.map(e=>e.value),1),g=p/Math.max(1,r.length),_=Math.max(6,Math.min(28,g*.55)),v=[0,h/4,h/2,h*3/4,h],y=r.reduce((e,t)=>e+t.value,0)/Math.max(1,r.length),b=e=>f.top+m-e/h*m;return(0,n.jsxs)(`svg`,{role:`img`,"aria-label":i,viewBox:`0 0 640 ${a}`,className:e.cn(`w-full`,l),style:{height:a},onMouseLeave:()=>d(void 0),children:[v.map(e=>(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`line`,{x1:f.left,x2:640-f.right,y1:b(e),y2:b(e),stroke:`var(--border)`,strokeDasharray:e===0?void 0:`2 6`}),(0,n.jsx)(`text`,{x:f.left-6,y:b(e),textAnchor:`end`,dominantBaseline:`middle`,className:`fill-muted-foreground text-[10px]`,children:Math.round(e)})]},e)),c&&(0,n.jsx)(`line`,{x1:f.left,x2:640-f.right,y1:b(y),y2:b(y),stroke:`var(--warning)`,strokeDasharray:`4 4`}),r.map((e,t)=>{let r=f.left+t*g+(g-_)/2,i=b(e.value),c=Math.max(2,f.top+m-i);return(0,n.jsxs)(`g`,{children:[(0,n.jsx)(`rect`,{x:f.left+t*g,y:f.top,width:g,height:m,fill:`transparent`,onMouseEnter:()=>d(t)}),(0,n.jsx)(`rect`,{x:r,y:i,width:_,height:c,rx:3,fill:o,opacity:u===void 0||u===t?1:.45}),u===t&&(0,n.jsxs)(`text`,{x:r+_/2,y:i-6,textAnchor:`middle`,className:`fill-foreground text-[10px] font-medium`,children:[e.value,s]}),(0,n.jsx)(`text`,{x:f.left+t*g+g/2,y:a-8,textAnchor:`middle`,className:`fill-muted-foreground text-[10px]`,children:e.label})]},e.label)})]})}exports.ColumnChart=r;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 普通柱状图(纵向):带纵轴刻度、网格线、横轴标签与悬停读数。
|
|
3
|
+
* 适合"按天/按月"的数值对比,比迷你柱状更适合单独成块的图表区。
|
|
4
|
+
*/
|
|
5
|
+
export declare function ColumnChart({ data, label, height, tone, valueSuffix, showAverage, className, }: {
|
|
6
|
+
data: {
|
|
7
|
+
label: string;
|
|
8
|
+
value: number;
|
|
9
|
+
}[];
|
|
10
|
+
label: string;
|
|
11
|
+
height?: number;
|
|
12
|
+
tone?: string;
|
|
13
|
+
valueSuffix?: string;
|
|
14
|
+
/** 是否画一条平均值参考线。 */
|
|
15
|
+
showAverage?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=column-chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-chart.d.ts","sourceRoot":"","sources":["../../src/components/column-chart.tsx"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,MAAY,EACZ,IAAuB,EACvB,WAAgB,EAChB,WAAkB,EAClB,SAAS,GACV,EAAE;IACD,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,mBAAmB;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BAoGA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { cn as e } from "../lib/utils.js";
|
|
2
|
+
import { useState as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/column-chart.tsx
|
|
5
|
+
function i({ data: i, label: a, height: o = 220, tone: s = "var(--primary)", valueSuffix: c = "", showAverage: l = !0, className: u }) {
|
|
6
|
+
let [d, f] = t(), p = {
|
|
7
|
+
top: 16,
|
|
8
|
+
right: 12,
|
|
9
|
+
bottom: 26,
|
|
10
|
+
left: 40
|
|
11
|
+
}, m = 640 - p.left - p.right, h = o - p.top - p.bottom, g = Math.max(...i.map((e) => e.value), 1), _ = m / Math.max(1, i.length), v = Math.max(6, Math.min(28, _ * .55)), y = [
|
|
12
|
+
0,
|
|
13
|
+
g / 4,
|
|
14
|
+
g / 2,
|
|
15
|
+
g * 3 / 4,
|
|
16
|
+
g
|
|
17
|
+
], b = i.reduce((e, t) => e + t.value, 0) / Math.max(1, i.length), x = (e) => p.top + h - e / g * h;
|
|
18
|
+
return /* @__PURE__ */ r("svg", {
|
|
19
|
+
role: "img",
|
|
20
|
+
"aria-label": a,
|
|
21
|
+
viewBox: `0 0 640 ${o}`,
|
|
22
|
+
className: e("w-full", u),
|
|
23
|
+
style: { height: o },
|
|
24
|
+
onMouseLeave: () => f(void 0),
|
|
25
|
+
children: [
|
|
26
|
+
y.map((e) => /* @__PURE__ */ r("g", { children: [/* @__PURE__ */ n("line", {
|
|
27
|
+
x1: p.left,
|
|
28
|
+
x2: 640 - p.right,
|
|
29
|
+
y1: x(e),
|
|
30
|
+
y2: x(e),
|
|
31
|
+
stroke: "var(--border)",
|
|
32
|
+
strokeDasharray: e === 0 ? void 0 : "2 6"
|
|
33
|
+
}), /* @__PURE__ */ n("text", {
|
|
34
|
+
x: p.left - 6,
|
|
35
|
+
y: x(e),
|
|
36
|
+
textAnchor: "end",
|
|
37
|
+
dominantBaseline: "middle",
|
|
38
|
+
className: "fill-muted-foreground text-[10px]",
|
|
39
|
+
children: Math.round(e)
|
|
40
|
+
})] }, e)),
|
|
41
|
+
l && /* @__PURE__ */ n("line", {
|
|
42
|
+
x1: p.left,
|
|
43
|
+
x2: 640 - p.right,
|
|
44
|
+
y1: x(b),
|
|
45
|
+
y2: x(b),
|
|
46
|
+
stroke: "var(--warning)",
|
|
47
|
+
strokeDasharray: "4 4"
|
|
48
|
+
}),
|
|
49
|
+
i.map((e, t) => {
|
|
50
|
+
let i = p.left + t * _ + (_ - v) / 2, a = x(e.value), l = Math.max(2, p.top + h - a);
|
|
51
|
+
return /* @__PURE__ */ r("g", { children: [
|
|
52
|
+
/* @__PURE__ */ n("rect", {
|
|
53
|
+
x: p.left + t * _,
|
|
54
|
+
y: p.top,
|
|
55
|
+
width: _,
|
|
56
|
+
height: h,
|
|
57
|
+
fill: "transparent",
|
|
58
|
+
onMouseEnter: () => f(t)
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ n("rect", {
|
|
61
|
+
x: i,
|
|
62
|
+
y: a,
|
|
63
|
+
width: v,
|
|
64
|
+
height: l,
|
|
65
|
+
rx: 3,
|
|
66
|
+
fill: s,
|
|
67
|
+
opacity: d === void 0 || d === t ? 1 : .45
|
|
68
|
+
}),
|
|
69
|
+
d === t && /* @__PURE__ */ r("text", {
|
|
70
|
+
x: i + v / 2,
|
|
71
|
+
y: a - 6,
|
|
72
|
+
textAnchor: "middle",
|
|
73
|
+
className: "fill-foreground text-[10px] font-medium",
|
|
74
|
+
children: [e.value, c]
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ n("text", {
|
|
77
|
+
x: p.left + t * _ + _ / 2,
|
|
78
|
+
y: o - 8,
|
|
79
|
+
textAnchor: "middle",
|
|
80
|
+
className: "fill-muted-foreground text-[10px]",
|
|
81
|
+
children: e.label
|
|
82
|
+
})
|
|
83
|
+
] }, e.label);
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { i as ColumnChart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../lib/utils.cjs"),t=require("./ui/button.cjs"),n=require("../lib/use-ui-translation.cjs"),r=require("./ui/input.cjs");let i=require("react"),a=require("radix-ui"),o=require("lucide-react"),s=require("react/jsx-runtime");function c({options:c,value:l,onValueChange:u,label:d,placeholder:f,emptyText:p,clearable:m=!1,disabled:h=!1,className:g}){let{t:_}=n.useUiTranslation(),[v,y]=(0,i.useState)(!1),[b,x]=(0,i.useState)(``),S=(0,i.useMemo)(()=>{let e=b.trim().toLowerCase();return c.map(e=>`group`in e?{group:e.group,options:e.options}:{group:``,options:[e]}).map(t=>({...t,options:t.options.filter(t=>e===``||t.label.toLowerCase().includes(e)||t.value.toLowerCase().includes(e))})).filter(e=>e.options.length>0)},[c,b]),C=(0,i.useMemo)(()=>S.flatMap(e=>e.options),[S]),w=(0,i.useMemo)(()=>c.flatMap(e=>`group`in e?e.options:[e]).find(e=>e.value===l),[c,l]);return(0,s.jsxs)(a.Popover.Root,{open:v,onOpenChange:e=>{y(e),e||x(``)},children:[(0,s.jsxs)(`div`,{className:e.cn(`relative flex items-center`,g),children:[(0,s.jsx)(a.Popover.Trigger,{asChild:!0,children:(0,s.jsxs)(t.Button,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":v,"aria-label":d,disabled:h,className:`w-full justify-between bg-card font-normal`,children:[(0,s.jsx)(`span`,{className:e.cn(`truncate`,!w&&`text-muted-foreground`),children:w?.label??f??_(`search`)}),(0,s.jsx)(o.ChevronDown,{"aria-hidden":`true`,className:`size-4 shrink-0 opacity-60`})]})}),m&&w&&(0,s.jsx)(`button`,{type:`button`,"aria-label":_(`clear`),className:`absolute right-8 rounded p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>u(void 0),children:(0,s.jsx)(o.X,{"aria-hidden":`true`,className:`size-3.5`})})]}),(0,s.jsx)(a.Popover.Portal,{children:(0,s.jsxs)(a.Popover.Content,{align:`start`,sideOffset:4,className:`z-50 w-[var(--radix-popover-trigger-width)] min-w-56 overflow-hidden rounded-lg border bg-popover p-1 shadow-lg outline-none`,children:[(0,s.jsx)(`div`,{className:`p-1`,children:(0,s.jsx)(r.Input,{autoFocus:!0,"aria-label":d,value:b,placeholder:f??_(`search`),className:`h-8`,onChange:e=>x(e.target.value)})}),(0,s.jsxs)(`div`,{role:`listbox`,"aria-label":d,className:`max-h-64 overflow-y-auto p-1`,children:[S.map(t=>(0,s.jsxs)(`div`,{children:[t.group&&(0,s.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:t.group}),t.options.map(t=>(0,s.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t.value===l,disabled:t.disabled,onClick:()=>{u(t.value),y(!1)},className:e.cn(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,`hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50`),children:[(0,s.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,s.jsx)(`span`,{className:`block truncate`,children:t.label}),t.description&&(0,s.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:t.description})]}),t.value===l&&(0,s.jsx)(o.Check,{"aria-hidden":`true`,className:`size-4 shrink-0`})]},t.value))]},t.group||`default`)),!C.length&&(0,s.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:p??_(`empty`)})]})]})})]})}exports.Combobox=c;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ComboboxOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type ComboboxGroup = {
|
|
8
|
+
group: string;
|
|
9
|
+
options: ComboboxOption[];
|
|
10
|
+
};
|
|
11
|
+
/** 可搜索单选下拉:输入即过滤,支持分组与清空。 */
|
|
12
|
+
export declare function Combobox({ options, value, onValueChange, label, placeholder, emptyText, clearable, disabled, className, }: {
|
|
13
|
+
options: (ComboboxOption | ComboboxGroup)[];
|
|
14
|
+
value?: string;
|
|
15
|
+
onValueChange: (value: string | undefined) => void;
|
|
16
|
+
/** 组合框的访问名称。 */
|
|
17
|
+
label: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
emptyText?: string;
|
|
20
|
+
clearable?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,CAAA;AAExE,6BAA6B;AAC7B,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,KAAK,EACL,aAAa,EACb,KAAK,EACL,WAAW,EACX,SAAS,EACT,SAAiB,EACjB,QAAgB,EAChB,SAAS,GACV,EAAE;IACD,OAAO,EAAE,CAAC,cAAc,GAAG,aAAa,CAAC,EAAE,CAAA;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAA;IAClD,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BAkIA"}
|