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