@vavt/react-ui 1.3.0 → 1.4.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/dist/{Col-CZjR94ac.js → Col-BZdKuXbj.js} +1 -1
- package/dist/{Col-qcq7T83y.cjs → Col-CvoVGKUn.cjs} +1 -1
- package/dist/{Cron-C3S1XI-J.js → Cron-HRBggBRO.js} +352 -344
- package/dist/Cron-vQ7RSsws.cjs +1 -0
- package/dist/{DatePicker-DhRxFPCj.js → DatePicker-B0f4Nh8h.js} +1 -1
- package/dist/{DatePicker-B5uYQlzy.cjs → DatePicker-DFTqHT8i.cjs} +1 -1
- package/dist/{DateTimePicker-BjDD15Av.js → DateTimePicker-BzkWgjkq.js} +1 -1
- package/dist/{DateTimePicker-Bve5qoeh.cjs → DateTimePicker-McwH-cWl.cjs} +1 -1
- package/dist/Dropdown-Chx8SZPS.cjs +1 -0
- package/dist/Dropdown-CyVxoFAH.js +330 -0
- package/dist/Form-CyCbST4e.cjs +1 -0
- package/dist/Form-Fe4b1pS1.js +446 -0
- package/dist/Input-BbJ4Q_xu.cjs +1 -0
- package/dist/Input-DpoSxIdb.js +113 -0
- package/dist/{Pagination-DTRhw83o.js → Pagination-BrG1pKYw.js} +1 -1
- package/dist/{Pagination-BRxRbWlU.cjs → Pagination-D3ok8N9k.cjs} +1 -1
- package/dist/Row-BGzLSkCy.js +24 -0
- package/dist/Row-CRQKzpiH.cjs +1 -0
- package/dist/Select-GleCzXQB.js +497 -0
- package/dist/Select-Rx6AHue2.cjs +1 -0
- package/dist/Sidebar-2KVVRUEM.cjs +1 -0
- package/dist/Sidebar-ByLinOVm.js +77 -0
- package/dist/{Table-DdWKhZAZ.js → Table-ClWg25Wn.js} +10 -7
- package/dist/{Table-B1BEfBJC.cjs → Table-Dv2qxs8q.cjs} +1 -1
- package/dist/TimePicker-BCU7D6uD.cjs +1 -0
- package/dist/{TimePicker-77L1Vyxn.js → TimePicker-BVZbkBvJ.js} +89 -81
- package/dist/Tooltip-BbbIT5nt.js +198 -0
- package/dist/Tooltip-z6u7ChKj.cjs +1 -0
- package/dist/base.css +1 -1
- package/dist/cjs/Col.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/Dropdown.cjs +1 -1
- package/dist/cjs/Form.cjs +1 -1
- package/dist/cjs/Input.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Row.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Sidebar.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.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/Button.css +1 -1
- package/dist/css/Checkbox.css +1 -1
- package/dist/css/Input.css +1 -1
- package/dist/css/Radio.css +1 -1
- package/dist/css/Sidebar.css +1 -1
- package/dist/css/Switch.css +1 -1
- package/dist/date-picker-BKXFZDN2.js +639 -0
- package/dist/date-picker-Dp0BXURF.cjs +1 -0
- package/dist/es/Col.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/Dropdown.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/Input.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Row.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Sidebar.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +14 -14
- package/dist/es/register.mjs +1 -1
- package/dist/floating-BpTI3sWS.cjs +1 -0
- package/dist/{floating-CqdcJWk2.js → floating-BqCWEj83.js} +27 -15
- package/dist/index.css +1 -1
- package/dist/{registry-DbMCy1-n.js → registry-BXGVMimF.js} +13 -13
- package/dist/{registry-Chcx2tDO.cjs → registry-C-Mo3vuy.cjs} +1 -1
- package/dist/style/Sidebar.cjs +1 -0
- package/dist/style/Sidebar.mjs +1 -0
- package/dist/types/Form/type.d.cts +2 -0
- package/dist/types/Form/type.d.ts +2 -0
- package/dist/types/Input/type.d.cts +4 -2
- package/dist/types/Input/type.d.ts +4 -2
- package/dist/types/Select/SelectList.d.cts +20 -0
- package/dist/types/Select/SelectList.d.ts +20 -0
- package/dist/types/_shared/date-calendar.d.cts +20 -0
- package/dist/types/_shared/date-calendar.d.ts +20 -0
- package/dist/types/_shared/floating.d.cts +13 -1
- package/dist/types/_shared/floating.d.ts +13 -1
- package/package.json +1 -1
- package/dist/Cron-CIZ9GKm0.cjs +0 -1
- package/dist/Dropdown-BcT4uaQT.js +0 -319
- package/dist/Dropdown-CPW-aSTx.cjs +0 -1
- package/dist/Form-LuUPwJc2.cjs +0 -1
- package/dist/Form-rXq9r3N-.js +0 -442
- package/dist/Input-BRy5Xuwy.js +0 -104
- package/dist/Input-C9ESmbJ7.cjs +0 -1
- package/dist/Row-BJZtEKxG.cjs +0 -1
- package/dist/Row-DpEse7PJ.js +0 -24
- package/dist/Select-B9umyfKd.cjs +0 -1
- package/dist/Select-DDsgKaDL.js +0 -466
- package/dist/Sidebar-BPXVnP7y.cjs +0 -1
- package/dist/Sidebar-u980T-QB.js +0 -76
- package/dist/TimePicker-CsaiM5CQ.cjs +0 -1
- package/dist/Tooltip-DH3oc4Wa.js +0 -205
- package/dist/Tooltip-DP2yxQpo.cjs +0 -1
- package/dist/date-picker-CIAVlMqv.cjs +0 -1
- package/dist/date-picker-Co0ySn01.js +0 -612
- package/dist/floating-5PRFyI8D.cjs +0 -1
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { t as e } from "./icon-Cbvuv4yF.js";
|
|
2
|
+
import { t } from "./effect-nifYL_rH.js";
|
|
3
|
+
import { n, t as r } from "./state-BSDh-Ob2.js";
|
|
4
|
+
import { n as i } from "./refs-D5IYOBaf.js";
|
|
5
|
+
import { t as ee } from "./Transition-DiO4GsP3.js";
|
|
6
|
+
import { t as a } from "./client-pj_wzx28.js";
|
|
7
|
+
import { i as o, r as s, t as c } from "./floating-BqCWEj83.js";
|
|
8
|
+
import { t as te } from "./id-CHixuHb7.js";
|
|
9
|
+
import { a as ne, r as re, t as ie } from "./layer-C1yCY0MO.js";
|
|
10
|
+
import { ChevronDown as ae, LoaderCircle as oe, X as se } from "lucide-react";
|
|
11
|
+
import { forwardRef as l, memo as u, useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
12
|
+
import { Fragment as ce, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
|
+
import { createPortal as le } from "react-dom";
|
|
14
|
+
//#region components/Select/SelectList.tsx
|
|
15
|
+
var v = u(function({ option: t, index: n, id: r, selected: i, active: ee, registerOption: a, onSelect: o, onActive: s, renderOption: c }) {
|
|
16
|
+
let te = d((e) => a(n, e), [n, a]), ne = [
|
|
17
|
+
"vl-select__option",
|
|
18
|
+
t.disabled ? "is-disabled" : "",
|
|
19
|
+
i ? "is-selected" : "",
|
|
20
|
+
ee ? "is-active" : ""
|
|
21
|
+
].filter(Boolean).join(" ");
|
|
22
|
+
return /* @__PURE__ */ g("div", {
|
|
23
|
+
ref: te,
|
|
24
|
+
id: r,
|
|
25
|
+
className: ne,
|
|
26
|
+
role: "option",
|
|
27
|
+
"aria-disabled": t.disabled || void 0,
|
|
28
|
+
"aria-selected": i,
|
|
29
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
30
|
+
onMouseEnter: () => {
|
|
31
|
+
t.disabled || s(n);
|
|
32
|
+
},
|
|
33
|
+
onClick: () => o(t),
|
|
34
|
+
children: c ? c(t, n, i) : /* @__PURE__ */ _(ce, { children: [t.icon ? e(t.icon, "vl-select__option-icon") : null, /* @__PURE__ */ g("span", {
|
|
35
|
+
className: "vl-select__option-label",
|
|
36
|
+
children: t.label
|
|
37
|
+
})] })
|
|
38
|
+
});
|
|
39
|
+
}), ue = u(function({ options: e, activeIndex: t, isSelected: n, getOptionId: r, registerOption: i, onSelect: ee, onActive: a, renderOption: o, emptyText: s, emptyContent: c }) {
|
|
40
|
+
return e.some((e) => !e.divider) ? /* @__PURE__ */ g("div", {
|
|
41
|
+
className: "vl-select__list",
|
|
42
|
+
children: e.map((e, s) => e.divider ? /* @__PURE__ */ g("div", {
|
|
43
|
+
className: "vl-select__divider",
|
|
44
|
+
role: "separator"
|
|
45
|
+
}, `divider-${s}`) : /* @__PURE__ */ g(v, {
|
|
46
|
+
option: e,
|
|
47
|
+
index: s,
|
|
48
|
+
id: r(s),
|
|
49
|
+
selected: n(e),
|
|
50
|
+
active: t === s,
|
|
51
|
+
registerOption: i,
|
|
52
|
+
onSelect: ee,
|
|
53
|
+
onActive: a,
|
|
54
|
+
renderOption: o
|
|
55
|
+
}, `option-${typeof e.value}-${String(e.value)}`))
|
|
56
|
+
}) : /* @__PURE__ */ g("div", {
|
|
57
|
+
className: "vl-select__empty",
|
|
58
|
+
role: "status",
|
|
59
|
+
children: c ?? s
|
|
60
|
+
});
|
|
61
|
+
}), de = [], y = (e) => !!(e && !e.disabled && !e.divider), b = l((e, l) => {
|
|
62
|
+
let { value: u, defaultValue: ce, options: v = de, placeholder: b = "请选择", filterable: fe = !1, filterPlaceholder: pe = "搜索", multiple: me = !1, taggable: x = !1, maxTagCount: S, disabled: C = !1, loading: w = !1, size: he = "md", clearable: ge = !1, placement: T = "bottom-start", offset: _e = 8, zIndex: ve, emptyText: ye = "暂无数据", renderOption: be, emptyContent: xe, className: Se, style: Ce, onChange: we, onClear: Te, onOpen: Ee, onClose: De, onFocus: Oe, onBlur: ke, id: Ae, "aria-label": je, "aria-labelledby": Me, "aria-describedby": Ne, tabIndex: Pe, ...Fe } = e, Ie = m(null), Le = m(null), Re = m(null), ze = m(null), Be = m([]), Ve = d((e, t) => {
|
|
63
|
+
Be.current[e] = t;
|
|
64
|
+
}, []), He = p(() => i(Ie, l), [l]), E = a(), Ue = ne({
|
|
65
|
+
defaultZIndex: re.dropdown,
|
|
66
|
+
zIndex: ve
|
|
67
|
+
}), D = fe || x, O = me || x, We = p(() => O ? [] : null, [O]), Ge = r(e, "value"), k = m(void 0), [A, Ke] = n({
|
|
68
|
+
value: u ?? We,
|
|
69
|
+
defaultValue: ce ?? We,
|
|
70
|
+
controlled: Ge,
|
|
71
|
+
onChange: (e) => {
|
|
72
|
+
let t = k.current;
|
|
73
|
+
k.current = void 0, we?.(e, t);
|
|
74
|
+
}
|
|
75
|
+
}), [j, qe] = h(!1), [Je, Ye] = h(!1), [M, N] = h(""), [Xe, P] = h([]), [{ style: Ze, placement: Qe }, $e] = o(T), [F, I] = h(-1), et = te("vl-select-control", Ae), L = te("vl-select-listbox"), tt = d((e) => `${L}-option-${e}`, [L]), nt = p(() => ["vl-select-wrapper", Se || ""].filter(Boolean).join(" "), [Se]), rt = p(() => [
|
|
76
|
+
"vl-select",
|
|
77
|
+
`size-${he}`,
|
|
78
|
+
O ? "is-multiple" : "",
|
|
79
|
+
j ? "is-open" : "",
|
|
80
|
+
Je ? "is-focus-within" : "",
|
|
81
|
+
C ? "is-disabled" : "",
|
|
82
|
+
w ? "is-loading" : ""
|
|
83
|
+
].filter(Boolean).join(" "), [
|
|
84
|
+
he,
|
|
85
|
+
O,
|
|
86
|
+
j,
|
|
87
|
+
Je,
|
|
88
|
+
C,
|
|
89
|
+
w
|
|
90
|
+
]), R = p(() => {
|
|
91
|
+
if (!x) return v;
|
|
92
|
+
let e = Xe.filter((e) => !v.some((t) => t.value === e.value));
|
|
93
|
+
return [...v, ...e];
|
|
94
|
+
}, [
|
|
95
|
+
v,
|
|
96
|
+
Xe,
|
|
97
|
+
x
|
|
98
|
+
]), z = p(() => {
|
|
99
|
+
if (!D || !j) return R;
|
|
100
|
+
let e = M.trim().toLocaleLowerCase();
|
|
101
|
+
return e ? R.filter((t) => !t.divider && t.label.toLocaleLowerCase().includes(e)) : R;
|
|
102
|
+
}, [
|
|
103
|
+
R,
|
|
104
|
+
D,
|
|
105
|
+
j,
|
|
106
|
+
M
|
|
107
|
+
]), B = p(() => z.flatMap((e, t) => y(e) ? [t] : []), [z]), V = p(() => O && Array.isArray(A) ? A : [], [O, A]), it = p(() => new Set(V), [V]), at = p(() => {
|
|
108
|
+
if (!(O || Array.isArray(A))) return R.find((e) => e.value === A);
|
|
109
|
+
}, [
|
|
110
|
+
R,
|
|
111
|
+
O,
|
|
112
|
+
A
|
|
113
|
+
]), H = p(() => O ? "" : at ? at.label : A === null || A === "" || Array.isArray(A) ? "" : String(A), [
|
|
114
|
+
O,
|
|
115
|
+
at,
|
|
116
|
+
A
|
|
117
|
+
]), U = p(() => V.map((e) => ({
|
|
118
|
+
value: e,
|
|
119
|
+
label: R.find((t) => t.value === e)?.label ?? String(e)
|
|
120
|
+
})), [V, R]), ot = p(() => !O || S === void 0 || !Number.isFinite(S) ? Infinity : Math.max(0, Math.floor(S)), [O, S]), st = ot === Infinity ? U : U.slice(0, ot), ct = Math.max(0, U.length - st.length), lt = O ? V.length > 0 : A !== null && A !== "" && !Array.isArray(A), ut = ge && !C && !w && lt, dt = F >= 0 && y(z[F]) ? tt(F) : void 0, ft = p(() => ["vl-select__panel", `is-${Qe}`].join(" "), [Qe]), W = d((e) => {
|
|
121
|
+
e && (C || w) || j !== e && (qe(e), e ? Ee?.() : De?.());
|
|
122
|
+
}, [
|
|
123
|
+
C,
|
|
124
|
+
w,
|
|
125
|
+
Ee,
|
|
126
|
+
De,
|
|
127
|
+
j
|
|
128
|
+
]), G = d((e) => O ? it.has(e.value) : e.value === A, [
|
|
129
|
+
O,
|
|
130
|
+
it,
|
|
131
|
+
A
|
|
132
|
+
]), K = d((e, t) => {
|
|
133
|
+
k.current = t, Ke(e), k.current = void 0;
|
|
134
|
+
}, [Ke]), q = d((e) => {
|
|
135
|
+
x && P((t) => t.filter((t) => e.includes(t.value)));
|
|
136
|
+
}, [x]), J = d((e) => {
|
|
137
|
+
if (y(e)) {
|
|
138
|
+
if (O) {
|
|
139
|
+
let t = V.includes(e.value) ? V.filter((t) => t !== e.value) : [...V, e.value];
|
|
140
|
+
K(t, e), q(t), N("");
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
K(e.value, e), N(e.label), W(!1);
|
|
144
|
+
}
|
|
145
|
+
}, [
|
|
146
|
+
O,
|
|
147
|
+
V,
|
|
148
|
+
K,
|
|
149
|
+
q,
|
|
150
|
+
W
|
|
151
|
+
]), pt = m(J);
|
|
152
|
+
t(() => {
|
|
153
|
+
pt.current = J;
|
|
154
|
+
}, [J]);
|
|
155
|
+
let mt = d((e) => pt.current(e), []), ht = d((e) => {
|
|
156
|
+
if (!x) return !1;
|
|
157
|
+
let t = e.trim();
|
|
158
|
+
if (!t) return !1;
|
|
159
|
+
let n = t.toLocaleLowerCase(), r = R.find((e) => e.label.toLocaleLowerCase() === n || String(e.value).toLocaleLowerCase() === n);
|
|
160
|
+
if (r) return G(r) ? N("") : J(r), !0;
|
|
161
|
+
let i = {
|
|
162
|
+
label: t,
|
|
163
|
+
value: t
|
|
164
|
+
};
|
|
165
|
+
return P((e) => [...e, i]), J(i), !0;
|
|
166
|
+
}, [
|
|
167
|
+
x,
|
|
168
|
+
R,
|
|
169
|
+
G,
|
|
170
|
+
J
|
|
171
|
+
]), Y = d(() => {
|
|
172
|
+
let e = z.findIndex((e) => y(e) && G(e));
|
|
173
|
+
return e >= 0 ? e : B[0] ?? -1;
|
|
174
|
+
}, [
|
|
175
|
+
z,
|
|
176
|
+
B,
|
|
177
|
+
G
|
|
178
|
+
]), X = d((e) => {
|
|
179
|
+
y(z[e]) && (I(e), Be.current[e]?.scrollIntoView?.({ block: "nearest" }));
|
|
180
|
+
}, [z]), gt = d((e) => {
|
|
181
|
+
if (!B.length) return;
|
|
182
|
+
let t = B.indexOf(F), n = (t >= 0 ? t + e : (e > 0 ? -1 : 0) + e + B.length) % B.length;
|
|
183
|
+
X(B[n]);
|
|
184
|
+
}, [
|
|
185
|
+
B,
|
|
186
|
+
F,
|
|
187
|
+
X
|
|
188
|
+
]), _t = d(() => {
|
|
189
|
+
let e = B[0];
|
|
190
|
+
e !== void 0 && X(e);
|
|
191
|
+
}, [B, X]), vt = d(() => {
|
|
192
|
+
let e = B.at(-1);
|
|
193
|
+
e !== void 0 && X(e);
|
|
194
|
+
}, [B, X]), Z = d(() => {
|
|
195
|
+
if (!j) return;
|
|
196
|
+
let e = Le.current, t = Re.current;
|
|
197
|
+
if (!e || !t) return;
|
|
198
|
+
let n = e.getBoundingClientRect(), r = c({
|
|
199
|
+
anchorRect: n,
|
|
200
|
+
floatingRect: t.getBoundingClientRect(),
|
|
201
|
+
placement: T,
|
|
202
|
+
offset: _e
|
|
203
|
+
});
|
|
204
|
+
$e({
|
|
205
|
+
placement: r.placement,
|
|
206
|
+
style: {
|
|
207
|
+
left: `${Math.round(r.x)}px`,
|
|
208
|
+
top: `${Math.round(r.y)}px`,
|
|
209
|
+
minWidth: `${Math.round(n.width)}px`
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}, [
|
|
213
|
+
j,
|
|
214
|
+
T,
|
|
215
|
+
_e,
|
|
216
|
+
$e
|
|
217
|
+
]), Q = d(() => {
|
|
218
|
+
D ? ze.current?.focus() : Le.current?.focus();
|
|
219
|
+
}, [D]), $ = d((e = "first") => {
|
|
220
|
+
if (C || w) return;
|
|
221
|
+
j || (D && N(""), W(!0));
|
|
222
|
+
let t = e === "last" ? B.at(-1) : Y();
|
|
223
|
+
t !== void 0 && t >= 0 && I(t), window.requestAnimationFrame(() => {
|
|
224
|
+
Q(), Z();
|
|
225
|
+
});
|
|
226
|
+
}, [
|
|
227
|
+
C,
|
|
228
|
+
w,
|
|
229
|
+
j,
|
|
230
|
+
D,
|
|
231
|
+
W,
|
|
232
|
+
B,
|
|
233
|
+
Y,
|
|
234
|
+
Q,
|
|
235
|
+
Z
|
|
236
|
+
]), yt = d(() => {
|
|
237
|
+
W(!1), window.requestAnimationFrame(Q);
|
|
238
|
+
}, [W, Q]), bt = d(() => {
|
|
239
|
+
let e = z[F];
|
|
240
|
+
return y(e) ? (J(e), !0) : !1;
|
|
241
|
+
}, [
|
|
242
|
+
z,
|
|
243
|
+
F,
|
|
244
|
+
J
|
|
245
|
+
]), xt = (e) => {
|
|
246
|
+
if (!(C || w) && !e.target.closest("button")) {
|
|
247
|
+
if (D) {
|
|
248
|
+
$();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
j ? W(!1) : $();
|
|
252
|
+
}
|
|
253
|
+
}, St = (e) => {
|
|
254
|
+
if (!(C || w)) {
|
|
255
|
+
if (e.key === "ArrowDown") {
|
|
256
|
+
e.preventDefault(), j ? gt(1) : $("first");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (e.key === "ArrowUp") {
|
|
260
|
+
e.preventDefault(), j ? gt(-1) : $("last");
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (e.key === "Home" && j && !D) {
|
|
264
|
+
e.preventDefault(), _t();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (e.key === "End" && j && !D) {
|
|
268
|
+
e.preventDefault(), vt();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (e.key === "Escape" && j) {
|
|
272
|
+
e.preventDefault(), yt();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (e.key === "Tab" && j) {
|
|
276
|
+
W(!1);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (e.key === "Enter") {
|
|
280
|
+
if (!j) {
|
|
281
|
+
e.preventDefault(), $();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
e.preventDefault(), !bt() && D && ht(M);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (e.key === " " && !D) {
|
|
288
|
+
e.preventDefault(), j ? bt() : $();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (e.key === "Backspace" && D && O && !M && V.length) {
|
|
292
|
+
let e = V.slice(0, -1);
|
|
293
|
+
K(e), q(e);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}, Ct = () => {
|
|
297
|
+
C || w || (K(O ? [] : null), Te?.(), N(""), q([]), W(!1), Q());
|
|
298
|
+
}, wt = (e) => {
|
|
299
|
+
if (C || w) return;
|
|
300
|
+
let t = V.filter((t) => t !== e);
|
|
301
|
+
K(t), q(t);
|
|
302
|
+
}, Tt = (e) => {
|
|
303
|
+
e.currentTarget.contains(e.relatedTarget) || (Ye(!0), Oe?.(e));
|
|
304
|
+
}, Et = (e) => {
|
|
305
|
+
e.currentTarget.contains(e.relatedTarget) || (Ye(!1), ke?.(e));
|
|
306
|
+
};
|
|
307
|
+
f(() => {
|
|
308
|
+
j || (N(O ? "" : H), I(-1));
|
|
309
|
+
}, [
|
|
310
|
+
j,
|
|
311
|
+
O,
|
|
312
|
+
H
|
|
313
|
+
]), f(() => {
|
|
314
|
+
if (!j || !E) return;
|
|
315
|
+
I(Y());
|
|
316
|
+
let e = window.requestAnimationFrame(Z);
|
|
317
|
+
return () => window.cancelAnimationFrame(e);
|
|
318
|
+
}, [
|
|
319
|
+
j,
|
|
320
|
+
E,
|
|
321
|
+
z,
|
|
322
|
+
Y,
|
|
323
|
+
Z
|
|
324
|
+
]), f(() => {
|
|
325
|
+
if (!x || !O) return;
|
|
326
|
+
let e = new Set(R.map((e) => e.value)), t = V.filter((t) => !e.has(t));
|
|
327
|
+
t.length && P((e) => [...e, ...t.map((e) => ({
|
|
328
|
+
label: String(e),
|
|
329
|
+
value: e
|
|
330
|
+
}))]);
|
|
331
|
+
}, [
|
|
332
|
+
x,
|
|
333
|
+
O,
|
|
334
|
+
R,
|
|
335
|
+
V
|
|
336
|
+
]), f(() => {
|
|
337
|
+
(C || w) && j && W(!1);
|
|
338
|
+
}, [
|
|
339
|
+
C,
|
|
340
|
+
w,
|
|
341
|
+
j,
|
|
342
|
+
W
|
|
343
|
+
]), s({
|
|
344
|
+
active: j && E,
|
|
345
|
+
rootRef: Ie,
|
|
346
|
+
floatingRef: Re,
|
|
347
|
+
onOutsideClick: () => W(!1),
|
|
348
|
+
onViewportChange: Z
|
|
349
|
+
});
|
|
350
|
+
let Dt = {
|
|
351
|
+
role: "combobox",
|
|
352
|
+
"aria-controls": L,
|
|
353
|
+
"aria-expanded": j,
|
|
354
|
+
"aria-haspopup": "listbox",
|
|
355
|
+
"aria-activedescendant": j ? dt : void 0,
|
|
356
|
+
"aria-disabled": C || w || void 0,
|
|
357
|
+
"aria-busy": w || void 0,
|
|
358
|
+
"aria-label": je ?? (Me ? void 0 : b),
|
|
359
|
+
"aria-labelledby": Me,
|
|
360
|
+
"aria-describedby": Ne
|
|
361
|
+
}, Ot = D ? /* @__PURE__ */ g("input", {
|
|
362
|
+
ref: ze,
|
|
363
|
+
id: et,
|
|
364
|
+
className: "vl-select__input",
|
|
365
|
+
type: "text",
|
|
366
|
+
value: M,
|
|
367
|
+
placeholder: j ? pe : O && V.length ? "" : b,
|
|
368
|
+
disabled: C || w,
|
|
369
|
+
autoComplete: "off",
|
|
370
|
+
"aria-autocomplete": "list",
|
|
371
|
+
...Dt,
|
|
372
|
+
tabIndex: Pe,
|
|
373
|
+
onChange: (e) => {
|
|
374
|
+
N(e.target.value), j || W(!0);
|
|
375
|
+
},
|
|
376
|
+
onFocus: () => {
|
|
377
|
+
j || $();
|
|
378
|
+
},
|
|
379
|
+
onKeyDown: St
|
|
380
|
+
}) : null, kt = /* @__PURE__ */ g(ee, {
|
|
381
|
+
show: j,
|
|
382
|
+
name: "vl-select",
|
|
383
|
+
deferEffects: !E,
|
|
384
|
+
children: /* @__PURE__ */ g("div", {
|
|
385
|
+
ref: Re,
|
|
386
|
+
id: L,
|
|
387
|
+
className: ft,
|
|
388
|
+
style: {
|
|
389
|
+
...Ze,
|
|
390
|
+
zIndex: Ue.zIndex
|
|
391
|
+
},
|
|
392
|
+
role: "listbox",
|
|
393
|
+
"aria-hidden": !j || void 0,
|
|
394
|
+
"aria-multiselectable": O || void 0,
|
|
395
|
+
children: /* @__PURE__ */ g(ue, {
|
|
396
|
+
options: z,
|
|
397
|
+
activeIndex: F,
|
|
398
|
+
isSelected: G,
|
|
399
|
+
getOptionId: tt,
|
|
400
|
+
registerOption: Ve,
|
|
401
|
+
onSelect: mt,
|
|
402
|
+
onActive: I,
|
|
403
|
+
renderOption: be,
|
|
404
|
+
emptyText: ye,
|
|
405
|
+
emptyContent: xe
|
|
406
|
+
})
|
|
407
|
+
})
|
|
408
|
+
});
|
|
409
|
+
return /* @__PURE__ */ g(ie, {
|
|
410
|
+
layer: Ue.layer,
|
|
411
|
+
children: /* @__PURE__ */ _("div", {
|
|
412
|
+
ref: He,
|
|
413
|
+
className: nt,
|
|
414
|
+
style: Ce,
|
|
415
|
+
...Fe,
|
|
416
|
+
children: [/* @__PURE__ */ _("div", {
|
|
417
|
+
ref: Le,
|
|
418
|
+
id: D ? void 0 : et,
|
|
419
|
+
className: rt,
|
|
420
|
+
...D ? {} : Dt,
|
|
421
|
+
tabIndex: C || w || D ? -1 : Pe ?? 0,
|
|
422
|
+
onClick: xt,
|
|
423
|
+
onKeyDown: D ? void 0 : St,
|
|
424
|
+
onFocus: Tt,
|
|
425
|
+
onBlur: Et,
|
|
426
|
+
children: [/* @__PURE__ */ g("div", {
|
|
427
|
+
className: "vl-select__value",
|
|
428
|
+
children: O ? /* @__PURE__ */ _("div", {
|
|
429
|
+
className: "vl-select__tags",
|
|
430
|
+
children: [
|
|
431
|
+
st.map((e) => /* @__PURE__ */ _("span", {
|
|
432
|
+
className: "vl-select__tag",
|
|
433
|
+
children: [/* @__PURE__ */ g("span", {
|
|
434
|
+
className: "vl-select__tag-label",
|
|
435
|
+
children: e.label
|
|
436
|
+
}), /* @__PURE__ */ g("button", {
|
|
437
|
+
type: "button",
|
|
438
|
+
className: "vl-select__tag-remove",
|
|
439
|
+
"aria-label": `移除 ${e.label}`,
|
|
440
|
+
disabled: C || w,
|
|
441
|
+
onClick: () => wt(e.value),
|
|
442
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
443
|
+
children: /* @__PURE__ */ g(se, {
|
|
444
|
+
size: 12,
|
|
445
|
+
"aria-hidden": "true"
|
|
446
|
+
})
|
|
447
|
+
})]
|
|
448
|
+
}, e.value)),
|
|
449
|
+
ct > 0 ? /* @__PURE__ */ _("span", {
|
|
450
|
+
className: "vl-select__tag is-collapsed",
|
|
451
|
+
"aria-label": `另有 ${ct} 项`,
|
|
452
|
+
children: ["+", ct]
|
|
453
|
+
}) : null,
|
|
454
|
+
D ? Ot : U.length ? null : /* @__PURE__ */ g("span", {
|
|
455
|
+
className: "vl-select__placeholder",
|
|
456
|
+
children: b
|
|
457
|
+
})
|
|
458
|
+
]
|
|
459
|
+
}) : D ? Ot : H ? /* @__PURE__ */ g("span", {
|
|
460
|
+
className: "vl-select__label",
|
|
461
|
+
children: H
|
|
462
|
+
}) : /* @__PURE__ */ g("span", {
|
|
463
|
+
className: "vl-select__placeholder",
|
|
464
|
+
children: b
|
|
465
|
+
})
|
|
466
|
+
}), /* @__PURE__ */ _("div", {
|
|
467
|
+
className: "vl-select__suffix",
|
|
468
|
+
children: [ut ? /* @__PURE__ */ g("button", {
|
|
469
|
+
type: "button",
|
|
470
|
+
className: "vl-select__clear",
|
|
471
|
+
"aria-label": "清除已选",
|
|
472
|
+
onClick: Ct,
|
|
473
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
474
|
+
children: /* @__PURE__ */ g(se, {
|
|
475
|
+
size: 16,
|
|
476
|
+
"aria-hidden": "true"
|
|
477
|
+
})
|
|
478
|
+
}) : null, w ? /* @__PURE__ */ g(oe, {
|
|
479
|
+
className: "vl-select__loading",
|
|
480
|
+
size: 16,
|
|
481
|
+
"aria-hidden": "true"
|
|
482
|
+
}) : /* @__PURE__ */ g("span", {
|
|
483
|
+
className: "vl-select__arrow",
|
|
484
|
+
"aria-hidden": "true",
|
|
485
|
+
children: /* @__PURE__ */ g(ae, { size: 16 })
|
|
486
|
+
})]
|
|
487
|
+
})]
|
|
488
|
+
}), E ? le(kt, document.body) : kt]
|
|
489
|
+
})
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
b.displayName = "VlSelect";
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region components/Select/index.ts
|
|
495
|
+
var fe = b, pe = b;
|
|
496
|
+
//#endregion
|
|
497
|
+
export { fe as n, pe as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./icon-DRLyKu8p.cjs"),t=require("./effect-BpNxm_06.cjs"),n=require("./state-BuUx1onZ.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./Transition-X_89ga-e.cjs"),a=require("./client-BkoqeUs3.cjs"),o=require("./floating-BpTI3sWS.cjs"),s=require("./id-CF0zOP1G.cjs"),c=require("./layer-DL1xVbJT.cjs");let l=require("lucide-react"),u=require("react"),d=require("react/jsx-runtime"),ee=require("react-dom");var f=(0,u.memo)(function({option:t,index:n,id:r,selected:i,active:a,registerOption:o,onSelect:s,onActive:c,renderOption:l}){let ee=(0,u.useCallback)(e=>o(n,e),[n,o]),f=[`vl-select__option`,t.disabled?`is-disabled`:``,i?`is-selected`:``,a?`is-active`:``].filter(Boolean).join(` `);return(0,d.jsx)(`div`,{ref:ee,id:r,className:f,role:`option`,"aria-disabled":t.disabled||void 0,"aria-selected":i,onPointerDown:e=>e.preventDefault(),onMouseEnter:()=>{t.disabled||c(n)},onClick:()=>s(t),children:l?l(t,n,i):(0,d.jsxs)(d.Fragment,{children:[t.icon?e.t(t.icon,`vl-select__option-icon`):null,(0,d.jsx)(`span`,{className:`vl-select__option-label`,children:t.label})]})})}),te=(0,u.memo)(function({options:e,activeIndex:t,isSelected:n,getOptionId:r,registerOption:i,onSelect:a,onActive:o,renderOption:s,emptyText:c,emptyContent:l}){return e.some(e=>!e.divider)?(0,d.jsx)(`div`,{className:`vl-select__list`,children:e.map((e,c)=>e.divider?(0,d.jsx)(`div`,{className:`vl-select__divider`,role:`separator`},`divider-${c}`):(0,d.jsx)(f,{option:e,index:c,id:r(c),selected:n(e),active:t===c,registerOption:i,onSelect:a,onActive:o,renderOption:s},`option-${typeof e.value}-${String(e.value)}`))}):(0,d.jsx)(`div`,{className:`vl-select__empty`,role:`status`,children:l??c})}),ne=[],p=e=>!!(e&&!e.disabled&&!e.divider),m=(0,u.forwardRef)((e,f)=>{let{value:m,defaultValue:re,options:h=ne,placeholder:g=`请选择`,filterable:ie=!1,filterPlaceholder:ae=`搜索`,multiple:oe=!1,taggable:_=!1,maxTagCount:v,disabled:y=!1,loading:b=!1,size:se=`md`,clearable:ce=!1,placement:x=`bottom-start`,offset:le=8,zIndex:ue,emptyText:de=`暂无数据`,renderOption:fe,emptyContent:pe,className:me,style:he,onChange:ge,onClear:_e,onOpen:ve,onClose:ye,onFocus:be,onBlur:xe,id:Se,"aria-label":Ce,"aria-labelledby":we,"aria-describedby":Te,tabIndex:Ee,...De}=e,Oe=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)(null),ke=(0,u.useRef)(null),Ae=(0,u.useRef)([]),je=(0,u.useCallback)((e,t)=>{Ae.current[e]=t},[]),Me=(0,u.useMemo)(()=>r.n(Oe,f),[f]),w=a.t(),Ne=c.a({defaultZIndex:c.r.dropdown,zIndex:ue}),T=ie||_,E=oe||_,Pe=(0,u.useMemo)(()=>E?[]:null,[E]),Fe=n.t(e,`value`),D=(0,u.useRef)(void 0),[O,Ie]=n.n({value:m??Pe,defaultValue:re??Pe,controlled:Fe,onChange:e=>{let t=D.current;D.current=void 0,ge?.(e,t)}}),[k,Le]=(0,u.useState)(!1),[Re,ze]=(0,u.useState)(!1),[A,j]=(0,u.useState)(``),[Be,M]=(0,u.useState)([]),[{style:Ve,placement:He},Ue]=o.i(x),[N,P]=(0,u.useState)(-1),We=s.t(`vl-select-control`,Se),F=s.t(`vl-select-listbox`),Ge=(0,u.useCallback)(e=>`${F}-option-${e}`,[F]),Ke=(0,u.useMemo)(()=>[`vl-select-wrapper`,me||``].filter(Boolean).join(` `),[me]),qe=(0,u.useMemo)(()=>[`vl-select`,`size-${se}`,E?`is-multiple`:``,k?`is-open`:``,Re?`is-focus-within`:``,y?`is-disabled`:``,b?`is-loading`:``].filter(Boolean).join(` `),[se,E,k,Re,y,b]),I=(0,u.useMemo)(()=>{if(!_)return h;let e=Be.filter(e=>!h.some(t=>t.value===e.value));return[...h,...e]},[h,Be,_]),L=(0,u.useMemo)(()=>{if(!T||!k)return I;let e=A.trim().toLocaleLowerCase();return e?I.filter(t=>!t.divider&&t.label.toLocaleLowerCase().includes(e)):I},[I,T,k,A]),R=(0,u.useMemo)(()=>L.flatMap((e,t)=>p(e)?[t]:[]),[L]),z=(0,u.useMemo)(()=>E&&Array.isArray(O)?O:[],[E,O]),Je=(0,u.useMemo)(()=>new Set(z),[z]),B=(0,u.useMemo)(()=>{if(!(E||Array.isArray(O)))return I.find(e=>e.value===O)},[I,E,O]),V=(0,u.useMemo)(()=>E?``:B?B.label:O===null||O===``||Array.isArray(O)?``:String(O),[E,B,O]),H=(0,u.useMemo)(()=>z.map(e=>({value:e,label:I.find(t=>t.value===e)?.label??String(e)})),[z,I]),Ye=(0,u.useMemo)(()=>!E||v===void 0||!Number.isFinite(v)?1/0:Math.max(0,Math.floor(v)),[E,v]),Xe=Ye===1/0?H:H.slice(0,Ye),U=Math.max(0,H.length-Xe.length),Ze=E?z.length>0:O!==null&&O!==``&&!Array.isArray(O),Qe=ce&&!y&&!b&&Ze,$e=N>=0&&p(L[N])?Ge(N):void 0,et=(0,u.useMemo)(()=>[`vl-select__panel`,`is-${He}`].join(` `),[He]),W=(0,u.useCallback)(e=>{e&&(y||b)||k!==e&&(Le(e),e?ve?.():ye?.())},[y,b,ve,ye,k]),G=(0,u.useCallback)(e=>E?Je.has(e.value):e.value===O,[E,Je,O]),K=(0,u.useCallback)((e,t)=>{D.current=t,Ie(e),D.current=void 0},[Ie]),q=(0,u.useCallback)(e=>{_&&M(t=>t.filter(t=>e.includes(t.value)))},[_]),J=(0,u.useCallback)(e=>{if(p(e)){if(E){let t=z.includes(e.value)?z.filter(t=>t!==e.value):[...z,e.value];K(t,e),q(t),j(``);return}K(e.value,e),j(e.label),W(!1)}},[E,z,K,q,W]),tt=(0,u.useRef)(J);t.t(()=>{tt.current=J},[J]);let nt=(0,u.useCallback)(e=>tt.current(e),[]),rt=(0,u.useCallback)(e=>{if(!_)return!1;let t=e.trim();if(!t)return!1;let n=t.toLocaleLowerCase(),r=I.find(e=>e.label.toLocaleLowerCase()===n||String(e.value).toLocaleLowerCase()===n);if(r)return G(r)?j(``):J(r),!0;let i={label:t,value:t};return M(e=>[...e,i]),J(i),!0},[_,I,G,J]),Y=(0,u.useCallback)(()=>{let e=L.findIndex(e=>p(e)&&G(e));return e>=0?e:R[0]??-1},[L,R,G]),X=(0,u.useCallback)(e=>{p(L[e])&&(P(e),Ae.current[e]?.scrollIntoView?.({block:`nearest`}))},[L]),it=(0,u.useCallback)(e=>{if(!R.length)return;let t=R.indexOf(N),n=(t>=0?t+e:(e>0?-1:0)+e+R.length)%R.length;X(R[n])},[R,N,X]),at=(0,u.useCallback)(()=>{let e=R[0];e!==void 0&&X(e)},[R,X]),ot=(0,u.useCallback)(()=>{let e=R.at(-1);e!==void 0&&X(e)},[R,X]),Z=(0,u.useCallback)(()=>{if(!k)return;let e=S.current,t=C.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=o.t({anchorRect:n,floatingRect:t.getBoundingClientRect(),placement:x,offset:le});Ue({placement:r.placement,style:{left:`${Math.round(r.x)}px`,top:`${Math.round(r.y)}px`,minWidth:`${Math.round(n.width)}px`}})},[k,x,le,Ue]),Q=(0,u.useCallback)(()=>{T?ke.current?.focus():S.current?.focus()},[T]),$=(0,u.useCallback)((e=`first`)=>{if(y||b)return;k||(T&&j(``),W(!0));let t=e===`last`?R.at(-1):Y();t!==void 0&&t>=0&&P(t),window.requestAnimationFrame(()=>{Q(),Z()})},[y,b,k,T,W,R,Y,Q,Z]),st=(0,u.useCallback)(()=>{W(!1),window.requestAnimationFrame(Q)},[W,Q]),ct=(0,u.useCallback)(()=>{let e=L[N];return p(e)?(J(e),!0):!1},[L,N,J]),lt=e=>{if(!(y||b)&&!e.target.closest(`button`)){if(T){$();return}k?W(!1):$()}},ut=e=>{if(!(y||b)){if(e.key===`ArrowDown`){e.preventDefault(),k?it(1):$(`first`);return}if(e.key===`ArrowUp`){e.preventDefault(),k?it(-1):$(`last`);return}if(e.key===`Home`&&k&&!T){e.preventDefault(),at();return}if(e.key===`End`&&k&&!T){e.preventDefault(),ot();return}if(e.key===`Escape`&&k){e.preventDefault(),st();return}if(e.key===`Tab`&&k){W(!1);return}if(e.key===`Enter`){if(!k){e.preventDefault(),$();return}e.preventDefault(),!ct()&&T&&rt(A);return}if(e.key===` `&&!T){e.preventDefault(),k?ct():$();return}if(e.key===`Backspace`&&T&&E&&!A&&z.length){let e=z.slice(0,-1);K(e),q(e)}}},dt=()=>{y||b||(K(E?[]:null),_e?.(),j(``),q([]),W(!1),Q())},ft=e=>{if(y||b)return;let t=z.filter(t=>t!==e);K(t),q(t)},pt=e=>{e.currentTarget.contains(e.relatedTarget)||(ze(!0),be?.(e))},mt=e=>{e.currentTarget.contains(e.relatedTarget)||(ze(!1),xe?.(e))};(0,u.useEffect)(()=>{k||(j(E?``:V),P(-1))},[k,E,V]),(0,u.useEffect)(()=>{if(!k||!w)return;P(Y());let e=window.requestAnimationFrame(Z);return()=>window.cancelAnimationFrame(e)},[k,w,L,Y,Z]),(0,u.useEffect)(()=>{if(!_||!E)return;let e=new Set(I.map(e=>e.value)),t=z.filter(t=>!e.has(t));t.length&&M(e=>[...e,...t.map(e=>({label:String(e),value:e}))])},[_,E,I,z]),(0,u.useEffect)(()=>{(y||b)&&k&&W(!1)},[y,b,k,W]),o.r({active:k&&w,rootRef:Oe,floatingRef:C,onOutsideClick:()=>W(!1),onViewportChange:Z});let ht={role:`combobox`,"aria-controls":F,"aria-expanded":k,"aria-haspopup":`listbox`,"aria-activedescendant":k?$e:void 0,"aria-disabled":y||b||void 0,"aria-busy":b||void 0,"aria-label":Ce??(we?void 0:g),"aria-labelledby":we,"aria-describedby":Te},gt=T?(0,d.jsx)(`input`,{ref:ke,id:We,className:`vl-select__input`,type:`text`,value:A,placeholder:k?ae:E&&z.length?``:g,disabled:y||b,autoComplete:`off`,"aria-autocomplete":`list`,...ht,tabIndex:Ee,onChange:e=>{j(e.target.value),k||W(!0)},onFocus:()=>{k||$()},onKeyDown:ut}):null,_t=(0,d.jsx)(i.t,{show:k,name:`vl-select`,deferEffects:!w,children:(0,d.jsx)(`div`,{ref:C,id:F,className:et,style:{...Ve,zIndex:Ne.zIndex},role:`listbox`,"aria-hidden":!k||void 0,"aria-multiselectable":E||void 0,children:(0,d.jsx)(te,{options:L,activeIndex:N,isSelected:G,getOptionId:Ge,registerOption:je,onSelect:nt,onActive:P,renderOption:fe,emptyText:de,emptyContent:pe})})});return(0,d.jsx)(c.t,{layer:Ne.layer,children:(0,d.jsxs)(`div`,{ref:Me,className:Ke,style:he,...De,children:[(0,d.jsxs)(`div`,{ref:S,id:T?void 0:We,className:qe,...T?{}:ht,tabIndex:y||b||T?-1:Ee??0,onClick:lt,onKeyDown:T?void 0:ut,onFocus:pt,onBlur:mt,children:[(0,d.jsx)(`div`,{className:`vl-select__value`,children:E?(0,d.jsxs)(`div`,{className:`vl-select__tags`,children:[Xe.map(e=>(0,d.jsxs)(`span`,{className:`vl-select__tag`,children:[(0,d.jsx)(`span`,{className:`vl-select__tag-label`,children:e.label}),(0,d.jsx)(`button`,{type:`button`,className:`vl-select__tag-remove`,"aria-label":`移除 ${e.label}`,disabled:y||b,onClick:()=>ft(e.value),onPointerDown:e=>e.stopPropagation(),children:(0,d.jsx)(l.X,{size:12,"aria-hidden":`true`})})]},e.value)),U>0?(0,d.jsxs)(`span`,{className:`vl-select__tag is-collapsed`,"aria-label":`另有 ${U} 项`,children:[`+`,U]}):null,T?gt:H.length?null:(0,d.jsx)(`span`,{className:`vl-select__placeholder`,children:g})]}):T?gt:V?(0,d.jsx)(`span`,{className:`vl-select__label`,children:V}):(0,d.jsx)(`span`,{className:`vl-select__placeholder`,children:g})}),(0,d.jsxs)(`div`,{className:`vl-select__suffix`,children:[Qe?(0,d.jsx)(`button`,{type:`button`,className:`vl-select__clear`,"aria-label":`清除已选`,onClick:dt,onPointerDown:e=>e.stopPropagation(),children:(0,d.jsx)(l.X,{size:16,"aria-hidden":`true`})}):null,b?(0,d.jsx)(l.LoaderCircle,{className:`vl-select__loading`,size:16,"aria-hidden":`true`}):(0,d.jsx)(`span`,{className:`vl-select__arrow`,"aria-hidden":`true`,children:(0,d.jsx)(l.ChevronDown,{size:16})})]})]}),w?(0,ee.createPortal)(_t,document.body):_t]})})});m.displayName=`VlSelect`;var re=m,h=m;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./icon-DRLyKu8p.cjs"),t=require("./Button-qURrKHQ0.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=e=>{if(e!==void 0)return typeof e==`number`||/^\d+(\.\d+)?$/.test(e)?`${e}px`:e},a=(0,n.forwardRef)((a,o)=>{let{items:s=[],position:c=`right`,offset:l=`var(--vl-space-6)`,top:u,bottom:d,size:f=`md`,shape:p=`square`,gap:m=`var(--vl-space-2)`,zIndex:h,className:g,style:_,role:v=`navigation`,"aria-label":y=`快捷操作`,onItemClick:b,...x}=a,S=(0,n.useMemo)(()=>[`vl-sidebar`,`size-${f}`,`is-${c}`,`is-${p}`,g||``].filter(Boolean).join(` `),[f,c,p,g]),C=(0,n.useMemo)(()=>{let e={"--vl-sidebar-gap":i(m)};h!==void 0&&(e.zIndex=h);let t=i(l);return t&&(e[c]=t),u===void 0?e.bottom=d===void 0?`var(--vl-space-6)`:i(d):e.top=i(u),{...e,..._}},[_,h,m,l,c,u,d]),w=(e,t)=>{e.disabled||e.divider||(e.onClick?.(e),b?.(e,t))};return(0,r.jsx)(`div`,{ref:o,className:S,style:C,role:v,"aria-label":y,...x,children:(0,r.jsx)(`div`,{className:`vl-sidebar__list`,children:s.map((n,i)=>{if(n.divider)return(0,r.jsx)(`div`,{className:`vl-sidebar__divider`,role:`separator`},n.key??`divider-${i}`);let a=[`vl-sidebar__item`,n.active?`is-active`:``].filter(Boolean).join(` `),o=n.label??(n.key===void 0?void 0:String(n.key));return(0,r.jsx)(t.t,{nativeType:`button`,status:`default`,variant:`outline`,size:f,shape:p,className:a,icon:e.n(n.icon,`vl-sidebar__icon`)??void 0,disabled:n.disabled,"aria-pressed":n.active?`true`:`false`,"aria-label":o,title:o,onClick:()=>w(n,i)},n.key??i)})})})});a.displayName=`VlSidebar`;var o=a,s=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { n as e } from "./icon-Cbvuv4yF.js";
|
|
2
|
+
import { t } from "./Button-CwkWSWau.js";
|
|
3
|
+
import { forwardRef as n, useMemo as r } from "react";
|
|
4
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
//#region components/Sidebar/Sidebar.tsx
|
|
6
|
+
var a = (e) => {
|
|
7
|
+
if (e !== void 0) return typeof e == "number" || /^\d+(\.\d+)?$/.test(e) ? `${e}px` : e;
|
|
8
|
+
}, o = n((n, o) => {
|
|
9
|
+
let { items: s = [], position: c = "right", offset: l = "var(--vl-space-6)", top: u, bottom: d, size: f = "md", shape: p = "square", gap: m = "var(--vl-space-2)", zIndex: h, className: g, style: _, role: v = "navigation", "aria-label": y = "快捷操作", onItemClick: b, ...x } = n, S = r(() => [
|
|
10
|
+
"vl-sidebar",
|
|
11
|
+
`size-${f}`,
|
|
12
|
+
`is-${c}`,
|
|
13
|
+
`is-${p}`,
|
|
14
|
+
g || ""
|
|
15
|
+
].filter(Boolean).join(" "), [
|
|
16
|
+
f,
|
|
17
|
+
c,
|
|
18
|
+
p,
|
|
19
|
+
g
|
|
20
|
+
]), C = r(() => {
|
|
21
|
+
let e = { "--vl-sidebar-gap": a(m) };
|
|
22
|
+
h !== void 0 && (e.zIndex = h);
|
|
23
|
+
let t = a(l);
|
|
24
|
+
return t && (e[c] = t), u === void 0 ? e.bottom = d === void 0 ? "var(--vl-space-6)" : a(d) : e.top = a(u), {
|
|
25
|
+
...e,
|
|
26
|
+
..._
|
|
27
|
+
};
|
|
28
|
+
}, [
|
|
29
|
+
_,
|
|
30
|
+
h,
|
|
31
|
+
m,
|
|
32
|
+
l,
|
|
33
|
+
c,
|
|
34
|
+
u,
|
|
35
|
+
d
|
|
36
|
+
]), w = (e, t) => {
|
|
37
|
+
e.disabled || e.divider || (e.onClick?.(e), b?.(e, t));
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ i("div", {
|
|
40
|
+
ref: o,
|
|
41
|
+
className: S,
|
|
42
|
+
style: C,
|
|
43
|
+
role: v,
|
|
44
|
+
"aria-label": y,
|
|
45
|
+
...x,
|
|
46
|
+
children: /* @__PURE__ */ i("div", {
|
|
47
|
+
className: "vl-sidebar__list",
|
|
48
|
+
children: s.map((n, r) => {
|
|
49
|
+
if (n.divider) return /* @__PURE__ */ i("div", {
|
|
50
|
+
className: "vl-sidebar__divider",
|
|
51
|
+
role: "separator"
|
|
52
|
+
}, n.key ?? `divider-${r}`);
|
|
53
|
+
let a = ["vl-sidebar__item", n.active ? "is-active" : ""].filter(Boolean).join(" "), o = n.label ?? (n.key === void 0 ? void 0 : String(n.key));
|
|
54
|
+
return /* @__PURE__ */ i(t, {
|
|
55
|
+
nativeType: "button",
|
|
56
|
+
status: "default",
|
|
57
|
+
variant: "outline",
|
|
58
|
+
size: f,
|
|
59
|
+
shape: p,
|
|
60
|
+
className: a,
|
|
61
|
+
icon: e(n.icon, "vl-sidebar__icon") ?? void 0,
|
|
62
|
+
disabled: n.disabled,
|
|
63
|
+
"aria-pressed": n.active ? "true" : "false",
|
|
64
|
+
"aria-label": o,
|
|
65
|
+
title: o,
|
|
66
|
+
onClick: () => w(n, r)
|
|
67
|
+
}, n.key ?? r);
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
o.displayName = "VlSidebar";
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region components/Sidebar/index.ts
|
|
75
|
+
var s = o, c = o;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { s as n, c as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
2
|
import { n as t, t as n } from "./state-BSDh-Ob2.js";
|
|
3
3
|
import { n as r } from "./number-BN2jHM6Z.js";
|
|
4
|
-
import { t as i } from "./Tooltip-
|
|
4
|
+
import { t as i } from "./Tooltip-BbbIT5nt.js";
|
|
5
5
|
import { t as a } from "./Scrollbar-BdMGZrYi.js";
|
|
6
6
|
import { ChevronDown as o, ChevronUp as s } from "lucide-react";
|
|
7
7
|
import { forwardRef as c, memo as l, useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
@@ -253,12 +253,15 @@ function T(i, c) {
|
|
|
253
253
|
Me
|
|
254
254
|
]);
|
|
255
255
|
d(() => {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
256
|
+
let e = Oe.current;
|
|
257
|
+
e.forEach((t, n) => {
|
|
258
|
+
!G.has(n) && (!P || !U.has(n)) && e.delete(n);
|
|
259
|
+
}), G.forEach((t, n) => e.set(n, t));
|
|
260
|
+
}, [
|
|
261
|
+
G,
|
|
262
|
+
P,
|
|
263
|
+
U
|
|
264
|
+
]), d(() => {
|
|
262
265
|
if (!k || M) return;
|
|
263
266
|
let e = v(P ? H : H.filter((e) => G.has(e)), N);
|
|
264
267
|
_(H, e) || z(e);
|