@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,126 @@
|
|
|
1
|
+
import { cn as e } from "../lib/utils.js";
|
|
2
|
+
import { useUiTranslation as t } from "../lib/use-ui-translation.js";
|
|
3
|
+
import { useEffect as n, useRef as r, useState as i } from "react";
|
|
4
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
|
+
import { match as s } from "pinyin-pro";
|
|
6
|
+
//#region src/components/mention.tsx
|
|
7
|
+
var c = 4, l = 112;
|
|
8
|
+
function u({ value: u, onValueChange: d, options: f, trigger: p = "@", label: m, placeholder: h, className: g }) {
|
|
9
|
+
let { t: _ } = t(), v = r(null), [y, b] = i(), [x, S] = i(0), [C, w] = i("bottom"), T = f.filter((e) => y !== void 0 && (e.label.toLowerCase().includes(y.toLowerCase()) || (s(e.label, y, { continuous: !0 })?.length ?? 0) > 0)), E = y !== void 0 && T.length > 0;
|
|
10
|
+
function D() {
|
|
11
|
+
let e = window.getSelection();
|
|
12
|
+
if (!e?.rangeCount) return;
|
|
13
|
+
let t = e.anchorNode;
|
|
14
|
+
if (!t || t.nodeType !== Node.TEXT_NODE) return;
|
|
15
|
+
let n = (t.textContent ?? "").slice(0, e.anchorOffset), r = n.lastIndexOf(p);
|
|
16
|
+
if (!(r < 0 || n.slice(r + p.length).includes(" "))) return n.slice(r + p.length);
|
|
17
|
+
}
|
|
18
|
+
function O() {
|
|
19
|
+
d(v.current?.textContent ?? ""), b(D()), S(0);
|
|
20
|
+
}
|
|
21
|
+
function k() {
|
|
22
|
+
let e = v.current?.getBoundingClientRect();
|
|
23
|
+
if (!e) return;
|
|
24
|
+
let t = window.innerHeight - e.bottom - c, n = e.top - c;
|
|
25
|
+
w(t < l && n > t ? "top" : "bottom");
|
|
26
|
+
}
|
|
27
|
+
function A(e) {
|
|
28
|
+
let t = window.getSelection(), n = t?.anchorNode;
|
|
29
|
+
if (!t || !n || n.nodeType !== Node.TEXT_NODE) return;
|
|
30
|
+
let r = n.textContent ?? "", i = t.anchorOffset, a = r.slice(0, i).lastIndexOf(p);
|
|
31
|
+
if (a < 0) return;
|
|
32
|
+
let o = document.createRange();
|
|
33
|
+
o.setStart(n, a), o.setEnd(n, i), o.deleteContents();
|
|
34
|
+
let s = document.createElement("span");
|
|
35
|
+
s.dataset.mention = e.value, s.contentEditable = "false", s.className = "mention-tag", s.textContent = `${p}${e.label}`;
|
|
36
|
+
let c = document.createTextNode("\xA0");
|
|
37
|
+
o.insertNode(c), o.insertNode(s);
|
|
38
|
+
let l = document.createRange();
|
|
39
|
+
l.setStart(c, c.length), l.collapse(!0), t.removeAllRanges(), t.addRange(l), b(void 0), window.requestAnimationFrame(() => {
|
|
40
|
+
O(), v.current?.focus();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function j(e) {
|
|
44
|
+
if (e.key === "Backspace" && !E) {
|
|
45
|
+
let t = window.getSelection();
|
|
46
|
+
if (t?.isCollapsed && t.anchorNode) {
|
|
47
|
+
let n = t.anchorNode.previousSibling;
|
|
48
|
+
if (n instanceof HTMLElement && n.dataset.mention) {
|
|
49
|
+
e.preventDefault(), n.remove(), O();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (t.anchorOffset === 0 && t.anchorNode.parentElement?.dataset.mention) {
|
|
53
|
+
e.preventDefault(), t.anchorNode.parentElement.remove(), O();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (E) {
|
|
59
|
+
if (e.key === "ArrowDown") e.preventDefault(), S((x + 1) % T.length);
|
|
60
|
+
else if (e.key === "ArrowUp") e.preventDefault(), S((x - 1 + T.length) % T.length);
|
|
61
|
+
else if (e.key === "Enter") {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
let t = T[x];
|
|
64
|
+
t && A(t);
|
|
65
|
+
} else e.key === "Escape" && b(void 0);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return n(() => {
|
|
69
|
+
if (E) return k(), window.addEventListener("resize", k), window.addEventListener("scroll", k, !0), () => {
|
|
70
|
+
window.removeEventListener("resize", k), window.removeEventListener("scroll", k, !0);
|
|
71
|
+
};
|
|
72
|
+
}, [E]), /* @__PURE__ */ o("div", {
|
|
73
|
+
"data-slot": "mention",
|
|
74
|
+
className: e("relative", g),
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ a("div", {
|
|
77
|
+
ref: v,
|
|
78
|
+
role: "textbox",
|
|
79
|
+
"aria-multiline": "true",
|
|
80
|
+
"aria-label": m,
|
|
81
|
+
contentEditable: !0,
|
|
82
|
+
suppressContentEditableWarning: !0,
|
|
83
|
+
"data-placeholder": h ?? _("mention.placeholder", { trigger: p }),
|
|
84
|
+
className: "mention-editor min-h-20 w-full rounded-lg border border-input bg-card px-3.5 py-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/20",
|
|
85
|
+
onInput: O,
|
|
86
|
+
onKeyDown: j,
|
|
87
|
+
onBlur: () => b(void 0),
|
|
88
|
+
onPaste: (e) => {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
let t = e.clipboardData.getData("text/plain");
|
|
91
|
+
document.execCommand("insertText", !1, t);
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
E && /* @__PURE__ */ a("ul", {
|
|
95
|
+
role: "listbox",
|
|
96
|
+
"aria-label": _("mention.title"),
|
|
97
|
+
className: e("absolute z-30 max-h-48 w-64 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md", C === "top" ? "bottom-full mb-1" : "top-full mt-1"),
|
|
98
|
+
children: T.map((t, n) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a("button", {
|
|
99
|
+
type: "button",
|
|
100
|
+
role: "option",
|
|
101
|
+
"aria-selected": n === x,
|
|
102
|
+
className: e("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm", n === x && "bg-accent text-accent-foreground"),
|
|
103
|
+
onMouseEnter: () => S(n),
|
|
104
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
105
|
+
onClick: () => A(t),
|
|
106
|
+
children: /* @__PURE__ */ o("span", {
|
|
107
|
+
className: "min-w-0 flex-1 truncate",
|
|
108
|
+
children: [/* @__PURE__ */ a("span", {
|
|
109
|
+
className: "block",
|
|
110
|
+
children: t.label
|
|
111
|
+
}), t.description && /* @__PURE__ */ a("span", {
|
|
112
|
+
className: "block truncate text-xs text-muted-foreground",
|
|
113
|
+
children: t.description
|
|
114
|
+
})]
|
|
115
|
+
})
|
|
116
|
+
}) }, t.value))
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ a("span", {
|
|
119
|
+
className: "sr-only",
|
|
120
|
+
children: u
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { u as Mention };
|
|
@@ -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/badge.cjs"),i=require("./ui/checkbox.cjs"),a=require("./ui/input.cjs");let o=require("react"),s=require("radix-ui"),c=require("lucide-react"),l=require("react/jsx-runtime");function u({options:u,values:d,onValuesChange:f,label:p,placeholder:m,className:h}){let{t:g}=n.useUiTranslation(),[_,v]=(0,o.useState)(!1),[y,b]=(0,o.useState)(``),x=(0,o.useMemo)(()=>{let e=y.trim().toLowerCase();return e?u.filter(t=>t.label.toLowerCase().includes(e)):u},[u,y]),S=u.filter(e=>d.includes(e.value));function C(e,t){f(t?[...d,e]:d.filter(t=>t!==e))}return(0,l.jsxs)(s.Popover.Root,{open:_,onOpenChange:e=>{v(e),e||b(``)},children:[(0,l.jsx)(s.Popover.Trigger,{asChild:!0,children:(0,l.jsxs)(t.Button,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":_,"aria-label":p,className:e.cn(`h-auto min-h-10 w-full justify-between bg-card py-1.5 font-normal`,h),children:[(0,l.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-wrap gap-1`,children:[S.length===0&&(0,l.jsx)(`span`,{className:`truncate text-muted-foreground`,children:m??g(`search`)}),S.map(e=>(0,l.jsx)(r.Badge,{variant:`secondary`,children:e.label},e.value))]}),(0,l.jsx)(c.ChevronDown,{"aria-hidden":`true`,className:`size-4 shrink-0 opacity-60`})]})}),(0,l.jsx)(s.Popover.Portal,{children:(0,l.jsxs)(s.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,l.jsx)(`div`,{className:`p-1`,children:(0,l.jsx)(a.Input,{autoFocus:!0,"aria-label":p,value:y,placeholder:g(`search`),className:`h-8`,onChange:e=>b(e.target.value)})}),(0,l.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 text-xs text-muted-foreground`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(i.Checkbox,{"aria-label":g(`tree.selectAll`),checked:x.length>0&&x.every(e=>d.includes(e.value)),indeterminate:x.some(e=>d.includes(e.value))&&!x.every(e=>d.includes(e.value)),onCheckedChange:e=>{let t=x.map(e=>e.value);f(e?[...new Set([...d,...t])]:d.filter(e=>!t.includes(e)))}}),g(`notifications.all`)]}),(0,l.jsx)(t.Button,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>f([]),children:g(`clear`)})]}),(0,l.jsxs)(`div`,{role:`listbox`,"aria-label":p,"aria-multiselectable":!0,className:`max-h-64 overflow-y-auto p-1`,children:[x.map(e=>(0,l.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground`,children:[(0,l.jsx)(i.Checkbox,{checked:d.includes(e.value),"aria-label":e.label,onCheckedChange:t=>C(e.value,t===!0)}),(0,l.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,l.jsx)(`span`,{className:`block truncate`,children:e.label}),e.description&&(0,l.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.description})]})]},e.value)),!x.length&&(0,l.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:g(`empty`)})]}),(0,l.jsxs)(`div`,{className:`flex items-center justify-between border-t px-2 py-1.5 text-xs text-muted-foreground`,children:[(0,l.jsx)(`span`,{children:g(`tree.selected`,{count:d.length})}),(0,l.jsxs)(t.Button,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>v(!1),children:[(0,l.jsx)(c.Check,{"aria-hidden":`true`}),g(`confirm`)]})]})]})})]})}exports.MultiSelect=u;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type MultiSelectOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* 多选下拉:支持搜索、全选与可清除,选中项以标签回显。
|
|
8
|
+
*/
|
|
9
|
+
export declare function MultiSelect({ options, values, onValuesChange, label, placeholder, className, }: {
|
|
10
|
+
options: MultiSelectOption[];
|
|
11
|
+
values: string[];
|
|
12
|
+
onValuesChange: (values: string[]) => void;
|
|
13
|
+
label: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=multi-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../src/components/multi-select.tsx"],"names":[],"mappings":"AAUA,MAAM,MAAM,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtF;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,MAAM,EACN,cAAc,EACd,KAAK,EACL,WAAW,EACX,SAAS,GACV,EAAE;IACD,OAAO,EAAE,iBAAiB,EAAE,CAAA;IAC5B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BAmIA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
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 { Badge as r } from "./ui/badge.js";
|
|
5
|
+
import { Checkbox as i } from "./ui/checkbox.js";
|
|
6
|
+
import { Input as a } from "./ui/input.js";
|
|
7
|
+
import { useMemo as o, useState as s } from "react";
|
|
8
|
+
import { Popover as c } from "radix-ui";
|
|
9
|
+
import { Check as l, ChevronDown as u } from "lucide-react";
|
|
10
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
|
+
//#region src/components/multi-select.tsx
|
|
12
|
+
function p({ options: p, values: m, onValuesChange: h, label: g, placeholder: _, className: v }) {
|
|
13
|
+
let { t: y } = n(), [b, x] = s(!1), [S, C] = s(""), w = o(() => {
|
|
14
|
+
let e = S.trim().toLowerCase();
|
|
15
|
+
return e ? p.filter((t) => t.label.toLowerCase().includes(e)) : p;
|
|
16
|
+
}, [p, S]), T = p.filter((e) => m.includes(e.value));
|
|
17
|
+
function E(e, t) {
|
|
18
|
+
h(t ? [...m, e] : m.filter((t) => t !== e));
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ f(c.Root, {
|
|
21
|
+
open: b,
|
|
22
|
+
onOpenChange: (e) => {
|
|
23
|
+
x(e), e || C("");
|
|
24
|
+
},
|
|
25
|
+
children: [/* @__PURE__ */ d(c.Trigger, {
|
|
26
|
+
asChild: !0,
|
|
27
|
+
children: /* @__PURE__ */ f(t, {
|
|
28
|
+
type: "button",
|
|
29
|
+
variant: "outline",
|
|
30
|
+
role: "combobox",
|
|
31
|
+
"aria-expanded": b,
|
|
32
|
+
"aria-label": g,
|
|
33
|
+
className: e("h-auto min-h-10 w-full justify-between bg-card py-1.5 font-normal", v),
|
|
34
|
+
children: [/* @__PURE__ */ f("span", {
|
|
35
|
+
className: "flex min-w-0 flex-1 flex-wrap gap-1",
|
|
36
|
+
children: [T.length === 0 && /* @__PURE__ */ d("span", {
|
|
37
|
+
className: "truncate text-muted-foreground",
|
|
38
|
+
children: _ ?? y("search")
|
|
39
|
+
}), T.map((e) => /* @__PURE__ */ d(r, {
|
|
40
|
+
variant: "secondary",
|
|
41
|
+
children: e.label
|
|
42
|
+
}, e.value))]
|
|
43
|
+
}), /* @__PURE__ */ d(u, {
|
|
44
|
+
"aria-hidden": "true",
|
|
45
|
+
className: "size-4 shrink-0 opacity-60"
|
|
46
|
+
})]
|
|
47
|
+
})
|
|
48
|
+
}), /* @__PURE__ */ d(c.Portal, { children: /* @__PURE__ */ f(c.Content, {
|
|
49
|
+
align: "start",
|
|
50
|
+
sideOffset: 4,
|
|
51
|
+
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",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ d("div", {
|
|
54
|
+
className: "p-1",
|
|
55
|
+
children: /* @__PURE__ */ d(a, {
|
|
56
|
+
autoFocus: !0,
|
|
57
|
+
"aria-label": g,
|
|
58
|
+
value: S,
|
|
59
|
+
placeholder: y("search"),
|
|
60
|
+
className: "h-8",
|
|
61
|
+
onChange: (e) => C(e.target.value)
|
|
62
|
+
})
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ f("div", {
|
|
65
|
+
className: "flex items-center justify-between px-2 py-1 text-xs text-muted-foreground",
|
|
66
|
+
children: [/* @__PURE__ */ f("label", {
|
|
67
|
+
className: "flex items-center gap-2",
|
|
68
|
+
children: [/* @__PURE__ */ d(i, {
|
|
69
|
+
"aria-label": y("tree.selectAll"),
|
|
70
|
+
checked: w.length > 0 && w.every((e) => m.includes(e.value)),
|
|
71
|
+
indeterminate: w.some((e) => m.includes(e.value)) && !w.every((e) => m.includes(e.value)),
|
|
72
|
+
onCheckedChange: (e) => {
|
|
73
|
+
let t = w.map((e) => e.value);
|
|
74
|
+
h(e ? [.../* @__PURE__ */ new Set([...m, ...t])] : m.filter((e) => !t.includes(e)));
|
|
75
|
+
}
|
|
76
|
+
}), y("notifications.all")]
|
|
77
|
+
}), /* @__PURE__ */ d(t, {
|
|
78
|
+
type: "button",
|
|
79
|
+
variant: "ghost",
|
|
80
|
+
size: "xs",
|
|
81
|
+
onClick: () => h([]),
|
|
82
|
+
children: y("clear")
|
|
83
|
+
})]
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ f("div", {
|
|
86
|
+
role: "listbox",
|
|
87
|
+
"aria-label": g,
|
|
88
|
+
"aria-multiselectable": !0,
|
|
89
|
+
className: "max-h-64 overflow-y-auto p-1",
|
|
90
|
+
children: [w.map((e) => /* @__PURE__ */ f("label", {
|
|
91
|
+
className: "flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground",
|
|
92
|
+
children: [/* @__PURE__ */ d(i, {
|
|
93
|
+
checked: m.includes(e.value),
|
|
94
|
+
"aria-label": e.label,
|
|
95
|
+
onCheckedChange: (t) => E(e.value, t === !0)
|
|
96
|
+
}), /* @__PURE__ */ f("span", {
|
|
97
|
+
className: "min-w-0 flex-1",
|
|
98
|
+
children: [/* @__PURE__ */ d("span", {
|
|
99
|
+
className: "block truncate",
|
|
100
|
+
children: e.label
|
|
101
|
+
}), e.description && /* @__PURE__ */ d("span", {
|
|
102
|
+
className: "block truncate text-xs text-muted-foreground",
|
|
103
|
+
children: e.description
|
|
104
|
+
})]
|
|
105
|
+
})]
|
|
106
|
+
}, e.value)), !w.length && /* @__PURE__ */ d("p", {
|
|
107
|
+
className: "px-2 py-6 text-center text-sm text-muted-foreground",
|
|
108
|
+
children: y("empty")
|
|
109
|
+
})]
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ f("div", {
|
|
112
|
+
className: "flex items-center justify-between border-t px-2 py-1.5 text-xs text-muted-foreground",
|
|
113
|
+
children: [/* @__PURE__ */ d("span", { children: y("tree.selected", { count: m.length }) }), /* @__PURE__ */ f(t, {
|
|
114
|
+
type: "button",
|
|
115
|
+
variant: "ghost",
|
|
116
|
+
size: "xs",
|
|
117
|
+
onClick: () => x(!1),
|
|
118
|
+
children: [/* @__PURE__ */ d(l, { "aria-hidden": "true" }), y("confirm")]
|
|
119
|
+
})]
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
}) })]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { p as MultiSelect };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("../lib/utils.cjs");let t=require("lucide-react"),n=require("react/jsx-runtime");function r({steps:r,current:i,failed:a,className:o}){return(0,n.jsx)(`ol`,{"data-slot":`multi-step-loader`,"aria-busy":i<r.length,className:e.cn(`space-y-3 rounded-xl border bg-card p-4`,o),children:r.map((r,o)=>{let s=a===o?`failed`:o<i?`done`:o===i?`doing`:`pending`;return(0,n.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,n.jsxs)(`span`,{"aria-hidden":`true`,className:`mt-0.5 flex size-4 shrink-0 items-center justify-center`,children:[s===`done`&&(0,n.jsx)(t.CircleCheck,{className:`size-4 text-success`}),s===`doing`&&(0,n.jsx)(t.LoaderCircle,{className:`size-4 animate-spin text-primary`}),s===`failed`&&(0,n.jsx)(t.X,{className:`size-4 text-danger`}),s===`pending`&&(0,n.jsx)(`span`,{className:`size-2 rounded-full bg-border`})]}),(0,n.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,n.jsx)(`span`,{className:e.cn(`block text-sm`,s===`pending`&&`text-muted-foreground`,s===`failed`&&`text-danger`),children:r.label}),r.description&&(0,n.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted-foreground`,children:r.description})]})]},r.key)})})}exports.MultiStepLoader=r;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type LoadingStep = {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* 多步加载:初始化、导入、批处理这类有阶段的过程。
|
|
8
|
+
* 已完成阶段打勾,当前阶段转圈,失败阶段标红。
|
|
9
|
+
*/
|
|
10
|
+
export declare function MultiStepLoader({ steps, current, failed, className, }: {
|
|
11
|
+
steps: LoadingStep[];
|
|
12
|
+
/** 当前阶段下标;等于 steps.length 表示全部完成。 */
|
|
13
|
+
current: number;
|
|
14
|
+
/** 失败阶段的下标,传入后该阶段显示为失败。 */
|
|
15
|
+
failed?: number;
|
|
16
|
+
className?: string;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=multi-step-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-step-loader.d.ts","sourceRoot":"","sources":["../../src/components/multi-step-loader.tsx"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,GACV,EAAE;IACD,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BAgDA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cn as e } from "../lib/utils.js";
|
|
2
|
+
import { CircleCheck as t, LoaderCircle as n, X as r } from "lucide-react";
|
|
3
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/multi-step-loader.tsx
|
|
5
|
+
function o({ steps: o, current: s, failed: c, className: l }) {
|
|
6
|
+
return /* @__PURE__ */ i("ol", {
|
|
7
|
+
"data-slot": "multi-step-loader",
|
|
8
|
+
"aria-busy": s < o.length,
|
|
9
|
+
className: e("space-y-3 rounded-xl border bg-card p-4", l),
|
|
10
|
+
children: o.map((o, l) => {
|
|
11
|
+
let u = c === l ? "failed" : l < s ? "done" : l === s ? "doing" : "pending";
|
|
12
|
+
return /* @__PURE__ */ a("li", {
|
|
13
|
+
className: "flex items-start gap-3",
|
|
14
|
+
children: [/* @__PURE__ */ a("span", {
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
className: "mt-0.5 flex size-4 shrink-0 items-center justify-center",
|
|
17
|
+
children: [
|
|
18
|
+
u === "done" && /* @__PURE__ */ i(t, { className: "size-4 text-success" }),
|
|
19
|
+
u === "doing" && /* @__PURE__ */ i(n, { className: "size-4 animate-spin text-primary" }),
|
|
20
|
+
u === "failed" && /* @__PURE__ */ i(r, { className: "size-4 text-danger" }),
|
|
21
|
+
u === "pending" && /* @__PURE__ */ i("span", { className: "size-2 rounded-full bg-border" })
|
|
22
|
+
]
|
|
23
|
+
}), /* @__PURE__ */ a("span", {
|
|
24
|
+
className: "min-w-0 flex-1",
|
|
25
|
+
children: [/* @__PURE__ */ i("span", {
|
|
26
|
+
className: e("block text-sm", u === "pending" && "text-muted-foreground", u === "failed" && "text-danger"),
|
|
27
|
+
children: o.label
|
|
28
|
+
}), o.description && /* @__PURE__ */ i("span", {
|
|
29
|
+
className: "mt-0.5 block text-xs text-muted-foreground",
|
|
30
|
+
children: o.description
|
|
31
|
+
})]
|
|
32
|
+
})]
|
|
33
|
+
}, o.key);
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { o as MultiStepLoader };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./ui/button.cjs");let t=require("lucide-react"),n=require("react/jsx-runtime");function r({direction:r,children:i,...a}){return(0,n.jsxs)(e.Button,{...a,variant:`outline`,size:`sm`,children:[r===`previous`&&(0,n.jsx)(t.ArrowLeft,{"aria-hidden":`true`,className:`size-3.5`}),i,r===`next`&&(0,n.jsx)(t.ArrowRight,{"aria-hidden":`true`,className:`size-3.5`})]})}exports.PageButton=r;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { Button } from './ui/button';
|
|
3
|
+
export declare function PageButton({ direction, children, ...props }: Omit<ComponentProps<typeof Button>, 'size' | 'variant' | 'asChild'> & {
|
|
4
|
+
direction: 'previous' | 'next';
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=page-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-button.d.ts","sourceRoot":"","sources":["../../src/components/page-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAE/C,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC,GAAG;IACvE,SAAS,EAAE,UAAU,GAAG,MAAM,CAAA;CAC/B,+BAQA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Button as e } from "./ui/button.js";
|
|
2
|
+
import { ArrowLeft as t, ArrowRight as n } from "lucide-react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/page-button.tsx
|
|
5
|
+
function a({ direction: a, children: o, ...s }) {
|
|
6
|
+
return /* @__PURE__ */ i(e, {
|
|
7
|
+
...s,
|
|
8
|
+
variant: "outline",
|
|
9
|
+
size: "sm",
|
|
10
|
+
children: [
|
|
11
|
+
a === "previous" && /* @__PURE__ */ r(t, {
|
|
12
|
+
"aria-hidden": "true",
|
|
13
|
+
className: "size-3.5"
|
|
14
|
+
}),
|
|
15
|
+
o,
|
|
16
|
+
a === "next" && /* @__PURE__ */ r(n, {
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
className: "size-3.5"
|
|
19
|
+
})
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { a as PageButton };
|
|
@@ -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"),i=require("../lib/pager.cjs");let a=require("react"),o=require("react/jsx-runtime");function s({page:s,pageCount:c,onPageChange:l,className:u}){let{t:d}=n.useUiTranslation(),[f,p]=(0,a.useState)(``),m=Math.max(1,c);return(0,o.jsxs)(`div`,{className:e.cn(`flex items-center gap-1`,u),children:[i.pagerItems(s,m).map((e,n)=>e===null?(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`px-1 text-muted-foreground`,children:`…`},`gap-${n}`):(0,o.jsx)(t.Button,{type:`button`,variant:e===s?`default`:`outline`,size:`sm`,"aria-label":d(`sample.pageSummary`,{page:e,count:m}),"aria-current":e===s?`page`:void 0,className:`min-w-8 px-2 tabular-nums`,onClick:()=>l(e),children:e},e)),m>7&&(0,o.jsxs)(`span`,{className:`ml-1 flex items-center gap-1 text-xs text-muted-foreground`,children:[d(`jumpTo`),(0,o.jsx)(r.Input,{"aria-label":d(`jumpTo`),inputMode:`numeric`,className:`h-8 w-14 px-2 text-center`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{if(e.key!==`Enter`)return;let t=i.parsePageInput(f,m);t&&l(t),p(``)}}),d(`jumpPage`)]})]})}exports.PagePager=s;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页码分页器。
|
|
3
|
+
* 与 PageButton 的上下页按钮组合使用,放进 PaginationBar 的右侧。
|
|
4
|
+
*/
|
|
5
|
+
export declare function PagePager({ page, pageCount, onPageChange, className, }: {
|
|
6
|
+
page: number;
|
|
7
|
+
pageCount: number;
|
|
8
|
+
onPageChange: (page: number) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=page-pager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-pager.d.ts","sourceRoot":"","sources":["../../src/components/page-pager.tsx"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BA+CA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { Input as r } from "./ui/input.js";
|
|
5
|
+
import { pagerItems as i, parsePageInput as a } from "../lib/pager.js";
|
|
6
|
+
import { useState as o } from "react";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/page-pager.tsx
|
|
9
|
+
function l({ page: l, pageCount: u, onPageChange: d, className: f }) {
|
|
10
|
+
let { t: p } = n(), [m, h] = o(""), g = Math.max(1, u);
|
|
11
|
+
return /* @__PURE__ */ c("div", {
|
|
12
|
+
className: e("flex items-center gap-1", f),
|
|
13
|
+
children: [i(l, g).map((e, n) => e === null ? /* @__PURE__ */ s("span", {
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
className: "px-1 text-muted-foreground",
|
|
16
|
+
children: "…"
|
|
17
|
+
}, `gap-${n}`) : /* @__PURE__ */ s(t, {
|
|
18
|
+
type: "button",
|
|
19
|
+
variant: e === l ? "default" : "outline",
|
|
20
|
+
size: "sm",
|
|
21
|
+
"aria-label": p("sample.pageSummary", {
|
|
22
|
+
page: e,
|
|
23
|
+
count: g
|
|
24
|
+
}),
|
|
25
|
+
"aria-current": e === l ? "page" : void 0,
|
|
26
|
+
className: "min-w-8 px-2 tabular-nums",
|
|
27
|
+
onClick: () => d(e),
|
|
28
|
+
children: e
|
|
29
|
+
}, e)), g > 7 && /* @__PURE__ */ c("span", {
|
|
30
|
+
className: "ml-1 flex items-center gap-1 text-xs text-muted-foreground",
|
|
31
|
+
children: [
|
|
32
|
+
p("jumpTo"),
|
|
33
|
+
/* @__PURE__ */ s(r, {
|
|
34
|
+
"aria-label": p("jumpTo"),
|
|
35
|
+
inputMode: "numeric",
|
|
36
|
+
className: "h-8 w-14 px-2 text-center",
|
|
37
|
+
value: m,
|
|
38
|
+
onChange: (e) => h(e.target.value),
|
|
39
|
+
onKeyDown: (e) => {
|
|
40
|
+
if (e.key !== "Enter") return;
|
|
41
|
+
let t = a(m, g);
|
|
42
|
+
t && d(t), h("");
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
p("jumpPage")
|
|
46
|
+
]
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { l as PagePager };
|
|
@@ -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("lucide-react"),i=require("react/jsx-runtime"),a=require("sonner");function o({title:e,description:t,eyebrow:n,actions:r}){return(0,i.jsxs)(`header`,{className:`mb-8 flex flex-wrap items-end justify-between gap-5`,children:[(0,i.jsxs)(`div`,{className:`min-w-0`,children:[(0,i.jsx)(`p`,{"data-slot":`page-eyebrow`,className:`mb-2 text-xs font-medium tracking-wide text-primary`,children:n}),(0,i.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight sm:text-[28px]`,children:e}),t&&(0,i.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm leading-6 text-muted-foreground`,children:t})]}),r&&(0,i.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:r})]})}function s({title:t,description:a,action:o,icon:s,size:c=`default`}){let{t:l}=n.useUiTranslation();return(0,i.jsxs)(`div`,{"data-size":c,className:e.cn(`flex flex-col items-center justify-center rounded-xl bg-muted/35 px-6 py-10 text-center`,c===`compact`?`min-h-32`:`min-h-64`),children:[(0,i.jsx)(`div`,{className:`mb-4 flex size-11 items-center justify-center rounded-xl border bg-muted`,children:s??(0,i.jsx)(r.Inbox,{className:`size-5 text-muted-foreground`})}),(0,i.jsx)(`h3`,{className:`text-sm font-medium`,children:t??l(`empty`)}),(0,i.jsx)(`p`,{className:`mt-2 max-w-sm text-sm leading-6 text-muted-foreground`,children:a??l(`emptyDescription`)}),o&&(0,i.jsx)(`div`,{className:`mt-5`,children:o})]})}function c({message:e,traceId:a,retry:o}){let{t:s}=n.useUiTranslation();return(0,i.jsx)(`section`,{role:`alert`,className:`rounded-lg border border-danger/25 bg-danger-soft px-5 py-4`,children:(0,i.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,i.jsx)(r.AlertCircle,{className:`mt-0.5 size-5 shrink-0 text-danger`}),(0,i.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,i.jsx)(`h2`,{className:`font-medium text-danger`,children:s(`errorTitle`)}),(0,i.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-foreground`,children:e}),a&&(0,i.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[s(`trace`),`: `,(0,i.jsx)(u,{value:a})]})]}),o&&(0,i.jsxs)(t.Button,{variant:`outline`,size:`sm`,onClick:o,children:[(0,i.jsx)(r.RefreshCw,{className:`size-3.5`}),s(`retry`)]})]})})}function l({variant:t=`spinner`,label:a}={}){let{t:o}=n.useUiTranslation();return t===`spinner`?(0,i.jsxs)(`div`,{role:`status`,className:`flex min-h-60 items-center justify-center gap-3 text-muted-foreground`,children:[(0,i.jsx)(r.LoaderCircle,{className:`size-5 animate-spin`}),(0,i.jsx)(`span`,{children:a??o(`loading`)})]}):(0,i.jsxs)(`div`,{role:`status`,className:`flex min-h-60 flex-col items-center justify-center gap-3 text-muted-foreground`,children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-end gap-1`,children:[0,1,2,3].map(n=>(0,i.jsx)(`span`,{className:e.cn(`w-1.5 rounded-full bg-primary/60`,t===`dots`?`size-2 animate-bounce`:`animate-pulse`),style:{animationDelay:`${n*120}ms`,height:t===`bars`?`${10+n*4}px`:void 0}},n))}),(0,i.jsx)(`span`,{children:a??o(`loading`)})]})}function u({value:e}){let{t:o}=n.useUiTranslation();async function s(){try{await navigator.clipboard.writeText(e),a.toast.success(o(`copied`))}catch{a.toast.error(o(`copyFailed`))}}return(0,i.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 align-middle`,children:[(0,i.jsx)(`code`,{className:`break-all font-mono text-xs`,children:e}),(0,i.jsx)(t.Button,{variant:`ghost`,size:`icon`,className:`size-7 shrink-0`,"aria-label":`${o(`copy`)} ${e}`,onClick:()=>void s(),children:(0,i.jsx)(r.Copy,{className:`size-3`})})]})}function d(){let{t:e}=n.useUiTranslation();return(0,i.jsxs)(`main`,{className:`flex min-h-screen flex-col items-center justify-center p-6 text-center`,children:[(0,i.jsx)(`p`,{className:`font-mono text-primary`,children:`404`}),(0,i.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold`,children:e(`unavailable`)}),(0,i.jsx)(`p`,{className:`mt-3 text-muted-foreground`,children:e(`unavailableDescription`)}),(0,i.jsx)(t.Button,{className:`mt-6`,asChild:!0,children:(0,i.jsxs)(`a`,{href:`/`,children:[(0,i.jsx)(r.ArrowLeft,{className:`size-4`}),e(`backHome`)]})})]})}function f(){let{t:e}=n.useUiTranslation();return(0,i.jsxs)(`section`,{role:`alert`,className:`flex flex-col items-center py-20 text-center`,children:[(0,i.jsx)(`p`,{className:`font-mono text-primary`,children:`403`}),(0,i.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold`,children:e(`forbidden`)}),(0,i.jsx)(`p`,{className:`mt-3 max-w-md text-muted-foreground`,children:e(`forbiddenDescription`)}),(0,i.jsx)(t.Button,{className:`mt-6`,asChild:!0,children:(0,i.jsxs)(`a`,{href:`/`,children:[(0,i.jsx)(r.ArrowLeft,{className:`size-4`}),e(`backHome`)]})})]})}exports.CopyValue=u,exports.EmptyState=s,exports.ErrorState=c,exports.ForbiddenPage=f,exports.LoadingState=l,exports.NotFoundPage=d,exports.PageHeader=o;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export declare function PageHeader({ title, description, eyebrow, actions, }: {
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
eyebrow: string;
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function EmptyState({ title, description, action, icon, size, }: {
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
action?: ReactNode;
|
|
12
|
+
/** 自定义图标,默认收件箱;列表类空态可换成对应业务图标。 */
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
/** 嵌入卡片时用 compact。 */
|
|
15
|
+
size?: 'default' | 'compact';
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
export declare function ErrorState({ message, traceId, retry, }: {
|
|
18
|
+
message: string;
|
|
19
|
+
traceId?: string;
|
|
20
|
+
retry?: () => void;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
|
+
export declare function LoadingState({
|
|
23
|
+
/** spinner(默认)/dots/bars,覆盖不同体量的加载场景。 */
|
|
24
|
+
variant, label, }?: {
|
|
25
|
+
variant?: 'spinner' | 'dots' | 'bars';
|
|
26
|
+
label?: string;
|
|
27
|
+
}): import("react").JSX.Element;
|
|
28
|
+
export declare function CopyValue({ value }: {
|
|
29
|
+
value: string;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
export declare function NotFoundPage(): import("react").JSX.Element;
|
|
32
|
+
/** 403:菜单里没有、但直接敲 URL 进来的页面。 */
|
|
33
|
+
export declare function ForbiddenPage(): import("react").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/components/page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMtC,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,WAAW,EACX,OAAO,EACP,OAAO,GACR,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,SAAS,CAAA;CACpB,+BAeA;AACD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,WAAW,EACX,MAAM,EACN,IAAI,EACJ,IAAgB,GACjB,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,kCAAkC;IAClC,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,sBAAsB;IACtB,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;CAC7B,+BAoBA;AACD,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,OAAO,EACP,KAAK,GACN,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CACnB,+BAwBA;AACD,wBAAgB,YAAY,CAAC;AAC3B,yCAAyC;AACzC,OAAmB,EACnB,KAAK,GACN,GAAE;IACD,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;CACV,+BAmCL;AACD,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,+BAwBrD;AACD,wBAAgB,YAAY,gCAe3B;AAED,gCAAgC;AAChC,wBAAgB,aAAa,gCAe5B"}
|