@levo-so/react 0.0.2-alpha → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Checbox-sq-atGlJ.js +28 -0
- package/dist/CheckboxWidget-ComdVcZ_.js +118 -0
- package/dist/CollectionFormBuilder-jwwjyIpv.js +738 -0
- package/dist/CurrencyWidget-DVqD_lsY.js +60 -0
- package/dist/DateTimeWidget-CvgzwY1U.js +80 -0
- package/dist/DefaultFormVariant-CbRB9O_e.js +80 -0
- package/dist/DropdownWidget-C2YaM9Cf.js +115 -0
- package/dist/EmailWidget-BBthwF68.js +41 -0
- package/dist/GeocoderWidget-Dht_2vi6.js +309 -0
- package/dist/Input-2CvZ90f8.js +54 -0
- package/dist/LevoProvider-DNbYyEaf.js +21 -0
- package/dist/MultiGeocoderWidget-paCFW0QZ.js +49 -0
- package/dist/PhoneWidget-CP2T2JDx.js +47 -0
- package/dist/RadioWidget-BuFPz7kK.js +109 -0
- package/dist/RichTextWidget-DGFNZ1jl.js +310 -0
- package/dist/Sonner-t6JVKA0a.js +39 -0
- package/dist/Spinner-CuUosd-S.js +297 -0
- package/dist/StepsFormVariant-5_c3f2Vk.js +137 -0
- package/dist/SwitchWidget-t8iwhxk9.js +53 -0
- package/dist/TextWidget-D0UBxTxe.js +33 -0
- package/dist/TextareaWidget-CG6J_plD.js +30 -0
- package/dist/ToggleCheckboxWidget-dl8ks4VX.js +44 -0
- package/dist/Tooltip-CI4i4mYr.js +144 -0
- package/dist/URLWidget-CHeUEUXl.js +14 -0
- package/dist/UploadWidget-CzYGViqE.js +503 -0
- package/dist/audience/{block.d.ts → components/block.d.ts} +1 -1
- package/dist/audience/components/block.d.ts.map +1 -0
- package/dist/audience/{component.d.ts → components/component.d.ts} +1 -1
- package/dist/audience/components/component.d.ts.map +1 -0
- package/dist/audience/{page.d.ts → components/page.d.ts} +1 -1
- package/dist/audience/components/page.d.ts.map +1 -0
- package/dist/audience/components/useScrollDepth.d.ts.map +1 -0
- package/dist/audience/index.d.ts +3 -3
- package/dist/audience/index.d.ts.map +1 -1
- package/dist/audience/index.js +4 -2303
- package/dist/byteToSize-BFKZSBu1.js +8 -0
- package/dist/cn-C9QoOYNG.js +6 -0
- package/dist/collection/components/CollectionFormBuilder.d.ts +12 -0
- package/dist/collection/components/CollectionFormBuilder.d.ts.map +1 -0
- package/dist/collection/components/FieldRenderer.d.ts +9 -0
- package/dist/collection/components/FieldRenderer.d.ts.map +1 -0
- package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts +5 -0
- package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +1 -0
- package/dist/collection/components/core/Checkbox/Checbox.d.ts +5 -0
- package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +1 -0
- package/dist/collection/components/core/Input/Input.d.ts +11 -0
- package/dist/collection/components/core/Input/Input.d.ts.map +1 -0
- package/dist/collection/components/core/Switch/Switch.d.ts +5 -0
- package/dist/collection/components/core/Switch/Switch.d.ts.map +1 -0
- package/dist/collection/components/renderer/RenderArrayWidget.d.ts +5 -0
- package/dist/collection/components/renderer/RenderArrayWidget.d.ts.map +1 -0
- package/dist/collection/components/renderer/RenderCommonField.d.ts +5 -0
- package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -0
- package/dist/collection/components/renderer/RenderRecordWidget.d.ts +4 -0
- package/dist/collection/components/renderer/RenderRecordWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/ErrorMessage.d.ts +6 -0
- package/dist/collection/components/widgets/ErrorMessage.d.ts.map +1 -0
- package/dist/collection/components/widgets/FieldWrapper.d.ts +14 -0
- package/dist/collection/components/widgets/FieldWrapper.d.ts.map +1 -0
- package/dist/collection/components/widgets/FormHelperText.d.ts +6 -0
- package/dist/collection/components/widgets/FormHelperText.d.ts.map +1 -0
- package/dist/collection/components/widgets/FormLabel.d.ts +8 -0
- package/dist/collection/components/widgets/FormLabel.d.ts.map +1 -0
- package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +8 -0
- package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts +7 -0
- package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts +9 -0
- package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts +8 -0
- package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts +9 -0
- package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts +8 -0
- package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts +8 -0
- package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts +8 -0
- package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts +8 -0
- package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts +11 -0
- package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts +12 -0
- package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts +8 -0
- package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/textWidget/TextWidget.d.ts +9 -0
- package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts +8 -0
- package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts +8 -0
- package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts +10 -0
- package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -0
- package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts +13 -0
- package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -0
- package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts +11 -0
- package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -0
- package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts +19 -0
- package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -0
- package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts +5 -0
- package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts.map +1 -0
- package/dist/collection/index.d.ts +5 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +19 -0
- package/dist/collection/lib/FormBuilder.d.ts +8 -0
- package/dist/collection/lib/FormBuilder.d.ts.map +1 -0
- package/dist/collection/lib/SaveDraftValues.d.ts +7 -0
- package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -0
- package/dist/collection/lib/hooks/useLevoForm.d.ts +18 -0
- package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -0
- package/dist/collection/lib/provider/LevoFormProvider.d.ts +9 -0
- package/dist/collection/lib/provider/LevoFormProvider.d.ts.map +1 -0
- package/dist/collection/lib/variants/DefaultFormVariant.d.ts +3 -0
- package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -0
- package/dist/collection/lib/variants/StepsFormVariant.d.ts +4 -0
- package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +1 -0
- package/dist/collection/types/context.d.ts +34 -0
- package/dist/collection/types/context.d.ts.map +1 -0
- package/dist/collection/types/errors.d.ts +7 -0
- package/dist/collection/types/errors.d.ts.map +1 -0
- package/dist/collection/types/formVariant.d.ts +18 -0
- package/dist/collection/types/formVariant.d.ts.map +1 -0
- package/dist/collection/types/forms.d.ts +31 -0
- package/dist/collection/types/forms.d.ts.map +1 -0
- package/dist/collection/types/index.d.ts +4 -0
- package/dist/collection/types/index.d.ts.map +1 -0
- package/dist/collection/types/renderer.d.ts +6 -0
- package/dist/collection/types/renderer.d.ts.map +1 -0
- package/dist/collection/utils/formHelpers.d.ts +47 -0
- package/dist/collection/utils/formHelpers.d.ts.map +1 -0
- package/dist/collection/utils/getFieldValidations.d.ts +6 -0
- package/dist/collection/utils/getFieldValidations.d.ts.map +1 -0
- package/dist/collection/utils/index.d.ts +4 -0
- package/dist/collection/utils/index.d.ts.map +1 -0
- package/dist/collection/utils/schema.d.ts +3 -0
- package/dist/collection/utils/schema.d.ts.map +1 -0
- package/dist/collection/utils/setFormErrors.d.ts +4 -0
- package/dist/collection/utils/setFormErrors.d.ts.map +1 -0
- package/dist/collection/utils/storage.d.ts +11 -0
- package/dist/collection/utils/storage.d.ts.map +1 -0
- package/dist/components/Dialog.d.ts +21 -0
- package/dist/components/Dialog.d.ts.map +1 -0
- package/dist/components/DialogWrapper.d.ts +11 -0
- package/dist/components/DialogWrapper.d.ts.map +1 -0
- package/dist/components/Sonner.d.ts +7 -0
- package/dist/components/Sonner.d.ts.map +1 -0
- package/dist/components/Spinner.d.ts +5 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Tabs.d.ts +8 -0
- package/dist/components/Tabs.d.ts.map +1 -0
- package/dist/components/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/button/Button.d.ts +12 -0
- package/dist/components/button/Button.d.ts.map +1 -0
- package/dist/components/button/buttonVariants.d.ts +6 -0
- package/dist/components/button/buttonVariants.d.ts.map +1 -0
- package/dist/components/button/index.d.ts +3 -0
- package/dist/components/button/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +33 -0
- package/dist/constants/fileUploadPresets.d.ts +34 -0
- package/dist/constants/fileUploadPresets.d.ts.map +1 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/errorHandler-BJcFS2qV.js +26 -0
- package/dist/fileUploadPresets-2raQmHT0.js +74 -0
- package/dist/index-wTf_TtOG.js +131 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +84 -0
- package/dist/isEmptyObject-C5s4GzLE.js +8 -0
- package/dist/jsx-runtime-B6kdoens.js +634 -0
- package/dist/membership/components/OAuth/Button.d.ts +8 -0
- package/dist/membership/components/OAuth/Button.d.ts.map +1 -0
- package/dist/membership/components/OAuth/Container.d.ts +24 -0
- package/dist/membership/components/OAuth/Container.d.ts.map +1 -0
- package/dist/membership/components/OAuth/Core.d.ts +17 -0
- package/dist/membership/components/OAuth/Core.d.ts.map +1 -0
- package/dist/membership/components/OAuth/Popup.d.ts +15 -0
- package/dist/membership/components/OAuth/Popup.d.ts.map +1 -0
- package/dist/membership/components/index.d.ts +8 -0
- package/dist/membership/components/index.d.ts.map +1 -0
- package/dist/membership/index.d.ts +2 -0
- package/dist/membership/index.d.ts.map +1 -0
- package/dist/membership/index.js +4 -0
- package/dist/page-CxaKoH22.js +205 -0
- package/dist/providers/LevoProvider.d.ts +25 -0
- package/dist/providers/LevoProvider.d.ts.map +1 -0
- package/dist/style.css +1 -0
- package/dist/useLevoForm-BcN8f66y.js +166 -0
- package/dist/utils/byteToSize.d.ts +3 -0
- package/dist/utils/byteToSize.d.ts.map +1 -0
- package/dist/utils/cn.d.ts +4 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/errorHandler.d.ts +2 -0
- package/dist/utils/errorHandler.d.ts.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +14 -0
- package/dist/utils/isDateObject.d.ts +2 -0
- package/dist/utils/isDateObject.d.ts.map +1 -0
- package/dist/utils/isEmptyObject.d.ts +5 -0
- package/dist/utils/isEmptyObject.d.ts.map +1 -0
- package/dist/utils/isNullOrUndefined.d.ts +2 -0
- package/dist/utils/isNullOrUndefined.d.ts.map +1 -0
- package/dist/utils/isObject.d.ts +3 -0
- package/dist/utils/isObject.d.ts.map +1 -0
- package/package.json +88 -5
- package/dist/audience/block.d.ts.map +0 -1
- package/dist/audience/component.d.ts.map +0 -1
- package/dist/audience/page.d.ts.map +0 -1
- package/dist/audience/useScrollDepth.d.ts.map +0 -1
- /package/dist/audience/{useScrollDepth.d.ts → components/useScrollDepth.d.ts} +0 -0
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { j as s } from "./jsx-runtime-B6kdoens.js";
|
|
3
|
+
import { FieldInterfaces as a, defaultByKinds as F, formatsByInterface as se, interfaceKinds as oe, FieldInterfacesList as ae } from "@levo-so/core";
|
|
4
|
+
import { G as O, T as ie, a as le, c as ce, B as v, d as ue, r as de, s as ge, S as me } from "./Spinner-CuUosd-S.js";
|
|
5
|
+
import j, { useState as R, lazy as h, Suspense as he, useEffect as pe } from "react";
|
|
6
|
+
import { useFieldArray as xe, useController as ye } from "react-hook-form";
|
|
7
|
+
import { Mate as $ } from "@theinternetfolks/mate";
|
|
8
|
+
import { Snowflake as fe } from "@theinternetfolks/snowflake";
|
|
9
|
+
import We from "google-libphonenumber";
|
|
10
|
+
import P from "validator";
|
|
11
|
+
import w from "validatorjs";
|
|
12
|
+
import { c as f } from "./cn-C9QoOYNG.js";
|
|
13
|
+
import { u as G } from "./LevoProvider-DNbYyEaf.js";
|
|
14
|
+
import * as be from "inflection";
|
|
15
|
+
import { useInView as je } from "react-intersection-observer";
|
|
16
|
+
const { PhoneNumberUtil: ke } = We, ve = (e) => {
|
|
17
|
+
const r = [];
|
|
18
|
+
for (const t of Object.keys(e))
|
|
19
|
+
for (const n of (e == null ? void 0 : e[t]) || [])
|
|
20
|
+
r.push({ message: n, name: t });
|
|
21
|
+
return r;
|
|
22
|
+
}, z = ke.getInstance(), we = (e) => {
|
|
23
|
+
try {
|
|
24
|
+
return e && (e == null ? void 0 : e.trim().length) > 3 ? z.isValidNumber(z.parseAndKeepRawInput(e)) : !0;
|
|
25
|
+
} catch {
|
|
26
|
+
return !1;
|
|
27
|
+
}
|
|
28
|
+
}, K = (e, r) => {
|
|
29
|
+
w.register(
|
|
30
|
+
"data_uri",
|
|
31
|
+
(n) => typeof n != "string" ? !1 : P.isDataURI(n),
|
|
32
|
+
"The :attribute is not a valid file."
|
|
33
|
+
), w.register(
|
|
34
|
+
"phone_number",
|
|
35
|
+
(n) => we(n),
|
|
36
|
+
"The :attribute has incorrect format."
|
|
37
|
+
), w.register(
|
|
38
|
+
"url",
|
|
39
|
+
(n) => P.isURL(n.toString(), {}),
|
|
40
|
+
"The :attribute is not a valid URL."
|
|
41
|
+
), w.setAttributeFormatter((n) => {
|
|
42
|
+
if (n.endsWith("Id"))
|
|
43
|
+
return n.replace("Id", "");
|
|
44
|
+
if (n.includes(".")) {
|
|
45
|
+
const [i] = n.split(".");
|
|
46
|
+
return i;
|
|
47
|
+
}
|
|
48
|
+
return n.replace(/_/g, " ");
|
|
49
|
+
});
|
|
50
|
+
const t = new w(e, r);
|
|
51
|
+
return t.passes() ? { status: !0 } : {
|
|
52
|
+
status: !1,
|
|
53
|
+
errors: ve(t.errors.all())
|
|
54
|
+
};
|
|
55
|
+
}, mt = (e, r) => {
|
|
56
|
+
const t = {};
|
|
57
|
+
for (const o of e.sections)
|
|
58
|
+
for (const c of o.fields) {
|
|
59
|
+
const u = [];
|
|
60
|
+
switch (c.required && u.push("required"), typeof c.max < "u" && c.max !== null && u.push({
|
|
61
|
+
max: [c.max]
|
|
62
|
+
}), typeof c.min < "u" && c.min !== null && u.push({
|
|
63
|
+
min: [c.min]
|
|
64
|
+
}), c.field_interface) {
|
|
65
|
+
case a.EmailWidget:
|
|
66
|
+
u.push("email");
|
|
67
|
+
break;
|
|
68
|
+
case a.PhoneWidget:
|
|
69
|
+
u.push("phone_number");
|
|
70
|
+
break;
|
|
71
|
+
case a.URLWidget:
|
|
72
|
+
u.push("url");
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
t[c.key] = u;
|
|
76
|
+
}
|
|
77
|
+
const n = K(r, t), { errors: i } = n, d = {};
|
|
78
|
+
return i && i.map((o) => {
|
|
79
|
+
d[o.name] = o.message;
|
|
80
|
+
}), d;
|
|
81
|
+
}, C = (e) => {
|
|
82
|
+
var t, n;
|
|
83
|
+
const r = {};
|
|
84
|
+
for (const i of e)
|
|
85
|
+
r[i.key] = (t = F) == null ? void 0 : t[i == null ? void 0 : i.kind], (i == null ? void 0 : i.field_interface) === a.RecordWidget && ((n = i == null ? void 0 : i.fields) != null && n.length) && (r[i.key] = C(i.fields));
|
|
86
|
+
return r;
|
|
87
|
+
}, ht = (e) => {
|
|
88
|
+
var t;
|
|
89
|
+
if (!(e != null && e.sections)) return {};
|
|
90
|
+
let r = {};
|
|
91
|
+
for (const n of e.sections)
|
|
92
|
+
n != null && n.fields && ((t = n == null ? void 0 : n.fields) == null ? void 0 : t.length) > 0 && (r = {
|
|
93
|
+
...r,
|
|
94
|
+
...C(n.fields)
|
|
95
|
+
});
|
|
96
|
+
return r;
|
|
97
|
+
}, B = (e) => typeof e < "u" ? e : null, pt = (e, r) => {
|
|
98
|
+
var n;
|
|
99
|
+
if (!(e != null && e.sections)) return {};
|
|
100
|
+
const t = {};
|
|
101
|
+
for (const i of e.sections) {
|
|
102
|
+
const d = C(i.fields ?? []);
|
|
103
|
+
for (const o of i.fields) {
|
|
104
|
+
let c = B(r == null ? void 0 : r[o == null ? void 0 : o.key]);
|
|
105
|
+
Array.isArray(c) && (c == null ? void 0 : c.length) > 0 && Array.isArray(o == null ? void 0 : o.values) && ((n = o == null ? void 0 : o.values) == null ? void 0 : n.length) > 0 && (c = c == null ? void 0 : c.filter((u) => {
|
|
106
|
+
var g;
|
|
107
|
+
return (g = o == null ? void 0 : o.values) == null ? void 0 : g.includes(u);
|
|
108
|
+
})), t[o.key] = c ?? B(o == null ? void 0 : o.default_value) ?? d[o.key];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return t;
|
|
112
|
+
}, xt = (e, r) => {
|
|
113
|
+
var i;
|
|
114
|
+
const t = { ...e };
|
|
115
|
+
let n = null;
|
|
116
|
+
return (t.field_interface === a.ArrayWidget && r !== a.ArrayWidget || t.field_interface === a.RecordWidget && r !== a.RecordWidget) && (t.fields = []), (r !== a.MultiDropdownWidget || r !== a.DropdownWidget || r !== a.RadioWidget || r !== a.CheckboxWidget) && t.field_interface !== a.MultiDropdownWidget && t.field_interface !== a.DropdownWidget && t.field_interface !== a.RadioWidget && t.field_interface !== a.CheckboxWidget && ((i = t.values) == null ? void 0 : i.length) !== 0 && (t.values = []), (r === a.MultiDropdownWidget && t.field_interface !== a.MultiDropdownWidget || r === a.DropdownWidget && t.field_interface !== a.DropdownWidget || r === a.RadioWidget && t.field_interface !== a.RadioWidget || r === a.CheckboxWidget && t.field_interface !== a.CheckboxWidget) && (t.values = [""], n = `${t.id}-option-0`), [a.RecordWidget, a.ArrayWidget].includes(
|
|
117
|
+
r
|
|
118
|
+
) && (n = `field-${fe.generate()}`, t.kind = r === a.RecordWidget ? "record" : "group", t.fields = [
|
|
119
|
+
...(t == null ? void 0 : t.fields) || [],
|
|
120
|
+
{
|
|
121
|
+
id: n,
|
|
122
|
+
key: "title",
|
|
123
|
+
label: "Title",
|
|
124
|
+
helper_text: "",
|
|
125
|
+
kind: "string",
|
|
126
|
+
field_interface: a.TextWidget,
|
|
127
|
+
default_value: "",
|
|
128
|
+
options: {},
|
|
129
|
+
fields: [],
|
|
130
|
+
hidden: !1,
|
|
131
|
+
readonly: !1,
|
|
132
|
+
required: !1,
|
|
133
|
+
unique: !1,
|
|
134
|
+
min: null,
|
|
135
|
+
max: null,
|
|
136
|
+
formats: se[r] || [],
|
|
137
|
+
values: [],
|
|
138
|
+
editable: !0
|
|
139
|
+
}
|
|
140
|
+
]), t.kind = oe[r] || "string", t.default_value || (t.default_value = F[t.kind] || null), r !== a.CollectionWidget && ae.includes(r) && (t.field_interface = r), { field: t, fieldFocused: n };
|
|
141
|
+
}, yt = (e, r) => {
|
|
142
|
+
var d;
|
|
143
|
+
const t = { ...e }, n = [], i = "_id";
|
|
144
|
+
if (r)
|
|
145
|
+
for (const o of r.sections ?? [])
|
|
146
|
+
for (const c of o.fields)
|
|
147
|
+
c.field_interface === "CollectionWidget" && n.push(c.key);
|
|
148
|
+
for (const o of n)
|
|
149
|
+
t[o] && typeof t[o] == "object" && (Array.isArray(t[o]) ? t[o] = (d = t[o]) == null ? void 0 : d.map(
|
|
150
|
+
(c) => c[i]
|
|
151
|
+
) : t[o] = t[o][i]);
|
|
152
|
+
return t;
|
|
153
|
+
}, ft = (e, r) => {
|
|
154
|
+
if (Array.isArray(e) && e.length > 0) {
|
|
155
|
+
let t = 0;
|
|
156
|
+
for (const n of e)
|
|
157
|
+
t += 1, n != null && n.param && r && r(
|
|
158
|
+
n == null ? void 0 : n.param,
|
|
159
|
+
{
|
|
160
|
+
type: "server_error",
|
|
161
|
+
message: n == null ? void 0 : n.message
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
shouldFocus: t === 0
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
function Wt(e) {
|
|
170
|
+
return O({ 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);
|
|
171
|
+
}
|
|
172
|
+
function H(e) {
|
|
173
|
+
return O({ 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);
|
|
174
|
+
}
|
|
175
|
+
const I = ({
|
|
176
|
+
children: e,
|
|
177
|
+
isRequired: r,
|
|
178
|
+
className: t,
|
|
179
|
+
...n
|
|
180
|
+
}) => /* @__PURE__ */ s.jsxs(
|
|
181
|
+
"label",
|
|
182
|
+
{
|
|
183
|
+
className: f(
|
|
184
|
+
"block text-sm font-medium leading-normal peer-disabled:cursor-not-allowed peer-disabled:opacity-70 select-none flex-1",
|
|
185
|
+
"mb-2",
|
|
186
|
+
t
|
|
187
|
+
),
|
|
188
|
+
...n,
|
|
189
|
+
children: [
|
|
190
|
+
e,
|
|
191
|
+
" ",
|
|
192
|
+
r && /* @__PURE__ */ s.jsx("span", { className: "text-red-500", children: "*" })
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
), Ce = ({
|
|
196
|
+
field: e,
|
|
197
|
+
isInternal: r
|
|
198
|
+
}) => {
|
|
199
|
+
const { key: t = "", label: n = "", field_interface: i = "", fields: d = [] } = e, [o, c] = R("0"), { fields: u, ...g } = xe({
|
|
200
|
+
name: t
|
|
201
|
+
});
|
|
202
|
+
return !i || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full max-w-full", children: [
|
|
203
|
+
/* @__PURE__ */ s.jsx(I, { className: "text-md font-medium mb-4", children: n }),
|
|
204
|
+
u && Array.isArray(u) ? /* @__PURE__ */ s.jsxs(ie, { value: o, onValueChange: c, className: "w-full", children: [
|
|
205
|
+
/* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
|
|
206
|
+
u.length ? /* @__PURE__ */ s.jsx(le, { className: "h-11 overflow-y-hidden overflow-x-auto flex-1 w-1 justify-start", children: u == null ? void 0 : u.map((x, l) => /* @__PURE__ */ s.jsx(
|
|
207
|
+
ce,
|
|
208
|
+
{
|
|
209
|
+
id: `${e == null ? void 0 : e.key}-${l}`,
|
|
210
|
+
value: l.toString(),
|
|
211
|
+
children: l + 1
|
|
212
|
+
},
|
|
213
|
+
`array-widget-tab-${e == null ? void 0 : e.id}-${l}`
|
|
214
|
+
)) }) : null,
|
|
215
|
+
/* @__PURE__ */ s.jsxs(
|
|
216
|
+
v,
|
|
217
|
+
{
|
|
218
|
+
variant: "ghost",
|
|
219
|
+
size: "xs",
|
|
220
|
+
className: "shrink-0 grow-0",
|
|
221
|
+
onClick: () => {
|
|
222
|
+
g.append(C(d)), c(((u == null ? void 0 : u.length) ?? 0).toString());
|
|
223
|
+
},
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ s.jsx(H, { className: "inline-block mr-1", size: "14px" }),
|
|
226
|
+
"Add"
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
] }),
|
|
231
|
+
u == null ? void 0 : u.map((x, l) => /* @__PURE__ */ s.jsxs(
|
|
232
|
+
ue,
|
|
233
|
+
{
|
|
234
|
+
className: "space-y-4 border rounded bg-secondary/40",
|
|
235
|
+
value: l.toString(),
|
|
236
|
+
children: [
|
|
237
|
+
/* @__PURE__ */ s.jsx("div", { className: "flex flex-col px-3 py-2 gap-3", children: d.map((p) => {
|
|
238
|
+
const b = {
|
|
239
|
+
...p,
|
|
240
|
+
key: `${t}.${l}.${p == null ? void 0 : p.key}`
|
|
241
|
+
};
|
|
242
|
+
return /* @__PURE__ */ s.jsx(
|
|
243
|
+
J,
|
|
244
|
+
{
|
|
245
|
+
field: b,
|
|
246
|
+
isInternal: r
|
|
247
|
+
},
|
|
248
|
+
`common-fields-${p == null ? void 0 : p.id}`
|
|
249
|
+
);
|
|
250
|
+
}) }),
|
|
251
|
+
/* @__PURE__ */ s.jsxs("div", { className: "flex p-2 items-center border-t", children: [
|
|
252
|
+
/* @__PURE__ */ s.jsx(
|
|
253
|
+
v,
|
|
254
|
+
{
|
|
255
|
+
onClick: () => {
|
|
256
|
+
c((l - 1).toString()), g.move(l, l - 1);
|
|
257
|
+
},
|
|
258
|
+
disabled: l === 0,
|
|
259
|
+
size: "icon",
|
|
260
|
+
className: "rounded-full w-8 h-8",
|
|
261
|
+
children: /* @__PURE__ */ s.jsx(de, { size: "24px" })
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
/* @__PURE__ */ s.jsx(
|
|
265
|
+
v,
|
|
266
|
+
{
|
|
267
|
+
className: "text-red-500",
|
|
268
|
+
variant: "link",
|
|
269
|
+
onClick: () => {
|
|
270
|
+
c((l - 1).toString()), g.remove(l);
|
|
271
|
+
},
|
|
272
|
+
children: "Remove Item"
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
/* @__PURE__ */ s.jsx(
|
|
276
|
+
v,
|
|
277
|
+
{
|
|
278
|
+
className: "rounded-full w-8 h-8",
|
|
279
|
+
onClick: () => {
|
|
280
|
+
c((l + 1).toString()), g.move(l, l + 1);
|
|
281
|
+
},
|
|
282
|
+
disabled: l >= u.length - 1,
|
|
283
|
+
size: "icon",
|
|
284
|
+
children: /* @__PURE__ */ s.jsx(ge, { size: "24px" })
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
] })
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
`array-widget-tab-content-${e == null ? void 0 : e.id}-${l}`
|
|
291
|
+
))
|
|
292
|
+
] }) : /* @__PURE__ */ s.jsxs(
|
|
293
|
+
v,
|
|
294
|
+
{
|
|
295
|
+
variant: "ghost",
|
|
296
|
+
size: "xs",
|
|
297
|
+
onClick: () => {
|
|
298
|
+
g.append(C(d)), c("0");
|
|
299
|
+
},
|
|
300
|
+
children: [
|
|
301
|
+
/* @__PURE__ */ s.jsx(H, { className: "inline-block mr-1", size: "14px" }),
|
|
302
|
+
"Add"
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
] });
|
|
307
|
+
}, _e = (e) => {
|
|
308
|
+
const r = e == null ? void 0 : e.key;
|
|
309
|
+
let t = r == null ? void 0 : r.replace(/_/g, " ");
|
|
310
|
+
if (t != null && t.endsWith("Id") && (t = t == null ? void 0 : t.replace("Id", "")), t.includes(".")) {
|
|
311
|
+
const [i] = t.split(".");
|
|
312
|
+
i && (t = i);
|
|
313
|
+
}
|
|
314
|
+
const n = [];
|
|
315
|
+
switch (typeof e.max < "u" && e.max !== null && n.push({
|
|
316
|
+
max: [e.max]
|
|
317
|
+
}), typeof e.min < "u" && e.min !== null && n.push({
|
|
318
|
+
min: [e.min]
|
|
319
|
+
}), e.field_interface) {
|
|
320
|
+
case a.EmailWidget:
|
|
321
|
+
n.push("email");
|
|
322
|
+
break;
|
|
323
|
+
case a.PhoneWidget:
|
|
324
|
+
n.push("phone_number");
|
|
325
|
+
break;
|
|
326
|
+
case a.URLWidget:
|
|
327
|
+
n.push("url");
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
required: {
|
|
332
|
+
value: !!(e != null && e.required),
|
|
333
|
+
message: `The ${t} field is required`
|
|
334
|
+
},
|
|
335
|
+
validate: (i) => {
|
|
336
|
+
var c, u;
|
|
337
|
+
if ((c = e == null ? void 0 : e.options) != null && c.disableValidation || !i)
|
|
338
|
+
return !0;
|
|
339
|
+
const d = K(
|
|
340
|
+
{
|
|
341
|
+
[e.key]: i
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
[e.key]: n
|
|
345
|
+
}
|
|
346
|
+
), { errors: o } = d;
|
|
347
|
+
return o && (o == null ? void 0 : o.length) > 0 ? (u = o == null ? void 0 : o[0]) == null ? void 0 : u.message : !0;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}, Re = _e, Le = j.lazy(
|
|
351
|
+
() => import("react-select-async-paginate").then((e) => ({
|
|
352
|
+
default: e.AsyncPaginate
|
|
353
|
+
}))
|
|
354
|
+
), Ne = (e) => /* @__PURE__ */ s.jsx(
|
|
355
|
+
Le,
|
|
356
|
+
{
|
|
357
|
+
isClearable: !0,
|
|
358
|
+
menuPlacement: "auto",
|
|
359
|
+
isSearchable: !0,
|
|
360
|
+
unstyled: !0,
|
|
361
|
+
classNames: {
|
|
362
|
+
container: () => f("w-full min-w-none h-auto min-h-none"),
|
|
363
|
+
control: ({ isFocused: r, isMulti: t, isDisabled: n }) => f(
|
|
364
|
+
"w-full pl-3",
|
|
365
|
+
t ? "!min-h-9 h-auto" : "h-9 !min-h-none",
|
|
366
|
+
"rounded-md border bg-transparent hover:cursor-pointer border-input text-sm shadow-sm transition-colors",
|
|
367
|
+
"flex ",
|
|
368
|
+
r && "outline-none ring-1 ring-ring",
|
|
369
|
+
n && "cursor-not-allowed opacity-50"
|
|
370
|
+
),
|
|
371
|
+
input: () => "",
|
|
372
|
+
valueContainer: () => "gap-[4px] py-1",
|
|
373
|
+
singleValue: () => "",
|
|
374
|
+
multiValue: () => "bg-gray-100 rounded items-center py-0.5 pl-2 pr-1 gap-1.5",
|
|
375
|
+
multiValueLabel: () => "py-0.5",
|
|
376
|
+
multiValueRemove: () => "border border-gray-200 bg-white hover:bg-red-50 hover:text-red-800 text-gray-500 hover:border-red-300 rounded-md",
|
|
377
|
+
indicatorsContainer: () => "",
|
|
378
|
+
clearIndicator: () => "text-gray-500 p-1 rounded-md hover:bg-red-50 hover:text-red-800",
|
|
379
|
+
indicatorSeparator: () => "",
|
|
380
|
+
dropdownIndicator: () => "p-1 hover:bg-gray-100 text-gray-500 rounded-md hover:text-black",
|
|
381
|
+
menu: () => "p-1 mt-2 border border-gray-200 bg-white rounded-md",
|
|
382
|
+
groupHeading: () => "ml-3 mt-2 mb-1 text-gray-500 text-sm",
|
|
383
|
+
placeholder: () => "text-gray-500 pl-1 py-0.5",
|
|
384
|
+
option: ({ isSelected: r, isFocused: t }) => f(
|
|
385
|
+
"text-[.875rem] font-medium hover:cursor-pointer px-3 py-2 rounded",
|
|
386
|
+
t && "bg-gray-100 active:bg-gray-200",
|
|
387
|
+
r && "text-white bg-primary/80"
|
|
388
|
+
),
|
|
389
|
+
noOptionsMessage: () => "text-gray-500 p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm"
|
|
390
|
+
},
|
|
391
|
+
...e
|
|
392
|
+
}
|
|
393
|
+
), Te = ({
|
|
394
|
+
children: e
|
|
395
|
+
}) => /* @__PURE__ */ s.jsx("p", { className: "text-xs font-normal text-red-400 text-wrap", children: e }), Ie = ({
|
|
396
|
+
children: e
|
|
397
|
+
}) => /* @__PURE__ */ s.jsx("p", { className: f("text-xs font-normal text-gray-600"), children: e }), Ae = j.forwardRef(({ error: e, helperText: r, containerStyles: t, readOnly: n, children: i }, d) => /* @__PURE__ */ s.jsx(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
className: f(
|
|
401
|
+
"form-control w-full",
|
|
402
|
+
n ? "pointer-events-none" : "",
|
|
403
|
+
t
|
|
404
|
+
),
|
|
405
|
+
ref: d,
|
|
406
|
+
children: /* @__PURE__ */ s.jsxs("div", { className: f("w-full shrink-0", "sm:flex-1"), children: [
|
|
407
|
+
i,
|
|
408
|
+
e && /* @__PURE__ */ s.jsx("div", { className: f("w-full mt-3"), children: /* @__PURE__ */ s.jsx(Te, { children: e }) }),
|
|
409
|
+
r && /* @__PURE__ */ s.jsx("div", { className: f("w-full mt-3"), children: /* @__PURE__ */ s.jsx(Ie, { children: r }) })
|
|
410
|
+
] })
|
|
411
|
+
}
|
|
412
|
+
)), De = ({
|
|
413
|
+
field: e
|
|
414
|
+
}) => {
|
|
415
|
+
var A, D, M;
|
|
416
|
+
const { collection: r } = G(), [t, n] = R(!1), { key: i = "", label: d = "", helper_text: o = "", readonly: c = !1 } = e, u = i, g = ((A = e == null ? void 0 : e.options) == null ? void 0 : A.collection_key) || "", x = ((D = e == null ? void 0 : e.options) == null ? void 0 : D.label_field_key) || "", {
|
|
417
|
+
field: { value: l, onBlur: p, onChange: b, ref: W, disabled: X, ...Y },
|
|
418
|
+
fieldState: L
|
|
419
|
+
} = ye({
|
|
420
|
+
name: u,
|
|
421
|
+
rules: Re(e)
|
|
422
|
+
}), Z = !!(e != null && e.required), ee = (M = L == null ? void 0 : L.error) == null ? void 0 : M.message, te = async (y, Ye, { page: N = 1 }) => {
|
|
423
|
+
var S;
|
|
424
|
+
n(!0);
|
|
425
|
+
try {
|
|
426
|
+
const _ = await (r == null ? void 0 : r.getCollectionContentList({
|
|
427
|
+
collection_key: g,
|
|
428
|
+
page: N,
|
|
429
|
+
search: y,
|
|
430
|
+
limit: 10
|
|
431
|
+
})), k = (S = _ == null ? void 0 : _.content) == null ? void 0 : S.data, V = (k || []).map((m) => {
|
|
432
|
+
const ne = m != null && m[x] ? m == null ? void 0 : m[x] : $.toTitle((m == null ? void 0 : m.slug) || "");
|
|
433
|
+
return {
|
|
434
|
+
value: {
|
|
435
|
+
_id: m == null ? void 0 : m._id,
|
|
436
|
+
slug: m == null ? void 0 : m.slug,
|
|
437
|
+
[x]: m == null ? void 0 : m[x]
|
|
438
|
+
},
|
|
439
|
+
label: ne
|
|
440
|
+
};
|
|
441
|
+
});
|
|
442
|
+
return {
|
|
443
|
+
options: Array.isArray(V) ? V : [],
|
|
444
|
+
hasMore: k && !((k == null ? void 0 : k.length) < 10),
|
|
445
|
+
additional: {
|
|
446
|
+
page: N + 1
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
} catch {
|
|
450
|
+
return {
|
|
451
|
+
options: [],
|
|
452
|
+
hasMore: !1,
|
|
453
|
+
additional: {
|
|
454
|
+
page: N
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
} finally {
|
|
458
|
+
n(!1);
|
|
459
|
+
}
|
|
460
|
+
}, re = l ? {
|
|
461
|
+
label: l != null && l[x] ? l == null ? void 0 : l[x] : l != null && l.slug ? $.toTitle((l == null ? void 0 : l.slug) || "") : "",
|
|
462
|
+
value: {
|
|
463
|
+
_id: l == null ? void 0 : l._id,
|
|
464
|
+
slug: l == null ? void 0 : l.slug,
|
|
465
|
+
[x]: l == null ? void 0 : l[x]
|
|
466
|
+
}
|
|
467
|
+
} : null;
|
|
468
|
+
return /* @__PURE__ */ s.jsxs(
|
|
469
|
+
Ae,
|
|
470
|
+
{
|
|
471
|
+
ref: W,
|
|
472
|
+
error: ee,
|
|
473
|
+
helperText: o,
|
|
474
|
+
readOnly: c,
|
|
475
|
+
children: [
|
|
476
|
+
d && /* @__PURE__ */ s.jsx(I, { htmlFor: u, isRequired: Z, children: d }),
|
|
477
|
+
/* @__PURE__ */ s.jsx(
|
|
478
|
+
Ne,
|
|
479
|
+
{
|
|
480
|
+
id: u,
|
|
481
|
+
value: re,
|
|
482
|
+
onChange: (y) => {
|
|
483
|
+
b((y == null ? void 0 : y.value) || null);
|
|
484
|
+
},
|
|
485
|
+
onBlur: () => {
|
|
486
|
+
p();
|
|
487
|
+
},
|
|
488
|
+
loadOptions: te,
|
|
489
|
+
debounceTimeout: 500,
|
|
490
|
+
getOptionLabel: (y) => y == null ? void 0 : y.label,
|
|
491
|
+
getOptionValue: (y) => y == null ? void 0 : y.value,
|
|
492
|
+
isLoading: t,
|
|
493
|
+
additional: {
|
|
494
|
+
page: 1
|
|
495
|
+
},
|
|
496
|
+
cacheUniqs: [g],
|
|
497
|
+
minMenuHeight: 250,
|
|
498
|
+
isDisabled: X,
|
|
499
|
+
...Y
|
|
500
|
+
}
|
|
501
|
+
)
|
|
502
|
+
]
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
}, E = h(() => import("./TextWidget-D0UBxTxe.js")), Me = h(
|
|
506
|
+
() => import("./CurrencyWidget-DVqD_lsY.js")
|
|
507
|
+
), Se = h(
|
|
508
|
+
() => import("./CheckboxWidget-ComdVcZ_.js")
|
|
509
|
+
), U = h(
|
|
510
|
+
() => import("./DateTimeWidget-CvgzwY1U.js")
|
|
511
|
+
), q = h(
|
|
512
|
+
() => import("./DropdownWidget-C2YaM9Cf.js")
|
|
513
|
+
), Ve = h(() => import("./EmailWidget-BBthwF68.js")), $e = h(
|
|
514
|
+
() => import("./GeocoderWidget-Dht_2vi6.js")
|
|
515
|
+
), Pe = h(
|
|
516
|
+
() => import("./MultiGeocoderWidget-paCFW0QZ.js")
|
|
517
|
+
), ze = h(() => import("./PhoneWidget-CP2T2JDx.js")), Be = h(() => import("./RadioWidget-BuFPz7kK.js")), He = h(
|
|
518
|
+
() => import("./RichTextWidget-DGFNZ1jl.js")
|
|
519
|
+
), Ee = h(() => import("./SwitchWidget-t8iwhxk9.js")), Ue = h(
|
|
520
|
+
() => import("./TextareaWidget-CG6J_plD.js")
|
|
521
|
+
), qe = h(
|
|
522
|
+
() => import("./ToggleCheckboxWidget-dl8ks4VX.js")
|
|
523
|
+
), Fe = h(() => import("./URLWidget-CHeUEUXl.js")), T = h(() => import("./UploadWidget-CzYGViqE.js")), Oe = ({
|
|
524
|
+
field: e,
|
|
525
|
+
isInternal: r
|
|
526
|
+
}) => {
|
|
527
|
+
var i, d, o, c;
|
|
528
|
+
const { field_interface: t, key: n } = e;
|
|
529
|
+
if (!t || !n)
|
|
530
|
+
return null;
|
|
531
|
+
switch (t) {
|
|
532
|
+
case a.TextWidget:
|
|
533
|
+
return /* @__PURE__ */ s.jsx(E, { field: e });
|
|
534
|
+
case a.NumberWidget:
|
|
535
|
+
return /* @__PURE__ */ s.jsx(E, { type: "number", field: e });
|
|
536
|
+
case a.CurrencyWidget:
|
|
537
|
+
return /* @__PURE__ */ s.jsx(Me, { field: e });
|
|
538
|
+
case a.CheckboxWidget:
|
|
539
|
+
return /* @__PURE__ */ s.jsx(Se, { field: e });
|
|
540
|
+
case a.DateTimeWidget:
|
|
541
|
+
return /* @__PURE__ */ s.jsx(U, { field: e });
|
|
542
|
+
case a.DateWidget:
|
|
543
|
+
return /* @__PURE__ */ s.jsx(U, { field: e });
|
|
544
|
+
case a.DropdownWidget:
|
|
545
|
+
return /* @__PURE__ */ s.jsx(q, { field: e, isMulti: !1 });
|
|
546
|
+
case a.MultiDropdownWidget:
|
|
547
|
+
return /* @__PURE__ */ s.jsx(q, { field: e, isMulti: !0 });
|
|
548
|
+
case a.EmailWidget:
|
|
549
|
+
return /* @__PURE__ */ s.jsx(Ve, { field: e });
|
|
550
|
+
case a.GeocoderWidget:
|
|
551
|
+
return /* @__PURE__ */ s.jsx($e, { field: e });
|
|
552
|
+
case a.MultiGeocoderWidget:
|
|
553
|
+
return /* @__PURE__ */ s.jsx(Pe, { field: e });
|
|
554
|
+
case a.PhoneWidget:
|
|
555
|
+
return /* @__PURE__ */ s.jsx(ze, { field: e });
|
|
556
|
+
case a.RadioWidget:
|
|
557
|
+
return /* @__PURE__ */ s.jsx(Be, { field: e });
|
|
558
|
+
case a.RichTextWidget:
|
|
559
|
+
return /* @__PURE__ */ s.jsx(He, { field: e });
|
|
560
|
+
case a.SwitchWidget:
|
|
561
|
+
return /* @__PURE__ */ s.jsx(Ee, { field: e });
|
|
562
|
+
case a.TextareaWidget:
|
|
563
|
+
return /* @__PURE__ */ s.jsx(Ue, { field: e });
|
|
564
|
+
case a.ToggleCheckboxWidget:
|
|
565
|
+
return /* @__PURE__ */ s.jsx(qe, { field: e });
|
|
566
|
+
case a.URLWidget:
|
|
567
|
+
return /* @__PURE__ */ s.jsx(Fe, { field: e });
|
|
568
|
+
case a.ImageUploadWidget:
|
|
569
|
+
return /* @__PURE__ */ s.jsx(
|
|
570
|
+
T,
|
|
571
|
+
{
|
|
572
|
+
field: e,
|
|
573
|
+
isMultiple: !1,
|
|
574
|
+
kind: ["image"],
|
|
575
|
+
isExternal: !r
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
case a.MultiImageUploadWidget:
|
|
579
|
+
return /* @__PURE__ */ s.jsx(
|
|
580
|
+
T,
|
|
581
|
+
{
|
|
582
|
+
field: e,
|
|
583
|
+
isMultiple: !0,
|
|
584
|
+
kind: ["image"],
|
|
585
|
+
isExternal: !r
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
case a.FileUploadWidget:
|
|
589
|
+
return /* @__PURE__ */ s.jsx(
|
|
590
|
+
T,
|
|
591
|
+
{
|
|
592
|
+
field: e,
|
|
593
|
+
isMultiple: !1,
|
|
594
|
+
kind: ["document"],
|
|
595
|
+
isExternal: !r
|
|
596
|
+
}
|
|
597
|
+
);
|
|
598
|
+
case a.CollectionWidget:
|
|
599
|
+
return !((i = e == null ? void 0 : e.options) != null && i.collection_key) || !((d = e == null ? void 0 : e.options) != null && d.label_field_key) ? (console.error(
|
|
600
|
+
"[LevoCollection]: Error while rendering collection widget. Collection key of label field key is required."
|
|
601
|
+
), null) : (o = e == null ? void 0 : e.options) != null && o.connected_have_many_current && ((c = e == null ? void 0 : e.options) != null && c.current_have_many_connected) ? (console.error(
|
|
602
|
+
"[LevoCollection]: Error while rendering collection widget. Field options not set correctly."
|
|
603
|
+
), null) : /* @__PURE__ */ s.jsx(De, { field: e });
|
|
604
|
+
default:
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
}, Ge = ({
|
|
608
|
+
field: e,
|
|
609
|
+
isInternal: r
|
|
610
|
+
}) => {
|
|
611
|
+
const { key: t = "", label: n = "", field_interface: i = "", fields: d = [] } = e;
|
|
612
|
+
return !i || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full", children: [
|
|
613
|
+
/* @__PURE__ */ s.jsx(I, { className: "text-md font-medium mb-4", children: n }),
|
|
614
|
+
/* @__PURE__ */ s.jsx("div", { className: "border rounded bg-secondary/40 flex flex-col px-3 py-4 gap-3", children: d.map((o) => {
|
|
615
|
+
const c = {
|
|
616
|
+
...o,
|
|
617
|
+
key: `${t}.${o == null ? void 0 : o.key}`
|
|
618
|
+
};
|
|
619
|
+
return /* @__PURE__ */ s.jsx(
|
|
620
|
+
J,
|
|
621
|
+
{
|
|
622
|
+
field: c,
|
|
623
|
+
isInternal: r
|
|
624
|
+
},
|
|
625
|
+
`common-fields-${e == null ? void 0 : e.id}-${o == null ? void 0 : o.id}`
|
|
626
|
+
);
|
|
627
|
+
}) })
|
|
628
|
+
] });
|
|
629
|
+
}, J = (e) => {
|
|
630
|
+
const { field_interface: r = "", key: t = "" } = e.field;
|
|
631
|
+
if (!r || !t)
|
|
632
|
+
return null;
|
|
633
|
+
switch (r) {
|
|
634
|
+
case a.ArrayWidget:
|
|
635
|
+
return /* @__PURE__ */ s.jsx(Ce, { ...e });
|
|
636
|
+
case a.RecordWidget:
|
|
637
|
+
return /* @__PURE__ */ s.jsx(Ge, { ...e });
|
|
638
|
+
default:
|
|
639
|
+
return /* @__PURE__ */ s.jsx(Oe, { ...e });
|
|
640
|
+
}
|
|
641
|
+
}, Q = j.createContext({
|
|
642
|
+
schema: null,
|
|
643
|
+
submitButtonConfig: {
|
|
644
|
+
show: !0
|
|
645
|
+
}
|
|
646
|
+
}), Ke = ({
|
|
647
|
+
children: e,
|
|
648
|
+
...r
|
|
649
|
+
}) => {
|
|
650
|
+
const { schema: t, onFormView: n } = r, { ref: i } = je({
|
|
651
|
+
triggerOnce: !0,
|
|
652
|
+
onChange: (d) => {
|
|
653
|
+
d && (t != null && t.id) && n && n({ schemaId: t.id });
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
return /* @__PURE__ */ s.jsxs(Q.Provider, { value: { ...r }, children: [
|
|
657
|
+
/* @__PURE__ */ s.jsx("div", { ref: i }),
|
|
658
|
+
e
|
|
659
|
+
] });
|
|
660
|
+
}, bt = () => j.useContext(Q), Je = j.lazy(
|
|
661
|
+
() => import("./DefaultFormVariant-CbRB9O_e.js")
|
|
662
|
+
), Qe = j.lazy(
|
|
663
|
+
() => import("./StepsFormVariant-5_c3f2Vk.js")
|
|
664
|
+
), Xe = ({
|
|
665
|
+
formVariant: e,
|
|
666
|
+
...r
|
|
667
|
+
}) => {
|
|
668
|
+
const { schema: t, uiConfig: n } = r;
|
|
669
|
+
return /* @__PURE__ */ s.jsxs(Ke, { ...r, children: [
|
|
670
|
+
n != null && n.hideFormHeading ? null : /* @__PURE__ */ s.jsxs(
|
|
671
|
+
"h1",
|
|
672
|
+
{
|
|
673
|
+
className: f(
|
|
674
|
+
"text-2xl text-left text-black mb-4 font-semibold",
|
|
675
|
+
e === "default" ? "ml-[32%]" : "ml-0"
|
|
676
|
+
),
|
|
677
|
+
children: [
|
|
678
|
+
"Create new ",
|
|
679
|
+
be.singularize((t == null ? void 0 : t.name) || "")
|
|
680
|
+
]
|
|
681
|
+
}
|
|
682
|
+
),
|
|
683
|
+
/* @__PURE__ */ s.jsx(he, { children: e === "steps" ? /* @__PURE__ */ s.jsx(Qe, {}) : /* @__PURE__ */ s.jsx(Je, {}) })
|
|
684
|
+
] });
|
|
685
|
+
}, jt = ({
|
|
686
|
+
collection_id: e,
|
|
687
|
+
hiddenFields: r,
|
|
688
|
+
...t
|
|
689
|
+
}) => {
|
|
690
|
+
const { collection: n } = G(), [i, d] = R(!0), [o, c] = R(null);
|
|
691
|
+
return pe(() => {
|
|
692
|
+
e ? n == null || n.getCollectionByIDExpanded(e, {
|
|
693
|
+
headers: {
|
|
694
|
+
"Levo-Workspace": t == null ? void 0 : t.workspace_id
|
|
695
|
+
}
|
|
696
|
+
}).then((u) => {
|
|
697
|
+
var x, l;
|
|
698
|
+
const g = (x = u == null ? void 0 : u.content) == null ? void 0 : x.data;
|
|
699
|
+
if (g)
|
|
700
|
+
g.sections = (l = g == null ? void 0 : g.sections) == null ? void 0 : l.map(
|
|
701
|
+
(p) => {
|
|
702
|
+
var b;
|
|
703
|
+
return p.fields = (b = p == null ? void 0 : p.fields) == null ? void 0 : b.map((W) => (r != null && r.includes(W == null ? void 0 : W.key) && (W.hidden = !0), W)), p;
|
|
704
|
+
}
|
|
705
|
+
), c(g);
|
|
706
|
+
else
|
|
707
|
+
throw new Error(`API response invalid: ${g}`);
|
|
708
|
+
}).catch((u) => {
|
|
709
|
+
console.error("Error fetching schema", u);
|
|
710
|
+
}).finally(() => {
|
|
711
|
+
d(!1);
|
|
712
|
+
}) : (console.error(
|
|
713
|
+
"[CollectionFormBuilder] Collection ID or Workspace ID is missing."
|
|
714
|
+
), d(!1));
|
|
715
|
+
}, [e]), /* @__PURE__ */ s.jsx("div", { className: "w-full h-auto", children: i ? /* @__PURE__ */ s.jsx("div", { className: "min-h-[400px] w-full flex justify-center items-center bg-white rounded-md", children: /* @__PURE__ */ s.jsx(me, {}) }) : o ? /* @__PURE__ */ s.jsx(Xe, { schema: o, ...t }) : null });
|
|
716
|
+
};
|
|
717
|
+
export {
|
|
718
|
+
jt as C,
|
|
719
|
+
J as F,
|
|
720
|
+
Wt as H,
|
|
721
|
+
K as a,
|
|
722
|
+
ht as b,
|
|
723
|
+
B as c,
|
|
724
|
+
pt as d,
|
|
725
|
+
ve as e,
|
|
726
|
+
ft as f,
|
|
727
|
+
C as g,
|
|
728
|
+
Re as h,
|
|
729
|
+
we as i,
|
|
730
|
+
Ae as j,
|
|
731
|
+
I as k,
|
|
732
|
+
_e as l,
|
|
733
|
+
bt as m,
|
|
734
|
+
z as p,
|
|
735
|
+
yt as s,
|
|
736
|
+
xt as u,
|
|
737
|
+
mt as v
|
|
738
|
+
};
|