@vavt/react-ui 1.2.2 → 1.3.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/README.md +1 -1
- package/dist/Announcement-BUvNHscy.cjs +1 -0
- package/dist/Announcement-CznCpx2T.js +174 -0
- package/dist/Badge-BkqoSV-F.cjs +1 -0
- package/dist/Badge-FzXPw1qS.js +72 -0
- package/dist/{Cron-DIB4GG4y.js → Cron-C3S1XI-J.js} +18 -18
- package/dist/{Cron-MhbYMEeJ.cjs → Cron-CIZ9GKm0.cjs} +1 -1
- package/dist/{DatePicker-Bj709smn.cjs → DatePicker-B5uYQlzy.cjs} +1 -1
- package/dist/{DatePicker--13tW0cw.js → DatePicker-DhRxFPCj.js} +1 -1
- package/dist/{DateTimePicker-Blqs2Bcv.js → DateTimePicker-BjDD15Av.js} +1 -1
- package/dist/{DateTimePicker-ZSScsk-j.cjs → DateTimePicker-Bve5qoeh.cjs} +1 -1
- package/dist/Drawer-DNZCj--j.js +113 -0
- package/dist/Drawer-YWO6-KLG.cjs +1 -0
- package/dist/{Dropdown-mYCY-LcF.js → Dropdown-BcT4uaQT.js} +13 -13
- package/dist/Dropdown-CPW-aSTx.cjs +1 -0
- package/dist/Form-LuUPwJc2.cjs +1 -0
- package/dist/Form-rXq9r3N-.js +442 -0
- package/dist/{Loading-CL0wUgYK.js → Loading-BAKnIASq.js} +4 -4
- package/dist/{Loading-C2pY-4fA.cjs → Loading-BSqhKOle.cjs} +1 -1
- package/dist/MessageBox-C35_ifsL.js +166 -0
- package/dist/MessageBox-C6NLihE1.cjs +1 -0
- package/dist/{Modal-Du7aVdWl.js → Modal-6kNs-9QU.js} +13 -12
- package/dist/Modal-BKvRyCXZ.cjs +1 -0
- package/dist/{Pagination-DatEegaF.cjs → Pagination-BRxRbWlU.cjs} +1 -1
- package/dist/{Pagination-CpbboRbF.js → Pagination-DTRhw83o.js} +1 -1
- package/dist/Select-B9umyfKd.cjs +1 -0
- package/dist/{Select-BHWa_6Q2.js → Select-DDsgKaDL.js} +13 -13
- package/dist/{Table-BNGO_7Rx.cjs → Table-B1BEfBJC.cjs} +1 -1
- package/dist/{Table-Cfs3XJgN.js → Table-DdWKhZAZ.js} +1 -1
- package/dist/{TimePicker-CYlcUTTM.js → TimePicker-77L1Vyxn.js} +12 -12
- package/dist/{TimePicker-DoGbwfkU.cjs → TimePicker-CsaiM5CQ.cjs} +1 -1
- package/dist/{Tooltip-BKPreZML.js → Tooltip-DH3oc4Wa.js} +18 -18
- package/dist/{Tooltip-DDjGLjoV.cjs → Tooltip-DP2yxQpo.cjs} +1 -1
- package/dist/base.css +1 -1
- package/dist/cjs/Announcement.cjs +1 -1
- package/dist/cjs/Badge.cjs +1 -0
- 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/Loading.cjs +1 -1
- 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/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/css/Announcement.css +1 -1
- package/dist/css/Badge.css +1 -0
- package/dist/css/Form.css +1 -1
- package/dist/css/Modal.css +1 -1
- package/dist/date-picker-CIAVlMqv.cjs +1 -0
- package/dist/{date-picker-CHP0eBuL.js → date-picker-Co0ySn01.js} +14 -14
- package/dist/dialog-shell-B7mE8A1p.cjs +1 -0
- package/dist/dialog-shell-FS5nSlBm.js +118 -0
- package/dist/es/Announcement.mjs +1 -1
- package/dist/es/Badge.mjs +3 -0
- 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/Loading.mjs +1 -1
- 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/global.mjs +1 -1
- package/dist/es/index.mjs +41 -40
- package/dist/es/register.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/{layer-DDm97-sb.js → layer-C1yCY0MO.js} +1 -1
- package/dist/{layer-BgiUZy_t.cjs → layer-DL1xVbJT.cjs} +1 -1
- package/dist/registry-Chcx2tDO.cjs +1 -0
- package/dist/registry-DbMCy1-n.js +87 -0
- package/dist/style/Badge.cjs +8 -0
- package/dist/style/Badge.mjs +8 -0
- package/dist/types/Announcement/type.d.cts +2 -2
- package/dist/types/Announcement/type.d.ts +2 -2
- package/dist/types/Badge/Badge.d.cts +3 -0
- package/dist/types/Badge/Badge.d.ts +3 -0
- package/dist/types/Badge/index.d.cts +5 -0
- package/dist/types/Badge/index.d.ts +5 -0
- package/dist/types/Badge/type.d.cts +31 -0
- package/dist/types/Badge/type.d.ts +31 -0
- 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 +4 -2
- package/dist/types/Form/context.d.ts +4 -2
- package/dist/types/Form/index.d.cts +2 -2
- package/dist/types/Form/index.d.ts +2 -2
- package/dist/types/_shared/dialog.d.cts +5 -1
- package/dist/types/_shared/dialog.d.ts +5 -1
- package/dist/types/global.d.cts +2 -0
- package/dist/types/global.d.ts +2 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/registry.d.cts +2 -1
- package/dist/types/registry.d.ts +2 -1
- package/package.json +1 -1
- package/dist/Announcement-D0hZE2sM.cjs +0 -1
- package/dist/Announcement-DzzaTvcO.js +0 -212
- package/dist/Drawer-DcbgMkub.cjs +0 -1
- package/dist/Drawer-yM_r1M0H.js +0 -112
- package/dist/Dropdown-PHqXNiAZ.cjs +0 -1
- package/dist/Form-BkyDHPEI.cjs +0 -1
- package/dist/Form-D_Uv-8HG.js +0 -449
- package/dist/MessageBox-D7Ib1f7K.cjs +0 -1
- package/dist/MessageBox-DDP6UWFU.js +0 -141
- package/dist/Modal-DPxZEr2v.cjs +0 -1
- package/dist/Select-C6O0tmM_.cjs +0 -1
- package/dist/date-picker-Be_1wA3S.cjs +0 -1
- package/dist/dialog-shell-CdYlPT9f.js +0 -111
- package/dist/dialog-shell-CzeGytVj.cjs +0 -1
- package/dist/registry-BUQSQSwB.js +0 -85
- package/dist/registry-DF1N2ITX.cjs +0 -1
- package/dist/types/Announcement/host.d.cts +0 -12
- package/dist/types/Announcement/host.d.ts +0 -12
package/dist/Form-D_Uv-8HG.js
DELETED
|
@@ -1,449 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
-
import { t } from "./state-BSDh-Ob2.js";
|
|
3
|
-
import { t as n } from "./refs-D5IYOBaf.js";
|
|
4
|
-
import { t as r } from "./id-CHixuHb7.js";
|
|
5
|
-
import { n as i } from "./focus-BDDJyKk3.js";
|
|
6
|
-
import { t as a } from "./Tooltip-BKPreZML.js";
|
|
7
|
-
import { cloneElement as o, createContext as s, forwardRef as c, isValidElement as l, memo as u, useCallback as d, useContext as f, useEffect as ee, useImperativeHandle as p, useMemo as m, useRef as h, useState as te, useSyncExternalStore as g } from "react";
|
|
8
|
-
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
9
|
-
//#region components/Form/context.ts
|
|
10
|
-
var y = [], b = Object.freeze({
|
|
11
|
-
value: void 0,
|
|
12
|
-
errors: y,
|
|
13
|
-
isValidating: !1
|
|
14
|
-
}), x = s(null), ne = x.Provider, S = () => f(x), C = s(null).Provider, re = (e) => {
|
|
15
|
-
let t = S(), n = d((n) => !e || !t ? () => {} : t.subscribeField(e, n), [t, e]), r = d(() => !e || !t ? b : t.getFieldState(e), [t, e]);
|
|
16
|
-
return g(n, r, r);
|
|
17
|
-
}, w = ["blur", "submit"], T = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, E = (e) => e ? Array.isArray(e) ? e : [e] : w, D = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) && e.length === 0, O = (e, t, n, r) => {
|
|
18
|
-
let i = t ?? e;
|
|
19
|
-
if (n.required && D(r)) return n.message ?? `请输入${i}`;
|
|
20
|
-
if (D(r)) return;
|
|
21
|
-
if (n.type && !(n.type === "array" ? Array.isArray(r) : n.type === "email" ? typeof r == "string" && T.test(r) : typeof r === n.type) || (n.pattern && (n.pattern.lastIndex = 0), n.pattern && (typeof r != "string" || !n.pattern.test(r)))) return n.message ?? `${i}格式不正确`;
|
|
22
|
-
let a = typeof r == "number" ? r : typeof r == "string" || Array.isArray(r) ? r.length : null;
|
|
23
|
-
if (n.len !== void 0 && a !== null && a !== n.len) return n.message ?? `${i}长度必须为 ${n.len}`;
|
|
24
|
-
if (n.min !== void 0 && a !== null && a < n.min) return n.message ?? `${i}不能小于 ${n.min}`;
|
|
25
|
-
if (n.max !== void 0 && a !== null && a > n.max) return n.message ?? `${i}不能大于 ${n.max}`;
|
|
26
|
-
}, k = c((n, r) => {
|
|
27
|
-
let { values: a, defaultValues: o = {}, layout: s = "vertical", labelWidth: c, labelAlign: l = s === "horizontal" ? "right" : "left", validateTrigger: u, className: f, style: ee, children: g, onValuesChange: v, onFinish: b, onFinishError: x, onFinishFailed: S, noValidate: re = !0, ...w } = n, T = t(n, "values"), D = h(T ? a ?? {} : o), k = h({}), A = h({}), j = h(!1), [ie, ae] = te(!1), M = h(null), N = h(/* @__PURE__ */ new Map()), P = h(/* @__PURE__ */ new Map()), F = h(/* @__PURE__ */ new Map()), I = h(/* @__PURE__ */ new Map()), L = h(v), R = h(b), z = h(x), B = h(S);
|
|
28
|
-
e(() => {
|
|
29
|
-
L.current = v, R.current = b, z.current = x, B.current = S;
|
|
30
|
-
});
|
|
31
|
-
let V = m(() => E(u), [u]), H = d((e) => {
|
|
32
|
-
let t = F.current.get(e);
|
|
33
|
-
t && t.forEach((e) => e());
|
|
34
|
-
}, []), U = d((e, t) => {
|
|
35
|
-
let n = F.current.get(e);
|
|
36
|
-
return n || (n = /* @__PURE__ */ new Set(), F.current.set(e, n)), n.add(t), () => {
|
|
37
|
-
n?.delete(t), n && n.size === 0 && F.current.delete(e);
|
|
38
|
-
};
|
|
39
|
-
}, []), W = d((e) => {
|
|
40
|
-
let t = D.current[e], n = k.current[e] ?? y, r = !!A.current[e], i = I.current.get(e);
|
|
41
|
-
if (i && Object.is(i.value, t) && i.errors === n && i.isValidating === r) return i;
|
|
42
|
-
let a = {
|
|
43
|
-
value: t,
|
|
44
|
-
errors: n,
|
|
45
|
-
isValidating: r
|
|
46
|
-
};
|
|
47
|
-
return I.current.set(e, a), a;
|
|
48
|
-
}, []);
|
|
49
|
-
e(() => {
|
|
50
|
-
if (T) {
|
|
51
|
-
let e = a ?? {}, t = D.current;
|
|
52
|
-
if (t !== e) {
|
|
53
|
-
D.current = e;
|
|
54
|
-
let n = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(e)]);
|
|
55
|
-
for (let r of n) Object.is(t[r], e[r]) || H(r);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, [
|
|
59
|
-
T,
|
|
60
|
-
H,
|
|
61
|
-
a
|
|
62
|
-
]);
|
|
63
|
-
let G = d((e) => {
|
|
64
|
-
let t = k.current;
|
|
65
|
-
k.current = e;
|
|
66
|
-
let n = /* @__PURE__ */ new Set();
|
|
67
|
-
for (let r of Object.keys(t)) t[r] !== e[r] && n.add(r);
|
|
68
|
-
for (let r of Object.keys(e)) t[r] !== e[r] && n.add(r);
|
|
69
|
-
n.forEach((e) => {
|
|
70
|
-
H(e);
|
|
71
|
-
});
|
|
72
|
-
}, [H]), K = d((e) => (N.current.set(e.name, e), () => {
|
|
73
|
-
if (N.current.get(e.name)?.token === e.token) {
|
|
74
|
-
if (N.current.delete(e.name), P.current.delete(e.name), I.current.delete(e.name), Object.prototype.hasOwnProperty.call(k.current, e.name)) {
|
|
75
|
-
let t = { ...k.current };
|
|
76
|
-
delete t[e.name], G(t);
|
|
77
|
-
}
|
|
78
|
-
if (A.current[e.name]) {
|
|
79
|
-
let t = { ...A.current };
|
|
80
|
-
delete t[e.name], A.current = t, H(e.name);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}), [G, H]), q = d((e, t) => {
|
|
84
|
-
let n = {
|
|
85
|
-
...D.current,
|
|
86
|
-
[e]: t
|
|
87
|
-
};
|
|
88
|
-
return T || (D.current = n, H(e)), L.current?.({ [e]: t }, n), n;
|
|
89
|
-
}, [T, H]), J = d(async (e, t) => {
|
|
90
|
-
let n = N.current.get(e);
|
|
91
|
-
if (!n) return [];
|
|
92
|
-
let r = t ?? D.current, i = r[e], a = Symbol(e);
|
|
93
|
-
P.current.set(e, a), A.current = {
|
|
94
|
-
...A.current,
|
|
95
|
-
[e]: !0
|
|
96
|
-
}, H(e);
|
|
97
|
-
let o = [], { rules: s, label: c } = n.metaRef.current;
|
|
98
|
-
for (let t of s) {
|
|
99
|
-
let n = O(e, c, t, i);
|
|
100
|
-
if (n && o.push(n), t.validator) try {
|
|
101
|
-
let e = await t.validator(i, r);
|
|
102
|
-
e && o.push(t.message ?? e);
|
|
103
|
-
} catch (e) {
|
|
104
|
-
let n = e instanceof Error ? e.message : "校验失败";
|
|
105
|
-
o.push(t.message ?? n);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (N.current.get(e)?.token !== n.token || P.current.get(e) !== a) return o;
|
|
109
|
-
let l = { ...k.current };
|
|
110
|
-
return o.length ? l[e] = o : delete l[e], G(l), A.current = {
|
|
111
|
-
...A.current,
|
|
112
|
-
[e]: !1
|
|
113
|
-
}, H(e), o;
|
|
114
|
-
}, [G, H]), Y = d(async () => {
|
|
115
|
-
let e = D.current, t = [...N.current.values()], n = await Promise.all(t.map(async (t) => {
|
|
116
|
-
let n = J(t.name, e);
|
|
117
|
-
return [
|
|
118
|
-
t,
|
|
119
|
-
P.current.get(t.name),
|
|
120
|
-
await n
|
|
121
|
-
];
|
|
122
|
-
})), r = { ...k.current };
|
|
123
|
-
return n.forEach(([e, t, n]) => {
|
|
124
|
-
N.current.get(e.name)?.token === e.token && P.current.get(e.name) === t && (n.length ? r[e.name] = n : delete r[e.name]);
|
|
125
|
-
}), G(r), {
|
|
126
|
-
valid: Object.keys(r).length === 0,
|
|
127
|
-
values: e,
|
|
128
|
-
errors: r
|
|
129
|
-
};
|
|
130
|
-
}, [G, J]), X = d(() => {
|
|
131
|
-
if (M.current) return M.current;
|
|
132
|
-
let e = (async () => {
|
|
133
|
-
j.current = !0, ae(!0);
|
|
134
|
-
try {
|
|
135
|
-
let e = await Y();
|
|
136
|
-
if (e.valid) try {
|
|
137
|
-
await R.current?.(e.values);
|
|
138
|
-
} catch (t) {
|
|
139
|
-
z.current?.(t, e.values);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
B.current?.(e.errors, e.values);
|
|
143
|
-
let t = [...N.current.keys()].find((t) => e.errors[t]);
|
|
144
|
-
t && i(N.current.get(t)?.metaRef.current.element ?? null);
|
|
145
|
-
}
|
|
146
|
-
return e;
|
|
147
|
-
} finally {
|
|
148
|
-
j.current = !1, ae(!1);
|
|
149
|
-
}
|
|
150
|
-
})();
|
|
151
|
-
return M.current = e, e.then(() => {
|
|
152
|
-
M.current === e && (M.current = null);
|
|
153
|
-
}, () => {
|
|
154
|
-
M.current === e && (M.current = null);
|
|
155
|
-
}), e;
|
|
156
|
-
}, [Y]), Z = d((e) => {
|
|
157
|
-
let t = D.current, n = {
|
|
158
|
-
...t,
|
|
159
|
-
...e
|
|
160
|
-
};
|
|
161
|
-
D.current = n;
|
|
162
|
-
for (let r of Object.keys(e)) Object.is(t[r], n[r]) || H(r);
|
|
163
|
-
L.current?.(e, n);
|
|
164
|
-
}, [H]), Q = d(() => {
|
|
165
|
-
let e = { ...o }, t = D.current;
|
|
166
|
-
D.current = e;
|
|
167
|
-
let n = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(e)]), r = Object.fromEntries([...n].filter((n) => !Object.is(t[n], e[n])).map((t) => [t, e[t]]));
|
|
168
|
-
Object.keys(r).length && L.current?.(r, e), n.forEach((n) => {
|
|
169
|
-
Object.is(t[n], e[n]) || H(n);
|
|
170
|
-
}), G({}), P.current.clear();
|
|
171
|
-
let i = A.current;
|
|
172
|
-
A.current = {}, Object.keys(i).forEach((e) => {
|
|
173
|
-
i[e] && H(e);
|
|
174
|
-
});
|
|
175
|
-
}, [
|
|
176
|
-
G,
|
|
177
|
-
o,
|
|
178
|
-
H
|
|
179
|
-
]);
|
|
180
|
-
p(r, () => ({
|
|
181
|
-
getValues: () => D.current,
|
|
182
|
-
setValues: Z,
|
|
183
|
-
reset: Q,
|
|
184
|
-
validate: Y,
|
|
185
|
-
submit: X,
|
|
186
|
-
isSubmitting: () => j.current,
|
|
187
|
-
getErrors: () => k.current
|
|
188
|
-
}), [
|
|
189
|
-
Q,
|
|
190
|
-
Z,
|
|
191
|
-
X,
|
|
192
|
-
Y
|
|
193
|
-
]);
|
|
194
|
-
let oe = m(() => ({
|
|
195
|
-
defaultValidateTrigger: V,
|
|
196
|
-
registerField: K,
|
|
197
|
-
updateField: q,
|
|
198
|
-
validateField: J,
|
|
199
|
-
subscribeField: U,
|
|
200
|
-
getFieldState: W
|
|
201
|
-
}), [
|
|
202
|
-
V,
|
|
203
|
-
W,
|
|
204
|
-
K,
|
|
205
|
-
U,
|
|
206
|
-
q,
|
|
207
|
-
J
|
|
208
|
-
]), $ = m(() => ({
|
|
209
|
-
get values() {
|
|
210
|
-
return D.current;
|
|
211
|
-
},
|
|
212
|
-
get errors() {
|
|
213
|
-
return k.current;
|
|
214
|
-
},
|
|
215
|
-
get validating() {
|
|
216
|
-
return A.current;
|
|
217
|
-
},
|
|
218
|
-
defaultValidateTrigger: V,
|
|
219
|
-
registerField: K,
|
|
220
|
-
updateField: q,
|
|
221
|
-
validateField: J
|
|
222
|
-
}), [
|
|
223
|
-
V,
|
|
224
|
-
K,
|
|
225
|
-
q,
|
|
226
|
-
J
|
|
227
|
-
]), se = {
|
|
228
|
-
...ee,
|
|
229
|
-
...c === void 0 ? null : { "--vl-form-label-width": typeof c == "number" ? `${c}px` : c }
|
|
230
|
-
}, ce = [
|
|
231
|
-
"vl-form",
|
|
232
|
-
`vl-form--${s}`,
|
|
233
|
-
`vl-form--label-${l}`,
|
|
234
|
-
ie ? "is-submitting" : "",
|
|
235
|
-
f || ""
|
|
236
|
-
].filter(Boolean).join(" "), le = (e) => {
|
|
237
|
-
e.preventDefault(), X();
|
|
238
|
-
}, ue = (e) => {
|
|
239
|
-
e.preventDefault(), Q();
|
|
240
|
-
};
|
|
241
|
-
return /* @__PURE__ */ _(ne, {
|
|
242
|
-
value: oe,
|
|
243
|
-
children: /* @__PURE__ */ _(C, {
|
|
244
|
-
value: $,
|
|
245
|
-
children: /* @__PURE__ */ _("form", {
|
|
246
|
-
...w,
|
|
247
|
-
className: ce,
|
|
248
|
-
style: se,
|
|
249
|
-
"aria-busy": ie || void 0,
|
|
250
|
-
noValidate: re,
|
|
251
|
-
onSubmit: le,
|
|
252
|
-
onReset: ue,
|
|
253
|
-
children: g
|
|
254
|
-
})
|
|
255
|
-
})
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
k.displayName = "VlForm";
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region components/Form/FormItem.tsx
|
|
261
|
-
var A = [], j = [], ie = (e, t) => e ? Array.isArray(e) ? e : [e] : t, ae = (e, t) => {
|
|
262
|
-
if (e === "checked" && typeof t[1] == "boolean") return t[1];
|
|
263
|
-
let n = t[0];
|
|
264
|
-
if (n && typeof n == "object" && "target" in n) {
|
|
265
|
-
let t = n.target;
|
|
266
|
-
if (t) return e === "checked" ? t.checked : t.value;
|
|
267
|
-
}
|
|
268
|
-
return n;
|
|
269
|
-
}, M = ({ id: t, content: n }) => {
|
|
270
|
-
let r = h(null), [i, o] = te(!1), s = d(() => {
|
|
271
|
-
let e = r.current;
|
|
272
|
-
if (!e) return;
|
|
273
|
-
let t = e.scrollWidth > e.clientWidth;
|
|
274
|
-
o((e) => e === t ? e : t);
|
|
275
|
-
}, []);
|
|
276
|
-
return e(() => {
|
|
277
|
-
s();
|
|
278
|
-
let e = r.current, t = typeof ResizeObserver > "u" ? null : new ResizeObserver(s);
|
|
279
|
-
return e && t?.observe(e), window.addEventListener("resize", s, { passive: !0 }), () => {
|
|
280
|
-
t?.disconnect(), window.removeEventListener("resize", s);
|
|
281
|
-
};
|
|
282
|
-
}, [n, s]), /* @__PURE__ */ _(a, {
|
|
283
|
-
id: t,
|
|
284
|
-
className: "vl-form-item__help-tooltip",
|
|
285
|
-
content: n,
|
|
286
|
-
disabled: !i,
|
|
287
|
-
children: /* @__PURE__ */ _("div", {
|
|
288
|
-
ref: r,
|
|
289
|
-
className: "vl-form-item__help is-text",
|
|
290
|
-
tabIndex: i ? 0 : void 0,
|
|
291
|
-
children: n
|
|
292
|
-
})
|
|
293
|
-
});
|
|
294
|
-
}, N = c((t, i) => {
|
|
295
|
-
let { name: a, label: s, required: c = !1, rules: u = A, help: d, valuePropName: f = "value", trigger: p = "onChange", getValueFromEvent: g, validateTrigger: y, className: b, children: x, ...ne } = t, C = S(), w = C?.registerField, T = l(x) ? x : null, E = T?.props ?? {}, D = r("vl-form-control", E.id), O = r("vl-form-label"), k = r("vl-form-help"), N = r("vl-form-error"), P = h(null), F = h(null), I = h(null), L = C?.defaultValidateTrigger ?? j, R = m(() => ie(y, L), [L, y]), z = m(() => c && !u.some((e) => e.required) ? [{ required: !0 }, ...u] : u, [c, u]), B = c || z.some((e) => e.required), V = d != null && typeof d != "boolean" && d !== "", H = re(a), U = H.errors, W = H.isValidating, G = H.value, K = R.includes("change") || U.length > 0, [q] = te(() => Symbol("form-field")), J = h({
|
|
296
|
-
label: void 0,
|
|
297
|
-
rules: A,
|
|
298
|
-
element: null
|
|
299
|
-
});
|
|
300
|
-
e(() => {
|
|
301
|
-
J.current.label = typeof s == "string" ? s : void 0, J.current.rules = z;
|
|
302
|
-
}, [z, s]), ee(() => {
|
|
303
|
-
if (!(!a || !w)) return w({
|
|
304
|
-
name: a,
|
|
305
|
-
token: q,
|
|
306
|
-
metaRef: J
|
|
307
|
-
});
|
|
308
|
-
}, [
|
|
309
|
-
q,
|
|
310
|
-
a,
|
|
311
|
-
w
|
|
312
|
-
]), ee(() => {
|
|
313
|
-
let e = F.current, t = I.current;
|
|
314
|
-
if (I.current = U, e) {
|
|
315
|
-
if (!U.length) {
|
|
316
|
-
e.classList.remove("is-shaking");
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
t !== U && (e.classList.remove("is-shaking"), e.offsetWidth, e.classList.add("is-shaking"));
|
|
320
|
-
}
|
|
321
|
-
}, [U]);
|
|
322
|
-
let Y = U.length > 0, X = V && !Y, Z = {
|
|
323
|
-
id: D,
|
|
324
|
-
"aria-describedby": [
|
|
325
|
-
E["aria-describedby"],
|
|
326
|
-
Y ? N : void 0,
|
|
327
|
-
X ? k : void 0
|
|
328
|
-
].filter(Boolean).join(" ") || void 0,
|
|
329
|
-
"aria-labelledby": [E["aria-labelledby"], s === void 0 ? void 0 : O].filter(Boolean).join(" ") || void 0,
|
|
330
|
-
"aria-invalid": U.length > 0 || void 0,
|
|
331
|
-
"aria-busy": W || void 0,
|
|
332
|
-
ref: (e) => {
|
|
333
|
-
P.current = e, J.current.element = e, n(E.ref, e);
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
if (a && C) {
|
|
337
|
-
Z[f] = G;
|
|
338
|
-
let e = E[p];
|
|
339
|
-
if (Z[p] = (...t) => {
|
|
340
|
-
typeof e == "function" && e(...t);
|
|
341
|
-
let n = g ? g(...t) : ae(f, t), r = C.updateField(a, n);
|
|
342
|
-
(K || p === "onBlur" && R.includes("blur")) && C.validateField(a, r);
|
|
343
|
-
}, p !== "onBlur") {
|
|
344
|
-
let e = E.onBlur;
|
|
345
|
-
Z.onBlur = (t) => {
|
|
346
|
-
typeof e == "function" && e(t), R.includes("blur") && C.validateField(a);
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
let Q = T ? o(T, Z) : x, oe = [
|
|
351
|
-
"vl-form-item",
|
|
352
|
-
s === void 0 ? "" : "has-label",
|
|
353
|
-
V ? "has-help" : "",
|
|
354
|
-
U.length ? "is-error" : "",
|
|
355
|
-
W ? "is-validating" : "",
|
|
356
|
-
B ? "is-required" : "",
|
|
357
|
-
b || ""
|
|
358
|
-
].filter(Boolean).join(" "), $ = W || U.length > 0;
|
|
359
|
-
return /* @__PURE__ */ v("div", {
|
|
360
|
-
...ne,
|
|
361
|
-
ref: i,
|
|
362
|
-
className: oe,
|
|
363
|
-
children: [s === void 0 ? null : /* @__PURE__ */ v("label", {
|
|
364
|
-
id: O,
|
|
365
|
-
className: "vl-form-item__label",
|
|
366
|
-
htmlFor: D,
|
|
367
|
-
children: [B ? /* @__PURE__ */ _("span", {
|
|
368
|
-
className: "vl-form-item__required",
|
|
369
|
-
"aria-hidden": "true",
|
|
370
|
-
children: "*"
|
|
371
|
-
}) : null, s]
|
|
372
|
-
}), /* @__PURE__ */ v("div", {
|
|
373
|
-
className: "vl-form-item__control",
|
|
374
|
-
children: [/* @__PURE__ */ v("div", {
|
|
375
|
-
className: "vl-form-item__field",
|
|
376
|
-
children: [/* @__PURE__ */ _("div", {
|
|
377
|
-
ref: F,
|
|
378
|
-
className: "vl-form-item__control-input",
|
|
379
|
-
children: Q
|
|
380
|
-
}), a ? /* @__PURE__ */ v("div", {
|
|
381
|
-
className: `vl-form-item__validation${$ ? "" : " is-empty"}`,
|
|
382
|
-
"aria-hidden": !$ || void 0,
|
|
383
|
-
children: [W ? /* @__PURE__ */ v("div", {
|
|
384
|
-
className: "vl-form-item__status",
|
|
385
|
-
role: "status",
|
|
386
|
-
"aria-label": "校验中",
|
|
387
|
-
children: [/* @__PURE__ */ _("span", {
|
|
388
|
-
className: "vl-form-item__spinner",
|
|
389
|
-
"aria-hidden": "true"
|
|
390
|
-
}), /* @__PURE__ */ _("span", { children: "校验中" })]
|
|
391
|
-
}) : null, U.length ? /* @__PURE__ */ _("div", {
|
|
392
|
-
id: N,
|
|
393
|
-
className: "vl-form-item__error",
|
|
394
|
-
role: "alert",
|
|
395
|
-
children: U.map((e) => /* @__PURE__ */ _("div", { children: e }, e))
|
|
396
|
-
}) : null]
|
|
397
|
-
}) : null]
|
|
398
|
-
}), X ? /* @__PURE__ */ _("div", {
|
|
399
|
-
className: "vl-form-item__feedback",
|
|
400
|
-
children: typeof d == "string" || typeof d == "number" ? /* @__PURE__ */ _(M, {
|
|
401
|
-
id: k,
|
|
402
|
-
content: d
|
|
403
|
-
}) : /* @__PURE__ */ _("div", {
|
|
404
|
-
id: k,
|
|
405
|
-
className: "vl-form-item__help",
|
|
406
|
-
children: d
|
|
407
|
-
})
|
|
408
|
-
}) : null]
|
|
409
|
-
})]
|
|
410
|
-
});
|
|
411
|
-
}), P = u(N, (e, t) => {
|
|
412
|
-
if (e.name !== t.name || e.label !== t.label || e.required !== t.required || e.help !== t.help || e.valuePropName !== t.valuePropName || e.trigger !== t.trigger || e.getValueFromEvent !== t.getValueFromEvent || e.validateTrigger !== t.validateTrigger || e.className !== t.className || e.style !== t.style) return !1;
|
|
413
|
-
if (e.rules !== t.rules) {
|
|
414
|
-
let n = e.rules ?? A, r = t.rules ?? A;
|
|
415
|
-
if (n.length !== r.length) return !1;
|
|
416
|
-
for (let e = 0; e < n.length; e++) if (n[e] !== r[e]) return !1;
|
|
417
|
-
}
|
|
418
|
-
if (e.children !== t.children) {
|
|
419
|
-
let n = e.children, r = t.children;
|
|
420
|
-
if (!l(n) || !l(r)) return Object.is(n, r);
|
|
421
|
-
if (n.type !== r.type || n.key !== r.key) return !1;
|
|
422
|
-
let i = n.props, a = r.props, o = Object.keys(i), s = Object.keys(a);
|
|
423
|
-
if (o.length !== s.length) return !1;
|
|
424
|
-
for (let e of o) if (!Object.is(i[e], a[e])) return !1;
|
|
425
|
-
}
|
|
426
|
-
let n = /* @__PURE__ */ new Set([
|
|
427
|
-
"name",
|
|
428
|
-
"label",
|
|
429
|
-
"required",
|
|
430
|
-
"rules",
|
|
431
|
-
"help",
|
|
432
|
-
"valuePropName",
|
|
433
|
-
"trigger",
|
|
434
|
-
"getValueFromEvent",
|
|
435
|
-
"validateTrigger",
|
|
436
|
-
"className",
|
|
437
|
-
"style",
|
|
438
|
-
"children"
|
|
439
|
-
]), r = e, i = t;
|
|
440
|
-
for (let t of Object.keys(e)) if (!n.has(t) && !Object.is(r[t], i[t])) return !1;
|
|
441
|
-
for (let e of Object.keys(t)) if (!n.has(e) && !Object.is(r[e], i[e])) return !1;
|
|
442
|
-
return !0;
|
|
443
|
-
});
|
|
444
|
-
P.displayName = "VlFormItem";
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region components/Form/index.ts
|
|
447
|
-
var F = Object.assign(k, { Item: P }), I = P;
|
|
448
|
-
//#endregion
|
|
449
|
-
export { I as n, F as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./state-BuUx1onZ.cjs"),t=require("./Button-qURrKHQ0.cjs"),n=require("./focus-D-h8CbGr.cjs"),r=require("./Modal-DPxZEr2v.cjs");let i=require("lucide-react"),a=require("react"),o=require("react/jsx-runtime"),s=require("react-dom/client");var c={info:i.Info,success:i.CircleCheck,warning:i.CircleAlert,error:i.CircleX},l={info:`primary`,success:`success`,warning:`warning`,error:`error`},u={[n.t]:!0},d=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&`then`in e&&typeof e.then==`function`,f=(0,a.forwardRef)((n,s)=>{let{open:f,defaultOpen:p=!1,title:m=`提示`,type:h=`info`,showCancelButton:g=!1,confirmButtonText:_=`确定`,confirmButtonLoadingText:v,cancelButtonText:y=`取消`,width:b=420,closeOnClickOverlay:x=!1,closeOnPressEscape:S=!0,showClose:C=!0,draggable:w=!1,className:T,children:E,onChange:D,onConfirm:O,onCancel:k,onClose:A,onConfirmError:j,...M}=n,N=e.t(n,`open`),[P,F]=e.n({value:!!f,defaultValue:p,controlled:N,onChange:D}),[I,L]=(0,a.useState)(!1),R=(0,a.useRef)(!1),z=e=>{R.current||(e===`cancel`?k?.():A?.(),F(!1))},B=async()=>{if(!R.current)try{let e=O?.();d(e)&&(R.current=!0,L(!0),await e),F(!1)}catch(e){j?.(e)}finally{R.current=!1,L(!1)}},V=c[h],H=[`vl-message-box`,`is-${h}`,T||``].filter(Boolean).join(` `);return(0,o.jsx)(r.t,{...M,ref:s,open:P,title:m,width:b,draggable:w,closeOnClickOverlay:!I&&x,closeOnPressEscape:!I&&S,showClose:!1,className:H,header:(0,o.jsxs)(`div`,{className:`vl-message-box__header`,children:[(0,o.jsx)(`div`,{className:`vl-message-box__title`,children:m}),C?(0,o.jsx)(`button`,{type:`button`,className:`vl-modal__close`,"aria-label":`关闭消息框`,disabled:I,onClick:()=>z(`close`),children:(0,o.jsx)(i.X,{size:20,"aria-hidden":`true`})}):null]}),footer:(0,o.jsxs)(`div`,{className:`vl-message-box__actions`,children:[g?(0,o.jsx)(t.t,{disabled:I,onClick:()=>z(`cancel`),children:y}):null,(0,o.jsx)(t.t,{...u,status:l[h],variant:`solid`,loading:I,loadingText:v,onClick:B,children:_})]}),onChange:e=>{e||z(`close`)},children:(0,o.jsxs)(`div`,{className:`vl-message-box__content`,children:[(0,o.jsx)(V,{className:`vl-message-box__icon`,"aria-hidden":`true`}),(0,o.jsx)(`div`,{className:`vl-message-box__message`,children:E})]})})});f.displayName=`VlMessageBox`;var p=(e,t={},n)=>typeof document>`u`?Promise.reject(Error(`VlMessageBox imperative APIs are only available in a browser environment.`)):new Promise((r,i)=>{let c=document.createElement(`div`);c.className=`vl-message-box-container`,document.body.appendChild(c);let l=(0,s.createRoot)(c);l.render((0,o.jsx)(()=>{let[s,u]=(0,a.useState)(!0);return(0,o.jsx)(f,{...t,open:s,showCancelButton:n,onChange:u,onConfirm:async()=>{await t.onConfirm?.(),r(`confirm`)},onCancel:()=>{t.onCancel?.(),i(`cancel`)},onClose:()=>{t.onClose?.(),i(`close`)},onAfterClose:()=>{try{t.onAfterClose?.()}finally{queueMicrotask(()=>{l.unmount(),c.remove()})}},children:e})},{}))}),m=Object.assign(f,{alert:(e,t)=>p(e,t,!1),confirm:(e,t)=>p(e,t,!0)});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { n as e, t } from "./state-BSDh-Ob2.js";
|
|
2
|
-
import { t as n } from "./Button-CwkWSWau.js";
|
|
3
|
-
import { t as r } from "./focus-BDDJyKk3.js";
|
|
4
|
-
import { t as i } from "./Modal-Du7aVdWl.js";
|
|
5
|
-
import { CircleAlert as a, CircleCheck as o, CircleX as s, Info as c, X as l } from "lucide-react";
|
|
6
|
-
import { forwardRef as u, useRef as d, useState as f } from "react";
|
|
7
|
-
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
8
|
-
import { createRoot as h } from "react-dom/client";
|
|
9
|
-
//#region components/MessageBox/MessageBox.tsx
|
|
10
|
-
var g = {
|
|
11
|
-
info: c,
|
|
12
|
-
success: o,
|
|
13
|
-
warning: a,
|
|
14
|
-
error: s
|
|
15
|
-
}, _ = {
|
|
16
|
-
info: "primary",
|
|
17
|
-
success: "success",
|
|
18
|
-
warning: "warning",
|
|
19
|
-
error: "error"
|
|
20
|
-
}, v = { [r]: !0 }, y = (e) => (typeof e == "object" || typeof e == "function") && e !== null && "then" in e && typeof e.then == "function", b = u((r, a) => {
|
|
21
|
-
let { open: o, defaultOpen: s = !1, title: c = "提示", type: u = "info", showCancelButton: h = !1, confirmButtonText: b = "确定", confirmButtonLoadingText: x, cancelButtonText: S = "取消", width: C = 420, closeOnClickOverlay: w = !1, closeOnPressEscape: T = !0, showClose: E = !0, draggable: D = !1, className: O, children: k, onChange: A, onConfirm: j, onCancel: M, onClose: N, onConfirmError: P, ...F } = r, I = t(r, "open"), [L, R] = e({
|
|
22
|
-
value: !!o,
|
|
23
|
-
defaultValue: s,
|
|
24
|
-
controlled: I,
|
|
25
|
-
onChange: A
|
|
26
|
-
}), [z, B] = f(!1), V = d(!1), H = (e) => {
|
|
27
|
-
V.current || (e === "cancel" ? M?.() : N?.(), R(!1));
|
|
28
|
-
}, U = async () => {
|
|
29
|
-
if (!V.current) try {
|
|
30
|
-
let e = j?.();
|
|
31
|
-
y(e) && (V.current = !0, B(!0), await e), R(!1);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
P?.(e);
|
|
34
|
-
} finally {
|
|
35
|
-
V.current = !1, B(!1);
|
|
36
|
-
}
|
|
37
|
-
}, W = g[u], G = [
|
|
38
|
-
"vl-message-box",
|
|
39
|
-
`is-${u}`,
|
|
40
|
-
O || ""
|
|
41
|
-
].filter(Boolean).join(" ");
|
|
42
|
-
return /* @__PURE__ */ p(i, {
|
|
43
|
-
...F,
|
|
44
|
-
ref: a,
|
|
45
|
-
open: L,
|
|
46
|
-
title: c,
|
|
47
|
-
width: C,
|
|
48
|
-
draggable: D,
|
|
49
|
-
closeOnClickOverlay: !z && w,
|
|
50
|
-
closeOnPressEscape: !z && T,
|
|
51
|
-
showClose: !1,
|
|
52
|
-
className: G,
|
|
53
|
-
header: /* @__PURE__ */ m("div", {
|
|
54
|
-
className: "vl-message-box__header",
|
|
55
|
-
children: [/* @__PURE__ */ p("div", {
|
|
56
|
-
className: "vl-message-box__title",
|
|
57
|
-
children: c
|
|
58
|
-
}), E ? /* @__PURE__ */ p("button", {
|
|
59
|
-
type: "button",
|
|
60
|
-
className: "vl-modal__close",
|
|
61
|
-
"aria-label": "关闭消息框",
|
|
62
|
-
disabled: z,
|
|
63
|
-
onClick: () => H("close"),
|
|
64
|
-
children: /* @__PURE__ */ p(l, {
|
|
65
|
-
size: 20,
|
|
66
|
-
"aria-hidden": "true"
|
|
67
|
-
})
|
|
68
|
-
}) : null]
|
|
69
|
-
}),
|
|
70
|
-
footer: /* @__PURE__ */ m("div", {
|
|
71
|
-
className: "vl-message-box__actions",
|
|
72
|
-
children: [h ? /* @__PURE__ */ p(n, {
|
|
73
|
-
disabled: z,
|
|
74
|
-
onClick: () => H("cancel"),
|
|
75
|
-
children: S
|
|
76
|
-
}) : null, /* @__PURE__ */ p(n, {
|
|
77
|
-
...v,
|
|
78
|
-
status: _[u],
|
|
79
|
-
variant: "solid",
|
|
80
|
-
loading: z,
|
|
81
|
-
loadingText: x,
|
|
82
|
-
onClick: U,
|
|
83
|
-
children: b
|
|
84
|
-
})]
|
|
85
|
-
}),
|
|
86
|
-
onChange: (e) => {
|
|
87
|
-
e || H("close");
|
|
88
|
-
},
|
|
89
|
-
children: /* @__PURE__ */ m("div", {
|
|
90
|
-
className: "vl-message-box__content",
|
|
91
|
-
children: [/* @__PURE__ */ p(W, {
|
|
92
|
-
className: "vl-message-box__icon",
|
|
93
|
-
"aria-hidden": "true"
|
|
94
|
-
}), /* @__PURE__ */ p("div", {
|
|
95
|
-
className: "vl-message-box__message",
|
|
96
|
-
children: k
|
|
97
|
-
})]
|
|
98
|
-
})
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
b.displayName = "VlMessageBox";
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region components/MessageBox/service.tsx
|
|
104
|
-
var x = (e, t = {}, n) => typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("VlMessageBox imperative APIs are only available in a browser environment.")) : new Promise((r, i) => {
|
|
105
|
-
let a = document.createElement("div");
|
|
106
|
-
a.className = "vl-message-box-container", document.body.appendChild(a);
|
|
107
|
-
let o = h(a);
|
|
108
|
-
o.render(/* @__PURE__ */ p(() => {
|
|
109
|
-
let [s, c] = f(!0);
|
|
110
|
-
return /* @__PURE__ */ p(b, {
|
|
111
|
-
...t,
|
|
112
|
-
open: s,
|
|
113
|
-
showCancelButton: n,
|
|
114
|
-
onChange: c,
|
|
115
|
-
onConfirm: async () => {
|
|
116
|
-
await t.onConfirm?.(), r("confirm");
|
|
117
|
-
},
|
|
118
|
-
onCancel: () => {
|
|
119
|
-
t.onCancel?.(), i("cancel");
|
|
120
|
-
},
|
|
121
|
-
onClose: () => {
|
|
122
|
-
t.onClose?.(), i("close");
|
|
123
|
-
},
|
|
124
|
-
onAfterClose: () => {
|
|
125
|
-
try {
|
|
126
|
-
t.onAfterClose?.();
|
|
127
|
-
} finally {
|
|
128
|
-
queueMicrotask(() => {
|
|
129
|
-
o.unmount(), a.remove();
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
children: e
|
|
134
|
-
});
|
|
135
|
-
}, {}));
|
|
136
|
-
}), S = Object.assign(b, {
|
|
137
|
-
alert: (e, t) => x(e, t, !1),
|
|
138
|
-
confirm: (e, t) => x(e, t, !0)
|
|
139
|
-
});
|
|
140
|
-
//#endregion
|
|
141
|
-
export { S as t };
|
package/dist/Modal-DPxZEr2v.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./content-DCGQZQp8.cjs"),a=require("./number-B7qJF_ZY.cjs"),o=require("./id-CF0zOP1G.cjs"),s=require("./layer-BgiUZy_t.cjs"),c=require("./dialog-shell-CzeGytVj.cjs"),ee=require("./Scrollbar-CEQT6Ao_.cjs");let te=require("lucide-react"),l=require("react"),u=require("react/jsx-runtime");var ne=.25,re=0,ie=e=>{if(typeof e==`number`)return Number.isFinite(e)?e:0;if(typeof e==`string`){let t=e.trim();if(t.endsWith(`vh`)){let e=parseFloat(t);return Number.isFinite(e)?window.innerHeight*e/100:0}if(t.endsWith(`px`)){let e=parseFloat(t);return Number.isFinite(e)?e:0}let n=parseFloat(t);return Number.isFinite(n)?n:0}return 0},d=(0,l.forwardRef)((d,f)=>{let{open:p,defaultOpen:ae=!1,title:m,width:oe=520,offsetY:h=re,center:g=!1,mask:se=!0,closeOnClickOverlay:ce=!0,closeOnPressEscape:le=!0,showClose:_=!0,lockScroll:ue=!0,destroyOnClose:v=!1,draggable:y=!0,fullscreen:b=!1,zIndex:de,header:x,footer:S,className:fe,style:C,children:pe,onClick:me,onChange:he,onOpen:w,onClose:T,onAfterClose:ge,"aria-label":_e,"aria-labelledby":ve,"aria-describedby":ye,...be}=d,E=n.t(),xe=typeof C?.zIndex==`number`?C.zIndex:void 0,D=s.r({defaultZIndex:s.n.modal,zIndex:de??xe,withMask:!0}),O=(0,l.useRef)(null),Se=(0,l.useMemo)(()=>r.n(O,f),[f]),Ce=t.t(d,`open`),[k,A]=t.n({value:!!p,defaultValue:ae,controlled:Ce,onChange:he}),[we,j]=(0,l.useState)(!1),M=(0,l.useRef)({x:0,y:0}),N=(0,l.useRef)(!1),P=(0,l.useRef)(!1),F=(0,l.useRef)({x:0,y:0}),I=(0,l.useRef)(null),L=(0,l.useRef)(!1),R=(0,l.useRef)(null),z=(0,l.useRef)(null),B=o.t(`vl-modal-title`),V=(0,l.useCallback)(()=>A(!1),[A]),{isTopLayer:H}=c.r({active:E&&k,containerRef:O,closeOnPressEscape:le,lockScroll:ue,onRequestClose:V}),U=(0,l.useCallback)(e=>{O.current&&(O.current.style.visibility=e?`visible`:`hidden`)},[]),W=(0,l.useCallback)((e,t)=>{M.current={x:e,y:t},O.current&&(O.current.style.left=`${e}px`,O.current.style.top=`${t}px`)},[]),G=(0,l.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)}},[]),K=(0,l.useCallback)(()=>{let e=O.current;if(!e||typeof window>`u`)return;if(b){W(0,0),N.current=!1;return}let{rect:t,maxX:n,maxY:r}=G(e,12),i=(g?(window.innerHeight-t.height)/2:window.innerHeight*ne)+ie(h);W(Math.round(a.t((window.innerWidth-t.width)/2,12,n)),Math.round(a.t(i,12,r)))},[g,b,G,h,W]),q=(0,l.useCallback)(()=>{let e=O.current;if(!e)return;let{maxX:t,maxY:n}=G(e,12);W(Math.round(a.t(M.current.x,12,t)),Math.round(a.t(M.current.y,12,n)))},[G,W]),J=(0,l.useCallback)((e,t)=>{let n=O.current;if(!n||b)return;let{maxX:r,maxY:i}=G(n,12),o=a.t(e-F.current.x,12,r),s=a.t(t-F.current.y,12,i);W(Math.round(o),Math.round(s)),N.current=!0},[b,G,W]),Y=(0,l.useRef)(J);e.t(()=>{Y.current=J},[J]);let Te=(0,l.useCallback)(e=>{P.current&&Y.current(e.clientX,e.clientY)},[]),X=(0,l.useCallback)(()=>{z.current?.abort(),z.current=null,I.current?.(),I.current=null},[]),Z=(0,l.useCallback)(()=>{P.current&&(P.current=!1,j(!1),X())},[X]),Ee=e=>{if(!y||b||!k||!H()||e.button!==0||e.target.closest(`.vl-modal__close, .vl-modal__title, .vl-message-box__title, [class*='__title'], [data-drag-cancel], button, input, textarea, select, a`))return;let t=O.current;if(!t)return;let n=window.getSelection();n&&n.rangeCount>0&&n.removeAllRanges(),e.preventDefault();let r=t.getBoundingClientRect();F.current={x:e.clientX-r.left,y:e.clientY-r.top},P.current=!0,j(!0),I.current=c.n(),z.current=new AbortController;let{signal:i}=z.current;window.addEventListener(`pointermove`,Te,{signal:i}),window.addEventListener(`pointerup`,Z,{once:!0,signal:i})};(0,l.useEffect)(()=>{let e=L.current;k&&!e?w?.():!k&&e&&T?.(),L.current=k},[k,w,T]),e.t(()=>{!k||!E||(U(!1),b?W(0,0):!v&&N.current?q():K(),U(!0))},[k,E,b,v,K,q,W,U]),(0,l.useEffect)(()=>{k||Z()},[k,Z]),(0,l.useEffect)(()=>{if(!k)return;let e=()=>{P.current||(R.current!==null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{R.current=null,N.current?q():K()},100))};return window.addEventListener(`resize`,e,{passive:!0}),()=>{window.removeEventListener(`resize`,e),R.current!==null&&(window.clearTimeout(R.current),R.current=null)}},[k,K,q]),(0,l.useEffect)(()=>()=>{X(),R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[X]);let De=()=>{ce&&H()&&V()},Oe=e=>{e.stopPropagation(),me?.(e)},ke=[`vl-modal`,we?`is-dragging`:``,g?`is-center`:``,b?`is-fullscreen`:``,fe||``].filter(Boolean).join(` `),Ae=[`vl-modal__header`,y&&!b?`is-draggable`:``].filter(Boolean).join(` `),Q={...C};D.zIndex!==void 0&&(Q.zIndex=D.zIndex),b?(Q.width=`100vw`,Q.height=`100vh`):Q.width=a.n(oe)??`520px`;let $=x??(m?(0,u.jsx)(`div`,{id:B,className:`vl-modal__title`,children:m}):null),je=ve??(!x&&m?B:void 0),Me=_e??(je?void 0:typeof m==`string`?m:`对话框`);return(0,u.jsx)(s.t,{layer:D.layer,children:(0,u.jsxs)(c.t,{clientReady:E,open:k,mask:se,destroyOnClose:v,maskTransitionName:`vl-modal-mask`,transitionName:`vl-modal`,maskClassName:`vl-modal__mask`,panelClassName:ke,panelStyle:Q,maskStyle:D.maskZIndex===void 0?void 0:{zIndex:D.maskZIndex},panelRef:Se,role:`dialog`,ariaLabel:Me,ariaLabelledBy:je,ariaDescribedBy:ye,onMaskClick:De,onPanelClick:Oe,onAfterLeave:()=>{Z(),v&&(N.current=!1),ge?.()},panelProps:be,children:[i.t($)||_?(0,u.jsx)(`div`,{className:Ae,onPointerDown:Ee,children:(0,u.jsxs)(`div`,{className:`vl-modal__headerInner`,children:[(0,u.jsx)(`div`,{className:`vl-modal__headerMain`,children:$}),_?(0,u.jsx)(`button`,{type:`button`,className:`vl-modal__close`,"aria-label":`关闭对话框`,onClick:V,children:(0,u.jsx)(te.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,u.jsx)(ee.t,{className:`vl-modal__body`,children:pe}),i.t(S)?(0,u.jsx)(`div`,{className:`vl-modal__footer`,children:S}):null]})})});d.displayName=`VlModal`;var f=d,p=d;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
|
package/dist/Select-C6O0tmM_.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./icon-DRLyKu8p.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./floating-5PRFyI8D.cjs"),ee=require("./id-CF0zOP1G.cjs"),a=require("./layer-BgiUZy_t.cjs"),te=require("./Transition-X_89ga-e.cjs");let o=require("lucide-react"),s=require("react"),c=require("react/jsx-runtime"),ne=require("react-dom");var l=e=>!!(e&&!e.disabled&&!e.divider),u=(0,s.forwardRef)((u,d)=>{let{value:re,defaultValue:ie,options:f=[],placeholder:p=`请选择`,filterable:ae=!1,filterPlaceholder:oe=`搜索`,multiple:se=!1,taggable:m=!1,maxTagCount:h,disabled:g=!1,loading:_=!1,size:ce=`md`,clearable:le=!1,placement:v=`bottom-start`,offset:ue=8,zIndex:de,emptyText:fe=`暂无数据`,renderOption:pe,emptyContent:me,className:he,style:ge,onChange:_e,onClear:ve,onOpen:ye,onClose:be,onFocus:xe,onBlur:Se,id:Ce,"aria-label":we,"aria-labelledby":Te,"aria-describedby":Ee,tabIndex:De,...Oe}=u,ke=(0,s.useRef)(null),y=(0,s.useRef)(null),b=(0,s.useRef)(null),Ae=(0,s.useRef)(null),je=(0,s.useRef)([]),Me=(0,s.useMemo)(()=>r.n(ke,d),[d]),x=n.t(),S=a.r({defaultZIndex:a.n.dropdown,zIndex:de}),C=ae||m,w=se||m,Ne=(0,s.useMemo)(()=>w?[]:null,[w]),Pe=t.t(u,`value`),T=(0,s.useRef)(void 0),[E,Fe]=t.n({value:re??Ne,defaultValue:ie??Ne,controlled:Pe,onChange:e=>{let t=T.current;T.current=void 0,_e?.(e,t)}}),[D,Ie]=(0,s.useState)(!1),[Le,Re]=(0,s.useState)(!1),[O,k]=(0,s.useState)(``),[ze,A]=(0,s.useState)([]),[Be,Ve]=(0,s.useState)({}),[He,Ue]=(0,s.useState)(v),[j,M]=(0,s.useState)(-1),We=ee.t(`vl-select-control`,Ce),N=ee.t(`vl-select-listbox`),P=(0,s.useCallback)(e=>`${N}-option-${e}`,[N]),Ge=(0,s.useMemo)(()=>[`vl-select-wrapper`,he||``].filter(Boolean).join(` `),[he]),Ke=(0,s.useMemo)(()=>[`vl-select`,`size-${ce}`,w?`is-multiple`:``,D?`is-open`:``,Le?`is-focus-within`:``,g?`is-disabled`:``,_?`is-loading`:``].filter(Boolean).join(` `),[ce,w,D,Le,g,_]),F=(0,s.useMemo)(()=>{if(!m)return f;let e=ze.filter(e=>!f.some(t=>t.value===e.value));return[...f,...e]},[f,ze,m]),I=(0,s.useMemo)(()=>{if(!C||!D)return F;let e=O.trim().toLocaleLowerCase();return e?F.filter(t=>!t.divider&&t.label.toLocaleLowerCase().includes(e)):F},[F,C,D,O]),L=(0,s.useMemo)(()=>I.flatMap((e,t)=>l(e)?[t]:[]),[I]),qe=I.some(e=>!e.divider),R=(0,s.useMemo)(()=>w&&Array.isArray(E)?E:[],[w,E]),z=(0,s.useMemo)(()=>{if(!(w||Array.isArray(E)))return F.find(e=>e.value===E)},[F,w,E]),B=(0,s.useMemo)(()=>w?``:z?z.label:E===null||E===``||Array.isArray(E)?``:String(E),[w,z,E]),V=(0,s.useMemo)(()=>R.map(e=>({value:e,label:F.find(t=>t.value===e)?.label??String(e)})),[R,F]),Je=(0,s.useMemo)(()=>!w||h===void 0||!Number.isFinite(h)?1/0:Math.max(0,Math.floor(h)),[w,h]),Ye=Je===1/0?V:V.slice(0,Je),H=Math.max(0,V.length-Ye.length),Xe=w?R.length>0:E!==null&&E!==``&&!Array.isArray(E),Ze=le&&!g&&!_&&Xe,Qe=j>=0&&l(I[j])?P(j):void 0,$e=(0,s.useMemo)(()=>[`vl-select__panel`,`is-${He}`].join(` `),[He]),U=(0,s.useCallback)(e=>{e&&(g||_)||D!==e&&(Ie(e),e?ye?.():be?.())},[g,_,ye,be,D]),W=(0,s.useCallback)(e=>w?R.includes(e.value):e.value===E,[w,R,E]),G=(0,s.useCallback)((e,t)=>{T.current=t,Fe(e),T.current=void 0},[Fe]),K=(0,s.useCallback)(e=>{m&&A(t=>t.filter(t=>e.includes(t.value)))},[m]),q=(0,s.useCallback)(e=>{if(l(e)){if(w){let t=R.includes(e.value)?R.filter(t=>t!==e.value):[...R,e.value];G(t,e),K(t),k(``);return}G(e.value,e),k(e.label),U(!1)}},[w,R,G,K,U]),et=(0,s.useCallback)(e=>{if(!m)return!1;let t=e.trim();if(!t)return!1;let n=t.toLocaleLowerCase(),r=F.find(e=>e.label.toLocaleLowerCase()===n||String(e.value).toLocaleLowerCase()===n);if(r)return W(r)?k(``):q(r),!0;let i={label:t,value:t};return A(e=>[...e,i]),q(i),!0},[m,F,W,q]),J=(0,s.useCallback)(()=>{let e=I.findIndex(e=>l(e)&&W(e));return e>=0?e:L[0]??-1},[I,L,W]),Y=(0,s.useCallback)(e=>{l(I[e])&&(M(e),je.current[e]?.scrollIntoView?.({block:`nearest`}))},[I]),tt=(0,s.useCallback)(e=>{if(!L.length)return;let t=L.indexOf(j),n=(t>=0?t+e:(e>0?-1:0)+e+L.length)%L.length;Y(L[n])},[L,j,Y]),nt=(0,s.useCallback)(()=>{let e=L[0];e!==void 0&&Y(e)},[L,Y]),rt=(0,s.useCallback)(()=>{let e=L.at(-1);e!==void 0&&Y(e)},[L,Y]),X=(0,s.useCallback)(()=>{if(!D)return;let e=y.current,t=b.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=i.t({anchorRect:n,floatingRect:t.getBoundingClientRect(),placement:v,offset:ue});Ue(r.placement),Ve({left:`${Math.round(r.x)}px`,top:`${Math.round(r.y)}px`,minWidth:`${Math.round(n.width)}px`})},[D,v,ue]),Z=(0,s.useCallback)(()=>{C?Ae.current?.focus():y.current?.focus()},[C]),Q=(0,s.useCallback)((e=`first`)=>{if(g||_)return;D||(C&&k(``),U(!0));let t=e===`last`?L.at(-1):J();t!==void 0&&t>=0&&M(t),window.requestAnimationFrame(()=>{Z(),X()})},[g,_,D,C,U,L,J,Z,X]),it=(0,s.useCallback)(()=>{U(!1),window.requestAnimationFrame(Z)},[U,Z]),at=(0,s.useCallback)(()=>{let e=I[j];return l(e)?(q(e),!0):!1},[I,j,q]),ot=e=>{if(!(g||_)&&!e.target.closest(`button`)){if(C){Q();return}D?U(!1):Q()}},st=e=>{if(!(g||_)){if(e.key===`ArrowDown`){e.preventDefault(),D?tt(1):Q(`first`);return}if(e.key===`ArrowUp`){e.preventDefault(),D?tt(-1):Q(`last`);return}if(e.key===`Home`&&D&&!C){e.preventDefault(),nt();return}if(e.key===`End`&&D&&!C){e.preventDefault(),rt();return}if(e.key===`Escape`&&D){e.preventDefault(),it();return}if(e.key===`Tab`&&D){U(!1);return}if(e.key===`Enter`){if(!D){e.preventDefault(),Q();return}e.preventDefault(),!at()&&C&&et(O);return}if(e.key===` `&&!C){e.preventDefault(),D?at():Q();return}if(e.key===`Backspace`&&C&&w&&!O&&R.length){let e=R.slice(0,-1);G(e),K(e)}}},ct=()=>{g||_||(G(w?[]:null),ve?.(),k(``),K([]),U(!1),Z())},lt=e=>{if(g||_)return;let t=R.filter(t=>t!==e);G(t),K(t)},ut=e=>{e.currentTarget.contains(e.relatedTarget)||(Re(!0),xe?.(e))},dt=e=>{e.currentTarget.contains(e.relatedTarget)||(Re(!1),Se?.(e))};(0,s.useEffect)(()=>{D||(k(w?``:B),M(-1))},[D,w,B]),(0,s.useEffect)(()=>{if(!D||!x)return;M(J());let e=window.requestAnimationFrame(X);return()=>window.cancelAnimationFrame(e)},[D,x,I,J,X]),(0,s.useEffect)(()=>{if(!m||!w)return;let e=new Set(F.map(e=>e.value)),t=R.filter(t=>!e.has(t));t.length&&A(e=>[...e,...t.map(e=>({label:String(e),value:e}))])},[m,w,F,R]),(0,s.useEffect)(()=>{(g||_)&&D&&U(!1)},[g,_,D,U]),i.r({active:D&&x,rootRef:ke,floatingRef:b,onOutsideClick:()=>U(!1),onViewportChange:X});let ft={role:`combobox`,"aria-controls":N,"aria-expanded":D,"aria-haspopup":`listbox`,"aria-activedescendant":D?Qe:void 0,"aria-disabled":g||_||void 0,"aria-busy":_||void 0,"aria-label":we??(Te?void 0:p),"aria-labelledby":Te,"aria-describedby":Ee},pt=C?(0,c.jsx)(`input`,{ref:Ae,id:We,className:`vl-select__input`,type:`text`,value:O,placeholder:D?oe:w&&R.length?``:p,disabled:g||_,autoComplete:`off`,"aria-autocomplete":`list`,...ft,tabIndex:De,onChange:e=>{k(e.target.value),D||U(!0)},onFocus:()=>{D||Q()},onKeyDown:st}):null,$=(0,c.jsx)(te.t,{show:D,name:`vl-select`,deferEffects:!x,children:(0,c.jsx)(`div`,{ref:b,id:N,className:$e,style:{...Be,zIndex:S.zIndex},role:`listbox`,"aria-hidden":!D||void 0,"aria-multiselectable":w||void 0,children:qe?(0,c.jsx)(`div`,{className:`vl-select__list`,children:I.map((t,n)=>{if(t.divider)return(0,c.jsx)(`div`,{className:`vl-select__divider`,role:`separator`},`divider-${n}`);let r=W(t),i=[`vl-select__option`,t.disabled?`is-disabled`:``,r?`is-selected`:``,j===n?`is-active`:``].filter(Boolean).join(` `);return(0,c.jsx)(`div`,{ref:e=>{je.current[n]=e},id:P(n),className:i,role:`option`,"aria-disabled":t.disabled||void 0,"aria-selected":r,onPointerDown:e=>e.preventDefault(),onMouseEnter:()=>{l(t)&&M(n)},onClick:()=>q(t),children:pe?pe(t,n,r):(0,c.jsxs)(c.Fragment,{children:[t.icon?e.t(t.icon,`vl-select__option-icon`):null,(0,c.jsx)(`span`,{className:`vl-select__option-label`,children:t.label})]})},`${String(t.value)}-${n}`)})}):(0,c.jsx)(`div`,{className:`vl-select__empty`,role:`status`,children:me??fe})})});return(0,c.jsx)(a.t,{layer:S.layer,children:(0,c.jsxs)(`div`,{ref:Me,className:Ge,style:ge,...Oe,children:[(0,c.jsxs)(`div`,{ref:y,id:C?void 0:We,className:Ke,...C?{}:ft,tabIndex:g||_||C?-1:De??0,onClick:ot,onKeyDown:C?void 0:st,onFocus:ut,onBlur:dt,children:[(0,c.jsx)(`div`,{className:`vl-select__value`,children:w?(0,c.jsxs)(`div`,{className:`vl-select__tags`,children:[Ye.map(e=>(0,c.jsxs)(`span`,{className:`vl-select__tag`,children:[(0,c.jsx)(`span`,{className:`vl-select__tag-label`,children:e.label}),(0,c.jsx)(`button`,{type:`button`,className:`vl-select__tag-remove`,"aria-label":`移除 ${e.label}`,disabled:g||_,onClick:()=>lt(e.value),onPointerDown:e=>e.stopPropagation(),children:(0,c.jsx)(o.X,{size:12,"aria-hidden":`true`})})]},e.value)),H>0?(0,c.jsxs)(`span`,{className:`vl-select__tag is-collapsed`,"aria-label":`另有 ${H} 项`,children:[`+`,H]}):null,C?pt:V.length?null:(0,c.jsx)(`span`,{className:`vl-select__placeholder`,children:p})]}):C?pt:B?(0,c.jsx)(`span`,{className:`vl-select__label`,children:B}):(0,c.jsx)(`span`,{className:`vl-select__placeholder`,children:p})}),(0,c.jsxs)(`div`,{className:`vl-select__suffix`,children:[Ze?(0,c.jsx)(`button`,{type:`button`,className:`vl-select__clear`,"aria-label":`清除已选`,onClick:ct,onPointerDown:e=>e.stopPropagation(),children:(0,c.jsx)(o.X,{size:16,"aria-hidden":`true`})}):null,_?(0,c.jsx)(o.LoaderCircle,{className:`vl-select__loading`,size:16,"aria-hidden":`true`}):(0,c.jsx)(`span`,{className:`vl-select__arrow`,"aria-hidden":`true`,children:(0,c.jsx)(o.ChevronDown,{size:16})})]})]}),x?(0,ne.createPortal)($,document.body):$]})})});u.displayName=`VlSelect`;var d=u,re=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return re}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./floating-5PRFyI8D.cjs"),a=require("./id-CF0zOP1G.cjs"),o=require("./layer-BgiUZy_t.cjs"),s=require("./Transition-X_89ga-e.cjs"),c=require("./Input-C9ESmbJ7.cjs"),l=require("./time-wheel-BaCcA9nk.cjs"),ee=require("./Dropdown-PHqXNiAZ.cjs");let u=require("lucide-react"),d=require("react"),f=require("react/jsx-runtime"),te=require("react-dom");var p=`data-vl-date-picker-popup-owner`,ne=[`日`,`一`,`二`,`三`,`四`,`五`,`六`],m=[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`],h=e=>Array.isArray(e)&&e.length===2,g=(e,t)=>l.b(e,t),re=(e,t)=>{if(h(e)){let n=g(e[0],t),r=g(e[1],t);return n&&r?`${l.d(n,t)} ~ ${l.d(r,t)}`:``}let n=g(e,t);return n?l.d(n,t):``},ie=e=>[e[0]?l.l(e[0]):null,e[1]?l.l(e[1]):null],ae=e=>`${e.getFullYear()}年 ${m[e.getMonth()]}`,oe=(e,t)=>t?l.l(e):l.g(e),se=(e,t,n)=>{let r=e=>{let t=g(e,n);return t?t.getTime():null};return h(e)||h(t)?!h(e)||!h(t)?!1:r(e[0])===r(t[0])&&r(e[1])===r(t[1]):r(e)===r(t)},_=(0,d.forwardRef)((m,_)=>{let{componentName:v,withTime:y=!1,value:ce,defaultValue:le,valueType:ue=`date`,format:b=y?`YYYY-MM-DD HH:mm:ss`:`YYYY-MM-DD`,range:x=!1,shortcuts:de=[],minDate:fe,maxDate:pe,disabledDate:me,minTime:he,maxTime:ge,disabledTime:_e,placeholder:ve=x?`请选择日期范围`:y?`请选择日期时间`:`请选择日期`,disabled:S=!1,clearable:ye=!1,size:be=`md`,placement:C=`bottom-start`,offset:xe=8,zIndex:Se,className:Ce,style:we,id:Te,"aria-label":Ee,"aria-labelledby":De,"aria-describedby":Oe,onChange:ke,onClear:Ae,onOpen:je,onClose:Me,...Ne}=m,w=ke,Pe=(0,d.useRef)(null),T=(0,d.useRef)(null),E=(0,d.useRef)(null),Fe=(0,d.useRef)(null),D=n.t(),Ie=o.r({defaultZIndex:o.n.popover,zIndex:Se}),Le=t.t(m,`value`),[O,k]=t.n({value:ce??null,defaultValue:le??null,controlled:Le}),[A,Re]=(0,d.useState)(!1),[ze,j]=(0,d.useState)(()=>{let e=h(O)?g(O[0],b):g(O,b);return l._(e??new Date)}),[M,Be]=(0,d.useState)(null),[N,P]=(0,d.useState)([null,null]),[Ve,F]=(0,d.useState)(null),[I,L]=(0,d.useState)(`start`),[He,Ue]=(0,d.useState)(!1),[R,We]=(0,d.useState)(null),[Ge,Ke]=(0,d.useState)({}),[qe,Je]=(0,d.useState)(C),[Ye,Xe]=(0,d.useState)(!1),[Ze,z]=(0,d.useState)(null),Qe=a.t(`vl-${v}-control`,Te),B=a.t(`vl-${v}-panel`),$e=(0,d.useMemo)(()=>r.n(Pe,_),[_]),V=(0,d.useCallback)(()=>{Ue(!1),We(null)},[]),et=(0,d.useMemo)(()=>x?h(O)?[g(O[0],b),g(O[1],b)]:[null,null]:Array.isArray(O)?null:g(O,b),[b,x,O]),H=x?et:null,U=x?null:et,tt=re(O,b),nt=ze,rt=l.c(ze,1),W=g(fe,b),G=g(pe,b),it=he?l.y(he):null,at=ge?l.y(ge):null,K=(0,d.useMemo)(()=>({minSeconds:it,maxSeconds:at,disabledTime:_e}),[_e,at,it]),q=(0,d.useCallback)(e=>{let t=l.g(e);return!!(W&&l.u(t,l.g(W))<0||G&&l.u(t,l.g(G))>0||me?.(t))},[me,G,W]),J=(0,d.useCallback)(e=>l.i(e,K),[K]),ot=(0,d.useCallback)((e,t,n)=>l.n(e,t,n,K),[K]),st=(0,d.useCallback)(e=>y&&J(l.d(e,`HH:mm:ss`)),[J,y]),Y=(0,d.useCallback)(e=>{if(!(e&&(S||A))&&!(!e&&!A)){if(e){let e=(x?H?.[0]:U)??new Date;j(l._(e)),x?P(ie(H??[null,null])):Be(U?l.l(U):null),F(null),L(`start`),Xe(!1),Ke({}),Je(C),z(null),V(),Re(!0),je?.()}else z(null),F(null),V(),Re(!1),Me?.()}},[S,Me,je,A,C,x,V,U,H]),ct=(0,d.useCallback)(()=>{if(!A||!T.current||!E.current)return;let e=T.current.getBoundingClientRect(),t=i.t({anchorRect:e,floatingRect:E.current.getBoundingClientRect(),placement:C,offset:xe});Je(t.placement),Ke({left:`${Math.round(t.x)}px`,top:`${Math.round(t.y)}px`}),Xe(!0)},[xe,A,C]);e.t(()=>{if(!A||!D)return;ct();let e=window.requestAnimationFrame(ct);return()=>window.cancelAnimationFrame(e)},[D,A,ct]),e.t(()=>{if(!A||!Ze)return;let e=E.current?.querySelector(`[data-time="${Ze.getTime()}"]:not(:disabled)`);e&&(e.focus(),z(null))},[ze,Ze,A]);let lt=(0,d.useCallback)(e=>e.some(e=>e instanceof HTMLElement&&(e.getAttribute(p)===B||e.classList.contains(`vl-dropdown__panel`)&&e.querySelector(`[${p}]`)?.getAttribute(p)===B)),[B]),ut=(0,d.useCallback)(()=>Y(!1),[Y]),dt=(0,d.useCallback)(()=>{He||(Y(!1),T.current?.focus())},[Y,He]);i.r({active:A,rootRef:Pe,floatingRef:E,isOwnedPopup:lt,onOutsideClick:ut,onEscape:dt,onViewportChange:ct}),(0,d.useEffect)(()=>{S&&A&&Y(!1)},[S,A,Y]);let X=(0,d.useCallback)(e=>ue===`string`?l.d(e,b):l.l(e),[b,ue]),ft=(0,d.useCallback)(e=>{let t=oe(e,y);if(q(t)||y&&J(l.d(t,`HH:mm:ss`)))return;let n=X(t);se(O,n,b)||(k(n),w?.(n)),Y(!1),T.current?.focus()},[w,b,q,J,X,O,Y,k,y]),pt=(0,d.useCallback)(e=>{if(!e[0]||!e[1])return;let t=l.u(e[0],e[1])<=0?e:[e[1],e[0]],n=oe(t[0],y),r=oe(t[1],y);if(q(n)||q(r)||y&&(J(l.d(n,`HH:mm:ss`))||J(l.d(r,`HH:mm:ss`))))return;let i=[X(n),X(r)];se(O,i,b)||(k(i),w?.(i)),Y(!1),T.current?.focus()},[w,b,q,J,X,O,Y,k,y]),mt=e=>{if(q(e))return;F(null);let t=x?N[I===`start`?0:1]:M,n=l.g(e);if(y){if(t)n=l.h(e,t.getHours(),t.getMinutes(),t.getSeconds());else{let t=ot(0,86399,0);n=t===null?l.l(e):l.h(e,Math.floor(t/3600),Math.floor(t%3600/60),t%60)}}if(!x){Be(n),y||ft(n);return}let[r,i]=N;if(!r||i){P([n,null]),L(`start`);return}l.u(n,r)<0?(P([n,r]),L(`end`)):(P([r,n]),L(`end`))},ht=e=>{if(!x||!e||N[1]||q(e)){F(null);return}F(l.g(e))},Z=(0,d.useCallback)((e,t=!1)=>{if(e&&R){if(x){let e=ie(N);e[I===`start`?0:1]=l.l(R),P(e)}else Be(l.l(R))}V(),t&&window.requestAnimationFrame(()=>Fe.current?.focus())},[I,N,x,V,R]),gt=(e,t)=>{let n=R?l.l(R):new Date,r={hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds()},{start:i,end:a,preferred:o}=l.r(e,t,r),s=ot(i,a,o);if(s===null)return;let c=l.h(n,Math.floor(s/3600),Math.floor(s%3600/60),s%60);We(c)},_t=e=>{let t=e.getValue(new Date);if(t===null)return;if(x){if(!h(t))return;let e=g(t[0],b),n=g(t[1],b);if(!e||!n||q(e)||q(n)||st(e)||st(n))return;P(l.u(e,n)<=0?[e,n]:[n,e]),L(`end`);return}if(h(t))return;let n=g(t,b);!n||q(n)||st(n)||ft(n)},vt=e=>{e?.stopPropagation(),!S&&(k(null),w?.(null),Ae?.(),Be(null),P([null,null]))},Q=(e,t,n=!1)=>{let r=n?l.g(e):l.s(l.g(e),t);for(let e=0;e<3660;e+=1){if(t<0&&W&&l.u(r,l.g(W))<0||t>0&&G&&l.u(r,l.g(G))>0)return null;if(!q(r))return r;r=l.s(r,t)}return null},yt=e=>{if(!S){if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),A)Y(!1);else{let e=(x?H?.[0]:U)??new Date,t=Q(e,1,!0)??Q(e,-1,!0)??null;Y(!0),t&&z(t)}}else e.key===`Escape`&&A&&(e.preventDefault(),Y(!1))}},bt=e=>{!l.m(e,nt)&&!(x&&l.m(e,rt))&&j(l._(e)),z(l.g(e))},xt=(e,t)=>{let n=null;if(e.key===`ArrowLeft`)n=Q(t,-1);else if(e.key===`ArrowRight`)n=Q(t,1);else if(e.key===`ArrowUp`)n=Q(t,-7);else if(e.key===`ArrowDown`)n=Q(t,7);else if(e.key===`Home`||e.key===`End`){let r=e.key===`Home`?l.s(t,-t.getDay()):l.s(t,6-t.getDay()),i=e.key===`Home`?1:-1;for(let e=0;e<7;e+=1){let t=l.s(r,e*i);if(!q(t)){n=t;break}}}n&&(e.preventDefault(),bt(n))},$=x?N[I===`start`?0:1]:M,St=(0,d.useCallback)(e=>{if(e){if(!$)return;We(l.l($)),Ue(!0);return}Z(!1)},[$,Z]),Ct=R??$??new Date,wt=Ct.getHours(),Tt=Ct.getMinutes(),Et=Ct.getSeconds(),Dt=$?l.d(Ct,`HH:mm:ss`):``,Ot=x?I===`start`?`开始时间`:`结束时间`:`时间`,kt=(0,d.useCallback)((e,t)=>l.a(e,t,{hours:wt,minutes:Tt,seconds:Et},ot),[ot,wt,Tt,Et]),At=x?!!(N[0]&&N[1]&&!q(N[0])&&!q(N[1])&&(!y||!J(l.d(N[0],`HH:mm:ss`))&&!J(l.d(N[1],`HH:mm:ss`)))):!!(M&&!q(M)&&(!y||!J(l.d(M,`HH:mm:ss`)))),jt=!!tt,Mt=[`vl-${v}`,`size-${be}`,A?`is-open`:``,S?`is-disabled`:``,x?`is-range`:``,y?`has-time`:``,Ce||``].filter(Boolean).join(` `),Nt=e=>{let t=l.f(e),n=x?N[0]:null,r=x?N[1]:null,i=x&&n&&!r?Ve:null,a=r??i,o=n&&a&&l.u(n,a)<=0?n:a,s=n&&a&&l.u(n,a)<=0?a:n,c=x?null:M??U,ee=(x?[N[0],N[1]]:[c]).find(t=>t&&l.m(t,e)&&!q(t))??t.find(t=>l.m(t,e)&&!q(t));return(0,f.jsxs)(`section`,{className:`vl-${v}__calendar`,"aria-label":ae(e),children:[x?(0,f.jsx)(`div`,{className:`vl-${v}__month-title`,children:ae(e)}):null,(0,f.jsx)(`div`,{className:`vl-${v}__weekdays`,role:`row`,children:ne.map(e=>(0,f.jsx)(`span`,{role:`columnheader`,children:e},e))}),(0,f.jsx)(`div`,{className:`vl-${v}__grid`,role:`grid`,onMouseLeave:()=>F(null),onBlur:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||F(null)},children:t.map(t=>{let a=!l.m(t,e),u=a||q(t),d=!!(n&&r&&l.u(t,l.g(n))>=0&&l.u(t,l.g(r))<=0),te=!!(n&&i&&o&&s&&l.u(t,l.g(o))>=0&&l.u(t,l.g(s))<=0),p=d||te,ne=!!(o&&p&&l.p(t,o)),m=!!(s&&p&&l.p(t,s)),h=!!(i&&l.p(t,i)),g=[`vl-${v}__day`,a?`is-other-month`:``,l.p(t,new Date)?`is-today`:``,x&&n&&l.p(t,n)?`is-range-start is-selected`:``,x&&r&&l.p(t,r)?`is-range-end is-selected`:``,c&&l.p(t,c)?`is-selected`:``,p?`is-in-range`:``,ne?`is-range-edge-start`:``,m?`is-range-edge-end`:``,h?`is-range-preview-end`:``,u?`is-disabled`:``].filter(Boolean).join(` `);return(0,f.jsx)(`button`,{type:`button`,className:g,role:`gridcell`,"data-time":t.getTime(),"aria-label":`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日`,"aria-selected":x?d:!!(c&&l.p(t,c)),"aria-current":l.p(t,new Date)?`date`:void 0,"aria-hidden":a||void 0,"aria-disabled":u||void 0,disabled:u,tabIndex:!u&&ee&&l.p(t,ee)?0:-1,onClick:()=>mt(t),onKeyDown:e=>xt(e,t),onMouseEnter:()=>ht(t),onFocus:()=>ht(t),children:(0,f.jsx)(`span`,{className:`vl-${v}__day-content`,children:t.getDate()})},t.toISOString())})})]})},Pt=(0,f.jsx)(s.t,{show:A,name:`vl-${v}`,deferEffects:!D,children:(0,f.jsxs)(`div`,{ref:E,id:B,className:`vl-${v}__panel is-${qe}${Ye?` is-positioned`:``}`,style:{...Ge,zIndex:Ie.zIndex,visibility:Ye?`visible`:`hidden`},role:`dialog`,"aria-label":x?`日期范围选择`:y?`日期时间选择`:`日期选择`,children:[(0,f.jsxs)(`div`,{className:`vl-${v}__header`,children:[(0,f.jsxs)(`div`,{className:`vl-${v}__header-actions`,children:[(0,f.jsx)(`button`,{type:`button`,"aria-label":`上一年`,onClick:()=>j(e=>l.c(e,-12)),children:(0,f.jsx)(u.ChevronsLeft,{size:16,"aria-hidden":`true`})}),(0,f.jsx)(`button`,{type:`button`,"aria-label":`上一个月`,onClick:()=>j(e=>l.c(e,-1)),children:(0,f.jsx)(u.ChevronLeft,{size:16,"aria-hidden":`true`})})]}),x?null:(0,f.jsx)(`span`,{children:ae(nt)}),(0,f.jsxs)(`div`,{className:`vl-${v}__header-actions`,children:[(0,f.jsx)(`button`,{type:`button`,"aria-label":`下一个月`,onClick:()=>j(e=>l.c(e,1)),children:(0,f.jsx)(u.ChevronRight,{size:16,"aria-hidden":`true`})}),(0,f.jsx)(`button`,{type:`button`,"aria-label":`下一年`,onClick:()=>j(e=>l.c(e,12)),children:(0,f.jsx)(u.ChevronsRight,{size:16,"aria-hidden":`true`})})]})]}),(0,f.jsxs)(`div`,{className:`vl-${v}__calendars`,children:[Nt(nt),x?Nt(rt):null]}),y?(0,f.jsx)(`div`,{className:`vl-${v}__time`,children:(0,f.jsxs)(`div`,{className:`vl-${v}__time-toolbar`,children:[(0,f.jsx)(`span`,{className:`vl-${v}__time-title`,children:`时间`}),x?(0,f.jsxs)(`div`,{className:`vl-${v}__time-range`,children:[(0,f.jsx)(`button`,{type:`button`,className:I===`start`?`is-active`:``,"aria-pressed":I===`start`,disabled:!N[0],onClick:()=>{Z(!1),L(`start`)},children:`开始时间`}),(0,f.jsx)(`button`,{type:`button`,className:I===`end`?`is-active`:``,"aria-pressed":I===`end`,disabled:!N[1],onClick:()=>{Z(!1),L(`end`)},children:`结束时间`})]}):null,(0,f.jsx)(ee.t,{className:`vl-${v}__time-dropdown`,open:He,disabled:!$,trigger:`click`,placement:`bottom-end`,offset:4,closeOnContentClick:!1,"aria-label":Ot,menuLabel:`${Ot}选择器`,triggerContent:(0,f.jsx)(c.t,{ref:Fe,className:`vl-${v}__time-input`,value:Dt,placeholder:`请先选择日期`,size:`sm`,suffixIcon:u.Clock3,readOnly:!0,disabled:!$}),onChange:St,children:(0,f.jsxs)(`div`,{className:`vl-${v}__time-popover`,[p]:B,children:[(0,f.jsx)(l.t,{value:{hours:wt,minutes:Tt,seconds:Et},disabled:!$,ariaLabel:Ot,visibleItemCount:3,itemHeight:30,isOptionDisabled:kt,onChange:gt}),(0,f.jsxs)(`div`,{className:`vl-${v}__footer`,children:[(0,f.jsx)(`button`,{type:`button`,className:`is-cancel`,"aria-label":`取消时间`,onClick:()=>Z(!1,!0),children:`取消`}),(0,f.jsx)(`button`,{type:`button`,className:`is-confirm`,"aria-label":`确定时间`,disabled:!R,onClick:()=>Z(!0,!0),children:`确定`})]})]})})]})}):null,de.length?(0,f.jsx)(`div`,{className:`vl-${v}__shortcuts`,role:`group`,"aria-label":`快捷选择`,children:de.map(e=>(0,f.jsx)(`button`,{type:`button`,onClick:()=>_t(e),children:e.label},e.label))}):null,x||y?(0,f.jsxs)(`div`,{className:`vl-${v}__footer`,children:[(0,f.jsx)(`button`,{type:`button`,className:`is-cancel`,onClick:()=>{Y(!1),T.current?.focus()},children:`取消`}),(0,f.jsx)(`button`,{type:`button`,className:`is-confirm`,disabled:!At,onClick:()=>{x?pt(N):M&&ft(M)},children:`确定`})]}):null]})});return(0,f.jsx)(o.t,{layer:Ie.layer,children:(0,f.jsxs)(`div`,{ref:$e,className:`vl-${v}-wrapper`,style:we,...Ne,children:[(0,f.jsxs)(`div`,{ref:T,id:Qe,className:Mt,role:`combobox`,"aria-expanded":A,"aria-controls":B,"aria-haspopup":`dialog`,"aria-disabled":S||void 0,"aria-label":Ee??(De?void 0:ve),"aria-labelledby":De,"aria-describedby":Oe,tabIndex:S?-1:0,onClick:()=>Y(!A),onKeyDown:yt,children:[(0,f.jsx)(`span`,{className:`vl-${v}__icon`,"aria-hidden":`true`,children:(0,f.jsx)(u.CalendarDays,{size:16})}),(0,f.jsx)(`span`,{className:`vl-${v}__value${tt?``:` is-placeholder`}`,children:tt||ve}),ye&&jt&&!S?(0,f.jsx)(`button`,{type:`button`,className:`vl-${v}__clear`,"aria-label":`清除已选`,onClick:vt,onMouseDown:e=>e.preventDefault(),children:(0,f.jsx)(u.X,{size:16,"aria-hidden":`true`})}):null]}),D?(0,te.createPortal)(Pt,document.body):Pt]})})});_.displayName=`VlDatePickerCore`,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _}});
|