@harnessio/forms 0.14.0 → 0.15.0
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/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +483 -435
- package/dist/index.js.map +1 -1
- package/dist/tests/transformer-chaining.test.d.ts +1 -0
- package/dist/types/types.d.ts +26 -0
- package/dist/utils/utils.d.ts +23 -0
- package/dist/utils/utils.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { isEmpty as
|
|
5
|
-
import
|
|
6
|
-
import { useFormContext as
|
|
7
|
-
import { Controller as
|
|
8
|
-
import * as
|
|
9
|
-
import { toNestErrors as
|
|
10
|
-
class
|
|
1
|
+
var Re = Object.defineProperty;
|
|
2
|
+
var je = (r, e, n) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var $ = (r, e, n) => je(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as D, set as O, get as T, forOwn as pe, isArray as x, isObject as he, merge as N, isUndefined as J, cloneDeep as W, unset as ye, isPlainObject as we, isNull as ge, omitBy as be, isNil as Ve, isString as xe, capitalize as Fe } from "lodash-es";
|
|
5
|
+
import Pe, { createContext as qe, useContext as Ae, Component as ke, memo as De, useMemo as B, useRef as V, useEffect as w, useCallback as Me, forwardRef as $e, Fragment as Ne } from "react";
|
|
6
|
+
import { useFormContext as Be, get as Ze, useForm as We, FormProvider as Je, appendErrors as Le, useController as Ue } from "react-hook-form";
|
|
7
|
+
import { Controller as Gr, Form as Kr, FormProvider as Qr, get as Xr, set as Yr, useFieldArray as zr, useForm as et, useFormContext as rt, useFormState as tt, useWatch as nt } from "react-hook-form";
|
|
8
|
+
import * as m from "zod";
|
|
9
|
+
import { toNestErrors as He } from "@hookform/resolvers";
|
|
10
|
+
class Ge extends Error {
|
|
11
11
|
constructor(e) {
|
|
12
12
|
super(`Input component '${e}' is already registered.`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
class
|
|
15
|
+
class ve {
|
|
16
16
|
constructor(e) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
$(this, "componentBank");
|
|
18
|
+
$(this, "allowOverride");
|
|
19
19
|
this.allowOverride = (e == null ? void 0 : e.allowOverride) ?? !1, this.componentBank = /* @__PURE__ */ new Map();
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -26,11 +26,11 @@ class be {
|
|
|
26
26
|
*/
|
|
27
27
|
registerComponent(e) {
|
|
28
28
|
if (!this.allowOverride && this.getComponent(e.internalType))
|
|
29
|
-
throw new
|
|
29
|
+
throw new Ge(e.internalType);
|
|
30
30
|
this.componentBank.set(e.internalType, e);
|
|
31
31
|
}
|
|
32
32
|
getComponent(e) {
|
|
33
|
-
if (e && !
|
|
33
|
+
if (e && !D(e))
|
|
34
34
|
return this.componentBank.get(e);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -47,7 +47,7 @@ class be {
|
|
|
47
47
|
* @returns new input factory
|
|
48
48
|
*/
|
|
49
49
|
clone() {
|
|
50
|
-
const e = new
|
|
50
|
+
const e = new ve({
|
|
51
51
|
allowOverride: this.allowOverride
|
|
52
52
|
});
|
|
53
53
|
return this.listRegisteredComponents().forEach((n) => {
|
|
@@ -55,15 +55,15 @@ class be {
|
|
|
55
55
|
}), e;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
var
|
|
58
|
+
var L = { exports: {} }, F = {};
|
|
59
59
|
/*
|
|
60
60
|
object-assign
|
|
61
61
|
(c) Sindre Sorhus
|
|
62
62
|
@license MIT
|
|
63
63
|
*/
|
|
64
|
-
var
|
|
65
|
-
function
|
|
66
|
-
if (oe) return
|
|
64
|
+
var U, oe;
|
|
65
|
+
function Ke() {
|
|
66
|
+
if (oe) return U;
|
|
67
67
|
oe = 1;
|
|
68
68
|
var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
|
|
69
69
|
function t(s) {
|
|
@@ -71,19 +71,19 @@ function Ge() {
|
|
|
71
71
|
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
72
72
|
return Object(s);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function i() {
|
|
75
75
|
try {
|
|
76
76
|
if (!Object.assign)
|
|
77
77
|
return !1;
|
|
78
78
|
var s = new String("abc");
|
|
79
79
|
if (s[5] = "de", Object.getOwnPropertyNames(s)[0] === "5")
|
|
80
80
|
return !1;
|
|
81
|
-
for (var a = {},
|
|
82
|
-
a["_" + String.fromCharCode(
|
|
83
|
-
var
|
|
81
|
+
for (var a = {}, o = 0; o < 10; o++)
|
|
82
|
+
a["_" + String.fromCharCode(o)] = o;
|
|
83
|
+
var u = Object.getOwnPropertyNames(a).map(function(c) {
|
|
84
84
|
return a[c];
|
|
85
85
|
});
|
|
86
|
-
if (
|
|
86
|
+
if (u.join("") !== "0123456789")
|
|
87
87
|
return !1;
|
|
88
88
|
var f = {};
|
|
89
89
|
return "abcdefghijklmnopqrst".split("").forEach(function(c) {
|
|
@@ -93,19 +93,19 @@ function Ge() {
|
|
|
93
93
|
return !1;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
return
|
|
97
|
-
for (var
|
|
98
|
-
|
|
99
|
-
for (var
|
|
100
|
-
e.call(
|
|
96
|
+
return U = i() ? Object.assign : function(s, a) {
|
|
97
|
+
for (var o, u = t(s), f, c = 1; c < arguments.length; c++) {
|
|
98
|
+
o = Object(arguments[c]);
|
|
99
|
+
for (var l in o)
|
|
100
|
+
e.call(o, l) && (u[l] = o[l]);
|
|
101
101
|
if (r) {
|
|
102
|
-
f = r(
|
|
103
|
-
for (var
|
|
104
|
-
n.call(
|
|
102
|
+
f = r(o);
|
|
103
|
+
for (var d = 0; d < f.length; d++)
|
|
104
|
+
n.call(o, f[d]) && (u[f[d]] = o[f[d]]);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
return
|
|
108
|
-
},
|
|
107
|
+
return u;
|
|
108
|
+
}, U;
|
|
109
109
|
}
|
|
110
110
|
/** @license React v17.0.2
|
|
111
111
|
* react-jsx-runtime.production.min.js
|
|
@@ -116,38 +116,38 @@ function Ge() {
|
|
|
116
116
|
* LICENSE file in the root directory of this source tree.
|
|
117
117
|
*/
|
|
118
118
|
var ue;
|
|
119
|
-
function
|
|
120
|
-
if (ue) return
|
|
121
|
-
ue = 1,
|
|
122
|
-
var r =
|
|
123
|
-
if (
|
|
119
|
+
function Qe() {
|
|
120
|
+
if (ue) return F;
|
|
121
|
+
ue = 1, Ke();
|
|
122
|
+
var r = Pe, e = 60103;
|
|
123
|
+
if (F.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
124
124
|
var n = Symbol.for;
|
|
125
|
-
e = n("react.element"),
|
|
125
|
+
e = n("react.element"), F.Fragment = n("react.fragment");
|
|
126
126
|
}
|
|
127
|
-
var t = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
|
|
128
|
-
function a(
|
|
129
|
-
var c,
|
|
130
|
-
f !== void 0 && (
|
|
131
|
-
for (c in
|
|
132
|
-
if (
|
|
133
|
-
return { $$typeof: e, type:
|
|
127
|
+
var t = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = Object.prototype.hasOwnProperty, s = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
128
|
+
function a(o, u, f) {
|
|
129
|
+
var c, l = {}, d = null, p = null;
|
|
130
|
+
f !== void 0 && (d = "" + f), u.key !== void 0 && (d = "" + u.key), u.ref !== void 0 && (p = u.ref);
|
|
131
|
+
for (c in u) i.call(u, c) && !s.hasOwnProperty(c) && (l[c] = u[c]);
|
|
132
|
+
if (o && o.defaultProps) for (c in u = o.defaultProps, u) l[c] === void 0 && (l[c] = u[c]);
|
|
133
|
+
return { $$typeof: e, type: o, key: d, ref: p, props: l, _owner: t.current };
|
|
134
134
|
}
|
|
135
|
-
return
|
|
135
|
+
return F.jsx = a, F.jsxs = a, F;
|
|
136
136
|
}
|
|
137
|
-
var
|
|
138
|
-
function
|
|
139
|
-
return
|
|
137
|
+
var ce;
|
|
138
|
+
function Xe() {
|
|
139
|
+
return ce || (ce = 1, L.exports = Qe()), L.exports;
|
|
140
140
|
}
|
|
141
|
-
var
|
|
142
|
-
const
|
|
143
|
-
function
|
|
141
|
+
var h = Xe();
|
|
142
|
+
const Ce = qe({});
|
|
143
|
+
function Ye({
|
|
144
144
|
children: r,
|
|
145
145
|
metadata: e,
|
|
146
146
|
inputErrorHandler: n,
|
|
147
147
|
readonly: t
|
|
148
148
|
}) {
|
|
149
|
-
return /* @__PURE__ */
|
|
150
|
-
|
|
149
|
+
return /* @__PURE__ */ h.jsx(
|
|
150
|
+
Ce.Provider,
|
|
151
151
|
{
|
|
152
152
|
value: {
|
|
153
153
|
metadata: e,
|
|
@@ -158,14 +158,14 @@ function Xe({
|
|
|
158
158
|
}
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
const r =
|
|
161
|
+
function ze() {
|
|
162
|
+
const r = Ae(Ce);
|
|
163
163
|
return r || console.warn("useRootFormContext must be used within RootFormProvider"), r;
|
|
164
164
|
}
|
|
165
|
-
class
|
|
165
|
+
class er extends ke {
|
|
166
166
|
constructor() {
|
|
167
167
|
super(...arguments);
|
|
168
|
-
|
|
168
|
+
$(this, "state", {
|
|
169
169
|
hasError: !1
|
|
170
170
|
});
|
|
171
171
|
}
|
|
@@ -175,71 +175,71 @@ class ze extends Ae {
|
|
|
175
175
|
componentDidCatch(n, t) {
|
|
176
176
|
var s, a;
|
|
177
177
|
console.error(n, t);
|
|
178
|
-
const
|
|
178
|
+
const i = new Error(
|
|
179
179
|
`Form input [${this.props.inputType}] has failed at path [${this.props.path}]. Error: ${n}, Error info: ${t}`
|
|
180
180
|
);
|
|
181
|
-
(a = (s = this.props).inputErrorHandler) == null || a.call(s,
|
|
181
|
+
(a = (s = this.props).inputErrorHandler) == null || a.call(s, i);
|
|
182
182
|
}
|
|
183
183
|
render() {
|
|
184
|
-
return this.state.hasError ? /* @__PURE__ */
|
|
184
|
+
return this.state.hasError ? /* @__PURE__ */ h.jsx(h.Fragment, {}) : this.props.children;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
const
|
|
187
|
+
const fe = ({
|
|
188
188
|
children: r,
|
|
189
189
|
withoutWrapper: e = !1
|
|
190
|
-
}) => e || !r ? r : /* @__PURE__ */
|
|
190
|
+
}) => e || !r ? r : /* @__PURE__ */ h.jsx("div", { children: r }), rr = De(function({
|
|
191
191
|
path: e,
|
|
192
192
|
factory: n,
|
|
193
193
|
onUpdate: t,
|
|
194
|
-
onChange:
|
|
194
|
+
onChange: i,
|
|
195
195
|
initialValues: s,
|
|
196
196
|
input: a,
|
|
197
|
-
withoutWrapper:
|
|
197
|
+
withoutWrapper: o = !1
|
|
198
198
|
}) {
|
|
199
|
-
var
|
|
200
|
-
const
|
|
201
|
-
if (!
|
|
202
|
-
let
|
|
203
|
-
return c && Object.keys(c).forEach((
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
}),
|
|
207
|
-
}, [
|
|
208
|
-
var
|
|
209
|
-
if (!
|
|
210
|
-
const
|
|
211
|
-
return !
|
|
212
|
-
}, [a.path,
|
|
199
|
+
var z, ee, re, te, ne;
|
|
200
|
+
const u = Be(), { formState: f } = u, { fixedValues: c = {} } = {}, { metadata: l, readonly: d, inputErrorHandler: p } = ze(), g = n == null ? void 0 : n.getComponent(a.inputType), b = !!(a.isVisible || typeof a.disabled == "function" || typeof ((z = a.validation) == null ? void 0 : z.schema) == "function" || typeof ((ee = a.warning) == null ? void 0 : ee.schema) == "function"), v = !!((re = a.warning) != null && re.schema || (te = a.validation) != null && te.schema), y = b ? u.watch() : {}, S = v ? b ? Ze(y, a.path) : u.watch(a.path) : void 0, _ = B(() => {
|
|
201
|
+
if (!b) return {};
|
|
202
|
+
let P = y;
|
|
203
|
+
return c && Object.keys(c).forEach((M) => {
|
|
204
|
+
const q = c[M];
|
|
205
|
+
P = O(P, M, q);
|
|
206
|
+
}), P;
|
|
207
|
+
}, [b, y, c]), j = !a.isVisible || a.isVisible(_, l), C = d || a.readonly, I = typeof a.disabled == "function" ? a.disabled(_, l) : a.disabled, E = (ne = a.warning) == null ? void 0 : ne.schema, X = B(() => {
|
|
208
|
+
var ae, ie;
|
|
209
|
+
if (!j || typeof E > "u") return;
|
|
210
|
+
const P = typeof E == "function" ? E(_, l) : E, { success: M, error: q } = P.safeParse(S), se = (ie = (ae = q == null ? void 0 : q.errors) == null ? void 0 : ae[0]) == null ? void 0 : ie.message;
|
|
211
|
+
return !M && se ? se : void 0;
|
|
212
|
+
}, [a.path, S, E, j, l]), Y = B(
|
|
213
213
|
() => ({
|
|
214
214
|
path: e,
|
|
215
215
|
key: e,
|
|
216
216
|
initialValues: s,
|
|
217
217
|
onUpdate: t,
|
|
218
|
-
onChange:
|
|
218
|
+
onChange: i,
|
|
219
219
|
factory: n,
|
|
220
|
-
readonly:
|
|
220
|
+
readonly: C,
|
|
221
221
|
input: a,
|
|
222
|
-
disabled:
|
|
223
|
-
warning:
|
|
222
|
+
disabled: I,
|
|
223
|
+
warning: X
|
|
224
224
|
}),
|
|
225
|
-
[n, s, a,
|
|
226
|
-
),
|
|
225
|
+
[n, s, a, i, t, e, C, f.errors, I, X]
|
|
226
|
+
), Ie = B(() => j ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
|
|
227
227
|
a.before ? a.before : null,
|
|
228
|
-
/* @__PURE__ */
|
|
228
|
+
/* @__PURE__ */ h.jsx(er, { path: e, inputType: a.inputType, inputErrorHandler: p, children: g == null ? void 0 : g.renderComponent(Y) }),
|
|
229
229
|
a.after ? a.after : null
|
|
230
|
-
] }) : null, [
|
|
231
|
-
return
|
|
230
|
+
] }) : null, [j, a.before, a.inputType, a.after, e, g, Y, f.errors]);
|
|
231
|
+
return g ? /* @__PURE__ */ h.jsx(fe, { withoutWrapper: o, children: Ie }) : /* @__PURE__ */ h.jsx(fe, { withoutWrapper: o, children: /* @__PURE__ */ h.jsxs("p", { children: [
|
|
232
232
|
"Input component not found (internal type: ",
|
|
233
233
|
a.inputType,
|
|
234
234
|
")"
|
|
235
235
|
] }) });
|
|
236
236
|
});
|
|
237
|
-
class
|
|
237
|
+
class Sr {
|
|
238
238
|
getType() {
|
|
239
239
|
return this.internalType;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function le() {
|
|
243
243
|
return typeof window < "u" && "requestIdleCallback" in window ? window.requestIdleCallback : function(r, e) {
|
|
244
244
|
const n = Date.now(), t = (e == null ? void 0 : e.timeout) || 1;
|
|
245
245
|
return setTimeout(function() {
|
|
@@ -252,40 +252,40 @@ function fe() {
|
|
|
252
252
|
}, t);
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function de() {
|
|
256
256
|
return typeof window < "u" && "cancelIdleCallback" in window ? window.cancelIdleCallback : clearTimeout;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function _r(r) {
|
|
259
259
|
const {
|
|
260
260
|
mode: e = "onSubmit",
|
|
261
261
|
resolver: n,
|
|
262
262
|
defaultValues: t,
|
|
263
|
-
shouldFocusError:
|
|
263
|
+
shouldFocusError: i,
|
|
264
264
|
// validateAfterFirstSubmit,
|
|
265
265
|
onValuesChange: s,
|
|
266
266
|
onValidationChange: a,
|
|
267
|
-
onSubmit:
|
|
268
|
-
onInputRenderError:
|
|
267
|
+
onSubmit: o,
|
|
268
|
+
onInputRenderError: u,
|
|
269
269
|
// validate,
|
|
270
270
|
// validateDebounceInterval,
|
|
271
271
|
// validationConfig,
|
|
272
272
|
metadata: f,
|
|
273
273
|
children: c,
|
|
274
274
|
// fixedValues
|
|
275
|
-
autoFocusPath:
|
|
276
|
-
readonly:
|
|
277
|
-
} = r,
|
|
275
|
+
autoFocusPath: l,
|
|
276
|
+
readonly: d
|
|
277
|
+
} = r, p = We({
|
|
278
278
|
mode: e,
|
|
279
279
|
reValidateMode: "onChange",
|
|
280
280
|
defaultValues: t,
|
|
281
|
-
shouldFocusError:
|
|
281
|
+
shouldFocusError: i,
|
|
282
282
|
resolver: n
|
|
283
|
-
}),
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}, [
|
|
287
|
-
const
|
|
288
|
-
|
|
283
|
+
}), g = V(!1), b = V(JSON.stringify(t ?? {}));
|
|
284
|
+
w(() => {
|
|
285
|
+
b.current = JSON.stringify(t ?? {}), p.reset(t, {});
|
|
286
|
+
}, [p.reset, t]), w(() => {
|
|
287
|
+
const C = le(), I = de(), E = C(() => {
|
|
288
|
+
p.reset({}, {
|
|
289
289
|
keepErrors: !0,
|
|
290
290
|
keepDirty: !0,
|
|
291
291
|
keepDirtyValues: !0,
|
|
@@ -298,80 +298,80 @@ function Or(r) {
|
|
|
298
298
|
keepSubmitCount: !0
|
|
299
299
|
});
|
|
300
300
|
});
|
|
301
|
-
return () =>
|
|
301
|
+
return () => I(E);
|
|
302
302
|
}, []);
|
|
303
|
-
const { handleSubmit:
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
const { handleSubmit: v } = p, y = V(s);
|
|
304
|
+
w(() => {
|
|
305
|
+
y.current = s;
|
|
306
306
|
}, [s]);
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
307
|
+
const S = V(a);
|
|
308
|
+
w(() => {
|
|
309
|
+
S.current = a;
|
|
310
310
|
}, [a]);
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
var
|
|
315
|
-
|
|
316
|
-
|
|
311
|
+
const _ = V(!1);
|
|
312
|
+
w(() => {
|
|
313
|
+
const C = p.watch((I) => {
|
|
314
|
+
var E;
|
|
315
|
+
_.current || JSON.stringify(I ?? {}) !== b.current && ((E = y.current) == null || E.call(y, { ...I }), g.current === !0 && (_.current = !0, p.trigger().finally(() => {
|
|
316
|
+
_.current = !1;
|
|
317
317
|
})));
|
|
318
318
|
});
|
|
319
319
|
return () => {
|
|
320
|
-
|
|
320
|
+
C.unsubscribe();
|
|
321
321
|
};
|
|
322
|
-
}, [
|
|
323
|
-
const
|
|
324
|
-
return
|
|
325
|
-
var
|
|
326
|
-
if (
|
|
327
|
-
|
|
322
|
+
}, [p]);
|
|
323
|
+
const j = V(!0);
|
|
324
|
+
return w(() => {
|
|
325
|
+
var C;
|
|
326
|
+
if (j.current) {
|
|
327
|
+
j.current = !1;
|
|
328
328
|
return;
|
|
329
329
|
}
|
|
330
|
-
(
|
|
331
|
-
}, [
|
|
332
|
-
if (
|
|
333
|
-
const
|
|
334
|
-
|
|
330
|
+
(C = S.current) == null || C.call(S, { isValid: p.formState.isValid, isSubmitted: p.formState.isSubmitted });
|
|
331
|
+
}, [p.formState.isValid, p.formState.isSubmitted]), w(() => {
|
|
332
|
+
if (l) {
|
|
333
|
+
const C = le(), I = de(), E = C(() => {
|
|
334
|
+
p.setFocus(l);
|
|
335
335
|
});
|
|
336
|
-
return () =>
|
|
336
|
+
return () => I(E);
|
|
337
337
|
}
|
|
338
|
-
}, [
|
|
339
|
-
...
|
|
338
|
+
}, [p, l]), /* @__PURE__ */ h.jsx(Ye, { metadata: f, readonly: d, inputErrorHandler: u, children: /* @__PURE__ */ h.jsx(Je, { ...p, children: typeof c == "function" ? c({
|
|
339
|
+
...p,
|
|
340
340
|
submitForm: async () => {
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
o && (g.current = !0, v((C) => {
|
|
342
|
+
o(C);
|
|
343
343
|
})());
|
|
344
344
|
}
|
|
345
345
|
}) : c }) });
|
|
346
346
|
}
|
|
347
|
-
const
|
|
347
|
+
const Ir = (r) => {
|
|
348
348
|
const e = {}, n = (t) => {
|
|
349
|
-
t.forEach((
|
|
350
|
-
const { path: s, default: a, inputs:
|
|
351
|
-
Array.isArray(
|
|
349
|
+
t.forEach((i) => {
|
|
350
|
+
const { path: s, default: a, inputs: o } = i;
|
|
351
|
+
Array.isArray(o) ? n(o) : T(e, s) === void 0 && O(e, s, a);
|
|
352
352
|
});
|
|
353
353
|
};
|
|
354
354
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
355
355
|
};
|
|
356
|
-
function
|
|
356
|
+
function Rr(r, e) {
|
|
357
357
|
const n = r.inputs.map((t) => {
|
|
358
|
-
const
|
|
359
|
-
return
|
|
358
|
+
const i = tr(e, t.path);
|
|
359
|
+
return i || t;
|
|
360
360
|
});
|
|
361
361
|
return { ...r, inputs: n };
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function tr(r, e) {
|
|
364
364
|
return r.inputs.find((n) => n.path === e);
|
|
365
365
|
}
|
|
366
|
-
const Te = "__temp_",
|
|
367
|
-
function
|
|
366
|
+
const Te = "__temp_", jr = (r) => Te + r.split(".").join("__");
|
|
367
|
+
function nr(r) {
|
|
368
368
|
const e = { ...r };
|
|
369
|
-
return
|
|
369
|
+
return pe(e, (n, t) => {
|
|
370
370
|
t.startsWith(Te) && delete e[t];
|
|
371
371
|
}), e;
|
|
372
372
|
}
|
|
373
|
-
const
|
|
374
|
-
function
|
|
373
|
+
const sr = "Required field";
|
|
374
|
+
function A(r) {
|
|
375
375
|
let e;
|
|
376
376
|
if (typeof r == "string")
|
|
377
377
|
try {
|
|
@@ -383,74 +383,74 @@ function q(r) {
|
|
|
383
383
|
e = r;
|
|
384
384
|
if (typeof e == "string")
|
|
385
385
|
return e;
|
|
386
|
-
if (
|
|
387
|
-
return
|
|
386
|
+
if (x(e))
|
|
387
|
+
return A(e[0]);
|
|
388
388
|
const n = e;
|
|
389
389
|
return he(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function ar(r, e, n) {
|
|
392
392
|
let t = {};
|
|
393
393
|
if (Z(t, r.inputs, e, n), n != null && n.prefix) {
|
|
394
394
|
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
395
|
-
t =
|
|
395
|
+
t = O({}, s, t);
|
|
396
396
|
}
|
|
397
|
-
return
|
|
397
|
+
return m.object(k(t, e, n));
|
|
398
398
|
}
|
|
399
|
-
function
|
|
400
|
-
const t = Object.keys(r).filter((a) => /^\d+$/.test(a) && !a.startsWith("_")).map((a) => parseInt(a, 10)).sort((a,
|
|
399
|
+
function ir(r, e, n) {
|
|
400
|
+
const t = Object.keys(r).filter((a) => /^\d+$/.test(a) && !a.startsWith("_")).map((a) => parseInt(a, 10)).sort((a, o) => a - o);
|
|
401
401
|
if (t.length === 0) return null;
|
|
402
|
-
const
|
|
403
|
-
for (let a = 0; a <=
|
|
402
|
+
const i = Math.max(...t), s = [];
|
|
403
|
+
for (let a = 0; a <= i; a++)
|
|
404
404
|
if (t.includes(a)) {
|
|
405
|
-
const
|
|
406
|
-
s.push(
|
|
405
|
+
const o = r[a], u = k({ item: o }, e, n);
|
|
406
|
+
s.push(u.item || m.any().optional());
|
|
407
407
|
} else
|
|
408
|
-
s.push(
|
|
409
|
-
return
|
|
408
|
+
s.push(m.any().optional());
|
|
409
|
+
return m.tuple(s).rest(m.any()).optional();
|
|
410
410
|
}
|
|
411
|
-
function
|
|
411
|
+
function k(r, e, n) {
|
|
412
412
|
const t = {};
|
|
413
|
-
return Object.keys(r).forEach((
|
|
413
|
+
return Object.keys(r).forEach((i) => {
|
|
414
414
|
const {
|
|
415
415
|
_requiredOnly: s,
|
|
416
416
|
_schemaObj: a,
|
|
417
|
-
_input:
|
|
418
|
-
_isList:
|
|
417
|
+
_input: o,
|
|
418
|
+
_isList: u,
|
|
419
419
|
_isArrayItem: f,
|
|
420
420
|
_isTuple: c,
|
|
421
|
-
_schema:
|
|
421
|
+
_schema: l
|
|
422
422
|
/*...nestedSchemaObj*/
|
|
423
|
-
} = r[
|
|
424
|
-
if (c && !
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
-
t[
|
|
423
|
+
} = r[i];
|
|
424
|
+
if (c && !u && !f) {
|
|
425
|
+
const d = ir(r[i], e, n);
|
|
426
|
+
if (d) {
|
|
427
|
+
t[i] = d;
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
if (
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
Ee(
|
|
435
|
-
]),
|
|
436
|
-
t[
|
|
437
|
-
} else if (f &&
|
|
438
|
-
const
|
|
439
|
-
t[
|
|
440
|
-
} else if (
|
|
441
|
-
const
|
|
442
|
-
t[
|
|
443
|
-
} else s &&
|
|
431
|
+
if (u && a && o) {
|
|
432
|
+
const d = m.object(k(a, e, n)), p = m.union([
|
|
433
|
+
m.array(d).optional(),
|
|
434
|
+
Ee(o, n)
|
|
435
|
+
]), g = me(l, o, e, n, p);
|
|
436
|
+
t[i] = g;
|
|
437
|
+
} else if (f && o) {
|
|
438
|
+
const d = a != null && a.___array ? k({ ___array: a.___array }, e, n) : { ___array: m.any() }, p = or(d, o, n), g = me(l, o, e, n, p);
|
|
439
|
+
t[i] = g;
|
|
440
|
+
} else if (l && o) {
|
|
441
|
+
const d = ur(l, o, e, n);
|
|
442
|
+
t[i] = d;
|
|
443
|
+
} else s && o ? t[i] = K(o, n) : t[i] = m.object(k(r[i], e, n)).optional();
|
|
444
444
|
}), t;
|
|
445
445
|
}
|
|
446
446
|
function Ee(r, e) {
|
|
447
|
-
return
|
|
448
|
-
var
|
|
449
|
-
if ((
|
|
447
|
+
return m.string().superRefine((n, t) => {
|
|
448
|
+
var i;
|
|
449
|
+
if ((i = e == null ? void 0 : e.validationConfig) != null && i.globalValidation) {
|
|
450
450
|
const s = e.validationConfig.globalValidation(n, r, e.metadata);
|
|
451
451
|
if (s.error)
|
|
452
452
|
return t.addIssue({
|
|
453
|
-
code:
|
|
453
|
+
code: m.ZodIssueCode.custom,
|
|
454
454
|
message: s.error
|
|
455
455
|
}), !1;
|
|
456
456
|
if (!s.continue)
|
|
@@ -460,115 +460,115 @@ function Ee(r, e) {
|
|
|
460
460
|
});
|
|
461
461
|
}
|
|
462
462
|
function or(r, e, n) {
|
|
463
|
-
return
|
|
463
|
+
return m.union([m.array(r.___array).optional(), Ee(e, n)]);
|
|
464
464
|
}
|
|
465
465
|
function ur(r, e, n, t) {
|
|
466
|
-
return
|
|
467
|
-
var
|
|
468
|
-
if (e.required && !(await
|
|
466
|
+
return m.any().optional().superRefine(async (i, s) => {
|
|
467
|
+
var o, u;
|
|
468
|
+
if (e.required && !(await K(e, t).safeParseAsync(i)).success)
|
|
469
469
|
return s.addIssue({
|
|
470
|
-
code:
|
|
471
|
-
message:
|
|
472
|
-
}),
|
|
473
|
-
if ((
|
|
474
|
-
const f = (
|
|
470
|
+
code: m.ZodIssueCode.custom,
|
|
471
|
+
message: H(e, t)
|
|
472
|
+
}), m.NEVER;
|
|
473
|
+
if ((o = t == null ? void 0 : t.validationConfig) != null && o.globalValidation) {
|
|
474
|
+
const f = (u = t == null ? void 0 : t.validationConfig) == null ? void 0 : u.globalValidation(i, e, t.metadata);
|
|
475
475
|
if (f.error)
|
|
476
476
|
return s.addIssue({
|
|
477
|
-
code:
|
|
477
|
+
code: m.ZodIssueCode.custom,
|
|
478
478
|
message: f.error
|
|
479
|
-
}),
|
|
479
|
+
}), m.NEVER;
|
|
480
480
|
if (!f.continue)
|
|
481
481
|
return !0;
|
|
482
482
|
}
|
|
483
|
-
const a =
|
|
483
|
+
const a = Oe(r, n);
|
|
484
484
|
if (a) {
|
|
485
|
-
const f = await a.safeParseAsync(
|
|
485
|
+
const f = await a.safeParseAsync(i);
|
|
486
486
|
if (!f.success) {
|
|
487
|
-
const c =
|
|
487
|
+
const c = A(f == null ? void 0 : f.error.message), l = c === "Required" ? H(e, t) : c;
|
|
488
488
|
s.addIssue({
|
|
489
|
-
code:
|
|
490
|
-
message:
|
|
489
|
+
code: m.ZodIssueCode.custom,
|
|
490
|
+
message: l
|
|
491
491
|
});
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
|
-
function
|
|
497
|
-
return
|
|
498
|
-
var c,
|
|
499
|
-
const
|
|
500
|
-
if (e.required && !
|
|
501
|
-
const
|
|
502
|
-
return a.addIssue({ code:
|
|
496
|
+
function me(r, e, n, t, i) {
|
|
497
|
+
return m.any().optional().superRefine(async (s, a) => {
|
|
498
|
+
var c, l;
|
|
499
|
+
const u = await K(e, t).safeParseAsync(s);
|
|
500
|
+
if (e.required && !u.success) {
|
|
501
|
+
const d = A(u.error.message);
|
|
502
|
+
return a.addIssue({ code: m.ZodIssueCode.custom, message: d, fatal: !0 }), m.NEVER;
|
|
503
503
|
}
|
|
504
|
-
if (!e.required && !
|
|
505
|
-
return
|
|
504
|
+
if (!e.required && !u.success)
|
|
505
|
+
return m.NEVER;
|
|
506
506
|
if ((c = t == null ? void 0 : t.validationConfig) != null && c.globalValidation) {
|
|
507
|
-
const
|
|
508
|
-
if (
|
|
507
|
+
const d = (l = t == null ? void 0 : t.validationConfig) == null ? void 0 : l.globalValidation(s, e, t.metadata);
|
|
508
|
+
if (d.error)
|
|
509
509
|
return a.addIssue({
|
|
510
|
-
code:
|
|
511
|
-
message:
|
|
512
|
-
}),
|
|
513
|
-
if (!
|
|
510
|
+
code: m.ZodIssueCode.custom,
|
|
511
|
+
message: A(d.error)
|
|
512
|
+
}), m.NEVER;
|
|
513
|
+
if (!d.continue)
|
|
514
514
|
return !0;
|
|
515
515
|
}
|
|
516
|
-
if (!
|
|
516
|
+
if (!x(s))
|
|
517
517
|
return a.addIssue({
|
|
518
|
-
code:
|
|
518
|
+
code: m.ZodIssueCode.custom,
|
|
519
519
|
message: "'Value is not array'"
|
|
520
|
-
}),
|
|
521
|
-
const f =
|
|
520
|
+
}), m.NEVER;
|
|
521
|
+
const f = Oe(r, n);
|
|
522
522
|
if (f) {
|
|
523
|
-
const
|
|
524
|
-
if (!
|
|
523
|
+
const d = await f.safeParseAsync(s);
|
|
524
|
+
if (!d.success)
|
|
525
525
|
return a.addIssue({
|
|
526
|
-
code:
|
|
527
|
-
message:
|
|
528
|
-
}),
|
|
526
|
+
code: m.ZodIssueCode.custom,
|
|
527
|
+
message: A(d.error.message)
|
|
528
|
+
}), m.NEVER;
|
|
529
529
|
}
|
|
530
|
-
}).pipe(
|
|
530
|
+
}).pipe(i ?? m.any());
|
|
531
531
|
}
|
|
532
|
-
function Z(r, e, n, t,
|
|
532
|
+
function Z(r, e, n, t, i) {
|
|
533
533
|
e.forEach((s) => {
|
|
534
|
-
var
|
|
534
|
+
var o, u, f, c, l, d, p;
|
|
535
535
|
const a = n;
|
|
536
|
-
if (!s.isVisible || (
|
|
537
|
-
const
|
|
538
|
-
if ((
|
|
536
|
+
if (!s.isVisible || (o = s.isVisible) != null && o.call(s, a, t == null ? void 0 : t.metadata)) {
|
|
537
|
+
const g = T(r, s.path);
|
|
538
|
+
if ((u = s.validation) != null && u.schema ? O(
|
|
539
539
|
r,
|
|
540
540
|
s.path,
|
|
541
|
-
|
|
541
|
+
N(g, {
|
|
542
542
|
_schema: (f = s.validation) == null ? void 0 : f.schema,
|
|
543
543
|
_input: s
|
|
544
544
|
})
|
|
545
|
-
) : s.required &&
|
|
546
|
-
const
|
|
545
|
+
) : s.required && O(r, s.path, N(g, { _requiredOnly: !0, _input: s })), s.inputs && Z(r, s.inputs, n, t), s.inputType === "list") {
|
|
546
|
+
const b = {};
|
|
547
547
|
Z(
|
|
548
|
-
|
|
549
|
-
(
|
|
550
|
-
...
|
|
551
|
-
path:
|
|
548
|
+
b,
|
|
549
|
+
(l = (c = s.inputConfig) == null ? void 0 : c.inputs) == null ? void 0 : l.map((y) => ({
|
|
550
|
+
...y,
|
|
551
|
+
path: y.relativePath
|
|
552
552
|
})),
|
|
553
553
|
n,
|
|
554
554
|
t
|
|
555
555
|
);
|
|
556
|
-
const
|
|
557
|
-
|
|
556
|
+
const v = T(r, s.path);
|
|
557
|
+
O(r, s.path, N(v, { _schemaObj: b, _isList: !0, _input: s }));
|
|
558
558
|
}
|
|
559
|
-
if (!((
|
|
560
|
-
const
|
|
559
|
+
if (!((d = s.validation) != null && d.schema) && s.inputType === "array") {
|
|
560
|
+
const b = {};
|
|
561
561
|
Z(
|
|
562
|
-
|
|
562
|
+
b,
|
|
563
563
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
564
564
|
n,
|
|
565
565
|
t
|
|
566
|
-
),
|
|
566
|
+
), O(
|
|
567
567
|
r,
|
|
568
568
|
s.path,
|
|
569
|
-
|
|
570
|
-
_schemaObj:
|
|
571
|
-
_schema: (
|
|
569
|
+
N(g, {
|
|
570
|
+
_schemaObj: b,
|
|
571
|
+
_schema: (p = s.validation) == null ? void 0 : p.schema,
|
|
572
572
|
_isArrayItem: !0,
|
|
573
573
|
_input: s
|
|
574
574
|
})
|
|
@@ -576,67 +576,67 @@ function Z(r, e, n, t, o) {
|
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
578
|
}), e.forEach((s) => {
|
|
579
|
-
var
|
|
579
|
+
var o;
|
|
580
580
|
const a = n;
|
|
581
|
-
if ((!s.isVisible || (
|
|
582
|
-
const
|
|
583
|
-
|
|
581
|
+
if ((!s.isVisible || (o = s.isVisible) != null && o.call(s, a, t == null ? void 0 : t.metadata)) && s.path) {
|
|
582
|
+
const u = s.path.split(".");
|
|
583
|
+
u.forEach((f, c) => {
|
|
584
584
|
if (c > 0 && /^\d+$/.test(f)) {
|
|
585
|
-
const
|
|
586
|
-
|
|
585
|
+
const l = u.slice(0, c).join("."), d = l ? T(r, l) : r;
|
|
586
|
+
d && typeof d == "object" && (d._isTuple = !0);
|
|
587
587
|
}
|
|
588
588
|
});
|
|
589
589
|
}
|
|
590
590
|
});
|
|
591
591
|
}
|
|
592
|
-
function
|
|
593
|
-
var n, t,
|
|
594
|
-
return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((
|
|
592
|
+
function H(r, e) {
|
|
593
|
+
var n, t, i;
|
|
594
|
+
return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((i = e == null ? void 0 : e.validationConfig) == null ? void 0 : i.requiredMessage) ?? sr;
|
|
595
595
|
}
|
|
596
|
-
function
|
|
597
|
-
var t,
|
|
598
|
-
if ((
|
|
596
|
+
function K(r, e) {
|
|
597
|
+
var t, i, s, a, o, u;
|
|
598
|
+
if ((i = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && i[r.inputType])
|
|
599
599
|
return (a = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : a[r.inputType];
|
|
600
|
-
if ((
|
|
601
|
-
return (
|
|
602
|
-
const n =
|
|
603
|
-
return
|
|
604
|
-
typeof f == "object" &&
|
|
605
|
-
code:
|
|
600
|
+
if ((o = e == null ? void 0 : e.validationConfig) != null && o.requiredSchema)
|
|
601
|
+
return (u = e == null ? void 0 : e.validationConfig) == null ? void 0 : u.requiredSchema;
|
|
602
|
+
const n = H(r, e);
|
|
603
|
+
return m.any().optional().superRefine((f, c) => {
|
|
604
|
+
typeof f == "object" && D(f) && c.addIssue({
|
|
605
|
+
code: m.ZodIssueCode.custom,
|
|
606
606
|
message: n
|
|
607
|
-
}), (
|
|
608
|
-
code:
|
|
607
|
+
}), (J(f) || f === "") && c.addIssue({
|
|
608
|
+
code: m.ZodIssueCode.custom,
|
|
609
609
|
message: n
|
|
610
610
|
});
|
|
611
611
|
});
|
|
612
612
|
}
|
|
613
|
-
function
|
|
614
|
-
if (r instanceof
|
|
613
|
+
function Oe(r, e) {
|
|
614
|
+
if (r instanceof m.ZodType)
|
|
615
615
|
return r;
|
|
616
616
|
if (typeof r == "function")
|
|
617
617
|
return r(e);
|
|
618
618
|
}
|
|
619
|
-
const
|
|
619
|
+
const cr = (r) => Array.isArray(r == null ? void 0 : r.errors), fr = (r, e) => {
|
|
620
620
|
const n = {};
|
|
621
621
|
for (; r.length; ) {
|
|
622
|
-
const t = r[0], { code:
|
|
623
|
-
if (!n[
|
|
622
|
+
const t = r[0], { code: i, message: s, path: a } = t, o = a.join(".");
|
|
623
|
+
if (!n[o])
|
|
624
624
|
if ("unionErrors" in t) {
|
|
625
|
-
const
|
|
626
|
-
n[
|
|
627
|
-
message:
|
|
628
|
-
type:
|
|
625
|
+
const u = t.unionErrors[0].errors[0];
|
|
626
|
+
n[o] = {
|
|
627
|
+
message: u.message,
|
|
628
|
+
type: u.code
|
|
629
629
|
};
|
|
630
630
|
} else
|
|
631
|
-
n[
|
|
632
|
-
"unionErrors" in t && t.unionErrors.forEach((
|
|
631
|
+
n[o] = { message: s, type: i };
|
|
632
|
+
"unionErrors" in t && t.unionErrors.forEach((u) => u.errors.forEach((f) => r.push(f)));
|
|
633
633
|
{
|
|
634
|
-
const
|
|
635
|
-
n[
|
|
636
|
-
|
|
634
|
+
const u = n[o].types, f = u && u[t.code];
|
|
635
|
+
n[o] = Le(
|
|
636
|
+
o,
|
|
637
637
|
e,
|
|
638
638
|
n,
|
|
639
|
-
|
|
639
|
+
i,
|
|
640
640
|
f ? [].concat(f, t.message) : t.message
|
|
641
641
|
);
|
|
642
642
|
}
|
|
@@ -645,18 +645,18 @@ const ir = (r) => Array.isArray(r == null ? void 0 : r.errors), cr = (r, e) => {
|
|
|
645
645
|
return n;
|
|
646
646
|
};
|
|
647
647
|
function wr(r, e) {
|
|
648
|
-
return
|
|
649
|
-
async (n, t,
|
|
648
|
+
return Me(
|
|
649
|
+
async (n, t, i) => {
|
|
650
650
|
try {
|
|
651
|
-
return await
|
|
651
|
+
return await ar(r, n, e).parseAsync(n), {
|
|
652
652
|
values: n,
|
|
653
653
|
errors: {}
|
|
654
654
|
};
|
|
655
655
|
} catch (s) {
|
|
656
|
-
if (
|
|
656
|
+
if (cr(s))
|
|
657
657
|
return {
|
|
658
658
|
values: {},
|
|
659
|
-
errors:
|
|
659
|
+
errors: He(fr(s.errors, !0), i)
|
|
660
660
|
};
|
|
661
661
|
throw s;
|
|
662
662
|
}
|
|
@@ -664,90 +664,97 @@ function wr(r, e) {
|
|
|
664
664
|
[r, e]
|
|
665
665
|
);
|
|
666
666
|
}
|
|
667
|
-
function
|
|
668
|
-
const n =
|
|
667
|
+
function lr(r, e) {
|
|
668
|
+
const n = W(r);
|
|
669
669
|
return e.forEach((t) => {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
670
|
+
if (t.inputTransform) {
|
|
671
|
+
const i = x(t.inputTransform) ? t.inputTransform : [t.inputTransform];
|
|
672
|
+
let s;
|
|
673
|
+
const a = t.path.split(".");
|
|
674
|
+
if (a.length > 1) {
|
|
675
|
+
const o = a.slice(0, -1).join("."), u = T(n, o);
|
|
676
|
+
typeof u == "string" || typeof u == "number" || typeof u == "boolean" ? s = void 0 : s = T(n, t.path);
|
|
676
677
|
} else
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
678
|
+
s = T(n, t.path);
|
|
679
|
+
i.forEach((o) => {
|
|
680
|
+
const u = o(s, n);
|
|
681
|
+
u && (s = u.value, O(n, u.path ?? t.path, u.value));
|
|
682
|
+
});
|
|
683
|
+
}
|
|
681
684
|
}), n;
|
|
682
685
|
}
|
|
683
|
-
function
|
|
686
|
+
function dr(r, e, n) {
|
|
684
687
|
const t = [];
|
|
685
|
-
let
|
|
686
|
-
n || (
|
|
687
|
-
const s =
|
|
688
|
+
let i = {};
|
|
689
|
+
n || (i = W(r));
|
|
690
|
+
const s = W(r);
|
|
688
691
|
return e.forEach((a) => {
|
|
689
|
-
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
|
|
692
|
+
if (a.outputTransform) {
|
|
693
|
+
const o = x(a.outputTransform) ? a.outputTransform : [a.outputTransform];
|
|
694
|
+
let u = T(s, a.path);
|
|
695
|
+
o.forEach((f) => {
|
|
696
|
+
const c = f(u, s);
|
|
697
|
+
c && (u = c.value, c.path ? (O(i, c.path, c.value), c.unset && t.push(a.path)) : O(i, a.path, c.value));
|
|
698
|
+
});
|
|
699
|
+
}
|
|
693
700
|
}), t.forEach((a) => {
|
|
694
|
-
|
|
695
|
-
}),
|
|
701
|
+
ye(i, a);
|
|
702
|
+
}), i;
|
|
696
703
|
}
|
|
697
|
-
function
|
|
698
|
-
return r.reduce((n, t) => Array.isArray(t.inputs) ? [...n, t, ...
|
|
704
|
+
function Q(r) {
|
|
705
|
+
return r.reduce((n, t) => Array.isArray(t.inputs) ? [...n, t, ...Q(t.inputs)] : [...n, t], []);
|
|
699
706
|
}
|
|
700
|
-
const
|
|
707
|
+
const mr = (r) => {
|
|
701
708
|
if (r !== void 0)
|
|
702
709
|
return { value: r };
|
|
703
|
-
},
|
|
710
|
+
}, pr = (r) => {
|
|
704
711
|
if (r !== void 0)
|
|
705
712
|
return { value: r };
|
|
706
713
|
};
|
|
707
|
-
function
|
|
708
|
-
const t =
|
|
709
|
-
const a = s.inputType === "text" || s.inputType === "boolean" || s.inputType === "number" || s.inputType === "textarea" || s.inputType === "select",
|
|
710
|
-
return
|
|
714
|
+
function Se(r, e) {
|
|
715
|
+
const t = Q(r.inputs).reduce((i, s) => {
|
|
716
|
+
const a = s.inputType === "text" || s.inputType === "boolean" || s.inputType === "number" || s.inputType === "textarea" || s.inputType === "select", o = !!s.inputTransform, u = !!s.outputTransform, f = Array.isArray(s.inputs) && s.inputs.length > 0, c = s.inputType === "list" || s.inputType === "array";
|
|
717
|
+
return o || u ? i.push({
|
|
711
718
|
path: s.path,
|
|
712
719
|
inputTransform: s.inputTransform,
|
|
713
720
|
outputTransform: s.outputTransform,
|
|
714
721
|
level: s.path.split(".").length,
|
|
715
722
|
isPrimitive: a
|
|
716
|
-
}) : e && !(f || c) &&
|
|
723
|
+
}) : e && !(f || c) && i.push({
|
|
717
724
|
path: s.path,
|
|
718
|
-
inputTransform:
|
|
719
|
-
outputTransform:
|
|
725
|
+
inputTransform: mr,
|
|
726
|
+
outputTransform: pr,
|
|
720
727
|
level: s.path.split(".").length,
|
|
721
728
|
isPrimitive: a
|
|
722
|
-
}),
|
|
729
|
+
}), i;
|
|
723
730
|
}, []);
|
|
724
|
-
return t.sort((
|
|
731
|
+
return t.sort((i, s) => i.level === s.level ? i.isPrimitive ? 1 : -1 : i.level < s.level ? -1 : 1), t;
|
|
725
732
|
}
|
|
726
733
|
function hr(r, e, n, t = {}) {
|
|
727
|
-
const { preserve:
|
|
728
|
-
return s.forEach((
|
|
729
|
-
|
|
734
|
+
const { preserve: i } = t, s = Q(r.inputs), a = W(e);
|
|
735
|
+
return s.forEach((o) => {
|
|
736
|
+
i && i.includes(o.path) || o.isVisible && !o.isVisible(e, n) && ye(a, o.path);
|
|
730
737
|
}), a;
|
|
731
738
|
}
|
|
732
|
-
function
|
|
733
|
-
const n =
|
|
734
|
-
return
|
|
739
|
+
function Vr(r, e) {
|
|
740
|
+
const n = Se(e);
|
|
741
|
+
return lr(r, n);
|
|
735
742
|
}
|
|
736
|
-
function
|
|
737
|
-
const
|
|
743
|
+
function xr(r, e, n, t = {}) {
|
|
744
|
+
const i = t.cleanOutput, s = Se(e, i);
|
|
738
745
|
let a = hr(e, r, n, t);
|
|
739
|
-
return a =
|
|
746
|
+
return a = dr(a, s, t.cleanOutput), a = nr(a), a;
|
|
740
747
|
}
|
|
741
|
-
function
|
|
748
|
+
function Fr(r) {
|
|
742
749
|
const e = {}, n = (t) => {
|
|
743
|
-
t.forEach((
|
|
744
|
-
const { default: s, path: a, inputs:
|
|
745
|
-
Array.isArray(
|
|
750
|
+
t.forEach((i) => {
|
|
751
|
+
const { default: s, path: a, inputs: o } = i;
|
|
752
|
+
Array.isArray(o) ? n(o) : s !== void 0 && O(e, a, s);
|
|
746
753
|
});
|
|
747
754
|
};
|
|
748
755
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
749
756
|
}
|
|
750
|
-
function
|
|
757
|
+
function Pr() {
|
|
751
758
|
return function(r, e) {
|
|
752
759
|
if (!(typeof r > "u"))
|
|
753
760
|
return !r || !we(r) ? { value: r } : {
|
|
@@ -755,188 +762,229 @@ function Fr() {
|
|
|
755
762
|
};
|
|
756
763
|
};
|
|
757
764
|
}
|
|
758
|
-
function
|
|
765
|
+
function qr(r) {
|
|
759
766
|
return function(e, n) {
|
|
760
767
|
if (typeof e > "u") return;
|
|
761
|
-
if (!e || !
|
|
768
|
+
if (!e || !x(e)) return { value: e };
|
|
762
769
|
const t = {
|
|
763
|
-
value: e.reduce((
|
|
764
|
-
...
|
|
770
|
+
value: e.reduce((i, s) => ({
|
|
771
|
+
...i,
|
|
765
772
|
[s.key]: r != null && r.assignKeyToValue ? s.key : s.value ?? (r == null ? void 0 : r.fallbackValue)
|
|
766
773
|
}), {})
|
|
767
774
|
};
|
|
768
775
|
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
769
776
|
};
|
|
770
777
|
}
|
|
771
|
-
function
|
|
778
|
+
function Ar() {
|
|
772
779
|
return function(r, e) {
|
|
773
780
|
if (!(typeof r > "u"))
|
|
774
|
-
return
|
|
781
|
+
return x(r) && D(r) ? { value: void 0 } : { value: r };
|
|
775
782
|
};
|
|
776
783
|
}
|
|
777
|
-
function
|
|
784
|
+
function kr(r) {
|
|
778
785
|
return function(e, n) {
|
|
779
|
-
const t = r ?
|
|
786
|
+
const t = r ? T(n, r) : e;
|
|
780
787
|
if (!(typeof t > "u")) {
|
|
781
|
-
if (
|
|
788
|
+
if (ge(t)) return { value: void 0, path: r };
|
|
782
789
|
if (he(t)) {
|
|
783
|
-
const
|
|
784
|
-
if (
|
|
790
|
+
const i = be(t, Ve);
|
|
791
|
+
if (D(i))
|
|
785
792
|
return { value: void 0, path: r };
|
|
786
793
|
}
|
|
787
794
|
return { value: t, path: r };
|
|
788
795
|
}
|
|
789
796
|
};
|
|
790
797
|
}
|
|
791
|
-
function
|
|
798
|
+
function Dr() {
|
|
792
799
|
return function(r, e) {
|
|
793
800
|
if (!(typeof r > "u"))
|
|
794
|
-
return
|
|
801
|
+
return xe(r) && D(r) ? { value: void 0 } : { value: r };
|
|
795
802
|
};
|
|
796
803
|
}
|
|
797
|
-
function
|
|
804
|
+
function Mr(r) {
|
|
798
805
|
return function(e, n) {
|
|
799
|
-
const t =
|
|
806
|
+
const t = T(n, r);
|
|
800
807
|
if (typeof t == "string")
|
|
801
808
|
return { value: t };
|
|
802
809
|
if (!(typeof t == "number" || typeof t == "boolean") && e !== void 0)
|
|
803
810
|
return { value: e };
|
|
804
811
|
};
|
|
805
812
|
}
|
|
806
|
-
function
|
|
813
|
+
function $r(r) {
|
|
807
814
|
return function(e, n) {
|
|
808
815
|
if (typeof e > "u") return;
|
|
809
816
|
if (!e) return { value: e };
|
|
810
|
-
const t =
|
|
817
|
+
const t = T(n, r);
|
|
811
818
|
if (typeof t == "object") {
|
|
812
|
-
const
|
|
813
|
-
if (Object.getOwnPropertyNames(
|
|
819
|
+
const i = yr(t);
|
|
820
|
+
if (Object.getOwnPropertyNames(i).length === 1)
|
|
814
821
|
return { value: e, path: r };
|
|
815
822
|
}
|
|
816
823
|
return { value: e };
|
|
817
824
|
};
|
|
818
825
|
}
|
|
819
|
-
function
|
|
826
|
+
function Nr(r) {
|
|
820
827
|
return function(e, n) {
|
|
821
|
-
const t =
|
|
828
|
+
const t = T(n, r);
|
|
822
829
|
if (typeof t == "string")
|
|
823
830
|
return { value: [t] };
|
|
824
831
|
if (!(typeof t == "number" || typeof t == "boolean") && e !== void 0)
|
|
825
832
|
return { value: e };
|
|
826
833
|
};
|
|
827
834
|
}
|
|
828
|
-
function
|
|
835
|
+
function Br(r, e) {
|
|
829
836
|
return function(n, t) {
|
|
830
837
|
if (typeof n > "u") return;
|
|
831
838
|
if (!n) return { value: n };
|
|
832
|
-
const
|
|
833
|
-
if (
|
|
834
|
-
if (
|
|
835
|
-
return { value:
|
|
836
|
-
if (
|
|
839
|
+
const i = T(t, r);
|
|
840
|
+
if (x(i)) {
|
|
841
|
+
if (i.length === 1)
|
|
842
|
+
return { value: i[0], path: r };
|
|
843
|
+
if (i.length === 0 && e != null && e.unsetIfEmpty)
|
|
837
844
|
return { value: void 0, path: r };
|
|
838
845
|
}
|
|
839
846
|
return { value: n };
|
|
840
847
|
};
|
|
841
848
|
}
|
|
842
|
-
function
|
|
843
|
-
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !
|
|
849
|
+
function _e(r) {
|
|
850
|
+
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !_e(r[e])) : J(r);
|
|
844
851
|
}
|
|
845
|
-
function
|
|
846
|
-
return
|
|
852
|
+
function yr(r) {
|
|
853
|
+
return be(r, (e) => typeof e == "object" ? _e(e) : J(e));
|
|
847
854
|
}
|
|
848
|
-
function
|
|
849
|
-
const { items: e, className: n, withoutWrapper: t = !0, ...
|
|
850
|
-
return t ? /* @__PURE__ */
|
|
855
|
+
function G(r) {
|
|
856
|
+
const { items: e, className: n, withoutWrapper: t = !0, ...i } = r, s = e.map((a) => /* @__PURE__ */ h.jsx(rr, { input: a, path: a.path, ...i }, `${a.inputType}_${a.path}`));
|
|
857
|
+
return t ? /* @__PURE__ */ h.jsx(h.Fragment, { children: s }) : /* @__PURE__ */ h.jsx("div", { className: n, children: s });
|
|
851
858
|
}
|
|
852
|
-
|
|
853
|
-
const
|
|
854
|
-
const { inputs: n, className: t, factory:
|
|
855
|
-
return s ? /* @__PURE__ */
|
|
859
|
+
G.displayName = "RenderInputs";
|
|
860
|
+
const gr = $e((r, e) => {
|
|
861
|
+
const { inputs: n, className: t, factory: i, withoutWrapper: s } = r;
|
|
862
|
+
return s ? /* @__PURE__ */ h.jsxs(Ne, { children: [
|
|
856
863
|
n.hero,
|
|
857
|
-
/* @__PURE__ */
|
|
858
|
-
] }) : /* @__PURE__ */
|
|
864
|
+
/* @__PURE__ */ h.jsx(G, { items: n.inputs, factory: i })
|
|
865
|
+
] }) : /* @__PURE__ */ h.jsxs("div", { className: t, ref: e, children: [
|
|
859
866
|
n.hero,
|
|
860
|
-
/* @__PURE__ */
|
|
867
|
+
/* @__PURE__ */ h.jsx(G, { items: n.inputs, factory: i })
|
|
861
868
|
] });
|
|
862
869
|
});
|
|
863
|
-
|
|
870
|
+
gr.displayName = "RenderForm";
|
|
864
871
|
function Zr(r) {
|
|
865
872
|
let e = !0;
|
|
866
|
-
return
|
|
867
|
-
e = e && (n === "" ||
|
|
873
|
+
return pe(r, (n) => {
|
|
874
|
+
e = e && (n === "" || ge(n) || J(n));
|
|
868
875
|
}), e;
|
|
869
876
|
}
|
|
870
|
-
const
|
|
871
|
-
let
|
|
877
|
+
const Wr = (r = "") => Fe(r.split("_").join(" ")), br = (r, e = 2, n, t = 1e3) => {
|
|
878
|
+
let i = !1;
|
|
872
879
|
const s = () => {
|
|
873
880
|
requestAnimationFrame(() => {
|
|
874
|
-
|
|
881
|
+
i || (e -= 1, e <= 0 ? r() : s());
|
|
875
882
|
});
|
|
876
883
|
};
|
|
877
884
|
return n && Date.now() - n <= t ? (r(), () => {
|
|
878
885
|
}) : (s(), () => {
|
|
879
|
-
|
|
886
|
+
i = !0;
|
|
880
887
|
});
|
|
881
888
|
};
|
|
882
|
-
function
|
|
889
|
+
function Jr(r, e) {
|
|
890
|
+
return {
|
|
891
|
+
...r,
|
|
892
|
+
inputs: r.inputs.map((n) => R(n, e))
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function R(r, e) {
|
|
896
|
+
var u, f, c;
|
|
897
|
+
const { override: n, ...t } = r, i = e && n ? n[e] : void 0, { inputConfig: s, ...a } = i || {}, o = i ? { ...t, ...a } : t;
|
|
898
|
+
if ((t.inputConfig || s) && (o.inputConfig = { ...t.inputConfig, ...s }), o.inputs && (o.inputs = o.inputs.map((l) => R(l, e))), o.inputType === "list" && o.inputConfig) {
|
|
899
|
+
const l = ((u = t.inputConfig) == null ? void 0 : u.inputs) || [], d = (s == null ? void 0 : s.inputs) || [];
|
|
900
|
+
if (l.length > 0 || d.length > 0) {
|
|
901
|
+
const p = Math.max(l.length, d.length);
|
|
902
|
+
o.inputConfig.inputs = Array.from({ length: p }, (g, b) => {
|
|
903
|
+
var S;
|
|
904
|
+
const v = l[b], y = d[b];
|
|
905
|
+
if (!v && y) return R(y, e);
|
|
906
|
+
if (v && !y) return R(v, e);
|
|
907
|
+
if (v && y) {
|
|
908
|
+
const _ = v.override ? { ...v.override } : {};
|
|
909
|
+
return e && y && (_[e] = (S = v.override) != null && S[e] ? { ...v.override[e], ...y } : y), R({ ...v, override: _ }, e);
|
|
910
|
+
}
|
|
911
|
+
}).filter(Boolean);
|
|
912
|
+
} else o.inputConfig.inputs && (o.inputConfig.inputs = o.inputConfig.inputs.map(
|
|
913
|
+
(p) => R(p, e)
|
|
914
|
+
));
|
|
915
|
+
}
|
|
916
|
+
if (o.inputType === "array" && o.inputConfig) {
|
|
917
|
+
const l = (f = t.inputConfig) == null ? void 0 : f.input, d = s == null ? void 0 : s.input;
|
|
918
|
+
if (l && d) {
|
|
919
|
+
const p = l.override ? { ...l.override } : {};
|
|
920
|
+
e && d && (p[e] = (c = l.override) != null && c[e] ? { ...l.override[e], ...d } : d), o.inputConfig.input = R(
|
|
921
|
+
{ ...l, override: p },
|
|
922
|
+
e
|
|
923
|
+
);
|
|
924
|
+
} else o.inputConfig.input && (o.inputConfig.input = R(o.inputConfig.input, e));
|
|
925
|
+
}
|
|
926
|
+
return o;
|
|
927
|
+
}
|
|
928
|
+
function Lr(r) {
|
|
883
929
|
const {
|
|
884
930
|
field: { onBlur: e, ...n },
|
|
885
931
|
...t
|
|
886
|
-
} =
|
|
932
|
+
} = Ue(r), i = V(Date.now());
|
|
887
933
|
return {
|
|
888
934
|
...t,
|
|
889
935
|
field: {
|
|
890
936
|
...n,
|
|
891
|
-
onBlur:
|
|
937
|
+
onBlur: br(e, 2, i.current)
|
|
892
938
|
}
|
|
893
939
|
};
|
|
894
940
|
}
|
|
895
941
|
export {
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
942
|
+
Gr as Controller,
|
|
943
|
+
Kr as Form,
|
|
944
|
+
Qr as FormProvider,
|
|
945
|
+
Sr as InputComponent,
|
|
946
|
+
rr as InputComponentRenderer,
|
|
947
|
+
ve as InputFactory,
|
|
948
|
+
Ge as InputOverrideError,
|
|
949
|
+
gr as RenderForm,
|
|
950
|
+
G as RenderInputs,
|
|
951
|
+
_r as RootForm,
|
|
952
|
+
br as afterFrames,
|
|
953
|
+
Jr as applyFormOverrides,
|
|
954
|
+
R as applyInputOverride,
|
|
955
|
+
qr as arrayToObjectOutputTransformer,
|
|
956
|
+
Fr as collectDefaultValues,
|
|
957
|
+
Vr as convertDataToFormModel,
|
|
958
|
+
xr as convertFormModelToData,
|
|
959
|
+
Wr as generateReadableLabel,
|
|
960
|
+
Xr as get,
|
|
961
|
+
Ir as getDefaultValuesFromFormDefinition,
|
|
962
|
+
jr as getTemporaryPath,
|
|
963
|
+
Se as getTransformers,
|
|
964
|
+
ar as getValidationSchema,
|
|
965
|
+
lr as inputTransformValues,
|
|
918
966
|
Zr as isChildrenEmpty,
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
967
|
+
Pr as objectToArrayInputTransformer,
|
|
968
|
+
dr as outputTransformValues,
|
|
969
|
+
Rr as overrideFormDefinition,
|
|
970
|
+
A as processValidationParseResponse,
|
|
971
|
+
nr as removeTemporaryFieldsValue,
|
|
972
|
+
Yr as set,
|
|
973
|
+
Nr as shorthandArrayInputTransformer,
|
|
974
|
+
Br as shorthandArrayOutputTransformer,
|
|
975
|
+
Mr as shorthandObjectInputTransformer,
|
|
976
|
+
$r as shorthandObjectOutputTransformer,
|
|
977
|
+
Ar as unsetEmptyArrayOutputTransformer,
|
|
978
|
+
kr as unsetEmptyObjectOutputTransformer,
|
|
979
|
+
Dr as unsetEmptyStringOutputTransformer,
|
|
932
980
|
hr as unsetHiddenInputsValues,
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
981
|
+
Lr as useController,
|
|
982
|
+
zr as useFieldArray,
|
|
983
|
+
et as useForm,
|
|
984
|
+
rt as useFormContext,
|
|
985
|
+
tt as useFormState,
|
|
986
|
+
ze as useRootFormContext,
|
|
987
|
+
nt as useWatch,
|
|
940
988
|
wr as useZodValidationResolver
|
|
941
989
|
};
|
|
942
990
|
//# sourceMappingURL=index.js.map
|