@harnessio/forms 0.0.6 → 0.0.7
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 +20 -49
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +150 -143
- package/dist/index.js.map +1 -1
- package/dist/types/types.d.ts +10 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Q = Object.defineProperty;
|
|
2
2
|
var Y = (r, e, n) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
3
|
var x = (r, e, n) => Y(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { isEmpty as
|
|
4
|
+
import { isEmpty as T, cloneDeep as q, set as p, get as g, isArray as E, isObject as L, merge as V, isUndefined as j, 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";
|
|
@@ -30,11 +30,11 @@ class qe {
|
|
|
30
30
|
this.componentBank.set(e.internalType, e);
|
|
31
31
|
}
|
|
32
32
|
getComponent(e) {
|
|
33
|
-
if (e && !
|
|
33
|
+
if (e && !T(e))
|
|
34
34
|
return this.componentBank.get(e);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
var N = { exports: {} },
|
|
37
|
+
var N = { exports: {} }, S = {};
|
|
38
38
|
/*
|
|
39
39
|
object-assign
|
|
40
40
|
(c) Sindre Sorhus
|
|
@@ -57,30 +57,30 @@ function le() {
|
|
|
57
57
|
var s = new String("abc");
|
|
58
58
|
if (s[5] = "de", Object.getOwnPropertyNames(s)[0] === "5")
|
|
59
59
|
return !1;
|
|
60
|
-
for (var o = {},
|
|
61
|
-
o["_" + String.fromCharCode(
|
|
62
|
-
var c = Object.getOwnPropertyNames(o).map(function(
|
|
63
|
-
return o[
|
|
60
|
+
for (var o = {}, u = 0; u < 10; u++)
|
|
61
|
+
o["_" + String.fromCharCode(u)] = u;
|
|
62
|
+
var c = Object.getOwnPropertyNames(o).map(function(i) {
|
|
63
|
+
return o[i];
|
|
64
64
|
});
|
|
65
65
|
if (c.join("") !== "0123456789")
|
|
66
66
|
return !1;
|
|
67
67
|
var f = {};
|
|
68
|
-
return "abcdefghijklmnopqrst".split("").forEach(function(
|
|
69
|
-
f[
|
|
68
|
+
return "abcdefghijklmnopqrst".split("").forEach(function(i) {
|
|
69
|
+
f[i] = i;
|
|
70
70
|
}), Object.keys(Object.assign({}, f)).join("") === "abcdefghijklmnopqrst";
|
|
71
71
|
} catch {
|
|
72
72
|
return !1;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
return k = a() ? Object.assign : function(s, o) {
|
|
76
|
-
for (var
|
|
77
|
-
|
|
78
|
-
for (var d in
|
|
79
|
-
e.call(
|
|
76
|
+
for (var u, c = t(s), f, i = 1; i < arguments.length; i++) {
|
|
77
|
+
u = Object(arguments[i]);
|
|
78
|
+
for (var d in u)
|
|
79
|
+
e.call(u, d) && (c[d] = u[d]);
|
|
80
80
|
if (r) {
|
|
81
|
-
f = r(
|
|
81
|
+
f = r(u);
|
|
82
82
|
for (var l = 0; l < f.length; l++)
|
|
83
|
-
n.call(
|
|
83
|
+
n.call(u, f[l]) && (c[f[l]] = u[f[l]]);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
return c;
|
|
@@ -96,22 +96,22 @@ function le() {
|
|
|
96
96
|
*/
|
|
97
97
|
var M;
|
|
98
98
|
function me() {
|
|
99
|
-
if (M) return
|
|
99
|
+
if (M) return S;
|
|
100
100
|
M = 1, le();
|
|
101
101
|
var r = ne, e = 60103;
|
|
102
|
-
if (
|
|
102
|
+
if (S.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
103
103
|
var n = Symbol.for;
|
|
104
|
-
e = n("react.element"),
|
|
104
|
+
e = n("react.element"), S.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
|
-
function o(
|
|
108
|
-
var
|
|
107
|
+
function o(u, c, f) {
|
|
108
|
+
var i, 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
|
-
for (
|
|
111
|
-
if (
|
|
112
|
-
return { $$typeof: e, type:
|
|
110
|
+
for (i in c) a.call(c, i) && !s.hasOwnProperty(i) && (d[i] = c[i]);
|
|
111
|
+
if (u && u.defaultProps) for (i in c = u.defaultProps, c) d[i] === void 0 && (d[i] = c[i]);
|
|
112
|
+
return { $$typeof: e, type: u, key: l, ref: h, props: d, _owner: t.current };
|
|
113
113
|
}
|
|
114
|
-
return
|
|
114
|
+
return S.jsx = o, S.jsxs = o, S;
|
|
115
115
|
}
|
|
116
116
|
var B;
|
|
117
117
|
function he() {
|
|
@@ -127,9 +127,9 @@ function ye({
|
|
|
127
127
|
initialValues: s,
|
|
128
128
|
input: o
|
|
129
129
|
}) {
|
|
130
|
-
const { formState:
|
|
130
|
+
const { formState: u, watch: c } = ue(), {
|
|
131
131
|
metadata: f = {},
|
|
132
|
-
fixedValues:
|
|
132
|
+
fixedValues: i = {}
|
|
133
133
|
/*getValuesWithDependencies*/
|
|
134
134
|
} = {}, d = e == null ? void 0 : e.getComponent(o.inputType), l = Z(
|
|
135
135
|
() => ({
|
|
@@ -141,18 +141,18 @@ function ye({
|
|
|
141
141
|
readonly: a,
|
|
142
142
|
input: o
|
|
143
143
|
}),
|
|
144
|
-
[e, s, o, t, n, r, a,
|
|
145
|
-
), h = c(),
|
|
146
|
-
|
|
147
|
-
const H =
|
|
148
|
-
|
|
144
|
+
[e, s, o, t, n, r, a, u.errors]
|
|
145
|
+
), h = c(), v = q(h);
|
|
146
|
+
i && Object.keys(i).forEach((_) => {
|
|
147
|
+
const H = i[_];
|
|
148
|
+
p(v, _, H);
|
|
149
149
|
});
|
|
150
|
-
const b = !o.isVisible || (o == null ? void 0 : o.isVisible(
|
|
150
|
+
const b = !o.isVisible || (o == null ? void 0 : o.isVisible(v, f)), I = 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, b,
|
|
155
|
-
return d ? b ?
|
|
154
|
+
] }) : null, [l, o.after, o.before, d, b, u.errors]);
|
|
155
|
+
return d ? b ? I : null : /* @__PURE__ */ y.jsxs("p", { children: [
|
|
156
156
|
"Input component not found (internal type: ",
|
|
157
157
|
o.inputType,
|
|
158
158
|
")"
|
|
@@ -172,7 +172,7 @@ function Pe(r) {
|
|
|
172
172
|
// validateAfterFirstSubmit,
|
|
173
173
|
onValuesChange: s,
|
|
174
174
|
onValidationChange: o,
|
|
175
|
-
onSubmit:
|
|
175
|
+
onSubmit: u,
|
|
176
176
|
// validate,
|
|
177
177
|
// validateDebounceInterval,
|
|
178
178
|
// validationConfig,
|
|
@@ -180,7 +180,7 @@ function Pe(r) {
|
|
|
180
180
|
children: c,
|
|
181
181
|
// fixedValues
|
|
182
182
|
autoFocusPath: f
|
|
183
|
-
} = r,
|
|
183
|
+
} = r, i = ie({
|
|
184
184
|
mode: e ?? "onSubmit",
|
|
185
185
|
reValidateMode: "onChange",
|
|
186
186
|
defaultValues: t,
|
|
@@ -188,10 +188,10 @@ function Pe(r) {
|
|
|
188
188
|
resolver: n
|
|
189
189
|
}), d = P(!1);
|
|
190
190
|
O(() => {
|
|
191
|
-
|
|
192
|
-
}, [
|
|
191
|
+
i.reset(t, {});
|
|
192
|
+
}, [i.reset, t]), O(() => {
|
|
193
193
|
requestIdleCallback(() => {
|
|
194
|
-
|
|
194
|
+
i.reset({}, {
|
|
195
195
|
keepErrors: !0,
|
|
196
196
|
keepDirty: !0,
|
|
197
197
|
keepDirtyValues: !0,
|
|
@@ -205,39 +205,39 @@ function Pe(r) {
|
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
}, []);
|
|
208
|
-
const { getValues: l, handleSubmit: h } =
|
|
208
|
+
const { getValues: l, handleSubmit: h } = i, v = l(), b = P(!0);
|
|
209
209
|
O(() => {
|
|
210
210
|
if (b.current) {
|
|
211
211
|
b.current = !1;
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
-
s == null || s({ ...
|
|
215
|
-
}, [JSON.stringify(
|
|
216
|
-
const
|
|
214
|
+
s == null || s({ ...v }), d.current === !0 && i.trigger();
|
|
215
|
+
}, [JSON.stringify(v)]);
|
|
216
|
+
const I = P(!0);
|
|
217
217
|
return O(() => {
|
|
218
|
-
if (
|
|
219
|
-
|
|
218
|
+
if (I.current) {
|
|
219
|
+
I.current = !1;
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
|
-
o == null || o({ isValid:
|
|
223
|
-
}, [
|
|
222
|
+
o == null || o({ isValid: i.formState.isValid, isSubmitted: i.formState.isSubmitted });
|
|
223
|
+
}, [i.formState.isValid, i.formState.isSubmitted]), O(() => {
|
|
224
224
|
if (f)
|
|
225
225
|
if ("requestIdleCallback" in window) {
|
|
226
226
|
const _ = requestIdleCallback(() => {
|
|
227
|
-
|
|
227
|
+
i.setFocus(f);
|
|
228
228
|
});
|
|
229
229
|
return () => cancelIdleCallback(_);
|
|
230
230
|
} else {
|
|
231
231
|
const _ = setTimeout(() => {
|
|
232
|
-
|
|
232
|
+
i.setFocus(f);
|
|
233
233
|
}, 100);
|
|
234
234
|
return () => clearTimeout(_);
|
|
235
235
|
}
|
|
236
|
-
}, [
|
|
237
|
-
...
|
|
236
|
+
}, [i]), /* @__PURE__ */ y.jsx(oe, { ...i, children: typeof c == "function" ? c({
|
|
237
|
+
...i,
|
|
238
238
|
submitForm: async () => {
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
u && (d.current = !0, h((_) => {
|
|
240
|
+
u(_);
|
|
241
241
|
})());
|
|
242
242
|
}
|
|
243
243
|
}) : c });
|
|
@@ -248,8 +248,8 @@ const Ne = (r) => {
|
|
|
248
248
|
return (n = r == null ? void 0 : r.inputs) == null || n.forEach((t) => {
|
|
249
249
|
var a;
|
|
250
250
|
t.inputType === "group" && ((a = t == null ? void 0 : t.inputs) == null || a.forEach((s) => {
|
|
251
|
-
typeof
|
|
252
|
-
})), typeof
|
|
251
|
+
typeof g(e, s.path) > "u" && p(e, s.path, s.default);
|
|
252
|
+
})), typeof g(e, t.path) > "u" && p(e, t.path, t.default);
|
|
253
253
|
}), e;
|
|
254
254
|
};
|
|
255
255
|
function ke(r, e) {
|
|
@@ -263,56 +263,56 @@ function ge(r, e) {
|
|
|
263
263
|
return r.inputs.find((n) => n.path === e);
|
|
264
264
|
}
|
|
265
265
|
const pe = "Required field";
|
|
266
|
-
function
|
|
266
|
+
function R(r) {
|
|
267
267
|
const e = typeof r == "string" ? JSON.parse(r) : r;
|
|
268
268
|
if (typeof e == "string")
|
|
269
269
|
return e;
|
|
270
|
-
if (
|
|
271
|
-
return
|
|
270
|
+
if (E(e))
|
|
271
|
+
return R(e[0]);
|
|
272
272
|
const n = e;
|
|
273
273
|
return L(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
274
274
|
}
|
|
275
275
|
function be(r, e, n) {
|
|
276
276
|
let t = {};
|
|
277
|
-
if (
|
|
277
|
+
if (C(t, r.inputs, e, n), n != null && n.prefix) {
|
|
278
278
|
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
279
|
-
t =
|
|
279
|
+
t = p({}, s, t);
|
|
280
280
|
}
|
|
281
|
-
return m.object(
|
|
281
|
+
return m.object(w(t, e, n));
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function w(r, e, n) {
|
|
284
284
|
const t = {};
|
|
285
285
|
return Object.keys(r).forEach((a) => {
|
|
286
286
|
const {
|
|
287
287
|
_requiredOnly: s,
|
|
288
288
|
_schemaObj: o,
|
|
289
|
-
_input:
|
|
289
|
+
_input: u,
|
|
290
290
|
_isList: c,
|
|
291
291
|
_isArrayItem: f,
|
|
292
|
-
_schema:
|
|
292
|
+
_schema: i
|
|
293
293
|
/*...nestedSchemaObj*/
|
|
294
294
|
} = r[a];
|
|
295
|
-
if (c && o &&
|
|
296
|
-
const d = m.array(m.object(
|
|
295
|
+
if (c && o && u) {
|
|
296
|
+
const d = m.array(m.object(w(o, e, n))).optional(), l = J(i, u, e, n, d);
|
|
297
297
|
t[a] = l;
|
|
298
|
-
} else if (f &&
|
|
299
|
-
const d = o != null && o.___array ?
|
|
298
|
+
} else if (f && u) {
|
|
299
|
+
const d = o != null && o.___array ? w({ ___array: o.___array }, e, n) : { ___array: m.any() }, l = m.array(d.___array).optional(), h = J(i, u, e, n, l);
|
|
300
300
|
t[a] = h;
|
|
301
|
-
} else if (
|
|
302
|
-
const d = _e(
|
|
301
|
+
} else if (i && u) {
|
|
302
|
+
const d = _e(i, u, e, n);
|
|
303
303
|
t[a] = d;
|
|
304
|
-
} else s &&
|
|
304
|
+
} else s && u ? t[a] = A(u, n) : t[a] = m.object(w(r[a], e, n)).optional();
|
|
305
305
|
}), t;
|
|
306
306
|
}
|
|
307
307
|
function _e(r, e, n, t) {
|
|
308
308
|
return m.any().optional().superRefine(async (a, s) => {
|
|
309
|
-
var
|
|
309
|
+
var u, c;
|
|
310
310
|
if (e.required && !(await A(e, t).safeParseAsync(a)).success)
|
|
311
311
|
return s.addIssue({
|
|
312
312
|
code: m.ZodIssueCode.custom,
|
|
313
313
|
message: F(e, t)
|
|
314
314
|
}), m.NEVER;
|
|
315
|
-
if ((
|
|
315
|
+
if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
|
|
316
316
|
const f = (c = t == null ? void 0 : t.validationConfig) == null ? void 0 : c.globalValidation(a, e, t.metadata);
|
|
317
317
|
if (f.error)
|
|
318
318
|
return s.addIssue({
|
|
@@ -326,7 +326,7 @@ function _e(r, e, n, t) {
|
|
|
326
326
|
if (o) {
|
|
327
327
|
const f = await o.safeParseAsync(a);
|
|
328
328
|
if (!f.success) {
|
|
329
|
-
const
|
|
329
|
+
const i = R(f == null ? void 0 : f.error.message), d = i === "Required" ? F(e, t) : i;
|
|
330
330
|
s.addIssue({
|
|
331
331
|
code: m.ZodIssueCode.custom,
|
|
332
332
|
message: d
|
|
@@ -337,25 +337,25 @@ function _e(r, e, n, t) {
|
|
|
337
337
|
}
|
|
338
338
|
function J(r, e, n, t, a) {
|
|
339
339
|
return m.any().optional().superRefine(async (s, o) => {
|
|
340
|
-
var
|
|
340
|
+
var i, d;
|
|
341
341
|
const c = await A(e, t).safeParseAsync(s);
|
|
342
342
|
if (e.required && !c.success) {
|
|
343
|
-
const l =
|
|
343
|
+
const l = R(c.error.message);
|
|
344
344
|
return o.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
|
|
345
345
|
}
|
|
346
346
|
if (!e.required && !c.success)
|
|
347
347
|
return m.NEVER;
|
|
348
|
-
if ((
|
|
348
|
+
if ((i = t == null ? void 0 : t.validationConfig) != null && i.globalValidation) {
|
|
349
349
|
const l = (d = t == null ? void 0 : t.validationConfig) == null ? void 0 : d.globalValidation(s, e, t.metadata);
|
|
350
350
|
if (l.error)
|
|
351
351
|
return o.addIssue({
|
|
352
352
|
code: m.ZodIssueCode.custom,
|
|
353
|
-
message:
|
|
353
|
+
message: R(l.error)
|
|
354
354
|
}), m.NEVER;
|
|
355
355
|
if (!l.continue)
|
|
356
356
|
return m.NEVER;
|
|
357
357
|
}
|
|
358
|
-
if (!
|
|
358
|
+
if (!E(s))
|
|
359
359
|
return o.addIssue({
|
|
360
360
|
code: m.ZodIssueCode.custom,
|
|
361
361
|
message: "'Value is not array'"
|
|
@@ -366,27 +366,27 @@ function J(r, e, n, t, a) {
|
|
|
366
366
|
if (!l.success)
|
|
367
367
|
return o.addIssue({
|
|
368
368
|
code: m.ZodIssueCode.custom,
|
|
369
|
-
message:
|
|
369
|
+
message: R(l.error.message)
|
|
370
370
|
}), m.NEVER;
|
|
371
371
|
}
|
|
372
372
|
}).pipe(a ?? m.any());
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function C(r, e, n, t, a) {
|
|
375
375
|
e.forEach((s) => {
|
|
376
|
-
var
|
|
376
|
+
var u, c, f, i, d;
|
|
377
377
|
const o = n;
|
|
378
|
-
if (!s.isVisible || (
|
|
379
|
-
const l =
|
|
380
|
-
if ((c = s.validation) != null && c.schema ?
|
|
378
|
+
if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
379
|
+
const l = g(r, s.path);
|
|
380
|
+
if ((c = s.validation) != null && c.schema ? p(
|
|
381
381
|
r,
|
|
382
382
|
s.path,
|
|
383
|
-
|
|
383
|
+
V(l, {
|
|
384
384
|
_schema: (f = s.validation) == null ? void 0 : f.schema,
|
|
385
385
|
_input: s
|
|
386
386
|
})
|
|
387
|
-
) : s.required &&
|
|
387
|
+
) : s.required && p(r, s.path, V(l, { _requiredOnly: !0, _input: s })), s.inputs && C(r, s.inputs, n, t), s.inputType === "list") {
|
|
388
388
|
const h = {};
|
|
389
|
-
|
|
389
|
+
C(
|
|
390
390
|
h,
|
|
391
391
|
s.inputConfig.inputs.map((b) => ({
|
|
392
392
|
...b,
|
|
@@ -395,20 +395,20 @@ function w(r, e, n, t, a) {
|
|
|
395
395
|
n,
|
|
396
396
|
t
|
|
397
397
|
);
|
|
398
|
-
const
|
|
399
|
-
|
|
398
|
+
const v = g(r, s.path);
|
|
399
|
+
p(r, s.path, V(v, { _schemaObj: h, _isList: !0, _input: s }));
|
|
400
400
|
}
|
|
401
|
-
if (!((
|
|
401
|
+
if (!((i = s.validation) != null && i.schema) && s.inputType === "array") {
|
|
402
402
|
const h = {};
|
|
403
|
-
|
|
403
|
+
C(
|
|
404
404
|
h,
|
|
405
405
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
406
406
|
n,
|
|
407
407
|
t
|
|
408
|
-
),
|
|
408
|
+
), p(
|
|
409
409
|
r,
|
|
410
410
|
s.path,
|
|
411
|
-
|
|
411
|
+
V(l, {
|
|
412
412
|
_schemaObj: h,
|
|
413
413
|
_schema: (d = s.validation) == null ? void 0 : d.schema,
|
|
414
414
|
_isArrayItem: !0,
|
|
@@ -424,17 +424,17 @@ function F(r, e) {
|
|
|
424
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;
|
|
425
425
|
}
|
|
426
426
|
function A(r, e) {
|
|
427
|
-
var t, a, s, o,
|
|
427
|
+
var t, a, s, o, u, c;
|
|
428
428
|
if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
|
|
429
429
|
return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
|
|
430
|
-
if ((
|
|
430
|
+
if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
|
|
431
431
|
return (c = e == null ? void 0 : e.validationConfig) == null ? void 0 : c.requiredSchema;
|
|
432
432
|
const n = F(r, e);
|
|
433
|
-
return m.any().optional().superRefine((f,
|
|
434
|
-
typeof f == "object" &&
|
|
433
|
+
return m.any().optional().superRefine((f, i) => {
|
|
434
|
+
typeof f == "object" && T(f) && i.addIssue({
|
|
435
435
|
code: m.ZodIssueCode.custom,
|
|
436
436
|
message: n
|
|
437
|
-
}), (
|
|
437
|
+
}), (j(f) || f === "") && i.addIssue({
|
|
438
438
|
code: m.ZodIssueCode.custom,
|
|
439
439
|
message: n
|
|
440
440
|
});
|
|
@@ -446,24 +446,24 @@ function W(r, e) {
|
|
|
446
446
|
if (typeof r == "function")
|
|
447
447
|
return r(e);
|
|
448
448
|
}
|
|
449
|
-
const
|
|
449
|
+
const ve = (r) => Array.isArray(r == null ? void 0 : r.errors), Se = (r, e) => {
|
|
450
450
|
const n = {};
|
|
451
451
|
for (; r.length; ) {
|
|
452
|
-
const t = r[0], { code: a, message: s, path: o } = t,
|
|
453
|
-
if (!n[
|
|
452
|
+
const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
|
|
453
|
+
if (!n[u])
|
|
454
454
|
if ("unionErrors" in t) {
|
|
455
455
|
const c = t.unionErrors[0].errors[0];
|
|
456
|
-
n[
|
|
456
|
+
n[u] = {
|
|
457
457
|
message: c.message,
|
|
458
458
|
type: c.code
|
|
459
459
|
};
|
|
460
460
|
} else
|
|
461
|
-
n[
|
|
461
|
+
n[u] = { message: s, type: a };
|
|
462
462
|
"unionErrors" in t && t.unionErrors.forEach((c) => c.errors.forEach((f) => r.push(f)));
|
|
463
463
|
{
|
|
464
|
-
const c = n[
|
|
465
|
-
n[
|
|
466
|
-
|
|
464
|
+
const c = n[u].types, f = c && c[t.code];
|
|
465
|
+
n[u] = ce(
|
|
466
|
+
u,
|
|
467
467
|
e,
|
|
468
468
|
n,
|
|
469
469
|
a,
|
|
@@ -484,10 +484,10 @@ function Fe(r, e) {
|
|
|
484
484
|
errors: {}
|
|
485
485
|
};
|
|
486
486
|
} catch (s) {
|
|
487
|
-
if (
|
|
487
|
+
if (ve(s))
|
|
488
488
|
return {
|
|
489
489
|
values: {},
|
|
490
|
-
errors: fe(
|
|
490
|
+
errors: fe(Se(s.errors, !0), a)
|
|
491
491
|
};
|
|
492
492
|
throw s;
|
|
493
493
|
}
|
|
@@ -496,20 +496,26 @@ function Fe(r, e) {
|
|
|
496
496
|
);
|
|
497
497
|
}
|
|
498
498
|
function Ae(r, e) {
|
|
499
|
-
const n =
|
|
499
|
+
const n = q(r);
|
|
500
500
|
return e.forEach((t) => {
|
|
501
501
|
if (t.inputTransform) {
|
|
502
|
-
const a =
|
|
503
|
-
|
|
502
|
+
const a = E(t.inputTransform) ? t.inputTransform : [t.inputTransform], s = g(n, t.path);
|
|
503
|
+
a.forEach((o) => {
|
|
504
|
+
const u = o(s, n);
|
|
505
|
+
u && p(n, u.path ?? t.path, u.value);
|
|
506
|
+
});
|
|
504
507
|
}
|
|
505
508
|
}), n;
|
|
506
509
|
}
|
|
507
510
|
function De(r, e) {
|
|
508
|
-
const n =
|
|
511
|
+
const n = q(r);
|
|
509
512
|
return e.forEach((t) => {
|
|
510
513
|
if (t.outputTransform) {
|
|
511
|
-
const a =
|
|
512
|
-
|
|
514
|
+
const a = E(t.outputTransform) ? t.outputTransform : [t.outputTransform], s = g(n, t.path);
|
|
515
|
+
a.forEach((o) => {
|
|
516
|
+
const u = o(s, n);
|
|
517
|
+
u && p(n, u.path ?? t.path, u.value);
|
|
518
|
+
});
|
|
513
519
|
}
|
|
514
520
|
}), n;
|
|
515
521
|
}
|
|
@@ -528,7 +534,7 @@ function Ze(r) {
|
|
|
528
534
|
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
529
535
|
}
|
|
530
536
|
function $e(r, e, n) {
|
|
531
|
-
const t = D(r.inputs), a =
|
|
537
|
+
const t = D(r.inputs), a = q(e);
|
|
532
538
|
return t.forEach((s) => {
|
|
533
539
|
s.isVisible && !s.isVisible(e, n) && X(a, s.path);
|
|
534
540
|
}), a;
|
|
@@ -554,30 +560,31 @@ function Be(r) {
|
|
|
554
560
|
function Je() {
|
|
555
561
|
return function(r, e) {
|
|
556
562
|
if (!(typeof r > "u"))
|
|
557
|
-
return
|
|
563
|
+
return E(r) && T(r) ? { value: void 0 } : { value: r };
|
|
558
564
|
};
|
|
559
565
|
}
|
|
560
|
-
function Le() {
|
|
561
|
-
return function(
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
566
|
+
function Le(r) {
|
|
567
|
+
return function(e, n) {
|
|
568
|
+
const t = r ? g(n, r) : e;
|
|
569
|
+
if (!(typeof t > "u")) {
|
|
570
|
+
if (L(t)) {
|
|
571
|
+
const a = U(t, j);
|
|
572
|
+
if (T(a))
|
|
573
|
+
return { value: void 0, path: r };
|
|
567
574
|
}
|
|
568
|
-
return { value: r };
|
|
575
|
+
return { value: t, path: r };
|
|
569
576
|
}
|
|
570
577
|
};
|
|
571
578
|
}
|
|
572
579
|
function Ue() {
|
|
573
580
|
return function(r, e) {
|
|
574
581
|
if (!(typeof r > "u"))
|
|
575
|
-
return z(r) &&
|
|
582
|
+
return z(r) && T(r) ? { value: void 0 } : { value: r };
|
|
576
583
|
};
|
|
577
584
|
}
|
|
578
585
|
function We(r) {
|
|
579
586
|
return function(e, n) {
|
|
580
|
-
const t =
|
|
587
|
+
const t = g(n, r);
|
|
581
588
|
return typeof t == "string" ? { value: t } : { value: e };
|
|
582
589
|
};
|
|
583
590
|
}
|
|
@@ -585,9 +592,9 @@ function Ge(r) {
|
|
|
585
592
|
return function(e, n) {
|
|
586
593
|
if (typeof e > "u") return;
|
|
587
594
|
if (!e) return { value: e };
|
|
588
|
-
const t =
|
|
595
|
+
const t = g(n, r);
|
|
589
596
|
if (typeof t == "object") {
|
|
590
|
-
const a =
|
|
597
|
+
const a = Ee(t);
|
|
591
598
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
592
599
|
return { value: e, path: r };
|
|
593
600
|
}
|
|
@@ -597,7 +604,7 @@ function Ge(r) {
|
|
|
597
604
|
function He(r) {
|
|
598
605
|
return function(e, n) {
|
|
599
606
|
if (typeof e > "u") return;
|
|
600
|
-
const t =
|
|
607
|
+
const t = g(n, r);
|
|
601
608
|
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
602
609
|
};
|
|
603
610
|
}
|
|
@@ -605,8 +612,8 @@ function Qe(r, e) {
|
|
|
605
612
|
return function(n, t) {
|
|
606
613
|
if (typeof n > "u") return;
|
|
607
614
|
if (!n) return { value: n };
|
|
608
|
-
const a =
|
|
609
|
-
if (
|
|
615
|
+
const a = g(t, r);
|
|
616
|
+
if (E(a)) {
|
|
610
617
|
if (a.length === 1)
|
|
611
618
|
return { value: a[0], path: r };
|
|
612
619
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
@@ -616,12 +623,12 @@ function Qe(r, e) {
|
|
|
616
623
|
};
|
|
617
624
|
}
|
|
618
625
|
function G(r) {
|
|
619
|
-
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !G(r[e])) :
|
|
626
|
+
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !G(r[e])) : j(r);
|
|
620
627
|
}
|
|
621
|
-
function
|
|
622
|
-
return U(r, (e) => typeof e == "object" ? G(e) :
|
|
628
|
+
function Ee(r) {
|
|
629
|
+
return U(r, (e) => typeof e == "object" ? G(e) : j(e));
|
|
623
630
|
}
|
|
624
|
-
function
|
|
631
|
+
function Oe({ input: r, factory: e }) {
|
|
625
632
|
const { prefix: n = "" } = {};
|
|
626
633
|
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ye, { path: `${n}${r.path}`, factory: e, readonly: !1, input: r }) });
|
|
627
634
|
}
|
|
@@ -629,21 +636,21 @@ function Re(r) {
|
|
|
629
636
|
const { items: e, factory: n } = r;
|
|
630
637
|
return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((t) => {
|
|
631
638
|
const a = `${t.inputType}_${t.path}_${t.label}`;
|
|
632
|
-
return /* @__PURE__ */ y.jsx(
|
|
639
|
+
return /* @__PURE__ */ y.jsx(Oe, { input: t, factory: n }, a);
|
|
633
640
|
}) });
|
|
634
641
|
}
|
|
635
|
-
const
|
|
642
|
+
const Te = ae((r, e) => {
|
|
636
643
|
const { inputs: n, className: t, factory: a } = r;
|
|
637
644
|
return /* @__PURE__ */ y.jsxs("div", { className: t, ref: e, children: [
|
|
638
645
|
n.hero,
|
|
639
646
|
/* @__PURE__ */ y.jsx(Re, { items: n.inputs, factory: a })
|
|
640
647
|
] });
|
|
641
648
|
});
|
|
642
|
-
|
|
649
|
+
Te.displayName = "RenderForm";
|
|
643
650
|
function Ye(r) {
|
|
644
651
|
let e = !0;
|
|
645
652
|
return ee(r, (n) => {
|
|
646
|
-
e = e && (n === "" || re(n) ||
|
|
653
|
+
e = e && (n === "" || re(n) || j(n));
|
|
647
654
|
}), e;
|
|
648
655
|
}
|
|
649
656
|
const Ke = (r = "") => te(r.split("_").join(" "));
|
|
@@ -652,10 +659,10 @@ export {
|
|
|
652
659
|
ye as InputComponentRenderer,
|
|
653
660
|
qe as InputFactory,
|
|
654
661
|
de as InputOverrideError,
|
|
655
|
-
|
|
662
|
+
Te as RenderForm,
|
|
656
663
|
Re as RenderInputs,
|
|
657
664
|
Pe as RootForm,
|
|
658
|
-
|
|
665
|
+
Oe as Row,
|
|
659
666
|
Be as arrayToObjectOutputTransformer,
|
|
660
667
|
Ke as generateReadableLabel,
|
|
661
668
|
Ne as getDefaultValuesFromFormDefinition,
|
|
@@ -666,7 +673,7 @@ export {
|
|
|
666
673
|
Me as objectToArrayInputTransformer,
|
|
667
674
|
De as outputTransformValues,
|
|
668
675
|
ke as overrideFormDefinition,
|
|
669
|
-
|
|
676
|
+
R as processValidationParseResponse,
|
|
670
677
|
He as shorthandArrayInputTransformer,
|
|
671
678
|
Qe as shorthandArrayOutputTransformer,
|
|
672
679
|
We as shorthandObjectInputTransformer,
|