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