treege 3.0.0-beta.8 → 3.0.0-beta.9

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.
Files changed (23) hide show
  1. package/dist/TreegeEditor-Lv5Tn9_F.js +1 -1
  2. package/dist/TreegeRenderer-BVaqgInZ.js +1405 -0
  3. package/dist/main.js +1 -1
  4. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
  5. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
  6. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
  7. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
  8. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
  9. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
  10. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
  11. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
  12. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
  13. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
  14. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
  15. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
  16. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
  17. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
  18. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
  19. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
  20. package/dist/renderer/types/renderer.d.ts +15 -0
  21. package/dist/renderer.js +1 -1
  22. package/package.json +1 -1
  23. package/dist/TreegeRenderer-D3EvsEfJ.js +0 -1413
@@ -1,1413 +0,0 @@
1
- import { j as t, i as q, L as ne, b as Fe, e as Qe, F as D, f as F, I as z, C as pe, h as fe, k as xe, l as ge, m as be, n as k, o as A, P as Y, p as Z, B as H, q as ee, r as Se, s as b, t as Ne, v as ve, S as Ce, w as Ie, x as De, y as ke, z as Ae, A as Re, D as Xe, E as Ye, G as le, N as X, a as Ze, c as et, T as tt } from "./ThemeContext-BIvs8Kw-.js";
2
- import * as ye from "react";
3
- import { createContext as Ee, useContext as _e, useMemo as L, useState as E, useCallback as V, useEffect as B, useRef as me } from "react";
4
- import { MapPin as we, ChevronsUpDown as Pe, Check as Oe, ChevronLeftIcon as at, ChevronRightIcon as st, ChevronDownIcon as je, Loader2 as ie, CircleIcon as rt } from "lucide-react";
5
- import { getDefaultClassNames as ze, DayPicker as nt } from "react-day-picker";
6
- import * as he from "@radix-ui/react-radio-group";
7
- import * as G from "@radix-ui/react-tooltip";
8
- const $e = Ee(void 0), lt = () => _e($e), la = ({
9
- children: e,
10
- components: r,
11
- googleApiKey: n,
12
- language: a,
13
- theme: s,
14
- validationMode: l
15
- }) => {
16
- const i = {
17
- components: r,
18
- googleApiKey: n,
19
- language: a,
20
- theme: s,
21
- validationMode: l
22
- };
23
- return /* @__PURE__ */ t.jsx($e.Provider, { value: i, children: e });
24
- }, Te = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" || typeof e == "string" ? e : typeof e == "object" ? JSON.stringify(e) : String(e), it = (e, r, n) => {
25
- const a = Te(e), s = Te(r);
26
- if (a === null || s === null)
27
- switch (n) {
28
- case "===":
29
- return a === s;
30
- case "!==":
31
- return a !== s;
32
- default:
33
- return !1;
34
- }
35
- if ([">", "<", ">=", "<="].includes(n)) {
36
- const l = Number(a), i = Number(s);
37
- if (!(Number.isNaN(l) || Number.isNaN(i)))
38
- switch (n) {
39
- case ">":
40
- return l > i;
41
- case "<":
42
- return l < i;
43
- case ">=":
44
- return l >= i;
45
- case "<=":
46
- return l <= i;
47
- default:
48
- return !1;
49
- }
50
- return !1;
51
- }
52
- switch (n) {
53
- case "===": {
54
- const l = Number(a), i = Number(s);
55
- return Number.isNaN(l) || Number.isNaN(i) ? String(a) === String(s) : l === i;
56
- }
57
- case "!==": {
58
- const l = Number(a), i = Number(s);
59
- return Number.isNaN(l) || Number.isNaN(i) ? String(a) !== String(s) : l !== i;
60
- }
61
- default:
62
- return !1;
63
- }
64
- }, oe = (e, r, n) => {
65
- const { field: a, operator: s, value: l } = e;
66
- if (!(a && s) || l === void 0)
67
- return !0;
68
- let i = r[a];
69
- if (i === void 0 && n) {
70
- const o = n.get(a);
71
- o && q(o) && (i = r[o.id]);
72
- }
73
- return it(i, l, s);
74
- }, ot = (e, r, n) => {
75
- if (!e || e.length === 0)
76
- return !0;
77
- if (e.length === 1)
78
- return oe(e[0], r, n);
79
- let a = oe(e[0], r, n);
80
- for (let s = 1; s < e.length; s += 1) {
81
- const l = e[s], i = oe(l, r, n), o = e[s - 1].logicalOperator || ne.AND;
82
- if (o === ne.AND) {
83
- if (a = a && i, !a)
84
- return !1;
85
- } else if (o === ne.OR && (a = a || i, a))
86
- return !0;
87
- }
88
- return a;
89
- }, de = (e) => e == null || typeof e == "string" && e.trim() === "" ? !0 : Array.isArray(e) && e.length === 0, dt = (e, r) => {
90
- if (!e)
91
- return !1;
92
- const n = r[e];
93
- return n != null;
94
- }, ct = (e, r) => {
95
- const n = {};
96
- return r.forEach((a) => {
97
- const s = a.id, l = a.data.name || s;
98
- e[s] !== void 0 && (n[l] = e[s]);
99
- }), n;
100
- }, ut = (e) => {
101
- const r = /* @__PURE__ */ new Map();
102
- return e.forEach((n) => {
103
- const a = r.get(n.source);
104
- a ? a.push(n) : r.set(n.source, [n]);
105
- }), r;
106
- }, mt = (e, r, n) => {
107
- const a = [], s = [], l = [];
108
- e.forEach((m) => {
109
- const c = m.data?.isFallback, f = m.data?.conditions?.length;
110
- c ? l.push(m) : f ? s.push(m) : a.push(m);
111
- });
112
- const i = [...a];
113
- if (s.length === 0)
114
- return l.length > 0 && i.length === 0 && i.push(...l), { edgesToFollow: i, waitingForInput: !1 };
115
- if (!s.every((m) => {
116
- const c = m.data?.conditions;
117
- return c ? c.every((f) => {
118
- if (!f.field)
119
- return !0;
120
- const p = n.get(f.field), x = q(p) ? p.id : f.field;
121
- return dt(x, r);
122
- }) : !1;
123
- }))
124
- return { edgesToFollow: i, waitingForInput: i.length === 0 };
125
- const d = s.filter((m) => ot(m.data?.conditions, r, n));
126
- return d.length > 0 ? (i.push(...d), { edgesToFollow: i, waitingForInput: !1 }) : (i.push(...l), { edgesToFollow: i, waitingForInput: !1 });
127
- }, Me = (e, r) => !r.some((n) => n.target === e), ht = (e, r) => {
128
- const n = e.filter((a) => Me(a.id, r));
129
- return n.find(q) || n[0];
130
- }, pt = (e, r, n, a) => {
131
- e.forEach((s) => {
132
- const l = a.get(s);
133
- if (!l)
134
- return;
135
- let { parentId: i } = l;
136
- const o = /* @__PURE__ */ new Set();
137
- for (; i && !o.has(i); ) {
138
- if (o.add(i), r.add(i), !n.has(i)) {
139
- const d = n.get(s);
140
- d !== void 0 && n.set(i, d);
141
- }
142
- i = a.get(i)?.parentId;
143
- }
144
- });
145
- }, ft = (e, r, n) => {
146
- const a = ht(e, r);
147
- if (!a)
148
- return {
149
- endOfPathReached: !0,
150
- visibleNodeIds: /* @__PURE__ */ new Set(),
151
- visibleNodes: [],
152
- visibleRootNodes: []
153
- };
154
- const s = new Map(e.map((h) => [h.id, h])), l = ut(r), i = [], o = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
155
- let m = !1;
156
- const c = (h) => {
157
- if (d.has(h))
158
- return;
159
- d.add(h);
160
- const u = s.get(h);
161
- if (!u)
162
- return;
163
- o.add(h), i.push(u);
164
- const S = l.get(h) || [], { edgesToFollow: N, waitingForInput: y } = mt(S, n, s);
165
- if (y) {
166
- m = !0;
167
- return;
168
- }
169
- N.forEach((j) => {
170
- c(j.target);
171
- });
172
- };
173
- c(a.id);
174
- const f = new Map(i.map((h, u) => [h.id, u])), p = new Set(o);
175
- pt(o, p, f, s);
176
- const x = e.filter((h) => p.has(h.id)).sort((h, u) => (f.get(h.id) ?? Number.MAX_SAFE_INTEGER) - (f.get(u.id) ?? Number.MAX_SAFE_INTEGER)), v = x.filter((h) => !(h.parentId && p.has(h.parentId)));
177
- return {
178
- endOfPathReached: !m,
179
- visibleNodeIds: p,
180
- visibleNodes: x,
181
- visibleRootNodes: v
182
- };
183
- }, xt = (e) => {
184
- if (e.length === 1)
185
- return e[0];
186
- const r = new Set(e.map((a) => a.id)), n = /* @__PURE__ */ new Set();
187
- return e.forEach((a) => {
188
- a.nodes.forEach((s) => {
189
- if (Fe(s)) {
190
- const l = s.data.targetId;
191
- l && r.has(l) && n.add(l);
192
- }
193
- });
194
- }), e.find((a) => !n.has(a.id)) || e[0];
195
- }, qe = (e, r, n, a, s = /* @__PURE__ */ new Set()) => {
196
- const l = /* @__PURE__ */ new Set();
197
- for (const i of e)
198
- if (n.has(i)) {
199
- const o = a.get(i), d = o ? r.get(o) : void 0;
200
- if (d) {
201
- if (o && s.has(o))
202
- continue;
203
- o && s.add(o);
204
- const m = new Set(d.nodes.map((f) => f.id)), c = qe(m, r, n, a, s);
205
- for (const f of c)
206
- l.add(f);
207
- }
208
- } else
209
- l.add(i);
210
- return l;
211
- }, gt = (e, r) => {
212
- const n = /* @__PURE__ */ new Set();
213
- return r.forEach((a) => {
214
- e.has(a.source) && e.has(a.target) && n.add(a.source);
215
- }), Array.from(e).filter((a) => !n.has(a));
216
- }, Be = (e) => {
217
- if (!e)
218
- return { edges: [], id: "empty", nodes: [] };
219
- const r = Array.isArray(e) ? e : [e];
220
- if (r.length === 0)
221
- return { edges: [], id: "empty", nodes: [] };
222
- const n = xt(r);
223
- if (r.length === 1)
224
- return n;
225
- const a = new Map(r.map((p) => [p.id, p])), s = [], l = [...n.edges], i = /* @__PURE__ */ new Set([n.id]), o = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), c = (p) => {
226
- const x = [];
227
- return p.forEach((v) => {
228
- if (!Fe(v)) {
229
- x.push(v);
230
- return;
231
- }
232
- const h = v.data.targetId;
233
- if (!h)
234
- return;
235
- const u = a.get(h);
236
- if (!u) {
237
- console.warn(`Flow with id "${h}" not found`);
238
- return;
239
- }
240
- const S = u.nodes.find((N) => !N.parentId);
241
- if (!S) {
242
- console.warn(`Flow "${h}" has no root node; preserving FlowNode "${v.id}"`), x.push(v);
243
- return;
244
- }
245
- o.set(v.id, S.id), d.set(v.id, h), i.has(h) || (i.add(h), l.push(...u.edges), x.push(...c(u.nodes)));
246
- }), x;
247
- };
248
- s.push(...c(n.nodes)), l.forEach((p) => {
249
- if (o.has(p.source)) {
250
- const x = m.get(p.source);
251
- x ? x.push(p) : m.set(p.source, [p]);
252
- }
253
- });
254
- const f = l.map((p) => {
255
- if (o.has(p.source))
256
- return null;
257
- const x = o.get(p.target);
258
- return x ? { ...p, target: x } : p;
259
- }).filter((p) => p !== null);
260
- return o.forEach((p, x) => {
261
- const v = m.get(x);
262
- if (!v?.length)
263
- return;
264
- const h = d.get(x), u = h ? a.get(h) : void 0;
265
- if (!u)
266
- return;
267
- const S = new Set(u.nodes.map((j) => j.id)), N = qe(
268
- S,
269
- a,
270
- o,
271
- d,
272
- new Set(h ? [h] : [])
273
- );
274
- gt(N, f).forEach((j) => {
275
- v.forEach((g) => {
276
- const w = o.get(g.target) ?? g.target, T = g.id ?? `${x}__${g.target}`;
277
- f.push({
278
- ...g,
279
- id: `${j}__${T}`,
280
- source: j,
281
- target: w
282
- });
283
- });
284
- });
285
- }), {
286
- edges: f,
287
- id: n.id,
288
- nodes: s
289
- };
290
- }, Ve = Ee(null), bt = ({ children: e, value: r }) => /* @__PURE__ */ t.jsx(Ve.Provider, { value: r, children: e }), te = () => {
291
- const r = _e(Ve) ?? {
292
- flows: null,
293
- formErrors: {},
294
- formValues: {},
295
- googleApiKey: void 0,
296
- language: "",
297
- setFieldValue: () => {
298
- }
299
- }, n = L(() => r.flows ? Be(r.flows).edges : [], [r.flows]);
300
- return {
301
- ...r,
302
- edges: n
303
- };
304
- }, I = (e) => {
305
- const r = te(), n = e ?? r.language;
306
- return Qe(n);
307
- }, jt = (e) => e.filter(q), Nt = (e, r) => {
308
- const n = r.find((a) => a.id === e);
309
- return n ? n.data.name || n.id : void 0;
310
- }, vt = (e, r = {}, n = "en") => {
311
- const a = L(() => Be(e), [e]), { nodes: s, edges: l } = a, i = L(() => jt(s), [s]), o = I(n), [d, m] = E({}), [c, f] = E(() => {
312
- const N = { ...r };
313
- return s.forEach((y) => {
314
- if (q(y)) {
315
- const j = y.id;
316
- if (N[j] !== void 0)
317
- return;
318
- const { defaultValue: g } = y.data;
319
- if (!g)
320
- return;
321
- if (g.type === "static" && g.staticValue !== void 0 && (N[j] = g.staticValue), g.type === "reference" && g.referenceField) {
322
- const { referenceField: w } = g, T = N[w];
323
- T !== void 0 && (N[j] = T);
324
- }
325
- }
326
- }), N;
327
- }), { endOfPathReached: p, visibleNodes: x, visibleRootNodes: v } = L(
328
- () => ft(s, l, c),
329
- [s, l, c]
330
- ), h = V((N, y) => {
331
- f((j) => ({
332
- ...j,
333
- [N]: y
334
- })), m((j) => {
335
- const g = { ...j };
336
- return delete g[N], g;
337
- });
338
- }, []), u = V(
339
- (N) => {
340
- const y = {};
341
- x.forEach((w) => {
342
- if (q(w)) {
343
- const T = w.id, _ = c[T];
344
- if (w.data.required && de(_)) {
345
- y[T] = o(w.data.errorMessage) || o("validation.required");
346
- return;
347
- }
348
- if (!de(_) && w.data.pattern)
349
- try {
350
- new RegExp(w.data.pattern).test(String(_)) || (y[T] = o(w.data.errorMessage) || o("validation.invalidFormat"));
351
- } catch (R) {
352
- console.error(`Invalid pattern for field ${T}:`, R);
353
- }
354
- }
355
- });
356
- const j = N ? N(c, x) : {}, g = {
357
- ...y,
358
- ...j
359
- };
360
- return m(g), {
361
- errors: g,
362
- hasCustomErrors: Object.keys(j).length > 0,
363
- isValid: Object.keys(g).length === 0
364
- };
365
- },
366
- [x, c, o]
367
- ), S = L(() => {
368
- const N = [];
369
- return x.forEach((y) => {
370
- if (!q(y))
371
- return;
372
- const j = y.id, g = c[j];
373
- if (y.data.required && de(g)) {
374
- const w = o(y.data.label) || j;
375
- N.push(w);
376
- }
377
- }), N;
378
- }, [x, c, o]);
379
- return {
380
- canSubmit: p && s.length > 0,
381
- formErrors: d,
382
- formValues: c,
383
- inputNodes: i,
384
- mergedFlow: a,
385
- missingRequiredFields: S,
386
- setFieldValue: h,
387
- setFormErrors: m,
388
- t: o,
389
- validateForm: u,
390
- visibleNodes: x,
391
- visibleRootNodes: v
392
- };
393
- }, yt = ({ children: e, onSubmit: r }) => /* @__PURE__ */ t.jsx("form", { onSubmit: r, className: "mx-auto max-w-2xl gap-y-3", children: e }), wt = ({ node: e, children: r }) => {
394
- const n = I();
395
- return /* @__PURE__ */ t.jsxs("section", { className: "mb-6 rounded-lg border p-4", children: [
396
- e.data.label && /* @__PURE__ */ t.jsx("h3", { className: "text-lg font-semibold mb-4", children: n(e.data.label) }),
397
- r
398
- ] });
399
- }, Tt = async (e, r) => {
400
- if (!e || e.trim().length < 3)
401
- return [];
402
- try {
403
- const n = await fetch(
404
- `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(e)}&format=jsonv2&addressdetails=1&limit=5`,
405
- {
406
- headers: {
407
- Accept: "application/json",
408
- "User-Agent": "Treege Renderer",
409
- ...r && { "Accept-Language": r }
410
- }
411
- }
412
- );
413
- return n.ok ? (await n.json()).map((s) => ({
414
- label: s.display_name,
415
- value: s.display_name
416
- })) : [];
417
- } catch (n) {
418
- return console.error("Nominatim fetch error:", n), [];
419
- }
420
- }, Ft = (e) => !e || e.trim().length < 3 ? Promise.resolve([]) : new Promise((r) => {
421
- if (!window.google?.maps?.places) {
422
- console.warn("Google Places SDK not loaded yet"), r([]);
423
- return;
424
- }
425
- new window.google.maps.places.AutocompleteService().getPlacePredictions({ input: e }, (a, s) => {
426
- if (s !== google.maps.places.PlacesServiceStatus.OK || !a) {
427
- console.warn("Google Places API status:", s), r([]);
428
- return;
429
- }
430
- r(
431
- a.map((l) => ({
432
- label: l.description,
433
- value: l.description
434
- }))
435
- );
436
- });
437
- }), St = ({ node: e, value: r, setValue: n, error: a }) => {
438
- const [s, l] = E(""), [i, o] = E([]), [d, m] = E(!1), { googleApiKey: c, language: f } = te(), p = I(), x = e.data.name || e.id, v = V(
439
- (u) => {
440
- n(u.value), l(u.value), m(!1);
441
- },
442
- [n]
443
- );
444
- B(() => {
445
- if (!s || s.trim().length < 3) {
446
- o([]);
447
- return;
448
- }
449
- const u = setTimeout(async () => {
450
- const S = c ? await Ft(s) : await Tt(s, f);
451
- o(S);
452
- }, 300);
453
- return () => clearTimeout(u);
454
- }, [s, c, f]);
455
- const h = V(
456
- (u) => {
457
- n(u), l(u), u.length >= 3 && m(!0);
458
- },
459
- [n]
460
- );
461
- return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
462
- c && /* @__PURE__ */ t.jsx("script", { async: !0, src: `https://maps.googleapis.com/maps/api/js?key=${c}&libraries=places` }),
463
- /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
464
- /* @__PURE__ */ t.jsxs(F, { htmlFor: x, children: [
465
- p(e.data.label) || e.data.name,
466
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
467
- ] }),
468
- /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
469
- /* @__PURE__ */ t.jsx(
470
- z,
471
- {
472
- type: "text",
473
- id: x,
474
- name: x,
475
- value: r || "",
476
- onChange: (u) => h(u.target.value),
477
- onFocus: () => {
478
- i.length > 0 && m(!0);
479
- },
480
- placeholder: p(e.data.placeholder) || p("renderer.defaultAddressInput.enterAddress"),
481
- className: "pr-10",
482
- autoComplete: "off"
483
- }
484
- ),
485
- /* @__PURE__ */ t.jsx(we, { className: "-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 h-4 w-4 text-muted-foreground" }),
486
- d && /* @__PURE__ */ t.jsx("div", { className: "absolute z-50 mt-1 w-full rounded-md border bg-popover shadow-md", children: /* @__PURE__ */ t.jsx(pe, { children: /* @__PURE__ */ t.jsxs(fe, { children: [
487
- /* @__PURE__ */ t.jsx(xe, { children: p("renderer.defaultAddressInput.noAddressesFound") }),
488
- /* @__PURE__ */ t.jsx(ge, { children: i.map((u, S) => /* @__PURE__ */ t.jsxs(
489
- be,
490
- {
491
- value: u.value,
492
- onSelect: () => v(u),
493
- onMouseDown: (N) => N.preventDefault(),
494
- children: [
495
- /* @__PURE__ */ t.jsx(we, { className: "mr-2 h-4 w-4" }),
496
- u.label
497
- ]
498
- },
499
- S
500
- )) })
501
- ] }) }) })
502
- ] }),
503
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
504
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: p(e.data.helperText) })
505
- ] })
506
- ] });
507
- }, Ct = ({ node: e, value: r, setValue: n, error: a }) => {
508
- const s = I(), [l, i] = E(!1), o = e.data.name || e.id, d = `${o}-trigger`, m = `${o}-error`, c = e.data.options || [], f = c.find((p) => p.value === r);
509
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
510
- /* @__PURE__ */ t.jsxs(F, { htmlFor: d, children: [
511
- s(e.data.label) || e.data.name,
512
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
513
- ] }),
514
- /* @__PURE__ */ t.jsxs(Y, { open: l, onOpenChange: i, children: [
515
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
516
- H,
517
- {
518
- id: d,
519
- variant: "outline",
520
- role: "combobox",
521
- "aria-expanded": l,
522
- "aria-invalid": !!a || void 0,
523
- "aria-describedby": a ? m : void 0,
524
- className: "w-full justify-between font-normal",
525
- children: [
526
- r ? f?.label ? s(f.label) : r : s(e.data.placeholder) || s("renderer.defaultAutocompleteInput.selectOption"),
527
- /* @__PURE__ */ t.jsx(Pe, { className: "ml-2 size-4 shrink-0 opacity-50" })
528
- ]
529
- }
530
- ) }),
531
- /* @__PURE__ */ t.jsx(ee, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ t.jsxs(pe, { children: [
532
- /* @__PURE__ */ t.jsx(Se, { placeholder: s(e.data.placeholder) || s("renderer.defaultAutocompleteInput.search") }),
533
- /* @__PURE__ */ t.jsxs(fe, { children: [
534
- /* @__PURE__ */ t.jsx(xe, { children: s("renderer.defaultAutocompleteInput.noResults") }),
535
- /* @__PURE__ */ t.jsx(ge, { children: c.map((p) => /* @__PURE__ */ t.jsxs(
536
- be,
537
- {
538
- value: p.value,
539
- disabled: p.disabled,
540
- onSelect: (x) => {
541
- n(x === r ? "" : x), i(!1);
542
- },
543
- children: [
544
- /* @__PURE__ */ t.jsx(Oe, { className: b("mr-2 size-4", r === p.value ? "opacity-100" : "opacity-0") }),
545
- s(p.label)
546
- ]
547
- },
548
- p.value
549
- )) })
550
- ] })
551
- ] }) })
552
- ] }),
553
- a && /* @__PURE__ */ t.jsx(k, { id: m, children: a }),
554
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
555
- ] });
556
- }, It = ({ node: e, value: r, setValue: n, error: a }) => {
557
- const s = I(), l = e.data.name || e.id;
558
- if (e.data.options && e.data.options.length > 0) {
559
- const i = Array.isArray(r) ? r.map(String) : [], o = (d, m) => {
560
- const c = m ? [...i, d] : i.filter((f) => f !== d);
561
- n(c);
562
- };
563
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
564
- /* @__PURE__ */ t.jsxs(F, { className: "mb-1", children: [
565
- s(e.data.label) || e.data.name,
566
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
567
- ] }),
568
- /* @__PURE__ */ t.jsx("div", { className: "space-y-2", children: e.data.options.map((d, m) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
569
- /* @__PURE__ */ t.jsx(
570
- Ne,
571
- {
572
- id: `${l}-${d.value}`,
573
- checked: i.includes(String(d.value)),
574
- onCheckedChange: (c) => o(String(d.value), !!c),
575
- disabled: d.disabled
576
- }
577
- ),
578
- /* @__PURE__ */ t.jsx(F, { htmlFor: `${l}-${d.value}`, className: "cursor-pointer font-normal text-sm", children: s(d.label) ? s(d.label) : d.value })
579
- ] }, d.value + m)) }),
580
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
581
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
582
- ] });
583
- }
584
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
585
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
586
- /* @__PURE__ */ t.jsx(
587
- Ne,
588
- {
589
- id: l,
590
- checked: typeof r == "boolean" ? r : !1,
591
- onCheckedChange: (i) => n(!!i)
592
- }
593
- ),
594
- /* @__PURE__ */ t.jsxs("div", { children: [
595
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, className: "cursor-pointer font-medium text-sm", children: [
596
- s(e.data.label) || e.data.name,
597
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
598
- ] }),
599
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
600
- ] })
601
- ] }),
602
- a && /* @__PURE__ */ t.jsx(k, { children: a })
603
- ] });
604
- };
605
- function Le({
606
- className: e,
607
- classNames: r,
608
- showOutsideDays: n = !0,
609
- captionLayout: a = "label",
610
- buttonVariant: s = "ghost",
611
- formatters: l,
612
- components: i,
613
- ...o
614
- }) {
615
- const d = ze();
616
- return /* @__PURE__ */ t.jsx(
617
- nt,
618
- {
619
- showOutsideDays: n,
620
- className: b(
621
- "group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
622
- String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
623
- String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
624
- e
625
- ),
626
- captionLayout: a,
627
- formatters: {
628
- formatMonthDropdown: (m) => m.toLocaleString("default", { month: "short" }),
629
- ...l
630
- },
631
- classNames: {
632
- button_next: b(
633
- ve({ variant: s }),
634
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
635
- d.button_next
636
- ),
637
- button_previous: b(
638
- ve({ variant: s }),
639
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
640
- d.button_previous
641
- ),
642
- caption_label: b(
643
- "select-none font-medium",
644
- a === "label" ? "text-sm" : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
645
- d.caption_label
646
- ),
647
- day: b(
648
- "relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
649
- d.day
650
- ),
651
- disabled: b("text-muted-foreground opacity-50", d.disabled),
652
- dropdown: b("absolute bg-popover inset-0 opacity-0", d.dropdown),
653
- dropdown_root: b(
654
- "relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
655
- d.dropdown_root
656
- ),
657
- dropdowns: b("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", d.dropdowns),
658
- hidden: b("invisible", d.hidden),
659
- month: b("flex flex-col w-full gap-4", d.month),
660
- month_caption: b("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", d.month_caption),
661
- months: b("flex gap-4 flex-col md:flex-row relative", d.months),
662
- nav: b("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", d.nav),
663
- outside: b("text-muted-foreground aria-selected:text-muted-foreground", d.outside),
664
- range_end: b("rounded-r-md bg-accent", d.range_end),
665
- range_middle: b("rounded-none", d.range_middle),
666
- range_start: b("rounded-l-md bg-accent", d.range_start),
667
- root: b("w-fit", d.root),
668
- table: "w-full border-collapse",
669
- today: b("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none", d.today),
670
- week: b("flex w-full mt-2", d.week),
671
- week_number: b("text-[0.8rem] select-none text-muted-foreground", d.week_number),
672
- week_number_header: b("select-none w-(--cell-size)", d.week_number_header),
673
- weekday: b("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", d.weekday),
674
- weekdays: b("flex", d.weekdays),
675
- ...r
676
- },
677
- components: {
678
- Chevron: ({ className: m, orientation: c, ...f }) => c === "left" ? /* @__PURE__ */ t.jsx(at, { className: b("size-4", m), ...f }) : c === "right" ? /* @__PURE__ */ t.jsx(st, { className: b("size-4", m), ...f }) : /* @__PURE__ */ t.jsx(je, { className: b("size-4", m), ...f }),
679
- DayButton: Dt,
680
- Root: ({ className: m, rootRef: c, ...f }) => /* @__PURE__ */ t.jsx("div", { "data-slot": "calendar", ref: c, className: b(m), ...f }),
681
- WeekNumber: ({ children: m, ...c }) => /* @__PURE__ */ t.jsx("td", { ...c, children: /* @__PURE__ */ t.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children: m }) }),
682
- ...i
683
- },
684
- ...o
685
- }
686
- );
687
- }
688
- function Dt({ className: e, day: r, modifiers: n, ...a }) {
689
- const s = ze(), l = ye.useRef(null);
690
- return ye.useEffect(() => {
691
- n.focused && l.current?.focus();
692
- }, [n.focused]), /* @__PURE__ */ t.jsx(
693
- H,
694
- {
695
- ref: l,
696
- variant: "ghost",
697
- size: "icon",
698
- "data-day": r.date.toLocaleDateString(),
699
- "data-selected-single": n.selected && !n.range_start && !n.range_end && !n.range_middle,
700
- "data-range-start": n.range_start,
701
- "data-range-end": n.range_end,
702
- "data-range-middle": n.range_middle,
703
- className: b(
704
- "flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-start=true]:rounded-l-md data-[range-end=true]:bg-primary data-[range-middle=true]:bg-accent data-[range-start=true]:bg-primary data-[selected-single=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:text-accent-foreground data-[range-start=true]:text-primary-foreground data-[selected-single=true]:text-primary-foreground group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
705
- s.day,
706
- e
707
- ),
708
- ...a
709
- }
710
- );
711
- }
712
- const kt = ({ node: e, value: r, setValue: n, error: a }) => {
713
- const s = I(), l = e.data.name || e.id, [i, o] = E(!1), d = r ? new Date(r) : void 0;
714
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
715
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
716
- s(e.data.label) || e.data.name,
717
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
718
- ] }),
719
- /* @__PURE__ */ t.jsxs(Y, { open: i, onOpenChange: o, children: [
720
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(H, { variant: "outline", id: l, className: "w-full justify-between font-normal", children: [
721
- d ? d.toLocaleDateString() : s(e.data.placeholder) || s("renderer.defaultInputs.selectDate"),
722
- /* @__PURE__ */ t.jsx(je, { className: "size-4" })
723
- ] }) }),
724
- /* @__PURE__ */ t.jsx(ee, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
725
- Le,
726
- {
727
- mode: "single",
728
- selected: d,
729
- captionLayout: "dropdown",
730
- onSelect: (m) => {
731
- n(m ? m.toISOString() : ""), o(!1);
732
- }
733
- }
734
- ) })
735
- ] }),
736
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
737
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
738
- ] });
739
- }, At = ({ node: e, value: r, setValue: n, error: a }) => {
740
- const s = I(), [l, i] = E(!1), o = Array.isArray(r) ? r : [], d = o[0] ? new Date(o[0]) : void 0, m = o[1] ? new Date(o[1]) : void 0, c = (p) => {
741
- n([p?.from ? p.from.toISOString() : void 0, p?.to ? p.to.toISOString() : void 0]);
742
- }, f = () => d && m ? `${d.toLocaleDateString()} - ${m.toLocaleDateString()}` : d ? d.toLocaleDateString() : s("renderer.defaultInputs.selectDateRange");
743
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
744
- /* @__PURE__ */ t.jsxs(F, { children: [
745
- s(e.data.label) || e.data.name,
746
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
747
- ] }),
748
- /* @__PURE__ */ t.jsxs(Y, { open: l, onOpenChange: i, children: [
749
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(H, { variant: "outline", className: "w-full justify-between font-normal", children: [
750
- f(),
751
- /* @__PURE__ */ t.jsx(je, { className: "size-4" })
752
- ] }) }),
753
- /* @__PURE__ */ t.jsx(ee, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
754
- Le,
755
- {
756
- mode: "range",
757
- selected: { from: d, to: m },
758
- captionLayout: "dropdown",
759
- onSelect: c,
760
- numberOfMonths: 2
761
- }
762
- ) })
763
- ] }),
764
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
765
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
766
- ] });
767
- }, Ge = (e) => new Promise((r, n) => {
768
- const a = new FileReader();
769
- a.onload = () => {
770
- const s = a.result;
771
- r({
772
- data: s,
773
- lastModified: e.lastModified,
774
- name: e.name,
775
- size: e.size,
776
- type: e.type
777
- });
778
- }, a.onerror = () => {
779
- n(new Error(`Failed to read file: ${e.name}`));
780
- }, a.readAsDataURL(e);
781
- }), ia = (e) => {
782
- const r = e.data.split(",")[1], n = atob(r), a = new ArrayBuffer(n.length), s = new Uint8Array(a);
783
- for (let i = 0; i < n.length; i++)
784
- s[i] = n.charCodeAt(i);
785
- const l = new Blob([a], { type: e.type });
786
- return new File([l], e.name, {
787
- lastModified: e.lastModified,
788
- type: e.type
789
- });
790
- }, Rt = (e) => Promise.all(e.map((r) => Ge(r))), Et = ({ node: e, setValue: r, error: n }) => {
791
- const a = I(), s = e.data.name || e.id, l = async (i) => {
792
- const { files: o } = i.target;
793
- if (!o || o.length === 0) {
794
- r(null);
795
- return;
796
- }
797
- if (e.data.multiple) {
798
- const m = await Rt(Array.from(o));
799
- r(m);
800
- return;
801
- }
802
- const d = await Ge(o[0]);
803
- r(d);
804
- };
805
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
806
- /* @__PURE__ */ t.jsxs(F, { htmlFor: s, children: [
807
- a(e.data.label) || e.data.name,
808
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
809
- ] }),
810
- /* @__PURE__ */ t.jsx(
811
- z,
812
- {
813
- type: "file",
814
- id: s,
815
- name: s,
816
- onChange: l,
817
- multiple: e.data.multiple,
818
- placeholder: a(e.data.placeholder)
819
- }
820
- ),
821
- n && /* @__PURE__ */ t.jsx(k, { children: n }),
822
- e.data.helperText && !n && /* @__PURE__ */ t.jsx(A, { children: a(e.data.helperText) })
823
- ] });
824
- }, _t = ({ node: e, value: r }) => {
825
- const n = e.data.name || e.id;
826
- return /* @__PURE__ */ t.jsx(z, { type: "hidden", name: n, value: r ?? "" });
827
- }, ce = (e, r) => r ? r.split(".").reduce((a, s) => {
828
- if (a == null)
829
- return;
830
- const l = s.match(/^(\w+)\[(\d+)]$/);
831
- if (l) {
832
- const [, i, o] = l, d = a[i];
833
- return Array.isArray(d) ? d[Number.parseInt(o, 10)] : d;
834
- }
835
- return a[s];
836
- }, e) : e, ue = (e, r) => e.replace(/{{(\w+)}}/g, (n, a) => String(r[a] || "")), Pt = ({ node: e, value: r, setValue: n, error: a }) => {
837
- const [s, l] = E(!1), [i, o] = E(null), [d, m] = E([]), [c, f] = E(""), [p, x] = E(!1), { formValues: v } = te(), h = I(), { httpConfig: u } = e.data, S = e.data.name || e.id, N = me(!1), y = V(
838
- async (j) => {
839
- if (!u?.url) {
840
- o(h("renderer.defaultHttpInput.noUrlConfigured"));
841
- return;
842
- }
843
- l(!0), o(null);
844
- try {
845
- const g = ue(u.url, v), w = u.searchParam && j ? `${g}${g.includes("?") ? "&" : "?"}${u.searchParam}=${encodeURIComponent(j)}` : g, T = {};
846
- u.headers?.forEach((M) => {
847
- T[M.key] = ue(M.value, v);
848
- });
849
- const _ = u.body && ["POST", "PUT", "PATCH"].includes(u.method || "") ? ue(u.body, v) : void 0, R = await fetch(w, {
850
- body: _ || void 0,
851
- headers: {
852
- "Content-Type": "application/json",
853
- ...T
854
- },
855
- method: u.method || "GET"
856
- });
857
- if (!R.ok) {
858
- o(`HTTP ${R.status}: ${R.statusText}`), l(!1);
859
- return;
860
- }
861
- const U = await R.json(), $ = u.responsePath ? ce(U, u.responsePath) : U;
862
- if (u.responseMapping && Array.isArray($)) {
863
- const { valueField: M = "value", labelField: ae = "label" } = u.responseMapping, K = $.map((C) => ({
864
- label: String(ce(C, ae) || ""),
865
- value: String(ce(C, M) || "")
866
- }));
867
- m(K);
868
- } else
869
- n(typeof $ == "string" ? $ : JSON.stringify($));
870
- } catch (g) {
871
- const w = g instanceof Error ? g.message : h("renderer.defaultHttpInput.fetchFailed");
872
- o(w), console.error("HTTP Input fetch error:", g);
873
- } finally {
874
- l(!1);
875
- }
876
- },
877
- [u, v, n, h]
878
- );
879
- if (B(() => {
880
- u?.fetchOnMount && !N.current && (N.current = !0, y());
881
- }, [u?.fetchOnMount, y]), B(() => {
882
- if (!(u?.searchParam && c))
883
- return;
884
- const j = setTimeout(() => {
885
- y(c);
886
- }, 300);
887
- return () => clearTimeout(j);
888
- }, [c, u?.searchParam, y]), u?.responseMapping) {
889
- const j = Array.isArray(r) ? r[0] : r, g = d.find((T) => T.value === j);
890
- if (u.searchParam) {
891
- const _ = s && u?.showLoading ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
892
- /* @__PURE__ */ t.jsx(ie, { className: "h-4 w-4 animate-spin" }),
893
- /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: g?.label || h(e.data.placeholder) || "Search..." })
894
- ] }) : g?.label || h(e.data.placeholder) || "Search...";
895
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
896
- /* @__PURE__ */ t.jsxs(F, { children: [
897
- h(e.data.label) || e.data.name,
898
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
899
- ] }),
900
- /* @__PURE__ */ t.jsxs(Y, { open: p, onOpenChange: x, children: [
901
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(H, { variant: "outline", role: "combobox", "aria-expanded": p, className: "w-full justify-between", children: [
902
- _,
903
- /* @__PURE__ */ t.jsx(Pe, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
904
- ] }) }),
905
- /* @__PURE__ */ t.jsx(ee, { className: "w-[300px] p-0", align: "start", children: /* @__PURE__ */ t.jsxs(pe, { shouldFilter: !1, children: [
906
- /* @__PURE__ */ t.jsx(
907
- Se,
908
- {
909
- placeholder: "Search...",
910
- value: c,
911
- onValueChange: (R) => {
912
- f(R), o(null);
913
- }
914
- }
915
- ),
916
- /* @__PURE__ */ t.jsxs(fe, { children: [
917
- s && /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ t.jsx(ie, { className: "h-4 w-4 animate-spin" }) }),
918
- !s && i && /* @__PURE__ */ t.jsxs("div", { className: "p-4 text-destructive text-sm", children: [
919
- /* @__PURE__ */ t.jsx("div", { children: i }),
920
- /* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => y(c), className: "mt-2 block text-primary hover:underline", children: "Retry" })
921
- ] }),
922
- !(s || i) && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
923
- /* @__PURE__ */ t.jsx(xe, { children: "No results found." }),
924
- /* @__PURE__ */ t.jsx(ge, { children: d.map((R) => /* @__PURE__ */ t.jsxs(
925
- be,
926
- {
927
- value: R.value,
928
- onSelect: () => {
929
- n(R.value), x(!1);
930
- },
931
- children: [
932
- /* @__PURE__ */ t.jsx(Oe, { className: b("mr-2 h-4 w-4", r === R.value ? "opacity-100" : "opacity-0") }),
933
- R.label
934
- ]
935
- },
936
- R.value
937
- )) })
938
- ] })
939
- ] })
940
- ] }) })
941
- ] }),
942
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
943
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
944
- ] });
945
- }
946
- const w = s && u?.showLoading;
947
- return d.length === 0 && !w ? /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
948
- /* @__PURE__ */ t.jsxs(F, { htmlFor: S, children: [
949
- h(e.data.label) || e.data.name,
950
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
951
- ] }),
952
- /* @__PURE__ */ t.jsx("div", { className: "py-2 text-muted-foreground text-sm", children: 'No data available. Configure "Fetch on mount" or add a search parameter.' }),
953
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
954
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
955
- ] }) : /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
956
- /* @__PURE__ */ t.jsxs(F, { htmlFor: S, children: [
957
- h(e.data.label) || e.data.name,
958
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
959
- ] }),
960
- /* @__PURE__ */ t.jsxs(Ce, { value: Array.isArray(r) ? r[0] ?? "" : r ?? "", onValueChange: (T) => n(T), disabled: w, children: [
961
- /* @__PURE__ */ t.jsxs(Ie, { id: S, className: "w-full", children: [
962
- w && /* @__PURE__ */ t.jsx(ie, { className: "mr-2 h-4 w-4 animate-spin" }),
963
- /* @__PURE__ */ t.jsx(De, { placeholder: h(e.data.placeholder) || h("renderer.defaultHttpInput.selectOption") })
964
- ] }),
965
- /* @__PURE__ */ t.jsx(ke, { children: /* @__PURE__ */ t.jsx(Ae, { children: d.map((T, _) => /* @__PURE__ */ t.jsx(Re, { value: T.value, children: T.label }, T.value + _)) }) })
966
- ] }),
967
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
968
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
969
- ] });
970
- }
971
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
972
- /* @__PURE__ */ t.jsxs(F, { htmlFor: S, children: [
973
- h(e.data.label) || e.data.name,
974
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
975
- ] }),
976
- /* @__PURE__ */ t.jsx(z, { type: "text", id: S, name: S, value: typeof r == "string" ? r : JSON.stringify(r), readOnly: !0, disabled: !0 }),
977
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
978
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
979
- ] });
980
- }, Ot = ({ node: e, value: r, setValue: n, error: a }) => {
981
- const s = I(), l = e.data.name || e.id;
982
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
983
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
984
- s(e.data.label) || e.data.name,
985
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
986
- ] }),
987
- /* @__PURE__ */ t.jsx(
988
- z,
989
- {
990
- type: "number",
991
- id: l,
992
- name: l,
993
- value: r ?? "",
994
- onChange: (i) => n(i.target.value === "" ? null : Number(i.target.value)),
995
- placeholder: s(e.data.placeholder)
996
- }
997
- ),
998
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
999
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1000
- ] });
1001
- }, zt = ({ node: e, value: r, setValue: n, error: a }) => {
1002
- const s = I(), l = e.data.name || e.id;
1003
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1004
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1005
- s(e.data.label) || e.data.name,
1006
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1007
- ] }),
1008
- /* @__PURE__ */ t.jsx(
1009
- z,
1010
- {
1011
- type: "password",
1012
- id: l,
1013
- name: l,
1014
- value: r ?? "",
1015
- onChange: (i) => n(i.target.value),
1016
- placeholder: s(e.data.placeholder),
1017
- autoComplete: "new-password"
1018
- }
1019
- ),
1020
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1021
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1022
- ] });
1023
- };
1024
- function $t({ className: e, ...r }) {
1025
- return /* @__PURE__ */ t.jsx(he.Root, { "data-slot": "radio-group", className: b("grid gap-3", e), ...r });
1026
- }
1027
- function Mt({ className: e, ...r }) {
1028
- return /* @__PURE__ */ t.jsx(
1029
- he.Item,
1030
- {
1031
- "data-slot": "radio-group-item",
1032
- className: b(
1033
- "border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
1034
- e
1035
- ),
1036
- ...r,
1037
- children: /* @__PURE__ */ t.jsx(he.Indicator, { "data-slot": "radio-group-indicator", className: "relative flex items-center justify-center", children: /* @__PURE__ */ t.jsx(rt, { className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" }) })
1038
- }
1039
- );
1040
- }
1041
- const qt = ({ node: e, value: r, setValue: n, error: a }) => {
1042
- const s = I(), l = e.data.name || e.id, i = r ? String(r) : "";
1043
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1044
- /* @__PURE__ */ t.jsxs(F, { className: "mb-1", children: [
1045
- s(e.data.label) || e.data.name,
1046
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1047
- ] }),
1048
- /* @__PURE__ */ t.jsx($t, { value: i, onValueChange: (o) => n(o), children: e.data.options?.map((o, d) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-2", children: [
1049
- /* @__PURE__ */ t.jsx(Mt, { value: String(o.value), id: `${l}-${o.value}`, disabled: o.disabled }),
1050
- /* @__PURE__ */ t.jsx(F, { htmlFor: `${l}-${o.value}`, className: "cursor-pointer font-normal text-sm", children: s(o.label) ? s(o.label) : o.value })
1051
- ] }, o.value + d)) }),
1052
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1053
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1054
- ] });
1055
- }, Bt = ({ node: e, value: r, setValue: n, error: a }) => {
1056
- const s = I(), l = e.data.name || e.id, i = r ? String(r) : "";
1057
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1058
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1059
- s(e.data.label) || e.data.name,
1060
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1061
- ] }),
1062
- /* @__PURE__ */ t.jsxs(Ce, { value: i, onValueChange: (o) => n(o), children: [
1063
- /* @__PURE__ */ t.jsx(Ie, { id: l, className: "w-full", children: /* @__PURE__ */ t.jsx(De, { placeholder: s(e.data.placeholder) || s("renderer.defaultSelectInput.selectOption") }) }),
1064
- /* @__PURE__ */ t.jsx(ke, { children: /* @__PURE__ */ t.jsx(Ae, { children: e.data.options?.map((o, d) => /* @__PURE__ */ t.jsx(Re, { value: String(o.value), disabled: o.disabled, children: s(o.label) ? s(o.label) : o.value }, `${o.value}-${d}`)) }) })
1065
- ] }),
1066
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1067
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1068
- ] });
1069
- }, Vt = ({ node: e, value: r, setValue: n, error: a }) => {
1070
- const s = I(), l = e.data.name || e.id;
1071
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1072
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1073
- s(e.data.label) || e.data.name,
1074
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1075
- ] }),
1076
- /* @__PURE__ */ t.jsx(Xe, { id: l, checked: r, onCheckedChange: n }),
1077
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) }),
1078
- a && /* @__PURE__ */ t.jsx(k, { children: a })
1079
- ] });
1080
- }, Lt = ({ node: e, value: r, setValue: n, error: a }) => {
1081
- const s = I(), l = e.data.name || e.id;
1082
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1083
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1084
- s(e.data.label) || e.data.name,
1085
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1086
- ] }),
1087
- /* @__PURE__ */ t.jsx(
1088
- Ye,
1089
- {
1090
- id: l,
1091
- name: l,
1092
- value: r ?? "",
1093
- onChange: (i) => n(i.target.value),
1094
- placeholder: s(e.data.placeholder),
1095
- className: "w-full rounded-md border px-3 py-2",
1096
- rows: 4
1097
- }
1098
- ),
1099
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1100
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1101
- ] });
1102
- }, Gt = ({ node: e, value: r, setValue: n, error: a }) => {
1103
- const s = I(), l = e.data.name || e.id;
1104
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1105
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1106
- s(e.data.label) || e.data.name,
1107
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1108
- ] }),
1109
- /* @__PURE__ */ t.jsx(
1110
- z,
1111
- {
1112
- type: "text",
1113
- id: l,
1114
- name: l,
1115
- value: r ?? "",
1116
- onChange: (i) => n(i.target.value),
1117
- placeholder: s(e.data.placeholder)
1118
- }
1119
- ),
1120
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1121
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1122
- ] });
1123
- }, Ut = ({ node: e, value: r, setValue: n, error: a }) => {
1124
- const s = I(), l = e.data.name || e.id;
1125
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1126
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1127
- s(e.data.label) || e.data.name,
1128
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1129
- ] }),
1130
- /* @__PURE__ */ t.jsx(
1131
- z,
1132
- {
1133
- type: "time",
1134
- id: l,
1135
- name: l,
1136
- value: r ?? "",
1137
- onChange: (i) => n(i.target.value),
1138
- placeholder: s(e.data.placeholder),
1139
- className: "bg-background [color-scheme:light] dark:[color-scheme:dark]"
1140
- }
1141
- ),
1142
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1143
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1144
- ] });
1145
- }, Wt = ({ node: e, value: r, setValue: n, error: a }) => {
1146
- const s = I(), l = Array.isArray(r) ? r : [], i = l[0] || "", o = l[1] || "", d = (c) => {
1147
- n([c, o]);
1148
- }, m = (c) => {
1149
- n([i, c]);
1150
- };
1151
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1152
- /* @__PURE__ */ t.jsxs(F, { children: [
1153
- s(e.data.label) || e.data.name,
1154
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1155
- ] }),
1156
- /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2", children: [
1157
- /* @__PURE__ */ t.jsx(
1158
- z,
1159
- {
1160
- "aria-label": `${s(e.data.label) || e.data.name} - ${s("renderer.defaultInputs.startTime")}`,
1161
- "aria-invalid": !!a,
1162
- "aria-describedby": a ? `${e.id}-error` : void 0,
1163
- type: "time",
1164
- value: i,
1165
- onChange: (c) => d(c.target.value),
1166
- placeholder: s("renderer.defaultInputs.startTime"),
1167
- className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
1168
- }
1169
- ),
1170
- /* @__PURE__ */ t.jsx(
1171
- z,
1172
- {
1173
- "aria-label": `${s(e.data.label) || e.data.name} - ${s("renderer.defaultInputs.endTime")}`,
1174
- "aria-invalid": !!a,
1175
- "aria-describedby": a ? `${e.id}-error` : void 0,
1176
- type: "time",
1177
- value: o,
1178
- onChange: (c) => m(c.target.value),
1179
- placeholder: s("renderer.defaultInputs.endTime"),
1180
- className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
1181
- }
1182
- )
1183
- ] }),
1184
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1185
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1186
- ] });
1187
- }, Ht = {
1188
- address: St,
1189
- autocomplete: Ct,
1190
- checkbox: It,
1191
- date: kt,
1192
- daterange: At,
1193
- file: Et,
1194
- hidden: _t,
1195
- http: Pt,
1196
- number: Ot,
1197
- password: zt,
1198
- radio: qt,
1199
- select: Bt,
1200
- switch: Vt,
1201
- text: Gt,
1202
- textarea: Lt,
1203
- time: Ut,
1204
- timerange: Wt
1205
- }, Kt = ({ label: e = "Submit", ...r }) => /* @__PURE__ */ t.jsx(
1206
- "button",
1207
- {
1208
- type: "submit",
1209
- className: "mt-4 rounded-md bg-blue-500 px-4 py-2 font-medium text-white transition-colors hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
1210
- ...r,
1211
- children: e
1212
- }
1213
- ), Jt = ({ node: e }) => {
1214
- const n = I()(e.data?.label);
1215
- return n ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-x-3", children: [
1216
- /* @__PURE__ */ t.jsx(le, { className: "my-8 flex-1" }),
1217
- /* @__PURE__ */ t.jsx("h4", { className: "font-semibold text-sm", children: n }),
1218
- /* @__PURE__ */ t.jsx(le, { className: "my-8 flex-1" })
1219
- ] }) : /* @__PURE__ */ t.jsx(le, { className: "my-8" });
1220
- }, Qt = ({ node: e }) => {
1221
- const { edges: r } = te(), n = I(), a = Me(e.id, r);
1222
- return /* @__PURE__ */ t.jsx("h2", { className: b("mb-5 font-bold text-2xl", !a && "mt-10"), children: n(e.data?.label) });
1223
- }, Xt = {
1224
- divider: Jt,
1225
- title: Qt
1226
- };
1227
- function Ue({ delayDuration: e = 0, ...r }) {
1228
- return /* @__PURE__ */ t.jsx(G.Provider, { "data-slot": "tooltip-provider", delayDuration: e, ...r });
1229
- }
1230
- function Yt({ ...e }) {
1231
- return /* @__PURE__ */ t.jsx(Ue, { children: /* @__PURE__ */ t.jsx(G.Root, { "data-slot": "tooltip", ...e }) });
1232
- }
1233
- function Zt({ ...e }) {
1234
- return /* @__PURE__ */ t.jsx(G.Trigger, { "data-slot": "tooltip-trigger", ...e });
1235
- }
1236
- function ea({ className: e, sideOffset: r = 0, children: n, ...a }) {
1237
- return /* @__PURE__ */ t.jsx(G.Portal, { children: /* @__PURE__ */ t.jsxs(
1238
- G.Content,
1239
- {
1240
- "data-slot": "tooltip-content",
1241
- sideOffset: r,
1242
- className: b(
1243
- "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
1244
- e
1245
- ),
1246
- ...a,
1247
- children: [
1248
- n,
1249
- /* @__PURE__ */ t.jsx(G.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
1250
- ]
1251
- }
1252
- ) });
1253
- }
1254
- const ta = ({ children: e, missingFields: r = [] }) => {
1255
- const n = r.length > 0, a = I();
1256
- return n ? /* @__PURE__ */ t.jsx(Ue, { children: /* @__PURE__ */ t.jsxs(Yt, { children: [
1257
- /* @__PURE__ */ t.jsx(Zt, { asChild: !0, children: e }),
1258
- /* @__PURE__ */ t.jsx(ea, { children: /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
1259
- /* @__PURE__ */ t.jsxs("p", { className: "font-semibold", children: [
1260
- a("renderer.defaultSubmitButton.requiredFieldsMissing"),
1261
- ":"
1262
- ] }),
1263
- /* @__PURE__ */ t.jsx("ul", { className: "list-inside list-disc", children: r.map((s, l) => /* @__PURE__ */ t.jsx("li", { children: s }, l)) })
1264
- ] }) })
1265
- ] }) }) : e;
1266
- }, oa = ({
1267
- components: e,
1268
- flows: r,
1269
- googleApiKey: n,
1270
- initialValues: a = {},
1271
- language: s,
1272
- onChange: l,
1273
- onSubmit: i,
1274
- theme: o,
1275
- validate: d,
1276
- validationMode: m
1277
- }) => {
1278
- const c = lt(), f = {
1279
- components: {
1280
- form: e?.form ?? c?.components?.form,
1281
- group: e?.group ?? c?.components?.group,
1282
- inputs: { ...c?.components?.inputs, ...e?.inputs },
1283
- submitButton: e?.submitButton ?? c?.components?.submitButton,
1284
- submitButtonWrapper: e?.submitButtonWrapper ?? c?.components?.submitButtonWrapper,
1285
- ui: { ...c?.components?.ui, ...e?.ui }
1286
- },
1287
- googleApiKey: n ?? c?.googleApiKey,
1288
- language: s ?? c?.language ?? "en",
1289
- theme: o ?? c?.theme ?? "dark",
1290
- validationMode: m ?? c?.validationMode ?? "onSubmit"
1291
- }, {
1292
- canSubmit: p,
1293
- mergedFlow: x,
1294
- formErrors: v,
1295
- formValues: h,
1296
- inputNodes: u,
1297
- missingRequiredFields: S,
1298
- visibleNodes: N,
1299
- visibleRootNodes: y,
1300
- setFieldValue: j,
1301
- validateForm: g,
1302
- t: w
1303
- } = vt(r, a, f.language), T = f.components.form || yt, _ = f.components.submitButton || Kt, R = f.components.submitButtonWrapper || ta, U = me(l), $ = me(d), M = L(() => ct(h, u), [h, u]), ae = V(
1304
- (C) => {
1305
- C.preventDefault();
1306
- const { isValid: J, errors: W } = g($.current);
1307
- if (J && i) {
1308
- i(M);
1309
- return;
1310
- }
1311
- const P = Object.keys(W)[0];
1312
- if (P) {
1313
- const O = Nt(P, u);
1314
- O && document.querySelector(`[name="${O}"]`)?.focus();
1315
- }
1316
- },
1317
- [g, i, M, u]
1318
- ), K = V(
1319
- (C) => {
1320
- const { type: J } = C;
1321
- switch (J) {
1322
- case X.input: {
1323
- if (!q(C))
1324
- return null;
1325
- const P = C.data.type || "text", O = f.components.inputs?.[P], Q = Ht[P], se = O || Q, re = C.id, We = h[re], He = v[re], Ke = (Je) => j(re, Je);
1326
- return /* @__PURE__ */ t.jsx(se, { node: C, value: We, setValue: Ke, error: He }, C.id);
1327
- }
1328
- case X.group: {
1329
- if (!et(C))
1330
- return null;
1331
- const W = f.components.group || wt, P = N.filter((O) => O.parentId === C.id);
1332
- return /* @__PURE__ */ t.jsx(W, { node: C, children: P.map((O) => K(O)) }, C.id);
1333
- }
1334
- case X.ui: {
1335
- if (!Ze(C))
1336
- return null;
1337
- const P = C.data.type || "title", O = f.components.ui?.[P], Q = Xt[P], se = O || Q;
1338
- return /* @__PURE__ */ t.jsx(se, { node: C }, C.id);
1339
- }
1340
- case X.flow:
1341
- return null;
1342
- default:
1343
- return console.warn("Unknown node type:", J), null;
1344
- }
1345
- },
1346
- [f.components, N, h, v, j]
1347
- );
1348
- return B(() => {
1349
- U.current = l;
1350
- }, [l]), B(() => {
1351
- $.current = d;
1352
- }, [d]), B(() => {
1353
- U.current?.(M);
1354
- }, [M]), B(() => {
1355
- f.validationMode === "onChange" && g($.current);
1356
- }, [f.validationMode, g]), /* @__PURE__ */ t.jsx(tt, { theme: f.theme, storageKey: "treege-renderer-theme", children: /* @__PURE__ */ t.jsx(
1357
- bt,
1358
- {
1359
- value: {
1360
- flows: x,
1361
- formErrors: v,
1362
- formValues: h,
1363
- googleApiKey: f.googleApiKey,
1364
- language: f.language,
1365
- setFieldValue: j
1366
- },
1367
- children: /* @__PURE__ */ t.jsxs(T, { onSubmit: ae, children: [
1368
- y.map((C) => K(C)),
1369
- p && /* @__PURE__ */ t.jsx(R, { missingFields: S, children: /* @__PURE__ */ t.jsx(_, { label: w("renderer.defaultSubmitButton.submit") }) })
1370
- ] })
1371
- }
1372
- ) });
1373
- };
1374
- export {
1375
- Ge as A,
1376
- ia as B,
1377
- Rt as C,
1378
- wt as D,
1379
- Me as E,
1380
- ht as F,
1381
- ft as G,
1382
- Be as H,
1383
- de as I,
1384
- dt as J,
1385
- ct as K,
1386
- la as T,
1387
- vt as a,
1388
- oa as b,
1389
- St as c,
1390
- Ct as d,
1391
- It as e,
1392
- kt as f,
1393
- At as g,
1394
- Et as h,
1395
- _t as i,
1396
- Pt as j,
1397
- Ot as k,
1398
- zt as l,
1399
- qt as m,
1400
- Bt as n,
1401
- Vt as o,
1402
- Lt as p,
1403
- Gt as q,
1404
- Ut as r,
1405
- Wt as s,
1406
- Ht as t,
1407
- lt as u,
1408
- Jt as v,
1409
- Qt as w,
1410
- Xt as x,
1411
- oe as y,
1412
- ot as z
1413
- };