@levo-so/react 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CheckboxWidget-CNoS-2W3.js +124 -0
- package/dist/CollectionFormBuilder-MAo2Ob3a.js +1199 -0
- package/dist/{CurrencyWidget-COoMkfsA.js → CurrencyWidget-Cu1Cthnw.js} +5 -5
- package/dist/{DateTimeWidget-DcbQ3smI.js → DateTimeWidget-N-wuCRSJ.js} +3 -3
- package/dist/DefaultFormVariant-IqWi1BiT.js +81 -0
- package/dist/DropdownWidget-BFttB4b-.js +115 -0
- package/dist/{EmailWidget-CG9oNUM5.js → EmailWidget-D_SqXx3M.js} +11 -11
- package/dist/FormCaptcha-CJ9KgDu0.js +197 -0
- package/dist/GeocoderWidget-Bxt3TeAf.js +68 -0
- package/dist/LevoProvider-BAZy7_tP.js +223 -0
- package/dist/{MultiGeocoderWidget-D3Xmv8g4.js → MultiGeocoderWidget-DFjuXZBN.js} +6 -6
- package/dist/{MultiTextWidget-CyQRcWC8.js → MultiTextWidget-CZzT51cH.js} +14 -14
- package/dist/{PhoneWidget-C1Jt7kXL.js → PhoneWidget--K5aS16s.js} +5 -5
- package/dist/{RadioWidget-BrLNF-I2.js → RadioWidget-BbMPtR3P.js} +9 -9
- package/dist/{RichTextWidget-BogYcPtS.js → RichTextWidget-Cce3Bw8d.js} +21 -21
- package/dist/Spinner-Bzu2xCFZ.js +405 -0
- package/dist/{StepsFormVariant-Bx-jdciC.js → StepsFormVariant-5wZbYAA9.js} +58 -55
- package/dist/{SwitchWidget-BT0-waP9.js → SwitchWidget-B0wkSWxa.js} +5 -5
- package/dist/{TextWidget-Bvsz-hey.js → TextWidget-ldbMuLB0.js} +7 -7
- package/dist/{TextareaWidget-8SLym--T.js → TextareaWidget-S8bKUTv0.js} +3 -3
- package/dist/{ToggleCheckboxWidget-VrCQBF5C.js → ToggleCheckboxWidget-CPduXE6Y.js} +7 -7
- package/dist/Tooltip-DEBnSqlo.js +36 -0
- package/dist/{URLWidget-B99nKr6N.js → URLWidget-KbhE2ZUA.js} +2 -2
- package/dist/UploadWidget-DFvfDUT6.js +616 -0
- package/dist/audience/components/block.d.ts.map +1 -1
- package/dist/audience/components/component.d.ts.map +1 -1
- package/dist/audience/components/page.d.ts.map +1 -1
- package/dist/audience/index.js +1 -1
- package/dist/collection/components/Altcha.d.ts +10 -0
- package/dist/collection/components/Altcha.d.ts.map +1 -0
- package/dist/collection/components/FormCaptcha.d.ts +3 -0
- package/dist/collection/components/FormCaptcha.d.ts.map +1 -0
- package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +1 -1
- package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +1 -1
- package/dist/collection/components/core/Input/Input.d.ts.map +1 -1
- package/dist/collection/components/core/Switch/Switch.d.ts.map +1 -1
- package/dist/collection/components/renderer/RenderCommonField.d.ts.map +1 -1
- package/dist/collection/components/widgets/FieldWrapper.d.ts.map +1 -1
- package/dist/collection/components/widgets/FormHelperText.d.ts.map +1 -1
- package/dist/collection/components/widgets/FormLabel.d.ts.map +1 -1
- package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +1 -1
- package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts +7 -0
- package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -0
- package/dist/collection/components/widgets/collectionWidget/{CollectionWidget.d.ts → CollectionWidgetM2O.d.ts} +1 -1
- package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts.map +1 -0
- package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts +8 -0
- package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +1 -0
- package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts +11 -0
- package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -0
- package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -1
- package/dist/collection/index.js +13 -12
- package/dist/collection/lib/FormBuilder.d.ts.map +1 -1
- package/dist/collection/lib/SaveDraftValues.d.ts.map +1 -1
- package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -1
- package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +1 -1
- package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +1 -1
- package/dist/collection/utils/formHelpers.d.ts.map +1 -1
- package/dist/collection/utils/index.d.ts +2 -0
- package/dist/collection/utils/index.d.ts.map +1 -1
- package/dist/components/Dialog.d.ts.map +1 -1
- package/dist/components/Spinner.d.ts.map +1 -1
- package/dist/components/Table.d.ts +11 -0
- package/dist/components/Table.d.ts.map +1 -0
- package/dist/components/Tabs.d.ts.map +1 -1
- package/dist/components/Tooltip.d.ts.map +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/index.js +29 -29
- package/dist/constants/fileUploadPresets.d.ts +4 -2
- package/dist/constants/fileUploadPresets.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +75 -75
- package/dist/membership/components/Button.d.ts.map +1 -1
- package/dist/membership/components/Container.d.ts.map +1 -1
- package/dist/membership/components/Core.d.ts.map +1 -1
- package/dist/membership/index.js +2 -3
- package/dist/page-BKyDlf0z.js +212 -0
- package/dist/utils/errorHandler.d.ts.map +1 -1
- package/package.json +12 -11
- package/dist/CheckboxWidget-BctVOZiO.js +0 -118
- package/dist/CollectionFormBuilder-B6CAVKhg.js +0 -772
- package/dist/DefaultFormVariant-C6zbKgwB.js +0 -80
- package/dist/DropdownWidget-DszCTSWr.js +0 -115
- package/dist/GeocoderWidget-CXu17A7y.js +0 -310
- package/dist/LevoProvider-BI6g_T4E.js +0 -212
- package/dist/Spinner-DzGH5rKe.js +0 -297
- package/dist/Tooltip-CI4i4mYr.js +0 -144
- package/dist/UploadWidget-ZebPWZZZ.js +0 -505
- package/dist/collection/components/widgets/collectionWidget/CollectionWidget.d.ts.map +0 -1
- package/dist/fileUploadPresets-2raQmHT0.js +0 -74
- package/dist/page-yeiAPg3O.js +0 -200
- package/dist/useLevoForm-DjvUas25.js +0 -166
|
@@ -1,772 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { j as s } from "./jsx-runtime-B6kdoens.js";
|
|
3
|
-
import { FieldInterfaces as a, defaultByKinds as F, formatsByInterface as se, interfaceKinds as oe, FieldInterfacesList as ae } from "@levo-so/core";
|
|
4
|
-
import b, { useState as T, lazy as h, Suspense as ie, useEffect as le } from "react";
|
|
5
|
-
import { useFieldArray as ce, useController as ue } from "react-hook-form";
|
|
6
|
-
import { G as O, T as de, a as ge, c as me, B as v, d as he, r as pe, s as xe, S as ye } from "./Spinner-DzGH5rKe.js";
|
|
7
|
-
import { Mate as $ } from "@theinternetfolks/mate";
|
|
8
|
-
import { u as G } from "./LevoProvider-BI6g_T4E.js";
|
|
9
|
-
import { Snowflake as fe } from "@theinternetfolks/snowflake";
|
|
10
|
-
import We from "google-libphonenumber";
|
|
11
|
-
import P from "validator";
|
|
12
|
-
import w from "validatorjs";
|
|
13
|
-
import { c as f } from "./cn-C9QoOYNG.js";
|
|
14
|
-
import * as je from "inflection";
|
|
15
|
-
import { useInView as be } from "react-intersection-observer";
|
|
16
|
-
const { PhoneNumberUtil: ke } = We, ve = (e) => {
|
|
17
|
-
const r = [];
|
|
18
|
-
for (const t of Object.keys(e))
|
|
19
|
-
for (const n of (e == null ? void 0 : e[t]) || [])
|
|
20
|
-
r.push({ message: n, name: t });
|
|
21
|
-
return r;
|
|
22
|
-
}, z = ke.getInstance(), we = (e) => {
|
|
23
|
-
try {
|
|
24
|
-
return z.isValidNumber(z.parseAndKeepRawInput(e));
|
|
25
|
-
} catch {
|
|
26
|
-
return !1;
|
|
27
|
-
}
|
|
28
|
-
}, K = (e, r) => {
|
|
29
|
-
w.register(
|
|
30
|
-
"data_uri",
|
|
31
|
-
(n) => typeof n != "string" ? !1 : P.isDataURI(n),
|
|
32
|
-
"The :attribute is not a valid file."
|
|
33
|
-
), w.register(
|
|
34
|
-
"phone_number",
|
|
35
|
-
(n) => we(n),
|
|
36
|
-
"The :attribute has incorrect format."
|
|
37
|
-
), w.register(
|
|
38
|
-
"url",
|
|
39
|
-
(n) => P.isURL(n.toString(), {}),
|
|
40
|
-
"The :attribute is not a valid URL."
|
|
41
|
-
), w.setAttributeFormatter((n) => {
|
|
42
|
-
if (n.endsWith("Id"))
|
|
43
|
-
return n.replace("Id", "");
|
|
44
|
-
if (n.includes(".")) {
|
|
45
|
-
const [i] = n.split(".");
|
|
46
|
-
return i;
|
|
47
|
-
}
|
|
48
|
-
return n.replace(/_/g, " ");
|
|
49
|
-
});
|
|
50
|
-
const t = new w(e, r);
|
|
51
|
-
return t.passes() ? { status: !0 } : {
|
|
52
|
-
status: !1,
|
|
53
|
-
errors: ve(t.errors.all())
|
|
54
|
-
};
|
|
55
|
-
}, mt = (e, r) => {
|
|
56
|
-
const t = {};
|
|
57
|
-
for (const o of e.sections)
|
|
58
|
-
for (const c of o.fields) {
|
|
59
|
-
const u = [];
|
|
60
|
-
switch (c.required && u.push("required"), typeof c.max < "u" && c.max !== null && u.push({
|
|
61
|
-
max: [c.max]
|
|
62
|
-
}), typeof c.min < "u" && c.min !== null && u.push({
|
|
63
|
-
min: [c.min]
|
|
64
|
-
}), c.field_interface) {
|
|
65
|
-
case a.EmailWidget:
|
|
66
|
-
u.push("email");
|
|
67
|
-
break;
|
|
68
|
-
case a.PhoneWidget:
|
|
69
|
-
u.push("phone_number");
|
|
70
|
-
break;
|
|
71
|
-
case a.URLWidget:
|
|
72
|
-
u.push("url");
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
t[c.key] = u;
|
|
76
|
-
}
|
|
77
|
-
const n = K(r, t), { errors: i } = n, d = {};
|
|
78
|
-
return i && i.map((o) => {
|
|
79
|
-
d[o.name] = o.message;
|
|
80
|
-
}), d;
|
|
81
|
-
}, C = (e) => {
|
|
82
|
-
var t, n;
|
|
83
|
-
const r = {};
|
|
84
|
-
for (const i of e)
|
|
85
|
-
r[i.key] = (t = F) == null ? void 0 : t[i == null ? void 0 : i.kind], (i == null ? void 0 : i.field_interface) === a.RecordWidget && ((n = i == null ? void 0 : i.fields) != null && n.length) && (r[i.key] = C(i.fields));
|
|
86
|
-
return r;
|
|
87
|
-
}, ht = (e) => {
|
|
88
|
-
var t;
|
|
89
|
-
if (!(e != null && e.sections)) return {};
|
|
90
|
-
let r = {};
|
|
91
|
-
for (const n of e.sections)
|
|
92
|
-
n != null && n.fields && ((t = n == null ? void 0 : n.fields) == null ? void 0 : t.length) > 0 && (r = {
|
|
93
|
-
...r,
|
|
94
|
-
...C(n.fields)
|
|
95
|
-
});
|
|
96
|
-
return r;
|
|
97
|
-
}, B = (e) => typeof e < "u" ? e : null, pt = (e, r) => {
|
|
98
|
-
var n;
|
|
99
|
-
if (!(e != null && e.sections)) return {};
|
|
100
|
-
const t = {};
|
|
101
|
-
for (const i of e.sections) {
|
|
102
|
-
const d = C(i.fields ?? []);
|
|
103
|
-
for (const o of i.fields) {
|
|
104
|
-
let c = B(r == null ? void 0 : r[o == null ? void 0 : o.key]);
|
|
105
|
-
Array.isArray(c) && (c == null ? void 0 : c.length) > 0 && Array.isArray(o == null ? void 0 : o.values) && ((n = o == null ? void 0 : o.values) == null ? void 0 : n.length) > 0 && (c = c == null ? void 0 : c.filter((u) => {
|
|
106
|
-
var g;
|
|
107
|
-
return (g = o == null ? void 0 : o.values) == null ? void 0 : g.includes(u);
|
|
108
|
-
})), t[o.key] = c ?? B(o == null ? void 0 : o.default_value) ?? d[o.key];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return t;
|
|
112
|
-
}, xt = (e, r) => {
|
|
113
|
-
var i;
|
|
114
|
-
const t = { ...e };
|
|
115
|
-
let n = null;
|
|
116
|
-
return (t.field_interface === a.ArrayWidget && r !== a.ArrayWidget || t.field_interface === a.RecordWidget && r !== a.RecordWidget) && (t.fields = []), (r !== a.MultiDropdownWidget || r !== a.DropdownWidget || r !== a.RadioWidget || r !== a.CheckboxWidget) && t.field_interface !== a.MultiDropdownWidget && t.field_interface !== a.DropdownWidget && t.field_interface !== a.RadioWidget && t.field_interface !== a.CheckboxWidget && ((i = t.values) == null ? void 0 : i.length) !== 0 && (t.values = []), (r === a.MultiDropdownWidget && t.field_interface !== a.MultiDropdownWidget || r === a.DropdownWidget && t.field_interface !== a.DropdownWidget || r === a.RadioWidget && t.field_interface !== a.RadioWidget || r === a.CheckboxWidget && t.field_interface !== a.CheckboxWidget) && (t.values = [""], n = `${t.id}-option-0`), [a.RecordWidget, a.ArrayWidget].includes(
|
|
117
|
-
r
|
|
118
|
-
) && (n = `field-${fe.generate()}`, t.kind = r === a.RecordWidget ? "record" : "group", t.fields = [
|
|
119
|
-
...(t == null ? void 0 : t.fields) || [],
|
|
120
|
-
{
|
|
121
|
-
id: n,
|
|
122
|
-
key: "title",
|
|
123
|
-
label: "Title",
|
|
124
|
-
helper_text: "",
|
|
125
|
-
kind: "string",
|
|
126
|
-
field_interface: a.TextWidget,
|
|
127
|
-
default_value: "",
|
|
128
|
-
options: {},
|
|
129
|
-
fields: [],
|
|
130
|
-
hidden: !1,
|
|
131
|
-
readonly: !1,
|
|
132
|
-
required: !1,
|
|
133
|
-
unique: !1,
|
|
134
|
-
min: null,
|
|
135
|
-
max: null,
|
|
136
|
-
formats: se[r] || [],
|
|
137
|
-
values: [],
|
|
138
|
-
editable: !0
|
|
139
|
-
}
|
|
140
|
-
]), t.kind = oe[r] || "string", t.default_value || (t.default_value = F[t.kind] || null), r !== a.CollectionWidget && ae.includes(r) && (t.field_interface = r), { field: t, fieldFocused: n };
|
|
141
|
-
}, yt = (e, r) => {
|
|
142
|
-
var d;
|
|
143
|
-
const t = { ...e }, n = [], i = "_id";
|
|
144
|
-
if (r)
|
|
145
|
-
for (const o of r.sections ?? [])
|
|
146
|
-
for (const c of o.fields)
|
|
147
|
-
c.field_interface === "CollectionWidget" && n.push(c.key);
|
|
148
|
-
for (const o of n)
|
|
149
|
-
t[o] && typeof t[o] == "object" && (Array.isArray(t[o]) ? t[o] = (d = t[o]) == null ? void 0 : d.map(
|
|
150
|
-
(c) => c[i]
|
|
151
|
-
) : t[o] = t[o][i]);
|
|
152
|
-
return t;
|
|
153
|
-
}, ft = (e, r) => {
|
|
154
|
-
if (Array.isArray(e) && e.length > 0) {
|
|
155
|
-
let t = 0;
|
|
156
|
-
for (const n of e)
|
|
157
|
-
t += 1, n != null && n.param && r && r(
|
|
158
|
-
n == null ? void 0 : n.param,
|
|
159
|
-
{
|
|
160
|
-
type: "server_error",
|
|
161
|
-
message: n == null ? void 0 : n.message
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
shouldFocus: t === 0
|
|
165
|
-
}
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
function Wt(e) {
|
|
170
|
-
return O({ tag: "svg", attr: { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, child: [{ tag: "path", attr: { fillRule: "evenodd", d: "M9.243 3.03a1 1 0 01.727 1.213L9.53 6h2.94l.56-2.243a1 1 0 111.94.486L14.53 6H17a1 1 0 110 2h-2.97l-1 4H15a1 1 0 110 2h-2.47l-.56 2.242a1 1 0 11-1.94-.485L10.47 14H7.53l-.56 2.242a1 1 0 11-1.94-.485L5.47 14H3a1 1 0 110-2h2.97l1-4H5a1 1 0 110-2h2.47l.56-2.243a1 1 0 011.213-.727zM9.03 8l-1 4h2.938l1-4H9.031z", clipRule: "evenodd" }, child: [] }] })(e);
|
|
171
|
-
}
|
|
172
|
-
function E(e) {
|
|
173
|
-
return O({ tag: "svg", attr: { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true" }, child: [{ tag: "path", attr: { fillRule: "evenodd", d: "M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z", clipRule: "evenodd" }, child: [] }] })(e);
|
|
174
|
-
}
|
|
175
|
-
const A = ({
|
|
176
|
-
children: e,
|
|
177
|
-
isRequired: r,
|
|
178
|
-
className: t,
|
|
179
|
-
...n
|
|
180
|
-
}) => /* @__PURE__ */ s.jsxs(
|
|
181
|
-
"label",
|
|
182
|
-
{
|
|
183
|
-
className: f(
|
|
184
|
-
"block text-sm font-medium leading-normal peer-disabled:cursor-not-allowed peer-disabled:opacity-70 select-none flex-1",
|
|
185
|
-
"mb-2",
|
|
186
|
-
t
|
|
187
|
-
),
|
|
188
|
-
...n,
|
|
189
|
-
children: [
|
|
190
|
-
e,
|
|
191
|
-
" ",
|
|
192
|
-
r && /* @__PURE__ */ s.jsx("span", { className: "text-red-500", children: "*" })
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
), Ce = ({
|
|
196
|
-
field: e,
|
|
197
|
-
isInternal: r
|
|
198
|
-
}) => {
|
|
199
|
-
const { key: t = "", label: n = "", field_interface: i = "", fields: d = [] } = e, [o, c] = T("0"), { fields: u, ...g } = ce({
|
|
200
|
-
name: t
|
|
201
|
-
});
|
|
202
|
-
return !i || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full max-w-full", children: [
|
|
203
|
-
/* @__PURE__ */ s.jsx(A, { className: "text-md font-medium mb-4", children: n }),
|
|
204
|
-
u && Array.isArray(u) ? /* @__PURE__ */ s.jsxs(de, { value: o, onValueChange: c, className: "w-full", children: [
|
|
205
|
-
/* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
|
|
206
|
-
u.length ? /* @__PURE__ */ s.jsx(ge, { className: "h-11 overflow-y-hidden overflow-x-auto flex-1 w-1 justify-start", children: u == null ? void 0 : u.map((x, l) => /* @__PURE__ */ s.jsx(
|
|
207
|
-
me,
|
|
208
|
-
{
|
|
209
|
-
id: `${e == null ? void 0 : e.key}-${l}`,
|
|
210
|
-
value: l.toString(),
|
|
211
|
-
children: l + 1
|
|
212
|
-
},
|
|
213
|
-
`array-widget-tab-${e == null ? void 0 : e.id}-${l}`
|
|
214
|
-
)) }) : null,
|
|
215
|
-
/* @__PURE__ */ s.jsxs(
|
|
216
|
-
v,
|
|
217
|
-
{
|
|
218
|
-
variant: "ghost",
|
|
219
|
-
size: "xs",
|
|
220
|
-
className: "shrink-0 grow-0",
|
|
221
|
-
onClick: () => {
|
|
222
|
-
g.append(C(d)), c(((u == null ? void 0 : u.length) ?? 0).toString());
|
|
223
|
-
},
|
|
224
|
-
children: [
|
|
225
|
-
/* @__PURE__ */ s.jsx(E, { className: "inline-block mr-1", size: "14px" }),
|
|
226
|
-
"Add"
|
|
227
|
-
]
|
|
228
|
-
}
|
|
229
|
-
)
|
|
230
|
-
] }),
|
|
231
|
-
u == null ? void 0 : u.map((x, l) => /* @__PURE__ */ s.jsxs(
|
|
232
|
-
he,
|
|
233
|
-
{
|
|
234
|
-
className: "space-y-4 border rounded bg-secondary/40",
|
|
235
|
-
value: l.toString(),
|
|
236
|
-
children: [
|
|
237
|
-
/* @__PURE__ */ s.jsx("div", { className: "flex flex-col px-3 py-2 gap-3", children: d.map((p) => {
|
|
238
|
-
const j = {
|
|
239
|
-
...p,
|
|
240
|
-
key: `${t}.${l}.${p == null ? void 0 : p.key}`
|
|
241
|
-
};
|
|
242
|
-
return /* @__PURE__ */ s.jsx(
|
|
243
|
-
J,
|
|
244
|
-
{
|
|
245
|
-
field: j,
|
|
246
|
-
isInternal: r
|
|
247
|
-
},
|
|
248
|
-
`common-fields-${p == null ? void 0 : p.id}`
|
|
249
|
-
);
|
|
250
|
-
}) }),
|
|
251
|
-
/* @__PURE__ */ s.jsxs("div", { className: "flex p-2 items-center border-t", children: [
|
|
252
|
-
/* @__PURE__ */ s.jsx(
|
|
253
|
-
v,
|
|
254
|
-
{
|
|
255
|
-
onClick: () => {
|
|
256
|
-
c((l - 1).toString()), g.move(l, l - 1);
|
|
257
|
-
},
|
|
258
|
-
disabled: l === 0,
|
|
259
|
-
size: "icon",
|
|
260
|
-
className: "rounded-full w-8 h-8",
|
|
261
|
-
children: /* @__PURE__ */ s.jsx(pe, { size: "24px" })
|
|
262
|
-
}
|
|
263
|
-
),
|
|
264
|
-
/* @__PURE__ */ s.jsx(
|
|
265
|
-
v,
|
|
266
|
-
{
|
|
267
|
-
className: "text-red-500",
|
|
268
|
-
variant: "link",
|
|
269
|
-
onClick: () => {
|
|
270
|
-
c((l - 1).toString()), g.remove(l);
|
|
271
|
-
},
|
|
272
|
-
children: "Remove Item"
|
|
273
|
-
}
|
|
274
|
-
),
|
|
275
|
-
/* @__PURE__ */ s.jsx(
|
|
276
|
-
v,
|
|
277
|
-
{
|
|
278
|
-
className: "rounded-full w-8 h-8",
|
|
279
|
-
onClick: () => {
|
|
280
|
-
c((l + 1).toString()), g.move(l, l + 1);
|
|
281
|
-
},
|
|
282
|
-
disabled: l >= u.length - 1,
|
|
283
|
-
size: "icon",
|
|
284
|
-
children: /* @__PURE__ */ s.jsx(xe, { size: "24px" })
|
|
285
|
-
}
|
|
286
|
-
)
|
|
287
|
-
] })
|
|
288
|
-
]
|
|
289
|
-
},
|
|
290
|
-
`array-widget-tab-content-${e == null ? void 0 : e.id}-${l}`
|
|
291
|
-
))
|
|
292
|
-
] }) : /* @__PURE__ */ s.jsxs(
|
|
293
|
-
v,
|
|
294
|
-
{
|
|
295
|
-
variant: "ghost",
|
|
296
|
-
size: "xs",
|
|
297
|
-
onClick: () => {
|
|
298
|
-
g.append(C(d)), c("0");
|
|
299
|
-
},
|
|
300
|
-
children: [
|
|
301
|
-
/* @__PURE__ */ s.jsx(E, { className: "inline-block mr-1", size: "14px" }),
|
|
302
|
-
"Add"
|
|
303
|
-
]
|
|
304
|
-
}
|
|
305
|
-
)
|
|
306
|
-
] });
|
|
307
|
-
}, Re = (e) => {
|
|
308
|
-
const r = e == null ? void 0 : e.key;
|
|
309
|
-
let t = r == null ? void 0 : r.replace(/_/g, " ");
|
|
310
|
-
if (t != null && t.endsWith("Id") && (t = t == null ? void 0 : t.replace("Id", "")), t.includes(".")) {
|
|
311
|
-
const [i] = t.split(".");
|
|
312
|
-
i && (t = i);
|
|
313
|
-
}
|
|
314
|
-
const n = [];
|
|
315
|
-
switch (typeof e.max < "u" && e.max !== null && n.push({
|
|
316
|
-
max: [e.max]
|
|
317
|
-
}), typeof e.min < "u" && e.min !== null && n.push({
|
|
318
|
-
min: [e.min]
|
|
319
|
-
}), e.field_interface) {
|
|
320
|
-
case a.EmailWidget:
|
|
321
|
-
n.push("email");
|
|
322
|
-
break;
|
|
323
|
-
case a.PhoneWidget:
|
|
324
|
-
n.push("phone_number");
|
|
325
|
-
break;
|
|
326
|
-
case a.URLWidget:
|
|
327
|
-
n.push("url");
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
required: {
|
|
332
|
-
value: !!(e != null && e.required),
|
|
333
|
-
message: `The ${t} field is required`
|
|
334
|
-
},
|
|
335
|
-
validate: (i) => {
|
|
336
|
-
var c, u;
|
|
337
|
-
if ((c = e == null ? void 0 : e.options) != null && c.disableValidation || !i)
|
|
338
|
-
return !0;
|
|
339
|
-
const d = K(
|
|
340
|
-
{
|
|
341
|
-
[e.key]: i
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
[e.key]: n
|
|
345
|
-
}
|
|
346
|
-
), { errors: o } = d;
|
|
347
|
-
return o && (o == null ? void 0 : o.length) > 0 ? (u = o == null ? void 0 : o[0]) == null ? void 0 : u.message : !0;
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
}, _e = b.lazy(
|
|
351
|
-
() => import("react-select-async-paginate").then((e) => ({
|
|
352
|
-
default: e.AsyncPaginate
|
|
353
|
-
}))
|
|
354
|
-
), Te = (e) => /* @__PURE__ */ s.jsx(
|
|
355
|
-
_e,
|
|
356
|
-
{
|
|
357
|
-
isClearable: !0,
|
|
358
|
-
menuPlacement: "auto",
|
|
359
|
-
isSearchable: !0,
|
|
360
|
-
unstyled: !0,
|
|
361
|
-
classNames: {
|
|
362
|
-
container: () => f("w-full min-w-none h-auto min-h-none"),
|
|
363
|
-
control: ({ isFocused: r, isMulti: t, isDisabled: n }) => f(
|
|
364
|
-
"w-full pl-3",
|
|
365
|
-
t ? "!min-h-9 h-auto" : "h-9 !min-h-none",
|
|
366
|
-
"rounded-md border bg-transparent hover:cursor-pointer border-input text-sm shadow-sm transition-colors",
|
|
367
|
-
"flex ",
|
|
368
|
-
r && "outline-none ring-1 ring-ring",
|
|
369
|
-
n && "cursor-not-allowed opacity-50"
|
|
370
|
-
),
|
|
371
|
-
input: () => "",
|
|
372
|
-
valueContainer: () => "gap-[4px] py-1",
|
|
373
|
-
singleValue: () => "",
|
|
374
|
-
multiValue: () => "bg-gray-100 rounded items-center py-0.5 pl-2 pr-1 gap-1.5",
|
|
375
|
-
multiValueLabel: () => "py-0.5",
|
|
376
|
-
multiValueRemove: () => "border border-gray-200 bg-white hover:bg-red-50 hover:text-red-800 text-gray-500 hover:border-red-300 rounded-md",
|
|
377
|
-
indicatorsContainer: () => "",
|
|
378
|
-
clearIndicator: () => "text-gray-500 p-1 rounded-md hover:bg-red-50 hover:text-red-800",
|
|
379
|
-
indicatorSeparator: () => "",
|
|
380
|
-
dropdownIndicator: () => "p-1 hover:bg-gray-100 text-gray-500 rounded-md hover:text-black",
|
|
381
|
-
menu: () => "p-1 mt-2 border border-gray-200 bg-white rounded-md",
|
|
382
|
-
groupHeading: () => "ml-3 mt-2 mb-1 text-gray-500 text-sm",
|
|
383
|
-
placeholder: () => "text-gray-500 pl-1 py-0.5",
|
|
384
|
-
option: ({ isSelected: r, isFocused: t }) => f(
|
|
385
|
-
"text-[.875rem] font-medium hover:cursor-pointer px-3 py-2 rounded",
|
|
386
|
-
t && "bg-gray-100 active:bg-gray-200",
|
|
387
|
-
r && "text-white bg-primary/80"
|
|
388
|
-
),
|
|
389
|
-
noOptionsMessage: () => "text-gray-500 p-2 bg-gray-50 border border-dashed border-gray-200 rounded-sm"
|
|
390
|
-
},
|
|
391
|
-
...e
|
|
392
|
-
}
|
|
393
|
-
), Le = ({
|
|
394
|
-
children: e
|
|
395
|
-
}) => /* @__PURE__ */ s.jsx("p", { className: "text-xs font-normal text-red-400 text-wrap", children: e }), Ne = ({
|
|
396
|
-
children: e
|
|
397
|
-
}) => /* @__PURE__ */ s.jsx("p", { className: f("text-xs font-normal text-gray-600"), children: e }), Ae = b.forwardRef(({ error: e, helperText: r, containerStyles: t, readOnly: n, children: i }, d) => /* @__PURE__ */ s.jsx(
|
|
398
|
-
"div",
|
|
399
|
-
{
|
|
400
|
-
className: f(
|
|
401
|
-
"form-control w-full",
|
|
402
|
-
n ? "pointer-events-none" : "",
|
|
403
|
-
t
|
|
404
|
-
),
|
|
405
|
-
ref: d,
|
|
406
|
-
children: /* @__PURE__ */ s.jsxs("div", { className: f("w-full shrink-0", "sm:flex-1"), children: [
|
|
407
|
-
i,
|
|
408
|
-
e && /* @__PURE__ */ s.jsx("div", { className: f("w-full mt-3"), children: /* @__PURE__ */ s.jsx(Le, { children: e }) }),
|
|
409
|
-
r && /* @__PURE__ */ s.jsx("div", { className: f("w-full mt-3"), children: /* @__PURE__ */ s.jsx(Ne, { children: r }) })
|
|
410
|
-
] })
|
|
411
|
-
}
|
|
412
|
-
)), Ie = ({
|
|
413
|
-
field: e
|
|
414
|
-
}) => {
|
|
415
|
-
var I, M, D;
|
|
416
|
-
const { collection: r } = G(), [t, n] = T(!1), { key: i = "", label: d = "", helper_text: o = "", readonly: c = !1 } = e, u = i, g = ((I = e == null ? void 0 : e.options) == null ? void 0 : I.collection_key) || "", x = ((M = e == null ? void 0 : e.options) == null ? void 0 : M.label_field_key) || "", {
|
|
417
|
-
field: { value: l, onBlur: p, onChange: j, ref: W, disabled: X, ...Y },
|
|
418
|
-
fieldState: L
|
|
419
|
-
} = ue({
|
|
420
|
-
name: u,
|
|
421
|
-
rules: Re(e)
|
|
422
|
-
}), Z = !!(e != null && e.required), ee = (D = L == null ? void 0 : L.error) == null ? void 0 : D.message, te = async (y, Ye, { page: N = 1 }) => {
|
|
423
|
-
var S;
|
|
424
|
-
n(!0);
|
|
425
|
-
try {
|
|
426
|
-
const R = await (r == null ? void 0 : r.getCollectionContentList({
|
|
427
|
-
collection_key: g,
|
|
428
|
-
page: N,
|
|
429
|
-
search: y,
|
|
430
|
-
limit: 10
|
|
431
|
-
})), k = (S = R == null ? void 0 : R.content) == null ? void 0 : S.data, V = (k || []).map((m) => {
|
|
432
|
-
const ne = m != null && m[x] ? m == null ? void 0 : m[x] : $.toTitle((m == null ? void 0 : m.slug) || "");
|
|
433
|
-
return {
|
|
434
|
-
value: {
|
|
435
|
-
_id: m == null ? void 0 : m._id,
|
|
436
|
-
slug: m == null ? void 0 : m.slug,
|
|
437
|
-
[x]: m == null ? void 0 : m[x]
|
|
438
|
-
},
|
|
439
|
-
label: ne
|
|
440
|
-
};
|
|
441
|
-
});
|
|
442
|
-
return {
|
|
443
|
-
options: Array.isArray(V) ? V : [],
|
|
444
|
-
hasMore: k && !((k == null ? void 0 : k.length) < 10),
|
|
445
|
-
additional: {
|
|
446
|
-
page: N + 1
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
} catch {
|
|
450
|
-
return {
|
|
451
|
-
options: [],
|
|
452
|
-
hasMore: !1,
|
|
453
|
-
additional: {
|
|
454
|
-
page: N
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
} finally {
|
|
458
|
-
n(!1);
|
|
459
|
-
}
|
|
460
|
-
}, re = l ? {
|
|
461
|
-
label: l != null && l[x] ? l == null ? void 0 : l[x] : l != null && l.slug ? $.toTitle((l == null ? void 0 : l.slug) || "") : "",
|
|
462
|
-
value: {
|
|
463
|
-
_id: l == null ? void 0 : l._id,
|
|
464
|
-
slug: l == null ? void 0 : l.slug,
|
|
465
|
-
[x]: l == null ? void 0 : l[x]
|
|
466
|
-
}
|
|
467
|
-
} : null;
|
|
468
|
-
return /* @__PURE__ */ s.jsxs(
|
|
469
|
-
Ae,
|
|
470
|
-
{
|
|
471
|
-
ref: W,
|
|
472
|
-
error: ee,
|
|
473
|
-
helperText: o,
|
|
474
|
-
readOnly: c,
|
|
475
|
-
children: [
|
|
476
|
-
d && /* @__PURE__ */ s.jsx(A, { htmlFor: u, isRequired: Z, children: d }),
|
|
477
|
-
/* @__PURE__ */ s.jsx(
|
|
478
|
-
Te,
|
|
479
|
-
{
|
|
480
|
-
id: u,
|
|
481
|
-
value: re,
|
|
482
|
-
onChange: (y) => {
|
|
483
|
-
j((y == null ? void 0 : y.value) || null);
|
|
484
|
-
},
|
|
485
|
-
onBlur: () => {
|
|
486
|
-
p();
|
|
487
|
-
},
|
|
488
|
-
loadOptions: te,
|
|
489
|
-
debounceTimeout: 500,
|
|
490
|
-
getOptionLabel: (y) => y == null ? void 0 : y.label,
|
|
491
|
-
getOptionValue: (y) => y == null ? void 0 : y.value,
|
|
492
|
-
isLoading: t,
|
|
493
|
-
additional: {
|
|
494
|
-
page: 1
|
|
495
|
-
},
|
|
496
|
-
cacheUniqs: [g],
|
|
497
|
-
minMenuHeight: 250,
|
|
498
|
-
isDisabled: X,
|
|
499
|
-
...Y
|
|
500
|
-
}
|
|
501
|
-
)
|
|
502
|
-
]
|
|
503
|
-
}
|
|
504
|
-
);
|
|
505
|
-
}, Me = h(
|
|
506
|
-
() => import("./MultiTextWidget-CyQRcWC8.js")
|
|
507
|
-
), H = h(() => import("./TextWidget-Bvsz-hey.js")), De = h(
|
|
508
|
-
() => import("./CurrencyWidget-COoMkfsA.js")
|
|
509
|
-
), Se = h(
|
|
510
|
-
() => import("./CheckboxWidget-BctVOZiO.js")
|
|
511
|
-
), U = h(
|
|
512
|
-
() => import("./DateTimeWidget-DcbQ3smI.js")
|
|
513
|
-
), q = h(
|
|
514
|
-
() => import("./DropdownWidget-DszCTSWr.js")
|
|
515
|
-
), Ve = h(() => import("./EmailWidget-CG9oNUM5.js")), $e = h(
|
|
516
|
-
() => import("./GeocoderWidget-CXu17A7y.js")
|
|
517
|
-
), Pe = h(
|
|
518
|
-
() => import("./MultiGeocoderWidget-D3Xmv8g4.js")
|
|
519
|
-
), ze = h(() => import("./PhoneWidget-C1Jt7kXL.js")), Be = h(() => import("./RadioWidget-BrLNF-I2.js")), Ee = h(
|
|
520
|
-
() => import("./RichTextWidget-BogYcPtS.js")
|
|
521
|
-
), He = h(() => import("./SwitchWidget-BT0-waP9.js")), Ue = h(
|
|
522
|
-
() => import("./TextareaWidget-8SLym--T.js")
|
|
523
|
-
), qe = h(
|
|
524
|
-
() => import("./ToggleCheckboxWidget-VrCQBF5C.js")
|
|
525
|
-
), Fe = h(() => import("./URLWidget-B99nKr6N.js")), _ = h(() => import("./UploadWidget-ZebPWZZZ.js")), Oe = ({
|
|
526
|
-
field: e,
|
|
527
|
-
isInternal: r
|
|
528
|
-
}) => {
|
|
529
|
-
var i, d, o;
|
|
530
|
-
const { field_interface: t, key: n } = e;
|
|
531
|
-
if (!t || !n)
|
|
532
|
-
return null;
|
|
533
|
-
switch (t) {
|
|
534
|
-
case a.TextWidget:
|
|
535
|
-
return /* @__PURE__ */ s.jsx(H, { field: e });
|
|
536
|
-
case a.NumberWidget:
|
|
537
|
-
return /* @__PURE__ */ s.jsx(H, { type: "number", field: e });
|
|
538
|
-
case a.CurrencyWidget:
|
|
539
|
-
return /* @__PURE__ */ s.jsx(De, { field: e });
|
|
540
|
-
case a.CheckboxWidget:
|
|
541
|
-
return /* @__PURE__ */ s.jsx(Se, { field: e });
|
|
542
|
-
case a.DateTimeWidget:
|
|
543
|
-
return /* @__PURE__ */ s.jsx(U, { field: e });
|
|
544
|
-
case a.DateWidget:
|
|
545
|
-
return /* @__PURE__ */ s.jsx(U, { field: e });
|
|
546
|
-
case a.DropdownWidget:
|
|
547
|
-
return /* @__PURE__ */ s.jsx(q, { field: e, isMulti: !1 });
|
|
548
|
-
case a.MultiDropdownWidget:
|
|
549
|
-
return /* @__PURE__ */ s.jsx(q, { field: e, isMulti: !0 });
|
|
550
|
-
case a.MultiTextWidget:
|
|
551
|
-
return /* @__PURE__ */ s.jsx(Me, { field: e });
|
|
552
|
-
case a.EmailWidget:
|
|
553
|
-
return /* @__PURE__ */ s.jsx(Ve, { field: e });
|
|
554
|
-
case a.GeocoderWidget:
|
|
555
|
-
return /* @__PURE__ */ s.jsx($e, { field: e });
|
|
556
|
-
case a.MultiGeocoderWidget:
|
|
557
|
-
return /* @__PURE__ */ s.jsx(Pe, { field: e });
|
|
558
|
-
case a.PhoneWidget:
|
|
559
|
-
return /* @__PURE__ */ s.jsx(ze, { field: e });
|
|
560
|
-
case a.RadioWidget:
|
|
561
|
-
return /* @__PURE__ */ s.jsx(Be, { field: e });
|
|
562
|
-
case a.RichTextWidget:
|
|
563
|
-
return /* @__PURE__ */ s.jsx(Ee, { field: e });
|
|
564
|
-
case a.SwitchWidget:
|
|
565
|
-
return /* @__PURE__ */ s.jsx(He, { field: e });
|
|
566
|
-
case a.TextareaWidget:
|
|
567
|
-
return /* @__PURE__ */ s.jsx(Ue, { field: e });
|
|
568
|
-
case a.ToggleCheckboxWidget:
|
|
569
|
-
return /* @__PURE__ */ s.jsx(qe, { field: e });
|
|
570
|
-
case a.URLWidget:
|
|
571
|
-
return /* @__PURE__ */ s.jsx(Fe, { field: e });
|
|
572
|
-
case a.ImageUploadWidget:
|
|
573
|
-
return /* @__PURE__ */ s.jsx(
|
|
574
|
-
_,
|
|
575
|
-
{
|
|
576
|
-
field: e,
|
|
577
|
-
isMultiple: !1,
|
|
578
|
-
kind: ["image"],
|
|
579
|
-
isExternal: !r
|
|
580
|
-
}
|
|
581
|
-
);
|
|
582
|
-
case a.MultiImageUploadWidget:
|
|
583
|
-
return /* @__PURE__ */ s.jsx(
|
|
584
|
-
_,
|
|
585
|
-
{
|
|
586
|
-
field: e,
|
|
587
|
-
isMultiple: !0,
|
|
588
|
-
kind: ["image"],
|
|
589
|
-
isExternal: !r
|
|
590
|
-
}
|
|
591
|
-
);
|
|
592
|
-
case a.FileUploadWidget:
|
|
593
|
-
return /* @__PURE__ */ s.jsx(
|
|
594
|
-
_,
|
|
595
|
-
{
|
|
596
|
-
field: e,
|
|
597
|
-
isMultiple: !1,
|
|
598
|
-
kind: ["audio", "video", "image", "document"],
|
|
599
|
-
isExternal: !r
|
|
600
|
-
}
|
|
601
|
-
);
|
|
602
|
-
case a.MultiFileUploadWidget:
|
|
603
|
-
return /* @__PURE__ */ s.jsx(
|
|
604
|
-
_,
|
|
605
|
-
{
|
|
606
|
-
field: e,
|
|
607
|
-
isMultiple: !0,
|
|
608
|
-
kind: ["audio", "video", "image", "document"],
|
|
609
|
-
isExternal: !r
|
|
610
|
-
}
|
|
611
|
-
);
|
|
612
|
-
case a.CollectionWidget:
|
|
613
|
-
return !((i = e == null ? void 0 : e.options) != null && i.collection_key) || !((d = e == null ? void 0 : e.options) != null && d.label_field_key) ? (console.error(
|
|
614
|
-
"[LevoCollection]: Error while rendering collection widget. Collection key of label field key is required."
|
|
615
|
-
), null) : (
|
|
616
|
-
/**
|
|
617
|
-
* @context
|
|
618
|
-
*
|
|
619
|
-
* this includes both `o2m` and `m2m` relationships, which if rendered
|
|
620
|
-
* should be using a multi-select dropdown widget
|
|
621
|
-
*
|
|
622
|
-
*
|
|
623
|
-
* @todo
|
|
624
|
-
* but, if such a field exist, we should be handling that with a modal or a drawer widget
|
|
625
|
-
* which renders a table with a multi-row select.
|
|
626
|
-
*
|
|
627
|
-
* the selected row, would then become connected to the current row.
|
|
628
|
-
*
|
|
629
|
-
* e.g.: `blog` collection key can have an `o2m` relationship with `post` collection key
|
|
630
|
-
*
|
|
631
|
-
* in this case, the `post` collection key should be rendered as a widget which shows count of posts
|
|
632
|
-
* and on clicking which actually opens a modal or a drawer widget which renders a table with a multi-row select
|
|
633
|
-
*
|
|
634
|
-
*/
|
|
635
|
-
(o = e == null ? void 0 : e.options) != null && o.current_have_many_connected ? (console.error(
|
|
636
|
-
"[LevoCollection]: Error while rendering collection widget. Field options not set correctly."
|
|
637
|
-
), null) : /* @__PURE__ */ s.jsx(Ie, { field: e })
|
|
638
|
-
);
|
|
639
|
-
default:
|
|
640
|
-
return null;
|
|
641
|
-
}
|
|
642
|
-
}, Ge = ({
|
|
643
|
-
field: e,
|
|
644
|
-
isInternal: r
|
|
645
|
-
}) => {
|
|
646
|
-
const { key: t = "", label: n = "", field_interface: i = "", fields: d = [] } = e;
|
|
647
|
-
return !i || !t ? null : /* @__PURE__ */ s.jsxs("div", { className: "w-full", children: [
|
|
648
|
-
/* @__PURE__ */ s.jsx(A, { className: "text-md font-medium mb-4", children: n }),
|
|
649
|
-
/* @__PURE__ */ s.jsx("div", { className: "border rounded bg-secondary/40 flex flex-col px-3 py-4 gap-3", children: d.map((o) => {
|
|
650
|
-
const c = {
|
|
651
|
-
...o,
|
|
652
|
-
key: `${t}.${o == null ? void 0 : o.key}`
|
|
653
|
-
};
|
|
654
|
-
return /* @__PURE__ */ s.jsx(
|
|
655
|
-
J,
|
|
656
|
-
{
|
|
657
|
-
field: c,
|
|
658
|
-
isInternal: r
|
|
659
|
-
},
|
|
660
|
-
`common-fields-${e == null ? void 0 : e.id}-${o == null ? void 0 : o.id}`
|
|
661
|
-
);
|
|
662
|
-
}) })
|
|
663
|
-
] });
|
|
664
|
-
}, J = (e) => {
|
|
665
|
-
const { field_interface: r = "", key: t = "" } = e.field;
|
|
666
|
-
if (!r || !t)
|
|
667
|
-
return null;
|
|
668
|
-
switch (r) {
|
|
669
|
-
case a.ArrayWidget:
|
|
670
|
-
return /* @__PURE__ */ s.jsx(Ce, { ...e });
|
|
671
|
-
case a.RecordWidget:
|
|
672
|
-
return /* @__PURE__ */ s.jsx(Ge, { ...e });
|
|
673
|
-
default:
|
|
674
|
-
return /* @__PURE__ */ s.jsx(Oe, { ...e });
|
|
675
|
-
}
|
|
676
|
-
}, Q = b.createContext({
|
|
677
|
-
schema: null,
|
|
678
|
-
submitButtonConfig: {
|
|
679
|
-
show: !0
|
|
680
|
-
}
|
|
681
|
-
}), Ke = ({
|
|
682
|
-
children: e,
|
|
683
|
-
...r
|
|
684
|
-
}) => {
|
|
685
|
-
const { schema: t, onFormView: n } = r, { ref: i } = be({
|
|
686
|
-
triggerOnce: !0,
|
|
687
|
-
onChange: (d) => {
|
|
688
|
-
d && (t != null && t.id) && n && n({ schemaId: t.id });
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
return /* @__PURE__ */ s.jsxs(Q.Provider, { value: { ...r }, children: [
|
|
692
|
-
/* @__PURE__ */ s.jsx("div", { ref: i }),
|
|
693
|
-
e
|
|
694
|
-
] });
|
|
695
|
-
}, jt = () => b.useContext(Q), Je = b.lazy(
|
|
696
|
-
() => import("./DefaultFormVariant-C6zbKgwB.js")
|
|
697
|
-
), Qe = b.lazy(
|
|
698
|
-
() => import("./StepsFormVariant-Bx-jdciC.js")
|
|
699
|
-
), Xe = ({
|
|
700
|
-
formVariant: e,
|
|
701
|
-
...r
|
|
702
|
-
}) => {
|
|
703
|
-
const { schema: t, uiConfig: n } = r;
|
|
704
|
-
return /* @__PURE__ */ s.jsxs(Ke, { ...r, children: [
|
|
705
|
-
n != null && n.hideFormHeading ? null : /* @__PURE__ */ s.jsxs(
|
|
706
|
-
"h1",
|
|
707
|
-
{
|
|
708
|
-
className: f(
|
|
709
|
-
"text-2xl text-left text-black mb-4 font-semibold",
|
|
710
|
-
e === "default" ? "ml-[32%]" : "ml-0"
|
|
711
|
-
),
|
|
712
|
-
children: [
|
|
713
|
-
"Create new ",
|
|
714
|
-
je.singularize((t == null ? void 0 : t.name) || "")
|
|
715
|
-
]
|
|
716
|
-
}
|
|
717
|
-
),
|
|
718
|
-
/* @__PURE__ */ s.jsx(ie, { children: e === "steps" ? /* @__PURE__ */ s.jsx(Qe, {}) : /* @__PURE__ */ s.jsx(Je, {}) })
|
|
719
|
-
] });
|
|
720
|
-
}, bt = ({
|
|
721
|
-
collection_id: e,
|
|
722
|
-
hiddenFields: r,
|
|
723
|
-
...t
|
|
724
|
-
}) => {
|
|
725
|
-
const { collection: n } = G(), [i, d] = T(!0), [o, c] = T(null);
|
|
726
|
-
return le(() => {
|
|
727
|
-
e ? n == null || n.getCollectionByIDExpanded(e, {
|
|
728
|
-
headers: {
|
|
729
|
-
"Levo-Workspace": t == null ? void 0 : t.workspace_id
|
|
730
|
-
}
|
|
731
|
-
}).then((u) => {
|
|
732
|
-
var x, l;
|
|
733
|
-
const g = (x = u == null ? void 0 : u.content) == null ? void 0 : x.data;
|
|
734
|
-
if (g)
|
|
735
|
-
g.sections = (l = g == null ? void 0 : g.sections) == null ? void 0 : l.map(
|
|
736
|
-
(p) => {
|
|
737
|
-
var j;
|
|
738
|
-
return p.fields = (j = p == null ? void 0 : p.fields) == null ? void 0 : j.map((W) => (r != null && r.includes(W == null ? void 0 : W.key) && (W.hidden = !0), W)), p;
|
|
739
|
-
}
|
|
740
|
-
), c(g);
|
|
741
|
-
else
|
|
742
|
-
throw new Error(`API response invalid: ${g}`);
|
|
743
|
-
}).catch((u) => {
|
|
744
|
-
console.error("Error fetching schema", u);
|
|
745
|
-
}).finally(() => {
|
|
746
|
-
d(!1);
|
|
747
|
-
}) : (console.error(
|
|
748
|
-
"[CollectionFormBuilder] Collection ID or Workspace ID is missing."
|
|
749
|
-
), d(!1));
|
|
750
|
-
}, [e]), /* @__PURE__ */ s.jsx("div", { className: "w-full h-auto", children: i ? /* @__PURE__ */ s.jsx("div", { className: "min-h-[400px] w-full flex justify-center items-center bg-white rounded-md", children: /* @__PURE__ */ s.jsx(ye, {}) }) : o ? /* @__PURE__ */ s.jsx(Xe, { schema: o, ...t }) : null });
|
|
751
|
-
};
|
|
752
|
-
export {
|
|
753
|
-
bt as C,
|
|
754
|
-
J as F,
|
|
755
|
-
Wt as H,
|
|
756
|
-
K as a,
|
|
757
|
-
ht as b,
|
|
758
|
-
B as c,
|
|
759
|
-
pt as d,
|
|
760
|
-
ve as e,
|
|
761
|
-
ft as f,
|
|
762
|
-
C as g,
|
|
763
|
-
Re as h,
|
|
764
|
-
we as i,
|
|
765
|
-
Ae as j,
|
|
766
|
-
A as k,
|
|
767
|
-
jt as l,
|
|
768
|
-
z as p,
|
|
769
|
-
yt as s,
|
|
770
|
-
xt as u,
|
|
771
|
-
mt as v
|
|
772
|
-
};
|