@levo-so/react 0.1.17 → 0.1.21

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 (38) hide show
  1. package/dist/{CheckboxWidget-CZWSPzDj.js → CheckboxWidget-C4hO5xNP.js} +1 -1
  2. package/dist/{CollectionFormBuilder-nZcXob6G.js → CollectionFormBuilder-nJWTPHeL.js} +161 -165
  3. package/dist/{CurrencyWidget-CvosXYBi.js → CurrencyWidget-CZC10BuG.js} +1 -1
  4. package/dist/{DateTimeWidget-CE0EPFkl.js → DateTimeWidget-C7PJ3I0X.js} +1 -1
  5. package/dist/{DefaultFormVariant-DiaIcOyu.js → DefaultFormVariant-CMwBglKk.js} +3 -3
  6. package/dist/{DropdownWidget-BquZdGIL.js → DropdownWidget-6t1Azs7b.js} +1 -1
  7. package/dist/{EmailWidget-KnkQjB4I.js → EmailWidget-pAm9hnZ9.js} +2 -2
  8. package/dist/FormCaptcha-D2AaDZdK.js +187 -0
  9. package/dist/{GeocoderWidget-DNkRmCVB.js → GeocoderWidget-TZBlYaeC.js} +2 -2
  10. package/dist/{MultiGeocoderWidget-D2Vh9SuR.js → MultiGeocoderWidget-B-zhvJVk.js} +3 -3
  11. package/dist/{MultiTextWidget-Ktmx0-ou.js → MultiTextWidget-Ciy7yoNk.js} +1 -1
  12. package/dist/{PhoneWidget-2JMw1hQ-.js → PhoneWidget-C_JKm3Kf.js} +1 -1
  13. package/dist/{RadioWidget-CsMqjCtP.js → RadioWidget-CXHvRIFJ.js} +2 -2
  14. package/dist/{RichTextWidget-CesaOZze.js → RichTextWidget-B8_J6aM2.js} +2 -2
  15. package/dist/{Spinner-Bzu2xCFZ.js → Spinner-BnrQ9e_i.js} +58 -57
  16. package/dist/{StepsFormVariant-FXwgPUG0.js → StepsFormVariant-gZTiDsQs.js} +3 -3
  17. package/dist/{SwitchWidget-W7FLoMLu.js → SwitchWidget-1ca0o1kt.js} +1 -1
  18. package/dist/{TextWidget-B6Y4Jjld.js → TextWidget-BttCChJt.js} +1 -1
  19. package/dist/{TextareaWidget-TszSrgEj.js → TextareaWidget-DsWOpkGn.js} +1 -1
  20. package/dist/{ToggleCheckboxWidget-sJoiRMME.js → ToggleCheckboxWidget-yJcUcHpk.js} +1 -1
  21. package/dist/{URLWidget-BjFx8Uf7.js → URLWidget-DPTwLvbi.js} +2 -2
  22. package/dist/{UploadWidget-Dzop6rEv.js → UploadWidget-Cg6EJDMD.js} +2 -2
  23. package/dist/audience/components/page.d.ts.map +1 -1
  24. package/dist/audience/index.js +1 -1
  25. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -1
  26. package/dist/collection/index.js +1 -1
  27. package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -1
  28. package/dist/components/Dialog.d.ts +3 -1
  29. package/dist/components/Dialog.d.ts.map +1 -1
  30. package/dist/components/Sonner.d.ts +1 -1
  31. package/dist/components/Sonner.d.ts.map +1 -1
  32. package/dist/components/index.js +29 -28
  33. package/dist/index.js +50 -49
  34. package/dist/membership/components/Popup.d.ts.map +1 -1
  35. package/dist/page-sR2SWtb2.js +189 -0
  36. package/package.json +4 -4
  37. package/dist/FormCaptcha-DNPGf2xY.js +0 -197
  38. package/dist/page-BKyDlf0z.js +0 -212
@@ -1,197 +0,0 @@
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
- };
@@ -1,212 +0,0 @@
1
- "use client";
2
- import { j as R } from "./jsx-runtime-B6kdoens.js";
3
- import { useEffect as m, useState as S } from "react";
4
- import { useInView as C } from "react-intersection-observer";
5
- import { u as O } from "./LevoProvider-BAZy7_tP.js";
6
- import { usePageLifecycle as H, LifecycleState as I } from "use-page-lifecycle";
7
- const wt = ({ id: t, properties: r = {} }) => {
8
- const { audience: e } = O(), { ref: n, inView: s } = C({
9
- triggerOnce: !0
10
- });
11
- return m(() => {
12
- e != null && e.instance && s && (e == null || e.track("block.view", {
13
- ...r,
14
- resource: "block",
15
- identifier: t
16
- }));
17
- }, [s]), /* @__PURE__ */ R.jsx("div", { ref: n, style: { height: "0px" } });
18
- }, Tt = ({ event: t, properties: r }) => {
19
- const { audience: e } = O();
20
- return m(() => {
21
- e != null && e.instance && (e == null || e.track(t, r));
22
- }, [e == null ? void 0 : e.instance, t, r]), null;
23
- };
24
- function k(t) {
25
- var r = typeof t;
26
- return t != null && (r == "object" || r == "function");
27
- }
28
- var F = typeof global == "object" && global && global.Object === Object && global, _ = typeof self == "object" && self && self.Object === Object && self, W = F || _ || Function("return this")(), j = function() {
29
- return W.Date.now();
30
- }, G = /\s/;
31
- function V(t) {
32
- for (var r = t.length; r-- && G.test(t.charAt(r)); )
33
- ;
34
- return r;
35
- }
36
- var z = /^\s+/;
37
- function X(t) {
38
- return t && t.slice(0, V(t) + 1).replace(z, "");
39
- }
40
- var y = W.Symbol, A = Object.prototype, Y = A.hasOwnProperty, Z = A.toString, b = y ? y.toStringTag : void 0;
41
- function q(t) {
42
- var r = Y.call(t, b), e = t[b];
43
- try {
44
- t[b] = void 0;
45
- var n = !0;
46
- } catch {
47
- }
48
- var s = Z.call(t);
49
- return n && (r ? t[b] = e : delete t[b]), s;
50
- }
51
- var J = Object.prototype, K = J.toString;
52
- function Q(t) {
53
- return K.call(t);
54
- }
55
- var tt = "[object Null]", et = "[object Undefined]", P = y ? y.toStringTag : void 0;
56
- function nt(t) {
57
- return t == null ? t === void 0 ? et : tt : P && P in Object(t) ? q(t) : Q(t);
58
- }
59
- function rt(t) {
60
- return t != null && typeof t == "object";
61
- }
62
- var it = "[object Symbol]";
63
- function ot(t) {
64
- return typeof t == "symbol" || rt(t) && nt(t) == it;
65
- }
66
- var U = NaN, st = /^[-+]0x[0-9a-f]+$/i, at = /^0b[01]+$/i, ct = /^0o[0-7]+$/i, ft = parseInt;
67
- function $(t) {
68
- if (typeof t == "number")
69
- return t;
70
- if (ot(t))
71
- return U;
72
- if (k(t)) {
73
- var r = typeof t.valueOf == "function" ? t.valueOf() : t;
74
- t = k(r) ? r + "" : r;
75
- }
76
- if (typeof t != "string")
77
- return t === 0 ? t : +t;
78
- t = X(t);
79
- var e = at.test(t);
80
- return e || ct.test(t) ? ft(t.slice(2), e ? 2 : 8) : st.test(t) ? U : +t;
81
- }
82
- var lt = "Expected a function", ut = Math.max, gt = Math.min;
83
- function dt(t, r, e) {
84
- var n, s, c, l, i, a, f = 0, h = !1, u = !1, g = !0;
85
- if (typeof t != "function")
86
- throw new TypeError(lt);
87
- r = $(r) || 0, k(e) && (h = !!e.leading, u = "maxWait" in e, c = u ? ut($(e.maxWait) || 0, r) : c, g = "trailing" in e ? !!e.trailing : g);
88
- function w(o) {
89
- var d = n, p = s;
90
- return n = s = void 0, f = o, l = t.apply(p, d), l;
91
- }
92
- function D(o) {
93
- return f = o, i = setTimeout(v, r), h ? w(o) : l;
94
- }
95
- function N(o) {
96
- var d = o - a, p = o - f, L = r - d;
97
- return u ? gt(L, c - p) : L;
98
- }
99
- function x(o) {
100
- var d = o - a, p = o - f;
101
- return a === void 0 || d >= r || d < 0 || u && p >= c;
102
- }
103
- function v() {
104
- var o = j();
105
- if (x(o))
106
- return E(o);
107
- i = setTimeout(v, N(o));
108
- }
109
- function E(o) {
110
- return i = void 0, g && n ? w(o) : (n = s = void 0, l);
111
- }
112
- function M() {
113
- i !== void 0 && clearTimeout(i), f = 0, n = a = s = i = void 0;
114
- }
115
- function B() {
116
- return i === void 0 ? l : E(j());
117
- }
118
- function T() {
119
- var o = j(), d = x(o);
120
- if (n = arguments, s = this, a = o, d) {
121
- if (i === void 0)
122
- return D(a);
123
- if (u)
124
- return clearTimeout(i), i = setTimeout(v, r), w(a);
125
- }
126
- return i === void 0 && (i = setTimeout(v, r)), l;
127
- }
128
- return T.cancel = M, T.flush = B, T;
129
- }
130
- const mt = () => {
131
- const [t, r] = S(0), [e, n] = S(0), s = dt((c) => {
132
- n(c), r(c);
133
- }, 250);
134
- return m(() => {
135
- const c = () => {
136
- const l = window.scrollY, i = document.documentElement.scrollHeight, a = window.innerHeight, f = Math.round(
137
- l / (i - a) * 100
138
- );
139
- f % 10 === 0 && f > e && s(f);
140
- };
141
- return window.addEventListener("scroll", c), () => window.removeEventListener("scroll", c);
142
- }, [e]), t;
143
- }, jt = ({ id: t, properties: r = {} }) => {
144
- var h;
145
- const { client: e, audience: n } = O(), [s, c] = S(), l = mt(), i = typeof window < "u" ? window.location.href : void 0;
146
- m(() => {
147
- i && c(i);
148
- }, [i]), m(() => {
149
- n != null && n.instance && (n == null || n.track("page.scroll", {
150
- resource: "page",
151
- identifier: t,
152
- percent: l
153
- }));
154
- }, [n == null ? void 0 : n.instance, l]), m(() => {
155
- const u = () => {
156
- n == null || n.track("page.bounce", {
157
- resource: "page",
158
- identifier: t
159
- });
160
- };
161
- return window && window.addEventListener("beforeunload", u), () => {
162
- window && window.removeEventListener("beforeunload", u);
163
- };
164
- }, [i]);
165
- const [a] = H();
166
- if (m(() => {
167
- a === I.TERMINATED && (n == null || n.track("page.bounce", {
168
- resource: "page",
169
- identifier: t,
170
- state: a
171
- })), a === I.FROZEN && (n == null || n.track("page.bounce", {
172
- resource: "page",
173
- identifier: t,
174
- state: a
175
- }));
176
- }, [a]), !(e != null && e.insightsUrl) || !e.workspace || !e.workspace.startsWith("W"))
177
- return console.error(
178
- "[@levo-so/audience] The utility could not be initialized, due to missing workspace, or endpoint for insights."
179
- ), null;
180
- let f = "";
181
- try {
182
- const u = (h = e == null ? void 0 : e.insightsUrl) != null && h.startsWith("/") ? `${window.location.origin}${e.insightsUrl}` : "", g = new URL(
183
- `${u}/v1/insights/event/hello.gif` || "http://localhost/v1/insights/event/hello.gif"
184
- );
185
- g.searchParams.set("workspace", e.workspace), s && (g.searchParams.set("url", s), g.searchParams.set("location", btoa(s))), typeof document < "u" && g.searchParams.set("page_title", document.title), t && g.searchParams.set("identifier", t), f = g.toString();
186
- } catch {
187
- }
188
- return e != null && e.insightsUrl && e.workspace && s ? /* @__PURE__ */ R.jsx(
189
- "img",
190
- {
191
- alt: "",
192
- src: f,
193
- style: {
194
- height: "0px"
195
- },
196
- onLoad: () => {
197
- n != null && n.instance ? n == null || n.instance.page({
198
- resource: "page",
199
- identifier: r.id
200
- }) : n == null || n.initiate({
201
- ...r,
202
- id: t
203
- });
204
- }
205
- }
206
- ) : null;
207
- };
208
- export {
209
- wt as L,
210
- Tt as a,
211
- jt as b
212
- };