@harnessio/forms 0.3.0-beta.1 → 0.4.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/core/transformers/transformers.d.ts +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +120 -118
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var N = (r, e, n) =>
|
|
4
|
-
import { isEmpty as
|
|
5
|
-
import
|
|
6
|
-
import { useFormContext as
|
|
1
|
+
var pe = Object.defineProperty;
|
|
2
|
+
var ye = (r, e, n) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var N = (r, e, n) => ye(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as I, cloneDeep as q, set as y, get as v, forOwn as te, isArray as S, isObject as ne, merge as w, isUndefined as F, unset as se, pick as ge, isNull as ae, omitBy as oe, isNil as be, isString as ve, capitalize as _e } from "lodash-es";
|
|
5
|
+
import Ee, { createContext as Re, useContext as Te, useMemo as D, useRef as M, useEffect as j, useCallback as Oe, forwardRef as Se, Fragment as je } from "react";
|
|
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";
|
|
9
9
|
import { toNestErrors as qe } from "@hookform/resolvers";
|
|
@@ -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 ue {
|
|
16
16
|
constructor(e) {
|
|
17
17
|
N(this, "componentBank");
|
|
18
18
|
N(this, "allowOverride");
|
|
@@ -30,7 +30,7 @@ class oe {
|
|
|
30
30
|
this.componentBank.set(e.internalType, e);
|
|
31
31
|
}
|
|
32
32
|
getComponent(e) {
|
|
33
|
-
if (e && !
|
|
33
|
+
if (e && !I(e))
|
|
34
34
|
return this.componentBank.get(e);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -47,7 +47,7 @@ class oe {
|
|
|
47
47
|
* @returns new input factory
|
|
48
48
|
*/
|
|
49
49
|
clone() {
|
|
50
|
-
const e = new
|
|
50
|
+
const e = new ue({
|
|
51
51
|
allowOverride: this.allowOverride
|
|
52
52
|
});
|
|
53
53
|
return this.listRegisteredComponents().forEach((n) => {
|
|
@@ -119,7 +119,7 @@ var Y;
|
|
|
119
119
|
function ke() {
|
|
120
120
|
if (Y) return O;
|
|
121
121
|
Y = 1, Ae();
|
|
122
|
-
var r =
|
|
122
|
+
var r = Ee, e = 60103;
|
|
123
123
|
if (O.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
124
124
|
var n = Symbol.for;
|
|
125
125
|
e = n("react.element"), O.Fragment = n("react.fragment");
|
|
@@ -139,14 +139,14 @@ function Ne() {
|
|
|
139
139
|
return K || (K = 1, Z.exports = ke()), Z.exports;
|
|
140
140
|
}
|
|
141
141
|
var p = Ne();
|
|
142
|
-
const
|
|
142
|
+
const ie = Re({});
|
|
143
143
|
function De({
|
|
144
144
|
children: r,
|
|
145
145
|
metadata: e,
|
|
146
146
|
readonly: n
|
|
147
147
|
}) {
|
|
148
148
|
return /* @__PURE__ */ p.jsx(
|
|
149
|
-
|
|
149
|
+
ie.Provider,
|
|
150
150
|
{
|
|
151
151
|
value: {
|
|
152
152
|
metadata: e,
|
|
@@ -157,7 +157,7 @@ function De({
|
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
function Me() {
|
|
160
|
-
const r = Te(
|
|
160
|
+
const r = Te(ie);
|
|
161
161
|
return r || console.warn("useRootFormContext must be used within RootFormProvider"), r;
|
|
162
162
|
}
|
|
163
163
|
const z = ({
|
|
@@ -174,23 +174,23 @@ function Ze({
|
|
|
174
174
|
withoutWrapper: i = !1
|
|
175
175
|
}) {
|
|
176
176
|
var W;
|
|
177
|
-
const { formState: o, watch: u } =
|
|
177
|
+
const { formState: o, watch: u } = Ce(), {
|
|
178
178
|
fixedValues: c = {}
|
|
179
179
|
/*getValuesWithDependencies*/
|
|
180
180
|
} = {}, { metadata: l, readonly: m } = Me(), f = e == null ? void 0 : e.getComponent(s.inputType), h = u(), _ = q(h);
|
|
181
|
-
c && Object.keys(c).forEach((
|
|
182
|
-
const A = c[
|
|
183
|
-
|
|
181
|
+
c && Object.keys(c).forEach((V) => {
|
|
182
|
+
const A = c[V];
|
|
183
|
+
y(_, V, A);
|
|
184
184
|
});
|
|
185
|
-
const
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
const
|
|
185
|
+
const g = !s.isVisible || s.isVisible(_, l);
|
|
186
|
+
let R, T;
|
|
187
|
+
g && (R = m || s.readonly, T = typeof s.disabled == "function" ? s.disabled(_, l) : s.disabled);
|
|
188
|
+
const E = (W = s.warning) == null ? void 0 : W.schema, b = D(() => {
|
|
189
189
|
var H, Q;
|
|
190
|
-
if (!
|
|
191
|
-
const
|
|
192
|
-
return !
|
|
193
|
-
}, [s.path, h,
|
|
190
|
+
if (!g || typeof E > "u") return;
|
|
191
|
+
const V = Ie(h, s.path), A = typeof E == "function" ? E(_) : E, { 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
|
+
return !he && G ? G : void 0;
|
|
193
|
+
}, [s.path, h, E, g]), L = D(
|
|
194
194
|
() => ({
|
|
195
195
|
path: r,
|
|
196
196
|
key: r,
|
|
@@ -198,18 +198,18 @@ function Ze({
|
|
|
198
198
|
onUpdate: n,
|
|
199
199
|
onChange: t,
|
|
200
200
|
factory: e,
|
|
201
|
-
readonly:
|
|
201
|
+
readonly: R,
|
|
202
202
|
input: s,
|
|
203
203
|
disabled: T,
|
|
204
|
-
warning:
|
|
204
|
+
warning: b
|
|
205
205
|
}),
|
|
206
|
-
[e, a, s, t, n, r,
|
|
207
|
-
),
|
|
206
|
+
[e, a, s, t, n, r, R, o.errors, T, b]
|
|
207
|
+
), me = D(() => g ? /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
|
|
208
208
|
s.before ? s.before : null,
|
|
209
|
-
f == null ? void 0 : f.renderComponent(
|
|
209
|
+
f == null ? void 0 : f.renderComponent(L),
|
|
210
210
|
s.after ? s.after : null
|
|
211
|
-
] }) : null, [
|
|
212
|
-
return f ? /* @__PURE__ */ p.jsx(z, { withoutWrapper: i, children:
|
|
211
|
+
] }) : null, [L, s.after, s.before, f, g, o.errors]);
|
|
212
|
+
return f ? /* @__PURE__ */ p.jsx(z, { withoutWrapper: i, children: me }) : /* @__PURE__ */ p.jsx(z, { withoutWrapper: i, children: /* @__PURE__ */ p.jsxs("p", { children: [
|
|
213
213
|
"Input component not found (internal type: ",
|
|
214
214
|
s.inputType,
|
|
215
215
|
")"
|
|
@@ -238,7 +238,7 @@ function or(r) {
|
|
|
238
238
|
// fixedValues
|
|
239
239
|
autoFocusPath: l,
|
|
240
240
|
readonly: m
|
|
241
|
-
} = r, f =
|
|
241
|
+
} = r, f = Ve({
|
|
242
242
|
mode: e ?? "onSubmit",
|
|
243
243
|
reValidateMode: "onChange",
|
|
244
244
|
defaultValues: t,
|
|
@@ -248,7 +248,7 @@ function or(r) {
|
|
|
248
248
|
j(() => {
|
|
249
249
|
f.reset(t, {});
|
|
250
250
|
}, [f.reset, t]), j(() => {
|
|
251
|
-
const
|
|
251
|
+
const b = requestIdleCallback(() => {
|
|
252
252
|
f.reset({}, {
|
|
253
253
|
keepErrors: !0,
|
|
254
254
|
keepDirty: !0,
|
|
@@ -262,41 +262,41 @@ function or(r) {
|
|
|
262
262
|
keepSubmitCount: !0
|
|
263
263
|
});
|
|
264
264
|
});
|
|
265
|
-
return () => cancelIdleCallback(
|
|
265
|
+
return () => cancelIdleCallback(b);
|
|
266
266
|
}, []);
|
|
267
|
-
const { getValues: _, handleSubmit:
|
|
267
|
+
const { getValues: _, handleSubmit: g } = f, R = _(), T = M(!0);
|
|
268
268
|
j(() => {
|
|
269
269
|
if (T.current) {
|
|
270
270
|
T.current = !1;
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
|
-
s == null || s({ ...
|
|
274
|
-
}, [JSON.stringify(
|
|
275
|
-
const
|
|
273
|
+
s == null || s({ ...R }), h.current === !0 && f.trigger();
|
|
274
|
+
}, [JSON.stringify(R)]);
|
|
275
|
+
const E = M(!0);
|
|
276
276
|
return j(() => {
|
|
277
|
-
if (
|
|
278
|
-
|
|
277
|
+
if (E.current) {
|
|
278
|
+
E.current = !1;
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
i == null || i({ isValid: f.formState.isValid, isSubmitted: f.formState.isSubmitted });
|
|
282
282
|
}, [f.formState.isValid, f.formState.isSubmitted]), j(() => {
|
|
283
283
|
if (l)
|
|
284
284
|
if ("requestIdleCallback" in window) {
|
|
285
|
-
const
|
|
285
|
+
const b = requestIdleCallback(() => {
|
|
286
286
|
f.setFocus(l);
|
|
287
287
|
});
|
|
288
|
-
return () => cancelIdleCallback(
|
|
288
|
+
return () => cancelIdleCallback(b);
|
|
289
289
|
} else {
|
|
290
|
-
const
|
|
290
|
+
const b = setTimeout(() => {
|
|
291
291
|
f.setFocus(l);
|
|
292
292
|
}, 100);
|
|
293
|
-
return () => clearTimeout(
|
|
293
|
+
return () => clearTimeout(b);
|
|
294
294
|
}
|
|
295
|
-
}, [f]), /* @__PURE__ */ p.jsx(De, { metadata: u, readonly: m, children: /* @__PURE__ */ p.jsx(
|
|
295
|
+
}, [f]), /* @__PURE__ */ p.jsx(De, { metadata: u, readonly: m, children: /* @__PURE__ */ p.jsx(we, { ...f, children: typeof c == "function" ? c({
|
|
296
296
|
...f,
|
|
297
297
|
submitForm: async () => {
|
|
298
|
-
o && (h.current = !0,
|
|
299
|
-
o(
|
|
298
|
+
o && (h.current = !0, g((b) => {
|
|
299
|
+
o(b);
|
|
300
300
|
})());
|
|
301
301
|
}
|
|
302
302
|
}) : c }) });
|
|
@@ -305,7 +305,7 @@ const ur = (r) => {
|
|
|
305
305
|
const e = {}, n = (t) => {
|
|
306
306
|
t.forEach((a) => {
|
|
307
307
|
const { path: s, default: i, inputType: o, inputs: u } = a;
|
|
308
|
-
(o === "group" || o === "accordion") && Array.isArray(u) ? n(u) :
|
|
308
|
+
(o === "group" || o === "accordion") && Array.isArray(u) ? n(u) : v(e, s) === void 0 && y(e, s, i);
|
|
309
309
|
});
|
|
310
310
|
};
|
|
311
311
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
@@ -320,28 +320,28 @@ function ir(r, e) {
|
|
|
320
320
|
function Be(r, e) {
|
|
321
321
|
return r.inputs.find((n) => n.path === e);
|
|
322
322
|
}
|
|
323
|
-
const
|
|
323
|
+
const ce = "__temp_", cr = (r) => ce + r.split(".").join("__");
|
|
324
324
|
function $e(r) {
|
|
325
325
|
const e = { ...r };
|
|
326
326
|
return te(e, (n, t) => {
|
|
327
|
-
t.startsWith(
|
|
327
|
+
t.startsWith(ce) && delete e[t];
|
|
328
328
|
}), e;
|
|
329
329
|
}
|
|
330
330
|
const Je = "Required field";
|
|
331
|
-
function
|
|
331
|
+
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
335
|
if (S(e))
|
|
336
|
-
return
|
|
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";
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function Ue(r, e, n) {
|
|
341
341
|
let t = {};
|
|
342
342
|
if (P(t, r.inputs, e, n), n != null && n.prefix) {
|
|
343
343
|
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
344
|
-
t =
|
|
344
|
+
t = y({}, s, t);
|
|
345
345
|
}
|
|
346
346
|
return d.object(x(t, e, n));
|
|
347
347
|
}
|
|
@@ -364,12 +364,12 @@ function x(r, e, n) {
|
|
|
364
364
|
const m = i != null && i.___array ? x({ ___array: i.___array }, e, n) : { ___array: d.any() }, f = d.array(m.___array).optional(), h = ee(l, o, e, n, f);
|
|
365
365
|
t[a] = h;
|
|
366
366
|
} else if (l && o) {
|
|
367
|
-
const m =
|
|
367
|
+
const m = Le(l, o, e, n);
|
|
368
368
|
t[a] = m;
|
|
369
369
|
} else s && o ? t[a] = J(o, n) : t[a] = d.object(x(r[a], e, n)).optional();
|
|
370
370
|
}), t;
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function Le(r, e, n, t) {
|
|
373
373
|
return d.any().optional().superRefine(async (a, s) => {
|
|
374
374
|
var o, u;
|
|
375
375
|
if (e.required && !(await J(e, t).safeParseAsync(a)).success)
|
|
@@ -387,11 +387,11 @@ function Ue(r, e, n, t) {
|
|
|
387
387
|
if (!c.continue)
|
|
388
388
|
return !0;
|
|
389
389
|
}
|
|
390
|
-
const i =
|
|
390
|
+
const i = fe(r, n);
|
|
391
391
|
if (i) {
|
|
392
392
|
const c = await i.safeParseAsync(a);
|
|
393
393
|
if (!c.success) {
|
|
394
|
-
const l =
|
|
394
|
+
const l = C(c == null ? void 0 : c.error.message), m = l === "Required" ? $(e, t) : l;
|
|
395
395
|
s.addIssue({
|
|
396
396
|
code: d.ZodIssueCode.custom,
|
|
397
397
|
message: m
|
|
@@ -405,7 +405,7 @@ function ee(r, e, n, t, a) {
|
|
|
405
405
|
var l, m;
|
|
406
406
|
const u = await J(e, t).safeParseAsync(s);
|
|
407
407
|
if (e.required && !u.success) {
|
|
408
|
-
const f =
|
|
408
|
+
const f = C(u.error.message);
|
|
409
409
|
return i.addIssue({ code: d.ZodIssueCode.custom, message: f, fatal: !0 }), d.NEVER;
|
|
410
410
|
}
|
|
411
411
|
if (!e.required && !u.success)
|
|
@@ -415,7 +415,7 @@ function ee(r, e, n, t, a) {
|
|
|
415
415
|
if (f.error)
|
|
416
416
|
return i.addIssue({
|
|
417
417
|
code: d.ZodIssueCode.custom,
|
|
418
|
-
message:
|
|
418
|
+
message: C(f.error)
|
|
419
419
|
}), d.NEVER;
|
|
420
420
|
if (!f.continue)
|
|
421
421
|
return d.NEVER;
|
|
@@ -425,13 +425,13 @@ function ee(r, e, n, t, a) {
|
|
|
425
425
|
code: d.ZodIssueCode.custom,
|
|
426
426
|
message: "'Value is not array'"
|
|
427
427
|
}), d.NEVER;
|
|
428
|
-
const c =
|
|
428
|
+
const c = fe(r, n);
|
|
429
429
|
if (c) {
|
|
430
430
|
const f = await c.safeParseAsync(s);
|
|
431
431
|
if (!f.success)
|
|
432
432
|
return i.addIssue({
|
|
433
433
|
code: d.ZodIssueCode.custom,
|
|
434
|
-
message:
|
|
434
|
+
message: C(f.error.message)
|
|
435
435
|
}), d.NEVER;
|
|
436
436
|
}
|
|
437
437
|
}).pipe(a ?? d.any());
|
|
@@ -441,27 +441,27 @@ function P(r, e, n, t, a) {
|
|
|
441
441
|
var o, u, c, l, m;
|
|
442
442
|
const i = n;
|
|
443
443
|
if (!s.isVisible || (o = s.isVisible) != null && o.call(s, i, t == null ? void 0 : t.metadata)) {
|
|
444
|
-
const f =
|
|
445
|
-
if ((u = s.validation) != null && u.schema ?
|
|
444
|
+
const f = v(r, s.path);
|
|
445
|
+
if ((u = s.validation) != null && u.schema ? y(
|
|
446
446
|
r,
|
|
447
447
|
s.path,
|
|
448
|
-
|
|
448
|
+
w(f, {
|
|
449
449
|
_schema: (c = s.validation) == null ? void 0 : c.schema,
|
|
450
450
|
_input: s
|
|
451
451
|
})
|
|
452
|
-
) : s.required &&
|
|
452
|
+
) : s.required && y(r, s.path, w(f, { _requiredOnly: !0, _input: s })), s.inputs && P(r, s.inputs, n, t), s.inputType === "list") {
|
|
453
453
|
const h = {};
|
|
454
454
|
P(
|
|
455
455
|
h,
|
|
456
|
-
s.inputConfig.inputs.map((
|
|
457
|
-
...
|
|
458
|
-
path:
|
|
456
|
+
s.inputConfig.inputs.map((g) => ({
|
|
457
|
+
...g,
|
|
458
|
+
path: g.relativePath
|
|
459
459
|
})),
|
|
460
460
|
n,
|
|
461
461
|
t
|
|
462
462
|
);
|
|
463
|
-
const _ =
|
|
464
|
-
|
|
463
|
+
const _ = v(r, s.path);
|
|
464
|
+
y(r, s.path, w(_, { _schemaObj: h, _isList: !0, _input: s }));
|
|
465
465
|
}
|
|
466
466
|
if (!((l = s.validation) != null && l.schema) && s.inputType === "array") {
|
|
467
467
|
const h = {};
|
|
@@ -470,10 +470,10 @@ function P(r, e, n, t, a) {
|
|
|
470
470
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
471
471
|
n,
|
|
472
472
|
t
|
|
473
|
-
),
|
|
473
|
+
), y(
|
|
474
474
|
r,
|
|
475
475
|
s.path,
|
|
476
|
-
|
|
476
|
+
w(f, {
|
|
477
477
|
_schemaObj: h,
|
|
478
478
|
_schema: (m = s.validation) == null ? void 0 : m.schema,
|
|
479
479
|
_isArrayItem: !0,
|
|
@@ -496,7 +496,7 @@ function J(r, e) {
|
|
|
496
496
|
return (u = e == null ? void 0 : e.validationConfig) == null ? void 0 : u.requiredSchema;
|
|
497
497
|
const n = $(r, e);
|
|
498
498
|
return d.any().optional().superRefine((c, l) => {
|
|
499
|
-
typeof c == "object" &&
|
|
499
|
+
typeof c == "object" && I(c) && l.addIssue({
|
|
500
500
|
code: d.ZodIssueCode.custom,
|
|
501
501
|
message: n
|
|
502
502
|
}), (F(c) || c === "") && l.addIssue({
|
|
@@ -505,7 +505,7 @@ function J(r, e) {
|
|
|
505
505
|
});
|
|
506
506
|
});
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function fe(r, e) {
|
|
509
509
|
if (r instanceof d.ZodType)
|
|
510
510
|
return r;
|
|
511
511
|
if (typeof r == "function")
|
|
@@ -543,7 +543,7 @@ function fr(r, e) {
|
|
|
543
543
|
return Oe(
|
|
544
544
|
async (n, t, a) => {
|
|
545
545
|
try {
|
|
546
|
-
return await
|
|
546
|
+
return await Ue(r, n, e).parseAsync(n), {
|
|
547
547
|
values: n,
|
|
548
548
|
// TODO: check this - values does not contains all data
|
|
549
549
|
errors: {}
|
|
@@ -564,28 +564,30 @@ function He(r, e) {
|
|
|
564
564
|
const n = q(r);
|
|
565
565
|
return e.forEach((t) => {
|
|
566
566
|
t.inputTransform && (S(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
|
|
567
|
-
const i =
|
|
568
|
-
o &&
|
|
567
|
+
const i = v(n, t.path), o = s(i, n);
|
|
568
|
+
o && y(n, o.path ?? t.path, o.value);
|
|
569
569
|
});
|
|
570
570
|
}), n;
|
|
571
571
|
}
|
|
572
572
|
function Qe(r, e) {
|
|
573
|
-
const n = q(r);
|
|
574
|
-
return e.forEach((
|
|
575
|
-
|
|
576
|
-
const
|
|
577
|
-
|
|
573
|
+
const n = [], t = q(r);
|
|
574
|
+
return e.forEach((a) => {
|
|
575
|
+
a.outputTransform && (S(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((i) => {
|
|
576
|
+
const o = v(t, a.path), u = i(o, t);
|
|
577
|
+
u && (u.path ? (y(t, u.path, u.value), n.push(a.path)) : y(t, a.path, u.value));
|
|
578
578
|
});
|
|
579
|
-
}), n
|
|
579
|
+
}), n.forEach((a) => {
|
|
580
|
+
se(t, a);
|
|
581
|
+
}), t;
|
|
580
582
|
}
|
|
581
|
-
function
|
|
582
|
-
return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...
|
|
583
|
+
function U(r) {
|
|
584
|
+
return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...U(t.inputs)] : [...n, t], []);
|
|
583
585
|
}
|
|
584
|
-
function
|
|
585
|
-
const n =
|
|
586
|
+
function le(r) {
|
|
587
|
+
const n = U(r.inputs).reduce((t, a) => {
|
|
586
588
|
const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
|
|
587
589
|
return (a.inputTransform || a.outputTransform) && t.push({
|
|
588
|
-
...
|
|
590
|
+
...ge(a, "path", "inputTransform", "outputTransform"),
|
|
589
591
|
level: a.path.split(".").length,
|
|
590
592
|
isPrimitive: s
|
|
591
593
|
}), t;
|
|
@@ -593,17 +595,17 @@ function fe(r) {
|
|
|
593
595
|
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
594
596
|
}
|
|
595
597
|
function Xe(r, e, n, t = {}) {
|
|
596
|
-
const { preserve: a } = t, s =
|
|
598
|
+
const { preserve: a } = t, s = U(r.inputs), i = q(e);
|
|
597
599
|
return s.forEach((o) => {
|
|
598
|
-
a && a.includes(o.path) || o.isVisible && !o.isVisible(e, n) &&
|
|
600
|
+
a && a.includes(o.path) || o.isVisible && !o.isVisible(e, n) && se(i, o.path);
|
|
599
601
|
}), i;
|
|
600
602
|
}
|
|
601
603
|
function lr(r, e) {
|
|
602
|
-
const n =
|
|
604
|
+
const n = le(e);
|
|
603
605
|
return He(r, n);
|
|
604
606
|
}
|
|
605
607
|
function dr(r, e, n, t = {}) {
|
|
606
|
-
const a =
|
|
608
|
+
const a = le(e);
|
|
607
609
|
let s = Xe(e, r, n, t);
|
|
608
610
|
return s = Qe(s, a), s = $e(s), s;
|
|
609
611
|
}
|
|
@@ -611,7 +613,7 @@ function mr(r) {
|
|
|
611
613
|
const e = {}, n = (t) => {
|
|
612
614
|
t.forEach((a) => {
|
|
613
615
|
const { default: s, path: i, inputType: o, inputs: u } = a;
|
|
614
|
-
(o === "group" || o === "accordion") && Array.isArray(u) ? n(u) : s !== void 0 &&
|
|
616
|
+
(o === "group" || o === "accordion") && Array.isArray(u) ? n(u) : s !== void 0 && y(e, i, s);
|
|
615
617
|
});
|
|
616
618
|
};
|
|
617
619
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
@@ -629,7 +631,7 @@ function pr(r) {
|
|
|
629
631
|
if (typeof e > "u") return;
|
|
630
632
|
if (!e) return { value: e };
|
|
631
633
|
const t = {
|
|
632
|
-
value: e.reduce((a, s) => ({ ...a, [s.key]: s.value }), {})
|
|
634
|
+
value: e.reduce((a, s) => ({ ...a, [s.key]: s.value ?? (r == null ? void 0 : r.fallbackValue) }), {})
|
|
633
635
|
};
|
|
634
636
|
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
635
637
|
};
|
|
@@ -637,17 +639,17 @@ function pr(r) {
|
|
|
637
639
|
function yr() {
|
|
638
640
|
return function(r, e) {
|
|
639
641
|
if (!(typeof r > "u"))
|
|
640
|
-
return S(r) &&
|
|
642
|
+
return S(r) && I(r) ? { value: void 0 } : { value: r };
|
|
641
643
|
};
|
|
642
644
|
}
|
|
643
645
|
function gr(r) {
|
|
644
646
|
return function(e, n) {
|
|
645
|
-
const t = r ?
|
|
647
|
+
const t = r ? v(n, r) : e;
|
|
646
648
|
if (!(typeof t > "u")) {
|
|
647
|
-
if (
|
|
649
|
+
if (ae(t)) return { value: void 0, path: r };
|
|
648
650
|
if (ne(t)) {
|
|
649
|
-
const a =
|
|
650
|
-
if (
|
|
651
|
+
const a = oe(t, be);
|
|
652
|
+
if (I(a))
|
|
651
653
|
return { value: void 0, path: r };
|
|
652
654
|
}
|
|
653
655
|
return { value: t, path: r };
|
|
@@ -657,12 +659,12 @@ function gr(r) {
|
|
|
657
659
|
function br() {
|
|
658
660
|
return function(r, e) {
|
|
659
661
|
if (!(typeof r > "u"))
|
|
660
|
-
return ve(r) &&
|
|
662
|
+
return ve(r) && I(r) ? { value: void 0 } : { value: r };
|
|
661
663
|
};
|
|
662
664
|
}
|
|
663
665
|
function vr(r) {
|
|
664
666
|
return function(e, n) {
|
|
665
|
-
const t =
|
|
667
|
+
const t = v(n, r);
|
|
666
668
|
return typeof t == "string" ? { value: t } : { value: e };
|
|
667
669
|
};
|
|
668
670
|
}
|
|
@@ -670,7 +672,7 @@ function _r(r) {
|
|
|
670
672
|
return function(e, n) {
|
|
671
673
|
if (typeof e > "u") return;
|
|
672
674
|
if (!e) return { value: e };
|
|
673
|
-
const t =
|
|
675
|
+
const t = v(n, r);
|
|
674
676
|
if (typeof t == "object") {
|
|
675
677
|
const a = Ye(t);
|
|
676
678
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
@@ -679,18 +681,18 @@ function _r(r) {
|
|
|
679
681
|
return { value: e };
|
|
680
682
|
};
|
|
681
683
|
}
|
|
682
|
-
function
|
|
684
|
+
function Er(r) {
|
|
683
685
|
return function(e, n) {
|
|
684
686
|
if (typeof e > "u") return;
|
|
685
|
-
const t =
|
|
687
|
+
const t = v(n, r);
|
|
686
688
|
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
687
689
|
};
|
|
688
690
|
}
|
|
689
|
-
function
|
|
691
|
+
function Rr(r, e) {
|
|
690
692
|
return function(n, t) {
|
|
691
693
|
if (typeof n > "u") return;
|
|
692
694
|
if (!n) return { value: n };
|
|
693
|
-
const a =
|
|
695
|
+
const a = v(t, r);
|
|
694
696
|
if (S(a)) {
|
|
695
697
|
if (a.length === 1)
|
|
696
698
|
return { value: a[0], path: r };
|
|
@@ -700,11 +702,11 @@ function Er(r, e) {
|
|
|
700
702
|
return { value: n };
|
|
701
703
|
};
|
|
702
704
|
}
|
|
703
|
-
function
|
|
704
|
-
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !
|
|
705
|
+
function de(r) {
|
|
706
|
+
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !de(r[e])) : F(r);
|
|
705
707
|
}
|
|
706
708
|
function Ye(r) {
|
|
707
|
-
return
|
|
709
|
+
return oe(r, (e) => typeof e == "object" ? de(e) : F(e));
|
|
708
710
|
}
|
|
709
711
|
function re(r) {
|
|
710
712
|
const { items: e, ...n } = r;
|
|
@@ -732,7 +734,7 @@ Ke.displayName = "RenderForm";
|
|
|
732
734
|
function Tr(r) {
|
|
733
735
|
let e = !0;
|
|
734
736
|
return te(r, (n) => {
|
|
735
|
-
e = e && (n === "" ||
|
|
737
|
+
e = e && (n === "" || ae(n) || F(n));
|
|
736
738
|
}), e;
|
|
737
739
|
}
|
|
738
740
|
const Or = (r = "") => _e(r.split("_").join(" ")), ze = (r, e = 2) => {
|
|
@@ -762,7 +764,7 @@ function Sr(r) {
|
|
|
762
764
|
export {
|
|
763
765
|
ar as InputComponent,
|
|
764
766
|
Ze as InputComponentRenderer,
|
|
765
|
-
|
|
767
|
+
ue as InputFactory,
|
|
766
768
|
Fe as InputOverrideError,
|
|
767
769
|
Ke as RenderForm,
|
|
768
770
|
re as RenderInputs,
|
|
@@ -775,17 +777,17 @@ export {
|
|
|
775
777
|
Or as generateReadableLabel,
|
|
776
778
|
ur as getDefaultValuesFromFormDefinition,
|
|
777
779
|
cr as getTemporaryPath,
|
|
778
|
-
|
|
779
|
-
|
|
780
|
+
le as getTransformers,
|
|
781
|
+
Ue as getValidationSchema,
|
|
780
782
|
He as inputTransformValues,
|
|
781
783
|
Tr as isChildrenEmpty,
|
|
782
784
|
hr as objectToArrayInputTransformer,
|
|
783
785
|
Qe as outputTransformValues,
|
|
784
786
|
ir as overrideFormDefinition,
|
|
785
|
-
|
|
787
|
+
C as processValidationParseResponse,
|
|
786
788
|
$e as removeTemporaryFieldsValue,
|
|
787
|
-
|
|
788
|
-
|
|
789
|
+
Er as shorthandArrayInputTransformer,
|
|
790
|
+
Rr as shorthandArrayOutputTransformer,
|
|
789
791
|
vr as shorthandObjectInputTransformer,
|
|
790
792
|
_r as shorthandObjectOutputTransformer,
|
|
791
793
|
yr as unsetEmptyArrayOutputTransformer,
|