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