@levo-so/react 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/CheckboxWidget-BGS61gcL.js +124 -0
  2. package/dist/CollectionFormBuilder-BIvx_z08.js +1197 -0
  3. package/dist/{CurrencyWidget-COoMkfsA.js → CurrencyWidget-sD8ijLvw.js} +5 -5
  4. package/dist/{DateTimeWidget-DcbQ3smI.js → DateTimeWidget-KrcsxgEF.js} +3 -3
  5. package/dist/DefaultFormVariant-j1HgVDiI.js +127 -0
  6. package/dist/DropdownWidget-rm5oUqOE.js +113 -0
  7. package/dist/{EmailWidget-CG9oNUM5.js → EmailWidget-CvZKOywL.js} +11 -11
  8. package/dist/GeocoderWidget-CSsp_-hW.js +68 -0
  9. package/dist/{LevoProvider-BI6g_T4E.js → LevoProvider-Do3jjJ4j.js} +0 -1
  10. package/dist/{MultiGeocoderWidget-D3Xmv8g4.js → MultiGeocoderWidget-Blqz-lHX.js} +6 -6
  11. package/dist/{MultiTextWidget-CyQRcWC8.js → MultiTextWidget-CxVpyf06.js} +14 -14
  12. package/dist/{PhoneWidget-C1Jt7kXL.js → PhoneWidget-DezcchSP.js} +5 -5
  13. package/dist/{RadioWidget-BrLNF-I2.js → RadioWidget-SfD1fFDG.js} +9 -9
  14. package/dist/{RichTextWidget-BogYcPtS.js → RichTextWidget-Cg3RizdO.js} +21 -21
  15. package/dist/Spinner-Bzu2xCFZ.js +405 -0
  16. package/dist/{StepsFormVariant-Bx-jdciC.js → StepsFormVariant-D35dFYK6.js} +9 -9
  17. package/dist/{SwitchWidget-BT0-waP9.js → SwitchWidget-Id6BNlPe.js} +5 -5
  18. package/dist/{TextWidget-Bvsz-hey.js → TextWidget-CtFaQde1.js} +7 -7
  19. package/dist/{TextareaWidget-8SLym--T.js → TextareaWidget-BKzAeMod.js} +3 -3
  20. package/dist/{ToggleCheckboxWidget-VrCQBF5C.js → ToggleCheckboxWidget-nSlie9sE.js} +7 -7
  21. package/dist/Tooltip-DEBnSqlo.js +36 -0
  22. package/dist/{URLWidget-B99nKr6N.js → URLWidget-DtJai3xY.js} +2 -2
  23. package/dist/UploadWidget-Dxx2_FYo.js +616 -0
  24. package/dist/audience/components/page.d.ts.map +1 -1
  25. package/dist/audience/index.js +1 -1
  26. package/dist/collection/components/Altcha.d.ts +10 -0
  27. package/dist/collection/components/Altcha.d.ts.map +1 -0
  28. package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -1
  29. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +1 -1
  30. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -1
  31. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts +7 -0
  32. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -0
  33. package/dist/collection/components/widgets/collectionWidget/{CollectionWidget.d.ts → CollectionWidgetM2O.d.ts} +1 -1
  34. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts.map +1 -0
  35. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts +8 -0
  36. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +1 -0
  37. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -1
  38. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +1 -1
  39. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts +11 -0
  40. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -0
  41. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
  42. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
  43. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -1
  44. package/dist/collection/index.js +13 -12
  45. package/dist/collection/lib/hooks/useLevoForm.d.ts +2 -1
  46. package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -1
  47. package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -1
  48. package/dist/collection/utils/formHelpers.d.ts.map +1 -1
  49. package/dist/collection/utils/index.d.ts +2 -0
  50. package/dist/collection/utils/index.d.ts.map +1 -1
  51. package/dist/components/Table.d.ts +11 -0
  52. package/dist/components/Table.d.ts.map +1 -0
  53. package/dist/components/index.js +29 -29
  54. package/dist/constants/fileUploadPresets.d.ts +4 -2
  55. package/dist/constants/fileUploadPresets.d.ts.map +1 -1
  56. package/dist/index.css +1 -1
  57. package/dist/index.js +75 -75
  58. package/dist/membership/index.js +1 -1
  59. package/dist/page-DgqTELmZ.js +212 -0
  60. package/dist/useLevoForm-3jSJ9I6v.js +170 -0
  61. package/package.json +8 -7
  62. package/dist/CheckboxWidget-BctVOZiO.js +0 -118
  63. package/dist/CollectionFormBuilder-B6CAVKhg.js +0 -772
  64. package/dist/DefaultFormVariant-C6zbKgwB.js +0 -80
  65. package/dist/DropdownWidget-DszCTSWr.js +0 -115
  66. package/dist/GeocoderWidget-CXu17A7y.js +0 -310
  67. package/dist/Spinner-DzGH5rKe.js +0 -297
  68. package/dist/Tooltip-CI4i4mYr.js +0 -144
  69. package/dist/UploadWidget-ZebPWZZZ.js +0 -505
  70. package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts.map +0 -1
  71. package/dist/fileUploadPresets-2raQmHT0.js +0 -74
  72. package/dist/page-yeiAPg3O.js +0 -200
  73. package/dist/useLevoForm-DjvUas25.js +0 -166
@@ -0,0 +1,1197 @@
1
+ "use client";
2
+ import { j as s } from "./jsx-runtime-B6kdoens.js";
3
+ import { FieldInterfaces as l, defaultByKinds as ue, formatsByInterface as we, interfaceKinds as ke, FieldInterfacesList as We } from "@levo-so/core";
4
+ import * as A from "react";
5
+ import E, { useState as w, useEffect as ge, lazy as v, Suspense as _e } from "react";
6
+ import { useFieldArray as Ne, useController as me } from "react-hook-form";
7
+ import { G as H, T as Re, k as Le, l as Te, B as W, m as Me, A as Ae, C as Ie, j as De, n as Be, S as Se } from "./Spinner-Bzu2xCFZ.js";
8
+ import { u as X } from "./LevoProvider-Do3jjJ4j.js";
9
+ import { Snowflake as Fe } from "@theinternetfolks/snowflake";
10
+ import Pe from "google-libphonenumber";
11
+ import re from "validator";
12
+ import z from "validatorjs";
13
+ import { c as b } from "./cn-C9QoOYNG.js";
14
+ import { Mate as J } from "@theinternetfolks/mate";
15
+ import { X as Ee } from "lucide-react";
16
+ import * as He from "inflection";
17
+ import { useInView as Oe } from "react-intersection-observer";
18
+ const Ve = [
19
+ "pdf",
20
+ "xls",
21
+ "xlsx",
22
+ "doc",
23
+ "docx",
24
+ "csv"
25
+ ], ze = [
26
+ "svg",
27
+ "png",
28
+ "jpg",
29
+ "jpeg",
30
+ "webp",
31
+ "gif",
32
+ "avif"
33
+ ], $e = ["mpeg", "mp4"], Ue = ["mp3", "ogg", "oga"], qe = {
34
+ "application/pdf": [".pdf"],
35
+ "application/msword": [".doc"],
36
+ "application/vnd.ms-excel": [".xls"],
37
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [
38
+ ".xlsx"
39
+ ],
40
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [
41
+ ".docx"
42
+ ],
43
+ "text/csv": [".csv"]
44
+ }, Ge = {
45
+ "image/jpeg": [".jpeg", ".jpg"],
46
+ "image/png": [".png"],
47
+ "image/gif": [".gif"],
48
+ "image/svg+xml": [".svg"],
49
+ "image/webp": [".webp"],
50
+ "image/avif": [".avif"]
51
+ }, Ze = {
52
+ "video/mp4": [".mp4"],
53
+ "video/mpeg": [".mpeg"]
54
+ }, Ke = {
55
+ "audio/mpeg": [".mp3"],
56
+ "audio/ogg": [".oga"]
57
+ }, $ = {
58
+ audio: Ke,
59
+ document: qe,
60
+ image: Ge,
61
+ video: Ze
62
+ }, Z = {
63
+ audio: Ue,
64
+ document: Ve,
65
+ image: ze,
66
+ video: $e
67
+ }, Gt = [
68
+ ...Z.audio,
69
+ ...Z.document,
70
+ ...Z.image,
71
+ ...Z.video
72
+ ], Zt = {
73
+ ...$.audio,
74
+ ...$.document,
75
+ ...$.image,
76
+ ...$.video
77
+ }, { PhoneNumberUtil: Xe } = Pe, Je = (e) => {
78
+ const n = [];
79
+ for (const t of Object.keys(e))
80
+ for (const r of (e == null ? void 0 : e[t]) || [])
81
+ n.push({ message: r, name: t });
82
+ return n;
83
+ }, oe = Xe.getInstance(), Qe = (e) => {
84
+ try {
85
+ return oe.isValidNumber(oe.parseAndKeepRawInput(e));
86
+ } catch {
87
+ return !1;
88
+ }
89
+ }, pe = (e, n) => {
90
+ z.register(
91
+ "data_uri",
92
+ (r) => typeof r != "string" ? !1 : re.isDataURI(r),
93
+ "The :attribute is not a valid file."
94
+ ), z.register(
95
+ "phone_number",
96
+ (r) => Qe(r),
97
+ "The :attribute has incorrect format."
98
+ ), z.register(
99
+ "url",
100
+ (r) => re.isURL(r.toString(), {}),
101
+ "The :attribute is not a valid URL."
102
+ ), z.setAttributeFormatter((r) => {
103
+ if (r.endsWith("Id"))
104
+ return r.replace("Id", "");
105
+ if (r.includes(".")) {
106
+ const [c] = r.split(".");
107
+ return c;
108
+ }
109
+ return r.replace(/_/g, " ");
110
+ });
111
+ const t = new z(e, n);
112
+ return t.passes() ? { status: !0 } : {
113
+ status: !1,
114
+ errors: Je(t.errors.all())
115
+ };
116
+ }, Kt = (e, n) => {
117
+ const t = {};
118
+ for (const a of e.sections)
119
+ for (const o of a.fields) {
120
+ const i = [];
121
+ switch (o.required && i.push("required"), typeof o.max < "u" && o.max !== null && i.push({
122
+ max: [o.max]
123
+ }), typeof o.min < "u" && o.min !== null && i.push({
124
+ min: [o.min]
125
+ }), o.field_interface) {
126
+ case l.EmailWidget:
127
+ i.push("email");
128
+ break;
129
+ case l.PhoneWidget:
130
+ i.push("phone_number");
131
+ break;
132
+ case l.URLWidget:
133
+ i.push("url");
134
+ break;
135
+ }
136
+ t[o.key] = i;
137
+ }
138
+ const r = pe(n, t), { errors: c } = r, g = {};
139
+ return c && c.map((a) => {
140
+ g[a.name] = a.message;
141
+ }), g;
142
+ }, U = (e) => {
143
+ var t, r;
144
+ const n = {};
145
+ for (const c of e)
146
+ n[c.key] = (t = ue) == null ? void 0 : t[c == null ? void 0 : c.kind], (c == null ? void 0 : c.field_interface) === l.RecordWidget && ((r = c == null ? void 0 : c.fields) != null && r.length) && (n[c.key] = U(c.fields));
147
+ return n;
148
+ }, Xt = (e) => {
149
+ var t;
150
+ if (!(e != null && e.sections)) return {};
151
+ let n = {};
152
+ for (const r of e.sections)
153
+ r != null && r.fields && ((t = r == null ? void 0 : r.fields) == null ? void 0 : t.length) > 0 && (n = {
154
+ ...n,
155
+ ...U(r.fields)
156
+ });
157
+ return n;
158
+ }, ae = (e) => typeof e < "u" ? e : null, Jt = (e, n) => {
159
+ var r, c;
160
+ if (!(e != null && e.sections)) return {};
161
+ const t = {};
162
+ for (const g of e.sections) {
163
+ const a = U(g.fields ?? []);
164
+ for (const o of g.fields) {
165
+ let i = ae(n == null ? void 0 : n[o == null ? void 0 : o.key]);
166
+ Array.isArray(i) && (i == null ? void 0 : i.length) > 0 && Array.isArray(o == null ? void 0 : o.values) && ((r = o == null ? void 0 : o.values) == null ? void 0 : r.length) > 0 && !((c = o == null ? void 0 : o.options) != null && c.custom_input) && (i = i == null ? void 0 : i.filter((m) => {
167
+ var x;
168
+ return (x = o == null ? void 0 : o.values) == null ? void 0 : x.includes(m);
169
+ })), t[o.key] = i ?? ae(o == null ? void 0 : o.default_value) ?? a[o.key];
170
+ }
171
+ }
172
+ return t;
173
+ }, Qt = (e, n) => {
174
+ var c;
175
+ const t = { ...e };
176
+ let r = null;
177
+ return (t.field_interface === l.ArrayWidget && n !== l.ArrayWidget || t.field_interface === l.RecordWidget && n !== l.RecordWidget) && (t.fields = []), (n !== l.MultiDropdownWidget || n !== l.DropdownWidget || n !== l.RadioWidget || n !== l.CheckboxWidget) && t.field_interface !== l.MultiDropdownWidget && t.field_interface !== l.DropdownWidget && t.field_interface !== l.RadioWidget && t.field_interface !== l.CheckboxWidget && ((c = t.values) == null ? void 0 : c.length) !== 0 && (t.values = []), (n === l.MultiDropdownWidget && t.field_interface !== l.MultiDropdownWidget || n === l.DropdownWidget && t.field_interface !== l.DropdownWidget || n === l.RadioWidget && t.field_interface !== l.RadioWidget || n === l.CheckboxWidget && t.field_interface !== l.CheckboxWidget) && (t.values = [""], r = `${t.id}-option-0`), [l.RecordWidget, l.ArrayWidget].includes(
178
+ n
179
+ ) && (r = `field-${Fe.generate()}`, t.kind = n === l.RecordWidget ? "record" : "group", t.fields = [
180
+ ...(t == null ? void 0 : t.fields) || [],
181
+ {
182
+ id: r,
183
+ key: "title",
184
+ label: "Title",
185
+ helper_text: "",
186
+ kind: "string",
187
+ field_interface: l.TextWidget,
188
+ default_value: "",
189
+ options: {},
190
+ fields: [],
191
+ hidden: !1,
192
+ readonly: !1,
193
+ required: !1,
194
+ unique: !1,
195
+ min: null,
196
+ max: null,
197
+ formats: we[n] || [],
198
+ values: [],
199
+ editable: !0
200
+ }
201
+ ]), t.kind = ke[n] || "string", t.default_value || (t.default_value = ue[t.kind] || null), n !== l.CollectionWidget && We.includes(n) && (t.field_interface = n), { field: t, fieldFocused: r };
202
+ }, Yt = (e, n) => {
203
+ var g;
204
+ const t = { ...e }, r = [], c = "_id";
205
+ if (n)
206
+ for (const a of n.sections ?? [])
207
+ for (const o of a.fields)
208
+ o.field_interface === "CollectionWidget" && r.push(o.key);
209
+ for (const a of r)
210
+ t[a] && typeof t[a] == "object" && (Array.isArray(t[a]) ? t[a] = (g = t[a]) == null ? void 0 : g.filter(
211
+ (o) => o
212
+ ) : t[a] = t[a][c]);
213
+ return t;
214
+ }, es = (e, n) => {
215
+ if (Array.isArray(e) && e.length > 0) {
216
+ let t = 0;
217
+ for (const r of e)
218
+ t += 1, r != null && r.param && n && n(
219
+ r == null ? void 0 : r.param,
220
+ {
221
+ type: "server_error",
222
+ message: r == null ? void 0 : r.message
223
+ },
224
+ {
225
+ shouldFocus: t === 0
226
+ }
227
+ );
228
+ }
229
+ }, ts = (e) => {
230
+ var n;
231
+ return (n = Object.entries($).find(
232
+ ([t, r]) => Object.keys(r).includes(e)
233
+ )) == null ? void 0 : n[0];
234
+ };
235
+ function ss(e) {
236
+ return H({ tag: "svg", attr: { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, child: [{ tag: "path", attr: { fillRule: "evenodd", d: "M9.243 3.03a1 1 0 01.727 1.213L9.53 6h2.94l.56-2.243a1 1 0 111.94.486L14.53 6H17a1 1 0 110 2h-2.97l-1 4H15a1 1 0 110 2h-2.47l-.56 2.242a1 1 0 11-1.94-.485L10.47 14H7.53l-.56 2.242a1 1 0 11-1.94-.485L5.47 14H3a1 1 0 110-2h2.97l1-4H5a1 1 0 110-2h2.47l.56-2.243a1 1 0 011.213-.727zM9.03 8l-1 4h2.938l1-4H9.031z", clipRule: "evenodd" }, child: [] }] })(e);
237
+ }
238
+ function le(e) {
239
+ return H({ tag: "svg", attr: { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, child: [{ tag: "path", attr: { fillRule: "evenodd", d: "M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z", clipRule: "evenodd" }, child: [] }] })(e);
240
+ }
241
+ const q = ({
242
+ children: e,
243
+ isRequired: n,
244
+ className: t,
245
+ ...r
246
+ }) => /* @__PURE__ */ s.jsxs(
247
+ "label",
248
+ {
249
+ className: b(
250
+ "block text-sm font-medium leading-normal peer-disabled:cursor-not-allowed peer-disabled:opacity-70 select-none flex-1",
251
+ "mb-2",
252
+ t
253
+ ),
254
+ ...r,
255
+ children: [
256
+ e,
257
+ " ",
258
+ n && /* @__PURE__ */ s.jsx("span", { className: "text-red-500", children: "*" })
259
+ ]
260
+ }
261
+ ), Ye = ({
262
+ field: e,
263
+ isInternal: n
264
+ }) => {
265
+ const { key: t = "", label: r = "", field_interface: c = "", fields: g = [] } = e, [a, o] = w("0"), { fields: i, ...m } = Ne({
266
+ name: t
267
+ });
268
+ return !c || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full max-w-full", children: [
269
+ /* @__PURE__ */ s.jsx(q, { children: r }),
270
+ i && Array.isArray(i) ? /* @__PURE__ */ s.jsxs(Re, { value: a, onValueChange: o, className: "w-full", children: [
271
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
272
+ i.length ? /* @__PURE__ */ s.jsx(Le, { className: "h-11 overflow-y-hidden overflow-x-auto flex-1 w-1 justify-start", children: i == null ? void 0 : i.map((x, d) => /* @__PURE__ */ s.jsx(
273
+ Te,
274
+ {
275
+ id: `${e == null ? void 0 : e.key}-${d}`,
276
+ value: d.toString(),
277
+ children: d + 1
278
+ },
279
+ `array-widget-tab-${e == null ? void 0 : e.id}-${d}`
280
+ )) }) : null,
281
+ /* @__PURE__ */ s.jsxs(
282
+ W,
283
+ {
284
+ variant: "ghost",
285
+ size: "xs",
286
+ className: "shrink-0 grow-0",
287
+ onClick: () => {
288
+ m.append(U(g)), o(((i == null ? void 0 : i.length) ?? 0).toString());
289
+ },
290
+ children: [
291
+ /* @__PURE__ */ s.jsx(le, { className: "inline-block mr-1", size: "14px" }),
292
+ "Add"
293
+ ]
294
+ }
295
+ )
296
+ ] }),
297
+ i == null ? void 0 : i.map((x, d) => /* @__PURE__ */ s.jsxs(
298
+ Me,
299
+ {
300
+ className: "space-y-4 border rounded bg-secondary/40",
301
+ value: d.toString(),
302
+ children: [
303
+ /* @__PURE__ */ s.jsx("div", { className: "flex flex-col px-3 py-2 gap-3", children: g.map((y) => {
304
+ const k = {
305
+ ...y,
306
+ key: `${t}.${d}.${y == null ? void 0 : y.key}`
307
+ };
308
+ return /* @__PURE__ */ s.jsx(
309
+ ve,
310
+ {
311
+ field: k,
312
+ isInternal: n
313
+ },
314
+ `common-fields-${y == null ? void 0 : y.id}`
315
+ );
316
+ }) }),
317
+ /* @__PURE__ */ s.jsxs("div", { className: "flex p-2 items-center border-t", children: [
318
+ /* @__PURE__ */ s.jsx(
319
+ W,
320
+ {
321
+ onClick: () => {
322
+ o((d - 1).toString()), m.move(d, d - 1);
323
+ },
324
+ disabled: d === 0,
325
+ size: "icon",
326
+ className: "rounded-full w-8 h-8",
327
+ children: /* @__PURE__ */ s.jsx(Ae, { size: "24px" })
328
+ }
329
+ ),
330
+ /* @__PURE__ */ s.jsx(
331
+ W,
332
+ {
333
+ className: "text-red-500",
334
+ variant: "link",
335
+ onClick: () => {
336
+ o((d - 1).toString()), m.remove(d);
337
+ },
338
+ children: "Remove Item"
339
+ }
340
+ ),
341
+ /* @__PURE__ */ s.jsx(
342
+ W,
343
+ {
344
+ className: "rounded-full w-8 h-8",
345
+ onClick: () => {
346
+ o((d + 1).toString()), m.move(d, d + 1);
347
+ },
348
+ disabled: d >= i.length - 1,
349
+ size: "icon",
350
+ children: /* @__PURE__ */ s.jsx(Ie, { size: "24px" })
351
+ }
352
+ )
353
+ ] })
354
+ ]
355
+ },
356
+ `array-widget-tab-content-${e == null ? void 0 : e.id}-${d}`
357
+ ))
358
+ ] }) : /* @__PURE__ */ s.jsxs(
359
+ W,
360
+ {
361
+ variant: "ghost",
362
+ size: "xs",
363
+ onClick: () => {
364
+ m.append(U(g)), o("0");
365
+ },
366
+ children: [
367
+ /* @__PURE__ */ s.jsx(le, { className: "inline-block mr-1", size: "14px" }),
368
+ "Add"
369
+ ]
370
+ }
371
+ )
372
+ ] });
373
+ };
374
+ function et(e) {
375
+ return H({ tag: "svg", attr: { viewBox: "0 0 15 15", fill: "none" }, child: [{ tag: "path", attr: { fillRule: "evenodd", clipRule: "evenodd", d: "M8.84182 3.13514C9.04327 3.32401 9.05348 3.64042 8.86462 3.84188L5.43521 7.49991L8.86462 11.1579C9.05348 11.3594 9.04327 11.6758 8.84182 11.8647C8.64036 12.0535 8.32394 12.0433 8.13508 11.8419L4.38508 7.84188C4.20477 7.64955 4.20477 7.35027 4.38508 7.15794L8.13508 3.15794C8.32394 2.95648 8.64036 2.94628 8.84182 3.13514Z", fill: "currentColor" }, child: [] }] })(e);
376
+ }
377
+ function tt(e) {
378
+ return H({ tag: "svg", attr: { viewBox: "0 0 15 15", fill: "none" }, child: [{ tag: "path", attr: { fillRule: "evenodd", clipRule: "evenodd", d: "M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z", fill: "currentColor" }, child: [] }] })(e);
379
+ }
380
+ function st(e) {
381
+ return H({ tag: "svg", attr: { viewBox: "0 0 15 15", fill: "none" }, child: [{ tag: "path", attr: { fillRule: "evenodd", clipRule: "evenodd", d: "M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z", fill: "currentColor" }, child: [] }] })(e);
382
+ }
383
+ function nt(e) {
384
+ return H({ tag: "svg", attr: { viewBox: "0 0 15 15", fill: "none" }, child: [{ tag: "path", attr: { fillRule: "evenodd", clipRule: "evenodd", d: "M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z", fill: "currentColor" }, child: [] }] })(e);
385
+ }
386
+ const xe = (e) => {
387
+ const n = e == null ? void 0 : e.key;
388
+ let t = n == null ? void 0 : n.replace(/_/g, " ");
389
+ if (t != null && t.endsWith("Id") && (t = t == null ? void 0 : t.replace("Id", "")), t.includes(".")) {
390
+ const [c] = t.split(".");
391
+ c && (t = c);
392
+ }
393
+ const r = [];
394
+ switch (typeof e.max < "u" && e.max !== null && r.push({
395
+ max: [e.max]
396
+ }), typeof e.min < "u" && e.min !== null && r.push({
397
+ min: [e.min]
398
+ }), e.field_interface) {
399
+ case l.EmailWidget:
400
+ r.push("email");
401
+ break;
402
+ case l.PhoneWidget:
403
+ r.push("phone_number");
404
+ break;
405
+ case l.URLWidget:
406
+ r.push("url");
407
+ break;
408
+ }
409
+ return {
410
+ required: {
411
+ value: !!(e != null && e.required),
412
+ message: `The ${t} field is required`
413
+ },
414
+ validate: (c) => {
415
+ var o, i;
416
+ if ((o = e == null ? void 0 : e.options) != null && o.disableValidation || !c)
417
+ return !0;
418
+ const g = pe(
419
+ {
420
+ [e.key]: c
421
+ },
422
+ {
423
+ [e.key]: r
424
+ }
425
+ ), { errors: a } = g;
426
+ return a && (a == null ? void 0 : a.length) > 0 ? (i = a == null ? void 0 : a[0]) == null ? void 0 : i.message : !0;
427
+ }
428
+ };
429
+ }, rt = ({
430
+ children: e
431
+ }) => /* @__PURE__ */ s.jsx("p", { className: "text-xs font-normal text-red-400 text-wrap", children: e }), ot = ({
432
+ children: e
433
+ }) => /* @__PURE__ */ s.jsx("p", { className: b("text-xs font-normal text-gray-600"), children: e }), Q = E.forwardRef(({ error: e, helperText: n, containerStyles: t, readOnly: r, children: c }, g) => /* @__PURE__ */ s.jsx(
434
+ "div",
435
+ {
436
+ className: b(
437
+ "form-control w-full",
438
+ r ? "pointer-events-none" : "",
439
+ t
440
+ ),
441
+ ref: g,
442
+ children: /* @__PURE__ */ s.jsxs("div", { className: b("w-full shrink-0", "sm:flex-1"), children: [
443
+ c,
444
+ e && /* @__PURE__ */ s.jsx("div", { className: b("w-full mt-3"), children: /* @__PURE__ */ s.jsx(rt, { children: e }) }),
445
+ n && /* @__PURE__ */ s.jsx("div", { className: b("w-full mt-3"), children: /* @__PURE__ */ s.jsx(ot, { children: n }) })
446
+ ] })
447
+ }
448
+ )), he = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
449
+ "table",
450
+ {
451
+ ref: t,
452
+ className: b("w-full caption-bottom text-sm", e),
453
+ ...n
454
+ }
455
+ ));
456
+ he.displayName = "Table";
457
+ const at = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx("thead", { ref: t, className: b("[&_tr]:border-b", e), ...n }));
458
+ at.displayName = "TableHeader";
459
+ const fe = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
460
+ "tbody",
461
+ {
462
+ ref: t,
463
+ className: b("[&_tr:last-child]:border-0", e),
464
+ ...n
465
+ }
466
+ ));
467
+ fe.displayName = "TableBody";
468
+ const lt = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
469
+ "tfoot",
470
+ {
471
+ ref: t,
472
+ className: b("bg-primary font-medium text-primary-foreground", e),
473
+ ...n
474
+ }
475
+ ));
476
+ lt.displayName = "TableFooter";
477
+ const ye = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
478
+ "tr",
479
+ {
480
+ ref: t,
481
+ className: b(
482
+ "border-b transition-colors data-[state=selected]:bg-muted",
483
+ e
484
+ ),
485
+ ...n
486
+ }
487
+ ));
488
+ ye.displayName = "TableRow";
489
+ const it = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
490
+ "th",
491
+ {
492
+ ref: t,
493
+ className: b(
494
+ "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
495
+ e
496
+ ),
497
+ ...n
498
+ }
499
+ ));
500
+ it.displayName = "TableHead";
501
+ const je = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
502
+ "td",
503
+ {
504
+ ref: t,
505
+ className: b("p-4 align-middle [&:has([role=checkbox])]:pr-0", e),
506
+ ...n
507
+ }
508
+ ));
509
+ je.displayName = "TableCell";
510
+ const ct = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
511
+ "caption",
512
+ {
513
+ ref: t,
514
+ className: b("mt-4 text-sm text-muted-foreground", e),
515
+ ...n
516
+ }
517
+ ));
518
+ ct.displayName = "TableCaption";
519
+ const dt = E.lazy(
520
+ () => import("react-select-async-paginate").then((e) => ({
521
+ default: e.AsyncPaginate
522
+ }))
523
+ ), be = (e) => /* @__PURE__ */ s.jsx(
524
+ dt,
525
+ {
526
+ isClearable: !0,
527
+ menuPlacement: "auto",
528
+ isSearchable: !0,
529
+ unstyled: !0,
530
+ classNames: {
531
+ container: () => b("w-full min-w-none h-auto min-h-none"),
532
+ control: ({ isFocused: n, isMulti: t, isDisabled: r }) => b(
533
+ "w-full pl-3",
534
+ t ? "!min-h-9 h-auto" : "h-9 !min-h-none",
535
+ "rounded-md border bg-transparent hover:cursor-pointer border-input text-sm shadow-sm transition-colors",
536
+ "flex ",
537
+ n && "outline-none ring-1 ring-ring",
538
+ r && "cursor-not-allowed opacity-50"
539
+ ),
540
+ input: () => "",
541
+ valueContainer: () => "gap-[4px] py-1",
542
+ singleValue: () => "",
543
+ multiValue: () => "bg-gray-100 rounded items-center py-0.5 pl-2 pr-1 gap-1.5",
544
+ multiValueLabel: () => "py-0.5",
545
+ multiValueRemove: () => "border border-gray-200 bg-white hover:bg-red-50 hover:text-red-800 text-gray-500 hover:border-red-300 rounded-md",
546
+ indicatorsContainer: () => "",
547
+ clearIndicator: () => "text-gray-500 p-1 rounded-md hover:bg-red-50 hover:text-red-800",
548
+ indicatorSeparator: () => "",
549
+ dropdownIndicator: () => "p-1 hover:bg-gray-100 text-gray-500 rounded-md hover:text-black",
550
+ menu: () => "p-1 mt-2 border border-gray-200 bg-white rounded-md",
551
+ groupHeading: () => "ml-3 mt-2 mb-1 text-gray-500 text-sm",
552
+ placeholder: () => "text-gray-500 pl-1 py-0.5",
553
+ option: ({ isSelected: n, isFocused: t }) => b(
554
+ "text-[.875rem] font-medium hover:cursor-pointer px-3 py-2 rounded",
555
+ t && "bg-gray-100 active:bg-gray-200",
556
+ n && "text-white bg-primary/80"
557
+ ),
558
+ noOptionsMessage: () => "text-gray-500 p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm"
559
+ },
560
+ ...e
561
+ }
562
+ ), ut = ({
563
+ field: e,
564
+ value: n,
565
+ onChange: t
566
+ }) => {
567
+ var S, f;
568
+ const { collection: r } = X(), [c, g] = w(!1), [a, o] = w([]), [i, m] = w(!1), {
569
+ key: x = "",
570
+ label: d = "items",
571
+ helper_text: y = "",
572
+ readonly: k = !1
573
+ } = e, C = x, B = ((S = e == null ? void 0 : e.options) == null ? void 0 : S.collection_key) || "", _ = ((f = e == null ? void 0 : e.options) == null ? void 0 : f.label_field_key) || "", I = async (j, N, { page: R = 1 }) => {
574
+ var F;
575
+ g(!0);
576
+ try {
577
+ const L = await (r == null ? void 0 : r.getCollectionContentList({
578
+ collection_key: B,
579
+ page: R,
580
+ search: j,
581
+ limit: 10,
582
+ where: {
583
+ _id: {
584
+ not_in: n
585
+ }
586
+ }
587
+ })), h = (F = L == null ? void 0 : L.content) == null ? void 0 : F.data, O = (h || []).map((p) => {
588
+ const P = p != null && p[_] ? p == null ? void 0 : p[_] : J.toTitle((p == null ? void 0 : p.slug) || "");
589
+ return {
590
+ value: {
591
+ _id: p == null ? void 0 : p._id,
592
+ slug: p == null ? void 0 : p.slug,
593
+ [_]: p == null ? void 0 : p[_]
594
+ },
595
+ label: P
596
+ };
597
+ });
598
+ return {
599
+ options: Array.isArray(O) ? O : [],
600
+ hasMore: h && !((h == null ? void 0 : h.length) < 10),
601
+ additional: {
602
+ page: R + 1
603
+ }
604
+ };
605
+ } catch {
606
+ return {
607
+ options: [],
608
+ hasMore: !1,
609
+ additional: {
610
+ page: R
611
+ }
612
+ };
613
+ } finally {
614
+ g(!1);
615
+ }
616
+ };
617
+ return /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
618
+ /* @__PURE__ */ s.jsxs(W, { size: "xs", onClick: () => m(!0), children: [
619
+ "Select more ",
620
+ d
621
+ ] }),
622
+ /* @__PURE__ */ s.jsxs(
623
+ De,
624
+ {
625
+ title: "Select more items",
626
+ isOpen: i,
627
+ onClose: () => m(!1),
628
+ contentClassName: "max-w-96",
629
+ children: [
630
+ /* @__PURE__ */ s.jsxs(Q, { helperText: y, readOnly: k, children: [
631
+ d && /* @__PURE__ */ s.jsx(q, { htmlFor: C, children: d }),
632
+ /* @__PURE__ */ s.jsx(
633
+ be,
634
+ {
635
+ id: C,
636
+ value: a,
637
+ onChange: (j) => {
638
+ o(j);
639
+ },
640
+ isMulti: !0,
641
+ loadOptions: I,
642
+ debounceTimeout: 500,
643
+ getOptionLabel: (j) => j == null ? void 0 : j.label,
644
+ getOptionValue: (j) => j == null ? void 0 : j.value,
645
+ isLoading: c,
646
+ additional: {
647
+ page: 1
648
+ },
649
+ cacheUniqs: [B],
650
+ minMenuHeight: 250
651
+ }
652
+ )
653
+ ] }),
654
+ /* @__PURE__ */ s.jsx(
655
+ W,
656
+ {
657
+ className: "mt-4",
658
+ onClick: () => {
659
+ t([
660
+ ...n,
661
+ ...(a ?? []).map((j) => {
662
+ var N;
663
+ return (N = j == null ? void 0 : j.value) == null ? void 0 : N._id;
664
+ })
665
+ ]), m(!1);
666
+ },
667
+ children: "Add"
668
+ }
669
+ )
670
+ ]
671
+ }
672
+ )
673
+ ] });
674
+ }, gt = ({
675
+ field: e
676
+ }) => {
677
+ var T, M, V;
678
+ const { collection: n } = X(), [t, r] = w(!1), [c, g] = w([]), [a, o] = w(1), [i, m] = w(0), [x, d] = w(0), { key: y = "", label: k = "", helper_text: C = "", readonly: B = !1 } = e, _ = y, I = ((T = e == null ? void 0 : e.options) == null ? void 0 : T.collection_key) || "", S = ((M = e == null ? void 0 : e.options) == null ? void 0 : M.label_field_key) || "", {
679
+ field: { value: f, onBlur: j, onChange: N, ref: R, disabled: F, ...L },
680
+ fieldState: h
681
+ } = me({
682
+ name: _,
683
+ rules: xe(e)
684
+ }), O = !!(e != null && e.required), p = (V = h == null ? void 0 : h.error) == null ? void 0 : V.message, P = async () => {
685
+ var Y, ee, te, se, ne;
686
+ r(!0);
687
+ const u = await (n == null ? void 0 : n.getCollectionContentList({
688
+ collection_key: I,
689
+ page: a,
690
+ limit: 5,
691
+ where: {
692
+ _id: {
693
+ in: f
694
+ }
695
+ }
696
+ })), D = ((Y = u == null ? void 0 : u.content) == null ? void 0 : Y.data) ?? [], G = ((te = (ee = u == null ? void 0 : u.content) == null ? void 0 : ee.meta) == null ? void 0 : te.pages) ?? 0;
697
+ m(((ne = (se = u == null ? void 0 : u.content) == null ? void 0 : se.meta) == null ? void 0 : ne.total) ?? 0), d(G), a > G && o(G), g(D), r(!1);
698
+ };
699
+ return ge(() => {
700
+ (f == null ? void 0 : f.length) > 0 && P();
701
+ }, [f, a]), /* @__PURE__ */ s.jsxs(
702
+ Q,
703
+ {
704
+ ref: R,
705
+ error: p,
706
+ helperText: C,
707
+ readOnly: B,
708
+ children: [
709
+ k && /* @__PURE__ */ s.jsx(q, { htmlFor: _, isRequired: O, children: k }),
710
+ /* @__PURE__ */ s.jsx(
711
+ ut,
712
+ {
713
+ onChange: N,
714
+ value: f ?? [],
715
+ field: e
716
+ }
717
+ ),
718
+ f != null && f.length ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
719
+ /* @__PURE__ */ s.jsxs("div", { className: "relative overflow-hidden", children: [
720
+ t ? /* @__PURE__ */ s.jsx("div", { className: "z-10 absolute top-0 left-0 right-0 bottom-0 flex items-center justify-center bg-[rgba(0,0,0,0.05)]", children: /* @__PURE__ */ s.jsxs("div", { className: "flex items-center", children: [
721
+ /* @__PURE__ */ s.jsx(Be, { className: "h-8 w-8 animate-spin mr-2" }),
722
+ "Fetching"
723
+ ] }) }) : null,
724
+ /* @__PURE__ */ s.jsx(he, { className: f.length > 5 ? "min-h-72" : "", children: /* @__PURE__ */ s.jsx(fe, { children: c.map((u) => /* @__PURE__ */ s.jsx(ye, { children: /* @__PURE__ */ s.jsxs(je, { className: "flex justify-between", children: [
725
+ u == null ? void 0 : u[S],
726
+ /* @__PURE__ */ s.jsx(
727
+ Ee,
728
+ {
729
+ className: "cursor-pointer",
730
+ size: 20,
731
+ onClick: () => {
732
+ console.log(
733
+ f,
734
+ f == null ? void 0 : f.filter((D) => D !== (u == null ? void 0 : u._id)),
735
+ u
736
+ ), N(
737
+ f == null ? void 0 : f.filter((D) => D !== (u == null ? void 0 : u._id))
738
+ );
739
+ }
740
+ }
741
+ )
742
+ ] }) }, u == null ? void 0 : u._id)) }) })
743
+ ] }),
744
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between px-2", children: [
745
+ /* @__PURE__ */ s.jsxs("div", { className: "flex-1 text-sm text-muted-foreground", children: [
746
+ "Showing",
747
+ " ",
748
+ i ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
749
+ 5 * (a - 1) + 1,
750
+ "-",
751
+ Math.min(5 * a, i),
752
+ " of",
753
+ " "
754
+ ] }) : null,
755
+ " ",
756
+ i,
757
+ " items"
758
+ ] }),
759
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
760
+ /* @__PURE__ */ s.jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
761
+ "Page ",
762
+ a,
763
+ " of ",
764
+ x
765
+ ] }),
766
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center space-x-2", children: [
767
+ /* @__PURE__ */ s.jsxs(
768
+ W,
769
+ {
770
+ onClick: () => o(1),
771
+ disabled: a === 1,
772
+ variant: "outline",
773
+ className: "hidden h-8 w-8 p-0 lg:flex",
774
+ children: [
775
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to first page" }),
776
+ /* @__PURE__ */ s.jsx(st, { className: "h-4 w-4" })
777
+ ]
778
+ }
779
+ ),
780
+ /* @__PURE__ */ s.jsxs(
781
+ W,
782
+ {
783
+ disabled: a === 1,
784
+ onClick: () => o(a - 1),
785
+ variant: "outline",
786
+ className: "h-8 w-8 p-0",
787
+ children: [
788
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to previous page" }),
789
+ /* @__PURE__ */ s.jsx(et, { className: "h-4 w-4" })
790
+ ]
791
+ }
792
+ ),
793
+ /* @__PURE__ */ s.jsxs(
794
+ W,
795
+ {
796
+ onClick: () => o(a + 1),
797
+ disabled: a === x,
798
+ variant: "outline",
799
+ className: "h-8 w-8 p-0",
800
+ children: [
801
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to next page" }),
802
+ /* @__PURE__ */ s.jsx(tt, { className: "h-4 w-4" })
803
+ ]
804
+ }
805
+ ),
806
+ /* @__PURE__ */ s.jsxs(
807
+ W,
808
+ {
809
+ onClick: () => o(x),
810
+ disabled: a === x,
811
+ variant: "outline",
812
+ className: "hidden h-8 w-8 p-0 lg:flex",
813
+ children: [
814
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to last page" }),
815
+ /* @__PURE__ */ s.jsx(nt, { className: "h-4 w-4" })
816
+ ]
817
+ }
818
+ )
819
+ ] })
820
+ ] })
821
+ ] })
822
+ ] }) : null
823
+ ]
824
+ }
825
+ );
826
+ }, mt = ({
827
+ field: e
828
+ }) => {
829
+ var R, F, L;
830
+ const { collection: n } = X(), [t, r] = w(!1), { key: c = "", label: g = "", helper_text: a = "", readonly: o = !1 } = e, i = c, m = ((R = e == null ? void 0 : e.options) == null ? void 0 : R.collection_key) || "", x = ((F = e == null ? void 0 : e.options) == null ? void 0 : F.label_field_key) || "", {
831
+ field: { value: d, onBlur: y, onChange: k, ref: C, disabled: B, ..._ },
832
+ fieldState: I
833
+ } = me({
834
+ name: i,
835
+ rules: xe(e)
836
+ }), S = !!(e != null && e.required), f = (L = I == null ? void 0 : I.error) == null ? void 0 : L.message, j = async (h, O, { page: p = 1 }) => {
837
+ var P;
838
+ r(!0);
839
+ try {
840
+ const T = await (n == null ? void 0 : n.getCollectionContentList({
841
+ collection_key: m,
842
+ page: p,
843
+ search: h,
844
+ limit: 10
845
+ })), M = (P = T == null ? void 0 : T.content) == null ? void 0 : P.data, V = (M || []).map((u) => {
846
+ const D = u != null && u[x] ? u == null ? void 0 : u[x] : J.toTitle((u == null ? void 0 : u.slug) || "");
847
+ return {
848
+ value: {
849
+ _id: u == null ? void 0 : u._id,
850
+ slug: u == null ? void 0 : u.slug,
851
+ [x]: u == null ? void 0 : u[x]
852
+ },
853
+ label: D
854
+ };
855
+ });
856
+ return {
857
+ options: Array.isArray(V) ? V : [],
858
+ hasMore: M && !((M == null ? void 0 : M.length) < 10),
859
+ additional: {
860
+ page: p + 1
861
+ }
862
+ };
863
+ } catch {
864
+ return {
865
+ options: [],
866
+ hasMore: !1,
867
+ additional: {
868
+ page: p
869
+ }
870
+ };
871
+ } finally {
872
+ r(!1);
873
+ }
874
+ }, N = d ? {
875
+ label: d != null && d[x] ? d == null ? void 0 : d[x] : d != null && d.slug ? J.toTitle((d == null ? void 0 : d.slug) || "") : "",
876
+ value: {
877
+ _id: d == null ? void 0 : d._id,
878
+ slug: d == null ? void 0 : d.slug,
879
+ [x]: d == null ? void 0 : d[x]
880
+ }
881
+ } : null;
882
+ return /* @__PURE__ */ s.jsxs(
883
+ Q,
884
+ {
885
+ ref: C,
886
+ error: f,
887
+ helperText: a,
888
+ readOnly: o,
889
+ children: [
890
+ g && /* @__PURE__ */ s.jsx(q, { htmlFor: i, isRequired: S, children: g }),
891
+ /* @__PURE__ */ s.jsx(
892
+ be,
893
+ {
894
+ id: i,
895
+ value: N,
896
+ onChange: (h) => {
897
+ k((h == null ? void 0 : h.value) || null);
898
+ },
899
+ onBlur: () => {
900
+ y();
901
+ },
902
+ loadOptions: j,
903
+ debounceTimeout: 500,
904
+ getOptionLabel: (h) => h == null ? void 0 : h.label,
905
+ getOptionValue: (h) => h == null ? void 0 : h.value,
906
+ isLoading: t,
907
+ additional: {
908
+ page: 1
909
+ },
910
+ cacheUniqs: [m],
911
+ minMenuHeight: 250,
912
+ isDisabled: B,
913
+ ..._
914
+ }
915
+ )
916
+ ]
917
+ }
918
+ );
919
+ }, pt = v(
920
+ () => import("./MultiTextWidget-CxVpyf06.js")
921
+ ), ie = v(() => import("./TextWidget-CtFaQde1.js")), xt = v(
922
+ () => import("./CurrencyWidget-sD8ijLvw.js")
923
+ ), ht = v(
924
+ () => import("./CheckboxWidget-BGS61gcL.js")
925
+ ), ce = v(
926
+ () => import("./DateTimeWidget-KrcsxgEF.js")
927
+ ), de = v(
928
+ () => import("./DropdownWidget-rm5oUqOE.js")
929
+ ), ft = v(() => import("./EmailWidget-CvZKOywL.js")), yt = v(
930
+ () => import("./GeocoderWidget-CSsp_-hW.js")
931
+ ), jt = v(
932
+ () => import("./MultiGeocoderWidget-Blqz-lHX.js")
933
+ ), bt = v(() => import("./PhoneWidget-DezcchSP.js")), vt = v(() => import("./RadioWidget-SfD1fFDG.js")), Ct = v(
934
+ () => import("./RichTextWidget-Cg3RizdO.js")
935
+ ), wt = v(() => import("./SwitchWidget-Id6BNlPe.js")), kt = v(
936
+ () => import("./TextareaWidget-BKzAeMod.js")
937
+ ), Wt = v(
938
+ () => import("./ToggleCheckboxWidget-nSlie9sE.js")
939
+ ), _t = v(() => import("./URLWidget-DtJai3xY.js")), K = v(() => import("./UploadWidget-Dxx2_FYo.js")), Nt = ({
940
+ field: e,
941
+ isInternal: n
942
+ }) => {
943
+ var c, g, a, o, i, m;
944
+ const { field_interface: t, key: r } = e;
945
+ if (!t || !r)
946
+ return null;
947
+ switch (t) {
948
+ case l.TextWidget:
949
+ return /* @__PURE__ */ s.jsx(ie, { field: e });
950
+ case l.NumberWidget:
951
+ return /* @__PURE__ */ s.jsx(ie, { type: "number", field: e });
952
+ case l.CurrencyWidget:
953
+ return /* @__PURE__ */ s.jsx(xt, { field: e });
954
+ case l.CheckboxWidget:
955
+ return /* @__PURE__ */ s.jsx(ht, { field: e });
956
+ case l.DateTimeWidget:
957
+ return /* @__PURE__ */ s.jsx(ce, { field: e });
958
+ case l.DateWidget:
959
+ return /* @__PURE__ */ s.jsx(ce, { field: e });
960
+ case l.DropdownWidget:
961
+ return /* @__PURE__ */ s.jsx(de, { field: e, isMulti: !1 });
962
+ case l.MultiDropdownWidget:
963
+ return /* @__PURE__ */ s.jsx(de, { field: e, isMulti: !0 });
964
+ case l.MultiTextWidget:
965
+ return /* @__PURE__ */ s.jsx(pt, { field: e });
966
+ case l.EmailWidget:
967
+ return /* @__PURE__ */ s.jsx(ft, { field: e });
968
+ case l.GeocoderWidget:
969
+ return /* @__PURE__ */ s.jsx(yt, { field: e });
970
+ case l.MultiGeocoderWidget:
971
+ return /* @__PURE__ */ s.jsx(jt, { field: e });
972
+ case l.PhoneWidget:
973
+ return /* @__PURE__ */ s.jsx(bt, { field: e });
974
+ case l.RadioWidget:
975
+ return /* @__PURE__ */ s.jsx(vt, { field: e });
976
+ case l.RichTextWidget:
977
+ return /* @__PURE__ */ s.jsx(Ct, { field: e });
978
+ case l.SwitchWidget:
979
+ return /* @__PURE__ */ s.jsx(wt, { field: e });
980
+ case l.TextareaWidget:
981
+ return /* @__PURE__ */ s.jsx(kt, { field: e });
982
+ case l.ToggleCheckboxWidget:
983
+ return /* @__PURE__ */ s.jsx(Wt, { field: e });
984
+ case l.URLWidget:
985
+ return /* @__PURE__ */ s.jsx(_t, { field: e });
986
+ case l.ImageUploadWidget:
987
+ return /* @__PURE__ */ s.jsx(
988
+ K,
989
+ {
990
+ field: e,
991
+ isMultiple: !1,
992
+ kind: ["image"],
993
+ isExternal: !n
994
+ }
995
+ );
996
+ case l.MultiImageUploadWidget:
997
+ return /* @__PURE__ */ s.jsx(
998
+ K,
999
+ {
1000
+ field: e,
1001
+ isMultiple: !0,
1002
+ kind: ["image"],
1003
+ isExternal: !n
1004
+ }
1005
+ );
1006
+ case l.FileUploadWidget:
1007
+ return /* @__PURE__ */ s.jsx(
1008
+ K,
1009
+ {
1010
+ field: e,
1011
+ isMultiple: !1,
1012
+ kind: ["audio", "video", "image", "document"],
1013
+ isExternal: !n
1014
+ }
1015
+ );
1016
+ case l.MultiFileUploadWidget:
1017
+ return /* @__PURE__ */ s.jsx(
1018
+ K,
1019
+ {
1020
+ field: e,
1021
+ isMultiple: !0,
1022
+ kind: ["audio", "video", "image", "document"],
1023
+ isExternal: !n
1024
+ }
1025
+ );
1026
+ case l.CollectionWidget:
1027
+ return !((c = e == null ? void 0 : e.options) != null && c.collection_key) || !((g = e == null ? void 0 : e.options) != null && g.label_field_key) ? (console.error(
1028
+ "[LevoCollection]: Error while rendering collection widget. Collection key of label field key is required."
1029
+ ), null) : (
1030
+ /**
1031
+ * @context
1032
+ *
1033
+ * this includes both `o2m` and `m2m` relationships, which if rendered
1034
+ * should be using a multi-select dropdown widget
1035
+ *
1036
+ *
1037
+ * @todo
1038
+ * but, if such a field exist, we should be handling that with a modal or a drawer widget
1039
+ * which renders a table with a multi-row select.
1040
+ *
1041
+ * the selected row, would then become connected to the current row.
1042
+ *
1043
+ * e.g.: `blog` collection key can have an `o2m` relationship with `post` collection key
1044
+ *
1045
+ * in this case, the `post` collection key should be rendered as a widget which shows count of posts
1046
+ * and on clicking which actually opens a modal or a drawer widget which renders a table with a multi-row select
1047
+ *
1048
+ */
1049
+ (a = e == null ? void 0 : e.options) != null && a.current_have_many_connected && !((o = e == null ? void 0 : e.options) != null && o.connected_have_many_current) ? (console.error("[LevoCollection]: O2M is not supported"), null) : (i = e == null ? void 0 : e.options) != null && i.current_have_many_connected && ((m = e == null ? void 0 : e.options) != null && m.connected_have_many_current) ? /* @__PURE__ */ s.jsx(gt, { field: e }) : /* @__PURE__ */ s.jsx(mt, { field: e })
1050
+ );
1051
+ default:
1052
+ return null;
1053
+ }
1054
+ }, Rt = ({
1055
+ field: e,
1056
+ isInternal: n
1057
+ }) => {
1058
+ const { key: t = "", label: r = "", field_interface: c = "", fields: g = [] } = e;
1059
+ return !c || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full", children: [
1060
+ /* @__PURE__ */ s.jsx(q, { children: r }),
1061
+ /* @__PURE__ */ s.jsx("div", { className: "border rounded bg-secondary/40 flex flex-col px-3 py-4 gap-3", children: g.map((a) => {
1062
+ const o = {
1063
+ ...a,
1064
+ key: `${t}.${a == null ? void 0 : a.key}`
1065
+ };
1066
+ return /* @__PURE__ */ s.jsx(
1067
+ ve,
1068
+ {
1069
+ field: o,
1070
+ isInternal: n
1071
+ },
1072
+ `common-fields-${e == null ? void 0 : e.id}-${a == null ? void 0 : a.id}`
1073
+ );
1074
+ }) })
1075
+ ] });
1076
+ }, ve = (e) => {
1077
+ const { field_interface: n = "", key: t = "" } = e.field;
1078
+ if (!n || !t)
1079
+ return null;
1080
+ switch (n) {
1081
+ case l.ArrayWidget:
1082
+ return /* @__PURE__ */ s.jsx(Ye, { ...e });
1083
+ case l.RecordWidget:
1084
+ return /* @__PURE__ */ s.jsx(Rt, { ...e });
1085
+ default:
1086
+ return /* @__PURE__ */ s.jsx(Nt, { ...e });
1087
+ }
1088
+ }, Ce = E.createContext({
1089
+ schema: null,
1090
+ submitButtonConfig: {
1091
+ show: !0
1092
+ }
1093
+ }), Lt = ({
1094
+ children: e,
1095
+ ...n
1096
+ }) => {
1097
+ const { schema: t, onFormView: r } = n, { ref: c } = Oe({
1098
+ triggerOnce: !0,
1099
+ onChange: (g) => {
1100
+ g && (t != null && t.id) && r && r({ schemaId: t.id });
1101
+ }
1102
+ });
1103
+ return /* @__PURE__ */ s.jsxs(Ce.Provider, { value: { ...n }, children: [
1104
+ /* @__PURE__ */ s.jsx("div", { ref: c }),
1105
+ e
1106
+ ] });
1107
+ }, ns = () => E.useContext(Ce), Tt = E.lazy(
1108
+ () => import("./DefaultFormVariant-j1HgVDiI.js")
1109
+ ), Mt = E.lazy(
1110
+ () => import("./StepsFormVariant-D35dFYK6.js")
1111
+ ), At = ({
1112
+ formVariant: e,
1113
+ ...n
1114
+ }) => {
1115
+ const { schema: t, uiConfig: r } = n;
1116
+ return /* @__PURE__ */ s.jsxs(Lt, { ...n, children: [
1117
+ r != null && r.hideFormHeading ? null : /* @__PURE__ */ s.jsxs(
1118
+ "h1",
1119
+ {
1120
+ className: b(
1121
+ "text-2xl text-left text-black mb-4 font-semibold",
1122
+ e === "default" ? "ml-[32%]" : "ml-0"
1123
+ ),
1124
+ children: [
1125
+ "Create new ",
1126
+ He.singularize((t == null ? void 0 : t.name) || "")
1127
+ ]
1128
+ }
1129
+ ),
1130
+ /* @__PURE__ */ s.jsx(_e, { children: e === "steps" ? /* @__PURE__ */ s.jsx(Mt, {}) : /* @__PURE__ */ s.jsx(Tt, {}) })
1131
+ ] });
1132
+ }, rs = ({
1133
+ collection_id: e,
1134
+ hiddenFields: n,
1135
+ ...t
1136
+ }) => {
1137
+ const { collection: r } = X(), [c, g] = w(!0), [a, o] = w(null);
1138
+ return ge(() => {
1139
+ e ? r == null || r.getCollectionByIDExpanded(e, {
1140
+ headers: {
1141
+ "Levo-Workspace": t == null ? void 0 : t.workspace_id
1142
+ }
1143
+ }).then((i) => {
1144
+ var x, d;
1145
+ const m = (x = i == null ? void 0 : i.content) == null ? void 0 : x.data;
1146
+ if (m)
1147
+ m.sections = (d = m == null ? void 0 : m.sections) == null ? void 0 : d.map(
1148
+ (y) => {
1149
+ var k;
1150
+ return y.fields = (k = y == null ? void 0 : y.fields) == null ? void 0 : k.map((C) => (n != null && n.includes(C == null ? void 0 : C.key) && (C.hidden = !0), C)), y;
1151
+ }
1152
+ ), o(m);
1153
+ else
1154
+ throw new Error(`API response invalid: ${m}`);
1155
+ }).catch((i) => {
1156
+ console.error("Error fetching schema", i);
1157
+ }).finally(() => {
1158
+ g(!1);
1159
+ }) : (console.error(
1160
+ "[CollectionFormBuilder] Collection ID or Workspace ID is missing."
1161
+ ), g(!1));
1162
+ }, [e]), /* @__PURE__ */ s.jsx("div", { className: "w-full h-auto", children: c ? /* @__PURE__ */ s.jsx("div", { className: "min-h-[400px] w-full flex justify-center items-center bg-white rounded-md", children: /* @__PURE__ */ s.jsx(Se, {}) }) : a ? /* @__PURE__ */ s.jsx(At, { schema: a, ...t }) : null });
1163
+ };
1164
+ export {
1165
+ Q as A,
1166
+ q as B,
1167
+ rs as C,
1168
+ ns as D,
1169
+ ve as F,
1170
+ ss as H,
1171
+ pe as a,
1172
+ U as b,
1173
+ Xt as c,
1174
+ ae as d,
1175
+ Je as e,
1176
+ Jt as f,
1177
+ ts as g,
1178
+ es as h,
1179
+ Qe as i,
1180
+ Ve as j,
1181
+ ze as k,
1182
+ $e as l,
1183
+ Ue as m,
1184
+ qe as n,
1185
+ Ge as o,
1186
+ oe as p,
1187
+ Ze as q,
1188
+ Ke as r,
1189
+ Yt as s,
1190
+ $ as t,
1191
+ Qt as u,
1192
+ Kt as v,
1193
+ Z as w,
1194
+ Gt as x,
1195
+ Zt as y,
1196
+ xe as z
1197
+ };