@harnessio/forms 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +194 -175
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var N = (r, e, n) =>
|
|
4
|
-
import { isEmpty as I, cloneDeep as q, set as g, get as _, forOwn as te, isArray as
|
|
5
|
-
import
|
|
1
|
+
var ye = Object.defineProperty;
|
|
2
|
+
var pe = (r, e, n) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var N = (r, e, n) => pe(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as I, cloneDeep as q, set as g, get as _, forOwn as te, isArray as O, isObject as ne, merge as w, isUndefined as F, unset as se, pick as ge, isNull as ae, omitBy as ue, isNil as be, isString as ve, capitalize as _e } from "lodash-es";
|
|
5
|
+
import Re, { createContext as Ee, useContext as Te, useMemo as D, useRef as M, useEffect as j, useCallback as Se, forwardRef as Oe, Fragment as je } from "react";
|
|
6
6
|
import { useFormContext as Ce, get as Ie, useForm as Ve, FormProvider as we, appendErrors as xe, useController as Pe } from "react-hook-form";
|
|
7
7
|
export * from "react-hook-form";
|
|
8
8
|
import * as d from "zod";
|
|
@@ -12,7 +12,7 @@ class Fe extends Error {
|
|
|
12
12
|
super(`Input component '${e}' is already registered.`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
class
|
|
15
|
+
class oe {
|
|
16
16
|
constructor(e) {
|
|
17
17
|
N(this, "componentBank");
|
|
18
18
|
N(this, "allowOverride");
|
|
@@ -47,7 +47,7 @@ class ue {
|
|
|
47
47
|
* @returns new input factory
|
|
48
48
|
*/
|
|
49
49
|
clone() {
|
|
50
|
-
const e = new
|
|
50
|
+
const e = new oe({
|
|
51
51
|
allowOverride: this.allowOverride
|
|
52
52
|
});
|
|
53
53
|
return this.listRegisteredComponents().forEach((n) => {
|
|
@@ -55,7 +55,7 @@ class ue {
|
|
|
55
55
|
}), e;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
var Z = { exports: {} },
|
|
58
|
+
var Z = { exports: {} }, S = {};
|
|
59
59
|
/*
|
|
60
60
|
object-assign
|
|
61
61
|
(c) Sindre Sorhus
|
|
@@ -78,12 +78,12 @@ function Ae() {
|
|
|
78
78
|
var s = new String("abc");
|
|
79
79
|
if (s[5] = "de", Object.getOwnPropertyNames(s)[0] === "5")
|
|
80
80
|
return !1;
|
|
81
|
-
for (var i = {},
|
|
82
|
-
i["_" + String.fromCharCode(
|
|
83
|
-
var
|
|
81
|
+
for (var i = {}, u = 0; u < 10; u++)
|
|
82
|
+
i["_" + String.fromCharCode(u)] = u;
|
|
83
|
+
var o = Object.getOwnPropertyNames(i).map(function(l) {
|
|
84
84
|
return i[l];
|
|
85
85
|
});
|
|
86
|
-
if (
|
|
86
|
+
if (o.join("") !== "0123456789")
|
|
87
87
|
return !1;
|
|
88
88
|
var c = {};
|
|
89
89
|
return "abcdefghijklmnopqrst".split("").forEach(function(l) {
|
|
@@ -94,17 +94,17 @@ function Ae() {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
return B = a() ? Object.assign : function(s, i) {
|
|
97
|
-
for (var
|
|
98
|
-
|
|
99
|
-
for (var m in
|
|
100
|
-
e.call(
|
|
97
|
+
for (var u, o = t(s), c, l = 1; l < arguments.length; l++) {
|
|
98
|
+
u = Object(arguments[l]);
|
|
99
|
+
for (var m in u)
|
|
100
|
+
e.call(u, m) && (o[m] = u[m]);
|
|
101
101
|
if (r) {
|
|
102
|
-
c = r(
|
|
102
|
+
c = r(u);
|
|
103
103
|
for (var f = 0; f < c.length; f++)
|
|
104
|
-
n.call(
|
|
104
|
+
n.call(u, c[f]) && (o[c[f]] = u[c[f]]);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
return
|
|
107
|
+
return o;
|
|
108
108
|
}, B;
|
|
109
109
|
}
|
|
110
110
|
/** @license React v17.0.2
|
|
@@ -117,29 +117,29 @@ function Ae() {
|
|
|
117
117
|
*/
|
|
118
118
|
var Y;
|
|
119
119
|
function ke() {
|
|
120
|
-
if (Y) return
|
|
120
|
+
if (Y) return S;
|
|
121
121
|
Y = 1, Ae();
|
|
122
|
-
var r =
|
|
123
|
-
if (
|
|
122
|
+
var r = Re, e = 60103;
|
|
123
|
+
if (S.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
124
124
|
var n = Symbol.for;
|
|
125
|
-
e = n("react.element"),
|
|
125
|
+
e = n("react.element"), S.Fragment = n("react.fragment");
|
|
126
126
|
}
|
|
127
127
|
var t = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, a = Object.prototype.hasOwnProperty, s = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
128
|
-
function i(
|
|
129
|
-
var l, m = {}, f = null,
|
|
130
|
-
c !== void 0 && (f = "" + c),
|
|
131
|
-
for (l in
|
|
132
|
-
if (
|
|
133
|
-
return { $$typeof: e, type:
|
|
128
|
+
function i(u, o, c) {
|
|
129
|
+
var l, m = {}, f = null, y = null;
|
|
130
|
+
c !== void 0 && (f = "" + c), o.key !== void 0 && (f = "" + o.key), o.ref !== void 0 && (y = o.ref);
|
|
131
|
+
for (l in o) a.call(o, l) && !s.hasOwnProperty(l) && (m[l] = o[l]);
|
|
132
|
+
if (u && u.defaultProps) for (l in o = u.defaultProps, o) m[l] === void 0 && (m[l] = o[l]);
|
|
133
|
+
return { $$typeof: e, type: u, key: f, ref: y, props: m, _owner: t.current };
|
|
134
134
|
}
|
|
135
|
-
return
|
|
135
|
+
return S.jsx = i, S.jsxs = i, S;
|
|
136
136
|
}
|
|
137
137
|
var K;
|
|
138
138
|
function Ne() {
|
|
139
139
|
return K || (K = 1, Z.exports = ke()), Z.exports;
|
|
140
140
|
}
|
|
141
141
|
var h = Ne();
|
|
142
|
-
const ie =
|
|
142
|
+
const ie = Ee({});
|
|
143
143
|
function De({
|
|
144
144
|
children: r,
|
|
145
145
|
metadata: e,
|
|
@@ -174,23 +174,23 @@ function Ze({
|
|
|
174
174
|
withoutWrapper: i = !1
|
|
175
175
|
}) {
|
|
176
176
|
var W;
|
|
177
|
-
const { formState:
|
|
177
|
+
const { formState: u, watch: o } = Ce(), {
|
|
178
178
|
fixedValues: c = {}
|
|
179
179
|
/*getValuesWithDependencies*/
|
|
180
|
-
} = {}, { metadata: l, readonly: m } = Me(), f = e == null ? void 0 : e.getComponent(s.inputType),
|
|
180
|
+
} = {}, { metadata: l, readonly: m } = Me(), f = e == null ? void 0 : e.getComponent(s.inputType), y = o(), b = q(y);
|
|
181
181
|
c && Object.keys(c).forEach((V) => {
|
|
182
182
|
const A = c[V];
|
|
183
183
|
g(b, V, A);
|
|
184
184
|
});
|
|
185
|
-
const
|
|
186
|
-
let
|
|
187
|
-
|
|
185
|
+
const p = !s.isVisible || s.isVisible(b, l);
|
|
186
|
+
let E, R;
|
|
187
|
+
p && (E = m || s.readonly, R = typeof s.disabled == "function" ? s.disabled(b, l) : s.disabled);
|
|
188
188
|
const T = (W = s.warning) == null ? void 0 : W.schema, v = D(() => {
|
|
189
189
|
var H, Q;
|
|
190
|
-
if (!
|
|
191
|
-
const V = Ie(
|
|
190
|
+
if (!p || typeof T > "u") return;
|
|
191
|
+
const V = Ie(y, s.path), A = typeof T == "function" ? T(b) : T, { success: he, error: k } = A.safeParse(V), G = (Q = (H = k == null ? void 0 : k.errors) == null ? void 0 : H[0]) == null ? void 0 : Q.message;
|
|
192
192
|
return !he && G ? G : void 0;
|
|
193
|
-
}, [s.path,
|
|
193
|
+
}, [s.path, y, T, p]), L = D(
|
|
194
194
|
() => ({
|
|
195
195
|
path: r,
|
|
196
196
|
key: r,
|
|
@@ -198,24 +198,24 @@ function Ze({
|
|
|
198
198
|
onUpdate: n,
|
|
199
199
|
onChange: t,
|
|
200
200
|
factory: e,
|
|
201
|
-
readonly:
|
|
201
|
+
readonly: E,
|
|
202
202
|
input: s,
|
|
203
|
-
disabled:
|
|
203
|
+
disabled: R,
|
|
204
204
|
warning: v
|
|
205
205
|
}),
|
|
206
|
-
[e, a, s, t, n, r,
|
|
207
|
-
), me = D(() =>
|
|
206
|
+
[e, a, s, t, n, r, E, u.errors, R, v]
|
|
207
|
+
), me = D(() => p ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
|
|
208
208
|
s.before ? s.before : null,
|
|
209
209
|
f == null ? void 0 : f.renderComponent(L),
|
|
210
210
|
s.after ? s.after : null
|
|
211
|
-
] }) : null, [L, s.after, s.before, f,
|
|
211
|
+
] }) : null, [L, s.after, s.before, f, p, u.errors]);
|
|
212
212
|
return f ? /* @__PURE__ */ h.jsx(z, { withoutWrapper: i, children: me }) : /* @__PURE__ */ h.jsx(z, { withoutWrapper: i, children: /* @__PURE__ */ h.jsxs("p", { children: [
|
|
213
213
|
"Input component not found (internal type: ",
|
|
214
214
|
s.inputType,
|
|
215
215
|
")"
|
|
216
216
|
] }) });
|
|
217
217
|
}
|
|
218
|
-
class
|
|
218
|
+
class ur {
|
|
219
219
|
getType() {
|
|
220
220
|
return this.internalType;
|
|
221
221
|
}
|
|
@@ -229,11 +229,11 @@ function or(r) {
|
|
|
229
229
|
// validateAfterFirstSubmit,
|
|
230
230
|
onValuesChange: s,
|
|
231
231
|
onValidationChange: i,
|
|
232
|
-
onSubmit:
|
|
232
|
+
onSubmit: u,
|
|
233
233
|
// validate,
|
|
234
234
|
// validateDebounceInterval,
|
|
235
235
|
// validationConfig,
|
|
236
|
-
metadata:
|
|
236
|
+
metadata: o,
|
|
237
237
|
children: c,
|
|
238
238
|
// fixedValues
|
|
239
239
|
autoFocusPath: l,
|
|
@@ -244,7 +244,7 @@ function or(r) {
|
|
|
244
244
|
defaultValues: t,
|
|
245
245
|
shouldFocusError: a,
|
|
246
246
|
resolver: n
|
|
247
|
-
}),
|
|
247
|
+
}), y = M(!1);
|
|
248
248
|
j(() => {
|
|
249
249
|
f.reset(t, {});
|
|
250
250
|
}, [f.reset, t]), j(() => {
|
|
@@ -264,14 +264,14 @@ function or(r) {
|
|
|
264
264
|
});
|
|
265
265
|
return () => cancelIdleCallback(v);
|
|
266
266
|
}, []);
|
|
267
|
-
const { getValues: b, handleSubmit:
|
|
267
|
+
const { getValues: b, handleSubmit: p } = f, E = b(), R = M(!0);
|
|
268
268
|
j(() => {
|
|
269
|
-
if (
|
|
270
|
-
|
|
269
|
+
if (R.current) {
|
|
270
|
+
R.current = !1;
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
|
-
s == null || s({ ...
|
|
274
|
-
}, [JSON.stringify(
|
|
273
|
+
s == null || s({ ...E }), y.current === !0 && f.trigger();
|
|
274
|
+
}, [JSON.stringify(E)]);
|
|
275
275
|
const T = M(!0);
|
|
276
276
|
return j(() => {
|
|
277
277
|
if (T.current) {
|
|
@@ -292,25 +292,25 @@ function or(r) {
|
|
|
292
292
|
}, 100);
|
|
293
293
|
return () => clearTimeout(v);
|
|
294
294
|
}
|
|
295
|
-
}, [f]), /* @__PURE__ */ h.jsx(De, { metadata:
|
|
295
|
+
}, [f]), /* @__PURE__ */ h.jsx(De, { metadata: o, readonly: m, children: /* @__PURE__ */ h.jsx(we, { ...f, children: typeof c == "function" ? c({
|
|
296
296
|
...f,
|
|
297
297
|
submitForm: async () => {
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
u && (y.current = !0, p((v) => {
|
|
299
|
+
u(v);
|
|
300
300
|
})());
|
|
301
301
|
}
|
|
302
302
|
}) : c }) });
|
|
303
303
|
}
|
|
304
|
-
const
|
|
304
|
+
const ir = (r) => {
|
|
305
305
|
const e = {}, n = (t) => {
|
|
306
306
|
t.forEach((a) => {
|
|
307
|
-
const { path: s, default: i, inputType:
|
|
308
|
-
(
|
|
307
|
+
const { path: s, default: i, inputType: u, inputs: o } = a;
|
|
308
|
+
(u === "group" || u === "accordion") && Array.isArray(o) ? n(o) : _(e, s) === void 0 && g(e, s, i);
|
|
309
309
|
});
|
|
310
310
|
};
|
|
311
311
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
312
312
|
};
|
|
313
|
-
function
|
|
313
|
+
function cr(r, e) {
|
|
314
314
|
const n = r.inputs.map((t) => {
|
|
315
315
|
const a = Be(e, t.path);
|
|
316
316
|
return a || t;
|
|
@@ -320,7 +320,7 @@ function ir(r, e) {
|
|
|
320
320
|
function Be(r, e) {
|
|
321
321
|
return r.inputs.find((n) => n.path === e);
|
|
322
322
|
}
|
|
323
|
-
const ce = "__temp_",
|
|
323
|
+
const ce = "__temp_", fr = (r) => ce + r.split(".").join("__");
|
|
324
324
|
function $e(r) {
|
|
325
325
|
const e = { ...r };
|
|
326
326
|
return te(e, (n, t) => {
|
|
@@ -332,7 +332,7 @@ function C(r) {
|
|
|
332
332
|
const e = typeof r == "string" ? JSON.parse(r) : r;
|
|
333
333
|
if (typeof e == "string")
|
|
334
334
|
return e;
|
|
335
|
-
if (
|
|
335
|
+
if (O(e))
|
|
336
336
|
return C(e[0]);
|
|
337
337
|
const n = e;
|
|
338
338
|
return ne(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
@@ -351,34 +351,53 @@ function x(r, e, n) {
|
|
|
351
351
|
const {
|
|
352
352
|
_requiredOnly: s,
|
|
353
353
|
_schemaObj: i,
|
|
354
|
-
_input:
|
|
355
|
-
_isList:
|
|
354
|
+
_input: u,
|
|
355
|
+
_isList: o,
|
|
356
356
|
_isArrayItem: c,
|
|
357
357
|
_schema: l
|
|
358
358
|
/*...nestedSchemaObj*/
|
|
359
359
|
} = r[a];
|
|
360
|
-
if (
|
|
361
|
-
const m = d.array(d.object(x(i, e, n))).optional(), f = ee(l,
|
|
360
|
+
if (o && i && u) {
|
|
361
|
+
const m = d.array(d.object(x(i, e, n))).optional(), f = ee(l, u, e, n, m);
|
|
362
362
|
t[a] = f;
|
|
363
|
-
} else if (c &&
|
|
364
|
-
const m = i != null && i.___array ? x({ ___array: i.___array }, e, n) : { ___array: d.any() }, f =
|
|
365
|
-
t[a] =
|
|
366
|
-
} else if (l &&
|
|
367
|
-
const m =
|
|
363
|
+
} else if (c && u) {
|
|
364
|
+
const m = i != null && i.___array ? x({ ___array: i.___array }, e, n) : { ___array: d.any() }, f = Le(m, u, n), y = ee(l, u, e, n, f);
|
|
365
|
+
t[a] = y;
|
|
366
|
+
} else if (l && u) {
|
|
367
|
+
const m = We(l, u, e, n);
|
|
368
368
|
t[a] = m;
|
|
369
|
-
} else s &&
|
|
369
|
+
} else s && u ? t[a] = J(u, n) : t[a] = d.object(x(r[a], e, n)).optional();
|
|
370
370
|
}), t;
|
|
371
371
|
}
|
|
372
|
-
function Le(r, e, n
|
|
372
|
+
function Le(r, e, n) {
|
|
373
|
+
return d.union([
|
|
374
|
+
d.array(r.___array).optional(),
|
|
375
|
+
d.string().superRefine((t, a) => {
|
|
376
|
+
var s;
|
|
377
|
+
if ((s = n == null ? void 0 : n.validationConfig) != null && s.globalValidation) {
|
|
378
|
+
const i = n.validationConfig.globalValidation(t, e, n.metadata);
|
|
379
|
+
if (i.error)
|
|
380
|
+
return a.addIssue({
|
|
381
|
+
code: d.ZodIssueCode.custom,
|
|
382
|
+
message: i.error
|
|
383
|
+
}), !1;
|
|
384
|
+
if (!i.continue)
|
|
385
|
+
return !0;
|
|
386
|
+
}
|
|
387
|
+
return !0;
|
|
388
|
+
})
|
|
389
|
+
]);
|
|
390
|
+
}
|
|
391
|
+
function We(r, e, n, t) {
|
|
373
392
|
return d.any().optional().superRefine(async (a, s) => {
|
|
374
|
-
var
|
|
393
|
+
var u, o;
|
|
375
394
|
if (e.required && !(await J(e, t).safeParseAsync(a)).success)
|
|
376
395
|
return s.addIssue({
|
|
377
396
|
code: d.ZodIssueCode.custom,
|
|
378
397
|
message: $(e, t)
|
|
379
398
|
}), d.NEVER;
|
|
380
|
-
if ((
|
|
381
|
-
const c = (
|
|
399
|
+
if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
|
|
400
|
+
const c = (o = t == null ? void 0 : t.validationConfig) == null ? void 0 : o.globalValidation(a, e, t.metadata);
|
|
382
401
|
if (c.error)
|
|
383
402
|
return s.addIssue({
|
|
384
403
|
code: d.ZodIssueCode.custom,
|
|
@@ -403,12 +422,12 @@ function Le(r, e, n, t) {
|
|
|
403
422
|
function ee(r, e, n, t, a) {
|
|
404
423
|
return d.any().optional().superRefine(async (s, i) => {
|
|
405
424
|
var l, m;
|
|
406
|
-
const
|
|
407
|
-
if (e.required && !
|
|
408
|
-
const f = C(
|
|
425
|
+
const o = await J(e, t).safeParseAsync(s);
|
|
426
|
+
if (e.required && !o.success) {
|
|
427
|
+
const f = C(o.error.message);
|
|
409
428
|
return i.addIssue({ code: d.ZodIssueCode.custom, message: f, fatal: !0 }), d.NEVER;
|
|
410
429
|
}
|
|
411
|
-
if (!e.required && !
|
|
430
|
+
if (!e.required && !o.success)
|
|
412
431
|
return d.NEVER;
|
|
413
432
|
if ((l = t == null ? void 0 : t.validationConfig) != null && l.globalValidation) {
|
|
414
433
|
const f = (m = t == null ? void 0 : t.validationConfig) == null ? void 0 : m.globalValidation(s, e, t.metadata);
|
|
@@ -420,7 +439,7 @@ function ee(r, e, n, t, a) {
|
|
|
420
439
|
if (!f.continue)
|
|
421
440
|
return d.NEVER;
|
|
422
441
|
}
|
|
423
|
-
if (!
|
|
442
|
+
if (!O(s))
|
|
424
443
|
return i.addIssue({
|
|
425
444
|
code: d.ZodIssueCode.custom,
|
|
426
445
|
message: "'Value is not array'"
|
|
@@ -438,11 +457,11 @@ function ee(r, e, n, t, a) {
|
|
|
438
457
|
}
|
|
439
458
|
function P(r, e, n, t, a) {
|
|
440
459
|
e.forEach((s) => {
|
|
441
|
-
var
|
|
460
|
+
var u, o, c, l, m, f, y;
|
|
442
461
|
const i = n;
|
|
443
|
-
if (!s.isVisible || (
|
|
462
|
+
if (!s.isVisible || (u = s.isVisible) != null && u.call(s, i, t == null ? void 0 : t.metadata)) {
|
|
444
463
|
const b = _(r, s.path);
|
|
445
|
-
if ((
|
|
464
|
+
if ((o = s.validation) != null && o.schema ? g(
|
|
446
465
|
r,
|
|
447
466
|
s.path,
|
|
448
467
|
w(b, {
|
|
@@ -450,23 +469,23 @@ function P(r, e, n, t, a) {
|
|
|
450
469
|
_input: s
|
|
451
470
|
})
|
|
452
471
|
) : s.required && g(r, s.path, w(b, { _requiredOnly: !0, _input: s })), s.inputs && P(r, s.inputs, n, t), s.inputType === "list") {
|
|
453
|
-
const
|
|
472
|
+
const p = {};
|
|
454
473
|
P(
|
|
455
|
-
|
|
456
|
-
(m = (l = s.inputConfig) == null ? void 0 : l.inputs) == null ? void 0 : m.map((
|
|
457
|
-
...
|
|
458
|
-
path:
|
|
474
|
+
p,
|
|
475
|
+
(m = (l = s.inputConfig) == null ? void 0 : l.inputs) == null ? void 0 : m.map((R) => ({
|
|
476
|
+
...R,
|
|
477
|
+
path: R.relativePath
|
|
459
478
|
})),
|
|
460
479
|
n,
|
|
461
480
|
t
|
|
462
481
|
);
|
|
463
|
-
const
|
|
464
|
-
g(r, s.path, w(
|
|
482
|
+
const E = _(r, s.path);
|
|
483
|
+
g(r, s.path, w(E, { _schemaObj: p, _isList: !0, _input: s }));
|
|
465
484
|
}
|
|
466
485
|
if (!((f = s.validation) != null && f.schema) && s.inputType === "array") {
|
|
467
|
-
const
|
|
486
|
+
const p = {};
|
|
468
487
|
P(
|
|
469
|
-
|
|
488
|
+
p,
|
|
470
489
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
471
490
|
n,
|
|
472
491
|
t
|
|
@@ -474,8 +493,8 @@ function P(r, e, n, t, a) {
|
|
|
474
493
|
r,
|
|
475
494
|
s.path,
|
|
476
495
|
w(b, {
|
|
477
|
-
_schemaObj:
|
|
478
|
-
_schema: (
|
|
496
|
+
_schemaObj: p,
|
|
497
|
+
_schema: (y = s.validation) == null ? void 0 : y.schema,
|
|
479
498
|
_isArrayItem: !0,
|
|
480
499
|
_input: s
|
|
481
500
|
})
|
|
@@ -489,11 +508,11 @@ function $(r, e) {
|
|
|
489
508
|
return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((a = e == null ? void 0 : e.validationConfig) == null ? void 0 : a.requiredMessage) ?? Je;
|
|
490
509
|
}
|
|
491
510
|
function J(r, e) {
|
|
492
|
-
var t, a, s, i,
|
|
511
|
+
var t, a, s, i, u, o;
|
|
493
512
|
if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
|
|
494
513
|
return (i = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : i[r.inputType];
|
|
495
|
-
if ((
|
|
496
|
-
return (
|
|
514
|
+
if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
|
|
515
|
+
return (o = e == null ? void 0 : e.validationConfig) == null ? void 0 : o.requiredSchema;
|
|
497
516
|
const n = $(r, e);
|
|
498
517
|
return d.any().optional().superRefine((c, l) => {
|
|
499
518
|
typeof c == "object" && I(c) && l.addIssue({
|
|
@@ -511,24 +530,24 @@ function fe(r, e) {
|
|
|
511
530
|
if (typeof r == "function")
|
|
512
531
|
return r(e);
|
|
513
532
|
}
|
|
514
|
-
const
|
|
533
|
+
const Ge = (r) => Array.isArray(r == null ? void 0 : r.errors), He = (r, e) => {
|
|
515
534
|
const n = {};
|
|
516
535
|
for (; r.length; ) {
|
|
517
|
-
const t = r[0], { code: a, message: s, path: i } = t,
|
|
518
|
-
if (!n[
|
|
536
|
+
const t = r[0], { code: a, message: s, path: i } = t, u = i.join(".");
|
|
537
|
+
if (!n[u])
|
|
519
538
|
if ("unionErrors" in t) {
|
|
520
|
-
const
|
|
521
|
-
n[
|
|
522
|
-
message:
|
|
523
|
-
type:
|
|
539
|
+
const o = t.unionErrors[0].errors[0];
|
|
540
|
+
n[u] = {
|
|
541
|
+
message: o.message,
|
|
542
|
+
type: o.code
|
|
524
543
|
};
|
|
525
544
|
} else
|
|
526
|
-
n[
|
|
527
|
-
"unionErrors" in t && t.unionErrors.forEach((
|
|
545
|
+
n[u] = { message: s, type: a };
|
|
546
|
+
"unionErrors" in t && t.unionErrors.forEach((o) => o.errors.forEach((c) => r.push(c)));
|
|
528
547
|
{
|
|
529
|
-
const
|
|
530
|
-
n[
|
|
531
|
-
|
|
548
|
+
const o = n[u].types, c = o && o[t.code];
|
|
549
|
+
n[u] = xe(
|
|
550
|
+
u,
|
|
532
551
|
e,
|
|
533
552
|
n,
|
|
534
553
|
a,
|
|
@@ -539,8 +558,8 @@ const We = (r) => Array.isArray(r == null ? void 0 : r.errors), Ge = (r, e) => {
|
|
|
539
558
|
}
|
|
540
559
|
return n;
|
|
541
560
|
};
|
|
542
|
-
function
|
|
543
|
-
return
|
|
561
|
+
function lr(r, e) {
|
|
562
|
+
return Se(
|
|
544
563
|
async (n, t, a) => {
|
|
545
564
|
try {
|
|
546
565
|
return await Ue(r, n, e).parseAsync(n), {
|
|
@@ -549,10 +568,10 @@ function fr(r, e) {
|
|
|
549
568
|
errors: {}
|
|
550
569
|
};
|
|
551
570
|
} catch (s) {
|
|
552
|
-
if (
|
|
571
|
+
if (Ge(s))
|
|
553
572
|
return {
|
|
554
573
|
values: {},
|
|
555
|
-
errors: qe(
|
|
574
|
+
errors: qe(He(s.errors, !0), a)
|
|
556
575
|
};
|
|
557
576
|
throw s;
|
|
558
577
|
}
|
|
@@ -560,21 +579,21 @@ function fr(r, e) {
|
|
|
560
579
|
[r]
|
|
561
580
|
);
|
|
562
581
|
}
|
|
563
|
-
function
|
|
582
|
+
function Qe(r, e) {
|
|
564
583
|
const n = q(r);
|
|
565
584
|
return e.forEach((t) => {
|
|
566
|
-
t.inputTransform && (
|
|
567
|
-
const i = _(n, t.path),
|
|
568
|
-
|
|
585
|
+
t.inputTransform && (O(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
|
|
586
|
+
const i = _(n, t.path), u = s(i, n);
|
|
587
|
+
u && g(n, u.path ?? t.path, u.value);
|
|
569
588
|
});
|
|
570
589
|
}), n;
|
|
571
590
|
}
|
|
572
|
-
function
|
|
591
|
+
function Xe(r, e) {
|
|
573
592
|
const n = [], t = q(r);
|
|
574
593
|
return e.forEach((a) => {
|
|
575
|
-
a.outputTransform && (
|
|
576
|
-
const
|
|
577
|
-
|
|
594
|
+
a.outputTransform && (O(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((i) => {
|
|
595
|
+
const u = _(t, a.path), o = i(u, t);
|
|
596
|
+
o && (o.path ? (g(t, o.path, o.value), o.unset && n.push(a.path)) : g(t, a.path, o.value));
|
|
578
597
|
});
|
|
579
598
|
}), n.forEach((a) => {
|
|
580
599
|
se(t, a);
|
|
@@ -594,31 +613,31 @@ function le(r) {
|
|
|
594
613
|
}, []);
|
|
595
614
|
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
596
615
|
}
|
|
597
|
-
function
|
|
616
|
+
function Ye(r, e, n, t = {}) {
|
|
598
617
|
const { preserve: a } = t, s = U(r.inputs), i = q(e);
|
|
599
|
-
return s.forEach((
|
|
600
|
-
a && a.includes(
|
|
618
|
+
return s.forEach((u) => {
|
|
619
|
+
a && a.includes(u.path) || u.isVisible && !u.isVisible(e, n) && se(i, u.path);
|
|
601
620
|
}), i;
|
|
602
621
|
}
|
|
603
|
-
function
|
|
622
|
+
function dr(r, e) {
|
|
604
623
|
const n = le(e);
|
|
605
|
-
return
|
|
624
|
+
return Qe(r, n);
|
|
606
625
|
}
|
|
607
|
-
function
|
|
626
|
+
function mr(r, e, n, t = {}) {
|
|
608
627
|
const a = le(e);
|
|
609
|
-
let s =
|
|
610
|
-
return s =
|
|
628
|
+
let s = Ye(e, r, n, t);
|
|
629
|
+
return s = Xe(s, a), s = $e(s), s;
|
|
611
630
|
}
|
|
612
|
-
function
|
|
631
|
+
function hr(r) {
|
|
613
632
|
const e = {}, n = (t) => {
|
|
614
633
|
t.forEach((a) => {
|
|
615
|
-
const { default: s, path: i, inputType:
|
|
616
|
-
(
|
|
634
|
+
const { default: s, path: i, inputType: u, inputs: o } = a;
|
|
635
|
+
(u === "group" || u === "accordion") && Array.isArray(o) ? n(o) : s !== void 0 && g(e, i, s);
|
|
617
636
|
});
|
|
618
637
|
};
|
|
619
638
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
620
639
|
}
|
|
621
|
-
function
|
|
640
|
+
function yr() {
|
|
622
641
|
return function(r, e) {
|
|
623
642
|
if (!(typeof r > "u"))
|
|
624
643
|
return r ? {
|
|
@@ -636,19 +655,19 @@ function pr(r) {
|
|
|
636
655
|
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
637
656
|
};
|
|
638
657
|
}
|
|
639
|
-
function
|
|
658
|
+
function gr() {
|
|
640
659
|
return function(r, e) {
|
|
641
660
|
if (!(typeof r > "u"))
|
|
642
|
-
return
|
|
661
|
+
return O(r) && I(r) ? { value: void 0 } : { value: r };
|
|
643
662
|
};
|
|
644
663
|
}
|
|
645
|
-
function
|
|
664
|
+
function br(r) {
|
|
646
665
|
return function(e, n) {
|
|
647
666
|
const t = r ? _(n, r) : e;
|
|
648
667
|
if (!(typeof t > "u")) {
|
|
649
668
|
if (ae(t)) return { value: void 0, path: r };
|
|
650
669
|
if (ne(t)) {
|
|
651
|
-
const a =
|
|
670
|
+
const a = ue(t, be);
|
|
652
671
|
if (I(a))
|
|
653
672
|
return { value: void 0, path: r };
|
|
654
673
|
}
|
|
@@ -656,25 +675,25 @@ function gr(r) {
|
|
|
656
675
|
}
|
|
657
676
|
};
|
|
658
677
|
}
|
|
659
|
-
function
|
|
678
|
+
function vr() {
|
|
660
679
|
return function(r, e) {
|
|
661
680
|
if (!(typeof r > "u"))
|
|
662
681
|
return ve(r) && I(r) ? { value: void 0 } : { value: r };
|
|
663
682
|
};
|
|
664
683
|
}
|
|
665
|
-
function
|
|
684
|
+
function _r(r) {
|
|
666
685
|
return function(e, n) {
|
|
667
686
|
const t = _(n, r);
|
|
668
687
|
return typeof t == "string" ? { value: t } : { value: e };
|
|
669
688
|
};
|
|
670
689
|
}
|
|
671
|
-
function
|
|
690
|
+
function Rr(r) {
|
|
672
691
|
return function(e, n) {
|
|
673
692
|
if (typeof e > "u") return;
|
|
674
693
|
if (!e) return { value: e };
|
|
675
694
|
const t = _(n, r);
|
|
676
695
|
if (typeof t == "object") {
|
|
677
|
-
const a =
|
|
696
|
+
const a = Ke(t);
|
|
678
697
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
679
698
|
return { value: e, path: r };
|
|
680
699
|
}
|
|
@@ -688,12 +707,12 @@ function Er(r) {
|
|
|
688
707
|
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
689
708
|
};
|
|
690
709
|
}
|
|
691
|
-
function
|
|
710
|
+
function Tr(r, e) {
|
|
692
711
|
return function(n, t) {
|
|
693
712
|
if (typeof n > "u") return;
|
|
694
713
|
if (!n) return { value: n };
|
|
695
714
|
const a = _(t, r);
|
|
696
|
-
if (
|
|
715
|
+
if (O(a)) {
|
|
697
716
|
if (a.length === 1)
|
|
698
717
|
return { value: a[0], path: r };
|
|
699
718
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
@@ -705,8 +724,8 @@ function Rr(r, e) {
|
|
|
705
724
|
function de(r) {
|
|
706
725
|
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !de(r[e])) : F(r);
|
|
707
726
|
}
|
|
708
|
-
function
|
|
709
|
-
return
|
|
727
|
+
function Ke(r) {
|
|
728
|
+
return ue(r, (e) => typeof e == "object" ? de(e) : F(e));
|
|
710
729
|
}
|
|
711
730
|
function re(r) {
|
|
712
731
|
const { items: e, ...n } = r;
|
|
@@ -720,7 +739,7 @@ function re(r) {
|
|
|
720
739
|
`${t.inputType}_${t.path}_${t.label}`
|
|
721
740
|
)) });
|
|
722
741
|
}
|
|
723
|
-
const
|
|
742
|
+
const ze = Oe((r, e) => {
|
|
724
743
|
const { inputs: n, className: t, factory: a, withoutWrapper: s } = r;
|
|
725
744
|
return s ? /* @__PURE__ */ h.jsxs(je, { children: [
|
|
726
745
|
n.hero,
|
|
@@ -730,14 +749,14 @@ const Ke = Se((r, e) => {
|
|
|
730
749
|
/* @__PURE__ */ h.jsx(re, { items: n.inputs, factory: a, withoutWrapper: s })
|
|
731
750
|
] });
|
|
732
751
|
});
|
|
733
|
-
|
|
734
|
-
function
|
|
752
|
+
ze.displayName = "RenderForm";
|
|
753
|
+
function Sr(r) {
|
|
735
754
|
let e = !0;
|
|
736
755
|
return te(r, (n) => {
|
|
737
756
|
e = e && (n === "" || ae(n) || F(n));
|
|
738
757
|
}), e;
|
|
739
758
|
}
|
|
740
|
-
const Or = (r = "") => _e(r.split("_").join(" ")),
|
|
759
|
+
const Or = (r = "") => _e(r.split("_").join(" ")), er = (r, e = 2) => {
|
|
741
760
|
let n = !1;
|
|
742
761
|
const t = () => {
|
|
743
762
|
requestAnimationFrame(() => {
|
|
@@ -748,7 +767,7 @@ const Or = (r = "") => _e(r.split("_").join(" ")), ze = (r, e = 2) => {
|
|
|
748
767
|
n = !0;
|
|
749
768
|
};
|
|
750
769
|
};
|
|
751
|
-
function
|
|
770
|
+
function jr(r) {
|
|
752
771
|
const {
|
|
753
772
|
field: { onBlur: e, ...n },
|
|
754
773
|
...t
|
|
@@ -757,45 +776,45 @@ function Sr(r) {
|
|
|
757
776
|
...t,
|
|
758
777
|
field: {
|
|
759
778
|
...n,
|
|
760
|
-
onBlur:
|
|
779
|
+
onBlur: er(e)
|
|
761
780
|
}
|
|
762
781
|
};
|
|
763
782
|
}
|
|
764
783
|
export {
|
|
765
|
-
|
|
784
|
+
ur as InputComponent,
|
|
766
785
|
Ze as InputComponentRenderer,
|
|
767
|
-
|
|
786
|
+
oe as InputFactory,
|
|
768
787
|
Fe as InputOverrideError,
|
|
769
|
-
|
|
788
|
+
ze as RenderForm,
|
|
770
789
|
re as RenderInputs,
|
|
771
790
|
or as RootForm,
|
|
772
|
-
|
|
791
|
+
er as afterFrames,
|
|
773
792
|
pr as arrayToObjectOutputTransformer,
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
793
|
+
hr as collectDefaultValues,
|
|
794
|
+
dr as convertDataToFormModel,
|
|
795
|
+
mr as convertFormModelToData,
|
|
777
796
|
Or as generateReadableLabel,
|
|
778
|
-
|
|
779
|
-
|
|
797
|
+
ir as getDefaultValuesFromFormDefinition,
|
|
798
|
+
fr as getTemporaryPath,
|
|
780
799
|
le as getTransformers,
|
|
781
800
|
Ue as getValidationSchema,
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
801
|
+
Qe as inputTransformValues,
|
|
802
|
+
Sr as isChildrenEmpty,
|
|
803
|
+
yr as objectToArrayInputTransformer,
|
|
804
|
+
Xe as outputTransformValues,
|
|
805
|
+
cr as overrideFormDefinition,
|
|
787
806
|
C as processValidationParseResponse,
|
|
788
807
|
$e as removeTemporaryFieldsValue,
|
|
789
808
|
Er as shorthandArrayInputTransformer,
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
809
|
+
Tr as shorthandArrayOutputTransformer,
|
|
810
|
+
_r as shorthandObjectInputTransformer,
|
|
811
|
+
Rr as shorthandObjectOutputTransformer,
|
|
812
|
+
gr as unsetEmptyArrayOutputTransformer,
|
|
813
|
+
br as unsetEmptyObjectOutputTransformer,
|
|
814
|
+
vr as unsetEmptyStringOutputTransformer,
|
|
815
|
+
Ye as unsetHiddenInputsValues,
|
|
816
|
+
jr as useController,
|
|
798
817
|
Me as useRootFormContext,
|
|
799
|
-
|
|
818
|
+
lr as useZodValidationResolver
|
|
800
819
|
};
|
|
801
820
|
//# sourceMappingURL=index.js.map
|