@vavt/react-ui 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -2
- package/dist/Card-BkZhLXQ5.cjs +1 -0
- package/dist/{Card-DlztNV-6.js → Card-DCLfLn1x.js} +13 -12
- package/dist/Cron-3D9GmlYf.cjs +1 -0
- package/dist/{Cron-Di7k2FTL.js → Cron-Go4yIqrd.js} +361 -353
- package/dist/{DatePicker-M-MwejjV.js → DatePicker-B-F5q_s_.js} +1 -1
- package/dist/{DatePicker-DAxv2h-d.cjs → DatePicker-CoHW85qm.cjs} +1 -1
- package/dist/{DateTimePicker-BcT3FtN-.js → DateTimePicker-BSBZZ7xV.js} +1 -1
- package/dist/{DateTimePicker-B3C3v99L.cjs → DateTimePicker-CAkdoY--.cjs} +1 -1
- package/dist/Divider-BXNZyvHY.js +48 -0
- package/dist/Divider-BnmUNmy2.cjs +1 -0
- package/dist/Drawer-C0toQ-fQ.js +112 -0
- package/dist/Drawer-D45miZ27.cjs +1 -0
- package/dist/Dropdown-BsXYVdt6.cjs +1 -0
- package/dist/Dropdown-DljKFnvO.js +319 -0
- package/dist/Empty-Dny96c3p.cjs +1 -0
- package/dist/Empty-MmxZitR8.js +40 -0
- package/dist/{MessageBox-CrIifoig.js → MessageBox-B4Qo1vs2.js} +1 -1
- package/dist/{MessageBox-Ddn-R2MS.cjs → MessageBox-CTJfdU29.cjs} +1 -1
- package/dist/Modal-i_Do8GsG.cjs +1 -0
- package/dist/Modal-otJ_9ldu.js +210 -0
- package/dist/{Pagination-DKEL6maR.js → Pagination-CSI5IzQB.js} +1 -1
- package/dist/{Pagination-DaMWXFn5.cjs → Pagination-ODU-i3gn.cjs} +1 -1
- package/dist/Select-BRKxpX-_.cjs +1 -0
- package/dist/Select-QedbJ4pD.js +468 -0
- package/dist/{Table-C8cSyts5.js → Table-B9NTkptC.js} +1 -1
- package/dist/{Table-JoJ9vpu-.cjs → Table-Bqjey5fw.cjs} +1 -1
- package/dist/TimePicker-CHZsr_jj.js +207 -0
- package/dist/TimePicker-Cpmvn8tx.cjs +1 -0
- package/dist/Tooltip-Buk5F9f_.js +205 -0
- package/dist/Tooltip-CP8rpNYG.cjs +1 -0
- package/dist/Upload-DZC_bt6G.js +183 -0
- package/dist/Upload-bxJz2avf.cjs +1 -0
- package/dist/base.css +1 -1
- package/dist/cjs/Card.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/Divider.cjs +1 -1
- package/dist/cjs/Drawer.cjs +1 -1
- package/dist/cjs/Dropdown.cjs +1 -1
- package/dist/cjs/Empty.cjs +1 -0
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Select.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/Upload.cjs +1 -0
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/content-DCGQZQp8.cjs +1 -0
- package/dist/content-Dllrr-7G.js +11 -0
- package/dist/css/Button.css +1 -1
- package/dist/css/DateTimePicker.css +1 -1
- package/dist/css/Empty.css +1 -0
- package/dist/css/Upload.css +1 -0
- package/dist/date-picker-BsiNrLZC.js +592 -0
- package/dist/date-picker-DNN0BiRA.cjs +1 -0
- package/dist/es/Card.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/Divider.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Empty.mjs +3 -0
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Select.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/Upload.mjs +3 -0
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +31 -29
- package/dist/es/register.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/layer-BgiUZy_t.cjs +1 -0
- package/dist/layer-DDm97-sb.js +53 -0
- package/dist/registry-BGNWNSiC.cjs +1 -0
- package/dist/registry-q6UdMOyj.js +83 -0
- package/dist/style/Empty.cjs +7 -0
- package/dist/style/Empty.mjs +7 -0
- package/dist/style/Upload.cjs +7 -0
- package/dist/style/Upload.mjs +7 -0
- package/dist/types/Cron/type.d.cts +2 -0
- package/dist/types/Cron/type.d.ts +2 -0
- package/dist/types/DatePicker/type.d.cts +2 -0
- package/dist/types/DatePicker/type.d.ts +2 -0
- package/dist/types/Dropdown/type.d.cts +2 -0
- package/dist/types/Dropdown/type.d.ts +2 -0
- package/dist/types/Empty/Empty.d.cts +3 -0
- package/dist/types/Empty/Empty.d.ts +3 -0
- package/dist/types/Empty/index.d.cts +5 -0
- package/dist/types/Empty/index.d.ts +5 -0
- package/dist/types/Empty/type.d.cts +24 -0
- package/dist/types/Empty/type.d.ts +24 -0
- package/dist/types/Select/type.d.cts +2 -0
- package/dist/types/Select/type.d.ts +2 -0
- package/dist/types/TimePicker/type.d.cts +2 -0
- package/dist/types/TimePicker/type.d.ts +2 -0
- package/dist/types/Tooltip/type.d.cts +2 -0
- package/dist/types/Tooltip/type.d.ts +2 -0
- package/dist/types/Upload/Upload.d.cts +3 -0
- package/dist/types/Upload/Upload.d.ts +3 -0
- package/dist/types/Upload/index.d.cts +5 -0
- package/dist/types/Upload/index.d.ts +5 -0
- package/dist/types/Upload/type.d.cts +62 -0
- package/dist/types/Upload/type.d.ts +62 -0
- package/dist/types/_shared/content.d.cts +13 -0
- package/dist/types/_shared/content.d.ts +13 -0
- package/dist/types/_shared/layer.d.cts +63 -0
- package/dist/types/_shared/layer.d.ts +63 -0
- package/dist/types/global.d.cts +4 -0
- package/dist/types/global.d.ts +4 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/registry.d.cts +2 -0
- package/dist/types/registry.d.ts +2 -0
- package/package.json +2 -4
- package/dist/Card-nILlh9c_.cjs +0 -1
- package/dist/Cron-CoO2Vnnm.cjs +0 -1
- package/dist/Divider-BfvQ6BVP.cjs +0 -1
- package/dist/Divider-vyftxh3F.js +0 -47
- package/dist/Drawer-D28QbyA3.js +0 -103
- package/dist/Drawer-OmMfdgKN.cjs +0 -1
- package/dist/Dropdown-CYx6RxVv.js +0 -311
- package/dist/Dropdown-swfND4yK.cjs +0 -1
- package/dist/Modal-B_VqN16m.js +0 -201
- package/dist/Modal-Dm48HmGu.cjs +0 -1
- package/dist/Select-DQLup8Y-.cjs +0 -1
- package/dist/Select-DccM9YpB.js +0 -458
- package/dist/TimePicker-ClQCHa6M.js +0 -199
- package/dist/TimePicker-DNBo2Rn5.cjs +0 -1
- package/dist/Tooltip-CbPYYr6R.cjs +0 -1
- package/dist/Tooltip-Ds4Odm7K.js +0 -197
- package/dist/date-picker-DkRwNu2m.js +0 -584
- package/dist/date-picker-DyGLrw5H.cjs +0 -1
- package/dist/registry-BYA5h9pE.cjs +0 -1
- package/dist/registry-rrmu3kvY.js +0 -79
|
@@ -1,311 +0,0 @@
|
|
|
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-oH-YwB7_.js";
|
|
4
|
-
import { t as ee } from "./client-pj_wzx28.js";
|
|
5
|
-
import { n as te } from "./refs-D5IYOBaf.js";
|
|
6
|
-
import { r as ne, t as re } from "./floating-DBAmeQIq.js";
|
|
7
|
-
import { t as ie } from "./id-CHixuHb7.js";
|
|
8
|
-
import { t as ae } from "./Transition-DiO4GsP3.js";
|
|
9
|
-
import { i as oe } from "./focus-BDDJyKk3.js";
|
|
10
|
-
import { Fragment as se, cloneElement as ce, forwardRef as i, isValidElement as le, useCallback as a, useEffect as ue, useMemo as o, useRef as s, useState as c } from "react";
|
|
11
|
-
import { jsx as l, jsxs as de } from "react/jsx-runtime";
|
|
12
|
-
import { createPortal as fe } from "react-dom";
|
|
13
|
-
//#region components/Dropdown/Dropdown.tsx
|
|
14
|
-
var pe = [], u = (e) => !!(e && !e.disabled && !e.divider), d = i((i, d) => {
|
|
15
|
-
let { open: f, defaultOpen: me = !1, disabled: p = !1, placement: m = "bottom-start", offset: h = 8, closeOnContentClick: g = !0, trigger: _ = "hover", options: v = pe, closeOnOutsideClick: he = !0, triggerContent: y, menuLabel: ge = "菜单", className: b, style: x, children: _e, onChange: ve, onOpen: S, onClose: ye, onSelect: be, onCommand: xe, "aria-label": Se, "aria-labelledby": Ce, ...we } = i, Te = s(null), C = s(null), w = s(null), T = s([]), E = s(null), D = s(null), O = s(null), k = s(null), Ee = o(() => te(Te, d), [d]), A = ee(), De = r(i, "open"), [j, M] = n({
|
|
16
|
-
value: !!f,
|
|
17
|
-
defaultValue: me,
|
|
18
|
-
controlled: De,
|
|
19
|
-
onChange: ve
|
|
20
|
-
}), N = j && !p, [P, Oe] = c(-1), [ke, F] = c({}), [Ae, I] = c(m), [L, R] = c(!1), [z, B] = c(N), [je, V] = c(!1), H = ie("vl-dropdown-menu"), Me = a((e) => `${H}-option-${e}`, [H]), U = o(() => v.flatMap((e, t) => u(e) ? [t] : []), [v]), Ne = U.length > 0, Pe = v.some((e) => !e.divider), W = U.includes(P) ? P : U[0] ?? -1, Fe = o(() => [
|
|
21
|
-
"vl-dropdown",
|
|
22
|
-
N ? "is-open" : "",
|
|
23
|
-
p ? "is-disabled" : "",
|
|
24
|
-
b || ""
|
|
25
|
-
].filter(Boolean).join(" "), [
|
|
26
|
-
N,
|
|
27
|
-
p,
|
|
28
|
-
b
|
|
29
|
-
]), Ie = o(() => ({
|
|
30
|
-
"--vl-dropdown-offset": `${h}px`,
|
|
31
|
-
...x
|
|
32
|
-
}), [h, x]), G = a(() => {
|
|
33
|
-
let e = E.current;
|
|
34
|
-
if (e && e.isConnected) {
|
|
35
|
-
e.focus();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
(C.current?.querySelector(oe))?.focus();
|
|
39
|
-
}, []), K = a(() => {
|
|
40
|
-
let e = document.activeElement;
|
|
41
|
-
if (e && C.current?.contains(e)) {
|
|
42
|
-
E.current = e;
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
E.current = C.current?.querySelector("button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? null;
|
|
46
|
-
}, []), q = a((e, t = !1) => {
|
|
47
|
-
if (!(e && p)) {
|
|
48
|
-
if (j === e) {
|
|
49
|
-
t && G();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
e && (K(), R(!1), F({}), I(m)), M(e), e ? S?.() : (ye?.(), t && window.requestAnimationFrame(G));
|
|
53
|
-
}
|
|
54
|
-
}, [
|
|
55
|
-
p,
|
|
56
|
-
j,
|
|
57
|
-
m,
|
|
58
|
-
G,
|
|
59
|
-
K,
|
|
60
|
-
M,
|
|
61
|
-
S,
|
|
62
|
-
ye
|
|
63
|
-
]), J = a(() => {
|
|
64
|
-
O.current !== null && (window.clearTimeout(O.current), O.current = null);
|
|
65
|
-
}, []), Y = a(() => {
|
|
66
|
-
J(), O.current = window.setTimeout(() => {
|
|
67
|
-
let e = document.activeElement;
|
|
68
|
-
e && (C.current?.contains(e) || w.current?.contains(e)) || q(!1);
|
|
69
|
-
}, 160);
|
|
70
|
-
}, [J, q]), X = a((e) => {
|
|
71
|
-
u(v[e]) && (Oe(e), T.current[e]?.focus());
|
|
72
|
-
}, [v]), Z = a(() => {
|
|
73
|
-
let e = U[0];
|
|
74
|
-
e !== void 0 && X(e);
|
|
75
|
-
}, [U, X]), Q = a(() => {
|
|
76
|
-
let e = U.at(-1);
|
|
77
|
-
e !== void 0 && X(e);
|
|
78
|
-
}, [U, X]), Le = a((e) => {
|
|
79
|
-
if (!U.length) return;
|
|
80
|
-
let t = U.indexOf(P), n = t < 0 ? e > 0 ? 0 : U.length - 1 : (t + e + U.length) % U.length;
|
|
81
|
-
X(U[n]);
|
|
82
|
-
}, [
|
|
83
|
-
U,
|
|
84
|
-
P,
|
|
85
|
-
X
|
|
86
|
-
]), $ = a(() => {
|
|
87
|
-
if (!N) return;
|
|
88
|
-
let e = w.current;
|
|
89
|
-
if (!e) return;
|
|
90
|
-
let t = D.current, n = t ? {
|
|
91
|
-
left: t.x,
|
|
92
|
-
right: t.x,
|
|
93
|
-
top: t.y,
|
|
94
|
-
bottom: t.y,
|
|
95
|
-
width: 0,
|
|
96
|
-
height: 0
|
|
97
|
-
} : C.current?.getBoundingClientRect();
|
|
98
|
-
if (!n) return;
|
|
99
|
-
let r = re({
|
|
100
|
-
anchorRect: n,
|
|
101
|
-
floatingRect: e.getBoundingClientRect(),
|
|
102
|
-
placement: m,
|
|
103
|
-
offset: h
|
|
104
|
-
});
|
|
105
|
-
I(r.placement), F({
|
|
106
|
-
left: `${Math.round(r.x)}px`,
|
|
107
|
-
top: `${Math.round(r.y)}px`
|
|
108
|
-
}), R(!0);
|
|
109
|
-
}, [
|
|
110
|
-
N,
|
|
111
|
-
m,
|
|
112
|
-
h
|
|
113
|
-
]), Re = (e) => {
|
|
114
|
-
p || _ !== "click" || (e.stopPropagation(), D.current = null, q(!N));
|
|
115
|
-
}, ze = () => {
|
|
116
|
-
p || _ !== "hover" || (D.current = null, J(), q(!0));
|
|
117
|
-
}, Be = () => {
|
|
118
|
-
p || _ !== "hover" || Y();
|
|
119
|
-
}, Ve = () => {
|
|
120
|
-
p || _ !== "hover" || (D.current = null, J(), q(!0));
|
|
121
|
-
}, He = (e) => {
|
|
122
|
-
e.currentTarget.contains(e.relatedTarget) || _ === "hover" && Y();
|
|
123
|
-
}, Ue = (e) => {
|
|
124
|
-
p || _ !== "context-menu" || (e.preventDefault(), e.stopPropagation(), D.current = {
|
|
125
|
-
x: e.clientX,
|
|
126
|
-
y: e.clientY
|
|
127
|
-
}, q(!0));
|
|
128
|
-
}, We = () => {
|
|
129
|
-
_ === "hover" && J();
|
|
130
|
-
}, Ge = () => {
|
|
131
|
-
_ === "hover" && Y();
|
|
132
|
-
}, Ke = () => J(), qe = (e) => {
|
|
133
|
-
u(e) && (e.onClick?.(e), be?.(e), xe?.(e.value, e), g && q(!1, !0));
|
|
134
|
-
}, Je = () => {
|
|
135
|
-
v.length || !g || q(!1, !0);
|
|
136
|
-
}, Ye = (e) => {
|
|
137
|
-
if (!p) {
|
|
138
|
-
if (D.current = null, e.key === "Escape" && N) {
|
|
139
|
-
e.preventDefault(), q(!1, !0);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
e.key === "ArrowDown" || e.key === "Enter" || e.key === " " ? (e.preventDefault(), K(), N ? Z() : (k.current = "first", q(!0))) : e.key === "ArrowUp" && (e.preventDefault(), K(), N ? Q() : (k.current = "last", q(!0)));
|
|
143
|
-
}
|
|
144
|
-
}, Xe = (e) => {
|
|
145
|
-
if (N) {
|
|
146
|
-
if (e.key === "Escape") {
|
|
147
|
-
e.preventDefault(), q(!1, !0);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (e.key === "Tab") {
|
|
151
|
-
q(!1);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (Ne) {
|
|
155
|
-
if (e.key === "ArrowDown") e.preventDefault(), Le(1);
|
|
156
|
-
else if (e.key === "ArrowUp") e.preventDefault(), Le(-1);
|
|
157
|
-
else if (e.key === "Home") e.preventDefault(), Z();
|
|
158
|
-
else if (e.key === "End") e.preventDefault(), Q();
|
|
159
|
-
else if (e.key === "Enter" || e.key === " ") {
|
|
160
|
-
e.preventDefault();
|
|
161
|
-
let t = v[P];
|
|
162
|
-
t && qe(t);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
ue(() => {
|
|
168
|
-
p && j && q(!1);
|
|
169
|
-
}, [
|
|
170
|
-
p,
|
|
171
|
-
j,
|
|
172
|
-
q
|
|
173
|
-
]), t(() => {
|
|
174
|
-
if (!A) return;
|
|
175
|
-
if (!N) {
|
|
176
|
-
V(!1);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (!z) {
|
|
180
|
-
B(!0);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
$(), V(!0);
|
|
184
|
-
let e = k.current;
|
|
185
|
-
k.current = null;
|
|
186
|
-
let t = window.requestAnimationFrame(() => {
|
|
187
|
-
$(), e === "first" ? Z() : e === "last" && Q();
|
|
188
|
-
});
|
|
189
|
-
return () => window.cancelAnimationFrame(t);
|
|
190
|
-
}, [
|
|
191
|
-
N,
|
|
192
|
-
A,
|
|
193
|
-
z,
|
|
194
|
-
Z,
|
|
195
|
-
Q,
|
|
196
|
-
$
|
|
197
|
-
]);
|
|
198
|
-
let Ze = a(() => {
|
|
199
|
-
R(!1), F({}), I(m);
|
|
200
|
-
}, [m]), Qe = a(() => {
|
|
201
|
-
N || (B(!1), Ze());
|
|
202
|
-
}, [N, Ze]), $e = a(() => q(!1), [q]), et = a(() => q(!1, !0), [q]);
|
|
203
|
-
ne({
|
|
204
|
-
active: N && A,
|
|
205
|
-
rootRef: Te,
|
|
206
|
-
floatingRef: w,
|
|
207
|
-
closeOnOutsideClick: he && _ !== "hover",
|
|
208
|
-
ignoreEscapeInsideFloating: !0,
|
|
209
|
-
onOutsideClick: $e,
|
|
210
|
-
onEscape: et,
|
|
211
|
-
onViewportChange: $
|
|
212
|
-
}), ue(() => () => J(), [J]);
|
|
213
|
-
let tt = {
|
|
214
|
-
"aria-haspopup": "menu",
|
|
215
|
-
"aria-expanded": N,
|
|
216
|
-
"aria-controls": H,
|
|
217
|
-
"aria-disabled": p || void 0,
|
|
218
|
-
...Se ? { "aria-label": Se } : {},
|
|
219
|
-
...Ce ? { "aria-labelledby": Ce } : {},
|
|
220
|
-
tabIndex: p ? -1 : void 0
|
|
221
|
-
}, nt = le(y) && y.type !== se ? ce(y, tt) : /* @__PURE__ */ l("button", {
|
|
222
|
-
type: "button",
|
|
223
|
-
className: "vl-dropdown__defaultTrigger",
|
|
224
|
-
disabled: p,
|
|
225
|
-
...tt,
|
|
226
|
-
children: y ?? "Menu"
|
|
227
|
-
}), rt = [
|
|
228
|
-
"vl-dropdown__panel",
|
|
229
|
-
`is-${Ae}`,
|
|
230
|
-
L ? "is-positioned" : ""
|
|
231
|
-
].filter(Boolean).join(" "), it = /* @__PURE__ */ l(ae, {
|
|
232
|
-
show: A ? je : N,
|
|
233
|
-
name: "vl-dropdown",
|
|
234
|
-
forceMount: A,
|
|
235
|
-
deferEffects: !A,
|
|
236
|
-
onAfterLeave: Qe,
|
|
237
|
-
children: /* @__PURE__ */ l("div", {
|
|
238
|
-
ref: w,
|
|
239
|
-
id: H,
|
|
240
|
-
className: rt,
|
|
241
|
-
style: {
|
|
242
|
-
...ke,
|
|
243
|
-
visibility: A && !L ? "hidden" : "visible"
|
|
244
|
-
},
|
|
245
|
-
role: "menu",
|
|
246
|
-
"aria-label": ge,
|
|
247
|
-
"aria-hidden": !N || void 0,
|
|
248
|
-
onClick: Je,
|
|
249
|
-
onMouseEnter: We,
|
|
250
|
-
onMouseLeave: Ge,
|
|
251
|
-
onFocus: Ke,
|
|
252
|
-
onKeyDown: Xe,
|
|
253
|
-
children: /* @__PURE__ */ l("div", {
|
|
254
|
-
className: "vl-dropdown__content",
|
|
255
|
-
children: Pe ? v.map((t, n) => t.divider ? /* @__PURE__ */ l("div", {
|
|
256
|
-
className: "vl-dropdown__divider",
|
|
257
|
-
role: "separator"
|
|
258
|
-
}, `divider-${n}`) : /* @__PURE__ */ de("div", {
|
|
259
|
-
ref: (e) => {
|
|
260
|
-
T.current[n] = e;
|
|
261
|
-
},
|
|
262
|
-
id: Me(n),
|
|
263
|
-
className: [
|
|
264
|
-
"vl-dropdown__option",
|
|
265
|
-
t.status ? `is-${t.status}` : "",
|
|
266
|
-
t.disabled ? "is-disabled" : "",
|
|
267
|
-
W === n ? "is-active" : ""
|
|
268
|
-
].filter(Boolean).join(" "),
|
|
269
|
-
role: "menuitem",
|
|
270
|
-
tabIndex: W === n && !t.disabled ? 0 : -1,
|
|
271
|
-
"aria-disabled": t.disabled || void 0,
|
|
272
|
-
onPointerDown: (e) => e.preventDefault(),
|
|
273
|
-
onMouseEnter: () => {
|
|
274
|
-
u(t) && Oe(n);
|
|
275
|
-
},
|
|
276
|
-
onClick: (e) => {
|
|
277
|
-
e.stopPropagation(), qe(t);
|
|
278
|
-
},
|
|
279
|
-
children: [t.icon ? e(t.icon, "vl-dropdown__option-icon") : null, /* @__PURE__ */ l("span", {
|
|
280
|
-
className: "vl-dropdown__option-label",
|
|
281
|
-
children: t.label ?? ""
|
|
282
|
-
})]
|
|
283
|
-
}, t.value ?? n)) : _e
|
|
284
|
-
})
|
|
285
|
-
})
|
|
286
|
-
});
|
|
287
|
-
return /* @__PURE__ */ de("div", {
|
|
288
|
-
ref: Ee,
|
|
289
|
-
className: Fe,
|
|
290
|
-
style: Ie,
|
|
291
|
-
...we,
|
|
292
|
-
onMouseEnter: ze,
|
|
293
|
-
onMouseLeave: Be,
|
|
294
|
-
onFocus: Ve,
|
|
295
|
-
onBlur: He,
|
|
296
|
-
children: [/* @__PURE__ */ l("div", {
|
|
297
|
-
ref: C,
|
|
298
|
-
className: "vl-dropdown__trigger",
|
|
299
|
-
onClick: Re,
|
|
300
|
-
onContextMenu: Ue,
|
|
301
|
-
onKeyDown: Ye,
|
|
302
|
-
children: nt
|
|
303
|
-
}), z ? A ? fe(it, document.body) : it : null]
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
d.displayName = "VlDropdown";
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region components/Dropdown/index.ts
|
|
309
|
-
var f = d, me = d;
|
|
310
|
-
//#endregion
|
|
311
|
-
export { f as n, me as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./icon-DRLyKu8p.cjs"),t=require("./effect-BpNxm_06.cjs"),n=require("./state-ZBA75xZ_.cjs"),r=require("./client-BkoqeUs3.cjs"),ee=require("./refs-DCqd87V8.cjs"),i=require("./floating-DXRnx48N.cjs"),te=require("./id-CF0zOP1G.cjs"),ne=require("./Transition-X_89ga-e.cjs"),re=require("./focus-D-h8CbGr.cjs");let a=require("react"),o=require("react/jsx-runtime"),ie=require("react-dom");var ae=[],s=e=>!!(e&&!e.disabled&&!e.divider),c=(0,a.forwardRef)((c,l)=>{let{open:u,defaultOpen:oe=!1,disabled:d=!1,placement:f=`bottom-start`,offset:p=8,closeOnContentClick:se=!0,trigger:m=`hover`,options:h=ae,closeOnOutsideClick:ce=!0,triggerContent:g,menuLabel:le=`菜单`,className:_,style:v,children:ue,onChange:de,onOpen:y,onClose:b,onSelect:fe,onCommand:pe,"aria-label":me,"aria-labelledby":x,...he}=c,S=(0,a.useRef)(null),C=(0,a.useRef)(null),w=(0,a.useRef)(null),T=(0,a.useRef)([]),E=(0,a.useRef)(null),D=(0,a.useRef)(null),O=(0,a.useRef)(null),k=(0,a.useRef)(null),ge=(0,a.useMemo)(()=>ee.n(S,l),[l]),A=r.t(),_e=n.t(c,`open`),[j,ve]=n.n({value:!!u,defaultValue:oe,controlled:_e,onChange:de}),M=j&&!d,[N,P]=(0,a.useState)(-1),[ye,F]=(0,a.useState)({}),[be,I]=(0,a.useState)(f),[L,R]=(0,a.useState)(!1),[z,B]=(0,a.useState)(M),[xe,V]=(0,a.useState)(!1),H=te.t(`vl-dropdown-menu`),Se=(0,a.useCallback)(e=>`${H}-option-${e}`,[H]),U=(0,a.useMemo)(()=>h.flatMap((e,t)=>s(e)?[t]:[]),[h]),Ce=U.length>0,we=h.some(e=>!e.divider),W=U.includes(N)?N:U[0]??-1,Te=(0,a.useMemo)(()=>[`vl-dropdown`,M?`is-open`:``,d?`is-disabled`:``,_||``].filter(Boolean).join(` `),[M,d,_]),Ee=(0,a.useMemo)(()=>({"--vl-dropdown-offset":`${p}px`,...v}),[p,v]),G=(0,a.useCallback)(()=>{let e=E.current;if(e&&e.isConnected){e.focus();return}(C.current?.querySelector(re.i))?.focus()},[]),K=(0,a.useCallback)(()=>{let e=document.activeElement;if(e&&C.current?.contains(e)){E.current=e;return}E.current=C.current?.querySelector(`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`)??null},[]),q=(0,a.useCallback)((e,t=!1)=>{if(!(e&&d)){if(j===e){t&&G();return}e&&(K(),R(!1),F({}),I(f)),ve(e),e?y?.():(b?.(),t&&window.requestAnimationFrame(G))}},[d,j,f,G,K,ve,y,b]),J=(0,a.useCallback)(()=>{O.current!==null&&(window.clearTimeout(O.current),O.current=null)},[]),Y=(0,a.useCallback)(()=>{J(),O.current=window.setTimeout(()=>{let e=document.activeElement;e&&(C.current?.contains(e)||w.current?.contains(e))||q(!1)},160)},[J,q]),X=(0,a.useCallback)(e=>{s(h[e])&&(P(e),T.current[e]?.focus())},[h]),Z=(0,a.useCallback)(()=>{let e=U[0];e!==void 0&&X(e)},[U,X]),Q=(0,a.useCallback)(()=>{let e=U.at(-1);e!==void 0&&X(e)},[U,X]),De=(0,a.useCallback)(e=>{if(!U.length)return;let t=U.indexOf(N),n=t<0?e>0?0:U.length-1:(t+e+U.length)%U.length;X(U[n])},[U,N,X]),$=(0,a.useCallback)(()=>{if(!M)return;let e=w.current;if(!e)return;let t=D.current,n=t?{left:t.x,right:t.x,top:t.y,bottom:t.y,width:0,height:0}:C.current?.getBoundingClientRect();if(!n)return;let r=i.t({anchorRect:n,floatingRect:e.getBoundingClientRect(),placement:f,offset:p});I(r.placement),F({left:`${Math.round(r.x)}px`,top:`${Math.round(r.y)}px`}),R(!0)},[M,f,p]),Oe=e=>{d||m!==`click`||(e.stopPropagation(),D.current=null,q(!M))},ke=()=>{d||m!==`hover`||(D.current=null,J(),q(!0))},Ae=()=>{d||m!==`hover`||Y()},je=()=>{d||m!==`hover`||(D.current=null,J(),q(!0))},Me=e=>{e.currentTarget.contains(e.relatedTarget)||m===`hover`&&Y()},Ne=e=>{d||m!==`context-menu`||(e.preventDefault(),e.stopPropagation(),D.current={x:e.clientX,y:e.clientY},q(!0))},Pe=()=>{m===`hover`&&J()},Fe=()=>{m===`hover`&&Y()},Ie=()=>J(),Le=e=>{s(e)&&(e.onClick?.(e),fe?.(e),pe?.(e.value,e),se&&q(!1,!0))},Re=()=>{h.length||!se||q(!1,!0)},ze=e=>{if(!d){if(D.current=null,e.key===`Escape`&&M){e.preventDefault(),q(!1,!0);return}e.key===`ArrowDown`||e.key===`Enter`||e.key===` `?(e.preventDefault(),K(),M?Z():(k.current=`first`,q(!0))):e.key===`ArrowUp`&&(e.preventDefault(),K(),M?Q():(k.current=`last`,q(!0)))}},Be=e=>{if(M){if(e.key===`Escape`){e.preventDefault(),q(!1,!0);return}if(e.key===`Tab`){q(!1);return}if(Ce){if(e.key===`ArrowDown`)e.preventDefault(),De(1);else if(e.key===`ArrowUp`)e.preventDefault(),De(-1);else if(e.key===`Home`)e.preventDefault(),Z();else if(e.key===`End`)e.preventDefault(),Q();else if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=h[N];t&&Le(t)}}}};(0,a.useEffect)(()=>{d&&j&&q(!1)},[d,j,q]),t.t(()=>{if(!A)return;if(!M){V(!1);return}if(!z){B(!0);return}$(),V(!0);let e=k.current;k.current=null;let t=window.requestAnimationFrame(()=>{$(),e===`first`?Z():e===`last`&&Q()});return()=>window.cancelAnimationFrame(t)},[M,A,z,Z,Q,$]);let Ve=(0,a.useCallback)(()=>{R(!1),F({}),I(f)},[f]),He=(0,a.useCallback)(()=>{M||(B(!1),Ve())},[M,Ve]),Ue=(0,a.useCallback)(()=>q(!1),[q]),We=(0,a.useCallback)(()=>q(!1,!0),[q]);i.r({active:M&&A,rootRef:S,floatingRef:w,closeOnOutsideClick:ce&&m!==`hover`,ignoreEscapeInsideFloating:!0,onOutsideClick:Ue,onEscape:We,onViewportChange:$}),(0,a.useEffect)(()=>()=>J(),[J]);let Ge={"aria-haspopup":`menu`,"aria-expanded":M,"aria-controls":H,"aria-disabled":d||void 0,...me?{"aria-label":me}:{},...x?{"aria-labelledby":x}:{},tabIndex:d?-1:void 0},Ke=(0,a.isValidElement)(g)&&g.type!==a.Fragment?(0,a.cloneElement)(g,Ge):(0,o.jsx)(`button`,{type:`button`,className:`vl-dropdown__defaultTrigger`,disabled:d,...Ge,children:g??`Menu`}),qe=[`vl-dropdown__panel`,`is-${be}`,L?`is-positioned`:``].filter(Boolean).join(` `),Je=(0,o.jsx)(ne.t,{show:A?xe:M,name:`vl-dropdown`,forceMount:A,deferEffects:!A,onAfterLeave:He,children:(0,o.jsx)(`div`,{ref:w,id:H,className:qe,style:{...ye,visibility:A&&!L?`hidden`:`visible`},role:`menu`,"aria-label":le,"aria-hidden":!M||void 0,onClick:Re,onMouseEnter:Pe,onMouseLeave:Fe,onFocus:Ie,onKeyDown:Be,children:(0,o.jsx)(`div`,{className:`vl-dropdown__content`,children:we?h.map((t,n)=>t.divider?(0,o.jsx)(`div`,{className:`vl-dropdown__divider`,role:`separator`},`divider-${n}`):(0,o.jsxs)(`div`,{ref:e=>{T.current[n]=e},id:Se(n),className:[`vl-dropdown__option`,t.status?`is-${t.status}`:``,t.disabled?`is-disabled`:``,W===n?`is-active`:``].filter(Boolean).join(` `),role:`menuitem`,tabIndex:W===n&&!t.disabled?0:-1,"aria-disabled":t.disabled||void 0,onPointerDown:e=>e.preventDefault(),onMouseEnter:()=>{s(t)&&P(n)},onClick:e=>{e.stopPropagation(),Le(t)},children:[t.icon?e.t(t.icon,`vl-dropdown__option-icon`):null,(0,o.jsx)(`span`,{className:`vl-dropdown__option-label`,children:t.label??``})]},t.value??n)):ue})})});return(0,o.jsxs)(`div`,{ref:ge,className:Te,style:Ee,...he,onMouseEnter:ke,onMouseLeave:Ae,onFocus:je,onBlur:Me,children:[(0,o.jsx)(`div`,{ref:C,className:`vl-dropdown__trigger`,onClick:Oe,onContextMenu:Ne,onKeyDown:ze,children:Ke}),z?A?(0,ie.createPortal)(Je,document.body):Je:null]})});c.displayName=`VlDropdown`;var l=c,u=c;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
|
package/dist/Modal-B_VqN16m.js
DELETED
|
@@ -1,201 +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 { t as r } from "./client-pj_wzx28.js";
|
|
4
|
-
import { n as i } from "./refs-D5IYOBaf.js";
|
|
5
|
-
import { n as a, t as o } from "./number-BN2jHM6Z.js";
|
|
6
|
-
import { t as s } from "./id-CHixuHb7.js";
|
|
7
|
-
import { n as ee, r as te, t as ne } from "./dialog-shell-DehX3PNh.js";
|
|
8
|
-
import { X as re } from "lucide-react";
|
|
9
|
-
import { forwardRef as c, useCallback as l, useEffect as u, useMemo as ie, useRef as d, useState as ae } from "react";
|
|
10
|
-
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
11
|
-
//#region components/Modal/Modal.tsx
|
|
12
|
-
var oe = -24, m = c((c, m) => {
|
|
13
|
-
let { open: h, defaultOpen: g = !1, title: _, width: se = 520, offsetY: v = oe, center: ce = !1, mask: le = !0, closeOnClickOverlay: ue = !0, closeOnPressEscape: de = !0, showClose: y = !0, lockScroll: fe = !0, destroyOnClose: b = !1, draggable: x = !0, fullscreen: S = !1, zIndex: C, header: w, footer: T, className: pe, style: me, children: he, onClick: ge, onChange: _e, onOpen: E, onClose: D, onAfterClose: ve, "aria-label": ye, "aria-labelledby": be, "aria-describedby": xe, ...Se } = c, O = r(), k = d(null), Ce = ie(() => i(k, m), [m]), we = n(c, "open"), [A, j] = t({
|
|
14
|
-
value: !!h,
|
|
15
|
-
defaultValue: g,
|
|
16
|
-
controlled: we,
|
|
17
|
-
onChange: _e
|
|
18
|
-
}), [Te, M] = ae(!1), N = d({
|
|
19
|
-
x: 0,
|
|
20
|
-
y: 0
|
|
21
|
-
}), P = d(!1), F = d(!1), I = d({
|
|
22
|
-
x: 0,
|
|
23
|
-
y: 0
|
|
24
|
-
}), L = d(null), R = d(!1), z = s("vl-modal-title"), B = l(() => j(!1), [j]), { isTopLayer: V } = te({
|
|
25
|
-
active: O && A,
|
|
26
|
-
containerRef: k,
|
|
27
|
-
closeOnPressEscape: de,
|
|
28
|
-
lockScroll: fe,
|
|
29
|
-
onRequestClose: B
|
|
30
|
-
}), H = l((e) => {
|
|
31
|
-
k.current && (k.current.style.visibility = e ? "visible" : "hidden");
|
|
32
|
-
}, []), U = l((e, t) => {
|
|
33
|
-
N.current = {
|
|
34
|
-
x: e,
|
|
35
|
-
y: t
|
|
36
|
-
}, k.current && (k.current.style.left = `${e}px`, k.current.style.top = `${t}px`);
|
|
37
|
-
}, []), W = l((e, t) => {
|
|
38
|
-
let n = e.getBoundingClientRect();
|
|
39
|
-
return {
|
|
40
|
-
rect: n,
|
|
41
|
-
maxX: Math.max(t, window.innerWidth - n.width - t),
|
|
42
|
-
maxY: Math.max(t, window.innerHeight - n.height - t)
|
|
43
|
-
};
|
|
44
|
-
}, []), G = l(() => {
|
|
45
|
-
let e = k.current;
|
|
46
|
-
if (!e) return;
|
|
47
|
-
if (S) {
|
|
48
|
-
U(0, 0);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
let { rect: t, maxX: n, maxY: r } = W(e, 16), i = (window.innerHeight - t.height) / 2 + v;
|
|
52
|
-
U(Math.round(o((window.innerWidth - t.width) / 2, 16, n)), Math.round(o(i, 16, r)));
|
|
53
|
-
}, [
|
|
54
|
-
S,
|
|
55
|
-
W,
|
|
56
|
-
v,
|
|
57
|
-
U
|
|
58
|
-
]), K = l(() => {
|
|
59
|
-
let e = k.current;
|
|
60
|
-
if (!e) return;
|
|
61
|
-
let { maxX: t, maxY: n } = W(e, 8);
|
|
62
|
-
U(Math.round(o(N.current.x, 8, t)), Math.round(o(N.current.y, 8, n)));
|
|
63
|
-
}, [W, U]), q = l((e, t) => {
|
|
64
|
-
let n = k.current;
|
|
65
|
-
if (!n || S) return;
|
|
66
|
-
let { maxX: r, maxY: i } = W(n, 8), a = o(e - I.current.x, 8, r), s = o(t - I.current.y, 8, i);
|
|
67
|
-
U(Math.round(a), Math.round(s)), P.current = !0;
|
|
68
|
-
}, [
|
|
69
|
-
S,
|
|
70
|
-
W,
|
|
71
|
-
U
|
|
72
|
-
]), J = d(q);
|
|
73
|
-
e(() => {
|
|
74
|
-
J.current = q;
|
|
75
|
-
}, [q]);
|
|
76
|
-
let Y = l((e) => {
|
|
77
|
-
F.current && J.current(e.clientX, e.clientY);
|
|
78
|
-
}, []), X = l(() => {
|
|
79
|
-
window.removeEventListener("pointermove", Y), L.current?.(), L.current = null;
|
|
80
|
-
}, [Y]), Z = l(() => {
|
|
81
|
-
F.current && (F.current = !1, M(!1), X());
|
|
82
|
-
}, [X]), Ee = (e) => {
|
|
83
|
-
if (!x || S || !A || !V() || e.button !== 0 || e.target.closest(".vl-modal__close")) return;
|
|
84
|
-
let t = k.current;
|
|
85
|
-
if (!t) return;
|
|
86
|
-
let n = t.getBoundingClientRect();
|
|
87
|
-
I.current = {
|
|
88
|
-
x: e.clientX - n.left,
|
|
89
|
-
y: e.clientY - n.top
|
|
90
|
-
}, F.current = !0, M(!0), L.current = ee(), window.addEventListener("pointermove", Y), window.addEventListener("pointerup", Z, { once: !0 });
|
|
91
|
-
};
|
|
92
|
-
u(() => {
|
|
93
|
-
let e = R.current;
|
|
94
|
-
A && !e ? E?.() : !A && e && D?.(), R.current = A;
|
|
95
|
-
}, [
|
|
96
|
-
A,
|
|
97
|
-
E,
|
|
98
|
-
D
|
|
99
|
-
]), e(() => {
|
|
100
|
-
!A || !O || (H(!1), S ? U(0, 0) : !b && P.current ? K() : G(), H(!0));
|
|
101
|
-
}, [
|
|
102
|
-
A,
|
|
103
|
-
O,
|
|
104
|
-
S,
|
|
105
|
-
b,
|
|
106
|
-
G,
|
|
107
|
-
K,
|
|
108
|
-
U,
|
|
109
|
-
H
|
|
110
|
-
]), u(() => {
|
|
111
|
-
A || Z();
|
|
112
|
-
}, [A, Z]), u(() => {
|
|
113
|
-
if (!A) return;
|
|
114
|
-
let e = () => {
|
|
115
|
-
F.current || (P.current ? K() : G());
|
|
116
|
-
};
|
|
117
|
-
return window.addEventListener("resize", e, { passive: !0 }), () => window.removeEventListener("resize", e);
|
|
118
|
-
}, [
|
|
119
|
-
A,
|
|
120
|
-
G,
|
|
121
|
-
K
|
|
122
|
-
]), u(() => () => {
|
|
123
|
-
window.removeEventListener("pointerup", Z), X();
|
|
124
|
-
}, [Z, X]);
|
|
125
|
-
let De = () => {
|
|
126
|
-
ue && V() && B();
|
|
127
|
-
}, Oe = (e) => {
|
|
128
|
-
e.stopPropagation(), ge?.(e);
|
|
129
|
-
}, ke = [
|
|
130
|
-
"vl-modal",
|
|
131
|
-
Te ? "is-dragging" : "",
|
|
132
|
-
ce ? "is-center" : "",
|
|
133
|
-
S ? "is-fullscreen" : "",
|
|
134
|
-
pe || ""
|
|
135
|
-
].filter(Boolean).join(" "), Ae = ["vl-modal__header", x && !S ? "is-draggable" : ""].filter(Boolean).join(" "), Q = { ...me };
|
|
136
|
-
C !== void 0 && (Q.zIndex = C), S ? (Q.width = "100vw", Q.height = "100vh") : Q.width = a(se) ?? "520px";
|
|
137
|
-
let $ = w ?? (_ ? /* @__PURE__ */ f("div", {
|
|
138
|
-
id: z,
|
|
139
|
-
className: "vl-modal__title",
|
|
140
|
-
children: _
|
|
141
|
-
}) : null), je = be ?? (!w && _ ? z : void 0), Me = ye ?? (je ? void 0 : typeof _ == "string" ? _ : "对话框");
|
|
142
|
-
return /* @__PURE__ */ p(ne, {
|
|
143
|
-
clientReady: O,
|
|
144
|
-
open: A,
|
|
145
|
-
mask: le,
|
|
146
|
-
destroyOnClose: b,
|
|
147
|
-
maskTransitionName: "vl-modal-mask",
|
|
148
|
-
transitionName: "vl-modal",
|
|
149
|
-
maskClassName: "vl-modal__mask",
|
|
150
|
-
panelClassName: ke,
|
|
151
|
-
panelStyle: Q,
|
|
152
|
-
maskStyle: C === void 0 ? void 0 : { zIndex: C - 1 },
|
|
153
|
-
panelRef: Ce,
|
|
154
|
-
role: "dialog",
|
|
155
|
-
ariaLabel: Me,
|
|
156
|
-
ariaLabelledBy: je,
|
|
157
|
-
ariaDescribedBy: xe,
|
|
158
|
-
onMaskClick: De,
|
|
159
|
-
onPanelClick: Oe,
|
|
160
|
-
onAfterLeave: () => {
|
|
161
|
-
Z(), b && (P.current = !1), ve?.();
|
|
162
|
-
},
|
|
163
|
-
panelProps: Se,
|
|
164
|
-
children: [
|
|
165
|
-
$ || y ? /* @__PURE__ */ f("div", {
|
|
166
|
-
className: Ae,
|
|
167
|
-
onPointerDown: Ee,
|
|
168
|
-
children: /* @__PURE__ */ p("div", {
|
|
169
|
-
className: "vl-modal__headerInner",
|
|
170
|
-
children: [/* @__PURE__ */ f("div", {
|
|
171
|
-
className: "vl-modal__headerMain",
|
|
172
|
-
children: $
|
|
173
|
-
}), y ? /* @__PURE__ */ f("button", {
|
|
174
|
-
type: "button",
|
|
175
|
-
className: "vl-modal__close",
|
|
176
|
-
"aria-label": "关闭对话框",
|
|
177
|
-
onClick: B,
|
|
178
|
-
children: /* @__PURE__ */ f(re, {
|
|
179
|
-
size: 20,
|
|
180
|
-
"aria-hidden": "true"
|
|
181
|
-
})
|
|
182
|
-
}) : null]
|
|
183
|
-
})
|
|
184
|
-
}) : null,
|
|
185
|
-
/* @__PURE__ */ f("div", {
|
|
186
|
-
className: "vl-modal__body",
|
|
187
|
-
children: he
|
|
188
|
-
}),
|
|
189
|
-
T ? /* @__PURE__ */ f("div", {
|
|
190
|
-
className: "vl-modal__footer",
|
|
191
|
-
children: T
|
|
192
|
-
}) : null
|
|
193
|
-
]
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
m.displayName = "VlModal";
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region components/Modal/index.ts
|
|
199
|
-
var h = m, g = m;
|
|
200
|
-
//#endregion
|
|
201
|
-
export { h as n, g as t };
|
package/dist/Modal-Dm48HmGu.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./number-B7qJF_ZY.cjs"),a=require("./id-CF0zOP1G.cjs"),o=require("./dialog-shell-DT1EoKQG.cjs");let s=require("lucide-react"),c=require("react"),l=require("react/jsx-runtime");var ee=-24,u=(0,c.forwardRef)((u,d)=>{let{open:f,defaultOpen:te=!1,title:p,width:ne=520,offsetY:m=ee,center:re=!1,mask:ie=!0,closeOnClickOverlay:h=!0,closeOnPressEscape:g=!0,showClose:_=!0,lockScroll:ae=!0,destroyOnClose:v=!1,draggable:y=!0,fullscreen:b=!1,zIndex:x,header:S,footer:C,className:oe,style:se,children:ce,onClick:le,onChange:ue,onOpen:w,onClose:T,onAfterClose:de,"aria-label":fe,"aria-labelledby":pe,"aria-describedby":me,...he}=u,E=n.t(),D=(0,c.useRef)(null),ge=(0,c.useMemo)(()=>r.n(D,d),[d]),_e=t.t(u,`open`),[O,k]=t.n({value:!!f,defaultValue:te,controlled:_e,onChange:ue}),[ve,A]=(0,c.useState)(!1),j=(0,c.useRef)({x:0,y:0}),M=(0,c.useRef)(!1),N=(0,c.useRef)(!1),P=(0,c.useRef)({x:0,y:0}),F=(0,c.useRef)(null),I=(0,c.useRef)(!1),L=a.t(`vl-modal-title`),R=(0,c.useCallback)(()=>k(!1),[k]),{isTopLayer:z}=o.r({active:E&&O,containerRef:D,closeOnPressEscape:g,lockScroll:ae,onRequestClose:R}),B=(0,c.useCallback)(e=>{D.current&&(D.current.style.visibility=e?`visible`:`hidden`)},[]),V=(0,c.useCallback)((e,t)=>{j.current={x:e,y:t},D.current&&(D.current.style.left=`${e}px`,D.current.style.top=`${t}px`)},[]),H=(0,c.useCallback)((e,t)=>{let n=e.getBoundingClientRect();return{rect:n,maxX:Math.max(t,window.innerWidth-n.width-t),maxY:Math.max(t,window.innerHeight-n.height-t)}},[]),U=(0,c.useCallback)(()=>{let e=D.current;if(!e)return;if(b){V(0,0);return}let{rect:t,maxX:n,maxY:r}=H(e,16),a=(window.innerHeight-t.height)/2+m;V(Math.round(i.t((window.innerWidth-t.width)/2,16,n)),Math.round(i.t(a,16,r)))},[b,H,m,V]),W=(0,c.useCallback)(()=>{let e=D.current;if(!e)return;let{maxX:t,maxY:n}=H(e,8);V(Math.round(i.t(j.current.x,8,t)),Math.round(i.t(j.current.y,8,n)))},[H,V]),G=(0,c.useCallback)((e,t)=>{let n=D.current;if(!n||b)return;let{maxX:r,maxY:a}=H(n,8),o=i.t(e-P.current.x,8,r),s=i.t(t-P.current.y,8,a);V(Math.round(o),Math.round(s)),M.current=!0},[b,H,V]),K=(0,c.useRef)(G);e.t(()=>{K.current=G},[G]);let q=(0,c.useCallback)(e=>{N.current&&K.current(e.clientX,e.clientY)},[]),J=(0,c.useCallback)(()=>{window.removeEventListener(`pointermove`,q),F.current?.(),F.current=null},[q]),Y=(0,c.useCallback)(()=>{N.current&&(N.current=!1,A(!1),J())},[J]),ye=e=>{if(!y||b||!O||!z()||e.button!==0||e.target.closest(`.vl-modal__close`))return;let t=D.current;if(!t)return;let n=t.getBoundingClientRect();P.current={x:e.clientX-n.left,y:e.clientY-n.top},N.current=!0,A(!0),F.current=o.n(),window.addEventListener(`pointermove`,q),window.addEventListener(`pointerup`,Y,{once:!0})};(0,c.useEffect)(()=>{let e=I.current;O&&!e?w?.():!O&&e&&T?.(),I.current=O},[O,w,T]),e.t(()=>{!O||!E||(B(!1),b?V(0,0):!v&&M.current?W():U(),B(!0))},[O,E,b,v,U,W,V,B]),(0,c.useEffect)(()=>{O||Y()},[O,Y]),(0,c.useEffect)(()=>{if(!O)return;let e=()=>{N.current||(M.current?W():U())};return window.addEventListener(`resize`,e,{passive:!0}),()=>window.removeEventListener(`resize`,e)},[O,U,W]),(0,c.useEffect)(()=>()=>{window.removeEventListener(`pointerup`,Y),J()},[Y,J]);let X=()=>{h&&z()&&R()},be=e=>{e.stopPropagation(),le?.(e)},xe=[`vl-modal`,ve?`is-dragging`:``,re?`is-center`:``,b?`is-fullscreen`:``,oe||``].filter(Boolean).join(` `),Se=[`vl-modal__header`,y&&!b?`is-draggable`:``].filter(Boolean).join(` `),Z={...se};x!==void 0&&(Z.zIndex=x),b?(Z.width=`100vw`,Z.height=`100vh`):Z.width=i.n(ne)??`520px`;let Q=S??(p?(0,l.jsx)(`div`,{id:L,className:`vl-modal__title`,children:p}):null),$=pe??(!S&&p?L:void 0),Ce=fe??($?void 0:typeof p==`string`?p:`对话框`);return(0,l.jsxs)(o.t,{clientReady:E,open:O,mask:ie,destroyOnClose:v,maskTransitionName:`vl-modal-mask`,transitionName:`vl-modal`,maskClassName:`vl-modal__mask`,panelClassName:xe,panelStyle:Z,maskStyle:x===void 0?void 0:{zIndex:x-1},panelRef:ge,role:`dialog`,ariaLabel:Ce,ariaLabelledBy:$,ariaDescribedBy:me,onMaskClick:X,onPanelClick:be,onAfterLeave:()=>{Y(),v&&(M.current=!1),de?.()},panelProps:he,children:[Q||_?(0,l.jsx)(`div`,{className:Se,onPointerDown:ye,children:(0,l.jsxs)(`div`,{className:`vl-modal__headerInner`,children:[(0,l.jsx)(`div`,{className:`vl-modal__headerMain`,children:Q}),_?(0,l.jsx)(`button`,{type:`button`,className:`vl-modal__close`,"aria-label":`关闭对话框`,onClick:R,children:(0,l.jsx)(s.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,l.jsx)(`div`,{className:`vl-modal__body`,children:ce}),C?(0,l.jsx)(`div`,{className:`vl-modal__footer`,children:C}):null]})});u.displayName=`VlModal`;var d=u,f=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
|
package/dist/Select-DQLup8Y-.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./icon-DRLyKu8p.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./floating-DXRnx48N.cjs"),ee=require("./id-CF0zOP1G.cjs"),te=require("./Transition-X_89ga-e.cjs");let a=require("lucide-react"),o=require("react"),s=require("react/jsx-runtime"),ne=require("react-dom");var c=e=>!!(e&&!e.disabled&&!e.divider),l=(0,o.forwardRef)((l,u)=>{let{value:re,defaultValue:ie,options:d=[],placeholder:f=`请选择`,filterable:ae=!1,filterPlaceholder:oe=`搜索`,multiple:se=!1,taggable:p=!1,maxTagCount:m,disabled:h=!1,loading:g=!1,size:ce=`md`,clearable:le=!1,placement:_=`bottom-start`,offset:ue=8,emptyText:de=`暂无数据`,renderOption:fe,emptyContent:pe,className:v,style:me,onChange:he,onClear:ge,onOpen:_e,onClose:y,onFocus:ve,onBlur:ye,id:be,"aria-label":xe,"aria-labelledby":Se,"aria-describedby":Ce,tabIndex:we,...Te}=l,Ee=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),De=(0,o.useRef)(null),Oe=(0,o.useRef)([]),ke=(0,o.useMemo)(()=>r.n(Ee,u),[u]),S=n.t(),C=ae||p,w=se||p,Ae=(0,o.useMemo)(()=>w?[]:null,[w]),je=t.t(l,`value`),T=(0,o.useRef)(void 0),[E,Me]=t.n({value:re??Ae,defaultValue:ie??Ae,controlled:je,onChange:e=>{let t=T.current;T.current=void 0,he?.(e,t)}}),[D,Ne]=(0,o.useState)(!1),[Pe,Fe]=(0,o.useState)(!1),[O,Ie]=(0,o.useState)(!1),[k,A]=(0,o.useState)(``),[Le,j]=(0,o.useState)([]),[Re,ze]=(0,o.useState)({}),[M,Be]=(0,o.useState)(_),[N,P]=(0,o.useState)(-1),Ve=ee.t(`vl-select-control`,be),F=ee.t(`vl-select-listbox`),He=(0,o.useCallback)(e=>`${F}-option-${e}`,[F]),Ue=(0,o.useMemo)(()=>[`vl-select-wrapper`,v||``].filter(Boolean).join(` `),[v]),We=(0,o.useMemo)(()=>[`vl-select`,`size-${ce}`,w?`is-multiple`:``,D?`is-open`:``,O?`is-focus-within`:``,h?`is-disabled`:``,g?`is-loading`:``].filter(Boolean).join(` `),[ce,w,D,O,h,g]),I=(0,o.useMemo)(()=>{if(!p)return d;let e=Le.filter(e=>!d.some(t=>t.value===e.value));return[...d,...e]},[d,Le,p]),L=(0,o.useMemo)(()=>{if(!C||!D)return I;let e=k.trim().toLocaleLowerCase();return e?I.filter(t=>!t.divider&&t.label.toLocaleLowerCase().includes(e)):I},[I,C,D,k]),R=(0,o.useMemo)(()=>L.flatMap((e,t)=>c(e)?[t]:[]),[L]),Ge=L.some(e=>!e.divider),z=(0,o.useMemo)(()=>w&&Array.isArray(E)?E:[],[w,E]),B=(0,o.useMemo)(()=>{if(!(w||Array.isArray(E)))return I.find(e=>e.value===E)},[I,w,E]),V=(0,o.useMemo)(()=>w?``:B?B.label:E===null||E===``||Array.isArray(E)?``:String(E),[w,B,E]),H=(0,o.useMemo)(()=>z.map(e=>({value:e,label:I.find(t=>t.value===e)?.label??String(e)})),[z,I]),Ke=(0,o.useMemo)(()=>!w||m===void 0||!Number.isFinite(m)?1/0:Math.max(0,Math.floor(m)),[w,m]),qe=Ke===1/0?H:H.slice(0,Ke),U=Math.max(0,H.length-qe.length),Je=w?z.length>0:E!==null&&E!==``&&!Array.isArray(E),Ye=le&&!h&&!g&&Je&&(Pe||O||D),Xe=N>=0&&c(L[N])?He(N):void 0,Ze=(0,o.useMemo)(()=>[`vl-select__panel`,`is-${M}`].join(` `),[M]),W=(0,o.useCallback)(e=>{e&&(h||g)||D!==e&&(Ne(e),e?_e?.():y?.())},[h,g,_e,y,D]),G=(0,o.useCallback)(e=>w?z.includes(e.value):e.value===E,[w,z,E]),K=(0,o.useCallback)((e,t)=>{T.current=t,Me(e),T.current=void 0},[Me]),q=(0,o.useCallback)(e=>{p&&j(t=>t.filter(t=>e.includes(t.value)))},[p]),J=(0,o.useCallback)(e=>{if(c(e)){if(w){let t=z.includes(e.value)?z.filter(t=>t!==e.value):[...z,e.value];K(t,e),q(t),A(``);return}K(e.value,e),A(e.label),W(!1)}},[w,z,K,q,W]),Qe=(0,o.useCallback)(e=>{if(!p)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)?A(``):J(r),!0;let i={label:t,value:t};return j(e=>[...e,i]),J(i),!0},[p,I,G,J]),Y=(0,o.useCallback)(()=>{let e=L.findIndex(e=>c(e)&&G(e));return e>=0?e:R[0]??-1},[L,R,G]),X=(0,o.useCallback)(e=>{c(L[e])&&(P(e),Oe.current[e]?.scrollIntoView?.({block:`nearest`}))},[L]),$e=(0,o.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]),et=(0,o.useCallback)(()=>{let e=R[0];e!==void 0&&X(e)},[R,X]),tt=(0,o.useCallback)(()=>{let e=R.at(-1);e!==void 0&&X(e)},[R,X]),Z=(0,o.useCallback)(()=>{if(!D)return;let e=b.current,t=x.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=i.t({anchorRect:n,floatingRect:t.getBoundingClientRect(),placement:_,offset:ue});Be(r.placement),ze({left:`${Math.round(r.x)}px`,top:`${Math.round(r.y)}px`,minWidth:`${Math.round(n.width)}px`})},[D,_,ue]),Q=(0,o.useCallback)(()=>{C?De.current?.focus():b.current?.focus()},[C]),$=(0,o.useCallback)((e=`first`)=>{if(h||g)return;D||(C&&A(``),W(!0));let t=e===`last`?R.at(-1):Y();t!==void 0&&t>=0&&P(t),window.requestAnimationFrame(()=>{Q(),Z()})},[h,g,D,C,W,R,Y,Q,Z]),nt=(0,o.useCallback)(()=>{W(!1),window.requestAnimationFrame(Q)},[W,Q]),rt=(0,o.useCallback)(()=>{let e=L[N];return c(e)?(J(e),!0):!1},[L,N,J]),it=e=>{if(!(h||g)&&!e.target.closest(`button`)){if(C){$();return}D?W(!1):$()}},at=e=>{if(!(h||g)){if(e.key===`ArrowDown`){e.preventDefault(),D?$e(1):$(`first`);return}if(e.key===`ArrowUp`){e.preventDefault(),D?$e(-1):$(`last`);return}if(e.key===`Home`&&D&&!C){e.preventDefault(),et();return}if(e.key===`End`&&D&&!C){e.preventDefault(),tt();return}if(e.key===`Escape`&&D){e.preventDefault(),nt();return}if(e.key===`Tab`&&D){W(!1);return}if(e.key===`Enter`){if(!D){e.preventDefault(),$();return}e.preventDefault(),!rt()&&C&&Qe(k);return}if(e.key===` `&&!C){e.preventDefault(),D?rt():$();return}if(e.key===`Backspace`&&C&&w&&!k&&z.length){let e=z.slice(0,-1);K(e),q(e)}}},ot=()=>{h||g||(K(w?[]:null),ge?.(),A(``),q([]),W(!1),Q())},st=e=>{if(h||g)return;let t=z.filter(t=>t!==e);K(t),q(t)},ct=e=>{e.currentTarget.contains(e.relatedTarget)||(Ie(!0),ve?.(e))},lt=e=>{e.currentTarget.contains(e.relatedTarget)||(Ie(!1),ye?.(e))};(0,o.useEffect)(()=>{D||(A(w?``:V),P(-1))},[D,w,V]),(0,o.useEffect)(()=>{if(!D||!S)return;P(Y());let e=window.requestAnimationFrame(Z);return()=>window.cancelAnimationFrame(e)},[D,S,L,Y,Z]),(0,o.useEffect)(()=>{if(!p||!w)return;let e=new Set(I.map(e=>e.value)),t=z.filter(t=>!e.has(t));t.length&&j(e=>[...e,...t.map(e=>({label:String(e),value:e}))])},[p,w,I,z]),(0,o.useEffect)(()=>{(h||g)&&D&&W(!1)},[h,g,D,W]),i.r({active:D&&S,rootRef:Ee,floatingRef:x,onOutsideClick:()=>W(!1),onViewportChange:Z});let ut={role:`combobox`,"aria-controls":F,"aria-expanded":D,"aria-haspopup":`listbox`,"aria-activedescendant":D?Xe:void 0,"aria-disabled":h||g||void 0,"aria-busy":g||void 0,"aria-label":xe??(Se?void 0:f),"aria-labelledby":Se,"aria-describedby":Ce},dt=C?(0,s.jsx)(`input`,{ref:De,id:Ve,className:`vl-select__input`,type:`text`,value:k,placeholder:D?oe:w&&z.length?``:f,disabled:h||g,autoComplete:`off`,"aria-autocomplete":`list`,...ut,tabIndex:we,onChange:e=>{A(e.target.value),D||W(!0)},onFocus:()=>{D||$()},onKeyDown:at}):null,ft=(0,s.jsx)(te.t,{show:D,name:`vl-select`,deferEffects:!S,children:(0,s.jsx)(`div`,{ref:x,id:F,className:Ze,style:Re,role:`listbox`,"aria-hidden":!D||void 0,"aria-multiselectable":w||void 0,children:Ge?(0,s.jsx)(`div`,{className:`vl-select__list`,children:L.map((t,n)=>{if(t.divider)return(0,s.jsx)(`div`,{className:`vl-select__divider`,role:`separator`},`divider-${n}`);let r=G(t),i=[`vl-select__option`,t.disabled?`is-disabled`:``,r?`is-selected`:``,N===n?`is-active`:``].filter(Boolean).join(` `);return(0,s.jsx)(`div`,{ref:e=>{Oe.current[n]=e},id:He(n),className:i,role:`option`,"aria-disabled":t.disabled||void 0,"aria-selected":r,onPointerDown:e=>e.preventDefault(),onMouseEnter:()=>{c(t)&&P(n)},onClick:()=>J(t),children:fe?fe(t,n,r):(0,s.jsxs)(s.Fragment,{children:[t.icon?e.t(t.icon,`vl-select__option-icon`):null,(0,s.jsx)(`span`,{className:`vl-select__option-label`,children:t.label})]})},`${String(t.value)}-${n}`)})}):(0,s.jsx)(`div`,{className:`vl-select__empty`,role:`status`,children:pe??de})})});return(0,s.jsxs)(`div`,{ref:ke,className:Ue,style:me,...Te,onMouseEnter:()=>Fe(!0),onMouseLeave:()=>Fe(!1),children:[(0,s.jsxs)(`div`,{ref:b,id:C?void 0:Ve,className:We,...C?{}:ut,tabIndex:h||g||C?-1:we??0,onClick:it,onKeyDown:C?void 0:at,onFocus:ct,onBlur:lt,children:[(0,s.jsx)(`div`,{className:`vl-select__value`,children:w?(0,s.jsxs)(`div`,{className:`vl-select__tags`,children:[qe.map(e=>(0,s.jsxs)(`span`,{className:`vl-select__tag`,children:[(0,s.jsx)(`span`,{className:`vl-select__tag-label`,children:e.label}),(0,s.jsx)(`button`,{type:`button`,className:`vl-select__tag-remove`,"aria-label":`移除 ${e.label}`,disabled:h||g,onClick:()=>st(e.value),onPointerDown:e=>e.stopPropagation(),children:(0,s.jsx)(a.X,{size:12,"aria-hidden":`true`})})]},e.value)),U>0?(0,s.jsxs)(`span`,{className:`vl-select__tag is-collapsed`,"aria-label":`另有 ${U} 项`,children:[`+`,U]}):null,C?dt:H.length?null:(0,s.jsx)(`span`,{className:`vl-select__placeholder`,children:f})]}):C?dt:V?(0,s.jsx)(`span`,{className:`vl-select__label`,children:V}):(0,s.jsx)(`span`,{className:`vl-select__placeholder`,children:f})}),(0,s.jsxs)(`div`,{className:`vl-select__suffix`,children:[Ye?(0,s.jsx)(`button`,{type:`button`,className:`vl-select__clear`,"aria-label":`清除已选`,onClick:ot,onPointerDown:e=>e.stopPropagation(),children:(0,s.jsx)(a.X,{size:16,"aria-hidden":`true`})}):null,g?(0,s.jsx)(a.LoaderCircle,{className:`vl-select__loading`,size:16,"aria-hidden":`true`}):(0,s.jsx)(`span`,{className:`vl-select__arrow`,"aria-hidden":`true`,children:(0,s.jsx)(a.ChevronDown,{size:16})})]})]}),S?(0,ne.createPortal)(ft,document.body):ft]})});l.displayName=`VlSelect`;var u=l,re=l;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return re}});
|