@harnessio/forms 0.0.5 → 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 +252 -244
- 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
|
-
var Y = (r, e,
|
|
3
|
-
var x = (r, e,
|
|
4
|
-
import { isEmpty as
|
|
2
|
+
var Y = (r, e, n) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var x = (r, e, n) => Y(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as 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
|
|
@@ -44,8 +44,8 @@ var k, $;
|
|
|
44
44
|
function le() {
|
|
45
45
|
if ($) return k;
|
|
46
46
|
$ = 1;
|
|
47
|
-
var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty,
|
|
48
|
-
function
|
|
47
|
+
var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
|
|
48
|
+
function t(s) {
|
|
49
49
|
if (s == null)
|
|
50
50
|
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
51
51
|
return Object(s);
|
|
@@ -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
|
-
|
|
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 (
|
|
103
|
-
var
|
|
104
|
-
e =
|
|
102
|
+
if (S.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
103
|
+
var n = Symbol.for;
|
|
104
|
+
e = n("react.element"), S.Fragment = n("react.fragment");
|
|
105
105
|
}
|
|
106
|
-
var
|
|
107
|
-
function o(
|
|
108
|
-
var
|
|
106
|
+
var t = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, a = Object.prototype.hasOwnProperty, s = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
107
|
+
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() {
|
|
@@ -121,38 +121,38 @@ var y = he();
|
|
|
121
121
|
function ye({
|
|
122
122
|
path: r,
|
|
123
123
|
factory: e,
|
|
124
|
-
onUpdate:
|
|
125
|
-
onChange:
|
|
124
|
+
onUpdate: n,
|
|
125
|
+
onChange: t,
|
|
126
126
|
readonly: a,
|
|
127
127
|
initialValues: s,
|
|
128
128
|
input: o
|
|
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
|
() => ({
|
|
136
136
|
path: r,
|
|
137
137
|
initialValues: s,
|
|
138
|
-
onUpdate:
|
|
139
|
-
onChange:
|
|
138
|
+
onUpdate: n,
|
|
139
|
+
onChange: t,
|
|
140
140
|
factory: e,
|
|
141
141
|
readonly: a,
|
|
142
142
|
input: o
|
|
143
143
|
}),
|
|
144
|
-
[e, s, o,
|
|
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
|
")"
|
|
@@ -166,13 +166,13 @@ class xe {
|
|
|
166
166
|
function Pe(r) {
|
|
167
167
|
const {
|
|
168
168
|
mode: e = "onSubmit",
|
|
169
|
-
resolver:
|
|
170
|
-
defaultValues:
|
|
169
|
+
resolver: n,
|
|
170
|
+
defaultValues: t,
|
|
171
171
|
shouldFocusError: a,
|
|
172
172
|
// validateAfterFirstSubmit,
|
|
173
173
|
onValuesChange: s,
|
|
174
174
|
onValidationChange: o,
|
|
175
|
-
onSubmit:
|
|
175
|
+
onSubmit: u,
|
|
176
176
|
// validate,
|
|
177
177
|
// validateDebounceInterval,
|
|
178
178
|
// validationConfig,
|
|
@@ -180,18 +180,18 @@ 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
|
-
defaultValues:
|
|
186
|
+
defaultValues: t,
|
|
187
187
|
shouldFocusError: a,
|
|
188
|
-
resolver:
|
|
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,114 +205,115 @@ 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 });
|
|
244
244
|
}
|
|
245
245
|
const Ne = (r) => {
|
|
246
|
+
var n;
|
|
246
247
|
const e = {};
|
|
247
|
-
return r.inputs.forEach((t) => {
|
|
248
|
-
var
|
|
249
|
-
t.inputType === "group" && ((
|
|
250
|
-
typeof
|
|
251
|
-
})), typeof
|
|
248
|
+
return (n = r == null ? void 0 : r.inputs) == null || n.forEach((t) => {
|
|
249
|
+
var a;
|
|
250
|
+
t.inputType === "group" && ((a = t == null ? void 0 : t.inputs) == null || a.forEach((s) => {
|
|
251
|
+
typeof g(e, s.path) > "u" && p(e, s.path, s.default);
|
|
252
|
+
})), typeof g(e, t.path) > "u" && p(e, t.path, t.default);
|
|
252
253
|
}), e;
|
|
253
254
|
};
|
|
254
255
|
function ke(r, e) {
|
|
255
|
-
const
|
|
256
|
-
const a = ge(e,
|
|
257
|
-
return a ||
|
|
256
|
+
const n = r.inputs.map((t) => {
|
|
257
|
+
const a = ge(e, t.path);
|
|
258
|
+
return a || t;
|
|
258
259
|
});
|
|
259
|
-
return { ...r, inputs:
|
|
260
|
+
return { ...r, inputs: n };
|
|
260
261
|
}
|
|
261
262
|
function ge(r, e) {
|
|
262
|
-
return r.inputs.find((
|
|
263
|
+
return r.inputs.find((n) => n.path === e);
|
|
263
264
|
}
|
|
264
265
|
const pe = "Required field";
|
|
265
|
-
function
|
|
266
|
+
function R(r) {
|
|
266
267
|
const e = typeof r == "string" ? JSON.parse(r) : r;
|
|
267
268
|
if (typeof e == "string")
|
|
268
269
|
return e;
|
|
269
|
-
if (
|
|
270
|
-
return
|
|
271
|
-
const
|
|
272
|
-
return L(
|
|
273
|
-
}
|
|
274
|
-
function be(r, e,
|
|
275
|
-
let
|
|
276
|
-
if (
|
|
277
|
-
const s =
|
|
278
|
-
|
|
270
|
+
if (E(e))
|
|
271
|
+
return R(e[0]);
|
|
272
|
+
const n = e;
|
|
273
|
+
return L(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
274
|
+
}
|
|
275
|
+
function be(r, e, n) {
|
|
276
|
+
let t = {};
|
|
277
|
+
if (C(t, r.inputs, e, n), n != null && n.prefix) {
|
|
278
|
+
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
279
|
+
t = p({}, s, t);
|
|
279
280
|
}
|
|
280
|
-
return m.object(
|
|
281
|
+
return m.object(w(t, e, n));
|
|
281
282
|
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
283
|
+
function w(r, e, n) {
|
|
284
|
+
const t = {};
|
|
284
285
|
return Object.keys(r).forEach((a) => {
|
|
285
286
|
const {
|
|
286
287
|
_requiredOnly: s,
|
|
287
288
|
_schemaObj: o,
|
|
288
|
-
_input:
|
|
289
|
+
_input: u,
|
|
289
290
|
_isList: c,
|
|
290
291
|
_isArrayItem: f,
|
|
291
|
-
_schema:
|
|
292
|
+
_schema: i
|
|
292
293
|
/*...nestedSchemaObj*/
|
|
293
294
|
} = r[a];
|
|
294
|
-
if (c && o &&
|
|
295
|
-
const d = m.array(m.object(
|
|
296
|
-
|
|
297
|
-
} else if (f &&
|
|
298
|
-
const d = o != null && o.___array ?
|
|
299
|
-
|
|
300
|
-
} else if (
|
|
301
|
-
const d = _e(
|
|
302
|
-
|
|
303
|
-
} else s &&
|
|
304
|
-
}),
|
|
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
|
+
t[a] = l;
|
|
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
|
+
t[a] = h;
|
|
301
|
+
} else if (i && u) {
|
|
302
|
+
const d = _e(i, u, e, n);
|
|
303
|
+
t[a] = d;
|
|
304
|
+
} else s && u ? t[a] = A(u, n) : t[a] = m.object(w(r[a], e, n)).optional();
|
|
305
|
+
}), t;
|
|
305
306
|
}
|
|
306
|
-
function _e(r, e,
|
|
307
|
+
function _e(r, e, n, t) {
|
|
307
308
|
return m.any().optional().superRefine(async (a, s) => {
|
|
308
|
-
var
|
|
309
|
-
if (e.required && !(await A(e,
|
|
309
|
+
var u, c;
|
|
310
|
+
if (e.required && !(await A(e, t).safeParseAsync(a)).success)
|
|
310
311
|
return s.addIssue({
|
|
311
312
|
code: m.ZodIssueCode.custom,
|
|
312
|
-
message: F(e,
|
|
313
|
+
message: F(e, t)
|
|
313
314
|
}), m.NEVER;
|
|
314
|
-
if ((
|
|
315
|
-
const f = (c =
|
|
315
|
+
if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
|
|
316
|
+
const f = (c = t == null ? void 0 : t.validationConfig) == null ? void 0 : c.globalValidation(a, e, t.metadata);
|
|
316
317
|
if (f.error)
|
|
317
318
|
return s.addIssue({
|
|
318
319
|
code: m.ZodIssueCode.custom,
|
|
@@ -321,11 +322,11 @@ function _e(r, e, t, n) {
|
|
|
321
322
|
if (!f.continue)
|
|
322
323
|
return !0;
|
|
323
324
|
}
|
|
324
|
-
const o = W(r,
|
|
325
|
+
const o = W(r, n);
|
|
325
326
|
if (o) {
|
|
326
327
|
const f = await o.safeParseAsync(a);
|
|
327
328
|
if (!f.success) {
|
|
328
|
-
const
|
|
329
|
+
const i = R(f == null ? void 0 : f.error.message), d = i === "Required" ? F(e, t) : i;
|
|
329
330
|
s.addIssue({
|
|
330
331
|
code: m.ZodIssueCode.custom,
|
|
331
332
|
message: d
|
|
@@ -334,80 +335,80 @@ function _e(r, e, t, n) {
|
|
|
334
335
|
}
|
|
335
336
|
});
|
|
336
337
|
}
|
|
337
|
-
function J(r, e,
|
|
338
|
+
function J(r, e, n, t, a) {
|
|
338
339
|
return m.any().optional().superRefine(async (s, o) => {
|
|
339
|
-
var
|
|
340
|
-
const c = await A(e,
|
|
340
|
+
var i, d;
|
|
341
|
+
const c = await A(e, t).safeParseAsync(s);
|
|
341
342
|
if (e.required && !c.success) {
|
|
342
|
-
const l =
|
|
343
|
+
const l = R(c.error.message);
|
|
343
344
|
return o.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
|
|
344
345
|
}
|
|
345
346
|
if (!e.required && !c.success)
|
|
346
347
|
return m.NEVER;
|
|
347
|
-
if ((
|
|
348
|
-
const l = (d =
|
|
348
|
+
if ((i = t == null ? void 0 : t.validationConfig) != null && i.globalValidation) {
|
|
349
|
+
const l = (d = t == null ? void 0 : t.validationConfig) == null ? void 0 : d.globalValidation(s, e, t.metadata);
|
|
349
350
|
if (l.error)
|
|
350
351
|
return o.addIssue({
|
|
351
352
|
code: m.ZodIssueCode.custom,
|
|
352
|
-
message:
|
|
353
|
+
message: R(l.error)
|
|
353
354
|
}), m.NEVER;
|
|
354
355
|
if (!l.continue)
|
|
355
356
|
return m.NEVER;
|
|
356
357
|
}
|
|
357
|
-
if (!
|
|
358
|
+
if (!E(s))
|
|
358
359
|
return o.addIssue({
|
|
359
360
|
code: m.ZodIssueCode.custom,
|
|
360
361
|
message: "'Value is not array'"
|
|
361
362
|
}), m.NEVER;
|
|
362
|
-
const f = W(r,
|
|
363
|
+
const f = W(r, n);
|
|
363
364
|
if (f) {
|
|
364
365
|
const l = await f.safeParseAsync(s);
|
|
365
366
|
if (!l.success)
|
|
366
367
|
return o.addIssue({
|
|
367
368
|
code: m.ZodIssueCode.custom,
|
|
368
|
-
message:
|
|
369
|
+
message: R(l.error.message)
|
|
369
370
|
}), m.NEVER;
|
|
370
371
|
}
|
|
371
372
|
}).pipe(a ?? m.any());
|
|
372
373
|
}
|
|
373
|
-
function
|
|
374
|
+
function C(r, e, n, t, a) {
|
|
374
375
|
e.forEach((s) => {
|
|
375
|
-
var
|
|
376
|
-
const o =
|
|
377
|
-
if (!s.isVisible || (
|
|
378
|
-
const l =
|
|
379
|
-
if ((c = s.validation) != null && c.schema ?
|
|
376
|
+
var u, c, f, i, d;
|
|
377
|
+
const o = n;
|
|
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(
|
|
380
381
|
r,
|
|
381
382
|
s.path,
|
|
382
|
-
|
|
383
|
+
V(l, {
|
|
383
384
|
_schema: (f = s.validation) == null ? void 0 : f.schema,
|
|
384
385
|
_input: s
|
|
385
386
|
})
|
|
386
|
-
) : 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") {
|
|
387
388
|
const h = {};
|
|
388
|
-
|
|
389
|
+
C(
|
|
389
390
|
h,
|
|
390
391
|
s.inputConfig.inputs.map((b) => ({
|
|
391
392
|
...b,
|
|
392
393
|
path: b.relativePath
|
|
393
394
|
})),
|
|
394
|
-
|
|
395
|
-
|
|
395
|
+
n,
|
|
396
|
+
t
|
|
396
397
|
);
|
|
397
|
-
const
|
|
398
|
-
|
|
398
|
+
const v = g(r, s.path);
|
|
399
|
+
p(r, s.path, V(v, { _schemaObj: h, _isList: !0, _input: s }));
|
|
399
400
|
}
|
|
400
|
-
if (!((
|
|
401
|
+
if (!((i = s.validation) != null && i.schema) && s.inputType === "array") {
|
|
401
402
|
const h = {};
|
|
402
|
-
|
|
403
|
+
C(
|
|
403
404
|
h,
|
|
404
405
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
),
|
|
406
|
+
n,
|
|
407
|
+
t
|
|
408
|
+
), p(
|
|
408
409
|
r,
|
|
409
410
|
s.path,
|
|
410
|
-
|
|
411
|
+
V(l, {
|
|
411
412
|
_schemaObj: h,
|
|
412
413
|
_schema: (d = s.validation) == null ? void 0 : d.schema,
|
|
413
414
|
_isArrayItem: !0,
|
|
@@ -419,23 +420,23 @@ function w(r, e, t, n, a) {
|
|
|
419
420
|
});
|
|
420
421
|
}
|
|
421
422
|
function F(r, e) {
|
|
422
|
-
var
|
|
423
|
-
return ((
|
|
423
|
+
var n, t, a;
|
|
424
|
+
return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((a = e == null ? void 0 : e.validationConfig) == null ? void 0 : a.requiredMessage) ?? pe;
|
|
424
425
|
}
|
|
425
426
|
function A(r, e) {
|
|
426
|
-
var
|
|
427
|
-
if ((a = (
|
|
427
|
+
var t, a, s, o, u, c;
|
|
428
|
+
if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
|
|
428
429
|
return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
|
|
429
|
-
if ((
|
|
430
|
+
if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
|
|
430
431
|
return (c = e == null ? void 0 : e.validationConfig) == null ? void 0 : c.requiredSchema;
|
|
431
|
-
const
|
|
432
|
-
return m.any().optional().superRefine((f,
|
|
433
|
-
typeof f == "object" &&
|
|
432
|
+
const n = F(r, e);
|
|
433
|
+
return m.any().optional().superRefine((f, i) => {
|
|
434
|
+
typeof f == "object" && T(f) && i.addIssue({
|
|
434
435
|
code: m.ZodIssueCode.custom,
|
|
435
|
-
message:
|
|
436
|
-
}), (
|
|
436
|
+
message: n
|
|
437
|
+
}), (j(f) || f === "") && i.addIssue({
|
|
437
438
|
code: m.ZodIssueCode.custom,
|
|
438
|
-
message:
|
|
439
|
+
message: n
|
|
439
440
|
});
|
|
440
441
|
});
|
|
441
442
|
}
|
|
@@ -445,48 +446,48 @@ function W(r, e) {
|
|
|
445
446
|
if (typeof r == "function")
|
|
446
447
|
return r(e);
|
|
447
448
|
}
|
|
448
|
-
const
|
|
449
|
-
const
|
|
449
|
+
const ve = (r) => Array.isArray(r == null ? void 0 : r.errors), Se = (r, e) => {
|
|
450
|
+
const n = {};
|
|
450
451
|
for (; r.length; ) {
|
|
451
|
-
const
|
|
452
|
-
if (!
|
|
453
|
-
if ("unionErrors" in
|
|
454
|
-
const c =
|
|
455
|
-
|
|
452
|
+
const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
|
|
453
|
+
if (!n[u])
|
|
454
|
+
if ("unionErrors" in t) {
|
|
455
|
+
const c = t.unionErrors[0].errors[0];
|
|
456
|
+
n[u] = {
|
|
456
457
|
message: c.message,
|
|
457
458
|
type: c.code
|
|
458
459
|
};
|
|
459
460
|
} else
|
|
460
|
-
|
|
461
|
-
"unionErrors" in
|
|
461
|
+
n[u] = { message: s, type: a };
|
|
462
|
+
"unionErrors" in t && t.unionErrors.forEach((c) => c.errors.forEach((f) => r.push(f)));
|
|
462
463
|
{
|
|
463
|
-
const c =
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
const c = n[u].types, f = c && c[t.code];
|
|
465
|
+
n[u] = ce(
|
|
466
|
+
u,
|
|
466
467
|
e,
|
|
467
|
-
|
|
468
|
+
n,
|
|
468
469
|
a,
|
|
469
|
-
f ? [].concat(f,
|
|
470
|
+
f ? [].concat(f, t.message) : t.message
|
|
470
471
|
);
|
|
471
472
|
}
|
|
472
473
|
r.shift();
|
|
473
474
|
}
|
|
474
|
-
return
|
|
475
|
+
return n;
|
|
475
476
|
};
|
|
476
477
|
function Fe(r, e) {
|
|
477
478
|
return se(
|
|
478
|
-
async (
|
|
479
|
+
async (n, t, a) => {
|
|
479
480
|
try {
|
|
480
|
-
return await be(r,
|
|
481
|
-
values:
|
|
481
|
+
return await be(r, n, e).parseAsync(n), {
|
|
482
|
+
values: n,
|
|
482
483
|
// TODO: check this - values does not contains all data
|
|
483
484
|
errors: {}
|
|
484
485
|
};
|
|
485
486
|
} catch (s) {
|
|
486
|
-
if (
|
|
487
|
+
if (ve(s))
|
|
487
488
|
return {
|
|
488
489
|
values: {},
|
|
489
|
-
errors: fe(
|
|
490
|
+
errors: fe(Se(s.errors, !0), a)
|
|
490
491
|
};
|
|
491
492
|
throw s;
|
|
492
493
|
}
|
|
@@ -495,98 +496,105 @@ function Fe(r, e) {
|
|
|
495
496
|
);
|
|
496
497
|
}
|
|
497
498
|
function Ae(r, e) {
|
|
498
|
-
const
|
|
499
|
-
return e.forEach((
|
|
500
|
-
if (
|
|
501
|
-
const a =
|
|
502
|
-
|
|
499
|
+
const n = q(r);
|
|
500
|
+
return e.forEach((t) => {
|
|
501
|
+
if (t.inputTransform) {
|
|
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
|
+
});
|
|
503
507
|
}
|
|
504
|
-
}),
|
|
508
|
+
}), n;
|
|
505
509
|
}
|
|
506
510
|
function De(r, e) {
|
|
507
|
-
const
|
|
508
|
-
return e.forEach((
|
|
509
|
-
if (
|
|
510
|
-
const a =
|
|
511
|
-
|
|
511
|
+
const n = q(r);
|
|
512
|
+
return e.forEach((t) => {
|
|
513
|
+
if (t.outputTransform) {
|
|
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
|
+
});
|
|
512
519
|
}
|
|
513
|
-
}),
|
|
520
|
+
}), n;
|
|
514
521
|
}
|
|
515
522
|
function D(r) {
|
|
516
|
-
return r.reduce((
|
|
523
|
+
return r.reduce((n, t) => t.inputType === "group" && t.inputs ? [...n, t, ...D(t.inputs)] : [...n, t], []);
|
|
517
524
|
}
|
|
518
525
|
function Ze(r) {
|
|
519
|
-
const
|
|
526
|
+
const n = D(r.inputs).reduce((t, a) => {
|
|
520
527
|
const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
|
|
521
|
-
return (a.inputTransform || a.outputTransform) &&
|
|
528
|
+
return (a.inputTransform || a.outputTransform) && t.push({
|
|
522
529
|
...K(a, "path", "inputTransform", "outputTransform"),
|
|
523
530
|
level: a.path.split(".").length,
|
|
524
531
|
isPrimitive: s
|
|
525
|
-
}),
|
|
532
|
+
}), t;
|
|
526
533
|
}, []);
|
|
527
|
-
return
|
|
534
|
+
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
528
535
|
}
|
|
529
|
-
function $e(r, e,
|
|
530
|
-
const
|
|
531
|
-
return
|
|
532
|
-
s.isVisible && !s.isVisible(e,
|
|
536
|
+
function $e(r, e, n) {
|
|
537
|
+
const t = D(r.inputs), a = q(e);
|
|
538
|
+
return t.forEach((s) => {
|
|
539
|
+
s.isVisible && !s.isVisible(e, n) && X(a, s.path);
|
|
533
540
|
}), a;
|
|
534
541
|
}
|
|
535
542
|
function Me() {
|
|
536
543
|
return function(r, e) {
|
|
537
544
|
if (!(typeof r > "u"))
|
|
538
545
|
return r ? {
|
|
539
|
-
value: Object.getOwnPropertyNames(r).map((
|
|
546
|
+
value: Object.getOwnPropertyNames(r).map((n) => ({ key: n, value: r[n] }))
|
|
540
547
|
} : { value: r };
|
|
541
548
|
};
|
|
542
549
|
}
|
|
543
550
|
function Be(r) {
|
|
544
|
-
return function(e,
|
|
551
|
+
return function(e, n) {
|
|
545
552
|
if (typeof e > "u") return;
|
|
546
553
|
if (!e) return { value: e };
|
|
547
|
-
const
|
|
554
|
+
const t = {
|
|
548
555
|
value: e.reduce((a, s) => ({ ...a, [s.key]: s.value }), {})
|
|
549
556
|
};
|
|
550
|
-
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(
|
|
557
|
+
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
551
558
|
};
|
|
552
559
|
}
|
|
553
560
|
function Je() {
|
|
554
561
|
return function(r, e) {
|
|
555
562
|
if (!(typeof r > "u"))
|
|
556
|
-
return
|
|
563
|
+
return E(r) && T(r) ? { value: void 0 } : { value: r };
|
|
557
564
|
};
|
|
558
565
|
}
|
|
559
|
-
function Le() {
|
|
560
|
-
return function(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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 };
|
|
566
574
|
}
|
|
567
|
-
return { value: r };
|
|
575
|
+
return { value: t, path: r };
|
|
568
576
|
}
|
|
569
577
|
};
|
|
570
578
|
}
|
|
571
579
|
function Ue() {
|
|
572
580
|
return function(r, e) {
|
|
573
581
|
if (!(typeof r > "u"))
|
|
574
|
-
return z(r) &&
|
|
582
|
+
return z(r) && T(r) ? { value: void 0 } : { value: r };
|
|
575
583
|
};
|
|
576
584
|
}
|
|
577
585
|
function We(r) {
|
|
578
|
-
return function(e,
|
|
579
|
-
const
|
|
580
|
-
return typeof
|
|
586
|
+
return function(e, n) {
|
|
587
|
+
const t = g(n, r);
|
|
588
|
+
return typeof t == "string" ? { value: t } : { value: e };
|
|
581
589
|
};
|
|
582
590
|
}
|
|
583
591
|
function Ge(r) {
|
|
584
|
-
return function(e,
|
|
592
|
+
return function(e, n) {
|
|
585
593
|
if (typeof e > "u") return;
|
|
586
594
|
if (!e) return { value: e };
|
|
587
|
-
const
|
|
588
|
-
if (typeof
|
|
589
|
-
const a =
|
|
595
|
+
const t = g(n, r);
|
|
596
|
+
if (typeof t == "object") {
|
|
597
|
+
const a = Ee(t);
|
|
590
598
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
591
599
|
return { value: e, path: r };
|
|
592
600
|
}
|
|
@@ -594,55 +602,55 @@ function Ge(r) {
|
|
|
594
602
|
};
|
|
595
603
|
}
|
|
596
604
|
function He(r) {
|
|
597
|
-
return function(e,
|
|
605
|
+
return function(e, n) {
|
|
598
606
|
if (typeof e > "u") return;
|
|
599
|
-
const
|
|
600
|
-
return typeof
|
|
607
|
+
const t = g(n, r);
|
|
608
|
+
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
601
609
|
};
|
|
602
610
|
}
|
|
603
611
|
function Qe(r, e) {
|
|
604
|
-
return function(
|
|
605
|
-
if (typeof
|
|
606
|
-
if (!
|
|
607
|
-
const a =
|
|
608
|
-
if (
|
|
612
|
+
return function(n, t) {
|
|
613
|
+
if (typeof n > "u") return;
|
|
614
|
+
if (!n) return { value: n };
|
|
615
|
+
const a = g(t, r);
|
|
616
|
+
if (E(a)) {
|
|
609
617
|
if (a.length === 1)
|
|
610
618
|
return { value: a[0], path: r };
|
|
611
619
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
612
620
|
return { value: void 0, path: r };
|
|
613
621
|
}
|
|
614
|
-
return { value:
|
|
622
|
+
return { value: n };
|
|
615
623
|
};
|
|
616
624
|
}
|
|
617
625
|
function G(r) {
|
|
618
|
-
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);
|
|
619
627
|
}
|
|
620
|
-
function
|
|
621
|
-
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));
|
|
622
630
|
}
|
|
623
|
-
function
|
|
624
|
-
const { prefix:
|
|
625
|
-
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ye, { path: `${
|
|
631
|
+
function Oe({ input: r, factory: e }) {
|
|
632
|
+
const { prefix: n = "" } = {};
|
|
633
|
+
return /* @__PURE__ */ y.jsx("div", { children: /* @__PURE__ */ y.jsx(ye, { path: `${n}${r.path}`, factory: e, readonly: !1, input: r }) });
|
|
626
634
|
}
|
|
627
635
|
function Re(r) {
|
|
628
|
-
const { items: e, factory:
|
|
629
|
-
return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((
|
|
630
|
-
const a = `${
|
|
631
|
-
return /* @__PURE__ */ y.jsx(
|
|
636
|
+
const { items: e, factory: n } = r;
|
|
637
|
+
return /* @__PURE__ */ y.jsx(y.Fragment, { children: e.map((t) => {
|
|
638
|
+
const a = `${t.inputType}_${t.path}_${t.label}`;
|
|
639
|
+
return /* @__PURE__ */ y.jsx(Oe, { input: t, factory: n }, a);
|
|
632
640
|
}) });
|
|
633
641
|
}
|
|
634
|
-
const
|
|
635
|
-
const { inputs:
|
|
636
|
-
return /* @__PURE__ */ y.jsxs("div", { className:
|
|
637
|
-
|
|
638
|
-
/* @__PURE__ */ y.jsx(Re, { items:
|
|
642
|
+
const Te = ae((r, e) => {
|
|
643
|
+
const { inputs: n, className: t, factory: a } = r;
|
|
644
|
+
return /* @__PURE__ */ y.jsxs("div", { className: t, ref: e, children: [
|
|
645
|
+
n.hero,
|
|
646
|
+
/* @__PURE__ */ y.jsx(Re, { items: n.inputs, factory: a })
|
|
639
647
|
] });
|
|
640
648
|
});
|
|
641
|
-
|
|
649
|
+
Te.displayName = "RenderForm";
|
|
642
650
|
function Ye(r) {
|
|
643
651
|
let e = !0;
|
|
644
|
-
return ee(r, (
|
|
645
|
-
e = e && (
|
|
652
|
+
return ee(r, (n) => {
|
|
653
|
+
e = e && (n === "" || re(n) || j(n));
|
|
646
654
|
}), e;
|
|
647
655
|
}
|
|
648
656
|
const Ke = (r = "") => te(r.split("_").join(" "));
|
|
@@ -651,10 +659,10 @@ export {
|
|
|
651
659
|
ye as InputComponentRenderer,
|
|
652
660
|
qe as InputFactory,
|
|
653
661
|
de as InputOverrideError,
|
|
654
|
-
|
|
662
|
+
Te as RenderForm,
|
|
655
663
|
Re as RenderInputs,
|
|
656
664
|
Pe as RootForm,
|
|
657
|
-
|
|
665
|
+
Oe as Row,
|
|
658
666
|
Be as arrayToObjectOutputTransformer,
|
|
659
667
|
Ke as generateReadableLabel,
|
|
660
668
|
Ne as getDefaultValuesFromFormDefinition,
|
|
@@ -665,7 +673,7 @@ export {
|
|
|
665
673
|
Me as objectToArrayInputTransformer,
|
|
666
674
|
De as outputTransformValues,
|
|
667
675
|
ke as overrideFormDefinition,
|
|
668
|
-
|
|
676
|
+
R as processValidationParseResponse,
|
|
669
677
|
He as shorthandArrayInputTransformer,
|
|
670
678
|
Qe as shorthandArrayOutputTransformer,
|
|
671
679
|
We as shorthandObjectInputTransformer,
|