@harnessio/forms 0.1.0 → 0.1.1
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 +2 -1
- package/dist/form/RenderInputs/RenderInputs.d.ts +2 -2
- package/dist/form/index.d.ts +0 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +259 -253
- package/dist/index.js.map +1 -1
- package/dist/types/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/form/Row/Row.d.ts +0 -8
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { isEmpty as j, cloneDeep as x, set as
|
|
5
|
-
import
|
|
6
|
-
import { useFormContext as
|
|
1
|
+
var ne = Object.defineProperty;
|
|
2
|
+
var se = (r, e, n) => e in r ? ne(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var q = (r, e, n) => se(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { isEmpty as j, cloneDeep as x, set as g, get as b, forOwn as G, isArray as E, isObject as H, merge as C, isUndefined as P, pick as ae, unset as ue, isNull as Q, omitBy as X, isNil as oe, isString as ie, capitalize as ce } from "lodash-es";
|
|
5
|
+
import fe, { createContext as de, useContext as le, useMemo as M, useRef as F, useEffect as S, useCallback as me, forwardRef as he, Fragment as pe } from "react";
|
|
6
|
+
import { useFormContext as ye, useForm as ge, FormProvider as be, appendErrors as ve } 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 _e } from "@hookform/resolvers";
|
|
10
|
+
class Ee extends Error {
|
|
11
11
|
constructor(e) {
|
|
12
12
|
super(`Input component '${e}' is already registered.`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
class Y {
|
|
16
16
|
constructor(e) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
q(this, "componentBank");
|
|
18
|
+
q(this, "allowOverride");
|
|
19
19
|
this.allowOverride = (e == null ? void 0 : e.allowOverride) ?? !1, this.componentBank = /* @__PURE__ */ new Map();
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -26,7 +26,7 @@ class Y {
|
|
|
26
26
|
*/
|
|
27
27
|
registerComponent(e) {
|
|
28
28
|
if (!this.allowOverride && this.getComponent(e.internalType))
|
|
29
|
-
throw new
|
|
29
|
+
throw new Ee(e.internalType);
|
|
30
30
|
this.componentBank.set(e.internalType, e);
|
|
31
31
|
}
|
|
32
32
|
getComponent(e) {
|
|
@@ -55,16 +55,16 @@ class Y {
|
|
|
55
55
|
}), e;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
var A = { exports: {} },
|
|
58
|
+
var A = { exports: {} }, _ = {};
|
|
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 N, B;
|
|
65
|
+
function Re() {
|
|
66
|
+
if (B) return N;
|
|
67
|
+
B = 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)
|
|
@@ -80,32 +80,32 @@ function Ee() {
|
|
|
80
80
|
return !1;
|
|
81
81
|
for (var o = {}, u = 0; u < 10; u++)
|
|
82
82
|
o["_" + String.fromCharCode(u)] = u;
|
|
83
|
-
var i = Object.getOwnPropertyNames(o).map(function(
|
|
84
|
-
return o[
|
|
83
|
+
var i = Object.getOwnPropertyNames(o).map(function(f) {
|
|
84
|
+
return o[f];
|
|
85
85
|
});
|
|
86
86
|
if (i.join("") !== "0123456789")
|
|
87
87
|
return !1;
|
|
88
88
|
var c = {};
|
|
89
|
-
return "abcdefghijklmnopqrst".split("").forEach(function(
|
|
90
|
-
c[
|
|
89
|
+
return "abcdefghijklmnopqrst".split("").forEach(function(f) {
|
|
90
|
+
c[f] = f;
|
|
91
91
|
}), Object.keys(Object.assign({}, c)).join("") === "abcdefghijklmnopqrst";
|
|
92
92
|
} catch {
|
|
93
93
|
return !1;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
return
|
|
97
|
-
for (var u, i = t(s), c,
|
|
98
|
-
u = Object(arguments[
|
|
99
|
-
for (var
|
|
100
|
-
e.call(u,
|
|
96
|
+
return N = a() ? Object.assign : function(s, o) {
|
|
97
|
+
for (var u, i = t(s), c, f = 1; f < arguments.length; f++) {
|
|
98
|
+
u = Object(arguments[f]);
|
|
99
|
+
for (var d in u)
|
|
100
|
+
e.call(u, d) && (i[d] = u[d]);
|
|
101
101
|
if (r) {
|
|
102
102
|
c = r(u);
|
|
103
|
-
for (var
|
|
104
|
-
n.call(u, c[
|
|
103
|
+
for (var l = 0; l < c.length; l++)
|
|
104
|
+
n.call(u, c[l]) && (i[c[l]] = u[c[l]]);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
return i;
|
|
108
|
-
},
|
|
108
|
+
}, N;
|
|
109
109
|
}
|
|
110
110
|
/** @license React v17.0.2
|
|
111
111
|
* react-jsx-runtime.production.min.js
|
|
@@ -115,32 +115,32 @@ function Ee() {
|
|
|
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 $;
|
|
119
|
+
function Oe() {
|
|
120
|
+
if ($) return _;
|
|
121
|
+
$ = 1, Re();
|
|
122
|
+
var r = fe, e = 60103;
|
|
123
|
+
if (_.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
|
|
124
124
|
var n = Symbol.for;
|
|
125
|
-
e = n("react.element"),
|
|
125
|
+
e = n("react.element"), _.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
128
|
function o(u, i, c) {
|
|
129
|
-
var
|
|
130
|
-
c !== void 0 && (
|
|
131
|
-
for (
|
|
132
|
-
if (u && u.defaultProps) for (
|
|
133
|
-
return { $$typeof: e, type: u, key:
|
|
129
|
+
var f, d = {}, l = null, p = null;
|
|
130
|
+
c !== void 0 && (l = "" + c), i.key !== void 0 && (l = "" + i.key), i.ref !== void 0 && (p = i.ref);
|
|
131
|
+
for (f in i) a.call(i, f) && !s.hasOwnProperty(f) && (d[f] = i[f]);
|
|
132
|
+
if (u && u.defaultProps) for (f in i = u.defaultProps, i) d[f] === void 0 && (d[f] = i[f]);
|
|
133
|
+
return { $$typeof: e, type: u, key: l, ref: p, props: d, _owner: t.current };
|
|
134
134
|
}
|
|
135
|
-
return
|
|
135
|
+
return _.jsx = o, _.jsxs = o, _;
|
|
136
136
|
}
|
|
137
137
|
var J;
|
|
138
|
-
function
|
|
139
|
-
return J || (J = 1, A.exports =
|
|
138
|
+
function Se() {
|
|
139
|
+
return J || (J = 1, A.exports = Oe()), A.exports;
|
|
140
140
|
}
|
|
141
|
-
var h =
|
|
142
|
-
const K =
|
|
143
|
-
function
|
|
141
|
+
var h = Se();
|
|
142
|
+
const K = de({});
|
|
143
|
+
function Te({ children: r, metadata: e }) {
|
|
144
144
|
return /* @__PURE__ */ h.jsx(
|
|
145
145
|
K.Provider,
|
|
146
146
|
{
|
|
@@ -151,23 +151,28 @@ function Se({ children: r, metadata: e }) {
|
|
|
151
151
|
}
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function je() {
|
|
155
155
|
const r = le(K);
|
|
156
156
|
return r || console.warn("useRootFormContext must be used within RootFormProvider"), r;
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
const L = ({
|
|
159
|
+
children: r,
|
|
160
|
+
withoutWrapper: e = !1
|
|
161
|
+
}) => e || !r ? r : /* @__PURE__ */ h.jsx("div", { children: r });
|
|
162
|
+
function Ie({
|
|
159
163
|
path: r,
|
|
160
164
|
factory: e,
|
|
161
165
|
onUpdate: n,
|
|
162
166
|
onChange: t,
|
|
163
167
|
readonly: a,
|
|
164
168
|
initialValues: s,
|
|
165
|
-
input: o
|
|
169
|
+
input: o,
|
|
170
|
+
withoutWrapper: u = !1
|
|
166
171
|
}) {
|
|
167
|
-
const { formState:
|
|
168
|
-
fixedValues:
|
|
172
|
+
const { formState: i, watch: c } = ye(), {
|
|
173
|
+
fixedValues: f = {}
|
|
169
174
|
/*getValuesWithDependencies*/
|
|
170
|
-
} = {}, { metadata:
|
|
175
|
+
} = {}, { metadata: d } = je(), l = e == null ? void 0 : e.getComponent(o.inputType), p = M(
|
|
171
176
|
() => ({
|
|
172
177
|
path: r,
|
|
173
178
|
initialValues: s,
|
|
@@ -177,29 +182,29 @@ function W({
|
|
|
177
182
|
readonly: a,
|
|
178
183
|
input: o
|
|
179
184
|
}),
|
|
180
|
-
[e, s, o, t, n, r, a,
|
|
181
|
-
),
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
+
[e, s, o, t, n, r, a, i.errors]
|
|
186
|
+
), R = c(), v = x(R);
|
|
187
|
+
f && Object.keys(f).forEach((y) => {
|
|
188
|
+
const te = f[y];
|
|
189
|
+
g(v, y, te);
|
|
185
190
|
});
|
|
186
|
-
const
|
|
191
|
+
const O = !o.isVisible || (o == null ? void 0 : o.isVisible(v, d)), I = M(() => O ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
|
|
187
192
|
o.before ? o.before : null,
|
|
188
|
-
|
|
193
|
+
l == null ? void 0 : l.renderComponent(p),
|
|
189
194
|
o.after ? o.after : null
|
|
190
|
-
] }) : null, [
|
|
191
|
-
return
|
|
195
|
+
] }) : null, [p, o.after, o.before, l, O, i.errors]);
|
|
196
|
+
return l ? /* @__PURE__ */ h.jsx(L, { withoutWrapper: u, children: I }) : /* @__PURE__ */ h.jsx(L, { withoutWrapper: u, children: /* @__PURE__ */ h.jsxs("p", { children: [
|
|
192
197
|
"Input component not found (internal type: ",
|
|
193
198
|
o.inputType,
|
|
194
199
|
")"
|
|
195
|
-
] });
|
|
200
|
+
] }) });
|
|
196
201
|
}
|
|
197
|
-
class
|
|
202
|
+
class Be {
|
|
198
203
|
getType() {
|
|
199
204
|
return this.internalType;
|
|
200
205
|
}
|
|
201
206
|
}
|
|
202
|
-
function
|
|
207
|
+
function $e(r) {
|
|
203
208
|
const {
|
|
204
209
|
mode: e = "onSubmit",
|
|
205
210
|
resolver: n,
|
|
@@ -215,19 +220,19 @@ function Me(r) {
|
|
|
215
220
|
metadata: i,
|
|
216
221
|
children: c,
|
|
217
222
|
// fixedValues
|
|
218
|
-
autoFocusPath:
|
|
219
|
-
} = r,
|
|
223
|
+
autoFocusPath: f
|
|
224
|
+
} = r, d = ge({
|
|
220
225
|
mode: e ?? "onSubmit",
|
|
221
226
|
reValidateMode: "onChange",
|
|
222
227
|
defaultValues: t,
|
|
223
228
|
shouldFocusError: a,
|
|
224
229
|
resolver: n
|
|
225
|
-
}),
|
|
230
|
+
}), l = F(!1);
|
|
226
231
|
S(() => {
|
|
227
|
-
|
|
228
|
-
}, [
|
|
229
|
-
const
|
|
230
|
-
|
|
232
|
+
d.reset(t, {});
|
|
233
|
+
}, [d.reset, t]), S(() => {
|
|
234
|
+
const y = requestIdleCallback(() => {
|
|
235
|
+
d.reset({}, {
|
|
231
236
|
keepErrors: !0,
|
|
232
237
|
keepDirty: !0,
|
|
233
238
|
keepDirtyValues: !0,
|
|
@@ -240,90 +245,90 @@ function Me(r) {
|
|
|
240
245
|
keepSubmitCount: !0
|
|
241
246
|
});
|
|
242
247
|
});
|
|
243
|
-
return () => cancelIdleCallback(
|
|
248
|
+
return () => cancelIdleCallback(y);
|
|
244
249
|
}, []);
|
|
245
|
-
const { getValues: p, handleSubmit:
|
|
250
|
+
const { getValues: p, handleSubmit: R } = d, v = p(), O = F(!0);
|
|
246
251
|
S(() => {
|
|
247
|
-
if (
|
|
248
|
-
|
|
252
|
+
if (O.current) {
|
|
253
|
+
O.current = !1;
|
|
249
254
|
return;
|
|
250
255
|
}
|
|
251
|
-
s == null || s({ ...
|
|
252
|
-
}, [JSON.stringify(
|
|
253
|
-
const
|
|
256
|
+
s == null || s({ ...v }), l.current === !0 && d.trigger();
|
|
257
|
+
}, [JSON.stringify(v)]);
|
|
258
|
+
const I = F(!0);
|
|
254
259
|
return S(() => {
|
|
255
|
-
if (
|
|
256
|
-
|
|
260
|
+
if (I.current) {
|
|
261
|
+
I.current = !1;
|
|
257
262
|
return;
|
|
258
263
|
}
|
|
259
|
-
o == null || o({ isValid:
|
|
260
|
-
}, [
|
|
261
|
-
if (
|
|
264
|
+
o == null || o({ isValid: d.formState.isValid, isSubmitted: d.formState.isSubmitted });
|
|
265
|
+
}, [d.formState.isValid, d.formState.isSubmitted]), S(() => {
|
|
266
|
+
if (f)
|
|
262
267
|
if ("requestIdleCallback" in window) {
|
|
263
|
-
const
|
|
264
|
-
|
|
268
|
+
const y = requestIdleCallback(() => {
|
|
269
|
+
d.setFocus(f);
|
|
265
270
|
});
|
|
266
|
-
return () => cancelIdleCallback(
|
|
271
|
+
return () => cancelIdleCallback(y);
|
|
267
272
|
} else {
|
|
268
|
-
const
|
|
269
|
-
|
|
273
|
+
const y = setTimeout(() => {
|
|
274
|
+
d.setFocus(f);
|
|
270
275
|
}, 100);
|
|
271
|
-
return () => clearTimeout(
|
|
276
|
+
return () => clearTimeout(y);
|
|
272
277
|
}
|
|
273
|
-
}, [
|
|
274
|
-
...
|
|
278
|
+
}, [d]), /* @__PURE__ */ h.jsx(Te, { metadata: i, children: /* @__PURE__ */ h.jsx(be, { ...d, children: typeof c == "function" ? c({
|
|
279
|
+
...d,
|
|
275
280
|
submitForm: async () => {
|
|
276
|
-
u && (
|
|
277
|
-
u(
|
|
281
|
+
u && (l.current = !0, R((y) => {
|
|
282
|
+
u(y);
|
|
278
283
|
})());
|
|
279
284
|
}
|
|
280
285
|
}) : c }) });
|
|
281
286
|
}
|
|
282
|
-
const
|
|
287
|
+
const Je = (r) => {
|
|
283
288
|
const e = {}, n = (t) => {
|
|
284
289
|
t.forEach((a) => {
|
|
285
290
|
const { path: s, default: o, inputType: u, inputs: i } = a;
|
|
286
|
-
(u === "group" || u === "accordion") && Array.isArray(i) ? n(i) :
|
|
291
|
+
(u === "group" || u === "accordion") && Array.isArray(i) ? n(i) : b(e, s) === void 0 && g(e, s, o);
|
|
287
292
|
});
|
|
288
293
|
};
|
|
289
294
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
290
295
|
};
|
|
291
|
-
function
|
|
296
|
+
function Le(r, e) {
|
|
292
297
|
const n = r.inputs.map((t) => {
|
|
293
|
-
const a =
|
|
298
|
+
const a = Ce(e, t.path);
|
|
294
299
|
return a || t;
|
|
295
300
|
});
|
|
296
301
|
return { ...r, inputs: n };
|
|
297
302
|
}
|
|
298
|
-
function
|
|
303
|
+
function Ce(r, e) {
|
|
299
304
|
return r.inputs.find((n) => n.path === e);
|
|
300
305
|
}
|
|
301
|
-
const z = "__temp_",
|
|
302
|
-
function
|
|
306
|
+
const z = "__temp_", Ue = (r) => z + r.split(".").join("__");
|
|
307
|
+
function We(r) {
|
|
303
308
|
const e = { ...r };
|
|
304
309
|
return G(e, (n, t) => {
|
|
305
310
|
t.startsWith(z) && delete e[t];
|
|
306
311
|
}), e;
|
|
307
312
|
}
|
|
308
|
-
const
|
|
313
|
+
const Ve = "Required field";
|
|
309
314
|
function T(r) {
|
|
310
315
|
const e = typeof r == "string" ? JSON.parse(r) : r;
|
|
311
316
|
if (typeof e == "string")
|
|
312
317
|
return e;
|
|
313
|
-
if (
|
|
318
|
+
if (E(e))
|
|
314
319
|
return T(e[0]);
|
|
315
320
|
const n = e;
|
|
316
321
|
return H(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
|
|
317
322
|
}
|
|
318
|
-
function
|
|
323
|
+
function we(r, e, n) {
|
|
319
324
|
let t = {};
|
|
320
|
-
if (
|
|
325
|
+
if (w(t, r.inputs, e, n), n != null && n.prefix) {
|
|
321
326
|
const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
|
|
322
|
-
t =
|
|
327
|
+
t = g({}, s, t);
|
|
323
328
|
}
|
|
324
|
-
return m.object(
|
|
329
|
+
return m.object(V(t, e, n));
|
|
325
330
|
}
|
|
326
|
-
function
|
|
331
|
+
function V(r, e, n) {
|
|
327
332
|
const t = {};
|
|
328
333
|
return Object.keys(r).forEach((a) => {
|
|
329
334
|
const {
|
|
@@ -332,28 +337,28 @@ function w(r, e, n) {
|
|
|
332
337
|
_input: u,
|
|
333
338
|
_isList: i,
|
|
334
339
|
_isArrayItem: c,
|
|
335
|
-
_schema:
|
|
340
|
+
_schema: f
|
|
336
341
|
/*...nestedSchemaObj*/
|
|
337
342
|
} = r[a];
|
|
338
343
|
if (i && o && u) {
|
|
339
|
-
const
|
|
340
|
-
t[a] =
|
|
344
|
+
const d = m.array(m.object(V(o, e, n))).optional(), l = U(f, u, e, n, d);
|
|
345
|
+
t[a] = l;
|
|
341
346
|
} else if (c && u) {
|
|
342
|
-
const
|
|
347
|
+
const d = o != null && o.___array ? V({ ___array: o.___array }, e, n) : { ___array: m.any() }, l = m.array(d.___array).optional(), p = U(f, u, e, n, l);
|
|
343
348
|
t[a] = p;
|
|
344
|
-
} else if (
|
|
345
|
-
const
|
|
346
|
-
t[a] =
|
|
347
|
-
} else s && u ? t[a] =
|
|
349
|
+
} else if (f && u) {
|
|
350
|
+
const d = xe(f, u, e, n);
|
|
351
|
+
t[a] = d;
|
|
352
|
+
} else s && u ? t[a] = D(u, n) : t[a] = m.object(V(r[a], e, n)).optional();
|
|
348
353
|
}), t;
|
|
349
354
|
}
|
|
350
|
-
function
|
|
355
|
+
function xe(r, e, n, t) {
|
|
351
356
|
return m.any().optional().superRefine(async (a, s) => {
|
|
352
357
|
var u, i;
|
|
353
|
-
if (e.required && !(await
|
|
358
|
+
if (e.required && !(await D(e, t).safeParseAsync(a)).success)
|
|
354
359
|
return s.addIssue({
|
|
355
360
|
code: m.ZodIssueCode.custom,
|
|
356
|
-
message:
|
|
361
|
+
message: k(e, t)
|
|
357
362
|
}), m.NEVER;
|
|
358
363
|
if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
|
|
359
364
|
const c = (i = t == null ? void 0 : t.validationConfig) == null ? void 0 : i.globalValidation(a, e, t.metadata);
|
|
@@ -369,91 +374,91 @@ function we(r, e, n, t) {
|
|
|
369
374
|
if (o) {
|
|
370
375
|
const c = await o.safeParseAsync(a);
|
|
371
376
|
if (!c.success) {
|
|
372
|
-
const
|
|
377
|
+
const f = T(c == null ? void 0 : c.error.message), d = f === "Required" ? k(e, t) : f;
|
|
373
378
|
s.addIssue({
|
|
374
379
|
code: m.ZodIssueCode.custom,
|
|
375
|
-
message:
|
|
380
|
+
message: d
|
|
376
381
|
});
|
|
377
382
|
}
|
|
378
383
|
}
|
|
379
384
|
});
|
|
380
385
|
}
|
|
381
|
-
function
|
|
386
|
+
function U(r, e, n, t, a) {
|
|
382
387
|
return m.any().optional().superRefine(async (s, o) => {
|
|
383
|
-
var
|
|
384
|
-
const i = await
|
|
388
|
+
var f, d;
|
|
389
|
+
const i = await D(e, t).safeParseAsync(s);
|
|
385
390
|
if (e.required && !i.success) {
|
|
386
|
-
const
|
|
387
|
-
return o.addIssue({ code: m.ZodIssueCode.custom, message:
|
|
391
|
+
const l = T(i.error.message);
|
|
392
|
+
return o.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
|
|
388
393
|
}
|
|
389
394
|
if (!e.required && !i.success)
|
|
390
395
|
return m.NEVER;
|
|
391
|
-
if ((
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
396
|
+
if ((f = t == null ? void 0 : t.validationConfig) != null && f.globalValidation) {
|
|
397
|
+
const l = (d = t == null ? void 0 : t.validationConfig) == null ? void 0 : d.globalValidation(s, e, t.metadata);
|
|
398
|
+
if (l.error)
|
|
394
399
|
return o.addIssue({
|
|
395
400
|
code: m.ZodIssueCode.custom,
|
|
396
|
-
message: T(
|
|
401
|
+
message: T(l.error)
|
|
397
402
|
}), m.NEVER;
|
|
398
|
-
if (!
|
|
403
|
+
if (!l.continue)
|
|
399
404
|
return m.NEVER;
|
|
400
405
|
}
|
|
401
|
-
if (!
|
|
406
|
+
if (!E(s))
|
|
402
407
|
return o.addIssue({
|
|
403
408
|
code: m.ZodIssueCode.custom,
|
|
404
409
|
message: "'Value is not array'"
|
|
405
410
|
}), m.NEVER;
|
|
406
411
|
const c = ee(r, n);
|
|
407
412
|
if (c) {
|
|
408
|
-
const
|
|
409
|
-
if (!
|
|
413
|
+
const l = await c.safeParseAsync(s);
|
|
414
|
+
if (!l.success)
|
|
410
415
|
return o.addIssue({
|
|
411
416
|
code: m.ZodIssueCode.custom,
|
|
412
|
-
message: T(
|
|
417
|
+
message: T(l.error.message)
|
|
413
418
|
}), m.NEVER;
|
|
414
419
|
}
|
|
415
420
|
}).pipe(a ?? m.any());
|
|
416
421
|
}
|
|
417
|
-
function
|
|
422
|
+
function w(r, e, n, t, a) {
|
|
418
423
|
e.forEach((s) => {
|
|
419
|
-
var u, i, c,
|
|
424
|
+
var u, i, c, f, d;
|
|
420
425
|
const o = n;
|
|
421
426
|
if (!s.isVisible || (u = s.isVisible) != null && u.call(s, o, t == null ? void 0 : t.metadata)) {
|
|
422
|
-
const
|
|
423
|
-
if ((i = s.validation) != null && i.schema ?
|
|
427
|
+
const l = b(r, s.path);
|
|
428
|
+
if ((i = s.validation) != null && i.schema ? g(
|
|
424
429
|
r,
|
|
425
430
|
s.path,
|
|
426
|
-
C(
|
|
431
|
+
C(l, {
|
|
427
432
|
_schema: (c = s.validation) == null ? void 0 : c.schema,
|
|
428
433
|
_input: s
|
|
429
434
|
})
|
|
430
|
-
) : s.required &&
|
|
435
|
+
) : s.required && g(r, s.path, C(l, { _requiredOnly: !0, _input: s })), s.inputs && w(r, s.inputs, n, t), s.inputType === "list") {
|
|
431
436
|
const p = {};
|
|
432
|
-
|
|
437
|
+
w(
|
|
433
438
|
p,
|
|
434
|
-
s.inputConfig.inputs.map((
|
|
435
|
-
...
|
|
436
|
-
path:
|
|
439
|
+
s.inputConfig.inputs.map((v) => ({
|
|
440
|
+
...v,
|
|
441
|
+
path: v.relativePath
|
|
437
442
|
})),
|
|
438
443
|
n,
|
|
439
444
|
t
|
|
440
445
|
);
|
|
441
|
-
const
|
|
442
|
-
|
|
446
|
+
const R = b(r, s.path);
|
|
447
|
+
g(r, s.path, C(R, { _schemaObj: p, _isList: !0, _input: s }));
|
|
443
448
|
}
|
|
444
|
-
if (!((
|
|
449
|
+
if (!((f = s.validation) != null && f.schema) && s.inputType === "array") {
|
|
445
450
|
const p = {};
|
|
446
|
-
|
|
451
|
+
w(
|
|
447
452
|
p,
|
|
448
453
|
[{ ...s.inputConfig.input, path: "___array" }],
|
|
449
454
|
n,
|
|
450
455
|
t
|
|
451
|
-
),
|
|
456
|
+
), g(
|
|
452
457
|
r,
|
|
453
458
|
s.path,
|
|
454
|
-
C(
|
|
459
|
+
C(l, {
|
|
455
460
|
_schemaObj: p,
|
|
456
|
-
_schema: (
|
|
461
|
+
_schema: (d = s.validation) == null ? void 0 : d.schema,
|
|
457
462
|
_isArrayItem: !0,
|
|
458
463
|
_input: s
|
|
459
464
|
})
|
|
@@ -462,22 +467,22 @@ function V(r, e, n, t, a) {
|
|
|
462
467
|
}
|
|
463
468
|
});
|
|
464
469
|
}
|
|
465
|
-
function
|
|
470
|
+
function k(r, e) {
|
|
466
471
|
var n, t, a;
|
|
467
|
-
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) ??
|
|
472
|
+
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) ?? Ve;
|
|
468
473
|
}
|
|
469
|
-
function
|
|
474
|
+
function D(r, e) {
|
|
470
475
|
var t, a, s, o, u, i;
|
|
471
476
|
if ((a = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && a[r.inputType])
|
|
472
477
|
return (o = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : o[r.inputType];
|
|
473
478
|
if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
|
|
474
479
|
return (i = e == null ? void 0 : e.validationConfig) == null ? void 0 : i.requiredSchema;
|
|
475
|
-
const n =
|
|
476
|
-
return m.any().optional().superRefine((c,
|
|
477
|
-
typeof c == "object" && j(c) &&
|
|
480
|
+
const n = k(r, e);
|
|
481
|
+
return m.any().optional().superRefine((c, f) => {
|
|
482
|
+
typeof c == "object" && j(c) && f.addIssue({
|
|
478
483
|
code: m.ZodIssueCode.custom,
|
|
479
484
|
message: n
|
|
480
|
-
}), (
|
|
485
|
+
}), (P(c) || c === "") && f.addIssue({
|
|
481
486
|
code: m.ZodIssueCode.custom,
|
|
482
487
|
message: n
|
|
483
488
|
});
|
|
@@ -489,7 +494,7 @@ function ee(r, e) {
|
|
|
489
494
|
if (typeof r == "function")
|
|
490
495
|
return r(e);
|
|
491
496
|
}
|
|
492
|
-
const
|
|
497
|
+
const Pe = (r) => Array.isArray(r == null ? void 0 : r.errors), qe = (r, e) => {
|
|
493
498
|
const n = {};
|
|
494
499
|
for (; r.length; ) {
|
|
495
500
|
const t = r[0], { code: a, message: s, path: o } = t, u = o.join(".");
|
|
@@ -505,7 +510,7 @@ const Ve = (r) => Array.isArray(r == null ? void 0 : r.errors), xe = (r, e) => {
|
|
|
505
510
|
"unionErrors" in t && t.unionErrors.forEach((i) => i.errors.forEach((c) => r.push(c)));
|
|
506
511
|
{
|
|
507
512
|
const i = n[u].types, c = i && i[t.code];
|
|
508
|
-
n[u] =
|
|
513
|
+
n[u] = ve(
|
|
509
514
|
u,
|
|
510
515
|
e,
|
|
511
516
|
n,
|
|
@@ -517,20 +522,20 @@ const Ve = (r) => Array.isArray(r == null ? void 0 : r.errors), xe = (r, e) => {
|
|
|
517
522
|
}
|
|
518
523
|
return n;
|
|
519
524
|
};
|
|
520
|
-
function
|
|
521
|
-
return
|
|
525
|
+
function Ge(r, e) {
|
|
526
|
+
return me(
|
|
522
527
|
async (n, t, a) => {
|
|
523
528
|
try {
|
|
524
|
-
return await
|
|
529
|
+
return await we(r, n, e).parseAsync(n), {
|
|
525
530
|
values: n,
|
|
526
531
|
// TODO: check this - values does not contains all data
|
|
527
532
|
errors: {}
|
|
528
533
|
};
|
|
529
534
|
} catch (s) {
|
|
530
|
-
if (
|
|
535
|
+
if (Pe(s))
|
|
531
536
|
return {
|
|
532
537
|
values: {},
|
|
533
|
-
errors:
|
|
538
|
+
errors: _e(qe(s.errors, !0), a)
|
|
534
539
|
};
|
|
535
540
|
throw s;
|
|
536
541
|
}
|
|
@@ -538,54 +543,54 @@ function Ue(r, e) {
|
|
|
538
543
|
[r]
|
|
539
544
|
);
|
|
540
545
|
}
|
|
541
|
-
function
|
|
546
|
+
function He(r, e) {
|
|
542
547
|
const n = x(r);
|
|
543
548
|
return e.forEach((t) => {
|
|
544
|
-
t.inputTransform && (
|
|
545
|
-
const o =
|
|
546
|
-
u &&
|
|
549
|
+
t.inputTransform && (E(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
|
|
550
|
+
const o = b(n, t.path), u = s(o, n);
|
|
551
|
+
u && g(n, u.path ?? t.path, u.value);
|
|
547
552
|
});
|
|
548
553
|
}), n;
|
|
549
554
|
}
|
|
550
|
-
function
|
|
555
|
+
function Qe(r, e) {
|
|
551
556
|
const n = x(r);
|
|
552
557
|
return e.forEach((t) => {
|
|
553
|
-
t.outputTransform && (
|
|
554
|
-
const o =
|
|
555
|
-
u &&
|
|
558
|
+
t.outputTransform && (E(t.outputTransform) ? t.outputTransform : [t.outputTransform]).forEach((s) => {
|
|
559
|
+
const o = b(n, t.path), u = s(o, n);
|
|
560
|
+
u && g(n, u.path ?? t.path, u.value);
|
|
556
561
|
});
|
|
557
562
|
}), n;
|
|
558
563
|
}
|
|
559
|
-
function
|
|
560
|
-
return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...
|
|
564
|
+
function Z(r) {
|
|
565
|
+
return r.reduce((n, t) => (t.inputType === "group" || t.inputType === "accordion") && t.inputs ? [...n, t, ...Z(t.inputs)] : [...n, t], []);
|
|
561
566
|
}
|
|
562
|
-
function
|
|
563
|
-
const n =
|
|
567
|
+
function Xe(r) {
|
|
568
|
+
const n = Z(r.inputs).reduce((t, a) => {
|
|
564
569
|
const s = a.inputType === "text" || a.inputType === "boolean" || a.inputType === "number" || a.inputType === "textarea" || a.inputType === "select";
|
|
565
570
|
return (a.inputTransform || a.outputTransform) && t.push({
|
|
566
|
-
...
|
|
571
|
+
...ae(a, "path", "inputTransform", "outputTransform"),
|
|
567
572
|
level: a.path.split(".").length,
|
|
568
573
|
isPrimitive: s
|
|
569
574
|
}), t;
|
|
570
575
|
}, []);
|
|
571
576
|
return n.sort((t, a) => t.level === a.level ? t.isPrimitive ? 1 : -1 : t.level > a.level ? -1 : 1), n;
|
|
572
577
|
}
|
|
573
|
-
function
|
|
574
|
-
const t =
|
|
578
|
+
function Ye(r, e, n) {
|
|
579
|
+
const t = Z(r.inputs), a = x(e);
|
|
575
580
|
return t.forEach((s) => {
|
|
576
|
-
s.isVisible && !s.isVisible(e, n) &&
|
|
581
|
+
s.isVisible && !s.isVisible(e, n) && ue(a, s.path);
|
|
577
582
|
}), a;
|
|
578
583
|
}
|
|
579
|
-
function
|
|
584
|
+
function Ke(r) {
|
|
580
585
|
const e = {}, n = (t) => {
|
|
581
586
|
t.forEach((a) => {
|
|
582
587
|
const { default: s, path: o, inputType: u, inputs: i } = a;
|
|
583
|
-
(u === "group" || u === "accordion") && Array.isArray(i) ? n(i) : s !== void 0 &&
|
|
588
|
+
(u === "group" || u === "accordion") && Array.isArray(i) ? n(i) : s !== void 0 && g(e, o, s);
|
|
584
589
|
});
|
|
585
590
|
};
|
|
586
591
|
return Array.isArray(r.inputs) && n(r.inputs), e;
|
|
587
592
|
}
|
|
588
|
-
function
|
|
593
|
+
function ze() {
|
|
589
594
|
return function(r, e) {
|
|
590
595
|
if (!(typeof r > "u"))
|
|
591
596
|
return r ? {
|
|
@@ -593,7 +598,7 @@ function Ke() {
|
|
|
593
598
|
} : { value: r };
|
|
594
599
|
};
|
|
595
600
|
}
|
|
596
|
-
function
|
|
601
|
+
function er(r) {
|
|
597
602
|
return function(e, n) {
|
|
598
603
|
if (typeof e > "u") return;
|
|
599
604
|
if (!e) return { value: e };
|
|
@@ -603,19 +608,19 @@ function ze(r) {
|
|
|
603
608
|
return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
|
|
604
609
|
};
|
|
605
610
|
}
|
|
606
|
-
function
|
|
611
|
+
function rr() {
|
|
607
612
|
return function(r, e) {
|
|
608
613
|
if (!(typeof r > "u"))
|
|
609
|
-
return
|
|
614
|
+
return E(r) && j(r) ? { value: void 0 } : { value: r };
|
|
610
615
|
};
|
|
611
616
|
}
|
|
612
|
-
function
|
|
617
|
+
function tr(r) {
|
|
613
618
|
return function(e, n) {
|
|
614
|
-
const t = r ?
|
|
619
|
+
const t = r ? b(n, r) : e;
|
|
615
620
|
if (!(typeof t > "u")) {
|
|
616
621
|
if (Q(t)) return { value: void 0, path: r };
|
|
617
622
|
if (H(t)) {
|
|
618
|
-
const a = X(t,
|
|
623
|
+
const a = X(t, oe);
|
|
619
624
|
if (j(a))
|
|
620
625
|
return { value: void 0, path: r };
|
|
621
626
|
}
|
|
@@ -623,44 +628,44 @@ function rr(r) {
|
|
|
623
628
|
}
|
|
624
629
|
};
|
|
625
630
|
}
|
|
626
|
-
function
|
|
631
|
+
function nr() {
|
|
627
632
|
return function(r, e) {
|
|
628
633
|
if (!(typeof r > "u"))
|
|
629
|
-
return
|
|
634
|
+
return ie(r) && j(r) ? { value: void 0 } : { value: r };
|
|
630
635
|
};
|
|
631
636
|
}
|
|
632
|
-
function
|
|
637
|
+
function sr(r) {
|
|
633
638
|
return function(e, n) {
|
|
634
|
-
const t =
|
|
639
|
+
const t = b(n, r);
|
|
635
640
|
return typeof t == "string" ? { value: t } : { value: e };
|
|
636
641
|
};
|
|
637
642
|
}
|
|
638
|
-
function
|
|
643
|
+
function ar(r) {
|
|
639
644
|
return function(e, n) {
|
|
640
645
|
if (typeof e > "u") return;
|
|
641
646
|
if (!e) return { value: e };
|
|
642
|
-
const t =
|
|
647
|
+
const t = b(n, r);
|
|
643
648
|
if (typeof t == "object") {
|
|
644
|
-
const a =
|
|
649
|
+
const a = Fe(t);
|
|
645
650
|
if (Object.getOwnPropertyNames(a).length === 1)
|
|
646
651
|
return { value: e, path: r };
|
|
647
652
|
}
|
|
648
653
|
return { value: e };
|
|
649
654
|
};
|
|
650
655
|
}
|
|
651
|
-
function
|
|
656
|
+
function ur(r) {
|
|
652
657
|
return function(e, n) {
|
|
653
658
|
if (typeof e > "u") return;
|
|
654
|
-
const t =
|
|
659
|
+
const t = b(n, r);
|
|
655
660
|
return typeof t == "string" ? { value: [t] } : { value: e };
|
|
656
661
|
};
|
|
657
662
|
}
|
|
658
|
-
function
|
|
663
|
+
function or(r, e) {
|
|
659
664
|
return function(n, t) {
|
|
660
665
|
if (typeof n > "u") return;
|
|
661
666
|
if (!n) return { value: n };
|
|
662
|
-
const a =
|
|
663
|
-
if (
|
|
667
|
+
const a = b(t, r);
|
|
668
|
+
if (E(a)) {
|
|
664
669
|
if (a.length === 1)
|
|
665
670
|
return { value: a[0], path: r };
|
|
666
671
|
if (a.length === 0 && e != null && e.unsetIfEmpty)
|
|
@@ -670,72 +675,73 @@ function ur(r, e) {
|
|
|
670
675
|
};
|
|
671
676
|
}
|
|
672
677
|
function re(r) {
|
|
673
|
-
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !re(r[e])) :
|
|
678
|
+
return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !re(r[e])) : P(r);
|
|
674
679
|
}
|
|
675
|
-
function
|
|
676
|
-
return X(r, (e) => typeof e == "object" ? re(e) :
|
|
680
|
+
function Fe(r) {
|
|
681
|
+
return X(r, (e) => typeof e == "object" ? re(e) : P(e));
|
|
677
682
|
}
|
|
678
|
-
function
|
|
679
|
-
const {
|
|
680
|
-
return
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
683
|
+
function W(r) {
|
|
684
|
+
const { items: e, ...n } = r;
|
|
685
|
+
return /* @__PURE__ */ h.jsx(h.Fragment, { children: e.map((t) => /* @__PURE__ */ h.jsx(
|
|
686
|
+
Ie,
|
|
687
|
+
{
|
|
688
|
+
input: t,
|
|
689
|
+
path: t.path,
|
|
690
|
+
readonly: !1,
|
|
691
|
+
...n
|
|
692
|
+
},
|
|
693
|
+
`${t.inputType}_${t.path}_${t.label}`
|
|
694
|
+
)) });
|
|
688
695
|
}
|
|
689
|
-
const
|
|
696
|
+
const Ae = he((r, e) => {
|
|
690
697
|
const { inputs: n, className: t, factory: a, withoutWrapper: s } = r;
|
|
691
|
-
return s ? /* @__PURE__ */ h.jsxs(
|
|
698
|
+
return s ? /* @__PURE__ */ h.jsxs(pe, { children: [
|
|
692
699
|
n.hero,
|
|
693
|
-
/* @__PURE__ */ h.jsx(
|
|
700
|
+
/* @__PURE__ */ h.jsx(W, { items: n.inputs, factory: a, withoutWrapper: s })
|
|
694
701
|
] }) : /* @__PURE__ */ h.jsxs("div", { className: t, ref: e, children: [
|
|
695
702
|
n.hero,
|
|
696
|
-
/* @__PURE__ */ h.jsx(
|
|
703
|
+
/* @__PURE__ */ h.jsx(W, { items: n.inputs, factory: a, withoutWrapper: s })
|
|
697
704
|
] });
|
|
698
705
|
});
|
|
699
|
-
|
|
700
|
-
function
|
|
706
|
+
Ae.displayName = "RenderForm";
|
|
707
|
+
function ir(r) {
|
|
701
708
|
let e = !0;
|
|
702
709
|
return G(r, (n) => {
|
|
703
|
-
e = e && (n === "" || Q(n) ||
|
|
710
|
+
e = e && (n === "" || Q(n) || P(n));
|
|
704
711
|
}), e;
|
|
705
712
|
}
|
|
706
|
-
const
|
|
713
|
+
const cr = (r = "") => ce(r.split("_").join(" "));
|
|
707
714
|
export {
|
|
708
|
-
|
|
709
|
-
|
|
715
|
+
Be as InputComponent,
|
|
716
|
+
Ie as InputComponentRenderer,
|
|
710
717
|
Y as InputFactory,
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
Je as overrideFormDefinition,
|
|
718
|
+
Ee as InputOverrideError,
|
|
719
|
+
Ae as RenderForm,
|
|
720
|
+
W as RenderInputs,
|
|
721
|
+
$e as RootForm,
|
|
722
|
+
er as arrayToObjectOutputTransformer,
|
|
723
|
+
Ke as collectDefaultValues,
|
|
724
|
+
cr as generateReadableLabel,
|
|
725
|
+
Je as getDefaultValuesFromFormDefinition,
|
|
726
|
+
Ue as getTemporaryPath,
|
|
727
|
+
Xe as getTransformers,
|
|
728
|
+
we as getValidationSchema,
|
|
729
|
+
He as inputTransformValues,
|
|
730
|
+
ir as isChildrenEmpty,
|
|
731
|
+
ze as objectToArrayInputTransformer,
|
|
732
|
+
Qe as outputTransformValues,
|
|
733
|
+
Le as overrideFormDefinition,
|
|
728
734
|
T as processValidationParseResponse,
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
735
|
+
We as removeTemporaryFieldsValue,
|
|
736
|
+
ur as shorthandArrayInputTransformer,
|
|
737
|
+
or as shorthandArrayOutputTransformer,
|
|
738
|
+
sr as shorthandObjectInputTransformer,
|
|
739
|
+
ar as shorthandObjectOutputTransformer,
|
|
740
|
+
rr as unsetEmptyArrayOutputTransformer,
|
|
741
|
+
tr as unsetEmptyObjectOutputTransformer,
|
|
742
|
+
nr as unsetEmptyStringOutputTransformer,
|
|
743
|
+
Ye as unsetHiddenInputsValues,
|
|
744
|
+
je as useRootFormContext,
|
|
745
|
+
Ge as useZodValidationResolver
|
|
740
746
|
};
|
|
741
747
|
//# sourceMappingURL=index.js.map
|