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