treege 3.0.0-beta.16 → 3.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ThemeContext-zQO8nZ9d.js +745 -0
- package/dist/TreegeEditor-DXhj6fWi.js +3300 -0
- package/dist/TreegeRenderer-CjLeK7_j.js +1740 -0
- package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
- package/dist/editor/constants/edgeTypes.d.ts +2 -1
- package/dist/editor/constants/nodeTypes.d.ts +4 -4
- package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
- package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
- package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
- package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +2 -2
- package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
- package/dist/editor/hooks/useFlowActions.d.ts +1 -0
- package/dist/editor.js +2 -2
- package/dist/main.js +34 -32
- package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +2 -0
- package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
- package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
- package/dist/renderer/types/renderer.d.ts +16 -2
- package/dist/renderer/utils/form.d.ts +19 -0
- package/dist/renderer/utils/http.d.ts +101 -0
- package/dist/renderer/utils/submit.d.ts +47 -0
- package/dist/renderer.js +30 -28
- package/dist/shared/components/ui/alert-dialog.d.ts +14 -0
- package/dist/shared/components/ui/badge.d.ts +1 -1
- package/dist/shared/components/ui/popover.d.ts +3 -1
- package/dist/shared/components/ui/select.d.ts +3 -1
- package/dist/shared/constants/inputType.d.ts +1 -0
- package/dist/shared/locales/ar.json.d.ts +48 -3
- package/dist/shared/locales/de.json.d.ts +48 -3
- package/dist/shared/locales/en.json.d.ts +49 -4
- package/dist/shared/locales/es.json.d.ts +48 -3
- package/dist/shared/locales/fr.json.d.ts +48 -3
- package/dist/shared/locales/it.json.d.ts +48 -3
- package/dist/shared/locales/pt.json.d.ts +48 -3
- package/dist/shared/types/node.d.ts +47 -0
- package/package.json +4 -3
- package/dist/ThemeContext-XefwjIme.js +0 -760
- package/dist/TreegeEditor-DOj2aQTI.js +0 -2735
- package/dist/TreegeRenderer-BKVKtiO4.js +0 -1441
|
@@ -0,0 +1,1740 @@
|
|
|
1
|
+
import { j as t, i as W, L as be, b as He, e as Nt, F as E, f as T, I as X, C as Re, h as ke, k as Ae, l as De, m as Ee, n as O, o as P, P as me, p as fe, B as le, q as pe, r as Ge, s as j, t as Ve, v as Me, S as We, w as Ke, x as Je, y as Qe, z as Xe, A as Ye, D as vt, E as wt, G as je, g as ne, N as ue, a as St, c as Ft, T as Ct } from "./ThemeContext-zQO8nZ9d.js";
|
|
2
|
+
import * as ze from "react";
|
|
3
|
+
import { createContext as Ze, useContext as et, useMemo as G, useRef as K, useState as B, useCallback as Q, useEffect as J, forwardRef as It } from "react";
|
|
4
|
+
import { MapPin as Be, ChevronsUpDown as tt, Check as st, ChevronLeftIcon as Tt, ChevronRightIcon as Rt, ChevronDownIcon as Oe, Loader2 as ye, CircleIcon as kt } from "lucide-react";
|
|
5
|
+
import { getDefaultClassNames as rt, DayPicker as At } from "react-day-picker";
|
|
6
|
+
import * as ae from "@radix-ui/react-tooltip";
|
|
7
|
+
import * as Ie from "@radix-ui/react-radio-group";
|
|
8
|
+
import "cmdk";
|
|
9
|
+
import "@radix-ui/react-dialog";
|
|
10
|
+
import "clsx";
|
|
11
|
+
import "tailwind-merge";
|
|
12
|
+
import "@radix-ui/react-label";
|
|
13
|
+
import "@radix-ui/react-popover";
|
|
14
|
+
import "@radix-ui/react-checkbox";
|
|
15
|
+
import "@radix-ui/react-select";
|
|
16
|
+
import "@radix-ui/react-switch";
|
|
17
|
+
import "@radix-ui/react-separator";
|
|
18
|
+
const nt = Ze(void 0), at = () => et(nt), Ls = ({
|
|
19
|
+
children: e,
|
|
20
|
+
components: r,
|
|
21
|
+
googleApiKey: n,
|
|
22
|
+
language: s,
|
|
23
|
+
theme: o,
|
|
24
|
+
validationMode: i
|
|
25
|
+
}) => {
|
|
26
|
+
const a = {
|
|
27
|
+
components: r,
|
|
28
|
+
googleApiKey: n,
|
|
29
|
+
language: s,
|
|
30
|
+
theme: o,
|
|
31
|
+
validationMode: i
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ t.jsx(nt.Provider, { value: a, children: e });
|
|
34
|
+
}, qe = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" ? e : typeof e == "string" ? e === "" ? null : e : typeof e == "object" ? JSON.stringify(e) : String(e), Dt = (e, r, n) => {
|
|
35
|
+
const s = qe(e), o = qe(r);
|
|
36
|
+
if (s === null || o === null)
|
|
37
|
+
switch (n) {
|
|
38
|
+
case "===":
|
|
39
|
+
return s === o;
|
|
40
|
+
case "!==":
|
|
41
|
+
return s !== o;
|
|
42
|
+
default:
|
|
43
|
+
return !1;
|
|
44
|
+
}
|
|
45
|
+
if ([">", "<", ">=", "<="].includes(n)) {
|
|
46
|
+
const i = Number(s), a = Number(o);
|
|
47
|
+
if (!(Number.isNaN(i) || Number.isNaN(a)))
|
|
48
|
+
switch (n) {
|
|
49
|
+
case ">":
|
|
50
|
+
return i > a;
|
|
51
|
+
case "<":
|
|
52
|
+
return i < a;
|
|
53
|
+
case ">=":
|
|
54
|
+
return i >= a;
|
|
55
|
+
case "<=":
|
|
56
|
+
return i <= a;
|
|
57
|
+
default:
|
|
58
|
+
return !1;
|
|
59
|
+
}
|
|
60
|
+
return !1;
|
|
61
|
+
}
|
|
62
|
+
switch (n) {
|
|
63
|
+
case "===": {
|
|
64
|
+
const i = Number(s), a = Number(o);
|
|
65
|
+
return Number.isNaN(i) || Number.isNaN(a) ? String(s) === String(o) : i === a;
|
|
66
|
+
}
|
|
67
|
+
case "!==": {
|
|
68
|
+
const i = Number(s), a = Number(o);
|
|
69
|
+
return Number.isNaN(i) || Number.isNaN(a) ? String(s) !== String(o) : i !== a;
|
|
70
|
+
}
|
|
71
|
+
default:
|
|
72
|
+
return !1;
|
|
73
|
+
}
|
|
74
|
+
}, Ne = (e, r, n) => {
|
|
75
|
+
const { field: s, operator: o, value: i } = e;
|
|
76
|
+
if (!(s && o) || i === void 0)
|
|
77
|
+
return !0;
|
|
78
|
+
let a = r[s];
|
|
79
|
+
if (a === void 0 && n) {
|
|
80
|
+
const l = n.get(s);
|
|
81
|
+
l && W(l) && (a = r[l.id]);
|
|
82
|
+
}
|
|
83
|
+
return Dt(a, i, o);
|
|
84
|
+
}, Et = (e, r, n) => {
|
|
85
|
+
if (!e || e.length === 0)
|
|
86
|
+
return !0;
|
|
87
|
+
if (e.length === 1)
|
|
88
|
+
return Ne(e[0], r, n);
|
|
89
|
+
let s = Ne(e[0], r, n);
|
|
90
|
+
for (let o = 1; o < e.length; o += 1) {
|
|
91
|
+
const i = e[o], a = Ne(i, r, n), l = e[o - 1].logicalOperator || be.AND;
|
|
92
|
+
if (l === be.AND) {
|
|
93
|
+
if (s = s && a, !s)
|
|
94
|
+
return !1;
|
|
95
|
+
} else if (l === be.OR && (s = s || a, s))
|
|
96
|
+
return !0;
|
|
97
|
+
}
|
|
98
|
+
return s;
|
|
99
|
+
}, Ot = (e) => e.filter(W), Pe = (e) => {
|
|
100
|
+
if (e.data.name)
|
|
101
|
+
return e.data.name;
|
|
102
|
+
if (e.data.label) {
|
|
103
|
+
if (e.data.label.en)
|
|
104
|
+
return e.data.label.en;
|
|
105
|
+
const r = Object.values(e.data.label).find(Boolean);
|
|
106
|
+
if (r)
|
|
107
|
+
return r;
|
|
108
|
+
}
|
|
109
|
+
return e.id;
|
|
110
|
+
}, Pt = (e, r) => {
|
|
111
|
+
const n = r.find((s) => s.id === e);
|
|
112
|
+
return n ? Pe(n) : void 0;
|
|
113
|
+
}, ve = (e) => e == null || typeof e == "string" && e.trim() === "" ? !0 : Array.isArray(e) && e.length === 0, $t = (e, r) => {
|
|
114
|
+
if (!e)
|
|
115
|
+
return !1;
|
|
116
|
+
const n = r[e];
|
|
117
|
+
return n != null;
|
|
118
|
+
}, $e = (e, r) => {
|
|
119
|
+
const n = {};
|
|
120
|
+
return r.forEach((s) => {
|
|
121
|
+
const o = s.id, i = Pe(s);
|
|
122
|
+
e[o] !== void 0 && (n[i] = e[o]);
|
|
123
|
+
}), n;
|
|
124
|
+
}, Le = (e, r, n) => {
|
|
125
|
+
if (!r)
|
|
126
|
+
return e;
|
|
127
|
+
switch (r) {
|
|
128
|
+
case "toString":
|
|
129
|
+
return String(e);
|
|
130
|
+
case "toNumber":
|
|
131
|
+
return Number(e);
|
|
132
|
+
case "toBoolean":
|
|
133
|
+
if (typeof e == "string") {
|
|
134
|
+
const s = e.trim().toLowerCase();
|
|
135
|
+
if (["true", "1", "yes", "on"].includes(s))
|
|
136
|
+
return !0;
|
|
137
|
+
if (["false", "0", "no", "off", ""].includes(s))
|
|
138
|
+
return !1;
|
|
139
|
+
}
|
|
140
|
+
return typeof e == "number" ? e !== 0 : typeof e == "boolean" ? e : !!e;
|
|
141
|
+
case "toArray":
|
|
142
|
+
return Array.isArray(e) ? e : [e];
|
|
143
|
+
case "toObject":
|
|
144
|
+
if (n && Array.isArray(n)) {
|
|
145
|
+
if (typeof e != "object" || e === null)
|
|
146
|
+
return e;
|
|
147
|
+
const s = {};
|
|
148
|
+
return n.forEach((o) => {
|
|
149
|
+
o.sourceKey && o.targetKey && (s[o.targetKey] = e[o.sourceKey]);
|
|
150
|
+
}), s;
|
|
151
|
+
}
|
|
152
|
+
return e;
|
|
153
|
+
default:
|
|
154
|
+
return e;
|
|
155
|
+
}
|
|
156
|
+
}, Ue = (e, r) => {
|
|
157
|
+
if (Object.is(e, r))
|
|
158
|
+
return !0;
|
|
159
|
+
if (!(e && r) || typeof e != "object" || typeof r != "object")
|
|
160
|
+
return !1;
|
|
161
|
+
try {
|
|
162
|
+
return JSON.stringify(e) === JSON.stringify(r);
|
|
163
|
+
} catch {
|
|
164
|
+
return !1;
|
|
165
|
+
}
|
|
166
|
+
}, _t = (e, r, n) => {
|
|
167
|
+
const s = {};
|
|
168
|
+
return e.forEach((o) => {
|
|
169
|
+
const { defaultValue: i } = o.data;
|
|
170
|
+
if (!i || i.type !== "reference" || !i.referenceField)
|
|
171
|
+
return;
|
|
172
|
+
const a = o.id, { referenceField: l, transformFunction: c, objectMapping: m } = i, u = r[l], d = n[l];
|
|
173
|
+
if (u === d || u === void 0 || u === null)
|
|
174
|
+
return;
|
|
175
|
+
const f = Le(u, c, m), h = Le(d, c, m), g = r[a], p = Ue(g, h), y = Ue(g, f);
|
|
176
|
+
!p || y || (s[a] = f);
|
|
177
|
+
}), s;
|
|
178
|
+
}, Vt = (e) => {
|
|
179
|
+
const r = /* @__PURE__ */ new Map();
|
|
180
|
+
return e.forEach((n) => {
|
|
181
|
+
const s = r.get(n.source);
|
|
182
|
+
s ? s.push(n) : r.set(n.source, [n]);
|
|
183
|
+
}), r;
|
|
184
|
+
}, Mt = (e, r, n) => {
|
|
185
|
+
const s = [], o = [], i = [];
|
|
186
|
+
e.forEach((m) => {
|
|
187
|
+
const u = m.data?.isFallback, d = m.data?.conditions?.length;
|
|
188
|
+
u ? i.push(m) : d ? o.push(m) : s.push(m);
|
|
189
|
+
});
|
|
190
|
+
const a = [...s];
|
|
191
|
+
if (o.length === 0)
|
|
192
|
+
return i.length > 0 && a.length === 0 && a.push(...i), { edgesToFollow: a, waitingForInput: !1 };
|
|
193
|
+
if (!o.every((m) => {
|
|
194
|
+
const u = m.data?.conditions;
|
|
195
|
+
return u ? u.every((d) => {
|
|
196
|
+
if (!d.field)
|
|
197
|
+
return !0;
|
|
198
|
+
const f = n.get(d.field), h = W(f) ? f.id : d.field;
|
|
199
|
+
return $t(h, r);
|
|
200
|
+
}) : !1;
|
|
201
|
+
}))
|
|
202
|
+
return i.length > 0 && a.push(...i), { edgesToFollow: a, waitingForInput: a.length === 0 };
|
|
203
|
+
const c = o.filter((m) => Et(m.data?.conditions, r, n));
|
|
204
|
+
return c.length > 0 ? (a.push(...c), { edgesToFollow: a, waitingForInput: !1 }) : (a.push(...i), { edgesToFollow: a, waitingForInput: !1 });
|
|
205
|
+
}, ot = (e, r) => !r.some((n) => n.target === e), zt = (e, r) => {
|
|
206
|
+
const n = e.filter((s) => ot(s.id, r));
|
|
207
|
+
return n.find(W) || n[0];
|
|
208
|
+
}, Bt = (e, r, n, s) => {
|
|
209
|
+
e.forEach((o) => {
|
|
210
|
+
const i = s.get(o);
|
|
211
|
+
if (!i)
|
|
212
|
+
return;
|
|
213
|
+
let { parentId: a } = i;
|
|
214
|
+
const l = /* @__PURE__ */ new Set();
|
|
215
|
+
for (; a && !l.has(a); ) {
|
|
216
|
+
if (l.add(a), r.add(a), !n.has(a)) {
|
|
217
|
+
const c = n.get(o);
|
|
218
|
+
c !== void 0 && n.set(a, c);
|
|
219
|
+
}
|
|
220
|
+
a = s.get(a)?.parentId;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}, qt = (e, r, n) => {
|
|
224
|
+
const s = zt(e, r);
|
|
225
|
+
if (!s)
|
|
226
|
+
return {
|
|
227
|
+
endOfPathReached: !0,
|
|
228
|
+
visibleNodeIds: /* @__PURE__ */ new Set(),
|
|
229
|
+
visibleNodes: [],
|
|
230
|
+
visibleRootNodes: []
|
|
231
|
+
};
|
|
232
|
+
const o = new Map(e.map((p) => [p.id, p])), i = Vt(r), a = [], l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
|
|
233
|
+
let m = !1;
|
|
234
|
+
const u = (p) => {
|
|
235
|
+
if (c.has(p))
|
|
236
|
+
return;
|
|
237
|
+
c.add(p);
|
|
238
|
+
const y = o.get(p);
|
|
239
|
+
if (!y)
|
|
240
|
+
return;
|
|
241
|
+
l.add(p), a.push(y);
|
|
242
|
+
const R = i.get(p) || [], { edgesToFollow: _, waitingForInput: k } = Mt(R, n, o);
|
|
243
|
+
if (k) {
|
|
244
|
+
m = !0;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
_.forEach((v) => {
|
|
248
|
+
u(v.target);
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
u(s.id);
|
|
252
|
+
const d = new Map(a.map((p, y) => [p.id, y])), f = new Set(l);
|
|
253
|
+
Bt(l, f, d, o);
|
|
254
|
+
const h = e.filter((p) => f.has(p.id)).sort((p, y) => (d.get(p.id) ?? Number.MAX_SAFE_INTEGER) - (d.get(y.id) ?? Number.MAX_SAFE_INTEGER)), g = h.filter((p) => !(p.parentId && f.has(p.parentId)));
|
|
255
|
+
return {
|
|
256
|
+
endOfPathReached: !m,
|
|
257
|
+
visibleNodeIds: f,
|
|
258
|
+
visibleNodes: h,
|
|
259
|
+
visibleRootNodes: g
|
|
260
|
+
};
|
|
261
|
+
}, Lt = (e) => {
|
|
262
|
+
if (e.length === 1)
|
|
263
|
+
return e[0];
|
|
264
|
+
const r = new Set(e.map((s) => s.id)), n = /* @__PURE__ */ new Set();
|
|
265
|
+
return e.forEach((s) => {
|
|
266
|
+
s.nodes.forEach((o) => {
|
|
267
|
+
if (He(o)) {
|
|
268
|
+
const i = o.data.targetId;
|
|
269
|
+
i && r.has(i) && n.add(i);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}), e.find((s) => !n.has(s.id)) || e[0];
|
|
273
|
+
}, it = (e, r, n, s, o = /* @__PURE__ */ new Set()) => {
|
|
274
|
+
const i = /* @__PURE__ */ new Set();
|
|
275
|
+
for (const a of e)
|
|
276
|
+
if (n.has(a)) {
|
|
277
|
+
const l = s.get(a), c = l ? r.get(l) : void 0;
|
|
278
|
+
if (c) {
|
|
279
|
+
if (l && o.has(l))
|
|
280
|
+
continue;
|
|
281
|
+
l && o.add(l);
|
|
282
|
+
const m = new Set(c.nodes.map((d) => d.id)), u = it(m, r, n, s, o);
|
|
283
|
+
for (const d of u)
|
|
284
|
+
i.add(d);
|
|
285
|
+
}
|
|
286
|
+
} else
|
|
287
|
+
i.add(a);
|
|
288
|
+
return i;
|
|
289
|
+
}, Ut = (e, r) => {
|
|
290
|
+
const n = /* @__PURE__ */ new Set();
|
|
291
|
+
return r.forEach((s) => {
|
|
292
|
+
e.has(s.source) && e.has(s.target) && n.add(s.source);
|
|
293
|
+
}), Array.from(e).filter((s) => !n.has(s));
|
|
294
|
+
}, lt = (e) => {
|
|
295
|
+
if (!e)
|
|
296
|
+
return { edges: [], id: "empty", nodes: [] };
|
|
297
|
+
const r = Array.isArray(e) ? e : [e];
|
|
298
|
+
if (r.length === 0)
|
|
299
|
+
return { edges: [], id: "empty", nodes: [] };
|
|
300
|
+
const n = Lt(r);
|
|
301
|
+
if (r.length === 1)
|
|
302
|
+
return n;
|
|
303
|
+
const s = new Map(r.map((f) => [f.id, f])), o = [], i = [...n.edges], a = /* @__PURE__ */ new Set([n.id]), l = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), u = (f) => {
|
|
304
|
+
const h = [];
|
|
305
|
+
return f.forEach((g) => {
|
|
306
|
+
if (!He(g)) {
|
|
307
|
+
h.push(g);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const p = g.data.targetId;
|
|
311
|
+
if (!p)
|
|
312
|
+
return;
|
|
313
|
+
const y = s.get(p);
|
|
314
|
+
if (!y) {
|
|
315
|
+
console.warn(`Flow with id "${p}" not found`);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const R = y.nodes.find((_) => !_.parentId);
|
|
319
|
+
if (!R) {
|
|
320
|
+
console.warn(`Flow "${p}" has no root node; preserving FlowNode "${g.id}"`), h.push(g);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
l.set(g.id, R.id), c.set(g.id, p), a.has(p) || (a.add(p), i.push(...y.edges), h.push(...u(y.nodes)));
|
|
324
|
+
}), h;
|
|
325
|
+
};
|
|
326
|
+
o.push(...u(n.nodes)), i.forEach((f) => {
|
|
327
|
+
if (l.has(f.source)) {
|
|
328
|
+
const h = m.get(f.source);
|
|
329
|
+
h ? h.push(f) : m.set(f.source, [f]);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
const d = i.map((f) => {
|
|
333
|
+
if (l.has(f.source))
|
|
334
|
+
return null;
|
|
335
|
+
const h = l.get(f.target);
|
|
336
|
+
return h ? { ...f, target: h } : f;
|
|
337
|
+
}).filter((f) => f !== null);
|
|
338
|
+
return l.forEach((f, h) => {
|
|
339
|
+
const g = m.get(h);
|
|
340
|
+
if (!g?.length)
|
|
341
|
+
return;
|
|
342
|
+
const p = c.get(h), y = p ? s.get(p) : void 0;
|
|
343
|
+
if (!y)
|
|
344
|
+
return;
|
|
345
|
+
const R = new Set(y.nodes.map((v) => v.id)), _ = it(
|
|
346
|
+
R,
|
|
347
|
+
s,
|
|
348
|
+
l,
|
|
349
|
+
c,
|
|
350
|
+
new Set(p ? [p] : [])
|
|
351
|
+
);
|
|
352
|
+
Ut(_, d).forEach((v) => {
|
|
353
|
+
g.forEach((x) => {
|
|
354
|
+
const b = l.get(x.target) ?? x.target, w = x.id ?? `${h}__${x.target}`;
|
|
355
|
+
d.push({
|
|
356
|
+
...x,
|
|
357
|
+
id: `${v}__${w}`,
|
|
358
|
+
source: v,
|
|
359
|
+
target: b
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
}), {
|
|
364
|
+
edges: d,
|
|
365
|
+
id: n.id,
|
|
366
|
+
nodes: o
|
|
367
|
+
};
|
|
368
|
+
}, ct = Ze(null), Ht = ({ children: e, value: r }) => /* @__PURE__ */ t.jsx(ct.Provider, { value: r, children: e }), he = () => {
|
|
369
|
+
const r = et(ct) ?? {
|
|
370
|
+
flows: null,
|
|
371
|
+
formErrors: {},
|
|
372
|
+
formValues: {},
|
|
373
|
+
googleApiKey: void 0,
|
|
374
|
+
inputNodes: [],
|
|
375
|
+
language: "",
|
|
376
|
+
setFieldValue: () => {
|
|
377
|
+
}
|
|
378
|
+
}, n = G(() => r.flows ? lt(r.flows).edges : [], [r.flows]);
|
|
379
|
+
return {
|
|
380
|
+
...r,
|
|
381
|
+
edges: n
|
|
382
|
+
};
|
|
383
|
+
}, q = (e) => {
|
|
384
|
+
const r = he(), n = e ?? r.language;
|
|
385
|
+
return Nt(n);
|
|
386
|
+
}, Gt = (e, r = {}, n = "en") => {
|
|
387
|
+
const s = G(() => lt(e), [e]), { nodes: o, edges: i } = s, a = G(() => Ot(o), [o]), l = q(n), c = K({}), [m, u] = B({}), [d, f] = B(() => {
|
|
388
|
+
const x = { ...r };
|
|
389
|
+
return o.forEach((b) => {
|
|
390
|
+
if (W(b)) {
|
|
391
|
+
const w = b.id;
|
|
392
|
+
if (x[w] !== void 0)
|
|
393
|
+
return;
|
|
394
|
+
const { defaultValue: F } = b.data;
|
|
395
|
+
if (!F)
|
|
396
|
+
return;
|
|
397
|
+
if (F.type === "static" && F.staticValue !== void 0 && (x[w] = F.staticValue), F.type === "reference" && F.referenceField) {
|
|
398
|
+
const { referenceField: $ } = F, L = x[$];
|
|
399
|
+
L !== void 0 && (x[w] = L);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}), x;
|
|
403
|
+
}), { endOfPathReached: h, visibleNodes: g, visibleRootNodes: p } = G(
|
|
404
|
+
() => qt(o, i, d),
|
|
405
|
+
[o, i, d]
|
|
406
|
+
), y = Q((x, b) => {
|
|
407
|
+
f((w) => ({
|
|
408
|
+
...w,
|
|
409
|
+
[x]: b
|
|
410
|
+
})), u((w) => {
|
|
411
|
+
const F = { ...w };
|
|
412
|
+
return delete F[x], F;
|
|
413
|
+
});
|
|
414
|
+
}, []), R = Q((x) => {
|
|
415
|
+
Object.keys(x).length !== 0 && (f((b) => ({
|
|
416
|
+
...b,
|
|
417
|
+
...x
|
|
418
|
+
})), u((b) => {
|
|
419
|
+
const w = { ...b };
|
|
420
|
+
return Object.keys(x).forEach((F) => {
|
|
421
|
+
delete w[F];
|
|
422
|
+
}), w;
|
|
423
|
+
}));
|
|
424
|
+
}, []), _ = Q(
|
|
425
|
+
(x) => {
|
|
426
|
+
const b = {};
|
|
427
|
+
g.forEach(($) => {
|
|
428
|
+
if (W($)) {
|
|
429
|
+
const L = $.id, ee = d[L];
|
|
430
|
+
if ($.data.required && ve(ee)) {
|
|
431
|
+
b[L] = l($.data.errorMessage) || l("validation.required");
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (!ve(ee) && $.data.pattern)
|
|
435
|
+
try {
|
|
436
|
+
new RegExp($.data.pattern).test(String(ee)) || (b[L] = l($.data.errorMessage) || l("validation.invalidFormat"));
|
|
437
|
+
} catch (Y) {
|
|
438
|
+
console.error(`Invalid pattern for field ${L}:`, Y);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
const w = x ? x(d, g) : {}, F = {
|
|
443
|
+
...b,
|
|
444
|
+
...w
|
|
445
|
+
};
|
|
446
|
+
return u(F), {
|
|
447
|
+
errors: F,
|
|
448
|
+
hasCustomErrors: Object.keys(w).length > 0,
|
|
449
|
+
isValid: Object.keys(F).length === 0
|
|
450
|
+
};
|
|
451
|
+
},
|
|
452
|
+
[g, d, l]
|
|
453
|
+
), k = G(() => {
|
|
454
|
+
const x = [];
|
|
455
|
+
return g.forEach((b) => {
|
|
456
|
+
if (!W(b))
|
|
457
|
+
return;
|
|
458
|
+
const w = b.id, F = d[w];
|
|
459
|
+
if (b.data.required && ve(F)) {
|
|
460
|
+
const $ = l(b.data.label) || w;
|
|
461
|
+
x.push($);
|
|
462
|
+
}
|
|
463
|
+
}), x;
|
|
464
|
+
}, [g, d, l]);
|
|
465
|
+
return {
|
|
466
|
+
canSubmit: !G(() => g.some((x) => W(x) && x.data.type === "submit"), [g]) && h && o.length > 0,
|
|
467
|
+
formErrors: m,
|
|
468
|
+
formValues: d,
|
|
469
|
+
inputNodes: a,
|
|
470
|
+
mergedFlow: s,
|
|
471
|
+
missingRequiredFields: k,
|
|
472
|
+
prevFormValuesRef: c,
|
|
473
|
+
setFieldValue: y,
|
|
474
|
+
setFormErrors: u,
|
|
475
|
+
setMultipleFieldValues: R,
|
|
476
|
+
t: l,
|
|
477
|
+
validateForm: _,
|
|
478
|
+
visibleNodes: g,
|
|
479
|
+
visibleRootNodes: p
|
|
480
|
+
};
|
|
481
|
+
}, Wt = ({ children: e, onSubmit: r }) => /* @__PURE__ */ t.jsx("form", { onSubmit: r, className: "mx-auto max-w-2xl gap-y-3", children: e }), Kt = ({ node: e, children: r }) => {
|
|
482
|
+
const n = q();
|
|
483
|
+
return /* @__PURE__ */ t.jsxs("section", { className: "mb-6 rounded-lg border p-4", children: [
|
|
484
|
+
e.data.label && /* @__PURE__ */ t.jsx("h3", { className: "text-lg font-semibold mb-4", children: n(e.data.label) }),
|
|
485
|
+
r
|
|
486
|
+
] });
|
|
487
|
+
}, Jt = async (e, r) => {
|
|
488
|
+
if (!e || e.trim().length < 3)
|
|
489
|
+
return [];
|
|
490
|
+
try {
|
|
491
|
+
const n = await fetch(
|
|
492
|
+
`https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(e)}&format=jsonv2&addressdetails=1&limit=5`,
|
|
493
|
+
{
|
|
494
|
+
headers: {
|
|
495
|
+
Accept: "application/json",
|
|
496
|
+
"User-Agent": "Treege Renderer",
|
|
497
|
+
...r && { "Accept-Language": r }
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
return n.ok ? (await n.json()).map((o) => ({
|
|
502
|
+
label: o.display_name,
|
|
503
|
+
value: o.display_name
|
|
504
|
+
})) : [];
|
|
505
|
+
} catch (n) {
|
|
506
|
+
return console.error("Nominatim fetch error:", n), [];
|
|
507
|
+
}
|
|
508
|
+
}, Qt = (e) => !e || e.trim().length < 3 ? Promise.resolve([]) : new Promise((r) => {
|
|
509
|
+
if (!window.google?.maps?.places) {
|
|
510
|
+
console.warn("Google Places SDK not loaded yet"), r([]);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
new window.google.maps.places.AutocompleteService().getPlacePredictions({ input: e }, (s, o) => {
|
|
514
|
+
if (o !== google.maps.places.PlacesServiceStatus.OK || !s) {
|
|
515
|
+
console.warn("Google Places API status:", o), r([]);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
r(
|
|
519
|
+
s.map((i) => ({
|
|
520
|
+
label: i.description,
|
|
521
|
+
value: i.description
|
|
522
|
+
}))
|
|
523
|
+
);
|
|
524
|
+
});
|
|
525
|
+
}), Xt = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, id: l, name: c }) => {
|
|
526
|
+
const [m, u] = B(""), [d, f] = B([]), [h, g] = B(!1), { googleApiKey: p, language: y } = he(), R = q(), _ = Q(
|
|
527
|
+
(v) => {
|
|
528
|
+
n(v.value), u(v.value), g(!1);
|
|
529
|
+
},
|
|
530
|
+
[n]
|
|
531
|
+
);
|
|
532
|
+
J(() => {
|
|
533
|
+
if (!m || m.trim().length < 3) {
|
|
534
|
+
f([]);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const v = setTimeout(async () => {
|
|
538
|
+
const x = p ? await Qt(m) : await Jt(m, y);
|
|
539
|
+
f(x);
|
|
540
|
+
}, 300);
|
|
541
|
+
return () => clearTimeout(v);
|
|
542
|
+
}, [m, p, y]);
|
|
543
|
+
const k = Q(
|
|
544
|
+
(v) => {
|
|
545
|
+
n(v), u(v), v.length >= 3 && g(!0);
|
|
546
|
+
},
|
|
547
|
+
[n]
|
|
548
|
+
);
|
|
549
|
+
return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
550
|
+
p && /* @__PURE__ */ t.jsx("script", { async: !0, src: `https://maps.googleapis.com/maps/api/js?key=${p}&libraries=places` }),
|
|
551
|
+
/* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
552
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: l, children: [
|
|
553
|
+
o || e.data.name,
|
|
554
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
555
|
+
] }),
|
|
556
|
+
/* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
|
|
557
|
+
/* @__PURE__ */ t.jsx(
|
|
558
|
+
X,
|
|
559
|
+
{
|
|
560
|
+
type: "text",
|
|
561
|
+
id: l,
|
|
562
|
+
name: c,
|
|
563
|
+
value: r || "",
|
|
564
|
+
onChange: (v) => k(v.target.value),
|
|
565
|
+
onFocus: () => {
|
|
566
|
+
d.length > 0 && g(!0);
|
|
567
|
+
},
|
|
568
|
+
placeholder: i || R("renderer.defaultAddressInput.enterAddress"),
|
|
569
|
+
className: "pr-10",
|
|
570
|
+
autoComplete: "off"
|
|
571
|
+
}
|
|
572
|
+
),
|
|
573
|
+
/* @__PURE__ */ t.jsx(Be, { className: "-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 h-4 w-4 text-muted-foreground" }),
|
|
574
|
+
h && /* @__PURE__ */ t.jsx("div", { className: "absolute z-50 mt-1 w-full rounded-md border bg-popover shadow-md", children: /* @__PURE__ */ t.jsx(Re, { children: /* @__PURE__ */ t.jsxs(ke, { children: [
|
|
575
|
+
/* @__PURE__ */ t.jsx(Ae, { children: R("renderer.defaultAddressInput.noAddressesFound") }),
|
|
576
|
+
/* @__PURE__ */ t.jsx(De, { children: d.map((v, x) => /* @__PURE__ */ t.jsxs(
|
|
577
|
+
Ee,
|
|
578
|
+
{
|
|
579
|
+
value: v.value,
|
|
580
|
+
onSelect: () => _(v),
|
|
581
|
+
onMouseDown: (b) => b.preventDefault(),
|
|
582
|
+
children: [
|
|
583
|
+
/* @__PURE__ */ t.jsx(Be, { className: "mr-2 h-4 w-4" }),
|
|
584
|
+
v.label
|
|
585
|
+
]
|
|
586
|
+
},
|
|
587
|
+
x
|
|
588
|
+
)) })
|
|
589
|
+
] }) }) })
|
|
590
|
+
] }),
|
|
591
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
592
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
593
|
+
] })
|
|
594
|
+
] });
|
|
595
|
+
}, Yt = ({
|
|
596
|
+
node: e,
|
|
597
|
+
value: r,
|
|
598
|
+
setValue: n,
|
|
599
|
+
error: s,
|
|
600
|
+
label: o,
|
|
601
|
+
placeholder: i,
|
|
602
|
+
helperText: a,
|
|
603
|
+
id: l
|
|
604
|
+
}) => {
|
|
605
|
+
const c = q(), [m, u] = B(!1), d = `${l}-trigger`, f = `${l}-error`, h = e.data.options || [], g = h.find((p) => p.value === r);
|
|
606
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
607
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: d, children: [
|
|
608
|
+
o || e.data.name,
|
|
609
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
610
|
+
] }),
|
|
611
|
+
/* @__PURE__ */ t.jsxs(me, { open: m, onOpenChange: u, children: [
|
|
612
|
+
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
|
|
613
|
+
le,
|
|
614
|
+
{
|
|
615
|
+
id: d,
|
|
616
|
+
variant: "outline",
|
|
617
|
+
role: "combobox",
|
|
618
|
+
"aria-expanded": m,
|
|
619
|
+
"aria-invalid": !!s || void 0,
|
|
620
|
+
"aria-describedby": s ? f : void 0,
|
|
621
|
+
className: "w-full justify-between font-normal",
|
|
622
|
+
children: [
|
|
623
|
+
r ? g?.label ? c(g.label) : r : i || c("renderer.defaultAutocompleteInput.selectOption"),
|
|
624
|
+
/* @__PURE__ */ t.jsx(tt, { className: "ml-2 size-4 shrink-0 opacity-50" })
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
) }),
|
|
628
|
+
/* @__PURE__ */ t.jsx(pe, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ t.jsxs(Re, { children: [
|
|
629
|
+
/* @__PURE__ */ t.jsx(Ge, { placeholder: i || c("renderer.defaultAutocompleteInput.search") }),
|
|
630
|
+
/* @__PURE__ */ t.jsxs(ke, { children: [
|
|
631
|
+
/* @__PURE__ */ t.jsx(Ae, { children: c("renderer.defaultAutocompleteInput.noResults") }),
|
|
632
|
+
/* @__PURE__ */ t.jsx(De, { children: h.map((p) => /* @__PURE__ */ t.jsxs(
|
|
633
|
+
Ee,
|
|
634
|
+
{
|
|
635
|
+
value: p.value,
|
|
636
|
+
disabled: p.disabled,
|
|
637
|
+
onSelect: (y) => {
|
|
638
|
+
n(y === r ? "" : y), u(!1);
|
|
639
|
+
},
|
|
640
|
+
children: [
|
|
641
|
+
/* @__PURE__ */ t.jsx(st, { className: j("mr-2 size-4", r === p.value ? "opacity-100" : "opacity-0") }),
|
|
642
|
+
c(p.label)
|
|
643
|
+
]
|
|
644
|
+
},
|
|
645
|
+
p.value
|
|
646
|
+
)) })
|
|
647
|
+
] })
|
|
648
|
+
] }) })
|
|
649
|
+
] }),
|
|
650
|
+
s && /* @__PURE__ */ t.jsx(O, { id: f, children: s }),
|
|
651
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
652
|
+
] });
|
|
653
|
+
}, Zt = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a, name: l }) => {
|
|
654
|
+
const c = q();
|
|
655
|
+
if (e.data.options && e.data.options.length > 0) {
|
|
656
|
+
const m = Array.isArray(r) ? r.map(String) : [], u = (d, f) => {
|
|
657
|
+
const h = f ? [...m, d] : m.filter((g) => g !== d);
|
|
658
|
+
n(h);
|
|
659
|
+
};
|
|
660
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
661
|
+
/* @__PURE__ */ t.jsxs(T, { className: "mb-1", children: [
|
|
662
|
+
o || e.data.name,
|
|
663
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
664
|
+
] }),
|
|
665
|
+
/* @__PURE__ */ t.jsx("div", { className: "space-y-2", children: e.data.options.map((d, f) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
666
|
+
/* @__PURE__ */ t.jsx(
|
|
667
|
+
Ve,
|
|
668
|
+
{
|
|
669
|
+
id: `${a}-${d.value}`,
|
|
670
|
+
name: l,
|
|
671
|
+
checked: m.includes(String(d.value)),
|
|
672
|
+
onCheckedChange: (h) => u(String(d.value), !!h),
|
|
673
|
+
disabled: d.disabled
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
/* @__PURE__ */ t.jsx(T, { htmlFor: `${a}-${d.value}`, className: "cursor-pointer font-normal text-sm", children: c(d.label) ? c(d.label) : d.value })
|
|
677
|
+
] }, d.value + f)) }),
|
|
678
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
679
|
+
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
680
|
+
] });
|
|
681
|
+
}
|
|
682
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
683
|
+
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
684
|
+
/* @__PURE__ */ t.jsx(
|
|
685
|
+
Ve,
|
|
686
|
+
{
|
|
687
|
+
id: a,
|
|
688
|
+
name: l,
|
|
689
|
+
checked: typeof r == "boolean" ? r : !1,
|
|
690
|
+
onCheckedChange: (m) => n(!!m)
|
|
691
|
+
}
|
|
692
|
+
),
|
|
693
|
+
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
694
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: a, className: "cursor-pointer font-medium text-sm", children: [
|
|
695
|
+
o || e.data.name,
|
|
696
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
697
|
+
] }),
|
|
698
|
+
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
699
|
+
] })
|
|
700
|
+
] }),
|
|
701
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s })
|
|
702
|
+
] });
|
|
703
|
+
};
|
|
704
|
+
function dt({
|
|
705
|
+
className: e,
|
|
706
|
+
classNames: r,
|
|
707
|
+
showOutsideDays: n = !0,
|
|
708
|
+
captionLayout: s = "label",
|
|
709
|
+
buttonVariant: o = "ghost",
|
|
710
|
+
formatters: i,
|
|
711
|
+
components: a,
|
|
712
|
+
...l
|
|
713
|
+
}) {
|
|
714
|
+
const c = rt();
|
|
715
|
+
return /* @__PURE__ */ t.jsx(
|
|
716
|
+
At,
|
|
717
|
+
{
|
|
718
|
+
showOutsideDays: n,
|
|
719
|
+
className: j(
|
|
720
|
+
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
721
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
722
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
723
|
+
e
|
|
724
|
+
),
|
|
725
|
+
captionLayout: s,
|
|
726
|
+
formatters: {
|
|
727
|
+
formatMonthDropdown: (m) => m.toLocaleString("default", { month: "short" }),
|
|
728
|
+
...i
|
|
729
|
+
},
|
|
730
|
+
classNames: {
|
|
731
|
+
button_next: j(
|
|
732
|
+
Me({ variant: o }),
|
|
733
|
+
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
734
|
+
c.button_next
|
|
735
|
+
),
|
|
736
|
+
button_previous: j(
|
|
737
|
+
Me({ variant: o }),
|
|
738
|
+
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
739
|
+
c.button_previous
|
|
740
|
+
),
|
|
741
|
+
caption_label: j(
|
|
742
|
+
"select-none font-medium",
|
|
743
|
+
s === "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",
|
|
744
|
+
c.caption_label
|
|
745
|
+
),
|
|
746
|
+
day: j(
|
|
747
|
+
"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",
|
|
748
|
+
c.day
|
|
749
|
+
),
|
|
750
|
+
disabled: j("text-muted-foreground opacity-50", c.disabled),
|
|
751
|
+
dropdown: j("absolute bg-popover inset-0 opacity-0", c.dropdown),
|
|
752
|
+
dropdown_root: j(
|
|
753
|
+
"relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
|
|
754
|
+
c.dropdown_root
|
|
755
|
+
),
|
|
756
|
+
dropdowns: j("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", c.dropdowns),
|
|
757
|
+
hidden: j("invisible", c.hidden),
|
|
758
|
+
month: j("flex flex-col w-full gap-4", c.month),
|
|
759
|
+
month_caption: j("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", c.month_caption),
|
|
760
|
+
months: j("flex gap-4 flex-col md:flex-row relative", c.months),
|
|
761
|
+
nav: j("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", c.nav),
|
|
762
|
+
outside: j("text-muted-foreground aria-selected:text-muted-foreground", c.outside),
|
|
763
|
+
range_end: j("rounded-r-md bg-accent", c.range_end),
|
|
764
|
+
range_middle: j("rounded-none", c.range_middle),
|
|
765
|
+
range_start: j("rounded-l-md bg-accent", c.range_start),
|
|
766
|
+
root: j("w-fit", c.root),
|
|
767
|
+
table: "w-full border-collapse",
|
|
768
|
+
today: j("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none", c.today),
|
|
769
|
+
week: j("flex w-full mt-2", c.week),
|
|
770
|
+
week_number: j("text-[0.8rem] select-none text-muted-foreground", c.week_number),
|
|
771
|
+
week_number_header: j("select-none w-(--cell-size)", c.week_number_header),
|
|
772
|
+
weekday: j("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", c.weekday),
|
|
773
|
+
weekdays: j("flex", c.weekdays),
|
|
774
|
+
...r
|
|
775
|
+
},
|
|
776
|
+
components: {
|
|
777
|
+
Chevron: ({ className: m, orientation: u, ...d }) => u === "left" ? /* @__PURE__ */ t.jsx(Tt, { className: j("size-4", m), ...d }) : u === "right" ? /* @__PURE__ */ t.jsx(Rt, { className: j("size-4", m), ...d }) : /* @__PURE__ */ t.jsx(Oe, { className: j("size-4", m), ...d }),
|
|
778
|
+
DayButton: es,
|
|
779
|
+
Root: ({ className: m, rootRef: u, ...d }) => /* @__PURE__ */ t.jsx("div", { "data-slot": "calendar", ref: u, className: j(m), ...d }),
|
|
780
|
+
WeekNumber: ({ children: m, ...u }) => /* @__PURE__ */ t.jsx("td", { ...u, children: /* @__PURE__ */ t.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children: m }) }),
|
|
781
|
+
...a
|
|
782
|
+
},
|
|
783
|
+
...l
|
|
784
|
+
}
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
function es({ className: e, day: r, modifiers: n, ...s }) {
|
|
788
|
+
const o = rt(), i = ze.useRef(null);
|
|
789
|
+
return ze.useEffect(() => {
|
|
790
|
+
n.focused && i.current?.focus();
|
|
791
|
+
}, [n.focused]), /* @__PURE__ */ t.jsx(
|
|
792
|
+
le,
|
|
793
|
+
{
|
|
794
|
+
ref: i,
|
|
795
|
+
variant: "ghost",
|
|
796
|
+
size: "icon",
|
|
797
|
+
"data-day": r.date.toLocaleDateString(),
|
|
798
|
+
"data-selected-single": n.selected && !n.range_start && !n.range_end && !n.range_middle,
|
|
799
|
+
"data-range-start": n.range_start,
|
|
800
|
+
"data-range-end": n.range_end,
|
|
801
|
+
"data-range-middle": n.range_middle,
|
|
802
|
+
className: j(
|
|
803
|
+
"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",
|
|
804
|
+
o.day,
|
|
805
|
+
e
|
|
806
|
+
),
|
|
807
|
+
...s
|
|
808
|
+
}
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
const ts = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, id: l, name: c }) => {
|
|
812
|
+
const [m, u] = B(!1), d = q(), f = r ? new Date(r) : void 0;
|
|
813
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
814
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: l, children: [
|
|
815
|
+
o || e.data.name,
|
|
816
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
817
|
+
] }),
|
|
818
|
+
/* @__PURE__ */ t.jsxs(me, { open: m, onOpenChange: u, children: [
|
|
819
|
+
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(le, { variant: "outline", id: l, name: c, className: "w-full justify-between font-normal", children: [
|
|
820
|
+
f ? f.toLocaleDateString() : i || d("renderer.defaultInputs.selectDate"),
|
|
821
|
+
/* @__PURE__ */ t.jsx(Oe, { className: "size-4" })
|
|
822
|
+
] }) }),
|
|
823
|
+
/* @__PURE__ */ t.jsx(pe, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
|
|
824
|
+
dt,
|
|
825
|
+
{
|
|
826
|
+
mode: "single",
|
|
827
|
+
selected: f,
|
|
828
|
+
captionLayout: "dropdown",
|
|
829
|
+
onSelect: (h) => {
|
|
830
|
+
n(h ? h.toISOString() : ""), u(!1);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
) })
|
|
834
|
+
] }),
|
|
835
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
836
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
837
|
+
] });
|
|
838
|
+
}, ss = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a }) => {
|
|
839
|
+
const [l, c] = B(!1), m = q(), u = Array.isArray(r) ? r : [], d = u[0] ? new Date(u[0]) : void 0, f = u[1] ? new Date(u[1]) : void 0, h = (p) => {
|
|
840
|
+
n([p?.from ? p.from.toISOString() : void 0, p?.to ? p.to.toISOString() : void 0]);
|
|
841
|
+
}, g = () => d && f ? `${d.toLocaleDateString()} - ${f.toLocaleDateString()}` : d ? d.toLocaleDateString() : m("renderer.defaultInputs.selectDateRange");
|
|
842
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
843
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: a, children: [
|
|
844
|
+
o || e.data.name,
|
|
845
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
846
|
+
] }),
|
|
847
|
+
/* @__PURE__ */ t.jsxs(me, { open: l, onOpenChange: c, children: [
|
|
848
|
+
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(le, { id: a, variant: "outline", className: "w-full justify-between font-normal", children: [
|
|
849
|
+
g(),
|
|
850
|
+
/* @__PURE__ */ t.jsx(Oe, { className: "size-4" })
|
|
851
|
+
] }) }),
|
|
852
|
+
/* @__PURE__ */ t.jsx(pe, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
|
|
853
|
+
dt,
|
|
854
|
+
{
|
|
855
|
+
mode: "range",
|
|
856
|
+
selected: { from: d, to: f },
|
|
857
|
+
captionLayout: "dropdown",
|
|
858
|
+
onSelect: h,
|
|
859
|
+
numberOfMonths: 2
|
|
860
|
+
}
|
|
861
|
+
) })
|
|
862
|
+
] }),
|
|
863
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
864
|
+
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
865
|
+
] });
|
|
866
|
+
}, ut = (e) => new Promise((r, n) => {
|
|
867
|
+
const s = new FileReader();
|
|
868
|
+
s.onload = () => {
|
|
869
|
+
const o = s.result;
|
|
870
|
+
r({
|
|
871
|
+
data: o,
|
|
872
|
+
lastModified: e.lastModified,
|
|
873
|
+
name: e.name,
|
|
874
|
+
size: e.size,
|
|
875
|
+
type: e.type
|
|
876
|
+
});
|
|
877
|
+
}, s.onerror = () => {
|
|
878
|
+
n(new Error(`Failed to read file: ${e.name}`));
|
|
879
|
+
}, s.readAsDataURL(e);
|
|
880
|
+
}), Us = (e) => {
|
|
881
|
+
const r = e.data.split(",")[1], n = atob(r), s = new ArrayBuffer(n.length), o = new Uint8Array(s);
|
|
882
|
+
for (let a = 0; a < n.length; a++)
|
|
883
|
+
o[a] = n.charCodeAt(a);
|
|
884
|
+
const i = new Blob([s], { type: e.type });
|
|
885
|
+
return new File([i], e.name, {
|
|
886
|
+
lastModified: e.lastModified,
|
|
887
|
+
type: e.type
|
|
888
|
+
});
|
|
889
|
+
}, rs = (e) => Promise.all(e.map((r) => ut(r))), ns = ({ node: e, setValue: r, error: n, label: s, placeholder: o, helperText: i, name: a, id: l }) => {
|
|
890
|
+
const c = async (m) => {
|
|
891
|
+
const { files: u } = m.target;
|
|
892
|
+
if (!u || u.length === 0) {
|
|
893
|
+
r(null);
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (e.data.multiple) {
|
|
897
|
+
const f = await rs(Array.from(u));
|
|
898
|
+
r(f);
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
const d = await ut(u[0]);
|
|
902
|
+
r(d);
|
|
903
|
+
};
|
|
904
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
905
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: l, children: [
|
|
906
|
+
s || e.data.name,
|
|
907
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
908
|
+
] }),
|
|
909
|
+
/* @__PURE__ */ t.jsx(X, { type: "file", name: a, id: l, onChange: c, multiple: e.data.multiple, placeholder: o }),
|
|
910
|
+
n && /* @__PURE__ */ t.jsx(O, { children: n }),
|
|
911
|
+
i && !n && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
912
|
+
] });
|
|
913
|
+
}, as = ({ value: e, name: r, id: n }) => /* @__PURE__ */ t.jsx(X, { type: "hidden", id: n, name: r, value: e ?? "" });
|
|
914
|
+
function _e({ delayDuration: e = 0, ...r }) {
|
|
915
|
+
return /* @__PURE__ */ t.jsx(ae.Provider, { "data-slot": "tooltip-provider", delayDuration: e, ...r });
|
|
916
|
+
}
|
|
917
|
+
function mt({ ...e }) {
|
|
918
|
+
return /* @__PURE__ */ t.jsx(_e, { children: /* @__PURE__ */ t.jsx(ae.Root, { "data-slot": "tooltip", ...e }) });
|
|
919
|
+
}
|
|
920
|
+
function ft({ ...e }) {
|
|
921
|
+
return /* @__PURE__ */ t.jsx(ae.Trigger, { "data-slot": "tooltip-trigger", ...e });
|
|
922
|
+
}
|
|
923
|
+
function pt({ className: e, sideOffset: r = 0, children: n, ...s }) {
|
|
924
|
+
return /* @__PURE__ */ t.jsx(ae.Portal, { children: /* @__PURE__ */ t.jsxs(
|
|
925
|
+
ae.Content,
|
|
926
|
+
{
|
|
927
|
+
"data-slot": "tooltip-content",
|
|
928
|
+
sideOffset: r,
|
|
929
|
+
className: j(
|
|
930
|
+
"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",
|
|
931
|
+
e
|
|
932
|
+
),
|
|
933
|
+
...s,
|
|
934
|
+
children: [
|
|
935
|
+
n,
|
|
936
|
+
/* @__PURE__ */ t.jsx(ae.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
|
|
937
|
+
]
|
|
938
|
+
}
|
|
939
|
+
) });
|
|
940
|
+
}
|
|
941
|
+
const we = (e, r) => r ? r.split(".").reduce((s, o) => {
|
|
942
|
+
if (s == null)
|
|
943
|
+
return;
|
|
944
|
+
const i = o.match(/^(\w+)\[(\d+)]$/);
|
|
945
|
+
if (i) {
|
|
946
|
+
const [, a, l] = i, c = s[a];
|
|
947
|
+
return Array.isArray(c) ? c[Number.parseInt(l, 10)] : c;
|
|
948
|
+
}
|
|
949
|
+
return s[o];
|
|
950
|
+
}, e) : e, Te = (e) => {
|
|
951
|
+
const r = e.matchAll(/{{([\w-]+)}}/g);
|
|
952
|
+
return Array.from(r, (n) => n[1]);
|
|
953
|
+
}, Se = (e, r) => Te(e).every((s) => {
|
|
954
|
+
const o = r[s];
|
|
955
|
+
return o != null && o !== "";
|
|
956
|
+
}), Fe = (e, r, n = !1) => e.replace(/{{([\w-]+)}}/g, (s, o) => {
|
|
957
|
+
const i = String(r[o] || "");
|
|
958
|
+
return n ? encodeURIComponent(i) : i;
|
|
959
|
+
}), os = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, id: l, name: c }) => {
|
|
960
|
+
const [m, u] = B(!1), [d, f] = B(null), [h, g] = B([]), [p, y] = B(""), [R, _] = B(!1), { formValues: k, inputNodes: v } = he(), x = q(), { httpConfig: b } = e.data, w = K(!1), F = K(""), $ = K(b), L = K(k), ee = K(v), Y = K(n), ce = K(null), te = G(() => b?.url ? Te(b.url) : [], [b?.url]), se = te.length > 0, oe = G(() => te.map((C) => `${C}:${String(k[C] ?? "")}`).join("|"), [te, k]), ie = G(() => b?.url ? se ? Se(b.url, k) : !0 : !1, [b?.url, se, k]), H = Q(
|
|
961
|
+
async (C) => {
|
|
962
|
+
const I = $.current, z = L.current, N = Y.current;
|
|
963
|
+
if (!I?.url) {
|
|
964
|
+
f(x("renderer.defaultHttpInput.noUrlConfigured"));
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
if (!(I.url && !Se(I.url, z))) {
|
|
968
|
+
u(!0), f(null);
|
|
969
|
+
try {
|
|
970
|
+
const V = Fe(I.url, z, !0), A = I.searchParam && C ? `${V}${V.includes("?") ? "&" : "?"}${I.searchParam}=${encodeURIComponent(C)}` : V, D = {};
|
|
971
|
+
I.headers?.forEach((re) => {
|
|
972
|
+
D[re.key] = Fe(re.value, z);
|
|
973
|
+
});
|
|
974
|
+
const S = ["POST", "PUT", "PATCH"].includes(I.method || "") ? I.sendFormData ? JSON.stringify($e(z, ee.current)) : I.body ? Fe(I.body, z) : void 0 : void 0, M = await fetch(A, {
|
|
975
|
+
body: S || void 0,
|
|
976
|
+
headers: {
|
|
977
|
+
"Content-Type": "application/json",
|
|
978
|
+
...D
|
|
979
|
+
},
|
|
980
|
+
method: I.method || "GET"
|
|
981
|
+
});
|
|
982
|
+
if (!M.ok) {
|
|
983
|
+
f(`HTTP ${M.status}: ${M.statusText}`), u(!1);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
const U = await M.json(), Z = I.responsePath ? we(U, I.responsePath) : U;
|
|
987
|
+
if (I.responseMapping && Array.isArray(Z)) {
|
|
988
|
+
const { valueField: re = "value", labelField: ge = "label" } = I.responseMapping, xe = Z.map((de) => ({
|
|
989
|
+
label: String(we(de, ge) || ""),
|
|
990
|
+
value: String(we(de, re) || "")
|
|
991
|
+
}));
|
|
992
|
+
g(xe);
|
|
993
|
+
} else
|
|
994
|
+
N(typeof Z == "string" ? Z : JSON.stringify(Z));
|
|
995
|
+
} catch (V) {
|
|
996
|
+
const A = V instanceof Error ? V.message : x("renderer.defaultHttpInput.fetchFailed");
|
|
997
|
+
f(A), console.error("HTTP Input fetch error:", V);
|
|
998
|
+
} finally {
|
|
999
|
+
u(!1);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
[x]
|
|
1004
|
+
);
|
|
1005
|
+
if (J(() => {
|
|
1006
|
+
$.current = b, L.current = k, ee.current = v, Y.current = n, ce.current = H;
|
|
1007
|
+
}, [b, k, v, n, H]), J(() => {
|
|
1008
|
+
if (w.current)
|
|
1009
|
+
return;
|
|
1010
|
+
w.current = !0;
|
|
1011
|
+
const C = $.current, I = L.current, z = ce.current, N = C?.url && Se(C.url, I);
|
|
1012
|
+
if (C?.fetchOnMount && N && z && (z(), C.url)) {
|
|
1013
|
+
const V = Te(C.url);
|
|
1014
|
+
F.current = V.map((A) => `${A}:${String(I[A] ?? "")}`).join("|");
|
|
1015
|
+
}
|
|
1016
|
+
}, []), J(() => {
|
|
1017
|
+
if (!w.current || !se || F.current === oe || !ie)
|
|
1018
|
+
return;
|
|
1019
|
+
const C = setTimeout(() => {
|
|
1020
|
+
H(), F.current = oe;
|
|
1021
|
+
}, 500);
|
|
1022
|
+
return () => clearTimeout(C);
|
|
1023
|
+
}, [oe, se, ie, H]), J(() => {
|
|
1024
|
+
if (!(b?.searchParam && p))
|
|
1025
|
+
return;
|
|
1026
|
+
const C = setTimeout(() => {
|
|
1027
|
+
H(p);
|
|
1028
|
+
}, 300);
|
|
1029
|
+
return () => clearTimeout(C);
|
|
1030
|
+
}, [p, b?.searchParam, H]), b?.responseMapping) {
|
|
1031
|
+
const C = Array.isArray(r) ? r[0] : r, I = h.find((S) => S.value === C);
|
|
1032
|
+
if (b.searchParam) {
|
|
1033
|
+
const M = m && b?.showLoading ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1034
|
+
/* @__PURE__ */ t.jsx(ye, { className: "h-4 w-4 animate-spin" }),
|
|
1035
|
+
/* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: I?.label || i || x("renderer.defaultHttpInput.search") })
|
|
1036
|
+
] }) : I?.label || i || x("renderer.defaultHttpInput.search");
|
|
1037
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1038
|
+
/* @__PURE__ */ t.jsxs(T, { children: [
|
|
1039
|
+
o || e.data.name,
|
|
1040
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1041
|
+
] }),
|
|
1042
|
+
/* @__PURE__ */ t.jsxs(me, { open: R, onOpenChange: _, children: [
|
|
1043
|
+
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(le, { variant: "outline", role: "combobox", "aria-expanded": R, className: "w-full justify-between", children: [
|
|
1044
|
+
M,
|
|
1045
|
+
/* @__PURE__ */ t.jsx(tt, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
1046
|
+
] }) }),
|
|
1047
|
+
/* @__PURE__ */ t.jsx(pe, { className: "w-[300px] p-0", align: "start", children: /* @__PURE__ */ t.jsxs(Re, { shouldFilter: !1, children: [
|
|
1048
|
+
/* @__PURE__ */ t.jsx(
|
|
1049
|
+
Ge,
|
|
1050
|
+
{
|
|
1051
|
+
placeholder: x("renderer.defaultHttpInput.search"),
|
|
1052
|
+
value: p,
|
|
1053
|
+
onValueChange: (U) => {
|
|
1054
|
+
y(U), f(null);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
),
|
|
1058
|
+
/* @__PURE__ */ t.jsxs(ke, { children: [
|
|
1059
|
+
m && /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ t.jsx(ye, { className: "h-4 w-4 animate-spin" }) }),
|
|
1060
|
+
!m && d && /* @__PURE__ */ t.jsxs("div", { className: "p-4 text-destructive text-sm", children: [
|
|
1061
|
+
/* @__PURE__ */ t.jsx("div", { children: d }),
|
|
1062
|
+
/* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => H(p), className: "mt-2 block text-primary hover:underline", children: x("renderer.defaultHttpInput.retry") })
|
|
1063
|
+
] }),
|
|
1064
|
+
!(m || d) && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1065
|
+
/* @__PURE__ */ t.jsx(Ae, { children: x("renderer.defaultHttpInput.noResults") }),
|
|
1066
|
+
/* @__PURE__ */ t.jsx(De, { children: h.map((U) => /* @__PURE__ */ t.jsxs(
|
|
1067
|
+
Ee,
|
|
1068
|
+
{
|
|
1069
|
+
value: U.value,
|
|
1070
|
+
onSelect: () => {
|
|
1071
|
+
n(U.value), _(!1);
|
|
1072
|
+
},
|
|
1073
|
+
children: [
|
|
1074
|
+
/* @__PURE__ */ t.jsx(st, { className: j("mr-2 h-4 w-4", r === U.value ? "opacity-100" : "opacity-0") }),
|
|
1075
|
+
U.label
|
|
1076
|
+
]
|
|
1077
|
+
},
|
|
1078
|
+
U.value
|
|
1079
|
+
)) })
|
|
1080
|
+
] })
|
|
1081
|
+
] })
|
|
1082
|
+
] }) })
|
|
1083
|
+
] }),
|
|
1084
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1085
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1086
|
+
] });
|
|
1087
|
+
}
|
|
1088
|
+
const z = m && b?.showLoading, N = te.filter((S) => {
|
|
1089
|
+
const M = k[S];
|
|
1090
|
+
return M == null || M === "";
|
|
1091
|
+
}), V = N.map((S) => Pt(S, v) || S), A = h.length === 0 && !z ? N.length > 0 ? `${x("renderer.defaultHttpInput.waitingForRequiredFields")}: ${V.join(", ")}` : x("renderer.defaultHttpInput.noDataAvailable") : void 0, D = /* @__PURE__ */ t.jsxs(
|
|
1092
|
+
We,
|
|
1093
|
+
{
|
|
1094
|
+
value: Array.isArray(r) ? r[0] ?? "" : r ?? "",
|
|
1095
|
+
onValueChange: (S) => n(S),
|
|
1096
|
+
disabled: z || h.length === 0,
|
|
1097
|
+
name: c,
|
|
1098
|
+
children: [
|
|
1099
|
+
/* @__PURE__ */ t.jsxs(Ke, { id: l, name: c, className: "w-full", children: [
|
|
1100
|
+
z && /* @__PURE__ */ t.jsx(ye, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
1101
|
+
/* @__PURE__ */ t.jsx(Je, { placeholder: i || x("renderer.defaultHttpInput.selectOption") })
|
|
1102
|
+
] }),
|
|
1103
|
+
/* @__PURE__ */ t.jsx(Qe, { children: /* @__PURE__ */ t.jsx(Xe, { children: h.map((S, M) => /* @__PURE__ */ t.jsx(Ye, { value: S.value, children: S.label }, S.value + M)) }) })
|
|
1104
|
+
]
|
|
1105
|
+
}
|
|
1106
|
+
);
|
|
1107
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1108
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: l, children: [
|
|
1109
|
+
o || e.data.name,
|
|
1110
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1111
|
+
] }),
|
|
1112
|
+
A ? /* @__PURE__ */ t.jsx(_e, { children: /* @__PURE__ */ t.jsxs(mt, { children: [
|
|
1113
|
+
/* @__PURE__ */ t.jsx(ft, { asChild: !0, children: /* @__PURE__ */ t.jsx("div", { className: "w-full", children: D }) }),
|
|
1114
|
+
/* @__PURE__ */ t.jsx(pt, { children: /* @__PURE__ */ t.jsx("p", { children: A }) })
|
|
1115
|
+
] }) }) : D,
|
|
1116
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1117
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1118
|
+
] });
|
|
1119
|
+
}
|
|
1120
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1121
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: l, children: [
|
|
1122
|
+
o || e.data.name,
|
|
1123
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1124
|
+
] }),
|
|
1125
|
+
/* @__PURE__ */ t.jsx(X, { type: "text", name: c, id: l, value: typeof r == "string" ? r : JSON.stringify(r), readOnly: !0, disabled: !0 }),
|
|
1126
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1127
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1128
|
+
] });
|
|
1129
|
+
}, is = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1130
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: c, children: [
|
|
1131
|
+
o || e.data.name,
|
|
1132
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1133
|
+
] }),
|
|
1134
|
+
/* @__PURE__ */ t.jsx(
|
|
1135
|
+
X,
|
|
1136
|
+
{
|
|
1137
|
+
id: c,
|
|
1138
|
+
type: "number",
|
|
1139
|
+
name: l,
|
|
1140
|
+
value: r ?? "",
|
|
1141
|
+
onChange: (m) => n(m.target.value === "" ? null : Number(m.target.value)),
|
|
1142
|
+
placeholder: i
|
|
1143
|
+
}
|
|
1144
|
+
),
|
|
1145
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1146
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1147
|
+
] }), ls = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1148
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: c, children: [
|
|
1149
|
+
o || e.data.name,
|
|
1150
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1151
|
+
] }),
|
|
1152
|
+
/* @__PURE__ */ t.jsx(
|
|
1153
|
+
X,
|
|
1154
|
+
{
|
|
1155
|
+
id: c,
|
|
1156
|
+
name: l,
|
|
1157
|
+
type: "password",
|
|
1158
|
+
value: r ?? "",
|
|
1159
|
+
onChange: (m) => n(m.target.value),
|
|
1160
|
+
placeholder: i,
|
|
1161
|
+
autoComplete: "new-password"
|
|
1162
|
+
}
|
|
1163
|
+
),
|
|
1164
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1165
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1166
|
+
] });
|
|
1167
|
+
function cs({ className: e, ...r }) {
|
|
1168
|
+
return /* @__PURE__ */ t.jsx(Ie.Root, { "data-slot": "radio-group", className: j("grid gap-3", e), ...r });
|
|
1169
|
+
}
|
|
1170
|
+
function ds({ className: e, ...r }) {
|
|
1171
|
+
return /* @__PURE__ */ t.jsx(
|
|
1172
|
+
Ie.Item,
|
|
1173
|
+
{
|
|
1174
|
+
"data-slot": "radio-group-item",
|
|
1175
|
+
className: j(
|
|
1176
|
+
"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",
|
|
1177
|
+
e
|
|
1178
|
+
),
|
|
1179
|
+
...r,
|
|
1180
|
+
children: /* @__PURE__ */ t.jsx(Ie.Indicator, { "data-slot": "radio-group-indicator", className: "relative flex items-center justify-center", children: /* @__PURE__ */ t.jsx(kt, { className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" }) })
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
const us = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a, name: l }) => {
|
|
1185
|
+
const c = q(), m = r ? String(r) : "";
|
|
1186
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1187
|
+
/* @__PURE__ */ t.jsxs(T, { className: "mb-1", htmlFor: a, children: [
|
|
1188
|
+
o || e.data.name,
|
|
1189
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1190
|
+
] }),
|
|
1191
|
+
/* @__PURE__ */ t.jsx(cs, { value: m, onValueChange: (u) => n(u), id: a, name: l, children: e.data.options?.map((u, d) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
1192
|
+
/* @__PURE__ */ t.jsx(ds, { value: String(u.value), id: `${a}-${u.value}`, disabled: u.disabled }),
|
|
1193
|
+
/* @__PURE__ */ t.jsx(T, { htmlFor: `${a}-${u.value}`, className: "cursor-pointer font-normal text-sm", children: c(u.label) ? c(u.label) : u.value })
|
|
1194
|
+
] }, u.value + d)) }),
|
|
1195
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1196
|
+
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
1197
|
+
] });
|
|
1198
|
+
}, ms = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => {
|
|
1199
|
+
const m = q(), u = r ? String(r) : "";
|
|
1200
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1201
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: c, children: [
|
|
1202
|
+
o || e.data.name,
|
|
1203
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1204
|
+
] }),
|
|
1205
|
+
/* @__PURE__ */ t.jsxs(We, { name: l, value: u, onValueChange: (d) => n(d), children: [
|
|
1206
|
+
/* @__PURE__ */ t.jsx(Ke, { id: c, name: l, className: "w-full", children: /* @__PURE__ */ t.jsx(Je, { placeholder: i || m("renderer.defaultSelectInput.selectOption") }) }),
|
|
1207
|
+
/* @__PURE__ */ t.jsx(Qe, { children: /* @__PURE__ */ t.jsx(Xe, { children: e.data.options?.map((d, f) => /* @__PURE__ */ t.jsx(Ye, { value: String(d.value), disabled: d.disabled, children: m(d.label) ? m(d.label) : d.value }, `${d.value}-${f}`)) }) })
|
|
1208
|
+
] }),
|
|
1209
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1210
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1211
|
+
] });
|
|
1212
|
+
}, ht = It(
|
|
1213
|
+
({ label: e, id: r, disabled: n, onBlur: s, onClick: o, onFocus: i, onPointerDown: a, onPointerLeave: l, onPointerMove: c, ...m }, u) => {
|
|
1214
|
+
const d = q();
|
|
1215
|
+
return /* @__PURE__ */ t.jsx(
|
|
1216
|
+
"button",
|
|
1217
|
+
{
|
|
1218
|
+
ref: u,
|
|
1219
|
+
id: r,
|
|
1220
|
+
onBlur: s,
|
|
1221
|
+
onClick: o,
|
|
1222
|
+
onFocus: i,
|
|
1223
|
+
onPointerDown: a,
|
|
1224
|
+
disabled: n,
|
|
1225
|
+
onPointerLeave: l,
|
|
1226
|
+
onPointerMove: c,
|
|
1227
|
+
type: "submit",
|
|
1228
|
+
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",
|
|
1229
|
+
...m,
|
|
1230
|
+
children: e || d("renderer.defaultSubmitButton.submit")
|
|
1231
|
+
}
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
), gt = ({ children: e, missingFields: r = [] }) => {
|
|
1235
|
+
const n = r.length > 0, s = q();
|
|
1236
|
+
return n ? /* @__PURE__ */ t.jsx(_e, { children: /* @__PURE__ */ t.jsxs(mt, { children: [
|
|
1237
|
+
/* @__PURE__ */ t.jsx(ft, { asChild: !0, children: e }),
|
|
1238
|
+
/* @__PURE__ */ t.jsx(pt, { children: /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
|
|
1239
|
+
/* @__PURE__ */ t.jsxs("p", { className: "font-semibold", children: [
|
|
1240
|
+
s("renderer.defaultSubmitButton.requiredFieldsMissing"),
|
|
1241
|
+
":"
|
|
1242
|
+
] }),
|
|
1243
|
+
/* @__PURE__ */ t.jsx("ul", { className: "list-inside list-disc", children: r.map((o, i) => /* @__PURE__ */ t.jsx("li", { children: o }, i)) })
|
|
1244
|
+
] }) })
|
|
1245
|
+
] }) }) : e;
|
|
1246
|
+
}, fs = ({ missingRequiredFields: e, isSubmitting: r, label: n }) => {
|
|
1247
|
+
const s = at(), o = s?.components?.submitButton, i = s?.components?.submitButtonWrapper, a = o || ht, l = i || gt;
|
|
1248
|
+
return /* @__PURE__ */ t.jsx(l, { missingFields: e, children: /* @__PURE__ */ t.jsx(a, { label: n, disabled: r }) });
|
|
1249
|
+
}, ps = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, name: a, id: l }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1250
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: l, children: [
|
|
1251
|
+
o || e.data.name,
|
|
1252
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1253
|
+
] }),
|
|
1254
|
+
/* @__PURE__ */ t.jsx(vt, { id: l, name: a, checked: r, onCheckedChange: n }),
|
|
1255
|
+
i && !s && /* @__PURE__ */ t.jsx(P, { children: i }),
|
|
1256
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s })
|
|
1257
|
+
] }), hs = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1258
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: c, children: [
|
|
1259
|
+
o || e.data.name,
|
|
1260
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1261
|
+
] }),
|
|
1262
|
+
/* @__PURE__ */ t.jsx(
|
|
1263
|
+
wt,
|
|
1264
|
+
{
|
|
1265
|
+
id: c,
|
|
1266
|
+
name: l,
|
|
1267
|
+
value: r ?? "",
|
|
1268
|
+
onChange: (m) => n(m.target.value),
|
|
1269
|
+
placeholder: i,
|
|
1270
|
+
className: "w-full rounded-md border px-3 py-2",
|
|
1271
|
+
rows: 4
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1275
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1276
|
+
] }), gs = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1277
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: c, children: [
|
|
1278
|
+
o || e.data.name,
|
|
1279
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1280
|
+
] }),
|
|
1281
|
+
/* @__PURE__ */ t.jsx(X, { type: "text", id: c, name: l, value: r ?? "", onChange: (m) => n(m.target.value), placeholder: i }),
|
|
1282
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1283
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1284
|
+
] }), xs = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1285
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: c, children: [
|
|
1286
|
+
o || e.data.name,
|
|
1287
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1288
|
+
] }),
|
|
1289
|
+
/* @__PURE__ */ t.jsx(
|
|
1290
|
+
X,
|
|
1291
|
+
{
|
|
1292
|
+
type: "time",
|
|
1293
|
+
id: c,
|
|
1294
|
+
name: l,
|
|
1295
|
+
value: r ?? "",
|
|
1296
|
+
onChange: (m) => n(m.target.value),
|
|
1297
|
+
placeholder: i,
|
|
1298
|
+
className: "bg-background [color-scheme:light] dark:[color-scheme:dark]"
|
|
1299
|
+
}
|
|
1300
|
+
),
|
|
1301
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1302
|
+
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1303
|
+
] }), bs = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a, name: l }) => {
|
|
1304
|
+
const c = q(), m = Array.isArray(r) ? r : [], u = m[0] || "", d = m[1] || "", f = (g) => {
|
|
1305
|
+
n([g, d]);
|
|
1306
|
+
}, h = (g) => {
|
|
1307
|
+
n([u, g]);
|
|
1308
|
+
};
|
|
1309
|
+
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1310
|
+
/* @__PURE__ */ t.jsxs(T, { htmlFor: `${a}-start`, children: [
|
|
1311
|
+
o || e.data.name,
|
|
1312
|
+
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1313
|
+
] }),
|
|
1314
|
+
/* @__PURE__ */ t.jsxs("div", { className: "flex gap-2", children: [
|
|
1315
|
+
/* @__PURE__ */ t.jsx(
|
|
1316
|
+
X,
|
|
1317
|
+
{
|
|
1318
|
+
id: `${a}-start`,
|
|
1319
|
+
name: `${l}-start`,
|
|
1320
|
+
"aria-label": `${o || e.data.name} - ${c("renderer.defaultInputs.startTime")}`,
|
|
1321
|
+
"aria-invalid": !!s,
|
|
1322
|
+
"aria-describedby": s ? `${e.id}-error` : void 0,
|
|
1323
|
+
type: "time",
|
|
1324
|
+
value: u,
|
|
1325
|
+
onChange: (g) => f(g.target.value),
|
|
1326
|
+
placeholder: c("renderer.defaultInputs.startTime"),
|
|
1327
|
+
className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
|
|
1328
|
+
}
|
|
1329
|
+
),
|
|
1330
|
+
/* @__PURE__ */ t.jsx(
|
|
1331
|
+
X,
|
|
1332
|
+
{
|
|
1333
|
+
id: `${a}-end`,
|
|
1334
|
+
name: `${l}-end`,
|
|
1335
|
+
"aria-label": `${o || e.data.name} - ${c("renderer.defaultInputs.endTime")}`,
|
|
1336
|
+
"aria-invalid": !!s,
|
|
1337
|
+
"aria-describedby": s ? `${e.id}-error` : void 0,
|
|
1338
|
+
type: "time",
|
|
1339
|
+
value: d,
|
|
1340
|
+
onChange: (g) => h(g.target.value),
|
|
1341
|
+
placeholder: c("renderer.defaultInputs.endTime"),
|
|
1342
|
+
className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
|
|
1343
|
+
}
|
|
1344
|
+
)
|
|
1345
|
+
] }),
|
|
1346
|
+
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1347
|
+
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
1348
|
+
] });
|
|
1349
|
+
}, js = {
|
|
1350
|
+
address: Xt,
|
|
1351
|
+
autocomplete: Yt,
|
|
1352
|
+
checkbox: Zt,
|
|
1353
|
+
date: ts,
|
|
1354
|
+
daterange: ss,
|
|
1355
|
+
file: ns,
|
|
1356
|
+
hidden: as,
|
|
1357
|
+
http: os,
|
|
1358
|
+
number: is,
|
|
1359
|
+
password: ls,
|
|
1360
|
+
radio: us,
|
|
1361
|
+
select: ms,
|
|
1362
|
+
submit: fs,
|
|
1363
|
+
switch: ps,
|
|
1364
|
+
text: gs,
|
|
1365
|
+
textarea: hs,
|
|
1366
|
+
time: xs,
|
|
1367
|
+
timerange: bs
|
|
1368
|
+
}, ys = ({ node: e }) => {
|
|
1369
|
+
const n = q()(e.data?.label);
|
|
1370
|
+
return n ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
1371
|
+
/* @__PURE__ */ t.jsx(je, { className: "my-8 flex-1" }),
|
|
1372
|
+
/* @__PURE__ */ t.jsx("h4", { className: "font-semibold text-sm", children: n }),
|
|
1373
|
+
/* @__PURE__ */ t.jsx(je, { className: "my-8 flex-1" })
|
|
1374
|
+
] }) : /* @__PURE__ */ t.jsx(je, { className: "my-8" });
|
|
1375
|
+
}, Ns = ({ node: e }) => {
|
|
1376
|
+
const { edges: r } = he(), n = q(), s = ot(e.id, r);
|
|
1377
|
+
return /* @__PURE__ */ t.jsx("h2", { className: j("mb-5 font-bold text-2xl", !s && "mt-10"), children: n(e.data?.label) });
|
|
1378
|
+
}, vs = {
|
|
1379
|
+
divider: ys,
|
|
1380
|
+
title: Ns
|
|
1381
|
+
}, ws = async (e) => {
|
|
1382
|
+
try {
|
|
1383
|
+
const { url: r, method: n = "GET", headers: s = [], body: o } = e;
|
|
1384
|
+
if (!r || r.trim() === "")
|
|
1385
|
+
return {
|
|
1386
|
+
error: "No URL provided",
|
|
1387
|
+
success: !1
|
|
1388
|
+
};
|
|
1389
|
+
const i = {
|
|
1390
|
+
"Content-Type": "application/json"
|
|
1391
|
+
};
|
|
1392
|
+
s.forEach((u) => {
|
|
1393
|
+
u.key && u.value && (i[u.key] = u.value);
|
|
1394
|
+
});
|
|
1395
|
+
const a = {
|
|
1396
|
+
headers: i,
|
|
1397
|
+
method: n
|
|
1398
|
+
};
|
|
1399
|
+
o && n && ["POST", "PUT", "PATCH"].includes(n) && (a.body = o);
|
|
1400
|
+
const l = await fetch(r, a);
|
|
1401
|
+
let c;
|
|
1402
|
+
return l.headers.get("content-type")?.includes("application/json") ? c = await l.json() : c = await l.text(), l.ok ? {
|
|
1403
|
+
data: c,
|
|
1404
|
+
status: l.status,
|
|
1405
|
+
statusText: l.statusText,
|
|
1406
|
+
success: !0
|
|
1407
|
+
} : {
|
|
1408
|
+
data: c,
|
|
1409
|
+
error: `HTTP ${l.status}: ${l.statusText}`,
|
|
1410
|
+
status: l.status,
|
|
1411
|
+
statusText: l.statusText,
|
|
1412
|
+
success: !1
|
|
1413
|
+
};
|
|
1414
|
+
} catch (r) {
|
|
1415
|
+
return {
|
|
1416
|
+
error: r instanceof Error ? r.message : "An unknown error occurred",
|
|
1417
|
+
success: !1
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
}, Ce = (e, r, n = {}) => {
|
|
1421
|
+
if (!e)
|
|
1422
|
+
return "";
|
|
1423
|
+
const { encode: s = !1, json: o = !1 } = n;
|
|
1424
|
+
return e.replace(/\{\{([\w-]+)}}/g, (i, a) => {
|
|
1425
|
+
const l = r[a.trim()];
|
|
1426
|
+
if (l == null)
|
|
1427
|
+
return o ? "null" : "";
|
|
1428
|
+
if (s)
|
|
1429
|
+
return encodeURIComponent(String(l));
|
|
1430
|
+
if (o) {
|
|
1431
|
+
if (typeof l == "string")
|
|
1432
|
+
return `"${l.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1433
|
+
if (typeof l == "number" || typeof l == "boolean")
|
|
1434
|
+
return String(l);
|
|
1435
|
+
if (typeof l == "object")
|
|
1436
|
+
return JSON.stringify(l);
|
|
1437
|
+
}
|
|
1438
|
+
return String(l);
|
|
1439
|
+
});
|
|
1440
|
+
}, Ss = (e, r) => e ? e.replace(/\{\{response\.([\w.-]+)}}/g, (n, s) => {
|
|
1441
|
+
const o = Fs(r, s.trim());
|
|
1442
|
+
return o != null ? String(o) : "";
|
|
1443
|
+
}) : "", Fs = (e, r) => {
|
|
1444
|
+
if (!(!e || typeof e != "object"))
|
|
1445
|
+
return r.split(".").reduce((n, s) => {
|
|
1446
|
+
if (!(n == null || typeof n != "object"))
|
|
1447
|
+
return n[s];
|
|
1448
|
+
}, e);
|
|
1449
|
+
}, Cs = async (e, r, n) => {
|
|
1450
|
+
if (!e.url || e.url.trim() === "")
|
|
1451
|
+
return {
|
|
1452
|
+
error: "No URL configured for submission",
|
|
1453
|
+
success: !1
|
|
1454
|
+
};
|
|
1455
|
+
const s = Ce(e.url, r, { encode: !0 });
|
|
1456
|
+
if (!s || s.trim() === "")
|
|
1457
|
+
return {
|
|
1458
|
+
error: "Invalid URL after template replacement",
|
|
1459
|
+
success: !1
|
|
1460
|
+
};
|
|
1461
|
+
const o = e.headers?.map((c) => ({
|
|
1462
|
+
key: c.key,
|
|
1463
|
+
value: Ce(c.value, r)
|
|
1464
|
+
})), i = e.sendFormData ? JSON.stringify($e(r, n)) : e.body ? Ce(e.body, r, { json: !0 }) : void 0, a = await ws({
|
|
1465
|
+
body: i,
|
|
1466
|
+
headers: o,
|
|
1467
|
+
method: e.method || "POST",
|
|
1468
|
+
url: s
|
|
1469
|
+
});
|
|
1470
|
+
if (!a.success)
|
|
1471
|
+
return {
|
|
1472
|
+
data: a.data,
|
|
1473
|
+
error: a.error,
|
|
1474
|
+
success: !1
|
|
1475
|
+
};
|
|
1476
|
+
const l = e.redirectUrl ? (() => {
|
|
1477
|
+
const c = Ss(e.redirectUrl, a.data);
|
|
1478
|
+
return c && c.trim() !== "" ? c : void 0;
|
|
1479
|
+
})() : void 0;
|
|
1480
|
+
return {
|
|
1481
|
+
data: a.data,
|
|
1482
|
+
redirectUrl: l,
|
|
1483
|
+
success: !0
|
|
1484
|
+
};
|
|
1485
|
+
}, Is = (e) => {
|
|
1486
|
+
if (!e)
|
|
1487
|
+
return;
|
|
1488
|
+
e.startsWith("http://") || e.startsWith("https://") ? window.location.href = e : window.history?.pushState ? (window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"))) : window.location.href = e;
|
|
1489
|
+
}, Ts = (e, r, n, s) => {
|
|
1490
|
+
const [o, i] = B(!1), [a, l] = B(null), c = G(() => {
|
|
1491
|
+
const d = e.find((f) => W(f) && f.data?.type === "submit");
|
|
1492
|
+
return d && W(d) ? d : null;
|
|
1493
|
+
}, [e]), m = Q(
|
|
1494
|
+
async (d) => {
|
|
1495
|
+
if (!c?.data?.submitConfig)
|
|
1496
|
+
return null;
|
|
1497
|
+
const f = c.data.submitConfig;
|
|
1498
|
+
if (!f.url || f.url.trim() === "")
|
|
1499
|
+
return null;
|
|
1500
|
+
l(null), f.showLoading !== !1 && i(!0);
|
|
1501
|
+
try {
|
|
1502
|
+
const h = await Cs(f, r, s);
|
|
1503
|
+
if (h.success) {
|
|
1504
|
+
const g = ne(f.successMessage, n);
|
|
1505
|
+
if (g && l({ message: g, type: "success" }), d && d(h.data), h.redirectUrl) {
|
|
1506
|
+
const p = h.redirectUrl;
|
|
1507
|
+
setTimeout(() => Is(p), 1e3);
|
|
1508
|
+
}
|
|
1509
|
+
} else {
|
|
1510
|
+
const g = ne(f.errorMessage, n) || h.error || "An error occurred during submission";
|
|
1511
|
+
l({ message: g, type: "error" });
|
|
1512
|
+
}
|
|
1513
|
+
return h;
|
|
1514
|
+
} catch (h) {
|
|
1515
|
+
const g = ne(f.errorMessage, n) || (h instanceof Error ? h.message : "An unexpected error occurred");
|
|
1516
|
+
return l({ message: g, type: "error" }), {
|
|
1517
|
+
error: g,
|
|
1518
|
+
success: !1
|
|
1519
|
+
};
|
|
1520
|
+
} finally {
|
|
1521
|
+
i(!1);
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
[c, r, n, s]
|
|
1525
|
+
);
|
|
1526
|
+
return {
|
|
1527
|
+
clearSubmitMessage: Q(() => {
|
|
1528
|
+
l(null);
|
|
1529
|
+
}, []),
|
|
1530
|
+
handleSubmitWithConfig: m,
|
|
1531
|
+
hasSubmitConfig: !!c?.data?.submitConfig,
|
|
1532
|
+
isSubmitting: o,
|
|
1533
|
+
submitButtonNode: c,
|
|
1534
|
+
submitMessage: a
|
|
1535
|
+
};
|
|
1536
|
+
}, Hs = ({
|
|
1537
|
+
components: e,
|
|
1538
|
+
flows: r,
|
|
1539
|
+
googleApiKey: n,
|
|
1540
|
+
initialValues: s = {},
|
|
1541
|
+
language: o,
|
|
1542
|
+
onChange: i,
|
|
1543
|
+
onSubmit: a,
|
|
1544
|
+
theme: l,
|
|
1545
|
+
validate: c,
|
|
1546
|
+
validationMode: m
|
|
1547
|
+
}) => {
|
|
1548
|
+
const u = at(), d = {
|
|
1549
|
+
components: {
|
|
1550
|
+
form: e?.form ?? u?.components?.form,
|
|
1551
|
+
group: e?.group ?? u?.components?.group,
|
|
1552
|
+
inputs: { ...u?.components?.inputs, ...e?.inputs },
|
|
1553
|
+
submitButton: e?.submitButton ?? u?.components?.submitButton,
|
|
1554
|
+
submitButtonWrapper: e?.submitButtonWrapper ?? u?.components?.submitButtonWrapper,
|
|
1555
|
+
ui: { ...u?.components?.ui, ...e?.ui }
|
|
1556
|
+
},
|
|
1557
|
+
googleApiKey: n ?? u?.googleApiKey,
|
|
1558
|
+
language: o ?? u?.language ?? "en",
|
|
1559
|
+
theme: l ?? u?.theme ?? "dark",
|
|
1560
|
+
validationMode: m ?? u?.validationMode ?? "onSubmit"
|
|
1561
|
+
}, {
|
|
1562
|
+
canSubmit: f,
|
|
1563
|
+
mergedFlow: h,
|
|
1564
|
+
formErrors: g,
|
|
1565
|
+
formValues: p,
|
|
1566
|
+
inputNodes: y,
|
|
1567
|
+
missingRequiredFields: R,
|
|
1568
|
+
prevFormValuesRef: _,
|
|
1569
|
+
visibleNodes: k,
|
|
1570
|
+
visibleRootNodes: v,
|
|
1571
|
+
setFieldValue: x,
|
|
1572
|
+
setMultipleFieldValues: b,
|
|
1573
|
+
validateForm: w,
|
|
1574
|
+
t: F
|
|
1575
|
+
} = Gt(r, s, d.language), { handleSubmitWithConfig: $, hasSubmitConfig: L, isSubmitting: ee, submitMessage: Y, clearSubmitMessage: ce } = Ts(
|
|
1576
|
+
k,
|
|
1577
|
+
p,
|
|
1578
|
+
d.language,
|
|
1579
|
+
y
|
|
1580
|
+
), te = d.components.form || Wt, se = d.components.submitButton || ht, oe = d.components.submitButtonWrapper || gt, ie = K(i), H = K(c), C = G(() => $e(p, y), [p, y]), I = Q(
|
|
1581
|
+
async (N) => {
|
|
1582
|
+
N.preventDefault();
|
|
1583
|
+
const { isValid: V, errors: A } = w(H.current);
|
|
1584
|
+
if (!V) {
|
|
1585
|
+
const D = Object.keys(A)[0];
|
|
1586
|
+
D && document.getElementById(D)?.focus();
|
|
1587
|
+
return;
|
|
1588
|
+
}
|
|
1589
|
+
if (L) {
|
|
1590
|
+
const D = await $((S) => {
|
|
1591
|
+
a && a(C, { httpResponse: S });
|
|
1592
|
+
});
|
|
1593
|
+
if (D === null) {
|
|
1594
|
+
a?.(C);
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
if (!D.success)
|
|
1598
|
+
return;
|
|
1599
|
+
} else a && a(C);
|
|
1600
|
+
},
|
|
1601
|
+
[w, L, $, a, C]
|
|
1602
|
+
), z = Q(
|
|
1603
|
+
(N) => {
|
|
1604
|
+
const { type: V } = N;
|
|
1605
|
+
switch (V) {
|
|
1606
|
+
case ue.input: {
|
|
1607
|
+
if (!W(N))
|
|
1608
|
+
return null;
|
|
1609
|
+
const A = N.data, D = A.type || "text", S = d.components.inputs?.[D], M = js[D], U = S || M, Z = N.id, re = p[Z], ge = g[Z], xe = (yt) => x(Z, yt), de = ne(A.label, d.language), xt = ne(A.placeholder, d.language), bt = ne(A.helperText, d.language), jt = Pe(N);
|
|
1610
|
+
return /* @__PURE__ */ t.jsx(
|
|
1611
|
+
U,
|
|
1612
|
+
{
|
|
1613
|
+
id: N.id,
|
|
1614
|
+
node: N,
|
|
1615
|
+
value: re,
|
|
1616
|
+
error: ge,
|
|
1617
|
+
label: de,
|
|
1618
|
+
placeholder: xt,
|
|
1619
|
+
helperText: bt,
|
|
1620
|
+
name: jt,
|
|
1621
|
+
setValue: xe,
|
|
1622
|
+
missingRequiredFields: R
|
|
1623
|
+
},
|
|
1624
|
+
N.id
|
|
1625
|
+
);
|
|
1626
|
+
}
|
|
1627
|
+
case ue.group: {
|
|
1628
|
+
if (!Ft(N))
|
|
1629
|
+
return null;
|
|
1630
|
+
const A = d.components.group || Kt, D = k.filter((S) => S.parentId === N.id);
|
|
1631
|
+
return /* @__PURE__ */ t.jsx(A, { node: N, children: D.map((S) => z(S)) }, N.id);
|
|
1632
|
+
}
|
|
1633
|
+
case ue.ui: {
|
|
1634
|
+
if (!St(N))
|
|
1635
|
+
return null;
|
|
1636
|
+
const D = N.data.type || "title", S = d.components.ui?.[D], M = vs[D], U = S || M;
|
|
1637
|
+
return /* @__PURE__ */ t.jsx(U, { node: N }, N.id);
|
|
1638
|
+
}
|
|
1639
|
+
case ue.flow:
|
|
1640
|
+
return null;
|
|
1641
|
+
default:
|
|
1642
|
+
return console.warn("Unknown node type:", V), null;
|
|
1643
|
+
}
|
|
1644
|
+
},
|
|
1645
|
+
[d.components, d.language, k, p, g, x, R]
|
|
1646
|
+
);
|
|
1647
|
+
return J(() => {
|
|
1648
|
+
ie.current = i;
|
|
1649
|
+
}, [i]), J(() => {
|
|
1650
|
+
H.current = c;
|
|
1651
|
+
}, [c]), J(() => {
|
|
1652
|
+
ie.current?.(C);
|
|
1653
|
+
}, [C]), J(() => {
|
|
1654
|
+
d.validationMode === "onChange" && w(H.current);
|
|
1655
|
+
}, [d.validationMode, w]), J(() => {
|
|
1656
|
+
const N = _t(y, p, _.current);
|
|
1657
|
+
Object.keys(N).length > 0 && b(N), _.current = p;
|
|
1658
|
+
}, [p, y, b, _]), /* @__PURE__ */ t.jsx(Ct, { theme: d.theme, storageKey: "treege-renderer-theme", children: /* @__PURE__ */ t.jsxs(
|
|
1659
|
+
Ht,
|
|
1660
|
+
{
|
|
1661
|
+
value: {
|
|
1662
|
+
flows: h,
|
|
1663
|
+
formErrors: g,
|
|
1664
|
+
formValues: p,
|
|
1665
|
+
googleApiKey: d.googleApiKey,
|
|
1666
|
+
inputNodes: y,
|
|
1667
|
+
language: d.language,
|
|
1668
|
+
setFieldValue: x
|
|
1669
|
+
},
|
|
1670
|
+
children: [
|
|
1671
|
+
/* @__PURE__ */ t.jsxs(te, { onSubmit: I, children: [
|
|
1672
|
+
v.map((N) => z(N)),
|
|
1673
|
+
f && /* @__PURE__ */ t.jsx(oe, { missingFields: R, children: /* @__PURE__ */ t.jsx(se, { label: F("renderer.defaultSubmitButton.submit"), disabled: ee }) })
|
|
1674
|
+
] }),
|
|
1675
|
+
/* @__PURE__ */ t.jsx("p", { className: "py-2 text-muted-foreground text-xs", children: "Powered by Treege" }),
|
|
1676
|
+
Y && /* @__PURE__ */ t.jsx(
|
|
1677
|
+
"div",
|
|
1678
|
+
{
|
|
1679
|
+
className: `my-4 rounded-md p-4 ${Y.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"}`,
|
|
1680
|
+
role: "alert",
|
|
1681
|
+
children: /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1682
|
+
/* @__PURE__ */ t.jsx("p", { className: "font-medium text-sm", children: Y.message }),
|
|
1683
|
+
/* @__PURE__ */ t.jsx(
|
|
1684
|
+
"button",
|
|
1685
|
+
{
|
|
1686
|
+
type: "button",
|
|
1687
|
+
onClick: ce,
|
|
1688
|
+
className: "ml-4 font-medium text-sm underline hover:no-underline focus:outline-none",
|
|
1689
|
+
children: F("common.close")
|
|
1690
|
+
}
|
|
1691
|
+
)
|
|
1692
|
+
] })
|
|
1693
|
+
}
|
|
1694
|
+
)
|
|
1695
|
+
]
|
|
1696
|
+
}
|
|
1697
|
+
) });
|
|
1698
|
+
};
|
|
1699
|
+
export {
|
|
1700
|
+
ut as A,
|
|
1701
|
+
Us as B,
|
|
1702
|
+
rs as C,
|
|
1703
|
+
Kt as D,
|
|
1704
|
+
ot as E,
|
|
1705
|
+
zt as F,
|
|
1706
|
+
qt as G,
|
|
1707
|
+
lt as H,
|
|
1708
|
+
ve as I,
|
|
1709
|
+
$t as J,
|
|
1710
|
+
$e as K,
|
|
1711
|
+
Le as L,
|
|
1712
|
+
_t as M,
|
|
1713
|
+
Ls as T,
|
|
1714
|
+
Gt as a,
|
|
1715
|
+
Hs as b,
|
|
1716
|
+
Xt as c,
|
|
1717
|
+
Yt as d,
|
|
1718
|
+
Zt as e,
|
|
1719
|
+
ts as f,
|
|
1720
|
+
ss as g,
|
|
1721
|
+
ns as h,
|
|
1722
|
+
as as i,
|
|
1723
|
+
os as j,
|
|
1724
|
+
is as k,
|
|
1725
|
+
ls as l,
|
|
1726
|
+
us as m,
|
|
1727
|
+
ms as n,
|
|
1728
|
+
ps as o,
|
|
1729
|
+
hs as p,
|
|
1730
|
+
gs as q,
|
|
1731
|
+
xs as r,
|
|
1732
|
+
bs as s,
|
|
1733
|
+
js as t,
|
|
1734
|
+
at as u,
|
|
1735
|
+
ys as v,
|
|
1736
|
+
Ns as w,
|
|
1737
|
+
vs as x,
|
|
1738
|
+
Ne as y,
|
|
1739
|
+
Et as z
|
|
1740
|
+
};
|