@sheetxl/utils-mui 0.8.0-beta.9 → 1.0.2
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/LICENSE.md +17 -7
- package/browser/esm/{B-9Z_PrXy3xrqV-k.mjs → BkzUbkIS7Gl4KBNM.mjs} +5 -5
- package/browser/esm/HjS7GfnM0bjK-8z3.mjs +2588 -0
- package/browser/esm/index.mjs +1013 -816
- package/licenses/dependencies.txt +2 -74
- package/node/esm/{CVCkIih_2s2gyrpD.mjs → DCQeUMbvzPRBReSp.mjs} +4 -4
- package/node/esm/index.mjs +1062 -1052
- package/package.json +11 -14
- package/types/src/command/CommandGroup.d.ts +1 -1
- package/types/src/command/CommandPopupButton.d.ts +3 -3
- package/types/src/components/ContextMenu.d.ts +2 -2
- package/types/src/components/ScrollButtons.d.ts +3 -3
- package/types/src/components/index.d.ts +1 -0
- package/types/src/components/lazyPanel.d.ts +23 -0
- package/types/src/float/ExhibitFloatPanel.d.ts +4 -4
- package/types/src/float/ExhibitFloatProvider.d.ts +1 -1
- package/types/src/float/ExhibitPopup.d.ts +15 -7
- package/types/src/theme/ExhibitTheme.d.ts +0 -8
- package/types/src/theme/index.d.ts +0 -1
- package/browser/cjs/BuNmQtxji8I9Yi5e.cjs +0 -1
- package/browser/cjs/DUxTGswhY7-hAb4I.cjs +0 -3
- package/browser/cjs/index.cjs +0 -4
- package/browser/esm/CszJijHEUkwwmT4u.mjs +0 -2566
- package/types/src/theme/ScrollbarTheming.d.ts +0 -12
|
@@ -0,0 +1,2588 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license @sheetxl/utils-mui - Utilities MUI - Utilities for MUI Components needed for all SheetXL components. - v1.0.2
|
|
3
|
+
*
|
|
4
|
+
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
import { Backdrop as e, Box as t, Button as n, Chip as r, CircularProgress as i, DialogActions as a, DialogContent as o, DialogTitle as s, Fade as c, IconButton as l, Paper as u, Tooltip as d, Typography as f, Unstable_TrapFocus as p, useTheme as m, useThemeProps as h } from "@mui/material";
|
|
8
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
9
|
+
import * as y from "react";
|
|
10
|
+
import b, { cloneElement as x, forwardRef as S, memo as C, useEffect as w, useId as ee, useLayoutEffect as T, useMemo as E, useRef as D, useState as O, version as k } from "react";
|
|
11
|
+
import { alpha as A } from "@mui/system";
|
|
12
|
+
import { CommonUtils as te } from "@sheetxl/utils";
|
|
13
|
+
import { Command as j, DynamicIcon as ne, KeyCodes as re, KeyModifiers as M, NotifierType as ie, ReactUtils as N, RenderSlot as P, floatThemeScopeProps as F, scrollbarThemedClassName as ae, useCallbackRef as oe, useFloatSurface as se, useFullscreenPortal as ce, useImperativeElement as le, useMeasure as ue, useTranslator as de, zIndexVar as fe } from "@sheetxl/utils-react";
|
|
14
|
+
import pe, { createPortal as me } from "react-dom";
|
|
15
|
+
var he = Object.create, ge = Object.defineProperty, I = Object.getOwnPropertyDescriptor, _e = Object.getOwnPropertyNames, ve = Object.getPrototypeOf, ye = Object.prototype.hasOwnProperty, be = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), xe = (e, t, n) => (n = e == null ? {} : he(ve(e)), ((e, t, n, r) => {
|
|
16
|
+
if (t && typeof t == "object" || typeof t == "function") for (var i, a = _e(t), o = 0, s = a.length; o < s; o++) i = a[o], ye.call(e, i) || i === n || ge(e, i, {
|
|
17
|
+
get: ((e) => t[e]).bind(null, i),
|
|
18
|
+
enumerable: !(r = I(t, i)) || r.enumerable
|
|
19
|
+
});
|
|
20
|
+
return e;
|
|
21
|
+
})(!t && e && e.__esModule && ye.call(e, "default") ? n : ge(n, "default", {
|
|
22
|
+
value: e,
|
|
23
|
+
enumerable: !0
|
|
24
|
+
}), e));
|
|
25
|
+
function Se(e) {
|
|
26
|
+
var t, n, r = "";
|
|
27
|
+
if (typeof e == "string" || typeof e == "number") r += e;
|
|
28
|
+
else if (typeof e == "object") {
|
|
29
|
+
if (Array.isArray(e)) {
|
|
30
|
+
var i = e.length;
|
|
31
|
+
for (t = 0; t < i; t++) e[t] && (n = Se(e[t])) && (r && (r += " "), r += n);
|
|
32
|
+
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
33
|
+
}
|
|
34
|
+
return r;
|
|
35
|
+
}
|
|
36
|
+
function Ce() {
|
|
37
|
+
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = Se(e)) && (r && (r += " "), r += t);
|
|
38
|
+
return r;
|
|
39
|
+
}
|
|
40
|
+
function we(e, t) {
|
|
41
|
+
if (typeof e == "function") return e(t);
|
|
42
|
+
e && (e.current = t);
|
|
43
|
+
}
|
|
44
|
+
var Te = parseInt(k.split(".")[0], 10) >= 19 ? function(e) {
|
|
45
|
+
return (t) => {
|
|
46
|
+
let n = [];
|
|
47
|
+
for (let r of e) {
|
|
48
|
+
let e = we(r, t), i = typeof e == "function";
|
|
49
|
+
n.push(i ? e : () => we(r, null));
|
|
50
|
+
}
|
|
51
|
+
return () => {
|
|
52
|
+
for (let e of n) e();
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
} : function(e) {
|
|
56
|
+
return (t) => {
|
|
57
|
+
for (let n of e) we(n, t);
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
function Ee(e) {
|
|
61
|
+
return E(() => Te(e), e);
|
|
62
|
+
}
|
|
63
|
+
var De = C(S((e, n) => {
|
|
64
|
+
let { chips: i, sx: a, ...o } = e, s = E(() => {
|
|
65
|
+
if (!i) return null;
|
|
66
|
+
let e = Array.isArray(i) ? i : [i], t = [], n = e.length;
|
|
67
|
+
for (let i = 0; i < n; i++) {
|
|
68
|
+
let n = e[i], a = null;
|
|
69
|
+
typeof n == "string" ? a = _(r, {
|
|
70
|
+
label: n,
|
|
71
|
+
color: "primary",
|
|
72
|
+
size: "small",
|
|
73
|
+
sx: { scale: "0.8" }
|
|
74
|
+
}, "chip-" + i) : x(n, { key: "chip-" + i }), t.push(a);
|
|
75
|
+
}
|
|
76
|
+
return t;
|
|
77
|
+
}, [i]);
|
|
78
|
+
return _(t, {
|
|
79
|
+
ref: n,
|
|
80
|
+
sx: {
|
|
81
|
+
display: "flex",
|
|
82
|
+
flexDirection: "row",
|
|
83
|
+
marginLeft: "4px",
|
|
84
|
+
gap: "2px",
|
|
85
|
+
...a
|
|
86
|
+
},
|
|
87
|
+
...o,
|
|
88
|
+
children: s
|
|
89
|
+
});
|
|
90
|
+
})), Oe = S((e, t) => {
|
|
91
|
+
let { slotProps: n, ...r } = e, { getPortalContainer: i, isFullscreen: a } = ce();
|
|
92
|
+
return _(d, {
|
|
93
|
+
ref: t,
|
|
94
|
+
slotProps: {
|
|
95
|
+
...n,
|
|
96
|
+
popper: {
|
|
97
|
+
container: a ? i : void 0,
|
|
98
|
+
...n?.popper || {}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
...r
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
Oe.displayName = "SimpleTooltip";
|
|
105
|
+
var L = C((e) => {
|
|
106
|
+
let { modifier: n, sx: r, ...i } = e;
|
|
107
|
+
return _(t, {
|
|
108
|
+
sx: {
|
|
109
|
+
marginLeft: "1px",
|
|
110
|
+
marginRight: "1px",
|
|
111
|
+
borderRadius: "4px",
|
|
112
|
+
borderStyle: "solid",
|
|
113
|
+
borderTopWidth: "1px",
|
|
114
|
+
borderLeftWidth: "1px",
|
|
115
|
+
borderRightWidth: "1px",
|
|
116
|
+
borderBottomWidth: "2px",
|
|
117
|
+
borderTopColor: (e) => A(e.palette.background.paper, e.palette.action.disabledOpacity),
|
|
118
|
+
borderLeftColor: (e) => A(e.palette.background.paper, e.palette.action.disabledOpacity),
|
|
119
|
+
borderRightColor: (e) => A(e.palette.background.paper, e.palette.action.disabledOpacity),
|
|
120
|
+
borderBottomColor: (e) => A(e.palette.background.paper, 1 - e.palette.action.disabledOpacity),
|
|
121
|
+
backgroundColor: (e) => A(e.palette.action.hover, e.palette.action.disabledOpacity),
|
|
122
|
+
paddingLeft: "4px",
|
|
123
|
+
paddingRight: "4px",
|
|
124
|
+
minHeight: "1.6em",
|
|
125
|
+
display: "flex",
|
|
126
|
+
justifyContent: "center",
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
boxSizing: "content-box",
|
|
129
|
+
overflow: "hidden",
|
|
130
|
+
...r
|
|
131
|
+
},
|
|
132
|
+
...i,
|
|
133
|
+
children: _(t, {
|
|
134
|
+
sx: {
|
|
135
|
+
display: "flex",
|
|
136
|
+
alignItems: "center",
|
|
137
|
+
justifyContent: "center",
|
|
138
|
+
textAlign: "center",
|
|
139
|
+
"& *": { fontWeight: "500" }
|
|
140
|
+
},
|
|
141
|
+
children: n
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
}), ke = (e, n, r = !1, i = null) => {
|
|
145
|
+
if (Array.isArray(e)) {
|
|
146
|
+
let a = [], o = e;
|
|
147
|
+
for (let e = 0; e < o.length; e++) a.push(ke(o[e], n, r, i ?? "" + e));
|
|
148
|
+
return _(t, {
|
|
149
|
+
sx: {
|
|
150
|
+
display: "flex",
|
|
151
|
+
alignItems: "center",
|
|
152
|
+
flexDirection: "column"
|
|
153
|
+
},
|
|
154
|
+
children: a
|
|
155
|
+
}, i);
|
|
156
|
+
}
|
|
157
|
+
if (!e?.key) return null;
|
|
158
|
+
let a = {};
|
|
159
|
+
for (let t = 0; e.modifiers && t < e.modifiers.length; t++) a[e.modifiers[t]] = !0;
|
|
160
|
+
let o = [], s = te.getPlatform() === te.OSType.MacOS || te.getPlatform() === te.OSType.IOS ? n("shortcut.modifier.cmd") : n("shortcut.modifier.ctrl");
|
|
161
|
+
return a?.[M.Ctrl] && (o.push(_(L, { modifier: r ? "^" : _("div", {
|
|
162
|
+
style: { paddingRight: "1px" },
|
|
163
|
+
children: s
|
|
164
|
+
}) }, "ctrl")), o.push("+")), a?.[M.Alt] && (o.push(_(L, { modifier: r ? "⌥" : n("shortcut.modifier.alt") }, "alt")), o.push("+")), a?.[M.Shift] && (o.push(_(L, { modifier: r ? "⇧" : _("div", {
|
|
165
|
+
style: { paddingRight: "1px" },
|
|
166
|
+
children: n("shortcut.modifier.shift")
|
|
167
|
+
}) }, "shift")), o.push("+")), a?.[M.Meta] && (o.push(_(L, { modifier: r ? _("div", {
|
|
168
|
+
style: { paddingTop: "1px" },
|
|
169
|
+
children: "⌘"
|
|
170
|
+
}) : n("shortcut.modifier.meta") }, "meta")), o.push("+")), o.push(_(L, { modifier: N.toPrettyKeyCode(e.key) }, "character")), _(t, {
|
|
171
|
+
sx: {
|
|
172
|
+
display: "flex",
|
|
173
|
+
alignItems: "center",
|
|
174
|
+
flexShrink: 0,
|
|
175
|
+
whiteSpace: "nowrap"
|
|
176
|
+
},
|
|
177
|
+
children: o
|
|
178
|
+
}, i);
|
|
179
|
+
}, Ae = C(S((e, n) => {
|
|
180
|
+
let { disabled: r = !1, label: i, shortcut: a, chips: o, description: s, maxWidth: c = 280, useModifierSymbols: l = !1, children: u, simple: d, componentDisabled: p = !1, sx: m, ...h } = e, y = de(), b = null;
|
|
181
|
+
a && (b = ke(a, y, l));
|
|
182
|
+
let [x, S] = O(null);
|
|
183
|
+
return w(() => {
|
|
184
|
+
Promise.resolve(i).then((e) => {
|
|
185
|
+
S(e);
|
|
186
|
+
});
|
|
187
|
+
}, [i]), _(Oe, {
|
|
188
|
+
slotProps: { popper: {
|
|
189
|
+
sx: {
|
|
190
|
+
"& .MuiTooltip-tooltip": { marginTop: "0px !important" },
|
|
191
|
+
...m
|
|
192
|
+
},
|
|
193
|
+
modifiers: [{
|
|
194
|
+
name: "offset",
|
|
195
|
+
options: { offset: [0, 14] }
|
|
196
|
+
}]
|
|
197
|
+
} },
|
|
198
|
+
className: "tooltip-wrapper",
|
|
199
|
+
tabIndex: -1,
|
|
200
|
+
title: !r && x ? v(t, {
|
|
201
|
+
sx: { maxWidth: `${c}px` },
|
|
202
|
+
ref: n,
|
|
203
|
+
children: [v(t, {
|
|
204
|
+
sx: {
|
|
205
|
+
display: "flex",
|
|
206
|
+
flexDirection: "row",
|
|
207
|
+
marginBottom: s ? "4px" : "0px"
|
|
208
|
+
},
|
|
209
|
+
children: [
|
|
210
|
+
_(f, {
|
|
211
|
+
variant: "subtitle1",
|
|
212
|
+
component: "div",
|
|
213
|
+
sx: { flex: "1 1 100%" },
|
|
214
|
+
children: x
|
|
215
|
+
}),
|
|
216
|
+
o ? _(De, { chips: o }) : null,
|
|
217
|
+
b ? _(t, { sx: { marginLeft: "8px" } }, "leadingSpace") : _(g, {}),
|
|
218
|
+
b
|
|
219
|
+
]
|
|
220
|
+
}), s ? _(f, {
|
|
221
|
+
variant: "caption",
|
|
222
|
+
sx: {
|
|
223
|
+
whiteSpace: "pre-line",
|
|
224
|
+
lineHeight: "1.4"
|
|
225
|
+
},
|
|
226
|
+
children: s
|
|
227
|
+
}) : _(g, {})]
|
|
228
|
+
}) : "",
|
|
229
|
+
enterDelay: 260,
|
|
230
|
+
enterNextDelay: 130,
|
|
231
|
+
leaveDelay: 230,
|
|
232
|
+
disableInteractive: !0,
|
|
233
|
+
...h,
|
|
234
|
+
children: _("div", {
|
|
235
|
+
style: {
|
|
236
|
+
display: "flex",
|
|
237
|
+
alignItems: "stretch",
|
|
238
|
+
justifyContent: "stretch"
|
|
239
|
+
},
|
|
240
|
+
children: u
|
|
241
|
+
})
|
|
242
|
+
});
|
|
243
|
+
})), je = {
|
|
244
|
+
"dialog.cancel": "Cancel",
|
|
245
|
+
"dialog.ok": "Ok",
|
|
246
|
+
"lazyLoad.retry": "Retry",
|
|
247
|
+
"overflow.more": "More",
|
|
248
|
+
"overflow.moreDescription": "More toolbar options…",
|
|
249
|
+
"scroll.edgeBottom": " Bottom: ''Ctrl+Click'' to scroll to the end",
|
|
250
|
+
"scroll.edgeLeft": " Left: ''Ctrl+Click'' to scroll to the beginning",
|
|
251
|
+
"scroll.edgeRight": " Right: ''Ctrl+Click'' to scroll to the end",
|
|
252
|
+
"scroll.edgeTop": " Top: ''Ctrl+Click'' to scroll to the beginning",
|
|
253
|
+
"shortcut.modifier.alt": "Alt",
|
|
254
|
+
"shortcut.modifier.cmd": "Cmd",
|
|
255
|
+
"shortcut.modifier.ctrl": "Ctrl",
|
|
256
|
+
"shortcut.modifier.meta": "Meta",
|
|
257
|
+
"shortcut.modifier.shift": "Shift",
|
|
258
|
+
"stackTrace.causedBy": "Caused by: {cause}",
|
|
259
|
+
"stackTrace.copy": "Copy stack trace",
|
|
260
|
+
"stackTrace.heading": "Stack Trace",
|
|
261
|
+
"stackTrace.headingFrames": "Stack Trace ({count} frames)",
|
|
262
|
+
"stackTrace.log": "Log error to console",
|
|
263
|
+
"stackTrace.moreFrames": "... and {count} more frames",
|
|
264
|
+
"window.close": "Close"
|
|
265
|
+
}, { DefaultCommandCatalogService: Me } = j, Ne = !1;
|
|
266
|
+
function Pe() {
|
|
267
|
+
Ne || (Ne = !0, Me.registerFromManifest("@sheetxl/utils-mui", import.meta.url, { messages: je }));
|
|
268
|
+
}
|
|
269
|
+
var Fe = be((e, t) => {
|
|
270
|
+
t.exports = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
271
|
+
}), Ie = be((e, t) => {
|
|
272
|
+
var n = Fe();
|
|
273
|
+
function r() {}
|
|
274
|
+
function i() {}
|
|
275
|
+
i.resetWarningCache = r, t.exports = function() {
|
|
276
|
+
function e(e, t, r, i, a, o) {
|
|
277
|
+
if (o !== n) {
|
|
278
|
+
var s = /* @__PURE__ */ Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");
|
|
279
|
+
throw s.name = "Invariant Violation", s;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function t() {
|
|
283
|
+
return e;
|
|
284
|
+
}
|
|
285
|
+
e.isRequired = e;
|
|
286
|
+
var a = {
|
|
287
|
+
array: e,
|
|
288
|
+
bigint: e,
|
|
289
|
+
bool: e,
|
|
290
|
+
func: e,
|
|
291
|
+
number: e,
|
|
292
|
+
object: e,
|
|
293
|
+
string: e,
|
|
294
|
+
symbol: e,
|
|
295
|
+
any: e,
|
|
296
|
+
arrayOf: t,
|
|
297
|
+
element: e,
|
|
298
|
+
elementType: e,
|
|
299
|
+
instanceOf: t,
|
|
300
|
+
node: e,
|
|
301
|
+
objectOf: t,
|
|
302
|
+
oneOf: t,
|
|
303
|
+
oneOfType: t,
|
|
304
|
+
shape: t,
|
|
305
|
+
exact: t,
|
|
306
|
+
checkPropTypes: i,
|
|
307
|
+
resetWarningCache: r
|
|
308
|
+
};
|
|
309
|
+
return a.PropTypes = a, a;
|
|
310
|
+
};
|
|
311
|
+
}), R = xe(be((e, t) => {
|
|
312
|
+
t.exports = Ie()();
|
|
313
|
+
})(), 1);
|
|
314
|
+
function Le(e, t) {
|
|
315
|
+
for (let n = 0, r = e.length; n < r; n++) if (t.apply(t, [
|
|
316
|
+
e[n],
|
|
317
|
+
n,
|
|
318
|
+
e
|
|
319
|
+
])) return e[n];
|
|
320
|
+
}
|
|
321
|
+
function Re(e) {
|
|
322
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Function]";
|
|
323
|
+
}
|
|
324
|
+
function ze(e) {
|
|
325
|
+
return typeof e == "number" && !isNaN(e);
|
|
326
|
+
}
|
|
327
|
+
function z(e) {
|
|
328
|
+
return parseInt(e, 10);
|
|
329
|
+
}
|
|
330
|
+
function B(e, t, n) {
|
|
331
|
+
if (e[t]) return /* @__PURE__ */ Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`);
|
|
332
|
+
}
|
|
333
|
+
var Be = [
|
|
334
|
+
"Moz",
|
|
335
|
+
"Webkit",
|
|
336
|
+
"O",
|
|
337
|
+
"ms"
|
|
338
|
+
];
|
|
339
|
+
function Ve(e, t) {
|
|
340
|
+
return t ? `${t}${function(e) {
|
|
341
|
+
let t = "", n = !0;
|
|
342
|
+
for (let r = 0; r < e.length; r++) n ? (t += e[r].toUpperCase(), n = !1) : e[r] === "-" ? n = !0 : t += e[r];
|
|
343
|
+
return t;
|
|
344
|
+
}(e)}` : e;
|
|
345
|
+
}
|
|
346
|
+
var He = function(e = "transform") {
|
|
347
|
+
if (typeof window > "u") return "";
|
|
348
|
+
let t = window.document?.documentElement?.style;
|
|
349
|
+
if (!t || e in t) return "";
|
|
350
|
+
for (let n = 0; n < Be.length; n++) if (Ve(e, Be[n]) in t) return Be[n];
|
|
351
|
+
return "";
|
|
352
|
+
}(), Ue = "";
|
|
353
|
+
function We(e, t) {
|
|
354
|
+
Ue ||= Le([
|
|
355
|
+
"matches",
|
|
356
|
+
"webkitMatchesSelector",
|
|
357
|
+
"mozMatchesSelector",
|
|
358
|
+
"msMatchesSelector",
|
|
359
|
+
"oMatchesSelector"
|
|
360
|
+
], function(t) {
|
|
361
|
+
return Re(e[t]);
|
|
362
|
+
}) ?? "";
|
|
363
|
+
let n = e[Ue];
|
|
364
|
+
return !!Re(n) && !!n.call(e, t);
|
|
365
|
+
}
|
|
366
|
+
function Ge(e, t, n) {
|
|
367
|
+
let r = e;
|
|
368
|
+
do {
|
|
369
|
+
if (We(r, t)) return !0;
|
|
370
|
+
if (r === n) return !1;
|
|
371
|
+
r = r.parentNode;
|
|
372
|
+
} while (r);
|
|
373
|
+
return !1;
|
|
374
|
+
}
|
|
375
|
+
function Ke(e, t, n, r) {
|
|
376
|
+
if (!e) return;
|
|
377
|
+
let i = {
|
|
378
|
+
capture: !0,
|
|
379
|
+
...r
|
|
380
|
+
}, a = n;
|
|
381
|
+
e.addEventListener ? e.addEventListener(t, a, i) : e.attachEvent ? e.attachEvent("on" + t, a) : e["on" + t] = a;
|
|
382
|
+
}
|
|
383
|
+
function qe(e, t, n, r) {
|
|
384
|
+
if (!e) return;
|
|
385
|
+
let i = {
|
|
386
|
+
capture: !0,
|
|
387
|
+
...r
|
|
388
|
+
}, a = n;
|
|
389
|
+
e.removeEventListener ? e.removeEventListener(t, a, i) : e.detachEvent ? e.detachEvent("on" + t, a) : e["on" + t] = null;
|
|
390
|
+
}
|
|
391
|
+
function Je(e) {
|
|
392
|
+
let t = e.clientHeight, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
393
|
+
return t += z(n.borderTopWidth), t += z(n.borderBottomWidth), t;
|
|
394
|
+
}
|
|
395
|
+
function Ye(e) {
|
|
396
|
+
let t = e.clientWidth, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
397
|
+
return t += z(n.borderLeftWidth), t += z(n.borderRightWidth), t;
|
|
398
|
+
}
|
|
399
|
+
function Xe(e) {
|
|
400
|
+
let t = e.clientHeight, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
401
|
+
return t -= z(n.paddingTop), t -= z(n.paddingBottom), t;
|
|
402
|
+
}
|
|
403
|
+
function Ze(e) {
|
|
404
|
+
let t = e.clientWidth, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
405
|
+
return t -= z(n.paddingLeft), t -= z(n.paddingRight), t;
|
|
406
|
+
}
|
|
407
|
+
function Qe({ x: e, y: t }, n, r) {
|
|
408
|
+
let i = `translate(${e}${r},${t}${r})`;
|
|
409
|
+
return n && (i = `translate(${typeof n.x == "string" ? n.x : n.x + r}, ${typeof n.y == "string" ? n.y : n.y + r})` + i), i;
|
|
410
|
+
}
|
|
411
|
+
function $e(e, t) {
|
|
412
|
+
if (!e) return;
|
|
413
|
+
let n = e.getElementById("react-draggable-style-el");
|
|
414
|
+
if (!n) {
|
|
415
|
+
n = e.createElement("style"), n.type = "text/css", n.id = "react-draggable-style-el";
|
|
416
|
+
let r = t ?? (typeof __webpack_nonce__ < "u" ? __webpack_nonce__ : void 0);
|
|
417
|
+
r && n.setAttribute("nonce", r), n.innerHTML = ".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n", n.innerHTML += ".react-draggable-transparent-selection *::selection {all: inherit;}\n", e.getElementsByTagName("head")[0].appendChild(n);
|
|
418
|
+
}
|
|
419
|
+
var r, i;
|
|
420
|
+
e.body && (r = e.body, i = "react-draggable-transparent-selection", r.classList ? r.classList.add(i) : r.className.match(RegExp(`(?:^|\\s)${i}(?!\\S)`)) || (r.className += ` ${i}`));
|
|
421
|
+
}
|
|
422
|
+
function et(e) {
|
|
423
|
+
window.requestAnimationFrame ? window.requestAnimationFrame(() => {
|
|
424
|
+
tt(e);
|
|
425
|
+
}) : tt(e);
|
|
426
|
+
}
|
|
427
|
+
function tt(e) {
|
|
428
|
+
var t, n;
|
|
429
|
+
if (e) try {
|
|
430
|
+
e.body && (t = e.body, n = "react-draggable-transparent-selection", t.classList ? t.classList.remove(n) : t.className = t.className.replace(RegExp(`(?:^|\\s)${n}(?!\\S)`, "g"), ""));
|
|
431
|
+
let r = e.selection;
|
|
432
|
+
if (r) r.empty();
|
|
433
|
+
else {
|
|
434
|
+
let t = (e.defaultView || window).getSelection();
|
|
435
|
+
t && t.type !== "Caret" && t.removeAllRanges();
|
|
436
|
+
}
|
|
437
|
+
} catch {}
|
|
438
|
+
}
|
|
439
|
+
function nt(e, t, n) {
|
|
440
|
+
return [Math.round(t / e[0]) * e[0], Math.round(n / e[1]) * e[1]];
|
|
441
|
+
}
|
|
442
|
+
function rt(e) {
|
|
443
|
+
return e.props.axis === "both" || e.props.axis === "x";
|
|
444
|
+
}
|
|
445
|
+
function it(e) {
|
|
446
|
+
return e.props.axis === "both" || e.props.axis === "y";
|
|
447
|
+
}
|
|
448
|
+
function at(e, t, n) {
|
|
449
|
+
let r = typeof t == "number" ? function(e, t) {
|
|
450
|
+
return e.targetTouches && Le(e.targetTouches, (e) => t === e.identifier) || e.changedTouches && Le(e.changedTouches, (e) => t === e.identifier);
|
|
451
|
+
}(e, t) : null;
|
|
452
|
+
if (typeof t == "number" && !r) return null;
|
|
453
|
+
let i = ct(n);
|
|
454
|
+
return function(e, t, n) {
|
|
455
|
+
let r = t === t.ownerDocument.body ? {
|
|
456
|
+
left: 0,
|
|
457
|
+
top: 0
|
|
458
|
+
} : t.getBoundingClientRect();
|
|
459
|
+
return {
|
|
460
|
+
x: (e.clientX + t.scrollLeft - r.left) / n,
|
|
461
|
+
y: (e.clientY + t.scrollTop - r.top) / n
|
|
462
|
+
};
|
|
463
|
+
}(r || e, n.props.offsetParent || i.offsetParent || i.ownerDocument.body, n.props.scale);
|
|
464
|
+
}
|
|
465
|
+
function ot(e, t, n) {
|
|
466
|
+
let r = !ze(e.lastX), i = ct(e);
|
|
467
|
+
return r ? {
|
|
468
|
+
node: i,
|
|
469
|
+
deltaX: 0,
|
|
470
|
+
deltaY: 0,
|
|
471
|
+
lastX: t,
|
|
472
|
+
lastY: n,
|
|
473
|
+
x: t,
|
|
474
|
+
y: n
|
|
475
|
+
} : {
|
|
476
|
+
node: i,
|
|
477
|
+
deltaX: t - e.lastX,
|
|
478
|
+
deltaY: n - e.lastY,
|
|
479
|
+
lastX: e.lastX,
|
|
480
|
+
lastY: e.lastY,
|
|
481
|
+
x: t,
|
|
482
|
+
y: n
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function st(e, t) {
|
|
486
|
+
let n = e.props.scale;
|
|
487
|
+
return {
|
|
488
|
+
node: t.node,
|
|
489
|
+
x: e.state.x + t.deltaX / n,
|
|
490
|
+
y: e.state.y + t.deltaY / n,
|
|
491
|
+
deltaX: t.deltaX / n,
|
|
492
|
+
deltaY: t.deltaY / n,
|
|
493
|
+
lastX: e.state.x,
|
|
494
|
+
lastY: e.state.y
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function ct(e) {
|
|
498
|
+
let t = e.findDOMNode();
|
|
499
|
+
if (!t) throw Error("<DraggableCore>: Unmounted during event!");
|
|
500
|
+
return t;
|
|
501
|
+
}
|
|
502
|
+
var lt = {
|
|
503
|
+
start: "touchstart",
|
|
504
|
+
move: "touchmove",
|
|
505
|
+
stop: "touchend"
|
|
506
|
+
}, ut = {
|
|
507
|
+
start: "mousedown",
|
|
508
|
+
move: "mousemove",
|
|
509
|
+
stop: "mouseup"
|
|
510
|
+
}, dt = ut, ft = class extends y.Component {
|
|
511
|
+
constructor() {
|
|
512
|
+
super(...arguments), this.dragging = !1, this.lastX = NaN, this.lastY = NaN, this.touchIdentifier = null, this.mounted = !1, this.handleDragStart = (e) => {
|
|
513
|
+
if (this.props.onMouseDown(e), !this.props.allowAnyClick && (typeof e.button == "number" && e.button !== 0 || e.ctrlKey)) return !1;
|
|
514
|
+
let t = this.findDOMNode();
|
|
515
|
+
if (!t || !t.ownerDocument || !t.ownerDocument.body) throw Error("<DraggableCore> not mounted on DragStart!");
|
|
516
|
+
let { ownerDocument: n } = t;
|
|
517
|
+
if (this.props.disabled || !(e.target instanceof n.defaultView.Node) || this.props.handle && !Ge(e.target, this.props.handle, t) || this.props.cancel && Ge(e.target, this.props.cancel, t)) return;
|
|
518
|
+
e.type !== "touchstart" || this.props.allowMobileScroll || e.preventDefault();
|
|
519
|
+
let r = function(e) {
|
|
520
|
+
return e.targetTouches && e.targetTouches[0] ? e.targetTouches[0].identifier : e.changedTouches && e.changedTouches[0] ? e.changedTouches[0].identifier : void 0;
|
|
521
|
+
}(e);
|
|
522
|
+
this.touchIdentifier = r;
|
|
523
|
+
let i = at(e, r, this);
|
|
524
|
+
if (i == null) return;
|
|
525
|
+
let { x: a, y: o } = i, s = ot(this, a, o);
|
|
526
|
+
this.props.onStart, !1 !== this.props.onStart(e, s) && !1 !== this.mounted && (this.props.enableUserSelectHack && $e(n, this.props.nonce), this.dragging = !0, this.lastX = a, this.lastY = o, Ke(n, dt.move, this.handleDrag), Ke(n, dt.stop, this.handleDragStop));
|
|
527
|
+
}, this.handleDrag = (e) => {
|
|
528
|
+
let t = at(e, this.touchIdentifier, this);
|
|
529
|
+
if (t == null) return;
|
|
530
|
+
let { x: n, y: r } = t;
|
|
531
|
+
if (Array.isArray(this.props.grid)) {
|
|
532
|
+
let e = n - this.lastX, t = r - this.lastY;
|
|
533
|
+
if ([e, t] = nt(this.props.grid, e, t), !e && !t) return;
|
|
534
|
+
n = this.lastX + e, r = this.lastY + t;
|
|
535
|
+
}
|
|
536
|
+
let i = ot(this, n, r);
|
|
537
|
+
if (!1 !== this.props.onDrag(e, i) && !1 !== this.mounted) this.lastX = n, this.lastY = r;
|
|
538
|
+
else try {
|
|
539
|
+
this.handleDragStop(new MouseEvent("mouseup"));
|
|
540
|
+
} catch {
|
|
541
|
+
let e = document.createEvent("MouseEvents");
|
|
542
|
+
e.initMouseEvent("mouseup", !0, !0, window, 0, 0, 0, 0, 0, !1, !1, !1, !1, 0, null), this.handleDragStop(e);
|
|
543
|
+
}
|
|
544
|
+
}, this.handleDragStop = (e) => {
|
|
545
|
+
if (!this.dragging) return;
|
|
546
|
+
let t = at(e, this.touchIdentifier, this);
|
|
547
|
+
if (t == null) return;
|
|
548
|
+
let { x: n, y: r } = t;
|
|
549
|
+
if (Array.isArray(this.props.grid)) {
|
|
550
|
+
let e = n - this.lastX || 0, t = r - this.lastY || 0;
|
|
551
|
+
[e, t] = nt(this.props.grid, e, t), n = this.lastX + e, r = this.lastY + t;
|
|
552
|
+
}
|
|
553
|
+
let i = ot(this, n, r);
|
|
554
|
+
if (!1 === this.props.onStop(e, i) || !1 === this.mounted) return !1;
|
|
555
|
+
let a = this.findDOMNode();
|
|
556
|
+
a && this.props.enableUserSelectHack && et(a.ownerDocument), this.dragging = !1, this.lastX = NaN, this.lastY = NaN, a && (qe(a.ownerDocument, dt.move, this.handleDrag), qe(a.ownerDocument, dt.stop, this.handleDragStop));
|
|
557
|
+
}, this.onMouseDown = (e) => (dt = ut, this.handleDragStart(e)), this.onMouseUp = (e) => (dt = ut, this.handleDragStop(e)), this.onTouchStart = (e) => (dt = lt, this.handleDragStart(e)), this.onTouchEnd = (e) => (dt = lt, this.handleDragStop(e));
|
|
558
|
+
}
|
|
559
|
+
componentDidMount() {
|
|
560
|
+
this.mounted = !0;
|
|
561
|
+
let e = this.findDOMNode();
|
|
562
|
+
e && Ke(e, lt.start, this.onTouchStart, { passive: !1 });
|
|
563
|
+
}
|
|
564
|
+
componentWillUnmount() {
|
|
565
|
+
this.mounted = !1;
|
|
566
|
+
let e = this.findDOMNode();
|
|
567
|
+
if (e) {
|
|
568
|
+
let { ownerDocument: t } = e;
|
|
569
|
+
qe(t, ut.move, this.handleDrag), qe(t, lt.move, this.handleDrag), qe(t, ut.stop, this.handleDragStop), qe(t, lt.stop, this.handleDragStop), qe(e, lt.start, this.onTouchStart, { passive: !1 }), this.props.enableUserSelectHack && et(t);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
findDOMNode() {
|
|
573
|
+
if (this.props?.nodeRef) return this.props.nodeRef.current;
|
|
574
|
+
let e = pe;
|
|
575
|
+
return typeof e.findDOMNode == "function" ? e.findDOMNode(this) : null;
|
|
576
|
+
}
|
|
577
|
+
render() {
|
|
578
|
+
return y.cloneElement(y.Children.only(this.props.children), {
|
|
579
|
+
onMouseDown: this.onMouseDown,
|
|
580
|
+
onMouseUp: this.onMouseUp,
|
|
581
|
+
onTouchEnd: this.onTouchEnd
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
ft.displayName = "DraggableCore", ft.propTypes = {
|
|
586
|
+
allowAnyClick: R.default.bool,
|
|
587
|
+
allowMobileScroll: R.default.bool,
|
|
588
|
+
children: R.default.node.isRequired,
|
|
589
|
+
disabled: R.default.bool,
|
|
590
|
+
enableUserSelectHack: R.default.bool,
|
|
591
|
+
offsetParent: function(e, t) {
|
|
592
|
+
if (e[t] && e[t].nodeType !== 1) throw Error("Draggable's offsetParent must be a DOM Node.");
|
|
593
|
+
},
|
|
594
|
+
grid: R.default.arrayOf(R.default.number),
|
|
595
|
+
handle: R.default.string,
|
|
596
|
+
cancel: R.default.string,
|
|
597
|
+
nodeRef: R.default.object,
|
|
598
|
+
nonce: R.default.string,
|
|
599
|
+
onStart: R.default.func,
|
|
600
|
+
onDrag: R.default.func,
|
|
601
|
+
onStop: R.default.func,
|
|
602
|
+
onMouseDown: R.default.func,
|
|
603
|
+
scale: R.default.number,
|
|
604
|
+
className: B,
|
|
605
|
+
style: B,
|
|
606
|
+
transform: B
|
|
607
|
+
}, ft.defaultProps = {
|
|
608
|
+
allowAnyClick: !1,
|
|
609
|
+
allowMobileScroll: !1,
|
|
610
|
+
disabled: !1,
|
|
611
|
+
enableUserSelectHack: !0,
|
|
612
|
+
onStart: function() {},
|
|
613
|
+
onDrag: function() {},
|
|
614
|
+
onStop: function() {},
|
|
615
|
+
onMouseDown: function() {},
|
|
616
|
+
scale: 1
|
|
617
|
+
};
|
|
618
|
+
var pt = class extends y.Component {
|
|
619
|
+
constructor(e) {
|
|
620
|
+
super(e), this.onDragStart = (e, t) => {
|
|
621
|
+
if (!1 === this.props.onStart(e, st(this, t))) return !1;
|
|
622
|
+
this.setState({
|
|
623
|
+
dragging: !0,
|
|
624
|
+
dragged: !0
|
|
625
|
+
});
|
|
626
|
+
}, this.onDrag = (e, t) => {
|
|
627
|
+
if (!this.state.dragging) return !1;
|
|
628
|
+
let n = st(this, t), r = {
|
|
629
|
+
x: n.x,
|
|
630
|
+
y: n.y,
|
|
631
|
+
slackX: 0,
|
|
632
|
+
slackY: 0
|
|
633
|
+
};
|
|
634
|
+
if (this.props.bounds) {
|
|
635
|
+
let { x: e, y: t } = r;
|
|
636
|
+
r.x += this.state.slackX, r.y += this.state.slackY;
|
|
637
|
+
let [i, a] = function(e, t, n) {
|
|
638
|
+
if (!e.props.bounds) return [t, n];
|
|
639
|
+
let { bounds: r } = e.props;
|
|
640
|
+
r = typeof r == "string" ? r : function(e) {
|
|
641
|
+
return {
|
|
642
|
+
left: e.left,
|
|
643
|
+
top: e.top,
|
|
644
|
+
right: e.right,
|
|
645
|
+
bottom: e.bottom
|
|
646
|
+
};
|
|
647
|
+
}(r);
|
|
648
|
+
let i = ct(e);
|
|
649
|
+
if (typeof r == "string") {
|
|
650
|
+
let { ownerDocument: e } = i, t = e.defaultView;
|
|
651
|
+
if (!t) throw Error("Cannot resolve the owner window of the draggable node.");
|
|
652
|
+
let n;
|
|
653
|
+
if (n = r === "parent" ? i.parentNode : i.getRootNode().querySelector(r), !(n instanceof t.HTMLElement)) throw Error("Bounds selector \"" + r + "\" could not find an element.");
|
|
654
|
+
let a = n, o = t.getComputedStyle(i), s = t.getComputedStyle(a);
|
|
655
|
+
r = {
|
|
656
|
+
left: -i.offsetLeft + z(s.paddingLeft) + z(o.marginLeft),
|
|
657
|
+
top: -i.offsetTop + z(s.paddingTop) + z(o.marginTop),
|
|
658
|
+
right: Ze(a) - Ye(i) - i.offsetLeft + z(s.paddingRight) - z(o.marginRight),
|
|
659
|
+
bottom: Xe(a) - Je(i) - i.offsetTop + z(s.paddingBottom) - z(o.marginBottom)
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
return ze(r.right) && (t = Math.min(t, r.right)), ze(r.bottom) && (n = Math.min(n, r.bottom)), ze(r.left) && (t = Math.max(t, r.left)), ze(r.top) && (n = Math.max(n, r.top)), [t, n];
|
|
663
|
+
}(this, r.x, r.y);
|
|
664
|
+
r.x = i, r.y = a, r.slackX = this.state.slackX + (e - r.x), r.slackY = this.state.slackY + (t - r.y), n.x = r.x, n.y = r.y, n.deltaX = r.x - this.state.x, n.deltaY = r.y - this.state.y;
|
|
665
|
+
}
|
|
666
|
+
if (!1 === this.props.onDrag(e, n)) return !1;
|
|
667
|
+
this.setState(r);
|
|
668
|
+
}, this.onDragStop = (e, t) => {
|
|
669
|
+
if (!this.state.dragging || !1 === this.props.onStop(e, st(this, t))) return !1;
|
|
670
|
+
let n = {
|
|
671
|
+
dragging: !1,
|
|
672
|
+
slackX: 0,
|
|
673
|
+
slackY: 0
|
|
674
|
+
};
|
|
675
|
+
if (this.props.position) {
|
|
676
|
+
let { x: e, y: t } = this.props.position;
|
|
677
|
+
n.x = e, n.y = t;
|
|
678
|
+
}
|
|
679
|
+
this.setState(n);
|
|
680
|
+
}, this.state = {
|
|
681
|
+
dragging: !1,
|
|
682
|
+
dragged: !1,
|
|
683
|
+
x: e.position ? e.position.x : e.defaultPosition.x,
|
|
684
|
+
y: e.position ? e.position.y : e.defaultPosition.y,
|
|
685
|
+
prevPropsPosition: { ...e.position },
|
|
686
|
+
slackX: 0,
|
|
687
|
+
slackY: 0,
|
|
688
|
+
isElementSVG: !1
|
|
689
|
+
}, !e.position || e.onDrag || e.onStop || console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.");
|
|
690
|
+
}
|
|
691
|
+
static getDerivedStateFromProps({ position: e }, { prevPropsPosition: t }) {
|
|
692
|
+
return !e || t && e.x === t.x && e.y === t.y ? null : {
|
|
693
|
+
x: e.x,
|
|
694
|
+
y: e.y,
|
|
695
|
+
prevPropsPosition: { ...e }
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
componentDidMount() {
|
|
699
|
+
window.SVGElement !== void 0 && this.findDOMNode() instanceof window.SVGElement && this.setState({ isElementSVG: !0 });
|
|
700
|
+
}
|
|
701
|
+
componentWillUnmount() {
|
|
702
|
+
this.state.dragging && this.setState({ dragging: !1 });
|
|
703
|
+
}
|
|
704
|
+
findDOMNode() {
|
|
705
|
+
if (this.props?.nodeRef) return this.props.nodeRef.current;
|
|
706
|
+
let e = pe;
|
|
707
|
+
return typeof e.findDOMNode == "function" ? e.findDOMNode(this) : null;
|
|
708
|
+
}
|
|
709
|
+
render() {
|
|
710
|
+
let { axis: e, bounds: t, children: n, defaultPosition: r, defaultClassName: i, defaultClassNameDragging: a, defaultClassNameDragged: o, position: s, positionOffset: c, scale: l, ...u } = this.props, d = {}, f = null, p = !s || this.state.dragging, m = s || r, h = {
|
|
711
|
+
x: rt(this) && p ? this.state.x : m.x,
|
|
712
|
+
y: it(this) && p ? this.state.y : m.y
|
|
713
|
+
};
|
|
714
|
+
this.state.isElementSVG ? f = function(e, t) {
|
|
715
|
+
return Qe(e, t, "");
|
|
716
|
+
}(h, c) : d = function(e, t) {
|
|
717
|
+
let n = Qe(e, t, "px");
|
|
718
|
+
return { [Ve("transform", He)]: n };
|
|
719
|
+
}(h, c);
|
|
720
|
+
let g = y.Children.only(n), _ = Ce(g.props.className || "", i, {
|
|
721
|
+
[a]: this.state.dragging,
|
|
722
|
+
[o]: this.state.dragged
|
|
723
|
+
});
|
|
724
|
+
return y.createElement(ft, {
|
|
725
|
+
...u,
|
|
726
|
+
onStart: this.onDragStart,
|
|
727
|
+
onDrag: this.onDrag,
|
|
728
|
+
onStop: this.onDragStop
|
|
729
|
+
}, y.cloneElement(g, {
|
|
730
|
+
className: _,
|
|
731
|
+
style: {
|
|
732
|
+
...g.props.style,
|
|
733
|
+
...d
|
|
734
|
+
},
|
|
735
|
+
transform: f
|
|
736
|
+
}));
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
pt.displayName = "Draggable", pt.propTypes = {
|
|
740
|
+
...ft.propTypes,
|
|
741
|
+
axis: R.default.oneOf([
|
|
742
|
+
"both",
|
|
743
|
+
"x",
|
|
744
|
+
"y",
|
|
745
|
+
"none"
|
|
746
|
+
]),
|
|
747
|
+
bounds: R.default.oneOfType([
|
|
748
|
+
R.default.shape({
|
|
749
|
+
left: R.default.number,
|
|
750
|
+
right: R.default.number,
|
|
751
|
+
top: R.default.number,
|
|
752
|
+
bottom: R.default.number
|
|
753
|
+
}),
|
|
754
|
+
R.default.string,
|
|
755
|
+
R.default.oneOf([!1])
|
|
756
|
+
]),
|
|
757
|
+
defaultClassName: R.default.string,
|
|
758
|
+
defaultClassNameDragging: R.default.string,
|
|
759
|
+
defaultClassNameDragged: R.default.string,
|
|
760
|
+
defaultPosition: R.default.shape({
|
|
761
|
+
x: R.default.number,
|
|
762
|
+
y: R.default.number
|
|
763
|
+
}),
|
|
764
|
+
positionOffset: R.default.shape({
|
|
765
|
+
x: R.default.oneOfType([R.default.number, R.default.string]),
|
|
766
|
+
y: R.default.oneOfType([R.default.number, R.default.string])
|
|
767
|
+
}),
|
|
768
|
+
position: R.default.shape({
|
|
769
|
+
x: R.default.number,
|
|
770
|
+
y: R.default.number
|
|
771
|
+
}),
|
|
772
|
+
className: B,
|
|
773
|
+
style: B,
|
|
774
|
+
transform: B
|
|
775
|
+
}, pt.defaultProps = {
|
|
776
|
+
...ft.defaultProps,
|
|
777
|
+
axis: "both",
|
|
778
|
+
bounds: !1,
|
|
779
|
+
defaultClassName: "react-draggable",
|
|
780
|
+
defaultClassNameDragging: "react-draggable-dragging",
|
|
781
|
+
defaultClassNameDragged: "react-draggable-dragged",
|
|
782
|
+
defaultPosition: {
|
|
783
|
+
x: 0,
|
|
784
|
+
y: 0
|
|
785
|
+
},
|
|
786
|
+
scale: 1
|
|
787
|
+
};
|
|
788
|
+
var mt = pt;
|
|
789
|
+
Pe();
|
|
790
|
+
var ht = {
|
|
791
|
+
x: 0,
|
|
792
|
+
y: 0
|
|
793
|
+
}, gt = C(S((e, t) => {
|
|
794
|
+
let { defaultPosition: n = ht, PaperComponent: r = u, onDragStop: i, rootSel: a = ".MuiModal-root", handleSel: o = ".draggable-title", titleSize: s, rootSize: c, ...l } = e, d = D(null), f = E(() => s?.width && s?.height && c?.width && c?.height ? {
|
|
795
|
+
left: 0,
|
|
796
|
+
top: 0,
|
|
797
|
+
right: c.width - s.width,
|
|
798
|
+
bottom: c.height - s.height
|
|
799
|
+
} : null, [s, c]), [p, m] = O(null), [h, g] = O(null), v = p ?? n ?? null, y = E(() => v && f ? {
|
|
800
|
+
x: Math.max(0, Math.min(v.x, f.right)),
|
|
801
|
+
y: Math.max(0, Math.min(v.y, f.bottom))
|
|
802
|
+
} : v, [v, f]), b = Ee([d, t]);
|
|
803
|
+
return _(mt, {
|
|
804
|
+
nodeRef: d,
|
|
805
|
+
handle: o,
|
|
806
|
+
cancel: "[class*=\"MuiDialogContent-root\"]",
|
|
807
|
+
position: y ?? void 0,
|
|
808
|
+
bounds: f ?? ".MuiModal-root",
|
|
809
|
+
enableUserSelectHack: !1,
|
|
810
|
+
onStop: i,
|
|
811
|
+
onStart: (e, t) => {
|
|
812
|
+
let n = e;
|
|
813
|
+
g({
|
|
814
|
+
x: (n.clientX ?? n.touches?.[0]?.clientX) - t.x,
|
|
815
|
+
y: (n.clientY ?? n.touches?.[0]?.clientY) - t.y
|
|
816
|
+
});
|
|
817
|
+
},
|
|
818
|
+
onDrag: (e, t) => {
|
|
819
|
+
let n = e;
|
|
820
|
+
if (!h) return;
|
|
821
|
+
let r = n.clientX ?? n.touches?.[0]?.clientX, i = n.clientY ?? n.touches?.[0]?.clientY;
|
|
822
|
+
m({
|
|
823
|
+
x: r - h.x,
|
|
824
|
+
y: i - h.y
|
|
825
|
+
});
|
|
826
|
+
},
|
|
827
|
+
children: _(r, {
|
|
828
|
+
ref: b,
|
|
829
|
+
...l
|
|
830
|
+
})
|
|
831
|
+
});
|
|
832
|
+
})), _t = {
|
|
833
|
+
x: "50",
|
|
834
|
+
y: "50"
|
|
835
|
+
}, vt = C(S((n, r) => {
|
|
836
|
+
let i = h({
|
|
837
|
+
props: n,
|
|
838
|
+
name: "MuiDialog"
|
|
839
|
+
}), a = m(), o = de(), d = {
|
|
840
|
+
enter: .66 * a.transitions.duration.enteringScreen,
|
|
841
|
+
exit: .66 * a.transitions.duration.leavingScreen
|
|
842
|
+
}, { title: f = "SheetXL", onCancel: g, onDone: y, onShow: b, onShown: x, onHide: S, onClose: C, open: E, autoFocusSel: k, children: j, transitionDuration: M = d, TransitionProps: ie, slots: N = te.EmptyArray, slotProps: P = te.EmptyArray, sx: pe, className: he, onMouseDown: ge, initialPosition: I = _t, isModal: _e = !1, suspendModal: ve = !1, restoreFocus: ye = !0, disableAutoDestroy: be = !1, revealToken: xe, startHidden: Se = !1, ...we } = i, Te = N.transition ?? c, De = N.backdrop ?? e, Oe = N.paper ?? u, L = P.transition;
|
|
843
|
+
ie && (L = {
|
|
844
|
+
...ie,
|
|
845
|
+
...L
|
|
846
|
+
});
|
|
847
|
+
let ke = P.backdrop, je = P.paper, [Me, Ne] = O(null), [Pe, Fe] = O(!1), [Ie, R] = O(!1), Le = D(null), [Re, ze] = ue(), z = D(null), B = D(null), [Be, Ve] = ue(), He = D(null), Ue = ee(), We = D(null);
|
|
848
|
+
T(() => {
|
|
849
|
+
if (!Me || Se) return;
|
|
850
|
+
let e = !!E;
|
|
851
|
+
We.current !== e && (We.current = e, Fe(e));
|
|
852
|
+
}, [
|
|
853
|
+
E,
|
|
854
|
+
Me,
|
|
855
|
+
Se
|
|
856
|
+
]);
|
|
857
|
+
let Ge = oe(() => {
|
|
858
|
+
g?.(), Fe(!1);
|
|
859
|
+
}, [g]);
|
|
860
|
+
T(() => {
|
|
861
|
+
if (Me) return;
|
|
862
|
+
let e = z.current, t = He.current;
|
|
863
|
+
if (!e || !t) return;
|
|
864
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
865
|
+
if (n.width === 0 && n.height === 0 || r.width === 0 && r.height === 0) return;
|
|
866
|
+
let i = n.height - r.height, a = n.width - r.width, o = .5 * a, s = .5 * i;
|
|
867
|
+
typeof I?.x == "number" ? o = I.x : typeof I?.x == "string" && (o = a * (parseFloat(I.x) / 100)), typeof I?.y == "number" ? s = I.y : typeof I?.y == "string" && (s = i * (parseFloat(I.y) / 100)), Ne({
|
|
868
|
+
x: o,
|
|
869
|
+
y: s
|
|
870
|
+
});
|
|
871
|
+
});
|
|
872
|
+
let [Ke, qe] = O(!1), [Je, Ye] = O(null), [Xe, Ze] = O(null), Qe = oe((e) => {
|
|
873
|
+
if (Je) return Je.focus(e), !0;
|
|
874
|
+
if (k) {
|
|
875
|
+
let t = B.current?.querySelectorAll?.(k);
|
|
876
|
+
if (t && t.length > 0) return t[0]?.focus?.(e), !0;
|
|
877
|
+
}
|
|
878
|
+
return B.current?.focus?.(e), !1;
|
|
879
|
+
}, [Je, k]), $e = le(r, () => ({ focus: (e) => {
|
|
880
|
+
Qe(e);
|
|
881
|
+
} }), []), et = D(xe);
|
|
882
|
+
w(() => {
|
|
883
|
+
xe !== et.current && (et.current = xe, Fe(!0));
|
|
884
|
+
}, [xe]);
|
|
885
|
+
let tt = {
|
|
886
|
+
...L,
|
|
887
|
+
onExited: (e) => {
|
|
888
|
+
y?.(null), be || L?.onExited?.(e);
|
|
889
|
+
},
|
|
890
|
+
onExit: (e) => {
|
|
891
|
+
let t = Xe, n = typeof ye == "function" ? ye() : ye;
|
|
892
|
+
t && !1 !== n && requestAnimationFrame(() => {
|
|
893
|
+
$e.current?.contains(document.activeElement) && t.focus();
|
|
894
|
+
}), S?.(), R(!1), L?.onExit?.(e);
|
|
895
|
+
},
|
|
896
|
+
onEntered: (e, t) => {
|
|
897
|
+
b?.(), L?.onEntered?.(e, t);
|
|
898
|
+
},
|
|
899
|
+
onEntering: (e, t) => {
|
|
900
|
+
R(!0), x?.($e.current);
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
w(() => {
|
|
904
|
+
Ie && Qe();
|
|
905
|
+
}, [Ie]);
|
|
906
|
+
let nt = Ee([He, r]), rt = _(p, {
|
|
907
|
+
open: Ie,
|
|
908
|
+
disableAutoFocus: !0,
|
|
909
|
+
disableEnforceFocus: !Ke,
|
|
910
|
+
disableRestoreFocus: !0 !== ye,
|
|
911
|
+
children: _(Te, {
|
|
912
|
+
in: Pe,
|
|
913
|
+
timeout: M,
|
|
914
|
+
role: "presentation",
|
|
915
|
+
...tt,
|
|
916
|
+
children: _(t, {
|
|
917
|
+
className: "MuiDialog-container",
|
|
918
|
+
ref: B,
|
|
919
|
+
tabIndex: 0,
|
|
920
|
+
sx: {
|
|
921
|
+
outline: "none",
|
|
922
|
+
position: "relative"
|
|
923
|
+
},
|
|
924
|
+
onKeyDown: (e) => {
|
|
925
|
+
e.which === re.Escape && (Ge(), Le.current?.start(e, { center: !1 }), setTimeout(() => Le.current?.stop(e), 180)), e.stopPropagation();
|
|
926
|
+
},
|
|
927
|
+
children: v(gt, {
|
|
928
|
+
ref: nt,
|
|
929
|
+
className: Ce({ "Mui-focusVisible": Ke }, he, "draggable", ae),
|
|
930
|
+
sx: {
|
|
931
|
+
pointerEvents: "auto",
|
|
932
|
+
userSelect: "none",
|
|
933
|
+
backgroundColor: "var(--sxl-color-elevated, var(--sxl-color-base-100))",
|
|
934
|
+
border: "1px solid var(--sxl-color-elevated-border, transparent)",
|
|
935
|
+
"&:hover:not([disabled]):not(.Mui-focusVisible)": { outline: (e) => `solid ${A(e.palette.text?.primary, .2)} 1px` },
|
|
936
|
+
"&.Mui-focusVisible": { outline: (e) => `solid ${A(e.palette.text?.primary, .2)} 1px` },
|
|
937
|
+
position: "absolute",
|
|
938
|
+
maxWidth: "100%",
|
|
939
|
+
...pe
|
|
940
|
+
},
|
|
941
|
+
defaultPosition: Me,
|
|
942
|
+
titleSize: Ve,
|
|
943
|
+
rootSize: ze,
|
|
944
|
+
PaperComponent: Oe,
|
|
945
|
+
...we,
|
|
946
|
+
...je,
|
|
947
|
+
children: [f ? _(s, {
|
|
948
|
+
className: Ce({ "Mui-selected": Ke }, "draggable-title"),
|
|
949
|
+
sx: {
|
|
950
|
+
cursor: "move",
|
|
951
|
+
display: "flex",
|
|
952
|
+
color: (e) => e.palette.text.secondary,
|
|
953
|
+
boxSizing: "border-box",
|
|
954
|
+
padding: "0 0",
|
|
955
|
+
transitionProperty: "opacity",
|
|
956
|
+
transitionDuration: (e) => `${e.transitions.duration.shortest}ms`,
|
|
957
|
+
opacity: .7,
|
|
958
|
+
"&.Mui-selected": {
|
|
959
|
+
opacity: 1,
|
|
960
|
+
transitionDuration: (e) => e.transitions.duration.shortest / 2 + "ms"
|
|
961
|
+
},
|
|
962
|
+
backgroundColor: (e) => A(e.palette.action.hover, .03)
|
|
963
|
+
},
|
|
964
|
+
ref: Be,
|
|
965
|
+
children: v(t, {
|
|
966
|
+
sx: {
|
|
967
|
+
display: "flex",
|
|
968
|
+
flex: "1 1 10%",
|
|
969
|
+
flexDirection: "row",
|
|
970
|
+
alignItems: "center",
|
|
971
|
+
marginTop: (e) => e.spacing(.25),
|
|
972
|
+
marginBottom: (e) => e.spacing(.25),
|
|
973
|
+
marginLeft: (e) => e.spacing(1),
|
|
974
|
+
marginRight: (e) => e.spacing(1)
|
|
975
|
+
},
|
|
976
|
+
children: [_(t, {
|
|
977
|
+
sx: {
|
|
978
|
+
flex: "1 1 100%",
|
|
979
|
+
paddingLeft: (e) => e.spacing(1)
|
|
980
|
+
},
|
|
981
|
+
children: f
|
|
982
|
+
}), _(Ae, {
|
|
983
|
+
label: o("window.close"),
|
|
984
|
+
children: _(l, {
|
|
985
|
+
"aria-label": "close",
|
|
986
|
+
sx: { color: (e) => e.palette.text.icon ?? e.palette.action.active },
|
|
987
|
+
touchRippleRef: Le,
|
|
988
|
+
onPointerDown: (e) => {
|
|
989
|
+
Le.current?.start(e, { center: !1 }), e.stopPropagation(), e.preventDefault();
|
|
990
|
+
},
|
|
991
|
+
onPointerUp: Ge,
|
|
992
|
+
children: _(ne, { iconKey: "Close" })
|
|
993
|
+
})
|
|
994
|
+
})]
|
|
995
|
+
})
|
|
996
|
+
}) : null, j]
|
|
997
|
+
})
|
|
998
|
+
})
|
|
999
|
+
})
|
|
1000
|
+
}), it = null;
|
|
1001
|
+
_e && !ve && (it = _(De, {
|
|
1002
|
+
...ke,
|
|
1003
|
+
open: Pe,
|
|
1004
|
+
onMouseDown: (e) => {
|
|
1005
|
+
Ge(), ke?.onMouseDown?.(e);
|
|
1006
|
+
},
|
|
1007
|
+
onClick: (e) => {
|
|
1008
|
+
C?.(e, "backdropClick"), ke?.onClick?.(e);
|
|
1009
|
+
},
|
|
1010
|
+
sx: {
|
|
1011
|
+
pointerEvents: "auto",
|
|
1012
|
+
...ke?.sx
|
|
1013
|
+
}
|
|
1014
|
+
}));
|
|
1015
|
+
let { getPortalContainer: at } = ce(), { className: ot, attrs: st } = F(se()?.themeScope), ct = Ee([
|
|
1016
|
+
$e,
|
|
1017
|
+
Re,
|
|
1018
|
+
z
|
|
1019
|
+
]);
|
|
1020
|
+
return me(v(t, {
|
|
1021
|
+
className: Ce("MuiModal-root", ot),
|
|
1022
|
+
...st,
|
|
1023
|
+
sx: {
|
|
1024
|
+
position: "fixed",
|
|
1025
|
+
zIndex: fe("popup"),
|
|
1026
|
+
right: "0",
|
|
1027
|
+
bottom: "0",
|
|
1028
|
+
top: "0",
|
|
1029
|
+
left: "0",
|
|
1030
|
+
outline: "0",
|
|
1031
|
+
display: "block",
|
|
1032
|
+
pointerEvents: "none"
|
|
1033
|
+
},
|
|
1034
|
+
ref: ct,
|
|
1035
|
+
onPointerDown: (e) => {
|
|
1036
|
+
Ke && (e.target === B.current || e.target.tabIndex < 0) && B.current?.contains(document.activeElement);
|
|
1037
|
+
},
|
|
1038
|
+
onContextMenu: (e) => {
|
|
1039
|
+
e.isPropagationStopped() || e.preventDefault();
|
|
1040
|
+
},
|
|
1041
|
+
onFocus: (e) => {
|
|
1042
|
+
!Ke && (e.target === B.current || e.target.tabIndex < 0) && setTimeout(() => {
|
|
1043
|
+
Qe();
|
|
1044
|
+
}, 100), qe(!0), B.current?.contains(e.target) && e.target !== B.current && Ye(e.target), e.relatedTarget && !Xe && Ze(e.relatedTarget);
|
|
1045
|
+
},
|
|
1046
|
+
onBlur: (e) => {
|
|
1047
|
+
$e?.current?.contains(e.relatedTarget) || (Ze(null), qe(!1));
|
|
1048
|
+
},
|
|
1049
|
+
children: [it, rt]
|
|
1050
|
+
}), at(), Ue);
|
|
1051
|
+
})), V = typeof window < "u" ? window : {
|
|
1052
|
+
screen: {},
|
|
1053
|
+
navigator: {}
|
|
1054
|
+
}, yt = (V.matchMedia || function() {
|
|
1055
|
+
return { matches: !1 };
|
|
1056
|
+
}).bind(V), bt = { get passive() {
|
|
1057
|
+
return !0;
|
|
1058
|
+
} }, xt = function() {};
|
|
1059
|
+
V.addEventListener && V.addEventListener("p", xt, bt), V.removeEventListener && V.removeEventListener("p", xt, !1);
|
|
1060
|
+
var St = "ontouchstart" in V, Ct = St || "TouchEvent" in V && yt("(any-pointer: coarse)").matches, wt = (V.navigator.maxTouchPoints || 0) > 0 || Ct, Tt = V.navigator.userAgent || "", Et = yt("(pointer: coarse)").matches && /iPad|Macintosh/.test(Tt) && Math.min(V.screen.width || 0, V.screen.height || 0) >= 768, Dt = (yt("(pointer: coarse)").matches || !yt("(pointer: fine)").matches && St) && !/Windows.*Firefox/.test(Tt), Ot = yt("(any-pointer: fine)").matches || yt("(any-hover: hover)").matches || Et || !St, kt = !wt || !Ot && Dt ? wt ? "touchOnly" : "mouseOnly" : "hybrid", At = kt === "mouseOnly" ? "mouse" : kt === "touchOnly" || Dt ? "touch" : "mouse", jt = (e) => e.type === "checkbox", Mt = (e) => e.type === "file", Nt = (e) => e instanceof Date, H = (e) => e == null, Pt = (e) => typeof e == "object", U = (e) => !H(e) && !Array.isArray(e) && Pt(e) && !Nt(e), Ft = /[.[\]'"]/, It = (e) => e.split(Ft).filter(Boolean), Lt = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
|
|
1061
|
+
function W(e) {
|
|
1062
|
+
if (typeof e != "object" || !e) return e;
|
|
1063
|
+
if (e instanceof Date) return new Date(e);
|
|
1064
|
+
let t = typeof Blob < "u" && e instanceof Blob, n = typeof FileList < "u" && e instanceof FileList;
|
|
1065
|
+
if (Lt && (t || n)) return e;
|
|
1066
|
+
let r = Array.isArray(e), i = Object.getPrototypeOf(e);
|
|
1067
|
+
if (!r && i && i.constructor !== Object) return e;
|
|
1068
|
+
let a = r ? Array(e.length) : Object.create(i);
|
|
1069
|
+
for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (a[t] = W(e[t]));
|
|
1070
|
+
return a;
|
|
1071
|
+
}
|
|
1072
|
+
var Rt = "blur", zt = "focusout", Bt = "submit", Vt = "trigger", Ht = "valid", Ut = "onBlur", Wt = "onChange", Gt = "onSubmit", Kt = "onTouched", qt = "all", Jt = "max", Yt = "min", Xt = "maxLength", Zt = "minLength", Qt = "pattern", $t = "required", en = "validate", tn = [
|
|
1073
|
+
$t,
|
|
1074
|
+
Yt,
|
|
1075
|
+
Jt,
|
|
1076
|
+
Zt,
|
|
1077
|
+
Xt,
|
|
1078
|
+
Qt,
|
|
1079
|
+
en
|
|
1080
|
+
], nn = "form", rn = "root", an = [
|
|
1081
|
+
"__proto__",
|
|
1082
|
+
"constructor",
|
|
1083
|
+
"prototype"
|
|
1084
|
+
], on = /^\w*$/, sn = (e) => on.test(e), G = (e) => e === void 0, K = (e, t, n) => {
|
|
1085
|
+
if (!t || !U(e)) return n;
|
|
1086
|
+
let r = sn(t) ? [t] : It(t);
|
|
1087
|
+
if (r.some((e) => an.includes(e))) return n;
|
|
1088
|
+
let i = r.reduce((e, t) => H(e) ? void 0 : e[t], e);
|
|
1089
|
+
return G(i) || i === e ? G(e[t]) ? n : e[t] : i;
|
|
1090
|
+
}, q = (e) => typeof e == "boolean", J = (e) => typeof e == "function", Y = (e, t, n) => {
|
|
1091
|
+
let r = -1, i = sn(t) ? [t] : It(t), a = i.length, o = a - 1;
|
|
1092
|
+
for (; ++r < a;) {
|
|
1093
|
+
let t = i[r], a = n;
|
|
1094
|
+
if (r !== o) {
|
|
1095
|
+
let n = e[t];
|
|
1096
|
+
a = U(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
|
|
1097
|
+
}
|
|
1098
|
+
if (an.includes(t)) return;
|
|
1099
|
+
e[t] = a, e = e[t];
|
|
1100
|
+
}
|
|
1101
|
+
}, cn = b.createContext(null);
|
|
1102
|
+
cn.displayName = "HookFormControlContext";
|
|
1103
|
+
var ln = Lt ? b.useLayoutEffect : b.useEffect, un = (e) => H(e) || !Pt(e), dn = (e, t) => t.length === 0 && !Array.isArray(e) && Object.getPrototypeOf(e) !== null && !((e) => {
|
|
1104
|
+
let t = e.constructor && e.constructor.prototype;
|
|
1105
|
+
return U(t) && t.hasOwnProperty("isPrototypeOf");
|
|
1106
|
+
})(e);
|
|
1107
|
+
function X(e, t, n = !1, r = /* @__PURE__ */ new WeakMap()) {
|
|
1108
|
+
if (e === t) return !0;
|
|
1109
|
+
if (un(e) || un(t)) return Object.is(e, t);
|
|
1110
|
+
if (Nt(e) && Nt(t)) return Object.is(e.getTime(), t.getTime());
|
|
1111
|
+
if (Array.isArray(e) && Array.isArray(t) && e.length !== t.length) return !1;
|
|
1112
|
+
let i = Object.keys(e), a = Object.keys(t);
|
|
1113
|
+
if (i.length !== a.length) return !1;
|
|
1114
|
+
if (dn(e, i) || dn(t, a)) return Object.is(e, t);
|
|
1115
|
+
if (!i.length && Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
1116
|
+
let o = r.get(e);
|
|
1117
|
+
if (o && o.has(t)) return !0;
|
|
1118
|
+
if (o) o.add(t);
|
|
1119
|
+
else {
|
|
1120
|
+
let n = /* @__PURE__ */ new WeakSet();
|
|
1121
|
+
n.add(t), r.set(e, n);
|
|
1122
|
+
}
|
|
1123
|
+
for (let a of i) {
|
|
1124
|
+
let i = e[a];
|
|
1125
|
+
if (!Object.prototype.hasOwnProperty.call(t, a)) return !1;
|
|
1126
|
+
if (!n || a !== "ref") {
|
|
1127
|
+
let e = t[a];
|
|
1128
|
+
if (Nt(i) && Nt(e) || (U(i) || Array.isArray(i)) && (U(e) || Array.isArray(e)) ? !X(i, e, n, r) : !Object.is(i, e)) return !1;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
return !0;
|
|
1132
|
+
}
|
|
1133
|
+
var Z = (e) => typeof e == "string", fn = (e) => ({
|
|
1134
|
+
isOnSubmit: !e || e === Gt,
|
|
1135
|
+
isOnBlur: e === Ut,
|
|
1136
|
+
isOnChange: e === Wt,
|
|
1137
|
+
isOnAll: e === qt,
|
|
1138
|
+
isOnTouch: e === Kt
|
|
1139
|
+
}), pn = (e, t, n) => {
|
|
1140
|
+
if (n) return !1;
|
|
1141
|
+
if (t.watchAll || t.watch.has(e)) return !0;
|
|
1142
|
+
for (let n of t.watch) if (e.startsWith(n) && e.charAt(n.length) === ".") return !0;
|
|
1143
|
+
return !1;
|
|
1144
|
+
}, mn = (e, t, n) => {
|
|
1145
|
+
for (let r of n || Object.keys(e)) {
|
|
1146
|
+
if (r === "_f") continue;
|
|
1147
|
+
let i = n ? K(e, r) : e[r];
|
|
1148
|
+
if (i) {
|
|
1149
|
+
let { _f: e } = i;
|
|
1150
|
+
if (e) {
|
|
1151
|
+
if (e.refs && e.refs[0] && t(e.refs[0], e.name) || e.ref && t(e.ref, e.name) || mn(i, t)) return !0;
|
|
1152
|
+
} else if ((U(i) || Array.isArray(i)) && mn(i, t)) return !0;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}, hn = (e, t, n) => {
|
|
1156
|
+
let r = K(e, n), i = Array.isArray(r) ? r : [];
|
|
1157
|
+
return Y(i, rn, t[n]), Y(e, n, i), e;
|
|
1158
|
+
}, Q = (e) => U(e) && !Object.keys(e).length, gn = (e) => {
|
|
1159
|
+
if (!Lt) return !1;
|
|
1160
|
+
let t = e ? e.ownerDocument : 0;
|
|
1161
|
+
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
1162
|
+
}, _n = (e) => e.type === "radio", vn = (e) => e instanceof RegExp, yn = (e, t, n, r, i) => t ? {
|
|
1163
|
+
...n[e],
|
|
1164
|
+
types: {
|
|
1165
|
+
...n[e] && n[e].types ? n[e].types : {},
|
|
1166
|
+
[r]: i || !0
|
|
1167
|
+
}
|
|
1168
|
+
} : {}, bn = {
|
|
1169
|
+
value: !1,
|
|
1170
|
+
isValid: !1
|
|
1171
|
+
}, xn = {
|
|
1172
|
+
value: !0,
|
|
1173
|
+
isValid: !0
|
|
1174
|
+
}, Sn = (e) => {
|
|
1175
|
+
if (!Array.isArray(e)) return bn;
|
|
1176
|
+
if (e.length > 1) {
|
|
1177
|
+
let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
1178
|
+
return {
|
|
1179
|
+
value: t,
|
|
1180
|
+
isValid: !!t.length
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
let t = e[0];
|
|
1184
|
+
return t && t.checked && !t.disabled ? t.attributes && "value" in t.attributes ? G(t.value) || t.value === "" ? xn : {
|
|
1185
|
+
value: t.value,
|
|
1186
|
+
isValid: !0
|
|
1187
|
+
} : xn : bn;
|
|
1188
|
+
}, Cn = {
|
|
1189
|
+
isValid: !1,
|
|
1190
|
+
value: null
|
|
1191
|
+
}, wn = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
|
|
1192
|
+
isValid: !0,
|
|
1193
|
+
value: t.value
|
|
1194
|
+
} : e, Cn) : Cn;
|
|
1195
|
+
function Tn(e, t, n = "validate") {
|
|
1196
|
+
if (Z(e) || Array.isArray(e) && e.length && e.every(Z) || q(e) && !e) return {
|
|
1197
|
+
type: n,
|
|
1198
|
+
message: Z(e) ? e : "",
|
|
1199
|
+
ref: t
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
var En = (e) => U(e) && !vn(e) ? e : {
|
|
1203
|
+
value: e,
|
|
1204
|
+
message: ""
|
|
1205
|
+
}, Dn = async (e, t, n, r, i, a) => {
|
|
1206
|
+
let { ref: o, refs: s, required: c, maxLength: l, minLength: u, min: d, max: f, pattern: p, validate: m, name: h, valueAsNumber: g, mount: _, _c: v } = e._f, y = K(n, h);
|
|
1207
|
+
if (!_ || t.has(h)) return {};
|
|
1208
|
+
let b = s ? s[0] : o, x = (e) => {
|
|
1209
|
+
if (i && b.reportValidity) {
|
|
1210
|
+
let t = q(e) ? "" : e || "";
|
|
1211
|
+
s ? s.forEach((e) => J(e.setCustomValidity) && e.setCustomValidity(t)) : b.setCustomValidity(t), b.reportValidity();
|
|
1212
|
+
}
|
|
1213
|
+
}, S = {}, C = !v && _n(o), w = !v && jt(o), ee = C || w, T = (g || Mt(o)) && G(o.value) && G(y) || gn(o) && o.value === "" && !v || y === "" || Array.isArray(y) && !y.length, E = yn.bind(null, h, r, S), D = (e, t, n, r = Xt, i = Zt) => {
|
|
1214
|
+
let a = e ? t : n;
|
|
1215
|
+
S[h] = {
|
|
1216
|
+
type: e ? r : i,
|
|
1217
|
+
message: a,
|
|
1218
|
+
ref: o,
|
|
1219
|
+
...E(e ? r : i, a)
|
|
1220
|
+
};
|
|
1221
|
+
};
|
|
1222
|
+
if (a ? !Array.isArray(y) || !y.length : c && (!ee && (T || H(y)) || q(y) && !y || w && !Sn(s).isValid || C && !wn(s).isValid)) {
|
|
1223
|
+
let { value: e, message: t } = Z(c) ? {
|
|
1224
|
+
value: !!c,
|
|
1225
|
+
message: c
|
|
1226
|
+
} : En(c);
|
|
1227
|
+
if (e && (S[h] = {
|
|
1228
|
+
type: $t,
|
|
1229
|
+
message: t,
|
|
1230
|
+
ref: b,
|
|
1231
|
+
...E($t, t)
|
|
1232
|
+
}, !r)) return x(t), S;
|
|
1233
|
+
}
|
|
1234
|
+
if (!(T || H(d) && H(f))) {
|
|
1235
|
+
let e, t, n = En(f), i = En(d);
|
|
1236
|
+
if (H(y) || Nt(y) || isNaN(y)) {
|
|
1237
|
+
let r = !v && o.valueAsDate || new Date(y), a = (e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + e), s = o.type == "time", c = o.type == "week";
|
|
1238
|
+
Z(n.value) && y && (e = s ? a(y) > a(n.value) : c ? y > n.value : r > new Date(n.value)), Z(i.value) && y && (t = s ? a(y) < a(i.value) : c ? y < i.value : r < new Date(i.value));
|
|
1239
|
+
} else {
|
|
1240
|
+
let r = !v && o.valueAsNumber || y && +y;
|
|
1241
|
+
H(n.value) || (e = r > n.value), H(i.value) || (t = r < i.value);
|
|
1242
|
+
}
|
|
1243
|
+
if ((e || t) && (D(!!e, n.message, i.message, Jt, Yt), !r)) return x(S[h].message), S;
|
|
1244
|
+
}
|
|
1245
|
+
if ((!H(l) || !H(u)) && !T && (Z(y) || a && Array.isArray(y))) {
|
|
1246
|
+
let e = En(l), t = En(u), n = !H(e.value) && y.length > +e.value, i = !H(t.value) && y.length < +t.value;
|
|
1247
|
+
if ((n || i) && (D(n, e.message, t.message), !r)) return x(S[h].message), S;
|
|
1248
|
+
}
|
|
1249
|
+
if (p && !T && Z(y)) {
|
|
1250
|
+
let { value: e, message: t } = En(p);
|
|
1251
|
+
if (vn(e) && !y.match(e) && (S[h] = {
|
|
1252
|
+
type: Qt,
|
|
1253
|
+
message: t,
|
|
1254
|
+
ref: o,
|
|
1255
|
+
...E(Qt, t)
|
|
1256
|
+
}, !r)) return x(t), S;
|
|
1257
|
+
}
|
|
1258
|
+
if (m) {
|
|
1259
|
+
if (J(m)) {
|
|
1260
|
+
let e = Tn(await m(y, n), b);
|
|
1261
|
+
if (e && (S[h] = {
|
|
1262
|
+
...e,
|
|
1263
|
+
...E(en, e.message)
|
|
1264
|
+
}, !r)) return x(e.message), S;
|
|
1265
|
+
} else if (U(m)) {
|
|
1266
|
+
let e = {};
|
|
1267
|
+
for (let t in m) {
|
|
1268
|
+
if (!Q(e) && !r) break;
|
|
1269
|
+
let i = Tn(await m[t](y, n), b, t);
|
|
1270
|
+
i && (e = {
|
|
1271
|
+
...i,
|
|
1272
|
+
...E(t, i.message)
|
|
1273
|
+
}, r || x(i.message), r && (S[h] = e));
|
|
1274
|
+
}
|
|
1275
|
+
if (!Q(e) && (S[h] = {
|
|
1276
|
+
ref: b,
|
|
1277
|
+
...e
|
|
1278
|
+
}, !r)) return S;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
let O = S[h];
|
|
1282
|
+
return x(!O || O.message), S;
|
|
1283
|
+
}, On = (e) => Array.isArray(e) ? e : [e], kn = (e) => Array.isArray(e) ? e.filter(Boolean) : [];
|
|
1284
|
+
function $(e, t) {
|
|
1285
|
+
if (Z(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
|
|
1286
|
+
let n = Array.isArray(t) ? t : sn(t) ? [t] : It(t);
|
|
1287
|
+
if (n.some((e) => an.includes(String(e)))) return e;
|
|
1288
|
+
let r = n.length === 1 ? e : function(e, t) {
|
|
1289
|
+
let n = t.length - 1, r = 0;
|
|
1290
|
+
for (; r < n;) {
|
|
1291
|
+
if (H(e)) {
|
|
1292
|
+
e = void 0;
|
|
1293
|
+
break;
|
|
1294
|
+
}
|
|
1295
|
+
e = e[t[r]], r++;
|
|
1296
|
+
}
|
|
1297
|
+
return e;
|
|
1298
|
+
}(e, n), i = n.length - 1, a = n[i];
|
|
1299
|
+
return r && delete r[a], i !== 0 && (U(r) && Q(r) || Array.isArray(r) && function(e) {
|
|
1300
|
+
for (let t in e) if (e.hasOwnProperty(t) && !G(e[t])) return !1;
|
|
1301
|
+
return !0;
|
|
1302
|
+
}(r)) && $(e, n.slice(0, -1)), e;
|
|
1303
|
+
}
|
|
1304
|
+
var An = () => {
|
|
1305
|
+
let e = /* @__PURE__ */ new Set(), t = 0;
|
|
1306
|
+
return {
|
|
1307
|
+
get observers() {
|
|
1308
|
+
return Array.from(e);
|
|
1309
|
+
},
|
|
1310
|
+
next: (n) => {
|
|
1311
|
+
let r = e;
|
|
1312
|
+
t++;
|
|
1313
|
+
for (let e of r) e.next && e.next(n);
|
|
1314
|
+
r === e && t--;
|
|
1315
|
+
},
|
|
1316
|
+
subscribe: (n) => (e.add(n), { unsubscribe: () => {
|
|
1317
|
+
t &&= (e = new Set(e), 0), e.delete(n);
|
|
1318
|
+
} }),
|
|
1319
|
+
unsubscribe: () => {
|
|
1320
|
+
e = /* @__PURE__ */ new Set(), t = 0;
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
};
|
|
1324
|
+
function jn(e, t) {
|
|
1325
|
+
let n = Array.isArray(e) ? [] : {};
|
|
1326
|
+
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
1327
|
+
let i = e[r], a = t[r];
|
|
1328
|
+
i && (U(i) || Array.isArray(i)) && a ? n[r] = jn(i, a) : e[r] && (n[r] = a);
|
|
1329
|
+
}
|
|
1330
|
+
return n;
|
|
1331
|
+
}
|
|
1332
|
+
var Mn = (e, t) => e !== null && Pt(e) && Object.prototype.hasOwnProperty.call(e, t), Nn = (e, t) => {
|
|
1333
|
+
if (!t) return !1;
|
|
1334
|
+
let n = e;
|
|
1335
|
+
for (let r of sn(t) ? [t] : It(t)) {
|
|
1336
|
+
if (!Mn(n, r)) return Mn(e, t);
|
|
1337
|
+
n = n[r];
|
|
1338
|
+
}
|
|
1339
|
+
return !0;
|
|
1340
|
+
}, Pn = (e) => e.type === "select-multiple", Fn = (e) => gn(e) && e.isConnected;
|
|
1341
|
+
function In(e) {
|
|
1342
|
+
return Array.isArray(e) || U(e);
|
|
1343
|
+
}
|
|
1344
|
+
function Ln(e, t, n = "", r = []) {
|
|
1345
|
+
for (let i in e) {
|
|
1346
|
+
let a = n ? `${n}.${i}` : i, o = e[i];
|
|
1347
|
+
In(o) && In(K(t, a)) ? Ln(o, t, a, r) : r.push(a);
|
|
1348
|
+
}
|
|
1349
|
+
return r;
|
|
1350
|
+
}
|
|
1351
|
+
function Rn(e) {
|
|
1352
|
+
return Array.isArray(e) || U(e) && !((e) => {
|
|
1353
|
+
for (let t in e) if (J(e[t])) return !0;
|
|
1354
|
+
return !1;
|
|
1355
|
+
})(e);
|
|
1356
|
+
}
|
|
1357
|
+
function zn(e) {
|
|
1358
|
+
return !(!e || !("_f" in e));
|
|
1359
|
+
}
|
|
1360
|
+
function Bn(e) {
|
|
1361
|
+
return Array.isArray(e) ? !e.some((e) => !G(e)) : !Object.keys(e).length;
|
|
1362
|
+
}
|
|
1363
|
+
function Vn(e, t) {
|
|
1364
|
+
Array.isArray(e) ? e[t] = void 0 : delete e[t];
|
|
1365
|
+
}
|
|
1366
|
+
function Hn(e, t = {}, n) {
|
|
1367
|
+
for (let r in e) {
|
|
1368
|
+
let i = e[r], a = n && n[r];
|
|
1369
|
+
!Rn(i) || Array.isArray(i) && zn(a) ? G(i) || (t[r] = !0) : (t[r] = Array.isArray(i) ? [] : {}, Hn(i, t[r], a), Bn(t[r]) && Vn(t, r));
|
|
1370
|
+
}
|
|
1371
|
+
return t;
|
|
1372
|
+
}
|
|
1373
|
+
function Un(e, t, n, r) {
|
|
1374
|
+
n ||= Hn(t, Array.isArray(H(t) ? e : t) ? [] : {}, r);
|
|
1375
|
+
for (let i in e) {
|
|
1376
|
+
let a = e[i], o = r && r[i];
|
|
1377
|
+
!Rn(a) || Array.isArray(a) && zn(o) ? X(a, H(t) ? void 0 : t[i]) ? Vn(n, i) : n[i] = !0 : (G(t) || un(n[i]) ? n[i] = Hn(a, Array.isArray(a) ? [] : {}, o) : Un(a, H(t) ? {} : t[i], n[i], o), Bn(n[i]) && Vn(n, i));
|
|
1378
|
+
}
|
|
1379
|
+
return n;
|
|
1380
|
+
}
|
|
1381
|
+
var Wn = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => G(e) ? e : t ? e === "" ? NaN : e && +e : n && Z(e) ? new Date(e) : r ? r(e) : e;
|
|
1382
|
+
function Gn(e) {
|
|
1383
|
+
let t = e.ref;
|
|
1384
|
+
return Mt(t) ? t.files : _n(t) ? wn(e.refs).value : Pn(t) ? [...t.selectedOptions].map(({ value: e }) => e) : jt(t) ? Sn(e.refs).value : Wn(t.value, e);
|
|
1385
|
+
}
|
|
1386
|
+
var Kn = (e) => G(e) ? e : vn(e) ? e.source : U(e) ? vn(e.value) ? e.value.source : e.value : e, qn = "AsyncFunction", Jn = (e) => {
|
|
1387
|
+
if (!e || !e.validate) return !1;
|
|
1388
|
+
if (J(e.validate)) return e.validate.constructor.name === qn;
|
|
1389
|
+
if (U(e.validate)) {
|
|
1390
|
+
for (let t in e.validate) if (e.validate[t].constructor.name === qn) return !0;
|
|
1391
|
+
}
|
|
1392
|
+
return !1;
|
|
1393
|
+
};
|
|
1394
|
+
function Yn(e, t, n) {
|
|
1395
|
+
let r = K(e, n);
|
|
1396
|
+
if (r && (r.type || r.message) || Array.isArray(r)) return {
|
|
1397
|
+
error: r,
|
|
1398
|
+
name: n
|
|
1399
|
+
};
|
|
1400
|
+
let i = n.split(".");
|
|
1401
|
+
for (; i.length;) {
|
|
1402
|
+
let r = i.join("."), a = K(t, r), o = K(e, r);
|
|
1403
|
+
if (a && !Array.isArray(a) && n !== r) return { name: n };
|
|
1404
|
+
if (o && o.type) return {
|
|
1405
|
+
name: r,
|
|
1406
|
+
error: o
|
|
1407
|
+
};
|
|
1408
|
+
if (o && o.root && o.root.type) return {
|
|
1409
|
+
name: `${r}.root`,
|
|
1410
|
+
error: o.root
|
|
1411
|
+
};
|
|
1412
|
+
i.pop();
|
|
1413
|
+
}
|
|
1414
|
+
return { name: n };
|
|
1415
|
+
}
|
|
1416
|
+
var Xn = (e, t, n) => n ? e === t || e.startsWith(t + ".") : e.startsWith(t) || t.startsWith(e), Zn = (e, t, n) => {
|
|
1417
|
+
if (!e || !t || e === t) return !0;
|
|
1418
|
+
if (!Array.isArray(e)) return Xn(e, t, n);
|
|
1419
|
+
for (let r of e) if (r && Xn(r, t, n)) return !0;
|
|
1420
|
+
return !1;
|
|
1421
|
+
}, Qn = {
|
|
1422
|
+
mode: Gt,
|
|
1423
|
+
reValidateMode: Wt,
|
|
1424
|
+
shouldFocusError: !0
|
|
1425
|
+
}, $n = {
|
|
1426
|
+
submitCount: 0,
|
|
1427
|
+
isDirty: !1,
|
|
1428
|
+
isReady: !1,
|
|
1429
|
+
isValidating: !1,
|
|
1430
|
+
isSubmitted: !1,
|
|
1431
|
+
isSubmitting: !1,
|
|
1432
|
+
isSubmitSuccessful: !1,
|
|
1433
|
+
isValid: !1,
|
|
1434
|
+
touchedFields: {},
|
|
1435
|
+
dirtyFields: {},
|
|
1436
|
+
validatingFields: {}
|
|
1437
|
+
};
|
|
1438
|
+
function er(e = {}) {
|
|
1439
|
+
let t = {
|
|
1440
|
+
...Qn,
|
|
1441
|
+
...e
|
|
1442
|
+
}, n = {
|
|
1443
|
+
...W($n),
|
|
1444
|
+
isLoading: J(t.defaultValues),
|
|
1445
|
+
errors: W(t.errors) || {},
|
|
1446
|
+
disabled: t.disabled || !1
|
|
1447
|
+
}, r = {}, i = (U(t.defaultValues) || U(t.values)) && W(t.defaultValues || t.values) || {}, a = t.shouldUnregister ? {} : W(i), o = {
|
|
1448
|
+
action: !1,
|
|
1449
|
+
actionArrayLengths: /* @__PURE__ */ new Map(),
|
|
1450
|
+
mount: !1,
|
|
1451
|
+
watch: !1,
|
|
1452
|
+
keepIsValid: !1
|
|
1453
|
+
}, s = !1, c = {
|
|
1454
|
+
mount: /* @__PURE__ */ new Set(),
|
|
1455
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
1456
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
1457
|
+
array: /* @__PURE__ */ new Set(),
|
|
1458
|
+
watch: /* @__PURE__ */ new Set(),
|
|
1459
|
+
registerName: /* @__PURE__ */ new Set()
|
|
1460
|
+
}, l = {}, u = {}, d = /* @__PURE__ */ new Set(), f = fn(t.mode), p = fn(t.reValidateMode), m = {
|
|
1461
|
+
isDirty: !1,
|
|
1462
|
+
dirtyFields: !1,
|
|
1463
|
+
validatingFields: !1,
|
|
1464
|
+
touchedFields: !1,
|
|
1465
|
+
isValidating: !1,
|
|
1466
|
+
isValid: !1,
|
|
1467
|
+
errors: !1
|
|
1468
|
+
}, h = { ...m }, g = {}, _ = (...e) => e.some((e) => h[e] || g[e]), v = (e) => {
|
|
1469
|
+
for (let t of d) if (Zn(t.name, e, t.exact)) return !0;
|
|
1470
|
+
return !1;
|
|
1471
|
+
}, y = {
|
|
1472
|
+
array: An(),
|
|
1473
|
+
state: An()
|
|
1474
|
+
}, b = 0, x = 0, S = 0, C = {}, w = t.criteriaMode === qt, ee = (e, t) => (n) => {
|
|
1475
|
+
clearTimeout(u[e]), u[e] = setTimeout(t, n);
|
|
1476
|
+
}, T = (e) => {
|
|
1477
|
+
clearTimeout(u[e]), delete u[e], delete l[e];
|
|
1478
|
+
}, E = (e) => {
|
|
1479
|
+
T(e);
|
|
1480
|
+
let t = `${e}.`;
|
|
1481
|
+
for (let e of Object.keys(l)) e.startsWith(t) && T(e);
|
|
1482
|
+
}, D = async (e) => {
|
|
1483
|
+
if (!o.keepIsValid && !t.disabled && (_("isValid") || e)) {
|
|
1484
|
+
let e = ++b, i;
|
|
1485
|
+
t.resolver ? (i = Q((await M()).errors), e === b && k()) : i = await N({
|
|
1486
|
+
fields: r,
|
|
1487
|
+
onlyCheckValid: !0,
|
|
1488
|
+
eventType: Ht
|
|
1489
|
+
}), e === b && i !== n.isValid && y.state.next({ isValid: i });
|
|
1490
|
+
}
|
|
1491
|
+
}, O = (e, t) => {
|
|
1492
|
+
let r = [...e];
|
|
1493
|
+
if (!r.some((e) => e && (t ? !0 !== K(n.validatingFields, e) : Nn(n.validatingFields, e)))) return;
|
|
1494
|
+
let i = W(n.validatingFields);
|
|
1495
|
+
for (let e of r) e && (t ? Y(i, e, !0) : $(i, e));
|
|
1496
|
+
X(n.validatingFields, i) || (n.validatingFields = i);
|
|
1497
|
+
}, k = (e, r) => {
|
|
1498
|
+
!t.disabled && _("isValidating", "validatingFields") && (O(e || c.mount, r), y.state.next({
|
|
1499
|
+
validatingFields: n.validatingFields,
|
|
1500
|
+
isValidating: !Q(n.validatingFields)
|
|
1501
|
+
}));
|
|
1502
|
+
}, A = () => {
|
|
1503
|
+
n.dirtyFields = Un(i, a, void 0, r);
|
|
1504
|
+
}, te = (e, t) => {
|
|
1505
|
+
Y(n.errors, e, t), n.errors = { ...n.errors }, y.state.next({ errors: n.errors });
|
|
1506
|
+
}, j = (e) => sn(e) ? [e] : It(e), ne = (e, l, u, d) => {
|
|
1507
|
+
let f = K(r, e);
|
|
1508
|
+
if (f) {
|
|
1509
|
+
if (((e) => {
|
|
1510
|
+
let t = j(e), n = a, r = i;
|
|
1511
|
+
for (let e = 0; e < t.length - 1; e++) {
|
|
1512
|
+
let i = t[e];
|
|
1513
|
+
if (n = H(n) ? n : n[i], r = H(r) ? r : r[i], n === null && r !== null) return !0;
|
|
1514
|
+
}
|
|
1515
|
+
return !1;
|
|
1516
|
+
})(e) || ((e) => {
|
|
1517
|
+
if (!o.actionArrayLengths.size) return !1;
|
|
1518
|
+
let t = j(e), n = a, r = "", i = -1, s = 0;
|
|
1519
|
+
for (let e = 0; e < t.length; e++) {
|
|
1520
|
+
if (H(n)) return !1;
|
|
1521
|
+
let a = t[e];
|
|
1522
|
+
if (r = r ? `${r}.${a}` : a, Array.isArray(n) && +a >= n.length) return i !== -1 && (e !== i || +a < s);
|
|
1523
|
+
if (o.actionArrayLengths.has(r) && (i = e + 1, s = o.actionArrayLengths.get(r)), n = n[a], G(n) && i !== -1 && e > i && +t[i] < s) return !0;
|
|
1524
|
+
}
|
|
1525
|
+
return !1;
|
|
1526
|
+
})(e)) return;
|
|
1527
|
+
let r = G(K(a, e)), p = K(a, e, G(u) ? K(i, e) : u), m = !!d && !n.isReady && ((e) => jt(e) ? e.checked !== e.defaultChecked : e.type === "select-one" || Pn(e) ? ((e) => {
|
|
1528
|
+
let t = [...e.options];
|
|
1529
|
+
return !e.multiple && e.size < 2 && !t.some((e) => e.defaultSelected) ? e.selectedIndex !== t.findIndex((e) => !e.disabled) : t.some((e) => e.selected !== e.defaultSelected);
|
|
1530
|
+
})(e) : !_n(e) && "defaultValue" in e && e.value !== e.defaultValue)(d);
|
|
1531
|
+
if (G(p) || d && d.defaultChecked || m || l) {
|
|
1532
|
+
let t = l ? p : Gn(f._f);
|
|
1533
|
+
G(t) && ((e) => {
|
|
1534
|
+
let t = a;
|
|
1535
|
+
for (let n of j(e)) {
|
|
1536
|
+
if (Array.isArray(t) && +n >= t.length) return !0;
|
|
1537
|
+
t &&= t[n];
|
|
1538
|
+
}
|
|
1539
|
+
return !1;
|
|
1540
|
+
})(e) || (_("dirtyFields") && !X(K(a, e), t) && (s = !0), Y(a, e, t), m && re(e, t));
|
|
1541
|
+
} else ae(e, p);
|
|
1542
|
+
o.mount && !o.action && (t.resolver && _("isValidating", "validatingFields") ? Promise.resolve().then(() => D()) : D(), r && n.isDirty && _("isDirty") && (P() || (n.isDirty = !1, y.state.next({ ...n }))), t.shouldUnregister && r && !G(K(a, e)) && pn(e, c) && (o.watch = !0));
|
|
1543
|
+
}
|
|
1544
|
+
}, re = (e, o, c, l, u) => {
|
|
1545
|
+
let d = !1, f = !1, p = { name: e };
|
|
1546
|
+
if (!t.disabled || !0 === l) {
|
|
1547
|
+
if (!c || l) {
|
|
1548
|
+
let t = X(K(i, e), o);
|
|
1549
|
+
if (_("isDirty") && (f = n.isDirty, n.isDirty = p.isDirty = !t || P(), d = f !== p.isDirty), f = !!K(n.dirtyFields, e), t) $(n.dirtyFields, e);
|
|
1550
|
+
else {
|
|
1551
|
+
let t = K(i, e), a = K(r, e), s = !!(a && a._f || !U(t) && !Array.isArray(t)) || Un(t, o, void 0, a);
|
|
1552
|
+
Y(n.dirtyFields, e, s);
|
|
1553
|
+
}
|
|
1554
|
+
let c = !1;
|
|
1555
|
+
if (s || t && (_("isDirty") ? n.isDirty : P())) {
|
|
1556
|
+
s = !1;
|
|
1557
|
+
let e = Un(i, a, void 0, r);
|
|
1558
|
+
X(n.dirtyFields, e) || (c = !0, ((e, t) => {
|
|
1559
|
+
for (let t in e) delete e[t];
|
|
1560
|
+
Object.assign(e, t);
|
|
1561
|
+
})(n.dirtyFields, e));
|
|
1562
|
+
}
|
|
1563
|
+
p.dirtyFields = n.dirtyFields, d ||= _("dirtyFields") && (c || f !== !t);
|
|
1564
|
+
}
|
|
1565
|
+
if (c) {
|
|
1566
|
+
let t = Nn(n.touchedFields, e) ? K(n.touchedFields, e) : void 0;
|
|
1567
|
+
t || (Y(n.touchedFields, e, c), p.touchedFields = n.touchedFields, d ||= _("touchedFields") && t !== c);
|
|
1568
|
+
}
|
|
1569
|
+
d && u && y.state.next(p);
|
|
1570
|
+
}
|
|
1571
|
+
return d ? p : {};
|
|
1572
|
+
}, M = async (e) => (k(e, !0), await t.resolver(a, t.context, ((e, t, n, r) => {
|
|
1573
|
+
let i = {};
|
|
1574
|
+
for (let n of e) {
|
|
1575
|
+
let e = K(t, n);
|
|
1576
|
+
e && Y(i, n, e._f);
|
|
1577
|
+
}
|
|
1578
|
+
return {
|
|
1579
|
+
criteriaMode: n,
|
|
1580
|
+
names: [...e],
|
|
1581
|
+
fields: i,
|
|
1582
|
+
shouldUseNativeValidation: r
|
|
1583
|
+
};
|
|
1584
|
+
})(e || c.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), ie = async ({ name: e, eventType: r }) => {
|
|
1585
|
+
if (t.validate) {
|
|
1586
|
+
let i = x, o = await t.validate({
|
|
1587
|
+
formValues: a,
|
|
1588
|
+
formState: n,
|
|
1589
|
+
name: e,
|
|
1590
|
+
eventType: r
|
|
1591
|
+
});
|
|
1592
|
+
if (i !== x) return !0;
|
|
1593
|
+
if (U(o)) {
|
|
1594
|
+
let e = !0;
|
|
1595
|
+
pe(nn);
|
|
1596
|
+
for (let t in o) {
|
|
1597
|
+
let n = o[t];
|
|
1598
|
+
n && (e = !1, me(`${nn}.${t}`, {
|
|
1599
|
+
message: Z(n.message) ? n.message : "",
|
|
1600
|
+
type: n.type || en
|
|
1601
|
+
}));
|
|
1602
|
+
}
|
|
1603
|
+
return e;
|
|
1604
|
+
}
|
|
1605
|
+
return Z(o) || !o ? (me(nn, {
|
|
1606
|
+
message: o || "",
|
|
1607
|
+
type: en
|
|
1608
|
+
}), !1) : (pe(nn), !0);
|
|
1609
|
+
}
|
|
1610
|
+
return !0;
|
|
1611
|
+
}, N = async ({ fields: e, onlyCheckValid: i, name: o, eventType: s, context: l = {
|
|
1612
|
+
valid: !0,
|
|
1613
|
+
runRootValidation: !1
|
|
1614
|
+
} }) => {
|
|
1615
|
+
let u = x;
|
|
1616
|
+
if (t.validate && !l.runRootValidation && (l.runRootValidation = !0, !await ie({
|
|
1617
|
+
name: o,
|
|
1618
|
+
eventType: s
|
|
1619
|
+
}) && (l.valid = !1, i))) return l.valid;
|
|
1620
|
+
for (let o in e) {
|
|
1621
|
+
let d = e[o];
|
|
1622
|
+
if (d) {
|
|
1623
|
+
let { _f: e, ...f } = d;
|
|
1624
|
+
if (e) {
|
|
1625
|
+
let o = c.array.has(e.name), s = d._f && Jn(d._f), f = _("isValidating", "validatingFields");
|
|
1626
|
+
s && f && k([e.name], !0);
|
|
1627
|
+
let p = S, m = await Dn(d, c.disabled, a, w, t.shouldUseNativeValidation && !i, o);
|
|
1628
|
+
if (u !== x) return l.valid;
|
|
1629
|
+
if (s && f && k([e.name]), !K(r, e.name) || C[e.name] > p) continue;
|
|
1630
|
+
if (m[e.name] && (l.valid = !1, i) || (i || (T(e.name), K(m, e.name) ? o ? hn(n.errors, m, e.name) : Y(n.errors, e.name, m[e.name]) : $(n.errors, e.name)), t.shouldUseNativeValidation && m[e.name])) break;
|
|
1631
|
+
}
|
|
1632
|
+
!Q(f) && await N({
|
|
1633
|
+
context: l,
|
|
1634
|
+
onlyCheckValid: i,
|
|
1635
|
+
fields: f,
|
|
1636
|
+
name: o,
|
|
1637
|
+
eventType: s
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
return l.valid;
|
|
1642
|
+
}, P = (e, t) => (e && !G(t) && Y(a, e, t), !X(o.mount ? a : i, i)), F = (e, t, n) => {
|
|
1643
|
+
let r = o.mount ? a : G(t) || !G(e) ? i : t;
|
|
1644
|
+
return ((e, t, n, r, i) => Z(e) ? (r && t.watch.add(e), K(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), K(n, e, K(i, e)))) : (r && (t.watchAll = !0), n))(e, c, G(e) ? { ...r } : r, n, t);
|
|
1645
|
+
}, ae = (e, t, n = {}, i = !1, o = !1, s = !1) => {
|
|
1646
|
+
let c = K(r, e), l = t;
|
|
1647
|
+
if (c) {
|
|
1648
|
+
let n = c._f;
|
|
1649
|
+
n && (!n.disabled && Y(a, e, Wn(t, n)), l = gn(n.ref) && H(t) ? "" : t, Pn(n.ref) ? [...n.ref.options].forEach((e) => e.selected = l.includes(e.value)) : n.refs ? jt(n.ref) ? n.refs.forEach((e) => {
|
|
1650
|
+
e.defaultChecked && e.disabled || (e.checked = Array.isArray(l) ? !!l.find((t) => t === e.value) : l === e.value || !!l);
|
|
1651
|
+
}) : n.refs.forEach((e) => e.checked = e.value === l) : Mt(n.ref) ? n.ref.value = "" : (n.ref.value = l, n.ref.type || o || s || y.state.next({
|
|
1652
|
+
name: e,
|
|
1653
|
+
values: i ? a : v(e) ? W(a) : void 0
|
|
1654
|
+
})));
|
|
1655
|
+
}
|
|
1656
|
+
(n.shouldDirty || n.shouldTouch) && re(e, c && c._f && !c._f.disabled && (c._f.valueAsNumber || c._f.valueAsDate || c._f.setValueAs) ? Wn(t, c._f) : l, n.shouldTouch, n.shouldDirty, !o), n.shouldValidate && de(e, { delayError: n.delayError }), n.shouldValidate && c && c._f && c._f.deps && (!Array.isArray(c._f.deps) || c._f.deps.length > 0) && de(c._f.deps);
|
|
1657
|
+
}, oe = (e, t, n, i = !1, o = !1, s = !1) => {
|
|
1658
|
+
for (let l in t) {
|
|
1659
|
+
if (!Object.prototype.hasOwnProperty.call(t, l)) continue;
|
|
1660
|
+
let u = t[l], d = e + "." + l, f = K(r, d);
|
|
1661
|
+
c.array.has(d) && y.array.next({
|
|
1662
|
+
name: d,
|
|
1663
|
+
values: i ? a : W(a)
|
|
1664
|
+
}), (c.array.has(e) || U(u) || f && !f._f) && !Nt(u) ? oe(d, u, n, i, o, s) : ae(d, u, n, i, o, s);
|
|
1665
|
+
}
|
|
1666
|
+
}, se = (e, t, i, s, l = !1) => {
|
|
1667
|
+
let u = K(r, e), d = c.array.has(e), f = s ? t : W(t), p = X(K(a, e), f);
|
|
1668
|
+
if (p || Y(a, e, f), d) y.array.next({
|
|
1669
|
+
name: e,
|
|
1670
|
+
values: s ? a : W(a)
|
|
1671
|
+
}), _("isDirty", "dirtyFields") && i.shouldDirty && (A(), n.isDirty = P(e, f), l || y.state.next({
|
|
1672
|
+
name: e,
|
|
1673
|
+
dirtyFields: n.dirtyFields,
|
|
1674
|
+
isDirty: n.isDirty
|
|
1675
|
+
})), i.shouldValidate && de(e, { delayError: i.delayError });
|
|
1676
|
+
else {
|
|
1677
|
+
let t = Array.isArray(f) && !f.length || Q(f), n = !p && !l;
|
|
1678
|
+
!u || u._f || H(f) || t ? ae(e, f, i, s, l, n) : oe(e, f, i, s, l, n);
|
|
1679
|
+
}
|
|
1680
|
+
if (!p && !l) {
|
|
1681
|
+
let t = pn(e, c), r = o.mount || t ? e : void 0, i = d ? [] : ((e, t) => {
|
|
1682
|
+
let n = t.split("."), r = [], i = n[0];
|
|
1683
|
+
for (let t = 1; t < n.length; i += "." + n[t++]) !isNaN(+n[t]) && e.has(i) && r.push(`${i}.${n[t]}`);
|
|
1684
|
+
return r;
|
|
1685
|
+
})(c.array, e), l = s ? a : v(r) || i.some(v) ? W(a) : void 0;
|
|
1686
|
+
y.state.next({
|
|
1687
|
+
...t && n,
|
|
1688
|
+
name: r,
|
|
1689
|
+
values: l
|
|
1690
|
+
});
|
|
1691
|
+
for (let e of i) y.state.next({
|
|
1692
|
+
name: e,
|
|
1693
|
+
values: l
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
}, ce = (e, t, n = {}) => se(e, t, n, !1), le = async (e) => {
|
|
1697
|
+
o.mount = !0;
|
|
1698
|
+
let i = e.target, s = i.name, u = !0, d = K(r, s), m = S, h = (e) => {
|
|
1699
|
+
u = !!K(r, s) && !(C[s] > m) && X(e, K(a, s, e));
|
|
1700
|
+
};
|
|
1701
|
+
if (d) {
|
|
1702
|
+
let m, g;
|
|
1703
|
+
o.keepIsValid = !1;
|
|
1704
|
+
let S = !1, C = i.type ? Gn(d._f) : ((e) => U(e) && e.target ? jt(e.target) ? e.target.checked : Mt(e.target) ? e.target.files : e.target.value : e)(e), E = e.type === Rt || e.type === zt, O = !(((e) => e.mount && (e.required || !G(e.required) && !1 !== e.required || !G(e.min) || !G(e.max) || !G(e.maxLength) || !G(e.minLength) || e.pattern || e.validate))(d._f) || t.validate || t.resolver || K(n.errors, s) || d._f.deps), A = O || ((e, t, n, r, i) => !i.isOnAll && (!n && i.isOnTouch ? !(t || e) : (n ? r.isOnBlur : i.isOnBlur) ? !e : !(n ? r.isOnChange : i.isOnChange) || e))(E, K(n.touchedFields, s), n.isSubmitted, p, f), j = pn(s, c, E);
|
|
1705
|
+
Y(a, s, W(C)), E ? i && i.readOnly || (d._f.onBlur && d._f.onBlur(e), Object.prototype.hasOwnProperty.call(l, s) && (S = !0, l[s](0))) : d._f.onChange && d._f.onChange(e);
|
|
1706
|
+
let ne = re(s, C, E), P = !Q(ne) || j;
|
|
1707
|
+
if (!E && y.state.next({
|
|
1708
|
+
name: s,
|
|
1709
|
+
type: e.type,
|
|
1710
|
+
...v(s) ? { values: W(a) } : {}
|
|
1711
|
+
}), A) return O && n.isValid || !_("isValid") || (t.mode === "onBlur" ? E && D() : E || D()), P && y.state.next({
|
|
1712
|
+
name: s,
|
|
1713
|
+
...j ? {} : ne
|
|
1714
|
+
});
|
|
1715
|
+
if (!t.resolver && t.validate && await ie({
|
|
1716
|
+
name: s,
|
|
1717
|
+
eventType: e.type
|
|
1718
|
+
}), !E && j && y.state.next({ ...n }), t.resolver) {
|
|
1719
|
+
let e = x, { errors: t } = await M([s]);
|
|
1720
|
+
if (e !== x) return;
|
|
1721
|
+
if (k([s]), h(C), !u) return void (!Q(ne) && y.state.next(ne));
|
|
1722
|
+
let i = Yn(n.errors, r, s), a = Yn(t, r, i.name || s);
|
|
1723
|
+
m = a.error, s = a.name, g = Q(t);
|
|
1724
|
+
} else {
|
|
1725
|
+
let n = x, i = ++b;
|
|
1726
|
+
if (k([s], !0), m = (await Dn(d, c.disabled, a, w, t.shouldUseNativeValidation))[s], n !== x) return;
|
|
1727
|
+
if (k([s]), h(C), u) {
|
|
1728
|
+
if (m) g = !1;
|
|
1729
|
+
else if (_("isValid")) {
|
|
1730
|
+
if (g = await N({
|
|
1731
|
+
fields: r,
|
|
1732
|
+
onlyCheckValid: !0,
|
|
1733
|
+
name: s,
|
|
1734
|
+
eventType: e.type
|
|
1735
|
+
}), n !== x) return;
|
|
1736
|
+
h(C), i !== b && (g = void 0);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
u && (d._f.deps && (!Array.isArray(d._f.deps) || d._f.deps.length > 0) && de(d._f.deps), ((e, r, i, a) => {
|
|
1741
|
+
let o = K(n.errors, e), s = _("isValid") && q(r) && n.isValid !== r;
|
|
1742
|
+
if (t.delayError && i ? (l[e] = ee(e, () => te(e, i)), l[e](t.delayError)) : (T(e), i ? Y(n.errors, e, i) : $(n.errors, e), n.errors = { ...n.errors }), (i ? !X(o, i, !0) : o) || !Q(a) || s) {
|
|
1743
|
+
let t = {
|
|
1744
|
+
...a,
|
|
1745
|
+
...s && q(r) ? { isValid: r } : {},
|
|
1746
|
+
errors: n.errors,
|
|
1747
|
+
name: e
|
|
1748
|
+
};
|
|
1749
|
+
y.state.next(t);
|
|
1750
|
+
}
|
|
1751
|
+
})(s, g, m, ne), S && Object.prototype.hasOwnProperty.call(l, s) && l[s](0));
|
|
1752
|
+
}
|
|
1753
|
+
}, ue = (e, t) => {
|
|
1754
|
+
if (K(n.errors, t) && e.focus) return e.focus(), 1;
|
|
1755
|
+
}, de = async (e, i = {}) => {
|
|
1756
|
+
let a, s;
|
|
1757
|
+
o.keepIsValid = !1;
|
|
1758
|
+
let u = On(e), d = x;
|
|
1759
|
+
if (t.resolver) {
|
|
1760
|
+
let t = await (async (e) => {
|
|
1761
|
+
let t = x, i = S, a = e ? e.filter((e) => K(r, e)) : [], { errors: o } = await M(e);
|
|
1762
|
+
if (t !== x) return o;
|
|
1763
|
+
if (k(e), e) {
|
|
1764
|
+
for (let t of e) {
|
|
1765
|
+
if (a.includes(t) && (!K(r, t) || C[t] > i)) {
|
|
1766
|
+
$(o, t);
|
|
1767
|
+
continue;
|
|
1768
|
+
}
|
|
1769
|
+
let e = K(o, t);
|
|
1770
|
+
E(t);
|
|
1771
|
+
let s = c.array.has(t) && U(e) && !Object.keys(e).some((e) => !Number.isNaN(Number(e))), l = K(r, t), u = U(l) && Object.keys(l).some((e) => e !== "_f");
|
|
1772
|
+
s ? hn(n.errors, { [t]: e }, t) : e && (e.type || e.message) || Array.isArray(e) || U(e) && u ? Y(n.errors, t, e) : $(n.errors, t);
|
|
1773
|
+
}
|
|
1774
|
+
n.errors = { ...n.errors };
|
|
1775
|
+
} else Object.keys(l).forEach(T), n.errors = o;
|
|
1776
|
+
return o;
|
|
1777
|
+
})(G(e) ? e : u);
|
|
1778
|
+
a = Q(t), s = e ? !u.some((e) => K(t, e)) : a;
|
|
1779
|
+
} else e ? (s = (await Promise.all(u.map(async (e) => {
|
|
1780
|
+
let t = K(r, e);
|
|
1781
|
+
return await N({
|
|
1782
|
+
fields: t && t._f ? { [e]: t } : t,
|
|
1783
|
+
eventType: Vt
|
|
1784
|
+
});
|
|
1785
|
+
}))).every(Boolean), (s || n.isValid) && D()) : s = a = await N({
|
|
1786
|
+
fields: r,
|
|
1787
|
+
name: e,
|
|
1788
|
+
eventType: Vt
|
|
1789
|
+
});
|
|
1790
|
+
if (d !== x) return s;
|
|
1791
|
+
if (i.delayError && t.delayError && Z(e)) {
|
|
1792
|
+
let r = K(n.errors, e);
|
|
1793
|
+
r ? ($(n.errors, e), l[e] = ee(e, () => te(e, r)), l[e](t.delayError)) : T(e);
|
|
1794
|
+
}
|
|
1795
|
+
if (i.shouldTouch) for (let t of e ? u : c.mount) !c.array.has(t) && Y(n.touchedFields, t, !0);
|
|
1796
|
+
return n.errors = { ...n.errors }, y.state.next({
|
|
1797
|
+
...!Z(e) || _("isValid") && a !== n.isValid ? {} : { name: e },
|
|
1798
|
+
...t.resolver || !e ? { isValid: a } : {},
|
|
1799
|
+
...i.shouldTouch && _("touchedFields") ? { touchedFields: n.touchedFields } : {},
|
|
1800
|
+
errors: n.errors
|
|
1801
|
+
}), i.shouldFocus && !s && mn(r, ue, e ? u : c.mount), s;
|
|
1802
|
+
}, fe = (e, t) => {
|
|
1803
|
+
let r = t || n, i = K(r.errors, e);
|
|
1804
|
+
return {
|
|
1805
|
+
invalid: !!i,
|
|
1806
|
+
isDirty: !!K(r.dirtyFields, e),
|
|
1807
|
+
error: i,
|
|
1808
|
+
isValidating: !!K(r.validatingFields, e),
|
|
1809
|
+
isTouched: !!K(r.touchedFields, e)
|
|
1810
|
+
};
|
|
1811
|
+
}, pe = (e) => {
|
|
1812
|
+
let t = e ? On(e) : void 0;
|
|
1813
|
+
t ? t.forEach((e) => {
|
|
1814
|
+
E(e), $(n.errors, e), n.errors = { ...n.errors }, y.state.next({
|
|
1815
|
+
name: e,
|
|
1816
|
+
errors: n.errors
|
|
1817
|
+
});
|
|
1818
|
+
}) : (Object.keys(l).forEach(T), n.errors = {}, y.state.next({ errors: n.errors }));
|
|
1819
|
+
}, me = (e, t, i) => {
|
|
1820
|
+
E(e);
|
|
1821
|
+
let a = K(r, e, { _f: {} }), o = a._f && a._f.ref, { ref: s, message: c, type: l, types: u, ...d } = K(n.errors, e) || {};
|
|
1822
|
+
Y(n.errors, e, {
|
|
1823
|
+
...d,
|
|
1824
|
+
...t,
|
|
1825
|
+
ref: o
|
|
1826
|
+
}), n.errors = { ...n.errors }, y.state.next({
|
|
1827
|
+
name: e,
|
|
1828
|
+
errors: n.errors,
|
|
1829
|
+
isValid: !1
|
|
1830
|
+
}), i && i.shouldFocus && o && o.focus && o.focus();
|
|
1831
|
+
}, he = (e) => {
|
|
1832
|
+
let t = {
|
|
1833
|
+
name: e.name,
|
|
1834
|
+
exact: e.exact
|
|
1835
|
+
};
|
|
1836
|
+
e.formState && e.formState.values && d.add(t);
|
|
1837
|
+
let { unsubscribe: r } = y.state.subscribe({ next: (t) => {
|
|
1838
|
+
if (Zn(e.name, t.name, e.exact) && ((e, t, n) => {
|
|
1839
|
+
let r = Object.keys(e).filter((e) => e !== "name");
|
|
1840
|
+
return !r.length || n && r.length >= Object.keys(t).length || r.find((e) => t[e] === (!n || qt));
|
|
1841
|
+
})(t, e.formState || h, e.reRenderRoot)) {
|
|
1842
|
+
let r = t.values || { ...a };
|
|
1843
|
+
e.callback({
|
|
1844
|
+
...n,
|
|
1845
|
+
...t,
|
|
1846
|
+
validatingFields: n.validatingFields,
|
|
1847
|
+
isValidating: n.isValidating,
|
|
1848
|
+
values: r,
|
|
1849
|
+
defaultValues: i
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
} });
|
|
1853
|
+
return () => {
|
|
1854
|
+
d.delete(t), r();
|
|
1855
|
+
};
|
|
1856
|
+
}, ge = (e, o = {}) => {
|
|
1857
|
+
let s = e ? On(e) : c.mount;
|
|
1858
|
+
o.keepIsValidating || O(s);
|
|
1859
|
+
for (let e of s) c.mount.delete(e), c.array.delete(e), c.disabled.delete(e), $(r, e), !o.keepValue && $(a, e), o.keepError || (E(e), $(n.errors, e)), !o.keepDirty && $(n.dirtyFields, e), !o.keepTouched && $(n.touchedFields, e), !t.shouldUnregister && !o.keepDefaultValue && $(i, e);
|
|
1860
|
+
o.keepError || (n.errors = { ...n.errors }), d.size && y.state.next({ values: W(a) }), y.state.next({
|
|
1861
|
+
...n,
|
|
1862
|
+
...o.keepDirty ? {} : { isDirty: P() },
|
|
1863
|
+
...o.keepIsValidating ? {} : { isValidating: !Q(n.validatingFields) }
|
|
1864
|
+
}), !o.keepIsValid && D();
|
|
1865
|
+
}, I = ({ disabled: e, name: t }) => {
|
|
1866
|
+
if (q(e) && o.mount || e || c.disabled.has(t)) {
|
|
1867
|
+
let n = c.disabled.has(t) !== !!e;
|
|
1868
|
+
e ? c.disabled.add(t) : c.disabled.delete(t), n && o.mount && !o.action && D();
|
|
1869
|
+
}
|
|
1870
|
+
}, _e = (e, n = {}) => {
|
|
1871
|
+
let a = K(r, e), s = q(n.disabled) || q(t.disabled), l = !c.registerName.has(e) && a && a._f && !a._f.mount;
|
|
1872
|
+
if (a && a._f || (C[e] = ++S), Y(r, e, {
|
|
1873
|
+
...a || {},
|
|
1874
|
+
_f: {
|
|
1875
|
+
...a && a._f ? a._f : { ref: { name: e } },
|
|
1876
|
+
name: e,
|
|
1877
|
+
mount: !0,
|
|
1878
|
+
...n
|
|
1879
|
+
}
|
|
1880
|
+
}), c.mount.add(e), a && a._f) {
|
|
1881
|
+
let t = K(r, e);
|
|
1882
|
+
for (let e of tn) e in n || delete t._f[e];
|
|
1883
|
+
}
|
|
1884
|
+
return a && !l ? I({
|
|
1885
|
+
disabled: q(n.disabled) ? n.disabled : t.disabled,
|
|
1886
|
+
name: e
|
|
1887
|
+
}) : ne(e, !0, n.value), {
|
|
1888
|
+
...s ? { disabled: n.disabled || t.disabled } : {},
|
|
1889
|
+
...t.progressive ? {
|
|
1890
|
+
required: !!Kn(n.required),
|
|
1891
|
+
min: Kn(n.min),
|
|
1892
|
+
max: Kn(n.max),
|
|
1893
|
+
minLength: Kn(n.minLength),
|
|
1894
|
+
maxLength: Kn(n.maxLength),
|
|
1895
|
+
pattern: Kn(n.pattern)
|
|
1896
|
+
} : {},
|
|
1897
|
+
name: e,
|
|
1898
|
+
onChange: le,
|
|
1899
|
+
onBlur: le,
|
|
1900
|
+
ref: (s) => {
|
|
1901
|
+
if (s) {
|
|
1902
|
+
c.registerName.add(e), _e(e, n), c.registerName.delete(e), a = K(r, e);
|
|
1903
|
+
let t = G(s.value) && s.querySelectorAll && s.querySelectorAll("input,select,textarea")[0] || s, o = ((e) => _n(e) || jt(e))(t), l = a._f.refs || [];
|
|
1904
|
+
if (o ? l.find((e) => e === t) : t === a._f.ref) return;
|
|
1905
|
+
let u = { ...a._f };
|
|
1906
|
+
o ? (u.refs = [
|
|
1907
|
+
...l.filter(Fn),
|
|
1908
|
+
t,
|
|
1909
|
+
...Array.isArray(K(i, e)) ? [{}] : []
|
|
1910
|
+
], u.ref = {
|
|
1911
|
+
type: t.type,
|
|
1912
|
+
name: e
|
|
1913
|
+
}) : (u.ref = t, delete u.refs), Y(r, e, { _f: u }), ne(e, !1, void 0, t);
|
|
1914
|
+
} else a = K(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && (!((e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))))(c.array, e) || !o.action) && c.unMount.add(e);
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
}, ve = () => t.shouldFocusError && !t.shouldUseNativeValidation && mn(r, ue, c.mount), ye = (e, i) => async (o) => {
|
|
1918
|
+
let s, u;
|
|
1919
|
+
o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
|
|
1920
|
+
let d = W(a);
|
|
1921
|
+
y.state.next({ isSubmitting: !0 });
|
|
1922
|
+
let f = x, p = (e) => {
|
|
1923
|
+
throw f === x && y.state.next({ isSubmitting: !1 }), e;
|
|
1924
|
+
};
|
|
1925
|
+
if (t.resolver) {
|
|
1926
|
+
let e;
|
|
1927
|
+
try {
|
|
1928
|
+
e = await M();
|
|
1929
|
+
} catch (e) {
|
|
1930
|
+
p(e);
|
|
1931
|
+
}
|
|
1932
|
+
let { errors: t, values: r } = e;
|
|
1933
|
+
if (f !== x) return;
|
|
1934
|
+
k(), Object.keys(l).forEach(T), n.errors = t, d = W(r);
|
|
1935
|
+
} else {
|
|
1936
|
+
try {
|
|
1937
|
+
await N({
|
|
1938
|
+
fields: r,
|
|
1939
|
+
eventType: Bt
|
|
1940
|
+
});
|
|
1941
|
+
} catch (e) {
|
|
1942
|
+
p(e);
|
|
1943
|
+
}
|
|
1944
|
+
if (f !== x) return;
|
|
1945
|
+
$(n.errors, rn), n.errors = { ...n.errors };
|
|
1946
|
+
}
|
|
1947
|
+
if (c.disabled.size) for (let e of c.disabled) $(d, e);
|
|
1948
|
+
if (Q(n.errors)) {
|
|
1949
|
+
y.state.next({ errors: {} });
|
|
1950
|
+
try {
|
|
1951
|
+
s = await e(d, o);
|
|
1952
|
+
} catch (e) {
|
|
1953
|
+
u = e;
|
|
1954
|
+
}
|
|
1955
|
+
} else {
|
|
1956
|
+
if (i) try {
|
|
1957
|
+
await i({ ...n.errors }, o);
|
|
1958
|
+
} catch (e) {
|
|
1959
|
+
p(e);
|
|
1960
|
+
}
|
|
1961
|
+
ve(), setTimeout(ve);
|
|
1962
|
+
}
|
|
1963
|
+
if (y.state.next({
|
|
1964
|
+
isSubmitted: !0,
|
|
1965
|
+
isSubmitting: !1,
|
|
1966
|
+
isSubmitSuccessful: Q(n.errors) && !u,
|
|
1967
|
+
submitCount: n.submitCount + 1,
|
|
1968
|
+
errors: n.errors
|
|
1969
|
+
}), u) throw u;
|
|
1970
|
+
return s;
|
|
1971
|
+
}, be = (e, u = {}) => {
|
|
1972
|
+
x++, b++;
|
|
1973
|
+
let d = e ? W(e) : i, f = W(d), p = Q(e), m = f, g = r;
|
|
1974
|
+
if (Object.keys(l).forEach(T), u.keepDefaultValues || (i = d), !u.keepValues) {
|
|
1975
|
+
if (u.keepDirtyValues) {
|
|
1976
|
+
let e = /* @__PURE__ */ new Set([...c.mount, ...Ln(Un(i, a, void 0, g), n.dirtyFields)]);
|
|
1977
|
+
for (let t of e) {
|
|
1978
|
+
let e = K(n.dirtyFields, t), r = K(a, t), i = K(m, t);
|
|
1979
|
+
e && !G(r) ? Y(m, t, r) : e || G(i) || ce(t, i);
|
|
1980
|
+
}
|
|
1981
|
+
} else {
|
|
1982
|
+
if (Lt && G(e)) for (let e of c.mount) {
|
|
1983
|
+
let t = K(r, e);
|
|
1984
|
+
if (t && t._f) {
|
|
1985
|
+
let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
|
|
1986
|
+
if (gn(e)) {
|
|
1987
|
+
let t = e.closest("form");
|
|
1988
|
+
if (t) {
|
|
1989
|
+
t.reset();
|
|
1990
|
+
break;
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
if (u.keepFieldsRef) for (let e of c.mount) ce(e, K(m, e));
|
|
1996
|
+
else r = {};
|
|
1997
|
+
}
|
|
1998
|
+
if (t.shouldUnregister) {
|
|
1999
|
+
if (a = u.keepDefaultValues ? W(i) : {}, u.keepFieldsRef) for (let e of c.mount) Y(a, e, K(m, e));
|
|
2000
|
+
} else a = W(m);
|
|
2001
|
+
y.array.next({ values: { ...m } }), y.state.next({
|
|
2002
|
+
name: void 0,
|
|
2003
|
+
type: void 0,
|
|
2004
|
+
values: { ...m }
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
c = {
|
|
2008
|
+
mount: u.keepDirtyValues ? c.mount : /* @__PURE__ */ new Set(),
|
|
2009
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
2010
|
+
array: /* @__PURE__ */ new Set(),
|
|
2011
|
+
registerName: /* @__PURE__ */ new Set(),
|
|
2012
|
+
disabled: u.keepValues || u.keepDirtyValues || u.keepFieldsRef ? new Set([...c.disabled].filter((e) => K(r, e))) : /* @__PURE__ */ new Set(),
|
|
2013
|
+
watch: /* @__PURE__ */ new Set(),
|
|
2014
|
+
watchAll: !1,
|
|
2015
|
+
focus: ""
|
|
2016
|
+
}, o.mount = !h.isValid || !!u.keepIsValid || !!u.keepDirtyValues || !t.shouldUnregister && !Q(m), o.watch = !!t.shouldUnregister, o.keepIsValid = !!u.keepIsValid, o.action = !1, o.actionArrayLengths.clear(), s = !1, u.keepErrors || (n.errors = {}), y.state.next({
|
|
2017
|
+
submitCount: u.keepSubmitCount ? n.submitCount : 0,
|
|
2018
|
+
isDirty: !p && (u.keepDirty ? n.isDirty : u.keepValues ? P() : !(!u.keepDefaultValues || !e || X(e, i))),
|
|
2019
|
+
isSubmitted: !!u.keepIsSubmitted && n.isSubmitted,
|
|
2020
|
+
dirtyFields: p ? {} : u.keepDirtyValues ? u.keepDefaultValues && a ? Un(i, a, void 0, g) : n.dirtyFields : u.keepDefaultValues && e ? Un(i, e, void 0, g) : u.keepDirty ? n.dirtyFields : u.keepValues ? Un(i, a, void 0, g) : {},
|
|
2021
|
+
touchedFields: u.keepTouched ? n.touchedFields : {},
|
|
2022
|
+
...u.keepIsValidating || !n.isValidating && Q(n.validatingFields) ? null : {
|
|
2023
|
+
validatingFields: {},
|
|
2024
|
+
isValidating: !1
|
|
2025
|
+
},
|
|
2026
|
+
errors: u.keepErrors ? n.errors : {},
|
|
2027
|
+
isSubmitSuccessful: !!u.keepIsSubmitSuccessful && n.isSubmitSuccessful,
|
|
2028
|
+
isSubmitting: !1,
|
|
2029
|
+
defaultValues: i
|
|
2030
|
+
});
|
|
2031
|
+
}, xe = (e, n) => be(J(e) ? e(a) : e, {
|
|
2032
|
+
...t.resetOptions,
|
|
2033
|
+
...n
|
|
2034
|
+
});
|
|
2035
|
+
y.state.subscribe({ next: (e) => {
|
|
2036
|
+
let { name: t, type: r, values: i, ...a } = e;
|
|
2037
|
+
Object.keys(a).length && (n = {
|
|
2038
|
+
...n,
|
|
2039
|
+
...a
|
|
2040
|
+
});
|
|
2041
|
+
} });
|
|
2042
|
+
let Se = {
|
|
2043
|
+
control: {
|
|
2044
|
+
register: _e,
|
|
2045
|
+
unregister: ge,
|
|
2046
|
+
getFieldState: fe,
|
|
2047
|
+
handleSubmit: ye,
|
|
2048
|
+
setError: me,
|
|
2049
|
+
_subscribe: he,
|
|
2050
|
+
_runSchema: M,
|
|
2051
|
+
_updateIsValidating: k,
|
|
2052
|
+
_focusError: ve,
|
|
2053
|
+
_getWatch: F,
|
|
2054
|
+
_getDirty: P,
|
|
2055
|
+
_setValid: D,
|
|
2056
|
+
_setFieldArray: (e, i = [], c, l, u = !0, d = !0) => {
|
|
2057
|
+
if (l && c && !t.disabled) {
|
|
2058
|
+
o.action = !0, o.keepIsValid = !1;
|
|
2059
|
+
let t = K(r, e), a = t && t._f, f = a ? Object.assign([], t) : t;
|
|
2060
|
+
if (o.actionArrayLengths.has(e) || o.actionArrayLengths.set(e, Array.isArray(f) ? f.length : 0), d && Array.isArray(f)) {
|
|
2061
|
+
let t = c(f, l.argA, l.argB) || f;
|
|
2062
|
+
a ? Y(r, e, {
|
|
2063
|
+
...t,
|
|
2064
|
+
_f: a
|
|
2065
|
+
}) : u && Y(r, e, t);
|
|
2066
|
+
}
|
|
2067
|
+
let p = K(n.errors, e);
|
|
2068
|
+
if (d && Array.isArray(p)) {
|
|
2069
|
+
let t = p.root, r = c(p, l.argA, l.argB) || p;
|
|
2070
|
+
t && (r.root = t), u && Y(n.errors, e, r), ((e, t) => {
|
|
2071
|
+
let n = K(e, t);
|
|
2072
|
+
!kn(n).length && (!n || !n.root) && $(e, t);
|
|
2073
|
+
})(n.errors, e), n.errors = { ...n.errors };
|
|
2074
|
+
}
|
|
2075
|
+
let m = K(n.touchedFields, e), h = d && Array.isArray(m);
|
|
2076
|
+
if (h) {
|
|
2077
|
+
let t = c(m, l.argA, l.argB);
|
|
2078
|
+
u && Y(n.touchedFields, e, t);
|
|
2079
|
+
}
|
|
2080
|
+
let g = K(n.dirtyFields, e);
|
|
2081
|
+
if (d && Array.isArray(g)) {
|
|
2082
|
+
let t = c(g, l.argA, l.argB) || g;
|
|
2083
|
+
u && Y(n.dirtyFields, e, t);
|
|
2084
|
+
}
|
|
2085
|
+
_("dirtyFields") ? A() : s = !0, y.state.next({
|
|
2086
|
+
name: e,
|
|
2087
|
+
isDirty: P(e, i),
|
|
2088
|
+
dirtyFields: n.dirtyFields,
|
|
2089
|
+
...h && { touchedFields: n.touchedFields },
|
|
2090
|
+
errors: n.errors,
|
|
2091
|
+
isValid: n.isValid
|
|
2092
|
+
});
|
|
2093
|
+
} else Y(a, e, i);
|
|
2094
|
+
},
|
|
2095
|
+
_setDisabledField: I,
|
|
2096
|
+
_setErrors: (e) => {
|
|
2097
|
+
Object.keys(l).forEach(T);
|
|
2098
|
+
let t = !Q(e);
|
|
2099
|
+
n.errors = W(e), y.state.next({
|
|
2100
|
+
errors: n.errors,
|
|
2101
|
+
...t ? { isValid: !1 } : {}
|
|
2102
|
+
}), !t && o.mount && D();
|
|
2103
|
+
},
|
|
2104
|
+
_getFieldArray: (e) => kn(K(o.mount ? a : i, e, t.shouldUnregister ? K(i, e, []) : [])),
|
|
2105
|
+
_reset: be,
|
|
2106
|
+
_resetDefaultValues: () => J(t.defaultValues) && t.defaultValues().then((e) => {
|
|
2107
|
+
xe(e, t.resetOptions), y.state.next({ isLoading: !1 });
|
|
2108
|
+
}),
|
|
2109
|
+
_removeUnmounted: () => {
|
|
2110
|
+
for (let e of c.unMount) {
|
|
2111
|
+
let t = K(r, e);
|
|
2112
|
+
t && (t._f.refs ? t._f.refs.every((e) => !Fn(e)) : !Fn(t._f.ref)) && ge(e);
|
|
2113
|
+
}
|
|
2114
|
+
c.unMount = /* @__PURE__ */ new Set();
|
|
2115
|
+
},
|
|
2116
|
+
_disableForm: (e) => {
|
|
2117
|
+
q(e) && (y.state.next({ disabled: e }), mn(r, (t, n) => {
|
|
2118
|
+
let i = K(r, n);
|
|
2119
|
+
i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
|
|
2120
|
+
t.disabled = i._f.disabled || e;
|
|
2121
|
+
}));
|
|
2122
|
+
}, 0));
|
|
2123
|
+
},
|
|
2124
|
+
_subjects: y,
|
|
2125
|
+
_proxyFormState: h,
|
|
2126
|
+
get _fields() {
|
|
2127
|
+
return r;
|
|
2128
|
+
},
|
|
2129
|
+
get _formValues() {
|
|
2130
|
+
return a;
|
|
2131
|
+
},
|
|
2132
|
+
get _state() {
|
|
2133
|
+
return o;
|
|
2134
|
+
},
|
|
2135
|
+
set _state(e) {
|
|
2136
|
+
o = e;
|
|
2137
|
+
},
|
|
2138
|
+
get _defaultValues() {
|
|
2139
|
+
return i;
|
|
2140
|
+
},
|
|
2141
|
+
get _names() {
|
|
2142
|
+
return c;
|
|
2143
|
+
},
|
|
2144
|
+
set _names(e) {
|
|
2145
|
+
c = e;
|
|
2146
|
+
},
|
|
2147
|
+
get _formState() {
|
|
2148
|
+
return n;
|
|
2149
|
+
},
|
|
2150
|
+
get _options() {
|
|
2151
|
+
return t;
|
|
2152
|
+
},
|
|
2153
|
+
set _options(e) {
|
|
2154
|
+
t = {
|
|
2155
|
+
...t,
|
|
2156
|
+
...e
|
|
2157
|
+
}, f = fn(t.mode), p = fn(t.reValidateMode), w = t.criteriaMode === qt;
|
|
2158
|
+
}
|
|
2159
|
+
},
|
|
2160
|
+
subscribe: (e) => {
|
|
2161
|
+
o.mount = !0;
|
|
2162
|
+
let t = Object.keys(e.formState || {}).filter((t) => e.formState && e.formState[t]);
|
|
2163
|
+
for (let e of t) g[e] = (g[e] || 0) + 1;
|
|
2164
|
+
let n = he({
|
|
2165
|
+
...e,
|
|
2166
|
+
formState: {
|
|
2167
|
+
...m,
|
|
2168
|
+
...e.formState
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
return () => {
|
|
2172
|
+
for (let e of t.splice(0)) g[e]--;
|
|
2173
|
+
n();
|
|
2174
|
+
};
|
|
2175
|
+
},
|
|
2176
|
+
trigger: de,
|
|
2177
|
+
register: _e,
|
|
2178
|
+
handleSubmit: ye,
|
|
2179
|
+
watch: (e, t) => {
|
|
2180
|
+
if (J(e)) {
|
|
2181
|
+
let n = {};
|
|
2182
|
+
d.add(n);
|
|
2183
|
+
let { unsubscribe: r } = y.state.subscribe({ next: (n) => "values" in n && e(n.values || F(void 0, t), n) });
|
|
2184
|
+
return { unsubscribe: () => {
|
|
2185
|
+
d.delete(n), r();
|
|
2186
|
+
} };
|
|
2187
|
+
}
|
|
2188
|
+
return F(e, t, !0);
|
|
2189
|
+
},
|
|
2190
|
+
setValue: ce,
|
|
2191
|
+
setValues: (e, t = {}) => {
|
|
2192
|
+
let r = J(e) ? e(a) : e;
|
|
2193
|
+
if (!X(a, r)) {
|
|
2194
|
+
a = {
|
|
2195
|
+
...a,
|
|
2196
|
+
...r
|
|
2197
|
+
};
|
|
2198
|
+
for (let e of /* @__PURE__ */ new Set([...c.mount, ...c.array])) Nn(r, e) && se(e, K(r, e), t, !0, !0);
|
|
2199
|
+
y.state.next({
|
|
2200
|
+
...n,
|
|
2201
|
+
name: void 0,
|
|
2202
|
+
type: void 0,
|
|
2203
|
+
...d.size ? { values: a } : {}
|
|
2204
|
+
}), t.shouldValidate && D();
|
|
2205
|
+
}
|
|
2206
|
+
},
|
|
2207
|
+
getValues: (e, t) => {
|
|
2208
|
+
let r = G(e) && !t ? { ...o.mount ? a : i } : o.mount ? a : i;
|
|
2209
|
+
return t && (r = jn(t.dirtyFields ? n.dirtyFields : n.touchedFields, r)), G(e) ? r : Z(e) ? K(r, e) : e.map((e) => K(r, e));
|
|
2210
|
+
},
|
|
2211
|
+
getErrors: (e) => G(e) ? { ...n.errors } : Z(e) ? K(n.errors, e) : e.map((e) => K(n.errors, e)),
|
|
2212
|
+
reset: xe,
|
|
2213
|
+
resetField: (e, t = {}) => {
|
|
2214
|
+
K(r, e) && (O([e]), G(t.defaultValue) ? ce(e, W(K(i, e))) : (ce(e, t.defaultValue), Y(i, e, W(t.defaultValue))), t.keepTouched || $(n.touchedFields, e), t.keepDirty || ($(n.dirtyFields, e), n.isDirty = G(t.defaultValue) ? P() : P(e, W(K(i, e)))), t.keepError || (E(e), $(n.errors, e), n.errors = { ...n.errors }, D()), y.state.next({
|
|
2215
|
+
...n,
|
|
2216
|
+
isValidating: !Q(n.validatingFields)
|
|
2217
|
+
}));
|
|
2218
|
+
},
|
|
2219
|
+
resetDefaultValues: (e, t = {}) => {
|
|
2220
|
+
if (i = W(e), !t.keepDirty) {
|
|
2221
|
+
let e = Un(i, a, void 0, r);
|
|
2222
|
+
n.dirtyFields = e, n.isDirty = !Q(e);
|
|
2223
|
+
}
|
|
2224
|
+
t.keepIsValid || D(), y.state.next({
|
|
2225
|
+
...n,
|
|
2226
|
+
defaultValues: i
|
|
2227
|
+
});
|
|
2228
|
+
},
|
|
2229
|
+
clearErrors: pe,
|
|
2230
|
+
unregister: ge,
|
|
2231
|
+
setError: me,
|
|
2232
|
+
setFocus: (e, t = {}) => {
|
|
2233
|
+
let n = K(r, e), i = n && n._f;
|
|
2234
|
+
if (i) {
|
|
2235
|
+
let e = i.refs ? i.refs[0] : i.ref;
|
|
2236
|
+
e.focus && setTimeout(() => {
|
|
2237
|
+
e.focus(), t.shouldSelect && J(e.select) && e.select();
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
},
|
|
2241
|
+
getFieldState: fe
|
|
2242
|
+
};
|
|
2243
|
+
return {
|
|
2244
|
+
...Se,
|
|
2245
|
+
formControl: Se
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
var tr = {
|
|
2249
|
+
mode: Qn.mode,
|
|
2250
|
+
reValidateMode: Qn.reValidateMode,
|
|
2251
|
+
shouldFocusError: Qn.shouldFocusError,
|
|
2252
|
+
resolver: void 0,
|
|
2253
|
+
criteriaMode: void 0,
|
|
2254
|
+
delayError: void 0,
|
|
2255
|
+
shouldUnregister: void 0,
|
|
2256
|
+
shouldUseNativeValidation: void 0,
|
|
2257
|
+
context: void 0,
|
|
2258
|
+
progressive: void 0,
|
|
2259
|
+
resetOptions: void 0
|
|
2260
|
+
};
|
|
2261
|
+
function nr(e = {}) {
|
|
2262
|
+
let t = b.useRef(void 0), n = b.useRef(void 0), r = b.useRef(e.formControl), i = b.useRef(!1), a = b.useRef(!!e.validate), o = b.useRef(!!e.errors), s = b.useRef(!1), [c, l] = b.useState(() => ({
|
|
2263
|
+
...W($n),
|
|
2264
|
+
isLoading: J(e.defaultValues),
|
|
2265
|
+
errors: e.errors || {},
|
|
2266
|
+
disabled: e.disabled || !1,
|
|
2267
|
+
defaultValues: J(e.defaultValues) ? void 0 : e.defaultValues
|
|
2268
|
+
}));
|
|
2269
|
+
if (!t.current || e.formControl && r.current !== e.formControl) {
|
|
2270
|
+
if (r.current = e.formControl, i.current = !1, e.formControl) t.current = {
|
|
2271
|
+
...e.formControl,
|
|
2272
|
+
formState: c
|
|
2273
|
+
}, e.defaultValues && !J(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
2274
|
+
else {
|
|
2275
|
+
let { formControl: n, ...r } = er(e);
|
|
2276
|
+
t.current = {
|
|
2277
|
+
...r,
|
|
2278
|
+
formState: c
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
let u = t.current.control, d = u._options, f = {};
|
|
2283
|
+
for (let t in tr) t in d && !(t in e) && (f[t] = tr[t]);
|
|
2284
|
+
i.current && !e.disabled && (f.disabled = !1), u._options = {
|
|
2285
|
+
...f,
|
|
2286
|
+
...e,
|
|
2287
|
+
validate: e.validate
|
|
2288
|
+
};
|
|
2289
|
+
let p = () => ({
|
|
2290
|
+
...u._formState,
|
|
2291
|
+
defaultValues: u._defaultValues
|
|
2292
|
+
}), { resyncIfNeeded: m, snapshot: h } = function(e) {
|
|
2293
|
+
let t = b.useRef(!1), n = b.useRef(!1), r = b.useRef(void 0), i = b.useRef(0);
|
|
2294
|
+
return i.current++, !n.current && e && (n.current = !0, r.current = W(e())), {
|
|
2295
|
+
resyncIfNeeded: b.useCallback((e, a, o) => {
|
|
2296
|
+
if (e && (t.current || n.current && i.current > 1)) {
|
|
2297
|
+
let e = a();
|
|
2298
|
+
X(r.current, e) || o(e);
|
|
2299
|
+
}
|
|
2300
|
+
t.current = !0;
|
|
2301
|
+
}, []),
|
|
2302
|
+
snapshot: b.useCallback((e, t) => {
|
|
2303
|
+
e && (r.current = W(t()));
|
|
2304
|
+
}, [])
|
|
2305
|
+
};
|
|
2306
|
+
}(p);
|
|
2307
|
+
return ln(() => {
|
|
2308
|
+
m(!0, p, l);
|
|
2309
|
+
let e = u._subscribe({
|
|
2310
|
+
formState: u._proxyFormState,
|
|
2311
|
+
callback: () => l({
|
|
2312
|
+
...u._formState,
|
|
2313
|
+
defaultValues: u._defaultValues
|
|
2314
|
+
}),
|
|
2315
|
+
reRenderRoot: !0
|
|
2316
|
+
});
|
|
2317
|
+
return l((e) => ({
|
|
2318
|
+
...e,
|
|
2319
|
+
isReady: !0
|
|
2320
|
+
})), u._formState.isReady = !0, u._subjects.state.next({ isReady: !0 }), () => {
|
|
2321
|
+
e(), h(!0, p);
|
|
2322
|
+
};
|
|
2323
|
+
}, [
|
|
2324
|
+
u,
|
|
2325
|
+
m,
|
|
2326
|
+
h
|
|
2327
|
+
]), b.useEffect(() => {
|
|
2328
|
+
u._disableForm(!(i.current && !e.disabled) && e.disabled), i.current = !!e.disabled;
|
|
2329
|
+
}, [u, e.disabled]), b.useEffect(() => {
|
|
2330
|
+
e.mode && (u._options.mode = e.mode), e.reValidateMode && (u._options.reValidateMode = e.reValidateMode);
|
|
2331
|
+
}, [
|
|
2332
|
+
u,
|
|
2333
|
+
e.mode,
|
|
2334
|
+
e.reValidateMode
|
|
2335
|
+
]), b.useEffect(() => {
|
|
2336
|
+
e.errors ? (u._setErrors(e.errors), u._focusError()) : o.current && u._setErrors({}), o.current = !!e.errors;
|
|
2337
|
+
}, [u, e.errors]), b.useEffect(() => {
|
|
2338
|
+
a.current && !e.validate && t.current && t.current.clearErrors(nn), a.current = !!e.validate;
|
|
2339
|
+
}, [e.validate]), b.useEffect(() => {
|
|
2340
|
+
e.shouldUnregister && u._subjects.state.next({ values: u._getWatch() });
|
|
2341
|
+
}, [u, e.shouldUnregister]), b.useEffect(() => {
|
|
2342
|
+
if (u._proxyFormState.isDirty) {
|
|
2343
|
+
let e = u._getDirty();
|
|
2344
|
+
e !== c.isDirty && u._subjects.state.next({ isDirty: e });
|
|
2345
|
+
}
|
|
2346
|
+
}, [u, c.isDirty]), b.useEffect(() => {
|
|
2347
|
+
e.values && !X(e.values, n.current) ? (u._reset(e.values, {
|
|
2348
|
+
keepFieldsRef: !0,
|
|
2349
|
+
...u._options.resetOptions
|
|
2350
|
+
}), u._options.resetOptions && u._options.resetOptions.keepIsValid || u._setValid(), n.current = e.values, l((e) => ({ ...e }))) : u._resetDefaultValues();
|
|
2351
|
+
}, [u, e.values]), b.useEffect(() => {
|
|
2352
|
+
u._state.mount && (s.current || e.values) || (u._setValid(), u._state.mount = !0), s.current = !0, u._state.watch && (u._state.watch = !1, u._subjects.state.next({ ...u._formState })), u._removeUnmounted();
|
|
2353
|
+
}), t.current.formState = b.useMemo(() => ((e, t, n, r = !0) => {
|
|
2354
|
+
let i = {};
|
|
2355
|
+
for (let a in e) Object.defineProperty(i, a, { get: () => {
|
|
2356
|
+
let i = a;
|
|
2357
|
+
return t._proxyFormState[i] !== qt && (t._proxyFormState[i] = !r || qt), n && (n[i] = !0), e[i];
|
|
2358
|
+
} });
|
|
2359
|
+
return i;
|
|
2360
|
+
})(c, u), [u, c]), t.current;
|
|
2361
|
+
}
|
|
2362
|
+
var rr = b.createContext(null);
|
|
2363
|
+
rr.displayName = "HookFormContext";
|
|
2364
|
+
var ir = ({ children: e, watch: t, getValues: n, getErrors: r, getFieldState: i, setError: a, clearErrors: o, setValue: s, setValues: c, trigger: l, formState: u, resetField: d, reset: f, resetDefaultValues: p, handleSubmit: m, unregister: h, control: g, register: _, setFocus: v, subscribe: y }) => {
|
|
2365
|
+
let x = b.useMemo(() => ({
|
|
2366
|
+
watch: t,
|
|
2367
|
+
getValues: n,
|
|
2368
|
+
getErrors: r,
|
|
2369
|
+
getFieldState: i,
|
|
2370
|
+
setError: a,
|
|
2371
|
+
clearErrors: o,
|
|
2372
|
+
setValue: s,
|
|
2373
|
+
setValues: c,
|
|
2374
|
+
trigger: l,
|
|
2375
|
+
formState: u,
|
|
2376
|
+
resetField: d,
|
|
2377
|
+
reset: f,
|
|
2378
|
+
resetDefaultValues: p,
|
|
2379
|
+
handleSubmit: m,
|
|
2380
|
+
unregister: h,
|
|
2381
|
+
control: g,
|
|
2382
|
+
register: _,
|
|
2383
|
+
setFocus: v,
|
|
2384
|
+
subscribe: y
|
|
2385
|
+
}), [
|
|
2386
|
+
o,
|
|
2387
|
+
g,
|
|
2388
|
+
u,
|
|
2389
|
+
r,
|
|
2390
|
+
i,
|
|
2391
|
+
n,
|
|
2392
|
+
m,
|
|
2393
|
+
_,
|
|
2394
|
+
f,
|
|
2395
|
+
p,
|
|
2396
|
+
d,
|
|
2397
|
+
a,
|
|
2398
|
+
v,
|
|
2399
|
+
s,
|
|
2400
|
+
c,
|
|
2401
|
+
y,
|
|
2402
|
+
l,
|
|
2403
|
+
h,
|
|
2404
|
+
t
|
|
2405
|
+
]);
|
|
2406
|
+
return b.createElement(rr.Provider, { value: x }, b.createElement(cn.Provider, { value: x.control }, e));
|
|
2407
|
+
}, ar = ["Ok", "Cancel"], or = {
|
|
2408
|
+
[ie.Info]: "ValidationInformation",
|
|
2409
|
+
[ie.Warning]: "ValidationWarning",
|
|
2410
|
+
[ie.Error]: "ValidationStop",
|
|
2411
|
+
[ie.Success]: "Check"
|
|
2412
|
+
}, sr = (e) => typeof e == "string" ? e : e.id ?? e, cr = (e, t) => t !== void 0 && sr(e) === sr(t), lr = (e) => typeof e != "string" && (typeof e.disabled == "function" ? e.disabled() : !0 === e.disabled), ur = C(S((e, r) => {
|
|
2413
|
+
let { description: s, type: c, icon: l, onCancel: u, onOption: d, onDone: p, onValidateOption: m, options: h = ar, autoFocusSel: g = ".defaultOption", defaultOption: y = h[0], cancelOption: b = "Cancel", autoFocus: x, children: S, ...C } = e, w = nr({ shouldUseNativeValidation: !1 }), { handleSubmit: ee, formState: T } = w, k = D(null), te = D(null), j = de(), M = E(() => {
|
|
2414
|
+
let e = typeof l == "string" ? l : l ? void 0 : or[c];
|
|
2415
|
+
return e ? _(ne, {
|
|
2416
|
+
iconKey: e,
|
|
2417
|
+
size: 32,
|
|
2418
|
+
ariaHidden: !0
|
|
2419
|
+
}) : l ?? null;
|
|
2420
|
+
}, [l, c]), ie = oe((e) => typeof e == "string" ? e === "Ok" ? j("dialog.ok") : e === "Cancel" ? j("dialog.cancel") : e : typeof e.label == "function" ? e.label() : e.label, [j]), N = D(null), [F, ae] = O(null), se = oe(async (e) => {
|
|
2421
|
+
let t = sr(e);
|
|
2422
|
+
if (F !== null || lr(e)) return;
|
|
2423
|
+
let n = cr(e, b), r;
|
|
2424
|
+
try {
|
|
2425
|
+
if (ae(t), r = !!n || (await Promise.resolve(m?.(t)) ?? !0), !0 !== r) return;
|
|
2426
|
+
await Promise.resolve(d?.(t, n, cr(e, y))), p?.(t);
|
|
2427
|
+
} catch {} finally {
|
|
2428
|
+
ae(null);
|
|
2429
|
+
}
|
|
2430
|
+
}, [
|
|
2431
|
+
d,
|
|
2432
|
+
p,
|
|
2433
|
+
m,
|
|
2434
|
+
b,
|
|
2435
|
+
y,
|
|
2436
|
+
F
|
|
2437
|
+
]), ce = oe((e, t) => {
|
|
2438
|
+
setTimeout(() => {
|
|
2439
|
+
se(y);
|
|
2440
|
+
}, 180);
|
|
2441
|
+
}, [se, y]), le = oe(() => {
|
|
2442
|
+
d?.(sr(b), !0, !1), u?.(), p?.(null);
|
|
2443
|
+
}, [
|
|
2444
|
+
d,
|
|
2445
|
+
b,
|
|
2446
|
+
u,
|
|
2447
|
+
p
|
|
2448
|
+
]), ue = T && (Object.keys(T.errors).length > 0 || T.disabled || T.isSubmitting), fe = oe((e, t, r) => {
|
|
2449
|
+
let a = cr(e, b), o = {
|
|
2450
|
+
className: t ? "defaultOption" : "action",
|
|
2451
|
+
type: t ? "submit" : "button",
|
|
2452
|
+
style: { minWidth: "75px" },
|
|
2453
|
+
onClick: () => {
|
|
2454
|
+
a ? le() : t || se(e);
|
|
2455
|
+
}
|
|
2456
|
+
}, s = typeof e == "string" ? void 0 : e.renderButton;
|
|
2457
|
+
if (s) return _(P, {
|
|
2458
|
+
render: s,
|
|
2459
|
+
props: {
|
|
2460
|
+
buttonProps: o,
|
|
2461
|
+
isDefaultOption: t
|
|
2462
|
+
}
|
|
2463
|
+
}, `action:${r}`);
|
|
2464
|
+
let c = F !== null && cr(e, F), l = {
|
|
2465
|
+
className: t ? "defaultOption" : "action",
|
|
2466
|
+
variant: t ? "contained" : "outlined",
|
|
2467
|
+
size: "small",
|
|
2468
|
+
disabled: !a && (ue || lr(e)) || F !== null && !c,
|
|
2469
|
+
color: "primary",
|
|
2470
|
+
...o
|
|
2471
|
+
};
|
|
2472
|
+
if (t || a) {
|
|
2473
|
+
let e = t ? k : te;
|
|
2474
|
+
l.touchRippleRef = e, l.onPointerDown = (t) => {
|
|
2475
|
+
e.current?.start(t, { center: !1 }), t.stopPropagation(), t.preventDefault();
|
|
2476
|
+
};
|
|
2477
|
+
}
|
|
2478
|
+
return v(n, {
|
|
2479
|
+
...l,
|
|
2480
|
+
children: [_("div", {
|
|
2481
|
+
style: { visibility: c ? "hidden" : void 0 },
|
|
2482
|
+
children: ie(e)
|
|
2483
|
+
}), m && !a ? _(i, {
|
|
2484
|
+
size: 16,
|
|
2485
|
+
color: "inherit",
|
|
2486
|
+
style: { opacity: +!!c },
|
|
2487
|
+
sx: {
|
|
2488
|
+
position: "absolute",
|
|
2489
|
+
top: "calc(50% - 8px)",
|
|
2490
|
+
left: "calc(50% - 8px)",
|
|
2491
|
+
zIndex: 1,
|
|
2492
|
+
pointerEvents: "none",
|
|
2493
|
+
transition: "opacity 120ms"
|
|
2494
|
+
}
|
|
2495
|
+
}) : null]
|
|
2496
|
+
}, `action:${r}`);
|
|
2497
|
+
}, [
|
|
2498
|
+
h,
|
|
2499
|
+
y,
|
|
2500
|
+
b,
|
|
2501
|
+
T,
|
|
2502
|
+
ie,
|
|
2503
|
+
F
|
|
2504
|
+
]), pe = E(() => {
|
|
2505
|
+
let e = [];
|
|
2506
|
+
for (let t = 0; t < h.length; t++) {
|
|
2507
|
+
let n = h[t], r = y === void 0 ? t === 0 : cr(n, y);
|
|
2508
|
+
e.push(fe(n, r, t));
|
|
2509
|
+
}
|
|
2510
|
+
return e;
|
|
2511
|
+
}, [
|
|
2512
|
+
h,
|
|
2513
|
+
y,
|
|
2514
|
+
T,
|
|
2515
|
+
j,
|
|
2516
|
+
F
|
|
2517
|
+
]);
|
|
2518
|
+
return _(vt, {
|
|
2519
|
+
onCancel: le,
|
|
2520
|
+
initialPosition: { y: At === "touch" ? "15" : "35" },
|
|
2521
|
+
onDone: p,
|
|
2522
|
+
autoFocusSel: g,
|
|
2523
|
+
isModal: !0,
|
|
2524
|
+
ref: r,
|
|
2525
|
+
...C,
|
|
2526
|
+
children: _(ir, {
|
|
2527
|
+
...w,
|
|
2528
|
+
children: v("form", {
|
|
2529
|
+
ref: N,
|
|
2530
|
+
onSubmit: ee(ce),
|
|
2531
|
+
children: [_(o, {
|
|
2532
|
+
dividers: !0,
|
|
2533
|
+
onKeyDown: (e) => {
|
|
2534
|
+
if (e.isDefaultPrevented()) return;
|
|
2535
|
+
e.stopPropagation();
|
|
2536
|
+
let t = null, n = null, r = e.which === re.Escape && b;
|
|
2537
|
+
if (r) {
|
|
2538
|
+
if (F !== null) return;
|
|
2539
|
+
t = b, n = te;
|
|
2540
|
+
} else {
|
|
2541
|
+
if (ue || F !== null) return;
|
|
2542
|
+
e.which === re.Enter && (t = y ?? h[0], n = k);
|
|
2543
|
+
}
|
|
2544
|
+
t && (n?.current?.start(e, { center: !1 }), setTimeout(() => {
|
|
2545
|
+
n?.current?.stop(e), r && le();
|
|
2546
|
+
}, 180));
|
|
2547
|
+
},
|
|
2548
|
+
children: v(t, {
|
|
2549
|
+
sx: {
|
|
2550
|
+
display: "flex",
|
|
2551
|
+
flexDirection: "column",
|
|
2552
|
+
whiteSpace: "pre-wrap",
|
|
2553
|
+
rowGap: (e) => e.spacing(M || s ? 1.5 : 0)
|
|
2554
|
+
},
|
|
2555
|
+
children: [v(t, {
|
|
2556
|
+
sx: {
|
|
2557
|
+
display: "flex",
|
|
2558
|
+
flexDirection: "row",
|
|
2559
|
+
alignItems: "flex-start",
|
|
2560
|
+
columnGap: (e) => e.spacing(2)
|
|
2561
|
+
},
|
|
2562
|
+
children: [M ? _(t, {
|
|
2563
|
+
sx: {
|
|
2564
|
+
display: "flex",
|
|
2565
|
+
flex: "none"
|
|
2566
|
+
},
|
|
2567
|
+
children: M
|
|
2568
|
+
}) : null, _(f, {
|
|
2569
|
+
sx: { alignSelf: "center" },
|
|
2570
|
+
children: s
|
|
2571
|
+
})]
|
|
2572
|
+
}), S]
|
|
2573
|
+
})
|
|
2574
|
+
}), _(a, {
|
|
2575
|
+
sx: {
|
|
2576
|
+
paddingTop: (e) => e.spacing(1),
|
|
2577
|
+
paddingBottom: (e) => e.spacing(1),
|
|
2578
|
+
paddingLeft: (e) => e.spacing(1),
|
|
2579
|
+
paddingRight: (e) => e.spacing(1),
|
|
2580
|
+
backgroundColor: (e) => A(e.palette.action.hover, .03)
|
|
2581
|
+
},
|
|
2582
|
+
children: pe
|
|
2583
|
+
})]
|
|
2584
|
+
})
|
|
2585
|
+
})
|
|
2586
|
+
});
|
|
2587
|
+
}));
|
|
2588
|
+
export { Ae as a, De as c, Pe as i, Ee as l, sr as n, ke as o, vt as r, Oe as s, ur as t, Ce as u };
|