treege 3.0.0-beta.70 → 3.0.0-beta.71

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