@harnessio/forms 0.10.1 → 0.11.1
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 +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +213 -210
- package/dist/index.js.map +1 -1
- package/dist/tests/global-validation.test.d.ts +0 -0
- package/dist/types/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var D = (r, e, n) =>
|
|
4
|
-
import { isEmpty as k, set as E, get as T, forOwn as me, isArray as
|
|
5
|
-
import
|
|
6
|
-
import { useFormContext as
|
|
7
|
-
import { Controller as
|
|
1
|
+
var Ie = Object.defineProperty;
|
|
2
|
+
var we = (r, e, n) => e in r ? Ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var D = (r, e, n) => we(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as k, set as E, get as T, forOwn as me, isArray as I, isObject as he, merge as M, isUndefined as B, cloneDeep as H, unset as pe, pick as je, isPlainObject as Oe, isNull as ye, omitBy as ge, isNil as Ve, isString as xe, capitalize as Fe } from "lodash-es";
|
|
5
|
+
import Pe, { createContext as qe, useContext as Ae, Component as ke, memo as Ne, useMemo as $, useRef as V, useEffect as C, useCallback as De, forwardRef as Me, Fragment as $e } from "react";
|
|
6
|
+
import { useFormContext as Ze, get as Be, useForm as We, FormProvider as Ue, appendErrors as Je, useController as Le } from "react-hook-form";
|
|
7
|
+
import { Controller as Jr, Form as Lr, FormProvider as Hr, get as Gr, set as Kr, useFieldArray as Qr, useForm as Xr, useFormContext as Yr, useFormState as zr, useWatch as et } from "react-hook-form";
|
|
8
8
|
import * as d from "zod";
|
|
9
|
-
import { toNestErrors as
|
|
10
|
-
class
|
|
9
|
+
import { toNestErrors as He } from "@hookform/resolvers";
|
|
10
|
+
class Ge extends Error {
|
|
11
11
|
constructor(e) {
|
|
12
12
|
super(`Input component '${e}' is already registered.`);
|
|
13
13
|
}
|
|
@@ -26,7 +26,7 @@ class be {
|
|
|
26
26
|
*/
|
|
27
27
|
registerComponent(e) {
|
|
28
28
|
if (!this.allowOverride && this.getComponent(e.internalType))
|
|
29
|
-
throw new
|
|
29
|
+
throw new Ge(e.internalType);
|
|
30
30
|
this.componentBank.set(e.internalType, e);
|
|
31
31
|
}
|
|
32
32
|
getComponent(e) {
|
|
@@ -55,14 +55,14 @@ class be {
|
|
|
55
55
|
}), e;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
var W = { exports: {} },
|
|
58
|
+
var W = { exports: {} }, O = {};
|
|
59
59
|
/*
|
|
60
60
|
object-assign
|
|
61
61
|
(c) Sindre Sorhus
|
|
62
62
|
@license MIT
|
|
63
63
|
*/
|
|
64
64
|
var U, oe;
|
|
65
|
-
function
|
|
65
|
+
function Ke() {
|
|
66
66
|
if (oe) return U;
|
|
67
67
|
oe = 1;
|
|
68
68
|
var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
|
|
@@ -116,13 +116,13 @@ function He() {
|
|
|
116
116
|
* LICENSE file in the root directory of this source tree.
|
|
117
117
|
*/
|
|
118
118
|
var ue;
|
|
119
|
-
function
|
|
120
|
-
if (ue) return
|
|
121
|
-
ue = 1,
|
|
122
|
-
var r =
|
|
123
|
-
if (
|
|
119
|
+
function Qe() {
|
|
120
|
+
if (ue) return O;
|
|
121
|
+
ue = 1, Ke();
|
|
122
|
+
var r = Pe, e = 60103;
|
|
123
|
+
if (O.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
124
124
|
var n = Symbol.for;
|
|
125
|
-
e = n("react.element"),
|
|
125
|
+
e = n("react.element"), O.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
128
|
function o(u, i, c) {
|
|
@@ -132,15 +132,15 @@ function Ke() {
|
|
|
132
132
|
if (u && u.defaultProps) for (f in i = u.defaultProps, i) m[f] === void 0 && (m[f] = i[f]);
|
|
133
133
|
return { $$typeof: e, type: u, key: l, ref: h, props: m, _owner: t.current };
|
|
134
134
|
}
|
|
135
|
-
return
|
|
135
|
+
return O.jsx = o, O.jsxs = o, O;
|
|
136
136
|
}
|
|
137
137
|
var ie;
|
|
138
|
-
function
|
|
139
|
-
return ie || (ie = 1, W.exports =
|
|
138
|
+
function Xe() {
|
|
139
|
+
return ie || (ie = 1, W.exports = Qe()), W.exports;
|
|
140
140
|
}
|
|
141
|
-
var p =
|
|
142
|
-
const ve =
|
|
143
|
-
function
|
|
141
|
+
var p = Xe();
|
|
142
|
+
const ve = qe({});
|
|
143
|
+
function Ye({
|
|
144
144
|
children: r,
|
|
145
145
|
metadata: e,
|
|
146
146
|
inputErrorHandler: n,
|
|
@@ -158,11 +158,11 @@ function Qe({
|
|
|
158
158
|
}
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
const r =
|
|
161
|
+
function ze() {
|
|
162
|
+
const r = Ae(ve);
|
|
163
163
|
return r || console.warn("useRootFormContext must be used within RootFormProvider"), r;
|
|
164
164
|
}
|
|
165
|
-
class
|
|
165
|
+
class er extends ke {
|
|
166
166
|
constructor() {
|
|
167
167
|
super(...arguments);
|
|
168
168
|
D(this, "state", {
|
|
@@ -187,7 +187,7 @@ class Ye extends qe {
|
|
|
187
187
|
const ce = ({
|
|
188
188
|
children: r,
|
|
189
189
|
withoutWrapper: e = !1
|
|
190
|
-
}) => e || !r ? r : /* @__PURE__ */ p.jsx("div", { children: r }),
|
|
190
|
+
}) => e || !r ? r : /* @__PURE__ */ p.jsx("div", { children: r }), rr = Ne(function({
|
|
191
191
|
path: e,
|
|
192
192
|
factory: n,
|
|
193
193
|
onUpdate: t,
|
|
@@ -197,19 +197,19 @@ const ce = ({
|
|
|
197
197
|
withoutWrapper: u = !1
|
|
198
198
|
}) {
|
|
199
199
|
var Y, z, ee, re, te;
|
|
200
|
-
const i =
|
|
200
|
+
const i = Ze(), { formState: c } = i, { fixedValues: f = {} } = {}, { metadata: m, readonly: l, inputErrorHandler: h } = ze(), y = n == null ? void 0 : n.getComponent(o.inputType), b = !!(o.isVisible || typeof o.disabled == "function" || typeof ((Y = o.validation) == null ? void 0 : Y.schema) == "function" || typeof ((z = o.warning) == null ? void 0 : z.schema) == "function"), S = !!((ee = o.warning) != null && ee.schema || (re = o.validation) != null && re.schema), v = b ? i.watch() : {}, w = S ? b ? Be(v, o.path) : i.watch(o.path) : void 0, j = $(() => {
|
|
201
201
|
if (!b) return {};
|
|
202
202
|
let F = v;
|
|
203
203
|
return f && Object.keys(f).forEach((N) => {
|
|
204
204
|
const P = f[N];
|
|
205
205
|
F = E(F, N, P);
|
|
206
206
|
}), F;
|
|
207
|
-
}, [b, v, f]),
|
|
207
|
+
}, [b, v, f]), g = !o.isVisible || o.isVisible(j, m), R = l || o.readonly, _ = typeof o.disabled == "function" ? o.disabled(j, m) : o.disabled, x = (te = o.warning) == null ? void 0 : te.schema, Q = $(() => {
|
|
208
208
|
var se, ae;
|
|
209
|
-
if (!
|
|
210
|
-
const F = typeof x == "function" ? x(
|
|
209
|
+
if (!g || typeof x > "u") return;
|
|
210
|
+
const F = typeof x == "function" ? x(j) : x, { success: N, error: P } = F.safeParse(w), ne = (ae = (se = P == null ? void 0 : P.errors) == null ? void 0 : se[0]) == null ? void 0 : ae.message;
|
|
211
211
|
return !N && ne ? ne : void 0;
|
|
212
|
-
}, [o.path,
|
|
212
|
+
}, [o.path, w, x, g]), X = $(
|
|
213
213
|
() => ({
|
|
214
214
|
path: e,
|
|
215
215
|
key: e,
|
|
@@ -217,24 +217,24 @@ const ce = ({
|
|
|
217
217
|
onUpdate: t,
|
|
218
218
|
onChange: a,
|
|
219
219
|
factory: n,
|
|
220
|
-
readonly:
|
|
220
|
+
readonly: R,
|
|
221
221
|
input: o,
|
|
222
222
|
disabled: _,
|
|
223
223
|
warning: Q
|
|
224
224
|
}),
|
|
225
|
-
[n, s, o, a, t, e,
|
|
226
|
-
),
|
|
225
|
+
[n, s, o, a, t, e, R, c.errors, _, Q]
|
|
226
|
+
), Ce = $(() => g ? /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
|
|
227
227
|
o.before ? o.before : null,
|
|
228
|
-
/* @__PURE__ */ p.jsx(
|
|
228
|
+
/* @__PURE__ */ p.jsx(er, { path: e, inputType: o.inputType, inputErrorHandler: h, children: y == null ? void 0 : y.renderComponent(X) }),
|
|
229
229
|
o.after ? o.after : null
|
|
230
|
-
] }) : null, [
|
|
231
|
-
return
|
|
230
|
+
] }) : null, [g, o.before, o.inputType, o.after, e, y, X, c.errors]);
|
|
231
|
+
return y ? /* @__PURE__ */ p.jsx(ce, { withoutWrapper: u, children: Ce }) : /* @__PURE__ */ p.jsx(ce, { withoutWrapper: u, children: /* @__PURE__ */ p.jsxs("p", { children: [
|
|
232
232
|
"Input component not found (internal type: ",
|
|
233
233
|
o.inputType,
|
|
234
234
|
")"
|
|
235
235
|
] }) });
|
|
236
236
|
});
|
|
237
|
-
class
|
|
237
|
+
class _r {
|
|
238
238
|
getType() {
|
|
239
239
|
return this.internalType;
|
|
240
240
|
}
|
|
@@ -255,7 +255,7 @@ function fe() {
|
|
|
255
255
|
function le() {
|
|
256
256
|
return typeof window < "u" && "cancelIdleCallback" in window ? window.cancelIdleCallback : clearTimeout;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function Sr(r) {
|
|
259
259
|
const {
|
|
260
260
|
mode: e = "onSubmit",
|
|
261
261
|
resolver: n,
|
|
@@ -274,17 +274,17 @@ function Tr(r) {
|
|
|
274
274
|
// fixedValues
|
|
275
275
|
autoFocusPath: m,
|
|
276
276
|
readonly: l
|
|
277
|
-
} = r, h =
|
|
277
|
+
} = r, h = We({
|
|
278
278
|
mode: e,
|
|
279
279
|
reValidateMode: "onChange",
|
|
280
280
|
defaultValues: t,
|
|
281
281
|
shouldFocusError: a,
|
|
282
282
|
resolver: n
|
|
283
|
-
}),
|
|
283
|
+
}), y = V(!1);
|
|
284
284
|
C(() => {
|
|
285
285
|
h.reset(t, {});
|
|
286
286
|
}, [h.reset, t]), C(() => {
|
|
287
|
-
const
|
|
287
|
+
const g = fe(), R = le(), _ = g(() => {
|
|
288
288
|
h.reset({}, {
|
|
289
289
|
keepErrors: !0,
|
|
290
290
|
keepDirty: !0,
|
|
@@ -298,53 +298,53 @@ function Tr(r) {
|
|
|
298
298
|
keepSubmitCount: !0
|
|
299
299
|
});
|
|
300
300
|
});
|
|
301
|
-
return () =>
|
|
301
|
+
return () => R(_);
|
|
302
302
|
}, []);
|
|
303
|
-
const { handleSubmit: b } = h,
|
|
303
|
+
const { handleSubmit: b } = h, S = V(s);
|
|
304
304
|
C(() => {
|
|
305
|
-
|
|
305
|
+
S.current = s;
|
|
306
306
|
}, [s]);
|
|
307
|
-
const v =
|
|
307
|
+
const v = V(o);
|
|
308
308
|
C(() => {
|
|
309
309
|
v.current = o;
|
|
310
310
|
}, [o]);
|
|
311
|
-
const
|
|
311
|
+
const w = V(!1);
|
|
312
312
|
C(() => {
|
|
313
|
-
const
|
|
313
|
+
const g = h.watch((R) => {
|
|
314
314
|
var _;
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
w.current || ((_ = S.current) == null || _.call(S, { ...R }), y.current === !0 && (w.current = !0, h.trigger().finally(() => {
|
|
316
|
+
w.current = !1;
|
|
317
317
|
})));
|
|
318
318
|
});
|
|
319
319
|
return () => {
|
|
320
|
-
|
|
320
|
+
g.unsubscribe();
|
|
321
321
|
};
|
|
322
322
|
}, [h]);
|
|
323
|
-
const
|
|
323
|
+
const j = V(!0);
|
|
324
324
|
return C(() => {
|
|
325
|
-
var
|
|
326
|
-
if (
|
|
327
|
-
|
|
325
|
+
var g;
|
|
326
|
+
if (j.current) {
|
|
327
|
+
j.current = !1;
|
|
328
328
|
return;
|
|
329
329
|
}
|
|
330
|
-
(
|
|
330
|
+
(g = v.current) == null || g.call(v, { isValid: h.formState.isValid, isSubmitted: h.formState.isSubmitted });
|
|
331
331
|
}, [h.formState.isValid, h.formState.isSubmitted]), C(() => {
|
|
332
332
|
if (m) {
|
|
333
|
-
const
|
|
333
|
+
const g = fe(), R = le(), _ = g(() => {
|
|
334
334
|
h.setFocus(m);
|
|
335
335
|
});
|
|
336
|
-
return () =>
|
|
336
|
+
return () => R(_);
|
|
337
337
|
}
|
|
338
|
-
}, [h, m]), /* @__PURE__ */ p.jsx(
|
|
338
|
+
}, [h, m]), /* @__PURE__ */ p.jsx(Ye, { metadata: c, readonly: l, inputErrorHandler: i, children: /* @__PURE__ */ p.jsx(Ue, { ...h, children: typeof f == "function" ? f({
|
|
339
339
|
...h,
|
|
340
340
|
submitForm: async () => {
|
|
341
|
-
u && (
|
|
342
|
-
u(
|
|
341
|
+
u && (y.current = !0, b((g) => {
|
|
342
|
+
u(g);
|
|
343
343
|
})());
|
|
344
344
|
}
|
|
345
345
|
}) : f }) });
|
|
346
346
|
}
|
|
347
|
-
const
|
|
347
|
+
const Rr = (r) => {
|
|
348
348
|
const e = {}, n = (t) => {
|
|
349
349
|
t.forEach((a) => {
|
|
350
350
|
const { path: s, default: o, inputType: u, inputs: i } = a;
|
|
@@ -353,24 +353,24 @@ const _r = (r) => {
|
|
|
353
353
|
};
|
|
354
354
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
355
355
|
};
|
|
356
|
-
function
|
|
356
|
+
function Cr(r, e) {
|
|
357
357
|
const n = r.inputs.map((t) => {
|
|
358
|
-
const a =
|
|
358
|
+
const a = tr(e, t.path);
|
|
359
359
|
return a || t;
|
|
360
360
|
});
|
|
361
361
|
return { ...r, inputs: n };
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function tr(r, e) {
|
|
364
364
|
return r.inputs.find((n) => n.path === e);
|
|
365
365
|
}
|
|
366
|
-
const Ee = "__temp_",
|
|
367
|
-
function
|
|
366
|
+
const Ee = "__temp_", Ir = (r) => Ee + r.split(".").join("__");
|
|
367
|
+
function nr(r) {
|
|
368
368
|
const e = { ...r };
|
|
369
369
|
return me(e, (n, t) => {
|
|
370
370
|
t.startsWith(Ee) && delete e[t];
|
|
371
371
|
}), e;
|
|
372
372
|
}
|
|
373
|
-
const
|
|
373
|
+
const sr = "Required field";
|
|
374
374
|
function q(r) {
|
|
375
375
|
let e;
|
|
376
376
|
if (typeof r == "string")
|
|
@@ -383,12 +383,12 @@ function q(r) {
|
|
|
383
383
|
e = r;
|
|
384
384
|
if (typeof e == "string")
|
|
385
385
|
return e;
|
|
386
|
-
if (
|
|
386
|
+
if (I(e))
|
|
387
387
|
return q(e[0]);
|
|
388
388
|
const n = e;
|
|
389
389
|
return he(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function ar(r, e, n) {
|
|
392
392
|
let t = {};
|
|
393
393
|
if (Z(t, r.inputs, e, n), n != null && n.prefix) {
|
|
394
394
|
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
@@ -396,7 +396,7 @@ function nr(r, e, n) {
|
|
|
396
396
|
}
|
|
397
397
|
return d.object(A(t, e, n));
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function or(r, e, n) {
|
|
400
400
|
const t = Object.keys(r).filter((o) => /^\d+$/.test(o) && !o.startsWith("_")).map((o) => parseInt(o, 10)).sort((o, u) => o - u);
|
|
401
401
|
if (t.length === 0) return null;
|
|
402
402
|
const a = Math.max(...t), s = [];
|
|
@@ -422,47 +422,50 @@ function A(r, e, n) {
|
|
|
422
422
|
/*...nestedSchemaObj*/
|
|
423
423
|
} = r[a];
|
|
424
424
|
if (f && !i && !c) {
|
|
425
|
-
const l =
|
|
425
|
+
const l = or(r[a], e, n);
|
|
426
426
|
if (l) {
|
|
427
427
|
t[a] = l;
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
if (i && o && u) {
|
|
432
|
-
const l = d.
|
|
433
|
-
|
|
432
|
+
const l = d.object(A(o, e, n)), h = d.union([
|
|
433
|
+
d.array(l).optional(),
|
|
434
|
+
Te(u, n)
|
|
435
|
+
]), y = de(m, u, e, n, h);
|
|
436
|
+
t[a] = y;
|
|
434
437
|
} else if (c && u) {
|
|
435
|
-
const l = o != null && o.___array ? A({ ___array: o.___array }, e, n) : { ___array: d.any() }, h =
|
|
436
|
-
t[a] =
|
|
438
|
+
const l = o != null && o.___array ? A({ ___array: o.___array }, e, n) : { ___array: d.any() }, h = ur(l, u, n), y = de(m, u, e, n, h);
|
|
439
|
+
t[a] = y;
|
|
437
440
|
} else if (m && u) {
|
|
438
|
-
const l =
|
|
441
|
+
const l = ir(m, u, e, n);
|
|
439
442
|
t[a] = l;
|
|
440
|
-
} else s && u ? t[a] =
|
|
443
|
+
} else s && u ? t[a] = G(u, n) : t[a] = d.object(A(r[a], e, n)).optional();
|
|
441
444
|
}), t;
|
|
442
445
|
}
|
|
443
|
-
function
|
|
444
|
-
return d.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
if (
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
]);
|
|
446
|
+
function Te(r, e) {
|
|
447
|
+
return d.string().superRefine((n, t) => {
|
|
448
|
+
var a;
|
|
449
|
+
if ((a = e == null ? void 0 : e.validationConfig) != null && a.globalValidation) {
|
|
450
|
+
const s = e.validationConfig.globalValidation(n, r, e.metadata);
|
|
451
|
+
if (s.error)
|
|
452
|
+
return t.addIssue({
|
|
453
|
+
code: d.ZodIssueCode.custom,
|
|
454
|
+
message: s.error
|
|
455
|
+
}), !1;
|
|
456
|
+
if (!s.continue)
|
|
457
|
+
return !0;
|
|
458
|
+
}
|
|
459
|
+
return !0;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function ur(r, e, n) {
|
|
463
|
+
return d.union([d.array(r.___array).optional(), Te(e, n)]);
|
|
461
464
|
}
|
|
462
|
-
function
|
|
465
|
+
function ir(r, e, n, t) {
|
|
463
466
|
return d.any().optional().superRefine(async (a, s) => {
|
|
464
467
|
var u, i;
|
|
465
|
-
if (e.required && !(await
|
|
468
|
+
if (e.required && !(await G(e, t).safeParseAsync(a)).success)
|
|
466
469
|
return s.addIssue({
|
|
467
470
|
code: d.ZodIssueCode.custom,
|
|
468
471
|
message: J(e, t)
|
|
@@ -477,7 +480,7 @@ function or(r, e, n, t) {
|
|
|
477
480
|
if (!c.continue)
|
|
478
481
|
return !0;
|
|
479
482
|
}
|
|
480
|
-
const o =
|
|
483
|
+
const o = _e(r, n);
|
|
481
484
|
if (o) {
|
|
482
485
|
const c = await o.safeParseAsync(a);
|
|
483
486
|
if (!c.success) {
|
|
@@ -493,7 +496,7 @@ function or(r, e, n, t) {
|
|
|
493
496
|
function de(r, e, n, t, a) {
|
|
494
497
|
return d.any().optional().superRefine(async (s, o) => {
|
|
495
498
|
var f, m;
|
|
496
|
-
const i = await
|
|
499
|
+
const i = await G(e, t).safeParseAsync(s);
|
|
497
500
|
if (e.required && !i.success) {
|
|
498
501
|
const l = q(i.error.message);
|
|
499
502
|
return o.addIssue({ code: d.ZodIssueCode.custom, message: l, fatal: !0 }), d.NEVER;
|
|
@@ -508,14 +511,14 @@ function de(r, e, n, t, a) {
|
|
|
508
511
|
message: q(l.error)
|
|
509
512
|
}), d.NEVER;
|
|
510
513
|
if (!l.continue)
|
|
511
|
-
return
|
|
514
|
+
return !0;
|
|
512
515
|
}
|
|
513
|
-
if (!
|
|
516
|
+
if (!I(s))
|
|
514
517
|
return o.addIssue({
|
|
515
518
|
code: d.ZodIssueCode.custom,
|
|
516
519
|
message: "'Value is not array'"
|
|
517
520
|
}), d.NEVER;
|
|
518
|
-
const c =
|
|
521
|
+
const c = _e(r, n);
|
|
519
522
|
if (c) {
|
|
520
523
|
const l = await c.safeParseAsync(s);
|
|
521
524
|
if (!l.success)
|
|
@@ -531,15 +534,15 @@ function Z(r, e, n, t, a) {
|
|
|
531
534
|
var u, i, c, f, m, l, h;
|
|
532
535
|
const o = n;
|
|
533
536
|
if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
534
|
-
const
|
|
537
|
+
const y = T(r, s.path);
|
|
535
538
|
if ((i = s.validation) != null && i.schema ? E(
|
|
536
539
|
r,
|
|
537
540
|
s.path,
|
|
538
|
-
M(
|
|
541
|
+
M(y, {
|
|
539
542
|
_schema: (c = s.validation) == null ? void 0 : c.schema,
|
|
540
543
|
_input: s
|
|
541
544
|
})
|
|
542
|
-
) : s.required && E(r, s.path, M(
|
|
545
|
+
) : s.required && E(r, s.path, M(y, { _requiredOnly: !0, _input: s })), s.inputs && Z(r, s.inputs, n, t), s.inputType === "list") {
|
|
543
546
|
const b = {};
|
|
544
547
|
Z(
|
|
545
548
|
b,
|
|
@@ -550,8 +553,8 @@ function Z(r, e, n, t, a) {
|
|
|
550
553
|
n,
|
|
551
554
|
t
|
|
552
555
|
);
|
|
553
|
-
const
|
|
554
|
-
E(r, s.path, M(
|
|
556
|
+
const S = T(r, s.path);
|
|
557
|
+
E(r, s.path, M(S, { _schemaObj: b, _isList: !0, _input: s }));
|
|
555
558
|
}
|
|
556
559
|
if (!((l = s.validation) != null && l.schema) && s.inputType === "array") {
|
|
557
560
|
const b = {};
|
|
@@ -563,7 +566,7 @@ function Z(r, e, n, t, a) {
|
|
|
563
566
|
), E(
|
|
564
567
|
r,
|
|
565
568
|
s.path,
|
|
566
|
-
M(
|
|
569
|
+
M(y, {
|
|
567
570
|
_schemaObj: b,
|
|
568
571
|
_schema: (h = s.validation) == null ? void 0 : h.schema,
|
|
569
572
|
_isArrayItem: !0,
|
|
@@ -575,7 +578,7 @@ function Z(r, e, n, t, a) {
|
|
|
575
578
|
}), e.forEach((s) => {
|
|
576
579
|
var u;
|
|
577
580
|
const o = n;
|
|
578
|
-
if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
581
|
+
if ((!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) && s.path) {
|
|
579
582
|
const i = s.path.split(".");
|
|
580
583
|
i.forEach((c, f) => {
|
|
581
584
|
if (f > 0 && /^\d+$/.test(c)) {
|
|
@@ -588,9 +591,9 @@ function Z(r, e, n, t, a) {
|
|
|
588
591
|
}
|
|
589
592
|
function J(r, e) {
|
|
590
593
|
var n, t, a;
|
|
591
|
-
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) ??
|
|
594
|
+
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) ?? sr;
|
|
592
595
|
}
|
|
593
|
-
function
|
|
596
|
+
function G(r, e) {
|
|
594
597
|
var t, a, s, o, u, i;
|
|
595
598
|
if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
|
|
596
599
|
return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
|
|
@@ -607,13 +610,13 @@ function K(r, e) {
|
|
|
607
610
|
});
|
|
608
611
|
});
|
|
609
612
|
}
|
|
610
|
-
function
|
|
613
|
+
function _e(r, e) {
|
|
611
614
|
if (r instanceof d.ZodType)
|
|
612
615
|
return r;
|
|
613
616
|
if (typeof r == "function")
|
|
614
617
|
return r(e);
|
|
615
618
|
}
|
|
616
|
-
const
|
|
619
|
+
const cr = (r) => Array.isArray(r == null ? void 0 : r.errors), fr = (r, e) => {
|
|
617
620
|
const n = {};
|
|
618
621
|
for (; r.length; ) {
|
|
619
622
|
const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
|
|
@@ -629,7 +632,7 @@ const ur = (r) => Array.isArray(r == null ? void 0 : r.errors), ir = (r, e) => {
|
|
|
629
632
|
"unionErrors" in t && t.unionErrors.forEach((i) => i.errors.forEach((c) => r.push(c)));
|
|
630
633
|
{
|
|
631
634
|
const i = n[u].types, c = i && i[t.code];
|
|
632
|
-
n[u] =
|
|
635
|
+
n[u] = Je(
|
|
633
636
|
u,
|
|
634
637
|
e,
|
|
635
638
|
n,
|
|
@@ -641,19 +644,19 @@ const ur = (r) => Array.isArray(r == null ? void 0 : r.errors), ir = (r, e) => {
|
|
|
641
644
|
}
|
|
642
645
|
return n;
|
|
643
646
|
};
|
|
644
|
-
function
|
|
645
|
-
return
|
|
647
|
+
function wr(r, e) {
|
|
648
|
+
return De(
|
|
646
649
|
async (n, t, a) => {
|
|
647
650
|
try {
|
|
648
|
-
return await
|
|
651
|
+
return await ar(r, n, e).parseAsync(n), {
|
|
649
652
|
values: n,
|
|
650
653
|
errors: {}
|
|
651
654
|
};
|
|
652
655
|
} catch (s) {
|
|
653
|
-
if (
|
|
656
|
+
if (cr(s))
|
|
654
657
|
return {
|
|
655
658
|
values: {},
|
|
656
|
-
errors:
|
|
659
|
+
errors: He(fr(s.errors, !0), a)
|
|
657
660
|
};
|
|
658
661
|
throw s;
|
|
659
662
|
}
|
|
@@ -661,19 +664,19 @@ function Cr(r, e) {
|
|
|
661
664
|
[r, e]
|
|
662
665
|
);
|
|
663
666
|
}
|
|
664
|
-
function
|
|
667
|
+
function lr(r, e) {
|
|
665
668
|
const n = H(r);
|
|
666
669
|
return e.forEach((t) => {
|
|
667
|
-
t.inputTransform && (
|
|
670
|
+
t.inputTransform && (I(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
|
|
668
671
|
const o = T(n, t.path), u = s(o, n);
|
|
669
672
|
u && E(n, u.path ?? t.path, u.value);
|
|
670
673
|
});
|
|
671
674
|
}), n;
|
|
672
675
|
}
|
|
673
|
-
function
|
|
676
|
+
function dr(r, e) {
|
|
674
677
|
const n = [], t = H(r);
|
|
675
678
|
return e.forEach((a) => {
|
|
676
|
-
a.outputTransform && (
|
|
679
|
+
a.outputTransform && (I(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((o) => {
|
|
677
680
|
const u = T(t, a.path), i = o(u, t);
|
|
678
681
|
i && (i.path ? (E(t, i.path, i.value), i.unset && n.push(a.path)) : E(t, a.path, i.value));
|
|
679
682
|
});
|
|
@@ -681,36 +684,36 @@ function fr(r, e) {
|
|
|
681
684
|
pe(t, a);
|
|
682
685
|
}), t;
|
|
683
686
|
}
|
|
684
|
-
function
|
|
685
|
-
return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...
|
|
687
|
+
function K(r) {
|
|
688
|
+
return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...K(t.inputs)] : [...n, t], []);
|
|
686
689
|
}
|
|
687
|
-
function
|
|
688
|
-
const n =
|
|
690
|
+
function Se(r) {
|
|
691
|
+
const n = K(r.inputs).reduce((t, a) => {
|
|
689
692
|
const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
|
|
690
693
|
return (a.inputTransform || a.outputTransform) && t.push({
|
|
691
|
-
...
|
|
694
|
+
...je(a, "path", "inputTransform", "outputTransform"),
|
|
692
695
|
level: a.path.split(".").length,
|
|
693
696
|
isPrimitive: s
|
|
694
697
|
}), t;
|
|
695
698
|
}, []);
|
|
696
699
|
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
697
700
|
}
|
|
698
|
-
function
|
|
699
|
-
const { preserve: a } = t, s =
|
|
701
|
+
function mr(r, e, n, t = {}) {
|
|
702
|
+
const { preserve: a } = t, s = K(r.inputs), o = H(e);
|
|
700
703
|
return s.forEach((u) => {
|
|
701
704
|
a && a.includes(u.path) || u.isVisible && !u.isVisible(e, n) && pe(o, u.path);
|
|
702
705
|
}), o;
|
|
703
706
|
}
|
|
704
|
-
function
|
|
705
|
-
const n =
|
|
706
|
-
return
|
|
707
|
+
function jr(r, e) {
|
|
708
|
+
const n = Se(e);
|
|
709
|
+
return lr(r, n);
|
|
707
710
|
}
|
|
708
|
-
function
|
|
709
|
-
const a =
|
|
710
|
-
let s =
|
|
711
|
-
return s =
|
|
711
|
+
function Or(r, e, n, t = {}) {
|
|
712
|
+
const a = Se(e);
|
|
713
|
+
let s = mr(e, r, n, t);
|
|
714
|
+
return s = dr(s, a), s = nr(s), s;
|
|
712
715
|
}
|
|
713
|
-
function
|
|
716
|
+
function Vr(r) {
|
|
714
717
|
const e = {}, n = (t) => {
|
|
715
718
|
t.forEach((a) => {
|
|
716
719
|
const { default: s, path: o, inputType: u, inputs: i } = a;
|
|
@@ -719,18 +722,18 @@ function jr(r) {
|
|
|
719
722
|
};
|
|
720
723
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
721
724
|
}
|
|
722
|
-
function
|
|
725
|
+
function xr() {
|
|
723
726
|
return function(r, e) {
|
|
724
727
|
if (!(typeof r > "u"))
|
|
725
|
-
return r ? {
|
|
728
|
+
return !r || !Oe(r) ? { value: r } : {
|
|
726
729
|
value: Object.getOwnPropertyNames(r).map((n) => ({ key: n, value: r[n] }))
|
|
727
|
-
}
|
|
730
|
+
};
|
|
728
731
|
};
|
|
729
732
|
}
|
|
730
|
-
function
|
|
733
|
+
function Fr(r) {
|
|
731
734
|
return function(e, n) {
|
|
732
735
|
if (typeof e > "u") return;
|
|
733
|
-
if (!e) return { value: e };
|
|
736
|
+
if (!e || !I(e)) return { value: e };
|
|
734
737
|
const t = {
|
|
735
738
|
value: e.reduce((a, s) => ({
|
|
736
739
|
...a,
|
|
@@ -740,19 +743,19 @@ function Vr(r) {
|
|
|
740
743
|
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
741
744
|
};
|
|
742
745
|
}
|
|
743
|
-
function
|
|
746
|
+
function Pr() {
|
|
744
747
|
return function(r, e) {
|
|
745
748
|
if (!(typeof r > "u"))
|
|
746
|
-
return
|
|
749
|
+
return I(r) && k(r) ? { value: void 0 } : { value: r };
|
|
747
750
|
};
|
|
748
751
|
}
|
|
749
|
-
function
|
|
752
|
+
function qr(r) {
|
|
750
753
|
return function(e, n) {
|
|
751
754
|
const t = r ? T(n, r) : e;
|
|
752
755
|
if (!(typeof t > "u")) {
|
|
753
756
|
if (ye(t)) return { value: void 0, path: r };
|
|
754
757
|
if (he(t)) {
|
|
755
|
-
const a = ge(t,
|
|
758
|
+
const a = ge(t, Ve);
|
|
756
759
|
if (k(a))
|
|
757
760
|
return { value: void 0, path: r };
|
|
758
761
|
}
|
|
@@ -760,44 +763,44 @@ function Fr(r) {
|
|
|
760
763
|
}
|
|
761
764
|
};
|
|
762
765
|
}
|
|
763
|
-
function
|
|
766
|
+
function Ar() {
|
|
764
767
|
return function(r, e) {
|
|
765
768
|
if (!(typeof r > "u"))
|
|
766
|
-
return
|
|
769
|
+
return xe(r) && k(r) ? { value: void 0 } : { value: r };
|
|
767
770
|
};
|
|
768
771
|
}
|
|
769
|
-
function
|
|
772
|
+
function kr(r) {
|
|
770
773
|
return function(e, n) {
|
|
771
774
|
const t = T(n, r);
|
|
772
775
|
return typeof t == "string" ? { value: t } : { value: e };
|
|
773
776
|
};
|
|
774
777
|
}
|
|
775
|
-
function
|
|
778
|
+
function Nr(r) {
|
|
776
779
|
return function(e, n) {
|
|
777
780
|
if (typeof e > "u") return;
|
|
778
781
|
if (!e) return { value: e };
|
|
779
782
|
const t = T(n, r);
|
|
780
783
|
if (typeof t == "object") {
|
|
781
|
-
const a =
|
|
784
|
+
const a = hr(t);
|
|
782
785
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
783
786
|
return { value: e, path: r };
|
|
784
787
|
}
|
|
785
788
|
return { value: e };
|
|
786
789
|
};
|
|
787
790
|
}
|
|
788
|
-
function
|
|
791
|
+
function Dr(r) {
|
|
789
792
|
return function(e, n) {
|
|
790
793
|
if (typeof e > "u") return;
|
|
791
794
|
const t = T(n, r);
|
|
792
795
|
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
793
796
|
};
|
|
794
797
|
}
|
|
795
|
-
function
|
|
798
|
+
function Mr(r, e) {
|
|
796
799
|
return function(n, t) {
|
|
797
800
|
if (typeof n > "u") return;
|
|
798
801
|
if (!n) return { value: n };
|
|
799
802
|
const a = T(t, r);
|
|
800
|
-
if (
|
|
803
|
+
if (I(a)) {
|
|
801
804
|
if (a.length === 1)
|
|
802
805
|
return { value: a[0], path: r };
|
|
803
806
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
@@ -809,13 +812,13 @@ function Nr(r, e) {
|
|
|
809
812
|
function Re(r) {
|
|
810
813
|
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !Re(r[e])) : B(r);
|
|
811
814
|
}
|
|
812
|
-
function
|
|
815
|
+
function hr(r) {
|
|
813
816
|
return ge(r, (e) => typeof e == "object" ? Re(e) : B(e));
|
|
814
817
|
}
|
|
815
818
|
function L(r) {
|
|
816
819
|
const { items: e, ...n } = r;
|
|
817
820
|
return /* @__PURE__ */ p.jsx(p.Fragment, { children: e.map((t) => /* @__PURE__ */ p.jsx(
|
|
818
|
-
|
|
821
|
+
rr,
|
|
819
822
|
{
|
|
820
823
|
input: t,
|
|
821
824
|
path: t.path,
|
|
@@ -825,9 +828,9 @@ function L(r) {
|
|
|
825
828
|
)) });
|
|
826
829
|
}
|
|
827
830
|
L.displayName = "RenderInputs";
|
|
828
|
-
const
|
|
831
|
+
const pr = Me((r, e) => {
|
|
829
832
|
const { inputs: n, className: t, factory: a, withoutWrapper: s } = r;
|
|
830
|
-
return s ? /* @__PURE__ */ p.jsxs(
|
|
833
|
+
return s ? /* @__PURE__ */ p.jsxs($e, { children: [
|
|
831
834
|
n.hero,
|
|
832
835
|
/* @__PURE__ */ p.jsx(L, { items: n.inputs, factory: a, withoutWrapper: s })
|
|
833
836
|
] }) : /* @__PURE__ */ p.jsxs("div", { className: t, ref: e, children: [
|
|
@@ -835,14 +838,14 @@ const mr = Ne((r, e) => {
|
|
|
835
838
|
/* @__PURE__ */ p.jsx(L, { items: n.inputs, factory: a, withoutWrapper: s })
|
|
836
839
|
] });
|
|
837
840
|
});
|
|
838
|
-
|
|
839
|
-
function
|
|
841
|
+
pr.displayName = "RenderForm";
|
|
842
|
+
function $r(r) {
|
|
840
843
|
let e = !0;
|
|
841
844
|
return me(r, (n) => {
|
|
842
845
|
e = e && (n === "" || ye(n) || B(n));
|
|
843
846
|
}), e;
|
|
844
847
|
}
|
|
845
|
-
const
|
|
848
|
+
const Zr = (r = "") => Fe(r.split("_").join(" ")), yr = (r, e = 2, n, t = 1e3) => {
|
|
846
849
|
let a = !1;
|
|
847
850
|
const s = () => {
|
|
848
851
|
requestAnimationFrame(() => {
|
|
@@ -854,64 +857,64 @@ const Mr = (r = "") => Ve(r.split("_").join(" ")), hr = (r, e = 2, n, t = 1e3) =
|
|
|
854
857
|
a = !0;
|
|
855
858
|
});
|
|
856
859
|
};
|
|
857
|
-
function
|
|
860
|
+
function Br(r) {
|
|
858
861
|
const {
|
|
859
862
|
field: { onBlur: e, ...n },
|
|
860
863
|
...t
|
|
861
|
-
} =
|
|
864
|
+
} = Le(r), a = V(Date.now());
|
|
862
865
|
return {
|
|
863
866
|
...t,
|
|
864
867
|
field: {
|
|
865
868
|
...n,
|
|
866
|
-
onBlur:
|
|
869
|
+
onBlur: yr(e, 2, a.current)
|
|
867
870
|
}
|
|
868
871
|
};
|
|
869
872
|
}
|
|
870
873
|
export {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
874
|
+
Jr as Controller,
|
|
875
|
+
Lr as Form,
|
|
876
|
+
Hr as FormProvider,
|
|
877
|
+
_r as InputComponent,
|
|
878
|
+
rr as InputComponentRenderer,
|
|
876
879
|
be as InputFactory,
|
|
877
|
-
|
|
878
|
-
|
|
880
|
+
Ge as InputOverrideError,
|
|
881
|
+
pr as RenderForm,
|
|
879
882
|
L as RenderInputs,
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
883
|
+
Sr as RootForm,
|
|
884
|
+
yr as afterFrames,
|
|
885
|
+
Fr as arrayToObjectOutputTransformer,
|
|
886
|
+
Vr as collectDefaultValues,
|
|
887
|
+
jr as convertDataToFormModel,
|
|
888
|
+
Or as convertFormModelToData,
|
|
889
|
+
Zr as generateReadableLabel,
|
|
890
|
+
Gr as get,
|
|
891
|
+
Rr as getDefaultValuesFromFormDefinition,
|
|
892
|
+
Ir as getTemporaryPath,
|
|
893
|
+
Se as getTransformers,
|
|
894
|
+
ar as getValidationSchema,
|
|
895
|
+
lr as inputTransformValues,
|
|
896
|
+
$r as isChildrenEmpty,
|
|
897
|
+
xr as objectToArrayInputTransformer,
|
|
898
|
+
dr as outputTransformValues,
|
|
899
|
+
Cr as overrideFormDefinition,
|
|
897
900
|
q as processValidationParseResponse,
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
901
|
+
nr as removeTemporaryFieldsValue,
|
|
902
|
+
Kr as set,
|
|
903
|
+
Dr as shorthandArrayInputTransformer,
|
|
904
|
+
Mr as shorthandArrayOutputTransformer,
|
|
905
|
+
kr as shorthandObjectInputTransformer,
|
|
906
|
+
Nr as shorthandObjectOutputTransformer,
|
|
907
|
+
Pr as unsetEmptyArrayOutputTransformer,
|
|
908
|
+
qr as unsetEmptyObjectOutputTransformer,
|
|
909
|
+
Ar as unsetEmptyStringOutputTransformer,
|
|
910
|
+
mr as unsetHiddenInputsValues,
|
|
911
|
+
Br as useController,
|
|
912
|
+
Qr as useFieldArray,
|
|
913
|
+
Xr as useForm,
|
|
914
|
+
Yr as useFormContext,
|
|
915
|
+
zr as useFormState,
|
|
916
|
+
ze as useRootFormContext,
|
|
917
|
+
et as useWatch,
|
|
918
|
+
wr as useZodValidationResolver
|
|
916
919
|
};
|
|
917
920
|
//# sourceMappingURL=index.js.map
|