@vavt/react-ui 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Anchor-QZROepM_.js → Anchor-CAZPkv56.js} +1 -1
- package/dist/{Anchor-iriRYxEs.cjs → Anchor-CmuV1Ump.cjs} +1 -1
- package/dist/{Announcement-XjJyJ28N.cjs → Announcement-D0hZE2sM.cjs} +1 -1
- package/dist/{Announcement-D_NccvTm.js → Announcement-DzzaTvcO.js} +1 -1
- package/dist/Checkbox-CBMmX-R-.js +86 -0
- package/dist/Checkbox-CzNGP2tH.cjs +1 -0
- package/dist/Checkbox-GJlGNzlH.cjs +1 -0
- package/dist/Checkbox-bHOjYdMp.js +61 -0
- package/dist/{Cron-Go4yIqrd.js → Cron-DIB4GG4y.js} +7 -7
- package/dist/{Cron-3D9GmlYf.cjs → Cron-MhbYMEeJ.cjs} +1 -1
- package/dist/{DatePicker-D75NqBYX.js → DatePicker--13tW0cw.js} +1 -1
- package/dist/{DatePicker-D3tdU7GY.cjs → DatePicker-Bj709smn.cjs} +1 -1
- package/dist/{DateTimePicker-CG-yv54X.js → DateTimePicker-Blqs2Bcv.js} +1 -1
- package/dist/{DateTimePicker-CCe5NUkC.cjs → DateTimePicker-ZSScsk-j.cjs} +1 -1
- package/dist/{Drawer-CeBlbSjY.cjs → Drawer-DcbgMkub.cjs} +1 -1
- package/dist/{Drawer-CgaSQfT_.js → Drawer-yM_r1M0H.js} +1 -1
- package/dist/{Dropdown-BsXYVdt6.cjs → Dropdown-PHqXNiAZ.cjs} +1 -1
- package/dist/{Dropdown-DljKFnvO.js → Dropdown-mYCY-LcF.js} +2 -2
- package/dist/Form-BkyDHPEI.cjs +1 -0
- package/dist/Form-D_Uv-8HG.js +449 -0
- package/dist/{Input-CIB_TY2n.js → Input-BRy5Xuwy.js} +28 -37
- package/dist/Input-C9ESmbJ7.cjs +1 -0
- package/dist/{MessageBox-nHLRzRJS.cjs → MessageBox-D7Ib1f7K.cjs} +1 -1
- package/dist/{MessageBox-DlAv_jQm.js → MessageBox-DDP6UWFU.js} +2 -2
- package/dist/{Modal-CAZ8vap0.cjs → Modal-DPxZEr2v.cjs} +1 -1
- package/dist/Modal-Du7aVdWl.js +239 -0
- package/dist/{NumberInput-C_vLULbX.js → NumberInput-CB-nKZgs.js} +1 -1
- package/dist/{NumberInput-CYVj89_s.cjs → NumberInput-Dp1vTDkW.cjs} +1 -1
- package/dist/{Pagination-CSI5IzQB.js → Pagination-CpbboRbF.js} +2 -2
- package/dist/{Pagination-ODU-i3gn.cjs → Pagination-DatEegaF.cjs} +1 -1
- package/dist/RadioGroup-DTodR0VJ.cjs +1 -0
- package/dist/RadioGroup-DYjQMXdB.js +136 -0
- package/dist/Select-BHWa_6Q2.js +466 -0
- package/dist/Select-C6O0tmM_.cjs +1 -0
- package/dist/{Slider-BzlZc0p4.js → Slider-CKU03SsT.js} +1 -1
- package/dist/{Slider-DCIUxcBa.cjs → Slider-CU9OS2HB.cjs} +1 -1
- package/dist/{Switch-7yJ-Q_o_.cjs → Switch-CpXDMcPW.cjs} +1 -1
- package/dist/{Switch-DOO2tiYR.js → Switch-CqTFvp-k.js} +1 -1
- package/dist/Table-BNGO_7Rx.cjs +1 -0
- package/dist/Table-Cfs3XJgN.js +531 -0
- package/dist/{Tabs-BhjvKN84.cjs → Tabs-BZ0Zc0bL.cjs} +1 -1
- package/dist/{Tabs-VT6nQ63W.js → Tabs-HWLkyrQR.js} +1 -1
- package/dist/Tag-4iZGcfrg.cjs +1 -0
- package/dist/Tag-TeYTDdHt.js +51 -0
- package/dist/{Textarea-BEd7ToXv.js → Textarea-CA6Vzu7t.js} +1 -1
- package/dist/{Textarea-C2dNYM0F.cjs → Textarea-CEhAvE10.cjs} +1 -1
- package/dist/{TimePicker-CHZsr_jj.js → TimePicker-CYlcUTTM.js} +2 -2
- package/dist/{TimePicker-Cpmvn8tx.cjs → TimePicker-DoGbwfkU.cjs} +1 -1
- package/dist/{Tooltip-Buk5F9f_.js → Tooltip-BKPreZML.js} +2 -2
- package/dist/{Tooltip-CP8rpNYG.cjs → Tooltip-DDjGLjoV.cjs} +1 -1
- package/dist/{Upload-CVIzg2Px.js → Upload-DZ6VaM7r.js} +1 -1
- package/dist/{Upload-CIOunhpr.cjs → Upload-wHEEoe1c.cjs} +1 -1
- package/dist/cjs/Anchor.cjs +1 -1
- package/dist/cjs/Announcement.cjs +1 -1
- package/dist/cjs/Checkbox.cjs +1 -1
- package/dist/cjs/Cron.cjs +1 -1
- package/dist/cjs/DatePicker.cjs +1 -1
- package/dist/cjs/DateTimePicker.cjs +1 -1
- package/dist/cjs/Drawer.cjs +1 -1
- package/dist/cjs/Dropdown.cjs +1 -1
- package/dist/cjs/Form.cjs +1 -1
- package/dist/cjs/Input.cjs +1 -1
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/NumberInput.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Radio.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Slider.cjs +1 -1
- package/dist/cjs/Switch.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/Tabs.cjs +1 -1
- package/dist/cjs/Tag.cjs +1 -1
- package/dist/cjs/Textarea.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/Upload.cjs +1 -1
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/css/Checkbox.css +1 -1
- package/dist/css/Form.css +1 -1
- package/dist/css/Input.css +1 -1
- package/dist/css/MessageBox.css +1 -1
- package/dist/css/Modal.css +1 -1
- package/dist/css/Radio.css +1 -1
- package/dist/css/Select.css +1 -1
- package/dist/css/Tag.css +1 -1
- package/dist/{date-picker-pwA2wCag.cjs → date-picker-Be_1wA3S.cjs} +1 -1
- package/dist/{date-picker-BH--Nh7g.js → date-picker-CHP0eBuL.js} +4 -4
- package/dist/es/Anchor.mjs +1 -1
- package/dist/es/Announcement.mjs +1 -1
- package/dist/es/Checkbox.mjs +1 -1
- package/dist/es/Cron.mjs +1 -1
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/Input.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/NumberInput.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Radio.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Slider.mjs +1 -1
- package/dist/es/Switch.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/Tabs.mjs +1 -1
- package/dist/es/Tag.mjs +1 -1
- package/dist/es/Textarea.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/Upload.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +25 -25
- package/dist/es/register.mjs +1 -1
- package/dist/floating-5PRFyI8D.cjs +1 -0
- package/dist/floating-CqdcJWk2.js +181 -0
- package/dist/index.css +1 -1
- package/dist/registry-BqfLh5B_.cjs +1 -0
- package/dist/{registry-macDoSyW.js → registry-C8ZL-n-l.js} +24 -24
- package/dist/state-BSDh-Ob2.js +22 -0
- package/dist/state-BuUx1onZ.cjs +1 -0
- package/dist/types/Checkbox/context.d.cts +12 -2
- package/dist/types/Checkbox/context.d.ts +12 -2
- package/dist/types/Checkbox/type.d.cts +33 -3
- package/dist/types/Checkbox/type.d.ts +33 -3
- package/dist/types/Form/FormItem.d.cts +1 -1
- package/dist/types/Form/FormItem.d.ts +1 -1
- package/dist/types/Form/context.d.cts +31 -0
- package/dist/types/Form/context.d.ts +31 -0
- package/dist/types/Form/index.d.cts +2 -2
- package/dist/types/Form/index.d.ts +2 -2
- package/dist/types/Form/type.d.cts +0 -2
- package/dist/types/Form/type.d.ts +0 -2
- package/dist/types/Radio/context.d.cts +12 -2
- package/dist/types/Radio/context.d.ts +12 -2
- package/dist/types/Radio/type.d.cts +33 -3
- package/dist/types/Radio/type.d.ts +33 -3
- package/dist/types/Tag/index.d.cts +1 -1
- package/dist/types/Tag/index.d.ts +1 -1
- package/dist/types/Tag/type.d.cts +5 -0
- package/dist/types/Tag/type.d.ts +5 -0
- package/dist/types/_shared/state.d.cts +3 -0
- package/dist/types/_shared/state.d.ts +3 -0
- package/dist/types/registry.d.cts +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/package.json +1 -1
- package/dist/Checkbox-BCXbK1-8.cjs +0 -1
- package/dist/Checkbox-CQZSg9Xu.cjs +0 -1
- package/dist/Checkbox-CQeqLO0S.js +0 -46
- package/dist/Checkbox-cnXHW9Oz.js +0 -61
- package/dist/Form-BfXRwX6y.js +0 -353
- package/dist/Form-QpWOfQpR.cjs +0 -1
- package/dist/Input-CoDZggqc.cjs +0 -1
- package/dist/Modal-DnLKpKvW.js +0 -238
- package/dist/RadioGroup-BRcNi5Oc.js +0 -98
- package/dist/RadioGroup-q2Aa50NV.cjs +0 -1
- package/dist/Select-BRKxpX-_.cjs +0 -1
- package/dist/Select-QedbJ4pD.js +0 -468
- package/dist/Table-BFqTvxt1.js +0 -440
- package/dist/Table-D4csqW47.cjs +0 -1
- package/dist/Tag-Cf9M_HT6.cjs +0 -1
- package/dist/Tag-CkfqoSwA.js +0 -42
- package/dist/floating-DBAmeQIq.js +0 -157
- package/dist/floating-DXRnx48N.cjs +0 -1
- package/dist/registry-BO2ao8Jc.cjs +0 -1
- package/dist/state-ZBA75xZ_.cjs +0 -1
- package/dist/state-oH-YwB7_.js +0 -15
|
@@ -0,0 +1,449 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./icon-Cbvuv4yF.js";
|
|
2
|
-
import { n as t, t as n } from "./state-
|
|
2
|
+
import { n as t, t as n } from "./state-BSDh-Ob2.js";
|
|
3
3
|
import { n as r } from "./refs-D5IYOBaf.js";
|
|
4
4
|
import { t as i } from "./id-CHixuHb7.js";
|
|
5
5
|
import { X as a } from "lucide-react";
|
|
@@ -7,49 +7,40 @@ import { forwardRef as o, useMemo as s, useRef as c, useState as l } from "react
|
|
|
7
7
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
8
|
//#region components/Input/Input.tsx
|
|
9
9
|
var f = o((o, f) => {
|
|
10
|
-
let { value: p, defaultValue: m = "", placeholder: h, disabled: g = !1, loading: _ = !1, size: v = "md", type: y = "text", clearable: b = !1, prefixIcon: x, suffixIcon: S, tips: C, prefix: w, suffix: T, id: E, "aria-describedby": D, className: O, style: k, onClear: A, onInput: j, onChange: M, onFocus: N, onBlur: P, onKeyDown: F, ...I } = o, L = c(null), R = s(() => r(L, f), [f]), [z, B] = l(!1),
|
|
10
|
+
let { value: p, defaultValue: m = "", placeholder: h, disabled: g = !1, loading: _ = !1, size: v = "md", type: y = "text", clearable: b = !1, prefixIcon: x, suffixIcon: S, tips: C, prefix: w, suffix: T, id: E, "aria-describedby": D, className: O, style: k, onClear: A, onInput: j, onChange: M, onFocus: N, onBlur: P, onKeyDown: F, ...I } = o, L = c(null), R = s(() => r(L, f), [f]), [z, B] = l(!1), V = n(o, "value"), [H, U] = t({
|
|
11
11
|
value: p == null ? "" : String(p),
|
|
12
12
|
defaultValue: m == null ? "" : String(m),
|
|
13
|
-
controlled:
|
|
13
|
+
controlled: V,
|
|
14
14
|
onChange: M
|
|
15
|
-
}),
|
|
15
|
+
}), W = i("vl-input", E), G = i("vl-input-tips"), K = [D, C ? G : void 0].filter(Boolean).join(" ") || void 0, q = [
|
|
16
16
|
"vl-input-wrapper",
|
|
17
17
|
C ? "has-tips" : "",
|
|
18
18
|
O || ""
|
|
19
|
-
].filter(Boolean).join(" "),
|
|
19
|
+
].filter(Boolean).join(" "), J = [
|
|
20
20
|
"vl-input",
|
|
21
21
|
v ? `size-${v}` : "",
|
|
22
22
|
g ? "is-disabled" : "",
|
|
23
23
|
_ ? "is-loading" : "",
|
|
24
24
|
z ? "is-focused" : ""
|
|
25
|
-
].filter(Boolean).join(" "),
|
|
26
|
-
b,
|
|
27
|
-
g,
|
|
28
|
-
_,
|
|
29
|
-
W,
|
|
30
|
-
z,
|
|
31
|
-
V
|
|
32
|
-
]), Q = (e) => {
|
|
25
|
+
].filter(Boolean).join(" "), Y = b && !g && !_ && H !== "" && H != null, X = (e) => {
|
|
33
26
|
j?.(e);
|
|
34
|
-
},
|
|
27
|
+
}, Z = (e) => {
|
|
35
28
|
let t = e.target;
|
|
36
|
-
|
|
37
|
-
},
|
|
29
|
+
U(t.value);
|
|
30
|
+
}, Q = (e) => {
|
|
38
31
|
B(!0), N?.(e);
|
|
39
|
-
},
|
|
32
|
+
}, $ = (e) => {
|
|
40
33
|
B(!1), P?.(e);
|
|
41
|
-
},
|
|
34
|
+
}, ee = (e) => {
|
|
42
35
|
F?.(e);
|
|
43
|
-
},
|
|
44
|
-
|
|
36
|
+
}, te = () => {
|
|
37
|
+
U(""), A?.(), L.current?.focus();
|
|
45
38
|
};
|
|
46
39
|
return /* @__PURE__ */ d("div", {
|
|
47
|
-
className:
|
|
40
|
+
className: q,
|
|
48
41
|
style: k,
|
|
49
42
|
children: [/* @__PURE__ */ d("div", {
|
|
50
|
-
className:
|
|
51
|
-
onMouseEnter: () => H(!0),
|
|
52
|
-
onMouseLeave: () => H(!1),
|
|
43
|
+
className: J,
|
|
53
44
|
children: [
|
|
54
45
|
w ? /* @__PURE__ */ u("div", {
|
|
55
46
|
className: "vl-input__prefix",
|
|
@@ -61,28 +52,28 @@ var f = o((o, f) => {
|
|
|
61
52
|
}) : null,
|
|
62
53
|
/* @__PURE__ */ u("input", {
|
|
63
54
|
ref: R,
|
|
64
|
-
id:
|
|
55
|
+
id: W,
|
|
65
56
|
className: "vl-input__inner",
|
|
66
57
|
type: y,
|
|
67
|
-
value:
|
|
58
|
+
value: H,
|
|
68
59
|
placeholder: h,
|
|
69
60
|
disabled: g || _,
|
|
70
61
|
"aria-busy": _ || void 0,
|
|
71
|
-
"aria-describedby":
|
|
72
|
-
onInput:
|
|
73
|
-
onChange:
|
|
74
|
-
onFocus:
|
|
75
|
-
onBlur:
|
|
76
|
-
onKeyDown:
|
|
62
|
+
"aria-describedby": K,
|
|
63
|
+
onInput: X,
|
|
64
|
+
onChange: Z,
|
|
65
|
+
onFocus: Q,
|
|
66
|
+
onBlur: $,
|
|
67
|
+
onKeyDown: ee,
|
|
77
68
|
...I
|
|
78
69
|
}),
|
|
79
70
|
b && !g && !_ ? /* @__PURE__ */ u("button", {
|
|
80
71
|
type: "button",
|
|
81
|
-
className: `vl-input__clear${
|
|
72
|
+
className: `vl-input__clear${Y ? " can-clear" : ""}`,
|
|
82
73
|
"aria-label": "清空输入",
|
|
83
|
-
"aria-hidden": !
|
|
84
|
-
tabIndex:
|
|
85
|
-
onClick:
|
|
74
|
+
"aria-hidden": !Y || void 0,
|
|
75
|
+
tabIndex: Y ? 0 : -1,
|
|
76
|
+
onClick: te,
|
|
86
77
|
onMouseDown: (e) => e.preventDefault(),
|
|
87
78
|
children: /* @__PURE__ */ u(a, {
|
|
88
79
|
size: 16,
|
|
@@ -99,7 +90,7 @@ var f = o((o, f) => {
|
|
|
99
90
|
}) : null
|
|
100
91
|
]
|
|
101
92
|
}), C ? /* @__PURE__ */ u("div", {
|
|
102
|
-
id:
|
|
93
|
+
id: G,
|
|
103
94
|
className: "vl-input__tips",
|
|
104
95
|
children: C
|
|
105
96
|
}) : null]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./icon-DRLyKu8p.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./id-CF0zOP1G.cjs");let i=require("lucide-react"),a=require("react"),o=require("react/jsx-runtime");var s=(0,a.forwardRef)((s,c)=>{let{value:l,defaultValue:u=``,placeholder:d,disabled:f=!1,loading:p=!1,size:m=`md`,type:h=`text`,clearable:g=!1,prefixIcon:_,suffixIcon:v,tips:y,prefix:b,suffix:x,id:S,"aria-describedby":C,className:w,style:T,onClear:E,onInput:D,onChange:O,onFocus:k,onBlur:A,onKeyDown:j,...M}=s,N=(0,a.useRef)(null),P=(0,a.useMemo)(()=>n.n(N,c),[c]),[F,I]=(0,a.useState)(!1),L=t.t(s,`value`),[R,z]=t.n({value:l==null?``:String(l),defaultValue:u==null?``:String(u),controlled:L,onChange:O}),B=r.t(`vl-input`,S),V=r.t(`vl-input-tips`),H=[C,y?V:void 0].filter(Boolean).join(` `)||void 0,U=[`vl-input-wrapper`,y?`has-tips`:``,w||``].filter(Boolean).join(` `),W=[`vl-input`,m?`size-${m}`:``,f?`is-disabled`:``,p?`is-loading`:``,F?`is-focused`:``].filter(Boolean).join(` `),G=g&&!f&&!p&&R!==``&&R!=null,K=e=>{D?.(e)},q=e=>{let t=e.target;z(t.value)},J=e=>{I(!0),k?.(e)},Y=e=>{I(!1),A?.(e)},X=e=>{j?.(e)},Z=()=>{z(``),E?.(),N.current?.focus()};return(0,o.jsxs)(`div`,{className:U,style:T,children:[(0,o.jsxs)(`div`,{className:W,children:[b?(0,o.jsx)(`div`,{className:`vl-input__prefix`,children:b}):null,_?(0,o.jsx)(`div`,{className:`vl-input__prefix-icon`,children:e.n(_)}):null,(0,o.jsx)(`input`,{ref:P,id:B,className:`vl-input__inner`,type:h,value:R,placeholder:d,disabled:f||p,"aria-busy":p||void 0,"aria-describedby":H,onInput:K,onChange:q,onFocus:J,onBlur:Y,onKeyDown:X,...M}),g&&!f&&!p?(0,o.jsx)(`button`,{type:`button`,className:`vl-input__clear${G?` can-clear`:``}`,"aria-label":`清空输入`,"aria-hidden":!G||void 0,tabIndex:G?0:-1,onClick:Z,onMouseDown:e=>e.preventDefault(),children:(0,o.jsx)(i.X,{size:16,"aria-hidden":`true`})}):null,v?(0,o.jsx)(`div`,{className:`vl-input__suffix-icon`,children:e.n(v)}):null,x?(0,o.jsx)(`div`,{className:`vl-input__suffix`,children:x}):null]}),y?(0,o.jsx)(`div`,{id:V,className:`vl-input__tips`,children:y}):null]})});s.displayName=`VlInput`;var c=s,l=s;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./state-
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import { n as e, t } from "./state-
|
|
1
|
+
import { n as e, t } from "./state-BSDh-Ob2.js";
|
|
2
2
|
import { t as n } from "./Button-CwkWSWau.js";
|
|
3
3
|
import { t as r } from "./focus-BDDJyKk3.js";
|
|
4
|
-
import { t as i } from "./Modal-
|
|
4
|
+
import { t as i } from "./Modal-Du7aVdWl.js";
|
|
5
5
|
import { CircleAlert as a, CircleCheck as o, CircleX as s, Info as c, X as l } from "lucide-react";
|
|
6
6
|
import { forwardRef as u, useRef as d, useState as f } from "react";
|
|
7
7
|
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-
|
|
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}});
|