@harnessio/forms 0.12.2 → 0.13.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 +116 -104
- package/dist/index.js.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var D = (r, e, n) =>
|
|
4
|
-
import { isEmpty as k, set as S, get as
|
|
5
|
-
import Pe, { createContext as qe, useContext as Ae, Component as ke, memo as Ne, useMemo as $, useRef as O, useEffect as
|
|
1
|
+
var je = Object.defineProperty;
|
|
2
|
+
var we = (r, e, n) => e in r ? je(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 S, get as v, forOwn as me, isArray as I, isObject as he, merge as M, isUndefined as B, cloneDeep as H, unset as pe, pick as Oe, isPlainObject as Ie, 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 O, useEffect as w, useCallback as De, forwardRef as Me, Fragment as $e } from "react";
|
|
6
6
|
import { useFormContext as Ze, get as Be, useForm as We, FormProvider as Je, appendErrors as Ue, useController as Le } from "react-hook-form";
|
|
7
7
|
import { Controller as Ur, 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";
|
|
@@ -138,7 +138,7 @@ var ue;
|
|
|
138
138
|
function Xe() {
|
|
139
139
|
return ue || (ue = 1, W.exports = Qe()), W.exports;
|
|
140
140
|
}
|
|
141
|
-
var
|
|
141
|
+
var p = Xe();
|
|
142
142
|
const ve = qe({});
|
|
143
143
|
function Ye({
|
|
144
144
|
children: r,
|
|
@@ -146,7 +146,7 @@ function Ye({
|
|
|
146
146
|
inputErrorHandler: n,
|
|
147
147
|
readonly: t
|
|
148
148
|
}) {
|
|
149
|
-
return /* @__PURE__ */
|
|
149
|
+
return /* @__PURE__ */ p.jsx(
|
|
150
150
|
ve.Provider,
|
|
151
151
|
{
|
|
152
152
|
value: {
|
|
@@ -181,13 +181,13 @@ class er extends ke {
|
|
|
181
181
|
(o = (s = this.props).inputErrorHandler) == null || o.call(s, a);
|
|
182
182
|
}
|
|
183
183
|
render() {
|
|
184
|
-
return this.state.hasError ? /* @__PURE__ */
|
|
184
|
+
return this.state.hasError ? /* @__PURE__ */ p.jsx(p.Fragment, {}) : this.props.children;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
const ce = ({
|
|
188
188
|
children: r,
|
|
189
189
|
withoutWrapper: e = !1
|
|
190
|
-
}) => e || !r ? r : /* @__PURE__ */
|
|
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: i = !1
|
|
198
198
|
}) {
|
|
199
199
|
var Y, z, ee, re, te;
|
|
200
|
-
const u = Ze(), { formState: c } = u, { fixedValues: f = {} } = {}, { metadata: m, readonly: l, inputErrorHandler: h } = ze(),
|
|
200
|
+
const u = Ze(), { formState: c } = u, { fixedValues: f = {} } = {}, { metadata: m, readonly: l, inputErrorHandler: h } = ze(), y = n == null ? void 0 : n.getComponent(o.inputType), g = !!(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"), x = !!((ee = o.warning) != null && ee.schema || (re = o.validation) != null && re.schema), _ = g ? u.watch() : {}, T = x ? g ? Be(_, o.path) : u.watch(o.path) : void 0, C = $(() => {
|
|
201
201
|
if (!g) return {};
|
|
202
|
-
let F =
|
|
202
|
+
let F = _;
|
|
203
203
|
return f && Object.keys(f).forEach((N) => {
|
|
204
204
|
const P = f[N];
|
|
205
205
|
F = S(F, N, P);
|
|
206
206
|
}), F;
|
|
207
|
-
}, [g,
|
|
207
|
+
}, [g, _, f]), j = !o.isVisible || o.isVisible(C, m), b = l || o.readonly, R = typeof o.disabled == "function" ? o.disabled(C, m) : o.disabled, E = (te = o.warning) == null ? void 0 : te.schema, Q = $(() => {
|
|
208
208
|
var se, ae;
|
|
209
|
-
if (!
|
|
210
|
-
const F = typeof
|
|
209
|
+
if (!j || typeof E > "u") return;
|
|
210
|
+
const F = typeof E == "function" ? E(C, m) : E, { success: N, error: P } = F.safeParse(T), 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, T,
|
|
212
|
+
}, [o.path, T, E, j, m]), X = $(
|
|
213
213
|
() => ({
|
|
214
214
|
path: e,
|
|
215
215
|
key: e,
|
|
@@ -223,18 +223,18 @@ const ce = ({
|
|
|
223
223
|
warning: Q
|
|
224
224
|
}),
|
|
225
225
|
[n, s, o, a, t, e, b, c.errors, R, Q]
|
|
226
|
-
), Ce = $(() =>
|
|
226
|
+
), Ce = $(() => j ? /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
|
|
227
227
|
o.before ? o.before : null,
|
|
228
|
-
/* @__PURE__ */
|
|
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, [j, o.before, o.inputType, o.after, e, y, X, c.errors]);
|
|
231
|
+
return y ? /* @__PURE__ */ p.jsx(ce, { withoutWrapper: i, children: Ce }) : /* @__PURE__ */ p.jsx(ce, { withoutWrapper: i, 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 Sr {
|
|
238
238
|
getType() {
|
|
239
239
|
return this.internalType;
|
|
240
240
|
}
|
|
@@ -280,11 +280,11 @@ function Rr(r) {
|
|
|
280
280
|
defaultValues: t,
|
|
281
281
|
shouldFocusError: a,
|
|
282
282
|
resolver: n
|
|
283
|
-
}),
|
|
284
|
-
|
|
283
|
+
}), y = O(!1), g = O(JSON.stringify(t ?? {}));
|
|
284
|
+
w(() => {
|
|
285
285
|
g.current = JSON.stringify(t ?? {}), h.reset(t, {});
|
|
286
|
-
}, [h.reset, t]),
|
|
287
|
-
const b = fe(), R = le(),
|
|
286
|
+
}, [h.reset, t]), w(() => {
|
|
287
|
+
const b = fe(), R = le(), E = b(() => {
|
|
288
288
|
h.reset({}, {
|
|
289
289
|
keepErrors: !0,
|
|
290
290
|
keepDirty: !0,
|
|
@@ -298,21 +298,21 @@ function Rr(r) {
|
|
|
298
298
|
keepSubmitCount: !0
|
|
299
299
|
});
|
|
300
300
|
});
|
|
301
|
-
return () => R(
|
|
301
|
+
return () => R(E);
|
|
302
302
|
}, []);
|
|
303
|
-
const { handleSubmit: x } = h,
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
const { handleSubmit: x } = h, _ = O(s);
|
|
304
|
+
w(() => {
|
|
305
|
+
_.current = s;
|
|
306
306
|
}, [s]);
|
|
307
307
|
const T = O(o);
|
|
308
|
-
|
|
308
|
+
w(() => {
|
|
309
309
|
T.current = o;
|
|
310
310
|
}, [o]);
|
|
311
311
|
const C = O(!1);
|
|
312
|
-
|
|
312
|
+
w(() => {
|
|
313
313
|
const b = h.watch((R) => {
|
|
314
|
-
var
|
|
315
|
-
C.current || JSON.stringify(R ?? {}) !== g.current && ((
|
|
314
|
+
var E;
|
|
315
|
+
C.current || JSON.stringify(R ?? {}) !== g.current && ((E = _.current) == null || E.call(_, { ...R }), y.current === !0 && (C.current = !0, h.trigger().finally(() => {
|
|
316
316
|
C.current = !1;
|
|
317
317
|
})));
|
|
318
318
|
});
|
|
@@ -320,25 +320,25 @@ function Rr(r) {
|
|
|
320
320
|
b.unsubscribe();
|
|
321
321
|
};
|
|
322
322
|
}, [h]);
|
|
323
|
-
const
|
|
324
|
-
return
|
|
323
|
+
const j = O(!0);
|
|
324
|
+
return w(() => {
|
|
325
325
|
var b;
|
|
326
|
-
if (
|
|
327
|
-
|
|
326
|
+
if (j.current) {
|
|
327
|
+
j.current = !1;
|
|
328
328
|
return;
|
|
329
329
|
}
|
|
330
330
|
(b = T.current) == null || b.call(T, { isValid: h.formState.isValid, isSubmitted: h.formState.isSubmitted });
|
|
331
|
-
}, [h.formState.isValid, h.formState.isSubmitted]),
|
|
331
|
+
}, [h.formState.isValid, h.formState.isSubmitted]), w(() => {
|
|
332
332
|
if (m) {
|
|
333
|
-
const b = fe(), R = le(),
|
|
333
|
+
const b = fe(), R = le(), E = b(() => {
|
|
334
334
|
h.setFocus(m);
|
|
335
335
|
});
|
|
336
|
-
return () => R(
|
|
336
|
+
return () => R(E);
|
|
337
337
|
}
|
|
338
|
-
}, [h, m]), /* @__PURE__ */
|
|
338
|
+
}, [h, m]), /* @__PURE__ */ p.jsx(Ye, { metadata: c, readonly: l, inputErrorHandler: u, children: /* @__PURE__ */ p.jsx(Je, { ...h, children: typeof f == "function" ? f({
|
|
339
339
|
...h,
|
|
340
340
|
submitForm: async () => {
|
|
341
|
-
i && (
|
|
341
|
+
i && (y.current = !0, x((b) => {
|
|
342
342
|
i(b);
|
|
343
343
|
})());
|
|
344
344
|
}
|
|
@@ -348,7 +348,7 @@ const Tr = (r) => {
|
|
|
348
348
|
const e = {}, n = (t) => {
|
|
349
349
|
t.forEach((a) => {
|
|
350
350
|
const { path: s, default: o, inputs: i } = a;
|
|
351
|
-
Array.isArray(i) ? n(i) :
|
|
351
|
+
Array.isArray(i) ? n(i) : v(e, s) === void 0 && S(e, s, o);
|
|
352
352
|
});
|
|
353
353
|
};
|
|
354
354
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
@@ -363,7 +363,7 @@ function Cr(r, e) {
|
|
|
363
363
|
function tr(r, e) {
|
|
364
364
|
return r.inputs.find((n) => n.path === e);
|
|
365
365
|
}
|
|
366
|
-
const Ee = "__temp_",
|
|
366
|
+
const Ee = "__temp_", jr = (r) => Ee + r.split(".").join("__");
|
|
367
367
|
function nr(r) {
|
|
368
368
|
const e = { ...r };
|
|
369
369
|
return me(e, (n, t) => {
|
|
@@ -383,7 +383,7 @@ 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";
|
|
@@ -431,19 +431,19 @@ function A(r, e, n) {
|
|
|
431
431
|
if (u && o && i) {
|
|
432
432
|
const l = d.object(A(o, e, n)), h = d.union([
|
|
433
433
|
d.array(l).optional(),
|
|
434
|
-
|
|
435
|
-
]),
|
|
436
|
-
t[a] =
|
|
434
|
+
_e(i, n)
|
|
435
|
+
]), y = de(m, i, e, n, h);
|
|
436
|
+
t[a] = y;
|
|
437
437
|
} else if (c && i) {
|
|
438
|
-
const l = o != null && o.___array ? A({ ___array: o.___array }, e, n) : { ___array: d.any() }, h = ir(l, i, n),
|
|
439
|
-
t[a] =
|
|
438
|
+
const l = o != null && o.___array ? A({ ___array: o.___array }, e, n) : { ___array: d.any() }, h = ir(l, i, n), y = de(m, i, e, n, h);
|
|
439
|
+
t[a] = y;
|
|
440
440
|
} else if (m && i) {
|
|
441
441
|
const l = ur(m, i, e, n);
|
|
442
442
|
t[a] = l;
|
|
443
443
|
} else s && i ? t[a] = G(i, n) : t[a] = d.object(A(r[a], e, n)).optional();
|
|
444
444
|
}), t;
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function _e(r, e) {
|
|
447
447
|
return d.string().superRefine((n, t) => {
|
|
448
448
|
var a;
|
|
449
449
|
if ((a = e == null ? void 0 : e.validationConfig) != null && a.globalValidation) {
|
|
@@ -460,7 +460,7 @@ function Se(r, e) {
|
|
|
460
460
|
});
|
|
461
461
|
}
|
|
462
462
|
function ir(r, e, n) {
|
|
463
|
-
return d.union([d.array(r.___array).optional(),
|
|
463
|
+
return d.union([d.array(r.___array).optional(), _e(e, n)]);
|
|
464
464
|
}
|
|
465
465
|
function ur(r, e, n, t) {
|
|
466
466
|
return d.any().optional().superRefine(async (a, s) => {
|
|
@@ -480,7 +480,7 @@ function ur(r, e, n, t) {
|
|
|
480
480
|
if (!c.continue)
|
|
481
481
|
return !0;
|
|
482
482
|
}
|
|
483
|
-
const o =
|
|
483
|
+
const o = Se(r, n);
|
|
484
484
|
if (o) {
|
|
485
485
|
const c = await o.safeParseAsync(a);
|
|
486
486
|
if (!c.success) {
|
|
@@ -513,12 +513,12 @@ function de(r, e, n, t, a) {
|
|
|
513
513
|
if (!l.continue)
|
|
514
514
|
return !0;
|
|
515
515
|
}
|
|
516
|
-
if (!
|
|
516
|
+
if (!I(s))
|
|
517
517
|
return o.addIssue({
|
|
518
518
|
code: d.ZodIssueCode.custom,
|
|
519
519
|
message: "'Value is not array'"
|
|
520
520
|
}), d.NEVER;
|
|
521
|
-
const c =
|
|
521
|
+
const c = Se(r, n);
|
|
522
522
|
if (c) {
|
|
523
523
|
const l = await c.safeParseAsync(s);
|
|
524
524
|
if (!l.success)
|
|
@@ -534,26 +534,26 @@ function Z(r, e, n, t, a) {
|
|
|
534
534
|
var i, u, c, f, m, l, h;
|
|
535
535
|
const o = n;
|
|
536
536
|
if (!s.isVisible || (i = s.isVisible) != null && i.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
537
|
-
const
|
|
537
|
+
const y = v(r, s.path);
|
|
538
538
|
if ((u = s.validation) != null && u.schema ? S(
|
|
539
539
|
r,
|
|
540
540
|
s.path,
|
|
541
|
-
M(
|
|
541
|
+
M(y, {
|
|
542
542
|
_schema: (c = s.validation) == null ? void 0 : c.schema,
|
|
543
543
|
_input: s
|
|
544
544
|
})
|
|
545
|
-
) : s.required && S(r, s.path, M(
|
|
545
|
+
) : s.required && S(r, s.path, M(y, { _requiredOnly: !0, _input: s })), s.inputs && Z(r, s.inputs, n, t), s.inputType === "list") {
|
|
546
546
|
const g = {};
|
|
547
547
|
Z(
|
|
548
548
|
g,
|
|
549
|
-
(m = (f = s.inputConfig) == null ? void 0 : f.inputs) == null ? void 0 : m.map((
|
|
550
|
-
...
|
|
551
|
-
path:
|
|
549
|
+
(m = (f = s.inputConfig) == null ? void 0 : f.inputs) == null ? void 0 : m.map((_) => ({
|
|
550
|
+
..._,
|
|
551
|
+
path: _.relativePath
|
|
552
552
|
})),
|
|
553
553
|
n,
|
|
554
554
|
t
|
|
555
555
|
);
|
|
556
|
-
const x =
|
|
556
|
+
const x = v(r, s.path);
|
|
557
557
|
S(r, s.path, M(x, { _schemaObj: g, _isList: !0, _input: s }));
|
|
558
558
|
}
|
|
559
559
|
if (!((l = s.validation) != null && l.schema) && s.inputType === "array") {
|
|
@@ -566,7 +566,7 @@ function Z(r, e, n, t, a) {
|
|
|
566
566
|
), S(
|
|
567
567
|
r,
|
|
568
568
|
s.path,
|
|
569
|
-
M(
|
|
569
|
+
M(y, {
|
|
570
570
|
_schemaObj: g,
|
|
571
571
|
_schema: (h = s.validation) == null ? void 0 : h.schema,
|
|
572
572
|
_isArrayItem: !0,
|
|
@@ -582,7 +582,7 @@ function Z(r, e, n, t, a) {
|
|
|
582
582
|
const u = s.path.split(".");
|
|
583
583
|
u.forEach((c, f) => {
|
|
584
584
|
if (f > 0 && /^\d+$/.test(c)) {
|
|
585
|
-
const m = u.slice(0, f).join("."), l = m ?
|
|
585
|
+
const m = u.slice(0, f).join("."), l = m ? v(r, m) : r;
|
|
586
586
|
l && typeof l == "object" && (l._isTuple = !0);
|
|
587
587
|
}
|
|
588
588
|
});
|
|
@@ -610,7 +610,7 @@ function G(r, e) {
|
|
|
610
610
|
});
|
|
611
611
|
});
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function Se(r, e) {
|
|
614
614
|
if (r instanceof d.ZodType)
|
|
615
615
|
return r;
|
|
616
616
|
if (typeof r == "function")
|
|
@@ -644,7 +644,7 @@ const cr = (r) => Array.isArray(r == null ? void 0 : r.errors), fr = (r, e) => {
|
|
|
644
644
|
}
|
|
645
645
|
return n;
|
|
646
646
|
};
|
|
647
|
-
function
|
|
647
|
+
function wr(r, e) {
|
|
648
648
|
return De(
|
|
649
649
|
async (n, t, a) => {
|
|
650
650
|
try {
|
|
@@ -667,21 +667,28 @@ function Ir(r, e) {
|
|
|
667
667
|
function lr(r, e) {
|
|
668
668
|
const n = H(r);
|
|
669
669
|
return e.forEach((t) => {
|
|
670
|
-
t.inputTransform && (
|
|
671
|
-
|
|
672
|
-
|
|
670
|
+
t.inputTransform && (I(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
|
|
671
|
+
let o;
|
|
672
|
+
const i = t.path.split(".");
|
|
673
|
+
if (i.length > 1) {
|
|
674
|
+
const c = i.slice(0, -1).join("."), f = v(n, c);
|
|
675
|
+
typeof f == "string" || typeof f == "number" || typeof f == "boolean" ? o = void 0 : o = v(n, t.path);
|
|
676
|
+
} else
|
|
677
|
+
o = v(n, t.path);
|
|
678
|
+
const u = s(o, n);
|
|
679
|
+
u && S(n, u.path ?? t.path, u.value);
|
|
673
680
|
});
|
|
674
681
|
}), n;
|
|
675
682
|
}
|
|
676
683
|
function dr(r, e) {
|
|
677
684
|
const n = [], t = H(r);
|
|
678
685
|
return e.forEach((a) => {
|
|
679
|
-
a.outputTransform && (
|
|
680
|
-
const i =
|
|
686
|
+
a.outputTransform && (I(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((o) => {
|
|
687
|
+
const i = v(t, a.path), u = o(i, t);
|
|
681
688
|
u && (u.path ? (S(t, u.path, u.value), u.unset && n.push(a.path)) : S(t, a.path, u.value));
|
|
682
689
|
});
|
|
683
690
|
}), n.forEach((a) => {
|
|
684
|
-
|
|
691
|
+
pe(t, a);
|
|
685
692
|
}), t;
|
|
686
693
|
}
|
|
687
694
|
function K(r) {
|
|
@@ -696,19 +703,19 @@ function Re(r) {
|
|
|
696
703
|
isPrimitive: s
|
|
697
704
|
}), t;
|
|
698
705
|
}, []);
|
|
699
|
-
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level
|
|
706
|
+
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level < a.level ? -1 : 1), n;
|
|
700
707
|
}
|
|
701
708
|
function mr(r, e, n, t = {}) {
|
|
702
709
|
const { preserve: a } = t, s = K(r.inputs), o = H(e);
|
|
703
710
|
return s.forEach((i) => {
|
|
704
|
-
a && a.includes(i.path) || i.isVisible && !i.isVisible(e, n) &&
|
|
711
|
+
a && a.includes(i.path) || i.isVisible && !i.isVisible(e, n) && pe(o, i.path);
|
|
705
712
|
}), o;
|
|
706
713
|
}
|
|
707
714
|
function Or(r, e) {
|
|
708
715
|
const n = Re(e);
|
|
709
716
|
return lr(r, n);
|
|
710
717
|
}
|
|
711
|
-
function
|
|
718
|
+
function Ir(r, e, n, t = {}) {
|
|
712
719
|
const a = Re(e);
|
|
713
720
|
let s = mr(e, r, n, t);
|
|
714
721
|
return s = dr(s, a), s = nr(s), s;
|
|
@@ -725,7 +732,7 @@ function Vr(r) {
|
|
|
725
732
|
function xr() {
|
|
726
733
|
return function(r, e) {
|
|
727
734
|
if (!(typeof r > "u"))
|
|
728
|
-
return !r || !
|
|
735
|
+
return !r || !Ie(r) ? { value: r } : {
|
|
729
736
|
value: Object.getOwnPropertyNames(r).map((n) => ({ key: n, value: r[n] }))
|
|
730
737
|
};
|
|
731
738
|
};
|
|
@@ -733,7 +740,7 @@ function xr() {
|
|
|
733
740
|
function Fr(r) {
|
|
734
741
|
return function(e, n) {
|
|
735
742
|
if (typeof e > "u") return;
|
|
736
|
-
if (!e || !
|
|
743
|
+
if (!e || !I(e)) return { value: e };
|
|
737
744
|
const t = {
|
|
738
745
|
value: e.reduce((a, s) => ({
|
|
739
746
|
...a,
|
|
@@ -746,14 +753,14 @@ function Fr(r) {
|
|
|
746
753
|
function Pr() {
|
|
747
754
|
return function(r, e) {
|
|
748
755
|
if (!(typeof r > "u"))
|
|
749
|
-
return
|
|
756
|
+
return I(r) && k(r) ? { value: void 0 } : { value: r };
|
|
750
757
|
};
|
|
751
758
|
}
|
|
752
759
|
function qr(r) {
|
|
753
760
|
return function(e, n) {
|
|
754
|
-
const t = r ?
|
|
761
|
+
const t = r ? v(n, r) : e;
|
|
755
762
|
if (!(typeof t > "u")) {
|
|
756
|
-
if (
|
|
763
|
+
if (ye(t)) return { value: void 0, path: r };
|
|
757
764
|
if (he(t)) {
|
|
758
765
|
const a = ge(t, Ve);
|
|
759
766
|
if (k(a))
|
|
@@ -771,15 +778,18 @@ function Ar() {
|
|
|
771
778
|
}
|
|
772
779
|
function kr(r) {
|
|
773
780
|
return function(e, n) {
|
|
774
|
-
const t =
|
|
775
|
-
|
|
781
|
+
const t = v(n, r);
|
|
782
|
+
if (typeof t == "string")
|
|
783
|
+
return { value: t };
|
|
784
|
+
if (!(typeof t == "number" || typeof t == "boolean") && e !== void 0)
|
|
785
|
+
return { value: e };
|
|
776
786
|
};
|
|
777
787
|
}
|
|
778
788
|
function Nr(r) {
|
|
779
789
|
return function(e, n) {
|
|
780
790
|
if (typeof e > "u") return;
|
|
781
791
|
if (!e) return { value: e };
|
|
782
|
-
const t =
|
|
792
|
+
const t = v(n, r);
|
|
783
793
|
if (typeof t == "object") {
|
|
784
794
|
const a = hr(t);
|
|
785
795
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
@@ -790,17 +800,19 @@ function Nr(r) {
|
|
|
790
800
|
}
|
|
791
801
|
function Dr(r) {
|
|
792
802
|
return function(e, n) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
803
|
+
const t = v(n, r);
|
|
804
|
+
if (typeof t == "string")
|
|
805
|
+
return { value: [t] };
|
|
806
|
+
if (!(typeof t == "number" || typeof t == "boolean") && e !== void 0)
|
|
807
|
+
return { value: e };
|
|
796
808
|
};
|
|
797
809
|
}
|
|
798
810
|
function Mr(r, e) {
|
|
799
811
|
return function(n, t) {
|
|
800
812
|
if (typeof n > "u") return;
|
|
801
813
|
if (!n) return { value: n };
|
|
802
|
-
const a =
|
|
803
|
-
if (
|
|
814
|
+
const a = v(t, r);
|
|
815
|
+
if (I(a)) {
|
|
804
816
|
if (a.length === 1)
|
|
805
817
|
return { value: a[0], path: r };
|
|
806
818
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
@@ -816,28 +828,28 @@ function hr(r) {
|
|
|
816
828
|
return ge(r, (e) => typeof e == "object" ? Te(e) : B(e));
|
|
817
829
|
}
|
|
818
830
|
function L(r) {
|
|
819
|
-
const { items: e, className: n, withoutWrapper: t = !0, ...a } = r, s = e.map((o) => /* @__PURE__ */
|
|
820
|
-
return t ? /* @__PURE__ */
|
|
831
|
+
const { items: e, className: n, withoutWrapper: t = !0, ...a } = r, s = e.map((o) => /* @__PURE__ */ p.jsx(rr, { input: o, path: o.path, ...a }, `${o.inputType}_${o.path}`));
|
|
832
|
+
return t ? /* @__PURE__ */ p.jsx(p.Fragment, { children: s }) : /* @__PURE__ */ p.jsx("div", { className: n, children: s });
|
|
821
833
|
}
|
|
822
834
|
L.displayName = "RenderInputs";
|
|
823
|
-
const
|
|
835
|
+
const pr = Me((r, e) => {
|
|
824
836
|
const { inputs: n, className: t, factory: a, withoutWrapper: s } = r;
|
|
825
|
-
return s ? /* @__PURE__ */
|
|
837
|
+
return s ? /* @__PURE__ */ p.jsxs($e, { children: [
|
|
826
838
|
n.hero,
|
|
827
|
-
/* @__PURE__ */
|
|
828
|
-
] }) : /* @__PURE__ */
|
|
839
|
+
/* @__PURE__ */ p.jsx(L, { items: n.inputs, factory: a })
|
|
840
|
+
] }) : /* @__PURE__ */ p.jsxs("div", { className: t, ref: e, children: [
|
|
829
841
|
n.hero,
|
|
830
|
-
/* @__PURE__ */
|
|
842
|
+
/* @__PURE__ */ p.jsx(L, { items: n.inputs, factory: a })
|
|
831
843
|
] });
|
|
832
844
|
});
|
|
833
|
-
|
|
845
|
+
pr.displayName = "RenderForm";
|
|
834
846
|
function $r(r) {
|
|
835
847
|
let e = !0;
|
|
836
848
|
return me(r, (n) => {
|
|
837
|
-
e = e && (n === "" ||
|
|
849
|
+
e = e && (n === "" || ye(n) || B(n));
|
|
838
850
|
}), e;
|
|
839
851
|
}
|
|
840
|
-
const Zr = (r = "") => Fe(r.split("_").join(" ")),
|
|
852
|
+
const Zr = (r = "") => Fe(r.split("_").join(" ")), yr = (r, e = 2, n, t = 1e3) => {
|
|
841
853
|
let a = !1;
|
|
842
854
|
const s = () => {
|
|
843
855
|
requestAnimationFrame(() => {
|
|
@@ -858,7 +870,7 @@ function Br(r) {
|
|
|
858
870
|
...t,
|
|
859
871
|
field: {
|
|
860
872
|
...n,
|
|
861
|
-
onBlur:
|
|
873
|
+
onBlur: yr(e, 2, a.current)
|
|
862
874
|
}
|
|
863
875
|
};
|
|
864
876
|
}
|
|
@@ -866,22 +878,22 @@ export {
|
|
|
866
878
|
Ur as Controller,
|
|
867
879
|
Lr as Form,
|
|
868
880
|
Hr as FormProvider,
|
|
869
|
-
|
|
881
|
+
Sr as InputComponent,
|
|
870
882
|
rr as InputComponentRenderer,
|
|
871
883
|
be as InputFactory,
|
|
872
884
|
Ge as InputOverrideError,
|
|
873
|
-
|
|
885
|
+
pr as RenderForm,
|
|
874
886
|
L as RenderInputs,
|
|
875
887
|
Rr as RootForm,
|
|
876
|
-
|
|
888
|
+
yr as afterFrames,
|
|
877
889
|
Fr as arrayToObjectOutputTransformer,
|
|
878
890
|
Vr as collectDefaultValues,
|
|
879
891
|
Or as convertDataToFormModel,
|
|
880
|
-
|
|
892
|
+
Ir as convertFormModelToData,
|
|
881
893
|
Zr as generateReadableLabel,
|
|
882
894
|
Gr as get,
|
|
883
895
|
Tr as getDefaultValuesFromFormDefinition,
|
|
884
|
-
|
|
896
|
+
jr as getTemporaryPath,
|
|
885
897
|
Re as getTransformers,
|
|
886
898
|
ar as getValidationSchema,
|
|
887
899
|
lr as inputTransformValues,
|
|
@@ -907,6 +919,6 @@ export {
|
|
|
907
919
|
zr as useFormState,
|
|
908
920
|
ze as useRootFormContext,
|
|
909
921
|
et as useWatch,
|
|
910
|
-
|
|
922
|
+
wr as useZodValidationResolver
|
|
911
923
|
};
|
|
912
924
|
//# sourceMappingURL=index.js.map
|