@levo-so/react 0.1.15 → 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 (81) hide show
  1. package/dist/{CheckboxWidget-BGS61gcL.js → CheckboxWidget-CNoS-2W3.js} +1 -1
  2. package/dist/{CollectionFormBuilder-BIvx_z08.js → CollectionFormBuilder-MAo2Ob3a.js} +67 -65
  3. package/dist/{CurrencyWidget-sD8ijLvw.js → CurrencyWidget-Cu1Cthnw.js} +1 -1
  4. package/dist/{DateTimeWidget-KrcsxgEF.js → DateTimeWidget-N-wuCRSJ.js} +1 -1
  5. package/dist/DefaultFormVariant-IqWi1BiT.js +81 -0
  6. package/dist/{DropdownWidget-rm5oUqOE.js → DropdownWidget-BFttB4b-.js} +4 -2
  7. package/dist/{EmailWidget-CvZKOywL.js → EmailWidget-D_SqXx3M.js} +1 -1
  8. package/dist/FormCaptcha-CJ9KgDu0.js +197 -0
  9. package/dist/{GeocoderWidget-CSsp_-hW.js → GeocoderWidget-Bxt3TeAf.js} +2 -2
  10. package/dist/LevoProvider-BAZy7_tP.js +223 -0
  11. package/dist/{MultiGeocoderWidget-Blqz-lHX.js → MultiGeocoderWidget-DFjuXZBN.js} +2 -2
  12. package/dist/{MultiTextWidget-CxVpyf06.js → MultiTextWidget-CZzT51cH.js} +1 -1
  13. package/dist/{PhoneWidget-DezcchSP.js → PhoneWidget--K5aS16s.js} +1 -1
  14. package/dist/{RadioWidget-SfD1fFDG.js → RadioWidget-BbMPtR3P.js} +1 -1
  15. package/dist/{RichTextWidget-Cg3RizdO.js → RichTextWidget-Cce3Bw8d.js} +1 -1
  16. package/dist/{StepsFormVariant-D35dFYK6.js → StepsFormVariant-5wZbYAA9.js} +59 -56
  17. package/dist/{SwitchWidget-Id6BNlPe.js → SwitchWidget-B0wkSWxa.js} +1 -1
  18. package/dist/{TextWidget-CtFaQde1.js → TextWidget-ldbMuLB0.js} +1 -1
  19. package/dist/{TextareaWidget-BKzAeMod.js → TextareaWidget-S8bKUTv0.js} +1 -1
  20. package/dist/{ToggleCheckboxWidget-nSlie9sE.js → ToggleCheckboxWidget-CPduXE6Y.js} +1 -1
  21. package/dist/{URLWidget-DtJai3xY.js → URLWidget-KbhE2ZUA.js} +2 -2
  22. package/dist/{UploadWidget-Dxx2_FYo.js → UploadWidget-DFvfDUT6.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 +6 -6
  79. package/dist/DefaultFormVariant-j1HgVDiI.js +0 -127
  80. package/dist/LevoProvider-Do3jjJ4j.js +0 -211
  81. package/dist/useLevoForm-3jSJ9I6v.js +0 -170
@@ -1,127 +0,0 @@
1
- import { j as l } from "./jsx-runtime-B6kdoens.js";
2
- import { forwardRef as L, useRef as v, useState as j, useImperativeHandle as N, useEffect as R } from "react";
3
- import { FormProvider as b } from "react-hook-form";
4
- import { c as u } from "./cn-C9QoOYNG.js";
5
- import { D as E, F as D } from "./CollectionFormBuilder-BIvx_z08.js";
6
- import { u as I, S as A } from "./useLevoForm-3jSJ9I6v.js";
7
- import "altcha";
8
- import { u as H } from "./LevoProvider-Do3jjJ4j.js";
9
- import { B as T } from "./Spinner-Bzu2xCFZ.js";
10
- const U = L(
11
- ({ onStateChange: a, challengeurl: f, verifyurl: i }, n) => {
12
- const e = v(null), [c, d] = j(null);
13
- return N(
14
- n,
15
- () => ({
16
- get value() {
17
- return c;
18
- }
19
- }),
20
- [c]
21
- ), R(() => {
22
- const m = (o) => {
23
- "detail" in o && (d(o.detail.state || null), a == null || a(o));
24
- }, { current: r } = e;
25
- if (r)
26
- return r.addEventListener("statechange", m), () => r.removeEventListener("statechange", m);
27
- }, [a]), /* @__PURE__ */ l.jsx(
28
- "altcha-widget",
29
- {
30
- ref: e,
31
- style: {
32
- "--altcha-max-width": "100%"
33
- },
34
- hidelogo: !0,
35
- auto: "onfocus",
36
- hidefooter: !0,
37
- challengeurl: f,
38
- verifyurl: i
39
- }
40
- );
41
- }
42
- ), O = () => {
43
- var p;
44
- const {
45
- schema: a,
46
- containerStyles: f,
47
- uiConfig: i,
48
- isInternal: n,
49
- submitButtonConfig: e,
50
- isDisabled: c
51
- } = E(), { client: d } = H(), m = v(null), [r, o] = j(null), {
52
- methods: h,
53
- allFormValues: y,
54
- isError: g,
55
- isLoading: w,
56
- handleContentId: S,
57
- handleSubmit: V
58
- } = I({
59
- schema: a,
60
- saveToRemote: !0,
61
- captchaValue: r
62
- }), {
63
- formState: { isSubmitting: F }
64
- } = h;
65
- return /* @__PURE__ */ l.jsxs(b, { ...h, children: [
66
- /* @__PURE__ */ l.jsx(
67
- A,
68
- {
69
- getContentId: (t) => S(t),
70
- isError: g,
71
- currentValues: y
72
- }
73
- ),
74
- /* @__PURE__ */ l.jsx("div", { className: u("w-full", f), children: /* @__PURE__ */ l.jsxs(
75
- "form",
76
- {
77
- className: u(
78
- "w-full bg-white rounded-md flex flex-col gap-6 px-4 md:px-8 py-6",
79
- w && "opacity-50 pointer-events-none"
80
- ),
81
- id: "collection-form",
82
- onSubmit: V,
83
- children: [
84
- (p = a == null ? void 0 : a.sections) == null ? void 0 : p.map((t) => {
85
- var x;
86
- return /* @__PURE__ */ l.jsxs("div", { className: "w-full", children: [
87
- !(i != null && i.hideSectionHeadings) && /* @__PURE__ */ l.jsx("p", { className: u("mb-4 text-lg font-semibold"), children: t == null ? void 0 : t.label }),
88
- /* @__PURE__ */ l.jsx("div", { className: u("flex flex-col gap-4"), children: (x = t == null ? void 0 : t.fields) == null ? void 0 : x.map((s) => s && !s.hidden ? /* @__PURE__ */ l.jsx(
89
- D,
90
- {
91
- field: s,
92
- isInternal: n
93
- },
94
- s == null ? void 0 : s.key
95
- ) : null) })
96
- ] }, t.id);
97
- }),
98
- !n && /* @__PURE__ */ l.jsx(
99
- U,
100
- {
101
- onStateChange: (t) => {
102
- "detail" in t && o(t.detail.state || null);
103
- },
104
- ref: m,
105
- challengeurl: `${d.apiUrl}/v1/identity/captcha/create-challenge`,
106
- verifyurl: `${d.apiUrl}/v1/identity/captcha/verify-challenge`
107
- }
108
- ),
109
- (e == null ? void 0 : e.show) && /* @__PURE__ */ l.jsx("div", { className: "w-full flex items-center justify-end mt-6", children: /* @__PURE__ */ l.jsx(
110
- T,
111
- {
112
- className: e == null ? void 0 : e.styles,
113
- loadingText: "Saving",
114
- isLoading: F,
115
- disabled: c || !n && r !== "verified",
116
- type: "submit",
117
- children: r === "verifying" ? "Verifying..." : (e == null ? void 0 : e.text) || "Save"
118
- }
119
- ) })
120
- ]
121
- }
122
- ) })
123
- ] });
124
- };
125
- export {
126
- O as default
127
- };
@@ -1,211 +0,0 @@
1
- "use client";
2
- var j = Object.defineProperty;
3
- var D = (r, l, o) => l in r ? j(r, l, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[l] = o;
4
- var p = (r, l, o) => D(r, typeof l != "symbol" ? l + "" : l, o);
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(r) {
10
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
11
- }
12
- var T = class {
13
- constructor(r) {
14
- p(this, "client");
15
- this.client = r;
16
- }
17
- }, F = { exports: {} };
18
- (function(r) {
19
- (function(l, o) {
20
- r.exports ? r.exports = o() : l.log = o();
21
- })(q, function() {
22
- var l = function() {
23
- }, o = "undefined", L = typeof window !== o && typeof window.navigator !== o && /Trident\/|MSIE /.test(window.navigator.userAgent), g = [
24
- "trace",
25
- "debug",
26
- "info",
27
- "warn",
28
- "error"
29
- ], c = {}, a = null;
30
- function b(t, i) {
31
- var e = t[i];
32
- if (typeof e.bind == "function")
33
- return e.bind(t);
34
- try {
35
- return Function.prototype.bind.call(e, t);
36
- } catch {
37
- return function() {
38
- return Function.prototype.apply.apply(e, [t, 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(t) {
46
- return t === "debug" && (t = "log"), typeof console === o ? !1 : t === "trace" && L ? S : console[t] !== void 0 ? b(console, t) : console.log !== void 0 ? b(console, "log") : l;
47
- }
48
- function d() {
49
- for (var t = this.getLevel(), i = 0; i < g.length; i++) {
50
- var e = g[i];
51
- this[e] = i < t ? l : this.methodFactory(e, t, this.name);
52
- }
53
- if (this.log = this.debug, typeof console === o && t < this.levels.SILENT)
54
- return "No console available for logging";
55
- }
56
- function A(t) {
57
- return function() {
58
- typeof console !== o && (d.call(this), this[t].apply(this, arguments));
59
- };
60
- }
61
- function M(t, i, e) {
62
- return U(t) || A.apply(this, arguments);
63
- }
64
- function E(t, i) {
65
- var e = this, w, m, f, u = "loglevel";
66
- typeof t == "string" ? u += ":" + t : typeof t == "symbol" && (u = void 0);
67
- function O(n) {
68
- var s = (g[n] || "silent").toUpperCase();
69
- if (!(typeof window === o || !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 n;
83
- if (!(typeof window === o || !u)) {
84
- try {
85
- n = window.localStorage[u];
86
- } catch {
87
- }
88
- if (typeof n === o)
89
- try {
90
- var s = window.document.cookie, h = encodeURIComponent(u), I = s.indexOf(h + "=");
91
- I !== -1 && (n = /^([^;]+)/.exec(
92
- s.slice(I + h.length + 1)
93
- )[1]);
94
- } catch {
95
- }
96
- return e.levels[n] === void 0 && (n = void 0), n;
97
- }
98
- }
99
- function P() {
100
- if (!(typeof window === o || !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(n) {
112
- var s = n;
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: " + n);
116
- }
117
- e.name = t, 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 f ?? m ?? w;
126
- }, e.setLevel = function(n, s) {
127
- return f = v(n), s !== !1 && O(f), d.call(e);
128
- }, e.setDefaultLevel = function(n) {
129
- m = v(n), C() || e.setLevel(n, !1);
130
- }, e.resetLevel = function() {
131
- f = null, P(), d.call(e);
132
- }, e.enableAll = function(n) {
133
- e.setLevel(e.levels.TRACE, n);
134
- }, e.disableAll = function(n) {
135
- e.setLevel(e.levels.SILENT, n);
136
- }, e.rebuild = function() {
137
- if (a !== e && (w = v(a.getLevel())), d.call(e), a === e)
138
- for (var n in c)
139
- c[n].rebuild();
140
- }, w = v(
141
- a ? a.getLevel() : "WARN"
142
- );
143
- var x = C();
144
- x != null && (f = 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 = c[i];
150
- return e || (e = c[i] = new E(
151
- i,
152
- a.methodFactory
153
- )), e;
154
- };
155
- var N = typeof window !== o ? window.log : void 0;
156
- return a.noConflict = function() {
157
- return typeof window !== o && window.log === a && (window.log = N), a;
158
- }, a.getLoggers = function() {
159
- return c;
160
- }, a.default = a, a;
161
- });
162
- })(F);
163
- var J = F.exports;
164
- const y = /* @__PURE__ */ z(J);
165
- var K = class extends T {
166
- constructor(l) {
167
- super(l);
168
- p(this, "logger", y);
169
- y.setLevel(
170
- this.client.NODE_ENV === "production" ? y.levels.INFO : y.levels.DEBUG
171
- ), y.methodFactory = (o) => (L, g = {}) => {
172
- k().url(`${this.client.apiUrl}/v1/apm/logs/json`).post({
173
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
174
- level: o,
175
- message: L,
176
- ...g
177
- }).res().catch((c) => console.error(c));
178
- };
179
- }
180
- }, V = class extends T {
181
- constructor() {
182
- super(...arguments);
183
- p(this, "mediaBulkUpload", (l, o = {}) => this.client.fetch.url("/v1/assets/media/bulk").options(o).post(l).json());
184
- p(this, "getAllMedia", async (l = {}) => await this.client.fetch.url("/v1/assets/media/query").post(l).json());
185
- }
186
- };
187
- const R = G(null), X = ({
188
- children: r,
189
- client: l,
190
- ...o
191
- }) => /* @__PURE__ */ B.jsx(
192
- R.Provider,
193
- {
194
- value: {
195
- client: l,
196
- media: new V(l),
197
- logger: new K(l),
198
- ...o
199
- },
200
- children: r
201
- }
202
- ), Z = () => {
203
- const r = W(R);
204
- if (!r)
205
- throw new Error("useLevo must be used within LevoProvider");
206
- return r;
207
- };
208
- export {
209
- X as L,
210
- Z as u
211
- };
@@ -1,170 +0,0 @@
1
- "use client";
2
- import { useEffect as L, useState as F, useRef as H } from "react";
3
- import { useFormContext as W, useWatch as q, useForm as z } from "react-hook-form";
4
- import { useDebouncedCallback as Q } from "use-debounce";
5
- import { u as J } from "./LevoProvider-Do3jjJ4j.js";
6
- import { D as N, c as M, s as X, h as Z } from "./CollectionFormBuilder-BIvx_z08.js";
7
- import { s as m } from "./Sonner-t6JVKA0a.js";
8
- import { e as U } from "./errorHandler-_34Yv8wA.js";
9
- import { a as h } from "./isEmptyObject-C5s4GzLE.js";
10
- const D = {
11
- FORM_DIRTY: "form-dirty",
12
- FORM_VALUES: "form-values"
13
- }, tt = (t) => {
14
- const s = localStorage.getItem(`${t}-${D.FORM_VALUES}`);
15
- return s ? JSON.parse(s) : {};
16
- }, rt = (t, s) => {
17
- localStorage.setItem(
18
- `${t}-${D.FORM_VALUES}`,
19
- JSON.stringify(s)
20
- );
21
- }, j = (t) => {
22
- localStorage.removeItem(`${t}-${D.FORM_VALUES}`);
23
- }, nt = async ({
24
- collection_key: t,
25
- data: s
26
- }) => {
27
- const { client: g } = J(), r = await fetch(
28
- `${g.apiUrl}/v1/bevy/content/${t}/save-entry`,
29
- {
30
- method: "POST",
31
- body: JSON.stringify({ ...s }),
32
- headers: {
33
- "Content-Type": "application/json"
34
- }
35
- }
36
- );
37
- return r != null && r.ok ? await r.json() : null;
38
- }, at = ({ currentValues: t, isError: s, getContentId: g }) => {
39
- var _;
40
- const { schema: r, isLoggedIn: d } = N(), a = W(), e = q(), E = Q((y) => {
41
- r != null && r.key && !s && r != null && r.allow_draft && (d ? nt({
42
- collection_key: r == null ? void 0 : r.key,
43
- data: y
44
- }).then((i) => {
45
- var b, I, k, O;
46
- (I = (b = i == null ? void 0 : i.content) == null ? void 0 : b.data) != null && I._id && g((O = (k = i == null ? void 0 : i.content) == null ? void 0 : k.data) == null ? void 0 : O._id);
47
- }) : rt(r == null ? void 0 : r.key, y));
48
- }, 2500);
49
- return L(() => {
50
- var y, i;
51
- !s && d && (y = a == null ? void 0 : a.formState) != null && y.isDirty && ((i = Object == null ? void 0 : Object.keys(e || {})) == null ? void 0 : i.length) > 0 && E({
52
- currentValues: t,
53
- ...e
54
- });
55
- }, [(_ = a == null ? void 0 : a.formState) == null ? void 0 : _.isDirty, s, d, e]), null;
56
- }, yt = ({
57
- schema: t,
58
- saveToRemote: s,
59
- onSubmit: g,
60
- onSubmitSuccess: r,
61
- onSubmitError: d,
62
- captchaValue: a
63
- }) => {
64
- const { collection: e } = J(), {
65
- toastConfig: E,
66
- onSuccess: _,
67
- onError: y,
68
- isLoggedIn: i,
69
- isDisabled: b,
70
- externalInitialValues: I = {},
71
- isInternal: k
72
- } = N(), [O, R] = F({}), [v, w] = F(null), [P, T] = F(!1), [K, $] = F(!1), n = H({}), Y = M(t), p = z({
73
- mode: "all",
74
- disabled: b,
75
- defaultValues: Y,
76
- values: O,
77
- resetOptions: {
78
- keepErrors: !0
79
- }
80
- }), B = p.handleSubmit(async (f) => {
81
- var V, S, c, o, C, x;
82
- if (!(!k && a !== "verified")) {
83
- if (n.current = {
84
- ...n.current || {},
85
- ...f
86
- }, s && e) {
87
- if (t)
88
- try {
89
- const l = X(n == null ? void 0 : n.current, t);
90
- let u = null;
91
- if (v ? u = await (e == null ? void 0 : e.submitDraftEntry(t == null ? void 0 : t.key, l).catch((A) => (U(A), null))) : u = await (e == null ? void 0 : e.saveCollectionData({
92
- collection_id: t == null ? void 0 : t.id,
93
- data: l
94
- }).catch((A) => (U(A), null))), (V = u == null ? void 0 : u.content) != null && V.data)
95
- return E != null && E.showSuccessToast && m(
96
- E.successToastText || "Form submitted successfully."
97
- ), n.current = h(I) ? {} : { ...I }, j(t == null ? void 0 : t.key), w(null), _ && _({
98
- schemaId: t == null ? void 0 : t.id,
99
- response: (S = u == null ? void 0 : u.content) == null ? void 0 : S.data
100
- }), !0;
101
- throw new Error("Failed to save form details, API response invalid");
102
- } catch (l) {
103
- const u = (C = (o = (c = l == null ? void 0 : l.response) == null ? void 0 : c.data) == null ? void 0 : o.content) == null ? void 0 : C.errors;
104
- return Z(u, p.setError), d && d(u), y && y(((x = l == null ? void 0 : l.response) == null ? void 0 : x.data) || l), !1;
105
- }
106
- return !1;
107
- }
108
- f && g && g(f);
109
- }
110
- }), G = (f) => {
111
- f && f !== v && w(f);
112
- };
113
- return L(() => {
114
- if (t && e) {
115
- const f = M(t);
116
- if (n.current = {
117
- ...f,
118
- ...I || {},
119
- ...n.current || {}
120
- }, !v && t != null && t.allow_draft) {
121
- if (i) {
122
- T(!0), e == null || e.getDraftEntry(t == null ? void 0 : t.key).then((S) => {
123
- if (S === null) {
124
- $(!0);
125
- return;
126
- }
127
- $(!1);
128
- const c = Array.isArray(S) ? S == null ? void 0 : S.filter((o) => (o == null ? void 0 : o._status) === "draft") : [];
129
- if ((c == null ? void 0 : c.length) > 0) {
130
- const o = (c == null ? void 0 : c[0]) || {};
131
- o != null && o._id && (n.current = {
132
- ...n.current || {},
133
- ...o
134
- }, w(o == null ? void 0 : o._id));
135
- }
136
- }).catch(() => null).finally(() => {
137
- R({
138
- ...n == null ? void 0 : n.current
139
- }), T(!1);
140
- });
141
- return;
142
- }
143
- const V = tt(t == null ? void 0 : t.key);
144
- V && (n.current = {
145
- ...V,
146
- ...n.current || {}
147
- });
148
- }
149
- R({
150
- ...(n == null ? void 0 : n.current) || {}
151
- });
152
- }
153
- }, [t]), L(() => {
154
- t && v && j(t == null ? void 0 : t.key);
155
- }, [v]), L(() => {
156
- p.formState.isSubmitSuccessful && (r && r(), p.reset(), p.clearErrors());
157
- }, [p.formState.isSubmitSuccessful]), {
158
- methods: p,
159
- isLoading: P,
160
- isError: K,
161
- contentId: v,
162
- allFormValues: n.current,
163
- handleContentId: G,
164
- handleSubmit: B
165
- };
166
- };
167
- export {
168
- at as S,
169
- yt as u
170
- };