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