treege 3.0.0-beta.28 → 3.0.0-beta.29

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.
@@ -1,1047 +0,0 @@
1
- import { j as e, T as Ze } from "./ThemeContext-BBEqRK_Q.js";
2
- import * as Re from "react";
3
- import { useState as $, useCallback as oe, useEffect as K, useRef as V, useMemo as me, forwardRef as et } from "react";
4
- import { q as R, r as ve, c as tt, f as at, k as st, p as rt, t as nt, u as lt, i as ot, a as it, v as dt, w as ct } from "./useRenderNode-BACcrUML.js";
5
- import { MapPin as Ae, ChevronsUpDown as ze, Check as Pe, ChevronLeftIcon as ut, ChevronRightIcon as mt, ChevronDownIcon as ye, Loader2 as he, CircleIcon as ht } from "lucide-react";
6
- import { F as N, L as v, I as _, C as Ne, a as we, b as Ce, c as Se, d as Ie, e as w, f as C, P as ie, g as de, B as ee, h as ce, i as _e, j as h, k as Te, l as $e, S as Oe, m as qe, n as Be, o as He, p as Ve, q as Le, r as pt, T as xt, s as pe } from "./separator-oCo7kxCK.js";
7
- import { getDefaultClassNames as Ee, DayPicker as ft } from "react-day-picker";
8
- import * as Q from "@radix-ui/react-tooltip";
9
- import * as je from "@radix-ui/react-radio-group";
10
- import "dompurify";
11
- import "cmdk";
12
- import "@radix-ui/react-dialog";
13
- import "clsx";
14
- import "tailwind-merge";
15
- import "@radix-ui/react-label";
16
- import "@radix-ui/react-popover";
17
- import "@radix-ui/react-checkbox";
18
- import "@radix-ui/react-select";
19
- import "@radix-ui/react-switch";
20
- import "@radix-ui/react-separator";
21
- const gt = ({ children: t, onSubmit: s }) => /* @__PURE__ */ e.jsx("form", { onSubmit: s, className: "mx-auto max-w-2xl gap-y-3", children: t }), jt = ({ node: t, children: s }) => {
22
- const a = R()(t.data.label);
23
- return /* @__PURE__ */ e.jsxs("section", { className: "mb-6 rounded-lg border p-4", children: [
24
- a && /* @__PURE__ */ e.jsx("h3", { className: "mb-4 font-semibold text-lg", children: a }),
25
- s
26
- ] });
27
- }, bt = async (t, s) => {
28
- if (!t || t.trim().length < 3)
29
- return [];
30
- try {
31
- const r = await fetch(
32
- `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(t)}&format=jsonv2&addressdetails=1&limit=5`,
33
- {
34
- headers: {
35
- Accept: "application/json",
36
- "User-Agent": "Treege Renderer",
37
- ...s && { "Accept-Language": s }
38
- }
39
- }
40
- );
41
- return r.ok ? (await r.json()).map((o) => ({
42
- label: o.display_name,
43
- value: o.display_name
44
- })) : [];
45
- } catch (r) {
46
- return console.error("Nominatim fetch error:", r), [];
47
- }
48
- }, vt = (t) => !t || t.trim().length < 3 ? Promise.resolve([]) : new Promise((s) => {
49
- if (!window.google?.maps?.places) {
50
- console.warn("Google Places SDK not loaded yet"), s([]);
51
- return;
52
- }
53
- new window.google.maps.places.AutocompleteService().getPlacePredictions({ input: t }, (a, o) => {
54
- if (o !== google.maps.places.PlacesServiceStatus.OK || !a) {
55
- console.warn("Google Places API status:", o), s([]);
56
- return;
57
- }
58
- s(
59
- a.map((i) => ({
60
- label: i.description,
61
- value: i.description
62
- }))
63
- );
64
- });
65
- }), yt = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, id: u, name: n }) => {
66
- const [d, m] = $(""), [c, p] = $([]), [g, x] = $(!1), { googleApiKey: f, language: I } = ve(), T = R(), M = oe(
67
- (b) => {
68
- r(b.value), m(b.value), x(!1);
69
- },
70
- [r]
71
- );
72
- K(() => {
73
- if (!d || d.trim().length < 3) {
74
- p([]);
75
- return;
76
- }
77
- const b = setTimeout(async () => {
78
- const S = f ? await vt(d) : await bt(d, I);
79
- p(S);
80
- }, 300);
81
- return () => clearTimeout(b);
82
- }, [d, f, I]);
83
- const A = oe(
84
- (b) => {
85
- r(b), m(b), b.length >= 3 && x(!0);
86
- },
87
- [r]
88
- );
89
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
90
- f && /* @__PURE__ */ e.jsx("script", { async: !0, src: `https://maps.googleapis.com/maps/api/js?key=${f}&libraries=places` }),
91
- /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
92
- /* @__PURE__ */ e.jsxs(v, { htmlFor: u, children: [
93
- o || t.data.name,
94
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
95
- ] }),
96
- /* @__PURE__ */ e.jsxs("div", { className: "relative", children: [
97
- /* @__PURE__ */ e.jsx(
98
- _,
99
- {
100
- type: "text",
101
- id: u,
102
- name: n,
103
- value: s || "",
104
- onChange: (b) => A(b.target.value),
105
- onFocus: () => {
106
- c.length > 0 && x(!0);
107
- },
108
- placeholder: i || T("renderer.defaultAddressInput.enterAddress"),
109
- className: "pr-10",
110
- autoComplete: "off"
111
- }
112
- ),
113
- /* @__PURE__ */ e.jsx(Ae, { className: "-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 h-4 w-4 text-muted-foreground" }),
114
- g && /* @__PURE__ */ e.jsx("div", { className: "absolute z-50 mt-1 w-full rounded-md border bg-popover shadow-md", children: /* @__PURE__ */ e.jsx(Ne, { children: /* @__PURE__ */ e.jsxs(we, { children: [
115
- /* @__PURE__ */ e.jsx(Ce, { children: T("renderer.defaultAddressInput.noAddressesFound") }),
116
- /* @__PURE__ */ e.jsx(Se, { children: c.map((b, S) => /* @__PURE__ */ e.jsxs(
117
- Ie,
118
- {
119
- value: b.value,
120
- onSelect: () => M(b),
121
- onMouseDown: (y) => y.preventDefault(),
122
- children: [
123
- /* @__PURE__ */ e.jsx(Ae, { className: "mr-2 h-4 w-4" }),
124
- b.label
125
- ]
126
- },
127
- S
128
- )) })
129
- ] }) }) })
130
- ] }),
131
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
132
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
133
- ] })
134
- ] });
135
- }, Nt = ({
136
- node: t,
137
- value: s,
138
- setValue: r,
139
- error: a,
140
- label: o,
141
- placeholder: i,
142
- helperText: l,
143
- id: u
144
- }) => {
145
- const n = R(), [d, m] = $(!1), c = `${u}-trigger`, p = `${u}-error`, g = t.data.options || [], x = g.find((f) => f.value === s);
146
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
147
- /* @__PURE__ */ e.jsxs(v, { htmlFor: c, children: [
148
- o || t.data.name,
149
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
150
- ] }),
151
- /* @__PURE__ */ e.jsxs(ie, { open: d, onOpenChange: m, children: [
152
- /* @__PURE__ */ e.jsx(de, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
153
- ee,
154
- {
155
- id: c,
156
- variant: "outline",
157
- role: "combobox",
158
- "aria-expanded": d,
159
- "aria-invalid": !!a || void 0,
160
- "aria-describedby": a ? p : void 0,
161
- className: "w-full justify-between font-normal",
162
- children: [
163
- s ? x?.label ? n(x.label) : s : i || n("renderer.defaultAutocompleteInput.selectOption"),
164
- /* @__PURE__ */ e.jsx(ze, { className: "ml-2 size-4 shrink-0 opacity-50" })
165
- ]
166
- }
167
- ) }),
168
- /* @__PURE__ */ e.jsx(ce, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ e.jsxs(Ne, { children: [
169
- /* @__PURE__ */ e.jsx(_e, { placeholder: i || n("renderer.defaultAutocompleteInput.search") }),
170
- /* @__PURE__ */ e.jsxs(we, { children: [
171
- /* @__PURE__ */ e.jsx(Ce, { children: n("renderer.defaultAutocompleteInput.noResults") }),
172
- /* @__PURE__ */ e.jsx(Se, { children: g.map((f) => /* @__PURE__ */ e.jsxs(
173
- Ie,
174
- {
175
- value: f.value,
176
- disabled: f.disabled,
177
- onSelect: (I) => {
178
- r(I === s ? "" : I), m(!1);
179
- },
180
- children: [
181
- /* @__PURE__ */ e.jsx(Pe, { className: h("mr-2 size-4", s === f.value ? "opacity-100" : "opacity-0") }),
182
- n(f.label)
183
- ]
184
- },
185
- f.value
186
- )) })
187
- ] })
188
- ] }) })
189
- ] }),
190
- a && /* @__PURE__ */ e.jsx(w, { id: p, children: a }),
191
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
192
- ] });
193
- }, wt = ({ node: t, value: s, setValue: r, error: a, label: o, helperText: i, id: l, name: u }) => {
194
- const n = R();
195
- if (t.data.options && t.data.options.length > 0) {
196
- const d = Array.isArray(s) ? s.map(String) : [], m = (c, p) => {
197
- const g = p ? [...d, c] : d.filter((x) => x !== c);
198
- r(g);
199
- };
200
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
201
- /* @__PURE__ */ e.jsxs(v, { className: "mb-1", children: [
202
- o || t.data.name,
203
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
204
- ] }),
205
- /* @__PURE__ */ e.jsx("div", { className: "space-y-2", children: t.data.options.map((c, p) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
206
- /* @__PURE__ */ e.jsx(
207
- Te,
208
- {
209
- id: `${l}-${c.value}`,
210
- name: u,
211
- checked: d.includes(String(c.value)),
212
- onCheckedChange: (g) => m(String(c.value), !!g),
213
- disabled: c.disabled
214
- }
215
- ),
216
- /* @__PURE__ */ e.jsx(v, { htmlFor: `${l}-${c.value}`, className: "cursor-pointer font-normal text-sm", children: n(c.label) ? n(c.label) : c.value })
217
- ] }, c.value + p)) }),
218
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
219
- i && !a && /* @__PURE__ */ e.jsx(C, { children: i })
220
- ] });
221
- }
222
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
223
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
224
- /* @__PURE__ */ e.jsx(
225
- Te,
226
- {
227
- id: l,
228
- name: u,
229
- checked: typeof s == "boolean" ? s : !1,
230
- onCheckedChange: (d) => r(!!d)
231
- }
232
- ),
233
- /* @__PURE__ */ e.jsxs("div", { children: [
234
- /* @__PURE__ */ e.jsxs(v, { htmlFor: l, className: "cursor-pointer font-medium text-sm", children: [
235
- o || t.data.name,
236
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
237
- ] }),
238
- i && !a && /* @__PURE__ */ e.jsx(C, { children: i })
239
- ] })
240
- ] }),
241
- a && /* @__PURE__ */ e.jsx(w, { children: a })
242
- ] });
243
- };
244
- function Me({
245
- className: t,
246
- classNames: s,
247
- showOutsideDays: r = !0,
248
- captionLayout: a = "label",
249
- buttonVariant: o = "ghost",
250
- formatters: i,
251
- components: l,
252
- ...u
253
- }) {
254
- const n = Ee();
255
- return /* @__PURE__ */ e.jsx(
256
- ft,
257
- {
258
- showOutsideDays: r,
259
- className: h(
260
- "group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
261
- String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
262
- String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
263
- t
264
- ),
265
- captionLayout: a,
266
- formatters: {
267
- formatMonthDropdown: (d) => d.toLocaleString("default", { month: "short" }),
268
- ...i
269
- },
270
- classNames: {
271
- button_next: h(
272
- $e({ variant: o }),
273
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
274
- n.button_next
275
- ),
276
- button_previous: h(
277
- $e({ variant: o }),
278
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
279
- n.button_previous
280
- ),
281
- caption_label: h(
282
- "select-none font-medium",
283
- 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",
284
- n.caption_label
285
- ),
286
- day: h(
287
- "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",
288
- n.day
289
- ),
290
- disabled: h("text-muted-foreground opacity-50", n.disabled),
291
- dropdown: h("absolute bg-popover inset-0 opacity-0", n.dropdown),
292
- dropdown_root: h(
293
- "relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
294
- n.dropdown_root
295
- ),
296
- dropdowns: h("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", n.dropdowns),
297
- hidden: h("invisible", n.hidden),
298
- month: h("flex flex-col w-full gap-4", n.month),
299
- month_caption: h("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", n.month_caption),
300
- months: h("flex gap-4 flex-col md:flex-row relative", n.months),
301
- nav: h("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", n.nav),
302
- outside: h("text-muted-foreground aria-selected:text-muted-foreground", n.outside),
303
- range_end: h("rounded-r-md bg-accent", n.range_end),
304
- range_middle: h("rounded-none", n.range_middle),
305
- range_start: h("rounded-l-md bg-accent", n.range_start),
306
- root: h("w-fit", n.root),
307
- table: "w-full border-collapse",
308
- today: h("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none", n.today),
309
- week: h("flex w-full mt-2", n.week),
310
- week_number: h("text-[0.8rem] select-none text-muted-foreground", n.week_number),
311
- week_number_header: h("select-none w-(--cell-size)", n.week_number_header),
312
- weekday: h("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", n.weekday),
313
- weekdays: h("flex", n.weekdays),
314
- ...s
315
- },
316
- components: {
317
- Chevron: ({ className: d, orientation: m, ...c }) => m === "left" ? /* @__PURE__ */ e.jsx(ut, { className: h("size-4", d), ...c }) : m === "right" ? /* @__PURE__ */ e.jsx(mt, { className: h("size-4", d), ...c }) : /* @__PURE__ */ e.jsx(ye, { className: h("size-4", d), ...c }),
318
- DayButton: Ct,
319
- Root: ({ className: d, rootRef: m, ...c }) => /* @__PURE__ */ e.jsx("div", { "data-slot": "calendar", ref: m, className: h(d), ...c }),
320
- WeekNumber: ({ children: d, ...m }) => /* @__PURE__ */ e.jsx("td", { ...m, children: /* @__PURE__ */ e.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children: d }) }),
321
- ...l
322
- },
323
- ...u
324
- }
325
- );
326
- }
327
- function Ct({ className: t, day: s, modifiers: r, ...a }) {
328
- const o = Ee(), i = Re.useRef(null);
329
- return Re.useEffect(() => {
330
- r.focused && i.current?.focus();
331
- }, [r.focused]), /* @__PURE__ */ e.jsx(
332
- ee,
333
- {
334
- ref: i,
335
- variant: "ghost",
336
- size: "icon",
337
- "data-day": s.date.toLocaleDateString(),
338
- "data-selected-single": r.selected && !r.range_start && !r.range_end && !r.range_middle,
339
- "data-range-start": r.range_start,
340
- "data-range-end": r.range_end,
341
- "data-range-middle": r.range_middle,
342
- className: h(
343
- "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",
344
- o.day,
345
- t
346
- ),
347
- ...a
348
- }
349
- );
350
- }
351
- const St = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, id: u, name: n }) => {
352
- const [d, m] = $(!1), c = R(), p = s ? new Date(s) : void 0, g = (x) => {
353
- if (t.data.disablePast) {
354
- const f = /* @__PURE__ */ new Date();
355
- return f.setHours(0, 0, 0, 0), x < f;
356
- }
357
- return !1;
358
- };
359
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
360
- /* @__PURE__ */ e.jsxs(v, { htmlFor: u, children: [
361
- o || t.data.name,
362
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
363
- ] }),
364
- /* @__PURE__ */ e.jsxs(ie, { open: d, onOpenChange: m, children: [
365
- /* @__PURE__ */ e.jsx(de, { asChild: !0, children: /* @__PURE__ */ e.jsxs(ee, { variant: "outline", id: u, name: n, className: "w-full justify-between font-normal", children: [
366
- p ? p.toLocaleDateString() : i || c("renderer.defaultInputs.selectDate"),
367
- /* @__PURE__ */ e.jsx(ye, { className: "size-4" })
368
- ] }) }),
369
- /* @__PURE__ */ e.jsx(ce, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ e.jsx(
370
- Me,
371
- {
372
- mode: "single",
373
- selected: p,
374
- captionLayout: "dropdown",
375
- disabled: g,
376
- onSelect: (x) => {
377
- r(x ? x.toISOString() : ""), m(!1);
378
- }
379
- }
380
- ) })
381
- ] }),
382
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
383
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
384
- ] });
385
- }, It = ({ node: t, value: s, setValue: r, error: a, label: o, helperText: i, id: l }) => {
386
- const [u, n] = $(!1), d = R(), m = Array.isArray(s) ? s : [], c = m[0] ? new Date(m[0]) : void 0, p = m[1] ? new Date(m[1]) : void 0, g = (I) => {
387
- r([I?.from ? I.from.toISOString() : void 0, I?.to ? I.to.toISOString() : void 0]);
388
- }, x = () => c && p ? `${c.toLocaleDateString()} - ${p.toLocaleDateString()}` : c ? c.toLocaleDateString() : d("renderer.defaultInputs.selectDateRange"), f = (I) => {
389
- if (t.data.disablePast) {
390
- const T = /* @__PURE__ */ new Date();
391
- return T.setHours(0, 0, 0, 0), I < T;
392
- }
393
- return !1;
394
- };
395
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
396
- /* @__PURE__ */ e.jsxs(v, { htmlFor: l, children: [
397
- o || t.data.name,
398
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
399
- ] }),
400
- /* @__PURE__ */ e.jsxs(ie, { open: u, onOpenChange: n, children: [
401
- /* @__PURE__ */ e.jsx(de, { asChild: !0, children: /* @__PURE__ */ e.jsxs(ee, { id: l, variant: "outline", className: "w-full justify-between font-normal", children: [
402
- x(),
403
- /* @__PURE__ */ e.jsx(ye, { className: "size-4" })
404
- ] }) }),
405
- /* @__PURE__ */ e.jsx(ce, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ e.jsx(
406
- Me,
407
- {
408
- mode: "range",
409
- selected: { from: c, to: p },
410
- captionLayout: "dropdown",
411
- disabled: f,
412
- onSelect: g,
413
- numberOfMonths: 2
414
- }
415
- ) })
416
- ] }),
417
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
418
- i && !a && /* @__PURE__ */ e.jsx(C, { children: i })
419
- ] });
420
- }, Dt = ({ node: t, setValue: s, error: r, label: a, placeholder: o, helperText: i, name: l, id: u }) => {
421
- const n = async (d) => {
422
- const { files: m } = d.target;
423
- if (!m || m.length === 0) {
424
- s(null);
425
- return;
426
- }
427
- if (t.data.multiple) {
428
- const p = await tt(Array.from(m));
429
- s(p);
430
- return;
431
- }
432
- const c = await at(m[0]);
433
- s(c);
434
- };
435
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
436
- /* @__PURE__ */ e.jsxs(v, { htmlFor: u, children: [
437
- a || t.data.name,
438
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
439
- ] }),
440
- /* @__PURE__ */ e.jsx(_, { type: "file", name: l, id: u, onChange: n, multiple: t.data.multiple, placeholder: o }),
441
- r && /* @__PURE__ */ e.jsx(w, { children: r }),
442
- i && !r && /* @__PURE__ */ e.jsx(C, { children: i })
443
- ] });
444
- }, Ft = ({ value: t, name: s, id: r }) => /* @__PURE__ */ e.jsx(_, { type: "hidden", id: r, name: s, value: t ?? "" });
445
- function De({ delayDuration: t = 0, ...s }) {
446
- return /* @__PURE__ */ e.jsx(Q.Provider, { "data-slot": "tooltip-provider", delayDuration: t, ...s });
447
- }
448
- function Ge({ ...t }) {
449
- return /* @__PURE__ */ e.jsx(De, { children: /* @__PURE__ */ e.jsx(Q.Root, { "data-slot": "tooltip", ...t }) });
450
- }
451
- function Ue({ ...t }) {
452
- return /* @__PURE__ */ e.jsx(Q.Trigger, { "data-slot": "tooltip-trigger", ...t });
453
- }
454
- function We({ className: t, sideOffset: s = 0, children: r, ...a }) {
455
- return /* @__PURE__ */ e.jsx(Q.Portal, { children: /* @__PURE__ */ e.jsxs(
456
- Q.Content,
457
- {
458
- "data-slot": "tooltip-content",
459
- sideOffset: s,
460
- className: h(
461
- "fade-in-0 zoom-in-95 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) animate-in text-balance rounded-md bg-foreground px-3 py-1.5 text-background text-xs data-[state=closed]:animate-out",
462
- t
463
- ),
464
- ...a,
465
- children: [
466
- r,
467
- /* @__PURE__ */ e.jsx(Q.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })
468
- ]
469
- }
470
- ) });
471
- }
472
- const xe = (t, s) => s ? s.split(".").reduce((a, o) => {
473
- if (a == null)
474
- return;
475
- const i = o.match(/^(\w+)\[(\d+)]$/);
476
- if (i) {
477
- const [, l, u] = i, n = a[l];
478
- return Array.isArray(n) ? n[Number.parseInt(u, 10)] : n;
479
- }
480
- return a[o];
481
- }, t) : t, be = (t) => {
482
- const s = t.matchAll(/{{([\w-]+)}}/g);
483
- return Array.from(s, (r) => r[1]);
484
- }, fe = (t, s) => be(t).every((a) => {
485
- const o = s[a];
486
- return o != null && o !== "";
487
- }), ge = (t, s, r = !1) => t.replace(/{{([\w-]+)}}/g, (a, o) => {
488
- const i = s[o], l = i == null ? "" : String(i);
489
- return r ? encodeURIComponent(l) : l;
490
- }), kt = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, id: u, name: n }) => {
491
- const [d, m] = $(!1), [c, p] = $(null), [g, x] = $([]), [f, I] = $(""), [T, M] = $(!1), { formValues: A, inputNodes: b } = ve(), S = R(), { httpConfig: y } = t.data, L = V(!1), G = V(""), J = V(y), X = V(A), te = V(b), ae = V(r), se = V(null), z = V(null), U = me(() => y?.url ? be(y.url) : [], [y?.url]), H = U.length > 0, re = me(() => U.map((D) => `${D}:${String(A[D] ?? "")}`).join("|"), [U, A]), ue = me(() => y?.url ? H ? fe(y.url, A) : !0 : !1, [y?.url, H, A]), E = oe(
492
- async (D) => {
493
- z.current && z.current.abort();
494
- const O = new AbortController();
495
- z.current = O;
496
- const j = J.current, P = X.current, Y = ae.current;
497
- if (!j?.url) {
498
- p(S("renderer.defaultHttpInput.noUrlConfigured")), z.current = null;
499
- return;
500
- }
501
- if (j.url && !fe(j.url, P)) {
502
- z.current = null;
503
- return;
504
- }
505
- m(!0), p(null);
506
- try {
507
- const k = ge(j.url, P, !0), W = j.searchParam && D ? `${k}${k.includes("?") ? "&" : "?"}${j.searchParam}=${encodeURIComponent(D)}` : k, F = {};
508
- j.headers?.forEach((le) => {
509
- F[le.key] = ge(le.value, P);
510
- });
511
- const q = ["POST", "PUT", "PATCH"].includes(j.method || "") ? j.sendAllFormValues ? JSON.stringify(st(P, te.current)) : j.body ? ge(j.body, P) : void 0 : void 0, B = setTimeout(() => O.abort(), 3e4), ne = await fetch(W, {
512
- body: q || void 0,
513
- headers: {
514
- "Content-Type": "application/json",
515
- ...F
516
- },
517
- method: j.method || "GET",
518
- signal: O.signal
519
- });
520
- if (clearTimeout(B), !ne.ok) {
521
- p(`HTTP Error ${ne.status}: ${ne.statusText}`), m(!1);
522
- return;
523
- }
524
- const Je = await ne.json(), Fe = rt(Je), Z = j.responsePath ? xe(Fe, j.responsePath) : Fe;
525
- if (j.responseMapping && Array.isArray(Z)) {
526
- const { valueField: le = "value", labelField: Xe = "label" } = j.responseMapping, Ye = Z.map((ke) => ({
527
- label: String(xe(ke, Xe) || ""),
528
- value: String(xe(ke, le) || "")
529
- }));
530
- x(Ye);
531
- } else
532
- Y(typeof Z == "string" ? Z : JSON.stringify(Z));
533
- } catch (k) {
534
- if (k instanceof Error && k.name === "AbortError")
535
- return;
536
- const W = k instanceof Error ? k.message : S("renderer.defaultHttpInput.fetchFailed");
537
- p(W), console.error("HTTP Input fetch error:", k);
538
- } finally {
539
- m(!1), z.current = null;
540
- }
541
- },
542
- [S]
543
- );
544
- if (K(() => {
545
- J.current = y, X.current = A, te.current = b, ae.current = r, se.current = E;
546
- }, [y, A, b, r, E]), K(() => () => {
547
- z.current && z.current.abort();
548
- }, []), K(() => {
549
- if (L.current)
550
- return;
551
- L.current = !0;
552
- const D = J.current, O = X.current, j = se.current, P = D?.url && fe(D.url, O);
553
- if (D?.fetchOnMount && P && j && (j(), D.url)) {
554
- const Y = be(D.url);
555
- G.current = Y.map((k) => `${k}:${String(O[k] ?? "")}`).join("|");
556
- }
557
- }, []), K(() => {
558
- if (!L.current || !H || G.current === re || !ue)
559
- return;
560
- const D = setTimeout(() => {
561
- E(), G.current = re;
562
- }, 500);
563
- return () => clearTimeout(D);
564
- }, [re, H, ue, E]), K(() => {
565
- if (!(y?.searchParam && f))
566
- return;
567
- const D = setTimeout(() => {
568
- E(f);
569
- }, 300);
570
- return () => clearTimeout(D);
571
- }, [f, y?.searchParam, E]), y?.responseMapping) {
572
- const D = Array.isArray(s) ? s[0] : s, O = g.find((F) => F.value === D);
573
- if (y.searchParam) {
574
- const q = d && y?.showLoading ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
575
- /* @__PURE__ */ e.jsx(he, { className: "h-4 w-4 animate-spin" }),
576
- /* @__PURE__ */ e.jsx("span", { className: "text-muted-foreground", children: O?.label || i || S("renderer.defaultHttpInput.search") })
577
- ] }) : O?.label || i || S("renderer.defaultHttpInput.search");
578
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
579
- /* @__PURE__ */ e.jsxs(v, { children: [
580
- o || t.data.name,
581
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
582
- ] }),
583
- /* @__PURE__ */ e.jsxs(ie, { open: T, onOpenChange: M, children: [
584
- /* @__PURE__ */ e.jsx(de, { asChild: !0, children: /* @__PURE__ */ e.jsxs(ee, { variant: "outline", role: "combobox", "aria-expanded": T, className: "w-full justify-between", children: [
585
- q,
586
- /* @__PURE__ */ e.jsx(ze, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
587
- ] }) }),
588
- /* @__PURE__ */ e.jsx(ce, { className: "w-[300px] p-0", align: "start", children: /* @__PURE__ */ e.jsxs(Ne, { shouldFilter: !1, children: [
589
- /* @__PURE__ */ e.jsx(
590
- _e,
591
- {
592
- placeholder: S("renderer.defaultHttpInput.search"),
593
- value: f,
594
- onValueChange: (B) => {
595
- I(B), p(null);
596
- }
597
- }
598
- ),
599
- /* @__PURE__ */ e.jsxs(we, { children: [
600
- d && /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e.jsx(he, { className: "h-4 w-4 animate-spin" }) }),
601
- !d && c && /* @__PURE__ */ e.jsxs("div", { className: "p-4 text-destructive text-sm", children: [
602
- /* @__PURE__ */ e.jsx("div", { children: c }),
603
- /* @__PURE__ */ e.jsx("button", { type: "button", onClick: () => E(f), className: "mt-2 block text-primary hover:underline", children: S("renderer.defaultHttpInput.retry") })
604
- ] }),
605
- !(d || c) && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
606
- /* @__PURE__ */ e.jsx(Ce, { children: S("renderer.defaultHttpInput.noResults") }),
607
- /* @__PURE__ */ e.jsx(Se, { children: g.map((B) => /* @__PURE__ */ e.jsxs(
608
- Ie,
609
- {
610
- value: B.value,
611
- onSelect: () => {
612
- r(B.value), M(!1);
613
- },
614
- children: [
615
- /* @__PURE__ */ e.jsx(Pe, { className: h("mr-2 h-4 w-4", s === B.value ? "opacity-100" : "opacity-0") }),
616
- B.label
617
- ]
618
- },
619
- B.value
620
- )) })
621
- ] })
622
- ] })
623
- ] }) })
624
- ] }),
625
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
626
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
627
- ] });
628
- }
629
- const j = d && y?.showLoading, P = U.filter((F) => {
630
- const q = A[F];
631
- return q == null || q === "";
632
- }), Y = P.map((F) => nt(F, b) || F), k = g.length === 0 && !j ? c || (P.length > 0 ? `${S("renderer.defaultHttpInput.waitingForRequiredFields")}: ${Y.join(", ")}` : S("renderer.defaultHttpInput.noDataAvailable")) : void 0, W = /* @__PURE__ */ e.jsxs(
633
- Oe,
634
- {
635
- value: Array.isArray(s) ? s[0] ?? "" : s ?? "",
636
- onValueChange: (F) => r(F),
637
- disabled: j || g.length === 0,
638
- name: n,
639
- children: [
640
- /* @__PURE__ */ e.jsxs(qe, { id: u, name: n, className: "w-full", children: [
641
- j && /* @__PURE__ */ e.jsx(he, { className: "mr-2 h-4 w-4 animate-spin" }),
642
- /* @__PURE__ */ e.jsx(Be, { placeholder: i || S("renderer.defaultHttpInput.selectOption") })
643
- ] }),
644
- /* @__PURE__ */ e.jsx(He, { children: /* @__PURE__ */ e.jsx(Ve, { children: g.map((F, q) => /* @__PURE__ */ e.jsx(Le, { value: F.value, children: F.label }, F.value + q)) }) })
645
- ]
646
- }
647
- );
648
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
649
- /* @__PURE__ */ e.jsxs(v, { htmlFor: u, children: [
650
- o || t.data.name,
651
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
652
- ] }),
653
- k ? /* @__PURE__ */ e.jsx(De, { children: /* @__PURE__ */ e.jsxs(Ge, { children: [
654
- /* @__PURE__ */ e.jsx(Ue, { asChild: !0, children: /* @__PURE__ */ e.jsx("div", { className: "w-full", children: W }) }),
655
- /* @__PURE__ */ e.jsx(We, { children: /* @__PURE__ */ e.jsx("p", { children: k }) })
656
- ] }) }) : W,
657
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
658
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
659
- ] });
660
- }
661
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
662
- /* @__PURE__ */ e.jsxs(v, { htmlFor: u, children: [
663
- o || t.data.name,
664
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
665
- ] }),
666
- /* @__PURE__ */ e.jsx(_, { type: "text", name: n, id: u, value: typeof s == "string" ? s : JSON.stringify(s), readOnly: !0, disabled: !0 }),
667
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
668
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
669
- ] });
670
- }, Rt = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, name: u, id: n }) => /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
671
- /* @__PURE__ */ e.jsxs(v, { htmlFor: n, children: [
672
- o || t.data.name,
673
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
674
- ] }),
675
- /* @__PURE__ */ e.jsx(
676
- _,
677
- {
678
- id: n,
679
- type: "number",
680
- name: u,
681
- value: s ?? "",
682
- onChange: (d) => r(d.target.value === "" ? null : Number(d.target.value)),
683
- placeholder: i
684
- }
685
- ),
686
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
687
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
688
- ] }), At = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, name: u, id: n }) => /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
689
- /* @__PURE__ */ e.jsxs(v, { htmlFor: n, children: [
690
- o || t.data.name,
691
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
692
- ] }),
693
- /* @__PURE__ */ e.jsx(
694
- _,
695
- {
696
- id: n,
697
- name: u,
698
- type: "password",
699
- value: s ?? "",
700
- onChange: (d) => r(d.target.value),
701
- placeholder: i,
702
- autoComplete: "new-password"
703
- }
704
- ),
705
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
706
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
707
- ] });
708
- function Tt({ className: t, ...s }) {
709
- return /* @__PURE__ */ e.jsx(je.Root, { "data-slot": "radio-group", className: h("grid gap-3", t), ...s });
710
- }
711
- function $t({ className: t, ...s }) {
712
- return /* @__PURE__ */ e.jsx(
713
- je.Item,
714
- {
715
- "data-slot": "radio-group-item",
716
- className: h(
717
- "aspect-square size-4 shrink-0 rounded-full border border-input text-primary shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
718
- t
719
- ),
720
- ...s,
721
- children: /* @__PURE__ */ e.jsx(je.Indicator, { "data-slot": "radio-group-indicator", className: "relative flex items-center justify-center", children: /* @__PURE__ */ e.jsx(ht, { className: "-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2 size-2 fill-primary" }) })
722
- }
723
- );
724
- }
725
- const zt = ({ node: t, value: s, setValue: r, error: a, label: o, helperText: i, id: l, name: u }) => {
726
- const n = R(), d = s ? String(s) : "";
727
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
728
- /* @__PURE__ */ e.jsxs(v, { className: "mb-1", htmlFor: l, children: [
729
- o || t.data.name,
730
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
731
- ] }),
732
- /* @__PURE__ */ e.jsx(Tt, { value: d, onValueChange: (m) => r(m), id: l, name: u, children: t.data.options?.map((m, c) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
733
- /* @__PURE__ */ e.jsx($t, { value: String(m.value), id: `${l}-${m.value}`, disabled: m.disabled }),
734
- /* @__PURE__ */ e.jsx(v, { htmlFor: `${l}-${m.value}`, className: "cursor-pointer font-normal text-sm", children: n(m.label) ? n(m.label) : m.value })
735
- ] }, m.value + c)) }),
736
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
737
- i && !a && /* @__PURE__ */ e.jsx(C, { children: i })
738
- ] });
739
- }, Pt = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, name: u, id: n }) => {
740
- const d = R(), m = s ? String(s) : "";
741
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
742
- /* @__PURE__ */ e.jsxs(v, { htmlFor: n, children: [
743
- o || t.data.name,
744
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
745
- ] }),
746
- /* @__PURE__ */ e.jsxs(Oe, { name: u, value: m, onValueChange: (c) => r(c), children: [
747
- /* @__PURE__ */ e.jsx(qe, { id: n, name: u, className: "w-full", children: /* @__PURE__ */ e.jsx(Be, { placeholder: i || d("renderer.defaultSelectInput.selectOption") }) }),
748
- /* @__PURE__ */ e.jsx(He, { children: /* @__PURE__ */ e.jsx(Ve, { children: t.data.options?.map((c, p) => /* @__PURE__ */ e.jsx(Le, { value: String(c.value), disabled: c.disabled, children: d(c.label) ? d(c.label) : c.value }, `${c.value}-${p}`)) }) })
749
- ] }),
750
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
751
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
752
- ] });
753
- }, Ke = et(
754
- ({ label: t, id: s, disabled: r, onBlur: a, onClick: o, onFocus: i, onPointerDown: l, onPointerLeave: u, onPointerMove: n, ...d }, m) => {
755
- const c = R();
756
- return /* @__PURE__ */ e.jsx(
757
- "button",
758
- {
759
- ref: m,
760
- id: s,
761
- onBlur: a,
762
- onClick: o,
763
- onFocus: i,
764
- onPointerDown: l,
765
- disabled: r,
766
- onPointerLeave: u,
767
- onPointerMove: n,
768
- type: "submit",
769
- 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",
770
- ...d,
771
- children: t || c("renderer.defaultSubmitButton.submit")
772
- }
773
- );
774
- }
775
- ), Qe = ({ children: t, missingFields: s = [] }) => {
776
- const r = s.length > 0, a = R();
777
- return r ? /* @__PURE__ */ e.jsx(De, { children: /* @__PURE__ */ e.jsxs(Ge, { children: [
778
- /* @__PURE__ */ e.jsx(Ue, { asChild: !0, children: t }),
779
- /* @__PURE__ */ e.jsx(We, { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
780
- /* @__PURE__ */ e.jsxs("p", { className: "font-semibold", children: [
781
- a("renderer.defaultSubmitButton.requiredFieldsMissing"),
782
- ":"
783
- ] }),
784
- /* @__PURE__ */ e.jsx("ul", { className: "list-inside list-disc", children: s.map((o, i) => /* @__PURE__ */ e.jsx("li", { children: o }, i)) })
785
- ] }) })
786
- ] }) }) : t;
787
- }, _t = ({ missingRequiredFields: t, isSubmitting: s, label: r }) => {
788
- const a = lt(), o = a?.components?.submitButton, i = a?.components?.submitButtonWrapper, l = o || Ke, u = i || Qe;
789
- return /* @__PURE__ */ e.jsx(u, { missingFields: t, children: /* @__PURE__ */ e.jsx(l, { label: r, disabled: s }) });
790
- }, Ot = ({ node: t, value: s, setValue: r, error: a, label: o, helperText: i, name: l, id: u }) => /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
791
- /* @__PURE__ */ e.jsxs(v, { htmlFor: u, children: [
792
- o || t.data.name,
793
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
794
- ] }),
795
- /* @__PURE__ */ e.jsx(pt, { id: u, name: l, checked: s, onCheckedChange: r }),
796
- i && !a && /* @__PURE__ */ e.jsx(C, { children: i }),
797
- a && /* @__PURE__ */ e.jsx(w, { children: a })
798
- ] }), qt = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, name: u, id: n }) => /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
799
- /* @__PURE__ */ e.jsxs(v, { htmlFor: n, children: [
800
- o || t.data.name,
801
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
802
- ] }),
803
- /* @__PURE__ */ e.jsx(
804
- xt,
805
- {
806
- id: n,
807
- name: u,
808
- value: s ?? "",
809
- onChange: (d) => r(d.target.value),
810
- placeholder: i,
811
- className: "w-full rounded-md border px-3 py-2",
812
- rows: 4
813
- }
814
- ),
815
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
816
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
817
- ] }), Bt = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, name: u, id: n }) => /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
818
- /* @__PURE__ */ e.jsxs(v, { htmlFor: n, children: [
819
- o || t.data.name,
820
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
821
- ] }),
822
- /* @__PURE__ */ e.jsx(_, { type: "text", id: n, name: u, value: s ?? "", onChange: (d) => r(d.target.value), placeholder: i }),
823
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
824
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
825
- ] }), Ht = ({ node: t, value: s, setValue: r, error: a, label: o, placeholder: i, helperText: l, name: u, id: n }) => /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
826
- /* @__PURE__ */ e.jsxs(v, { htmlFor: n, children: [
827
- o || t.data.name,
828
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
829
- ] }),
830
- /* @__PURE__ */ e.jsx(
831
- _,
832
- {
833
- type: "time",
834
- id: n,
835
- name: u,
836
- value: s ?? "",
837
- onChange: (d) => r(d.target.value),
838
- placeholder: i,
839
- className: "bg-background [color-scheme:light] dark:[color-scheme:dark]"
840
- }
841
- ),
842
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
843
- l && !a && /* @__PURE__ */ e.jsx(C, { children: l })
844
- ] }), Vt = ({ node: t, value: s, setValue: r, error: a, label: o, helperText: i, id: l, name: u }) => {
845
- const n = R(), d = Array.isArray(s) ? s : [], m = d[0] || "", c = d[1] || "", p = (x) => {
846
- r([x, c]);
847
- }, g = (x) => {
848
- r([m, x]);
849
- };
850
- return /* @__PURE__ */ e.jsxs(N, { className: "mb-4", children: [
851
- /* @__PURE__ */ e.jsxs(v, { htmlFor: `${l}-start`, children: [
852
- o || t.data.name,
853
- t.data.required && /* @__PURE__ */ e.jsx("span", { className: "text-red-500", children: "*" })
854
- ] }),
855
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
856
- /* @__PURE__ */ e.jsx(
857
- _,
858
- {
859
- id: `${l}-start`,
860
- name: `${u}-start`,
861
- "aria-label": `${o || t.data.name} - ${n("renderer.defaultInputs.startTime")}`,
862
- "aria-invalid": !!a,
863
- "aria-describedby": a ? `${t.id}-error` : void 0,
864
- type: "time",
865
- value: m,
866
- onChange: (x) => p(x.target.value),
867
- placeholder: n("renderer.defaultInputs.startTime"),
868
- className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
869
- }
870
- ),
871
- /* @__PURE__ */ e.jsx(
872
- _,
873
- {
874
- id: `${l}-end`,
875
- name: `${u}-end`,
876
- "aria-label": `${o || t.data.name} - ${n("renderer.defaultInputs.endTime")}`,
877
- "aria-invalid": !!a,
878
- "aria-describedby": a ? `${t.id}-error` : void 0,
879
- type: "time",
880
- value: c,
881
- onChange: (x) => g(x.target.value),
882
- placeholder: n("renderer.defaultInputs.endTime"),
883
- className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
884
- }
885
- )
886
- ] }),
887
- a && /* @__PURE__ */ e.jsx(w, { children: a }),
888
- i && !a && /* @__PURE__ */ e.jsx(C, { children: i })
889
- ] });
890
- }, Lt = {
891
- address: yt,
892
- autocomplete: Nt,
893
- checkbox: wt,
894
- date: St,
895
- daterange: It,
896
- file: Dt,
897
- hidden: Ft,
898
- http: kt,
899
- number: Rt,
900
- password: At,
901
- radio: zt,
902
- select: Pt,
903
- submit: _t,
904
- switch: Ot,
905
- text: Bt,
906
- textarea: qt,
907
- time: Ht,
908
- timerange: Vt
909
- }, Et = ({ node: t }) => {
910
- const r = R()(t.data?.label);
911
- return r ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-x-3", children: [
912
- /* @__PURE__ */ e.jsx(pe, { className: "my-8 flex-1" }),
913
- /* @__PURE__ */ e.jsx("h4", { className: "font-semibold text-sm", children: r }),
914
- /* @__PURE__ */ e.jsx(pe, { className: "my-8 flex-1" })
915
- ] }) : /* @__PURE__ */ e.jsx(pe, { className: "my-8" });
916
- }, Mt = ({ node: t }) => {
917
- const { edges: s } = ve(), r = R(), a = ot(t.id, s);
918
- return /* @__PURE__ */ e.jsx("h2", { className: h("mb-5 font-bold text-2xl", !a && "mt-10"), children: r(t.data?.label) });
919
- }, Gt = {
920
- divider: Et,
921
- title: Mt
922
- }, da = ({
923
- components: t,
924
- className: s,
925
- flows: r,
926
- googleApiKey: a,
927
- language: o,
928
- onChange: i,
929
- onSubmit: l,
930
- theme: u,
931
- validate: n,
932
- validationMode: d,
933
- initialValues: m = {}
934
- }) => {
935
- const {
936
- canSubmit: c,
937
- clearSubmitMessage: p,
938
- config: g,
939
- firstErrorFieldId: x,
940
- formErrors: f,
941
- formValues: I,
942
- handleSubmit: T,
943
- inputNodes: M,
944
- isSubmitting: A,
945
- mergedFlow: b,
946
- missingRequiredFields: S,
947
- setFieldValue: y,
948
- submitMessage: L,
949
- t: G,
950
- visibleNodes: J,
951
- visibleRootNodes: X
952
- } = it({
953
- components: t,
954
- flows: r,
955
- googleApiKey: a,
956
- initialValues: m,
957
- language: o,
958
- onChange: i,
959
- onSubmit: l,
960
- theme: u,
961
- validate: n,
962
- validationMode: d
963
- }), { FormWrapper: te, SubmitButton: ae, SubmitButtonWrapper: se, renderNode: z } = dt({
964
- config: g,
965
- DefaultFormWrapper: gt,
966
- DefaultGroup: jt,
967
- DefaultSubmitButton: Ke,
968
- DefaultSubmitButtonWrapper: Qe,
969
- defaultInputRenderers: Lt,
970
- defaultUI: Gt,
971
- formErrors: f,
972
- formValues: I,
973
- missingRequiredFields: S,
974
- setFieldValue: y,
975
- visibleNodes: J
976
- }), U = oe(
977
- async (H) => {
978
- H.preventDefault(), !await T() && x && document.getElementById(x)?.focus();
979
- },
980
- [T, x]
981
- );
982
- return /* @__PURE__ */ e.jsx("div", { className: h("treege", s), children: /* @__PURE__ */ e.jsx(Ze, { theme: g.theme, storageKey: "treege-renderer-theme", children: /* @__PURE__ */ e.jsxs(
983
- ct,
984
- {
985
- value: {
986
- flows: b,
987
- formErrors: f,
988
- formValues: I,
989
- googleApiKey: g.googleApiKey,
990
- inputNodes: M,
991
- language: g.language,
992
- setFieldValue: y
993
- },
994
- children: [
995
- /* @__PURE__ */ e.jsxs(te, { onSubmit: U, children: [
996
- X.map((H) => z(H)),
997
- c && /* @__PURE__ */ e.jsx(se, { missingFields: S, children: /* @__PURE__ */ e.jsx(ae, { label: G("renderer.defaultSubmitButton.submit"), disabled: A }) }),
998
- /* @__PURE__ */ e.jsx("p", { className: "py-2 text-muted-foreground text-xs", children: "Powered by Treege" })
999
- ] }),
1000
- L && /* @__PURE__ */ e.jsx(
1001
- "div",
1002
- {
1003
- className: `my-4 rounded-md p-4 ${L.type === "success" ? "bg-green-50 text-green-800 dark:bg-green-900/20 dark:text-green-300" : "bg-red-50 text-red-800 dark:bg-red-900/20 dark:text-red-300"}`,
1004
- role: "alert",
1005
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
1006
- /* @__PURE__ */ e.jsx("p", { className: "font-medium text-sm", children: L.message }),
1007
- /* @__PURE__ */ e.jsx(
1008
- "button",
1009
- {
1010
- type: "button",
1011
- onClick: p,
1012
- className: "ml-4 font-medium text-sm underline hover:no-underline focus:outline-none",
1013
- children: G("common.close")
1014
- }
1015
- )
1016
- ] })
1017
- }
1018
- )
1019
- ]
1020
- }
1021
- ) }) });
1022
- };
1023
- export {
1024
- jt as D,
1025
- da as T,
1026
- yt as a,
1027
- Nt as b,
1028
- wt as c,
1029
- St as d,
1030
- It as e,
1031
- Dt as f,
1032
- Ft as g,
1033
- kt as h,
1034
- Rt as i,
1035
- At as j,
1036
- zt as k,
1037
- Pt as l,
1038
- Ot as m,
1039
- qt as n,
1040
- Bt as o,
1041
- Ht as p,
1042
- Vt as q,
1043
- Lt as r,
1044
- Et as s,
1045
- Mt as t,
1046
- Gt as u
1047
- };