@gravitee/graphene-core 2.56.0 → 2.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CodeEditor-izUXIn0I.js +260 -0
- package/dist/CodeEditorField-2Ph093QR.js +52 -0
- package/dist/SchemaBanner-lrLehIB4.js +1026 -0
- package/dist/Skeleton-DYPFDpYt.js +1754 -0
- package/dist/code-editor/index.js +1 -1
- package/dist/composed/JsonSchemaForm/SchemaField.d.ts.map +1 -1
- package/dist/index.js +8446 -9507
- package/package.json +1 -1
- package/dist/CodeEditor-Cnn11Gx1.js +0 -2010
|
@@ -0,0 +1,1026 @@
|
|
|
1
|
+
import { i as e, r as t } from "./Skeleton-DYPFDpYt.js";
|
|
2
|
+
import { pt as n } from "./icons-YplRdF9A.js";
|
|
3
|
+
import * as r from "react";
|
|
4
|
+
import i, { createContext as a, useContext as o, useMemo as s } from "react";
|
|
5
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
+
import * as d from "react-dom";
|
|
7
|
+
//#region ../../node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
8
|
+
function f(e, t) {
|
|
9
|
+
if (typeof e == "function") return e(t);
|
|
10
|
+
e != null && (e.current = t);
|
|
11
|
+
}
|
|
12
|
+
function p(...e) {
|
|
13
|
+
return (t) => {
|
|
14
|
+
let n = !1, r = e.map((e) => {
|
|
15
|
+
let r = f(e, t);
|
|
16
|
+
return !n && typeof r == "function" && (n = !0), r;
|
|
17
|
+
});
|
|
18
|
+
if (n) return () => {
|
|
19
|
+
for (let t = 0; t < r.length; t++) {
|
|
20
|
+
let n = r[t];
|
|
21
|
+
typeof n == "function" ? n() : f(e[t], null);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function m(...e) {
|
|
27
|
+
return r.useCallback(p(...e), e);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region ../../node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
31
|
+
// @__NO_SIDE_EFFECTS__
|
|
32
|
+
function h(e) {
|
|
33
|
+
let t = /* @__PURE__ */ _(e), n = r.forwardRef((e, n) => {
|
|
34
|
+
let { children: i, ...a } = e, o = r.Children.toArray(i), s = o.find(b);
|
|
35
|
+
if (s) {
|
|
36
|
+
let e = s.props.children, i = o.map((t) => t === s ? r.Children.count(e) > 1 ? r.Children.only(null) : r.isValidElement(e) ? e.props.children : null : t);
|
|
37
|
+
return /* @__PURE__ */ l(t, {
|
|
38
|
+
...a,
|
|
39
|
+
ref: n,
|
|
40
|
+
children: r.isValidElement(e) ? r.cloneElement(e, void 0, i) : null
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return /* @__PURE__ */ l(t, {
|
|
44
|
+
...a,
|
|
45
|
+
ref: n,
|
|
46
|
+
children: i
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return n.displayName = `${e}.Slot`, n;
|
|
50
|
+
}
|
|
51
|
+
var g = /* @__PURE__ */ h("Slot");
|
|
52
|
+
// @__NO_SIDE_EFFECTS__
|
|
53
|
+
function _(e) {
|
|
54
|
+
let t = r.forwardRef((e, t) => {
|
|
55
|
+
let { children: n, ...i } = e;
|
|
56
|
+
if (r.isValidElement(n)) {
|
|
57
|
+
let e = S(n), a = x(i, n.props);
|
|
58
|
+
return n.type !== r.Fragment && (a.ref = t ? p(t, e) : e), r.cloneElement(n, a);
|
|
59
|
+
}
|
|
60
|
+
return r.Children.count(n) > 1 ? r.Children.only(null) : null;
|
|
61
|
+
});
|
|
62
|
+
return t.displayName = `${e}.SlotClone`, t;
|
|
63
|
+
}
|
|
64
|
+
var v = Symbol("radix.slottable");
|
|
65
|
+
// @__NO_SIDE_EFFECTS__
|
|
66
|
+
function y(e) {
|
|
67
|
+
let t = ({ children: e }) => /* @__PURE__ */ l(c, { children: e });
|
|
68
|
+
return t.displayName = `${e}.Slottable`, t.__radixId = v, t;
|
|
69
|
+
}
|
|
70
|
+
function b(e) {
|
|
71
|
+
return r.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === v;
|
|
72
|
+
}
|
|
73
|
+
function x(e, t) {
|
|
74
|
+
let n = { ...t };
|
|
75
|
+
for (let r in t) {
|
|
76
|
+
let i = e[r], a = t[r];
|
|
77
|
+
/^on[A-Z]/.test(r) ? i && a ? n[r] = (...e) => {
|
|
78
|
+
let t = a(...e);
|
|
79
|
+
return i(...e), t;
|
|
80
|
+
} : i && (n[r] = i) : r === "style" ? n[r] = {
|
|
81
|
+
...i,
|
|
82
|
+
...a
|
|
83
|
+
} : r === "className" && (n[r] = [i, a].filter(Boolean).join(" "));
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
...e,
|
|
87
|
+
...n
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function S(e) {
|
|
91
|
+
let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning;
|
|
92
|
+
return n ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region ../../node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
96
|
+
var C = [
|
|
97
|
+
"a",
|
|
98
|
+
"button",
|
|
99
|
+
"div",
|
|
100
|
+
"form",
|
|
101
|
+
"h2",
|
|
102
|
+
"h3",
|
|
103
|
+
"img",
|
|
104
|
+
"input",
|
|
105
|
+
"label",
|
|
106
|
+
"li",
|
|
107
|
+
"nav",
|
|
108
|
+
"ol",
|
|
109
|
+
"p",
|
|
110
|
+
"select",
|
|
111
|
+
"span",
|
|
112
|
+
"svg",
|
|
113
|
+
"ul"
|
|
114
|
+
].reduce((e, t) => {
|
|
115
|
+
let n = /* @__PURE__ */ h(`Primitive.${t}`), i = r.forwardRef((e, r) => {
|
|
116
|
+
let { asChild: i, ...a } = e, o = i ? n : t;
|
|
117
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ l(o, {
|
|
118
|
+
...a,
|
|
119
|
+
ref: r
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
return i.displayName = `Primitive.${t}`, {
|
|
123
|
+
...e,
|
|
124
|
+
[t]: i
|
|
125
|
+
};
|
|
126
|
+
}, {});
|
|
127
|
+
function ee(e, t) {
|
|
128
|
+
e && d.flushSync(() => e.dispatchEvent(t));
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region ../../node_modules/@radix-ui/react-label/dist/index.mjs
|
|
132
|
+
var w = "Label", T = r.forwardRef((e, t) => /* @__PURE__ */ l(C.label, {
|
|
133
|
+
...e,
|
|
134
|
+
ref: t,
|
|
135
|
+
onMouseDown: (t) => {
|
|
136
|
+
t.target.closest("button, input, select, textarea") || (e.onMouseDown?.(t), !t.defaultPrevented && t.detail > 1 && t.preventDefault());
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
T.displayName = w;
|
|
140
|
+
var E = T, te = "Separator", ne = "horizontal", re = ["horizontal", "vertical"], ie = r.forwardRef((e, t) => {
|
|
141
|
+
let { decorative: n, orientation: r = ne, ...i } = e, a = ae(r) ? r : ne, o = n ? { role: "none" } : {
|
|
142
|
+
"aria-orientation": a === "vertical" ? a : void 0,
|
|
143
|
+
role: "separator"
|
|
144
|
+
};
|
|
145
|
+
return /* @__PURE__ */ l(C.div, {
|
|
146
|
+
"data-orientation": a,
|
|
147
|
+
...o,
|
|
148
|
+
...i,
|
|
149
|
+
ref: t
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
ie.displayName = te;
|
|
153
|
+
function ae(e) {
|
|
154
|
+
return re.includes(e);
|
|
155
|
+
}
|
|
156
|
+
var oe = ie, se = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, ce = e, D = (e, t) => (n) => {
|
|
157
|
+
if (t?.variants == null) return ce(e, n?.class, n?.className);
|
|
158
|
+
let { variants: r, defaultVariants: i } = t, a = Object.keys(r).map((e) => {
|
|
159
|
+
let t = n?.[e], a = i?.[e];
|
|
160
|
+
if (t === null) return null;
|
|
161
|
+
let o = se(t) || se(a);
|
|
162
|
+
return r[e][o];
|
|
163
|
+
}), o = n && Object.entries(n).reduce((e, t) => {
|
|
164
|
+
let [n, r] = t;
|
|
165
|
+
return r === void 0 || (e[n] = r), e;
|
|
166
|
+
}, {});
|
|
167
|
+
return ce(e, a, t?.compoundVariants?.reduce((e, t) => {
|
|
168
|
+
let { class: n, className: r, ...a } = t;
|
|
169
|
+
return Object.entries(a).every((e) => {
|
|
170
|
+
let [t, n] = e;
|
|
171
|
+
return Array.isArray(n) ? n.includes({
|
|
172
|
+
...i,
|
|
173
|
+
...o
|
|
174
|
+
}[t]) : {
|
|
175
|
+
...i,
|
|
176
|
+
...o
|
|
177
|
+
}[t] === n;
|
|
178
|
+
}) ? [
|
|
179
|
+
...e,
|
|
180
|
+
n,
|
|
181
|
+
r
|
|
182
|
+
] : e;
|
|
183
|
+
}, []), n?.class, n?.className);
|
|
184
|
+
}, le = D("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-20 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", {
|
|
185
|
+
variants: { variant: {
|
|
186
|
+
default: "bg-card text-card-foreground",
|
|
187
|
+
destructive: "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"
|
|
188
|
+
} },
|
|
189
|
+
defaultVariants: { variant: "default" }
|
|
190
|
+
});
|
|
191
|
+
function ue({ className: e, variant: n = "default", ...r }) {
|
|
192
|
+
return /* @__PURE__ */ l("div", {
|
|
193
|
+
"data-slot": "alert",
|
|
194
|
+
"data-variant": n,
|
|
195
|
+
role: "alert",
|
|
196
|
+
className: t(le({ variant: n }), e),
|
|
197
|
+
...r
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function de({ className: e, ...n }) {
|
|
201
|
+
return /* @__PURE__ */ l("div", {
|
|
202
|
+
"data-slot": "alert-title",
|
|
203
|
+
className: t("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground", e),
|
|
204
|
+
...n
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function fe({ className: e, ...n }) {
|
|
208
|
+
return /* @__PURE__ */ l("div", {
|
|
209
|
+
"data-slot": "alert-description",
|
|
210
|
+
className: t("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4", e),
|
|
211
|
+
...n
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function pe({ className: e, ...n }) {
|
|
215
|
+
return /* @__PURE__ */ l("div", {
|
|
216
|
+
"data-slot": "alert-action",
|
|
217
|
+
className: t("absolute top-2 right-2", e),
|
|
218
|
+
...n
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/base/Separator/Separator.tsx
|
|
223
|
+
function me({ className: e, orientation: n = "horizontal", decorative: r = !0, ...i }) {
|
|
224
|
+
return /* @__PURE__ */ l(oe, {
|
|
225
|
+
"data-slot": "separator",
|
|
226
|
+
decorative: r,
|
|
227
|
+
orientation: n,
|
|
228
|
+
className: t("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch", e),
|
|
229
|
+
...i
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/base/Label/Label.tsx
|
|
234
|
+
function he({ className: e, ...n }) {
|
|
235
|
+
return /* @__PURE__ */ l(E, {
|
|
236
|
+
"data-slot": "label",
|
|
237
|
+
className: t("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", e),
|
|
238
|
+
...n
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/base/Field/Field.tsx
|
|
243
|
+
function ge({ className: e, ...n }) {
|
|
244
|
+
return /* @__PURE__ */ l("fieldset", {
|
|
245
|
+
"data-slot": "field-set",
|
|
246
|
+
className: t("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", e),
|
|
247
|
+
...n
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function _e({ className: e, variant: n = "legend", required: r, children: i, ...a }) {
|
|
251
|
+
return /* @__PURE__ */ l("legend", {
|
|
252
|
+
"data-slot": "field-legend",
|
|
253
|
+
"data-variant": n,
|
|
254
|
+
className: t("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base", e),
|
|
255
|
+
...a,
|
|
256
|
+
children: r ? /* @__PURE__ */ u("span", {
|
|
257
|
+
className: "inline-flex items-baseline gap-0.5",
|
|
258
|
+
children: [i, /* @__PURE__ */ l("span", {
|
|
259
|
+
"aria-hidden": "true",
|
|
260
|
+
className: "group-data-[invalid=true]/field:text-destructive",
|
|
261
|
+
children: "*"
|
|
262
|
+
})]
|
|
263
|
+
}) : i
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function ve({ className: e, ...n }) {
|
|
267
|
+
return /* @__PURE__ */ l("div", {
|
|
268
|
+
"data-slot": "field-group",
|
|
269
|
+
className: t("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4", e),
|
|
270
|
+
...n
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
var ye = D("group/field flex w-full gap-2 data-[invalid=true]:text-destructive", {
|
|
274
|
+
variants: { orientation: {
|
|
275
|
+
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
|
|
276
|
+
horizontal: "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
277
|
+
responsive: "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
278
|
+
} },
|
|
279
|
+
defaultVariants: { orientation: "vertical" }
|
|
280
|
+
});
|
|
281
|
+
function be({ className: e, orientation: n = "vertical", ...r }) {
|
|
282
|
+
return /* @__PURE__ */ l("div", {
|
|
283
|
+
role: "group",
|
|
284
|
+
"data-slot": "field",
|
|
285
|
+
"data-orientation": n,
|
|
286
|
+
className: t(ye({ orientation: n }), e),
|
|
287
|
+
...r
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function xe({ className: e, ...n }) {
|
|
291
|
+
return /* @__PURE__ */ l("div", {
|
|
292
|
+
"data-slot": "field-content",
|
|
293
|
+
className: t("group/field-content flex flex-1 flex-col gap-0.5 leading-snug", e),
|
|
294
|
+
...n
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function Se({ className: e, required: n, children: r, ...i }) {
|
|
298
|
+
return /* @__PURE__ */ l(he, {
|
|
299
|
+
"data-slot": "field-label",
|
|
300
|
+
className: t("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col", e),
|
|
301
|
+
...i,
|
|
302
|
+
children: n ? /* @__PURE__ */ u("span", {
|
|
303
|
+
className: "inline-flex items-baseline gap-0.5",
|
|
304
|
+
children: [r, /* @__PURE__ */ l("span", {
|
|
305
|
+
"aria-hidden": "true",
|
|
306
|
+
className: "group-data-[invalid=true]/field:text-destructive",
|
|
307
|
+
children: "*"
|
|
308
|
+
})]
|
|
309
|
+
}) : r
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function Ce({ className: e, ...n }) {
|
|
313
|
+
return /* @__PURE__ */ l("div", {
|
|
314
|
+
"data-slot": "field-title",
|
|
315
|
+
className: t("flex w-fit items-center gap-2 text-sm/snug font-medium group-data-[disabled=true]/field:opacity-50", e),
|
|
316
|
+
...n
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function we({ className: e, ...n }) {
|
|
320
|
+
return /* @__PURE__ */ l("p", {
|
|
321
|
+
"data-slot": "field-description",
|
|
322
|
+
className: t("text-left text-sm/normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5", "last:mt-0 nth-last-2:-mt-1", "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", e),
|
|
323
|
+
...n
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function Te({ children: e, className: n, ...r }) {
|
|
327
|
+
return /* @__PURE__ */ u("div", {
|
|
328
|
+
"data-slot": "field-separator",
|
|
329
|
+
"data-content": !!e,
|
|
330
|
+
className: t("relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2", n),
|
|
331
|
+
...r,
|
|
332
|
+
children: [/* @__PURE__ */ l(me, { className: "absolute inset-0 top-1/2" }), e && /* @__PURE__ */ l("span", {
|
|
333
|
+
className: "relative mx-auto block w-fit bg-background px-2 text-muted-foreground",
|
|
334
|
+
"data-slot": "field-separator-content",
|
|
335
|
+
children: e
|
|
336
|
+
})]
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function Ee({ className: e, children: n, errors: r, ...i }) {
|
|
340
|
+
let a = s(() => {
|
|
341
|
+
if (n) return n;
|
|
342
|
+
if (!r?.length) return null;
|
|
343
|
+
let e = [...new Map(r.map((e) => [e?.message, e])).values()];
|
|
344
|
+
return e?.length === 1 ? e[0]?.message : /* @__PURE__ */ l("ul", {
|
|
345
|
+
className: "ml-4 flex list-disc flex-col gap-1",
|
|
346
|
+
children: e.map((e, t) => e?.message && /* @__PURE__ */ l("li", { children: e.message }, t))
|
|
347
|
+
});
|
|
348
|
+
}, [n, r]);
|
|
349
|
+
return a ? /* @__PURE__ */ l("div", {
|
|
350
|
+
role: "alert",
|
|
351
|
+
"data-slot": "field-error",
|
|
352
|
+
className: t("text-sm font-normal text-destructive", e),
|
|
353
|
+
...i,
|
|
354
|
+
children: a
|
|
355
|
+
}) : null;
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region ../../node_modules/react-hook-form/dist/index.esm.mjs
|
|
359
|
+
var De = (e) => e.type === "checkbox", O = (e) => e instanceof Date, k = (e) => e == null, Oe = (e) => typeof e == "object", A = (e) => !k(e) && !Array.isArray(e) && Oe(e) && !O(e), ke = (e) => A(e) && e.target ? De(e.target) ? e.target.checked : e.target.value : e, Ae = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), je = (e) => {
|
|
360
|
+
let t = e.constructor && e.constructor.prototype;
|
|
361
|
+
return A(t) && t.hasOwnProperty("isPrototypeOf");
|
|
362
|
+
}, j = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
|
|
363
|
+
function M(e) {
|
|
364
|
+
if (e instanceof Date) return new Date(e);
|
|
365
|
+
let t = typeof FileList < "u" && e instanceof FileList;
|
|
366
|
+
if (j && (e instanceof Blob || t)) return e;
|
|
367
|
+
let n = Array.isArray(e);
|
|
368
|
+
if (!n && !(A(e) && je(e))) return e;
|
|
369
|
+
let r = n ? [] : Object.create(Object.getPrototypeOf(e));
|
|
370
|
+
for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = M(e[t]));
|
|
371
|
+
return r;
|
|
372
|
+
}
|
|
373
|
+
var Me = {
|
|
374
|
+
BLUR: "blur",
|
|
375
|
+
FOCUS_OUT: "focusout",
|
|
376
|
+
CHANGE: "change",
|
|
377
|
+
SUBMIT: "submit",
|
|
378
|
+
TRIGGER: "trigger",
|
|
379
|
+
VALID: "valid"
|
|
380
|
+
}, N = {
|
|
381
|
+
onBlur: "onBlur",
|
|
382
|
+
onChange: "onChange",
|
|
383
|
+
onSubmit: "onSubmit",
|
|
384
|
+
onTouched: "onTouched",
|
|
385
|
+
all: "all"
|
|
386
|
+
}, P = {
|
|
387
|
+
max: "max",
|
|
388
|
+
min: "min",
|
|
389
|
+
maxLength: "maxLength",
|
|
390
|
+
minLength: "minLength",
|
|
391
|
+
pattern: "pattern",
|
|
392
|
+
required: "required",
|
|
393
|
+
validate: "validate"
|
|
394
|
+
}, Ne = "root", Pe = [
|
|
395
|
+
"__proto__",
|
|
396
|
+
"constructor",
|
|
397
|
+
"prototype"
|
|
398
|
+
], F = (e) => /^\w*$/.test(e), I = (e) => e === void 0, L = (e) => e.split(/[.[\]'"]/g).filter(Boolean), R = (e, t, n) => {
|
|
399
|
+
if (!t || !A(e)) return n;
|
|
400
|
+
let r = F(t) ? [t] : L(t);
|
|
401
|
+
if (r.some((e) => Pe.includes(e))) return n;
|
|
402
|
+
let i = r.reduce((e, t) => k(e) ? void 0 : e[t], e);
|
|
403
|
+
return I(i) || i === e ? I(e[t]) ? n : e[t] : i;
|
|
404
|
+
}, z = (e) => typeof e == "boolean", B = (e) => typeof e == "function", V = (e, t, n) => {
|
|
405
|
+
let r = -1, i = F(t) ? [t] : L(t), a = i.length, o = a - 1;
|
|
406
|
+
for (; ++r < a;) {
|
|
407
|
+
let t = i[r], a = n;
|
|
408
|
+
if (r !== o) {
|
|
409
|
+
let n = e[t];
|
|
410
|
+
a = A(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
|
|
411
|
+
}
|
|
412
|
+
if (Pe.includes(t)) return;
|
|
413
|
+
e[t] = a, e = e[t];
|
|
414
|
+
}
|
|
415
|
+
}, Fe = i.createContext(null);
|
|
416
|
+
Fe.displayName = "HookFormControlContext";
|
|
417
|
+
var H = () => i.useContext(Fe), Ie = (e, t, n, r = !0) => {
|
|
418
|
+
let i = {};
|
|
419
|
+
for (let a in e) Object.defineProperty(i, a, { get: () => {
|
|
420
|
+
let i = a;
|
|
421
|
+
return t._proxyFormState[i] !== N.all && (t._proxyFormState[i] = !r || N.all), n && (n[i] = !0), e[i];
|
|
422
|
+
} });
|
|
423
|
+
return i;
|
|
424
|
+
}, U = j ? i.useLayoutEffect : i.useEffect;
|
|
425
|
+
function Le(e) {
|
|
426
|
+
let t = H(), { control: n = t, disabled: r, name: a, exact: o } = e || {}, [s, c] = i.useState(() => ({
|
|
427
|
+
...n._formState,
|
|
428
|
+
defaultValues: n._defaultValues
|
|
429
|
+
})), l = i.useRef({
|
|
430
|
+
isDirty: !1,
|
|
431
|
+
isLoading: !1,
|
|
432
|
+
dirtyFields: !1,
|
|
433
|
+
touchedFields: !1,
|
|
434
|
+
validatingFields: !1,
|
|
435
|
+
isValidating: !1,
|
|
436
|
+
isValid: !1,
|
|
437
|
+
errors: !1
|
|
438
|
+
});
|
|
439
|
+
return U(() => n._subscribe({
|
|
440
|
+
name: a,
|
|
441
|
+
formState: l.current,
|
|
442
|
+
exact: o,
|
|
443
|
+
callback: (e) => {
|
|
444
|
+
!r && c({
|
|
445
|
+
...n._formState,
|
|
446
|
+
...e,
|
|
447
|
+
defaultValues: n._defaultValues
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}), [
|
|
451
|
+
a,
|
|
452
|
+
r,
|
|
453
|
+
o
|
|
454
|
+
]), i.useEffect(() => {
|
|
455
|
+
l.current.isValid && n._setValid(!0);
|
|
456
|
+
}, [n]), i.useMemo(() => Ie(s, n, l.current, !1), [s, n]);
|
|
457
|
+
}
|
|
458
|
+
var W = (e) => typeof e == "string", Re = (e, t, n, r, i) => W(e) ? (r && t.watch.add(e), R(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), R(n, e))) : (r && (t.watchAll = !0), n), ze = (e) => k(e) || !Oe(e), Be = (e, t) => t.length === 0 && !Array.isArray(e) && !je(e);
|
|
459
|
+
function G(e, t, n = /* @__PURE__ */ new WeakSet()) {
|
|
460
|
+
if (e === t) return !0;
|
|
461
|
+
if (ze(e) || ze(t)) return Object.is(e, t);
|
|
462
|
+
if (O(e) && O(t)) return Object.is(e.getTime(), t.getTime());
|
|
463
|
+
let r = Object.keys(e), i = Object.keys(t);
|
|
464
|
+
if (r.length !== i.length) return !1;
|
|
465
|
+
if (Be(e, r) || Be(t, i)) return Object.is(e, t);
|
|
466
|
+
if (n.has(e) || n.has(t)) return !0;
|
|
467
|
+
n.add(e), n.add(t);
|
|
468
|
+
for (let i of r) {
|
|
469
|
+
let r = e[i];
|
|
470
|
+
if (!(i in t)) return !1;
|
|
471
|
+
if (i !== "ref") {
|
|
472
|
+
let e = t[i];
|
|
473
|
+
if (O(r) && O(e) || (A(r) || Array.isArray(r)) && (A(e) || Array.isArray(e)) ? !G(r, e, n) : !Object.is(r, e)) return !1;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return !0;
|
|
477
|
+
}
|
|
478
|
+
function Ve(e) {
|
|
479
|
+
let t = H(), { control: n = t, name: r, defaultValue: a, disabled: o, exact: s, compute: c } = e || {}, l = i.useRef(a), u = i.useRef(c), d = i.useRef(void 0), f = i.useRef(n), p = i.useRef(r);
|
|
480
|
+
u.current = c;
|
|
481
|
+
let [m, h] = i.useState(() => {
|
|
482
|
+
let e = n._getWatch(r, l.current);
|
|
483
|
+
return u.current ? u.current(e) : e;
|
|
484
|
+
}), g = i.useCallback((e) => {
|
|
485
|
+
let t = Re(r, n._names, e || n._formValues, !1, l.current);
|
|
486
|
+
return u.current ? u.current(t) : t;
|
|
487
|
+
}, [
|
|
488
|
+
n._formValues,
|
|
489
|
+
n._names,
|
|
490
|
+
r
|
|
491
|
+
]), _ = i.useCallback((e) => {
|
|
492
|
+
if (!o) {
|
|
493
|
+
let t = Re(r, n._names, e || n._formValues, !1, l.current);
|
|
494
|
+
if (u.current) {
|
|
495
|
+
let e = u.current(t);
|
|
496
|
+
G(e, d.current) || (h(e), d.current = e);
|
|
497
|
+
} else h(t);
|
|
498
|
+
}
|
|
499
|
+
}, [
|
|
500
|
+
n._formValues,
|
|
501
|
+
n._names,
|
|
502
|
+
o,
|
|
503
|
+
r
|
|
504
|
+
]);
|
|
505
|
+
U(() => ((f.current !== n || !G(p.current, r)) && (f.current = n, p.current = r, _()), n._subscribe({
|
|
506
|
+
name: r,
|
|
507
|
+
formState: { values: !0 },
|
|
508
|
+
exact: s,
|
|
509
|
+
callback: (e) => {
|
|
510
|
+
_(e.values);
|
|
511
|
+
}
|
|
512
|
+
})), [
|
|
513
|
+
n,
|
|
514
|
+
s,
|
|
515
|
+
r,
|
|
516
|
+
_
|
|
517
|
+
]), i.useEffect(() => n._removeUnmounted());
|
|
518
|
+
let v = f.current !== n, y = p.current, b = i.useMemo(() => {
|
|
519
|
+
if (o) return null;
|
|
520
|
+
let e = !v && !G(y, r);
|
|
521
|
+
return v || e ? g() : null;
|
|
522
|
+
}, [
|
|
523
|
+
o,
|
|
524
|
+
v,
|
|
525
|
+
r,
|
|
526
|
+
y,
|
|
527
|
+
g
|
|
528
|
+
]);
|
|
529
|
+
return b === null ? m : b;
|
|
530
|
+
}
|
|
531
|
+
function He(e) {
|
|
532
|
+
let t = H(), { name: n, disabled: r, control: a = t, shouldUnregister: o, defaultValue: s, exact: c = !0 } = e, l = Ae(a._names.array, n), u = Ve({
|
|
533
|
+
control: a,
|
|
534
|
+
name: n,
|
|
535
|
+
defaultValue: i.useMemo(() => R(a._formValues, n, R(a._defaultValues, n, s)), [
|
|
536
|
+
a,
|
|
537
|
+
n,
|
|
538
|
+
s
|
|
539
|
+
]),
|
|
540
|
+
exact: c
|
|
541
|
+
}), d = Le({
|
|
542
|
+
control: a,
|
|
543
|
+
name: n,
|
|
544
|
+
exact: c
|
|
545
|
+
}), f = i.useRef(e), p = i.useRef(a.register(n, {
|
|
546
|
+
...e.rules,
|
|
547
|
+
value: u,
|
|
548
|
+
...z(e.disabled) ? { disabled: e.disabled } : {}
|
|
549
|
+
}));
|
|
550
|
+
f.current = e;
|
|
551
|
+
let m = i.useMemo(() => Object.defineProperties({}, {
|
|
552
|
+
invalid: {
|
|
553
|
+
enumerable: !0,
|
|
554
|
+
get: () => !!R(d.errors, n)
|
|
555
|
+
},
|
|
556
|
+
isDirty: {
|
|
557
|
+
enumerable: !0,
|
|
558
|
+
get: () => !!R(d.dirtyFields, n)
|
|
559
|
+
},
|
|
560
|
+
isTouched: {
|
|
561
|
+
enumerable: !0,
|
|
562
|
+
get: () => !!R(d.touchedFields, n)
|
|
563
|
+
},
|
|
564
|
+
isValidating: {
|
|
565
|
+
enumerable: !0,
|
|
566
|
+
get: () => !!R(d.validatingFields, n)
|
|
567
|
+
},
|
|
568
|
+
error: {
|
|
569
|
+
enumerable: !0,
|
|
570
|
+
get: () => R(d.errors, n)
|
|
571
|
+
}
|
|
572
|
+
}), [d, n]), h = i.useCallback((e) => {
|
|
573
|
+
let t = ke(e);
|
|
574
|
+
R(a._fields, n) || (p.current = a.register(n, {
|
|
575
|
+
...f.current.rules,
|
|
576
|
+
value: t
|
|
577
|
+
})), p.current.onChange({
|
|
578
|
+
target: {
|
|
579
|
+
value: ke(e),
|
|
580
|
+
name: n
|
|
581
|
+
},
|
|
582
|
+
type: Me.CHANGE
|
|
583
|
+
});
|
|
584
|
+
}, [n, a]), g = i.useCallback(() => p.current.onBlur({
|
|
585
|
+
target: {
|
|
586
|
+
value: R(a._formValues, n),
|
|
587
|
+
name: n
|
|
588
|
+
},
|
|
589
|
+
type: Me.BLUR
|
|
590
|
+
}), [n, a._formValues]), _ = i.useCallback((e) => {
|
|
591
|
+
let t = R(a._fields, n);
|
|
592
|
+
t && t._f && e && (t._f.ref = {
|
|
593
|
+
focus: () => B(e.focus) && e.focus(),
|
|
594
|
+
select: () => B(e.select) && e.select(),
|
|
595
|
+
setCustomValidity: (t) => B(e.setCustomValidity) && e.setCustomValidity(t),
|
|
596
|
+
reportValidity: () => B(e.reportValidity) && e.reportValidity()
|
|
597
|
+
});
|
|
598
|
+
}, [a._fields, n]), v = i.useMemo(() => ({
|
|
599
|
+
name: n,
|
|
600
|
+
value: u,
|
|
601
|
+
...z(r) || d.disabled ? { disabled: d.disabled || r } : {},
|
|
602
|
+
onChange: h,
|
|
603
|
+
onBlur: g,
|
|
604
|
+
ref: _
|
|
605
|
+
}), [
|
|
606
|
+
n,
|
|
607
|
+
r,
|
|
608
|
+
d.disabled,
|
|
609
|
+
h,
|
|
610
|
+
g,
|
|
611
|
+
_,
|
|
612
|
+
u
|
|
613
|
+
]);
|
|
614
|
+
return i.useEffect(() => {
|
|
615
|
+
let e = a._options.shouldUnregister || o;
|
|
616
|
+
a.register(n, {
|
|
617
|
+
...f.current.rules,
|
|
618
|
+
...z(f.current.disabled) ? { disabled: f.current.disabled } : {}
|
|
619
|
+
});
|
|
620
|
+
let t = (e, t) => {
|
|
621
|
+
let n = R(a._fields, e);
|
|
622
|
+
n && n._f && (n._f.mount = t);
|
|
623
|
+
};
|
|
624
|
+
if (t(n, !0), e) {
|
|
625
|
+
let e = M(R(o ? a._defaultValues : a._options.values || a._defaultValues, n, R(a._options.defaultValues, n, f.current.defaultValue)));
|
|
626
|
+
V(a._defaultValues, n, e), I(R(a._formValues, n)) && V(a._formValues, n, e);
|
|
627
|
+
}
|
|
628
|
+
return !l && a.register(n), () => {
|
|
629
|
+
(l ? e && !a._state.action : e) ? a.unregister(n) : t(n, !1);
|
|
630
|
+
};
|
|
631
|
+
}, [
|
|
632
|
+
n,
|
|
633
|
+
a,
|
|
634
|
+
l,
|
|
635
|
+
o
|
|
636
|
+
]), i.useEffect(() => {
|
|
637
|
+
a._setDisabledField({
|
|
638
|
+
disabled: r,
|
|
639
|
+
name: n
|
|
640
|
+
});
|
|
641
|
+
}, [
|
|
642
|
+
r,
|
|
643
|
+
n,
|
|
644
|
+
a
|
|
645
|
+
]), i.useMemo(() => ({
|
|
646
|
+
field: v,
|
|
647
|
+
formState: d,
|
|
648
|
+
fieldState: m
|
|
649
|
+
}), [
|
|
650
|
+
v,
|
|
651
|
+
d,
|
|
652
|
+
m
|
|
653
|
+
]);
|
|
654
|
+
}
|
|
655
|
+
var Ue = i.createContext(null);
|
|
656
|
+
Ue.displayName = "HookFormContext";
|
|
657
|
+
var We = (e, t, n, r, i) => t ? {
|
|
658
|
+
...n[e],
|
|
659
|
+
types: {
|
|
660
|
+
...n[e] && n[e].types ? n[e].types : {},
|
|
661
|
+
[r]: i || !0
|
|
662
|
+
}
|
|
663
|
+
} : {}, Ge = (e) => Array.isArray(e) ? e.filter(Boolean) : [], K = (e) => Array.isArray(e) ? e : [e], q = (e) => A(e) && !Object.keys(e).length, Ke = (e) => e.type === "file", qe = (e) => {
|
|
664
|
+
if (!j) return !1;
|
|
665
|
+
let t = e ? e.ownerDocument : 0;
|
|
666
|
+
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
667
|
+
}, Je = (e) => e.type === "radio";
|
|
668
|
+
function Ye(e, t) {
|
|
669
|
+
let n = t.slice(0, -1).length, r = 0;
|
|
670
|
+
for (; r < n;) {
|
|
671
|
+
if (k(e)) {
|
|
672
|
+
e = void 0;
|
|
673
|
+
break;
|
|
674
|
+
}
|
|
675
|
+
e = e[t[r]], r++;
|
|
676
|
+
}
|
|
677
|
+
return e;
|
|
678
|
+
}
|
|
679
|
+
function Xe(e) {
|
|
680
|
+
for (let t in e) if (e.hasOwnProperty(t) && !I(e[t])) return !1;
|
|
681
|
+
return !0;
|
|
682
|
+
}
|
|
683
|
+
function Ze(e, t) {
|
|
684
|
+
if (W(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
|
|
685
|
+
let n = Array.isArray(t) ? t : F(t) ? [t] : L(t), r = n.length === 1 ? e : Ye(e, n), i = n.length - 1, a = n[i];
|
|
686
|
+
return r && delete r[a], i !== 0 && (A(r) && q(r) || Array.isArray(r) && Xe(r)) && Ze(e, n.slice(0, -1)), e;
|
|
687
|
+
}
|
|
688
|
+
var Qe = {
|
|
689
|
+
value: !1,
|
|
690
|
+
isValid: !1
|
|
691
|
+
}, $e = {
|
|
692
|
+
value: !0,
|
|
693
|
+
isValid: !0
|
|
694
|
+
}, et = (e) => {
|
|
695
|
+
if (Array.isArray(e)) {
|
|
696
|
+
if (e.length > 1) {
|
|
697
|
+
let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
|
|
698
|
+
return {
|
|
699
|
+
value: t,
|
|
700
|
+
isValid: !!t.length
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
return e[0].checked && !e[0].disabled ? e[0].attributes && !I(e[0].attributes.value) ? I(e[0].value) || e[0].value === "" ? $e : {
|
|
704
|
+
value: e[0].value,
|
|
705
|
+
isValid: !0
|
|
706
|
+
} : $e : Qe;
|
|
707
|
+
}
|
|
708
|
+
return Qe;
|
|
709
|
+
}, tt = {
|
|
710
|
+
isValid: !1,
|
|
711
|
+
value: null
|
|
712
|
+
}, nt = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
|
|
713
|
+
isValid: !0,
|
|
714
|
+
value: t.value
|
|
715
|
+
} : e, tt) : tt, rt = (e) => e instanceof RegExp, J = (e) => ({
|
|
716
|
+
isOnSubmit: !e || e === N.onSubmit,
|
|
717
|
+
isOnBlur: e === N.onBlur,
|
|
718
|
+
isOnChange: e === N.onChange,
|
|
719
|
+
isOnAll: e === N.all,
|
|
720
|
+
isOnTouch: e === N.onTouched
|
|
721
|
+
}), it = (e, t, n) => !n && (t.watchAll || t.watch.has(e) || [...t.watch].some((t) => e.startsWith(`${t}.`))), Y = (e, t, n, r) => {
|
|
722
|
+
for (let i of n || Object.keys(e)) {
|
|
723
|
+
let n = R(e, i);
|
|
724
|
+
if (n) {
|
|
725
|
+
let { _f: e, ...a } = n;
|
|
726
|
+
if (e) {
|
|
727
|
+
if (e.refs && e.refs[0] && t(e.refs[0], i) && !r || e.ref && t(e.ref, e.name) && !r) return !0;
|
|
728
|
+
if (Y(a, t)) break;
|
|
729
|
+
} else if (A(a) && Y(a, t)) break;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}, at = (e, t, n) => {
|
|
733
|
+
let r = R(e, n), i = Array.isArray(r) ? r : [];
|
|
734
|
+
return V(i, Ne, t[n]), V(e, n, i), e;
|
|
735
|
+
};
|
|
736
|
+
function ot(e, t, n = "validate") {
|
|
737
|
+
if (W(e) || Array.isArray(e) && e.every(W) || z(e) && !e) return {
|
|
738
|
+
type: n,
|
|
739
|
+
message: W(e) ? e : "",
|
|
740
|
+
ref: t
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
var X = (e) => A(e) && !rt(e) ? e : {
|
|
744
|
+
value: e,
|
|
745
|
+
message: ""
|
|
746
|
+
}, st = async (e, t, n, r, i, a) => {
|
|
747
|
+
let { ref: o, refs: s, required: c, maxLength: l, minLength: u, min: d, max: f, pattern: p, validate: m, name: h, valueAsNumber: g, mount: _ } = e._f, v = R(n, h);
|
|
748
|
+
if (!_ || t.has(h)) return {};
|
|
749
|
+
let y = s ? s[0] : o, b = (e) => {
|
|
750
|
+
i && y.reportValidity && (y.setCustomValidity(z(e) ? "" : e || ""), y.reportValidity());
|
|
751
|
+
}, x = {}, S = Je(o), C = De(o), ee = S || C, w = (g || Ke(o)) && I(o.value) && I(v) || qe(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length, T = We.bind(null, h, r, x), E = (e, t, n, r = P.maxLength, i = P.minLength) => {
|
|
752
|
+
let a = e ? t : n;
|
|
753
|
+
x[h] = {
|
|
754
|
+
type: e ? r : i,
|
|
755
|
+
message: a,
|
|
756
|
+
ref: o,
|
|
757
|
+
...T(e ? r : i, a)
|
|
758
|
+
};
|
|
759
|
+
};
|
|
760
|
+
if (a ? !Array.isArray(v) || !v.length : c && (!ee && (w || k(v)) || z(v) && !v || C && !et(s).isValid || S && !nt(s).isValid)) {
|
|
761
|
+
let { value: e, message: t } = W(c) ? {
|
|
762
|
+
value: !!c,
|
|
763
|
+
message: c
|
|
764
|
+
} : X(c);
|
|
765
|
+
if (e && (x[h] = {
|
|
766
|
+
type: P.required,
|
|
767
|
+
message: t,
|
|
768
|
+
ref: y,
|
|
769
|
+
...T(P.required, t)
|
|
770
|
+
}, !r)) return b(t), x;
|
|
771
|
+
}
|
|
772
|
+
if (!w && (!k(d) || !k(f))) {
|
|
773
|
+
let e, t, n = X(f), i = X(d);
|
|
774
|
+
if (!k(v) && !isNaN(v)) {
|
|
775
|
+
let r = o.valueAsNumber || v && +v;
|
|
776
|
+
k(n.value) || (e = r > n.value), k(i.value) || (t = r < i.value);
|
|
777
|
+
} else {
|
|
778
|
+
let r = o.valueAsDate || new Date(v), a = (e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + e), s = o.type == "time", c = o.type == "week";
|
|
779
|
+
W(n.value) && v && (e = s ? a(v) > a(n.value) : c ? v > n.value : r > new Date(n.value)), W(i.value) && v && (t = s ? a(v) < a(i.value) : c ? v < i.value : r < new Date(i.value));
|
|
780
|
+
}
|
|
781
|
+
if ((e || t) && (E(!!e, n.message, i.message, P.max, P.min), !r)) return b(x[h].message), x;
|
|
782
|
+
}
|
|
783
|
+
if ((l || u) && !w && (W(v) || a && Array.isArray(v))) {
|
|
784
|
+
let e = X(l), t = X(u), n = !k(e.value) && v.length > +e.value, i = !k(t.value) && v.length < +t.value;
|
|
785
|
+
if ((n || i) && (E(n, e.message, t.message), !r)) return b(x[h].message), x;
|
|
786
|
+
}
|
|
787
|
+
if (p && !w && W(v)) {
|
|
788
|
+
let { value: e, message: t } = X(p);
|
|
789
|
+
if (rt(e) && !v.match(e) && (x[h] = {
|
|
790
|
+
type: P.pattern,
|
|
791
|
+
message: t,
|
|
792
|
+
ref: o,
|
|
793
|
+
...T(P.pattern, t)
|
|
794
|
+
}, !r)) return b(t), x;
|
|
795
|
+
}
|
|
796
|
+
if (m) {
|
|
797
|
+
if (B(m)) {
|
|
798
|
+
let e = ot(await m(v, n), y);
|
|
799
|
+
if (e && (x[h] = {
|
|
800
|
+
...e,
|
|
801
|
+
...T(P.validate, e.message)
|
|
802
|
+
}, !r)) return b(e.message), x;
|
|
803
|
+
} else if (A(m)) {
|
|
804
|
+
let e = {};
|
|
805
|
+
for (let t in m) {
|
|
806
|
+
if (!q(e) && !r) break;
|
|
807
|
+
let i = ot(await m[t](v, n), y, t);
|
|
808
|
+
i && (e = {
|
|
809
|
+
...i,
|
|
810
|
+
...T(t, i.message)
|
|
811
|
+
}, b(i.message), r && (x[h] = e));
|
|
812
|
+
}
|
|
813
|
+
if (!q(e) && (x[h] = {
|
|
814
|
+
ref: y,
|
|
815
|
+
...e
|
|
816
|
+
}, !r)) return x;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return b(!0), x;
|
|
820
|
+
};
|
|
821
|
+
N.onSubmit, N.onChange;
|
|
822
|
+
var Z = () => {
|
|
823
|
+
if (typeof crypto < "u" && crypto.randomUUID) return crypto.randomUUID();
|
|
824
|
+
let e = typeof performance > "u" ? Date.now() : performance.now() * 1e3;
|
|
825
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
|
|
826
|
+
let n = (Math.random() * 16 + e) % 16 | 0;
|
|
827
|
+
return (t == "x" ? n : n & 3 | 8).toString(16);
|
|
828
|
+
});
|
|
829
|
+
}, Q = (e, t, n = {}) => n.shouldFocus || I(n.shouldFocus) ? n.focusName || `${e}.${I(n.focusIndex) ? t : n.focusIndex}.` : "", ct = (e, t) => [...e, ...K(t)], lt = (e) => Array.isArray(e) ? e.map(() => void 0) : void 0;
|
|
830
|
+
function ut(e, t, n) {
|
|
831
|
+
return [
|
|
832
|
+
...e.slice(0, t),
|
|
833
|
+
...K(n),
|
|
834
|
+
...e.slice(t)
|
|
835
|
+
];
|
|
836
|
+
}
|
|
837
|
+
var dt = (e, t, n) => Array.isArray(e) ? (I(e[n]) && (e[n] = void 0), e.splice(n, 0, e.splice(t, 1)[0]), e) : [], ft = (e, t) => [...K(t), ...K(e)];
|
|
838
|
+
function pt(e, t) {
|
|
839
|
+
let n = 0, r = [...e];
|
|
840
|
+
for (let e of t) r.splice(e - n, 1), n++;
|
|
841
|
+
return Ge(r).length ? r : [];
|
|
842
|
+
}
|
|
843
|
+
var mt = (e, t) => I(t) ? [] : pt(e, K(t).sort((e, t) => e - t)), $ = (e, t, n) => {
|
|
844
|
+
[e[t], e[n]] = [e[n], e[t]];
|
|
845
|
+
}, ht = (e, t, n) => (e[t] = n, e);
|
|
846
|
+
function gt(e) {
|
|
847
|
+
let t = H(), { control: n = t, name: r, keyName: a = "id", shouldUnregister: o, rules: s } = e, [c, l] = i.useState(n._getFieldArray(r)), u = i.useRef(n._getFieldArray(r).map(Z)), d = i.useRef(!1);
|
|
848
|
+
n._names.array.add(r), i.useMemo(() => s && c.length >= 0 && n.register(r, s), [
|
|
849
|
+
n,
|
|
850
|
+
r,
|
|
851
|
+
c.length,
|
|
852
|
+
s
|
|
853
|
+
]), U(() => n._subjects.array.subscribe({ next: ({ values: e, name: t }) => {
|
|
854
|
+
if (t === r || !t) {
|
|
855
|
+
let n = R(e, r);
|
|
856
|
+
Array.isArray(n) ? (l(n), u.current = n.map(Z)) : t || (l([]), u.current = []);
|
|
857
|
+
}
|
|
858
|
+
} }).unsubscribe, [n, r]);
|
|
859
|
+
let f = i.useCallback((e) => {
|
|
860
|
+
d.current = !0, n._setFieldArray(r, e);
|
|
861
|
+
}, [n, r]);
|
|
862
|
+
return i.useEffect(() => {
|
|
863
|
+
n._state.action = !1, it(r, n._names) && n._subjects.state.next({ ...n._formState });
|
|
864
|
+
let e = J(n._options.mode);
|
|
865
|
+
if (d.current && (!e.isOnSubmit || n._formState.isSubmitted) && !J(n._options.reValidateMode).isOnSubmit && !e.isOnBlur) if (n._options.resolver) n._runSchema([r]).then((e) => {
|
|
866
|
+
n._updateIsValidating([r]);
|
|
867
|
+
let t = R(e.errors, r), i = R(n._formState.errors, r);
|
|
868
|
+
(i ? !t && i.type || t && (i.type !== t.type || i.message !== t.message) : t && t.type) && (t ? V(n._formState.errors, r, t) : Ze(n._formState.errors, r), n._subjects.state.next({ errors: n._formState.errors }));
|
|
869
|
+
});
|
|
870
|
+
else {
|
|
871
|
+
let e = R(n._fields, r);
|
|
872
|
+
e && e._f && !(J(n._options.reValidateMode).isOnSubmit && J(n._options.mode).isOnSubmit) && st(e, n._names.disabled, n._formValues, n._options.criteriaMode === N.all, n._options.shouldUseNativeValidation, !0).then((e) => !q(e) && n._subjects.state.next({ errors: at(n._formState.errors, e, r) }));
|
|
873
|
+
}
|
|
874
|
+
n._subjects.state.next({
|
|
875
|
+
name: r,
|
|
876
|
+
values: M(n._formValues)
|
|
877
|
+
}), n._names.focus && Y(n._fields, (e, t) => {
|
|
878
|
+
if (n._names.focus && t.startsWith(n._names.focus) && e.focus) return e.focus(), 1;
|
|
879
|
+
}), n._names.focus = "", n._setValid(), d.current = !1;
|
|
880
|
+
}, [
|
|
881
|
+
c,
|
|
882
|
+
r,
|
|
883
|
+
n
|
|
884
|
+
]), i.useEffect(() => (!R(n._formValues, r) && n._setFieldArray(r), () => {
|
|
885
|
+
let e = !(n._options.shouldUnregister || o);
|
|
886
|
+
d.current && e && n._subjects.state.next({
|
|
887
|
+
name: r,
|
|
888
|
+
values: M(n._formValues)
|
|
889
|
+
}), e ? ((e, t) => {
|
|
890
|
+
let r = R(n._fields, e);
|
|
891
|
+
r && r._f && (r._f.mount = t);
|
|
892
|
+
})(r, !1) : n.unregister(r);
|
|
893
|
+
}), [
|
|
894
|
+
r,
|
|
895
|
+
n,
|
|
896
|
+
a,
|
|
897
|
+
o
|
|
898
|
+
]), {
|
|
899
|
+
swap: i.useCallback((e, t) => {
|
|
900
|
+
let i = n._getFieldArray(r);
|
|
901
|
+
$(i, e, t), $(u.current, e, t), f(i), l(i), n._setFieldArray(r, i, $, {
|
|
902
|
+
argA: e,
|
|
903
|
+
argB: t
|
|
904
|
+
}, !1);
|
|
905
|
+
}, [
|
|
906
|
+
f,
|
|
907
|
+
r,
|
|
908
|
+
n
|
|
909
|
+
]),
|
|
910
|
+
move: i.useCallback((e, t) => {
|
|
911
|
+
let i = n._getFieldArray(r);
|
|
912
|
+
dt(i, e, t), dt(u.current, e, t), f(i), l(i), n._setFieldArray(r, i, dt, {
|
|
913
|
+
argA: e,
|
|
914
|
+
argB: t
|
|
915
|
+
}, !1);
|
|
916
|
+
}, [
|
|
917
|
+
f,
|
|
918
|
+
r,
|
|
919
|
+
n
|
|
920
|
+
]),
|
|
921
|
+
prepend: i.useCallback((e, t) => {
|
|
922
|
+
let i = K(M(e)), a = ft(n._getFieldArray(r), i);
|
|
923
|
+
n._names.focus = Q(r, 0, t), u.current = ft(u.current, i.map(Z)), f(a), l(a), n._setFieldArray(r, a, ft, { argA: lt(e) });
|
|
924
|
+
}, [
|
|
925
|
+
f,
|
|
926
|
+
r,
|
|
927
|
+
n
|
|
928
|
+
]),
|
|
929
|
+
append: i.useCallback((e, t) => {
|
|
930
|
+
let i = K(M(e)), a = ct(n._getFieldArray(r), i);
|
|
931
|
+
n._names.focus = Q(r, a.length - 1, t), u.current = ct(u.current, i.map(Z)), f(a), l(a), n._setFieldArray(r, a, ct, { argA: lt(e) });
|
|
932
|
+
}, [
|
|
933
|
+
f,
|
|
934
|
+
r,
|
|
935
|
+
n
|
|
936
|
+
]),
|
|
937
|
+
remove: i.useCallback((e) => {
|
|
938
|
+
let t = mt(n._getFieldArray(r), e);
|
|
939
|
+
u.current = mt(u.current, e), f(t), l(t), !Array.isArray(R(n._fields, r)) && V(n._fields, r, void 0), n._setFieldArray(r, t, mt, { argA: e });
|
|
940
|
+
}, [
|
|
941
|
+
f,
|
|
942
|
+
r,
|
|
943
|
+
n
|
|
944
|
+
]),
|
|
945
|
+
insert: i.useCallback((e, t, i) => {
|
|
946
|
+
let a = K(M(t)), o = ut(n._getFieldArray(r), e, a);
|
|
947
|
+
n._names.focus = Q(r, e, i), u.current = ut(u.current, e, a.map(Z)), f(o), l(o), n._setFieldArray(r, o, ut, {
|
|
948
|
+
argA: e,
|
|
949
|
+
argB: lt(t)
|
|
950
|
+
});
|
|
951
|
+
}, [
|
|
952
|
+
f,
|
|
953
|
+
r,
|
|
954
|
+
n
|
|
955
|
+
]),
|
|
956
|
+
update: i.useCallback((e, t) => {
|
|
957
|
+
let i = M(t), a = ht(n._getFieldArray(r), e, i);
|
|
958
|
+
u.current = [...a].map((t, n) => !t || n === e ? Z() : u.current[n]), f(a), l([...a]), n._setFieldArray(r, a, ht, {
|
|
959
|
+
argA: e,
|
|
960
|
+
argB: i
|
|
961
|
+
}, !0, !1);
|
|
962
|
+
}, [
|
|
963
|
+
f,
|
|
964
|
+
r,
|
|
965
|
+
n
|
|
966
|
+
]),
|
|
967
|
+
replace: i.useCallback((e) => {
|
|
968
|
+
let t = K(M(e));
|
|
969
|
+
u.current = t.map(Z), f([...t]), l([...t]), n._setFieldArray(r, [...t], (e) => e, {}, !0, !1);
|
|
970
|
+
}, [
|
|
971
|
+
f,
|
|
972
|
+
r,
|
|
973
|
+
n
|
|
974
|
+
]),
|
|
975
|
+
fields: i.useMemo(() => c.map((e, t) => ({
|
|
976
|
+
...e,
|
|
977
|
+
[a]: u.current[t] || Z()
|
|
978
|
+
})), [c, a])
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/composed/JsonSchemaForm/models/JsonSchemaFormContext.ts
|
|
983
|
+
var _t = a(null);
|
|
984
|
+
function vt() {
|
|
985
|
+
let e = o(_t);
|
|
986
|
+
if (e === null) throw Error("useJsonSchemaFormContext must be used within a <JsonSchemaForm>");
|
|
987
|
+
return e;
|
|
988
|
+
}
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/composed/JsonSchemaForm/utils/fieldErrors.ts
|
|
991
|
+
function yt(e) {
|
|
992
|
+
return e ? e.types ? Object.values(e.types).flat().filter((e) => typeof e == "string").map((e) => ({ message: e })) : [{ message: e.message }] : [];
|
|
993
|
+
}
|
|
994
|
+
//#endregion
|
|
995
|
+
//#region src/composed/JsonSchemaForm/utils/labelOf.ts
|
|
996
|
+
function bt(e) {
|
|
997
|
+
return e ? e.charAt(0).toUpperCase() + e.slice(1) : "Field";
|
|
998
|
+
}
|
|
999
|
+
function xt(e) {
|
|
1000
|
+
return bt(e.split(".").pop());
|
|
1001
|
+
}
|
|
1002
|
+
function St(e, t) {
|
|
1003
|
+
return typeof e.title == "string" && e.title.length > 0 ? e.title : bt(t);
|
|
1004
|
+
}
|
|
1005
|
+
//#endregion
|
|
1006
|
+
//#region src/composed/JsonSchemaForm/fields/banner/SchemaBanner.tsx
|
|
1007
|
+
function Ct({ banner: e }) {
|
|
1008
|
+
let t = "title" in e ? e.title : void 0;
|
|
1009
|
+
return /* @__PURE__ */ u(ue, {
|
|
1010
|
+
role: "note",
|
|
1011
|
+
className: "border-warning/8 bg-warning/4 dark:border-warning/25 dark:bg-warning/8 [&>svg]:text-badge-warning-foreground/85",
|
|
1012
|
+
children: [
|
|
1013
|
+
/* @__PURE__ */ l(n, { "aria-hidden": "true" }),
|
|
1014
|
+
t && /* @__PURE__ */ l(de, {
|
|
1015
|
+
className: "font-semibold text-foreground",
|
|
1016
|
+
children: t
|
|
1017
|
+
}),
|
|
1018
|
+
/* @__PURE__ */ l(fe, {
|
|
1019
|
+
className: "text-muted-foreground [&_code]:rounded-sm [&_code]:bg-warning/8 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-xs [&_code]:text-foreground [&_li]:mt-0.5 [&_strong]:font-medium [&_strong]:text-foreground [&_ul]:ml-4 [&_ul]:list-disc",
|
|
1020
|
+
dangerouslySetInnerHTML: { __html: e.text }
|
|
1021
|
+
})
|
|
1022
|
+
]
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
//#endregion
|
|
1026
|
+
export { g as A, pe as C, D, le as E, y as M, p as N, C as O, m as P, ue as S, de as T, Te as _, _t as a, he as b, gt as c, xe as d, we as f, _e as g, Se as h, yt as i, h as j, ee as k, Ve as l, ve as m, xt as n, vt as o, Ee as p, St as r, He as s, Ct as t, be as u, ge as v, fe as w, me as x, Ce as y };
|