@harnessio/forms 0.0.4 → 0.0.6
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 +162 -158
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Q = Object.defineProperty;
|
|
2
|
-
var Y = (r, e,
|
|
3
|
-
var x = (r, e,
|
|
4
|
-
import { isEmpty as R, cloneDeep as C, set as g, get as
|
|
2
|
+
var Y = (r, e, n) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var x = (r, e, n) => Y(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as R, cloneDeep as C, set as g, get as p, isArray as q, isObject as L, merge as T, isUndefined as I, pick as K, unset as X, omitBy as U, isString as z, forOwn as ee, isNull as re, capitalize as te } from "lodash-es";
|
|
5
5
|
import ne, { useMemo as Z, useRef as P, useEffect as O, useCallback as se, forwardRef as ae } from "react";
|
|
6
6
|
import { useFormContext as ue, useForm as ie, FormProvider as oe, appendErrors as ce } from "react-hook-form";
|
|
7
7
|
export * from "react-hook-form";
|
|
@@ -44,8 +44,8 @@ var k, $;
|
|
|
44
44
|
function le() {
|
|
45
45
|
if ($) return k;
|
|
46
46
|
$ = 1;
|
|
47
|
-
var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty,
|
|
48
|
-
function
|
|
47
|
+
var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
|
|
48
|
+
function t(s) {
|
|
49
49
|
if (s == null)
|
|
50
50
|
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
51
51
|
return Object(s);
|
|
@@ -73,14 +73,14 @@ function le() {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
return k = a() ? Object.assign : function(s, o) {
|
|
76
|
-
for (var i, c =
|
|
76
|
+
for (var i, c = t(s), f, u = 1; u < arguments.length; u++) {
|
|
77
77
|
i = Object(arguments[u]);
|
|
78
78
|
for (var d in i)
|
|
79
79
|
e.call(i, d) && (c[d] = i[d]);
|
|
80
80
|
if (r) {
|
|
81
81
|
f = r(i);
|
|
82
82
|
for (var l = 0; l < f.length; l++)
|
|
83
|
-
|
|
83
|
+
n.call(i, f[l]) && (c[f[l]] = i[f[l]]);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
return c;
|
|
@@ -100,16 +100,16 @@ function me() {
|
|
|
100
100
|
M = 1, le();
|
|
101
101
|
var r = ne, e = 60103;
|
|
102
102
|
if (v.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
103
|
-
var
|
|
104
|
-
e =
|
|
103
|
+
var n = Symbol.for;
|
|
104
|
+
e = n("react.element"), v.Fragment = n("react.fragment");
|
|
105
105
|
}
|
|
106
|
-
var
|
|
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(i, c, f) {
|
|
108
108
|
var u, d = {}, l = null, h = null;
|
|
109
109
|
f !== void 0 && (l = "" + f), c.key !== void 0 && (l = "" + c.key), c.ref !== void 0 && (h = c.ref);
|
|
110
110
|
for (u in c) a.call(c, u) && !s.hasOwnProperty(u) && (d[u] = c[u]);
|
|
111
111
|
if (i && i.defaultProps) for (u in c = i.defaultProps, c) d[u] === void 0 && (d[u] = c[u]);
|
|
112
|
-
return { $$typeof: e, type: i, key: l, ref: h, props: d, _owner:
|
|
112
|
+
return { $$typeof: e, type: i, key: l, ref: h, props: d, _owner: t.current };
|
|
113
113
|
}
|
|
114
114
|
return v.jsx = o, v.jsxs = o, v;
|
|
115
115
|
}
|
|
@@ -121,8 +121,8 @@ var y = he();
|
|
|
121
121
|
function ye({
|
|
122
122
|
path: r,
|
|
123
123
|
factory: e,
|
|
124
|
-
onUpdate:
|
|
125
|
-
onChange:
|
|
124
|
+
onUpdate: n,
|
|
125
|
+
onChange: t,
|
|
126
126
|
readonly: a,
|
|
127
127
|
initialValues: s,
|
|
128
128
|
input: o
|
|
@@ -135,24 +135,24 @@ function ye({
|
|
|
135
135
|
() => ({
|
|
136
136
|
path: r,
|
|
137
137
|
initialValues: s,
|
|
138
|
-
onUpdate:
|
|
139
|
-
onChange:
|
|
138
|
+
onUpdate: n,
|
|
139
|
+
onChange: t,
|
|
140
140
|
factory: e,
|
|
141
141
|
readonly: a,
|
|
142
142
|
input: o
|
|
143
143
|
}),
|
|
144
|
-
[e, s, o,
|
|
144
|
+
[e, s, o, t, n, r, a, i.errors]
|
|
145
145
|
), h = c(), S = C(h);
|
|
146
146
|
u && Object.keys(u).forEach((_) => {
|
|
147
147
|
const H = u[_];
|
|
148
148
|
g(S, _, H);
|
|
149
149
|
});
|
|
150
|
-
const
|
|
150
|
+
const b = !o.isVisible || (o == null ? void 0 : o.isVisible(S, f)), j = Z(() => b ? /* @__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, b, i.errors]);
|
|
155
|
+
return d ? b ? j : null : /* @__PURE__ */ y.jsxs("p", { children: [
|
|
156
156
|
"Input component not found (internal type: ",
|
|
157
157
|
o.inputType,
|
|
158
158
|
")"
|
|
@@ -166,8 +166,8 @@ class xe {
|
|
|
166
166
|
function Pe(r) {
|
|
167
167
|
const {
|
|
168
168
|
mode: e = "onSubmit",
|
|
169
|
-
resolver:
|
|
170
|
-
defaultValues:
|
|
169
|
+
resolver: n,
|
|
170
|
+
defaultValues: t,
|
|
171
171
|
shouldFocusError: a,
|
|
172
172
|
// validateAfterFirstSubmit,
|
|
173
173
|
onValuesChange: s,
|
|
@@ -183,13 +183,13 @@ function Pe(r) {
|
|
|
183
183
|
} = r, u = ie({
|
|
184
184
|
mode: e ?? "onSubmit",
|
|
185
185
|
reValidateMode: "onChange",
|
|
186
|
-
defaultValues:
|
|
186
|
+
defaultValues: t,
|
|
187
187
|
shouldFocusError: a,
|
|
188
|
-
resolver:
|
|
188
|
+
resolver: n
|
|
189
189
|
}), d = P(!1);
|
|
190
190
|
O(() => {
|
|
191
|
-
u.reset(
|
|
192
|
-
}, [u.reset,
|
|
191
|
+
u.reset(t, {});
|
|
192
|
+
}, [u.reset, t]), O(() => {
|
|
193
193
|
requestIdleCallback(() => {
|
|
194
194
|
u.reset({}, {
|
|
195
195
|
keepErrors: !0,
|
|
@@ -205,10 +205,10 @@ function Pe(r) {
|
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
}, []);
|
|
208
|
-
const { getValues: l, handleSubmit: h } = u, S = l(),
|
|
208
|
+
const { getValues: l, handleSubmit: h } = u, S = l(), b = P(!0);
|
|
209
209
|
O(() => {
|
|
210
|
-
if (
|
|
211
|
-
|
|
210
|
+
if (b.current) {
|
|
211
|
+
b.current = !1;
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
214
|
s == null || s({ ...S }), d.current === !0 && u.trigger();
|
|
@@ -243,41 +243,45 @@ function Pe(r) {
|
|
|
243
243
|
}) : c });
|
|
244
244
|
}
|
|
245
245
|
const Ne = (r) => {
|
|
246
|
+
var n;
|
|
246
247
|
const e = {};
|
|
247
|
-
return r.inputs.forEach((t) => {
|
|
248
|
-
|
|
248
|
+
return (n = r == null ? void 0 : r.inputs) == null || n.forEach((t) => {
|
|
249
|
+
var a;
|
|
250
|
+
t.inputType === "group" && ((a = t == null ? void 0 : t.inputs) == null || a.forEach((s) => {
|
|
251
|
+
typeof p(e, s.path) > "u" && g(e, s.path, s.default);
|
|
252
|
+
})), typeof p(e, t.path) > "u" && g(e, t.path, t.default);
|
|
249
253
|
}), e;
|
|
250
254
|
};
|
|
251
255
|
function ke(r, e) {
|
|
252
|
-
const
|
|
253
|
-
const a =
|
|
254
|
-
return a ||
|
|
256
|
+
const n = r.inputs.map((t) => {
|
|
257
|
+
const a = ge(e, t.path);
|
|
258
|
+
return a || t;
|
|
255
259
|
});
|
|
256
|
-
return { ...r, inputs:
|
|
260
|
+
return { ...r, inputs: n };
|
|
257
261
|
}
|
|
258
|
-
function
|
|
259
|
-
return r.inputs.find((
|
|
262
|
+
function ge(r, e) {
|
|
263
|
+
return r.inputs.find((n) => n.path === e);
|
|
260
264
|
}
|
|
261
|
-
const
|
|
265
|
+
const pe = "Required field";
|
|
262
266
|
function E(r) {
|
|
263
267
|
const e = typeof r == "string" ? JSON.parse(r) : r;
|
|
264
268
|
if (typeof e == "string")
|
|
265
269
|
return e;
|
|
266
270
|
if (q(e))
|
|
267
271
|
return E(e[0]);
|
|
268
|
-
const
|
|
269
|
-
return L(
|
|
270
|
-
}
|
|
271
|
-
function be(r, e,
|
|
272
|
-
let
|
|
273
|
-
if (w(
|
|
274
|
-
const s =
|
|
275
|
-
|
|
272
|
+
const n = e;
|
|
273
|
+
return L(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
274
|
+
}
|
|
275
|
+
function be(r, e, n) {
|
|
276
|
+
let t = {};
|
|
277
|
+
if (w(t, r.inputs, e, n), n != null && n.prefix) {
|
|
278
|
+
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
279
|
+
t = g({}, s, t);
|
|
276
280
|
}
|
|
277
|
-
return m.object(V(
|
|
281
|
+
return m.object(V(t, e, n));
|
|
278
282
|
}
|
|
279
|
-
function V(r, e,
|
|
280
|
-
const
|
|
283
|
+
function V(r, e, n) {
|
|
284
|
+
const t = {};
|
|
281
285
|
return Object.keys(r).forEach((a) => {
|
|
282
286
|
const {
|
|
283
287
|
_requiredOnly: s,
|
|
@@ -289,27 +293,27 @@ function V(r, e, t) {
|
|
|
289
293
|
/*...nestedSchemaObj*/
|
|
290
294
|
} = r[a];
|
|
291
295
|
if (c && o && i) {
|
|
292
|
-
const d = m.array(m.object(V(o, e,
|
|
293
|
-
|
|
296
|
+
const d = m.array(m.object(V(o, e, n))).optional(), l = J(u, i, e, n, d);
|
|
297
|
+
t[a] = l;
|
|
294
298
|
} else if (f && i) {
|
|
295
|
-
const d = o != null && o.___array ? V({ ___array: o.___array }, e,
|
|
296
|
-
|
|
299
|
+
const d = o != null && o.___array ? V({ ___array: o.___array }, e, n) : { ___array: m.any() }, l = m.array(d.___array).optional(), h = J(u, i, e, n, l);
|
|
300
|
+
t[a] = h;
|
|
297
301
|
} else if (u && i) {
|
|
298
|
-
const d = _e(u, i, e,
|
|
299
|
-
|
|
300
|
-
} else s && i ?
|
|
301
|
-
}),
|
|
302
|
+
const d = _e(u, i, e, n);
|
|
303
|
+
t[a] = d;
|
|
304
|
+
} else s && i ? t[a] = A(i, n) : t[a] = m.object(V(r[a], e, n)).optional();
|
|
305
|
+
}), t;
|
|
302
306
|
}
|
|
303
|
-
function _e(r, e,
|
|
307
|
+
function _e(r, e, n, t) {
|
|
304
308
|
return m.any().optional().superRefine(async (a, s) => {
|
|
305
309
|
var i, c;
|
|
306
|
-
if (e.required && !(await A(e,
|
|
310
|
+
if (e.required && !(await A(e, t).safeParseAsync(a)).success)
|
|
307
311
|
return s.addIssue({
|
|
308
312
|
code: m.ZodIssueCode.custom,
|
|
309
|
-
message: F(e,
|
|
313
|
+
message: F(e, t)
|
|
310
314
|
}), m.NEVER;
|
|
311
|
-
if ((i =
|
|
312
|
-
const f = (c =
|
|
315
|
+
if ((i = t == null ? void 0 : t.validationConfig) != null && i.globalValidation) {
|
|
316
|
+
const f = (c = t == null ? void 0 : t.validationConfig) == null ? void 0 : c.globalValidation(a, e, t.metadata);
|
|
313
317
|
if (f.error)
|
|
314
318
|
return s.addIssue({
|
|
315
319
|
code: m.ZodIssueCode.custom,
|
|
@@ -318,11 +322,11 @@ function _e(r, e, t, n) {
|
|
|
318
322
|
if (!f.continue)
|
|
319
323
|
return !0;
|
|
320
324
|
}
|
|
321
|
-
const o = W(r,
|
|
325
|
+
const o = W(r, n);
|
|
322
326
|
if (o) {
|
|
323
327
|
const f = await o.safeParseAsync(a);
|
|
324
328
|
if (!f.success) {
|
|
325
|
-
const u = E(f == null ? void 0 : f.error.message), d = u === "Required" ? F(e,
|
|
329
|
+
const u = E(f == null ? void 0 : f.error.message), d = u === "Required" ? F(e, t) : u;
|
|
326
330
|
s.addIssue({
|
|
327
331
|
code: m.ZodIssueCode.custom,
|
|
328
332
|
message: d
|
|
@@ -331,18 +335,18 @@ function _e(r, e, t, n) {
|
|
|
331
335
|
}
|
|
332
336
|
});
|
|
333
337
|
}
|
|
334
|
-
function J(r, e,
|
|
338
|
+
function J(r, e, n, t, a) {
|
|
335
339
|
return m.any().optional().superRefine(async (s, o) => {
|
|
336
340
|
var u, d;
|
|
337
|
-
const c = await A(e,
|
|
341
|
+
const c = await A(e, t).safeParseAsync(s);
|
|
338
342
|
if (e.required && !c.success) {
|
|
339
343
|
const l = E(c.error.message);
|
|
340
344
|
return o.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
|
|
341
345
|
}
|
|
342
346
|
if (!e.required && !c.success)
|
|
343
347
|
return m.NEVER;
|
|
344
|
-
if ((u =
|
|
345
|
-
const l = (d =
|
|
348
|
+
if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
|
|
349
|
+
const l = (d = t == null ? void 0 : t.validationConfig) == null ? void 0 : d.globalValidation(s, e, t.metadata);
|
|
346
350
|
if (l.error)
|
|
347
351
|
return o.addIssue({
|
|
348
352
|
code: m.ZodIssueCode.custom,
|
|
@@ -356,7 +360,7 @@ function J(r, e, t, n, a) {
|
|
|
356
360
|
code: m.ZodIssueCode.custom,
|
|
357
361
|
message: "'Value is not array'"
|
|
358
362
|
}), m.NEVER;
|
|
359
|
-
const f = W(r,
|
|
363
|
+
const f = W(r, n);
|
|
360
364
|
if (f) {
|
|
361
365
|
const l = await f.safeParseAsync(s);
|
|
362
366
|
if (!l.success)
|
|
@@ -367,12 +371,12 @@ function J(r, e, t, n, a) {
|
|
|
367
371
|
}
|
|
368
372
|
}).pipe(a ?? m.any());
|
|
369
373
|
}
|
|
370
|
-
function w(r, e,
|
|
374
|
+
function w(r, e, n, t, a) {
|
|
371
375
|
e.forEach((s) => {
|
|
372
376
|
var i, c, f, u, d;
|
|
373
|
-
const o =
|
|
374
|
-
if (!s.isVisible || (i = s.isVisible) != null && i.call(s, o,
|
|
375
|
-
const l =
|
|
377
|
+
const o = n;
|
|
378
|
+
if (!s.isVisible || (i = s.isVisible) != null && i.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
379
|
+
const l = p(r, s.path);
|
|
376
380
|
if ((c = s.validation) != null && c.schema ? g(
|
|
377
381
|
r,
|
|
378
382
|
s.path,
|
|
@@ -380,18 +384,18 @@ function w(r, e, t, n, a) {
|
|
|
380
384
|
_schema: (f = s.validation) == null ? void 0 : f.schema,
|
|
381
385
|
_input: s
|
|
382
386
|
})
|
|
383
|
-
) : s.required && g(r, s.path, T(l, { _requiredOnly: !0, _input: s })), s.inputs && w(r, s.inputs,
|
|
387
|
+
) : s.required && g(r, s.path, T(l, { _requiredOnly: !0, _input: s })), s.inputs && w(r, s.inputs, n, t), s.inputType === "list") {
|
|
384
388
|
const h = {};
|
|
385
389
|
w(
|
|
386
390
|
h,
|
|
387
|
-
s.inputConfig.inputs.map((
|
|
388
|
-
...
|
|
389
|
-
path:
|
|
391
|
+
s.inputConfig.inputs.map((b) => ({
|
|
392
|
+
...b,
|
|
393
|
+
path: b.relativePath
|
|
390
394
|
})),
|
|
391
|
-
|
|
392
|
-
|
|
395
|
+
n,
|
|
396
|
+
t
|
|
393
397
|
);
|
|
394
|
-
const S =
|
|
398
|
+
const S = p(r, s.path);
|
|
395
399
|
g(r, s.path, T(S, { _schemaObj: h, _isList: !0, _input: s }));
|
|
396
400
|
}
|
|
397
401
|
if (!((u = s.validation) != null && u.schema) && s.inputType === "array") {
|
|
@@ -399,8 +403,8 @@ function w(r, e, t, n, a) {
|
|
|
399
403
|
w(
|
|
400
404
|
h,
|
|
401
405
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
402
|
-
|
|
403
|
-
|
|
406
|
+
n,
|
|
407
|
+
t
|
|
404
408
|
), g(
|
|
405
409
|
r,
|
|
406
410
|
s.path,
|
|
@@ -416,23 +420,23 @@ function w(r, e, t, n, a) {
|
|
|
416
420
|
});
|
|
417
421
|
}
|
|
418
422
|
function F(r, e) {
|
|
419
|
-
var
|
|
420
|
-
return ((
|
|
423
|
+
var n, t, a;
|
|
424
|
+
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) ?? pe;
|
|
421
425
|
}
|
|
422
426
|
function A(r, e) {
|
|
423
|
-
var
|
|
424
|
-
if ((a = (
|
|
427
|
+
var t, a, s, o, i, c;
|
|
428
|
+
if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
|
|
425
429
|
return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
|
|
426
430
|
if ((i = e == null ? void 0 : e.validationConfig) != null && i.requiredSchema)
|
|
427
431
|
return (c = e == null ? void 0 : e.validationConfig) == null ? void 0 : c.requiredSchema;
|
|
428
|
-
const
|
|
432
|
+
const n = F(r, e);
|
|
429
433
|
return m.any().optional().superRefine((f, u) => {
|
|
430
434
|
typeof f == "object" && R(f) && u.addIssue({
|
|
431
435
|
code: m.ZodIssueCode.custom,
|
|
432
|
-
message:
|
|
436
|
+
message: n
|
|
433
437
|
}), (I(f) || f === "") && u.addIssue({
|
|
434
438
|
code: m.ZodIssueCode.custom,
|
|
435
|
-
message:
|
|
439
|
+
message: n
|
|
436
440
|
});
|
|
437
441
|
});
|
|
438
442
|
}
|
|
@@ -443,39 +447,39 @@ function W(r, e) {
|
|
|
443
447
|
return r(e);
|
|
444
448
|
}
|
|
445
449
|
const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), ve = (r, e) => {
|
|
446
|
-
const
|
|
450
|
+
const n = {};
|
|
447
451
|
for (; r.length; ) {
|
|
448
|
-
const
|
|
449
|
-
if (!
|
|
450
|
-
if ("unionErrors" in
|
|
451
|
-
const c =
|
|
452
|
-
|
|
452
|
+
const t = r[0], { code: a, message: s, path: o } = t, i = o.join(".");
|
|
453
|
+
if (!n[i])
|
|
454
|
+
if ("unionErrors" in t) {
|
|
455
|
+
const c = t.unionErrors[0].errors[0];
|
|
456
|
+
n[i] = {
|
|
453
457
|
message: c.message,
|
|
454
458
|
type: c.code
|
|
455
459
|
};
|
|
456
460
|
} else
|
|
457
|
-
|
|
458
|
-
"unionErrors" in
|
|
461
|
+
n[i] = { message: s, type: a };
|
|
462
|
+
"unionErrors" in t && t.unionErrors.forEach((c) => c.errors.forEach((f) => r.push(f)));
|
|
459
463
|
{
|
|
460
|
-
const c =
|
|
461
|
-
|
|
464
|
+
const c = n[i].types, f = c && c[t.code];
|
|
465
|
+
n[i] = ce(
|
|
462
466
|
i,
|
|
463
467
|
e,
|
|
464
|
-
|
|
468
|
+
n,
|
|
465
469
|
a,
|
|
466
|
-
f ? [].concat(f,
|
|
470
|
+
f ? [].concat(f, t.message) : t.message
|
|
467
471
|
);
|
|
468
472
|
}
|
|
469
473
|
r.shift();
|
|
470
474
|
}
|
|
471
|
-
return
|
|
475
|
+
return n;
|
|
472
476
|
};
|
|
473
477
|
function Fe(r, e) {
|
|
474
478
|
return se(
|
|
475
|
-
async (
|
|
479
|
+
async (n, t, a) => {
|
|
476
480
|
try {
|
|
477
|
-
return await be(r,
|
|
478
|
-
values:
|
|
481
|
+
return await be(r, n, e).parseAsync(n), {
|
|
482
|
+
values: n,
|
|
479
483
|
// TODO: check this - values does not contains all data
|
|
480
484
|
errors: {}
|
|
481
485
|
};
|
|
@@ -492,59 +496,59 @@ function Fe(r, e) {
|
|
|
492
496
|
);
|
|
493
497
|
}
|
|
494
498
|
function Ae(r, e) {
|
|
495
|
-
const
|
|
496
|
-
return e.forEach((
|
|
497
|
-
if (
|
|
498
|
-
const a =
|
|
499
|
-
s && g(
|
|
499
|
+
const n = C(r);
|
|
500
|
+
return e.forEach((t) => {
|
|
501
|
+
if (t.inputTransform) {
|
|
502
|
+
const a = p(n, t.path), s = t.inputTransform(a, n);
|
|
503
|
+
s && g(n, s.path ?? t.path, s.value);
|
|
500
504
|
}
|
|
501
|
-
}),
|
|
505
|
+
}), n;
|
|
502
506
|
}
|
|
503
507
|
function De(r, e) {
|
|
504
|
-
const
|
|
505
|
-
return e.forEach((
|
|
506
|
-
if (
|
|
507
|
-
const a =
|
|
508
|
-
s && g(
|
|
508
|
+
const n = C(r);
|
|
509
|
+
return e.forEach((t) => {
|
|
510
|
+
if (t.outputTransform) {
|
|
511
|
+
const a = p(n, t.path), s = t.outputTransform(a, n);
|
|
512
|
+
s && g(n, s.path ?? t.path, s.value);
|
|
509
513
|
}
|
|
510
|
-
}),
|
|
514
|
+
}), n;
|
|
511
515
|
}
|
|
512
516
|
function D(r) {
|
|
513
|
-
return r.reduce((
|
|
517
|
+
return r.reduce((n, t) => t.inputType === "group" && t.inputs ? [...n, t, ...D(t.inputs)] : [...n, t], []);
|
|
514
518
|
}
|
|
515
519
|
function Ze(r) {
|
|
516
|
-
const
|
|
520
|
+
const n = D(r.inputs).reduce((t, a) => {
|
|
517
521
|
const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
|
|
518
|
-
return (a.inputTransform || a.outputTransform) &&
|
|
522
|
+
return (a.inputTransform || a.outputTransform) && t.push({
|
|
519
523
|
...K(a, "path", "inputTransform", "outputTransform"),
|
|
520
524
|
level: a.path.split(".").length,
|
|
521
525
|
isPrimitive: s
|
|
522
|
-
}),
|
|
526
|
+
}), t;
|
|
523
527
|
}, []);
|
|
524
|
-
return
|
|
528
|
+
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
525
529
|
}
|
|
526
|
-
function $e(r, e,
|
|
527
|
-
const
|
|
528
|
-
return
|
|
529
|
-
s.isVisible && !s.isVisible(e,
|
|
530
|
+
function $e(r, e, n) {
|
|
531
|
+
const t = D(r.inputs), a = C(e);
|
|
532
|
+
return t.forEach((s) => {
|
|
533
|
+
s.isVisible && !s.isVisible(e, n) && X(a, s.path);
|
|
530
534
|
}), a;
|
|
531
535
|
}
|
|
532
536
|
function Me() {
|
|
533
537
|
return function(r, e) {
|
|
534
538
|
if (!(typeof r > "u"))
|
|
535
539
|
return r ? {
|
|
536
|
-
value: Object.getOwnPropertyNames(r).map((
|
|
540
|
+
value: Object.getOwnPropertyNames(r).map((n) => ({ key: n, value: r[n] }))
|
|
537
541
|
} : { value: r };
|
|
538
542
|
};
|
|
539
543
|
}
|
|
540
544
|
function Be(r) {
|
|
541
|
-
return function(e,
|
|
545
|
+
return function(e, n) {
|
|
542
546
|
if (typeof e > "u") return;
|
|
543
547
|
if (!e) return { value: e };
|
|
544
|
-
const
|
|
548
|
+
const t = {
|
|
545
549
|
value: e.reduce((a, s) => ({ ...a, [s.key]: s.value }), {})
|
|
546
550
|
};
|
|
547
|
-
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(
|
|
551
|
+
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
548
552
|
};
|
|
549
553
|
}
|
|
550
554
|
function Je() {
|
|
@@ -557,8 +561,8 @@ function Le() {
|
|
|
557
561
|
return function(r, e) {
|
|
558
562
|
if (!(typeof r > "u")) {
|
|
559
563
|
if (L(r)) {
|
|
560
|
-
const
|
|
561
|
-
if (R(
|
|
564
|
+
const n = U(r, I);
|
|
565
|
+
if (R(n))
|
|
562
566
|
return { value: void 0 };
|
|
563
567
|
}
|
|
564
568
|
return { value: r };
|
|
@@ -572,18 +576,18 @@ function Ue() {
|
|
|
572
576
|
};
|
|
573
577
|
}
|
|
574
578
|
function We(r) {
|
|
575
|
-
return function(e,
|
|
576
|
-
const
|
|
577
|
-
return typeof
|
|
579
|
+
return function(e, n) {
|
|
580
|
+
const t = p(n, r);
|
|
581
|
+
return typeof t == "string" ? { value: t } : { value: e };
|
|
578
582
|
};
|
|
579
583
|
}
|
|
580
584
|
function Ge(r) {
|
|
581
|
-
return function(e,
|
|
585
|
+
return function(e, n) {
|
|
582
586
|
if (typeof e > "u") return;
|
|
583
587
|
if (!e) return { value: e };
|
|
584
|
-
const
|
|
585
|
-
if (typeof
|
|
586
|
-
const a = Oe(
|
|
588
|
+
const t = p(n, r);
|
|
589
|
+
if (typeof t == "object") {
|
|
590
|
+
const a = Oe(t);
|
|
587
591
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
588
592
|
return { value: e, path: r };
|
|
589
593
|
}
|
|
@@ -591,24 +595,24 @@ function Ge(r) {
|
|
|
591
595
|
};
|
|
592
596
|
}
|
|
593
597
|
function He(r) {
|
|
594
|
-
return function(e,
|
|
598
|
+
return function(e, n) {
|
|
595
599
|
if (typeof e > "u") return;
|
|
596
|
-
const
|
|
597
|
-
return typeof
|
|
600
|
+
const t = p(n, r);
|
|
601
|
+
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
598
602
|
};
|
|
599
603
|
}
|
|
600
604
|
function Qe(r, e) {
|
|
601
|
-
return function(
|
|
602
|
-
if (typeof
|
|
603
|
-
if (!
|
|
604
|
-
const a =
|
|
605
|
+
return function(n, t) {
|
|
606
|
+
if (typeof n > "u") return;
|
|
607
|
+
if (!n) return { value: n };
|
|
608
|
+
const a = p(t, r);
|
|
605
609
|
if (q(a)) {
|
|
606
610
|
if (a.length === 1)
|
|
607
611
|
return { value: a[0], path: r };
|
|
608
612
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
609
613
|
return { value: void 0, path: r };
|
|
610
614
|
}
|
|
611
|
-
return { value:
|
|
615
|
+
return { value: n };
|
|
612
616
|
};
|
|
613
617
|
}
|
|
614
618
|
function G(r) {
|
|
@@ -618,28 +622,28 @@ function Oe(r) {
|
|
|
618
622
|
return U(r, (e) => typeof e == "object" ? G(e) : I(e));
|
|
619
623
|
}
|
|
620
624
|
function Ee({ input: r, factory: e }) {
|
|
621
|
-
const { prefix:
|
|
622
|
-
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ye, { path: `${
|
|
625
|
+
const { prefix: n = "" } = {};
|
|
626
|
+
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ye, { path: `${n}${r.path}`, factory: e, readonly: !1, input: r }) });
|
|
623
627
|
}
|
|
624
628
|
function Re(r) {
|
|
625
|
-
const { items: e, factory:
|
|
626
|
-
return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((
|
|
627
|
-
const a = `${
|
|
628
|
-
return /* @__PURE__ */ y.jsx(Ee, { input:
|
|
629
|
+
const { items: e, factory: n } = r;
|
|
630
|
+
return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((t) => {
|
|
631
|
+
const a = `${t.inputType}_${t.path}_${t.label}`;
|
|
632
|
+
return /* @__PURE__ */ y.jsx(Ee, { input: t, factory: n }, a);
|
|
629
633
|
}) });
|
|
630
634
|
}
|
|
631
635
|
const Ie = ae((r, e) => {
|
|
632
|
-
const { inputs:
|
|
633
|
-
return /* @__PURE__ */ y.jsxs("div", { className:
|
|
634
|
-
|
|
635
|
-
/* @__PURE__ */ y.jsx(Re, { items:
|
|
636
|
+
const { inputs: n, className: t, factory: a } = r;
|
|
637
|
+
return /* @__PURE__ */ y.jsxs("div", { className: t, ref: e, children: [
|
|
638
|
+
n.hero,
|
|
639
|
+
/* @__PURE__ */ y.jsx(Re, { items: n.inputs, factory: a })
|
|
636
640
|
] });
|
|
637
641
|
});
|
|
638
642
|
Ie.displayName = "RenderForm";
|
|
639
643
|
function Ye(r) {
|
|
640
644
|
let e = !0;
|
|
641
|
-
return ee(r, (
|
|
642
|
-
e = e && (
|
|
645
|
+
return ee(r, (n) => {
|
|
646
|
+
e = e && (n === "" || re(n) || I(n));
|
|
643
647
|
}), e;
|
|
644
648
|
}
|
|
645
649
|
const Ke = (r = "") => te(r.split("_").join(" "));
|