@vavt/react-ui 1.0.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Anchor-QZROepM_.js → Anchor-CAZPkv56.js} +1 -1
- package/dist/{Anchor-iriRYxEs.cjs → Anchor-CmuV1Ump.cjs} +1 -1
- package/dist/{Announcement-XjJyJ28N.cjs → Announcement-D0hZE2sM.cjs} +1 -1
- package/dist/{Announcement-D_NccvTm.js → Announcement-DzzaTvcO.js} +1 -1
- package/dist/Checkbox-CBMmX-R-.js +86 -0
- package/dist/Checkbox-CzNGP2tH.cjs +1 -0
- package/dist/Checkbox-GJlGNzlH.cjs +1 -0
- package/dist/Checkbox-bHOjYdMp.js +61 -0
- package/dist/{Cron-Go4yIqrd.js → Cron-DIB4GG4y.js} +7 -7
- package/dist/{Cron-3D9GmlYf.cjs → Cron-MhbYMEeJ.cjs} +1 -1
- package/dist/{DatePicker-B-F5q_s_.js → DatePicker--13tW0cw.js} +1 -1
- package/dist/{DatePicker-CoHW85qm.cjs → DatePicker-Bj709smn.cjs} +1 -1
- package/dist/{DateTimePicker-BSBZZ7xV.js → DateTimePicker-Blqs2Bcv.js} +1 -1
- package/dist/{DateTimePicker-CAkdoY--.cjs → DateTimePicker-ZSScsk-j.cjs} +1 -1
- package/dist/{Drawer-D45miZ27.cjs → Drawer-DcbgMkub.cjs} +1 -1
- package/dist/{Drawer-C0toQ-fQ.js → Drawer-yM_r1M0H.js} +2 -2
- package/dist/{Dropdown-BsXYVdt6.cjs → Dropdown-PHqXNiAZ.cjs} +1 -1
- package/dist/{Dropdown-DljKFnvO.js → Dropdown-mYCY-LcF.js} +2 -2
- package/dist/Form-BkyDHPEI.cjs +1 -0
- package/dist/Form-D_Uv-8HG.js +449 -0
- package/dist/{Input-CIB_TY2n.js → Input-BRy5Xuwy.js} +28 -37
- package/dist/Input-C9ESmbJ7.cjs +1 -0
- package/dist/{MessageBox-CTJfdU29.cjs → MessageBox-BSMYQenX.cjs} +1 -1
- package/dist/{MessageBox-B4Qo1vs2.js → MessageBox-DipOfKXI.js} +2 -2
- package/dist/Modal-BOI8r4y1.cjs +1 -0
- package/dist/Modal-De9igZ5e.js +238 -0
- package/dist/{NumberInput-C_vLULbX.js → NumberInput-CB-nKZgs.js} +1 -1
- package/dist/{NumberInput-CYVj89_s.cjs → NumberInput-Dp1vTDkW.cjs} +1 -1
- package/dist/{Pagination-CSI5IzQB.js → Pagination-CpbboRbF.js} +2 -2
- package/dist/{Pagination-ODU-i3gn.cjs → Pagination-DatEegaF.cjs} +1 -1
- package/dist/RadioGroup-DTodR0VJ.cjs +1 -0
- package/dist/RadioGroup-DYjQMXdB.js +136 -0
- package/dist/Select-BHWa_6Q2.js +466 -0
- package/dist/Select-C6O0tmM_.cjs +1 -0
- package/dist/{Slider-BzlZc0p4.js → Slider-CKU03SsT.js} +1 -1
- package/dist/{Slider-DCIUxcBa.cjs → Slider-CU9OS2HB.cjs} +1 -1
- package/dist/{Switch-7yJ-Q_o_.cjs → Switch-CpXDMcPW.cjs} +1 -1
- package/dist/{Switch-DOO2tiYR.js → Switch-CqTFvp-k.js} +1 -1
- package/dist/Table-BNGO_7Rx.cjs +1 -0
- package/dist/Table-Cfs3XJgN.js +531 -0
- package/dist/{Tabs-BhjvKN84.cjs → Tabs-BZ0Zc0bL.cjs} +1 -1
- package/dist/{Tabs-VT6nQ63W.js → Tabs-HWLkyrQR.js} +1 -1
- package/dist/{Textarea-BEd7ToXv.js → Textarea-CA6Vzu7t.js} +1 -1
- package/dist/{Textarea-C2dNYM0F.cjs → Textarea-CEhAvE10.cjs} +1 -1
- package/dist/{TimePicker-CHZsr_jj.js → TimePicker-CYlcUTTM.js} +2 -2
- package/dist/{TimePicker-Cpmvn8tx.cjs → TimePicker-DoGbwfkU.cjs} +1 -1
- package/dist/{Tooltip-Buk5F9f_.js → Tooltip-BKPreZML.js} +2 -2
- package/dist/{Tooltip-CP8rpNYG.cjs → Tooltip-DDjGLjoV.cjs} +1 -1
- package/dist/{Upload-DZC_bt6G.js → Upload-DZ6VaM7r.js} +66 -65
- package/dist/Upload-wHEEoe1c.cjs +1 -0
- package/dist/base.css +1 -1
- package/dist/cjs/Anchor.cjs +1 -1
- package/dist/cjs/Announcement.cjs +1 -1
- package/dist/cjs/Checkbox.cjs +1 -1
- package/dist/cjs/Cron.cjs +1 -1
- package/dist/cjs/DatePicker.cjs +1 -1
- package/dist/cjs/DateTimePicker.cjs +1 -1
- package/dist/cjs/Drawer.cjs +1 -1
- package/dist/cjs/Dropdown.cjs +1 -1
- package/dist/cjs/Form.cjs +1 -1
- package/dist/cjs/Input.cjs +1 -1
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/NumberInput.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Radio.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Slider.cjs +1 -1
- package/dist/cjs/Switch.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/Tabs.cjs +1 -1
- package/dist/cjs/Textarea.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/Upload.cjs +1 -1
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/css/Alert.css +1 -1
- package/dist/css/Announcement.css +1 -1
- package/dist/css/Button.css +1 -1
- package/dist/css/Card.css +1 -1
- package/dist/css/Checkbox.css +1 -1
- package/dist/css/Cron.css +1 -1
- package/dist/css/DatePicker.css +1 -1
- package/dist/css/DateTimePicker.css +1 -1
- package/dist/css/Drawer.css +1 -1
- package/dist/css/Dropdown.css +1 -1
- package/dist/css/Empty.css +1 -1
- package/dist/css/Form.css +1 -1
- package/dist/css/Input.css +1 -1
- package/dist/css/MessageBox.css +1 -1
- package/dist/css/Modal.css +1 -1
- package/dist/css/NumberInput.css +1 -1
- package/dist/css/Progress.css +1 -1
- package/dist/css/Radio.css +1 -1
- package/dist/css/Select.css +1 -1
- package/dist/css/Sidebar.css +1 -1
- package/dist/css/Switch.css +1 -1
- package/dist/css/Tag.css +1 -1
- package/dist/css/Textarea.css +1 -1
- package/dist/css/TimePicker.css +1 -1
- package/dist/css/Tooltip.css +1 -1
- package/dist/css/Upload.css +1 -1
- package/dist/date-picker-Be_1wA3S.cjs +1 -0
- package/dist/date-picker-CHP0eBuL.js +612 -0
- package/dist/{dialog-shell-DehX3PNh.js → dialog-shell-CdYlPT9f.js} +12 -12
- package/dist/dialog-shell-CzeGytVj.cjs +1 -0
- package/dist/es/Anchor.mjs +1 -1
- package/dist/es/Announcement.mjs +1 -1
- package/dist/es/Checkbox.mjs +1 -1
- package/dist/es/Cron.mjs +1 -1
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/Input.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/NumberInput.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Radio.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Slider.mjs +1 -1
- package/dist/es/Switch.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/Tabs.mjs +1 -1
- package/dist/es/Textarea.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/Upload.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +32 -32
- package/dist/es/register.mjs +1 -1
- package/dist/floating-5PRFyI8D.cjs +1 -0
- package/dist/floating-CqdcJWk2.js +181 -0
- package/dist/index.css +1 -1
- package/dist/registry-BLaletUC.js +83 -0
- package/dist/registry-hU7S5myb.cjs +1 -0
- package/dist/state-BSDh-Ob2.js +22 -0
- package/dist/state-BuUx1onZ.cjs +1 -0
- package/dist/style/Form.cjs +1 -0
- package/dist/style/Form.mjs +1 -0
- package/dist/style/Modal.cjs +1 -0
- package/dist/style/Modal.mjs +1 -0
- package/dist/types/Checkbox/context.d.cts +12 -2
- package/dist/types/Checkbox/context.d.ts +12 -2
- package/dist/types/Checkbox/type.d.cts +33 -3
- package/dist/types/Checkbox/type.d.ts +33 -3
- package/dist/types/Form/FormItem.d.cts +1 -1
- package/dist/types/Form/FormItem.d.ts +1 -1
- package/dist/types/Form/context.d.cts +31 -0
- package/dist/types/Form/context.d.ts +31 -0
- package/dist/types/Form/index.d.cts +2 -2
- package/dist/types/Form/index.d.ts +2 -2
- package/dist/types/Form/type.d.cts +1 -1
- package/dist/types/Form/type.d.ts +1 -1
- package/dist/types/Modal/type.d.cts +3 -3
- package/dist/types/Modal/type.d.ts +3 -3
- package/dist/types/Radio/context.d.cts +12 -2
- package/dist/types/Radio/context.d.ts +12 -2
- package/dist/types/Radio/type.d.cts +33 -3
- package/dist/types/Radio/type.d.ts +33 -3
- package/dist/types/Upload/type.d.cts +4 -0
- package/dist/types/Upload/type.d.ts +4 -0
- package/dist/types/_shared/state.d.cts +3 -0
- package/dist/types/_shared/state.d.ts +3 -0
- package/dist/types/registry.d.cts +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/package.json +1 -1
- package/dist/Checkbox-BCXbK1-8.cjs +0 -1
- package/dist/Checkbox-CQZSg9Xu.cjs +0 -1
- package/dist/Checkbox-CQeqLO0S.js +0 -46
- package/dist/Checkbox-cnXHW9Oz.js +0 -61
- package/dist/Form-7un_DeDk.cjs +0 -1
- package/dist/Form-CwgaAZWr.js +0 -323
- package/dist/Input-CoDZggqc.cjs +0 -1
- package/dist/Modal-i_Do8GsG.cjs +0 -1
- package/dist/Modal-otJ_9ldu.js +0 -210
- package/dist/RadioGroup-BRcNi5Oc.js +0 -98
- package/dist/RadioGroup-q2Aa50NV.cjs +0 -1
- package/dist/Select-BRKxpX-_.cjs +0 -1
- package/dist/Select-QedbJ4pD.js +0 -468
- package/dist/Table-B9NTkptC.js +0 -440
- package/dist/Table-Bqjey5fw.cjs +0 -1
- package/dist/Upload-bxJz2avf.cjs +0 -1
- package/dist/date-picker-BsiNrLZC.js +0 -592
- package/dist/date-picker-DNN0BiRA.cjs +0 -1
- package/dist/dialog-shell-DT1EoKQG.cjs +0 -1
- package/dist/floating-DBAmeQIq.js +0 -157
- package/dist/floating-DXRnx48N.cjs +0 -1
- package/dist/registry-BGNWNSiC.cjs +0 -1
- package/dist/registry-q6UdMOyj.js +0 -83
- package/dist/state-ZBA75xZ_.cjs +0 -1
- package/dist/state-oH-YwB7_.js +0 -15
package/dist/Table-B9NTkptC.js
DELETED
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
-
import { n as t, t as n } from "./state-oH-YwB7_.js";
|
|
3
|
-
import { n as r } from "./number-BN2jHM6Z.js";
|
|
4
|
-
import { t as i } from "./Scrollbar-BdMGZrYi.js";
|
|
5
|
-
import { t as a } from "./Tooltip-Buk5F9f_.js";
|
|
6
|
-
import { ChevronDown as o, ChevronUp as s } from "lucide-react";
|
|
7
|
-
import { forwardRef as c, useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
8
|
-
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
|
-
//#region components/Table/Table.tsx
|
|
10
|
-
var ee = (e, t) => e.length === t.length && e.every((e, n) => Object.is(e, t[n])), g = (e, t) => {
|
|
11
|
-
let n = [...new Set(e)];
|
|
12
|
-
return t === "radio" ? n.slice(0, 1) : n;
|
|
13
|
-
}, te = ({ type: t, checked: n, disabled: r = !1, indeterminate: i = !1, ariaLabel: a, onChange: o }) => {
|
|
14
|
-
let s = f(null);
|
|
15
|
-
e(() => {
|
|
16
|
-
s.current && (s.current.indeterminate = t === "checkbox" && i);
|
|
17
|
-
}, [i, t]);
|
|
18
|
-
let c = (e) => e.stopPropagation();
|
|
19
|
-
return /* @__PURE__ */ h("label", {
|
|
20
|
-
className: [
|
|
21
|
-
"vl-table__selection-control",
|
|
22
|
-
`is-${t}`,
|
|
23
|
-
n ? "is-checked" : "",
|
|
24
|
-
i ? "is-indeterminate" : "",
|
|
25
|
-
r ? "is-disabled" : ""
|
|
26
|
-
].filter(Boolean).join(" "),
|
|
27
|
-
onClick: c,
|
|
28
|
-
onDoubleClick: c,
|
|
29
|
-
children: [/* @__PURE__ */ m("input", {
|
|
30
|
-
ref: s,
|
|
31
|
-
className: "vl-table__selection-input",
|
|
32
|
-
type: t,
|
|
33
|
-
checked: n,
|
|
34
|
-
disabled: r,
|
|
35
|
-
"aria-label": a,
|
|
36
|
-
onChange: o
|
|
37
|
-
}), /* @__PURE__ */ m("span", {
|
|
38
|
-
className: "vl-table__selection-indicator",
|
|
39
|
-
"aria-hidden": "true"
|
|
40
|
-
})]
|
|
41
|
-
});
|
|
42
|
-
}, ne = ({ content: t, tooltipContent: n, showTooltip: r }) => {
|
|
43
|
-
let i = f(null), [o, s] = p(!1), c = l(() => {
|
|
44
|
-
let e = i.current;
|
|
45
|
-
e && s(e.scrollWidth > e.clientWidth);
|
|
46
|
-
}, []);
|
|
47
|
-
return e(() => {
|
|
48
|
-
c();
|
|
49
|
-
let e = i.current, t = typeof ResizeObserver > "u" ? null : new ResizeObserver(c);
|
|
50
|
-
return e && t?.observe(e), window.addEventListener("resize", c, { passive: !0 }), () => {
|
|
51
|
-
t?.disconnect(), window.removeEventListener("resize", c);
|
|
52
|
-
};
|
|
53
|
-
}, [t, c]), /* @__PURE__ */ m(a, {
|
|
54
|
-
className: "vl-table__ellipsis-tooltip",
|
|
55
|
-
content: n,
|
|
56
|
-
disabled: !o || !r,
|
|
57
|
-
children: /* @__PURE__ */ m("span", {
|
|
58
|
-
ref: i,
|
|
59
|
-
className: "vl-table__ellipsis-content",
|
|
60
|
-
tabIndex: o && r ? 0 : void 0,
|
|
61
|
-
children: t
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
function _(a, c) {
|
|
66
|
-
let { data: _, columns: v, rowKey: y, size: b = "md", bordered: re = !0, striped: ie = !1, highlightCurrentRow: x = !1, showHeader: S = !0, emptyText: ae = "暂无数据", maxHeight: C, loading: w = !1, caption: oe, emptyContent: se, loadingContent: ce, tableLayout: le, sortState: ue, defaultSortState: de = null, rowSelection: T, currentRowKey: fe, defaultCurrentRowKey: pe = null, className: me, style: he, onRowClick: ge, onRowDoubleClick: _e, onCellClick: ve, onSortChange: ye, onCurrentRowChange: be, ...xe } = a, Se = n(a, "sortState"), E = n(a, "currentRowKey"), D = !!(T && n(T, "selectedRowKeys")), O = T?.type ?? "checkbox", k = T?.preserveSelectedRowKeys ?? !1, Ce = T?.columnWidth ?? 48, A = C != null, [j, we] = t({
|
|
67
|
-
value: ue ?? null,
|
|
68
|
-
defaultValue: de,
|
|
69
|
-
controlled: Se
|
|
70
|
-
}), [M, N] = t({
|
|
71
|
-
value: fe ?? null,
|
|
72
|
-
defaultValue: pe,
|
|
73
|
-
controlled: E
|
|
74
|
-
}), [Te, P] = t({
|
|
75
|
-
value: T?.selectedRowKeys ?? [],
|
|
76
|
-
defaultValue: g(T?.defaultSelectedRowKeys ?? [], O),
|
|
77
|
-
controlled: D
|
|
78
|
-
}), F = f(null), I = f([]), L = f(/* @__PURE__ */ new Map()), [Ee, De] = p([]), [Oe, ke] = p(!1), R = d(() => g(Te, O), [Te, O]), z = d(() => new Set(R), [R]), B = l((e) => typeof y == "function" ? y(e) : e[y], [y]), V = d(() => {
|
|
79
|
-
let e = /* @__PURE__ */ new Map();
|
|
80
|
-
return _.forEach((t) => e.set(B(t), t)), e;
|
|
81
|
-
}, [_, B]), Ae = d(() => {
|
|
82
|
-
if (!j) return _;
|
|
83
|
-
let e = v.find((e) => e.key === j.columnKey);
|
|
84
|
-
if (!e || typeof e.sorter != "function") return _;
|
|
85
|
-
let t = e.sorter, n = j.order === "asc" ? 1 : -1;
|
|
86
|
-
return _.map((e, t) => ({
|
|
87
|
-
row: e,
|
|
88
|
-
index: t
|
|
89
|
-
})).sort((e, r) => t(e.row, r.row) * n || e.index - r.index).map(({ row: e }) => e);
|
|
90
|
-
}, [
|
|
91
|
-
v,
|
|
92
|
-
_,
|
|
93
|
-
j
|
|
94
|
-
]), H = d(() => Ae.map((e, t) => ({
|
|
95
|
-
row: e,
|
|
96
|
-
index: t,
|
|
97
|
-
key: B(e),
|
|
98
|
-
controlProps: T?.getControlProps?.(e, t) ?? {}
|
|
99
|
-
})), [
|
|
100
|
-
B,
|
|
101
|
-
T,
|
|
102
|
-
Ae
|
|
103
|
-
]);
|
|
104
|
-
u(() => {
|
|
105
|
-
if (k) {
|
|
106
|
-
V.forEach((e, t) => L.current.set(t, e));
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
L.current = new Map(V);
|
|
110
|
-
}, [V, k]), u(() => {
|
|
111
|
-
if (!T || D) return;
|
|
112
|
-
let e = g(k ? R : R.filter((e) => V.has(e)), O);
|
|
113
|
-
ee(R, e) || P(e);
|
|
114
|
-
}, [
|
|
115
|
-
V,
|
|
116
|
-
k,
|
|
117
|
-
T,
|
|
118
|
-
R,
|
|
119
|
-
D,
|
|
120
|
-
O,
|
|
121
|
-
P
|
|
122
|
-
]), u(() => {
|
|
123
|
-
E || M === null || V.has(M) || N(null);
|
|
124
|
-
}, [
|
|
125
|
-
E,
|
|
126
|
-
M,
|
|
127
|
-
V,
|
|
128
|
-
N
|
|
129
|
-
]);
|
|
130
|
-
let U = d(() => H.filter(({ controlProps: e }) => !e.disabled), [H]), W = U.length > 0 && U.every(({ key: e }) => z.has(e)), je = !W && U.some(({ key: e }) => z.has(e)), G = d(() => [...T ? [{
|
|
131
|
-
width: Ce,
|
|
132
|
-
fixed: T.fixed ? "left" : void 0
|
|
133
|
-
}] : [], ...v], [
|
|
134
|
-
v,
|
|
135
|
-
T,
|
|
136
|
-
Ce
|
|
137
|
-
]), K = +!!T, Me = d(() => {
|
|
138
|
-
let e = -1;
|
|
139
|
-
return G.forEach((t, n) => {
|
|
140
|
-
t.fixed === "left" && (e = n);
|
|
141
|
-
}), e;
|
|
142
|
-
}, [G]), Ne = d(() => G.findIndex((e) => e.fixed === "right"), [G]), Pe = G.some((e) => e.fixed !== void 0), q = A || Pe, J = l((e) => {
|
|
143
|
-
let t = e.width ?? e.minWidth;
|
|
144
|
-
return typeof t == "number" && Number.isFinite(t) ? Math.max(0, t) : typeof t == "string" && /^\d+(?:\.\d+)?px$/.test(t.trim()) ? Number.parseFloat(t) : 0;
|
|
145
|
-
}, []), Y = l(() => {
|
|
146
|
-
let e = G.map((e, t) => {
|
|
147
|
-
let n = I.current[t]?.getBoundingClientRect().width ?? 0;
|
|
148
|
-
return n > 0 ? n : J(e);
|
|
149
|
-
}), t = G.map(() => ({})), n = 0;
|
|
150
|
-
G.forEach((r, i) => {
|
|
151
|
-
r.fixed === "left" && (t[i].left = n, n += e[i]);
|
|
152
|
-
});
|
|
153
|
-
let r = 0;
|
|
154
|
-
for (let n = G.length - 1; n >= 0; --n) G[n].fixed === "right" && (t[n].right = r, r += e[n]);
|
|
155
|
-
let i = F.current?.querySelector(".vl-scrollbar__viewport")?.clientWidth ?? 0, a = i > 0 ? i : F.current?.clientWidth ?? 0;
|
|
156
|
-
ke(a > 0 && n + r > a), De((e) => e.length === t.length && e.every((e, n) => Object.is(e.left, t[n].left) && Object.is(e.right, t[n].right)) ? e : t);
|
|
157
|
-
}, [J, G]);
|
|
158
|
-
e(() => {
|
|
159
|
-
I.current.length = G.length, Y();
|
|
160
|
-
let e = typeof ResizeObserver > "u" ? null : new ResizeObserver(Y);
|
|
161
|
-
return I.current.forEach((t) => {
|
|
162
|
-
t && e?.observe(t);
|
|
163
|
-
}), window.addEventListener("resize", Y, { passive: !0 }), () => {
|
|
164
|
-
e?.disconnect(), window.removeEventListener("resize", Y);
|
|
165
|
-
};
|
|
166
|
-
}, [
|
|
167
|
-
G,
|
|
168
|
-
H.length,
|
|
169
|
-
S,
|
|
170
|
-
Y
|
|
171
|
-
]);
|
|
172
|
-
let Fe = d(() => [
|
|
173
|
-
"vl-table",
|
|
174
|
-
`size-${b}`,
|
|
175
|
-
re ? "is-bordered" : "",
|
|
176
|
-
ie ? "is-striped" : "",
|
|
177
|
-
w ? "is-loading" : "",
|
|
178
|
-
T ? "has-row-selection" : "",
|
|
179
|
-
A ? "has-sticky-header" : "",
|
|
180
|
-
q ? "has-custom-scrollbar" : "",
|
|
181
|
-
me || ""
|
|
182
|
-
].filter(Boolean).join(" "), [
|
|
183
|
-
re,
|
|
184
|
-
me,
|
|
185
|
-
A,
|
|
186
|
-
w,
|
|
187
|
-
T,
|
|
188
|
-
b,
|
|
189
|
-
ie,
|
|
190
|
-
q
|
|
191
|
-
]), Ie = d(() => A ? q ? {
|
|
192
|
-
maxHeight: r(C),
|
|
193
|
-
overflow: "visible"
|
|
194
|
-
} : {
|
|
195
|
-
maxHeight: r(C),
|
|
196
|
-
overflowY: "auto"
|
|
197
|
-
} : {}, [
|
|
198
|
-
A,
|
|
199
|
-
C,
|
|
200
|
-
q
|
|
201
|
-
]), Le = [
|
|
202
|
-
"vl-table__wrapper",
|
|
203
|
-
q ? "is-custom-scrollbar" : "",
|
|
204
|
-
A ? "is-sticky-scrollbar" : ""
|
|
205
|
-
].filter(Boolean).join(" "), Re = le ?? (v.some((e) => e.ellipsis) ? "fixed" : "auto"), ze = d(() => {
|
|
206
|
-
let e = G.map(J);
|
|
207
|
-
return e.length > 0 && e.every((e) => e > 0) ? e.reduce((e, t) => e + t, 0) : 0;
|
|
208
|
-
}, [J, G]), Be = (e) => {
|
|
209
|
-
let t = {};
|
|
210
|
-
return e.width !== void 0 && (t.width = r(e.width)), e.minWidth !== void 0 && (t.minWidth = r(e.minWidth)), t;
|
|
211
|
-
}, X = (e, t, n, i = "left") => {
|
|
212
|
-
let a = { textAlign: i };
|
|
213
|
-
return e.width !== void 0 && (a.width = r(e.width)), e.minWidth !== void 0 && (a.minWidth = r(e.minWidth)), n && A && (a.position = "sticky", a.top = 0, a.zIndex = e.fixed ? 5 : 4), !e.fixed || e.fixed === "right" && Oe ? a : (a.position = "sticky", a.zIndex = n ? 5 : 2, e.fixed === "left" ? a.left = Ee[t]?.left ?? 0 : a.right = Ee[t]?.right ?? 0, a);
|
|
214
|
-
}, Z = (e, t) => {
|
|
215
|
-
let n = e.fixed === "right" && Oe ? void 0 : e.fixed;
|
|
216
|
-
return [
|
|
217
|
-
n ? `is-fixed is-fixed-${n}` : "",
|
|
218
|
-
n === "left" && t === Me ? "is-fixed-edge-left" : "",
|
|
219
|
-
n === "right" && t === Ne ? "is-fixed-edge-right" : ""
|
|
220
|
-
];
|
|
221
|
-
}, Ve = (e, t) => [
|
|
222
|
-
"vl-table__header-cell",
|
|
223
|
-
e.headerClass || "",
|
|
224
|
-
e.sorter ? "is-sortable" : "",
|
|
225
|
-
j?.columnKey === e.key ? "is-sorted" : "",
|
|
226
|
-
...Z(e, t)
|
|
227
|
-
].filter(Boolean).join(" "), He = (e, t) => [
|
|
228
|
-
"vl-table__cell",
|
|
229
|
-
e.cellClass || "",
|
|
230
|
-
e.ellipsis ? "is-ellipsis" : "",
|
|
231
|
-
...Z(e, t)
|
|
232
|
-
].filter(Boolean).join(" "), Q = (e) => {
|
|
233
|
-
let t = G[0];
|
|
234
|
-
return [
|
|
235
|
-
e ? "vl-table__header-cell" : "vl-table__cell",
|
|
236
|
-
"vl-table__selection-cell",
|
|
237
|
-
...Z(t, 0)
|
|
238
|
-
].filter(Boolean).join(" ");
|
|
239
|
-
}, Ue = (e) => [
|
|
240
|
-
"vl-table__sort-icons",
|
|
241
|
-
j?.columnKey === e.key && j.order === "asc" ? "is-asc" : "",
|
|
242
|
-
j?.columnKey === e.key && j.order === "desc" ? "is-desc" : ""
|
|
243
|
-
].filter(Boolean).join(" "), $ = (e) => {
|
|
244
|
-
if (!T) return;
|
|
245
|
-
let t = g(e, O);
|
|
246
|
-
P(t);
|
|
247
|
-
let n = k ? L.current : V, r = t.map((e) => V.get(e) ?? n.get(e)).filter((e) => e !== void 0);
|
|
248
|
-
T.onChange?.(t, r);
|
|
249
|
-
}, We = (e) => {
|
|
250
|
-
if (O === "radio") {
|
|
251
|
-
z.has(e) || $([e]);
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
$(z.has(e) ? R.filter((t) => !Object.is(t, e)) : [...R, e]);
|
|
255
|
-
}, Ge = () => {
|
|
256
|
-
let e = U.map(({ key: e }) => e), t = new Set(e);
|
|
257
|
-
if (W) {
|
|
258
|
-
$(R.filter((e) => !t.has(e)));
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
$([...R, ...e.filter((e) => !z.has(e))]);
|
|
262
|
-
}, Ke = (e) => {
|
|
263
|
-
if (!e.sorter) return;
|
|
264
|
-
let t = {
|
|
265
|
-
columnKey: e.key,
|
|
266
|
-
order: "asc"
|
|
267
|
-
};
|
|
268
|
-
j?.columnKey === e.key && (t = j.order === "asc" ? {
|
|
269
|
-
columnKey: e.key,
|
|
270
|
-
order: "desc"
|
|
271
|
-
} : null), we(t), ye?.(t, e);
|
|
272
|
-
}, qe = (e, t) => {
|
|
273
|
-
if (x) {
|
|
274
|
-
let t = B(e);
|
|
275
|
-
N(t), Object.is(M, t) || be?.(t, e);
|
|
276
|
-
}
|
|
277
|
-
ge?.(e, t);
|
|
278
|
-
}, Je = (e, t, n) => {
|
|
279
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), qe(t, n));
|
|
280
|
-
}, Ye = (e) => {
|
|
281
|
-
if (e.sorter) return j?.columnKey === e.key ? j.order === "asc" ? "ascending" : "descending" : "none";
|
|
282
|
-
}, Xe = (e, t, n) => {
|
|
283
|
-
let r = t.render ? t.render(e, n) : e[t.key];
|
|
284
|
-
if (!t.ellipsis) return r;
|
|
285
|
-
let i = typeof t.ellipsis != "object" || t.ellipsis.tooltip, a = i !== !1, o = typeof i == "function" ? i(e, n) : r;
|
|
286
|
-
return /* @__PURE__ */ m(ne, {
|
|
287
|
-
content: r,
|
|
288
|
-
tooltipContent: o,
|
|
289
|
-
showTooltip: a
|
|
290
|
-
});
|
|
291
|
-
}, Ze = /* @__PURE__ */ h("table", {
|
|
292
|
-
className: "vl-table__inner",
|
|
293
|
-
style: {
|
|
294
|
-
tableLayout: Re,
|
|
295
|
-
minWidth: ze || void 0
|
|
296
|
-
},
|
|
297
|
-
children: [
|
|
298
|
-
oe ? /* @__PURE__ */ m("caption", {
|
|
299
|
-
className: "vl-table__caption",
|
|
300
|
-
children: oe
|
|
301
|
-
}) : null,
|
|
302
|
-
/* @__PURE__ */ m("colgroup", { children: G.map((e, t) => /* @__PURE__ */ m("col", { style: Be(e) }, T && t === 0 ? "selection" : v[t - K].key)) }),
|
|
303
|
-
S ? /* @__PURE__ */ m("thead", {
|
|
304
|
-
className: "vl-table__header",
|
|
305
|
-
children: /* @__PURE__ */ h("tr", { children: [T ? /* @__PURE__ */ m("th", {
|
|
306
|
-
ref: (e) => {
|
|
307
|
-
I.current[0] = e;
|
|
308
|
-
},
|
|
309
|
-
className: Q(!0),
|
|
310
|
-
style: X(G[0], 0, !0, "center"),
|
|
311
|
-
scope: "col",
|
|
312
|
-
"aria-label": "行选择",
|
|
313
|
-
children: O === "checkbox" ? /* @__PURE__ */ m(te, {
|
|
314
|
-
type: "checkbox",
|
|
315
|
-
checked: W,
|
|
316
|
-
indeterminate: je,
|
|
317
|
-
disabled: U.length === 0,
|
|
318
|
-
ariaLabel: "选择全部行",
|
|
319
|
-
onChange: Ge
|
|
320
|
-
}) : null
|
|
321
|
-
}) : null, v.map((e, t) => {
|
|
322
|
-
let n = t + K;
|
|
323
|
-
return /* @__PURE__ */ m("th", {
|
|
324
|
-
ref: (e) => {
|
|
325
|
-
I.current[n] = e;
|
|
326
|
-
},
|
|
327
|
-
className: Ve(e, n),
|
|
328
|
-
style: X(e, n, !0, e.align || "left"),
|
|
329
|
-
scope: "col",
|
|
330
|
-
"aria-sort": Ye(e),
|
|
331
|
-
children: e.sorter ? /* @__PURE__ */ h("button", {
|
|
332
|
-
type: "button",
|
|
333
|
-
className: "vl-table__sort-button",
|
|
334
|
-
onClick: () => Ke(e),
|
|
335
|
-
children: [/* @__PURE__ */ m("span", { children: e.title }), /* @__PURE__ */ h("span", {
|
|
336
|
-
className: Ue(e),
|
|
337
|
-
children: [/* @__PURE__ */ m(s, {
|
|
338
|
-
className: "vl-table__sort-icon--asc",
|
|
339
|
-
size: 14,
|
|
340
|
-
"aria-hidden": "true"
|
|
341
|
-
}), /* @__PURE__ */ m(o, {
|
|
342
|
-
className: "vl-table__sort-icon--desc",
|
|
343
|
-
size: 14,
|
|
344
|
-
"aria-hidden": "true"
|
|
345
|
-
})]
|
|
346
|
-
})]
|
|
347
|
-
}) : /* @__PURE__ */ m("span", {
|
|
348
|
-
className: "vl-table__header-cell-content",
|
|
349
|
-
children: e.title
|
|
350
|
-
})
|
|
351
|
-
}, e.key);
|
|
352
|
-
})] })
|
|
353
|
-
}) : null,
|
|
354
|
-
/* @__PURE__ */ m("tbody", {
|
|
355
|
-
className: "vl-table__body",
|
|
356
|
-
children: H.length > 0 ? H.map(({ row: e, index: t, key: n, controlProps: r }) => {
|
|
357
|
-
let i = z.has(n), a = x && Object.is(M, n), o = T ? i : x ? a : void 0;
|
|
358
|
-
return /* @__PURE__ */ h("tr", {
|
|
359
|
-
className: [
|
|
360
|
-
"vl-table__row",
|
|
361
|
-
i ? "is-selected" : "",
|
|
362
|
-
a ? "is-current" : ""
|
|
363
|
-
].filter(Boolean).join(" "),
|
|
364
|
-
tabIndex: ge || x ? 0 : void 0,
|
|
365
|
-
"aria-selected": o,
|
|
366
|
-
onClick: () => qe(e, t),
|
|
367
|
-
onDoubleClick: () => _e?.(e, t),
|
|
368
|
-
onKeyDown: (n) => Je(n, e, t),
|
|
369
|
-
children: [T ? /* @__PURE__ */ m("td", {
|
|
370
|
-
ref: (e) => {
|
|
371
|
-
!S && t === 0 && (I.current[0] = e);
|
|
372
|
-
},
|
|
373
|
-
className: Q(!1),
|
|
374
|
-
style: X(G[0], 0, !1, "center"),
|
|
375
|
-
onClick: (e) => e.stopPropagation(),
|
|
376
|
-
onDoubleClick: (e) => e.stopPropagation(),
|
|
377
|
-
children: /* @__PURE__ */ m(te, {
|
|
378
|
-
type: O,
|
|
379
|
-
checked: i,
|
|
380
|
-
disabled: r.disabled,
|
|
381
|
-
ariaLabel: r["aria-label"] ?? `选择第 ${t + 1} 行`,
|
|
382
|
-
onChange: () => We(n)
|
|
383
|
-
})
|
|
384
|
-
}) : null, v.map((n, r) => {
|
|
385
|
-
let i = r + K;
|
|
386
|
-
return /* @__PURE__ */ m("td", {
|
|
387
|
-
ref: (e) => {
|
|
388
|
-
!S && t === 0 && (I.current[i] = e);
|
|
389
|
-
},
|
|
390
|
-
className: He(n, i),
|
|
391
|
-
style: X(n, i, !1, n.align || "left"),
|
|
392
|
-
onClick: () => ve?.(e, n, t),
|
|
393
|
-
children: Xe(e, n, t)
|
|
394
|
-
}, n.key);
|
|
395
|
-
})]
|
|
396
|
-
}, n);
|
|
397
|
-
}) : /* @__PURE__ */ m("tr", {
|
|
398
|
-
className: "vl-table__empty-row",
|
|
399
|
-
children: /* @__PURE__ */ m("td", {
|
|
400
|
-
className: "vl-table__empty-cell",
|
|
401
|
-
colSpan: G.length,
|
|
402
|
-
children: se ?? ae
|
|
403
|
-
})
|
|
404
|
-
})
|
|
405
|
-
})
|
|
406
|
-
]
|
|
407
|
-
});
|
|
408
|
-
return /* @__PURE__ */ h("div", {
|
|
409
|
-
ref: c,
|
|
410
|
-
className: Fe,
|
|
411
|
-
style: he,
|
|
412
|
-
"aria-busy": w || void 0,
|
|
413
|
-
...xe,
|
|
414
|
-
children: [/* @__PURE__ */ m("div", {
|
|
415
|
-
ref: F,
|
|
416
|
-
className: Le,
|
|
417
|
-
style: Ie,
|
|
418
|
-
children: q ? /* @__PURE__ */ m(i, {
|
|
419
|
-
className: "vl-table__scrollbar",
|
|
420
|
-
orientation: A ? "both" : "horizontal",
|
|
421
|
-
style: A ? { "--vl-table-scrollbar-max-height": r(C) } : void 0,
|
|
422
|
-
viewportLabel: "表格内容",
|
|
423
|
-
children: Ze
|
|
424
|
-
}) : Ze
|
|
425
|
-
}), w ? /* @__PURE__ */ m("div", {
|
|
426
|
-
className: "vl-table__loading",
|
|
427
|
-
role: "status",
|
|
428
|
-
"aria-live": "polite",
|
|
429
|
-
"aria-label": "数据加载中",
|
|
430
|
-
children: ce ?? /* @__PURE__ */ m("span", { className: "vl-table__loading-spinner" })
|
|
431
|
-
}) : null]
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
var v = c(_);
|
|
435
|
-
v.displayName = "VlTable";
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region components/Table/index.ts
|
|
438
|
-
var y = v, b = v;
|
|
439
|
-
//#endregion
|
|
440
|
-
export { y as n, b as t };
|
package/dist/Table-Bqjey5fw.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./number-B7qJF_ZY.cjs"),r=require("./Scrollbar-CEQT6Ao_.cjs"),i=require("./Tooltip-CP8rpNYG.cjs");let a=require("lucide-react"),o=require("react"),s=require("react/jsx-runtime");var c=(e,t)=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),l=(e,t)=>{let n=[...new Set(e)];return t===`radio`?n.slice(0,1):n},u=({type:t,checked:n,disabled:r=!1,indeterminate:i=!1,ariaLabel:a,onChange:c})=>{let l=(0,o.useRef)(null);e.t(()=>{l.current&&(l.current.indeterminate=t===`checkbox`&&i)},[i,t]);let u=e=>e.stopPropagation();return(0,s.jsxs)(`label`,{className:[`vl-table__selection-control`,`is-${t}`,n?`is-checked`:``,i?`is-indeterminate`:``,r?`is-disabled`:``].filter(Boolean).join(` `),onClick:u,onDoubleClick:u,children:[(0,s.jsx)(`input`,{ref:l,className:`vl-table__selection-input`,type:t,checked:n,disabled:r,"aria-label":a,onChange:c}),(0,s.jsx)(`span`,{className:`vl-table__selection-indicator`,"aria-hidden":`true`})]})},ee=({content:t,tooltipContent:n,showTooltip:r})=>{let a=(0,o.useRef)(null),[c,l]=(0,o.useState)(!1),u=(0,o.useCallback)(()=>{let e=a.current;e&&l(e.scrollWidth>e.clientWidth)},[]);e.t(()=>{u();let e=a.current,t=typeof ResizeObserver>`u`?null:new ResizeObserver(u);return e&&t?.observe(e),window.addEventListener(`resize`,u,{passive:!0}),()=>{t?.disconnect(),window.removeEventListener(`resize`,u)}},[t,u]);let ee=(0,s.jsx)(`span`,{ref:a,className:`vl-table__ellipsis-content`,tabIndex:c&&r?0:void 0,children:t});return(0,s.jsx)(i.t,{className:`vl-table__ellipsis-tooltip`,content:n,disabled:!c||!r,children:ee})};function d(i,d){let{data:f,columns:p,rowKey:m,size:h=`md`,bordered:te=!0,striped:ne=!1,highlightCurrentRow:g=!1,showHeader:_=!0,emptyText:re=`暂无数据`,maxHeight:v,loading:y=!1,caption:b,emptyContent:ie,loadingContent:ae,tableLayout:oe,sortState:se,defaultSortState:ce=null,rowSelection:x,currentRowKey:le,defaultCurrentRowKey:ue=null,className:S,style:de,onRowClick:fe,onRowDoubleClick:pe,onCellClick:me,onSortChange:he,onCurrentRowChange:ge,..._e}=i,ve=t.t(i,`sortState`),C=t.t(i,`currentRowKey`),w=!!(x&&t.t(x,`selectedRowKeys`)),T=x?.type??`checkbox`,E=x?.preserveSelectedRowKeys??!1,ye=x?.columnWidth??48,D=v!=null,[O,be]=t.n({value:se??null,defaultValue:ce,controlled:ve}),[k,A]=t.n({value:le??null,defaultValue:ue,controlled:C}),[j,M]=t.n({value:x?.selectedRowKeys??[],defaultValue:l(x?.defaultSelectedRowKeys??[],T),controlled:w}),N=(0,o.useRef)(null),P=(0,o.useRef)([]),F=(0,o.useRef)(new Map),[I,xe]=(0,o.useState)([]),[L,Se]=(0,o.useState)(!1),R=(0,o.useMemo)(()=>l(j,T),[j,T]),z=(0,o.useMemo)(()=>new Set(R),[R]),B=(0,o.useCallback)(e=>typeof m==`function`?m(e):e[m],[m]),V=(0,o.useMemo)(()=>{let e=new Map;return f.forEach(t=>e.set(B(t),t)),e},[f,B]),Ce=(0,o.useMemo)(()=>{if(!O)return f;let e=p.find(e=>e.key===O.columnKey);if(!e||typeof e.sorter!=`function`)return f;let t=e.sorter,n=O.order===`asc`?1:-1;return f.map((e,t)=>({row:e,index:t})).sort((e,r)=>t(e.row,r.row)*n||e.index-r.index).map(({row:e})=>e)},[p,f,O]),H=(0,o.useMemo)(()=>Ce.map((e,t)=>({row:e,index:t,key:B(e),controlProps:x?.getControlProps?.(e,t)??{}})),[B,x,Ce]);(0,o.useEffect)(()=>{if(E){V.forEach((e,t)=>F.current.set(t,e));return}F.current=new Map(V)},[V,E]),(0,o.useEffect)(()=>{if(!x||w)return;let e=l(E?R:R.filter(e=>V.has(e)),T);c(R,e)||M(e)},[V,E,x,R,w,T,M]),(0,o.useEffect)(()=>{C||k===null||V.has(k)||A(null)},[C,k,V,A]);let U=(0,o.useMemo)(()=>H.filter(({controlProps:e})=>!e.disabled),[H]),W=U.length>0&&U.every(({key:e})=>z.has(e)),we=!W&&U.some(({key:e})=>z.has(e)),G=(0,o.useMemo)(()=>[...x?[{width:ye,fixed:x.fixed?`left`:void 0}]:[],...p],[p,x,ye]),K=+!!x,Te=(0,o.useMemo)(()=>{let e=-1;return G.forEach((t,n)=>{t.fixed===`left`&&(e=n)}),e},[G]),Ee=(0,o.useMemo)(()=>G.findIndex(e=>e.fixed===`right`),[G]),De=G.some(e=>e.fixed!==void 0),q=D||De,J=(0,o.useCallback)(e=>{let t=e.width??e.minWidth;return typeof t==`number`&&Number.isFinite(t)?Math.max(0,t):typeof t==`string`&&/^\d+(?:\.\d+)?px$/.test(t.trim())?Number.parseFloat(t):0},[]),Y=(0,o.useCallback)(()=>{let e=G.map((e,t)=>{let n=P.current[t]?.getBoundingClientRect().width??0;return n>0?n:J(e)}),t=G.map(()=>({})),n=0;G.forEach((r,i)=>{r.fixed===`left`&&(t[i].left=n,n+=e[i])});let r=0;for(let n=G.length-1;n>=0;--n)G[n].fixed===`right`&&(t[n].right=r,r+=e[n]);let i=N.current?.querySelector(`.vl-scrollbar__viewport`)?.clientWidth??0,a=i>0?i:N.current?.clientWidth??0;Se(a>0&&n+r>a),xe(e=>e.length===t.length&&e.every((e,n)=>Object.is(e.left,t[n].left)&&Object.is(e.right,t[n].right))?e:t)},[J,G]);e.t(()=>{P.current.length=G.length,Y();let e=typeof ResizeObserver>`u`?null:new ResizeObserver(Y);return P.current.forEach(t=>{t&&e?.observe(t)}),window.addEventListener(`resize`,Y,{passive:!0}),()=>{e?.disconnect(),window.removeEventListener(`resize`,Y)}},[G,H.length,_,Y]);let Oe=(0,o.useMemo)(()=>[`vl-table`,`size-${h}`,te?`is-bordered`:``,ne?`is-striped`:``,y?`is-loading`:``,x?`has-row-selection`:``,D?`has-sticky-header`:``,q?`has-custom-scrollbar`:``,S||``].filter(Boolean).join(` `),[te,S,D,y,x,h,ne,q]),ke=(0,o.useMemo)(()=>D?q?{maxHeight:n.n(v),overflow:`visible`}:{maxHeight:n.n(v),overflowY:`auto`}:{},[D,v,q]),Ae=[`vl-table__wrapper`,q?`is-custom-scrollbar`:``,D?`is-sticky-scrollbar`:``].filter(Boolean).join(` `),je=oe??(p.some(e=>e.ellipsis)?`fixed`:`auto`),Me=(0,o.useMemo)(()=>{let e=G.map(J);return e.length>0&&e.every(e=>e>0)?e.reduce((e,t)=>e+t,0):0},[J,G]),Ne=e=>{let t={};return e.width!==void 0&&(t.width=n.n(e.width)),e.minWidth!==void 0&&(t.minWidth=n.n(e.minWidth)),t},X=(e,t,r,i=`left`)=>{let a={textAlign:i};return e.width!==void 0&&(a.width=n.n(e.width)),e.minWidth!==void 0&&(a.minWidth=n.n(e.minWidth)),r&&D&&(a.position=`sticky`,a.top=0,a.zIndex=e.fixed?5:4),!e.fixed||e.fixed===`right`&&L?a:(a.position=`sticky`,a.zIndex=r?5:2,e.fixed===`left`?a.left=I[t]?.left??0:a.right=I[t]?.right??0,a)},Z=(e,t)=>{let n=e.fixed===`right`&&L?void 0:e.fixed;return[n?`is-fixed is-fixed-${n}`:``,n===`left`&&t===Te?`is-fixed-edge-left`:``,n===`right`&&t===Ee?`is-fixed-edge-right`:``]},Pe=(e,t)=>[`vl-table__header-cell`,e.headerClass||``,e.sorter?`is-sortable`:``,O?.columnKey===e.key?`is-sorted`:``,...Z(e,t)].filter(Boolean).join(` `),Fe=(e,t)=>[`vl-table__cell`,e.cellClass||``,e.ellipsis?`is-ellipsis`:``,...Z(e,t)].filter(Boolean).join(` `),Ie=e=>{let t=G[0];return[e?`vl-table__header-cell`:`vl-table__cell`,`vl-table__selection-cell`,...Z(t,0)].filter(Boolean).join(` `)},Le=e=>[`vl-table__sort-icons`,O?.columnKey===e.key&&O.order===`asc`?`is-asc`:``,O?.columnKey===e.key&&O.order===`desc`?`is-desc`:``].filter(Boolean).join(` `),Q=e=>{if(!x)return;let t=l(e,T);M(t);let n=E?F.current:V,r=t.map(e=>V.get(e)??n.get(e)).filter(e=>e!==void 0);x.onChange?.(t,r)},Re=e=>{if(T===`radio`){z.has(e)||Q([e]);return}Q(z.has(e)?R.filter(t=>!Object.is(t,e)):[...R,e])},ze=()=>{let e=U.map(({key:e})=>e),t=new Set(e);if(W){Q(R.filter(e=>!t.has(e)));return}Q([...R,...e.filter(e=>!z.has(e))])},Be=e=>{if(!e.sorter)return;let t={columnKey:e.key,order:`asc`};O?.columnKey===e.key&&(t=O.order===`asc`?{columnKey:e.key,order:`desc`}:null),be(t),he?.(t,e)},Ve=(e,t)=>{if(g){let t=B(e);A(t),Object.is(k,t)||ge?.(t,e)}fe?.(e,t)},He=(e,t,n)=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Ve(t,n))},Ue=e=>{if(e.sorter)return O?.columnKey===e.key?O.order===`asc`?`ascending`:`descending`:`none`},We=(e,t,n)=>{let r=t.render?t.render(e,n):e[t.key];if(!t.ellipsis)return r;let i=typeof t.ellipsis!=`object`||t.ellipsis.tooltip,a=i!==!1,o=typeof i==`function`?i(e,n):r;return(0,s.jsx)(ee,{content:r,tooltipContent:o,showTooltip:a})},$=(0,s.jsxs)(`table`,{className:`vl-table__inner`,style:{tableLayout:je,minWidth:Me||void 0},children:[b?(0,s.jsx)(`caption`,{className:`vl-table__caption`,children:b}):null,(0,s.jsx)(`colgroup`,{children:G.map((e,t)=>(0,s.jsx)(`col`,{style:Ne(e)},x&&t===0?`selection`:p[t-K].key))}),_?(0,s.jsx)(`thead`,{className:`vl-table__header`,children:(0,s.jsxs)(`tr`,{children:[x?(0,s.jsx)(`th`,{ref:e=>{P.current[0]=e},className:Ie(!0),style:X(G[0],0,!0,`center`),scope:`col`,"aria-label":`行选择`,children:T===`checkbox`?(0,s.jsx)(u,{type:`checkbox`,checked:W,indeterminate:we,disabled:U.length===0,ariaLabel:`选择全部行`,onChange:ze}):null}):null,p.map((e,t)=>{let n=t+K;return(0,s.jsx)(`th`,{ref:e=>{P.current[n]=e},className:Pe(e,n),style:X(e,n,!0,e.align||`left`),scope:`col`,"aria-sort":Ue(e),children:e.sorter?(0,s.jsxs)(`button`,{type:`button`,className:`vl-table__sort-button`,onClick:()=>Be(e),children:[(0,s.jsx)(`span`,{children:e.title}),(0,s.jsxs)(`span`,{className:Le(e),children:[(0,s.jsx)(a.ChevronUp,{className:`vl-table__sort-icon--asc`,size:14,"aria-hidden":`true`}),(0,s.jsx)(a.ChevronDown,{className:`vl-table__sort-icon--desc`,size:14,"aria-hidden":`true`})]})]}):(0,s.jsx)(`span`,{className:`vl-table__header-cell-content`,children:e.title})},e.key)})]})}):null,(0,s.jsx)(`tbody`,{className:`vl-table__body`,children:H.length>0?H.map(({row:e,index:t,key:n,controlProps:r})=>{let i=z.has(n),a=g&&Object.is(k,n),o=x?i:g?a:void 0;return(0,s.jsxs)(`tr`,{className:[`vl-table__row`,i?`is-selected`:``,a?`is-current`:``].filter(Boolean).join(` `),tabIndex:fe||g?0:void 0,"aria-selected":o,onClick:()=>Ve(e,t),onDoubleClick:()=>pe?.(e,t),onKeyDown:n=>He(n,e,t),children:[x?(0,s.jsx)(`td`,{ref:e=>{!_&&t===0&&(P.current[0]=e)},className:Ie(!1),style:X(G[0],0,!1,`center`),onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:(0,s.jsx)(u,{type:T,checked:i,disabled:r.disabled,ariaLabel:r[`aria-label`]??`选择第 ${t+1} 行`,onChange:()=>Re(n)})}):null,p.map((n,r)=>{let i=r+K;return(0,s.jsx)(`td`,{ref:e=>{!_&&t===0&&(P.current[i]=e)},className:Fe(n,i),style:X(n,i,!1,n.align||`left`),onClick:()=>me?.(e,n,t),children:We(e,n,t)},n.key)})]},n)}):(0,s.jsx)(`tr`,{className:`vl-table__empty-row`,children:(0,s.jsx)(`td`,{className:`vl-table__empty-cell`,colSpan:G.length,children:ie??re})})})]});return(0,s.jsxs)(`div`,{ref:d,className:Oe,style:de,"aria-busy":y||void 0,..._e,children:[(0,s.jsx)(`div`,{ref:N,className:Ae,style:ke,children:q?(0,s.jsx)(r.t,{className:`vl-table__scrollbar`,orientation:D?`both`:`horizontal`,style:D?{"--vl-table-scrollbar-max-height":n.n(v)}:void 0,viewportLabel:`表格内容`,children:$}):$}),y?(0,s.jsx)(`div`,{className:`vl-table__loading`,role:`status`,"aria-live":`polite`,"aria-label":`数据加载中`,children:ae??(0,s.jsx)(`span`,{className:`vl-table__loading-spinner`})}):null]})}var f=(0,o.forwardRef)(d);f.displayName=`VlTable`;var p=f,m=f;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
|
package/dist/Upload-bxJz2avf.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./state-ZBA75xZ_.cjs"),t=require("./content-DCGQZQp8.cjs"),n=require("./number-B7qJF_ZY.cjs"),r=require("./id-CF0zOP1G.cjs");let i=require("lucide-react"),a=require("react"),o=require("react/jsx-runtime");var s=[],c=0,l=()=>`vl-upload-${++c}`,u=e=>({uid:l(),name:e.name,size:e.size,type:e.type,status:`ready`,file:e}),d=e=>(e.file?.type??e.type??``).startsWith(`image/`),f=(0,a.forwardRef)((c,l)=>{let{value:f,defaultValue:p=s,accept:m,multiple:h=!1,disabled:g=!1,drag:_=!1,maxCount:v,listType:y=`text`,showFileList:b=!0,uploadText:x=`选择文件`,tip:S,beforeUpload:C,onChange:w,onRemove:T,onPreview:E,onExceed:D,id:O,"aria-describedby":k,"aria-labelledby":A,"aria-invalid":j,"aria-busy":M,className:ee,children:te,...ne}=c,N=(0,a.useRef)(null),P=r.t(`vl-upload`,O),F=r.t(`vl-upload-tip`),I=e.t(c,`value`),[L,R]=e.n({value:f??s,defaultValue:p,controlled:I,onChange:w}),[z,B]=(0,a.useState)(!1),[V,H]=(0,a.useState)(``),U=(0,a.useRef)(L),W=(0,a.useRef)(L);W.current!==L&&(U.current=L,W.current=L);let G=(e,t)=>{U.current=e,W.current=e,R(e),t&&H(t)},K=async e=>{if(e.length===0)return;let t=U.current,n=h?v===void 0?e.length:Math.max(0,v-t.length):1,r=e.slice(0,n);if(r.length<e.length&&D?.(e.slice(r.length),t),r.length===0)return;let i=[];for(let e of r){if(C){let t;try{t=!!await C(e,r)}catch{t=!1}if(!t)continue}i.push(u(e))}if(i.length===0)return;let a=h?U.current:s,o=h&&v!==void 0?Math.max(0,v-a.length):i.length,c=i.slice(0,o);if(c.length<i.length){let e=i.slice(c.length).map(e=>e.file).filter(e=>e!==void 0);e.length>0&&D?.(e,a)}if(c.length===0)return;let l=c.map(e=>e.name).join(`、`);G([...a,...c],`已添加 ${l}`)},q=(0,a.useRef)(Promise.resolve()),J=e=>{g||e.length===0||(q.current=q.current.then(()=>K(e)).catch(()=>void 0))},Y=h&&v!==void 0&&L.length>=v,X=g||Y,re=()=>{X||N.current?.click()},ie=e=>{J(Array.from(e.target.files??[])),e.target.value=``},Z=(0,a.useRef)(0),ae=e=>{e.preventDefault(),Z.current+=1,g||B(!0)},oe=()=>{Z.current=Math.max(0,Z.current-1),Z.current===0&&B(!1)},se=e=>{e.preventDefault(),Z.current=0,B(!1),J(Array.from(e.dataTransfer.files))},ce=(e,t)=>{e.stopPropagation();let n=U.current.filter(e=>e.uid!==t.uid);G(n,`已移除 ${t.name}`),T?.(t,n)},le=[`vl-upload`,_?`is-drag`:``,z?`is-dragover`:``,g?`is-disabled`:``,Y?`is-full`:``,y===`picture`?`list-picture`:``,ee||``].filter(Boolean).join(` `),Q=t.t(S),$=[k,Q?F:void 0].filter(Boolean).join(` `)||void 0,ue=e=>y===`picture`?e.url?(0,o.jsx)(`img`,{src:e.url,alt:``,className:`vl-upload__thumbnail`}):d(e)?(0,o.jsx)(i.FileImage,{"aria-hidden":`true`}):(0,o.jsx)(i.File,{"aria-hidden":`true`}):(0,o.jsx)(i.Paperclip,{"aria-hidden":`true`}),de=te??(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.UploadCloud,{className:`vl-upload__icon`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{className:`vl-upload__text`,children:x})]});return(0,o.jsxs)(`div`,{ref:l,className:le,..._?{onDragEnter:ae,onDragOver:e=>e.preventDefault(),onDragLeave:oe,onDrop:se}:void 0,...ne,children:[(0,o.jsx)(`input`,{ref:N,className:`vl-upload__input`,type:`file`,accept:m,multiple:h,disabled:g,tabIndex:-1,"aria-hidden":`true`,onChange:ie}),(0,o.jsx)(`button`,{type:`button`,id:P,className:`vl-upload__trigger`,disabled:X,"aria-describedby":$,"aria-labelledby":A,"aria-invalid":j,"aria-busy":M,onClick:re,children:de}),Q?(0,o.jsx)(`div`,{id:F,className:`vl-upload__tip`,children:S}):null,(0,o.jsx)(`div`,{className:`vl-upload__status`,role:`status`,"aria-live":`polite`,children:V}),b&&L.length>0?(0,o.jsx)(`ul`,{className:`vl-upload__list`,children:L.map(e=>(0,o.jsxs)(`li`,{className:`vl-upload__item is-${e.status??`ready`}`,children:[ue(e),E?(0,o.jsx)(`button`,{type:`button`,className:`vl-upload__name`,title:e.name,onClick:()=>E(e),children:e.name}):(0,o.jsx)(`span`,{className:`vl-upload__name is-static`,title:e.name,children:e.name}),e.status===`error`&&e.error?(0,o.jsx)(`span`,{className:`vl-upload__error`,children:e.error}):null,(0,o.jsx)(`button`,{type:`button`,className:`vl-upload__remove`,"aria-label":`移除 ${e.name}`,onClick:t=>ce(t,e),children:(0,o.jsx)(i.Trash2,{"aria-hidden":`true`})}),e.status===`uploading`&&typeof e.percent==`number`?(0,o.jsx)(`div`,{className:`vl-upload__progress`,role:`progressbar`,"aria-valuenow":n.t(Math.round(e.percent),0,100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${e.name} 上传进度`,children:(0,o.jsx)(`div`,{className:`vl-upload__progress-bar`,style:{width:`${n.t(e.percent,0,100)}%`}})}):null]},e.uid))}):null]})});f.displayName=`VlUpload`;var p=f,m=f;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
|