@levo-so/react 0.1.37 → 0.1.40

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 (182) hide show
  1. package/dist/{Sonner-t6JVKA0a.js → Sonner-5IAqCkBs.js} +12 -9
  2. package/dist/Tooltip-DcdGb876.js +383 -0
  3. package/dist/audience/hooks/useBounce.d.ts.map +1 -1
  4. package/dist/audience/hooks/useCurrentTab.d.ts.map +1 -1
  5. package/dist/audience/hooks/useDownloadSpeed.d.ts.map +1 -1
  6. package/dist/audience/hooks/useIdentifyAudience.d.ts.map +1 -1
  7. package/dist/audience/hooks/useOpenTabs.d.ts.map +1 -1
  8. package/dist/audience/hooks/usePerformanceMetrics.d.ts.map +1 -1
  9. package/dist/audience/index.js +1 -1
  10. package/dist/audience/utils/autocapture.d.ts.map +1 -1
  11. package/dist/components/Sonner.d.ts.map +1 -1
  12. package/dist/components/Spinner.d.ts.map +1 -1
  13. package/dist/components/index.js +20 -21
  14. package/dist/index.css +1 -1
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.js +121 -83
  17. package/dist/isEmptyObject-B9yh0nbg.js +19 -0
  18. package/dist/{jsx-runtime-B6kdoens.js → jsx-runtime-D0AQ1Mn7.js} +216 -217
  19. package/dist/membership/index.d.ts +1 -1
  20. package/dist/membership/index.d.ts.map +1 -1
  21. package/dist/membership/index.js +1 -1
  22. package/dist/{page-BVVduzWl.js → page-DweUjn1K.js} +21 -20
  23. package/dist/providers/index.js +1 -1
  24. package/dist/utils/byteToSize.d.ts.map +1 -1
  25. package/dist/utils/cn.d.ts.map +1 -1
  26. package/dist/utils/errorHandler.d.ts.map +1 -1
  27. package/dist/utils/index.js +10 -12
  28. package/dist/utils/isDateObject.d.ts.map +1 -1
  29. package/dist/utils/isEmptyObject.d.ts.map +1 -1
  30. package/dist/utils/isNullOrUndefined.d.ts.map +1 -1
  31. package/dist/utils/isObject.d.ts.map +1 -1
  32. package/package.json +8 -13
  33. package/dist/Checbox-sq-atGlJ.js +0 -28
  34. package/dist/CheckboxWidget-BR6g2qCr.js +0 -124
  35. package/dist/CollectionFormBuilder-KNHR7ngy.js +0 -1195
  36. package/dist/CurrencyWidget-XHAkyPjV.js +0 -60
  37. package/dist/DateTimeWidget-UaUunQAK.js +0 -80
  38. package/dist/DefaultFormVariant-C8hqkuxx.js +0 -81
  39. package/dist/DropdownWidget-DvObQQMp.js +0 -115
  40. package/dist/EmailWidget-7L0S6tat.js +0 -41
  41. package/dist/FormCaptcha-CgYoGiya.js +0 -187
  42. package/dist/GeocoderWidget-DfghAiuD.js +0 -68
  43. package/dist/Input-Vv7mKQFt.js +0 -54
  44. package/dist/MultiGeocoderWidget-CqwjH855.js +0 -49
  45. package/dist/MultiTextWidget-BMp9xdSv.js +0 -33
  46. package/dist/PhoneWidget-DFP4giY9.js +0 -48
  47. package/dist/RadioWidget-DMWMo2Mj.js +0 -109
  48. package/dist/RichTextWidget-DOCSDDib.js +0 -310
  49. package/dist/Spinner-B4CjY8aw.js +0 -411
  50. package/dist/StepsFormVariant-CUFLCpGE.js +0 -140
  51. package/dist/SwitchWidget-BjpxXOcZ.js +0 -53
  52. package/dist/TextWidget-Cgk_TFqD.js +0 -33
  53. package/dist/TextareaWidget-DGU_Xhrx.js +0 -30
  54. package/dist/ToggleCheckboxWidget-bhmeasG_.js +0 -44
  55. package/dist/Tooltip-DoWyn3Ho.js +0 -37
  56. package/dist/URLWidget-B20QysNc.js +0 -14
  57. package/dist/UploadWidget-SQ1MLpbO.js +0 -656
  58. package/dist/byteToSize-BFKZSBu1.js +0 -8
  59. package/dist/cn-C9QoOYNG.js +0 -6
  60. package/dist/collection/components/Altcha.d.ts +0 -10
  61. package/dist/collection/components/Altcha.d.ts.map +0 -1
  62. package/dist/collection/components/CollectionFormBuilder.d.ts +0 -12
  63. package/dist/collection/components/CollectionFormBuilder.d.ts.map +0 -1
  64. package/dist/collection/components/FieldRenderer.d.ts +0 -9
  65. package/dist/collection/components/FieldRenderer.d.ts.map +0 -1
  66. package/dist/collection/components/FormCaptcha.d.ts +0 -3
  67. package/dist/collection/components/FormCaptcha.d.ts.map +0 -1
  68. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts +0 -5
  69. package/dist/collection/components/core/AsyncSelectPaginate/AsyncSelectPaginate.d.ts.map +0 -1
  70. package/dist/collection/components/core/Checkbox/Checbox.d.ts +0 -5
  71. package/dist/collection/components/core/Checkbox/Checbox.d.ts.map +0 -1
  72. package/dist/collection/components/core/Input/Input.d.ts +0 -11
  73. package/dist/collection/components/core/Input/Input.d.ts.map +0 -1
  74. package/dist/collection/components/core/Switch/Switch.d.ts +0 -5
  75. package/dist/collection/components/core/Switch/Switch.d.ts.map +0 -1
  76. package/dist/collection/components/renderer/RenderArrayWidget.d.ts +0 -5
  77. package/dist/collection/components/renderer/RenderArrayWidget.d.ts.map +0 -1
  78. package/dist/collection/components/renderer/RenderCommonField.d.ts +0 -5
  79. package/dist/collection/components/renderer/RenderCommonField.d.ts.map +0 -1
  80. package/dist/collection/components/renderer/RenderRecordWidget.d.ts +0 -4
  81. package/dist/collection/components/renderer/RenderRecordWidget.d.ts.map +0 -1
  82. package/dist/collection/components/widgets/ErrorMessage.d.ts +0 -6
  83. package/dist/collection/components/widgets/ErrorMessage.d.ts.map +0 -1
  84. package/dist/collection/components/widgets/FieldWrapper.d.ts +0 -14
  85. package/dist/collection/components/widgets/FieldWrapper.d.ts.map +0 -1
  86. package/dist/collection/components/widgets/FormHelperText.d.ts +0 -6
  87. package/dist/collection/components/widgets/FormHelperText.d.ts.map +0 -1
  88. package/dist/collection/components/widgets/FormLabel.d.ts +0 -8
  89. package/dist/collection/components/widgets/FormLabel.d.ts.map +0 -1
  90. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts +0 -8
  91. package/dist/collection/components/widgets/checkboxWidget/CheckboxWidget.d.ts.map +0 -1
  92. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts +0 -7
  93. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +0 -1
  94. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts +0 -7
  95. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2O.d.ts.map +0 -1
  96. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts +0 -8
  97. package/dist/collection/components/widgets/collectionWidget/SelectedCollectionItems.d.ts.map +0 -1
  98. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts +0 -9
  99. package/dist/collection/components/widgets/currencyWidget/CurrencyWidget.d.ts.map +0 -1
  100. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts +0 -8
  101. package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +0 -1
  102. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts +0 -9
  103. package/dist/collection/components/widgets/dropdownWidget/DropdownWidget.d.ts.map +0 -1
  104. package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts +0 -8
  105. package/dist/collection/components/widgets/emailWidget/EmailWidget.d.ts.map +0 -1
  106. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts +0 -8
  107. package/dist/collection/components/widgets/geocoderWidget/GeocoderWidget.d.ts.map +0 -1
  108. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts +0 -8
  109. package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +0 -1
  110. package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts +0 -7
  111. package/dist/collection/components/widgets/multiTextWidget/MultiTextWidget.d.ts.map +0 -1
  112. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts +0 -8
  113. package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +0 -1
  114. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts +0 -11
  115. package/dist/collection/components/widgets/radioWidget/RadioWidget.d.ts.map +0 -1
  116. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts +0 -12
  117. package/dist/collection/components/widgets/richTextWidget/RichTextWidget.d.ts.map +0 -1
  118. package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts +0 -8
  119. package/dist/collection/components/widgets/switchWidget/SwitchWidget.d.ts.map +0 -1
  120. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts +0 -9
  121. package/dist/collection/components/widgets/textWidget/TextWidget.d.ts.map +0 -1
  122. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts +0 -8
  123. package/dist/collection/components/widgets/textareaWidget/TextareaWidget.d.ts.map +0 -1
  124. package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts +0 -8
  125. package/dist/collection/components/widgets/toggleCheckboxWidget/ToggleCheckboxWidget.d.ts.map +0 -1
  126. package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts +0 -11
  127. package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts.map +0 -1
  128. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts +0 -11
  129. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +0 -1
  130. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts +0 -10
  131. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +0 -1
  132. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts +0 -13
  133. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +0 -1
  134. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts +0 -11
  135. package/dist/collection/components/widgets/uploadWidget/ImportFromAssets.d.ts.map +0 -1
  136. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts +0 -19
  137. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +0 -1
  138. package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts +0 -5
  139. package/dist/collection/components/widgets/urlWidget/URLWidget.d.ts.map +0 -1
  140. package/dist/collection/index.d.ts +0 -5
  141. package/dist/collection/index.d.ts.map +0 -1
  142. package/dist/collection/index.js +0 -20
  143. package/dist/collection/lib/FormBuilder.d.ts +0 -8
  144. package/dist/collection/lib/FormBuilder.d.ts.map +0 -1
  145. package/dist/collection/lib/SaveDraftValues.d.ts +0 -7
  146. package/dist/collection/lib/SaveDraftValues.d.ts.map +0 -1
  147. package/dist/collection/lib/hooks/useLevoForm.d.ts +0 -18
  148. package/dist/collection/lib/hooks/useLevoForm.d.ts.map +0 -1
  149. package/dist/collection/lib/provider/LevoFormProvider.d.ts +0 -9
  150. package/dist/collection/lib/provider/LevoFormProvider.d.ts.map +0 -1
  151. package/dist/collection/lib/variants/DefaultFormVariant.d.ts +0 -3
  152. package/dist/collection/lib/variants/DefaultFormVariant.d.ts.map +0 -1
  153. package/dist/collection/lib/variants/StepsFormVariant.d.ts +0 -4
  154. package/dist/collection/lib/variants/StepsFormVariant.d.ts.map +0 -1
  155. package/dist/collection/types/context.d.ts +0 -34
  156. package/dist/collection/types/context.d.ts.map +0 -1
  157. package/dist/collection/types/errors.d.ts +0 -7
  158. package/dist/collection/types/errors.d.ts.map +0 -1
  159. package/dist/collection/types/formVariant.d.ts +0 -18
  160. package/dist/collection/types/formVariant.d.ts.map +0 -1
  161. package/dist/collection/types/forms.d.ts +0 -31
  162. package/dist/collection/types/forms.d.ts.map +0 -1
  163. package/dist/collection/types/index.d.ts +0 -4
  164. package/dist/collection/types/index.d.ts.map +0 -1
  165. package/dist/collection/types/renderer.d.ts +0 -6
  166. package/dist/collection/types/renderer.d.ts.map +0 -1
  167. package/dist/collection/utils/formHelpers.d.ts +0 -48
  168. package/dist/collection/utils/formHelpers.d.ts.map +0 -1
  169. package/dist/collection/utils/getFieldValidations.d.ts +0 -6
  170. package/dist/collection/utils/getFieldValidations.d.ts.map +0 -1
  171. package/dist/collection/utils/index.d.ts +0 -6
  172. package/dist/collection/utils/index.d.ts.map +0 -1
  173. package/dist/collection/utils/schema.d.ts +0 -3
  174. package/dist/collection/utils/schema.d.ts.map +0 -1
  175. package/dist/collection/utils/setFormErrors.d.ts +0 -4
  176. package/dist/collection/utils/setFormErrors.d.ts.map +0 -1
  177. package/dist/collection/utils/storage.d.ts +0 -11
  178. package/dist/collection/utils/storage.d.ts.map +0 -1
  179. package/dist/errorHandler-_34Yv8wA.js +0 -9
  180. package/dist/isEmptyObject-C5s4GzLE.js +0 -8
  181. package/dist/libs.css +0 -1
  182. package/dist/libs.d.ts +0 -1
@@ -1,656 +0,0 @@
1
- "use client";
2
- import { j as r } from "./jsx-runtime-B6kdoens.js";
3
- import { MediaKindList as rt } from "@levo-so/core";
4
- import { Upload as Z, X as at, ExternalLink as et } from "lucide-react";
5
- import { useState as B, useMemo as D, useRef as st, useEffect as R } from "react";
6
- import { useController as ot } from "react-hook-form";
7
- import { G as q, S as W, B as F, k as nt, T as ct, l as lt, m as V, n as H } from "./Spinner-B4CjY8aw.js";
8
- import { t as it, g as dt, z as xt, w as J, A as ut, B as mt } from "./CollectionFormBuilder-KNHR7ngy.js";
9
- import { useLevo as G } from "./providers/index.js";
10
- import { e as k } from "./errorHandler-_34Yv8wA.js";
11
- import { I as Q } from "./Input-Vv7mKQFt.js";
12
- import { c as I } from "./cn-C9QoOYNG.js";
13
- import { useDropzone as ht } from "react-dropzone";
14
- import { c as pt, S as jt } from "./Tooltip-DoWyn3Ho.js";
15
- import { e as $ } from "./Sonner-t6JVKA0a.js";
16
- import { useDebouncedCallback as yt } from "use-debounce";
17
- import { b as gt } from "./byteToSize-BFKZSBu1.js";
18
- import { C as bt } from "./Checbox-sq-atGlJ.js";
19
- function X(a) {
20
- return q({ tag: "svg", attr: { fill: "currentColor", viewBox: "0 0 16 16" }, child: [{ tag: "path", attr: { d: "M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z" }, child: [] }] })(a);
21
- }
22
- function vt(a) {
23
- return q({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M304 48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zm0 416a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM48 304a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm464-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM142.9 437A48 48 0 1 0 75 369.1 48 48 0 1 0 142.9 437zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1 48 48 0 1 0 369.1 437z" }, child: [] }] })(a);
24
- }
25
- function wt(a) {
26
- return q({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z" }, child: [] }] })(a);
27
- }
28
- const Nt = ({ onChange: a, value: l, kind: j, isMultiple: n = !1 }) => {
29
- const { media: s } = G(), [i, x] = B(!1), u = Array.isArray(l) ? l : [], v = D(() => {
30
- let c = {};
31
- return j.forEach((N) => {
32
- c = {
33
- ...c,
34
- ...it[N]
35
- };
36
- }), c;
37
- }, [j]), o = (c) => {
38
- a == null || a(c);
39
- }, y = async (c) => {
40
- if ((c == null ? void 0 : c.length) === 0) {
41
- $("No file selected. Please select one file.");
42
- return;
43
- }
44
- x(!0);
45
- const N = new FormData();
46
- c == null || c.forEach((t) => {
47
- N.append("media", t);
48
- }), await (s == null ? void 0 : s.mediaBulkUpload(N).then((t) => {
49
- var z, A, f;
50
- (((z = t.content) == null ? void 0 : z.errors) ?? []).forEach(
51
- (m) => {
52
- var S, e, T;
53
- (e = (S = m.param) == null ? void 0 : S.split(".")) != null && e[1] && $(
54
- m.message,
55
- `Error uploading ${((T = c[m.param.split(".")[1]]) == null ? void 0 : T.name) ?? "File"}`
56
- );
57
- }
58
- );
59
- const d = (f = (A = t == null ? void 0 : t.content) == null ? void 0 : A.data) == null ? void 0 : f.map(
60
- (m) => {
61
- var S;
62
- return {
63
- id: m == null ? void 0 : m.id,
64
- kind: m == null ? void 0 : m.kind,
65
- location: m == null ? void 0 : m.location,
66
- mimetype: (S = m == null ? void 0 : m.metadata) == null ? void 0 : S.mimetype,
67
- srcset: m == null ? void 0 : m.srcset
68
- };
69
- }
70
- );
71
- let h = [];
72
- n ? h = [...Array.isArray(u) ? Array.from(u) : [], ...d] : h = Array.from(d), o(h), x(!1);
73
- }).catch((t) => {
74
- x(!1), k(t);
75
- }));
76
- }, g = D(() => n ? !1 : (u == null ? void 0 : u.length) > 0, [n, u]), { getRootProps: w, getInputProps: L, isDragActive: _ } = ht({
77
- onDrop: y,
78
- accept: v,
79
- multiple: n,
80
- maxSize: 25 * 1024 * 1024,
81
- disabled: i || g,
82
- onDropRejected: (c) => {
83
- c.forEach((N) => {
84
- N.errors.forEach((t) => {
85
- t.code === "file-too-large" && $(`${N.file.name} is bigger than 25MB`);
86
- });
87
- });
88
- }
89
- }), P = i || g;
90
- return /* @__PURE__ */ r.jsx(pt, { children: /* @__PURE__ */ r.jsx("div", { className: "min-h-[150px] w-full", children: /* @__PURE__ */ r.jsxs(
91
- "div",
92
- {
93
- className: I(
94
- "relative flex h-[14rem] w-full flex-col items-center justify-center gap-2 rounded-md border-[2px] border-dashed border-gray-400 p-4",
95
- P && "cursor-not-allowed opacity-80"
96
- ),
97
- ...w(),
98
- children: [
99
- i && /* @__PURE__ */ r.jsx("div", { className: "absolute inset-0 flex cursor-progress items-center justify-center bg-white bg-opacity-60", children: /* @__PURE__ */ r.jsx(W, {}) }),
100
- /* @__PURE__ */ r.jsx("p", { className: "my-2 text-xl", children: _ ? "Drop your files here..." : "Drag & Drop here to upload!" }),
101
- /* @__PURE__ */ r.jsx(
102
- "div",
103
- {
104
- className: I(
105
- "flex gap-4",
106
- P && "pointer-events-none"
107
- ),
108
- children: /* @__PURE__ */ r.jsx(jt, { label: "Upload", children: /* @__PURE__ */ r.jsxs(F, { size: "icon", className: "text-md", children: [
109
- /* @__PURE__ */ r.jsx("input", { ...L() }),
110
- /* @__PURE__ */ r.jsx(Z, { size: 20 })
111
- ] }) })
112
- }
113
- )
114
- ]
115
- }
116
- ) }) });
117
- }, ft = ({
118
- selectedFiles: a = [],
119
- onChange: l,
120
- isMultiple: j = !1,
121
- kind: n
122
- }) => {
123
- const { media: s } = G(), [i, x] = B(1), [u, v] = B([]), [o, y] = B(!1), g = st(null), [w, L] = B({
124
- searchText: "",
125
- currentPage: 1
126
- }), _ = yt(() => {
127
- y(!0), s == null || s.getAllMedia({
128
- page: w.currentPage,
129
- limit: 24,
130
- sort: {
131
- created_at: "desc"
132
- },
133
- search: w.searchText || void 0
134
- }).then((t) => {
135
- var d, h;
136
- x((h = (d = t == null ? void 0 : t.content) == null ? void 0 : d.meta) == null ? void 0 : h.pages), v((z) => {
137
- var A;
138
- return [...z, ...((A = t == null ? void 0 : t.content) == null ? void 0 : A.data) || []];
139
- });
140
- }).catch((t) => {
141
- console.error(t);
142
- }).finally(() => {
143
- y(!1);
144
- });
145
- }, 500);
146
- R(() => {
147
- _();
148
- }, [w]), R(() => {
149
- const t = g.current;
150
- if (t)
151
- return t.addEventListener("scroll", P), () => t.removeEventListener("scroll", P);
152
- }, [g, w.currentPage, i]);
153
- const P = () => {
154
- const t = g.current;
155
- t && t.scrollTop + t.clientHeight + 1 >= t.scrollHeight && c();
156
- }, c = () => {
157
- w.currentPage < i && L((t) => ({
158
- searchText: t.searchText,
159
- currentPage: t.currentPage + 1
160
- }));
161
- }, N = (t) => {
162
- if (!(n != null && n.includes(t == null ? void 0 : t.kind))) {
163
- $(`Only ${n == null ? void 0 : n.join(", ")}s are allowed.`);
164
- return;
165
- }
166
- j ? (a == null ? void 0 : a.findIndex((d) => (d == null ? void 0 : d.id) === (t == null ? void 0 : t.id))) >= 0 ? l == null || l(a == null ? void 0 : a.filter((d) => (d == null ? void 0 : d.id) !== (t == null ? void 0 : t.id))) : l == null || l([...a || [], t]) : l == null || l([t]);
167
- };
168
- return /* @__PURE__ */ r.jsxs("div", { className: "relative w-full rounded-md bg-white p-0", children: [
169
- /* @__PURE__ */ r.jsx("div", { className: "sticky top-0 z-50 w-full bg-white pb-2", children: /* @__PURE__ */ r.jsx(
170
- Q,
171
- {
172
- name: "searchText",
173
- type: "text",
174
- placeholder: "Search...",
175
- value: w.searchText,
176
- onChange: (t) => {
177
- y(!0), L({ currentPage: 1, searchText: t.target.value }), v([]);
178
- }
179
- }
180
- ) }),
181
- o && !u.length ? /* @__PURE__ */ r.jsx("div", { className: "flex h-full min-h-[28rem] w-full items-center justify-center", children: /* @__PURE__ */ r.jsx(W, {}) }) : /* @__PURE__ */ r.jsxs(
182
- "div",
183
- {
184
- ref: g,
185
- className: "grid h-[28rem] w-full gap-x-6 gap-y-4 overflow-y-auto overflow-x-hidden p-2 lg:grid-cols-4",
186
- children: [
187
- u == null ? void 0 : u.map((t, d) => {
188
- var A;
189
- const h = n == null ? void 0 : n.includes(t == null ? void 0 : t.kind), z = (a == null ? void 0 : a.findIndex((f) => (f == null ? void 0 : f.id) === (t == null ? void 0 : t.id))) >= 0;
190
- return /* @__PURE__ */ r.jsxs(
191
- "div",
192
- {
193
- className: I(
194
- "relative w-full",
195
- h ? "opacity-100" : "opacity-50"
196
- ),
197
- children: [
198
- /* @__PURE__ */ r.jsxs(
199
- "div",
200
- {
201
- className: I(
202
- "group flex h-[130px] w-full cursor-pointer items-center justify-center overflow-hidden rounded-md border-2",
203
- z ? "border-primary" : "border-gray-100"
204
- ),
205
- onClick: () => {
206
- var f;
207
- return N({
208
- id: t == null ? void 0 : t.id,
209
- location: t == null ? void 0 : t.location,
210
- mimetype: (f = t == null ? void 0 : t.metadata) == null ? void 0 : f.mimetype,
211
- kind: t == null ? void 0 : t.kind,
212
- srcset: t == null ? void 0 : t.srcset
213
- });
214
- },
215
- children: [
216
- /* @__PURE__ */ r.jsx(
217
- "div",
218
- {
219
- className: I(
220
- "absolute left-0 right-0 top-0 h-[42px] w-full rounded-md bg-[linear-gradient(0deg,_transparent_0%,_#000000_200%)] opacity-0",
221
- h ? "group-hover:opacity-100" : ""
222
- )
223
- }
224
- ),
225
- h && /* @__PURE__ */ r.jsx(
226
- bt,
227
- {
228
- name: "isFileIncluded",
229
- className: "absolute left-[10px] top-[10px]",
230
- checked: z
231
- }
232
- ),
233
- (t == null ? void 0 : t.kind) !== "image" ? /* @__PURE__ */ r.jsx(X, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ r.jsx(
234
- "img",
235
- {
236
- className: "h-full w-full object-contain",
237
- srcSet: (A = t == null ? void 0 : t.srcset) == null ? void 0 : A.path,
238
- src: t == null ? void 0 : t.location
239
- }
240
- )
241
- ]
242
- }
243
- ),
244
- /* @__PURE__ */ r.jsxs("div", { className: "my-[10px]", children: [
245
- /* @__PURE__ */ r.jsx("p", { className: "overflow-hidden text-ellipsis whitespace-nowrap text-sm", children: t == null ? void 0 : t.filename }),
246
- /* @__PURE__ */ r.jsx("p", { className: "text-xs text-gray-500", children: gt(t == null ? void 0 : t.metadata.size) })
247
- ] })
248
- ]
249
- },
250
- `media-layout-file-${d}`
251
- );
252
- }),
253
- o && /* @__PURE__ */ r.jsx("div", { className: "flex h-full w-full items-center justify-center", children: /* @__PURE__ */ r.jsx(W, {}) })
254
- ]
255
- }
256
- )
257
- ] });
258
- }, zt = ({
259
- selectedFiles: a = [],
260
- onChange: l,
261
- isMultiple: j = !1
262
- }) => {
263
- const [n, s] = B("");
264
- return R(() => {
265
- var i, x;
266
- !j && a[0] && !((i = a[0]) != null && i.location.includes("levo")) && s((x = a[0]) == null ? void 0 : x.location);
267
- }, [a]), /* @__PURE__ */ r.jsx("div", { className: "relative w-full rounded-md bg-white p-0", children: /* @__PURE__ */ r.jsxs("div", { className: "sticky top-0 z-50 flex w-full items-center gap-4 bg-white py-2 pl-0.5", children: [
268
- /* @__PURE__ */ r.jsx(
269
- Q,
270
- {
271
- name: "searchText",
272
- type: "text",
273
- value: n,
274
- placeholder: "Enter image URL...",
275
- onChange: (i) => s(i.target.value)
276
- }
277
- ),
278
- /* @__PURE__ */ r.jsx(
279
- F,
280
- {
281
- onClick: () => {
282
- l && fetch(n).then((i) => i == null ? void 0 : i.blob()).then((i) => {
283
- const x = i.type, u = dt(x);
284
- if (!u) return;
285
- const v = Array.isArray(a) ? Array.from(a) : [], o = j ? [
286
- ...v,
287
- {
288
- id: `external-${(/* @__PURE__ */ new Date()).getTime()}`,
289
- location: n,
290
- kind: u,
291
- mimetype: x
292
- }
293
- ] : [
294
- {
295
- id: `external-${(/* @__PURE__ */ new Date()).getTime()}`,
296
- location: n,
297
- kind: u,
298
- mimetype: x
299
- }
300
- ];
301
- l == null || l(o);
302
- }).catch((i) => {
303
- console.error("Error fetching file details:", i), $("Unable to fetch file details");
304
- });
305
- },
306
- disabled: !n,
307
- children: "Add"
308
- }
309
- )
310
- ] }) });
311
- }, At = ({ media: a, handleDeleteSelf: l }) => /* @__PURE__ */ r.jsxs(
312
- "div",
313
- {
314
- className: I("group relative flex w-full items-center border-b py-2"),
315
- children: [
316
- (a == null ? void 0 : a.kind) !== "image" ? /* @__PURE__ */ r.jsx(X, { size: 48, className: "text-muted-foreground/80" }) : /* @__PURE__ */ r.jsx("img", { className: "h-12 max-w-16 object-contain", src: a == null ? void 0 : a.location }),
317
- /* @__PURE__ */ r.jsx("p", { className: "ml-5 text-sm", children: (a == null ? void 0 : a.filename) ?? (a == null ? void 0 : a.location) }),
318
- /* @__PURE__ */ r.jsx(
319
- F,
320
- {
321
- className: "absolute right-4 top-4 z-10 opacity-0 group-hover:opacity-100",
322
- size: "icon-small",
323
- variant: "secondary",
324
- onClick: () => l(a),
325
- children: /* @__PURE__ */ r.jsx(at, { className: "text-primary", size: 20 })
326
- }
327
- )
328
- ]
329
- }
330
- ), Y = ({ aggregatedMedia: a, setAggregatedMedia: l, containerStyles: j, kind: n }) => {
331
- const s = D(
332
- () => Object.entries(a).flatMap(
333
- ([x, u]) => Array.isArray(u) ? u == null ? void 0 : u.map((v) => ({ ...v, identifier: x })) : []
334
- ),
335
- [a]
336
- ), i = (x) => {
337
- const { identifier: u, ...v } = x;
338
- l == null || l((o) => {
339
- var y;
340
- return {
341
- ...o,
342
- [u]: (y = o == null ? void 0 : o[u]) == null ? void 0 : y.filter((g) => g.id !== v.id)
343
- };
344
- });
345
- };
346
- return (s == null ? void 0 : s.length) === 0 ? null : /* @__PURE__ */ r.jsxs("div", { className: I("mt-4", j), children: [
347
- /* @__PURE__ */ r.jsx("p", { className: "mb-1 text-sm text-muted-foreground", children: (n == null ? void 0 : n.length) > 1 ? "All files" : `All ${n == null ? void 0 : n[0]}s` }),
348
- /* @__PURE__ */ r.jsx("div", { children: s == null ? void 0 : s.map((x) => /* @__PURE__ */ r.jsx(
349
- At,
350
- {
351
- media: x,
352
- handleDeleteSelf: i
353
- },
354
- x == null ? void 0 : x.id
355
- )) })
356
- ] });
357
- }, K = ({ count: a }) => a ? /* @__PURE__ */ r.jsx(
358
- "span",
359
- {
360
- className: I(
361
- "ml-1 grid flex-shrink-0 place-content-center rounded-full bg-gray-300 px-1.5 text-sm"
362
- ),
363
- children: a
364
- }
365
- ) : null, Tt = ({
366
- isOpen: a,
367
- onClose: l,
368
- onChange: j,
369
- value: n,
370
- kind: s,
371
- isMultiple: i = !1,
372
- isExternal: x
373
- }) => {
374
- var P, c, N;
375
- const [u, v] = B(
376
- "upload"
377
- ), [o, y] = B({
378
- upload: [],
379
- import: [],
380
- external_url: []
381
- }), g = () => {
382
- l();
383
- };
384
- R(() => {
385
- const t = n == null ? void 0 : n.filter((d) => !!d.location);
386
- y((d) => ({
387
- ...d,
388
- import: t
389
- }));
390
- }, [n]);
391
- const w = D(
392
- () => {
393
- var t;
394
- return ((t = Object.entries(o).flatMap(
395
- ([d, h]) => Array.isArray(h) ? Array.from(h) : []
396
- )) == null ? void 0 : t.length) ?? 0;
397
- },
398
- [o]
399
- ), L = () => {
400
- var d;
401
- const t = (d = Object.entries(o)) == null ? void 0 : d.flatMap(
402
- ([h, z]) => Array.isArray(z) ? z : []
403
- );
404
- t && (j == null || j(t)), g();
405
- }, _ = (t, d) => {
406
- if (i)
407
- y((h) => ({
408
- ...h,
409
- [d]: t
410
- }));
411
- else {
412
- const h = [
413
- ["upload", []],
414
- ["import", []],
415
- ["external_url", []]
416
- ];
417
- h.push([d, t]), y(Object == null ? void 0 : Object.fromEntries(h));
418
- }
419
- };
420
- return /* @__PURE__ */ r.jsxs(
421
- nt,
422
- {
423
- title: (s == null ? void 0 : s.length) > 1 ? "Upload file" : `Upload ${s == null ? void 0 : s[0]}`,
424
- isOpen: a,
425
- onClose: () => g(),
426
- contentClassName: "max-w-[60%]",
427
- children: [
428
- /* @__PURE__ */ r.jsxs(ct, { value: u, onValueChange: (t) => v(t), children: [
429
- /* @__PURE__ */ r.jsxs(lt, { children: [
430
- /* @__PURE__ */ r.jsxs(V, { value: "upload", className: "capitalize", children: [
431
- "Local ",
432
- (s == null ? void 0 : s.length) > 1 ? "File" : s == null ? void 0 : s[0],
433
- /* @__PURE__ */ r.jsx(K, { count: (P = o == null ? void 0 : o.upload) == null ? void 0 : P.length })
434
- ] }),
435
- !x && /* @__PURE__ */ r.jsxs(V, { value: "import", children: [
436
- "Import from Gallery",
437
- /* @__PURE__ */ r.jsx(K, { count: (c = o == null ? void 0 : o.import) == null ? void 0 : c.length })
438
- ] }),
439
- !x && s.includes("image") && /* @__PURE__ */ r.jsxs(V, { value: "external_url", children: [
440
- "External URL",
441
- /* @__PURE__ */ r.jsx(K, { count: (N = o == null ? void 0 : o.external_url) == null ? void 0 : N.length })
442
- ] })
443
- ] }),
444
- /* @__PURE__ */ r.jsx(H, { value: "upload", children: /* @__PURE__ */ r.jsxs("div", { className: "mt-5 max-h-[70vh] overflow-y-auto pr-1", children: [
445
- /* @__PURE__ */ r.jsx(
446
- Nt,
447
- {
448
- kind: s,
449
- value: o == null ? void 0 : o.upload,
450
- onChange: (t) => _(t, "upload"),
451
- isMultiple: i
452
- }
453
- ),
454
- /* @__PURE__ */ r.jsx(
455
- Y,
456
- {
457
- aggregatedMedia: o,
458
- setAggregatedMedia: y,
459
- kind: s
460
- }
461
- )
462
- ] }) }),
463
- /* @__PURE__ */ r.jsx(H, { value: "import", children: /* @__PURE__ */ r.jsx(
464
- ft,
465
- {
466
- selectedFiles: o == null ? void 0 : o.import,
467
- onChange: (t) => _(t, "import"),
468
- isMultiple: i,
469
- kind: s
470
- }
471
- ) }),
472
- /* @__PURE__ */ r.jsx(H, { value: "external_url", children: /* @__PURE__ */ r.jsxs("div", { className: "mt-5 max-h-[70vh] overflow-y-auto pr-1", children: [
473
- /* @__PURE__ */ r.jsx(
474
- zt,
475
- {
476
- onChange: (t) => _(t, "external_url"),
477
- selectedFiles: o == null ? void 0 : o.external_url,
478
- isMultiple: i,
479
- kind: s
480
- }
481
- ),
482
- /* @__PURE__ */ r.jsx(
483
- Y,
484
- {
485
- aggregatedMedia: o,
486
- setAggregatedMedia: y,
487
- kind: s
488
- }
489
- )
490
- ] }) })
491
- ] }),
492
- /* @__PURE__ */ r.jsx("div", { className: "mt-5 flex justify-end", children: /* @__PURE__ */ r.jsxs(F, { variant: "default", onClick: L, children: [
493
- "Save",
494
- " ",
495
- w === 1 ? `${w} file` : `${w} files`
496
- ] }) })
497
- ]
498
- }
499
- );
500
- }, Wt = ({
501
- field: a,
502
- kind: l = rt,
503
- isMultiple: j,
504
- isExternal: n = !1
505
- }) => {
506
- var S;
507
- const { media: s } = G(), { key: i = "", label: x = "", helper_text: u = "", readonly: v = !1 } = a, {
508
- field: { onBlur: o, onChange: y, value: g, disabled: w, ref: L },
509
- fieldState: _
510
- } = ot({
511
- name: i,
512
- rules: xt(a)
513
- }), P = D(() => {
514
- const e = [];
515
- return l.forEach((T) => {
516
- e.push(...J[T]);
517
- }), e;
518
- }, [l]), c = g ? Array.isArray(g) ? g : [g] : [], [N, t] = B(!1), d = () => t(!0), h = () => t(!1), [z, A] = B(!1), f = (e) => {
519
- y && (j === !0 ? y(e) : j === !1 && y(e == null ? void 0 : e[0]));
520
- }, m = async (e) => {
521
- const T = new FormData();
522
- let b = [...e];
523
- j || (b = e == null ? void 0 : e.slice(0, 1)), (b == null ? void 0 : b.length) > 0 && (b == null || b.forEach((p) => {
524
- var O;
525
- const E = p.name.split("."), U = (O = E[E.length - 1]) == null ? void 0 : O.toLowerCase();
526
- l == null || l.forEach((M) => {
527
- P.push(...J[M]);
528
- }), U && P.includes(U) && T.append("media", p);
529
- })), A(!0), await (s == null ? void 0 : s.mediaBulkUpload(T).then((p) => {
530
- var E, U, O, M;
531
- if (A(!1), (E = p == null ? void 0 : p.content) != null && E.data) {
532
- let C = [];
533
- if (j) {
534
- const tt = Array.isArray((U = p == null ? void 0 : p.content) == null ? void 0 : U.data) ? Array.from((O = p == null ? void 0 : p.content) == null ? void 0 : O.data) : [];
535
- C = [...Array.isArray(c) ? Array.from(c) : [], ...tt];
536
- } else
537
- C = Array.from(
538
- (M = p == null ? void 0 : p.content) == null ? void 0 : M.data
539
- );
540
- f(C);
541
- }
542
- }).catch((p) => {
543
- k(p);
544
- }).finally(() => {
545
- A(!1);
546
- }));
547
- };
548
- return /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
549
- N && /* @__PURE__ */ r.jsx(
550
- Tt,
551
- {
552
- isOpen: N,
553
- onClose: h,
554
- onChange: (e) => {
555
- f(e);
556
- },
557
- value: c,
558
- kind: [...l],
559
- isMultiple: j,
560
- isExternal: n
561
- }
562
- ),
563
- /* @__PURE__ */ r.jsxs(
564
- ut,
565
- {
566
- error: (S = _ == null ? void 0 : _.error) == null ? void 0 : S.message,
567
- helperText: u,
568
- readOnly: v,
569
- children: [
570
- x && /* @__PURE__ */ r.jsx(mt, { htmlFor: i, isRequired: a == null ? void 0 : a.required, children: x }),
571
- /* @__PURE__ */ r.jsxs("div", { className: "flex gap-2", ref: L, children: [
572
- /* @__PURE__ */ r.jsx(
573
- F,
574
- {
575
- size: "icon-small",
576
- variant: "outline",
577
- disabled: w,
578
- onClick: d,
579
- children: /* @__PURE__ */ r.jsx(Z, { size: 15 })
580
- }
581
- ),
582
- /* @__PURE__ */ r.jsxs("div", { className: "relative flex", children: [
583
- /* @__PURE__ */ r.jsx(
584
- Q,
585
- {
586
- name: "pasteUrl",
587
- placeholder: "Paste your files here...",
588
- onBlur: () => o(),
589
- onPaste: (e) => {
590
- const T = e.clipboardData.items, b = [];
591
- for (let p = 0; p < T.length; p++) {
592
- const E = T[p];
593
- if ((E == null ? void 0 : E.kind) === "file") {
594
- const U = E == null ? void 0 : E.getAsFile();
595
- U && b.push(U);
596
- }
597
- }
598
- (b == null ? void 0 : b.length) > 0 && m(b);
599
- },
600
- disabled: w,
601
- readOnly: v
602
- }
603
- ),
604
- z && /* @__PURE__ */ r.jsxs(
605
- "div",
606
- {
607
- role: "status",
608
- className: "absolute right-3 top-[50%] translate-y-[-50%]",
609
- children: [
610
- /* @__PURE__ */ r.jsx(vt, { className: "animate-spin" }),
611
- /* @__PURE__ */ r.jsx("span", { className: "sr-only", children: "Loading..." })
612
- ]
613
- }
614
- )
615
- ] })
616
- ] }),
617
- (c == null ? void 0 : c.length) > 0 && /* @__PURE__ */ r.jsx("div", { className: "mt-3 w-full", children: /* @__PURE__ */ r.jsx("div", { className: "grid w-full grid-cols-[repeat(auto-fill,_minmax(100px,_1fr))] gap-4", children: c == null ? void 0 : c.map((e, T) => e != null && e.location ? /* @__PURE__ */ r.jsxs(
618
- "div",
619
- {
620
- className: "group relative flex h-28 w-full items-center justify-center overflow-hidden rounded-xl border",
621
- children: [
622
- /* @__PURE__ */ r.jsx("div", { className: "absolute left-0 top-0 z-10 hidden h-full w-full items-center justify-center bg-black/20 group-hover:flex", children: /* @__PURE__ */ r.jsx("a", { href: e == null ? void 0 : e.location, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ r.jsx(et, { size: 24 }) }) }),
623
- (e == null ? void 0 : e.kind) !== "image" ? /* @__PURE__ */ r.jsx(X, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ r.jsx(
624
- "img",
625
- {
626
- className: "h-full w-full object-contain",
627
- src: e == null ? void 0 : e.location,
628
- alt: e == null ? void 0 : e.id
629
- }
630
- ),
631
- /* @__PURE__ */ r.jsx(
632
- "button",
633
- {
634
- className: "absolute right-1 top-1 z-10 rounded-full bg-white p-1 focus:outline-none",
635
- onClick: () => {
636
- f(
637
- c == null ? void 0 : c.filter((b) => (b == null ? void 0 : b.id) !== (e == null ? void 0 : e.id))
638
- );
639
- },
640
- type: "button",
641
- children: /* @__PURE__ */ r.jsx(wt, { className: "text-sm" })
642
- }
643
- )
644
- ]
645
- },
646
- `${e == null ? void 0 : e.location}-${T}`
647
- ) : null) }) })
648
- ]
649
- }
650
- )
651
- ] });
652
- };
653
- export {
654
- Wt as UploadWidget,
655
- Wt as default
656
- };
@@ -1,8 +0,0 @@
1
- const s = (o, t = 2) => {
2
- if (o === 0) return "0 B";
3
- const B = 1024, e = t < 0 ? 0 : t, n = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], r = Math.floor(Math.log(o) / Math.log(B));
4
- return `${Number.parseFloat((o / B ** r).toFixed(e))} ${n[r]}`;
5
- };
6
- export {
7
- s as b
8
- };
@@ -1,6 +0,0 @@
1
- import { clsx as o } from "clsx";
2
- import { twMerge as t } from "tailwind-merge";
3
- const m = (...r) => t(o(r));
4
- export {
5
- m as c
6
- };
@@ -1,10 +0,0 @@
1
- interface AltchaProps {
2
- onStateChange?: (ev: Event | CustomEvent) => void;
3
- challengeurl: string;
4
- verifyurl: string;
5
- }
6
- declare const Altcha: import('react').ForwardRefExoticComponent<AltchaProps & import('react').RefAttributes<{
7
- value: string | null;
8
- }>>;
9
- export default Altcha;
10
- //# sourceMappingURL=Altcha.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Altcha.d.ts","sourceRoot":"","sources":["../../../src/collection/components/Altcha.tsx"],"names":[],"mappings":"AASA,OAAO,QAAQ,CAAC;AAEhB,UAAU,WAAW;IACnB,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,GAAG,WAAW,KAAK,IAAI,CAAC;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,MAAM;WAAuB,MAAM,GAAG,IAAI;GA6C/C,CAAC;AAEF,eAAe,MAAM,CAAC"}