@harnessio/forms 0.0.8 → 0.0.9
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/index.d.ts +1 -0
- package/dist/core/utils/temporary-field-utils.d.ts +3 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +171 -168
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { isEmpty as
|
|
5
|
-
import
|
|
6
|
-
import { useFormContext as
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var z = (r, e, n) => e in r ? K(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var P = (r, e, n) => z(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as R, cloneDeep as C, set as b, get as p, forOwn as L, isArray as S, isObject as U, merge as I, isUndefined as q, pick as ee, unset as re, isNull as W, omitBy as G, isNil as te, isString as ne, capitalize as se } from "lodash-es";
|
|
5
|
+
import ae, { useMemo as Z, useRef as x, useEffect as O, useCallback as ue, forwardRef as ie } from "react";
|
|
6
|
+
import { useFormContext as oe, useForm as ce, FormProvider as fe, appendErrors as de } from "react-hook-form";
|
|
7
7
|
export * from "react-hook-form";
|
|
8
8
|
import * as m from "zod";
|
|
9
|
-
import { toNestErrors as
|
|
10
|
-
class
|
|
9
|
+
import { toNestErrors as le } from "@hookform/resolvers";
|
|
10
|
+
class me extends Error {
|
|
11
11
|
constructor(e) {
|
|
12
12
|
super(`Input component '${e}' is already registered.`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
class xe {
|
|
16
16
|
constructor(e) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
P(this, "componentBank");
|
|
18
|
+
P(this, "allowOverride");
|
|
19
19
|
this.allowOverride = (e == null ? void 0 : e.allowOverride) ?? !1, this.componentBank = /* @__PURE__ */ new Map();
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -26,23 +26,23 @@ class xe {
|
|
|
26
26
|
*/
|
|
27
27
|
registerComponent(e) {
|
|
28
28
|
if (!this.allowOverride && this.getComponent(e.internalType))
|
|
29
|
-
throw new
|
|
29
|
+
throw new me(e.internalType);
|
|
30
30
|
this.componentBank.set(e.internalType, e);
|
|
31
31
|
}
|
|
32
32
|
getComponent(e) {
|
|
33
|
-
if (e && !
|
|
33
|
+
if (e && !R(e))
|
|
34
34
|
return this.componentBank.get(e);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
var N = { exports: {} },
|
|
37
|
+
var N = { exports: {} }, E = {};
|
|
38
38
|
/*
|
|
39
39
|
object-assign
|
|
40
40
|
(c) Sindre Sorhus
|
|
41
41
|
@license MIT
|
|
42
42
|
*/
|
|
43
|
-
var
|
|
44
|
-
function
|
|
45
|
-
if ($) return
|
|
43
|
+
var F, $;
|
|
44
|
+
function he() {
|
|
45
|
+
if ($) return F;
|
|
46
46
|
$ = 1;
|
|
47
47
|
var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
|
|
48
48
|
function t(s) {
|
|
@@ -72,7 +72,7 @@ function me() {
|
|
|
72
72
|
return !1;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return F = a() ? Object.assign : function(s, o) {
|
|
76
76
|
for (var u, c = t(s), f, i = 1; i < arguments.length; i++) {
|
|
77
77
|
u = Object(arguments[i]);
|
|
78
78
|
for (var d in u)
|
|
@@ -84,7 +84,7 @@ function me() {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
return c;
|
|
87
|
-
},
|
|
87
|
+
}, F;
|
|
88
88
|
}
|
|
89
89
|
/** @license React v17.0.2
|
|
90
90
|
* react-jsx-runtime.production.min.js
|
|
@@ -95,13 +95,13 @@ function me() {
|
|
|
95
95
|
* LICENSE file in the root directory of this source tree.
|
|
96
96
|
*/
|
|
97
97
|
var M;
|
|
98
|
-
function
|
|
99
|
-
if (M) return
|
|
100
|
-
M = 1,
|
|
101
|
-
var r =
|
|
102
|
-
if (
|
|
98
|
+
function ye() {
|
|
99
|
+
if (M) return E;
|
|
100
|
+
M = 1, he();
|
|
101
|
+
var r = ae, e = 60103;
|
|
102
|
+
if (E.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
103
103
|
var n = Symbol.for;
|
|
104
|
-
e = n("react.element"),
|
|
104
|
+
e = n("react.element"), E.Fragment = n("react.fragment");
|
|
105
105
|
}
|
|
106
106
|
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 };
|
|
107
107
|
function o(u, c, f) {
|
|
@@ -111,13 +111,13 @@ function he() {
|
|
|
111
111
|
if (u && u.defaultProps) for (i in c = u.defaultProps, c) d[i] === void 0 && (d[i] = c[i]);
|
|
112
112
|
return { $$typeof: e, type: u, key: l, ref: h, props: d, _owner: t.current };
|
|
113
113
|
}
|
|
114
|
-
return
|
|
114
|
+
return E.jsx = o, E.jsxs = o, E;
|
|
115
115
|
}
|
|
116
116
|
var B;
|
|
117
|
-
function
|
|
118
|
-
return B || (B = 1, N.exports =
|
|
117
|
+
function pe() {
|
|
118
|
+
return B || (B = 1, N.exports = ye()), N.exports;
|
|
119
119
|
}
|
|
120
|
-
var y =
|
|
120
|
+
var y = pe();
|
|
121
121
|
function ge({
|
|
122
122
|
path: r,
|
|
123
123
|
factory: e,
|
|
@@ -127,7 +127,7 @@ function ge({
|
|
|
127
127
|
initialValues: s,
|
|
128
128
|
input: o
|
|
129
129
|
}) {
|
|
130
|
-
const { formState: u, watch: c } =
|
|
130
|
+
const { formState: u, watch: c } = oe(), {
|
|
131
131
|
metadata: f = {},
|
|
132
132
|
fixedValues: i = {}
|
|
133
133
|
/*getValuesWithDependencies*/
|
|
@@ -142,28 +142,28 @@ function ge({
|
|
|
142
142
|
input: o
|
|
143
143
|
}),
|
|
144
144
|
[e, s, o, t, n, r, a, u.errors]
|
|
145
|
-
), h = c(),
|
|
146
|
-
i && Object.keys(i).forEach((
|
|
147
|
-
const
|
|
148
|
-
b(
|
|
145
|
+
), h = c(), v = C(h);
|
|
146
|
+
i && Object.keys(i).forEach((g) => {
|
|
147
|
+
const Y = i[g];
|
|
148
|
+
b(v, g, Y);
|
|
149
149
|
});
|
|
150
|
-
const
|
|
150
|
+
const _ = !o.isVisible || (o == null ? void 0 : o.isVisible(v, f)), j = Z(() => _ ? /* @__PURE__ */ y.jsxs(y.Fragment, { children: [
|
|
151
151
|
o.before ? o.before : null,
|
|
152
152
|
d == null ? void 0 : d.renderComponent(l),
|
|
153
153
|
o.after ? o.after : null
|
|
154
|
-
] }) : null, [l, o.after, o.before, d,
|
|
155
|
-
return d ?
|
|
154
|
+
] }) : null, [l, o.after, o.before, d, _, u.errors]);
|
|
155
|
+
return d ? _ ? j : null : /* @__PURE__ */ y.jsxs("p", { children: [
|
|
156
156
|
"Input component not found (internal type: ",
|
|
157
157
|
o.inputType,
|
|
158
158
|
")"
|
|
159
159
|
] });
|
|
160
160
|
}
|
|
161
|
-
class
|
|
161
|
+
class Ne {
|
|
162
162
|
getType() {
|
|
163
163
|
return this.internalType;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function Fe(r) {
|
|
167
167
|
const {
|
|
168
168
|
mode: e = "onSubmit",
|
|
169
169
|
resolver: n,
|
|
@@ -180,17 +180,17 @@ function Ne(r) {
|
|
|
180
180
|
children: c,
|
|
181
181
|
// fixedValues
|
|
182
182
|
autoFocusPath: f
|
|
183
|
-
} = r, i =
|
|
183
|
+
} = r, i = ce({
|
|
184
184
|
mode: e ?? "onSubmit",
|
|
185
185
|
reValidateMode: "onChange",
|
|
186
186
|
defaultValues: t,
|
|
187
187
|
shouldFocusError: a,
|
|
188
188
|
resolver: n
|
|
189
|
-
}), d =
|
|
189
|
+
}), d = x(!1);
|
|
190
190
|
O(() => {
|
|
191
191
|
i.reset(t, {});
|
|
192
192
|
}, [i.reset, t]), O(() => {
|
|
193
|
-
const
|
|
193
|
+
const g = requestIdleCallback(() => {
|
|
194
194
|
i.reset({}, {
|
|
195
195
|
keepErrors: !0,
|
|
196
196
|
keepDirty: !0,
|
|
@@ -204,17 +204,17 @@ function Ne(r) {
|
|
|
204
204
|
keepSubmitCount: !0
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
|
-
return () => cancelIdleCallback(
|
|
207
|
+
return () => cancelIdleCallback(g);
|
|
208
208
|
}, []);
|
|
209
|
-
const { getValues: l, handleSubmit: h } = i,
|
|
209
|
+
const { getValues: l, handleSubmit: h } = i, v = l(), _ = x(!0);
|
|
210
210
|
O(() => {
|
|
211
|
-
if (
|
|
212
|
-
|
|
211
|
+
if (_.current) {
|
|
212
|
+
_.current = !1;
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
|
-
s == null || s({ ...
|
|
216
|
-
}, [JSON.stringify(
|
|
217
|
-
const j =
|
|
215
|
+
s == null || s({ ...v }), d.current === !0 && i.trigger();
|
|
216
|
+
}, [JSON.stringify(v)]);
|
|
217
|
+
const j = x(!0);
|
|
218
218
|
return O(() => {
|
|
219
219
|
if (j.current) {
|
|
220
220
|
j.current = !1;
|
|
@@ -224,21 +224,21 @@ function Ne(r) {
|
|
|
224
224
|
}, [i.formState.isValid, i.formState.isSubmitted]), O(() => {
|
|
225
225
|
if (f)
|
|
226
226
|
if ("requestIdleCallback" in window) {
|
|
227
|
-
const
|
|
227
|
+
const g = requestIdleCallback(() => {
|
|
228
228
|
i.setFocus(f);
|
|
229
229
|
});
|
|
230
|
-
return () => cancelIdleCallback(
|
|
230
|
+
return () => cancelIdleCallback(g);
|
|
231
231
|
} else {
|
|
232
|
-
const
|
|
232
|
+
const g = setTimeout(() => {
|
|
233
233
|
i.setFocus(f);
|
|
234
234
|
}, 100);
|
|
235
|
-
return () => clearTimeout(
|
|
235
|
+
return () => clearTimeout(g);
|
|
236
236
|
}
|
|
237
|
-
}, [i]), /* @__PURE__ */ y.jsx(
|
|
237
|
+
}, [i]), /* @__PURE__ */ y.jsx(fe, { ...i, children: typeof c == "function" ? c({
|
|
238
238
|
...i,
|
|
239
239
|
submitForm: async () => {
|
|
240
|
-
u && (d.current = !0, h((
|
|
241
|
-
u(
|
|
240
|
+
u && (d.current = !0, h((g) => {
|
|
241
|
+
u(g);
|
|
242
242
|
})());
|
|
243
243
|
}
|
|
244
244
|
}) : c });
|
|
@@ -249,29 +249,36 @@ const ke = (r) => {
|
|
|
249
249
|
return (n = r == null ? void 0 : r.inputs) == null || n.forEach((t) => {
|
|
250
250
|
var a;
|
|
251
251
|
t.inputType === "group" && ((a = t == null ? void 0 : t.inputs) == null || a.forEach((s) => {
|
|
252
|
-
typeof
|
|
253
|
-
})), typeof
|
|
252
|
+
typeof p(e, s.path) > "u" && b(e, s.path, s.default);
|
|
253
|
+
})), typeof p(e, t.path) > "u" && b(e, t.path, t.default);
|
|
254
254
|
}), e;
|
|
255
255
|
};
|
|
256
|
-
function
|
|
256
|
+
function Ae(r, e) {
|
|
257
257
|
const n = r.inputs.map((t) => {
|
|
258
|
-
const a =
|
|
258
|
+
const a = be(e, t.path);
|
|
259
259
|
return a || t;
|
|
260
260
|
});
|
|
261
261
|
return { ...r, inputs: n };
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function be(r, e) {
|
|
264
264
|
return r.inputs.find((n) => n.path === e);
|
|
265
265
|
}
|
|
266
|
-
const
|
|
267
|
-
function
|
|
266
|
+
const H = "__temp_", De = (r) => H + r.split(".").join("__");
|
|
267
|
+
function Ze(r) {
|
|
268
|
+
const e = { ...r };
|
|
269
|
+
return L(e, (n, t) => {
|
|
270
|
+
t.startsWith(H) && delete e[t];
|
|
271
|
+
}), e;
|
|
272
|
+
}
|
|
273
|
+
const _e = "Required field";
|
|
274
|
+
function T(r) {
|
|
268
275
|
const e = typeof r == "string" ? JSON.parse(r) : r;
|
|
269
276
|
if (typeof e == "string")
|
|
270
277
|
return e;
|
|
271
|
-
if (
|
|
272
|
-
return
|
|
278
|
+
if (S(e))
|
|
279
|
+
return T(e[0]);
|
|
273
280
|
const n = e;
|
|
274
|
-
return
|
|
281
|
+
return U(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
275
282
|
}
|
|
276
283
|
function ve(r, e, n) {
|
|
277
284
|
let t = {};
|
|
@@ -300,18 +307,18 @@ function V(r, e, n) {
|
|
|
300
307
|
const d = o != null && o.___array ? V({ ___array: o.___array }, e, n) : { ___array: m.any() }, l = m.array(d.___array).optional(), h = J(i, u, e, n, l);
|
|
301
308
|
t[a] = h;
|
|
302
309
|
} else if (i && u) {
|
|
303
|
-
const d =
|
|
310
|
+
const d = Ee(i, u, e, n);
|
|
304
311
|
t[a] = d;
|
|
305
312
|
} else s && u ? t[a] = A(u, n) : t[a] = m.object(V(r[a], e, n)).optional();
|
|
306
313
|
}), t;
|
|
307
314
|
}
|
|
308
|
-
function
|
|
315
|
+
function Ee(r, e, n, t) {
|
|
309
316
|
return m.any().optional().superRefine(async (a, s) => {
|
|
310
317
|
var u, c;
|
|
311
318
|
if (e.required && !(await A(e, t).safeParseAsync(a)).success)
|
|
312
319
|
return s.addIssue({
|
|
313
320
|
code: m.ZodIssueCode.custom,
|
|
314
|
-
message:
|
|
321
|
+
message: k(e, t)
|
|
315
322
|
}), m.NEVER;
|
|
316
323
|
if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
|
|
317
324
|
const f = (c = t == null ? void 0 : t.validationConfig) == null ? void 0 : c.globalValidation(a, e, t.metadata);
|
|
@@ -323,11 +330,11 @@ function _e(r, e, n, t) {
|
|
|
323
330
|
if (!f.continue)
|
|
324
331
|
return !0;
|
|
325
332
|
}
|
|
326
|
-
const o =
|
|
333
|
+
const o = Q(r, n);
|
|
327
334
|
if (o) {
|
|
328
335
|
const f = await o.safeParseAsync(a);
|
|
329
336
|
if (!f.success) {
|
|
330
|
-
const i =
|
|
337
|
+
const i = T(f == null ? void 0 : f.error.message), d = i === "Required" ? k(e, t) : i;
|
|
331
338
|
s.addIssue({
|
|
332
339
|
code: m.ZodIssueCode.custom,
|
|
333
340
|
message: d
|
|
@@ -341,7 +348,7 @@ function J(r, e, n, t, a) {
|
|
|
341
348
|
var i, d;
|
|
342
349
|
const c = await A(e, t).safeParseAsync(s);
|
|
343
350
|
if (e.required && !c.success) {
|
|
344
|
-
const l =
|
|
351
|
+
const l = T(c.error.message);
|
|
345
352
|
return o.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
|
|
346
353
|
}
|
|
347
354
|
if (!e.required && !c.success)
|
|
@@ -351,23 +358,23 @@ function J(r, e, n, t, a) {
|
|
|
351
358
|
if (l.error)
|
|
352
359
|
return o.addIssue({
|
|
353
360
|
code: m.ZodIssueCode.custom,
|
|
354
|
-
message:
|
|
361
|
+
message: T(l.error)
|
|
355
362
|
}), m.NEVER;
|
|
356
363
|
if (!l.continue)
|
|
357
364
|
return m.NEVER;
|
|
358
365
|
}
|
|
359
|
-
if (!
|
|
366
|
+
if (!S(s))
|
|
360
367
|
return o.addIssue({
|
|
361
368
|
code: m.ZodIssueCode.custom,
|
|
362
369
|
message: "'Value is not array'"
|
|
363
370
|
}), m.NEVER;
|
|
364
|
-
const f =
|
|
371
|
+
const f = Q(r, n);
|
|
365
372
|
if (f) {
|
|
366
373
|
const l = await f.safeParseAsync(s);
|
|
367
374
|
if (!l.success)
|
|
368
375
|
return o.addIssue({
|
|
369
376
|
code: m.ZodIssueCode.custom,
|
|
370
|
-
message:
|
|
377
|
+
message: T(l.error.message)
|
|
371
378
|
}), m.NEVER;
|
|
372
379
|
}
|
|
373
380
|
}).pipe(a ?? m.any());
|
|
@@ -377,7 +384,7 @@ function w(r, e, n, t, a) {
|
|
|
377
384
|
var u, c, f, i, d;
|
|
378
385
|
const o = n;
|
|
379
386
|
if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
380
|
-
const l =
|
|
387
|
+
const l = p(r, s.path);
|
|
381
388
|
if ((c = s.validation) != null && c.schema ? b(
|
|
382
389
|
r,
|
|
383
390
|
s.path,
|
|
@@ -389,15 +396,15 @@ function w(r, e, n, t, a) {
|
|
|
389
396
|
const h = {};
|
|
390
397
|
w(
|
|
391
398
|
h,
|
|
392
|
-
s.inputConfig.inputs.map((
|
|
393
|
-
...
|
|
394
|
-
path:
|
|
399
|
+
s.inputConfig.inputs.map((_) => ({
|
|
400
|
+
..._,
|
|
401
|
+
path: _.relativePath
|
|
395
402
|
})),
|
|
396
403
|
n,
|
|
397
404
|
t
|
|
398
405
|
);
|
|
399
|
-
const
|
|
400
|
-
b(r, s.path, I(
|
|
406
|
+
const v = p(r, s.path);
|
|
407
|
+
b(r, s.path, I(v, { _schemaObj: h, _isList: !0, _input: s }));
|
|
401
408
|
}
|
|
402
409
|
if (!((i = s.validation) != null && i.schema) && s.inputType === "array") {
|
|
403
410
|
const h = {};
|
|
@@ -420,9 +427,9 @@ function w(r, e, n, t, a) {
|
|
|
420
427
|
}
|
|
421
428
|
});
|
|
422
429
|
}
|
|
423
|
-
function
|
|
430
|
+
function k(r, e) {
|
|
424
431
|
var n, t, a;
|
|
425
|
-
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) ??
|
|
432
|
+
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) ?? _e;
|
|
426
433
|
}
|
|
427
434
|
function A(r, e) {
|
|
428
435
|
var t, a, s, o, u, c;
|
|
@@ -430,9 +437,9 @@ function A(r, e) {
|
|
|
430
437
|
return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
|
|
431
438
|
if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
|
|
432
439
|
return (c = e == null ? void 0 : e.validationConfig) == null ? void 0 : c.requiredSchema;
|
|
433
|
-
const n =
|
|
440
|
+
const n = k(r, e);
|
|
434
441
|
return m.any().optional().superRefine((f, i) => {
|
|
435
|
-
typeof f == "object" &&
|
|
442
|
+
typeof f == "object" && R(f) && i.addIssue({
|
|
436
443
|
code: m.ZodIssueCode.custom,
|
|
437
444
|
message: n
|
|
438
445
|
}), (q(f) || f === "") && i.addIssue({
|
|
@@ -441,13 +448,13 @@ function A(r, e) {
|
|
|
441
448
|
});
|
|
442
449
|
});
|
|
443
450
|
}
|
|
444
|
-
function
|
|
451
|
+
function Q(r, e) {
|
|
445
452
|
if (r instanceof m.ZodType)
|
|
446
453
|
return r;
|
|
447
454
|
if (typeof r == "function")
|
|
448
455
|
return r(e);
|
|
449
456
|
}
|
|
450
|
-
const Se = (r) => Array.isArray(r == null ? void 0 : r.errors),
|
|
457
|
+
const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Oe = (r, e) => {
|
|
451
458
|
const n = {};
|
|
452
459
|
for (; r.length; ) {
|
|
453
460
|
const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
|
|
@@ -463,7 +470,7 @@ const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Ee = (r, e) => {
|
|
|
463
470
|
"unionErrors" in t && t.unionErrors.forEach((c) => c.errors.forEach((f) => r.push(f)));
|
|
464
471
|
{
|
|
465
472
|
const c = n[u].types, f = c && c[t.code];
|
|
466
|
-
n[u] =
|
|
473
|
+
n[u] = de(
|
|
467
474
|
u,
|
|
468
475
|
e,
|
|
469
476
|
n,
|
|
@@ -475,8 +482,8 @@ const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Ee = (r, e) => {
|
|
|
475
482
|
}
|
|
476
483
|
return n;
|
|
477
484
|
};
|
|
478
|
-
function
|
|
479
|
-
return
|
|
485
|
+
function $e(r, e) {
|
|
486
|
+
return ue(
|
|
480
487
|
async (n, t, a) => {
|
|
481
488
|
try {
|
|
482
489
|
return await ve(r, n, e).parseAsync(n), {
|
|
@@ -488,7 +495,7 @@ function Ae(r, e) {
|
|
|
488
495
|
if (Se(s))
|
|
489
496
|
return {
|
|
490
497
|
values: {},
|
|
491
|
-
errors:
|
|
498
|
+
errors: le(Oe(s.errors, !0), a)
|
|
492
499
|
};
|
|
493
500
|
throw s;
|
|
494
501
|
}
|
|
@@ -496,51 +503,45 @@ function Ae(r, e) {
|
|
|
496
503
|
[r]
|
|
497
504
|
);
|
|
498
505
|
}
|
|
499
|
-
function
|
|
506
|
+
function Me(r, e) {
|
|
500
507
|
const n = C(r);
|
|
501
508
|
return e.forEach((t) => {
|
|
502
|
-
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
u && b(n, u.path ?? t.path, u.value);
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
+
t.inputTransform && (S(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
|
|
510
|
+
const o = p(n, t.path), u = s(o, n);
|
|
511
|
+
u && b(n, u.path ?? t.path, u.value);
|
|
512
|
+
});
|
|
509
513
|
}), n;
|
|
510
514
|
}
|
|
511
|
-
function
|
|
515
|
+
function Be(r, e) {
|
|
512
516
|
const n = C(r);
|
|
513
517
|
return e.forEach((t) => {
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
u && b(n, u.path ?? t.path, u.value);
|
|
519
|
-
});
|
|
520
|
-
}
|
|
518
|
+
t.outputTransform && (S(t.outputTransform) ? t.outputTransform : [t.outputTransform]).forEach((s) => {
|
|
519
|
+
const o = p(n, t.path), u = s(o, n);
|
|
520
|
+
u && b(n, u.path ?? t.path, u.value);
|
|
521
|
+
});
|
|
521
522
|
}), n;
|
|
522
523
|
}
|
|
523
524
|
function D(r) {
|
|
524
525
|
return r.reduce((n, t) => t.inputType === "group" && t.inputs ? [...n, t, ...D(t.inputs)] : [...n, t], []);
|
|
525
526
|
}
|
|
526
|
-
function
|
|
527
|
+
function Je(r) {
|
|
527
528
|
const n = D(r.inputs).reduce((t, a) => {
|
|
528
529
|
const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
|
|
529
530
|
return (a.inputTransform || a.outputTransform) && t.push({
|
|
530
|
-
...
|
|
531
|
+
...ee(a, "path", "inputTransform", "outputTransform"),
|
|
531
532
|
level: a.path.split(".").length,
|
|
532
533
|
isPrimitive: s
|
|
533
534
|
}), t;
|
|
534
535
|
}, []);
|
|
535
536
|
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
536
537
|
}
|
|
537
|
-
function
|
|
538
|
+
function Le(r, e, n) {
|
|
538
539
|
const t = D(r.inputs), a = C(e);
|
|
539
540
|
return t.forEach((s) => {
|
|
540
|
-
s.isVisible && !s.isVisible(e, n) &&
|
|
541
|
+
s.isVisible && !s.isVisible(e, n) && re(a, s.path);
|
|
541
542
|
}), a;
|
|
542
543
|
}
|
|
543
|
-
function
|
|
544
|
+
function Ue() {
|
|
544
545
|
return function(r, e) {
|
|
545
546
|
if (!(typeof r > "u"))
|
|
546
547
|
return r ? {
|
|
@@ -548,7 +549,7 @@ function Be() {
|
|
|
548
549
|
} : { value: r };
|
|
549
550
|
};
|
|
550
551
|
}
|
|
551
|
-
function
|
|
552
|
+
function We(r) {
|
|
552
553
|
return function(e, n) {
|
|
553
554
|
if (typeof e > "u") return;
|
|
554
555
|
if (!e) return { value: e };
|
|
@@ -558,64 +559,64 @@ function Je(r) {
|
|
|
558
559
|
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
559
560
|
};
|
|
560
561
|
}
|
|
561
|
-
function
|
|
562
|
+
function Ge() {
|
|
562
563
|
return function(r, e) {
|
|
563
564
|
if (!(typeof r > "u"))
|
|
564
|
-
return
|
|
565
|
+
return S(r) && R(r) ? { value: void 0 } : { value: r };
|
|
565
566
|
};
|
|
566
567
|
}
|
|
567
|
-
function
|
|
568
|
+
function He(r) {
|
|
568
569
|
return function(e, n) {
|
|
569
|
-
const t = r ?
|
|
570
|
+
const t = r ? p(n, r) : e;
|
|
570
571
|
if (!(typeof t > "u")) {
|
|
571
|
-
if (
|
|
572
|
-
if (
|
|
573
|
-
const a =
|
|
574
|
-
if (
|
|
572
|
+
if (W(t)) return { value: void 0, path: r };
|
|
573
|
+
if (U(t)) {
|
|
574
|
+
const a = G(t, te);
|
|
575
|
+
if (R(a))
|
|
575
576
|
return { value: void 0, path: r };
|
|
576
577
|
}
|
|
577
578
|
return { value: t, path: r };
|
|
578
579
|
}
|
|
579
580
|
};
|
|
580
581
|
}
|
|
581
|
-
function
|
|
582
|
+
function Qe() {
|
|
582
583
|
return function(r, e) {
|
|
583
584
|
if (!(typeof r > "u"))
|
|
584
|
-
return
|
|
585
|
+
return ne(r) && R(r) ? { value: void 0 } : { value: r };
|
|
585
586
|
};
|
|
586
587
|
}
|
|
587
|
-
function
|
|
588
|
+
function Xe(r) {
|
|
588
589
|
return function(e, n) {
|
|
589
|
-
const t =
|
|
590
|
+
const t = p(n, r);
|
|
590
591
|
return typeof t == "string" ? { value: t } : { value: e };
|
|
591
592
|
};
|
|
592
593
|
}
|
|
593
|
-
function
|
|
594
|
+
function Ye(r) {
|
|
594
595
|
return function(e, n) {
|
|
595
596
|
if (typeof e > "u") return;
|
|
596
597
|
if (!e) return { value: e };
|
|
597
|
-
const t =
|
|
598
|
+
const t = p(n, r);
|
|
598
599
|
if (typeof t == "object") {
|
|
599
|
-
const a =
|
|
600
|
+
const a = Te(t);
|
|
600
601
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
601
602
|
return { value: e, path: r };
|
|
602
603
|
}
|
|
603
604
|
return { value: e };
|
|
604
605
|
};
|
|
605
606
|
}
|
|
606
|
-
function
|
|
607
|
+
function Ke(r) {
|
|
607
608
|
return function(e, n) {
|
|
608
609
|
if (typeof e > "u") return;
|
|
609
|
-
const t =
|
|
610
|
+
const t = p(n, r);
|
|
610
611
|
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
611
612
|
};
|
|
612
613
|
}
|
|
613
|
-
function
|
|
614
|
+
function ze(r, e) {
|
|
614
615
|
return function(n, t) {
|
|
615
616
|
if (typeof n > "u") return;
|
|
616
617
|
if (!n) return { value: n };
|
|
617
|
-
const a =
|
|
618
|
-
if (
|
|
618
|
+
const a = p(t, r);
|
|
619
|
+
if (S(a)) {
|
|
619
620
|
if (a.length === 1)
|
|
620
621
|
return { value: a[0], path: r };
|
|
621
622
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
@@ -624,66 +625,68 @@ function Ye(r, e) {
|
|
|
624
625
|
return { value: n };
|
|
625
626
|
};
|
|
626
627
|
}
|
|
627
|
-
function
|
|
628
|
-
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !
|
|
628
|
+
function X(r) {
|
|
629
|
+
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !X(r[e])) : q(r);
|
|
629
630
|
}
|
|
630
|
-
function
|
|
631
|
-
return
|
|
631
|
+
function Te(r) {
|
|
632
|
+
return G(r, (e) => typeof e == "object" ? X(e) : q(e));
|
|
632
633
|
}
|
|
633
634
|
function Re({ input: r, factory: e }) {
|
|
634
635
|
const { prefix: n = "" } = {};
|
|
635
636
|
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ge, { path: `${n}${r.path}`, factory: e, readonly: !1, input: r }) });
|
|
636
637
|
}
|
|
637
|
-
function
|
|
638
|
+
function je(r) {
|
|
638
639
|
const { items: e, factory: n } = r;
|
|
639
640
|
return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((t) => {
|
|
640
641
|
const a = `${t.inputType}_${t.path}_${t.label}`;
|
|
641
642
|
return /* @__PURE__ */ y.jsx(Re, { input: t, factory: n }, a);
|
|
642
643
|
}) });
|
|
643
644
|
}
|
|
644
|
-
const
|
|
645
|
+
const Ie = ie((r, e) => {
|
|
645
646
|
const { inputs: n, className: t, factory: a } = r;
|
|
646
647
|
return /* @__PURE__ */ y.jsxs("div", { className: t, ref: e, children: [
|
|
647
648
|
n.hero,
|
|
648
|
-
/* @__PURE__ */ y.jsx(
|
|
649
|
+
/* @__PURE__ */ y.jsx(je, { items: n.inputs, factory: a })
|
|
649
650
|
] });
|
|
650
651
|
});
|
|
651
|
-
|
|
652
|
-
function
|
|
652
|
+
Ie.displayName = "RenderForm";
|
|
653
|
+
function er(r) {
|
|
653
654
|
let e = !0;
|
|
654
|
-
return
|
|
655
|
-
e = e && (n === "" ||
|
|
655
|
+
return L(r, (n) => {
|
|
656
|
+
e = e && (n === "" || W(n) || q(n));
|
|
656
657
|
}), e;
|
|
657
658
|
}
|
|
658
|
-
const
|
|
659
|
+
const rr = (r = "") => se(r.split("_").join(" "));
|
|
659
660
|
export {
|
|
660
|
-
|
|
661
|
+
Ne as InputComponent,
|
|
661
662
|
ge as InputComponentRenderer,
|
|
662
663
|
xe as InputFactory,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
664
|
+
me as InputOverrideError,
|
|
665
|
+
Ie as RenderForm,
|
|
666
|
+
je as RenderInputs,
|
|
667
|
+
Fe as RootForm,
|
|
667
668
|
Re as Row,
|
|
668
|
-
|
|
669
|
-
|
|
669
|
+
We as arrayToObjectOutputTransformer,
|
|
670
|
+
rr as generateReadableLabel,
|
|
670
671
|
ke as getDefaultValuesFromFormDefinition,
|
|
671
|
-
|
|
672
|
+
De as getTemporaryPath,
|
|
673
|
+
Je as getTransformers,
|
|
672
674
|
ve as getValidationSchema,
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
675
|
+
Me as inputTransformValues,
|
|
676
|
+
er as isChildrenEmpty,
|
|
677
|
+
Ue as objectToArrayInputTransformer,
|
|
678
|
+
Be as outputTransformValues,
|
|
679
|
+
Ae as overrideFormDefinition,
|
|
680
|
+
T as processValidationParseResponse,
|
|
681
|
+
Ze as removeTemporaryFieldsValue,
|
|
682
|
+
Ke as shorthandArrayInputTransformer,
|
|
683
|
+
ze as shorthandArrayOutputTransformer,
|
|
684
|
+
Xe as shorthandObjectInputTransformer,
|
|
685
|
+
Ye as shorthandObjectOutputTransformer,
|
|
686
|
+
Ge as unsetEmptyArrayOutputTransformer,
|
|
687
|
+
He as unsetEmptyObjectOutputTransformer,
|
|
688
|
+
Qe as unsetEmptyStringOutputTransformer,
|
|
689
|
+
Le as unsetHiddenInputsValues,
|
|
690
|
+
$e as useZodValidationResolver
|
|
688
691
|
};
|
|
689
692
|
//# sourceMappingURL=index.js.map
|