@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,60 @@
|
|
|
1
|
+
import { j as t } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
+
import { useController as j } from "react-hook-form";
|
|
3
|
+
import { NumericFormat as F } from "react-number-format";
|
|
4
|
+
import { h as w, j as C, k } from "./CollectionFormBuilder-jwwjyIpv.js";
|
|
5
|
+
import { c as N } from "./cn-C9QoOYNG.js";
|
|
6
|
+
const V = ({
|
|
7
|
+
field: r,
|
|
8
|
+
...m
|
|
9
|
+
}) => {
|
|
10
|
+
var u, c;
|
|
11
|
+
const { key: d = "", label: n = "", helper_text: p = "", readonly: e = !1 } = r, o = d, {
|
|
12
|
+
field: { value: f, onBlur: a, onChange: l, ref: h, ...x },
|
|
13
|
+
fieldState: s
|
|
14
|
+
} = j({
|
|
15
|
+
name: o,
|
|
16
|
+
rules: w(r)
|
|
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
|
+
return /* @__PURE__ */ t.jsxs(
|
|
19
|
+
C,
|
|
20
|
+
{
|
|
21
|
+
ref: h,
|
|
22
|
+
error: g,
|
|
23
|
+
helperText: p,
|
|
24
|
+
readOnly: e,
|
|
25
|
+
children: [
|
|
26
|
+
n && /* @__PURE__ */ t.jsx(k, { htmlFor: o, isRequired: b, children: n }),
|
|
27
|
+
/* @__PURE__ */ t.jsx(
|
|
28
|
+
F,
|
|
29
|
+
{
|
|
30
|
+
thousandSeparator: !0,
|
|
31
|
+
prefix: i || "$",
|
|
32
|
+
thousandsGroupStyle: i === "₹" ? "lakh" : "thousand",
|
|
33
|
+
suffix: "",
|
|
34
|
+
allowNegative: !1,
|
|
35
|
+
id: o,
|
|
36
|
+
onValueChange: (y) => {
|
|
37
|
+
const { value: v } = y;
|
|
38
|
+
l && l(v);
|
|
39
|
+
},
|
|
40
|
+
onBlur: () => {
|
|
41
|
+
a && a();
|
|
42
|
+
},
|
|
43
|
+
value: f,
|
|
44
|
+
readOnly: e,
|
|
45
|
+
className: N(
|
|
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
|
+
e && "focus-visible:ring-0"
|
|
48
|
+
),
|
|
49
|
+
...x,
|
|
50
|
+
...m
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
V as CurrencyWidget,
|
|
59
|
+
V as default
|
|
60
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { j as r } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
+
import { Calendar as b, X as w } from "lucide-react";
|
|
3
|
+
import * as l from "react-datepicker";
|
|
4
|
+
import { FieldInterfaces as N } from "@levo-so/core";
|
|
5
|
+
import { useController as v } from "react-hook-form";
|
|
6
|
+
import { h as M, j as D, k as C } from "./CollectionFormBuilder-jwwjyIpv.js";
|
|
7
|
+
import { I as F } from "./Input-2CvZ90f8.js";
|
|
8
|
+
import { c as p } from "./cn-C9QoOYNG.js";
|
|
9
|
+
const T = l.default.default || l.default || l, I = (e) => {
|
|
10
|
+
if (e) {
|
|
11
|
+
const o = new Date(e);
|
|
12
|
+
return Number.isNaN(o.getTime()) ? null : o;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}, B = ({ field: e }) => {
|
|
16
|
+
var d;
|
|
17
|
+
const { key: o = "", label: m = "", helper_text: f = "", readonly: x = !1 } = e, n = o, {
|
|
18
|
+
field: { value: i, onBlur: u, onChange: s, ref: h, ...j },
|
|
19
|
+
fieldState: a
|
|
20
|
+
} = v({
|
|
21
|
+
name: n,
|
|
22
|
+
rules: M(e)
|
|
23
|
+
}), y = !!(e != null && e.required), g = (d = a == null ? void 0 : a.error) == null ? void 0 : d.message, c = (e == null ? void 0 : e.field_interface) === N.DateTimeWidget;
|
|
24
|
+
return /* @__PURE__ */ r.jsxs(D, { helperText: f, readOnly: x, error: g, children: [
|
|
25
|
+
m && /* @__PURE__ */ r.jsx(C, { htmlFor: n, isRequired: y, children: m }),
|
|
26
|
+
/* @__PURE__ */ r.jsxs("div", { className: "w-full relative rounded-md", children: [
|
|
27
|
+
/* @__PURE__ */ r.jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: p(
|
|
31
|
+
"absolute left-0 top-0 bottom-0 w-9 flex items-center justify-center rounded-l-md overflow-hidden pointer-events-none"
|
|
32
|
+
),
|
|
33
|
+
children: /* @__PURE__ */ r.jsx(b, { size: "20px", className: "text-muted-foreground" })
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ r.jsx(
|
|
37
|
+
T,
|
|
38
|
+
{
|
|
39
|
+
id: n,
|
|
40
|
+
selected: I(i),
|
|
41
|
+
onChange: (t) => {
|
|
42
|
+
s && s((t == null ? void 0 : t.toISOString()) || null);
|
|
43
|
+
},
|
|
44
|
+
onBlur: () => {
|
|
45
|
+
u && u();
|
|
46
|
+
},
|
|
47
|
+
className: "w-full pl-8",
|
|
48
|
+
showTimeSelect: c,
|
|
49
|
+
customInput: /* @__PURE__ */ r.jsx(F, { ref: h }),
|
|
50
|
+
autoComplete: "off",
|
|
51
|
+
dateFormat: c ? "d MMMM, yyyy h:mm aa" : "d MMMM, yyyy",
|
|
52
|
+
popperPlacement: "bottom-start",
|
|
53
|
+
showPopperArrow: !1,
|
|
54
|
+
...j
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
i && /* @__PURE__ */ r.jsx(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
className: p(
|
|
61
|
+
"absolute right-0 top-0 bottom-0 w-9 z-10 flex items-center justify-center rounded-l-md overflow-hidden"
|
|
62
|
+
),
|
|
63
|
+
children: /* @__PURE__ */ r.jsx(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
type: "button",
|
|
67
|
+
onClick: (t) => {
|
|
68
|
+
t == null || t.preventDefault(), t == null || t.stopPropagation(), s && s(null);
|
|
69
|
+
},
|
|
70
|
+
children: /* @__PURE__ */ r.jsx(w, { size: "20px", className: "text-muted-foreground" })
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] })
|
|
76
|
+
] });
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
B as default
|
|
80
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { j as e } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
+
import { FormProvider as S } from "react-hook-form";
|
|
3
|
+
import { m as b, F as y } from "./CollectionFormBuilder-jwwjyIpv.js";
|
|
4
|
+
import { u as F, S as N } from "./useLevoForm-BcN8f66y.js";
|
|
5
|
+
import { c as m } from "./cn-C9QoOYNG.js";
|
|
6
|
+
import { B as g } from "./Spinner-CuUosd-S.js";
|
|
7
|
+
const E = () => {
|
|
8
|
+
var d;
|
|
9
|
+
const {
|
|
10
|
+
schema: l,
|
|
11
|
+
containerStyles: i,
|
|
12
|
+
uiConfig: o,
|
|
13
|
+
isInternal: x,
|
|
14
|
+
submitButtonConfig: r,
|
|
15
|
+
isDisabled: c
|
|
16
|
+
} = b(), {
|
|
17
|
+
methods: t,
|
|
18
|
+
allFormValues: p,
|
|
19
|
+
isError: u,
|
|
20
|
+
isLoading: h,
|
|
21
|
+
handleContentId: j,
|
|
22
|
+
handleSubmit: f
|
|
23
|
+
} = F({
|
|
24
|
+
schema: l,
|
|
25
|
+
saveToRemote: !0
|
|
26
|
+
}), {
|
|
27
|
+
formState: { isSubmitting: v }
|
|
28
|
+
} = t;
|
|
29
|
+
return /* @__PURE__ */ e.jsxs(S, { ...t, children: [
|
|
30
|
+
/* @__PURE__ */ e.jsx(
|
|
31
|
+
N,
|
|
32
|
+
{
|
|
33
|
+
getContentId: (s) => j(s),
|
|
34
|
+
isError: u,
|
|
35
|
+
currentValues: p
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
/* @__PURE__ */ e.jsx("div", { className: m("w-full", i), children: /* @__PURE__ */ e.jsxs(
|
|
39
|
+
"form",
|
|
40
|
+
{
|
|
41
|
+
className: m(
|
|
42
|
+
"w-full bg-white rounded-md border border-[rgb(229, 231, 235)] flex flex-col gap-6 px-4 md:px-8 py-6",
|
|
43
|
+
h && "opacity-50 pointer-events-none"
|
|
44
|
+
),
|
|
45
|
+
id: "collection-form",
|
|
46
|
+
onSubmit: f,
|
|
47
|
+
children: [
|
|
48
|
+
(d = l == null ? void 0 : l.sections) == null ? void 0 : d.map((s) => {
|
|
49
|
+
var n;
|
|
50
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "w-full", children: [
|
|
51
|
+
!(o != null && o.hideSectionHeadings) && /* @__PURE__ */ e.jsx("p", { className: m("mb-4 text-lg font-semibold"), children: s == null ? void 0 : s.label }),
|
|
52
|
+
/* @__PURE__ */ e.jsx("div", { className: m("flex flex-col gap-4"), children: (n = s == null ? void 0 : s.fields) == null ? void 0 : n.map((a) => a && !a.hidden ? /* @__PURE__ */ e.jsx(
|
|
53
|
+
y,
|
|
54
|
+
{
|
|
55
|
+
field: a,
|
|
56
|
+
isInternal: x
|
|
57
|
+
},
|
|
58
|
+
a == null ? void 0 : a.key
|
|
59
|
+
) : null) })
|
|
60
|
+
] }, s.id);
|
|
61
|
+
}),
|
|
62
|
+
(r == null ? void 0 : r.show) && /* @__PURE__ */ e.jsx("div", { className: "w-full flex items-center justify-end mt-6", children: /* @__PURE__ */ e.jsx(
|
|
63
|
+
g,
|
|
64
|
+
{
|
|
65
|
+
className: r == null ? void 0 : r.styles,
|
|
66
|
+
loadingText: "Saving",
|
|
67
|
+
isLoading: v,
|
|
68
|
+
disabled: c,
|
|
69
|
+
type: "submit",
|
|
70
|
+
children: (r == null ? void 0 : r.text) || "Save"
|
|
71
|
+
}
|
|
72
|
+
) })
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
) })
|
|
76
|
+
] });
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
E as default
|
|
80
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { j as i } from "./jsx-runtime-B6kdoens.js";
|
|
3
|
+
import { useState as f, useEffect as j } from "react";
|
|
4
|
+
import { useController as k } from "react-hook-form";
|
|
5
|
+
import D from "react-select";
|
|
6
|
+
import { h as N, j as q, k as B } from "./CollectionFormBuilder-jwwjyIpv.js";
|
|
7
|
+
import { I as L } from "./Input-2CvZ90f8.js";
|
|
8
|
+
import { c as x } from "./cn-C9QoOYNG.js";
|
|
9
|
+
const G = ({
|
|
10
|
+
field: s,
|
|
11
|
+
...r
|
|
12
|
+
}) => {
|
|
13
|
+
var O;
|
|
14
|
+
const [t, w] = f([]), [h, g] = f(""), [I, b] = f(!1), {
|
|
15
|
+
key: S = "",
|
|
16
|
+
label: p = "",
|
|
17
|
+
helper_text: C = "",
|
|
18
|
+
readonly: v = !1,
|
|
19
|
+
values: n = [],
|
|
20
|
+
options: y = {}
|
|
21
|
+
} = s, u = S, {
|
|
22
|
+
field: { value: o, onBlur: P, onChange: a, disabled: E, ...F },
|
|
23
|
+
fieldState: c
|
|
24
|
+
} = k({
|
|
25
|
+
name: u,
|
|
26
|
+
rules: N(s)
|
|
27
|
+
}), M = !!(s != null && s.required), R = (O = c == null ? void 0 : c.error) == null ? void 0 : O.message, d = !!(y != null && y.custom_input);
|
|
28
|
+
return j(() => {
|
|
29
|
+
if (n != null && n.length) {
|
|
30
|
+
const l = [...n == null ? void 0 : n.map((m) => ({
|
|
31
|
+
label: m,
|
|
32
|
+
value: m
|
|
33
|
+
}))];
|
|
34
|
+
d && l.push({
|
|
35
|
+
label: "Other, Please Specify",
|
|
36
|
+
value: "Other"
|
|
37
|
+
}), w(l);
|
|
38
|
+
}
|
|
39
|
+
}, [n, d]), j(() => {
|
|
40
|
+
!(r != null && r.isMulti) && d && typeof o == "string" && o && (t == null ? void 0 : t.findIndex(
|
|
41
|
+
(e) => (e == null ? void 0 : e.value) !== "Other" && (e == null ? void 0 : e.value) === o
|
|
42
|
+
)) === -1 && (b(!0), g(o));
|
|
43
|
+
}, [o]), /* @__PURE__ */ i.jsxs(q, { error: R, helperText: C, readOnly: v, children: [
|
|
44
|
+
p && /* @__PURE__ */ i.jsx(B, { htmlFor: u, isRequired: M, children: p }),
|
|
45
|
+
/* @__PURE__ */ i.jsx(
|
|
46
|
+
D,
|
|
47
|
+
{
|
|
48
|
+
id: u,
|
|
49
|
+
value: I ? {
|
|
50
|
+
label: "Other, Please Specify",
|
|
51
|
+
value: "Other"
|
|
52
|
+
} : o ? r != null && r.isMulti ? t == null ? void 0 : t.filter(
|
|
53
|
+
(e) => o == null ? void 0 : o.includes(e == null ? void 0 : e.value)
|
|
54
|
+
) : t == null ? void 0 : t.find((e) => (e == null ? void 0 : e.value) === o) : null,
|
|
55
|
+
onChange: (e) => {
|
|
56
|
+
d && (e == null ? void 0 : e.value) === "Other" && (e == null ? void 0 : e.label) === "Other, Please Specify" ? (b(!0), a(h)) : (b(!1), r != null && r.isMulti ? a(e == null ? void 0 : e.map((l) => l == null ? void 0 : l.value)) : a(e == null ? void 0 : e.value));
|
|
57
|
+
},
|
|
58
|
+
onBlur: () => P(),
|
|
59
|
+
options: t,
|
|
60
|
+
isDisabled: E,
|
|
61
|
+
menuPlacement: "auto",
|
|
62
|
+
...F,
|
|
63
|
+
...r,
|
|
64
|
+
unstyled: !0,
|
|
65
|
+
classNames: {
|
|
66
|
+
container: () => x("w-full min-w-none h-auto min-h-none"),
|
|
67
|
+
control: ({ isFocused: e, isMulti: l, isDisabled: m }) => x(
|
|
68
|
+
"w-full pl-3",
|
|
69
|
+
l ? "!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
|
+
v && "ring-0",
|
|
74
|
+
m && "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: l }) => x(
|
|
90
|
+
"text-sm font-medium hover:cursor-pointer px-3 py-2 rounded",
|
|
91
|
+
l && "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
|
+
d && /* @__PURE__ */ i.jsx("div", { className: "w-full", children: /* @__PURE__ */ i.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
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { j as r } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
+
import { useController as y } from "react-hook-form";
|
|
3
|
+
import { G as C } from "./Spinner-CuUosd-S.js";
|
|
4
|
+
import { h as F, j as I, k as V } from "./CollectionFormBuilder-jwwjyIpv.js";
|
|
5
|
+
import { I as b } from "./Input-2CvZ90f8.js";
|
|
6
|
+
function w(e) {
|
|
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
|
+
}
|
|
9
|
+
const k = ({ field: e, ...c }) => {
|
|
10
|
+
var l;
|
|
11
|
+
const { key: u = "", label: s = "", helper_text: d = "", readonly: h = !1 } = e, t = u, {
|
|
12
|
+
field: { value: p, onBlur: x, onChange: g, ...f },
|
|
13
|
+
fieldState: a
|
|
14
|
+
} = y({
|
|
15
|
+
name: t,
|
|
16
|
+
rules: F(e)
|
|
17
|
+
}), j = !!(e != null && e.required), v = (l = a == null ? void 0 : a.error) == null ? void 0 : l.message;
|
|
18
|
+
return /* @__PURE__ */ r.jsxs(I, { error: v, helperText: d, children: [
|
|
19
|
+
s && /* @__PURE__ */ r.jsx(V, { htmlFor: t, isRequired: j, children: s }),
|
|
20
|
+
/* @__PURE__ */ r.jsx(
|
|
21
|
+
b,
|
|
22
|
+
{
|
|
23
|
+
id: t,
|
|
24
|
+
type: "email",
|
|
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: p || "",
|
|
27
|
+
onChange: (o) => {
|
|
28
|
+
var n, i, m;
|
|
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
|
+
},
|
|
31
|
+
onBlur: x,
|
|
32
|
+
readOnly: h,
|
|
33
|
+
...f,
|
|
34
|
+
...c
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
] });
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
k as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { j as h } from "./jsx-runtime-B6kdoens.js";
|
|
3
|
+
import le, { useState as J, useEffect as fe } from "react";
|
|
4
|
+
import { useController as de } from "react-hook-form";
|
|
5
|
+
import { q as pe } from "./Spinner-CuUosd-S.js";
|
|
6
|
+
import { h as ge, j as me, k as ye } from "./CollectionFormBuilder-jwwjyIpv.js";
|
|
7
|
+
import { I as _e } from "./Input-2CvZ90f8.js";
|
|
8
|
+
var U = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, ne = {}, ve = "Expected a function", Y = NaN, be = "[object Symbol]", Se = /^\s+|\s+$/g, Pe = /^[-+]0x[0-9a-f]+$/i, Oe = /^0b[01]+$/i, he = /^0o[0-7]+$/i, Te = parseInt, je = typeof U == "object" && U && U.Object === Object && U, xe = typeof self == "object" && self && self.Object === Object && self, Ae = je || xe || Function("return this")(), Le = Object.prototype, Ee = Le.toString, we = Math.max, Ie = Math.min, $ = function() {
|
|
9
|
+
return Ae.Date.now();
|
|
10
|
+
};
|
|
11
|
+
function Ce(e, t, r) {
|
|
12
|
+
var n, a, c, u, s, l, g = 0, d = !1, v = !1, T = !0;
|
|
13
|
+
if (typeof e != "function")
|
|
14
|
+
throw new TypeError(ve);
|
|
15
|
+
t = Z(t) || 0, q(r) && (d = !!r.leading, v = "maxWait" in r, c = v ? we(Z(r.maxWait) || 0, t) : c, T = "trailing" in r ? !!r.trailing : T);
|
|
16
|
+
function P(i) {
|
|
17
|
+
var o = n, f = a;
|
|
18
|
+
return n = a = void 0, g = i, u = e.apply(f, o), u;
|
|
19
|
+
}
|
|
20
|
+
function j(i) {
|
|
21
|
+
return g = i, s = setTimeout(y, t), d ? P(i) : u;
|
|
22
|
+
}
|
|
23
|
+
function A(i) {
|
|
24
|
+
var o = i - l, f = i - g, O = t - o;
|
|
25
|
+
return v ? Ie(O, c - f) : O;
|
|
26
|
+
}
|
|
27
|
+
function L(i) {
|
|
28
|
+
var o = i - l, f = i - g;
|
|
29
|
+
return l === void 0 || o >= t || o < 0 || v && f >= c;
|
|
30
|
+
}
|
|
31
|
+
function y() {
|
|
32
|
+
var i = $();
|
|
33
|
+
if (L(i))
|
|
34
|
+
return b(i);
|
|
35
|
+
s = setTimeout(y, A(i));
|
|
36
|
+
}
|
|
37
|
+
function b(i) {
|
|
38
|
+
return s = void 0, T && n ? P(i) : (n = a = void 0, u);
|
|
39
|
+
}
|
|
40
|
+
function E() {
|
|
41
|
+
s !== void 0 && clearTimeout(s), g = 0, n = l = a = s = void 0;
|
|
42
|
+
}
|
|
43
|
+
function w() {
|
|
44
|
+
return s === void 0 ? u : b($());
|
|
45
|
+
}
|
|
46
|
+
function S() {
|
|
47
|
+
var i = $(), o = L(i);
|
|
48
|
+
if (n = arguments, a = this, l = i, o) {
|
|
49
|
+
if (s === void 0)
|
|
50
|
+
return j(l);
|
|
51
|
+
if (v)
|
|
52
|
+
return s = setTimeout(y, t), P(l);
|
|
53
|
+
}
|
|
54
|
+
return s === void 0 && (s = setTimeout(y, t)), u;
|
|
55
|
+
}
|
|
56
|
+
return S.cancel = E, S.flush = w, S;
|
|
57
|
+
}
|
|
58
|
+
function q(e) {
|
|
59
|
+
var t = typeof e;
|
|
60
|
+
return !!e && (t == "object" || t == "function");
|
|
61
|
+
}
|
|
62
|
+
function Me(e) {
|
|
63
|
+
return !!e && typeof e == "object";
|
|
64
|
+
}
|
|
65
|
+
function ke(e) {
|
|
66
|
+
return typeof e == "symbol" || Me(e) && Ee.call(e) == be;
|
|
67
|
+
}
|
|
68
|
+
function Z(e) {
|
|
69
|
+
if (typeof e == "number")
|
|
70
|
+
return e;
|
|
71
|
+
if (ke(e))
|
|
72
|
+
return Y;
|
|
73
|
+
if (q(e)) {
|
|
74
|
+
var t = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
75
|
+
e = q(t) ? t + "" : t;
|
|
76
|
+
}
|
|
77
|
+
if (typeof e != "string")
|
|
78
|
+
return e === 0 ? e : +e;
|
|
79
|
+
e = e.replace(Se, "");
|
|
80
|
+
var r = Oe.test(e);
|
|
81
|
+
return r || he.test(e) ? Te(e.slice(2), r ? 2 : 8) : Pe.test(e) ? Y : +e;
|
|
82
|
+
}
|
|
83
|
+
var Ge = Ce, k = {};
|
|
84
|
+
Object.defineProperty(k, "__esModule", {
|
|
85
|
+
value: !0
|
|
86
|
+
});
|
|
87
|
+
k.loadGoogleMapScript = k.isBrowser = void 0;
|
|
88
|
+
var oe = typeof window < "u" && window.document;
|
|
89
|
+
k.isBrowser = oe;
|
|
90
|
+
var Re = function(t, r) {
|
|
91
|
+
if (!oe || typeof google < "u" && google.maps && google.maps.api)
|
|
92
|
+
return Promise.resolve();
|
|
93
|
+
var n = document.querySelectorAll('script[src*="'.concat(t, '"]'));
|
|
94
|
+
if (n && n.length)
|
|
95
|
+
return new Promise(function(u) {
|
|
96
|
+
if (typeof google < "u") return u();
|
|
97
|
+
n[0].addEventListener("load", function() {
|
|
98
|
+
return u();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
var a = new URL(r);
|
|
102
|
+
a.searchParams.set("callback", "__REACT_GOOGLE_AUTOCOMPLETE_CALLBACK__");
|
|
103
|
+
var c = document.createElement("script");
|
|
104
|
+
return c.src = a.toString(), new Promise(function(u) {
|
|
105
|
+
window.__REACT_GOOGLE_AUTOCOMPLETE_CALLBACK__ = u, document.body.appendChild(c);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
k.loadGoogleMapScript = Re;
|
|
109
|
+
var N = {};
|
|
110
|
+
Object.defineProperty(N, "__esModule", {
|
|
111
|
+
value: !0
|
|
112
|
+
});
|
|
113
|
+
N.GOOGLE_MAP_SCRIPT_BASE_URL = void 0;
|
|
114
|
+
var Be = "https://maps.googleapis.com/maps/api/js";
|
|
115
|
+
N.GOOGLE_MAP_SCRIPT_BASE_URL = Be;
|
|
116
|
+
Object.defineProperty(ne, "__esModule", {
|
|
117
|
+
value: !0
|
|
118
|
+
});
|
|
119
|
+
var Ue = ne.default = Ve, m = le, D = Qe(Ge), ee = k, Ne = N;
|
|
120
|
+
function Qe(e) {
|
|
121
|
+
return e && e.__esModule ? e : { default: e };
|
|
122
|
+
}
|
|
123
|
+
function te(e, t) {
|
|
124
|
+
var r = Object.keys(e);
|
|
125
|
+
if (Object.getOwnPropertySymbols) {
|
|
126
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
127
|
+
t && (n = n.filter(function(a) {
|
|
128
|
+
return Object.getOwnPropertyDescriptor(e, a).enumerable;
|
|
129
|
+
})), r.push.apply(r, n);
|
|
130
|
+
}
|
|
131
|
+
return r;
|
|
132
|
+
}
|
|
133
|
+
function C(e) {
|
|
134
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
135
|
+
var r = arguments[t] != null ? arguments[t] : {};
|
|
136
|
+
t % 2 ? te(Object(r), !0).forEach(function(n) {
|
|
137
|
+
$e(e, n, r[n]);
|
|
138
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : te(Object(r)).forEach(function(n) {
|
|
139
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return e;
|
|
143
|
+
}
|
|
144
|
+
function $e(e, t, r) {
|
|
145
|
+
return t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
|
|
146
|
+
}
|
|
147
|
+
function M(e, t) {
|
|
148
|
+
return We(e) || Ke(e, t) || Fe(e, t) || qe();
|
|
149
|
+
}
|
|
150
|
+
function qe() {
|
|
151
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
152
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
153
|
+
}
|
|
154
|
+
function Fe(e, t) {
|
|
155
|
+
if (e) {
|
|
156
|
+
if (typeof e == "string") return re(e, t);
|
|
157
|
+
var r = Object.prototype.toString.call(e).slice(8, -1);
|
|
158
|
+
if (r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set") return Array.from(e);
|
|
159
|
+
if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return re(e, t);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function re(e, t) {
|
|
163
|
+
(t == null || t > e.length) && (t = e.length);
|
|
164
|
+
for (var r = 0, n = new Array(t); r < t; r++)
|
|
165
|
+
n[r] = e[r];
|
|
166
|
+
return n;
|
|
167
|
+
}
|
|
168
|
+
function Ke(e, t) {
|
|
169
|
+
var r = e && (typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"]);
|
|
170
|
+
if (r != null) {
|
|
171
|
+
var n = [], a = !0, c = !1, u, s;
|
|
172
|
+
try {
|
|
173
|
+
for (r = r.call(e); !(a = (u = r.next()).done) && (n.push(u.value), !(t && n.length === t)); a = !0)
|
|
174
|
+
;
|
|
175
|
+
} catch (l) {
|
|
176
|
+
c = !0, s = l;
|
|
177
|
+
} finally {
|
|
178
|
+
try {
|
|
179
|
+
!a && r.return != null && r.return();
|
|
180
|
+
} finally {
|
|
181
|
+
if (c) throw s;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return n;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function We(e) {
|
|
188
|
+
if (Array.isArray(e)) return e;
|
|
189
|
+
}
|
|
190
|
+
function Ve(e) {
|
|
191
|
+
var t = e.apiKey, r = e.libraries, n = r === void 0 ? "places" : r, a = e.googleMapsScriptBaseUrl, c = a === void 0 ? Ne.GOOGLE_MAP_SCRIPT_BASE_URL : a, u = e.debounce, s = u === void 0 ? 300 : u, l = e.options, g = l === void 0 ? {} : l, d = e.sessionToken, v = e.language, T = v ? "&language=".concat(v) : "", P = "".concat(c, "?key=").concat(t, "&libraries=").concat(n).concat(T), j = (0, m.useState)([]), A = M(j, 2), L = A[0], y = A[1], b = (0, m.useState)(!1), E = M(b, 2), w = E[0], S = E[1], i = (0, m.useState)(null), o = M(i, 2), f = o[0], O = o[1], R = (0, m.useState)(!1), G = M(R, 2), B = G[0], Q = G[1], ie = (0, m.useState)(!1), F = M(ie, 2), ae = F[0], K = F[1], se = (0, m.useState)([]), W = M(se, 2), ue = W[0], V = W[1], I = (0, m.useRef)(null), H = (0, m.useRef)(null), x = (0, m.useRef)(null), ce = (0, m.useCallback)(function() {
|
|
192
|
+
return (0, ee.loadGoogleMapScript)(c, P);
|
|
193
|
+
}, [c, P]), z = (0, m.useCallback)((0, D.default)(function(_) {
|
|
194
|
+
I.current && _.input && I.current.getPlacePredictions(C(C(C({}, d && x.current ? {
|
|
195
|
+
sessionToken: x.current
|
|
196
|
+
} : {}), g), _), function(p) {
|
|
197
|
+
S(!1), y(p || []);
|
|
198
|
+
});
|
|
199
|
+
}, s), [s]), X = (0, m.useCallback)((0, D.default)(function(_) {
|
|
200
|
+
I.current && _.input && I.current.getQueryPredictions(C(C(C({}, d && x.current ? {
|
|
201
|
+
sessionToken: x.current
|
|
202
|
+
} : {}), g), _), function(p) {
|
|
203
|
+
Q(!1), V(p || []);
|
|
204
|
+
});
|
|
205
|
+
}, s), [s]);
|
|
206
|
+
return (0, m.useEffect)(function() {
|
|
207
|
+
if (ee.isBrowser) {
|
|
208
|
+
var _ = function() {
|
|
209
|
+
if (!google) return console.error("Google has not been found. Make sure your provide apiKey prop.");
|
|
210
|
+
I.current = new google.maps.places.AutocompleteService(), H.current = new google.maps.places.PlacesService(document.createElement("div")), d && (x.current = new google.maps.places.AutocompleteSessionToken());
|
|
211
|
+
};
|
|
212
|
+
t ? ce().then(function() {
|
|
213
|
+
return _();
|
|
214
|
+
}) : _();
|
|
215
|
+
}
|
|
216
|
+
}, []), {
|
|
217
|
+
placesService: H.current,
|
|
218
|
+
autocompleteSessionToken: x.current,
|
|
219
|
+
placesAutocompleteService: I.current,
|
|
220
|
+
placePredictions: f ? L : [],
|
|
221
|
+
isPlacePredictionsLoading: w,
|
|
222
|
+
getPlacePredictions: function(p) {
|
|
223
|
+
if (p.input) {
|
|
224
|
+
O(p.input), S(!0), z(p);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
y([]), O(null), z(p), S(!1);
|
|
228
|
+
},
|
|
229
|
+
queryPredictions: ae ? ue : [],
|
|
230
|
+
isQueryPredictionsLoading: B,
|
|
231
|
+
getQueryPredictions: function(p) {
|
|
232
|
+
if (p.input) {
|
|
233
|
+
K(p.input), Q(!0), X(p);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
V([]), K(null), X(p), Q(!1);
|
|
237
|
+
},
|
|
238
|
+
refreshSessionToken: function() {
|
|
239
|
+
x.current = new google.maps.places.AutocompleteSessionToken();
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
const De = ({ field: e }) => {
|
|
244
|
+
var i;
|
|
245
|
+
const [t, r] = J(""), [n, a] = J(!1), { key: c = "", label: u = "", helper_text: s = "", readonly: l = !1 } = e, g = c, {
|
|
246
|
+
field: { value: d, onBlur: v, onChange: T, ...P },
|
|
247
|
+
fieldState: j
|
|
248
|
+
} = de({
|
|
249
|
+
name: g,
|
|
250
|
+
rules: ge(e)
|
|
251
|
+
}), A = !!(e != null && e.required), L = (i = j == null ? void 0 : j.error) == null ? void 0 : i.message, {
|
|
252
|
+
placesService: y,
|
|
253
|
+
placePredictions: b,
|
|
254
|
+
getPlacePredictions: E,
|
|
255
|
+
isPlacePredictionsLoading: w
|
|
256
|
+
} = Ue({
|
|
257
|
+
apiKey: process.env.NEXT_PUBLIC_GOOGLE_MAPS,
|
|
258
|
+
debounce: 200
|
|
259
|
+
}), S = (o) => {
|
|
260
|
+
y == null || y.getDetails(
|
|
261
|
+
{
|
|
262
|
+
placeId: o == null ? void 0 : o.place_id
|
|
263
|
+
},
|
|
264
|
+
(f) => {
|
|
265
|
+
var O, R, G, B;
|
|
266
|
+
T(g, {
|
|
267
|
+
...f,
|
|
268
|
+
place_name: o == null ? void 0 : o.description,
|
|
269
|
+
latitude: ((R = (O = f == null ? void 0 : f.geometry) == null ? void 0 : O.location) == null ? void 0 : R.lat()) || 0,
|
|
270
|
+
longitude: ((B = (G = f == null ? void 0 : f.geometry) == null ? void 0 : G.location) == null ? void 0 : B.lng()) || 0
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
), a(!0);
|
|
274
|
+
};
|
|
275
|
+
return fe(() => {
|
|
276
|
+
d != null && d.place_name && (r(d == null ? void 0 : d.place_name), a(!0));
|
|
277
|
+
}, [d]), /* @__PURE__ */ h.jsx(me, { error: L, helperText: s, readOnly: l, children: /* @__PURE__ */ h.jsxs("div", { className: "w-full relative", children: [
|
|
278
|
+
u && /* @__PURE__ */ h.jsx(ye, { htmlFor: g, isRequired: A, children: u }),
|
|
279
|
+
/* @__PURE__ */ h.jsx(
|
|
280
|
+
_e,
|
|
281
|
+
{
|
|
282
|
+
id: g,
|
|
283
|
+
value: t,
|
|
284
|
+
onChange: (o) => {
|
|
285
|
+
a(!1), E({ input: o.target.value }), r(o.target.value);
|
|
286
|
+
},
|
|
287
|
+
onBlur: () => {
|
|
288
|
+
v();
|
|
289
|
+
},
|
|
290
|
+
rightIcon: w && /* @__PURE__ */ h.jsx(pe, { size: "20px", className: "animate-spin" }),
|
|
291
|
+
readOnly: l,
|
|
292
|
+
...P
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
t && !w && !n && /* @__PURE__ */ h.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: b != null && b.length ? b.map((o) => /* @__PURE__ */ h.jsx(
|
|
296
|
+
"p",
|
|
297
|
+
{
|
|
298
|
+
className: "text-md p-[8px] cursor-pointer rounded-[6px] hover:bg-gray-200",
|
|
299
|
+
onClick: () => S(o),
|
|
300
|
+
children: o.description
|
|
301
|
+
},
|
|
302
|
+
o.place_id
|
|
303
|
+
)) : /* @__PURE__ */ h.jsx("p", { className: "text-md p-[8px] text-muted-foreground", children: "No results found" }) })
|
|
304
|
+
] }) });
|
|
305
|
+
};
|
|
306
|
+
export {
|
|
307
|
+
De as GeocoderWidget,
|
|
308
|
+
De as default
|
|
309
|
+
};
|