treege 3.0.0-beta.87 → 3.0.0-beta.89

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