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