@levo-so/react 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CheckboxWidget-CNoS-2W3.js +124 -0
- package/dist/CollectionFormBuilder-MAo2Ob3a.js +1199 -0
- package/dist/{CurrencyWidget-COoMkfsA.js → CurrencyWidget-Cu1Cthnw.js} +5 -5
- package/dist/{DateTimeWidget-DcbQ3smI.js → DateTimeWidget-N-wuCRSJ.js} +3 -3
- package/dist/DefaultFormVariant-IqWi1BiT.js +81 -0
- package/dist/DropdownWidget-BFttB4b-.js +115 -0
- package/dist/{EmailWidget-CG9oNUM5.js → EmailWidget-D_SqXx3M.js} +11 -11
- package/dist/FormCaptcha-CJ9KgDu0.js +197 -0
- package/dist/GeocoderWidget-Bxt3TeAf.js +68 -0
- package/dist/LevoProvider-BAZy7_tP.js +223 -0
- package/dist/{MultiGeocoderWidget-D3Xmv8g4.js → MultiGeocoderWidget-DFjuXZBN.js} +6 -6
- package/dist/{MultiTextWidget-CyQRcWC8.js → MultiTextWidget-CZzT51cH.js} +14 -14
- package/dist/{PhoneWidget-C1Jt7kXL.js → PhoneWidget--K5aS16s.js} +5 -5
- package/dist/{RadioWidget-BrLNF-I2.js → RadioWidget-BbMPtR3P.js} +9 -9
- package/dist/{RichTextWidget-BogYcPtS.js → RichTextWidget-Cce3Bw8d.js} +21 -21
- package/dist/Spinner-Bzu2xCFZ.js +405 -0
- package/dist/{StepsFormVariant-Bx-jdciC.js → StepsFormVariant-5wZbYAA9.js} +58 -55
- package/dist/{SwitchWidget-BT0-waP9.js → SwitchWidget-B0wkSWxa.js} +5 -5
- package/dist/{TextWidget-Bvsz-hey.js → TextWidget-ldbMuLB0.js} +7 -7
- package/dist/{TextareaWidget-8SLym--T.js → TextareaWidget-S8bKUTv0.js} +3 -3
- package/dist/{ToggleCheckboxWidget-VrCQBF5C.js → ToggleCheckboxWidget-CPduXE6Y.js} +7 -7
- package/dist/Tooltip-DEBnSqlo.js +36 -0
- package/dist/{URLWidget-B99nKr6N.js → URLWidget-KbhE2ZUA.js} +2 -2
- package/dist/UploadWidget-DFvfDUT6.js +616 -0
- package/dist/audience/components/block.d.ts.map +1 -1
- package/dist/audience/components/component.d.ts.map +1 -1
- package/dist/audience/components/page.d.ts.map +1 -1
- package/dist/audience/index.js +1 -1
- package/dist/collection/components/Altcha.d.ts +10 -0
- package/dist/collection/components/Altcha.d.ts.map +1 -0
- package/dist/collection/components/FormCaptcha.d.ts +3 -0
- package/dist/collection/components/FormCaptcha.d.ts.map +1 -0
- package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +1 -1
- package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +1 -1
- package/dist/collection/components/core/Input/Input.d.ts.map +1 -1
- package/dist/collection/components/core/Switch/Switch.d.ts.map +1 -1
- package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -1
- package/dist/collection/components/widgets/FieldWrapper.d.ts.map +1 -1
- package/dist/collection/components/widgets/FormHelperText.d.ts.map +1 -1
- package/dist/collection/components/widgets/FormLabel.d.ts.map +1 -1
- package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +1 -1
- package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts +7 -0
- package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -0
- package/dist/collection/components/widgets/collectionWidget/{CollectionWidget.d.ts → CollectionWidgetM2O.d.ts} +1 -1
- package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts.map +1 -0
- package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts +8 -0
- package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +1 -0
- package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts +11 -0
- package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -0
- package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -1
- package/dist/collection/index.js +13 -12
- package/dist/collection/lib/FormBuilder.d.ts.map +1 -1
- package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -1
- package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -1
- package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -1
- package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +1 -1
- package/dist/collection/utils/formHelpers.d.ts.map +1 -1
- package/dist/collection/utils/index.d.ts +2 -0
- package/dist/collection/utils/index.d.ts.map +1 -1
- package/dist/components/Dialog.d.ts.map +1 -1
- package/dist/components/Spinner.d.ts.map +1 -1
- package/dist/components/Table.d.ts +11 -0
- package/dist/components/Table.d.ts.map +1 -0
- package/dist/components/Tabs.d.ts.map +1 -1
- package/dist/components/Tooltip.d.ts.map +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/index.js +29 -29
- package/dist/constants/fileUploadPresets.d.ts +4 -2
- package/dist/constants/fileUploadPresets.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +75 -75
- package/dist/membership/components/Button.d.ts.map +1 -1
- package/dist/membership/components/Container.d.ts.map +1 -1
- package/dist/membership/components/Core.d.ts.map +1 -1
- package/dist/membership/index.js +2 -3
- package/dist/page-BKyDlf0z.js +212 -0
- package/dist/utils/errorHandler.d.ts.map +1 -1
- package/package.json +12 -11
- package/dist/CheckboxWidget-BctVOZiO.js +0 -118
- package/dist/CollectionFormBuilder-B6CAVKhg.js +0 -772
- package/dist/DefaultFormVariant-C6zbKgwB.js +0 -80
- package/dist/DropdownWidget-DszCTSWr.js +0 -115
- package/dist/GeocoderWidget-CXu17A7y.js +0 -310
- package/dist/LevoProvider-BI6g_T4E.js +0 -212
- package/dist/Spinner-DzGH5rKe.js +0 -297
- package/dist/Tooltip-CI4i4mYr.js +0 -144
- package/dist/UploadWidget-ZebPWZZZ.js +0 -505
- package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts.map +0 -1
- package/dist/fileUploadPresets-2raQmHT0.js +0 -74
- package/dist/page-yeiAPg3O.js +0 -200
- package/dist/useLevoForm-DjvUas25.js +0 -166
|
@@ -2,23 +2,23 @@ import { j as t } from "./jsx-runtime-B6kdoens.js";
|
|
|
2
2
|
import { useController as j } from "react-hook-form";
|
|
3
3
|
import { NumericFormat as F } from "react-number-format";
|
|
4
4
|
import { c as w } from "./cn-C9QoOYNG.js";
|
|
5
|
-
import {
|
|
5
|
+
import { z as C, A as B, B as N } from "./CollectionFormBuilder-MAo2Ob3a.js";
|
|
6
6
|
const V = ({
|
|
7
7
|
field: r,
|
|
8
8
|
...m
|
|
9
9
|
}) => {
|
|
10
10
|
var u, c;
|
|
11
11
|
const { key: d = "", label: n = "", helper_text: p = "", readonly: e = !1 } = r, o = d, {
|
|
12
|
-
field: { value: f, onBlur: a, onChange: l, ref:
|
|
12
|
+
field: { value: f, onBlur: a, onChange: l, ref: x, ...h },
|
|
13
13
|
fieldState: s
|
|
14
14
|
} = j({
|
|
15
15
|
name: o,
|
|
16
16
|
rules: C(r)
|
|
17
17
|
}), b = !!(r != null && r.required), g = (u = s == null ? void 0 : s.error) == null ? void 0 : u.message, i = (c = r == null ? void 0 : r.options) == null ? void 0 : c.currency_code;
|
|
18
18
|
return /* @__PURE__ */ t.jsxs(
|
|
19
|
-
|
|
19
|
+
B,
|
|
20
20
|
{
|
|
21
|
-
ref:
|
|
21
|
+
ref: x,
|
|
22
22
|
error: g,
|
|
23
23
|
helperText: p,
|
|
24
24
|
readOnly: e,
|
|
@@ -46,7 +46,7 @@ const V = ({
|
|
|
46
46
|
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
47
47
|
e && "focus-visible:ring-0"
|
|
48
48
|
),
|
|
49
|
-
...
|
|
49
|
+
...h,
|
|
50
50
|
...m
|
|
51
51
|
}
|
|
52
52
|
)
|
|
@@ -4,7 +4,7 @@ import { Calendar as w, X as N } from "lucide-react";
|
|
|
4
4
|
import * as l from "react-datepicker";
|
|
5
5
|
import { useController as v } from "react-hook-form";
|
|
6
6
|
import { c as p } from "./cn-C9QoOYNG.js";
|
|
7
|
-
import {
|
|
7
|
+
import { z as M, A as D, B as C } from "./CollectionFormBuilder-MAo2Ob3a.js";
|
|
8
8
|
import { I as F } from "./Input-2CvZ90f8.js";
|
|
9
9
|
const T = l.default.default || l.default || l, I = (e) => {
|
|
10
10
|
if (e) {
|
|
@@ -12,7 +12,7 @@ const T = l.default.default || l.default || l, I = (e) => {
|
|
|
12
12
|
return Number.isNaN(o.getTime()) ? null : o;
|
|
13
13
|
}
|
|
14
14
|
return null;
|
|
15
|
-
},
|
|
15
|
+
}, q = ({ field: e }) => {
|
|
16
16
|
var d;
|
|
17
17
|
const { key: o = "", label: m = "", helper_text: f = "", readonly: x = !1 } = e, n = o, {
|
|
18
18
|
field: { value: i, onBlur: u, onChange: s, ref: h, ...j },
|
|
@@ -76,5 +76,5 @@ const T = l.default.default || l.default || l, I = (e) => {
|
|
|
76
76
|
] });
|
|
77
77
|
};
|
|
78
78
|
export {
|
|
79
|
-
|
|
79
|
+
q as default
|
|
80
80
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { j as e } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
+
import { FormProvider as y } from "react-hook-form";
|
|
3
|
+
import { c as t } from "./cn-C9QoOYNG.js";
|
|
4
|
+
import { D as F, F as g } from "./CollectionFormBuilder-MAo2Ob3a.js";
|
|
5
|
+
import { u as w, S as N, F as b } from "./FormCaptcha-CJ9KgDu0.js";
|
|
6
|
+
import { B as D } from "./Spinner-Bzu2xCFZ.js";
|
|
7
|
+
const _ = () => {
|
|
8
|
+
var n;
|
|
9
|
+
const {
|
|
10
|
+
schema: l,
|
|
11
|
+
containerStyles: c,
|
|
12
|
+
uiConfig: m,
|
|
13
|
+
isInternal: d,
|
|
14
|
+
submitButtonConfig: a,
|
|
15
|
+
isDisabled: x
|
|
16
|
+
} = F(), {
|
|
17
|
+
methods: o,
|
|
18
|
+
allFormValues: p,
|
|
19
|
+
isError: h,
|
|
20
|
+
isLoading: u,
|
|
21
|
+
handleContentId: f,
|
|
22
|
+
handleSubmit: j
|
|
23
|
+
} = w({
|
|
24
|
+
schema: l,
|
|
25
|
+
saveToRemote: !0
|
|
26
|
+
}), {
|
|
27
|
+
formState: { isSubmitting: v }
|
|
28
|
+
} = o, S = o.watch("__captcha");
|
|
29
|
+
return /* @__PURE__ */ e.jsxs(y, { ...o, children: [
|
|
30
|
+
/* @__PURE__ */ e.jsx(
|
|
31
|
+
N,
|
|
32
|
+
{
|
|
33
|
+
getContentId: (s) => f(s),
|
|
34
|
+
isError: h,
|
|
35
|
+
currentValues: p
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ e.jsx("div", { className: t("w-full", c), children: /* @__PURE__ */ e.jsxs(
|
|
39
|
+
"form",
|
|
40
|
+
{
|
|
41
|
+
className: t(
|
|
42
|
+
"w-full bg-white rounded-md flex flex-col gap-6 px-4 md:px-8 py-6",
|
|
43
|
+
u && "opacity-50 pointer-events-none"
|
|
44
|
+
),
|
|
45
|
+
id: "collection-form",
|
|
46
|
+
onSubmit: j,
|
|
47
|
+
children: [
|
|
48
|
+
(n = l == null ? void 0 : l.sections) == null ? void 0 : n.map((s) => {
|
|
49
|
+
var i;
|
|
50
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "w-full", children: [
|
|
51
|
+
!(m != null && m.hideSectionHeadings) && /* @__PURE__ */ e.jsx("p", { className: t("mb-4 text-lg font-semibold"), children: s == null ? void 0 : s.label }),
|
|
52
|
+
/* @__PURE__ */ e.jsx("div", { className: t("flex flex-col gap-4"), children: (i = s == null ? void 0 : s.fields) == null ? void 0 : i.map((r) => r && !r.hidden ? /* @__PURE__ */ e.jsx(
|
|
53
|
+
g,
|
|
54
|
+
{
|
|
55
|
+
field: r,
|
|
56
|
+
isInternal: d
|
|
57
|
+
},
|
|
58
|
+
r == null ? void 0 : r.key
|
|
59
|
+
) : null) })
|
|
60
|
+
] }, s.id);
|
|
61
|
+
}),
|
|
62
|
+
!d && /* @__PURE__ */ e.jsx(b, {}),
|
|
63
|
+
(a == null ? void 0 : a.show) && /* @__PURE__ */ e.jsx("div", { className: "w-full flex items-center justify-end mt-6", children: /* @__PURE__ */ e.jsx(
|
|
64
|
+
D,
|
|
65
|
+
{
|
|
66
|
+
className: a == null ? void 0 : a.styles,
|
|
67
|
+
loadingText: "Saving",
|
|
68
|
+
isLoading: v,
|
|
69
|
+
disabled: x,
|
|
70
|
+
type: "submit",
|
|
71
|
+
children: S === "verifying" ? "Verifying..." : (a == null ? void 0 : a.text) || "Save"
|
|
72
|
+
}
|
|
73
|
+
) })
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
) })
|
|
77
|
+
] });
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
_ as default
|
|
81
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { j as d } from "./jsx-runtime-B6kdoens.js";
|
|
3
|
+
import { useState as x, useEffect as w } from "react";
|
|
4
|
+
import { useController as B } from "react-hook-form";
|
|
5
|
+
import D from "react-select";
|
|
6
|
+
import { c as y } from "./cn-C9QoOYNG.js";
|
|
7
|
+
import { z as N, A as k, B as q } from "./CollectionFormBuilder-MAo2Ob3a.js";
|
|
8
|
+
import { I as L } from "./Input-2CvZ90f8.js";
|
|
9
|
+
const G = ({
|
|
10
|
+
field: s,
|
|
11
|
+
...o
|
|
12
|
+
}) => {
|
|
13
|
+
var j;
|
|
14
|
+
const [t, I] = x([]), [h, g] = x(""), [p, i] = x(!1), {
|
|
15
|
+
key: C = "",
|
|
16
|
+
label: v = "",
|
|
17
|
+
helper_text: S = "",
|
|
18
|
+
readonly: O = !1,
|
|
19
|
+
values: n = [],
|
|
20
|
+
options: c = {}
|
|
21
|
+
} = s, u = C, {
|
|
22
|
+
field: { value: l, onBlur: E, onChange: a, disabled: F, ...M },
|
|
23
|
+
fieldState: f
|
|
24
|
+
} = B({
|
|
25
|
+
name: u,
|
|
26
|
+
rules: N(s)
|
|
27
|
+
}), P = !!(s != null && s.required), R = (j = f == null ? void 0 : f.error) == null ? void 0 : j.message, m = !!(c != null && c.custom_input);
|
|
28
|
+
return w(() => {
|
|
29
|
+
if (n != null && n.length) {
|
|
30
|
+
const r = [...n == null ? void 0 : n.map((b) => ({
|
|
31
|
+
label: b,
|
|
32
|
+
value: b
|
|
33
|
+
}))];
|
|
34
|
+
m && r.push({
|
|
35
|
+
label: "Other",
|
|
36
|
+
value: "Other"
|
|
37
|
+
}), I(r);
|
|
38
|
+
}
|
|
39
|
+
}, [n, m]), w(() => {
|
|
40
|
+
!(o != null && o.isMulti) && m && typeof l == "string" && l && ((t == null ? void 0 : t.findIndex(
|
|
41
|
+
(r) => (r == null ? void 0 : r.value) !== "Other" && (r == null ? void 0 : r.value) === l
|
|
42
|
+
)) === -1 ? (i(!0), g(l)) : i(!1));
|
|
43
|
+
}, [l, t]), /* @__PURE__ */ d.jsxs(k, { error: R, helperText: S, readOnly: O, children: [
|
|
44
|
+
v && /* @__PURE__ */ d.jsx(q, { htmlFor: u, isRequired: P, children: v }),
|
|
45
|
+
/* @__PURE__ */ d.jsx(
|
|
46
|
+
D,
|
|
47
|
+
{
|
|
48
|
+
id: u,
|
|
49
|
+
value: p ? {
|
|
50
|
+
label: "Other, Please Specify",
|
|
51
|
+
value: "Other"
|
|
52
|
+
} : l ? o != null && o.isMulti ? t == null ? void 0 : t.filter(
|
|
53
|
+
(e) => l == null ? void 0 : l.includes(e == null ? void 0 : e.value)
|
|
54
|
+
) : t == null ? void 0 : t.find((e) => (e == null ? void 0 : e.value) === l) : null,
|
|
55
|
+
onChange: (e) => {
|
|
56
|
+
m && (e == null ? void 0 : e.value) === "Other" && (e == null ? void 0 : e.label) === "Other, Please Specify" ? (i(!0), a(h)) : (i(!1), o != null && o.isMulti ? a(e == null ? void 0 : e.map((r) => r == null ? void 0 : r.value)) : a(e == null ? void 0 : e.value));
|
|
57
|
+
},
|
|
58
|
+
onBlur: () => E(),
|
|
59
|
+
options: t,
|
|
60
|
+
isDisabled: F,
|
|
61
|
+
menuPlacement: "auto",
|
|
62
|
+
...M,
|
|
63
|
+
...o,
|
|
64
|
+
unstyled: !0,
|
|
65
|
+
classNames: {
|
|
66
|
+
container: () => y("w-full min-w-none h-auto min-h-none"),
|
|
67
|
+
control: ({ isFocused: e, isMulti: r, isDisabled: b }) => y(
|
|
68
|
+
"w-full pl-3",
|
|
69
|
+
r ? "!min-h-9 h-auto" : "h-9 !min-h-none",
|
|
70
|
+
"rounded-md border bg-transparent hover:cursor-pointer border-input text-sm shadow-sm transition-colors",
|
|
71
|
+
"flex ",
|
|
72
|
+
e && "outline-none ring-1 ring-ring",
|
|
73
|
+
O && "ring-0",
|
|
74
|
+
b && "cursor-not-allowed opacity-50"
|
|
75
|
+
),
|
|
76
|
+
input: () => "",
|
|
77
|
+
valueContainer: () => "gap-[4px] py-1",
|
|
78
|
+
singleValue: () => "",
|
|
79
|
+
multiValue: () => "bg-gray-100 rounded items-center py-0.5 pl-2 pr-1 gap-1.5",
|
|
80
|
+
multiValueLabel: () => "py-0.5",
|
|
81
|
+
multiValueRemove: () => "border border-gray-200 bg-white hover:bg-red-50 hover:text-red-800 text-gray-500 hover:border-red-300 rounded-md",
|
|
82
|
+
indicatorsContainer: () => "",
|
|
83
|
+
clearIndicator: () => "text-gray-500 p-1 rounded-md hover:bg-red-50 hover:text-red-800",
|
|
84
|
+
indicatorSeparator: () => "",
|
|
85
|
+
dropdownIndicator: () => "p-1 hover:bg-gray-100 text-gray-500 rounded-md hover:text-black",
|
|
86
|
+
menu: () => "p-1 mt-2 border border-gray-200 bg-white rounded-md",
|
|
87
|
+
groupHeading: () => "ml-3 mt-2 mb-1 text-gray-500 text-sm",
|
|
88
|
+
placeholder: () => "text-gray-500 pl-1 py-0.5",
|
|
89
|
+
option: ({ isSelected: e, isFocused: r }) => y(
|
|
90
|
+
"text-sm font-medium hover:cursor-pointer px-3 py-2 rounded",
|
|
91
|
+
r && "bg-gray-100 active:bg-gray-200",
|
|
92
|
+
e && "text-white bg-primary/80"
|
|
93
|
+
),
|
|
94
|
+
noOptionsMessage: () => "text-gray-500 p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
p && /* @__PURE__ */ d.jsx("div", { className: "w-full", children: /* @__PURE__ */ d.jsx(
|
|
99
|
+
L,
|
|
100
|
+
{
|
|
101
|
+
name: `select-other-${u}`,
|
|
102
|
+
value: h,
|
|
103
|
+
onChange: (e) => {
|
|
104
|
+
a == null || a(e.target.value), g(e.target.value);
|
|
105
|
+
},
|
|
106
|
+
className: "mt-4",
|
|
107
|
+
placeholder: "Other, Please Specify"
|
|
108
|
+
}
|
|
109
|
+
) })
|
|
110
|
+
] });
|
|
111
|
+
};
|
|
112
|
+
export {
|
|
113
|
+
G as DropdownWidget,
|
|
114
|
+
G as default
|
|
115
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { j as r } from "./jsx-runtime-B6kdoens.js";
|
|
2
2
|
import { useController as y } from "react-hook-form";
|
|
3
|
-
import { G as C } from "./Spinner-
|
|
4
|
-
import {
|
|
3
|
+
import { G as C } from "./Spinner-Bzu2xCFZ.js";
|
|
4
|
+
import { z as F, A as I, B as V } from "./CollectionFormBuilder-MAo2Ob3a.js";
|
|
5
5
|
import { I as b } from "./Input-2CvZ90f8.js";
|
|
6
6
|
function w(e) {
|
|
7
7
|
return C({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M1.75 3h20.5c.966 0 1.75.784 1.75 1.75v14a1.75 1.75 0 0 1-1.75 1.75H1.75A1.75 1.75 0 0 1 0 18.75v-14C0 3.784.784 3 1.75 3ZM1.5 7.412V18.75c0 .138.112.25.25.25h20.5a.25.25 0 0 0 .25-.25V7.412l-9.52 6.433c-.592.4-1.368.4-1.96 0Zm0-2.662v.852l10.36 7a.25.25 0 0 0 .28 0l10.36-7V4.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z" }, child: [] }] })(e);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const Z = ({ field: e, ...c }) => {
|
|
10
10
|
var l;
|
|
11
|
-
const { key: u = "", label: s = "", helper_text: d = "", readonly:
|
|
12
|
-
field: { value:
|
|
11
|
+
const { key: u = "", label: s = "", helper_text: d = "", readonly: p = !1 } = e, t = u, {
|
|
12
|
+
field: { value: h, onBlur: x, onChange: g, ...f },
|
|
13
13
|
fieldState: a
|
|
14
14
|
} = y({
|
|
15
15
|
name: t,
|
|
16
16
|
rules: F(e)
|
|
17
|
-
}),
|
|
18
|
-
return /* @__PURE__ */ r.jsxs(I, { error:
|
|
19
|
-
s && /* @__PURE__ */ r.jsx(V, { htmlFor: t, isRequired:
|
|
17
|
+
}), v = !!(e != null && e.required), j = (l = a == null ? void 0 : a.error) == null ? void 0 : l.message;
|
|
18
|
+
return /* @__PURE__ */ r.jsxs(I, { error: j, helperText: d, children: [
|
|
19
|
+
s && /* @__PURE__ */ r.jsx(V, { htmlFor: t, isRequired: v, children: s }),
|
|
20
20
|
/* @__PURE__ */ r.jsx(
|
|
21
21
|
b,
|
|
22
22
|
{
|
|
23
23
|
id: t,
|
|
24
24
|
type: "email",
|
|
25
25
|
leftIcon: /* @__PURE__ */ r.jsx("div", { className: "w-full h-full flex items-center justify-center bg-muted", children: /* @__PURE__ */ r.jsx(w, { size: "20px", className: "text-muted-foreground" }) }),
|
|
26
|
-
value:
|
|
26
|
+
value: h || "",
|
|
27
27
|
onChange: (o) => {
|
|
28
28
|
var n, i, m;
|
|
29
29
|
return g((m = (i = (n = o == null ? void 0 : o.target) == null ? void 0 : n.value) == null ? void 0 : i.trim()) == null ? void 0 : m.toLocaleLowerCase());
|
|
30
30
|
},
|
|
31
31
|
onBlur: x,
|
|
32
|
-
readOnly:
|
|
32
|
+
readOnly: p,
|
|
33
33
|
...f,
|
|
34
34
|
...c
|
|
35
35
|
}
|
|
@@ -37,5 +37,5 @@ const k = ({ field: e, ...c }) => {
|
|
|
37
37
|
] });
|
|
38
38
|
};
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
Z as default
|
|
41
41
|
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as O, useState as L, useRef as N } from "react";
|
|
3
|
+
import { useFormContext as B, useWatch as G, useForm as H, useController as z } from "react-hook-form";
|
|
4
|
+
import { useDebouncedCallback as Q } from "use-debounce";
|
|
5
|
+
import { u as x } from "./LevoProvider-BAZy7_tP.js";
|
|
6
|
+
import { D as C, c as T, s as X, h as Z, A as m } from "./CollectionFormBuilder-MAo2Ob3a.js";
|
|
7
|
+
import { s as h } from "./Sonner-t6JVKA0a.js";
|
|
8
|
+
import { e as U } from "./errorHandler-_34Yv8wA.js";
|
|
9
|
+
import { a as tt } from "./isEmptyObject-C5s4GzLE.js";
|
|
10
|
+
import { j as M } from "./jsx-runtime-B6kdoens.js";
|
|
11
|
+
import "altcha";
|
|
12
|
+
const R = {
|
|
13
|
+
FORM_DIRTY: "form-dirty",
|
|
14
|
+
FORM_VALUES: "form-values"
|
|
15
|
+
}, et = (t) => {
|
|
16
|
+
const o = localStorage.getItem(`${t}-${R.FORM_VALUES}`);
|
|
17
|
+
return o ? JSON.parse(o) : {};
|
|
18
|
+
}, rt = (t, o) => {
|
|
19
|
+
localStorage.setItem(
|
|
20
|
+
`${t}-${R.FORM_VALUES}`,
|
|
21
|
+
JSON.stringify(o)
|
|
22
|
+
);
|
|
23
|
+
}, J = (t) => {
|
|
24
|
+
localStorage.removeItem(`${t}-${R.FORM_VALUES}`);
|
|
25
|
+
}, nt = async ({
|
|
26
|
+
collection_key: t,
|
|
27
|
+
data: o
|
|
28
|
+
}) => {
|
|
29
|
+
const { client: c } = x(), e = await fetch(
|
|
30
|
+
`${c.apiUrl}/v1/bevy/content/${t}/save-entry`,
|
|
31
|
+
{
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify({ ...o }),
|
|
34
|
+
headers: {
|
|
35
|
+
"Content-Type": "application/json"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
return e != null && e.ok ? await e.json() : null;
|
|
40
|
+
}, pt = ({ currentValues: t, isError: o, getContentId: c }) => {
|
|
41
|
+
var I;
|
|
42
|
+
const { schema: e, isLoggedIn: f } = C(), r = B(), s = G(), S = Q((v) => {
|
|
43
|
+
e != null && e.key && !o && e != null && e.allow_draft && (f ? nt({
|
|
44
|
+
collection_key: e == null ? void 0 : e.key,
|
|
45
|
+
data: v
|
|
46
|
+
}).then((l) => {
|
|
47
|
+
var E, k, _, d;
|
|
48
|
+
(k = (E = l == null ? void 0 : l.content) == null ? void 0 : E.data) != null && k._id && c((d = (_ = l == null ? void 0 : l.content) == null ? void 0 : _.data) == null ? void 0 : d._id);
|
|
49
|
+
}) : rt(e == null ? void 0 : e.key, v));
|
|
50
|
+
}, 2500);
|
|
51
|
+
return O(() => {
|
|
52
|
+
var v, l;
|
|
53
|
+
o || (v = r == null ? void 0 : r.formState) != null && v.isDirty && ((l = Object == null ? void 0 : Object.keys(s || {})) == null ? void 0 : l.length) > 0 && S({
|
|
54
|
+
currentValues: t,
|
|
55
|
+
...s
|
|
56
|
+
});
|
|
57
|
+
}, [(I = r == null ? void 0 : r.formState) == null ? void 0 : I.isDirty, o, f, s]), null;
|
|
58
|
+
}, gt = ({
|
|
59
|
+
schema: t,
|
|
60
|
+
saveToRemote: o,
|
|
61
|
+
onSubmit: c,
|
|
62
|
+
onSubmitSuccess: e,
|
|
63
|
+
onSubmitError: f
|
|
64
|
+
}) => {
|
|
65
|
+
const { collection: r } = x(), {
|
|
66
|
+
toastConfig: s,
|
|
67
|
+
onSuccess: S,
|
|
68
|
+
onError: I,
|
|
69
|
+
isLoggedIn: v,
|
|
70
|
+
isDisabled: l,
|
|
71
|
+
externalInitialValues: E = {}
|
|
72
|
+
} = C(), [k, _] = L({}), [d, w] = L(null), [P, $] = L(!1), [q, A] = L(!1), n = N({}), K = T(t), V = H({
|
|
73
|
+
mode: "all",
|
|
74
|
+
disabled: l,
|
|
75
|
+
defaultValues: K,
|
|
76
|
+
values: k,
|
|
77
|
+
resetOptions: {
|
|
78
|
+
keepErrors: !0
|
|
79
|
+
}
|
|
80
|
+
}), W = V.handleSubmit(async (y) => {
|
|
81
|
+
var F, g, p, i, j, D;
|
|
82
|
+
if (n.current = {
|
|
83
|
+
...n.current || {},
|
|
84
|
+
...y
|
|
85
|
+
}, o && r) {
|
|
86
|
+
if (t)
|
|
87
|
+
try {
|
|
88
|
+
const a = X(n == null ? void 0 : n.current, t);
|
|
89
|
+
let u = null;
|
|
90
|
+
if (d ? u = await (r == null ? void 0 : r.submitDraftEntry(t == null ? void 0 : t.key, a).catch((b) => (U(b), null))) : u = await (r == null ? void 0 : r.saveCollectionData({
|
|
91
|
+
collection_id: t == null ? void 0 : t.id,
|
|
92
|
+
data: a
|
|
93
|
+
}).catch((b) => (U(b), null))), (F = u == null ? void 0 : u.content) != null && F.data)
|
|
94
|
+
return s != null && s.showSuccessToast && h(
|
|
95
|
+
s.successToastText || "Form submitted successfully."
|
|
96
|
+
), n.current = tt(E) ? {} : { ...E }, J(t == null ? void 0 : t.key), w(null), S && S({
|
|
97
|
+
schemaId: t == null ? void 0 : t.id,
|
|
98
|
+
response: (g = u == null ? void 0 : u.content) == null ? void 0 : g.data
|
|
99
|
+
}), e && e(), V.reset(), V.clearErrors(), !0;
|
|
100
|
+
throw new Error("Failed to save form details, API response invalid");
|
|
101
|
+
} catch (a) {
|
|
102
|
+
const u = (j = (i = (p = a == null ? void 0 : a.response) == null ? void 0 : p.data) == null ? void 0 : i.content) == null ? void 0 : j.errors;
|
|
103
|
+
return Z(u, V.setError), f && f(u), I && I(((D = a == null ? void 0 : a.response) == null ? void 0 : D.data) || a), !1;
|
|
104
|
+
}
|
|
105
|
+
return !1;
|
|
106
|
+
}
|
|
107
|
+
y && c && c(y);
|
|
108
|
+
}), Y = (y) => {
|
|
109
|
+
y && y !== d && w(y);
|
|
110
|
+
};
|
|
111
|
+
return O(() => {
|
|
112
|
+
if (t && r) {
|
|
113
|
+
const y = T(t);
|
|
114
|
+
if (n.current = {
|
|
115
|
+
...y,
|
|
116
|
+
...E || {},
|
|
117
|
+
...n.current || {}
|
|
118
|
+
}, !d && t != null && t.allow_draft) {
|
|
119
|
+
if (v) {
|
|
120
|
+
$(!0), r == null || r.getDraftEntry(t == null ? void 0 : t.key).then((g) => {
|
|
121
|
+
if (g === null) {
|
|
122
|
+
A(!0);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
A(!1);
|
|
126
|
+
const p = Array.isArray(g) ? g == null ? void 0 : g.filter((i) => (i == null ? void 0 : i._status) === "draft") : [];
|
|
127
|
+
if ((p == null ? void 0 : p.length) > 0) {
|
|
128
|
+
const i = (p == null ? void 0 : p[0]) || {};
|
|
129
|
+
i != null && i._id && (n.current = {
|
|
130
|
+
...n.current || {},
|
|
131
|
+
...i
|
|
132
|
+
}, w(i == null ? void 0 : i._id));
|
|
133
|
+
}
|
|
134
|
+
}).catch(() => null).finally(() => {
|
|
135
|
+
_({
|
|
136
|
+
...n == null ? void 0 : n.current
|
|
137
|
+
}), $(!1);
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const F = et(t == null ? void 0 : t.key);
|
|
142
|
+
F && (n.current = {
|
|
143
|
+
...F,
|
|
144
|
+
...n.current || {}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
_({
|
|
148
|
+
...(n == null ? void 0 : n.current) || {}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}, [t]), O(() => {
|
|
152
|
+
t && d && J(t == null ? void 0 : t.key);
|
|
153
|
+
}, [d]), {
|
|
154
|
+
methods: V,
|
|
155
|
+
isLoading: P,
|
|
156
|
+
isError: q,
|
|
157
|
+
contentId: d,
|
|
158
|
+
allFormValues: n.current,
|
|
159
|
+
handleContentId: Y,
|
|
160
|
+
handleSubmit: W
|
|
161
|
+
};
|
|
162
|
+
}, St = () => {
|
|
163
|
+
const { isInternal: t } = C(), { client: o } = x(), c = N(null), {
|
|
164
|
+
field: { onChange: e },
|
|
165
|
+
fieldState: { error: f }
|
|
166
|
+
} = z({
|
|
167
|
+
name: "__captcha",
|
|
168
|
+
rules: {
|
|
169
|
+
required: t ? !1 : "Verification is required"
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
return O(() => {
|
|
173
|
+
const r = (S) => {
|
|
174
|
+
"detail" in S && e(S.detail.state || null);
|
|
175
|
+
}, { current: s } = c;
|
|
176
|
+
if (s)
|
|
177
|
+
return s.addEventListener("statechange", r), () => s.removeEventListener("statechange", r);
|
|
178
|
+
}, []), /* @__PURE__ */ M.jsx(m, { error: f == null ? void 0 : f.message, children: /* @__PURE__ */ M.jsx(
|
|
179
|
+
"altcha-widget",
|
|
180
|
+
{
|
|
181
|
+
ref: c,
|
|
182
|
+
style: {
|
|
183
|
+
"--altcha-max-width": "100%"
|
|
184
|
+
},
|
|
185
|
+
hidelogo: !0,
|
|
186
|
+
auto: "onfocus",
|
|
187
|
+
hidefooter: !0,
|
|
188
|
+
challengeurl: `${o.apiUrl}/v1/identity/captcha/create-challenge`,
|
|
189
|
+
verifyurl: `${o.apiUrl}/v1/identity/captcha/verify-challenge`
|
|
190
|
+
}
|
|
191
|
+
) });
|
|
192
|
+
};
|
|
193
|
+
export {
|
|
194
|
+
St as F,
|
|
195
|
+
pt as S,
|
|
196
|
+
gt as u
|
|
197
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { j as o } from "./jsx-runtime-B6kdoens.js";
|
|
3
|
+
import { useState as p, useEffect as v } from "react";
|
|
4
|
+
import { useController as z } from "react-hook-form";
|
|
5
|
+
import { n as T } from "./Spinner-Bzu2xCFZ.js";
|
|
6
|
+
import { z as k, A as q, B as A } from "./CollectionFormBuilder-MAo2Ob3a.js";
|
|
7
|
+
import { I as E } from "./Input-2CvZ90f8.js";
|
|
8
|
+
import { u as O } from "./LevoProvider-BAZy7_tP.js";
|
|
9
|
+
const $ = ({ field: t }) => {
|
|
10
|
+
var _;
|
|
11
|
+
const [c, h] = p(""), [m, u] = p(!1), [l, N] = p([]), [g, i] = p(!1), { client: a } = O(), { key: d = "", label: f = "", helper_text: w = "", readonly: j = !1 } = t, {
|
|
12
|
+
field: { value: s, onBlur: F, onChange: y, ...L },
|
|
13
|
+
fieldState: x
|
|
14
|
+
} = z({
|
|
15
|
+
name: d,
|
|
16
|
+
rules: k(t)
|
|
17
|
+
}), B = !!(t != null && t.required), C = (_ = x == null ? void 0 : x.error) == null ? void 0 : _.message, I = (e) => {
|
|
18
|
+
i(!0), u(!0), a == null || a.fetch.url(`/v1/bevy/content/location/${e == null ? void 0 : e.place_id}/get-location-details`).get().json().then((n) => {
|
|
19
|
+
var r;
|
|
20
|
+
y && y((r = n == null ? void 0 : n.content) == null ? void 0 : r.data);
|
|
21
|
+
}).finally(() => i(!1));
|
|
22
|
+
};
|
|
23
|
+
return v(() => {
|
|
24
|
+
var e, n;
|
|
25
|
+
c && !m && (i(!0), a == null || a.fetch.url("/v1/bevy/content/location/search-location").post({
|
|
26
|
+
search: c,
|
|
27
|
+
where: (e = t == null ? void 0 : t.options) != null && e.location_type ? {
|
|
28
|
+
location_type: (n = t == null ? void 0 : t.options) == null ? void 0 : n.location_type
|
|
29
|
+
} : {}
|
|
30
|
+
}).json().then((r) => {
|
|
31
|
+
var b;
|
|
32
|
+
N((b = r == null ? void 0 : r.content) == null ? void 0 : b.data);
|
|
33
|
+
}).finally(() => i(!1)));
|
|
34
|
+
}, [c, m]), v(() => {
|
|
35
|
+
s != null && s.place_name && (h(s == null ? void 0 : s.place_name), u(!0));
|
|
36
|
+
}, [s]), /* @__PURE__ */ o.jsx(q, { error: C, helperText: w, readOnly: j, children: /* @__PURE__ */ o.jsxs("div", { className: "w-full relative", children: [
|
|
37
|
+
f && /* @__PURE__ */ o.jsx(A, { htmlFor: d, isRequired: B, children: f }),
|
|
38
|
+
/* @__PURE__ */ o.jsx(
|
|
39
|
+
E,
|
|
40
|
+
{
|
|
41
|
+
id: d,
|
|
42
|
+
value: c,
|
|
43
|
+
onChange: (e) => {
|
|
44
|
+
u(!1), h(e.target.value);
|
|
45
|
+
},
|
|
46
|
+
onBlur: () => {
|
|
47
|
+
F();
|
|
48
|
+
},
|
|
49
|
+
rightIcon: g && /* @__PURE__ */ o.jsx(T, { size: "20px", className: "animate-spin" }),
|
|
50
|
+
readOnly: j,
|
|
51
|
+
...L
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
c && !g && !m && /* @__PURE__ */ o.jsx("div", { className: "absolute bg-white left-[-1px] z-50 p-[4px] w-full shadow-[0_0_8px_rgba(0,0,0,0.25)] rounded-[6px]", children: l != null && l.length ? l.map((e) => /* @__PURE__ */ o.jsx(
|
|
55
|
+
"p",
|
|
56
|
+
{
|
|
57
|
+
className: "text-md p-[8px] cursor-pointer rounded-[6px] hover:bg-gray-200",
|
|
58
|
+
onClick: () => I(e),
|
|
59
|
+
children: e.description
|
|
60
|
+
},
|
|
61
|
+
e.place_id
|
|
62
|
+
)) : /* @__PURE__ */ o.jsx("p", { className: "text-md p-[8px] text-muted-foreground", children: "No results found" }) })
|
|
63
|
+
] }) });
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
$ as GeocoderWidget,
|
|
67
|
+
$ as default
|
|
68
|
+
};
|