@vavt/react-ui 1.4.3 → 1.4.4
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/{Cron-vQ7RSsws.cjs → Cron-2avclmKf.cjs} +1 -1
- package/dist/{Cron-HRBggBRO.js → Cron-BVMn9OXM.js} +3 -3
- package/dist/{DatePicker-B0f4Nh8h.js → DatePicker-3wbkApMJ.js} +1 -1
- package/dist/{DatePicker-DFTqHT8i.cjs → DatePicker-B3mA7BzE.cjs} +1 -1
- package/dist/{DateTimePicker-BzkWgjkq.js → DateTimePicker--A4EWUe-.js} +1 -1
- package/dist/{DateTimePicker-McwH-cWl.cjs → DateTimePicker-C1bggaBl.cjs} +1 -1
- package/dist/Drawer-D1elCS8V.js +109 -0
- package/dist/Drawer-DbH5rUvZ.cjs +1 -0
- package/dist/{Dropdown-CyVxoFAH.js → Dropdown-CYo0Ckcg.js} +3 -3
- package/dist/{Dropdown-Chx8SZPS.cjs → Dropdown-DlT_kSLw.cjs} +1 -1
- package/dist/{Form-Fe4b1pS1.js → Form-DiYdJJNH.js} +1 -1
- package/dist/{Form-CyCbST4e.cjs → Form-X98FSlHG.cjs} +1 -1
- package/dist/MessageBox-Bp-3oqz4.cjs +1 -0
- package/dist/MessageBox-C0dCtUie.js +145 -0
- package/dist/Modal-BfHARuVJ.cjs +1 -0
- package/dist/Modal-UWOcLzA6.js +250 -0
- package/dist/{Pagination-BrG1pKYw.js → Pagination-BGbiLFtp.js} +1 -1
- package/dist/{Pagination-D3ok8N9k.cjs → Pagination-CtnBykzs.cjs} +1 -1
- package/dist/{Select-GleCzXQB.js → Select-BBw595_R.js} +3 -3
- package/dist/{Select-Rx6AHue2.cjs → Select-CcuSjVhm.cjs} +1 -1
- package/dist/{Table-ClWg25Wn.js → Table-CpyEziz5.js} +1 -1
- package/dist/{Table-Dv2qxs8q.cjs → Table-uBqeNSnm.cjs} +1 -1
- package/dist/{TimePicker-BCU7D6uD.cjs → TimePicker-BtorXdZv.cjs} +1 -1
- package/dist/{TimePicker-BVZbkBvJ.js → TimePicker-DxDA8bbO.js} +3 -3
- package/dist/{Tooltip-BbbIT5nt.js → Tooltip-2-mZgyai.js} +3 -3
- package/dist/{Tooltip-z6u7ChKj.cjs → Tooltip-BCH9SOnY.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/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/{date-picker-Dp0BXURF.cjs → date-picker-BrlkzTx6.cjs} +1 -1
- package/dist/{date-picker-BKXFZDN2.js → date-picker-DBzPbLf2.js} +4 -4
- package/dist/dialog-shell-DqKDnSak.js +207 -0
- package/dist/dialog-shell-WCsdja9-.cjs +1 -0
- package/dist/es/Cron.mjs +1 -1
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +14 -14
- package/dist/es/register.mjs +1 -1
- package/dist/{layer-C1yCY0MO.js → layer-CWiOhvXF.js} +1 -1
- package/dist/{layer-DL1xVbJT.cjs → layer-DfWO72Y-.cjs} +1 -1
- package/dist/{registry-DRuhdXZS.cjs → registry-7LU6RUh_.cjs} +1 -1
- package/dist/{registry-DUsYI8p5.js → registry-BYt8u6us.js} +13 -13
- package/dist/types/Drawer/type.d.cts +1 -1
- package/dist/types/Drawer/type.d.ts +1 -1
- package/dist/types/Modal/type.d.cts +3 -3
- package/dist/types/Modal/type.d.ts +3 -3
- package/dist/types/_shared/dialog-layer.d.cts +51 -0
- package/dist/types/_shared/dialog-layer.d.ts +51 -0
- package/dist/types/_shared/dialog.d.cts +3 -7
- package/dist/types/_shared/dialog.d.ts +3 -7
- package/package.json +1 -1
- package/dist/Drawer-DNZCj--j.js +0 -113
- package/dist/Drawer-YWO6-KLG.cjs +0 -1
- package/dist/MessageBox-BiSWjPH3.cjs +0 -1
- package/dist/MessageBox-DgBoAkV3.js +0 -166
- package/dist/Modal-BbIpvT94.js +0 -255
- package/dist/Modal-CPL3TGSm.cjs +0 -1
- package/dist/dialog-shell-B7mE8A1p.cjs +0 -1
- package/dist/dialog-shell-FS5nSlBm.js +0 -118
package/dist/Modal-BbIpvT94.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
-
import { n as t, t as n } from "./state-BSDh-Ob2.js";
|
|
3
|
-
import { n as r } from "./refs-D5IYOBaf.js";
|
|
4
|
-
import { t as i } from "./content-Dllrr-7G.js";
|
|
5
|
-
import { t as a } from "./client-pj_wzx28.js";
|
|
6
|
-
import { n as o, t as s } from "./number-BN2jHM6Z.js";
|
|
7
|
-
import { t as ee } from "./id-CHixuHb7.js";
|
|
8
|
-
import { a as te, r as ne, t as re } from "./layer-C1yCY0MO.js";
|
|
9
|
-
import { i as ie, n as ae, t as oe } from "./dialog-shell-FS5nSlBm.js";
|
|
10
|
-
import { t as se } from "./Scrollbar-BdMGZrYi.js";
|
|
11
|
-
import { X as ce } from "lucide-react";
|
|
12
|
-
import { forwardRef as c, useCallback as l, useEffect as u, useMemo as le, useRef as d, useState as ue } from "react";
|
|
13
|
-
import { jsx as f, jsxs as de } from "react/jsx-runtime";
|
|
14
|
-
//#region components/Modal/Modal.tsx
|
|
15
|
-
var fe = .25, pe = 0, me = (e) => {
|
|
16
|
-
if (typeof e == "number") return Number.isFinite(e) ? e : 0;
|
|
17
|
-
if (typeof e == "string") {
|
|
18
|
-
let t = e.trim();
|
|
19
|
-
if (t.endsWith("vh")) {
|
|
20
|
-
let e = parseFloat(t);
|
|
21
|
-
return Number.isFinite(e) ? window.innerHeight * e / 100 : 0;
|
|
22
|
-
}
|
|
23
|
-
if (t.endsWith("px")) {
|
|
24
|
-
let e = parseFloat(t);
|
|
25
|
-
return Number.isFinite(e) ? e : 0;
|
|
26
|
-
}
|
|
27
|
-
let n = parseFloat(t);
|
|
28
|
-
return Number.isFinite(n) ? n : 0;
|
|
29
|
-
}
|
|
30
|
-
return 0;
|
|
31
|
-
}, p = c((c, p) => {
|
|
32
|
-
let { open: he, defaultOpen: ge = !1, title: m, width: _e = 520, offsetY: h = pe, center: g = !1, mask: ve = !0, closeOnClickOverlay: ye = !0, closeOnPressEscape: be = !0, showClose: _ = !0, lockScroll: xe = !0, destroyOnClose: v = !1, draggable: y = !0, fullscreen: b = !1, zIndex: Se, header: x, footer: S, className: Ce, style: C, children: we, onClick: Te, onChange: Ee, onOpen: w, onClose: T, onAfterClose: De, "aria-label": Oe, "aria-labelledby": ke, "aria-describedby": Ae, ...je } = c, E = a(), Me = typeof C?.zIndex == "number" ? C.zIndex : void 0, D = te({
|
|
33
|
-
defaultZIndex: ne.modal,
|
|
34
|
-
zIndex: Se ?? Me,
|
|
35
|
-
withMask: !0
|
|
36
|
-
}), O = d(null), Ne = le(() => r(O, p), [p]), Pe = n(c, "open"), [k, A] = t({
|
|
37
|
-
value: !!he,
|
|
38
|
-
defaultValue: ge,
|
|
39
|
-
controlled: Pe,
|
|
40
|
-
onChange: Ee
|
|
41
|
-
}), [Fe, j] = ue(!1), M = d({
|
|
42
|
-
x: 0,
|
|
43
|
-
y: 0
|
|
44
|
-
}), N = d(!1), P = d(!1), F = d({
|
|
45
|
-
x: 0,
|
|
46
|
-
y: 0
|
|
47
|
-
}), I = d(null), L = d(!1), R = d(null), z = ee("vl-modal-title"), B = l(() => A(!1), [A]), { isTopLayer: V } = ie({
|
|
48
|
-
active: E && k,
|
|
49
|
-
layer: D.layer,
|
|
50
|
-
containerRef: O,
|
|
51
|
-
closeOnPressEscape: be,
|
|
52
|
-
lockScroll: xe,
|
|
53
|
-
onRequestClose: B
|
|
54
|
-
}), H = l((e) => {
|
|
55
|
-
O.current && (O.current.style.visibility = e ? "visible" : "hidden");
|
|
56
|
-
}, []), U = l((e, t) => {
|
|
57
|
-
M.current = {
|
|
58
|
-
x: e,
|
|
59
|
-
y: t
|
|
60
|
-
}, O.current && (O.current.style.left = `${e}px`, O.current.style.top = `${t}px`);
|
|
61
|
-
}, []), W = l((e, t) => {
|
|
62
|
-
let n = e.offsetWidth, r = e.offsetHeight;
|
|
63
|
-
return {
|
|
64
|
-
width: n,
|
|
65
|
-
height: r,
|
|
66
|
-
maxX: Math.max(t, window.innerWidth - n - t),
|
|
67
|
-
maxY: Math.max(t, window.innerHeight - r - t)
|
|
68
|
-
};
|
|
69
|
-
}, []), G = l(() => {
|
|
70
|
-
let e = O.current;
|
|
71
|
-
if (!e || typeof window > "u") return;
|
|
72
|
-
if (b) {
|
|
73
|
-
U(0, 0), N.current = !1;
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
let { width: t, height: n, maxX: r, maxY: i } = W(e, 12), a = (g ? (window.innerHeight - n) / 2 : window.innerHeight * fe) + me(h);
|
|
77
|
-
U(Math.round(s((window.innerWidth - t) / 2, 12, r)), Math.round(s(a, 12, i)));
|
|
78
|
-
}, [
|
|
79
|
-
g,
|
|
80
|
-
b,
|
|
81
|
-
W,
|
|
82
|
-
h,
|
|
83
|
-
U
|
|
84
|
-
]), K = l(() => {
|
|
85
|
-
let e = O.current;
|
|
86
|
-
if (!e) return;
|
|
87
|
-
let { maxX: t, maxY: n } = W(e, 12);
|
|
88
|
-
U(Math.round(s(M.current.x, 12, t)), Math.round(s(M.current.y, 12, n)));
|
|
89
|
-
}, [W, U]), q = l(() => {
|
|
90
|
-
k && (b || !N.current ? G() : K());
|
|
91
|
-
}, [
|
|
92
|
-
k,
|
|
93
|
-
b,
|
|
94
|
-
G,
|
|
95
|
-
K
|
|
96
|
-
]), J = l((e, t) => {
|
|
97
|
-
let n = O.current;
|
|
98
|
-
if (!n || b) return;
|
|
99
|
-
let { maxX: r, maxY: i } = W(n, 12), a = s(e - F.current.x, 12, r), o = s(t - F.current.y, 12, i);
|
|
100
|
-
U(Math.round(a), Math.round(o)), N.current = !0;
|
|
101
|
-
}, [
|
|
102
|
-
b,
|
|
103
|
-
W,
|
|
104
|
-
U
|
|
105
|
-
]), Y = d({
|
|
106
|
-
applyDragPosition: J,
|
|
107
|
-
syncPosition: q
|
|
108
|
-
});
|
|
109
|
-
e(() => {
|
|
110
|
-
Y.current = {
|
|
111
|
-
applyDragPosition: J,
|
|
112
|
-
syncPosition: q
|
|
113
|
-
};
|
|
114
|
-
}, [J, q]);
|
|
115
|
-
let Ie = l((e) => {
|
|
116
|
-
P.current && Y.current.applyDragPosition(e.clientX, e.clientY);
|
|
117
|
-
}, []), X = l(() => {
|
|
118
|
-
R.current?.abort(), R.current = null, I.current?.(), I.current = null;
|
|
119
|
-
}, []), Z = l(() => {
|
|
120
|
-
P.current && (P.current = !1, j(!1), X(), Y.current.syncPosition());
|
|
121
|
-
}, [X]), Le = (e) => {
|
|
122
|
-
if (!y || b || !k || !V() || 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;
|
|
123
|
-
let t = O.current;
|
|
124
|
-
if (!t) return;
|
|
125
|
-
let n = window.getSelection();
|
|
126
|
-
n && n.rangeCount > 0 && n.removeAllRanges(), e.preventDefault();
|
|
127
|
-
let r = t.getBoundingClientRect();
|
|
128
|
-
F.current = {
|
|
129
|
-
x: e.clientX - r.left,
|
|
130
|
-
y: e.clientY - r.top
|
|
131
|
-
}, P.current = !0, j(!0), I.current = ae(), R.current = new AbortController();
|
|
132
|
-
let { signal: i } = R.current;
|
|
133
|
-
window.addEventListener("pointermove", Ie, { signal: i }), window.addEventListener("pointerup", Z, {
|
|
134
|
-
once: !0,
|
|
135
|
-
signal: i
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
u(() => {
|
|
139
|
-
let e = L.current;
|
|
140
|
-
k && !e ? w?.() : !k && e && T?.(), L.current = k;
|
|
141
|
-
}, [
|
|
142
|
-
k,
|
|
143
|
-
w,
|
|
144
|
-
T
|
|
145
|
-
]), e(() => {
|
|
146
|
-
!k || !E || (H(!1), b ? G() : !v && N.current ? K() : G(), H(!0));
|
|
147
|
-
}, [
|
|
148
|
-
k,
|
|
149
|
-
E,
|
|
150
|
-
b,
|
|
151
|
-
v,
|
|
152
|
-
G,
|
|
153
|
-
K,
|
|
154
|
-
U,
|
|
155
|
-
H
|
|
156
|
-
]), u(() => {
|
|
157
|
-
k || Z();
|
|
158
|
-
}, [k, Z]), u(() => {
|
|
159
|
-
let e = O.current;
|
|
160
|
-
if (!k || !E || !e) return;
|
|
161
|
-
let t = null, n = () => {
|
|
162
|
-
P.current || t !== null || (t = window.requestAnimationFrame(() => {
|
|
163
|
-
t = null, P.current || q();
|
|
164
|
-
}));
|
|
165
|
-
}, r = typeof ResizeObserver > "u" ? null : new ResizeObserver(n);
|
|
166
|
-
return r?.observe(e, { box: "border-box" }), window.addEventListener("resize", n, { passive: !0 }), () => {
|
|
167
|
-
r?.disconnect(), window.removeEventListener("resize", n), t !== null && window.cancelAnimationFrame(t);
|
|
168
|
-
};
|
|
169
|
-
}, [
|
|
170
|
-
k,
|
|
171
|
-
E,
|
|
172
|
-
q
|
|
173
|
-
]), u(() => () => {
|
|
174
|
-
X();
|
|
175
|
-
}, [X]);
|
|
176
|
-
let Re = () => {
|
|
177
|
-
ye && V() && B();
|
|
178
|
-
}, ze = (e) => {
|
|
179
|
-
e.stopPropagation(), Te?.(e);
|
|
180
|
-
}, Be = [
|
|
181
|
-
"vl-modal",
|
|
182
|
-
Fe ? "is-dragging" : "",
|
|
183
|
-
g ? "is-center" : "",
|
|
184
|
-
b ? "is-fullscreen" : "",
|
|
185
|
-
Ce || ""
|
|
186
|
-
].filter(Boolean).join(" "), Ve = ["vl-modal__header", y && !b ? "is-draggable" : ""].filter(Boolean).join(" "), Q = { ...C };
|
|
187
|
-
D.zIndex !== void 0 && (Q.zIndex = D.zIndex), b ? (Q.width = "100vw", Q.height = void 0) : Q.width = o(_e) ?? "520px";
|
|
188
|
-
let He = x ?? (m ? /* @__PURE__ */ f("div", {
|
|
189
|
-
id: z,
|
|
190
|
-
className: "vl-modal__title",
|
|
191
|
-
children: m
|
|
192
|
-
}) : null), $ = ke ?? (!x && m ? z : void 0), Ue = Oe ?? ($ ? void 0 : typeof m == "string" ? m : "对话框");
|
|
193
|
-
return /* @__PURE__ */ f(re, {
|
|
194
|
-
layer: D.layer,
|
|
195
|
-
children: /* @__PURE__ */ de(oe, {
|
|
196
|
-
clientReady: E,
|
|
197
|
-
open: k,
|
|
198
|
-
mask: ve,
|
|
199
|
-
destroyOnClose: v,
|
|
200
|
-
maskTransitionName: "vl-modal-mask",
|
|
201
|
-
transitionName: "vl-modal",
|
|
202
|
-
maskClassName: "vl-modal__mask",
|
|
203
|
-
panelClassName: Be,
|
|
204
|
-
panelStyle: Q,
|
|
205
|
-
maskStyle: D.maskZIndex === void 0 ? void 0 : { zIndex: D.maskZIndex },
|
|
206
|
-
panelRef: Ne,
|
|
207
|
-
role: "dialog",
|
|
208
|
-
ariaLabel: Ue,
|
|
209
|
-
ariaLabelledBy: $,
|
|
210
|
-
ariaDescribedBy: Ae,
|
|
211
|
-
onMaskClick: Re,
|
|
212
|
-
onPanelClick: ze,
|
|
213
|
-
onAfterLeave: () => {
|
|
214
|
-
Z(), v && (N.current = !1), De?.();
|
|
215
|
-
},
|
|
216
|
-
panelProps: je,
|
|
217
|
-
children: [
|
|
218
|
-
i(He) || _ ? /* @__PURE__ */ f("div", {
|
|
219
|
-
className: Ve,
|
|
220
|
-
onPointerDown: Le,
|
|
221
|
-
children: /* @__PURE__ */ de("div", {
|
|
222
|
-
className: "vl-modal__headerInner",
|
|
223
|
-
children: [/* @__PURE__ */ f("div", {
|
|
224
|
-
className: "vl-modal__headerMain",
|
|
225
|
-
children: He
|
|
226
|
-
}), _ ? /* @__PURE__ */ f("button", {
|
|
227
|
-
type: "button",
|
|
228
|
-
className: "vl-modal__close",
|
|
229
|
-
"aria-label": "关闭对话框",
|
|
230
|
-
onClick: B,
|
|
231
|
-
children: /* @__PURE__ */ f(ce, {
|
|
232
|
-
size: 20,
|
|
233
|
-
"aria-hidden": "true"
|
|
234
|
-
})
|
|
235
|
-
}) : null]
|
|
236
|
-
})
|
|
237
|
-
}) : null,
|
|
238
|
-
/* @__PURE__ */ f(se, {
|
|
239
|
-
className: "vl-modal__body",
|
|
240
|
-
children: we
|
|
241
|
-
}),
|
|
242
|
-
i(S) ? /* @__PURE__ */ f("div", {
|
|
243
|
-
className: "vl-modal__footer",
|
|
244
|
-
children: S
|
|
245
|
-
}) : null
|
|
246
|
-
]
|
|
247
|
-
})
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
p.displayName = "VlModal";
|
|
251
|
-
//#endregion
|
|
252
|
-
//#region components/Modal/index.ts
|
|
253
|
-
var he = p, ge = p;
|
|
254
|
-
//#endregion
|
|
255
|
-
export { he as n, ge as t };
|
package/dist/Modal-CPL3TGSm.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./content-DCGQZQp8.cjs"),i=require("./client-BkoqeUs3.cjs"),a=require("./number-B7qJF_ZY.cjs"),o=require("./id-CF0zOP1G.cjs"),s=require("./layer-DL1xVbJT.cjs"),c=require("./dialog-shell-B7mE8A1p.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:fe,footer:x,className:pe,style:S,children:me,onClick:he,onChange:ge,onOpen:C,onClose:w,onAfterClose:_e,"aria-label":ve,"aria-labelledby":ye,"aria-describedby":be,...xe}=d,T=i.t(),Se=typeof S?.zIndex==`number`?S.zIndex:void 0,E=s.a({defaultZIndex:s.r.modal,zIndex:de??Se,withMask:!0}),D=(0,l.useRef)(null),Ce=(0,l.useMemo)(()=>n.n(D,f),[f]),we=t.t(d,`open`),[O,k]=t.n({value:!!p,defaultValue:ae,controlled:we,onChange:ge}),[Te,A]=(0,l.useState)(!1),j=(0,l.useRef)({x:0,y:0}),M=(0,l.useRef)(!1),N=(0,l.useRef)(!1),P=(0,l.useRef)({x:0,y:0}),F=(0,l.useRef)(null),I=(0,l.useRef)(!1),L=(0,l.useRef)(null),R=o.t(`vl-modal-title`),z=(0,l.useCallback)(()=>k(!1),[k]),{isTopLayer:B}=c.i({active:T&&O,layer:E.layer,containerRef:D,closeOnPressEscape:le,lockScroll:ue,onRequestClose:z}),V=(0,l.useCallback)(e=>{D.current&&(D.current.style.visibility=e?`visible`:`hidden`)},[]),H=(0,l.useCallback)((e,t)=>{j.current={x:e,y:t},D.current&&(D.current.style.left=`${e}px`,D.current.style.top=`${t}px`)},[]),U=(0,l.useCallback)((e,t)=>{let n=e.offsetWidth,r=e.offsetHeight;return{width:n,height:r,maxX:Math.max(t,window.innerWidth-n-t),maxY:Math.max(t,window.innerHeight-r-t)}},[]),W=(0,l.useCallback)(()=>{let e=D.current;if(!e||typeof window>`u`)return;if(b){H(0,0),M.current=!1;return}let{width:t,height:n,maxX:r,maxY:i}=U(e,12),o=(g?(window.innerHeight-n)/2:window.innerHeight*ne)+ie(h);H(Math.round(a.t((window.innerWidth-t)/2,12,r)),Math.round(a.t(o,12,i)))},[g,b,U,h,H]),G=(0,l.useCallback)(()=>{let e=D.current;if(!e)return;let{maxX:t,maxY:n}=U(e,12);H(Math.round(a.t(j.current.x,12,t)),Math.round(a.t(j.current.y,12,n)))},[U,H]),K=(0,l.useCallback)(()=>{O&&(b||!M.current?W():G())},[O,b,W,G]),q=(0,l.useCallback)((e,t)=>{let n=D.current;if(!n||b)return;let{maxX:r,maxY:i}=U(n,12),o=a.t(e-P.current.x,12,r),s=a.t(t-P.current.y,12,i);H(Math.round(o),Math.round(s)),M.current=!0},[b,U,H]),J=(0,l.useRef)({applyDragPosition:q,syncPosition:K});e.t(()=>{J.current={applyDragPosition:q,syncPosition:K}},[q,K]);let Ee=(0,l.useCallback)(e=>{N.current&&J.current.applyDragPosition(e.clientX,e.clientY)},[]),Y=(0,l.useCallback)(()=>{L.current?.abort(),L.current=null,F.current?.(),F.current=null},[]),X=(0,l.useCallback)(()=>{N.current&&(N.current=!1,A(!1),Y(),J.current.syncPosition())},[Y]),De=e=>{if(!y||b||!O||!B()||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=D.current;if(!t)return;let n=window.getSelection();n&&n.rangeCount>0&&n.removeAllRanges(),e.preventDefault();let r=t.getBoundingClientRect();P.current={x:e.clientX-r.left,y:e.clientY-r.top},N.current=!0,A(!0),F.current=c.n(),L.current=new AbortController;let{signal:i}=L.current;window.addEventListener(`pointermove`,Ee,{signal:i}),window.addEventListener(`pointerup`,X,{once:!0,signal:i})};(0,l.useEffect)(()=>{let e=I.current;O&&!e?C?.():!O&&e&&w?.(),I.current=O},[O,C,w]),e.t(()=>{!O||!T||(V(!1),b?W():!v&&M.current?G():W(),V(!0))},[O,T,b,v,W,G,H,V]),(0,l.useEffect)(()=>{O||X()},[O,X]),(0,l.useEffect)(()=>{let e=D.current;if(!O||!T||!e)return;let t=null,n=()=>{N.current||t!==null||(t=window.requestAnimationFrame(()=>{t=null,N.current||K()}))},r=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return r?.observe(e,{box:`border-box`}),window.addEventListener(`resize`,n,{passive:!0}),()=>{r?.disconnect(),window.removeEventListener(`resize`,n),t!==null&&window.cancelAnimationFrame(t)}},[O,T,K]),(0,l.useEffect)(()=>()=>{Y()},[Y]);let Oe=()=>{ce&&B()&&z()},ke=e=>{e.stopPropagation(),he?.(e)},Ae=[`vl-modal`,Te?`is-dragging`:``,g?`is-center`:``,b?`is-fullscreen`:``,pe||``].filter(Boolean).join(` `),je=[`vl-modal__header`,y&&!b?`is-draggable`:``].filter(Boolean).join(` `),Z={...S};E.zIndex!==void 0&&(Z.zIndex=E.zIndex),b?(Z.width=`100vw`,Z.height=void 0):Z.width=a.n(oe)??`520px`;let Q=fe??(m?(0,u.jsx)(`div`,{id:R,className:`vl-modal__title`,children:m}):null),$=ye??(!fe&&m?R:void 0),Me=ve??($?void 0:typeof m==`string`?m:`对话框`);return(0,u.jsx)(s.t,{layer:E.layer,children:(0,u.jsxs)(c.t,{clientReady:T,open:O,mask:se,destroyOnClose:v,maskTransitionName:`vl-modal-mask`,transitionName:`vl-modal`,maskClassName:`vl-modal__mask`,panelClassName:Ae,panelStyle:Z,maskStyle:E.maskZIndex===void 0?void 0:{zIndex:E.maskZIndex},panelRef:Ce,role:`dialog`,ariaLabel:Me,ariaLabelledBy:$,ariaDescribedBy:be,onMaskClick:Oe,onPanelClick:ke,onAfterLeave:()=>{X(),v&&(M.current=!1),_e?.()},panelProps:xe,children:[r.t(Q)||_?(0,u.jsx)(`div`,{className:je,onPointerDown:De,children:(0,u.jsxs)(`div`,{className:`vl-modal__headerInner`,children:[(0,u.jsx)(`div`,{className:`vl-modal__headerMain`,children:Q}),_?(0,u.jsx)(`button`,{type:`button`,className:`vl-modal__close`,"aria-label":`关闭对话框`,onClick:z,children:(0,u.jsx)(te.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,u.jsx)(ee.t,{className:`vl-modal__body`,children:me}),r.t(x)?(0,u.jsx)(`div`,{className:`vl-modal__footer`,children:x}):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}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./effect-BpNxm_06.cjs"),t=require("./Transition-X_89ga-e.cjs"),n=require("./focus-D-h8CbGr.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("react-dom");var o=[],s=new Set,c=new Map,l=0,u=0,d=``,f=``,p=``,m=e=>(o.push(e),s.forEach(e=>e()),()=>{let t=o.lastIndexOf(e);t>=0&&o.splice(t,1),s.forEach(e=>e())}),h=e=>o.at(-1)===e,g=()=>[...c.values()],_=()=>{if(l===0){d=document.body.style.overflow,f=document.body.style.paddingRight;let e=document.documentElement.clientWidth,t=e>0?Math.max(0,window.innerWidth-e):0;if(t>0){let e=Number.parseFloat(window.getComputedStyle(document.body).paddingRight)||0;document.body.style.paddingRight=`${e+t}px`}document.body.style.overflow=`hidden`}l+=1;let e=!1;return()=>{e||(e=!0,l=Math.max(0,l-1),l===0&&(document.body.style.overflow=d,document.body.style.paddingRight=f))}},v=()=>{u===0&&(p=document.body.style.userSelect,document.body.style.userSelect=`none`),u+=1;let e=!1;return()=>{e||(e=!0,u=Math.max(0,u-1),u===0&&(document.body.style.userSelect=p))}},y=({active:t,layer:i,containerRef:a,closeOnPressEscape:o,lockScroll:l,onRequestClose:u})=>{let d=(0,r.useRef)(Symbol(`vl-dialog`)),f=(0,r.useRef)(null),p=(0,r.useRef)(!1),g=(0,r.useCallback)(()=>h(d.current),[]);return e.t(()=>{if(!t)return;let e=d.current;return c.set(e,i),()=>{c.delete(e)}},[t,i]),(0,r.useEffect)(()=>{if(!t)return;let e=d.current;p.current=!0,f.current=document.activeElement instanceof HTMLElement?document.activeElement:null;let r=m(e),i=l?_():()=>{},c=()=>{let e=a.current;e&&n.r(e)},g=window.requestAnimationFrame(c),v=()=>{h(e)&&(a.current?.contains(document.activeElement)||window.requestAnimationFrame(c))};s.add(v);let y=t=>{if(!h(e))return;if(t.key===`Escape`&&o){t.preventDefault(),u();return}if(t.key!==`Tab`)return;let r=a.current;if(!r)return;let i=n.a(r);if(!i.length){t.preventDefault(),r.focus({preventScroll:!0});return}let s=i[0],c=i.at(-1)??s,l=document.activeElement;t.shiftKey&&(l===s||!r.contains(l))?(t.preventDefault(),c.focus()):!t.shiftKey&&(l===c||!r.contains(l))&&(t.preventDefault(),s.focus())},b=t=>{if(!h(e))return;let r=a.current;!r||r.contains(t.target)||n.r(r)};return document.addEventListener(`keydown`,y),document.addEventListener(`focusin`,b),()=>{window.cancelAnimationFrame(g),document.removeEventListener(`keydown`,y),document.removeEventListener(`focusin`,b),s.delete(v),r(),i(),p.current=!1;let e=f.current;f.current=null,window.requestAnimationFrame(()=>{!p.current&&e?.isConnected&&e.focus({preventScroll:!0})})}},[t,o,a,l,u]),{isTopLayer:g}},b=({clientReady:e,open:n,mask:r,destroyOnClose:o,maskUnmountOnExit:s=!1,maskTransitionName:c,transitionName:l,maskClassName:u,panelClassName:d,panelStyle:f,maskStyle:p,panelRef:m,role:h,ariaModal:g=!0,ariaLabel:_,ariaLabelledBy:v,ariaDescribedBy:y,onMaskClick:b,onPanelClick:x,onAfterLeave:S,panelProps:C,children:w})=>e?(0,a.createPortal)((0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.t,{show:n&&r,name:c,unmountOnExit:s,children:(0,i.jsx)(`div`,{className:u,style:p,"aria-hidden":`true`,onClick:b})}),(0,i.jsx)(t.t,{show:n,name:l,unmountOnExit:o,onAfterLeave:S,children:(0,i.jsx)(`div`,{ref:m,className:d,style:f,role:h,"aria-modal":g,"aria-label":_,"aria-labelledby":v,"aria-describedby":y,"aria-hidden":!n||void 0,tabIndex:-1,onClick:x,...C,children:w})})]}),document.body):null;Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return b}});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
-
import { t } from "./Transition-DiO4GsP3.js";
|
|
3
|
-
import { a as n, r } from "./focus-BDDJyKk3.js";
|
|
4
|
-
import { useCallback as i, useEffect as a, useRef as o } from "react";
|
|
5
|
-
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
-
import { createPortal as u } from "react-dom";
|
|
7
|
-
//#region components/_shared/dialog.ts
|
|
8
|
-
var d = [], f = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Map(), m = 0, h = 0, g = "", _ = "", v = "", y = (e) => (d.push(e), f.forEach((e) => e()), () => {
|
|
9
|
-
let t = d.lastIndexOf(e);
|
|
10
|
-
t >= 0 && d.splice(t, 1), f.forEach((e) => e());
|
|
11
|
-
}), b = (e) => d.at(-1) === e, x = () => [...p.values()], S = () => {
|
|
12
|
-
if (m === 0) {
|
|
13
|
-
g = document.body.style.overflow, _ = document.body.style.paddingRight;
|
|
14
|
-
let e = document.documentElement.clientWidth, t = e > 0 ? Math.max(0, window.innerWidth - e) : 0;
|
|
15
|
-
if (t > 0) {
|
|
16
|
-
let e = Number.parseFloat(window.getComputedStyle(document.body).paddingRight) || 0;
|
|
17
|
-
document.body.style.paddingRight = `${e + t}px`;
|
|
18
|
-
}
|
|
19
|
-
document.body.style.overflow = "hidden";
|
|
20
|
-
}
|
|
21
|
-
m += 1;
|
|
22
|
-
let e = !1;
|
|
23
|
-
return () => {
|
|
24
|
-
e || (e = !0, m = Math.max(0, m - 1), m === 0 && (document.body.style.overflow = g, document.body.style.paddingRight = _));
|
|
25
|
-
};
|
|
26
|
-
}, C = () => {
|
|
27
|
-
h === 0 && (v = document.body.style.userSelect, document.body.style.userSelect = "none"), h += 1;
|
|
28
|
-
let e = !1;
|
|
29
|
-
return () => {
|
|
30
|
-
e || (e = !0, h = Math.max(0, h - 1), h === 0 && (document.body.style.userSelect = v));
|
|
31
|
-
};
|
|
32
|
-
}, w = ({ active: t, layer: s, containerRef: c, closeOnPressEscape: l, lockScroll: u, onRequestClose: d }) => {
|
|
33
|
-
let m = o(Symbol("vl-dialog")), h = o(null), g = o(!1), _ = i(() => b(m.current), []);
|
|
34
|
-
return e(() => {
|
|
35
|
-
if (!t) return;
|
|
36
|
-
let e = m.current;
|
|
37
|
-
return p.set(e, s), () => {
|
|
38
|
-
p.delete(e);
|
|
39
|
-
};
|
|
40
|
-
}, [t, s]), a(() => {
|
|
41
|
-
if (!t) return;
|
|
42
|
-
let e = m.current;
|
|
43
|
-
g.current = !0, h.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
44
|
-
let i = y(e), a = u ? S() : () => {}, o = () => {
|
|
45
|
-
let e = c.current;
|
|
46
|
-
e && r(e);
|
|
47
|
-
}, s = window.requestAnimationFrame(o), p = () => {
|
|
48
|
-
b(e) && (c.current?.contains(document.activeElement) || window.requestAnimationFrame(o));
|
|
49
|
-
};
|
|
50
|
-
f.add(p);
|
|
51
|
-
let _ = (t) => {
|
|
52
|
-
if (!b(e)) return;
|
|
53
|
-
if (t.key === "Escape" && l) {
|
|
54
|
-
t.preventDefault(), d();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (t.key !== "Tab") return;
|
|
58
|
-
let r = c.current;
|
|
59
|
-
if (!r) return;
|
|
60
|
-
let i = n(r);
|
|
61
|
-
if (!i.length) {
|
|
62
|
-
t.preventDefault(), r.focus({ preventScroll: !0 });
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
let a = i[0], o = i.at(-1) ?? a, s = document.activeElement;
|
|
66
|
-
t.shiftKey && (s === a || !r.contains(s)) ? (t.preventDefault(), o.focus()) : !t.shiftKey && (s === o || !r.contains(s)) && (t.preventDefault(), a.focus());
|
|
67
|
-
}, v = (t) => {
|
|
68
|
-
if (!b(e)) return;
|
|
69
|
-
let n = c.current;
|
|
70
|
-
!n || n.contains(t.target) || r(n);
|
|
71
|
-
};
|
|
72
|
-
return document.addEventListener("keydown", _), document.addEventListener("focusin", v), () => {
|
|
73
|
-
window.cancelAnimationFrame(s), document.removeEventListener("keydown", _), document.removeEventListener("focusin", v), f.delete(p), i(), a(), g.current = !1;
|
|
74
|
-
let e = h.current;
|
|
75
|
-
h.current = null, window.requestAnimationFrame(() => {
|
|
76
|
-
!g.current && e?.isConnected && e.focus({ preventScroll: !0 });
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
}, [
|
|
80
|
-
t,
|
|
81
|
-
l,
|
|
82
|
-
c,
|
|
83
|
-
u,
|
|
84
|
-
d
|
|
85
|
-
]), { isTopLayer: _ };
|
|
86
|
-
}, T = ({ clientReady: e, open: n, mask: r, destroyOnClose: i, maskUnmountOnExit: a = !1, maskTransitionName: o, transitionName: d, maskClassName: f, panelClassName: p, panelStyle: m, maskStyle: h, panelRef: g, role: _, ariaModal: v = !0, ariaLabel: y, ariaLabelledBy: b, ariaDescribedBy: x, onMaskClick: S, onPanelClick: C, onAfterLeave: w, panelProps: T, children: E }) => e ? u(/* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(t, {
|
|
87
|
-
show: n && r,
|
|
88
|
-
name: o,
|
|
89
|
-
unmountOnExit: a,
|
|
90
|
-
children: /* @__PURE__ */ c("div", {
|
|
91
|
-
className: f,
|
|
92
|
-
style: h,
|
|
93
|
-
"aria-hidden": "true",
|
|
94
|
-
onClick: S
|
|
95
|
-
})
|
|
96
|
-
}), /* @__PURE__ */ c(t, {
|
|
97
|
-
show: n,
|
|
98
|
-
name: d,
|
|
99
|
-
unmountOnExit: i,
|
|
100
|
-
onAfterLeave: w,
|
|
101
|
-
children: /* @__PURE__ */ c("div", {
|
|
102
|
-
ref: g,
|
|
103
|
-
className: p,
|
|
104
|
-
style: m,
|
|
105
|
-
role: _,
|
|
106
|
-
"aria-modal": v,
|
|
107
|
-
"aria-label": y,
|
|
108
|
-
"aria-labelledby": b,
|
|
109
|
-
"aria-describedby": x,
|
|
110
|
-
"aria-hidden": !n || void 0,
|
|
111
|
-
tabIndex: -1,
|
|
112
|
-
onClick: C,
|
|
113
|
-
...T,
|
|
114
|
-
children: E
|
|
115
|
-
})
|
|
116
|
-
})] }), document.body) : null;
|
|
117
|
-
//#endregion
|
|
118
|
-
export { w as i, C as n, x as r, T as t };
|