@levo-so/react 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CheckboxWidget-CZWSPzDj.js → CheckboxWidget-Dp9IAz5Q.js} +1 -1
- package/dist/{CollectionFormBuilder-nZcXob6G.js → CollectionFormBuilder-DpTePTDd.js} +17 -17
- package/dist/{CurrencyWidget-CvosXYBi.js → CurrencyWidget-BfnmQP9S.js} +1 -1
- package/dist/{DateTimeWidget-CE0EPFkl.js → DateTimeWidget-CqjC2iYx.js} +1 -1
- package/dist/{DefaultFormVariant-DiaIcOyu.js → DefaultFormVariant-CG7WUPV3.js} +2 -2
- package/dist/{DropdownWidget-BquZdGIL.js → DropdownWidget-15oYGYnv.js} +1 -1
- package/dist/{EmailWidget-KnkQjB4I.js → EmailWidget-mGeLzigY.js} +1 -1
- package/dist/FormCaptcha-CbLdFHHY.js +187 -0
- package/dist/{GeocoderWidget-DNkRmCVB.js → GeocoderWidget-BXv8P8Y1.js} +1 -1
- package/dist/{MultiGeocoderWidget-D2Vh9SuR.js → MultiGeocoderWidget-eCOGwc1m.js} +2 -2
- package/dist/{MultiTextWidget-Ktmx0-ou.js → MultiTextWidget-DpT1gLmr.js} +1 -1
- package/dist/{PhoneWidget-2JMw1hQ-.js → PhoneWidget-DisB02Ll.js} +1 -1
- package/dist/{RadioWidget-CsMqjCtP.js → RadioWidget-DjWXEZQx.js} +1 -1
- package/dist/{RichTextWidget-CesaOZze.js → RichTextWidget-BnqTjA-v.js} +1 -1
- package/dist/{StepsFormVariant-FXwgPUG0.js → StepsFormVariant-BYzPBT2c.js} +2 -2
- package/dist/{SwitchWidget-W7FLoMLu.js → SwitchWidget-DQ2OHpuP.js} +1 -1
- package/dist/{TextWidget-B6Y4Jjld.js → TextWidget-qHY9_hkz.js} +1 -1
- package/dist/{TextareaWidget-TszSrgEj.js → TextareaWidget-BP5mJR7j.js} +1 -1
- package/dist/{ToggleCheckboxWidget-sJoiRMME.js → ToggleCheckboxWidget-CzXZ9l_k.js} +1 -1
- package/dist/{URLWidget-BjFx8Uf7.js → URLWidget-BcZQVzW7.js} +2 -2
- package/dist/{UploadWidget-Dzop6rEv.js → UploadWidget-BNdydN68.js} +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/FormCaptcha-DNPGf2xY.js +0 -197
|
@@ -3,7 +3,7 @@ import { j as a } from "./jsx-runtime-B6kdoens.js";
|
|
|
3
3
|
import { useState as w, useEffect as B } from "react";
|
|
4
4
|
import { useController as E } from "react-hook-form";
|
|
5
5
|
import { c as C } from "./cn-C9QoOYNG.js";
|
|
6
|
-
import { z as O, A as I, B as x } from "./CollectionFormBuilder-
|
|
6
|
+
import { z as O, A as I, B as x } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
7
7
|
import { C as g } from "./Checbox-sq-atGlJ.js";
|
|
8
8
|
import { I as S } from "./Input-2CvZ90f8.js";
|
|
9
9
|
const L = ({ field: i }) => {
|
|
@@ -919,26 +919,26 @@ const dt = E.lazy(
|
|
|
919
919
|
}
|
|
920
920
|
);
|
|
921
921
|
}, pt = v(
|
|
922
|
-
() => import("./MultiTextWidget-
|
|
923
|
-
), ie = v(() => import("./TextWidget-
|
|
924
|
-
() => import("./CurrencyWidget-
|
|
922
|
+
() => import("./MultiTextWidget-DpT1gLmr.js")
|
|
923
|
+
), ie = v(() => import("./TextWidget-qHY9_hkz.js")), xt = v(
|
|
924
|
+
() => import("./CurrencyWidget-BfnmQP9S.js")
|
|
925
925
|
), ht = v(
|
|
926
|
-
() => import("./CheckboxWidget-
|
|
926
|
+
() => import("./CheckboxWidget-Dp9IAz5Q.js")
|
|
927
927
|
), ce = v(
|
|
928
|
-
() => import("./DateTimeWidget-
|
|
928
|
+
() => import("./DateTimeWidget-CqjC2iYx.js")
|
|
929
929
|
), de = v(
|
|
930
|
-
() => import("./DropdownWidget-
|
|
931
|
-
), yt = v(() => import("./EmailWidget-
|
|
932
|
-
() => import("./GeocoderWidget-
|
|
930
|
+
() => import("./DropdownWidget-15oYGYnv.js")
|
|
931
|
+
), yt = v(() => import("./EmailWidget-mGeLzigY.js")), ft = v(
|
|
932
|
+
() => import("./GeocoderWidget-BXv8P8Y1.js")
|
|
933
933
|
), jt = v(
|
|
934
|
-
() => import("./MultiGeocoderWidget-
|
|
935
|
-
), bt = v(() => import("./PhoneWidget-
|
|
936
|
-
() => import("./RichTextWidget-
|
|
937
|
-
), wt = v(() => import("./SwitchWidget-
|
|
938
|
-
() => import("./TextareaWidget-
|
|
934
|
+
() => import("./MultiGeocoderWidget-eCOGwc1m.js")
|
|
935
|
+
), bt = v(() => import("./PhoneWidget-DisB02Ll.js")), vt = v(() => import("./RadioWidget-DjWXEZQx.js")), Ct = v(
|
|
936
|
+
() => import("./RichTextWidget-BnqTjA-v.js")
|
|
937
|
+
), wt = v(() => import("./SwitchWidget-DQ2OHpuP.js")), kt = v(
|
|
938
|
+
() => import("./TextareaWidget-BP5mJR7j.js")
|
|
939
939
|
), Wt = v(
|
|
940
|
-
() => import("./ToggleCheckboxWidget-
|
|
941
|
-
), _t = v(() => import("./URLWidget-
|
|
940
|
+
() => import("./ToggleCheckboxWidget-CzXZ9l_k.js")
|
|
941
|
+
), _t = v(() => import("./URLWidget-BcZQVzW7.js")), K = v(() => import("./UploadWidget-BNdydN68.js")), Nt = ({
|
|
942
942
|
field: e,
|
|
943
943
|
isInternal: n
|
|
944
944
|
}) => {
|
|
@@ -1107,9 +1107,9 @@ const dt = E.lazy(
|
|
|
1107
1107
|
e
|
|
1108
1108
|
] });
|
|
1109
1109
|
}, ns = () => E.useContext(Ce), Tt = E.lazy(
|
|
1110
|
-
() => import("./DefaultFormVariant-
|
|
1110
|
+
() => import("./DefaultFormVariant-CG7WUPV3.js")
|
|
1111
1111
|
), Mt = E.lazy(
|
|
1112
|
-
() => import("./StepsFormVariant-
|
|
1112
|
+
() => import("./StepsFormVariant-BYzPBT2c.js")
|
|
1113
1113
|
), At = ({
|
|
1114
1114
|
formVariant: e,
|
|
1115
1115
|
...n
|
|
@@ -2,7 +2,7 @@ import { j as t } from "./jsx-runtime-B6kdoens.js";
|
|
|
2
2
|
import { useController as j } from "react-hook-form";
|
|
3
3
|
import { NumericFormat as F } from "react-number-format";
|
|
4
4
|
import { c as w } from "./cn-C9QoOYNG.js";
|
|
5
|
-
import { z as C, A as B, B as N } from "./CollectionFormBuilder-
|
|
5
|
+
import { z as C, A as B, B as N } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
6
6
|
const V = ({
|
|
7
7
|
field: r,
|
|
8
8
|
...m
|
|
@@ -4,7 +4,7 @@ import { Calendar as w, X as N } from "lucide-react";
|
|
|
4
4
|
import * as l from "react-datepicker";
|
|
5
5
|
import { useController as v } from "react-hook-form";
|
|
6
6
|
import { c as p } from "./cn-C9QoOYNG.js";
|
|
7
|
-
import { z as M, A as D, B as C } from "./CollectionFormBuilder-
|
|
7
|
+
import { z as M, A as D, B as C } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
8
8
|
import { I as F } from "./Input-2CvZ90f8.js";
|
|
9
9
|
const T = l.default.default || l.default || l, I = (e) => {
|
|
10
10
|
if (e) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-B6kdoens.js";
|
|
2
2
|
import { FormProvider as y } from "react-hook-form";
|
|
3
3
|
import { c as t } from "./cn-C9QoOYNG.js";
|
|
4
|
-
import { D as F, F as g } from "./CollectionFormBuilder-
|
|
5
|
-
import { u as w, S as N, F as b } from "./FormCaptcha-
|
|
4
|
+
import { D as F, F as g } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
5
|
+
import { u as w, S as N, F as b } from "./FormCaptcha-CbLdFHHY.js";
|
|
6
6
|
import { B as D } from "./Spinner-Bzu2xCFZ.js";
|
|
7
7
|
const _ = () => {
|
|
8
8
|
var n;
|
|
@@ -4,7 +4,7 @@ import { useState as x, useEffect as w } from "react";
|
|
|
4
4
|
import { useController as B } from "react-hook-form";
|
|
5
5
|
import D from "react-select";
|
|
6
6
|
import { c as y } from "./cn-C9QoOYNG.js";
|
|
7
|
-
import { z as N, A as k, B as q } from "./CollectionFormBuilder-
|
|
7
|
+
import { z as N, A as k, B as q } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
8
8
|
import { I as L } from "./Input-2CvZ90f8.js";
|
|
9
9
|
const G = ({
|
|
10
10
|
field: s,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { j as r } from "./jsx-runtime-B6kdoens.js";
|
|
2
2
|
import { useController as y } from "react-hook-form";
|
|
3
3
|
import { G as C } from "./Spinner-Bzu2xCFZ.js";
|
|
4
|
-
import { z as F, A as I, B as V } from "./CollectionFormBuilder-
|
|
4
|
+
import { z as F, A as I, B as V } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
5
5
|
import { I as b } from "./Input-2CvZ90f8.js";
|
|
6
6
|
function w(e) {
|
|
7
7
|
return C({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M1.75 3h20.5c.966 0 1.75.784 1.75 1.75v14a1.75 1.75 0 0 1-1.75 1.75H1.75A1.75 1.75 0 0 1 0 18.75v-14C0 3.784.784 3 1.75 3ZM1.5 7.412V18.75c0 .138.112.25.25.25h20.5a.25.25 0 0 0 .25-.25V7.412l-9.52 6.433c-.592.4-1.368.4-1.96 0Zm0-2.662v.852l10.36 7a.25.25 0 0 0 .28 0l10.36-7V4.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Z" }, child: [] }] })(e);
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as k, useState as b, 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-DpTePTDd.js";
|
|
7
|
+
import { s as m } from "./Sonner-t6JVKA0a.js";
|
|
8
|
+
import { e as D } 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 s = localStorage.getItem(`${t}-${R.FORM_VALUES}`);
|
|
17
|
+
return s ? JSON.parse(s) : {};
|
|
18
|
+
}, et = (t, s) => {
|
|
19
|
+
localStorage.setItem(
|
|
20
|
+
`${t}-${R.FORM_VALUES}`,
|
|
21
|
+
JSON.stringify(s)
|
|
22
|
+
);
|
|
23
|
+
}, M = (t) => {
|
|
24
|
+
localStorage.removeItem(`${t}-${R.FORM_VALUES}`);
|
|
25
|
+
}, dt = ({ currentValues: t, isError: s, getContentId: p }) => {
|
|
26
|
+
var O;
|
|
27
|
+
const { schema: n, isLoggedIn: a } = C(), e = W(), l = Y(), { client: S } = x(), I = H((v) => {
|
|
28
|
+
n != null && n.key && !s && n != null && n.allow_draft && (a ? fetch(`${S.apiUrl}/v1/bevy/content/${n == null ? void 0 : n.key}/save-entry`, {
|
|
29
|
+
method: "POST",
|
|
30
|
+
body: JSON.stringify({ ...v }),
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
}
|
|
34
|
+
}).then((o) => o.json()).then((o) => {
|
|
35
|
+
var _, V, c, E;
|
|
36
|
+
(V = (_ = o == null ? void 0 : o.content) == null ? void 0 : _.data) != null && V._id && p((E = (c = o == null ? void 0 : o.content) == null ? void 0 : c.data) == null ? void 0 : E._id);
|
|
37
|
+
}).catch(() => {
|
|
38
|
+
console.log("saving entry failed");
|
|
39
|
+
}) : et(n == null ? void 0 : n.key, v));
|
|
40
|
+
}, 2500);
|
|
41
|
+
return k(() => {
|
|
42
|
+
var v, o;
|
|
43
|
+
s || (v = e == null ? void 0 : e.formState) != null && v.isDirty && ((o = Object == null ? void 0 : Object.keys(l || {})) == null ? void 0 : o.length) > 0 && (I.cancel(), I({
|
|
44
|
+
...t,
|
|
45
|
+
...l
|
|
46
|
+
}));
|
|
47
|
+
}, [(O = e == null ? void 0 : e.formState) == null ? void 0 : O.isDirty, s, a, l]), null;
|
|
48
|
+
}, yt = ({
|
|
49
|
+
schema: t,
|
|
50
|
+
saveToRemote: s,
|
|
51
|
+
onSubmit: p,
|
|
52
|
+
onSubmitSuccess: n,
|
|
53
|
+
onSubmitError: a
|
|
54
|
+
}) => {
|
|
55
|
+
const { collection: e } = x(), {
|
|
56
|
+
toastConfig: l,
|
|
57
|
+
onSuccess: S,
|
|
58
|
+
onError: I,
|
|
59
|
+
isLoggedIn: O,
|
|
60
|
+
isDisabled: v,
|
|
61
|
+
externalInitialValues: o = {}
|
|
62
|
+
} = C(), [_, V] = b({}), [c, E] = b(null), [N, $] = b(!1), [P, A] = b(!1), r = J({}), F = B({
|
|
63
|
+
mode: "all",
|
|
64
|
+
disabled: v,
|
|
65
|
+
defaultValues: _,
|
|
66
|
+
values: _,
|
|
67
|
+
resetOptions: {
|
|
68
|
+
keepErrors: !0
|
|
69
|
+
}
|
|
70
|
+
}), q = F.handleSubmit(async (d) => {
|
|
71
|
+
var L, g, y, i, j, T;
|
|
72
|
+
if (r.current = {
|
|
73
|
+
...r.current || {},
|
|
74
|
+
...d
|
|
75
|
+
}, s && e) {
|
|
76
|
+
if (t)
|
|
77
|
+
try {
|
|
78
|
+
const f = z(r == null ? void 0 : r.current, t);
|
|
79
|
+
let u = null;
|
|
80
|
+
if (c ? u = await (e == null ? void 0 : e.submitDraftEntry(t == null ? void 0 : t.key, f).catch((w) => (D(w), null))) : u = await (e == null ? void 0 : e.saveCollectionData({
|
|
81
|
+
collection_id: t == null ? void 0 : t.id,
|
|
82
|
+
data: f
|
|
83
|
+
}).catch((w) => (D(w), null))), (L = u == null ? void 0 : u.content) != null && L.data)
|
|
84
|
+
return l != null && l.showSuccessToast && m(
|
|
85
|
+
l.successToastText || "Form submitted successfully."
|
|
86
|
+
), r.current = h(o) ? {} : { ...o }, M(t == null ? void 0 : t.key), E(null), S && S({
|
|
87
|
+
schemaId: t == null ? void 0 : t.id,
|
|
88
|
+
response: (g = u == null ? void 0 : u.content) == null ? void 0 : g.data
|
|
89
|
+
}), n && n(), F.reset(), F.clearErrors(), !0;
|
|
90
|
+
throw new Error("Failed to save form details, API response invalid");
|
|
91
|
+
} catch (f) {
|
|
92
|
+
const u = (j = (i = (y = f == null ? void 0 : f.response) == null ? void 0 : y.data) == null ? void 0 : i.content) == null ? void 0 : j.errors;
|
|
93
|
+
return Q(u, F.setError), a && a(u), I && I(((T = f == null ? void 0 : f.response) == null ? void 0 : T.data) || f), !1;
|
|
94
|
+
}
|
|
95
|
+
return !1;
|
|
96
|
+
}
|
|
97
|
+
d && p && p(d);
|
|
98
|
+
}), K = (d) => {
|
|
99
|
+
d && d !== c && E(d);
|
|
100
|
+
};
|
|
101
|
+
return k(() => {
|
|
102
|
+
if (t && e) {
|
|
103
|
+
const d = X(t);
|
|
104
|
+
if (r.current = {
|
|
105
|
+
...d,
|
|
106
|
+
...o || {},
|
|
107
|
+
...r.current || {}
|
|
108
|
+
}, !c && t != null && t.allow_draft) {
|
|
109
|
+
if (O) {
|
|
110
|
+
$(!0), e == null || e.getDraftEntry(t == null ? void 0 : t.key).then((g) => {
|
|
111
|
+
if (g === null) {
|
|
112
|
+
A(!0);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
A(!1);
|
|
116
|
+
const y = Array.isArray(g) ? g == null ? void 0 : g.filter((i) => (i == null ? void 0 : i._status) === "draft") : [];
|
|
117
|
+
if ((y == null ? void 0 : y.length) > 0) {
|
|
118
|
+
const i = (y == null ? void 0 : y[0]) || {};
|
|
119
|
+
i != null && i._id && (r.current = {
|
|
120
|
+
...r.current || {},
|
|
121
|
+
...i
|
|
122
|
+
}, E(i == null ? void 0 : i._id));
|
|
123
|
+
}
|
|
124
|
+
}).catch(() => null).finally(() => {
|
|
125
|
+
V({
|
|
126
|
+
...r == null ? void 0 : r.current
|
|
127
|
+
}), $(!1);
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const L = tt(t == null ? void 0 : t.key);
|
|
132
|
+
L && (r.current = {
|
|
133
|
+
...r.current || {},
|
|
134
|
+
...L
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
V({
|
|
138
|
+
...(r == null ? void 0 : r.current) || {}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, [t]), k(() => {
|
|
142
|
+
t && c && M(t == null ? void 0 : t.key);
|
|
143
|
+
}, [c]), {
|
|
144
|
+
methods: F,
|
|
145
|
+
isLoading: N,
|
|
146
|
+
isError: P,
|
|
147
|
+
contentId: c,
|
|
148
|
+
allFormValues: r.current,
|
|
149
|
+
handleContentId: K,
|
|
150
|
+
handleSubmit: q
|
|
151
|
+
};
|
|
152
|
+
}, gt = () => {
|
|
153
|
+
const { isInternal: t } = C(), { client: s } = x(), p = J(null), {
|
|
154
|
+
field: { onChange: n },
|
|
155
|
+
fieldState: { error: a }
|
|
156
|
+
} = G({
|
|
157
|
+
name: "__captcha",
|
|
158
|
+
rules: {
|
|
159
|
+
required: t ? !1 : "Verification is required"
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return k(() => {
|
|
163
|
+
const e = (S) => {
|
|
164
|
+
"detail" in S && n(S.detail.state || null);
|
|
165
|
+
}, { current: l } = p;
|
|
166
|
+
if (l)
|
|
167
|
+
return l.addEventListener("statechange", e), () => l.removeEventListener("statechange", e);
|
|
168
|
+
}, []), /* @__PURE__ */ U.jsx(Z, { error: a == null ? void 0 : a.message, children: /* @__PURE__ */ U.jsx(
|
|
169
|
+
"altcha-widget",
|
|
170
|
+
{
|
|
171
|
+
ref: p,
|
|
172
|
+
style: {
|
|
173
|
+
"--altcha-max-width": "100%"
|
|
174
|
+
},
|
|
175
|
+
hidelogo: !0,
|
|
176
|
+
auto: "onfocus",
|
|
177
|
+
hidefooter: !0,
|
|
178
|
+
challengeurl: `${s.apiUrl}/v1/identity/captcha/create-challenge`,
|
|
179
|
+
verifyurl: `${s.apiUrl}/v1/identity/captcha/verify-challenge`
|
|
180
|
+
}
|
|
181
|
+
) });
|
|
182
|
+
};
|
|
183
|
+
export {
|
|
184
|
+
gt as F,
|
|
185
|
+
dt as S,
|
|
186
|
+
yt as u
|
|
187
|
+
};
|
|
@@ -3,7 +3,7 @@ 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-
|
|
6
|
+
import { z as k, A as q, B as A } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
7
7
|
import { I as E } from "./Input-2CvZ90f8.js";
|
|
8
8
|
import { u as O } from "./LevoProvider-BAZy7_tP.js";
|
|
9
9
|
const $ = ({ field: t }) => {
|
|
@@ -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-
|
|
6
|
-
import { GeocoderWidget as d } from "./GeocoderWidget-
|
|
5
|
+
import { B as c } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
6
|
+
import { GeocoderWidget as d } from "./GeocoderWidget-BXv8P8Y1.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-
|
|
3
|
+
import { z as C, A as b, B as q } from "./CollectionFormBuilder-DpTePTDd.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-
|
|
6
|
+
import { z as x, A as v, B as y } from "./CollectionFormBuilder-DpTePTDd.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-
|
|
8
|
+
import { z as E, A as G, B as f } from "./CollectionFormBuilder-DpTePTDd.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-
|
|
22
|
+
import { z as ln, A as en, B as sn } from "./CollectionFormBuilder-DpTePTDd.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
|
}
|
|
@@ -3,8 +3,8 @@ import { j as t } from "./jsx-runtime-B6kdoens.js";
|
|
|
3
3
|
import { useState as I, useMemo as y } from "react";
|
|
4
4
|
import { FormProvider as T } from "react-hook-form";
|
|
5
5
|
import { c as F } from "./cn-C9QoOYNG.js";
|
|
6
|
-
import { D as N, F as _ } from "./CollectionFormBuilder-
|
|
7
|
-
import { u as C, S as H, F as M } from "./FormCaptcha-
|
|
6
|
+
import { D as N, F as _ } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
7
|
+
import { u as C, S as H, F as M } from "./FormCaptcha-CbLdFHHY.js";
|
|
8
8
|
import { B as g } from "./Spinner-Bzu2xCFZ.js";
|
|
9
9
|
const Y = () => {
|
|
10
10
|
const [n, a] = I(0), { containerStyles: m } = N(), l = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { j as r } from "./jsx-runtime-B6kdoens.js";
|
|
3
3
|
import { useController as k } from "react-hook-form";
|
|
4
|
-
import { z as w, A as j, B as v } from "./CollectionFormBuilder-
|
|
4
|
+
import { z as w, A as j, B as v } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
5
5
|
import * as c from "@radix-ui/react-switch";
|
|
6
6
|
import * as y from "react";
|
|
7
7
|
import { c as d } from "./cn-C9QoOYNG.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { j as t } from "./jsx-runtime-B6kdoens.js";
|
|
2
2
|
import { useFormContext as g, get as h } from "react-hook-form";
|
|
3
3
|
import { c as j } from "./cn-C9QoOYNG.js";
|
|
4
|
-
import { A as F, B as b, z as y } from "./CollectionFormBuilder-
|
|
4
|
+
import { A as F, B as b, z as y } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
5
5
|
import { I as f } from "./Input-2CvZ90f8.js";
|
|
6
6
|
const k = ({
|
|
7
7
|
field: r,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { j as s } from "./jsx-runtime-B6kdoens.js";
|
|
2
2
|
import { useFormContext as u, get as x } from "react-hook-form";
|
|
3
3
|
import { c as b } from "./cn-C9QoOYNG.js";
|
|
4
|
-
import { A as g, B as f, z as h } from "./CollectionFormBuilder-
|
|
4
|
+
import { A as g, B as f, z as h } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
5
5
|
const w = ({ field: e }) => {
|
|
6
6
|
var a;
|
|
7
7
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { j as r } from "./jsx-runtime-B6kdoens.js";
|
|
3
3
|
import { useController as p } from "react-hook-form";
|
|
4
|
-
import { z as u, A as g, B as C } from "./CollectionFormBuilder-
|
|
4
|
+
import { z as u, A as g, B as C } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
5
5
|
import { C as f } from "./Checbox-sq-atGlJ.js";
|
|
6
6
|
const y = ({
|
|
7
7
|
field: e
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
-
import { H as s } from "./CollectionFormBuilder-
|
|
3
|
-
import r from "./TextWidget-
|
|
2
|
+
import { H as s } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
3
|
+
import r from "./TextWidget-qHY9_hkz.js";
|
|
4
4
|
const a = (t) => /* @__PURE__ */ e.jsx(
|
|
5
5
|
r,
|
|
6
6
|
{
|
|
@@ -5,7 +5,7 @@ import { X, Upload as O, ExternalLink as aa } from "lucide-react";
|
|
|
5
5
|
import { useMemo as J, useState as U, useRef as ra, useEffect as M } from "react";
|
|
6
6
|
import { useController as ta } from "react-hook-form";
|
|
7
7
|
import { G as H, B as P, S as G, j as sa, T as ea, k as oa, l as $, m as V } from "./Spinner-Bzu2xCFZ.js";
|
|
8
|
-
import { t as na, g as ca, z as la, w as C, A as da, B as ia } from "./CollectionFormBuilder-
|
|
8
|
+
import { t as na, g as ca, z as la, w as C, A as da, B as ia } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
9
9
|
import { u as k } from "./LevoProvider-BAZy7_tP.js";
|
|
10
10
|
import { e as Y } from "./errorHandler-_34Yv8wA.js";
|
|
11
11
|
import { I as K } from "./Input-2CvZ90f8.js";
|
package/dist/collection/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as s, F as r, e as t, b as i, c as l, f as o, g as d, d as m, i as u, a as n, p as f, h as F, s as g, u as p, v as V } from "../CollectionFormBuilder-
|
|
1
|
+
import { C as s, F as r, e as t, b as i, c as l, f as o, g as d, d as m, i as u, a as n, p as f, h as F, s as g, u as p, v as V } from "../CollectionFormBuilder-DpTePTDd.js";
|
|
2
2
|
import { default as h } from "validatorjs";
|
|
3
3
|
export {
|
|
4
4
|
s as CollectionFormBuilder,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveDraftValues.d.ts","sourceRoot":"","sources":["../../../src/collection/lib/SaveDraftValues.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SaveDraftValues.d.ts","sourceRoot":"","sources":["../../../src/collection/lib/SaveDraftValues.tsx"],"names":[],"mappings":"AAmBA,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAmDA,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as s, u as o } from "./LevoProvider-BAZy7_tP.js";
|
|
2
2
|
import { L as t, a as r, b as l } from "./page-BKyDlf0z.js";
|
|
3
|
-
import { C as m, F as p, x as d, y as g, m as T, r as f, j as u, n as c, e as x, b, c as D, f as y, g as F, d as v, k as h, o as L, i as M, a as E, w as P, t as B, p as O, h as V, s as j, u as C, v as I, l as S, q as K } from "./CollectionFormBuilder-
|
|
3
|
+
import { C as m, F as p, x as d, y as g, m as T, r as f, j as u, n as c, e as x, b, c as D, f as y, g as F, d as v, k as h, o as L, i as M, a as E, w as P, t as B, p as O, h as V, s as j, u as C, v as I, l as S, q as K } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
4
4
|
import { LevoOAuth as U } from "./membership/index.js";
|
|
5
5
|
import { B as H, D as N, e as q, i as w, g as z, f as A, c as R, a as G, h as J, d as Q, j as X, S as Y, T as Z, m as _, k as $, l as aa, b as ea } from "./Spinner-Bzu2xCFZ.js";
|
|
6
6
|
import { T as oa, e as ia, s as ta } from "./Sonner-t6JVKA0a.js";
|
package/package.json
CHANGED
|
@@ -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
|
-
};
|