@levo-so/react 0.1.18 → 0.1.22

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 (47) hide show
  1. package/dist/{CheckboxWidget-Dp9IAz5Q.js → CheckboxWidget-nJO8XlGD.js} +1 -1
  2. package/dist/{CollectionFormBuilder-DpTePTDd.js → CollectionFormBuilder-DeGyMEXJ.js} +162 -166
  3. package/dist/{CurrencyWidget-BfnmQP9S.js → CurrencyWidget-BaMho9Pw.js} +1 -1
  4. package/dist/{DateTimeWidget-CqjC2iYx.js → DateTimeWidget-VCmX__cv.js} +1 -1
  5. package/dist/{DefaultFormVariant-CG7WUPV3.js → DefaultFormVariant-fTWKRYI_.js} +7 -7
  6. package/dist/{DropdownWidget-15oYGYnv.js → DropdownWidget-zAr9v_IY.js} +18 -18
  7. package/dist/{EmailWidget-mGeLzigY.js → EmailWidget-d3hSxbAS.js} +2 -2
  8. package/dist/{FormCaptcha-CbLdFHHY.js → FormCaptcha-YeElu90S.js} +16 -16
  9. package/dist/{GeocoderWidget-BXv8P8Y1.js → GeocoderWidget-BOqaJMm1.js} +2 -2
  10. package/dist/{MultiGeocoderWidget-eCOGwc1m.js → MultiGeocoderWidget-BTffSkJX.js} +3 -3
  11. package/dist/{MultiTextWidget-DpT1gLmr.js → MultiTextWidget-L2Eoz2Zv.js} +1 -1
  12. package/dist/{PhoneWidget-DisB02Ll.js → PhoneWidget-CnDhiovx.js} +1 -1
  13. package/dist/{RadioWidget-DjWXEZQx.js → RadioWidget-CG01ys9E.js} +2 -2
  14. package/dist/{RichTextWidget-BnqTjA-v.js → RichTextWidget-DCX1Vpw4.js} +2 -2
  15. package/dist/{Spinner-Bzu2xCFZ.js → Spinner-BnrQ9e_i.js} +58 -57
  16. package/dist/{StepsFormVariant-BYzPBT2c.js → StepsFormVariant-eW9O8rik.js} +22 -22
  17. package/dist/{SwitchWidget-DQ2OHpuP.js → SwitchWidget-CstjQ_nx.js} +1 -1
  18. package/dist/{TextWidget-qHY9_hkz.js → TextWidget-D4uLMuLS.js} +1 -1
  19. package/dist/{TextareaWidget-BP5mJR7j.js → TextareaWidget-CHgyJUuy.js} +1 -1
  20. package/dist/{ToggleCheckboxWidget-CzXZ9l_k.js → ToggleCheckboxWidget-Cfwlrjn7.js} +1 -1
  21. package/dist/{Tooltip-DEBnSqlo.js → Tooltip-DPzkfrjl.js} +15 -14
  22. package/dist/{URLWidget-BcZQVzW7.js → URLWidget-CZE68DgS.js} +2 -2
  23. package/dist/UploadWidget-Dstuk_qo.js +656 -0
  24. package/dist/audience/components/page.d.ts.map +1 -1
  25. package/dist/audience/index.js +1 -1
  26. package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -1
  27. package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts +11 -0
  28. package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts.map +1 -0
  29. package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -1
  30. package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
  31. package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
  32. package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -1
  33. package/dist/collection/index.js +1 -1
  34. package/dist/components/Dialog.d.ts +3 -1
  35. package/dist/components/Dialog.d.ts.map +1 -1
  36. package/dist/components/Sonner.d.ts +1 -1
  37. package/dist/components/Sonner.d.ts.map +1 -1
  38. package/dist/components/Tooltip.d.ts +1 -0
  39. package/dist/components/Tooltip.d.ts.map +1 -1
  40. package/dist/components/index.js +29 -28
  41. package/dist/index.css +1 -1
  42. package/dist/index.js +50 -49
  43. package/dist/membership/components/Popup.d.ts.map +1 -1
  44. package/dist/page-sR2SWtb2.js +189 -0
  45. package/package.json +4 -4
  46. package/dist/UploadWidget-BNdydN68.js +0 -616
  47. package/dist/page-BKyDlf0z.js +0 -212
@@ -0,0 +1,656 @@
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-BnrQ9e_i.js";
8
+ import { t as it, g as dt, z as xt, w as J, A as ut, B as mt } from "./CollectionFormBuilder-DeGyMEXJ.js";
9
+ import { u as G } from "./LevoProvider-BAZy7_tP.js";
10
+ import { e as k } from "./errorHandler-_34Yv8wA.js";
11
+ import { I as Q } from "./Input-2CvZ90f8.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-DPzkfrjl.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: "w-full min-h-[150px]", children: /* @__PURE__ */ r.jsxs(
91
+ "div",
92
+ {
93
+ className: I(
94
+ "flex items-center justify-center flex-col w-full rounded-md border-dashed border-[2px] border-gray-400 h-[14rem] p-4 gap-2 relative",
95
+ P && "cursor-not-allowed opacity-80 "
96
+ ),
97
+ ...w(),
98
+ children: [
99
+ i && /* @__PURE__ */ r.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-white bg-opacity-60 cursor-progress", children: /* @__PURE__ */ r.jsx(W, {}) }),
100
+ /* @__PURE__ */ r.jsx("p", { className: "text-xl my-2", 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: "bg-white p-0 rounded-md w-full relative", children: [
169
+ /* @__PURE__ */ r.jsx("div", { className: "pb-2 bg-white sticky top-0 z-50 w-full", 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: "w-full h-full min-h-[28rem] flex items-center justify-center", children: /* @__PURE__ */ r.jsx(W, {}) }) : /* @__PURE__ */ r.jsxs(
182
+ "div",
183
+ {
184
+ ref: g,
185
+ className: "w-full h-[28rem] overflow-y-auto overflow-x-hidden grid lg:grid-cols-4 gap-x-6 gap-y-4 p-2",
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
+ "cursor-pointer w-full group rounded-md overflow-hidden h-[130px] border-2 flex items-center justify-center",
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
+ "rounded-md opacity-0 absolute left-0 right-0 top-0 w-full h-[42px] bg-[linear-gradient(0deg,_transparent_0%,_#000000_200%)]",
221
+ h ? "group-hover:opacity-100" : ""
222
+ )
223
+ }
224
+ ),
225
+ h && /* @__PURE__ */ r.jsx(
226
+ bt,
227
+ {
228
+ name: "isFileIncluded",
229
+ className: "absolute top-[10px] left-[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: "w-full h-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: "text-sm whitespace-nowrap overflow-hidden text-ellipsis", 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: "w-full h-full flex 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: "bg-white p-0 rounded-md w-full relative", children: /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-4 py-2 pl-0.5 bg-white sticky top-0 z-50 w-full", 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 py-2 flex items-center relative w-full border-b"),
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: "text-sm ml-5", 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: "text-sm text-muted-foreground mb-1", 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
+ "rounded-full flex-shrink-0 text-sm px-1.5 grid place-content-center bg-gray-300 ml-1"
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: "flex justify-end mt-5", 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: "w-full grid gap-4 grid-cols-[repeat(auto-fill,_minmax(100px,_1fr))]", children: c == null ? void 0 : c.map((e, T) => e != null && e.location ? /* @__PURE__ */ r.jsxs(
618
+ "div",
619
+ {
620
+ className: "relative border overflow-hidden group w-full rounded-xl h-28 flex items-center justify-center",
621
+ children: [
622
+ /* @__PURE__ */ r.jsx("div", { className: "w-full bg-black/20 h-full absolute top-0 left-0 z-10 hidden group-hover:flex items-center justify-center", 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: "w-full h-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 z-10 top-1 right-1 bg-white p-1 rounded-full 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 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/audience/components/page.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAMnD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;CACvC,CA8HA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/audience/components/page.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAMnD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;CACvC,CA4FA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { L as e, a, b as n } from "../page-BKyDlf0z.js";
1
+ import { L as e, a, b as n } from "../page-sR2SWtb2.js";
2
2
  export {
3
3
  e as LevoInsightsBlock,
4
4
  a as LevoInsightsComponent,
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionWidgetM2M.d.ts","sourceRoot":"","sources":["../../../../../src/collection/components/widgets/collectionWidget/CollectionWidgetM2M.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA2BhD,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAwKnE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"CollectionWidgetM2M.d.ts","sourceRoot":"","sources":["../../../../../src/collection/components/widgets/collectionWidget/CollectionWidgetM2M.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA2BhD,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAmKnE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { IMediaObject, MediaKindList } from '@levo-so/core';
2
+ import { default as React } from 'react';
3
+ export type IAggregatedMedia = Record<"upload" | "import" | "external_url", IMediaObject[]>;
4
+ declare const CommonPreview: React.FC<{
5
+ aggregatedMedia: IAggregatedMedia;
6
+ setAggregatedMedia?: React.Dispatch<React.SetStateAction<IAggregatedMedia>>;
7
+ containerStyles?: string;
8
+ kind: (typeof MediaKindList)[number][];
9
+ }>;
10
+ export default CommonPreview;
11
+ //# sourceMappingURL=CommonPreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommonPreview.d.ts","sourceRoot":"","sources":["../../../../../src/collection/components/widgets/uploadWidget/CommonPreview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAkB,MAAM,OAAO,CAAC;AAOvC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACnC,QAAQ,GAAG,QAAQ,GAAG,cAAc,EACpC,YAAY,EAAE,CACf,CAAC;AAgCF,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5B,eAAe,EAAE,gBAAgB,CAAC;IAClC,kBAAkB,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;CACxC,CA0CA,CAAC;AAEF,eAAe,aAAa,CAAC"}