@levo-so/react 0.1.15 → 0.1.17

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 (81) hide show
  1. package/dist/{CheckboxWidget-BGS61gcL.js → CheckboxWidget-CZWSPzDj.js} +1 -1
  2. package/dist/{CollectionFormBuilder-BIvx_z08.js → CollectionFormBuilder-nZcXob6G.js} +67 -65
  3. package/dist/{CurrencyWidget-sD8ijLvw.js → CurrencyWidget-CvosXYBi.js} +1 -1
  4. package/dist/{DateTimeWidget-KrcsxgEF.js → DateTimeWidget-CE0EPFkl.js} +1 -1
  5. package/dist/DefaultFormVariant-DiaIcOyu.js +81 -0
  6. package/dist/{DropdownWidget-rm5oUqOE.js → DropdownWidget-BquZdGIL.js} +4 -2
  7. package/dist/{EmailWidget-CvZKOywL.js → EmailWidget-KnkQjB4I.js} +1 -1
  8. package/dist/FormCaptcha-DNPGf2xY.js +197 -0
  9. package/dist/{GeocoderWidget-CSsp_-hW.js → GeocoderWidget-DNkRmCVB.js} +2 -2
  10. package/dist/LevoProvider-BAZy7_tP.js +223 -0
  11. package/dist/{MultiGeocoderWidget-Blqz-lHX.js → MultiGeocoderWidget-D2Vh9SuR.js} +2 -2
  12. package/dist/{MultiTextWidget-CxVpyf06.js → MultiTextWidget-Ktmx0-ou.js} +1 -1
  13. package/dist/{PhoneWidget-DezcchSP.js → PhoneWidget-2JMw1hQ-.js} +1 -1
  14. package/dist/{RadioWidget-SfD1fFDG.js → RadioWidget-CsMqjCtP.js} +1 -1
  15. package/dist/{RichTextWidget-Cg3RizdO.js → RichTextWidget-CesaOZze.js} +1 -1
  16. package/dist/{StepsFormVariant-D35dFYK6.js → StepsFormVariant-FXwgPUG0.js} +59 -56
  17. package/dist/{SwitchWidget-Id6BNlPe.js → SwitchWidget-W7FLoMLu.js} +1 -1
  18. package/dist/{TextWidget-CtFaQde1.js → TextWidget-B6Y4Jjld.js} +1 -1
  19. package/dist/{TextareaWidget-BKzAeMod.js → TextareaWidget-TszSrgEj.js} +1 -1
  20. package/dist/{ToggleCheckboxWidget-nSlie9sE.js → ToggleCheckboxWidget-sJoiRMME.js} +1 -1
  21. package/dist/{URLWidget-DtJai3xY.js → URLWidget-BjFx8Uf7.js} +2 -2
  22. package/dist/{UploadWidget-Dxx2_FYo.js → UploadWidget-Dzop6rEv.js} +6 -6
  23. package/dist/audience/components/block.d.ts.map +1 -1
  24. package/dist/audience/components/component.d.ts.map +1 -1
  25. package/dist/audience/components/page.d.ts.map +1 -1
  26. package/dist/audience/index.js +1 -1
  27. package/dist/collection/components/Altcha.d.ts.map +1 -1
  28. package/dist/collection/components/FormCaptcha.d.ts +3 -0
  29. package/dist/collection/components/FormCaptcha.d.ts.map +1 -0
  30. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +1 -1
  31. package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +1 -1
  32. package/dist/collection/components/core/Input/Input.d.ts.map +1 -1
  33. package/dist/collection/components/core/Switch/Switch.d.ts.map +1 -1
  34. package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -1
  35. package/dist/collection/components/widgets/FieldWrapper.d.ts.map +1 -1
  36. package/dist/collection/components/widgets/FormHelperText.d.ts.map +1 -1
  37. package/dist/collection/components/widgets/FormLabel.d.ts.map +1 -1
  38. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -1
  39. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -1
  40. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +1 -1
  41. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +1 -1
  42. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -1
  43. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -1
  44. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -1
  45. package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts.map +1 -1
  46. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -1
  47. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +1 -1
  48. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +1 -1
  49. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +1 -1
  50. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +1 -1
  51. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -1
  52. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
  53. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
  54. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -1
  55. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -1
  56. package/dist/collection/index.js +1 -1
  57. package/dist/collection/lib/FormBuilder.d.ts.map +1 -1
  58. package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -1
  59. package/dist/collection/lib/hooks/useLevoForm.d.ts +1 -2
  60. package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -1
  61. package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -1
  62. package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +1 -1
  63. package/dist/collection/utils/formHelpers.d.ts.map +1 -1
  64. package/dist/collection/utils/index.d.ts.map +1 -1
  65. package/dist/components/Dialog.d.ts.map +1 -1
  66. package/dist/components/Spinner.d.ts.map +1 -1
  67. package/dist/components/Table.d.ts.map +1 -1
  68. package/dist/components/Tabs.d.ts.map +1 -1
  69. package/dist/components/Tooltip.d.ts.map +1 -1
  70. package/dist/components/button/Button.d.ts.map +1 -1
  71. package/dist/index.js +3 -3
  72. package/dist/membership/components/Button.d.ts.map +1 -1
  73. package/dist/membership/components/Container.d.ts.map +1 -1
  74. package/dist/membership/components/Core.d.ts.map +1 -1
  75. package/dist/membership/index.js +2 -3
  76. package/dist/{page-DgqTELmZ.js → page-BKyDlf0z.js} +1 -1
  77. package/dist/utils/errorHandler.d.ts.map +1 -1
  78. package/package.json +4 -4
  79. package/dist/DefaultFormVariant-j1HgVDiI.js +0 -127
  80. package/dist/LevoProvider-Do3jjJ4j.js +0 -211
  81. package/dist/useLevoForm-3jSJ9I6v.js +0 -170
@@ -0,0 +1,197 @@
1
+ "use client";
2
+ import { useEffect as O, useState as L, useRef as J } from "react";
3
+ import { useFormContext as W, useWatch as Y, useForm as B, useController as G } from "react-hook-form";
4
+ import { useDebouncedCallback as H } from "use-debounce";
5
+ import { u as x } from "./LevoProvider-BAZy7_tP.js";
6
+ import { D as C, s as z, h as Q, c as X, A as Z } from "./CollectionFormBuilder-nZcXob6G.js";
7
+ import { s as m } from "./Sonner-t6JVKA0a.js";
8
+ import { e as T } from "./errorHandler-_34Yv8wA.js";
9
+ import { a as h } from "./isEmptyObject-C5s4GzLE.js";
10
+ import { j as U } from "./jsx-runtime-B6kdoens.js";
11
+ import "altcha";
12
+ const R = {
13
+ FORM_DIRTY: "form-dirty",
14
+ FORM_VALUES: "form-values"
15
+ }, tt = (t) => {
16
+ const o = localStorage.getItem(`${t}-${R.FORM_VALUES}`);
17
+ return o ? JSON.parse(o) : {};
18
+ }, et = (t, o) => {
19
+ localStorage.setItem(
20
+ `${t}-${R.FORM_VALUES}`,
21
+ JSON.stringify(o)
22
+ );
23
+ }, M = (t) => {
24
+ localStorage.removeItem(`${t}-${R.FORM_VALUES}`);
25
+ }, rt = 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
+ }, yt = ({ currentValues: t, isError: o, getContentId: c }) => {
41
+ var I;
42
+ const { schema: e, isLoggedIn: a } = C(), r = W(), s = Y(), g = H((v) => {
43
+ e != null && e.key && !o && e != null && e.allow_draft && (a ? rt({
44
+ collection_key: e == null ? void 0 : e.key,
45
+ data: v
46
+ }).then((l) => {
47
+ var E, _, V, d;
48
+ (_ = (E = l == null ? void 0 : l.content) == null ? void 0 : E.data) != null && _._id && c((d = (V = l == null ? void 0 : l.content) == null ? void 0 : V.data) == null ? void 0 : d._id);
49
+ }) : et(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 && (g.cancel(), g({
54
+ ...t,
55
+ ...s
56
+ }));
57
+ }, [(I = r == null ? void 0 : r.formState) == null ? void 0 : I.isDirty, o, a, s]), null;
58
+ }, pt = ({
59
+ schema: t,
60
+ saveToRemote: o,
61
+ onSubmit: c,
62
+ onSubmitSuccess: e,
63
+ onSubmitError: a
64
+ }) => {
65
+ const { collection: r } = x(), {
66
+ toastConfig: s,
67
+ onSuccess: g,
68
+ onError: I,
69
+ isLoggedIn: v,
70
+ isDisabled: l,
71
+ externalInitialValues: E = {}
72
+ } = C(), [_, V] = L({}), [d, w] = L(null), [N, $] = L(!1), [P, A] = L(!1), n = J({}), F = B({
73
+ mode: "all",
74
+ disabled: l,
75
+ defaultValues: _,
76
+ values: _,
77
+ resetOptions: {
78
+ keepErrors: !0
79
+ }
80
+ }), q = F.handleSubmit(async (y) => {
81
+ var k, S, p, i, j, D;
82
+ if (n.current = {
83
+ ...n.current || {},
84
+ ...y
85
+ }, o && r) {
86
+ if (t)
87
+ try {
88
+ const f = z(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, f).catch((b) => (T(b), null))) : u = await (r == null ? void 0 : r.saveCollectionData({
91
+ collection_id: t == null ? void 0 : t.id,
92
+ data: f
93
+ }).catch((b) => (T(b), null))), (k = u == null ? void 0 : u.content) != null && k.data)
94
+ return s != null && s.showSuccessToast && m(
95
+ s.successToastText || "Form submitted successfully."
96
+ ), n.current = h(E) ? {} : { ...E }, M(t == null ? void 0 : t.key), w(null), g && g({
97
+ schemaId: t == null ? void 0 : t.id,
98
+ response: (S = u == null ? void 0 : u.content) == null ? void 0 : S.data
99
+ }), e && e(), F.reset(), F.clearErrors(), !0;
100
+ throw new Error("Failed to save form details, API response invalid");
101
+ } catch (f) {
102
+ const u = (j = (i = (p = f == null ? void 0 : f.response) == null ? void 0 : p.data) == null ? void 0 : i.content) == null ? void 0 : j.errors;
103
+ return Q(u, F.setError), a && a(u), I && I(((D = f == null ? void 0 : f.response) == null ? void 0 : D.data) || f), !1;
104
+ }
105
+ return !1;
106
+ }
107
+ y && c && c(y);
108
+ }), K = (y) => {
109
+ y && y !== d && w(y);
110
+ };
111
+ return O(() => {
112
+ if (t && r) {
113
+ const y = X(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((S) => {
121
+ if (S === null) {
122
+ A(!0);
123
+ return;
124
+ }
125
+ A(!1);
126
+ const p = Array.isArray(S) ? S == null ? void 0 : S.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
+ V({
136
+ ...n == null ? void 0 : n.current
137
+ }), $(!1);
138
+ });
139
+ return;
140
+ }
141
+ const k = tt(t == null ? void 0 : t.key);
142
+ k && (n.current = {
143
+ ...n.current || {},
144
+ ...k
145
+ });
146
+ }
147
+ V({
148
+ ...(n == null ? void 0 : n.current) || {}
149
+ });
150
+ }
151
+ }, [t]), O(() => {
152
+ t && d && M(t == null ? void 0 : t.key);
153
+ }, [d]), {
154
+ methods: F,
155
+ isLoading: N,
156
+ isError: P,
157
+ contentId: d,
158
+ allFormValues: n.current,
159
+ handleContentId: K,
160
+ handleSubmit: q
161
+ };
162
+ }, gt = () => {
163
+ const { isInternal: t } = C(), { client: o } = x(), c = J(null), {
164
+ field: { onChange: e },
165
+ fieldState: { error: a }
166
+ } = G({
167
+ name: "__captcha",
168
+ rules: {
169
+ required: t ? !1 : "Verification is required"
170
+ }
171
+ });
172
+ return O(() => {
173
+ const r = (g) => {
174
+ "detail" in g && e(g.detail.state || null);
175
+ }, { current: s } = c;
176
+ if (s)
177
+ return s.addEventListener("statechange", r), () => s.removeEventListener("statechange", r);
178
+ }, []), /* @__PURE__ */ U.jsx(Z, { error: a == null ? void 0 : a.message, children: /* @__PURE__ */ U.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
+ gt as F,
195
+ yt as S,
196
+ pt as u
197
+ };
@@ -3,9 +3,9 @@ import { j as o } from "./jsx-runtime-B6kdoens.js";
3
3
  import { useState as p, useEffect as v } from "react";
4
4
  import { useController as z } from "react-hook-form";
5
5
  import { n as T } from "./Spinner-Bzu2xCFZ.js";
6
- import { z as k, A as q, B as A } from "./CollectionFormBuilder-BIvx_z08.js";
6
+ import { z as k, A as q, B as A } from "./CollectionFormBuilder-nZcXob6G.js";
7
7
  import { I as E } from "./Input-2CvZ90f8.js";
8
- import { u as O } from "./LevoProvider-Do3jjJ4j.js";
8
+ import { u as O } from "./LevoProvider-BAZy7_tP.js";
9
9
  const $ = ({ field: t }) => {
10
10
  var _;
11
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, {
@@ -0,0 +1,223 @@
1
+ "use client";
2
+ var j = Object.defineProperty;
3
+ var D = (l, o, t) => o in l ? j(l, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[o] = t;
4
+ var p = (l, o, t) => D(l, typeof o != "symbol" ? o + "" : o, t);
5
+ import { j as B } from "./jsx-runtime-B6kdoens.js";
6
+ import k from "wretch";
7
+ import { createContext as G, useContext as W } from "react";
8
+ var q = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
9
+ function z(l) {
10
+ return l && l.__esModule && Object.prototype.hasOwnProperty.call(l, "default") ? l.default : l;
11
+ }
12
+ var T = class {
13
+ constructor(l) {
14
+ p(this, "client");
15
+ this.client = l;
16
+ }
17
+ }, F = { exports: {} };
18
+ (function(l) {
19
+ (function(o, t) {
20
+ l.exports ? l.exports = t() : o.log = t();
21
+ })(q, function() {
22
+ var o = function() {
23
+ }, t = "undefined", L = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), g = [
24
+ "trace",
25
+ "debug",
26
+ "info",
27
+ "warn",
28
+ "error"
29
+ ], f = {}, a = null;
30
+ function b(n, i) {
31
+ var e = n[i];
32
+ if (typeof e.bind == "function")
33
+ return e.bind(n);
34
+ try {
35
+ return Function.prototype.bind.call(e, n);
36
+ } catch {
37
+ return function() {
38
+ return Function.prototype.apply.apply(e, [n, arguments]);
39
+ };
40
+ }
41
+ }
42
+ function S() {
43
+ console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
44
+ }
45
+ function U(n) {
46
+ return n === "debug" && (n = "log"), typeof console === t ? !1 : n === "trace" && L ? S : console[n] !== void 0 ? b(console, n) : console.log !== void 0 ? b(console, "log") : o;
47
+ }
48
+ function d() {
49
+ for (var n = this.getLevel(), i = 0; i < g.length; i++) {
50
+ var e = g[i];
51
+ this[e] = i < n ? o : this.methodFactory(e, n, this.name);
52
+ }
53
+ if (this.log = this.debug, typeof console === t && n < this.levels.SILENT)
54
+ return "No console available for logging";
55
+ }
56
+ function A(n) {
57
+ return function() {
58
+ typeof console !== t && (d.call(this), this[n].apply(this, arguments));
59
+ };
60
+ }
61
+ function M(n, i, e) {
62
+ return U(n) || A.apply(this, arguments);
63
+ }
64
+ function E(n, i) {
65
+ var e = this, y, m, c, u = "loglevel";
66
+ typeof n == "string" ? u += ":" + n : typeof n == "symbol" && (u = void 0);
67
+ function O(r) {
68
+ var s = (g[r] || "silent").toUpperCase();
69
+ if (!(typeof window === t || !u)) {
70
+ try {
71
+ window.localStorage[u] = s;
72
+ return;
73
+ } catch {
74
+ }
75
+ try {
76
+ window.document.cookie = encodeURIComponent(u) + "=" + s + ";";
77
+ } catch {
78
+ }
79
+ }
80
+ }
81
+ function C() {
82
+ var r;
83
+ if (!(typeof window === t || !u)) {
84
+ try {
85
+ r = window.localStorage[u];
86
+ } catch {
87
+ }
88
+ if (typeof r === t)
89
+ try {
90
+ var s = window.document.cookie, h = encodeURIComponent(u), I = s.indexOf(h + "=");
91
+ I !== -1 && (r = /^([^;]+)/.exec(
92
+ s.slice(I + h.length + 1)
93
+ )[1]);
94
+ } catch {
95
+ }
96
+ return e.levels[r] === void 0 && (r = void 0), r;
97
+ }
98
+ }
99
+ function P() {
100
+ if (!(typeof window === t || !u)) {
101
+ try {
102
+ window.localStorage.removeItem(u);
103
+ } catch {
104
+ }
105
+ try {
106
+ window.document.cookie = encodeURIComponent(u) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
107
+ } catch {
108
+ }
109
+ }
110
+ }
111
+ function v(r) {
112
+ var s = r;
113
+ if (typeof s == "string" && e.levels[s.toUpperCase()] !== void 0 && (s = e.levels[s.toUpperCase()]), typeof s == "number" && s >= 0 && s <= e.levels.SILENT)
114
+ return s;
115
+ throw new TypeError("log.setLevel() called with invalid level: " + r);
116
+ }
117
+ e.name = n, e.levels = {
118
+ TRACE: 0,
119
+ DEBUG: 1,
120
+ INFO: 2,
121
+ WARN: 3,
122
+ ERROR: 4,
123
+ SILENT: 5
124
+ }, e.methodFactory = i || M, e.getLevel = function() {
125
+ return c ?? m ?? y;
126
+ }, e.setLevel = function(r, s) {
127
+ return c = v(r), s !== !1 && O(c), d.call(e);
128
+ }, e.setDefaultLevel = function(r) {
129
+ m = v(r), C() || e.setLevel(r, !1);
130
+ }, e.resetLevel = function() {
131
+ c = null, P(), d.call(e);
132
+ }, e.enableAll = function(r) {
133
+ e.setLevel(e.levels.TRACE, r);
134
+ }, e.disableAll = function(r) {
135
+ e.setLevel(e.levels.SILENT, r);
136
+ }, e.rebuild = function() {
137
+ if (a !== e && (y = v(a.getLevel())), d.call(e), a === e)
138
+ for (var r in f)
139
+ f[r].rebuild();
140
+ }, y = v(
141
+ a ? a.getLevel() : "WARN"
142
+ );
143
+ var x = C();
144
+ x != null && (c = v(x)), d.call(e);
145
+ }
146
+ a = new E(), a.getLogger = function(i) {
147
+ if (typeof i != "symbol" && typeof i != "string" || i === "")
148
+ throw new TypeError("You must supply a name when creating a logger.");
149
+ var e = f[i];
150
+ return e || (e = f[i] = new E(
151
+ i,
152
+ a.methodFactory
153
+ )), e;
154
+ };
155
+ var N = typeof window !== t ? window.log : void 0;
156
+ return a.noConflict = function() {
157
+ return typeof window !== t && window.log === a && (window.log = N), a;
158
+ }, a.getLoggers = function() {
159
+ return f;
160
+ }, a.default = a, a;
161
+ });
162
+ })(F);
163
+ var J = F.exports;
164
+ const w = /* @__PURE__ */ z(J);
165
+ var K = class extends T {
166
+ constructor(o) {
167
+ super(o);
168
+ p(this, "logger", w);
169
+ w.setLevel(
170
+ this.client.NODE_ENV === "production" ? w.levels.INFO : w.levels.DEBUG
171
+ ), w.methodFactory = (t) => (L, g = {}) => {
172
+ k().url(`${this.client.apiUrl}/v1/apm/logs/json`).post({
173
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
174
+ level: t,
175
+ message: L,
176
+ ...g
177
+ }).res().catch((f) => console.error(f));
178
+ };
179
+ }
180
+ error(...o) {
181
+ return this.logger.error(...o);
182
+ }
183
+ log(...o) {
184
+ return this.logger.debug(...o);
185
+ }
186
+ info(...o) {
187
+ return this.logger.info(...o);
188
+ }
189
+ warn(...o) {
190
+ return this.logger.warn(...o);
191
+ }
192
+ }, V = class extends T {
193
+ constructor() {
194
+ super(...arguments);
195
+ p(this, "mediaBulkUpload", (o, t = {}) => this.client.fetch.url("/v1/assets/media/bulk").options(t).post(o).json());
196
+ p(this, "getAllMedia", async (o = {}) => await this.client.fetch.url("/v1/assets/media/query").post(o).json());
197
+ }
198
+ };
199
+ const R = G(null), X = ({
200
+ children: l,
201
+ client: o,
202
+ ...t
203
+ }) => /* @__PURE__ */ B.jsx(
204
+ R.Provider,
205
+ {
206
+ value: {
207
+ client: o,
208
+ media: new V(o),
209
+ logger: new K(o),
210
+ ...t
211
+ },
212
+ children: l
213
+ }
214
+ ), Z = () => {
215
+ const l = W(R);
216
+ if (!l)
217
+ throw new Error("useLevo must be used within LevoProvider");
218
+ return l;
219
+ };
220
+ export {
221
+ X as L,
222
+ Z as u
223
+ };
@@ -2,8 +2,8 @@
2
2
  import { j as e } from "./jsx-runtime-B6kdoens.js";
3
3
  import { Plus as m } from "lucide-react";
4
4
  import { useFieldArray as n } from "react-hook-form";
5
- import { B as c } from "./CollectionFormBuilder-BIvx_z08.js";
6
- import { GeocoderWidget as d } from "./GeocoderWidget-CSsp_-hW.js";
5
+ import { B as c } from "./CollectionFormBuilder-nZcXob6G.js";
6
+ import { GeocoderWidget as d } from "./GeocoderWidget-DNkRmCVB.js";
7
7
  import { B as p } from "./Spinner-Bzu2xCFZ.js";
8
8
  const k = ({
9
9
  field: l
@@ -1,6 +1,6 @@
1
1
  import { j as a } from "./jsx-runtime-B6kdoens.js";
2
2
  import { useController as A } from "react-hook-form";
3
- import { z as C, A as b, B as q } from "./CollectionFormBuilder-BIvx_z08.js";
3
+ import { z as C, A as b, B as q } from "./CollectionFormBuilder-nZcXob6G.js";
4
4
  import { I } from "./Input-2CvZ90f8.js";
5
5
  const f = ({ field: r }) => {
6
6
  var l;
@@ -3,7 +3,7 @@ import { j as o } from "./jsx-runtime-B6kdoens.js";
3
3
  import { useController as f } from "react-hook-form";
4
4
  import { PhoneInput as g } from "react-international-phone";
5
5
  import { c as l } from "./cn-C9QoOYNG.js";
6
- import { z as x, A as v, B as y } from "./CollectionFormBuilder-BIvx_z08.js";
6
+ import { z as x, A as v, B as y } from "./CollectionFormBuilder-nZcXob6G.js";
7
7
  const P = ({ field: e }) => {
8
8
  const { key: u = "", label: t = "", helper_text: c = "", readonly: n = !1 } = e, s = u, {
9
9
  field: { value: d, onBlur: a, onChange: i, ...m },
@@ -5,7 +5,7 @@ import * as d from "react";
5
5
  import { useController as F } from "react-hook-form";
6
6
  import { G as B } from "./Spinner-Bzu2xCFZ.js";
7
7
  import { c as N } from "./cn-C9QoOYNG.js";
8
- import { z as E, A as G, B as f } from "./CollectionFormBuilder-BIvx_z08.js";
8
+ import { z as E, A as G, B as f } from "./CollectionFormBuilder-nZcXob6G.js";
9
9
  import { I as V } from "./Input-2CvZ90f8.js";
10
10
  function q(s) {
11
11
  return B({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M416 128 192 384l-96-96" }, child: [] }] })(s);
@@ -19,7 +19,7 @@ import { useState as q, useEffect as D } from "react";
19
19
  import { useController as G } from "react-hook-form";
20
20
  import { G as p, o as J, p as V, q as W, r as Z, s as _, t as P, u as K, v as Q, w as X, x as Y, y as $, z as nn } from "./Spinner-Bzu2xCFZ.js";
21
21
  import { c as j } from "./cn-C9QoOYNG.js";
22
- import { z as ln, A as en, B as sn } from "./CollectionFormBuilder-BIvx_z08.js";
22
+ import { z as ln, A as en, B as sn } from "./CollectionFormBuilder-nZcXob6G.js";
23
23
  function an(n) {
24
24
  return p({ tag: "svg", attr: { viewBox: "0 0 1024 1024" }, child: [{ tag: "path", attr: { d: "M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 0 1-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 0 1-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 0 0-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z" }, child: [] }] })(n);
25
25
  }
@@ -1,91 +1,91 @@
1
1
  "use client";
2
2
  import { j as t } from "./jsx-runtime-B6kdoens.js";
3
- import { useState as A, useMemo as v } from "react";
4
- import { FormProvider as I } from "react-hook-form";
5
- import { c as N } from "./cn-C9QoOYNG.js";
6
- import { D as g, F as T } from "./CollectionFormBuilder-BIvx_z08.js";
7
- import { u as H, S as M } from "./useLevoForm-3jSJ9I6v.js";
8
- import { B as y } from "./Spinner-Bzu2xCFZ.js";
9
- const X = () => {
10
- const [n, l] = A(0), { containerStyles: m } = g(), a = () => {
11
- l((o) => o - 1);
3
+ import { useState as I, useMemo as y } from "react";
4
+ import { FormProvider as T } from "react-hook-form";
5
+ import { c as F } from "./cn-C9QoOYNG.js";
6
+ import { D as N, F as _ } from "./CollectionFormBuilder-nZcXob6G.js";
7
+ import { u as C, S as H, F as M } from "./FormCaptcha-DNPGf2xY.js";
8
+ import { B as g } from "./Spinner-Bzu2xCFZ.js";
9
+ const Y = () => {
10
+ const [n, a] = I(0), { containerStyles: m } = N(), l = () => {
11
+ a((o) => o - 1);
12
12
  }, s = () => {
13
- l((o) => o + 1);
14
- }, d = (o) => {
15
- l(o);
13
+ a((o) => o + 1);
14
+ }, c = (o) => {
15
+ a(o);
16
16
  };
17
- return /* @__PURE__ */ t.jsx("div", { className: N("w-full", m), children: /* @__PURE__ */ t.jsx(
17
+ return /* @__PURE__ */ t.jsx("div", { className: F("w-full", m), children: /* @__PURE__ */ t.jsx(
18
18
  q,
19
19
  {
20
20
  currentSectionIndex: n,
21
21
  handleNext: s,
22
- handlePrev: a,
23
- goToIndex: d
22
+ handlePrev: l,
23
+ goToIndex: c
24
24
  }
25
25
  ) });
26
- }, q = ({ currentSectionIndex: n, handleNext: l, handlePrev: m, goToIndex: a }) => {
27
- var f, j, h;
28
- const { schema: s, isInternal: d, isDisabled: o, submitButtonConfig: i, uiConfig: c } = g(), r = v(
26
+ }, q = ({ currentSectionIndex: n, handleNext: a, handlePrev: m, goToIndex: l }) => {
27
+ var h, j, v;
28
+ const { schema: s, isInternal: c, isDisabled: o, submitButtonConfig: i, uiConfig: d } = N(), r = y(
29
29
  () => {
30
30
  var e;
31
31
  return (e = s == null ? void 0 : s.sections) == null ? void 0 : e[n];
32
32
  },
33
33
  [n]
34
- ), F = v(() => {
34
+ ), w = y(() => {
35
35
  if (s) {
36
36
  const e = { ...s };
37
37
  return r && e && (e.sections = [r]), e;
38
38
  }
39
39
  return null;
40
- }, [r]), u = n === Number((f = s == null ? void 0 : s.sections) == null ? void 0 : f.length) - 1, {
41
- methods: p,
42
- handleSubmit: w,
43
- isLoading: E,
44
- handleContentId: L,
45
- isError: D,
46
- allFormValues: P
47
- } = H({
48
- schema: F,
49
- saveToRemote: u,
40
+ }, [r]), x = n === Number((h = s == null ? void 0 : s.sections) == null ? void 0 : h.length) - 1, {
41
+ methods: u,
42
+ handleSubmit: E,
43
+ isLoading: L,
44
+ handleContentId: D,
45
+ isError: P,
46
+ allFormValues: V
47
+ } = C({
48
+ schema: w,
49
+ saveToRemote: x,
50
50
  onSubmit: () => {
51
- l();
51
+ a();
52
52
  },
53
53
  onSubmitSuccess: () => {
54
- a(0);
54
+ l(0);
55
55
  },
56
56
  onSubmitError: (e) => {
57
57
  var S;
58
58
  if (Array.isArray(e) && (e != null && e[0])) {
59
59
  const R = e == null ? void 0 : e[0];
60
- (S = s == null ? void 0 : s.sections) == null || S.forEach((x, V) => {
60
+ (S = s == null ? void 0 : s.sections) == null || S.forEach((p, z) => {
61
61
  var b;
62
- ((b = x == null ? void 0 : x.fields) == null ? void 0 : b.find((z) => z.key === R.param)) && a(V);
62
+ ((b = p == null ? void 0 : p.fields) == null ? void 0 : b.find((A) => A.key === R.param)) && l(z);
63
63
  });
64
64
  }
65
65
  }
66
66
  }), {
67
67
  formState: { isSubmitting: k }
68
- } = p;
69
- return /* @__PURE__ */ t.jsxs(I, { ...p, children: [
68
+ } = u, f = u.watch("__captcha");
69
+ return /* @__PURE__ */ t.jsxs(T, { ...u, children: [
70
70
  /* @__PURE__ */ t.jsx(
71
- M,
71
+ H,
72
72
  {
73
- getContentId: (e) => L(e),
74
- isError: D,
75
- currentValues: P
73
+ getContentId: (e) => D(e),
74
+ isError: P,
75
+ currentValues: V
76
76
  }
77
77
  ),
78
78
  /* @__PURE__ */ t.jsxs(
79
79
  "form",
80
80
  {
81
- className: N(
81
+ className: F(
82
82
  "w-full bg-white rounded-md border border-[rgb(229, 231, 235)] min-h-12 px-4 md:px-8 py-6",
83
- E && "opacity-50 pointer-events-none"
83
+ L && "opacity-50 pointer-events-none"
84
84
  ),
85
85
  id: "collection-form",
86
- onSubmit: w,
86
+ onSubmit: E,
87
87
  children: [
88
- !(c != null && c.hideSectionHeadings) && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between mb-6", children: [
88
+ !(d != null && d.hideSectionHeadings) && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between mb-6", children: [
89
89
  /* @__PURE__ */ t.jsx("p", { className: "text-xl font-medium", children: (r == null ? void 0 : r.label) || "Details" }),
90
90
  /* @__PURE__ */ t.jsxs("p", { children: [
91
91
  "Step ",
@@ -94,17 +94,20 @@ const X = () => {
94
94
  ((j = s == null ? void 0 : s.sections) == null ? void 0 : j.length) || 1
95
95
  ] })
96
96
  ] }),
97
- /* @__PURE__ */ t.jsx("div", { className: "w-full flex flex-col gap-6", children: (h = r == null ? void 0 : r.fields) == null ? void 0 : h.map((e) => e && !e.hidden ? /* @__PURE__ */ t.jsx(
98
- T,
99
- {
100
- field: e,
101
- isInternal: d
102
- },
103
- e == null ? void 0 : e.key
104
- ) : null) }),
97
+ /* @__PURE__ */ t.jsxs("div", { className: "w-full flex flex-col gap-6", children: [
98
+ (v = r == null ? void 0 : r.fields) == null ? void 0 : v.map((e) => e && !e.hidden ? /* @__PURE__ */ t.jsx(
99
+ _,
100
+ {
101
+ field: e,
102
+ isInternal: c
103
+ },
104
+ e == null ? void 0 : e.key
105
+ ) : null),
106
+ !c && x && /* @__PURE__ */ t.jsx(M, {})
107
+ ] }),
105
108
  /* @__PURE__ */ t.jsxs("div", { className: "flex mt-8 justify-between", children: [
106
109
  n !== 0 ? /* @__PURE__ */ t.jsx(
107
- y,
110
+ g,
108
111
  {
109
112
  type: "button",
110
113
  size: "sm",
@@ -115,15 +118,15 @@ const X = () => {
115
118
  }
116
119
  ) : /* @__PURE__ */ t.jsx("div", {}),
117
120
  /* @__PURE__ */ t.jsx(
118
- y,
121
+ g,
119
122
  {
120
123
  type: "submit",
121
124
  loadingText: "Saving",
122
125
  size: "sm",
123
- isLoading: k,
126
+ isLoading: k || f === "verifying",
124
127
  disabled: o,
125
128
  className: i == null ? void 0 : i.styles,
126
- children: u ? (i == null ? void 0 : i.text) ?? "Save" : "Next"
129
+ children: x ? f === "verifying" ? "Verifying..." : (i == null ? void 0 : i.text) || "Save" : "Next"
127
130
  }
128
131
  )
129
132
  ] })
@@ -133,5 +136,5 @@ const X = () => {
133
136
  ] });
134
137
  };
135
138
  export {
136
- X as default
139
+ Y as default
137
140
  };