@levo-so/react 0.1.36 → 0.1.40

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 (191) hide show
  1. package/dist/{Sonner-t6JVKA0a.js → Sonner-5IAqCkBs.js} +12 -9
  2. package/dist/Tooltip-DcdGb876.js +383 -0
  3. package/dist/audience/components/block.d.ts.map +1 -1
  4. package/dist/audience/components/component.d.ts +2 -2
  5. package/dist/audience/components/component.d.ts.map +1 -1
  6. package/dist/audience/components/page.d.ts.map +1 -1
  7. package/dist/audience/hooks/useBounce.d.ts +4 -0
  8. package/dist/audience/hooks/useBounce.d.ts.map +1 -0
  9. package/dist/audience/hooks/useCurrentTab.d.ts.map +1 -1
  10. package/dist/audience/hooks/useDownloadSpeed.d.ts.map +1 -1
  11. package/dist/audience/hooks/useIdentifyAudience.d.ts +7 -0
  12. package/dist/audience/hooks/useIdentifyAudience.d.ts.map +1 -0
  13. package/dist/audience/hooks/useOpenTabs.d.ts.map +1 -1
  14. package/dist/audience/hooks/usePerformanceMetrics.d.ts.map +1 -1
  15. package/dist/audience/index.js +1 -1
  16. package/dist/audience/utils/autocapture.d.ts.map +1 -1
  17. package/dist/components/Sonner.d.ts.map +1 -1
  18. package/dist/components/Spinner.d.ts.map +1 -1
  19. package/dist/components/button/buttonVariants.d.ts +1 -1
  20. package/dist/components/button/buttonVariants.d.ts.map +1 -1
  21. package/dist/components/index.js +20 -21
  22. package/dist/index.css +1 -1
  23. package/dist/index.d.ts +0 -1
  24. package/dist/index.js +121 -83
  25. package/dist/isEmptyObject-B9yh0nbg.js +19 -0
  26. package/dist/{jsx-runtime-B6kdoens.js → jsx-runtime-D0AQ1Mn7.js} +216 -217
  27. package/dist/membership/index.d.ts +1 -1
  28. package/dist/membership/index.d.ts.map +1 -1
  29. package/dist/membership/index.js +1 -1
  30. package/dist/page-DweUjn1K.js +627 -0
  31. package/dist/providers/index.js +1 -1
  32. package/dist/utils/byteToSize.d.ts.map +1 -1
  33. package/dist/utils/cn.d.ts.map +1 -1
  34. package/dist/utils/errorHandler.d.ts.map +1 -1
  35. package/dist/utils/index.js +10 -12
  36. package/dist/utils/isDateObject.d.ts.map +1 -1
  37. package/dist/utils/isEmptyObject.d.ts.map +1 -1
  38. package/dist/utils/isNullOrUndefined.d.ts.map +1 -1
  39. package/dist/utils/isObject.d.ts.map +1 -1
  40. package/package.json +7 -12
  41. package/dist/Checbox-sq-atGlJ.js +0 -28
  42. package/dist/CheckboxWidget-3qTjxIlp.js +0 -124
  43. package/dist/CollectionFormBuilder-CUzpwIva.js +0 -1195
  44. package/dist/CurrencyWidget-DgH4uCpg.js +0 -60
  45. package/dist/DateTimeWidget-C2hLHKU6.js +0 -80
  46. package/dist/DefaultFormVariant-Cm9i2BBn.js +0 -81
  47. package/dist/DropdownWidget-B6mRXcTa.js +0 -115
  48. package/dist/EmailWidget-CBFnvo9z.js +0 -41
  49. package/dist/FormCaptcha-btA0HfMx.js +0 -187
  50. package/dist/GeocoderWidget-DZGXm9Ji.js +0 -68
  51. package/dist/Input-Vv7mKQFt.js +0 -54
  52. package/dist/MultiGeocoderWidget-D7ogTcWu.js +0 -49
  53. package/dist/MultiTextWidget-DYxi8PHm.js +0 -33
  54. package/dist/PhoneWidget-BxaGCfLs.js +0 -48
  55. package/dist/RadioWidget-Bkq1Oudi.js +0 -109
  56. package/dist/RichTextWidget-Caqhw4GK.js +0 -310
  57. package/dist/Spinner-BcBoT-J5.js +0 -410
  58. package/dist/StepsFormVariant-D-m93LMv.js +0 -140
  59. package/dist/SwitchWidget-BpAzgVui.js +0 -53
  60. package/dist/TextWidget-CHkFlxmT.js +0 -33
  61. package/dist/TextareaWidget-B0htlijX.js +0 -30
  62. package/dist/ToggleCheckboxWidget-DLrS6ax4.js +0 -44
  63. package/dist/Tooltip-DoWyn3Ho.js +0 -37
  64. package/dist/URLWidget-CnWKNlOF.js +0 -14
  65. package/dist/UploadWidget-DSvWOBuR.js +0 -656
  66. package/dist/byteToSize-BFKZSBu1.js +0 -8
  67. package/dist/cn-C9QoOYNG.js +0 -6
  68. package/dist/collection/components/Altcha.d.ts +0 -10
  69. package/dist/collection/components/Altcha.d.ts.map +0 -1
  70. package/dist/collection/components/CollectionFormBuilder.d.ts +0 -12
  71. package/dist/collection/components/CollectionFormBuilder.d.ts.map +0 -1
  72. package/dist/collection/components/FieldRenderer.d.ts +0 -9
  73. package/dist/collection/components/FieldRenderer.d.ts.map +0 -1
  74. package/dist/collection/components/FormCaptcha.d.ts +0 -3
  75. package/dist/collection/components/FormCaptcha.d.ts.map +0 -1
  76. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts +0 -5
  77. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +0 -1
  78. package/dist/collection/components/core/Checkbox/Checbox.d.ts +0 -5
  79. package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +0 -1
  80. package/dist/collection/components/core/Input/Input.d.ts +0 -11
  81. package/dist/collection/components/core/Input/Input.d.ts.map +0 -1
  82. package/dist/collection/components/core/Switch/Switch.d.ts +0 -5
  83. package/dist/collection/components/core/Switch/Switch.d.ts.map +0 -1
  84. package/dist/collection/components/renderer/RenderArrayWidget.d.ts +0 -5
  85. package/dist/collection/components/renderer/RenderArrayWidget.d.ts.map +0 -1
  86. package/dist/collection/components/renderer/RenderCommonField.d.ts +0 -5
  87. package/dist/collection/components/renderer/RenderCommonField.d.ts.map +0 -1
  88. package/dist/collection/components/renderer/RenderRecordWidget.d.ts +0 -4
  89. package/dist/collection/components/renderer/RenderRecordWidget.d.ts.map +0 -1
  90. package/dist/collection/components/widgets/ErrorMessage.d.ts +0 -6
  91. package/dist/collection/components/widgets/ErrorMessage.d.ts.map +0 -1
  92. package/dist/collection/components/widgets/FieldWrapper.d.ts +0 -14
  93. package/dist/collection/components/widgets/FieldWrapper.d.ts.map +0 -1
  94. package/dist/collection/components/widgets/FormHelperText.d.ts +0 -6
  95. package/dist/collection/components/widgets/FormHelperText.d.ts.map +0 -1
  96. package/dist/collection/components/widgets/FormLabel.d.ts +0 -8
  97. package/dist/collection/components/widgets/FormLabel.d.ts.map +0 -1
  98. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +0 -8
  99. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +0 -1
  100. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts +0 -7
  101. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +0 -1
  102. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts +0 -7
  103. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts.map +0 -1
  104. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts +0 -8
  105. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +0 -1
  106. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts +0 -9
  107. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +0 -1
  108. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts +0 -8
  109. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +0 -1
  110. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts +0 -9
  111. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +0 -1
  112. package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts +0 -8
  113. package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts.map +0 -1
  114. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts +0 -8
  115. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +0 -1
  116. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts +0 -8
  117. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +0 -1
  118. package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts +0 -7
  119. package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts.map +0 -1
  120. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts +0 -8
  121. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +0 -1
  122. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts +0 -11
  123. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +0 -1
  124. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts +0 -12
  125. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +0 -1
  126. package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts +0 -8
  127. package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts.map +0 -1
  128. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts +0 -9
  129. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +0 -1
  130. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts +0 -8
  131. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +0 -1
  132. package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts +0 -8
  133. package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts.map +0 -1
  134. package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts +0 -11
  135. package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts.map +0 -1
  136. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts +0 -11
  137. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +0 -1
  138. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts +0 -10
  139. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +0 -1
  140. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts +0 -13
  141. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +0 -1
  142. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts +0 -11
  143. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +0 -1
  144. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts +0 -19
  145. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +0 -1
  146. package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts +0 -5
  147. package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts.map +0 -1
  148. package/dist/collection/index.d.ts +0 -5
  149. package/dist/collection/index.d.ts.map +0 -1
  150. package/dist/collection/index.js +0 -20
  151. package/dist/collection/lib/FormBuilder.d.ts +0 -8
  152. package/dist/collection/lib/FormBuilder.d.ts.map +0 -1
  153. package/dist/collection/lib/SaveDraftValues.d.ts +0 -7
  154. package/dist/collection/lib/SaveDraftValues.d.ts.map +0 -1
  155. package/dist/collection/lib/hooks/useLevoForm.d.ts +0 -18
  156. package/dist/collection/lib/hooks/useLevoForm.d.ts.map +0 -1
  157. package/dist/collection/lib/provider/LevoFormProvider.d.ts +0 -9
  158. package/dist/collection/lib/provider/LevoFormProvider.d.ts.map +0 -1
  159. package/dist/collection/lib/variants/DefaultFormVariant.d.ts +0 -3
  160. package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +0 -1
  161. package/dist/collection/lib/variants/StepsFormVariant.d.ts +0 -4
  162. package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +0 -1
  163. package/dist/collection/types/context.d.ts +0 -34
  164. package/dist/collection/types/context.d.ts.map +0 -1
  165. package/dist/collection/types/errors.d.ts +0 -7
  166. package/dist/collection/types/errors.d.ts.map +0 -1
  167. package/dist/collection/types/formVariant.d.ts +0 -18
  168. package/dist/collection/types/formVariant.d.ts.map +0 -1
  169. package/dist/collection/types/forms.d.ts +0 -31
  170. package/dist/collection/types/forms.d.ts.map +0 -1
  171. package/dist/collection/types/index.d.ts +0 -4
  172. package/dist/collection/types/index.d.ts.map +0 -1
  173. package/dist/collection/types/renderer.d.ts +0 -6
  174. package/dist/collection/types/renderer.d.ts.map +0 -1
  175. package/dist/collection/utils/formHelpers.d.ts +0 -48
  176. package/dist/collection/utils/formHelpers.d.ts.map +0 -1
  177. package/dist/collection/utils/getFieldValidations.d.ts +0 -6
  178. package/dist/collection/utils/getFieldValidations.d.ts.map +0 -1
  179. package/dist/collection/utils/index.d.ts +0 -6
  180. package/dist/collection/utils/index.d.ts.map +0 -1
  181. package/dist/collection/utils/schema.d.ts +0 -3
  182. package/dist/collection/utils/schema.d.ts.map +0 -1
  183. package/dist/collection/utils/setFormErrors.d.ts +0 -4
  184. package/dist/collection/utils/setFormErrors.d.ts.map +0 -1
  185. package/dist/collection/utils/storage.d.ts +0 -11
  186. package/dist/collection/utils/storage.d.ts.map +0 -1
  187. package/dist/errorHandler-_34Yv8wA.js +0 -9
  188. package/dist/isEmptyObject-C5s4GzLE.js +0 -8
  189. package/dist/libs.css +0 -1
  190. package/dist/libs.d.ts +0 -1
  191. package/dist/page-C1-z2EsC.js +0 -574
@@ -1,1195 +0,0 @@
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 I 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 P, T as Re, l as Le, m as Te, B as W, n as Me, C as Ie, E as Ae, k as De, o as Be, S as Se } from "./Spinner-BcBoT-J5.js";
8
- import { X as Fe } from "lucide-react";
9
- import { useLevo as X } from "./providers/index.js";
10
- import { Snowflake as Ee } from "@theinternetfolks/snowflake";
11
- import Pe 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 } = 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
- }, ae = Xe.getInstance(), Qe = (e) => {
84
- try {
85
- return ae.isValidNumber(ae.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 o of e.sections)
119
- for (const a of o.fields) {
120
- const i = [];
121
- switch (a.required && i.push("required"), typeof a.max < "u" && a.max !== null && i.push({
122
- max: [a.max]
123
- }), typeof a.min < "u" && a.min !== null && i.push({
124
- min: [a.min]
125
- }), a.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[a.key] = i;
137
- }
138
- const r = pe(n, t), { errors: c } = r, g = {};
139
- return c && c.map((o) => {
140
- g[o.name] = o.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
- }, oe = (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 o = U(g.fields ?? []);
164
- for (const a of g.fields) {
165
- let i = oe(n == null ? void 0 : n[a == null ? void 0 : a.key]);
166
- Array.isArray(i) && (i == null ? void 0 : i.length) > 0 && Array.isArray(a == null ? void 0 : a.values) && ((r = a == null ? void 0 : a.values) == null ? void 0 : r.length) > 0 && !((c = a == null ? void 0 : a.options) != null && c.custom_input) && (i = i == null ? void 0 : i.filter((m) => {
167
- var x;
168
- return (x = a == null ? void 0 : a.values) == null ? void 0 : x.includes(m);
169
- })), t[a.key] = i ?? oe(a == null ? void 0 : a.default_value) ?? o[a.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-${Ee.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 o of n.sections ?? [])
207
- for (const a of o.fields)
208
- a.field_interface === "CollectionWidget" && r.push(a.key);
209
- for (const o of r)
210
- t[o] && typeof t[o] == "object" && (Array.isArray(t[o]) ? t[o] = (g = t[o]) == null ? void 0 : g.filter(
211
- (a) => a
212
- ) : t[o] = t[o][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 P({ 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 P({ 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 flex-1 select-none text-sm font-medium leading-normal text-text-1 peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
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, [o, a] = 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: o, onValueChange: a, className: "w-full", children: [
271
- /* @__PURE__ */ s.jsxs("div", { className: "flex w-full items-center gap-2", children: [
272
- i.length ? /* @__PURE__ */ s.jsx(Le, { className: "h-11 w-1 flex-1 justify-start overflow-x-auto overflow-y-hidden", 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)), a(((i == null ? void 0 : i.length) ?? 0).toString());
289
- },
290
- children: [
291
- /* @__PURE__ */ s.jsx(le, { className: "mr-1 inline-block", 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 rounded border bg-secondary/40",
301
- value: d.toString(),
302
- children: [
303
- /* @__PURE__ */ s.jsx("div", { className: "flex flex-col gap-3 px-3 py-2", 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 items-center border-t p-2", children: [
318
- /* @__PURE__ */ s.jsx(
319
- W,
320
- {
321
- onClick: () => {
322
- a((d - 1).toString()), m.move(d, d - 1);
323
- },
324
- disabled: d === 0,
325
- size: "icon",
326
- className: "h-8 w-8 rounded-full",
327
- children: /* @__PURE__ */ s.jsx(Ie, { size: "24px" })
328
- }
329
- ),
330
- /* @__PURE__ */ s.jsx(
331
- W,
332
- {
333
- className: "text-red-500",
334
- variant: "link",
335
- onClick: () => {
336
- a((d - 1).toString()), m.remove(d);
337
- },
338
- children: "Remove Item"
339
- }
340
- ),
341
- /* @__PURE__ */ s.jsx(
342
- W,
343
- {
344
- className: "h-8 w-8 rounded-full",
345
- onClick: () => {
346
- a((d + 1).toString()), m.move(d, d + 1);
347
- },
348
- disabled: d >= i.length - 1,
349
- size: "icon",
350
- children: /* @__PURE__ */ s.jsx(Ae, { 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)), a("0");
365
- },
366
- children: [
367
- /* @__PURE__ */ s.jsx(le, { className: "mr-1 inline-block", size: "14px" }),
368
- "Add"
369
- ]
370
- }
371
- )
372
- ] });
373
- };
374
- function et(e) {
375
- return P({ 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 P({ 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 P({ 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 P({ 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 a, i;
416
- if ((a = e == null ? void 0 : e.options) != null && a.disableValidation || !c)
417
- return !0;
418
- const g = pe(
419
- {
420
- [e.key]: c
421
- },
422
- {
423
- [e.key]: r
424
- }
425
- ), { errors: o } = g;
426
- return o && (o == null ? void 0 : o.length) > 0 ? (i = o == null ? void 0 : o[0]) == null ? void 0 : i.message : !0;
427
- }
428
- };
429
- }, rt = ({
430
- children: e
431
- }) => /* @__PURE__ */ s.jsx("p", { className: "text-wrap text-xs font-normal text-red-400", children: e }), at = ({
432
- children: e
433
- }) => /* @__PURE__ */ s.jsx("p", { className: b("text-xs font-normal text-text-1"), 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("mt-3 w-full"), children: /* @__PURE__ */ s.jsx(rt, { children: e }) }),
445
- n && /* @__PURE__ */ s.jsx("div", { className: b("mt-3 w-full"), children: /* @__PURE__ */ s.jsx(at, { children: n }) })
446
- ] })
447
- }
448
- ));
449
- J.displayName = "FieldWrapper";
450
- const he = I.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 ot = I.forwardRef(({ className: e, ...n }, t) => /* @__PURE__ */ s.jsx("thead", { ref: t, className: b("[&_tr]:border-b", e), ...n }));
460
- ot.displayName = "TableHeader";
461
- const ye = I.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 = I.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 = I.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 = I.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 = I.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 = I.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 B, f;
570
- const { collection: r } = X(), [c, g] = w(!1), [o, a] = w([]), [i, m] = w(!1), {
571
- key: x = "",
572
- label: d = "items",
573
- helper_text: y = "",
574
- readonly: k = !1
575
- } = e, C = x, D = ((B = e == null ? void 0 : e.options) == null ? void 0 : B.collection_key) || "", _ = ((f = e == null ? void 0 : e.options) == null ? void 0 : f.label_field_key) || "", A = async (j, N, { page: R = 1 }) => {
576
- var S;
577
- g(!0);
578
- try {
579
- const L = await (r == null ? void 0 : r.getCollectionContentList({
580
- collection_key: D,
581
- page: R,
582
- search: j,
583
- limit: 10,
584
- where: {
585
- _id: {
586
- not_in: n
587
- }
588
- }
589
- })), h = (S = L == null ? void 0 : L.content) == null ? void 0 : S.data, H = (h || []).map((p) => {
590
- const F = 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: F
598
- };
599
- });
600
- return {
601
- options: Array.isArray(H) ? H : [],
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: y, 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: o,
639
- onChange: (j) => {
640
- a(j);
641
- },
642
- isMulti: !0,
643
- loadOptions: A,
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: [D],
652
- minMenuHeight: 250
653
- }
654
- )
655
- ] }),
656
- /* @__PURE__ */ s.jsx(
657
- W,
658
- {
659
- className: "mt-4",
660
- onClick: () => {
661
- t([
662
- ...n,
663
- ...(o ?? []).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, O;
680
- const { collection: n } = X(), [t, r] = w(!1), [c, g] = w([]), [o, a] = w(1), [i, m] = w(0), [x, d] = w(0), { key: y = "", label: k = "", helper_text: C = "", readonly: D = !1 } = e, _ = y, A = ((T = e == null ? void 0 : e.options) == null ? void 0 : T.collection_key) || "", B = ((M = e == null ? void 0 : e.options) == null ? void 0 : M.label_field_key) || "", {
681
- field: { value: f, onBlur: j, onChange: N, ref: R, disabled: S, ...L },
682
- fieldState: h
683
- } = me({
684
- name: _,
685
- rules: xe(e)
686
- }), H = !!(e != null && e.required), p = (O = h == null ? void 0 : h.error) == null ? void 0 : O.message, F = async () => {
687
- var Y, ee, te, se, ne;
688
- r(!0);
689
- const u = await (n == null ? void 0 : n.getCollectionContentList({
690
- collection_key: A,
691
- page: o,
692
- limit: 5,
693
- where: {
694
- _id: {
695
- in: f
696
- }
697
- }
698
- })), V = ((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), o > G && a(G), g(V), r(!1);
700
- };
701
- return ge(() => {
702
- (f == null ? void 0 : f.length) > 0 && F();
703
- }, [f, o]), /* @__PURE__ */ s.jsxs(
704
- J,
705
- {
706
- ref: R,
707
- error: p,
708
- helperText: C,
709
- readOnly: D,
710
- children: [
711
- k && /* @__PURE__ */ s.jsx(q, { htmlFor: _, isRequired: H, children: k }),
712
- /* @__PURE__ */ s.jsx(
713
- ut,
714
- {
715
- onChange: N,
716
- value: f ?? [],
717
- field: e
718
- }
719
- ),
720
- f != null && f.length ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
721
- /* @__PURE__ */ s.jsxs("div", { className: "relative overflow-hidden", children: [
722
- t ? /* @__PURE__ */ s.jsx("div", { className: "absolute bottom-0 left-0 right-0 top-0 z-10 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: "mr-2 h-8 w-8 animate-spin" }),
724
- "Fetching"
725
- ] }) }) : null,
726
- /* @__PURE__ */ s.jsx(he, { className: f.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[B],
728
- /* @__PURE__ */ s.jsx(
729
- Fe,
730
- {
731
- className: "cursor-pointer",
732
- size: 20,
733
- onClick: () => {
734
- N(
735
- f == null ? void 0 : f.filter((V) => V !== (u == null ? void 0 : u._id))
736
- );
737
- }
738
- }
739
- )
740
- ] }) }, u == null ? void 0 : u._id)) }) })
741
- ] }),
742
- /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between px-2", children: [
743
- /* @__PURE__ */ s.jsxs("div", { className: "flex-1 text-sm text-muted-foreground", children: [
744
- "Showing",
745
- " ",
746
- i ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
747
- 5 * (o - 1) + 1,
748
- "-",
749
- Math.min(5 * o, i),
750
- " of",
751
- " "
752
- ] }) : null,
753
- " ",
754
- i,
755
- " items"
756
- ] }),
757
- /* @__PURE__ */ s.jsxs("div", { className: "flex items-center space-x-6 lg:space-x-8", children: [
758
- /* @__PURE__ */ s.jsxs("div", { className: "flex w-[100px] items-center justify-center text-sm font-medium", children: [
759
- "Page ",
760
- o,
761
- " of ",
762
- x
763
- ] }),
764
- /* @__PURE__ */ s.jsxs("div", { className: "flex items-center space-x-2", children: [
765
- /* @__PURE__ */ s.jsxs(
766
- W,
767
- {
768
- onClick: () => a(1),
769
- disabled: o === 1,
770
- variant: "outline",
771
- className: "hidden h-8 w-8 p-0 lg:flex",
772
- children: [
773
- /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to first page" }),
774
- /* @__PURE__ */ s.jsx(st, { className: "h-4 w-4" })
775
- ]
776
- }
777
- ),
778
- /* @__PURE__ */ s.jsxs(
779
- W,
780
- {
781
- disabled: o === 1,
782
- onClick: () => a(o - 1),
783
- variant: "outline",
784
- className: "h-8 w-8 p-0",
785
- children: [
786
- /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to previous page" }),
787
- /* @__PURE__ */ s.jsx(et, { className: "h-4 w-4" })
788
- ]
789
- }
790
- ),
791
- /* @__PURE__ */ s.jsxs(
792
- W,
793
- {
794
- onClick: () => a(o + 1),
795
- disabled: o === x,
796
- variant: "outline",
797
- className: "h-8 w-8 p-0",
798
- children: [
799
- /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to next page" }),
800
- /* @__PURE__ */ s.jsx(tt, { className: "h-4 w-4" })
801
- ]
802
- }
803
- ),
804
- /* @__PURE__ */ s.jsxs(
805
- W,
806
- {
807
- onClick: () => a(x),
808
- disabled: o === x,
809
- variant: "outline",
810
- className: "hidden h-8 w-8 p-0 lg:flex",
811
- children: [
812
- /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Go to last page" }),
813
- /* @__PURE__ */ s.jsx(nt, { className: "h-4 w-4" })
814
- ]
815
- }
816
- )
817
- ] })
818
- ] })
819
- ] })
820
- ] }) : null
821
- ]
822
- }
823
- );
824
- }, mt = ({
825
- field: e
826
- }) => {
827
- var R, S, L;
828
- const { collection: n } = X(), [t, r] = w(!1), { key: c = "", label: g = "", helper_text: o = "", readonly: a = !1 } = e, i = c, m = ((R = e == null ? void 0 : e.options) == null ? void 0 : R.collection_key) || "", x = ((S = e == null ? void 0 : e.options) == null ? void 0 : S.label_field_key) || "", {
829
- field: { value: d, onBlur: y, onChange: k, ref: C, disabled: D, ..._ },
830
- fieldState: A
831
- } = me({
832
- name: i,
833
- rules: xe(e)
834
- }), B = !!(e != null && e.required), f = (L = A == null ? void 0 : A.error) == null ? void 0 : L.message, j = async (h, H, { page: p = 1 }) => {
835
- var F;
836
- r(!0);
837
- try {
838
- const T = await (n == null ? void 0 : n.getCollectionContentList({
839
- collection_key: m,
840
- page: p,
841
- search: h,
842
- limit: 10
843
- })), M = (F = T == null ? void 0 : T.content) == null ? void 0 : F.data, O = (M || []).map((u) => {
844
- const V = u != null && u[x] ? u == null ? void 0 : u[x] : Q.toTitle((u == null ? void 0 : u.slug) || "");
845
- return {
846
- value: {
847
- _id: u == null ? void 0 : u._id,
848
- slug: u == null ? void 0 : u.slug,
849
- [x]: u == null ? void 0 : u[x]
850
- },
851
- label: V
852
- };
853
- });
854
- return {
855
- options: Array.isArray(O) ? O : [],
856
- hasMore: M && !((M == null ? void 0 : M.length) < 10),
857
- additional: {
858
- page: p + 1
859
- }
860
- };
861
- } catch {
862
- return {
863
- options: [],
864
- hasMore: !1,
865
- additional: {
866
- page: p
867
- }
868
- };
869
- } finally {
870
- r(!1);
871
- }
872
- }, N = d ? {
873
- label: d != null && d[x] ? d == null ? void 0 : d[x] : d != null && d.slug ? Q.toTitle((d == null ? void 0 : d.slug) || "") : "",
874
- value: {
875
- _id: d == null ? void 0 : d._id,
876
- slug: d == null ? void 0 : d.slug,
877
- [x]: d == null ? void 0 : d[x]
878
- }
879
- } : null;
880
- return /* @__PURE__ */ s.jsxs(
881
- J,
882
- {
883
- ref: C,
884
- error: f,
885
- helperText: o,
886
- readOnly: a,
887
- children: [
888
- g && /* @__PURE__ */ s.jsx(q, { htmlFor: i, isRequired: B, children: g }),
889
- /* @__PURE__ */ s.jsx(
890
- be,
891
- {
892
- id: i,
893
- value: N,
894
- onChange: (h) => {
895
- k((h == null ? void 0 : h.value) || null);
896
- },
897
- onBlur: () => {
898
- y();
899
- },
900
- loadOptions: j,
901
- debounceTimeout: 500,
902
- getOptionLabel: (h) => h == null ? void 0 : h.label,
903
- getOptionValue: (h) => h == null ? void 0 : h.value,
904
- isLoading: t,
905
- additional: {
906
- page: 1
907
- },
908
- cacheUniqs: [m],
909
- minMenuHeight: 250,
910
- isDisabled: D,
911
- ..._
912
- }
913
- )
914
- ]
915
- }
916
- );
917
- }, pt = v(
918
- () => import("./MultiTextWidget-DYxi8PHm.js")
919
- ), ie = v(() => import("./TextWidget-CHkFlxmT.js")), xt = v(
920
- () => import("./CurrencyWidget-DgH4uCpg.js")
921
- ), ht = v(
922
- () => import("./CheckboxWidget-3qTjxIlp.js")
923
- ), ce = v(
924
- () => import("./DateTimeWidget-C2hLHKU6.js")
925
- ), de = v(
926
- () => import("./DropdownWidget-B6mRXcTa.js")
927
- ), yt = v(() => import("./EmailWidget-CBFnvo9z.js")), ft = v(
928
- () => import("./GeocoderWidget-DZGXm9Ji.js")
929
- ), jt = v(
930
- () => import("./MultiGeocoderWidget-D7ogTcWu.js")
931
- ), bt = v(() => import("./PhoneWidget-BxaGCfLs.js")), vt = v(() => import("./RadioWidget-Bkq1Oudi.js")), Ct = v(
932
- () => import("./RichTextWidget-Caqhw4GK.js")
933
- ), wt = v(() => import("./SwitchWidget-BpAzgVui.js")), kt = v(
934
- () => import("./TextareaWidget-B0htlijX.js")
935
- ), Wt = v(
936
- () => import("./ToggleCheckboxWidget-DLrS6ax4.js")
937
- ), _t = v(() => import("./URLWidget-CnWKNlOF.js")), K = v(() => import("./UploadWidget-DSvWOBuR.js")), Nt = ({
938
- field: e,
939
- isInternal: n
940
- }) => {
941
- var c, g, o, a, i, m;
942
- const { field_interface: t, key: r } = e;
943
- if (!t || !r)
944
- return null;
945
- switch (t) {
946
- case l.TextWidget:
947
- return /* @__PURE__ */ s.jsx(ie, { field: e });
948
- case l.NumberWidget:
949
- return /* @__PURE__ */ s.jsx(ie, { type: "number", field: e });
950
- case l.CurrencyWidget:
951
- return /* @__PURE__ */ s.jsx(xt, { field: e });
952
- case l.CheckboxWidget:
953
- return /* @__PURE__ */ s.jsx(ht, { field: e });
954
- case l.DateTimeWidget:
955
- return /* @__PURE__ */ s.jsx(ce, { field: e });
956
- case l.DateWidget:
957
- return /* @__PURE__ */ s.jsx(ce, { field: e });
958
- case l.DropdownWidget:
959
- return /* @__PURE__ */ s.jsx(de, { field: e, isMulti: !1 });
960
- case l.MultiDropdownWidget:
961
- return /* @__PURE__ */ s.jsx(de, { field: e, isMulti: !0 });
962
- case l.MultiTextWidget:
963
- return /* @__PURE__ */ s.jsx(pt, { field: e });
964
- case l.EmailWidget:
965
- return /* @__PURE__ */ s.jsx(yt, { field: e });
966
- case l.GeocoderWidget:
967
- return /* @__PURE__ */ s.jsx(ft, { field: e });
968
- case l.MultiGeocoderWidget:
969
- return /* @__PURE__ */ s.jsx(jt, { field: e });
970
- case l.PhoneWidget:
971
- return /* @__PURE__ */ s.jsx(bt, { field: e });
972
- case l.RadioWidget:
973
- return /* @__PURE__ */ s.jsx(vt, { field: e });
974
- case l.RichTextWidget:
975
- return /* @__PURE__ */ s.jsx(Ct, { field: e });
976
- case l.SwitchWidget:
977
- return /* @__PURE__ */ s.jsx(wt, { field: e });
978
- case l.TextareaWidget:
979
- return /* @__PURE__ */ s.jsx(kt, { field: e });
980
- case l.ToggleCheckboxWidget:
981
- return /* @__PURE__ */ s.jsx(Wt, { field: e });
982
- case l.URLWidget:
983
- return /* @__PURE__ */ s.jsx(_t, { field: e });
984
- case l.ImageUploadWidget:
985
- return /* @__PURE__ */ s.jsx(
986
- K,
987
- {
988
- field: e,
989
- isMultiple: !1,
990
- kind: ["image"],
991
- isExternal: !n
992
- }
993
- );
994
- case l.MultiImageUploadWidget:
995
- return /* @__PURE__ */ s.jsx(
996
- K,
997
- {
998
- field: e,
999
- isMultiple: !0,
1000
- kind: ["image"],
1001
- isExternal: !n
1002
- }
1003
- );
1004
- case l.FileUploadWidget:
1005
- return /* @__PURE__ */ s.jsx(
1006
- K,
1007
- {
1008
- field: e,
1009
- isMultiple: !1,
1010
- kind: ["audio", "video", "image", "document"],
1011
- isExternal: !n
1012
- }
1013
- );
1014
- case l.MultiFileUploadWidget:
1015
- return /* @__PURE__ */ s.jsx(
1016
- K,
1017
- {
1018
- field: e,
1019
- isMultiple: !0,
1020
- kind: ["audio", "video", "image", "document"],
1021
- isExternal: !n
1022
- }
1023
- );
1024
- case l.CollectionWidget:
1025
- 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(
1026
- "[LevoCollection]: Error while rendering collection widget. Collection key of label field key is required."
1027
- ), null) : (
1028
- /**
1029
- * @context
1030
- *
1031
- * this includes both `o2m` and `m2m` relationships, which if rendered
1032
- * should be using a multi-select dropdown widget
1033
- *
1034
- *
1035
- * @todo
1036
- * but, if such a field exist, we should be handling that with a modal or a drawer widget
1037
- * which renders a table with a multi-row select.
1038
- *
1039
- * the selected row, would then become connected to the current row.
1040
- *
1041
- * e.g.: `blog` collection key can have an `o2m` relationship with `post` collection key
1042
- *
1043
- * in this case, the `post` collection key should be rendered as a widget which shows count of posts
1044
- * and on clicking which actually opens a modal or a drawer widget which renders a table with a multi-row select
1045
- *
1046
- */
1047
- (o = e == null ? void 0 : e.options) != null && o.current_have_many_connected && !((a = e == null ? void 0 : e.options) != null && a.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 })
1048
- );
1049
- default:
1050
- return null;
1051
- }
1052
- }, Rt = ({
1053
- field: e,
1054
- isInternal: n
1055
- }) => {
1056
- const { key: t = "", label: r = "", field_interface: c = "", fields: g = [] } = e;
1057
- return !c || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full", children: [
1058
- /* @__PURE__ */ s.jsx(q, { children: r }),
1059
- /* @__PURE__ */ s.jsx("div", { className: "flex flex-col gap-3 rounded border bg-secondary/40 px-3 py-4", children: g.map((o) => {
1060
- const a = {
1061
- ...o,
1062
- key: `${t}.${o == null ? void 0 : o.key}`
1063
- };
1064
- return /* @__PURE__ */ s.jsx(
1065
- ve,
1066
- {
1067
- field: a,
1068
- isInternal: n
1069
- },
1070
- `common-fields-${e == null ? void 0 : e.id}-${o == null ? void 0 : o.id}`
1071
- );
1072
- }) })
1073
- ] });
1074
- }, ve = (e) => {
1075
- const { field_interface: n = "", key: t = "" } = e.field;
1076
- if (!n || !t)
1077
- return null;
1078
- switch (n) {
1079
- case l.ArrayWidget:
1080
- return /* @__PURE__ */ s.jsx(Ye, { ...e });
1081
- case l.RecordWidget:
1082
- return /* @__PURE__ */ s.jsx(Rt, { ...e });
1083
- default:
1084
- return /* @__PURE__ */ s.jsx(Nt, { ...e });
1085
- }
1086
- }, Ce = E.createContext({
1087
- schema: null,
1088
- submitButtonConfig: {
1089
- show: !0
1090
- }
1091
- }), Lt = ({
1092
- children: e,
1093
- ...n
1094
- }) => {
1095
- const { schema: t, onFormView: r } = n, { ref: c } = Oe({
1096
- triggerOnce: !0,
1097
- onChange: (g) => {
1098
- g && (t != null && t.id) && r && r({ schemaId: t.id });
1099
- }
1100
- });
1101
- return /* @__PURE__ */ s.jsxs(Ce.Provider, { value: { ...n }, children: [
1102
- /* @__PURE__ */ s.jsx("div", { ref: c }),
1103
- e
1104
- ] });
1105
- }, ns = () => E.useContext(Ce), Tt = E.lazy(
1106
- () => import("./DefaultFormVariant-Cm9i2BBn.js")
1107
- ), Mt = E.lazy(
1108
- () => import("./StepsFormVariant-D-m93LMv.js")
1109
- ), It = ({
1110
- formVariant: e,
1111
- ...n
1112
- }) => {
1113
- const { schema: t, uiConfig: r } = n;
1114
- return /* @__PURE__ */ s.jsxs(Lt, { ...n, children: [
1115
- r != null && r.hideFormHeading ? null : /* @__PURE__ */ s.jsxs(
1116
- "h1",
1117
- {
1118
- className: b(
1119
- "mb-4 text-left text-2xl font-semibold text-black",
1120
- e === "default" ? "ml-[32%]" : "ml-0"
1121
- ),
1122
- children: [
1123
- "Create new ",
1124
- He.singularize((t == null ? void 0 : t.name) || "")
1125
- ]
1126
- }
1127
- ),
1128
- /* @__PURE__ */ s.jsx(_e, { children: e === "steps" ? /* @__PURE__ */ s.jsx(Mt, {}) : /* @__PURE__ */ s.jsx(Tt, {}) })
1129
- ] });
1130
- }, rs = ({
1131
- collection_id: e,
1132
- hiddenFields: n,
1133
- ...t
1134
- }) => {
1135
- const { collection: r } = X(), [c, g] = w(!0), [o, a] = w(null);
1136
- return ge(() => {
1137
- e ? r == null || r.getCollectionByIDExpanded(e, {
1138
- headers: {
1139
- "Levo-Workspace": t == null ? void 0 : t.workspace_id
1140
- }
1141
- }).then((i) => {
1142
- var x, d;
1143
- const m = (x = i == null ? void 0 : i.content) == null ? void 0 : x.data;
1144
- if (m)
1145
- m.sections = (d = m == null ? void 0 : m.sections) == null ? void 0 : d.map(
1146
- (y) => {
1147
- var k;
1148
- 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;
1149
- }
1150
- ), a(m);
1151
- else
1152
- throw new Error(`API response invalid: ${m}`);
1153
- }).catch((i) => {
1154
- console.error("Error fetching schema", i);
1155
- }).finally(() => {
1156
- g(!1);
1157
- }) : (console.error(
1158
- "[CollectionFormBuilder] Collection ID or Workspace ID is missing."
1159
- ), g(!1));
1160
- }, [e]), /* @__PURE__ */ s.jsx("div", { className: "h-auto w-full", children: c ? /* @__PURE__ */ s.jsx("div", { className: "flex min-h-[400px] w-full items-center justify-center rounded-md", children: /* @__PURE__ */ s.jsx(Se, {}) }) : o ? /* @__PURE__ */ s.jsx(It, { schema: o, ...t }) : null });
1161
- };
1162
- export {
1163
- J as A,
1164
- q as B,
1165
- rs as C,
1166
- ns as D,
1167
- ve as F,
1168
- ss as H,
1169
- pe as a,
1170
- U as b,
1171
- Xt as c,
1172
- oe as d,
1173
- Je as e,
1174
- Jt as f,
1175
- ts as g,
1176
- es as h,
1177
- Qe as i,
1178
- Ve as j,
1179
- ze as k,
1180
- $e as l,
1181
- Ue as m,
1182
- qe as n,
1183
- Ge as o,
1184
- ae as p,
1185
- Ze as q,
1186
- Ke as r,
1187
- Yt as s,
1188
- $ as t,
1189
- Qt as u,
1190
- Kt as v,
1191
- Z as w,
1192
- Gt as x,
1193
- Zt as y,
1194
- xe as z
1195
- };