@levo-so/studio 0.1.106 → 0.1.107

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 (39) hide show
  1. package/{BillingStep-BNRcxjRl.js → BillingStep-CJqmdIz2.js} +1 -1
  2. package/{Button-BIpdwMrO.js → Button-DujHjtOV.js} +3 -3
  3. package/CollectionField-BPl8E9MW.js +318 -0
  4. package/CollectionFormBuilder-BvFtiZeH.js +3668 -0
  5. package/{DateTimeWidget-DPHIhkAi.js → DateTimeWidget-CbpvxQ9s.js} +3 -4
  6. package/{EntryCard-yFsTPjEj.js → EntryCard-Drnobf4s.js} +3 -3
  7. package/{LoginCard-CUapIHAo.js → LoginCard-B9HKjZEk.js} +3 -3
  8. package/{LoginForm-n-6Z7eVb.js → LoginForm-DpgxFh89.js} +1 -1
  9. package/{LoginModal-wyVhIJk8.js → LoginModal-CaqsScly.js} +2 -2
  10. package/{MessageCard-C2fU_Bo_.js → MessageCard-DojQRKnf.js} +2 -2
  11. package/{ModalManager-D-yKU_15.js → ModalManager-CaBZKQR2.js} +1 -1
  12. package/{PendingApprovalCard-CDZRD8Jm.js → PendingApprovalCard-CrdOrMRu.js} +3 -3
  13. package/{PhoneWidget-BOFhs8Ra.js → PhoneWidget-BxW2gL28.js} +3 -4
  14. package/{PopupRenderer-CV5HY1dP-DlAn5Rc8.js → PopupRenderer-CV5HY1dP-hICGc5AG.js} +1 -1
  15. package/{RichTextWidget-18XLL8wW.js → RichTextWidget-DCzgJ9EA.js} +3 -4
  16. package/{Toolbar-Y6JtgPFn.js → Toolbar-B5UZer_x.js} +3 -3
  17. package/{VerifyButton-TNkt-SDu.js → VerifyButton-DFAg6STD.js} +1 -1
  18. package/{bookingCard-MDpR8SL_.js → bookingCard-BgApvrcj.js} +2 -2
  19. package/collection.js +7 -8
  20. package/dist-DZbXWctg.js +97 -0
  21. package/index.d.ts +10 -0
  22. package/index.js +1294 -1294
  23. package/package.json +3 -3
  24. package/{utils-B01DL3RB.js → utils-CUqS5dMC.js} +1 -1
  25. package/CollectionField-xa-jed3_.js +0 -232
  26. package/dist-BjFMATnH.js +0 -3550
  27. package/getFieldValidations-CSkSV2hW.js +0 -90
  28. package/widgets-NzmPF3Ji.js +0 -215
  29. /package/{Beams-DEybrmUZ.js → Beams-DboMUgCv.js} +0 -0
  30. /package/{CollectionInput-CpNGIXJx.js → CollectionInput-DcNJT5Pg.js} +0 -0
  31. /package/{Dots-CMyy77GM.js → Dots-a8xSboDv.js} +0 -0
  32. /package/{Gradient-DBn_zXzI.js → Gradient-NacpoDCM.js} +0 -0
  33. /package/{Grid-kGCr-6by.js → Grid-BJQvxnks.js} +0 -0
  34. /package/{MessageFooter-4qIEK91O.js → MessageFooter-C4qC8cem.js} +0 -0
  35. /package/{Popover-O1poOHk2.js → Popover-DOvRAGzc.js} +0 -0
  36. /package/{Tooltip-NEMQqPyr.js → Tooltip-CJINDx93.js} +0 -0
  37. /package/{Waves-DjLcbiBu.js → Waves-DUuT_IFr.js} +0 -0
  38. /package/{authentication-hnV1BI8s.js → authentication-ClOFcry8.js} +0 -0
  39. /package/{card-5ooLmYSr.js → card-E2LKF9nT.js} +0 -0
@@ -1,90 +0,0 @@
1
- import { FieldInterfaces as e } from "@levo-so/core";
2
- import { isValidPhoneNumber as t } from "react-phone-number-input";
3
- import * as n from "yup";
4
- //#region ../../libraries/react-collection/dist/utils/getFieldValidations.js
5
- var r = (r, i) => {
6
- let a = (r?.label || r?.key || "")?.replace(/_/g, " ");
7
- if (a?.endsWith("Id") && (a = a?.replace("Id", "")), a.includes(".")) {
8
- let [e] = a.split(".");
9
- e && (a = e);
10
- }
11
- let o = (e) => {
12
- let t = e;
13
- return r.max !== void 0 && r.max !== null && r.max !== "" && (t = t.max(Number(r.max), `The ${a} value is too large (max ${r.max})`)), r.min !== void 0 && r.min !== null && r.min !== "" && (t = t.min(Number(r.min), `The ${a} value is too small (min ${r.min})`)), t;
14
- }, s;
15
- switch (r.field_interface) {
16
- case e.NumberWidget:
17
- s = o(n.number());
18
- break;
19
- case e.ArrayWidget:
20
- s = o(n.array().typeError("The field must be an array"));
21
- break;
22
- case e.RecordWidget:
23
- s = n.object();
24
- break;
25
- case e.EmailWidget:
26
- s = o(n.string().email("The email address is not valid"));
27
- break;
28
- case e.PhoneWidget:
29
- s = o(n.string().test("phone", "The phone number has incorrect format", (e) => {
30
- if (e) try {
31
- return t(e);
32
- } catch {
33
- return !1;
34
- }
35
- return !0;
36
- }));
37
- break;
38
- case e.URLWidget:
39
- s = o(n.string().matches(/^(?:https?:\/\/)?(?:[a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+(?:\.[a-zA-Z]{2,})+(?:\/[^\s?#]*)?(?:\?[^\s]*)?$/, "The URL is not valid"));
40
- break;
41
- case e.ImageUploadWidget:
42
- case e.FileUploadWidget:
43
- case e.GeocoderWidget:
44
- s = n.object();
45
- break;
46
- case e.MultiImageUploadWidget:
47
- case e.MultiFileUploadWidget:
48
- case e.MultiGeocoderWidget:
49
- s = n.array().of(n.object());
50
- break;
51
- case e.JSONWidget:
52
- case e.DropdownWidget:
53
- s = n.string();
54
- break;
55
- case e.MultiTextWidget:
56
- case e.MultiDropdownWidget:
57
- case e.CheckboxWidget:
58
- s = n.array().of(n.string());
59
- break;
60
- case e.ToggleCheckboxWidget:
61
- s = n.boolean();
62
- break;
63
- case e.CollectionWidget:
64
- s = r.options.current_have_many_connected ? n.array() : n.object();
65
- break;
66
- default:
67
- s = o(n.string());
68
- break;
69
- }
70
- if (r.options?.validationsPresets && Array.isArray(r.options.validationsPresets)) {
71
- let t = r.options.validationsPresets;
72
- (r.field_interface === e.TextWidget || r.field_interface === e.TextareaWidget) && (t.includes("exclude_special_chars") && (s = s.matches(/^[a-zA-Z0-9\s]*$/, "Special characters are not allowed")), t.includes("exclude_numbers") && (s = s.matches(/^[^0-9]*$/, "Numbers are not allowed")));
73
- }
74
- return {
75
- required: {
76
- value: !!r?.required,
77
- message: `The ${a} field is required`
78
- },
79
- validate: (e) => {
80
- if (r?.options?.disableValidation || e === "" || e == null) return !0;
81
- try {
82
- return s.validateSync(e), i ? i(e) : !0;
83
- } catch (e) {
84
- return e instanceof n.ValidationError ? e.message : !0;
85
- }
86
- }
87
- };
88
- };
89
- //#endregion
90
- export { r as t };
@@ -1,215 +0,0 @@
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
- audio: {
28
- "audio/mpeg": [".mp3"],
29
- "audio/ogg": [".oga"]
30
- },
31
- document: {
32
- "application/pdf": [".pdf"],
33
- "application/msword": [".doc"],
34
- "application/vnd.ms-excel": [".xls"],
35
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
36
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
37
- "text/csv": [".csv"]
38
- },
39
- image: {
40
- "image/jpeg": [".jpeg", ".jpg"],
41
- "image/png": [".png"],
42
- "image/gif": [".gif"],
43
- "image/svg+xml": [".svg"],
44
- "image/webp": [".webp"],
45
- "image/avif": [".avif"]
46
- },
47
- video: {
48
- "video/mp4": [".mp4"],
49
- "video/mpeg": [".mpeg"]
50
- }
51
- }, m = {
52
- audio: f,
53
- document: l,
54
- image: u,
55
- video: d
56
- };
57
- [
58
- ...m.audio,
59
- ...m.document,
60
- ...m.image,
61
- ...m.video
62
- ], {
63
- ...p.audio,
64
- ...p.document,
65
- ...p.image,
66
- ...p.video
67
- };
68
- //#endregion
69
- //#region ../../libraries/react-collection/dist/utils/formHelpers.js
70
- var h = (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
- }, g = (e) => e ? s(e) : !1, _ = (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 ? g(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
- }, v = (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 } = _(n, r), a = {};
134
- return i && i.map((e) => {
135
- a[e.name] = e.message;
136
- }), a;
137
- }, y = (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] = y(i.fields));
145
- }
146
- return n;
147
- }, b = (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
- ...y(n.fields)
153
- });
154
- return t;
155
- }, x = (e) => e === void 0 ? null : e, S = (e, t) => {
156
- if (!e?.sections) return {};
157
- let n = {};
158
- for (let r of e.sections) {
159
- let e = y(r.fields ?? []);
160
- for (let i of r.fields) {
161
- let r = x(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 ?? x(i?.default_value) ?? e[i.key];
163
- }
164
- }
165
- return n;
166
- }, C = (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
- }, w = (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
- }, T = (e) => e.every((e) => {
203
- let { field_interface: t = "", key: n = "", hidden: r } = e;
204
- return !t || !n || r;
205
- }), E = (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
- }, D = (t) => e.memo(t);
214
- //#endregion
215
- export { v as a, S as c, b as d, T as f, h as i, g as l, p as m, E as n, y as o, m as p, w as r, C as s, D as t, x as u };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes