@harnessio/forms 0.0.7 → 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 +204 -199
- 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
|
-
class
|
|
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 qe {
|
|
|
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 le() {
|
|
|
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 le() {
|
|
|
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 le() {
|
|
|
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,14 +111,14 @@ function me() {
|
|
|
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 =
|
|
121
|
-
function
|
|
120
|
+
var y = pe();
|
|
121
|
+
function ge({
|
|
122
122
|
path: r,
|
|
123
123
|
factory: e,
|
|
124
124
|
onUpdate: n,
|
|
@@ -127,7 +127,7 @@ function ye({
|
|
|
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 ye({
|
|
|
142
142
|
input: o
|
|
143
143
|
}),
|
|
144
144
|
[e, s, o, t, n, r, a, u.errors]
|
|
145
|
-
), h = c(), v =
|
|
146
|
-
i && Object.keys(i).forEach((
|
|
147
|
-
const
|
|
148
|
-
|
|
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 Pe(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
|
-
requestIdleCallback(() => {
|
|
193
|
+
const g = requestIdleCallback(() => {
|
|
194
194
|
i.reset({}, {
|
|
195
195
|
keepErrors: !0,
|
|
196
196
|
keepDirty: !0,
|
|
@@ -204,83 +204,91 @@ function Pe(r) {
|
|
|
204
204
|
keepSubmitCount: !0
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
|
+
return () => cancelIdleCallback(g);
|
|
207
208
|
}, []);
|
|
208
|
-
const { getValues: l, handleSubmit: h } = i, v = l(),
|
|
209
|
+
const { getValues: l, handleSubmit: h } = i, v = l(), _ = x(!0);
|
|
209
210
|
O(() => {
|
|
210
|
-
if (
|
|
211
|
-
|
|
211
|
+
if (_.current) {
|
|
212
|
+
_.current = !1;
|
|
212
213
|
return;
|
|
213
214
|
}
|
|
214
215
|
s == null || s({ ...v }), d.current === !0 && i.trigger();
|
|
215
216
|
}, [JSON.stringify(v)]);
|
|
216
|
-
const
|
|
217
|
+
const j = x(!0);
|
|
217
218
|
return O(() => {
|
|
218
|
-
if (
|
|
219
|
-
|
|
219
|
+
if (j.current) {
|
|
220
|
+
j.current = !1;
|
|
220
221
|
return;
|
|
221
222
|
}
|
|
222
223
|
o == null || o({ isValid: i.formState.isValid, isSubmitted: i.formState.isSubmitted });
|
|
223
224
|
}, [i.formState.isValid, i.formState.isSubmitted]), O(() => {
|
|
224
225
|
if (f)
|
|
225
226
|
if ("requestIdleCallback" in window) {
|
|
226
|
-
const
|
|
227
|
+
const g = requestIdleCallback(() => {
|
|
227
228
|
i.setFocus(f);
|
|
228
229
|
});
|
|
229
|
-
return () => cancelIdleCallback(
|
|
230
|
+
return () => cancelIdleCallback(g);
|
|
230
231
|
} else {
|
|
231
|
-
const
|
|
232
|
+
const g = setTimeout(() => {
|
|
232
233
|
i.setFocus(f);
|
|
233
234
|
}, 100);
|
|
234
|
-
return () => clearTimeout(
|
|
235
|
+
return () => clearTimeout(g);
|
|
235
236
|
}
|
|
236
|
-
}, [i]), /* @__PURE__ */ y.jsx(
|
|
237
|
+
}, [i]), /* @__PURE__ */ y.jsx(fe, { ...i, children: typeof c == "function" ? c({
|
|
237
238
|
...i,
|
|
238
239
|
submitForm: async () => {
|
|
239
|
-
u && (d.current = !0, h((
|
|
240
|
-
u(
|
|
240
|
+
u && (d.current = !0, h((g) => {
|
|
241
|
+
u(g);
|
|
241
242
|
})());
|
|
242
243
|
}
|
|
243
244
|
}) : c });
|
|
244
245
|
}
|
|
245
|
-
const
|
|
246
|
+
const ke = (r) => {
|
|
246
247
|
var n;
|
|
247
248
|
const e = {};
|
|
248
249
|
return (n = r == null ? void 0 : r.inputs) == null || n.forEach((t) => {
|
|
249
250
|
var a;
|
|
250
251
|
t.inputType === "group" && ((a = t == null ? void 0 : t.inputs) == null || a.forEach((s) => {
|
|
251
|
-
typeof
|
|
252
|
-
})), 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);
|
|
253
254
|
}), e;
|
|
254
255
|
};
|
|
255
|
-
function
|
|
256
|
+
function Ae(r, e) {
|
|
256
257
|
const n = r.inputs.map((t) => {
|
|
257
|
-
const a =
|
|
258
|
+
const a = be(e, t.path);
|
|
258
259
|
return a || t;
|
|
259
260
|
});
|
|
260
261
|
return { ...r, inputs: n };
|
|
261
262
|
}
|
|
262
|
-
function
|
|
263
|
+
function be(r, e) {
|
|
263
264
|
return r.inputs.find((n) => n.path === e);
|
|
264
265
|
}
|
|
265
|
-
const
|
|
266
|
-
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) {
|
|
267
275
|
const e = typeof r == "string" ? JSON.parse(r) : r;
|
|
268
276
|
if (typeof e == "string")
|
|
269
277
|
return e;
|
|
270
|
-
if (
|
|
271
|
-
return
|
|
278
|
+
if (S(e))
|
|
279
|
+
return T(e[0]);
|
|
272
280
|
const n = e;
|
|
273
|
-
return
|
|
281
|
+
return U(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
274
282
|
}
|
|
275
|
-
function
|
|
283
|
+
function ve(r, e, n) {
|
|
276
284
|
let t = {};
|
|
277
|
-
if (
|
|
285
|
+
if (w(t, r.inputs, e, n), n != null && n.prefix) {
|
|
278
286
|
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
279
|
-
t =
|
|
287
|
+
t = b({}, s, t);
|
|
280
288
|
}
|
|
281
|
-
return m.object(
|
|
289
|
+
return m.object(V(t, e, n));
|
|
282
290
|
}
|
|
283
|
-
function
|
|
291
|
+
function V(r, e, n) {
|
|
284
292
|
const t = {};
|
|
285
293
|
return Object.keys(r).forEach((a) => {
|
|
286
294
|
const {
|
|
@@ -293,24 +301,24 @@ function w(r, e, n) {
|
|
|
293
301
|
/*...nestedSchemaObj*/
|
|
294
302
|
} = r[a];
|
|
295
303
|
if (c && o && u) {
|
|
296
|
-
const d = m.array(m.object(
|
|
304
|
+
const d = m.array(m.object(V(o, e, n))).optional(), l = J(i, u, e, n, d);
|
|
297
305
|
t[a] = l;
|
|
298
306
|
} else if (f && u) {
|
|
299
|
-
const d = o != null && o.___array ?
|
|
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);
|
|
300
308
|
t[a] = h;
|
|
301
309
|
} else if (i && u) {
|
|
302
|
-
const d =
|
|
310
|
+
const d = Ee(i, u, e, n);
|
|
303
311
|
t[a] = d;
|
|
304
|
-
} else s && u ? t[a] = A(u, n) : t[a] = m.object(
|
|
312
|
+
} else s && u ? t[a] = A(u, n) : t[a] = m.object(V(r[a], e, n)).optional();
|
|
305
313
|
}), t;
|
|
306
314
|
}
|
|
307
|
-
function
|
|
315
|
+
function Ee(r, e, n, t) {
|
|
308
316
|
return m.any().optional().superRefine(async (a, s) => {
|
|
309
317
|
var u, c;
|
|
310
318
|
if (e.required && !(await A(e, t).safeParseAsync(a)).success)
|
|
311
319
|
return s.addIssue({
|
|
312
320
|
code: m.ZodIssueCode.custom,
|
|
313
|
-
message:
|
|
321
|
+
message: k(e, t)
|
|
314
322
|
}), m.NEVER;
|
|
315
323
|
if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
|
|
316
324
|
const f = (c = t == null ? void 0 : t.validationConfig) == null ? void 0 : c.globalValidation(a, e, t.metadata);
|
|
@@ -322,11 +330,11 @@ function _e(r, e, n, t) {
|
|
|
322
330
|
if (!f.continue)
|
|
323
331
|
return !0;
|
|
324
332
|
}
|
|
325
|
-
const o =
|
|
333
|
+
const o = Q(r, n);
|
|
326
334
|
if (o) {
|
|
327
335
|
const f = await o.safeParseAsync(a);
|
|
328
336
|
if (!f.success) {
|
|
329
|
-
const i =
|
|
337
|
+
const i = T(f == null ? void 0 : f.error.message), d = i === "Required" ? k(e, t) : i;
|
|
330
338
|
s.addIssue({
|
|
331
339
|
code: m.ZodIssueCode.custom,
|
|
332
340
|
message: d
|
|
@@ -340,7 +348,7 @@ function J(r, e, n, t, a) {
|
|
|
340
348
|
var i, d;
|
|
341
349
|
const c = await A(e, t).safeParseAsync(s);
|
|
342
350
|
if (e.required && !c.success) {
|
|
343
|
-
const l =
|
|
351
|
+
const l = T(c.error.message);
|
|
344
352
|
return o.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
|
|
345
353
|
}
|
|
346
354
|
if (!e.required && !c.success)
|
|
@@ -350,65 +358,65 @@ function J(r, e, n, t, a) {
|
|
|
350
358
|
if (l.error)
|
|
351
359
|
return o.addIssue({
|
|
352
360
|
code: m.ZodIssueCode.custom,
|
|
353
|
-
message:
|
|
361
|
+
message: T(l.error)
|
|
354
362
|
}), m.NEVER;
|
|
355
363
|
if (!l.continue)
|
|
356
364
|
return m.NEVER;
|
|
357
365
|
}
|
|
358
|
-
if (!
|
|
366
|
+
if (!S(s))
|
|
359
367
|
return o.addIssue({
|
|
360
368
|
code: m.ZodIssueCode.custom,
|
|
361
369
|
message: "'Value is not array'"
|
|
362
370
|
}), m.NEVER;
|
|
363
|
-
const f =
|
|
371
|
+
const f = Q(r, n);
|
|
364
372
|
if (f) {
|
|
365
373
|
const l = await f.safeParseAsync(s);
|
|
366
374
|
if (!l.success)
|
|
367
375
|
return o.addIssue({
|
|
368
376
|
code: m.ZodIssueCode.custom,
|
|
369
|
-
message:
|
|
377
|
+
message: T(l.error.message)
|
|
370
378
|
}), m.NEVER;
|
|
371
379
|
}
|
|
372
380
|
}).pipe(a ?? m.any());
|
|
373
381
|
}
|
|
374
|
-
function
|
|
382
|
+
function w(r, e, n, t, a) {
|
|
375
383
|
e.forEach((s) => {
|
|
376
384
|
var u, c, f, i, d;
|
|
377
385
|
const o = n;
|
|
378
386
|
if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
379
|
-
const l =
|
|
380
|
-
if ((c = s.validation) != null && c.schema ?
|
|
387
|
+
const l = p(r, s.path);
|
|
388
|
+
if ((c = s.validation) != null && c.schema ? b(
|
|
381
389
|
r,
|
|
382
390
|
s.path,
|
|
383
|
-
|
|
391
|
+
I(l, {
|
|
384
392
|
_schema: (f = s.validation) == null ? void 0 : f.schema,
|
|
385
393
|
_input: s
|
|
386
394
|
})
|
|
387
|
-
) : s.required &&
|
|
395
|
+
) : s.required && b(r, s.path, I(l, { _requiredOnly: !0, _input: s })), s.inputs && w(r, s.inputs, n, t), s.inputType === "list") {
|
|
388
396
|
const h = {};
|
|
389
|
-
|
|
397
|
+
w(
|
|
390
398
|
h,
|
|
391
|
-
s.inputConfig.inputs.map((
|
|
392
|
-
...
|
|
393
|
-
path:
|
|
399
|
+
s.inputConfig.inputs.map((_) => ({
|
|
400
|
+
..._,
|
|
401
|
+
path: _.relativePath
|
|
394
402
|
})),
|
|
395
403
|
n,
|
|
396
404
|
t
|
|
397
405
|
);
|
|
398
|
-
const v =
|
|
399
|
-
|
|
406
|
+
const v = p(r, s.path);
|
|
407
|
+
b(r, s.path, I(v, { _schemaObj: h, _isList: !0, _input: s }));
|
|
400
408
|
}
|
|
401
409
|
if (!((i = s.validation) != null && i.schema) && s.inputType === "array") {
|
|
402
410
|
const h = {};
|
|
403
|
-
|
|
411
|
+
w(
|
|
404
412
|
h,
|
|
405
413
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
406
414
|
n,
|
|
407
415
|
t
|
|
408
|
-
),
|
|
416
|
+
), b(
|
|
409
417
|
r,
|
|
410
418
|
s.path,
|
|
411
|
-
|
|
419
|
+
I(l, {
|
|
412
420
|
_schemaObj: h,
|
|
413
421
|
_schema: (d = s.validation) == null ? void 0 : d.schema,
|
|
414
422
|
_isArrayItem: !0,
|
|
@@ -419,9 +427,9 @@ function C(r, e, n, t, a) {
|
|
|
419
427
|
}
|
|
420
428
|
});
|
|
421
429
|
}
|
|
422
|
-
function
|
|
430
|
+
function k(r, e) {
|
|
423
431
|
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) ??
|
|
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;
|
|
425
433
|
}
|
|
426
434
|
function A(r, e) {
|
|
427
435
|
var t, a, s, o, u, c;
|
|
@@ -429,24 +437,24 @@ function A(r, e) {
|
|
|
429
437
|
return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
|
|
430
438
|
if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
|
|
431
439
|
return (c = e == null ? void 0 : e.validationConfig) == null ? void 0 : c.requiredSchema;
|
|
432
|
-
const n =
|
|
440
|
+
const n = k(r, e);
|
|
433
441
|
return m.any().optional().superRefine((f, i) => {
|
|
434
|
-
typeof f == "object" &&
|
|
442
|
+
typeof f == "object" && R(f) && i.addIssue({
|
|
435
443
|
code: m.ZodIssueCode.custom,
|
|
436
444
|
message: n
|
|
437
|
-
}), (
|
|
445
|
+
}), (q(f) || f === "") && i.addIssue({
|
|
438
446
|
code: m.ZodIssueCode.custom,
|
|
439
447
|
message: n
|
|
440
448
|
});
|
|
441
449
|
});
|
|
442
450
|
}
|
|
443
|
-
function
|
|
451
|
+
function Q(r, e) {
|
|
444
452
|
if (r instanceof m.ZodType)
|
|
445
453
|
return r;
|
|
446
454
|
if (typeof r == "function")
|
|
447
455
|
return r(e);
|
|
448
456
|
}
|
|
449
|
-
const
|
|
457
|
+
const Se = (r) => Array.isArray(r == null ? void 0 : r.errors), Oe = (r, e) => {
|
|
450
458
|
const n = {};
|
|
451
459
|
for (; r.length; ) {
|
|
452
460
|
const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
|
|
@@ -462,7 +470,7 @@ const ve = (r) => Array.isArray(r == null ? void 0 : r.errors), Se = (r, e) => {
|
|
|
462
470
|
"unionErrors" in t && t.unionErrors.forEach((c) => c.errors.forEach((f) => r.push(f)));
|
|
463
471
|
{
|
|
464
472
|
const c = n[u].types, f = c && c[t.code];
|
|
465
|
-
n[u] =
|
|
473
|
+
n[u] = de(
|
|
466
474
|
u,
|
|
467
475
|
e,
|
|
468
476
|
n,
|
|
@@ -474,20 +482,20 @@ const ve = (r) => Array.isArray(r == null ? void 0 : r.errors), Se = (r, e) => {
|
|
|
474
482
|
}
|
|
475
483
|
return n;
|
|
476
484
|
};
|
|
477
|
-
function
|
|
478
|
-
return
|
|
485
|
+
function $e(r, e) {
|
|
486
|
+
return ue(
|
|
479
487
|
async (n, t, a) => {
|
|
480
488
|
try {
|
|
481
|
-
return await
|
|
489
|
+
return await ve(r, n, e).parseAsync(n), {
|
|
482
490
|
values: n,
|
|
483
491
|
// TODO: check this - values does not contains all data
|
|
484
492
|
errors: {}
|
|
485
493
|
};
|
|
486
494
|
} catch (s) {
|
|
487
|
-
if (
|
|
495
|
+
if (Se(s))
|
|
488
496
|
return {
|
|
489
497
|
values: {},
|
|
490
|
-
errors:
|
|
498
|
+
errors: le(Oe(s.errors, !0), a)
|
|
491
499
|
};
|
|
492
500
|
throw s;
|
|
493
501
|
}
|
|
@@ -495,51 +503,45 @@ function Fe(r, e) {
|
|
|
495
503
|
[r]
|
|
496
504
|
);
|
|
497
505
|
}
|
|
498
|
-
function
|
|
499
|
-
const n =
|
|
506
|
+
function Me(r, e) {
|
|
507
|
+
const n = C(r);
|
|
500
508
|
return e.forEach((t) => {
|
|
501
|
-
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
u && p(n, u.path ?? t.path, u.value);
|
|
506
|
-
});
|
|
507
|
-
}
|
|
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
|
+
});
|
|
508
513
|
}), n;
|
|
509
514
|
}
|
|
510
|
-
function
|
|
511
|
-
const n =
|
|
515
|
+
function Be(r, e) {
|
|
516
|
+
const n = C(r);
|
|
512
517
|
return e.forEach((t) => {
|
|
513
|
-
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
u && p(n, u.path ?? t.path, u.value);
|
|
518
|
-
});
|
|
519
|
-
}
|
|
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
|
+
});
|
|
520
522
|
}), n;
|
|
521
523
|
}
|
|
522
524
|
function D(r) {
|
|
523
525
|
return r.reduce((n, t) => t.inputType === "group" && t.inputs ? [...n, t, ...D(t.inputs)] : [...n, t], []);
|
|
524
526
|
}
|
|
525
|
-
function
|
|
527
|
+
function Je(r) {
|
|
526
528
|
const n = D(r.inputs).reduce((t, a) => {
|
|
527
529
|
const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
|
|
528
530
|
return (a.inputTransform || a.outputTransform) && t.push({
|
|
529
|
-
...
|
|
531
|
+
...ee(a, "path", "inputTransform", "outputTransform"),
|
|
530
532
|
level: a.path.split(".").length,
|
|
531
533
|
isPrimitive: s
|
|
532
534
|
}), t;
|
|
533
535
|
}, []);
|
|
534
536
|
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
535
537
|
}
|
|
536
|
-
function
|
|
537
|
-
const t = D(r.inputs), a =
|
|
538
|
+
function Le(r, e, n) {
|
|
539
|
+
const t = D(r.inputs), a = C(e);
|
|
538
540
|
return t.forEach((s) => {
|
|
539
|
-
s.isVisible && !s.isVisible(e, n) &&
|
|
541
|
+
s.isVisible && !s.isVisible(e, n) && re(a, s.path);
|
|
540
542
|
}), a;
|
|
541
543
|
}
|
|
542
|
-
function
|
|
544
|
+
function Ue() {
|
|
543
545
|
return function(r, e) {
|
|
544
546
|
if (!(typeof r > "u"))
|
|
545
547
|
return r ? {
|
|
@@ -547,7 +549,7 @@ function Me() {
|
|
|
547
549
|
} : { value: r };
|
|
548
550
|
};
|
|
549
551
|
}
|
|
550
|
-
function
|
|
552
|
+
function We(r) {
|
|
551
553
|
return function(e, n) {
|
|
552
554
|
if (typeof e > "u") return;
|
|
553
555
|
if (!e) return { value: e };
|
|
@@ -557,63 +559,64 @@ function Be(r) {
|
|
|
557
559
|
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
558
560
|
};
|
|
559
561
|
}
|
|
560
|
-
function
|
|
562
|
+
function Ge() {
|
|
561
563
|
return function(r, e) {
|
|
562
564
|
if (!(typeof r > "u"))
|
|
563
|
-
return
|
|
565
|
+
return S(r) && R(r) ? { value: void 0 } : { value: r };
|
|
564
566
|
};
|
|
565
567
|
}
|
|
566
|
-
function
|
|
568
|
+
function He(r) {
|
|
567
569
|
return function(e, n) {
|
|
568
|
-
const t = r ?
|
|
570
|
+
const t = r ? p(n, r) : e;
|
|
569
571
|
if (!(typeof t > "u")) {
|
|
570
|
-
if (
|
|
571
|
-
|
|
572
|
-
|
|
572
|
+
if (W(t)) return { value: void 0, path: r };
|
|
573
|
+
if (U(t)) {
|
|
574
|
+
const a = G(t, te);
|
|
575
|
+
if (R(a))
|
|
573
576
|
return { value: void 0, path: r };
|
|
574
577
|
}
|
|
575
578
|
return { value: t, path: r };
|
|
576
579
|
}
|
|
577
580
|
};
|
|
578
581
|
}
|
|
579
|
-
function
|
|
582
|
+
function Qe() {
|
|
580
583
|
return function(r, e) {
|
|
581
584
|
if (!(typeof r > "u"))
|
|
582
|
-
return
|
|
585
|
+
return ne(r) && R(r) ? { value: void 0 } : { value: r };
|
|
583
586
|
};
|
|
584
587
|
}
|
|
585
|
-
function
|
|
588
|
+
function Xe(r) {
|
|
586
589
|
return function(e, n) {
|
|
587
|
-
const t =
|
|
590
|
+
const t = p(n, r);
|
|
588
591
|
return typeof t == "string" ? { value: t } : { value: e };
|
|
589
592
|
};
|
|
590
593
|
}
|
|
591
|
-
function
|
|
594
|
+
function Ye(r) {
|
|
592
595
|
return function(e, n) {
|
|
593
596
|
if (typeof e > "u") return;
|
|
594
597
|
if (!e) return { value: e };
|
|
595
|
-
const t =
|
|
598
|
+
const t = p(n, r);
|
|
596
599
|
if (typeof t == "object") {
|
|
597
|
-
const a =
|
|
600
|
+
const a = Te(t);
|
|
598
601
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
599
602
|
return { value: e, path: r };
|
|
600
603
|
}
|
|
601
604
|
return { value: e };
|
|
602
605
|
};
|
|
603
606
|
}
|
|
604
|
-
function
|
|
607
|
+
function Ke(r) {
|
|
605
608
|
return function(e, n) {
|
|
606
609
|
if (typeof e > "u") return;
|
|
607
|
-
const t =
|
|
610
|
+
const t = p(n, r);
|
|
608
611
|
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
609
612
|
};
|
|
610
613
|
}
|
|
611
|
-
function
|
|
614
|
+
function ze(r, e) {
|
|
612
615
|
return function(n, t) {
|
|
613
616
|
if (typeof n > "u") return;
|
|
614
617
|
if (!n) return { value: n };
|
|
615
|
-
const a =
|
|
616
|
-
if (
|
|
618
|
+
const a = p(t, r);
|
|
619
|
+
if (S(a)) {
|
|
617
620
|
if (a.length === 1)
|
|
618
621
|
return { value: a[0], path: r };
|
|
619
622
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
@@ -622,66 +625,68 @@ function Qe(r, e) {
|
|
|
622
625
|
return { value: n };
|
|
623
626
|
};
|
|
624
627
|
}
|
|
625
|
-
function
|
|
626
|
-
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);
|
|
627
630
|
}
|
|
628
|
-
function
|
|
629
|
-
return
|
|
631
|
+
function Te(r) {
|
|
632
|
+
return G(r, (e) => typeof e == "object" ? X(e) : q(e));
|
|
630
633
|
}
|
|
631
|
-
function
|
|
634
|
+
function Re({ input: r, factory: e }) {
|
|
632
635
|
const { prefix: n = "" } = {};
|
|
633
|
-
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(
|
|
636
|
+
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ge, { path: `${n}${r.path}`, factory: e, readonly: !1, input: r }) });
|
|
634
637
|
}
|
|
635
|
-
function
|
|
638
|
+
function je(r) {
|
|
636
639
|
const { items: e, factory: n } = r;
|
|
637
640
|
return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((t) => {
|
|
638
641
|
const a = `${t.inputType}_${t.path}_${t.label}`;
|
|
639
|
-
return /* @__PURE__ */ y.jsx(
|
|
642
|
+
return /* @__PURE__ */ y.jsx(Re, { input: t, factory: n }, a);
|
|
640
643
|
}) });
|
|
641
644
|
}
|
|
642
|
-
const
|
|
645
|
+
const Ie = ie((r, e) => {
|
|
643
646
|
const { inputs: n, className: t, factory: a } = r;
|
|
644
647
|
return /* @__PURE__ */ y.jsxs("div", { className: t, ref: e, children: [
|
|
645
648
|
n.hero,
|
|
646
|
-
/* @__PURE__ */ y.jsx(
|
|
649
|
+
/* @__PURE__ */ y.jsx(je, { items: n.inputs, factory: a })
|
|
647
650
|
] });
|
|
648
651
|
});
|
|
649
|
-
|
|
650
|
-
function
|
|
652
|
+
Ie.displayName = "RenderForm";
|
|
653
|
+
function er(r) {
|
|
651
654
|
let e = !0;
|
|
652
|
-
return
|
|
653
|
-
e = e && (n === "" ||
|
|
655
|
+
return L(r, (n) => {
|
|
656
|
+
e = e && (n === "" || W(n) || q(n));
|
|
654
657
|
}), e;
|
|
655
658
|
}
|
|
656
|
-
const
|
|
659
|
+
const rr = (r = "") => se(r.split("_").join(" "));
|
|
657
660
|
export {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
661
|
+
Ne as InputComponent,
|
|
662
|
+
ge as InputComponentRenderer,
|
|
663
|
+
xe as InputFactory,
|
|
664
|
+
me as InputOverrideError,
|
|
665
|
+
Ie as RenderForm,
|
|
666
|
+
je as RenderInputs,
|
|
667
|
+
Fe as RootForm,
|
|
668
|
+
Re as Row,
|
|
669
|
+
We as arrayToObjectOutputTransformer,
|
|
670
|
+
rr as generateReadableLabel,
|
|
671
|
+
ke as getDefaultValuesFromFormDefinition,
|
|
672
|
+
De as getTemporaryPath,
|
|
673
|
+
Je as getTransformers,
|
|
674
|
+
ve as getValidationSchema,
|
|
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
|
|
686
691
|
};
|
|
687
692
|
//# sourceMappingURL=index.js.map
|