@levo-so/studio 0.1.95 → 0.1.96
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/{BillingStep-BLwl9IDQ.js → BillingStep-C3jJkLXQ.js} +1 -1
- package/{Button-C6BOkG_z.js → Button-CwN6jTXH.js} +1 -1
- package/CollectionField-DnbpB0Z5.js +254 -0
- package/CollectionInput-BoNAc4sq.js +132 -0
- package/DateTimeWidget-IRleQI-3.js +255 -0
- package/{EntryCard-B-feJvrB.js → EntryCard-CZIUBwtE.js} +3 -3
- package/{LoginCard-CF9JbU-y.js → LoginCard-Bthy9dcf.js} +3 -3
- package/{LoginForm-CdpNCQJa.js → LoginForm-CPMtCyMF.js} +4 -0
- package/{LoginModal-ngTHCyli.js → LoginModal-BPI5tOIZ.js} +3 -3
- package/{MessageCard-D2uja800.js → MessageCard-BYxgc9dl.js} +2 -2
- package/{ModalManager-B7pCzvK1.js → ModalManager-BaIL6HG-.js} +1 -1
- package/{PendingApprovalCard-Dut-Xiw1.js → PendingApprovalCard-DEnawzxD.js} +3 -3
- package/PhoneWidget-CjhHfwuG.js +100 -0
- package/Popover-DHVZdJuv.js +56 -0
- package/RichTextWidget-CgT1_zC3.js +1135 -0
- package/Tooltip-ByJRyayB.js +78 -0
- package/VerifyButton-DFKzKYxC.js +283 -0
- package/{bookingCard-BU_MdmS9.js → bookingCard-Bw4tvDYh.js} +3 -3
- package/collection.d.ts +81 -46
- package/collection.js +8 -5
- package/dist-D_jY4Tf1.js +3168 -0
- package/getFieldValidations-qVzuq6mv.js +195 -0
- package/index.d.ts +5 -5
- package/index.js +1229 -1434
- package/nodeAlignment-CG3qmAuQ.js +180 -0
- package/package.json +3 -4
- package/studio.css +1 -1
- package/theme.cssm-De_pl52g.js +4 -0
- package/{utils-KqbqLlMF.js → utils-F6eBcsyI.js} +1 -1
- package/widgets-Dvyv5_uj.js +215 -0
- package/dist-DDKHTnIW.js +0 -3653
- package/widgets-B84lq4lO.js +0 -351
- /package/{Beams-CCNNOvfW.js → Beams-Blr-zwvz.js} +0 -0
- /package/{Dots-89WGkd-z.js → Dots-DeBKuibU.js} +0 -0
- /package/{Gradient-vTa_uWCj.js → Gradient-DGFxOjft.js} +0 -0
- /package/{Grid-CrtztrxK.js → Grid-A7HRCQ0T.js} +0 -0
- /package/{MessageFooter-Bu-jyPkJ.js → MessageFooter-C6DivT4m.js} +0 -0
- /package/{StripePaymentModal-CajqohNM.js → StripePaymentModal-BcePXzmC.js} +0 -0
- /package/{Waves-BhA6CLEI.js → Waves-CIT6Ngng.js} +0 -0
- /package/{card-DCbhJCO9.js → card-izMd2DvE.js} +0 -0
- /package/{dialog-CILIXExr.js → dialog-CCWrvmHd.js} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
import { FieldInterfaces as t, FieldInterfacesList as n, defaultByKinds as r, formatsByInterface as i, interfaceKinds as a } from "@levo-so/core";
|
|
3
|
+
import { Snowflake as o } from "@theinternetfolks/snowflake";
|
|
4
|
+
import { isPossiblePhoneNumber as s } from "react-phone-number-input";
|
|
5
|
+
import * as c from "yup";
|
|
6
|
+
//#region ../../libraries/react-collection/dist/constants/fileUploadPresets.js
|
|
7
|
+
var l = [
|
|
8
|
+
"pdf",
|
|
9
|
+
"xls",
|
|
10
|
+
"xlsx",
|
|
11
|
+
"doc",
|
|
12
|
+
"docx",
|
|
13
|
+
"csv"
|
|
14
|
+
], u = [
|
|
15
|
+
"svg",
|
|
16
|
+
"png",
|
|
17
|
+
"jpg",
|
|
18
|
+
"jpeg",
|
|
19
|
+
"webp",
|
|
20
|
+
"gif",
|
|
21
|
+
"avif"
|
|
22
|
+
], d = ["mpeg", "mp4"], f = [
|
|
23
|
+
"mp3",
|
|
24
|
+
"ogg",
|
|
25
|
+
"oga"
|
|
26
|
+
], p = {
|
|
27
|
+
"application/pdf": [".pdf"],
|
|
28
|
+
"application/msword": [".doc"],
|
|
29
|
+
"application/vnd.ms-excel": [".xls"],
|
|
30
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
|
31
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
|
|
32
|
+
"text/csv": [".csv"]
|
|
33
|
+
}, m = {
|
|
34
|
+
"image/jpeg": [".jpeg", ".jpg"],
|
|
35
|
+
"image/png": [".png"],
|
|
36
|
+
"image/gif": [".gif"],
|
|
37
|
+
"image/svg+xml": [".svg"],
|
|
38
|
+
"image/webp": [".webp"],
|
|
39
|
+
"image/avif": [".avif"]
|
|
40
|
+
}, h = {
|
|
41
|
+
"video/mp4": [".mp4"],
|
|
42
|
+
"video/mpeg": [".mpeg"]
|
|
43
|
+
}, g = {
|
|
44
|
+
audio: {
|
|
45
|
+
"audio/mpeg": [".mp3"],
|
|
46
|
+
"audio/ogg": [".oga"]
|
|
47
|
+
},
|
|
48
|
+
document: p,
|
|
49
|
+
image: m,
|
|
50
|
+
video: h
|
|
51
|
+
}, _ = {
|
|
52
|
+
audio: f,
|
|
53
|
+
document: l,
|
|
54
|
+
image: u,
|
|
55
|
+
video: d
|
|
56
|
+
};
|
|
57
|
+
[
|
|
58
|
+
..._.audio,
|
|
59
|
+
..._.document,
|
|
60
|
+
..._.image,
|
|
61
|
+
..._.video
|
|
62
|
+
], {
|
|
63
|
+
...g.audio,
|
|
64
|
+
...g.document,
|
|
65
|
+
...g.image,
|
|
66
|
+
...g.video
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region ../../libraries/react-collection/dist/utils/formHelpers.js
|
|
70
|
+
var v = (e) => {
|
|
71
|
+
let t = [];
|
|
72
|
+
for (let n of Object.keys(e)) for (let r of e?.[n] || []) t.push({
|
|
73
|
+
message: r,
|
|
74
|
+
name: n
|
|
75
|
+
});
|
|
76
|
+
return t;
|
|
77
|
+
}, y = (e) => e ? s(e) : !1, b = (e, t) => {
|
|
78
|
+
let n = [];
|
|
79
|
+
for (let [r, i] of Object.entries(t)) {
|
|
80
|
+
let t = e?.[r], a = c.string();
|
|
81
|
+
for (let e of i) if (typeof e == "string") switch (e) {
|
|
82
|
+
case "required":
|
|
83
|
+
a = a.required(`The ${r} field is required`);
|
|
84
|
+
break;
|
|
85
|
+
case "email":
|
|
86
|
+
a = a.email("The email address is not valid");
|
|
87
|
+
break;
|
|
88
|
+
case "phone_number":
|
|
89
|
+
a = a.test("phone", "The phone number has incorrect format", (e) => e ? y(e) : !0);
|
|
90
|
+
break;
|
|
91
|
+
case "url":
|
|
92
|
+
a = a.url("The URL is not valid");
|
|
93
|
+
break;
|
|
94
|
+
case "data_uri":
|
|
95
|
+
a = a.test("data_uri", "The field does not have a valid file", (e) => typeof e == "string" ? e.startsWith("data:") && e.includes(",") : !1);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
else if (typeof e == "object" && e) {
|
|
99
|
+
let t = e;
|
|
100
|
+
"max" in e && t.max?.[0] && (a = a.max(Number(t.max[0]))), "min" in e && t.min?.[0] && (a = a.min(Number(t.min[0])));
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
a.validateSync(t);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
e instanceof c.ValidationError && n.push({
|
|
106
|
+
message: e.message,
|
|
107
|
+
name: r
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return n.length > 0 ? {
|
|
112
|
+
status: !1,
|
|
113
|
+
errors: n
|
|
114
|
+
} : { status: !0 };
|
|
115
|
+
}, x = (e, n) => {
|
|
116
|
+
let r = {};
|
|
117
|
+
for (let n of e.sections) for (let e of n.fields) {
|
|
118
|
+
let n = [];
|
|
119
|
+
switch (e.required && n.push("required"), e.max !== void 0 && e.max !== null && n.push({ max: [e.max] }), e.min !== void 0 && e.min !== null && n.push({ min: [e.min] }), e.field_interface) {
|
|
120
|
+
case t.EmailWidget:
|
|
121
|
+
n.push("email");
|
|
122
|
+
break;
|
|
123
|
+
case t.PhoneWidget:
|
|
124
|
+
n.push("phone_number");
|
|
125
|
+
break;
|
|
126
|
+
case t.URLWidget:
|
|
127
|
+
n.push("url");
|
|
128
|
+
break;
|
|
129
|
+
default: break;
|
|
130
|
+
}
|
|
131
|
+
r[e.key] = n;
|
|
132
|
+
}
|
|
133
|
+
let { errors: i } = b(n, r), a = {};
|
|
134
|
+
return i && i.map((e) => {
|
|
135
|
+
a[e.name] = e.message;
|
|
136
|
+
}), a;
|
|
137
|
+
}, S = (e) => {
|
|
138
|
+
let n = {};
|
|
139
|
+
for (let i of e) {
|
|
140
|
+
if (i.kind === "collection") {
|
|
141
|
+
let e = i.options?.current_have_many_connected, t = i.options?.connected_have_many_current;
|
|
142
|
+
e && t ? n[i.key] = r.collection.m2m : n[i.key] = r.collection.m2o;
|
|
143
|
+
} else n[i.key] = r?.[i?.kind];
|
|
144
|
+
i?.field_interface === t.RecordWidget && i?.fields?.length && (n[i.key] = S(i.fields));
|
|
145
|
+
}
|
|
146
|
+
return n;
|
|
147
|
+
}, C = (e) => {
|
|
148
|
+
if (!e?.sections) return {};
|
|
149
|
+
let t = {};
|
|
150
|
+
for (let n of e.sections) n?.fields && n?.fields?.length > 0 && (t = {
|
|
151
|
+
...t,
|
|
152
|
+
...S(n.fields)
|
|
153
|
+
});
|
|
154
|
+
return t;
|
|
155
|
+
}, w = (e) => e === void 0 ? null : e, T = (e, t) => {
|
|
156
|
+
if (!e?.sections) return {};
|
|
157
|
+
let n = {};
|
|
158
|
+
for (let r of e.sections) {
|
|
159
|
+
let e = S(r.fields ?? []);
|
|
160
|
+
for (let i of r.fields) {
|
|
161
|
+
let r = w(t?.[i?.key]);
|
|
162
|
+
Array.isArray(r) && r?.length > 0 && Array.isArray(i?.values) && i?.values?.length > 0 && !i?.options?.custom_input && (r = r?.filter((e) => i?.values?.includes(e))), n[i.key] = r ?? w(i?.default_value) ?? e[i.key];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return n;
|
|
166
|
+
}, E = (e, s) => {
|
|
167
|
+
let c = { ...e }, l = null;
|
|
168
|
+
if ((c.field_interface === t.ArrayWidget && s !== t.ArrayWidget || c.field_interface === t.RecordWidget && s !== t.RecordWidget) && (c.fields = []), (s !== t.MultiDropdownWidget || s !== t.DropdownWidget || s !== t.RadioWidget || s !== t.CheckboxWidget) && c.field_interface !== t.MultiDropdownWidget && c.field_interface !== t.DropdownWidget && c.field_interface !== t.RadioWidget && c.field_interface !== t.CheckboxWidget && c.values?.length !== 0 && (c.values = []), (s === t.MultiDropdownWidget && c.field_interface !== t.MultiDropdownWidget || s === t.DropdownWidget && c.field_interface !== t.DropdownWidget || s === t.RadioWidget && c.field_interface !== t.RadioWidget || s === t.CheckboxWidget && c.field_interface !== t.CheckboxWidget) && (c.values = [""], l = `${c.id}-option-0`), [t.RecordWidget, t.ArrayWidget].includes(s) && (l = `field-${o.generate()}`, c.kind = s === t.RecordWidget ? "record" : "group", c.fields = [...c?.fields || [], {
|
|
169
|
+
id: l,
|
|
170
|
+
key: "title",
|
|
171
|
+
label: "Title",
|
|
172
|
+
helper_text: "",
|
|
173
|
+
kind: "string",
|
|
174
|
+
field_interface: t.TextWidget,
|
|
175
|
+
default_value: "",
|
|
176
|
+
options: {},
|
|
177
|
+
fields: [],
|
|
178
|
+
hidden: !1,
|
|
179
|
+
readonly: !1,
|
|
180
|
+
required: !1,
|
|
181
|
+
unique: !1,
|
|
182
|
+
min: null,
|
|
183
|
+
max: null,
|
|
184
|
+
formats: i[s] || [],
|
|
185
|
+
values: [],
|
|
186
|
+
editable: !0
|
|
187
|
+
}]), c.kind = a[s] || "string", !c.default_value) if (c.kind === "collection") {
|
|
188
|
+
let e = c.options?.current_have_many_connected, t = c.options?.connected_have_many_current;
|
|
189
|
+
e && t ? c.default_value = r.collection.m2m : c.default_value = r.collection.m2o;
|
|
190
|
+
} else c.default_value = r[c.kind] || null;
|
|
191
|
+
return s !== t.CollectionWidget && n.includes(s) && (c.field_interface = s), {
|
|
192
|
+
field: c,
|
|
193
|
+
fieldFocused: l
|
|
194
|
+
};
|
|
195
|
+
}, D = (e, t) => {
|
|
196
|
+
let n = {};
|
|
197
|
+
if (t) for (let r of t?.sections ?? []) for (let t of r?.fields) if (t.field_interface === "CollectionWidget") {
|
|
198
|
+
let r = e?.[t?.key];
|
|
199
|
+
r && typeof r == "object" && (Array.isArray(r) ? n[t?.key] = r?.filter((e) => e) : n[t?.key] = r._id);
|
|
200
|
+
} else n[t?.key] = e?.[t?.key];
|
|
201
|
+
return n;
|
|
202
|
+
}, O = (e) => e.every((e) => {
|
|
203
|
+
let { field_interface: t = "", key: n = "", hidden: r } = e;
|
|
204
|
+
return !t || !n || r;
|
|
205
|
+
}), k = (e, t) => {
|
|
206
|
+
if (Array.isArray(e) && e.length > 0) {
|
|
207
|
+
let n = 0;
|
|
208
|
+
for (let r of e) n += 1, r?.param && t && t(r?.param, {
|
|
209
|
+
type: "server_error",
|
|
210
|
+
message: r?.message
|
|
211
|
+
}, { shouldFocus: n === 0 });
|
|
212
|
+
}
|
|
213
|
+
}, A = (t) => e.memo(t);
|
|
214
|
+
//#endregion
|
|
215
|
+
export { x as a, T as c, C as d, O as f, v as i, y as l, g as m, k as n, S as o, _ as p, D as r, E as s, A as t, w as u };
|