@levo-so/react 0.1.14 → 0.1.16

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 (106) hide show
  1. package/dist/CheckboxWidget-CNoS-2W3.js +124 -0
  2. package/dist/CollectionFormBuilder-MAo2Ob3a.js +1199 -0
  3. package/dist/{CurrencyWidget-COoMkfsA.js → CurrencyWidget-Cu1Cthnw.js} +5 -5
  4. package/dist/{DateTimeWidget-DcbQ3smI.js → DateTimeWidget-N-wuCRSJ.js} +3 -3
  5. package/dist/DefaultFormVariant-IqWi1BiT.js +81 -0
  6. package/dist/DropdownWidget-BFttB4b-.js +115 -0
  7. package/dist/{EmailWidget-CG9oNUM5.js → EmailWidget-D_SqXx3M.js} +11 -11
  8. package/dist/FormCaptcha-CJ9KgDu0.js +197 -0
  9. package/dist/GeocoderWidget-Bxt3TeAf.js +68 -0
  10. package/dist/LevoProvider-BAZy7_tP.js +223 -0
  11. package/dist/{MultiGeocoderWidget-D3Xmv8g4.js → MultiGeocoderWidget-DFjuXZBN.js} +6 -6
  12. package/dist/{MultiTextWidget-CyQRcWC8.js → MultiTextWidget-CZzT51cH.js} +14 -14
  13. package/dist/{PhoneWidget-C1Jt7kXL.js → PhoneWidget--K5aS16s.js} +5 -5
  14. package/dist/{RadioWidget-BrLNF-I2.js → RadioWidget-BbMPtR3P.js} +9 -9
  15. package/dist/{RichTextWidget-BogYcPtS.js → RichTextWidget-Cce3Bw8d.js} +21 -21
  16. package/dist/Spinner-Bzu2xCFZ.js +405 -0
  17. package/dist/{StepsFormVariant-Bx-jdciC.js → StepsFormVariant-5wZbYAA9.js} +58 -55
  18. package/dist/{SwitchWidget-BT0-waP9.js → SwitchWidget-B0wkSWxa.js} +5 -5
  19. package/dist/{TextWidget-Bvsz-hey.js → TextWidget-ldbMuLB0.js} +7 -7
  20. package/dist/{TextareaWidget-8SLym--T.js → TextareaWidget-S8bKUTv0.js} +3 -3
  21. package/dist/{ToggleCheckboxWidget-VrCQBF5C.js → ToggleCheckboxWidget-CPduXE6Y.js} +7 -7
  22. package/dist/Tooltip-DEBnSqlo.js +36 -0
  23. package/dist/{URLWidget-B99nKr6N.js → URLWidget-KbhE2ZUA.js} +2 -2
  24. package/dist/UploadWidget-DFvfDUT6.js +616 -0
  25. package/dist/audience/components/block.d.ts.map +1 -1
  26. package/dist/audience/components/component.d.ts.map +1 -1
  27. package/dist/audience/components/page.d.ts.map +1 -1
  28. package/dist/audience/index.js +1 -1
  29. package/dist/collection/components/Altcha.d.ts +10 -0
  30. package/dist/collection/components/Altcha.d.ts.map +1 -0
  31. package/dist/collection/components/FormCaptcha.d.ts +3 -0
  32. package/dist/collection/components/FormCaptcha.d.ts.map +1 -0
  33. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +1 -1
  34. package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +1 -1
  35. package/dist/collection/components/core/Input/Input.d.ts.map +1 -1
  36. package/dist/collection/components/core/Switch/Switch.d.ts.map +1 -1
  37. package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -1
  38. package/dist/collection/components/widgets/FieldWrapper.d.ts.map +1 -1
  39. package/dist/collection/components/widgets/FormHelperText.d.ts.map +1 -1
  40. package/dist/collection/components/widgets/FormLabel.d.ts.map +1 -1
  41. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +1 -1
  42. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -1
  43. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts +7 -0
  44. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -0
  45. package/dist/collection/components/widgets/collectionWidget/{CollectionWidget.d.ts → CollectionWidgetM2O.d.ts} +1 -1
  46. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts.map +1 -0
  47. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts +8 -0
  48. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +1 -0
  49. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +1 -1
  50. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -1
  51. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -1
  52. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +1 -1
  53. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -1
  54. package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts.map +1 -1
  55. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -1
  56. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +1 -1
  57. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +1 -1
  58. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +1 -1
  59. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +1 -1
  60. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts +11 -0
  61. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -0
  62. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
  63. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
  64. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -1
  65. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -1
  66. package/dist/collection/index.js +13 -12
  67. package/dist/collection/lib/FormBuilder.d.ts.map +1 -1
  68. package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -1
  69. package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -1
  70. package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -1
  71. package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +1 -1
  72. package/dist/collection/utils/formHelpers.d.ts.map +1 -1
  73. package/dist/collection/utils/index.d.ts +2 -0
  74. package/dist/collection/utils/index.d.ts.map +1 -1
  75. package/dist/components/Dialog.d.ts.map +1 -1
  76. package/dist/components/Spinner.d.ts.map +1 -1
  77. package/dist/components/Table.d.ts +11 -0
  78. package/dist/components/Table.d.ts.map +1 -0
  79. package/dist/components/Tabs.d.ts.map +1 -1
  80. package/dist/components/Tooltip.d.ts.map +1 -1
  81. package/dist/components/button/Button.d.ts.map +1 -1
  82. package/dist/components/index.js +29 -29
  83. package/dist/constants/fileUploadPresets.d.ts +4 -2
  84. package/dist/constants/fileUploadPresets.d.ts.map +1 -1
  85. package/dist/index.css +1 -1
  86. package/dist/index.js +75 -75
  87. package/dist/membership/components/Button.d.ts.map +1 -1
  88. package/dist/membership/components/Container.d.ts.map +1 -1
  89. package/dist/membership/components/Core.d.ts.map +1 -1
  90. package/dist/membership/index.js +2 -3
  91. package/dist/page-BKyDlf0z.js +212 -0
  92. package/dist/utils/errorHandler.d.ts.map +1 -1
  93. package/package.json +12 -11
  94. package/dist/CheckboxWidget-BctVOZiO.js +0 -118
  95. package/dist/CollectionFormBuilder-B6CAVKhg.js +0 -772
  96. package/dist/DefaultFormVariant-C6zbKgwB.js +0 -80
  97. package/dist/DropdownWidget-DszCTSWr.js +0 -115
  98. package/dist/GeocoderWidget-CXu17A7y.js +0 -310
  99. package/dist/LevoProvider-BI6g_T4E.js +0 -212
  100. package/dist/Spinner-DzGH5rKe.js +0 -297
  101. package/dist/Tooltip-CI4i4mYr.js +0 -144
  102. package/dist/UploadWidget-ZebPWZZZ.js +0 -505
  103. package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts.map +0 -1
  104. package/dist/fileUploadPresets-2raQmHT0.js +0 -74
  105. package/dist/page-yeiAPg3O.js +0 -200
  106. package/dist/useLevoForm-DjvUas25.js +0 -166
@@ -0,0 +1,1199 @@
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 { X as Fe } from "lucide-react";
9
+ import { u as X } from "./LevoProvider-BAZy7_tP.js";
10
+ import { Snowflake as Pe } from "@theinternetfolks/snowflake";
11
+ import Ee from "google-libphonenumber";
12
+ import re from "validator";
13
+ import z from "validatorjs";
14
+ import { c as b } from "./cn-C9QoOYNG.js";
15
+ import { Mate as Q } from "@theinternetfolks/mate";
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 } = Ee, 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-${Pe.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 (delete t.__captcha, 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((f) => {
304
+ const k = {
305
+ ...f,
306
+ key: `${t}.${d}.${f == null ? void 0 : f.key}`
307
+ };
308
+ return /* @__PURE__ */ s.jsx(
309
+ ve,
310
+ {
311
+ field: k,
312
+ isInternal: n
313
+ },
314
+ `common-fields-${f == null ? void 0 : f.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 }), J = 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
+ ));
449
+ J.displayName = "FieldWrapper";
450
+ const he = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
451
+ "table",
452
+ {
453
+ ref: t,
454
+ className: b("w-full caption-bottom text-sm", e),
455
+ ...n
456
+ }
457
+ ));
458
+ he.displayName = "Table";
459
+ const at = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx("thead", { ref: t, className: b("[&_tr]:border-b", e), ...n }));
460
+ at.displayName = "TableHeader";
461
+ const ye = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
462
+ "tbody",
463
+ {
464
+ ref: t,
465
+ className: b("[&_tr:last-child]:border-0", e),
466
+ ...n
467
+ }
468
+ ));
469
+ ye.displayName = "TableBody";
470
+ const lt = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
471
+ "tfoot",
472
+ {
473
+ ref: t,
474
+ className: b("bg-primary font-medium text-primary-foreground", e),
475
+ ...n
476
+ }
477
+ ));
478
+ lt.displayName = "TableFooter";
479
+ const fe = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
480
+ "tr",
481
+ {
482
+ ref: t,
483
+ className: b(
484
+ "border-b transition-colors data-[state=selected]:bg-muted",
485
+ e
486
+ ),
487
+ ...n
488
+ }
489
+ ));
490
+ fe.displayName = "TableRow";
491
+ const it = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
492
+ "th",
493
+ {
494
+ ref: t,
495
+ className: b(
496
+ "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
497
+ e
498
+ ),
499
+ ...n
500
+ }
501
+ ));
502
+ it.displayName = "TableHead";
503
+ const je = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
504
+ "td",
505
+ {
506
+ ref: t,
507
+ className: b("p-4 align-middle [&:has([role=checkbox])]:pr-0", e),
508
+ ...n
509
+ }
510
+ ));
511
+ je.displayName = "TableCell";
512
+ const ct = A.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx(
513
+ "caption",
514
+ {
515
+ ref: t,
516
+ className: b("mt-4 text-sm text-muted-foreground", e),
517
+ ...n
518
+ }
519
+ ));
520
+ ct.displayName = "TableCaption";
521
+ const dt = E.lazy(
522
+ () => import("react-select-async-paginate").then((e) => ({
523
+ default: e.AsyncPaginate
524
+ }))
525
+ ), be = (e) => /* @__PURE__ */ s.jsx(
526
+ dt,
527
+ {
528
+ isClearable: !0,
529
+ menuPlacement: "auto",
530
+ isSearchable: !0,
531
+ unstyled: !0,
532
+ classNames: {
533
+ container: () => b("w-full min-w-none h-auto min-h-none"),
534
+ control: ({ isFocused: n, isMulti: t, isDisabled: r }) => b(
535
+ "w-full pl-3",
536
+ t ? "!min-h-9 h-auto" : "h-9 !min-h-none",
537
+ "rounded-md border bg-transparent hover:cursor-pointer border-input text-sm shadow-sm transition-colors",
538
+ "flex ",
539
+ n && "outline-none ring-1 ring-ring",
540
+ r && "cursor-not-allowed opacity-50"
541
+ ),
542
+ input: () => "",
543
+ valueContainer: () => "gap-[4px] py-1",
544
+ singleValue: () => "",
545
+ multiValue: () => "bg-gray-100 rounded items-center py-0.5 pl-2 pr-1 gap-1.5",
546
+ multiValueLabel: () => "py-0.5",
547
+ multiValueRemove: () => "border border-gray-200 bg-white hover:bg-red-50 hover:text-red-800 text-gray-500 hover:border-red-300 rounded-md",
548
+ indicatorsContainer: () => "",
549
+ clearIndicator: () => "text-gray-500 p-1 rounded-md hover:bg-red-50 hover:text-red-800",
550
+ indicatorSeparator: () => "",
551
+ dropdownIndicator: () => "p-1 hover:bg-gray-100 text-gray-500 rounded-md hover:text-black",
552
+ menu: () => "p-1 mt-2 border border-gray-200 bg-white rounded-md",
553
+ groupHeading: () => "ml-3 mt-2 mb-1 text-gray-500 text-sm",
554
+ placeholder: () => "text-gray-500 pl-1 py-0.5",
555
+ option: ({ isSelected: n, isFocused: t }) => b(
556
+ "text-[.875rem] font-medium hover:cursor-pointer px-3 py-2 rounded",
557
+ t && "bg-gray-100 active:bg-gray-200",
558
+ n && "text-white bg-primary/80"
559
+ ),
560
+ noOptionsMessage: () => "text-gray-500 p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm"
561
+ },
562
+ ...e
563
+ }
564
+ ), ut = ({
565
+ field: e,
566
+ value: n,
567
+ onChange: t
568
+ }) => {
569
+ var S, y;
570
+ const { collection: r } = X(), [c, g] = w(!1), [a, o] = w([]), [i, m] = w(!1), {
571
+ key: x = "",
572
+ label: d = "items",
573
+ helper_text: f = "",
574
+ readonly: k = !1
575
+ } = e, C = x, B = ((S = e == null ? void 0 : e.options) == null ? void 0 : S.collection_key) || "", _ = ((y = e == null ? void 0 : e.options) == null ? void 0 : y.label_field_key) || "", I = async (j, N, { page: R = 1 }) => {
576
+ var F;
577
+ g(!0);
578
+ try {
579
+ const L = await (r == null ? void 0 : r.getCollectionContentList({
580
+ collection_key: B,
581
+ page: R,
582
+ search: j,
583
+ limit: 10,
584
+ where: {
585
+ _id: {
586
+ not_in: n
587
+ }
588
+ }
589
+ })), h = (F = L == null ? void 0 : L.content) == null ? void 0 : F.data, O = (h || []).map((p) => {
590
+ const P = p != null && p[_] ? p == null ? void 0 : p[_] : Q.toTitle((p == null ? void 0 : p.slug) || "");
591
+ return {
592
+ value: {
593
+ _id: p == null ? void 0 : p._id,
594
+ slug: p == null ? void 0 : p.slug,
595
+ [_]: p == null ? void 0 : p[_]
596
+ },
597
+ label: P
598
+ };
599
+ });
600
+ return {
601
+ options: Array.isArray(O) ? O : [],
602
+ hasMore: h && !((h == null ? void 0 : h.length) < 10),
603
+ additional: {
604
+ page: R + 1
605
+ }
606
+ };
607
+ } catch {
608
+ return {
609
+ options: [],
610
+ hasMore: !1,
611
+ additional: {
612
+ page: R
613
+ }
614
+ };
615
+ } finally {
616
+ g(!1);
617
+ }
618
+ };
619
+ return /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
620
+ /* @__PURE__ */ s.jsxs(W, { size: "xs", onClick: () => m(!0), children: [
621
+ "Select more ",
622
+ d
623
+ ] }),
624
+ /* @__PURE__ */ s.jsxs(
625
+ De,
626
+ {
627
+ title: "Select more items",
628
+ isOpen: i,
629
+ onClose: () => m(!1),
630
+ contentClassName: "max-w-96",
631
+ children: [
632
+ /* @__PURE__ */ s.jsxs(J, { helperText: f, readOnly: k, children: [
633
+ d && /* @__PURE__ */ s.jsx(q, { htmlFor: C, children: d }),
634
+ /* @__PURE__ */ s.jsx(
635
+ be,
636
+ {
637
+ id: C,
638
+ value: a,
639
+ onChange: (j) => {
640
+ o(j);
641
+ },
642
+ isMulti: !0,
643
+ loadOptions: I,
644
+ debounceTimeout: 500,
645
+ getOptionLabel: (j) => j == null ? void 0 : j.label,
646
+ getOptionValue: (j) => j == null ? void 0 : j.value,
647
+ isLoading: c,
648
+ additional: {
649
+ page: 1
650
+ },
651
+ cacheUniqs: [B],
652
+ minMenuHeight: 250
653
+ }
654
+ )
655
+ ] }),
656
+ /* @__PURE__ */ s.jsx(
657
+ W,
658
+ {
659
+ className: "mt-4",
660
+ onClick: () => {
661
+ t([
662
+ ...n,
663
+ ...(a ?? []).map((j) => {
664
+ var N;
665
+ return (N = j == null ? void 0 : j.value) == null ? void 0 : N._id;
666
+ })
667
+ ]), m(!1);
668
+ },
669
+ children: "Add"
670
+ }
671
+ )
672
+ ]
673
+ }
674
+ )
675
+ ] });
676
+ }, gt = ({
677
+ field: e
678
+ }) => {
679
+ var T, M, V;
680
+ const { collection: n } = X(), [t, r] = w(!1), [c, g] = w([]), [a, o] = w(1), [i, m] = w(0), [x, d] = w(0), { key: f = "", label: k = "", helper_text: C = "", readonly: B = !1 } = e, _ = f, 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) || "", {
681
+ field: { value: y, onBlur: j, onChange: N, ref: R, disabled: F, ...L },
682
+ fieldState: h
683
+ } = me({
684
+ name: _,
685
+ rules: xe(e)
686
+ }), O = !!(e != null && e.required), p = (V = h == null ? void 0 : h.error) == null ? void 0 : V.message, P = async () => {
687
+ var Y, ee, te, se, ne;
688
+ r(!0);
689
+ const u = await (n == null ? void 0 : n.getCollectionContentList({
690
+ collection_key: I,
691
+ page: a,
692
+ limit: 5,
693
+ where: {
694
+ _id: {
695
+ in: y
696
+ }
697
+ }
698
+ })), 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;
699
+ 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);
700
+ };
701
+ return ge(() => {
702
+ (y == null ? void 0 : y.length) > 0 && P();
703
+ }, [y, a]), /* @__PURE__ */ s.jsxs(
704
+ J,
705
+ {
706
+ ref: R,
707
+ error: p,
708
+ helperText: C,
709
+ readOnly: B,
710
+ children: [
711
+ k && /* @__PURE__ */ s.jsx(q, { htmlFor: _, isRequired: O, children: k }),
712
+ /* @__PURE__ */ s.jsx(
713
+ ut,
714
+ {
715
+ onChange: N,
716
+ value: y ?? [],
717
+ field: e
718
+ }
719
+ ),
720
+ y != null && y.length ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
721
+ /* @__PURE__ */ s.jsxs("div", { className: "relative overflow-hidden", children: [
722
+ 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: [
723
+ /* @__PURE__ */ s.jsx(Be, { className: "h-8 w-8 animate-spin mr-2" }),
724
+ "Fetching"
725
+ ] }) }) : null,
726
+ /* @__PURE__ */ s.jsx(he, { className: y.length > 5 ? "min-h-72" : "", children: /* @__PURE__ */ s.jsx(ye, { children: c.map((u) => /* @__PURE__ */ s.jsx(fe, { children: /* @__PURE__ */ s.jsxs(je, { className: "flex justify-between", children: [
727
+ u == null ? void 0 : u[S],
728
+ /* @__PURE__ */ s.jsx(
729
+ Fe,
730
+ {
731
+ className: "cursor-pointer",
732
+ size: 20,
733
+ onClick: () => {
734
+ console.log(
735
+ y,
736
+ y == null ? void 0 : y.filter((D) => D !== (u == null ? void 0 : u._id)),
737
+ u
738
+ ), N(
739
+ y == null ? void 0 : y.filter((D) => D !== (u == null ? void 0 : u._id))
740
+ );
741
+ }
742
+ }
743
+ )
744
+ ] }) }, u == null ? void 0 : u._id)) }) })
745
+ ] }),
746
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between px-2", children: [
747
+ /* @__PURE__ */ s.jsxs("div", { className: "flex-1 text-sm text-muted-foreground", children: [
748
+ "Showing",
749
+ " ",
750
+ i ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
751
+ 5 * (a - 1) + 1,
752
+ "-",
753
+ Math.min(5 * a, i),
754
+ " of",
755
+ " "
756
+ ] }) : null,
757
+ " ",
758
+ i,
759
+ " items"
760
+ ] }),
761
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
762
+ /* @__PURE__ */ s.jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
763
+ "Page ",
764
+ a,
765
+ " of ",
766
+ x
767
+ ] }),
768
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center space-x-2", children: [
769
+ /* @__PURE__ */ s.jsxs(
770
+ W,
771
+ {
772
+ onClick: () => o(1),
773
+ disabled: a === 1,
774
+ variant: "outline",
775
+ className: "hidden h-8 w-8 p-0 lg:flex",
776
+ children: [
777
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to first page" }),
778
+ /* @__PURE__ */ s.jsx(st, { className: "h-4 w-4" })
779
+ ]
780
+ }
781
+ ),
782
+ /* @__PURE__ */ s.jsxs(
783
+ W,
784
+ {
785
+ disabled: a === 1,
786
+ onClick: () => o(a - 1),
787
+ variant: "outline",
788
+ className: "h-8 w-8 p-0",
789
+ children: [
790
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to previous page" }),
791
+ /* @__PURE__ */ s.jsx(et, { className: "h-4 w-4" })
792
+ ]
793
+ }
794
+ ),
795
+ /* @__PURE__ */ s.jsxs(
796
+ W,
797
+ {
798
+ onClick: () => o(a + 1),
799
+ disabled: a === x,
800
+ variant: "outline",
801
+ className: "h-8 w-8 p-0",
802
+ children: [
803
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to next page" }),
804
+ /* @__PURE__ */ s.jsx(tt, { className: "h-4 w-4" })
805
+ ]
806
+ }
807
+ ),
808
+ /* @__PURE__ */ s.jsxs(
809
+ W,
810
+ {
811
+ onClick: () => o(x),
812
+ disabled: a === x,
813
+ variant: "outline",
814
+ className: "hidden h-8 w-8 p-0 lg:flex",
815
+ children: [
816
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to last page" }),
817
+ /* @__PURE__ */ s.jsx(nt, { className: "h-4 w-4" })
818
+ ]
819
+ }
820
+ )
821
+ ] })
822
+ ] })
823
+ ] })
824
+ ] }) : null
825
+ ]
826
+ }
827
+ );
828
+ }, mt = ({
829
+ field: e
830
+ }) => {
831
+ var R, F, L;
832
+ 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) || "", {
833
+ field: { value: d, onBlur: f, onChange: k, ref: C, disabled: B, ..._ },
834
+ fieldState: I
835
+ } = me({
836
+ name: i,
837
+ rules: xe(e)
838
+ }), S = !!(e != null && e.required), y = (L = I == null ? void 0 : I.error) == null ? void 0 : L.message, j = async (h, O, { page: p = 1 }) => {
839
+ var P;
840
+ r(!0);
841
+ try {
842
+ const T = await (n == null ? void 0 : n.getCollectionContentList({
843
+ collection_key: m,
844
+ page: p,
845
+ search: h,
846
+ limit: 10
847
+ })), M = (P = T == null ? void 0 : T.content) == null ? void 0 : P.data, V = (M || []).map((u) => {
848
+ const D = u != null && u[x] ? u == null ? void 0 : u[x] : Q.toTitle((u == null ? void 0 : u.slug) || "");
849
+ return {
850
+ value: {
851
+ _id: u == null ? void 0 : u._id,
852
+ slug: u == null ? void 0 : u.slug,
853
+ [x]: u == null ? void 0 : u[x]
854
+ },
855
+ label: D
856
+ };
857
+ });
858
+ return {
859
+ options: Array.isArray(V) ? V : [],
860
+ hasMore: M && !((M == null ? void 0 : M.length) < 10),
861
+ additional: {
862
+ page: p + 1
863
+ }
864
+ };
865
+ } catch {
866
+ return {
867
+ options: [],
868
+ hasMore: !1,
869
+ additional: {
870
+ page: p
871
+ }
872
+ };
873
+ } finally {
874
+ r(!1);
875
+ }
876
+ }, N = d ? {
877
+ label: d != null && d[x] ? d == null ? void 0 : d[x] : d != null && d.slug ? Q.toTitle((d == null ? void 0 : d.slug) || "") : "",
878
+ value: {
879
+ _id: d == null ? void 0 : d._id,
880
+ slug: d == null ? void 0 : d.slug,
881
+ [x]: d == null ? void 0 : d[x]
882
+ }
883
+ } : null;
884
+ return /* @__PURE__ */ s.jsxs(
885
+ J,
886
+ {
887
+ ref: C,
888
+ error: y,
889
+ helperText: a,
890
+ readOnly: o,
891
+ children: [
892
+ g && /* @__PURE__ */ s.jsx(q, { htmlFor: i, isRequired: S, children: g }),
893
+ /* @__PURE__ */ s.jsx(
894
+ be,
895
+ {
896
+ id: i,
897
+ value: N,
898
+ onChange: (h) => {
899
+ k((h == null ? void 0 : h.value) || null);
900
+ },
901
+ onBlur: () => {
902
+ f();
903
+ },
904
+ loadOptions: j,
905
+ debounceTimeout: 500,
906
+ getOptionLabel: (h) => h == null ? void 0 : h.label,
907
+ getOptionValue: (h) => h == null ? void 0 : h.value,
908
+ isLoading: t,
909
+ additional: {
910
+ page: 1
911
+ },
912
+ cacheUniqs: [m],
913
+ minMenuHeight: 250,
914
+ isDisabled: B,
915
+ ..._
916
+ }
917
+ )
918
+ ]
919
+ }
920
+ );
921
+ }, pt = v(
922
+ () => import("./MultiTextWidget-CZzT51cH.js")
923
+ ), ie = v(() => import("./TextWidget-ldbMuLB0.js")), xt = v(
924
+ () => import("./CurrencyWidget-Cu1Cthnw.js")
925
+ ), ht = v(
926
+ () => import("./CheckboxWidget-CNoS-2W3.js")
927
+ ), ce = v(
928
+ () => import("./DateTimeWidget-N-wuCRSJ.js")
929
+ ), de = v(
930
+ () => import("./DropdownWidget-BFttB4b-.js")
931
+ ), yt = v(() => import("./EmailWidget-D_SqXx3M.js")), ft = v(
932
+ () => import("./GeocoderWidget-Bxt3TeAf.js")
933
+ ), jt = v(
934
+ () => import("./MultiGeocoderWidget-DFjuXZBN.js")
935
+ ), bt = v(() => import("./PhoneWidget--K5aS16s.js")), vt = v(() => import("./RadioWidget-BbMPtR3P.js")), Ct = v(
936
+ () => import("./RichTextWidget-Cce3Bw8d.js")
937
+ ), wt = v(() => import("./SwitchWidget-B0wkSWxa.js")), kt = v(
938
+ () => import("./TextareaWidget-S8bKUTv0.js")
939
+ ), Wt = v(
940
+ () => import("./ToggleCheckboxWidget-CPduXE6Y.js")
941
+ ), _t = v(() => import("./URLWidget-KbhE2ZUA.js")), K = v(() => import("./UploadWidget-DFvfDUT6.js")), Nt = ({
942
+ field: e,
943
+ isInternal: n
944
+ }) => {
945
+ var c, g, a, o, i, m;
946
+ const { field_interface: t, key: r } = e;
947
+ if (!t || !r)
948
+ return null;
949
+ switch (t) {
950
+ case l.TextWidget:
951
+ return /* @__PURE__ */ s.jsx(ie, { field: e });
952
+ case l.NumberWidget:
953
+ return /* @__PURE__ */ s.jsx(ie, { type: "number", field: e });
954
+ case l.CurrencyWidget:
955
+ return /* @__PURE__ */ s.jsx(xt, { field: e });
956
+ case l.CheckboxWidget:
957
+ return /* @__PURE__ */ s.jsx(ht, { field: e });
958
+ case l.DateTimeWidget:
959
+ return /* @__PURE__ */ s.jsx(ce, { field: e });
960
+ case l.DateWidget:
961
+ return /* @__PURE__ */ s.jsx(ce, { field: e });
962
+ case l.DropdownWidget:
963
+ return /* @__PURE__ */ s.jsx(de, { field: e, isMulti: !1 });
964
+ case l.MultiDropdownWidget:
965
+ return /* @__PURE__ */ s.jsx(de, { field: e, isMulti: !0 });
966
+ case l.MultiTextWidget:
967
+ return /* @__PURE__ */ s.jsx(pt, { field: e });
968
+ case l.EmailWidget:
969
+ return /* @__PURE__ */ s.jsx(yt, { field: e });
970
+ case l.GeocoderWidget:
971
+ return /* @__PURE__ */ s.jsx(ft, { field: e });
972
+ case l.MultiGeocoderWidget:
973
+ return /* @__PURE__ */ s.jsx(jt, { field: e });
974
+ case l.PhoneWidget:
975
+ return /* @__PURE__ */ s.jsx(bt, { field: e });
976
+ case l.RadioWidget:
977
+ return /* @__PURE__ */ s.jsx(vt, { field: e });
978
+ case l.RichTextWidget:
979
+ return /* @__PURE__ */ s.jsx(Ct, { field: e });
980
+ case l.SwitchWidget:
981
+ return /* @__PURE__ */ s.jsx(wt, { field: e });
982
+ case l.TextareaWidget:
983
+ return /* @__PURE__ */ s.jsx(kt, { field: e });
984
+ case l.ToggleCheckboxWidget:
985
+ return /* @__PURE__ */ s.jsx(Wt, { field: e });
986
+ case l.URLWidget:
987
+ return /* @__PURE__ */ s.jsx(_t, { field: e });
988
+ case l.ImageUploadWidget:
989
+ return /* @__PURE__ */ s.jsx(
990
+ K,
991
+ {
992
+ field: e,
993
+ isMultiple: !1,
994
+ kind: ["image"],
995
+ isExternal: !n
996
+ }
997
+ );
998
+ case l.MultiImageUploadWidget:
999
+ return /* @__PURE__ */ s.jsx(
1000
+ K,
1001
+ {
1002
+ field: e,
1003
+ isMultiple: !0,
1004
+ kind: ["image"],
1005
+ isExternal: !n
1006
+ }
1007
+ );
1008
+ case l.FileUploadWidget:
1009
+ return /* @__PURE__ */ s.jsx(
1010
+ K,
1011
+ {
1012
+ field: e,
1013
+ isMultiple: !1,
1014
+ kind: ["audio", "video", "image", "document"],
1015
+ isExternal: !n
1016
+ }
1017
+ );
1018
+ case l.MultiFileUploadWidget:
1019
+ return /* @__PURE__ */ s.jsx(
1020
+ K,
1021
+ {
1022
+ field: e,
1023
+ isMultiple: !0,
1024
+ kind: ["audio", "video", "image", "document"],
1025
+ isExternal: !n
1026
+ }
1027
+ );
1028
+ case l.CollectionWidget:
1029
+ 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(
1030
+ "[LevoCollection]: Error while rendering collection widget. Collection key of label field key is required."
1031
+ ), null) : (
1032
+ /**
1033
+ * @context
1034
+ *
1035
+ * this includes both `o2m` and `m2m` relationships, which if rendered
1036
+ * should be using a multi-select dropdown widget
1037
+ *
1038
+ *
1039
+ * @todo
1040
+ * but, if such a field exist, we should be handling that with a modal or a drawer widget
1041
+ * which renders a table with a multi-row select.
1042
+ *
1043
+ * the selected row, would then become connected to the current row.
1044
+ *
1045
+ * e.g.: `blog` collection key can have an `o2m` relationship with `post` collection key
1046
+ *
1047
+ * in this case, the `post` collection key should be rendered as a widget which shows count of posts
1048
+ * and on clicking which actually opens a modal or a drawer widget which renders a table with a multi-row select
1049
+ *
1050
+ */
1051
+ (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 })
1052
+ );
1053
+ default:
1054
+ return null;
1055
+ }
1056
+ }, Rt = ({
1057
+ field: e,
1058
+ isInternal: n
1059
+ }) => {
1060
+ const { key: t = "", label: r = "", field_interface: c = "", fields: g = [] } = e;
1061
+ return !c || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full", children: [
1062
+ /* @__PURE__ */ s.jsx(q, { children: r }),
1063
+ /* @__PURE__ */ s.jsx("div", { className: "border rounded bg-secondary/40 flex flex-col px-3 py-4 gap-3", children: g.map((a) => {
1064
+ const o = {
1065
+ ...a,
1066
+ key: `${t}.${a == null ? void 0 : a.key}`
1067
+ };
1068
+ return /* @__PURE__ */ s.jsx(
1069
+ ve,
1070
+ {
1071
+ field: o,
1072
+ isInternal: n
1073
+ },
1074
+ `common-fields-${e == null ? void 0 : e.id}-${a == null ? void 0 : a.id}`
1075
+ );
1076
+ }) })
1077
+ ] });
1078
+ }, ve = (e) => {
1079
+ const { field_interface: n = "", key: t = "" } = e.field;
1080
+ if (!n || !t)
1081
+ return null;
1082
+ switch (n) {
1083
+ case l.ArrayWidget:
1084
+ return /* @__PURE__ */ s.jsx(Ye, { ...e });
1085
+ case l.RecordWidget:
1086
+ return /* @__PURE__ */ s.jsx(Rt, { ...e });
1087
+ default:
1088
+ return /* @__PURE__ */ s.jsx(Nt, { ...e });
1089
+ }
1090
+ }, Ce = E.createContext({
1091
+ schema: null,
1092
+ submitButtonConfig: {
1093
+ show: !0
1094
+ }
1095
+ }), Lt = ({
1096
+ children: e,
1097
+ ...n
1098
+ }) => {
1099
+ const { schema: t, onFormView: r } = n, { ref: c } = Oe({
1100
+ triggerOnce: !0,
1101
+ onChange: (g) => {
1102
+ g && (t != null && t.id) && r && r({ schemaId: t.id });
1103
+ }
1104
+ });
1105
+ return /* @__PURE__ */ s.jsxs(Ce.Provider, { value: { ...n }, children: [
1106
+ /* @__PURE__ */ s.jsx("div", { ref: c }),
1107
+ e
1108
+ ] });
1109
+ }, ns = () => E.useContext(Ce), Tt = E.lazy(
1110
+ () => import("./DefaultFormVariant-IqWi1BiT.js")
1111
+ ), Mt = E.lazy(
1112
+ () => import("./StepsFormVariant-5wZbYAA9.js")
1113
+ ), At = ({
1114
+ formVariant: e,
1115
+ ...n
1116
+ }) => {
1117
+ const { schema: t, uiConfig: r } = n;
1118
+ return /* @__PURE__ */ s.jsxs(Lt, { ...n, children: [
1119
+ r != null && r.hideFormHeading ? null : /* @__PURE__ */ s.jsxs(
1120
+ "h1",
1121
+ {
1122
+ className: b(
1123
+ "text-2xl text-left text-black mb-4 font-semibold",
1124
+ e === "default" ? "ml-[32%]" : "ml-0"
1125
+ ),
1126
+ children: [
1127
+ "Create new ",
1128
+ He.singularize((t == null ? void 0 : t.name) || "")
1129
+ ]
1130
+ }
1131
+ ),
1132
+ /* @__PURE__ */ s.jsx(_e, { children: e === "steps" ? /* @__PURE__ */ s.jsx(Mt, {}) : /* @__PURE__ */ s.jsx(Tt, {}) })
1133
+ ] });
1134
+ }, rs = ({
1135
+ collection_id: e,
1136
+ hiddenFields: n,
1137
+ ...t
1138
+ }) => {
1139
+ const { collection: r } = X(), [c, g] = w(!0), [a, o] = w(null);
1140
+ return ge(() => {
1141
+ e ? r == null || r.getCollectionByIDExpanded(e, {
1142
+ headers: {
1143
+ "Levo-Workspace": t == null ? void 0 : t.workspace_id
1144
+ }
1145
+ }).then((i) => {
1146
+ var x, d;
1147
+ const m = (x = i == null ? void 0 : i.content) == null ? void 0 : x.data;
1148
+ if (m)
1149
+ m.sections = (d = m == null ? void 0 : m.sections) == null ? void 0 : d.map(
1150
+ (f) => {
1151
+ var k;
1152
+ return f.fields = (k = f == null ? void 0 : f.fields) == null ? void 0 : k.map((C) => (n != null && n.includes(C == null ? void 0 : C.key) && (C.hidden = !0), C)), f;
1153
+ }
1154
+ ), o(m);
1155
+ else
1156
+ throw new Error(`API response invalid: ${m}`);
1157
+ }).catch((i) => {
1158
+ console.error("Error fetching schema", i);
1159
+ }).finally(() => {
1160
+ g(!1);
1161
+ }) : (console.error(
1162
+ "[CollectionFormBuilder] Collection ID or Workspace ID is missing."
1163
+ ), g(!1));
1164
+ }, [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 });
1165
+ };
1166
+ export {
1167
+ J as A,
1168
+ q as B,
1169
+ rs as C,
1170
+ ns as D,
1171
+ ve as F,
1172
+ ss as H,
1173
+ pe as a,
1174
+ U as b,
1175
+ Xt as c,
1176
+ ae as d,
1177
+ Je as e,
1178
+ Jt as f,
1179
+ ts as g,
1180
+ es as h,
1181
+ Qe as i,
1182
+ Ve as j,
1183
+ ze as k,
1184
+ $e as l,
1185
+ Ue as m,
1186
+ qe as n,
1187
+ Ge as o,
1188
+ oe as p,
1189
+ Ze as q,
1190
+ Ke as r,
1191
+ Yt as s,
1192
+ $ as t,
1193
+ Qt as u,
1194
+ Kt as v,
1195
+ Z as w,
1196
+ Gt as x,
1197
+ Zt as y,
1198
+ xe as z
1199
+ };