@levo-so/react 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/CheckboxWidget-CNoS-2W3.js +124 -0
  2. package/dist/CollectionFormBuilder-MAo2Ob3a.js +1199 -0
  3. package/dist/{CurrencyWidget-COoMkfsA.js → CurrencyWidget-Cu1Cthnw.js} +5 -5
  4. package/dist/{DateTimeWidget-DcbQ3smI.js → DateTimeWidget-N-wuCRSJ.js} +3 -3
  5. package/dist/DefaultFormVariant-IqWi1BiT.js +81 -0
  6. package/dist/DropdownWidget-BFttB4b-.js +115 -0
  7. package/dist/{EmailWidget-CG9oNUM5.js → EmailWidget-D_SqXx3M.js} +11 -11
  8. package/dist/FormCaptcha-CJ9KgDu0.js +197 -0
  9. package/dist/GeocoderWidget-Bxt3TeAf.js +68 -0
  10. package/dist/LevoProvider-BAZy7_tP.js +223 -0
  11. package/dist/{MultiGeocoderWidget-D3Xmv8g4.js → MultiGeocoderWidget-DFjuXZBN.js} +6 -6
  12. package/dist/{MultiTextWidget-CyQRcWC8.js → MultiTextWidget-CZzT51cH.js} +14 -14
  13. package/dist/{PhoneWidget-C1Jt7kXL.js → PhoneWidget--K5aS16s.js} +5 -5
  14. package/dist/{RadioWidget-BrLNF-I2.js → RadioWidget-BbMPtR3P.js} +9 -9
  15. package/dist/{RichTextWidget-BogYcPtS.js → RichTextWidget-Cce3Bw8d.js} +21 -21
  16. package/dist/Spinner-Bzu2xCFZ.js +405 -0
  17. package/dist/{StepsFormVariant-Bx-jdciC.js → StepsFormVariant-5wZbYAA9.js} +58 -55
  18. package/dist/{SwitchWidget-BT0-waP9.js → SwitchWidget-B0wkSWxa.js} +5 -5
  19. package/dist/{TextWidget-Bvsz-hey.js → TextWidget-ldbMuLB0.js} +7 -7
  20. package/dist/{TextareaWidget-8SLym--T.js → TextareaWidget-S8bKUTv0.js} +3 -3
  21. package/dist/{ToggleCheckboxWidget-VrCQBF5C.js → ToggleCheckboxWidget-CPduXE6Y.js} +7 -7
  22. package/dist/Tooltip-DEBnSqlo.js +36 -0
  23. package/dist/{URLWidget-B99nKr6N.js → URLWidget-KbhE2ZUA.js} +2 -2
  24. package/dist/UploadWidget-DFvfDUT6.js +616 -0
  25. package/dist/audience/components/block.d.ts.map +1 -1
  26. package/dist/audience/components/component.d.ts.map +1 -1
  27. package/dist/audience/components/page.d.ts.map +1 -1
  28. package/dist/audience/index.js +1 -1
  29. package/dist/collection/components/Altcha.d.ts +10 -0
  30. package/dist/collection/components/Altcha.d.ts.map +1 -0
  31. package/dist/collection/components/FormCaptcha.d.ts +3 -0
  32. package/dist/collection/components/FormCaptcha.d.ts.map +1 -0
  33. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +1 -1
  34. package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +1 -1
  35. package/dist/collection/components/core/Input/Input.d.ts.map +1 -1
  36. package/dist/collection/components/core/Switch/Switch.d.ts.map +1 -1
  37. package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -1
  38. package/dist/collection/components/widgets/FieldWrapper.d.ts.map +1 -1
  39. package/dist/collection/components/widgets/FormHelperText.d.ts.map +1 -1
  40. package/dist/collection/components/widgets/FormLabel.d.ts.map +1 -1
  41. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +1 -1
  42. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -1
  43. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts +7 -0
  44. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -0
  45. package/dist/collection/components/widgets/collectionWidget/{CollectionWidget.d.ts → CollectionWidgetM2O.d.ts} +1 -1
  46. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts.map +1 -0
  47. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts +8 -0
  48. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +1 -0
  49. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +1 -1
  50. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -1
  51. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -1
  52. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +1 -1
  53. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -1
  54. package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts.map +1 -1
  55. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -1
  56. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +1 -1
  57. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +1 -1
  58. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +1 -1
  59. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +1 -1
  60. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts +11 -0
  61. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -0
  62. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
  63. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
  64. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -1
  65. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -1
  66. package/dist/collection/index.js +13 -12
  67. package/dist/collection/lib/FormBuilder.d.ts.map +1 -1
  68. package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -1
  69. package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -1
  70. package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -1
  71. package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +1 -1
  72. package/dist/collection/utils/formHelpers.d.ts.map +1 -1
  73. package/dist/collection/utils/index.d.ts +2 -0
  74. package/dist/collection/utils/index.d.ts.map +1 -1
  75. package/dist/components/Dialog.d.ts.map +1 -1
  76. package/dist/components/Spinner.d.ts.map +1 -1
  77. package/dist/components/Table.d.ts +11 -0
  78. package/dist/components/Table.d.ts.map +1 -0
  79. package/dist/components/Tabs.d.ts.map +1 -1
  80. package/dist/components/Tooltip.d.ts.map +1 -1
  81. package/dist/components/button/Button.d.ts.map +1 -1
  82. package/dist/components/index.js +29 -29
  83. package/dist/constants/fileUploadPresets.d.ts +4 -2
  84. package/dist/constants/fileUploadPresets.d.ts.map +1 -1
  85. package/dist/index.css +1 -1
  86. package/dist/index.js +75 -75
  87. package/dist/membership/components/Button.d.ts.map +1 -1
  88. package/dist/membership/components/Container.d.ts.map +1 -1
  89. package/dist/membership/components/Core.d.ts.map +1 -1
  90. package/dist/membership/index.js +2 -3
  91. package/dist/page-BKyDlf0z.js +212 -0
  92. package/dist/utils/errorHandler.d.ts.map +1 -1
  93. package/package.json +12 -11
  94. package/dist/CheckboxWidget-BctVOZiO.js +0 -118
  95. package/dist/CollectionFormBuilder-B6CAVKhg.js +0 -772
  96. package/dist/DefaultFormVariant-C6zbKgwB.js +0 -80
  97. package/dist/DropdownWidget-DszCTSWr.js +0 -115
  98. package/dist/GeocoderWidget-CXu17A7y.js +0 -310
  99. package/dist/LevoProvider-BI6g_T4E.js +0 -212
  100. package/dist/Spinner-DzGH5rKe.js +0 -297
  101. package/dist/Tooltip-CI4i4mYr.js +0 -144
  102. package/dist/UploadWidget-ZebPWZZZ.js +0 -505
  103. package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts.map +0 -1
  104. package/dist/fileUploadPresets-2raQmHT0.js +0 -74
  105. package/dist/page-yeiAPg3O.js +0 -200
  106. package/dist/useLevoForm-DjvUas25.js +0 -166
@@ -1,80 +0,0 @@
1
- import { j as e } from "./jsx-runtime-B6kdoens.js";
2
- import { FormProvider as S } from "react-hook-form";
3
- import { c as m } from "./cn-C9QoOYNG.js";
4
- import { l as y, F } from "./CollectionFormBuilder-B6CAVKhg.js";
5
- import { u as N, S as w } from "./useLevoForm-DjvUas25.js";
6
- import { B as b } from "./Spinner-DzGH5rKe.js";
7
- const E = () => {
8
- var d;
9
- const {
10
- schema: l,
11
- containerStyles: i,
12
- uiConfig: t,
13
- isInternal: x,
14
- submitButtonConfig: s,
15
- isDisabled: c
16
- } = y(), {
17
- methods: o,
18
- allFormValues: p,
19
- isError: u,
20
- isLoading: h,
21
- handleContentId: j,
22
- handleSubmit: f
23
- } = N({
24
- schema: l,
25
- saveToRemote: !0
26
- }), {
27
- formState: { isSubmitting: v }
28
- } = o;
29
- return /* @__PURE__ */ e.jsxs(S, { ...o, children: [
30
- /* @__PURE__ */ e.jsx(
31
- w,
32
- {
33
- getContentId: (r) => j(r),
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 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((r) => {
49
- var n;
50
- return /* @__PURE__ */ e.jsxs("div", { className: "w-full", children: [
51
- !(t != null && t.hideSectionHeadings) && /* @__PURE__ */ e.jsx("p", { className: m("mb-4 text-lg font-semibold"), children: r == null ? void 0 : r.label }),
52
- /* @__PURE__ */ e.jsx("div", { className: m("flex flex-col gap-4"), children: (n = r == null ? void 0 : r.fields) == null ? void 0 : n.map((a) => a && !a.hidden ? /* @__PURE__ */ e.jsx(
53
- F,
54
- {
55
- field: a,
56
- isInternal: x
57
- },
58
- a == null ? void 0 : a.key
59
- ) : null) })
60
- ] }, r.id);
61
- }),
62
- (s == null ? void 0 : s.show) && /* @__PURE__ */ e.jsx("div", { className: "w-full flex items-center justify-end mt-6", children: /* @__PURE__ */ e.jsx(
63
- b,
64
- {
65
- className: s == null ? void 0 : s.styles,
66
- loadingText: "Saving",
67
- isLoading: v,
68
- disabled: c,
69
- type: "submit",
70
- children: (s == null ? void 0 : s.text) || "Save"
71
- }
72
- ) })
73
- ]
74
- }
75
- ) })
76
- ] });
77
- };
78
- export {
79
- E as default
80
- };
@@ -1,115 +0,0 @@
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 { c as x } from "./cn-C9QoOYNG.js";
7
- import { h as N, j as q, k as B } from "./CollectionFormBuilder-B6CAVKhg.js";
8
- import { I as L } from "./Input-2CvZ90f8.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
- };
@@ -1,310 +0,0 @@
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 { c as U } from "./LevoProvider-BI6g_T4E.js";
5
- import { useController as de } from "react-hook-form";
6
- import { q as pe } from "./Spinner-DzGH5rKe.js";
7
- import { h as ge, j as me, k as ye } from "./CollectionFormBuilder-B6CAVKhg.js";
8
- import { I as _e } from "./Input-2CvZ90f8.js";
9
- var 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, Ie = Math.max, we = Math.min, $ = function() {
10
- return Ae.Date.now();
11
- };
12
- function Ce(e, r, t) {
13
- var n, a, c, u, s, l, m = 0, d = !1, v = !1, T = !0;
14
- if (typeof e != "function")
15
- throw new TypeError(ve);
16
- r = Z(r) || 0, q(t) && (d = !!t.leading, v = "maxWait" in t, c = v ? Ie(Z(t.maxWait) || 0, r) : c, T = "trailing" in t ? !!t.trailing : T);
17
- function P(i) {
18
- var o = n, f = a;
19
- return n = a = void 0, m = i, u = e.apply(f, o), u;
20
- }
21
- function j(i) {
22
- return m = i, s = setTimeout(y, r), d ? P(i) : u;
23
- }
24
- function A(i) {
25
- var o = i - l, f = i - m, O = r - o;
26
- return v ? we(O, c - f) : O;
27
- }
28
- function L(i) {
29
- var o = i - l, f = i - m;
30
- return l === void 0 || o >= r || o < 0 || v && f >= c;
31
- }
32
- function y() {
33
- var i = $();
34
- if (L(i))
35
- return b(i);
36
- s = setTimeout(y, A(i));
37
- }
38
- function b(i) {
39
- return s = void 0, T && n ? P(i) : (n = a = void 0, u);
40
- }
41
- function E() {
42
- s !== void 0 && clearTimeout(s), m = 0, n = l = a = s = void 0;
43
- }
44
- function I() {
45
- return s === void 0 ? u : b($());
46
- }
47
- function S() {
48
- var i = $(), o = L(i);
49
- if (n = arguments, a = this, l = i, o) {
50
- if (s === void 0)
51
- return j(l);
52
- if (v)
53
- return s = setTimeout(y, r), P(l);
54
- }
55
- return s === void 0 && (s = setTimeout(y, r)), u;
56
- }
57
- return S.cancel = E, S.flush = I, S;
58
- }
59
- function q(e) {
60
- var r = typeof e;
61
- return !!e && (r == "object" || r == "function");
62
- }
63
- function Me(e) {
64
- return !!e && typeof e == "object";
65
- }
66
- function ke(e) {
67
- return typeof e == "symbol" || Me(e) && Ee.call(e) == be;
68
- }
69
- function Z(e) {
70
- if (typeof e == "number")
71
- return e;
72
- if (ke(e))
73
- return Y;
74
- if (q(e)) {
75
- var r = typeof e.valueOf == "function" ? e.valueOf() : e;
76
- e = q(r) ? r + "" : r;
77
- }
78
- if (typeof e != "string")
79
- return e === 0 ? e : +e;
80
- e = e.replace(Se, "");
81
- var t = Oe.test(e);
82
- return t || he.test(e) ? Te(e.slice(2), t ? 2 : 8) : Pe.test(e) ? Y : +e;
83
- }
84
- var Ge = Ce, k = {};
85
- Object.defineProperty(k, "__esModule", {
86
- value: !0
87
- });
88
- k.loadGoogleMapScript = k.isBrowser = void 0;
89
- var oe = typeof window < "u" && window.document;
90
- k.isBrowser = oe;
91
- var Re = function(r, t) {
92
- if (!oe || typeof google < "u" && google.maps && google.maps.api)
93
- return Promise.resolve();
94
- var n = document.querySelectorAll('script[src*="'.concat(r, '"]'));
95
- if (n && n.length)
96
- return new Promise(function(u) {
97
- if (typeof google < "u") return u();
98
- n[0].addEventListener("load", function() {
99
- return u();
100
- });
101
- });
102
- var a = new URL(t);
103
- a.searchParams.set("callback", "__REACT_GOOGLE_AUTOCOMPLETE_CALLBACK__");
104
- var c = document.createElement("script");
105
- return c.src = a.toString(), new Promise(function(u) {
106
- window.__REACT_GOOGLE_AUTOCOMPLETE_CALLBACK__ = u, document.body.appendChild(c);
107
- });
108
- };
109
- k.loadGoogleMapScript = Re;
110
- var N = {};
111
- Object.defineProperty(N, "__esModule", {
112
- value: !0
113
- });
114
- N.GOOGLE_MAP_SCRIPT_BASE_URL = void 0;
115
- var Be = "https://maps.googleapis.com/maps/api/js";
116
- N.GOOGLE_MAP_SCRIPT_BASE_URL = Be;
117
- Object.defineProperty(ne, "__esModule", {
118
- value: !0
119
- });
120
- var Ue = ne.default = Ve, g = le, D = Qe(Ge), ee = k, Ne = N;
121
- function Qe(e) {
122
- return e && e.__esModule ? e : { default: e };
123
- }
124
- function re(e, r) {
125
- var t = Object.keys(e);
126
- if (Object.getOwnPropertySymbols) {
127
- var n = Object.getOwnPropertySymbols(e);
128
- r && (n = n.filter(function(a) {
129
- return Object.getOwnPropertyDescriptor(e, a).enumerable;
130
- })), t.push.apply(t, n);
131
- }
132
- return t;
133
- }
134
- function C(e) {
135
- for (var r = 1; r < arguments.length; r++) {
136
- var t = arguments[r] != null ? arguments[r] : {};
137
- r % 2 ? re(Object(t), !0).forEach(function(n) {
138
- $e(e, n, t[n]);
139
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : re(Object(t)).forEach(function(n) {
140
- Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
141
- });
142
- }
143
- return e;
144
- }
145
- function $e(e, r, t) {
146
- return r in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e;
147
- }
148
- function M(e, r) {
149
- return We(e) || Ke(e, r) || Fe(e, r) || qe();
150
- }
151
- function qe() {
152
- throw new TypeError(`Invalid attempt to destructure non-iterable instance.
153
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
154
- }
155
- function Fe(e, r) {
156
- if (e) {
157
- if (typeof e == "string") return te(e, r);
158
- var t = Object.prototype.toString.call(e).slice(8, -1);
159
- if (t === "Object" && e.constructor && (t = e.constructor.name), t === "Map" || t === "Set") return Array.from(e);
160
- if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return te(e, r);
161
- }
162
- }
163
- function te(e, r) {
164
- (r == null || r > e.length) && (r = e.length);
165
- for (var t = 0, n = new Array(r); t < r; t++)
166
- n[t] = e[t];
167
- return n;
168
- }
169
- function Ke(e, r) {
170
- var t = e && (typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"]);
171
- if (t != null) {
172
- var n = [], a = !0, c = !1, u, s;
173
- try {
174
- for (t = t.call(e); !(a = (u = t.next()).done) && (n.push(u.value), !(r && n.length === r)); a = !0)
175
- ;
176
- } catch (l) {
177
- c = !0, s = l;
178
- } finally {
179
- try {
180
- !a && t.return != null && t.return();
181
- } finally {
182
- if (c) throw s;
183
- }
184
- }
185
- return n;
186
- }
187
- }
188
- function We(e) {
189
- if (Array.isArray(e)) return e;
190
- }
191
- function Ve(e) {
192
- var r = e.apiKey, t = e.libraries, n = t === void 0 ? "places" : t, 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, m = l === void 0 ? {} : l, d = e.sessionToken, v = e.language, T = v ? "&language=".concat(v) : "", P = "".concat(c, "?key=").concat(r, "&libraries=").concat(n).concat(T), j = (0, g.useState)([]), A = M(j, 2), L = A[0], y = A[1], b = (0, g.useState)(!1), E = M(b, 2), I = E[0], S = E[1], i = (0, g.useState)(null), o = M(i, 2), f = o[0], O = o[1], R = (0, g.useState)(!1), G = M(R, 2), B = G[0], Q = G[1], ie = (0, g.useState)(!1), F = M(ie, 2), ae = F[0], K = F[1], se = (0, g.useState)([]), W = M(se, 2), ue = W[0], V = W[1], w = (0, g.useRef)(null), H = (0, g.useRef)(null), x = (0, g.useRef)(null), ce = (0, g.useCallback)(function() {
193
- return (0, ee.loadGoogleMapScript)(c, P);
194
- }, [c, P]), z = (0, g.useCallback)((0, D.default)(function(_) {
195
- w.current && _.input && w.current.getPlacePredictions(C(C(C({}, d && x.current ? {
196
- sessionToken: x.current
197
- } : {}), m), _), function(p) {
198
- S(!1), y(p || []);
199
- });
200
- }, s), [s]), X = (0, g.useCallback)((0, D.default)(function(_) {
201
- w.current && _.input && w.current.getQueryPredictions(C(C(C({}, d && x.current ? {
202
- sessionToken: x.current
203
- } : {}), m), _), function(p) {
204
- Q(!1), V(p || []);
205
- });
206
- }, s), [s]);
207
- return (0, g.useEffect)(function() {
208
- if (ee.isBrowser) {
209
- var _ = function() {
210
- if (!google) return console.error("Google has not been found. Make sure your provide apiKey prop.");
211
- w.current = new google.maps.places.AutocompleteService(), H.current = new google.maps.places.PlacesService(document.createElement("div")), d && (x.current = new google.maps.places.AutocompleteSessionToken());
212
- };
213
- r ? ce().then(function() {
214
- return _();
215
- }) : _();
216
- }
217
- }, []), {
218
- placesService: H.current,
219
- autocompleteSessionToken: x.current,
220
- placesAutocompleteService: w.current,
221
- placePredictions: f ? L : [],
222
- isPlacePredictionsLoading: I,
223
- getPlacePredictions: function(p) {
224
- if (p.input) {
225
- O(p.input), S(!0), z(p);
226
- return;
227
- }
228
- y([]), O(null), z(p), S(!1);
229
- },
230
- queryPredictions: ae ? ue : [],
231
- isQueryPredictionsLoading: B,
232
- getQueryPredictions: function(p) {
233
- if (p.input) {
234
- K(p.input), Q(!0), X(p);
235
- return;
236
- }
237
- V([]), K(null), X(p), Q(!1);
238
- },
239
- refreshSessionToken: function() {
240
- x.current = new google.maps.places.AutocompleteSessionToken();
241
- }
242
- };
243
- }
244
- const er = ({ field: e }) => {
245
- var i;
246
- const [r, t] = J(""), [n, a] = J(!1), { key: c = "", label: u = "", helper_text: s = "", readonly: l = !1 } = e, m = c, {
247
- field: { value: d, onBlur: v, onChange: T, ...P },
248
- fieldState: j
249
- } = de({
250
- name: m,
251
- rules: ge(e)
252
- }), A = !!(e != null && e.required), L = (i = j == null ? void 0 : j.error) == null ? void 0 : i.message, {
253
- placesService: y,
254
- placePredictions: b,
255
- getPlacePredictions: E,
256
- isPlacePredictionsLoading: I
257
- } = Ue({
258
- apiKey: process.env.NEXT_PUBLIC_GOOGLE_MAPS,
259
- debounce: 200
260
- }), S = (o) => {
261
- y == null || y.getDetails(
262
- {
263
- placeId: o == null ? void 0 : o.place_id
264
- },
265
- (f) => {
266
- var O, R, G, B;
267
- T({
268
- ...f,
269
- place_name: o == null ? void 0 : o.description,
270
- latitude: ((R = (O = f == null ? void 0 : f.geometry) == null ? void 0 : O.location) == null ? void 0 : R.lat()) || 0,
271
- longitude: ((B = (G = f == null ? void 0 : f.geometry) == null ? void 0 : G.location) == null ? void 0 : B.lng()) || 0
272
- });
273
- }
274
- ), a(!0);
275
- };
276
- return fe(() => {
277
- d != null && d.place_name && (t(d == null ? void 0 : d.place_name), a(!0));
278
- }, [d]), /* @__PURE__ */ h.jsx(me, { error: L, helperText: s, readOnly: l, children: /* @__PURE__ */ h.jsxs("div", { className: "w-full relative", children: [
279
- u && /* @__PURE__ */ h.jsx(ye, { htmlFor: m, isRequired: A, children: u }),
280
- /* @__PURE__ */ h.jsx(
281
- _e,
282
- {
283
- id: m,
284
- value: r,
285
- onChange: (o) => {
286
- a(!1), E({ input: o.target.value }), t(o.target.value);
287
- },
288
- onBlur: () => {
289
- v();
290
- },
291
- rightIcon: I && /* @__PURE__ */ h.jsx(pe, { size: "20px", className: "animate-spin" }),
292
- readOnly: l,
293
- ...P
294
- }
295
- ),
296
- r && !I && !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(
297
- "p",
298
- {
299
- className: "text-md p-[8px] cursor-pointer rounded-[6px] hover:bg-gray-200",
300
- onClick: () => S(o),
301
- children: o.description
302
- },
303
- o.place_id
304
- )) : /* @__PURE__ */ h.jsx("p", { className: "text-md p-[8px] text-muted-foreground", children: "No results found" }) })
305
- ] }) });
306
- };
307
- export {
308
- er as GeocoderWidget,
309
- er as default
310
- };