treege 3.0.0-beta.94 → 3.0.0-beta.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -22
- package/dist/DefaultSubmitButton-D4Hqyara.js +5130 -0
- package/dist/{ThemeContext-CE3SE9DG.js → ThemeContext-CDewydK5.js} +94 -70
- package/dist/{editor-mvGEgr3P.js → editor-BzhBNy8O.js} +1521 -1521
- package/dist/editor.js +2 -2
- package/dist/main.js +6 -6
- package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +3 -2
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +8 -1
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultStep.d.ts +1 -1
- package/dist/renderer/hooks/useRenderNode.d.ts +7 -1
- package/dist/renderer/types/renderer.d.ts +19 -1
- package/dist/renderer/utils/dateLocale.d.ts +6 -0
- package/dist/renderer/utils/step.d.ts +9 -0
- package/dist/renderer-Cd2P21x9.js +437 -0
- package/dist/renderer-native.js +646 -661
- package/dist/renderer.js +5 -5
- package/dist/useRenderNode-BaBKq6Ed.js +600 -0
- package/package.json +1 -1
- package/dist/DefaultSubmitButton-DNVIV9BO.js +0 -1909
- package/dist/renderer-CfoZiy7J.js +0 -449
- package/dist/useRenderNode-BPgpYSyg.js +0 -538
|
@@ -1,538 +0,0 @@
|
|
|
1
|
-
import { A as e, C as t, F as n, H as r, I as i, M as a, N as o, O as s, U as c, X as l, Y as u, Z as d, a as f, c as p, d as m, f as h, i as g, j as _, k as v, l as ee, o as y, p as b, q as x, s as S, u as C } from "./ThemeContext-CE3SE9DG.js";
|
|
2
|
-
import { Fragment as w, createContext as T, useCallback as E, useContext as D, useEffect as O, useMemo as k, useRef as A, useState as j } from "react";
|
|
3
|
-
import { jsx as M } from "react/jsx-runtime";
|
|
4
|
-
//#region src/renderer/context/TreegeRendererProvider.tsx
|
|
5
|
-
var N = T(void 0), te = () => D(N), P = ({ children: e, ...t }) => /* @__PURE__ */ M(N.Provider, {
|
|
6
|
-
value: t,
|
|
7
|
-
children: e
|
|
8
|
-
}), ne = (e, t, n) => {
|
|
9
|
-
if (!t) return e;
|
|
10
|
-
let r = typeof t == "function" ? t(n) : t;
|
|
11
|
-
return !r || typeof r != "object" || Array.isArray(r) ? e : e == null ? r : typeof e != "object" || Array.isArray(e) ? e : {
|
|
12
|
-
...e,
|
|
13
|
-
...r
|
|
14
|
-
};
|
|
15
|
-
}, F = async (n, r, i, c, l, u) => {
|
|
16
|
-
if (!n.url || n.url.trim() === "") return {
|
|
17
|
-
error: "No URL configured for submission",
|
|
18
|
-
success: !1
|
|
19
|
-
};
|
|
20
|
-
let d = o(_(n.url, r, { encode: !0 }), l);
|
|
21
|
-
if (!d || d.trim() === "") return {
|
|
22
|
-
error: "Invalid URL after template replacement",
|
|
23
|
-
success: !1
|
|
24
|
-
};
|
|
25
|
-
let f = S(r, i), p = n.payloadTemplate ? t(n.payloadTemplate, r, i) : void 0, m = ne(p === void 0 ? n.sendAllFormValues ? f : void 0 : p, u, f), h = await s({
|
|
26
|
-
body: m === void 0 ? void 0 : JSON.stringify(m),
|
|
27
|
-
headers: v(a(c, r), a(n.headers, r)),
|
|
28
|
-
method: n.method || "POST",
|
|
29
|
-
queryParams: a(n.queryParams, r),
|
|
30
|
-
url: d
|
|
31
|
-
});
|
|
32
|
-
if (!h.success) return {
|
|
33
|
-
data: h.data,
|
|
34
|
-
error: h.error,
|
|
35
|
-
success: !1
|
|
36
|
-
};
|
|
37
|
-
let g = n.redirectUrl ? (() => {
|
|
38
|
-
let t = e(n.redirectUrl, h.data);
|
|
39
|
-
return t && t.trim() !== "" ? t : void 0;
|
|
40
|
-
})() : void 0;
|
|
41
|
-
return {
|
|
42
|
-
data: h.data,
|
|
43
|
-
redirectUrl: g,
|
|
44
|
-
success: !0
|
|
45
|
-
};
|
|
46
|
-
}, I = (e) => {
|
|
47
|
-
e && (typeof window > "u" || !window.location || (e.startsWith("http://") || e.startsWith("https://") ? window.location.href = e : window.history?.pushState ? (window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"))) : window.location.href = e));
|
|
48
|
-
}, re = (e, t, n, r, i, a, o) => {
|
|
49
|
-
let [s, c] = j(!1), [u, d] = j(null), f = k(() => {
|
|
50
|
-
let t = e.find((e) => l(e) && e.data?.type === "submit");
|
|
51
|
-
return t && l(t) ? t : null;
|
|
52
|
-
}, [e]), p = E(async (e) => {
|
|
53
|
-
if (!f?.data?.submitConfig) return null;
|
|
54
|
-
let s = f.data.submitConfig;
|
|
55
|
-
if (!s.url || s.url.trim() === "") return null;
|
|
56
|
-
d(null), s.showLoading !== !1 && c(!0);
|
|
57
|
-
try {
|
|
58
|
-
let c = await F(s, t, r, i, a, o);
|
|
59
|
-
if (c.success) {
|
|
60
|
-
let t = x(s.successMessage, n);
|
|
61
|
-
if (t && d({
|
|
62
|
-
message: t,
|
|
63
|
-
type: "success"
|
|
64
|
-
}), e && e(c.data), c.redirectUrl) {
|
|
65
|
-
let e = c.redirectUrl;
|
|
66
|
-
setTimeout(() => I(e), 1e3);
|
|
67
|
-
}
|
|
68
|
-
} else d({
|
|
69
|
-
message: x(s.errorMessage, n) || c.error || "An error occurred during submission",
|
|
70
|
-
type: "error"
|
|
71
|
-
});
|
|
72
|
-
return c;
|
|
73
|
-
} catch (e) {
|
|
74
|
-
let t = x(s.errorMessage, n) || (e instanceof Error ? e.message : "An unexpected error occurred");
|
|
75
|
-
return d({
|
|
76
|
-
message: t,
|
|
77
|
-
type: "error"
|
|
78
|
-
}), {
|
|
79
|
-
error: t,
|
|
80
|
-
success: !1
|
|
81
|
-
};
|
|
82
|
-
} finally {
|
|
83
|
-
c(!1);
|
|
84
|
-
}
|
|
85
|
-
}, [
|
|
86
|
-
f,
|
|
87
|
-
t,
|
|
88
|
-
n,
|
|
89
|
-
r,
|
|
90
|
-
i,
|
|
91
|
-
a,
|
|
92
|
-
o
|
|
93
|
-
]);
|
|
94
|
-
return {
|
|
95
|
-
clearSubmitMessage: E(() => {
|
|
96
|
-
d(null);
|
|
97
|
-
}, []),
|
|
98
|
-
handleSubmitWithConfig: p,
|
|
99
|
-
hasSubmitConfig: !!f?.data?.submitConfig,
|
|
100
|
-
isSubmitting: s,
|
|
101
|
-
submitButtonNode: f,
|
|
102
|
-
submitMessage: u
|
|
103
|
-
};
|
|
104
|
-
}, L = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" ? e : typeof e == "string" ? e === "" ? null : e : typeof e == "object" ? JSON.stringify(e) : String(e), R = (e, t, n) => {
|
|
105
|
-
let r = L(e), i = L(t);
|
|
106
|
-
if (r === null || i === null) switch (n) {
|
|
107
|
-
case "===": return r === i;
|
|
108
|
-
case "!==": return r !== i;
|
|
109
|
-
default: return !1;
|
|
110
|
-
}
|
|
111
|
-
if ([
|
|
112
|
-
">",
|
|
113
|
-
"<",
|
|
114
|
-
">=",
|
|
115
|
-
"<="
|
|
116
|
-
].includes(n)) {
|
|
117
|
-
let e = Number(r), t = Number(i);
|
|
118
|
-
if (!(Number.isNaN(e) || Number.isNaN(t))) switch (n) {
|
|
119
|
-
case ">": return e > t;
|
|
120
|
-
case "<": return e < t;
|
|
121
|
-
case ">=": return e >= t;
|
|
122
|
-
case "<=": return e <= t;
|
|
123
|
-
default: return !1;
|
|
124
|
-
}
|
|
125
|
-
return !1;
|
|
126
|
-
}
|
|
127
|
-
switch (n) {
|
|
128
|
-
case "===": {
|
|
129
|
-
let e = Number(r), t = Number(i);
|
|
130
|
-
return Number.isNaN(e) || Number.isNaN(t) ? String(r) === String(i) : e === t;
|
|
131
|
-
}
|
|
132
|
-
case "!==": {
|
|
133
|
-
let e = Number(r), t = Number(i);
|
|
134
|
-
return Number.isNaN(e) || Number.isNaN(t) ? String(r) !== String(i) : e !== t;
|
|
135
|
-
}
|
|
136
|
-
default: return !1;
|
|
137
|
-
}
|
|
138
|
-
}, z = (e, t, n) => {
|
|
139
|
-
let { field: r, operator: i, value: a } = e;
|
|
140
|
-
if (!(r && i) || a === void 0) return !0;
|
|
141
|
-
let o = t[r], s = o === void 0 && n ? n.get(r) : void 0, c = s && l(s) ? t[s.id] : o;
|
|
142
|
-
return Array.isArray(c) ? i === "===" ? c.some((e) => R(e, a, "===")) || R(c, a, "===") : i === "!==" ? c.every((e) => R(e, a, "!==")) && R(c, a, "!==") : c.some((e) => R(e, a, i)) : R(c, a, i);
|
|
143
|
-
}, B = (e, t, n) => {
|
|
144
|
-
if (!e || e.length === 0) return !0;
|
|
145
|
-
if (e.length === 1) return z(e[0], t, n);
|
|
146
|
-
let r = z(e[0], t, n);
|
|
147
|
-
for (let i = 1; i < e.length; i += 1) {
|
|
148
|
-
let a = e[i], o = z(a, t, n), s = e[i - 1].logicalOperator || c.AND;
|
|
149
|
-
if (s === c.AND) {
|
|
150
|
-
if (r &&= o, !r) return !1;
|
|
151
|
-
} else if (s === c.OR && (r ||= o, r)) return !0;
|
|
152
|
-
}
|
|
153
|
-
return r;
|
|
154
|
-
}, V = (e) => {
|
|
155
|
-
let t = /* @__PURE__ */ new Map();
|
|
156
|
-
return e.forEach((e) => {
|
|
157
|
-
let n = t.get(e.source);
|
|
158
|
-
n ? n.push(e) : t.set(e.source, [e]);
|
|
159
|
-
}), t;
|
|
160
|
-
}, H = (e, t, n) => {
|
|
161
|
-
let r = [], i = [], a = [];
|
|
162
|
-
e.forEach((e) => {
|
|
163
|
-
let t = e.data?.isFallback, n = e.data?.conditions?.length;
|
|
164
|
-
t ? a.push(e) : n ? i.push(e) : r.push(e);
|
|
165
|
-
});
|
|
166
|
-
let o = [...r];
|
|
167
|
-
if (i.length === 0) return a.length > 0 && o.length === 0 && o.push(...a), {
|
|
168
|
-
edgesToFollow: o,
|
|
169
|
-
waitingForInput: !1
|
|
170
|
-
};
|
|
171
|
-
if (!i.every((e) => {
|
|
172
|
-
let r = e.data?.conditions;
|
|
173
|
-
return r ? r.every((e) => {
|
|
174
|
-
if (!e.field) return !0;
|
|
175
|
-
let r = n.get(e.field);
|
|
176
|
-
return y(l(r) ? r.id : e.field, t);
|
|
177
|
-
}) : !1;
|
|
178
|
-
})) return a.length > 0 && o.push(...a), {
|
|
179
|
-
edgesToFollow: o,
|
|
180
|
-
waitingForInput: o.length === 0
|
|
181
|
-
};
|
|
182
|
-
let s = i.filter((e) => B(e.data?.conditions, t, n));
|
|
183
|
-
return s.length > 0 ? (o.push(...s), {
|
|
184
|
-
edgesToFollow: o,
|
|
185
|
-
waitingForInput: !1
|
|
186
|
-
}) : (o.push(...a), {
|
|
187
|
-
edgesToFollow: o,
|
|
188
|
-
waitingForInput: !1
|
|
189
|
-
});
|
|
190
|
-
}, ie = (e, t) => !t.some((t) => t.target === e), U = (e, t) => {
|
|
191
|
-
let n = e.filter((e) => ie(e.id, t));
|
|
192
|
-
return n.find(l) || n[0];
|
|
193
|
-
}, ae = (e, t, n = /* @__PURE__ */ new Set()) => !e || n.has(e) ? [] : (n.add(e), [e, ...ae(t.get(e)?.parentId, t, n)]), W = (e, t, n, r) => {
|
|
194
|
-
e.forEach((e) => {
|
|
195
|
-
let i = n.get(e);
|
|
196
|
-
ae(r.get(e)?.parentId, r).forEach((e) => {
|
|
197
|
-
t.add(e), !n.has(e) && i !== void 0 && n.set(e, i);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
}, oe = (e, t, n) => {
|
|
201
|
-
let r = U(e, t);
|
|
202
|
-
if (!r) return {
|
|
203
|
-
endOfPathReached: !0,
|
|
204
|
-
visibleNodeIds: /* @__PURE__ */ new Set(),
|
|
205
|
-
visibleNodes: [],
|
|
206
|
-
visibleRootNodes: []
|
|
207
|
-
};
|
|
208
|
-
let i = new Map(e.map((e) => [e.id, e])), a = V(t), o = [], s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = !1, u = (e) => {
|
|
209
|
-
if (c.has(e)) return;
|
|
210
|
-
c.add(e);
|
|
211
|
-
let t = i.get(e);
|
|
212
|
-
if (!t) return;
|
|
213
|
-
s.add(e), o.push(t);
|
|
214
|
-
let { edgesToFollow: r, waitingForInput: d } = H(a.get(e) || [], n, i);
|
|
215
|
-
if (d) {
|
|
216
|
-
l = !0;
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
r.forEach((e) => {
|
|
220
|
-
u(e.target);
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
u(r.id);
|
|
224
|
-
let d = new Map(o.map((e, t) => [e.id, t])), f = new Set(s);
|
|
225
|
-
W(s, f, d, i);
|
|
226
|
-
let p = e.filter((e) => f.has(e.id)).sort((e, t) => (d.get(e.id) ?? 2 ** 53 - 1) - (d.get(t.id) ?? 2 ** 53 - 1)), m = p.filter((e) => !(e.parentId && f.has(e.parentId)));
|
|
227
|
-
return {
|
|
228
|
-
endOfPathReached: !l,
|
|
229
|
-
visibleNodeIds: f,
|
|
230
|
-
visibleNodes: p,
|
|
231
|
-
visibleRootNodes: m
|
|
232
|
-
};
|
|
233
|
-
}, se = (e) => e.filter((e) => !u(e)).reduce((e, t) => {
|
|
234
|
-
let n = t.parentId ?? null, r = e.at(-1);
|
|
235
|
-
return r && r.groupId === n ? [...e.slice(0, -1), {
|
|
236
|
-
...r,
|
|
237
|
-
nodes: [...r.nodes, t]
|
|
238
|
-
}] : [...e, {
|
|
239
|
-
groupId: n,
|
|
240
|
-
nodes: [t]
|
|
241
|
-
}];
|
|
242
|
-
}, []), G = (e) => {
|
|
243
|
-
if (typeof e != "object" || !e) return JSON.stringify(e) ?? "null";
|
|
244
|
-
if (Array.isArray(e)) return `[${e.map(G).join(",")}]`;
|
|
245
|
-
let t = e;
|
|
246
|
-
return `{${Object.keys(t).sort().map((e) => `${JSON.stringify(e)}:${G(t[e])}`).join(",")}}`;
|
|
247
|
-
}, K = ({ baseUrl: e, components: r, extraPayload: i, flow: a, googleApiKey: o, headers: s, language: c, onChange: d, onSubmit: m, showPoweredBy: h, theme: _, validate: y, validationMode: b, initialValues: x = {} }) => {
|
|
248
|
-
let w = te(), T = k(() => ({
|
|
249
|
-
baseUrl: e ?? w?.baseUrl,
|
|
250
|
-
components: {
|
|
251
|
-
form: r?.form ?? w?.components?.form,
|
|
252
|
-
inputs: {
|
|
253
|
-
...w?.components?.inputs,
|
|
254
|
-
...r?.inputs
|
|
255
|
-
},
|
|
256
|
-
loadingSkeleton: r?.loadingSkeleton ?? w?.components?.loadingSkeleton,
|
|
257
|
-
step: r?.step ?? w?.components?.step,
|
|
258
|
-
submitButton: r?.submitButton ?? w?.components?.submitButton,
|
|
259
|
-
submitButtonWrapper: r?.submitButtonWrapper ?? w?.components?.submitButtonWrapper,
|
|
260
|
-
ui: {
|
|
261
|
-
...w?.components?.ui,
|
|
262
|
-
...r?.ui
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
googleApiKey: o ?? w?.googleApiKey,
|
|
266
|
-
headers: v(w?.headers, s),
|
|
267
|
-
language: c ?? w?.language ?? "en",
|
|
268
|
-
showPoweredBy: h ?? w?.showPoweredBy ?? !0,
|
|
269
|
-
theme: _ ?? w?.theme ?? "dark",
|
|
270
|
-
validationMode: b ?? w?.validationMode ?? "onSubmit"
|
|
271
|
-
}), [
|
|
272
|
-
e,
|
|
273
|
-
r,
|
|
274
|
-
w,
|
|
275
|
-
o,
|
|
276
|
-
s,
|
|
277
|
-
c,
|
|
278
|
-
h,
|
|
279
|
-
_,
|
|
280
|
-
b
|
|
281
|
-
]), D = k(() => a?.nodes ?? [], [a]), M = k(() => a?.edges ?? [], [a]), N = k(() => C(D), [D]), P = n(T.language), F = A({}), I = A(null), [L, R] = j({}), [z, B] = j(() => g(x, N)), V = k(() => G(x), [x]), H = A(V), { endOfPathReached: ie, visibleNodes: U, visibleRootNodes: ae } = k(() => oe(D, M, z), [
|
|
282
|
-
D,
|
|
283
|
-
M,
|
|
284
|
-
z
|
|
285
|
-
]), W = k(() => C(U), [U]), K = k(() => se(U), [U]), ce = k(() => {
|
|
286
|
-
let e = /* @__PURE__ */ new Map();
|
|
287
|
-
return D.forEach((t) => {
|
|
288
|
-
u(t) && e.set(t.id, t);
|
|
289
|
-
}), e;
|
|
290
|
-
}, [D]), [q, J] = j(0), Y = K.length === 0 ? 0 : Math.min(q, K.length - 1), X = K[Y], le = X?.groupId ? ce.get(X.groupId) : void 0, ue = Y === 0, de = K.length === 0 || Y >= K.length - 1, { clearSubmitMessage: fe, handleSubmitWithConfig: pe, hasSubmitConfig: me, isSubmitting: he, submitButtonNode: ge, submitMessage: _e } = re(U, z, T.language, W, T.headers, T.baseUrl, i), ve = A(d), Z = A(y), Q = k(() => S(z, W), [z, W]), ye = k(() => {
|
|
291
|
-
let e = ge?.data?.submitConfig?.payloadTemplate;
|
|
292
|
-
return e ? t(e, z, W) ?? Q : Q;
|
|
293
|
-
}, [
|
|
294
|
-
ge,
|
|
295
|
-
z,
|
|
296
|
-
W,
|
|
297
|
-
Q
|
|
298
|
-
]), be = E((e, t) => {
|
|
299
|
-
B((n) => ({
|
|
300
|
-
...n,
|
|
301
|
-
[e]: t
|
|
302
|
-
})), R((t) => {
|
|
303
|
-
let n = { ...t };
|
|
304
|
-
return delete n[e], n;
|
|
305
|
-
});
|
|
306
|
-
}, []), xe = E((e) => {
|
|
307
|
-
Object.keys(e).length !== 0 && (B((t) => ({
|
|
308
|
-
...t,
|
|
309
|
-
...e
|
|
310
|
-
})), R((t) => {
|
|
311
|
-
let n = { ...t };
|
|
312
|
-
return Object.keys(e).forEach((e) => {
|
|
313
|
-
delete n[e];
|
|
314
|
-
}), n;
|
|
315
|
-
}));
|
|
316
|
-
}, []), $ = E((e) => {
|
|
317
|
-
let t = {};
|
|
318
|
-
U.forEach((e) => {
|
|
319
|
-
if (l(e)) {
|
|
320
|
-
let n = e.id, r = z[n];
|
|
321
|
-
if (e.data.required && p(r)) {
|
|
322
|
-
t[n] = P(e.data.errorMessage) || P("validation.required");
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
if (!p(r) && e.data.pattern) try {
|
|
326
|
-
new RegExp(e.data.pattern).test(String(r)) || (t[n] = P(e.data.errorMessage) || P("validation.invalidFormat"));
|
|
327
|
-
} catch (e) {
|
|
328
|
-
console.error(`Invalid pattern for field ${n}:`, e);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
let n = e ? e(z, U) : {}, r = {
|
|
333
|
-
...t,
|
|
334
|
-
...n
|
|
335
|
-
};
|
|
336
|
-
return R(r), {
|
|
337
|
-
errors: r,
|
|
338
|
-
hasCustomErrors: Object.keys(n).length > 0,
|
|
339
|
-
isValid: Object.keys(r).length === 0
|
|
340
|
-
};
|
|
341
|
-
}, [
|
|
342
|
-
U,
|
|
343
|
-
z,
|
|
344
|
-
P
|
|
345
|
-
]), Se = E(() => {
|
|
346
|
-
J((e) => e >= K.length - 1 ? e : e + 1);
|
|
347
|
-
}, [K.length]), Ce = E(() => {
|
|
348
|
-
J((e) => Math.max(0, e - 1));
|
|
349
|
-
}, []), we = E(async () => {
|
|
350
|
-
let { isValid: e } = $(Z.current);
|
|
351
|
-
if (!e) return !1;
|
|
352
|
-
let t = ne(ye, i, Q);
|
|
353
|
-
if (me) {
|
|
354
|
-
let e = await pe((e) => {
|
|
355
|
-
m && m(t, { httpResponse: e });
|
|
356
|
-
});
|
|
357
|
-
if (e === null) return m?.(t), !0;
|
|
358
|
-
if (!e.success) return !0;
|
|
359
|
-
} else m && m(t);
|
|
360
|
-
return !0;
|
|
361
|
-
}, [
|
|
362
|
-
$,
|
|
363
|
-
me,
|
|
364
|
-
pe,
|
|
365
|
-
m,
|
|
366
|
-
ye,
|
|
367
|
-
i,
|
|
368
|
-
Q
|
|
369
|
-
]), Te = k(() => {
|
|
370
|
-
if (!X) return [];
|
|
371
|
-
let e = [];
|
|
372
|
-
return X.nodes.forEach((t) => {
|
|
373
|
-
l(t) && t.data.type !== "submit" && t.data.required && p(z[t.id]) && e.push(P(t.data.label) || t.id);
|
|
374
|
-
}), e;
|
|
375
|
-
}, [
|
|
376
|
-
X,
|
|
377
|
-
z,
|
|
378
|
-
P
|
|
379
|
-
]), Ee = k(() => U.some((e) => l(e) && e.data.type === "submit"), [U]), De = k(() => X ? X.nodes.every((e) => !l(e) || !e.data.required || e.data.type === "submit" ? !0 : !p(z[e.id])) : !1, [X, z]), Oe = k(() => {
|
|
380
|
-
let e = Object.keys(L);
|
|
381
|
-
return e.length > 0 ? e[0] : void 0;
|
|
382
|
-
}, [L]);
|
|
383
|
-
return O(() => {
|
|
384
|
-
if (K.length === 0) {
|
|
385
|
-
q !== 0 && J(0);
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
q > K.length - 1 && J(K.length - 1);
|
|
389
|
-
}, [K.length, q]), O(() => {
|
|
390
|
-
ve.current = d;
|
|
391
|
-
}, [d]), O(() => {
|
|
392
|
-
Z.current = y;
|
|
393
|
-
}, [y]), O(() => {
|
|
394
|
-
ve.current?.(Q);
|
|
395
|
-
}, [Q]), O(() => {
|
|
396
|
-
T.validationMode === "onChange" && $(Z.current);
|
|
397
|
-
}, [T.validationMode, $]), O(() => {
|
|
398
|
-
let e = f(N, z, F.current);
|
|
399
|
-
Object.keys(e).length > 0 && xe(e), F.current = z;
|
|
400
|
-
}, [
|
|
401
|
-
z,
|
|
402
|
-
N,
|
|
403
|
-
xe
|
|
404
|
-
]), O(() => {
|
|
405
|
-
let e = I.current, t = new Set(W.map((e) => e.id));
|
|
406
|
-
if (I.current = t, !e) return;
|
|
407
|
-
let n = [...e].filter((e) => !t.has(e)), r = {};
|
|
408
|
-
W.forEach((t) => {
|
|
409
|
-
if (e.has(t.id) || z[t.id] !== void 0) return;
|
|
410
|
-
let n = ee(t, z);
|
|
411
|
-
n !== void 0 && (r[t.id] = n);
|
|
412
|
-
}), !(n.length === 0 && Object.keys(r).length === 0) && (B((e) => {
|
|
413
|
-
let t = {
|
|
414
|
-
...e,
|
|
415
|
-
...r
|
|
416
|
-
};
|
|
417
|
-
return n.forEach((e) => {
|
|
418
|
-
delete t[e];
|
|
419
|
-
}), t;
|
|
420
|
-
}), n.length > 0 && R((e) => {
|
|
421
|
-
let t = !1, r = { ...e };
|
|
422
|
-
return n.forEach((e) => {
|
|
423
|
-
e in r && (delete r[e], t = !0);
|
|
424
|
-
}), t ? r : e;
|
|
425
|
-
}));
|
|
426
|
-
}, [W, z]), O(() => {
|
|
427
|
-
H.current !== V && (H.current = V, B(g(x, N)), R({}), I.current = null);
|
|
428
|
-
}, [
|
|
429
|
-
V,
|
|
430
|
-
x,
|
|
431
|
-
N
|
|
432
|
-
]), {
|
|
433
|
-
canContinueStep: De,
|
|
434
|
-
canSubmit: (Ee || ie) && D.length > 0,
|
|
435
|
-
clearSubmitMessage: fe,
|
|
436
|
-
config: T,
|
|
437
|
-
currentStep: X,
|
|
438
|
-
currentStepGroupNode: le,
|
|
439
|
-
currentStepIndex: Y,
|
|
440
|
-
firstErrorFieldId: Oe,
|
|
441
|
-
formErrors: L,
|
|
442
|
-
formValues: z,
|
|
443
|
-
goToNextStep: Se,
|
|
444
|
-
goToPreviousStep: Ce,
|
|
445
|
-
handleSubmit: we,
|
|
446
|
-
hasSubmitInput: Ee,
|
|
447
|
-
inputNodes: N,
|
|
448
|
-
isFirstStep: ue,
|
|
449
|
-
isLastStep: de,
|
|
450
|
-
isSubmitting: he,
|
|
451
|
-
missingRequiredFields: Te,
|
|
452
|
-
prevFormValuesRef: F,
|
|
453
|
-
setFieldErrors: R,
|
|
454
|
-
setFieldValue: be,
|
|
455
|
-
setMultipleFieldValues: xe,
|
|
456
|
-
steps: K,
|
|
457
|
-
submitMessage: _e,
|
|
458
|
-
t: P,
|
|
459
|
-
validateForm: $,
|
|
460
|
-
visibleNodes: U,
|
|
461
|
-
visibleRootNodes: ae
|
|
462
|
-
};
|
|
463
|
-
}, ce = /\{\{([\w-]+)}}/g, q = (e) => e == null || e === "", J = (...e) => {
|
|
464
|
-
let t = [];
|
|
465
|
-
for (let n of e) if (n) for (let e of n.matchAll(ce)) t.includes(e[1]) || t.push(e[1]);
|
|
466
|
-
return t;
|
|
467
|
-
}, Y = (e) => {
|
|
468
|
-
let t = e.data.httpConfig ?? e.data.optionsSource;
|
|
469
|
-
if (!t) return [];
|
|
470
|
-
let n = Object.values(t.queryParams ?? {});
|
|
471
|
-
return J(t.url, t.body, ...n);
|
|
472
|
-
}, X = (e, t, n, r) => Y(e).filter((e) => q(t[e])).map((e) => {
|
|
473
|
-
let t = n.find((t) => t.id === e);
|
|
474
|
-
return {
|
|
475
|
-
id: e,
|
|
476
|
-
label: t ? b(t, r) : e
|
|
477
|
-
};
|
|
478
|
-
}), le = ({ DefaultFormWrapper: e, DefaultInputLabel: t, DefaultInputWrapper: n, DefaultSubmitButton: a, DefaultSubmitButtonWrapper: o, config: s, defaultInputRenderers: c, defaultUI: u, formErrors: f, formValues: p, inputNodes: g, isSubmitting: _, missingRequiredFields: v, setFieldValue: ee }) => {
|
|
479
|
-
let y = k(() => s.components.form || e, [s.components.form, e]), b = k(() => s.components.submitButton || a, [s.components.submitButton, a]), S = k(() => s.components.submitButtonWrapper || o || w, [s.components.submitButtonWrapper, o]), C = k(() => s.components.inputLabel || t, [s.components.inputLabel, t]);
|
|
480
|
-
return {
|
|
481
|
-
FormWrapper: y,
|
|
482
|
-
renderNode: E(function(e) {
|
|
483
|
-
let { type: t } = e;
|
|
484
|
-
switch (t) {
|
|
485
|
-
case r.input: {
|
|
486
|
-
if (!l(e)) return null;
|
|
487
|
-
let t = e.data, r = t.type || "text", a = s.components.inputs?.[r], o = c[r], u = a || o, d = e.id, y = (e) => ee(d, e), b = p[d], S = f[d], w = x(t.label, s.language), T = m(t, s.language), E = x(t.helperText, s.language), D = h(e), O = i(w), k = i(T), A = i(E);
|
|
488
|
-
return u ? /* @__PURE__ */ M(n, {
|
|
489
|
-
node: e,
|
|
490
|
-
children: /* @__PURE__ */ M(u, {
|
|
491
|
-
field: {
|
|
492
|
-
"aria-invalid": S ? !0 : void 0,
|
|
493
|
-
id: e.id,
|
|
494
|
-
name: D,
|
|
495
|
-
placeholder: k,
|
|
496
|
-
required: t.required,
|
|
497
|
-
value: b
|
|
498
|
-
},
|
|
499
|
-
extra: {
|
|
500
|
-
error: S,
|
|
501
|
-
helperText: A,
|
|
502
|
-
InputLabel: C,
|
|
503
|
-
isSubmitting: _,
|
|
504
|
-
label: O,
|
|
505
|
-
missingDependencies: X(e, p, g, s.language),
|
|
506
|
-
missingRequiredFields: v,
|
|
507
|
-
node: e,
|
|
508
|
-
setValue: y
|
|
509
|
-
}
|
|
510
|
-
}, r)
|
|
511
|
-
}, e.id) : (console.warn("No renderer found for input type:", r), null);
|
|
512
|
-
}
|
|
513
|
-
case r.group: return null;
|
|
514
|
-
case r.ui: {
|
|
515
|
-
if (!d(e)) return null;
|
|
516
|
-
let t = e.data.type || "title", n = s.components.ui?.[t], r = u[t], i = n || r;
|
|
517
|
-
return i ? /* @__PURE__ */ M(i, { node: e }, e.id) : null;
|
|
518
|
-
}
|
|
519
|
-
default: return console.warn("Unknown node type:", t), null;
|
|
520
|
-
}
|
|
521
|
-
}, [
|
|
522
|
-
s,
|
|
523
|
-
p,
|
|
524
|
-
f,
|
|
525
|
-
ee,
|
|
526
|
-
_,
|
|
527
|
-
v,
|
|
528
|
-
g,
|
|
529
|
-
c,
|
|
530
|
-
u,
|
|
531
|
-
n
|
|
532
|
-
]),
|
|
533
|
-
SubmitButton: b,
|
|
534
|
-
SubmitButtonWrapper: S
|
|
535
|
-
};
|
|
536
|
-
};
|
|
537
|
-
//#endregion
|
|
538
|
-
export { ie as a, P as c, oe as i, te as l, K as n, z as o, U as r, B as s, le as t };
|