@vavt/react-ui 1.0.4 → 1.1.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/{DatePicker-CoHW85qm.cjs → DatePicker-D3tdU7GY.cjs} +1 -1
- package/dist/{DatePicker-B-F5q_s_.js → DatePicker-D75NqBYX.js} +1 -1
- package/dist/{DateTimePicker-CAkdoY--.cjs → DateTimePicker-CCe5NUkC.cjs} +1 -1
- package/dist/{DateTimePicker-BSBZZ7xV.js → DateTimePicker-CG-yv54X.js} +1 -1
- package/dist/{Drawer-D45miZ27.cjs → Drawer-CeBlbSjY.cjs} +1 -1
- package/dist/{Drawer-C0toQ-fQ.js → Drawer-CgaSQfT_.js} +1 -1
- package/dist/Form-BfXRwX6y.js +353 -0
- package/dist/Form-QpWOfQpR.cjs +1 -0
- package/dist/{MessageBox-B4Qo1vs2.js → MessageBox-DlAv_jQm.js} +1 -1
- package/dist/{MessageBox-CTJfdU29.cjs → MessageBox-nHLRzRJS.cjs} +1 -1
- package/dist/Modal-CAZ8vap0.cjs +1 -0
- package/dist/Modal-DnLKpKvW.js +238 -0
- package/dist/{Table-B9NTkptC.js → Table-BFqTvxt1.js} +10 -10
- package/dist/{Table-Bqjey5fw.cjs → Table-D4csqW47.cjs} +1 -1
- package/dist/Upload-CIOunhpr.cjs +1 -0
- package/dist/{Upload-DZC_bt6G.js → Upload-CVIzg2Px.js} +65 -64
- package/dist/base.css +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/Form.cjs +1 -1
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/Table.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/Alert.css +1 -1
- package/dist/css/Announcement.css +1 -1
- package/dist/css/Button.css +1 -1
- package/dist/css/Card.css +1 -1
- package/dist/css/Checkbox.css +1 -1
- package/dist/css/Cron.css +1 -1
- package/dist/css/DatePicker.css +1 -1
- package/dist/css/DateTimePicker.css +1 -1
- package/dist/css/Drawer.css +1 -1
- package/dist/css/Dropdown.css +1 -1
- package/dist/css/Empty.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/NumberInput.css +1 -1
- package/dist/css/Progress.css +1 -1
- package/dist/css/Radio.css +1 -1
- package/dist/css/Select.css +1 -1
- package/dist/css/Sidebar.css +1 -1
- package/dist/css/Switch.css +1 -1
- package/dist/css/Tag.css +1 -1
- package/dist/css/Textarea.css +1 -1
- package/dist/css/TimePicker.css +1 -1
- package/dist/css/Tooltip.css +1 -1
- package/dist/css/Upload.css +1 -1
- package/dist/date-picker-BH--Nh7g.js +612 -0
- package/dist/date-picker-pwA2wCag.cjs +1 -0
- package/dist/{dialog-shell-DehX3PNh.js → dialog-shell-CdYlPT9f.js} +12 -12
- package/dist/dialog-shell-CzeGytVj.cjs +1 -0
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/Upload.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +22 -22
- package/dist/es/register.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/registry-BO2ao8Jc.cjs +1 -0
- package/dist/{registry-q6UdMOyj.js → registry-macDoSyW.js} +34 -34
- package/dist/style/Form.cjs +1 -0
- package/dist/style/Form.mjs +1 -0
- package/dist/style/Modal.cjs +1 -0
- package/dist/style/Modal.mjs +1 -0
- package/dist/types/Form/type.d.cts +3 -1
- package/dist/types/Form/type.d.ts +3 -1
- package/dist/types/Modal/type.d.cts +3 -3
- package/dist/types/Modal/type.d.ts +3 -3
- package/dist/types/Upload/type.d.cts +4 -0
- package/dist/types/Upload/type.d.ts +4 -0
- package/package.json +1 -1
- package/dist/Form-7un_DeDk.cjs +0 -1
- package/dist/Form-CwgaAZWr.js +0 -323
- package/dist/Modal-i_Do8GsG.cjs +0 -1
- package/dist/Modal-otJ_9ldu.js +0 -210
- package/dist/Upload-bxJz2avf.cjs +0 -1
- package/dist/date-picker-BsiNrLZC.js +0 -592
- package/dist/date-picker-DNN0BiRA.cjs +0 -1
- package/dist/dialog-shell-DT1EoKQG.cjs +0 -1
- package/dist/registry-BGNWNSiC.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./date-picker-
|
|
1
|
+
const e=require("./date-picker-pwA2wCag.cjs");let t=require("react"),n=require("react/jsx-runtime");var r=(0,t.forwardRef)((t,r)=>(0,n.jsx)(e.t,{...t,ref:r,componentName:`date-picker`}));r.displayName=`VlDatePicker`;var i=r,a=r;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./date-picker-
|
|
1
|
+
const e=require("./date-picker-pwA2wCag.cjs");let t=require("react"),n=require("react/jsx-runtime");var r=(0,t.forwardRef)((t,r)=>(0,n.jsx)(e.t,{...t,ref:r,componentName:`date-time-picker`,withTime:!0}));r.displayName=`VlDateTimePicker`;var i=r,a=r;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./state-ZBA75xZ_.cjs"),t=require("./client-BkoqeUs3.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./content-DCGQZQp8.cjs"),i=require("./number-B7qJF_ZY.cjs"),ee=require("./id-CF0zOP1G.cjs"),a=require("./layer-BgiUZy_t.cjs"),o=require("./dialog-shell-
|
|
1
|
+
const e=require("./state-ZBA75xZ_.cjs"),t=require("./client-BkoqeUs3.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./content-DCGQZQp8.cjs"),i=require("./number-B7qJF_ZY.cjs"),ee=require("./id-CF0zOP1G.cjs"),a=require("./layer-BgiUZy_t.cjs"),o=require("./dialog-shell-CzeGytVj.cjs");let s=require("lucide-react"),c=require("react"),l=require("react/jsx-runtime");var u=(0,c.forwardRef)((u,d)=>{let{open:f,defaultOpen:p=!1,title:m,header:h,footer:g,placement:_=`right`,width:v=360,height:y=320,mask:b=!0,closeOnClickOverlay:x=!0,closeOnPressEscape:S=!0,showClose:C=!0,lockScroll:w=!0,destroyOnClose:T=!1,zIndex:E,className:D,style:O,children:te,onClick:ne,onChange:k,onOpen:A,onClose:j,"aria-label":M,"aria-labelledby":N,"aria-describedby":P,...F}=u,I=t.t(),L=typeof O?.zIndex==`number`?O.zIndex:void 0,R=a.r({defaultZIndex:a.n.modal,zIndex:E??L,withMask:!0}),z=(0,c.useRef)(null),B=(0,c.useMemo)(()=>n.n(z,d),[d]),V=(0,c.useRef)(!1),H=e.t(u,`open`),[U,W]=e.n({value:!!f,defaultValue:p,controlled:H,onChange:k}),G=(0,c.useCallback)(()=>W(!1),[W]),{isTopLayer:K}=o.r({active:I&&U,containerRef:z,closeOnPressEscape:S,lockScroll:w,onRequestClose:G}),q=ee.t(`vl-drawer-title`);(0,c.useEffect)(()=>{let e=V.current;U&&!e?A?.():!U&&e&&j?.(),V.current=U},[U,A,j]);let J=()=>{x&&K()&&G()},Y=e=>{e.stopPropagation(),ne?.(e)},X=[`vl-drawer`,`is-${_}`,D||``].filter(Boolean).join(` `),Z={...O};R.zIndex!==void 0&&(Z.zIndex=R.zIndex),_===`left`||_===`right`?(Z.width=i.n(v)??`360px`,Z.height=`100vh`):(Z.height=i.n(y)??`320px`,Z.width=`100vw`);let Q=h??(m?(0,l.jsx)(`div`,{id:q,className:`vl-drawer__title`,children:m}):null),$=N??(!h&&m?q:void 0),re=M??($?void 0:typeof m==`string`?m:`抽屉`);return(0,l.jsx)(a.t,{layer:R.layer,children:(0,l.jsxs)(o.t,{clientReady:I,open:U,mask:b,destroyOnClose:T,maskUnmountOnExit:T,maskTransitionName:`vl-drawer-mask`,transitionName:`vl-drawer-${_}`,maskClassName:`vl-drawer__mask`,panelClassName:X,panelStyle:Z,maskStyle:R.maskZIndex===void 0?void 0:{zIndex:R.maskZIndex},panelRef:B,role:`dialog`,ariaLabel:re,ariaLabelledBy:$,ariaDescribedBy:P,onMaskClick:J,onPanelClick:Y,panelProps:F,children:[r.t(Q)||C?(0,l.jsx)(`div`,{className:`vl-drawer__header`,children:(0,l.jsxs)(`div`,{className:`vl-drawer__headerInner`,children:[(0,l.jsx)(`div`,{className:`vl-drawer__headerMain`,children:Q}),C?(0,l.jsx)(`button`,{type:`button`,className:`vl-drawer__close`,"aria-label":`关闭抽屉`,onClick:G,children:(0,l.jsx)(s.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,l.jsx)(`div`,{className:`vl-drawer__body`,children:te}),r.t(g)?(0,l.jsx)(`div`,{className:`vl-drawer__footer`,children:g}):null]})})});u.displayName=`VlDrawer`;var d=u,f=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
|
|
@@ -5,7 +5,7 @@ import { t as i } from "./content-Dllrr-7G.js";
|
|
|
5
5
|
import { n as a } from "./number-BN2jHM6Z.js";
|
|
6
6
|
import { t as o } from "./id-CHixuHb7.js";
|
|
7
7
|
import { n as s, r as c, t as l } from "./layer-DDm97-sb.js";
|
|
8
|
-
import { r as u, t as ee } from "./dialog-shell-
|
|
8
|
+
import { r as u, t as ee } from "./dialog-shell-CdYlPT9f.js";
|
|
9
9
|
import { X as te } from "lucide-react";
|
|
10
10
|
import { forwardRef as d, useCallback as f, useEffect as p, useMemo as ne, useRef as m } from "react";
|
|
11
11
|
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
+
import { t } from "./state-oH-YwB7_.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-Buk5F9f_.js";
|
|
7
|
+
import { cloneElement as o, createContext as s, forwardRef as c, useCallback as l, useContext as u, useEffect as d, useImperativeHandle as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
8
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
9
|
+
//#region components/Form/context.ts
|
|
10
|
+
var v = s(null), y = v.Provider, ee = () => u(v), b = ["blur", "submit"], x = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, te = (e) => e ? Array.isArray(e) ? e : [e] : b, S = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) && e.length === 0, C = (e, t, n, r) => {
|
|
11
|
+
let i = t ?? e;
|
|
12
|
+
if (n.required && S(r)) return n.message ?? `请输入${i}`;
|
|
13
|
+
if (S(r)) return;
|
|
14
|
+
if (n.type && !(n.type === "array" ? Array.isArray(r) : n.type === "email" ? typeof r == "string" && x.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}格式不正确`;
|
|
15
|
+
let a = typeof r == "number" ? r : typeof r == "string" || Array.isArray(r) ? r.length : null;
|
|
16
|
+
if (n.len !== void 0 && a !== null && a !== n.len) return n.message ?? `${i}长度必须为 ${n.len}`;
|
|
17
|
+
if (n.min !== void 0 && a !== null && a < n.min) return n.message ?? `${i}不能小于 ${n.min}`;
|
|
18
|
+
if (n.max !== void 0 && a !== null && a > n.max) return n.message ?? `${i}不能大于 ${n.max}`;
|
|
19
|
+
}, w = c((n, r) => {
|
|
20
|
+
let { values: a, defaultValues: o = {}, layout: s = "vertical", labelWidth: c, feedbackWidth: u, labelAlign: d = s === "horizontal" ? "right" : "left", validateTrigger: _, className: v, style: ee, children: b, onValuesChange: x, onFinish: S, onFinishError: w, onFinishFailed: T, noValidate: E = !0, ...D } = n, O = t(n, "values"), [k, A] = h(o), j = p(() => O ? a ?? {} : k, [
|
|
21
|
+
O,
|
|
22
|
+
k,
|
|
23
|
+
a
|
|
24
|
+
]), M = m(j);
|
|
25
|
+
e(() => {
|
|
26
|
+
M.current = j;
|
|
27
|
+
}, [j]);
|
|
28
|
+
let [N, P] = h({}), F = m(N), [I, L] = h({}), [R, z] = h(!1), B = m(!1), V = m(null), H = m(/* @__PURE__ */ new Map()), U = m(/* @__PURE__ */ new Map()), W = p(() => te(_), [_]), G = l((e) => {
|
|
29
|
+
F.current = e, P(e);
|
|
30
|
+
}, []), K = l((e) => (H.current.set(e.name, e), () => {
|
|
31
|
+
if (H.current.get(e.name)?.token === e.token) {
|
|
32
|
+
if (H.current.delete(e.name), U.current.delete(e.name), Object.prototype.hasOwnProperty.call(F.current, e.name)) {
|
|
33
|
+
let t = { ...F.current };
|
|
34
|
+
delete t[e.name], G(t);
|
|
35
|
+
}
|
|
36
|
+
L((t) => {
|
|
37
|
+
if (!Object.prototype.hasOwnProperty.call(t, e.name)) return t;
|
|
38
|
+
let n = { ...t };
|
|
39
|
+
return delete n[e.name], n;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}), [G]), q = l((e, t) => {
|
|
43
|
+
let n = {
|
|
44
|
+
...M.current,
|
|
45
|
+
[e]: t
|
|
46
|
+
};
|
|
47
|
+
return M.current = n, O || A(n), x?.({ [e]: t }, n), n;
|
|
48
|
+
}, [O, x]), J = l(async (e, t) => {
|
|
49
|
+
let n = H.current.get(e);
|
|
50
|
+
if (!n) return [];
|
|
51
|
+
let r = t ?? M.current, i = r[e], a = Symbol(e);
|
|
52
|
+
U.current.set(e, a), L((t) => ({
|
|
53
|
+
...t,
|
|
54
|
+
[e]: !0
|
|
55
|
+
}));
|
|
56
|
+
let o = [], { rules: s, label: c } = n.metaRef.current;
|
|
57
|
+
for (let t of s) {
|
|
58
|
+
let n = C(e, c, t, i);
|
|
59
|
+
if (n && o.push(n), t.validator) try {
|
|
60
|
+
let e = await t.validator(i, r);
|
|
61
|
+
e && o.push(t.message ?? e);
|
|
62
|
+
} catch (e) {
|
|
63
|
+
let n = e instanceof Error ? e.message : "校验失败";
|
|
64
|
+
o.push(t.message ?? n);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (H.current.get(e)?.token !== n.token || U.current.get(e) !== a) return o;
|
|
68
|
+
let l = { ...F.current };
|
|
69
|
+
return o.length ? l[e] = o : delete l[e], G(l), L((t) => ({
|
|
70
|
+
...t,
|
|
71
|
+
[e]: !1
|
|
72
|
+
})), o;
|
|
73
|
+
}, [G]), Y = l(async () => {
|
|
74
|
+
let e = M.current, t = [...H.current.values()], n = await Promise.all(t.map(async (t) => {
|
|
75
|
+
let n = J(t.name, e);
|
|
76
|
+
return [
|
|
77
|
+
t,
|
|
78
|
+
U.current.get(t.name),
|
|
79
|
+
await n
|
|
80
|
+
];
|
|
81
|
+
})), r = { ...F.current };
|
|
82
|
+
return n.forEach(([e, t, n]) => {
|
|
83
|
+
H.current.get(e.name)?.token === e.token && U.current.get(e.name) === t && (n.length ? r[e.name] = n : delete r[e.name]);
|
|
84
|
+
}), G(r), {
|
|
85
|
+
valid: Object.keys(r).length === 0,
|
|
86
|
+
values: e,
|
|
87
|
+
errors: r
|
|
88
|
+
};
|
|
89
|
+
}, [G, J]), X = l(() => {
|
|
90
|
+
if (V.current) return V.current;
|
|
91
|
+
let e = (async () => {
|
|
92
|
+
B.current = !0, z(!0);
|
|
93
|
+
try {
|
|
94
|
+
let e = await Y();
|
|
95
|
+
if (e.valid) try {
|
|
96
|
+
await S?.(e.values);
|
|
97
|
+
} catch (t) {
|
|
98
|
+
w?.(t, e.values);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
T?.(e.errors, e.values);
|
|
102
|
+
let t = [...H.current.keys()].find((t) => e.errors[t]);
|
|
103
|
+
t && i(H.current.get(t)?.metaRef.current.element ?? null);
|
|
104
|
+
}
|
|
105
|
+
return e;
|
|
106
|
+
} finally {
|
|
107
|
+
B.current = !1, z(!1);
|
|
108
|
+
}
|
|
109
|
+
})();
|
|
110
|
+
return V.current = e, e.then(() => {
|
|
111
|
+
V.current === e && (V.current = null);
|
|
112
|
+
}, () => {
|
|
113
|
+
V.current === e && (V.current = null);
|
|
114
|
+
}), e;
|
|
115
|
+
}, [
|
|
116
|
+
S,
|
|
117
|
+
w,
|
|
118
|
+
T,
|
|
119
|
+
Y
|
|
120
|
+
]), Z = l((e) => {
|
|
121
|
+
let t = {
|
|
122
|
+
...M.current,
|
|
123
|
+
...e
|
|
124
|
+
};
|
|
125
|
+
M.current = t, O || A(t), x?.(e, t);
|
|
126
|
+
}, [O, x]), Q = l(() => {
|
|
127
|
+
let e = { ...o }, t = M.current;
|
|
128
|
+
M.current = e, O || A(e);
|
|
129
|
+
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]]));
|
|
130
|
+
Object.keys(r).length && x?.(r, e), G({}), U.current.clear(), L({});
|
|
131
|
+
}, [
|
|
132
|
+
G,
|
|
133
|
+
O,
|
|
134
|
+
o,
|
|
135
|
+
x
|
|
136
|
+
]);
|
|
137
|
+
f(r, () => ({
|
|
138
|
+
getValues: () => M.current,
|
|
139
|
+
setValues: Z,
|
|
140
|
+
reset: Q,
|
|
141
|
+
validate: Y,
|
|
142
|
+
submit: X,
|
|
143
|
+
isSubmitting: () => B.current,
|
|
144
|
+
getErrors: () => F.current
|
|
145
|
+
}), [
|
|
146
|
+
Q,
|
|
147
|
+
Z,
|
|
148
|
+
X,
|
|
149
|
+
Y
|
|
150
|
+
]);
|
|
151
|
+
let $ = p(() => ({
|
|
152
|
+
values: j,
|
|
153
|
+
errors: N,
|
|
154
|
+
validating: I,
|
|
155
|
+
defaultValidateTrigger: W,
|
|
156
|
+
registerField: K,
|
|
157
|
+
updateField: q,
|
|
158
|
+
validateField: J
|
|
159
|
+
}), [
|
|
160
|
+
W,
|
|
161
|
+
N,
|
|
162
|
+
K,
|
|
163
|
+
q,
|
|
164
|
+
J,
|
|
165
|
+
I,
|
|
166
|
+
j
|
|
167
|
+
]), ne = {
|
|
168
|
+
...ee,
|
|
169
|
+
...c === void 0 ? null : { "--vl-form-label-width": typeof c == "number" ? `${c}px` : c },
|
|
170
|
+
...u === void 0 ? null : { "--vl-form-feedback-width": typeof u == "number" ? `${u}px` : u }
|
|
171
|
+
}, re = [
|
|
172
|
+
"vl-form",
|
|
173
|
+
`vl-form--${s}`,
|
|
174
|
+
`vl-form--label-${d}`,
|
|
175
|
+
R ? "is-submitting" : "",
|
|
176
|
+
v || ""
|
|
177
|
+
].filter(Boolean).join(" "), ie = (e) => {
|
|
178
|
+
e.preventDefault(), X();
|
|
179
|
+
}, ae = (e) => {
|
|
180
|
+
e.preventDefault(), Q();
|
|
181
|
+
};
|
|
182
|
+
return /* @__PURE__ */ g(y, {
|
|
183
|
+
value: $,
|
|
184
|
+
children: /* @__PURE__ */ g("form", {
|
|
185
|
+
...D,
|
|
186
|
+
className: re,
|
|
187
|
+
style: ne,
|
|
188
|
+
"aria-busy": R || void 0,
|
|
189
|
+
noValidate: E,
|
|
190
|
+
onSubmit: ie,
|
|
191
|
+
onReset: ae,
|
|
192
|
+
children: b
|
|
193
|
+
})
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
w.displayName = "VlForm";
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region components/Form/FormItem.tsx
|
|
199
|
+
var T = [], E = [], D = [], O = (e, t) => e ? Array.isArray(e) ? e : [e] : t, k = (e, t) => {
|
|
200
|
+
if (e === "checked" && typeof t[1] == "boolean") return t[1];
|
|
201
|
+
let n = t[0];
|
|
202
|
+
if (n && typeof n == "object" && "target" in n) {
|
|
203
|
+
let t = n.target;
|
|
204
|
+
if (t) return e === "checked" ? t.checked : t.value;
|
|
205
|
+
}
|
|
206
|
+
return n;
|
|
207
|
+
}, A = ({ id: t, content: n }) => {
|
|
208
|
+
let r = m(null), [i, o] = h(!1), s = l(() => {
|
|
209
|
+
let e = r.current;
|
|
210
|
+
e && o(e.scrollWidth > e.clientWidth);
|
|
211
|
+
}, []);
|
|
212
|
+
return e(() => {
|
|
213
|
+
s();
|
|
214
|
+
let e = r.current, t = typeof ResizeObserver > "u" ? null : new ResizeObserver(s);
|
|
215
|
+
return e && t?.observe(e), window.addEventListener("resize", s, { passive: !0 }), () => {
|
|
216
|
+
t?.disconnect(), window.removeEventListener("resize", s);
|
|
217
|
+
};
|
|
218
|
+
}, [n, s]), /* @__PURE__ */ g(a, {
|
|
219
|
+
id: t,
|
|
220
|
+
className: "vl-form-item__help-tooltip",
|
|
221
|
+
content: n,
|
|
222
|
+
disabled: !i,
|
|
223
|
+
children: /* @__PURE__ */ g("div", {
|
|
224
|
+
ref: r,
|
|
225
|
+
className: "vl-form-item__help is-text",
|
|
226
|
+
tabIndex: i ? 0 : void 0,
|
|
227
|
+
children: n
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
}, j = c((t, i) => {
|
|
231
|
+
let { name: a, label: s, required: c = !1, rules: l = T, help: u, valuePropName: f = "value", trigger: v = "onChange", getValueFromEvent: y, validateTrigger: b, className: x, children: te, ...S } = t, C = ee(), w = C?.registerField, j = te, M = j.props, N = r("vl-form-control", M.id), P = r("vl-form-label"), F = r("vl-form-help"), I = r("vl-form-error"), L = m(null), R = m(null), z = m(null), B = C?.defaultValidateTrigger ?? E, V = p(() => O(b, B), [B, b]), H = p(() => c && !l.some((e) => e.required) ? [{ required: !0 }, ...l] : l, [c, l]), U = c || H.some((e) => e.required), W = u != null && typeof u != "boolean" && u !== "", G = a ? C?.errors[a] ?? D : D, K = a ? !!C?.validating[a] : !1, q = V.includes("change") || G.length > 0, [J] = h(() => Symbol("form-field")), Y = m({
|
|
232
|
+
label: void 0,
|
|
233
|
+
rules: T,
|
|
234
|
+
element: null
|
|
235
|
+
});
|
|
236
|
+
e(() => {
|
|
237
|
+
Y.current.label = typeof s == "string" ? s : void 0, Y.current.rules = H;
|
|
238
|
+
}, [H, s]), d(() => {
|
|
239
|
+
if (!(!a || !w)) return w({
|
|
240
|
+
name: a,
|
|
241
|
+
token: J,
|
|
242
|
+
metaRef: Y
|
|
243
|
+
});
|
|
244
|
+
}, [
|
|
245
|
+
J,
|
|
246
|
+
a,
|
|
247
|
+
w
|
|
248
|
+
]), d(() => {
|
|
249
|
+
let e = R.current, t = z.current;
|
|
250
|
+
if (z.current = G, e) {
|
|
251
|
+
if (!G.length) {
|
|
252
|
+
e.classList.remove("is-shaking");
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
t !== G && (e.classList.remove("is-shaking"), e.offsetWidth, e.classList.add("is-shaking"));
|
|
256
|
+
}
|
|
257
|
+
}, [G]);
|
|
258
|
+
let X = {
|
|
259
|
+
id: N,
|
|
260
|
+
"aria-describedby": [
|
|
261
|
+
M["aria-describedby"],
|
|
262
|
+
G.length ? I : void 0,
|
|
263
|
+
W ? F : void 0
|
|
264
|
+
].filter(Boolean).join(" ") || void 0,
|
|
265
|
+
"aria-labelledby": [M["aria-labelledby"], s === void 0 ? void 0 : P].filter(Boolean).join(" ") || void 0,
|
|
266
|
+
"aria-invalid": G.length > 0 || void 0,
|
|
267
|
+
"aria-busy": K || void 0,
|
|
268
|
+
ref: (e) => {
|
|
269
|
+
L.current = e, Y.current.element = e, n(M.ref, e);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
if (a && C) {
|
|
273
|
+
X[f] = C.values[a];
|
|
274
|
+
let e = M[v];
|
|
275
|
+
if (X[v] = (...t) => {
|
|
276
|
+
typeof e == "function" && e(...t);
|
|
277
|
+
let n = y ? y(...t) : k(f, t), r = C.updateField(a, n);
|
|
278
|
+
(q || v === "onBlur" && V.includes("blur")) && C.validateField(a, r);
|
|
279
|
+
}, v !== "onBlur") {
|
|
280
|
+
let e = M.onBlur;
|
|
281
|
+
X.onBlur = (t) => {
|
|
282
|
+
typeof e == "function" && e(t), V.includes("blur") && C.validateField(a);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
let Z = o(j, X), Q = [
|
|
287
|
+
"vl-form-item",
|
|
288
|
+
s === void 0 ? "" : "has-label",
|
|
289
|
+
W ? "has-help" : "",
|
|
290
|
+
G.length ? "is-error" : "",
|
|
291
|
+
K ? "is-validating" : "",
|
|
292
|
+
U ? "is-required" : "",
|
|
293
|
+
x || ""
|
|
294
|
+
].filter(Boolean).join(" "), $ = K || G.length > 0;
|
|
295
|
+
return /* @__PURE__ */ _("div", {
|
|
296
|
+
...S,
|
|
297
|
+
ref: i,
|
|
298
|
+
className: Q,
|
|
299
|
+
children: [s === void 0 ? null : /* @__PURE__ */ _("label", {
|
|
300
|
+
id: P,
|
|
301
|
+
className: "vl-form-item__label",
|
|
302
|
+
htmlFor: N,
|
|
303
|
+
children: [U ? /* @__PURE__ */ g("span", {
|
|
304
|
+
className: "vl-form-item__required",
|
|
305
|
+
"aria-hidden": "true",
|
|
306
|
+
children: "*"
|
|
307
|
+
}) : null, s]
|
|
308
|
+
}), /* @__PURE__ */ _("div", {
|
|
309
|
+
className: "vl-form-item__control",
|
|
310
|
+
children: [/* @__PURE__ */ _("div", {
|
|
311
|
+
className: "vl-form-item__field",
|
|
312
|
+
children: [/* @__PURE__ */ g("div", {
|
|
313
|
+
ref: R,
|
|
314
|
+
className: "vl-form-item__control-input",
|
|
315
|
+
children: Z
|
|
316
|
+
}), a ? /* @__PURE__ */ _("div", {
|
|
317
|
+
className: `vl-form-item__validation${$ ? "" : " is-empty"}`,
|
|
318
|
+
"aria-hidden": !$ || void 0,
|
|
319
|
+
children: [K ? /* @__PURE__ */ _("div", {
|
|
320
|
+
className: "vl-form-item__status",
|
|
321
|
+
role: "status",
|
|
322
|
+
"aria-label": "校验中",
|
|
323
|
+
children: [/* @__PURE__ */ g("span", {
|
|
324
|
+
className: "vl-form-item__spinner",
|
|
325
|
+
"aria-hidden": "true"
|
|
326
|
+
}), /* @__PURE__ */ g("span", { children: "校验中" })]
|
|
327
|
+
}) : null, G.length ? /* @__PURE__ */ g("div", {
|
|
328
|
+
id: I,
|
|
329
|
+
className: "vl-form-item__error",
|
|
330
|
+
role: "alert",
|
|
331
|
+
children: G.map((e) => /* @__PURE__ */ g("div", { children: e }, e))
|
|
332
|
+
}) : null]
|
|
333
|
+
}) : null]
|
|
334
|
+
}), W ? /* @__PURE__ */ g("div", {
|
|
335
|
+
className: "vl-form-item__feedback",
|
|
336
|
+
children: typeof u == "string" || typeof u == "number" ? /* @__PURE__ */ g(A, {
|
|
337
|
+
id: F,
|
|
338
|
+
content: u
|
|
339
|
+
}) : /* @__PURE__ */ g("div", {
|
|
340
|
+
id: F,
|
|
341
|
+
className: "vl-form-item__help",
|
|
342
|
+
children: u
|
|
343
|
+
})
|
|
344
|
+
}) : null]
|
|
345
|
+
})]
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
j.displayName = "VlFormItem";
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region components/Form/index.ts
|
|
351
|
+
var M = Object.assign(w, { Item: j }), N = j;
|
|
352
|
+
//#endregion
|
|
353
|
+
export { N as n, M as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./id-CF0zOP1G.cjs"),i=require("./focus-D-h8CbGr.cjs"),a=require("./Tooltip-CP8rpNYG.cjs");let o=require("react"),s=require("react/jsx-runtime");var c=(0,o.createContext)(null),l=c.Provider,u=()=>(0,o.useContext)(c),d=[`blur`,`submit`],f=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,p=e=>e?Array.isArray(e)?e:[e]:d,m=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)&&e.length===0,h=(e,t,n,r)=>{let i=t??e;if(n.required&&m(r))return n.message??`请输入${i}`;if(m(r))return;if(n.type&&!(n.type===`array`?Array.isArray(r):n.type===`email`?typeof r==`string`&&f.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}格式不正确`;let a=typeof r==`number`?r:typeof r==`string`||Array.isArray(r)?r.length:null;if(n.len!==void 0&&a!==null&&a!==n.len)return n.message??`${i}长度必须为 ${n.len}`;if(n.min!==void 0&&a!==null&&a<n.min)return n.message??`${i}不能小于 ${n.min}`;if(n.max!==void 0&&a!==null&&a>n.max)return n.message??`${i}不能大于 ${n.max}`},g=(0,o.forwardRef)((n,r)=>{let{values:a,defaultValues:c={},layout:u=`vertical`,labelWidth:d,feedbackWidth:f,labelAlign:m=u===`horizontal`?`right`:`left`,validateTrigger:g,className:_,style:v,children:y,onValuesChange:b,onFinish:x,onFinishError:S,onFinishFailed:C,noValidate:w=!0,...T}=n,E=t.t(n,`values`),[D,O]=(0,o.useState)(c),k=(0,o.useMemo)(()=>E?a??{}:D,[E,D,a]),A=(0,o.useRef)(k);e.t(()=>{A.current=k},[k]);let[j,M]=(0,o.useState)({}),N=(0,o.useRef)(j),[P,F]=(0,o.useState)({}),[I,L]=(0,o.useState)(!1),R=(0,o.useRef)(!1),z=(0,o.useRef)(null),B=(0,o.useRef)(new Map),V=(0,o.useRef)(new Map),H=(0,o.useMemo)(()=>p(g),[g]),U=(0,o.useCallback)(e=>{N.current=e,M(e)},[]),W=(0,o.useCallback)(e=>(B.current.set(e.name,e),()=>{if(B.current.get(e.name)?.token===e.token){if(B.current.delete(e.name),V.current.delete(e.name),Object.prototype.hasOwnProperty.call(N.current,e.name)){let t={...N.current};delete t[e.name],U(t)}F(t=>{if(!Object.prototype.hasOwnProperty.call(t,e.name))return t;let n={...t};return delete n[e.name],n})}}),[U]),G=(0,o.useCallback)((e,t)=>{let n={...A.current,[e]:t};return A.current=n,E||O(n),b?.({[e]:t},n),n},[E,b]),K=(0,o.useCallback)(async(e,t)=>{let n=B.current.get(e);if(!n)return[];let r=t??A.current,i=r[e],a=Symbol(e);V.current.set(e,a),F(t=>({...t,[e]:!0}));let o=[],{rules:s,label:c}=n.metaRef.current;for(let t of s){let n=h(e,c,t,i);if(n&&o.push(n),t.validator)try{let e=await t.validator(i,r);e&&o.push(t.message??e)}catch(e){let n=e instanceof Error?e.message:`校验失败`;o.push(t.message??n)}}if(B.current.get(e)?.token!==n.token||V.current.get(e)!==a)return o;let l={...N.current};return o.length?l[e]=o:delete l[e],U(l),F(t=>({...t,[e]:!1})),o},[U]),q=(0,o.useCallback)(async()=>{let e=A.current,t=[...B.current.values()],n=await Promise.all(t.map(async t=>{let n=K(t.name,e);return[t,V.current.get(t.name),await n]})),r={...N.current};return n.forEach(([e,t,n])=>{B.current.get(e.name)?.token===e.token&&V.current.get(e.name)===t&&(n.length?r[e.name]=n:delete r[e.name])}),U(r),{valid:Object.keys(r).length===0,values:e,errors:r}},[U,K]),J=(0,o.useCallback)(()=>{if(z.current)return z.current;let e=(async()=>{R.current=!0,L(!0);try{let e=await q();if(e.valid)try{await x?.(e.values)}catch(t){S?.(t,e.values)}else{C?.(e.errors,e.values);let t=[...B.current.keys()].find(t=>e.errors[t]);t&&i.n(B.current.get(t)?.metaRef.current.element??null)}return e}finally{R.current=!1,L(!1)}})();return z.current=e,e.then(()=>{z.current===e&&(z.current=null)},()=>{z.current===e&&(z.current=null)}),e},[x,S,C,q]),Y=(0,o.useCallback)(e=>{let t={...A.current,...e};A.current=t,E||O(t),b?.(e,t)},[E,b]),X=(0,o.useCallback)(()=>{let e={...c},t=A.current;A.current=e,E||O(e);let n=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]]));Object.keys(r).length&&b?.(r,e),U({}),V.current.clear(),F({})},[U,E,c,b]);(0,o.useImperativeHandle)(r,()=>({getValues:()=>A.current,setValues:Y,reset:X,validate:q,submit:J,isSubmitting:()=>R.current,getErrors:()=>N.current}),[X,Y,J,q]);let Z=(0,o.useMemo)(()=>({values:k,errors:j,validating:P,defaultValidateTrigger:H,registerField:W,updateField:G,validateField:K}),[H,j,W,G,K,P,k]),Q={...v,...d===void 0?null:{"--vl-form-label-width":typeof d==`number`?`${d}px`:d},...f===void 0?null:{"--vl-form-feedback-width":typeof f==`number`?`${f}px`:f}},$=[`vl-form`,`vl-form--${u}`,`vl-form--label-${m}`,I?`is-submitting`:``,_||``].filter(Boolean).join(` `),ee=e=>{e.preventDefault(),J()},te=e=>{e.preventDefault(),X()};return(0,s.jsx)(l,{value:Z,children:(0,s.jsx)(`form`,{...T,className:$,style:Q,"aria-busy":I||void 0,noValidate:w,onSubmit:ee,onReset:te,children:y})})});g.displayName=`VlForm`;var _=[],v=[],y=[],b=(e,t)=>e?Array.isArray(e)?e:[e]:t,x=(e,t)=>{if(e===`checked`&&typeof t[1]==`boolean`)return t[1];let n=t[0];if(n&&typeof n==`object`&&`target`in n){let t=n.target;if(t)return e===`checked`?t.checked:t.value}return n},S=({id:t,content:n})=>{let r=(0,o.useRef)(null),[i,c]=(0,o.useState)(!1),l=(0,o.useCallback)(()=>{let e=r.current;e&&c(e.scrollWidth>e.clientWidth)},[]);return e.t(()=>{l();let e=r.current,t=typeof ResizeObserver>`u`?null:new ResizeObserver(l);return e&&t?.observe(e),window.addEventListener(`resize`,l,{passive:!0}),()=>{t?.disconnect(),window.removeEventListener(`resize`,l)}},[n,l]),(0,s.jsx)(a.t,{id:t,className:`vl-form-item__help-tooltip`,content:n,disabled:!i,children:(0,s.jsx)(`div`,{ref:r,className:`vl-form-item__help is-text`,tabIndex:i?0:void 0,children:n})})},C=(0,o.forwardRef)((t,i)=>{let{name:a,label:c,required:l=!1,rules:d=_,help:f,valuePropName:p=`value`,trigger:m=`onChange`,getValueFromEvent:h,validateTrigger:g,className:C,children:w,...T}=t,E=u(),D=E?.registerField,O=w,k=O.props,A=r.t(`vl-form-control`,k.id),j=r.t(`vl-form-label`),M=r.t(`vl-form-help`),N=r.t(`vl-form-error`),P=(0,o.useRef)(null),F=(0,o.useRef)(null),I=(0,o.useRef)(null),L=E?.defaultValidateTrigger??v,R=(0,o.useMemo)(()=>b(g,L),[L,g]),z=(0,o.useMemo)(()=>l&&!d.some(e=>e.required)?[{required:!0},...d]:d,[l,d]),B=l||z.some(e=>e.required),V=f!=null&&typeof f!=`boolean`&&f!==``,H=a?E?.errors[a]??y:y,U=a?!!E?.validating[a]:!1,W=R.includes(`change`)||H.length>0,[G]=(0,o.useState)(()=>Symbol(`form-field`)),K=(0,o.useRef)({label:void 0,rules:_,element:null});e.t(()=>{K.current.label=typeof c==`string`?c:void 0,K.current.rules=z},[z,c]),(0,o.useEffect)(()=>{if(!(!a||!D))return D({name:a,token:G,metaRef:K})},[G,a,D]),(0,o.useEffect)(()=>{let e=F.current,t=I.current;if(I.current=H,e){if(!H.length){e.classList.remove(`is-shaking`);return}t!==H&&(e.classList.remove(`is-shaking`),e.offsetWidth,e.classList.add(`is-shaking`))}},[H]);let q={id:A,"aria-describedby":[k[`aria-describedby`],H.length?N:void 0,V?M:void 0].filter(Boolean).join(` `)||void 0,"aria-labelledby":[k[`aria-labelledby`],c===void 0?void 0:j].filter(Boolean).join(` `)||void 0,"aria-invalid":H.length>0||void 0,"aria-busy":U||void 0,ref:e=>{P.current=e,K.current.element=e,n.t(k.ref,e)}};if(a&&E){q[p]=E.values[a];let e=k[m];if(q[m]=(...t)=>{typeof e==`function`&&e(...t);let n=h?h(...t):x(p,t),r=E.updateField(a,n);(W||m===`onBlur`&&R.includes(`blur`))&&E.validateField(a,r)},m!==`onBlur`){let e=k.onBlur;q.onBlur=t=>{typeof e==`function`&&e(t),R.includes(`blur`)&&E.validateField(a)}}}let J=(0,o.cloneElement)(O,q),Y=[`vl-form-item`,c===void 0?``:`has-label`,V?`has-help`:``,H.length?`is-error`:``,U?`is-validating`:``,B?`is-required`:``,C||``].filter(Boolean).join(` `),X=U||H.length>0;return(0,s.jsxs)(`div`,{...T,ref:i,className:Y,children:[c===void 0?null:(0,s.jsxs)(`label`,{id:j,className:`vl-form-item__label`,htmlFor:A,children:[B?(0,s.jsx)(`span`,{className:`vl-form-item__required`,"aria-hidden":`true`,children:`*`}):null,c]}),(0,s.jsxs)(`div`,{className:`vl-form-item__control`,children:[(0,s.jsxs)(`div`,{className:`vl-form-item__field`,children:[(0,s.jsx)(`div`,{ref:F,className:`vl-form-item__control-input`,children:J}),a?(0,s.jsxs)(`div`,{className:`vl-form-item__validation${X?``:` is-empty`}`,"aria-hidden":!X||void 0,children:[U?(0,s.jsxs)(`div`,{className:`vl-form-item__status`,role:`status`,"aria-label":`校验中`,children:[(0,s.jsx)(`span`,{className:`vl-form-item__spinner`,"aria-hidden":`true`}),(0,s.jsx)(`span`,{children:`校验中`})]}):null,H.length?(0,s.jsx)(`div`,{id:N,className:`vl-form-item__error`,role:`alert`,children:H.map(e=>(0,s.jsx)(`div`,{children:e},e))}):null]}):null]}),V?(0,s.jsx)(`div`,{className:`vl-form-item__feedback`,children:typeof f==`string`||typeof f==`number`?(0,s.jsx)(S,{id:M,content:f}):(0,s.jsx)(`div`,{id:M,className:`vl-form-item__help`,children:f})}):null]})]})});C.displayName=`VlFormItem`;var w=Object.assign(g,{Item:C}),T=C;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e, t } from "./state-oH-YwB7_.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-DnLKpKvW.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("./state-ZBA75xZ_.cjs"),t=require("./Button-qURrKHQ0.cjs"),n=require("./focus-D-h8CbGr.cjs"),r=require("./Modal-
|
|
1
|
+
const e=require("./state-ZBA75xZ_.cjs"),t=require("./Button-qURrKHQ0.cjs"),n=require("./focus-D-h8CbGr.cjs"),r=require("./Modal-CAZ8vap0.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}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./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`))return;let t=O.current;if(!t)return;e.preventDefault();let n=t.getBoundingClientRect();F.current={x:e.clientX-n.left,y:e.clientY-n.top},P.current=!0,j(!0),I.current=c.n(),z.current=new AbortController;let{signal:r}=z.current;window.addEventListener(`pointermove`,Te,{signal:r}),window.addEventListener(`pointerup`,Z,{once:!0,signal:r})};(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 je=x??(m?(0,u.jsx)(`div`,{id:B,className:`vl-modal__title`,children:m}):null),$=ve??(!x&&m?B:void 0),Me=_e??($?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:$,ariaDescribedBy:ye,onMaskClick:De,onPanelClick:Oe,onAfterLeave:()=>{Z(),v&&(N.current=!1),ge?.()},panelProps:be,children:[i.t(je)||_?(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:je}),_?(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}});
|