@vavt/react-ui 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Col-CZjR94ac.js → Col-BZdKuXbj.js} +1 -1
- package/dist/{Col-qcq7T83y.cjs → Col-CvoVGKUn.cjs} +1 -1
- package/dist/Cron-B4S_KhO1.cjs +1 -0
- package/dist/{Cron-C3S1XI-J.js → Cron-B8cGD7-3.js} +352 -344
- package/dist/{DatePicker-B5uYQlzy.cjs → DatePicker-DwACFSC7.cjs} +1 -1
- package/dist/{DatePicker-DhRxFPCj.js → DatePicker-w6jWiNfz.js} +1 -1
- package/dist/{DateTimePicker-Bve5qoeh.cjs → DateTimePicker-B5atDTPW.cjs} +1 -1
- package/dist/{DateTimePicker-BjDD15Av.js → DateTimePicker-NP2aVE5R.js} +1 -1
- package/dist/Dropdown-Chx8SZPS.cjs +1 -0
- package/dist/Dropdown-CyVxoFAH.js +330 -0
- package/dist/Form-CyCbST4e.cjs +1 -0
- package/dist/Form-Fe4b1pS1.js +446 -0
- package/dist/{Pagination-DTRhw83o.js → Pagination-BrG1pKYw.js} +1 -1
- package/dist/{Pagination-BRxRbWlU.cjs → Pagination-D3ok8N9k.cjs} +1 -1
- package/dist/Row-BGzLSkCy.js +24 -0
- package/dist/Row-CRQKzpiH.cjs +1 -0
- package/dist/Select-GleCzXQB.js +497 -0
- package/dist/Select-Rx6AHue2.cjs +1 -0
- package/dist/Sidebar-2KVVRUEM.cjs +1 -0
- package/dist/Sidebar-ByLinOVm.js +77 -0
- package/dist/{Table-DdWKhZAZ.js → Table-ClWg25Wn.js} +10 -7
- package/dist/{Table-B1BEfBJC.cjs → Table-Dv2qxs8q.cjs} +1 -1
- package/dist/TimePicker-BCU7D6uD.cjs +1 -0
- package/dist/{TimePicker-77L1Vyxn.js → TimePicker-BVZbkBvJ.js} +89 -81
- package/dist/Tooltip-BbbIT5nt.js +198 -0
- package/dist/Tooltip-z6u7ChKj.cjs +1 -0
- package/dist/base.css +1 -1
- package/dist/cjs/Col.cjs +1 -1
- package/dist/cjs/Cron.cjs +1 -1
- package/dist/cjs/DatePicker.cjs +1 -1
- package/dist/cjs/DateTimePicker.cjs +1 -1
- package/dist/cjs/Dropdown.cjs +1 -1
- package/dist/cjs/Form.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Row.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Sidebar.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/css/Button.css +1 -1
- package/dist/css/Checkbox.css +1 -1
- package/dist/css/Radio.css +1 -1
- package/dist/css/Sidebar.css +1 -1
- package/dist/css/Switch.css +1 -1
- package/dist/date-picker-DVvBQnvF.cjs +1 -0
- package/dist/date-picker-pcnebTrf.js +639 -0
- package/dist/es/Col.mjs +1 -1
- package/dist/es/Cron.mjs +1 -1
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Row.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Sidebar.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +13 -13
- package/dist/es/register.mjs +1 -1
- package/dist/floating-BpTI3sWS.cjs +1 -0
- package/dist/{floating-CqdcJWk2.js → floating-BqCWEj83.js} +27 -15
- package/dist/index.css +1 -1
- package/dist/{registry-DbMCy1-n.js → registry-Cddoj83d.js} +12 -12
- package/dist/{registry-Chcx2tDO.cjs → registry-DvXvnY8T.cjs} +1 -1
- package/dist/style/Sidebar.cjs +1 -0
- package/dist/style/Sidebar.mjs +1 -0
- package/dist/types/Form/type.d.cts +2 -0
- package/dist/types/Form/type.d.ts +2 -0
- package/dist/types/Select/SelectList.d.cts +20 -0
- package/dist/types/Select/SelectList.d.ts +20 -0
- package/dist/types/_shared/date-calendar.d.cts +20 -0
- package/dist/types/_shared/date-calendar.d.ts +20 -0
- package/dist/types/_shared/floating.d.cts +13 -1
- package/dist/types/_shared/floating.d.ts +13 -1
- package/package.json +1 -1
- package/dist/Cron-CIZ9GKm0.cjs +0 -1
- package/dist/Dropdown-BcT4uaQT.js +0 -319
- package/dist/Dropdown-CPW-aSTx.cjs +0 -1
- package/dist/Form-LuUPwJc2.cjs +0 -1
- package/dist/Form-rXq9r3N-.js +0 -442
- package/dist/Row-BJZtEKxG.cjs +0 -1
- package/dist/Row-DpEse7PJ.js +0 -24
- package/dist/Select-B9umyfKd.cjs +0 -1
- package/dist/Select-DDsgKaDL.js +0 -466
- package/dist/Sidebar-BPXVnP7y.cjs +0 -1
- package/dist/Sidebar-u980T-QB.js +0 -76
- package/dist/TimePicker-CsaiM5CQ.cjs +0 -1
- package/dist/Tooltip-DH3oc4Wa.js +0 -205
- package/dist/Tooltip-DP2yxQpo.cjs +0 -1
- package/dist/date-picker-CIAVlMqv.cjs +0 -1
- package/dist/date-picker-Co0ySn01.js +0 -612
- package/dist/floating-5PRFyI8D.cjs +0 -1
|
@@ -0,0 +1,446 @@
|
|
|
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-BbbIT5nt.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), w = C.Provider, re = () => f(C), T = s(null).Provider, E = (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
|
+
}, D = ["blur", "submit"], O = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, k = (e) => e ? Array.isArray(e) ? e : [e] : D, A = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) && e.length === 0, ie = (e, t, n, r) => {
|
|
18
|
+
let i = t ?? e;
|
|
19
|
+
if (n.required && A(r)) return n.message ?? `请输入${i}`;
|
|
20
|
+
if (A(r)) return;
|
|
21
|
+
if (n.type && !(n.type === "array" ? Array.isArray(r) : n.type === "email" ? typeof r == "string" && O.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
|
+
}, j = 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: C = !0, ...re } = n, E = t(n, "values"), D = m(() => E ? a ?? {} : null, [E, a]), O = h(D ?? o), A = h({}), j = h({}), M = h(!1), [ae, oe] = te(!1), N = h(null), P = h(/* @__PURE__ */ new Map()), F = h(/* @__PURE__ */ new Map()), I = h(/* @__PURE__ */ new Map()), L = h(/* @__PURE__ */ new Map()), R = h(v), z = h(b), B = h(x), V = h(S);
|
|
28
|
+
e(() => {
|
|
29
|
+
R.current = v, z.current = b, B.current = x, V.current = S;
|
|
30
|
+
});
|
|
31
|
+
let H = m(() => k(u), [u]), U = d((e) => {
|
|
32
|
+
let t = I.current.get(e);
|
|
33
|
+
t && t.forEach((e) => e());
|
|
34
|
+
}, []), W = d((e, t) => {
|
|
35
|
+
let n = I.current.get(e);
|
|
36
|
+
return n || (n = /* @__PURE__ */ new Set(), I.current.set(e, n)), n.add(t), () => {
|
|
37
|
+
n?.delete(t), n && n.size === 0 && I.current.delete(e);
|
|
38
|
+
};
|
|
39
|
+
}, []), G = d((e) => {
|
|
40
|
+
let t = E ? void 0 : O.current[e], n = A.current[e] ?? y, r = !!j.current[e], i = L.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 L.current.set(e, a), a;
|
|
48
|
+
}, [E]);
|
|
49
|
+
e(() => {
|
|
50
|
+
D !== null && (O.current = D);
|
|
51
|
+
}, [D]);
|
|
52
|
+
let K = d((e) => {
|
|
53
|
+
let t = A.current;
|
|
54
|
+
A.current = e;
|
|
55
|
+
let n = /* @__PURE__ */ new Set();
|
|
56
|
+
for (let r of Object.keys(t)) t[r] !== e[r] && n.add(r);
|
|
57
|
+
for (let r of Object.keys(e)) t[r] !== e[r] && n.add(r);
|
|
58
|
+
n.forEach((e) => {
|
|
59
|
+
U(e);
|
|
60
|
+
});
|
|
61
|
+
}, [U]), q = d((e) => (P.current.set(e.name, e), () => {
|
|
62
|
+
if (P.current.get(e.name)?.token === e.token) {
|
|
63
|
+
if (P.current.delete(e.name), F.current.delete(e.name), L.current.delete(e.name), Object.prototype.hasOwnProperty.call(A.current, e.name)) {
|
|
64
|
+
let t = { ...A.current };
|
|
65
|
+
delete t[e.name], K(t);
|
|
66
|
+
}
|
|
67
|
+
if (j.current[e.name]) {
|
|
68
|
+
let t = { ...j.current };
|
|
69
|
+
delete t[e.name], j.current = t, U(e.name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}), [K, U]), J = d((e, t) => {
|
|
73
|
+
let n = {
|
|
74
|
+
...O.current,
|
|
75
|
+
[e]: t
|
|
76
|
+
};
|
|
77
|
+
return E || (O.current = n, U(e)), R.current?.({ [e]: t }, n), n;
|
|
78
|
+
}, [E, U]), Y = d(async (e, t) => {
|
|
79
|
+
let n = P.current.get(e);
|
|
80
|
+
if (!n) return [];
|
|
81
|
+
let r = t ?? O.current, i = r[e], a = Symbol(e);
|
|
82
|
+
F.current.set(e, a), j.current = {
|
|
83
|
+
...j.current,
|
|
84
|
+
[e]: !0
|
|
85
|
+
}, U(e);
|
|
86
|
+
let o = [], { rules: s, label: c } = n.metaRef.current;
|
|
87
|
+
for (let t of s) {
|
|
88
|
+
let n = ie(e, c, t, i);
|
|
89
|
+
if (n && o.push(n), t.validator) try {
|
|
90
|
+
let e = await t.validator(i, r);
|
|
91
|
+
e && o.push(t.message ?? e);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
let n = e instanceof Error ? e.message : "校验失败";
|
|
94
|
+
o.push(t.message ?? n);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (P.current.get(e)?.token !== n.token || F.current.get(e) !== a) return o;
|
|
98
|
+
let l = { ...A.current };
|
|
99
|
+
return o.length ? l[e] = o : delete l[e], K(l), j.current = {
|
|
100
|
+
...j.current,
|
|
101
|
+
[e]: !1
|
|
102
|
+
}, U(e), o;
|
|
103
|
+
}, [K, U]), X = d(async () => {
|
|
104
|
+
let e = O.current, t = [...P.current.values()], n = await Promise.all(t.map(async (t) => {
|
|
105
|
+
let n = Y(t.name, e);
|
|
106
|
+
return [
|
|
107
|
+
t,
|
|
108
|
+
F.current.get(t.name),
|
|
109
|
+
await n
|
|
110
|
+
];
|
|
111
|
+
})), r = { ...A.current };
|
|
112
|
+
return n.forEach(([e, t, n]) => {
|
|
113
|
+
P.current.get(e.name)?.token === e.token && F.current.get(e.name) === t && (n.length ? r[e.name] = n : delete r[e.name]);
|
|
114
|
+
}), K(r), {
|
|
115
|
+
valid: Object.keys(r).length === 0,
|
|
116
|
+
values: e,
|
|
117
|
+
errors: r
|
|
118
|
+
};
|
|
119
|
+
}, [K, Y]), Z = d(() => {
|
|
120
|
+
if (N.current) return N.current;
|
|
121
|
+
let e = (async () => {
|
|
122
|
+
M.current = !0, oe(!0);
|
|
123
|
+
try {
|
|
124
|
+
let e = await X();
|
|
125
|
+
if (e.valid) try {
|
|
126
|
+
await z.current?.(e.values);
|
|
127
|
+
} catch (t) {
|
|
128
|
+
B.current?.(t, e.values);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
V.current?.(e.errors, e.values);
|
|
132
|
+
let t = [...P.current.keys()].find((t) => e.errors[t]);
|
|
133
|
+
t && i(P.current.get(t)?.metaRef.current.element ?? null);
|
|
134
|
+
}
|
|
135
|
+
return e;
|
|
136
|
+
} finally {
|
|
137
|
+
M.current = !1, oe(!1);
|
|
138
|
+
}
|
|
139
|
+
})();
|
|
140
|
+
return N.current = e, e.then(() => {
|
|
141
|
+
N.current === e && (N.current = null);
|
|
142
|
+
}, () => {
|
|
143
|
+
N.current === e && (N.current = null);
|
|
144
|
+
}), e;
|
|
145
|
+
}, [X]), Q = d((e) => {
|
|
146
|
+
let t = O.current, n = {
|
|
147
|
+
...t,
|
|
148
|
+
...e
|
|
149
|
+
};
|
|
150
|
+
O.current = n;
|
|
151
|
+
for (let r of Object.keys(e)) Object.is(t[r], n[r]) || U(r);
|
|
152
|
+
R.current?.(e, n);
|
|
153
|
+
}, [U]), $ = d(() => {
|
|
154
|
+
let e = { ...o }, t = O.current;
|
|
155
|
+
O.current = e;
|
|
156
|
+
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]]));
|
|
157
|
+
Object.keys(r).length && R.current?.(r, e), n.forEach((n) => {
|
|
158
|
+
Object.is(t[n], e[n]) || U(n);
|
|
159
|
+
}), K({}), F.current.clear();
|
|
160
|
+
let i = j.current;
|
|
161
|
+
j.current = {}, Object.keys(i).forEach((e) => {
|
|
162
|
+
i[e] && U(e);
|
|
163
|
+
});
|
|
164
|
+
}, [
|
|
165
|
+
K,
|
|
166
|
+
o,
|
|
167
|
+
U
|
|
168
|
+
]);
|
|
169
|
+
p(r, () => ({
|
|
170
|
+
getValues: () => O.current,
|
|
171
|
+
setValues: Q,
|
|
172
|
+
reset: $,
|
|
173
|
+
validate: X,
|
|
174
|
+
submit: Z,
|
|
175
|
+
isSubmitting: () => M.current,
|
|
176
|
+
getErrors: () => A.current
|
|
177
|
+
}), [
|
|
178
|
+
$,
|
|
179
|
+
Q,
|
|
180
|
+
Z,
|
|
181
|
+
X
|
|
182
|
+
]);
|
|
183
|
+
let se = m(() => ({
|
|
184
|
+
defaultValidateTrigger: H,
|
|
185
|
+
registerField: q,
|
|
186
|
+
updateField: J,
|
|
187
|
+
validateField: Y,
|
|
188
|
+
subscribeField: W,
|
|
189
|
+
getFieldState: G
|
|
190
|
+
}), [
|
|
191
|
+
H,
|
|
192
|
+
G,
|
|
193
|
+
q,
|
|
194
|
+
W,
|
|
195
|
+
J,
|
|
196
|
+
Y
|
|
197
|
+
]), ce = m(() => ({
|
|
198
|
+
get values() {
|
|
199
|
+
return O.current;
|
|
200
|
+
},
|
|
201
|
+
get errors() {
|
|
202
|
+
return A.current;
|
|
203
|
+
},
|
|
204
|
+
get validating() {
|
|
205
|
+
return j.current;
|
|
206
|
+
},
|
|
207
|
+
defaultValidateTrigger: H,
|
|
208
|
+
registerField: q,
|
|
209
|
+
updateField: J,
|
|
210
|
+
validateField: Y
|
|
211
|
+
}), [
|
|
212
|
+
H,
|
|
213
|
+
q,
|
|
214
|
+
J,
|
|
215
|
+
Y
|
|
216
|
+
]), le = {
|
|
217
|
+
...ee,
|
|
218
|
+
...c === void 0 ? null : { "--vl-form-label-width": typeof c == "number" ? `${c}px` : c }
|
|
219
|
+
}, ue = [
|
|
220
|
+
"vl-form",
|
|
221
|
+
`vl-form--${s}`,
|
|
222
|
+
`vl-form--label-${l}`,
|
|
223
|
+
ae ? "is-submitting" : "",
|
|
224
|
+
f || ""
|
|
225
|
+
].filter(Boolean).join(" "), de = (e) => {
|
|
226
|
+
e.preventDefault(), Z();
|
|
227
|
+
}, fe = (e) => {
|
|
228
|
+
e.preventDefault(), $();
|
|
229
|
+
};
|
|
230
|
+
return /* @__PURE__ */ _(ne, {
|
|
231
|
+
value: se,
|
|
232
|
+
children: /* @__PURE__ */ _(w, {
|
|
233
|
+
value: D,
|
|
234
|
+
children: /* @__PURE__ */ _(T, {
|
|
235
|
+
value: ce,
|
|
236
|
+
children: /* @__PURE__ */ _("form", {
|
|
237
|
+
...re,
|
|
238
|
+
className: ue,
|
|
239
|
+
style: le,
|
|
240
|
+
"aria-busy": ae || void 0,
|
|
241
|
+
noValidate: C,
|
|
242
|
+
onSubmit: de,
|
|
243
|
+
onReset: fe,
|
|
244
|
+
children: g
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
j.displayName = "VlForm";
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region components/Form/FormItem.tsx
|
|
253
|
+
var M = [], ae = [], oe = (e, t) => e ? Array.isArray(e) ? e : [e] : t, N = (e, t) => {
|
|
254
|
+
if (e === "checked" && typeof t[1] == "boolean") return t[1];
|
|
255
|
+
let n = t[0];
|
|
256
|
+
if (n && typeof n == "object" && "target" in n) {
|
|
257
|
+
let t = n.target;
|
|
258
|
+
if (t) return e === "checked" ? t.checked : t.value;
|
|
259
|
+
}
|
|
260
|
+
return n;
|
|
261
|
+
}, P = ({ id: t, content: n }) => {
|
|
262
|
+
let r = h(null), [i, o] = te(!1), s = d(() => {
|
|
263
|
+
let e = r.current;
|
|
264
|
+
if (!e) return;
|
|
265
|
+
let t = e.scrollWidth > e.clientWidth;
|
|
266
|
+
o((e) => e === t ? e : t);
|
|
267
|
+
}, []);
|
|
268
|
+
return e(() => {
|
|
269
|
+
s();
|
|
270
|
+
let e = r.current, t = typeof ResizeObserver > "u" ? null : new ResizeObserver(s);
|
|
271
|
+
return e && t?.observe(e), window.addEventListener("resize", s, { passive: !0 }), () => {
|
|
272
|
+
t?.disconnect(), window.removeEventListener("resize", s);
|
|
273
|
+
};
|
|
274
|
+
}, [n, s]), /* @__PURE__ */ _(a, {
|
|
275
|
+
id: t,
|
|
276
|
+
className: "vl-form-item__help-tooltip",
|
|
277
|
+
content: n,
|
|
278
|
+
disabled: !i,
|
|
279
|
+
children: /* @__PURE__ */ _("div", {
|
|
280
|
+
ref: r,
|
|
281
|
+
className: "vl-form-item__help is-text",
|
|
282
|
+
tabIndex: i ? 0 : void 0,
|
|
283
|
+
children: n
|
|
284
|
+
})
|
|
285
|
+
});
|
|
286
|
+
}, F = c((t, i) => {
|
|
287
|
+
let { formControlled: a, formValue: s, name: c, label: u, reserveLabelWidth: d = !1, required: f = !1, rules: p = M, help: g, valuePropName: y = "value", trigger: b = "onChange", getValueFromEvent: x, validateTrigger: ne, className: C, children: w, ...re } = t, T = S(), D = T?.registerField, O = l(w) ? w : null, k = O?.props ?? {}, A = r("vl-form-control", k.id), ie = r("vl-form-label"), j = r("vl-form-help"), F = r("vl-form-error"), I = h(null), L = T?.defaultValidateTrigger ?? ae, R = m(() => oe(ne, L), [L, ne]), z = m(() => f && !p.some((e) => e.required) ? [{ required: !0 }, ...p] : p, [f, p]), B = f || z.some((e) => e.required), V = u !== void 0, H = V || d, U = g != null && typeof g != "boolean" && g !== "", W = E(c), G = W.errors, K = W.isValidating, q = a ? s : W.value, J = R.includes("change") || G.length > 0, [Y] = te(() => Symbol("form-field")), X = h({
|
|
288
|
+
label: void 0,
|
|
289
|
+
rules: M,
|
|
290
|
+
element: null
|
|
291
|
+
});
|
|
292
|
+
e(() => {
|
|
293
|
+
X.current.label = typeof u == "string" ? u : void 0, X.current.rules = z;
|
|
294
|
+
}, [z, u]), ee(() => {
|
|
295
|
+
if (!(!c || !D)) return D({
|
|
296
|
+
name: c,
|
|
297
|
+
token: Y,
|
|
298
|
+
metaRef: X
|
|
299
|
+
});
|
|
300
|
+
}, [
|
|
301
|
+
Y,
|
|
302
|
+
c,
|
|
303
|
+
D
|
|
304
|
+
]);
|
|
305
|
+
let Z = G.length > 0, Q = U && !Z, $ = {
|
|
306
|
+
id: A,
|
|
307
|
+
"aria-describedby": [
|
|
308
|
+
k["aria-describedby"],
|
|
309
|
+
Z ? F : void 0,
|
|
310
|
+
Q ? j : void 0
|
|
311
|
+
].filter(Boolean).join(" ") || void 0,
|
|
312
|
+
"aria-labelledby": [k["aria-labelledby"], V ? ie : void 0].filter(Boolean).join(" ") || void 0,
|
|
313
|
+
"aria-invalid": G.length > 0 || void 0,
|
|
314
|
+
"aria-busy": K || void 0,
|
|
315
|
+
ref: (e) => {
|
|
316
|
+
I.current = e, X.current.element = e, n(k.ref, e);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
if (c && T) {
|
|
320
|
+
$[y] = q;
|
|
321
|
+
let e = k[b];
|
|
322
|
+
if ($[b] = (...t) => {
|
|
323
|
+
typeof e == "function" && e(...t);
|
|
324
|
+
let n = x ? x(...t) : N(y, t), r = T.updateField(c, n);
|
|
325
|
+
(J || b === "onBlur" && R.includes("blur")) && T.validateField(c, r);
|
|
326
|
+
}, b !== "onBlur") {
|
|
327
|
+
let e = k.onBlur;
|
|
328
|
+
$.onBlur = (t) => {
|
|
329
|
+
typeof e == "function" && e(t), R.includes("blur") && T.validateField(c);
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
let se = O ? o(O, $) : w, ce = [
|
|
334
|
+
"vl-form-item",
|
|
335
|
+
c ? "has-name" : "",
|
|
336
|
+
H ? "has-label" : "",
|
|
337
|
+
U ? "has-help" : "",
|
|
338
|
+
G.length ? "is-error" : "",
|
|
339
|
+
K ? "is-validating" : "",
|
|
340
|
+
B ? "is-required" : "",
|
|
341
|
+
C || ""
|
|
342
|
+
].filter(Boolean).join(" "), le = K || G.length > 0;
|
|
343
|
+
return /* @__PURE__ */ v("div", {
|
|
344
|
+
...re,
|
|
345
|
+
ref: i,
|
|
346
|
+
className: ce,
|
|
347
|
+
children: [V ? /* @__PURE__ */ v("label", {
|
|
348
|
+
id: ie,
|
|
349
|
+
className: "vl-form-item__label",
|
|
350
|
+
htmlFor: A,
|
|
351
|
+
children: [B ? /* @__PURE__ */ _("span", {
|
|
352
|
+
className: "vl-form-item__required",
|
|
353
|
+
"aria-hidden": "true",
|
|
354
|
+
children: "*"
|
|
355
|
+
}) : null, u]
|
|
356
|
+
}) : d ? /* @__PURE__ */ _("div", {
|
|
357
|
+
className: "vl-form-item__label",
|
|
358
|
+
"aria-hidden": "true"
|
|
359
|
+
}) : null, /* @__PURE__ */ v("div", {
|
|
360
|
+
className: "vl-form-item__control",
|
|
361
|
+
children: [/* @__PURE__ */ v("div", {
|
|
362
|
+
className: "vl-form-item__field",
|
|
363
|
+
children: [/* @__PURE__ */ _("div", {
|
|
364
|
+
className: "vl-form-item__control-input",
|
|
365
|
+
children: se
|
|
366
|
+
}), c ? /* @__PURE__ */ v("div", {
|
|
367
|
+
className: `vl-form-item__validation${le ? "" : " is-empty"}`,
|
|
368
|
+
"aria-hidden": !le || void 0,
|
|
369
|
+
children: [K ? /* @__PURE__ */ v("div", {
|
|
370
|
+
className: "vl-form-item__status",
|
|
371
|
+
role: "status",
|
|
372
|
+
"aria-label": "校验中",
|
|
373
|
+
children: [/* @__PURE__ */ _("span", {
|
|
374
|
+
className: "vl-form-item__spinner",
|
|
375
|
+
"aria-hidden": "true"
|
|
376
|
+
}), /* @__PURE__ */ _("span", { children: "校验中" })]
|
|
377
|
+
}) : null, G.length ? /* @__PURE__ */ _("div", {
|
|
378
|
+
id: F,
|
|
379
|
+
className: "vl-form-item__error",
|
|
380
|
+
role: "alert",
|
|
381
|
+
children: G.map((e) => /* @__PURE__ */ _("div", { children: e }, e))
|
|
382
|
+
}) : null]
|
|
383
|
+
}) : null]
|
|
384
|
+
}), Q ? /* @__PURE__ */ _("div", {
|
|
385
|
+
className: "vl-form-item__feedback",
|
|
386
|
+
children: typeof g == "string" || typeof g == "number" ? /* @__PURE__ */ _(P, {
|
|
387
|
+
id: j,
|
|
388
|
+
content: g
|
|
389
|
+
}) : /* @__PURE__ */ _("div", {
|
|
390
|
+
id: j,
|
|
391
|
+
className: "vl-form-item__help",
|
|
392
|
+
children: g
|
|
393
|
+
})
|
|
394
|
+
}) : null]
|
|
395
|
+
})]
|
|
396
|
+
});
|
|
397
|
+
}), I = u(F, (e, t) => {
|
|
398
|
+
if (e.formControlled !== t.formControlled || !Object.is(e.formValue, t.formValue) || e.name !== t.name || e.label !== t.label || e.reserveLabelWidth !== t.reserveLabelWidth || 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;
|
|
399
|
+
if (e.rules !== t.rules) {
|
|
400
|
+
let n = e.rules ?? M, r = t.rules ?? M;
|
|
401
|
+
if (n.length !== r.length) return !1;
|
|
402
|
+
for (let e = 0; e < n.length; e++) if (n[e] !== r[e]) return !1;
|
|
403
|
+
}
|
|
404
|
+
if (e.children !== t.children) {
|
|
405
|
+
let n = e.children, r = t.children;
|
|
406
|
+
if (!l(n) || !l(r)) return Object.is(n, r);
|
|
407
|
+
if (n.type !== r.type || n.key !== r.key) return !1;
|
|
408
|
+
let i = n.props, a = r.props, o = Object.keys(i), s = Object.keys(a);
|
|
409
|
+
if (o.length !== s.length) return !1;
|
|
410
|
+
for (let e of o) if (!Object.is(i[e], a[e])) return !1;
|
|
411
|
+
}
|
|
412
|
+
let n = /* @__PURE__ */ new Set([
|
|
413
|
+
"formControlled",
|
|
414
|
+
"formValue",
|
|
415
|
+
"name",
|
|
416
|
+
"label",
|
|
417
|
+
"reserveLabelWidth",
|
|
418
|
+
"required",
|
|
419
|
+
"rules",
|
|
420
|
+
"help",
|
|
421
|
+
"valuePropName",
|
|
422
|
+
"trigger",
|
|
423
|
+
"getValueFromEvent",
|
|
424
|
+
"validateTrigger",
|
|
425
|
+
"className",
|
|
426
|
+
"style",
|
|
427
|
+
"children"
|
|
428
|
+
]), r = e, i = t;
|
|
429
|
+
for (let t of Object.keys(e)) if (!n.has(t) && !Object.is(r[t], i[t])) return !1;
|
|
430
|
+
for (let e of Object.keys(t)) if (!n.has(e) && !Object.is(r[e], i[e])) return !1;
|
|
431
|
+
return !0;
|
|
432
|
+
}), L = c((e, t) => {
|
|
433
|
+
let n = re();
|
|
434
|
+
return /* @__PURE__ */ _(I, {
|
|
435
|
+
...e,
|
|
436
|
+
ref: t,
|
|
437
|
+
formControlled: n !== null,
|
|
438
|
+
formValue: e.name ? n?.[e.name] : void 0
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
L.displayName = "VlFormItem";
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region components/Form/index.ts
|
|
444
|
+
var R = Object.assign(j, { Item: L }), z = L;
|
|
445
|
+
//#endregion
|
|
446
|
+
export { z as n, R as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as e } from "./state-BSDh-Ob2.js";
|
|
2
2
|
import { t } from "./number-BN2jHM6Z.js";
|
|
3
|
-
import { t as n } from "./Select-
|
|
3
|
+
import { t as n } from "./Select-GleCzXQB.js";
|
|
4
4
|
import { ChevronLeft as r, ChevronRight as i, ChevronsLeft as a, ChevronsRight as ee } from "lucide-react";
|
|
5
5
|
import { createElement as o, forwardRef as s, useEffect as c, useMemo as l, useState as u } from "react";
|
|
6
6
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./state-BuUx1onZ.cjs"),t=require("./number-B7qJF_ZY.cjs"),n=require("./Select-
|
|
1
|
+
const e=require("./state-BuUx1onZ.cjs"),t=require("./number-B7qJF_ZY.cjs"),n=require("./Select-Rx6AHue2.cjs");let r=require("lucide-react"),i=require("react"),a=require("react/jsx-runtime");var o=[10,20,50,100],s=(e,t)=>typeof e!=`number`||!Number.isFinite(e)?t:Math.max(1,Math.floor(e)),c=e=>typeof e!=`number`||!Number.isFinite(e)?0:Math.max(0,Math.floor(e)),l=(e,t)=>{let n=[...e??o].filter(e=>typeof e==`number`&&Number.isFinite(e)&&e>0).map(e=>Math.floor(e)).filter(e=>e>0).filter((e,t,n)=>n.indexOf(e)===t).sort((e,t)=>e-t);return n.length?n:[t]},u=(e,t)=>{if(e<=7)return Array.from({length:e},(e,t)=>t+1);let n=Math.max(2,t-1),r=Math.min(e-1,t+1),i=n>2,a=r<e-1;return i?a?[1,`ellipsis-start`,n,t,r,`ellipsis-end`,e]:[1,`ellipsis-start`,e-4,e-3,e-2,e-1,e]:[1,2,3,4,5,`ellipsis-end`,e]},d=(0,i.forwardRef)((o,d)=>{let{current:f,defaultCurrent:p=1,total:m=0,pageSize:h,defaultPageSize:g=10,pageSizeOptions:_,showTotal:v=!1,showSizeChanger:y=!1,showQuickJumper:b=!1,size:x=`md`,disabled:S=!1,className:C,id:w,"aria-label":T=`分页导航`,onChange:E,onPageSizeChange:D,...O}=o,k=e.t(o,`current`),A=e.t(o,`pageSize`),j=s(g,10),[M,N]=(0,i.useState)(()=>s(p,1)),[P,F]=(0,i.useState)(j),[I,L]=(0,i.useState)(``),R=c(m),z=s(A?h:P,j),B=Math.max(1,Math.ceil(R/z)),V=t.t(s(k?f:M,1),1,B),H=(0,i.useMemo)(()=>l(_,z),[_,z]),U=(0,i.useMemo)(()=>H.map(e=>({value:e,label:`${e} 条/页`})),[H]),W=(0,i.useMemo)(()=>u(B,V),[B,V]),G=R===0?[0,0]:[(V-1)*z+1,Math.min(V*z,R)];(0,i.useEffect)(()=>{L(String(V))},[V]),(0,i.useEffect)(()=>{!k&&M!==V&&N(V)},[V,k,M]);let K=[`vl-pagination`,`size-${x}`,S?`is-disabled`:``,C||``].filter(Boolean).join(` `),q=(e,t=z)=>{k||N(e),E?.(e,t)},J=e=>{if(S)return;let n=t.t(e,1,B);n!==V&&q(n)},Y=e=>{if(S||e===null||Array.isArray(e))return;let n=s(Number(e),z);if(n===z)return;let r=Math.max(1,Math.ceil(R/n)),i=t.t(V,1,r);A||F(n),k||N(i),D?.(n,i),E?.(i,n)},X=()=>{if(S)return;let e=I.trim();if(!/^\d+$/.test(e))return;let t=Number(e);!Number.isSafeInteger(t)||t<1||t>B||J(t)},Z=e=>{e.key===`Enter`&&(e.preventDefault(),X())},Q=(e,t,n,r)=>{let o=e===`first`||e===`previous`?V<=1:V>=B;return(0,a.jsx)(`button`,{type:`button`,className:`vl-pagination__button vl-pagination__nav-button`,"aria-label":t,disabled:S||o,onClick:()=>J(n),children:(0,i.createElement)(r,{"aria-hidden":!0,focusable:!1})})};return(0,a.jsxs)(`nav`,{ref:d,id:w,className:K,"aria-label":T,"aria-disabled":S||void 0,...O,children:[v?(0,a.jsx)(`span`,{className:`vl-pagination__total`,children:typeof v==`function`?v(R,G):`第 ${G[0]}-${G[1]} 条,共 ${R} 条`}):null,(0,a.jsxs)(`div`,{className:`vl-pagination__controls`,children:[(0,a.jsxs)(`div`,{className:`vl-pagination__pages`,children:[Q(`first`,`第一页`,1,r.ChevronsLeft),Q(`previous`,`上一页`,V-1,r.ChevronLeft),W.map(e=>typeof e==`number`?(0,a.jsx)(`button`,{type:`button`,className:`vl-pagination__button ${e===V?`is-active`:``}`,"aria-label":`第 ${e} 页`,"aria-current":e===V?`page`:void 0,disabled:S,onClick:()=>J(e),children:e},e):(0,a.jsx)(`span`,{className:`vl-pagination__ellipsis`,"aria-hidden":`true`,children:`…`},e)),Q(`next`,`下一页`,V+1,r.ChevronRight),Q(`last`,`最后一页`,B,r.ChevronsRight)]}),y?(0,a.jsx)(`div`,{className:`vl-pagination__size-changer`,children:(0,a.jsx)(n.t,{value:z,options:U,size:x,disabled:S,"aria-label":`每页条数`,onChange:Y})}):null,b?(0,a.jsxs)(`label`,{className:`vl-pagination__quick-jumper`,children:[(0,a.jsx)(`span`,{children:`跳至`}),(0,a.jsx)(`input`,{value:I,type:`text`,inputMode:`numeric`,"aria-label":`跳转到页码`,disabled:S,onChange:e=>L(e.target.value),onKeyDown:Z,onBlur:X}),(0,a.jsx)(`span`,{children:`页`})]}):null]})]})});d.displayName=`VlPagination`;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}});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createContext as e, forwardRef as t, useMemo as n } from "react";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
//#region components/Row/Row.tsx
|
|
4
|
+
var i = e({ gutter: 0 }), a = t((e, t) => {
|
|
5
|
+
let { tag: a = "div", gutter: o = 0, justify: s = "start", align: c = "top", className: l, style: u, children: d, ...f } = e, p = Number.isFinite(o) ? Math.max(0, o) : 0, m = n(() => ({ gutter: p }), [p]), h = [
|
|
6
|
+
"vl-row",
|
|
7
|
+
`is-justify-${s}`,
|
|
8
|
+
`is-align-${c}`,
|
|
9
|
+
l || ""
|
|
10
|
+
].filter(Boolean).join(" "), g = { ...u };
|
|
11
|
+
return p && (g.marginLeft = `-${p / 2}px`, g.marginRight = `-${p / 2}px`), /* @__PURE__ */ r(i.Provider, {
|
|
12
|
+
value: m,
|
|
13
|
+
children: /* @__PURE__ */ r(a, {
|
|
14
|
+
ref: t,
|
|
15
|
+
className: h,
|
|
16
|
+
style: g,
|
|
17
|
+
...f,
|
|
18
|
+
children: d
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
a.displayName = "VlRow";
|
|
23
|
+
//#endregion
|
|
24
|
+
export { i as n, a as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("react"),t=require("react/jsx-runtime");var n=(0,e.createContext)({gutter:0}),r=(0,e.forwardRef)((r,i)=>{let{tag:a=`div`,gutter:o=0,justify:s=`start`,align:c=`top`,className:l,style:u,children:d,...f}=r,p=Number.isFinite(o)?Math.max(0,o):0,m=(0,e.useMemo)(()=>({gutter:p}),[p]),h=[`vl-row`,`is-justify-${s}`,`is-align-${c}`,l||``].filter(Boolean).join(` `),g={...u};return p&&(g.marginLeft=`-${p/2}px`,g.marginRight=`-${p/2}px`),(0,t.jsx)(n.Provider,{value:m,children:(0,t.jsx)(a,{ref:i,className:h,style:g,...f,children:d})})});r.displayName=`VlRow`,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|