@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.
- package/dist/{CheckboxWidget-Dp9IAz5Q.js → CheckboxWidget-nJO8XlGD.js} +1 -1
- package/dist/{CollectionFormBuilder-DpTePTDd.js → CollectionFormBuilder-DeGyMEXJ.js} +162 -166
- package/dist/{CurrencyWidget-BfnmQP9S.js → CurrencyWidget-BaMho9Pw.js} +1 -1
- package/dist/{DateTimeWidget-CqjC2iYx.js → DateTimeWidget-VCmX__cv.js} +1 -1
- package/dist/{DefaultFormVariant-CG7WUPV3.js → DefaultFormVariant-fTWKRYI_.js} +7 -7
- package/dist/{DropdownWidget-15oYGYnv.js → DropdownWidget-zAr9v_IY.js} +18 -18
- package/dist/{EmailWidget-mGeLzigY.js → EmailWidget-d3hSxbAS.js} +2 -2
- package/dist/{FormCaptcha-CbLdFHHY.js → FormCaptcha-YeElu90S.js} +16 -16
- package/dist/{GeocoderWidget-BXv8P8Y1.js → GeocoderWidget-BOqaJMm1.js} +2 -2
- package/dist/{MultiGeocoderWidget-eCOGwc1m.js → MultiGeocoderWidget-BTffSkJX.js} +3 -3
- package/dist/{MultiTextWidget-DpT1gLmr.js → MultiTextWidget-L2Eoz2Zv.js} +1 -1
- package/dist/{PhoneWidget-DisB02Ll.js → PhoneWidget-CnDhiovx.js} +1 -1
- package/dist/{RadioWidget-DjWXEZQx.js → RadioWidget-CG01ys9E.js} +2 -2
- package/dist/{RichTextWidget-BnqTjA-v.js → RichTextWidget-DCX1Vpw4.js} +2 -2
- package/dist/{Spinner-Bzu2xCFZ.js → Spinner-BnrQ9e_i.js} +58 -57
- package/dist/{StepsFormVariant-BYzPBT2c.js → StepsFormVariant-eW9O8rik.js} +22 -22
- package/dist/{SwitchWidget-DQ2OHpuP.js → SwitchWidget-CstjQ_nx.js} +1 -1
- package/dist/{TextWidget-qHY9_hkz.js → TextWidget-D4uLMuLS.js} +1 -1
- package/dist/{TextareaWidget-BP5mJR7j.js → TextareaWidget-CHgyJUuy.js} +1 -1
- package/dist/{ToggleCheckboxWidget-CzXZ9l_k.js → ToggleCheckboxWidget-Cfwlrjn7.js} +1 -1
- package/dist/{Tooltip-DEBnSqlo.js → Tooltip-DPzkfrjl.js} +15 -14
- package/dist/{URLWidget-BcZQVzW7.js → URLWidget-CZE68DgS.js} +2 -2
- package/dist/UploadWidget-Dstuk_qo.js +656 -0
- package/dist/audience/components/page.d.ts.map +1 -1
- package/dist/audience/index.js +1 -1
- package/dist/collection/components/widgets/collectionWidget/CollectionWidgetM2M.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts +11 -0
- package/dist/collection/components/widgets/uploadWidget/CommonPreview.d.ts.map +1 -0
- package/dist/collection/components/widgets/uploadWidget/ExternalURL.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/FileUploadDropBox.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/FileUploadModal.d.ts.map +1 -1
- package/dist/collection/components/widgets/uploadWidget/UploadWidget.d.ts.map +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/components/Dialog.d.ts +3 -1
- package/dist/components/Dialog.d.ts.map +1 -1
- package/dist/components/Sonner.d.ts +1 -1
- package/dist/components/Sonner.d.ts.map +1 -1
- package/dist/components/Tooltip.d.ts +1 -0
- package/dist/components/Tooltip.d.ts.map +1 -1
- package/dist/components/index.js +29 -28
- package/dist/index.css +1 -1
- package/dist/index.js +50 -49
- package/dist/membership/components/Popup.d.ts.map +1 -1
- package/dist/page-sR2SWtb2.js +189 -0
- package/package.json +4 -4
- package/dist/UploadWidget-BNdydN68.js +0 -616
- package/dist/page-BKyDlf0z.js +0 -212
|
@@ -1,616 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { j as a } from "./jsx-runtime-B6kdoens.js";
|
|
3
|
-
import { MediaKindList as F } from "@levo-so/core";
|
|
4
|
-
import { X, Upload as O, ExternalLink as aa } from "lucide-react";
|
|
5
|
-
import { useMemo as J, useState as U, useRef as ra, useEffect as M } from "react";
|
|
6
|
-
import { useController as ta } from "react-hook-form";
|
|
7
|
-
import { G as H, B as P, S as G, j as sa, T as ea, k as oa, l as $, m as V } from "./Spinner-Bzu2xCFZ.js";
|
|
8
|
-
import { t as na, g as ca, z as la, w as C, A as da, B as ia } from "./CollectionFormBuilder-DpTePTDd.js";
|
|
9
|
-
import { u as k } from "./LevoProvider-BAZy7_tP.js";
|
|
10
|
-
import { e as Y } from "./errorHandler-_34Yv8wA.js";
|
|
11
|
-
import { I as K } from "./Input-2CvZ90f8.js";
|
|
12
|
-
import { useDropzone as xa } from "react-dropzone";
|
|
13
|
-
import { c as pa, S as Q } from "./Tooltip-DEBnSqlo.js";
|
|
14
|
-
import { e as D } from "./Sonner-t6JVKA0a.js";
|
|
15
|
-
import { c as S } from "./cn-C9QoOYNG.js";
|
|
16
|
-
import { useDebouncedCallback as ha } from "use-debounce";
|
|
17
|
-
import { b as ma } from "./byteToSize-BFKZSBu1.js";
|
|
18
|
-
import { C as ua } from "./Checbox-sq-atGlJ.js";
|
|
19
|
-
function R(s) {
|
|
20
|
-
return H({ 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: [] }] })(s);
|
|
21
|
-
}
|
|
22
|
-
function ga(s) {
|
|
23
|
-
return H({ 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: [] }] })(s);
|
|
24
|
-
}
|
|
25
|
-
function ja(s) {
|
|
26
|
-
return H({ 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: [] }] })(s);
|
|
27
|
-
}
|
|
28
|
-
const ba = ({ onChange: s, value: c, kind: g, isMultiple: p = !1 }) => {
|
|
29
|
-
const { media: l } = k(), i = Array.isArray(c) ? c : [], o = J(() => {
|
|
30
|
-
let t = {};
|
|
31
|
-
return g.forEach((j) => {
|
|
32
|
-
t = {
|
|
33
|
-
...t,
|
|
34
|
-
...na[j]
|
|
35
|
-
};
|
|
36
|
-
}), t;
|
|
37
|
-
}, [g]), d = (t) => {
|
|
38
|
-
s == null || s(t);
|
|
39
|
-
}, x = async (t) => {
|
|
40
|
-
if ((t == null ? void 0 : t.length) === 0) {
|
|
41
|
-
D("No file selected. Please select one file.");
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const j = new FormData();
|
|
45
|
-
t == null || t.forEach((m) => {
|
|
46
|
-
j.append("media", m);
|
|
47
|
-
}), await (l == null ? void 0 : l.mediaBulkUpload(j).then((m) => {
|
|
48
|
-
var b, I, r;
|
|
49
|
-
(((b = m.content) == null ? void 0 : b.errors) ?? []).forEach(
|
|
50
|
-
(n) => {
|
|
51
|
-
var v, A, w;
|
|
52
|
-
(A = (v = n.param) == null ? void 0 : v.split(".")) != null && A[1] && D(
|
|
53
|
-
n.message,
|
|
54
|
-
`Error uploading ${((w = t[n.param.split(".")[1]]) == null ? void 0 : w.name) ?? "File"}`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
const _ = (r = (I = m == null ? void 0 : m.content) == null ? void 0 : I.data) == null ? void 0 : r.map(
|
|
59
|
-
(n) => {
|
|
60
|
-
var v;
|
|
61
|
-
return {
|
|
62
|
-
id: n == null ? void 0 : n.id,
|
|
63
|
-
kind: n == null ? void 0 : n.kind,
|
|
64
|
-
location: n == null ? void 0 : n.location,
|
|
65
|
-
mimetype: (v = n == null ? void 0 : n.metadata) == null ? void 0 : v.mimetype,
|
|
66
|
-
srcset: n == null ? void 0 : n.srcset
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
d([...i, ..._]);
|
|
71
|
-
}).catch(Y));
|
|
72
|
-
}, { getRootProps: T, getInputProps: h, isDragActive: N } = xa({
|
|
73
|
-
onDrop: x,
|
|
74
|
-
accept: o,
|
|
75
|
-
multiple: p,
|
|
76
|
-
maxSize: 25 * 1024 * 1024,
|
|
77
|
-
onDropRejected: (t) => {
|
|
78
|
-
t.forEach((j) => {
|
|
79
|
-
j.errors.forEach((m) => {
|
|
80
|
-
m.code === "file-too-large" && D(`${j.file.name} is bigger than 25MB`);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
return /* @__PURE__ */ a.jsx(pa, { children: /* @__PURE__ */ a.jsx("div", { className: "w-full min-h-[150px]", children: (i == null ? void 0 : i.length) > 0 ? /* @__PURE__ */ a.jsxs("div", { className: "w-full grid gap-4 grid-cols-[repeat(auto-fit,_minmax(150px,_1fr))]", children: [
|
|
86
|
-
i == null ? void 0 : i.map((t) => {
|
|
87
|
-
var j, m;
|
|
88
|
-
return /* @__PURE__ */ a.jsxs(
|
|
89
|
-
"div",
|
|
90
|
-
{
|
|
91
|
-
className: "group relative w-full overflow-hidden h-auto max-[350px] rounded-md border border-gray-300",
|
|
92
|
-
style: {
|
|
93
|
-
background: "linear-gradient(to top, black -50%, transparent 45%)"
|
|
94
|
-
},
|
|
95
|
-
children: [
|
|
96
|
-
(t == null ? void 0 : t.kind) !== "image" ? /* @__PURE__ */ a.jsx("div", { className: "flex items-center h-[100px]", children: /* @__PURE__ */ a.jsx(
|
|
97
|
-
R,
|
|
98
|
-
{
|
|
99
|
-
size: "60px",
|
|
100
|
-
className: "text-gray-400 p-2"
|
|
101
|
-
}
|
|
102
|
-
) }) : /* @__PURE__ */ a.jsx(
|
|
103
|
-
"img",
|
|
104
|
-
{
|
|
105
|
-
className: "w-full h-full object-contain",
|
|
106
|
-
src: t == null ? void 0 : t.location
|
|
107
|
-
}
|
|
108
|
-
),
|
|
109
|
-
/* @__PURE__ */ a.jsx(
|
|
110
|
-
"div",
|
|
111
|
-
{
|
|
112
|
-
className: S(
|
|
113
|
-
"absolute left-0 right-0 bottom-0 h-16 bg-[linear-gradient(to-t,_rgba(0,_0,_10,_0.35),_transparent)]",
|
|
114
|
-
"group-hover:bg-[linear-gradient(to-t,_rgba(0,0,10,0.5),_transparent)] group-hover:h-[70%]"
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
|
-
/* @__PURE__ */ a.jsx("p", { className: "absolute left-4 bottom-2 text-base text-white", children: (m = t == null ? void 0 : t.location) == null ? void 0 : m.split("/")[((j = t == null ? void 0 : t.location) == null ? void 0 : j.split("/").length) - 1] }),
|
|
119
|
-
/* @__PURE__ */ a.jsx(
|
|
120
|
-
P,
|
|
121
|
-
{
|
|
122
|
-
className: "absolute right-4 top-4 z-10",
|
|
123
|
-
size: "icon",
|
|
124
|
-
variant: "secondary",
|
|
125
|
-
onClick: () => {
|
|
126
|
-
d(
|
|
127
|
-
i == null ? void 0 : i.filter((_) => (_ == null ? void 0 : _.id) !== (t == null ? void 0 : t.id))
|
|
128
|
-
);
|
|
129
|
-
},
|
|
130
|
-
children: /* @__PURE__ */ a.jsx(X, { className: "text-primary" })
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
]
|
|
134
|
-
},
|
|
135
|
-
t == null ? void 0 : t.id
|
|
136
|
-
);
|
|
137
|
-
}),
|
|
138
|
-
p && /* @__PURE__ */ a.jsxs(
|
|
139
|
-
"div",
|
|
140
|
-
{
|
|
141
|
-
className: "flex items-center justify-center flex-col w-full rounded-md border-dashed border-[2px] border-gray-400 h-[14rem] p-4 gap-2",
|
|
142
|
-
...T(),
|
|
143
|
-
children: [
|
|
144
|
-
/* @__PURE__ */ a.jsx("p", { className: "text-xl text-center my-2", children: N ? "Drop your files here..." : "Drag & Drop here to upload!" }),
|
|
145
|
-
/* @__PURE__ */ a.jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ a.jsx(Q, { label: "Upload a file", children: /* @__PURE__ */ a.jsxs(P, { size: "icon", className: "text-md", children: [
|
|
146
|
-
/* @__PURE__ */ a.jsx("input", { ...h() }),
|
|
147
|
-
/* @__PURE__ */ a.jsx(O, { size: 20 })
|
|
148
|
-
] }) }) })
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
] }) : /* @__PURE__ */ a.jsxs(
|
|
153
|
-
"div",
|
|
154
|
-
{
|
|
155
|
-
className: "flex items-center justify-center flex-col w-full rounded-md border-dashed border-[2px] border-gray-400 h-[14rem] p-4 gap-2",
|
|
156
|
-
...T(),
|
|
157
|
-
children: [
|
|
158
|
-
/* @__PURE__ */ a.jsx("p", { className: "text-xl my-2", children: N ? "Drop your files here..." : "Drag & Drop here to upload!" }),
|
|
159
|
-
/* @__PURE__ */ a.jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ a.jsx(Q, { label: "Upload a file", children: /* @__PURE__ */ a.jsxs(P, { size: "icon", className: "text-md", children: [
|
|
160
|
-
/* @__PURE__ */ a.jsx("input", { ...h() }),
|
|
161
|
-
/* @__PURE__ */ a.jsx(O, { size: 20 })
|
|
162
|
-
] }) }) })
|
|
163
|
-
]
|
|
164
|
-
}
|
|
165
|
-
) }) });
|
|
166
|
-
}, ya = ({
|
|
167
|
-
selectedFiles: s = [],
|
|
168
|
-
onChange: c,
|
|
169
|
-
isMultiple: g = !1,
|
|
170
|
-
kind: p
|
|
171
|
-
}) => {
|
|
172
|
-
const { media: l } = k(), [i, o] = U(1), [d, x] = U([]), [T, h] = U(!1), N = ra(null), [t, j] = U({
|
|
173
|
-
searchText: "",
|
|
174
|
-
currentPage: 1
|
|
175
|
-
}), m = ha(() => {
|
|
176
|
-
h(!0), l == null || l.getAllMedia({
|
|
177
|
-
page: t.currentPage,
|
|
178
|
-
limit: 24,
|
|
179
|
-
sort: {
|
|
180
|
-
created_at: "desc"
|
|
181
|
-
},
|
|
182
|
-
search: t.searchText || void 0
|
|
183
|
-
}).then((r) => {
|
|
184
|
-
var n, v;
|
|
185
|
-
o((v = (n = r == null ? void 0 : r.content) == null ? void 0 : n.meta) == null ? void 0 : v.pages), x((A) => {
|
|
186
|
-
var w;
|
|
187
|
-
return [...A, ...((w = r == null ? void 0 : r.content) == null ? void 0 : w.data) || []];
|
|
188
|
-
});
|
|
189
|
-
}).catch((r) => {
|
|
190
|
-
console.error(r);
|
|
191
|
-
}).finally(() => {
|
|
192
|
-
h(!1);
|
|
193
|
-
});
|
|
194
|
-
}, 500);
|
|
195
|
-
M(() => {
|
|
196
|
-
m();
|
|
197
|
-
}, [t]), M(() => {
|
|
198
|
-
const r = N.current;
|
|
199
|
-
if (r)
|
|
200
|
-
return r.addEventListener("scroll", _), () => r.removeEventListener("scroll", _);
|
|
201
|
-
}, [N, t.currentPage, i]);
|
|
202
|
-
const _ = () => {
|
|
203
|
-
const r = N.current;
|
|
204
|
-
r && r.scrollTop + r.clientHeight + 1 >= r.scrollHeight && b();
|
|
205
|
-
}, b = () => {
|
|
206
|
-
t.currentPage < i && j((r) => ({
|
|
207
|
-
searchText: r.searchText,
|
|
208
|
-
currentPage: r.currentPage + 1
|
|
209
|
-
}));
|
|
210
|
-
}, I = (r) => {
|
|
211
|
-
if (!(p != null && p.includes(r == null ? void 0 : r.kind))) {
|
|
212
|
-
D(`Only ${p == null ? void 0 : p.join(", ")}s are allowed.`);
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
g ? (s == null ? void 0 : s.findIndex((n) => (n == null ? void 0 : n.id) === (r == null ? void 0 : r.id))) >= 0 ? c == null || c(s == null ? void 0 : s.filter((n) => (n == null ? void 0 : n.id) !== (r == null ? void 0 : r.id))) : c == null || c([...s || [], r]) : c == null || c([r]);
|
|
216
|
-
};
|
|
217
|
-
return /* @__PURE__ */ a.jsxs("div", { className: "bg-white p-0 rounded-md w-full relative", children: [
|
|
218
|
-
/* @__PURE__ */ a.jsx("div", { className: "py-2 bg-white sticky top-0 z-50 w-full", children: /* @__PURE__ */ a.jsx(
|
|
219
|
-
K,
|
|
220
|
-
{
|
|
221
|
-
name: "searchText",
|
|
222
|
-
type: "text",
|
|
223
|
-
placeholder: "Search...",
|
|
224
|
-
value: t.searchText,
|
|
225
|
-
onChange: (r) => {
|
|
226
|
-
h(!0), j({ currentPage: 1, searchText: r.target.value }), x([]);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
) }),
|
|
230
|
-
T && !d.length ? /* @__PURE__ */ a.jsx("div", { className: "w-full h-full min-h-[30rem] flex items-center justify-center", children: /* @__PURE__ */ a.jsx(G, {}) }) : /* @__PURE__ */ a.jsxs(
|
|
231
|
-
"div",
|
|
232
|
-
{
|
|
233
|
-
ref: N,
|
|
234
|
-
className: "w-full h-[30rem] overflow-y-auto overflow-x-hidden grid lg:grid-cols-4 gap-6 p-2",
|
|
235
|
-
children: [
|
|
236
|
-
d == null ? void 0 : d.map((r, n) => {
|
|
237
|
-
var w;
|
|
238
|
-
const v = p == null ? void 0 : p.includes(r == null ? void 0 : r.kind), A = (s == null ? void 0 : s.findIndex((E) => (E == null ? void 0 : E.id) === (r == null ? void 0 : r.id))) >= 0;
|
|
239
|
-
return /* @__PURE__ */ a.jsxs(
|
|
240
|
-
"div",
|
|
241
|
-
{
|
|
242
|
-
className: S(
|
|
243
|
-
"relative w-full",
|
|
244
|
-
v ? "opacity-100" : "opacity-50"
|
|
245
|
-
),
|
|
246
|
-
children: [
|
|
247
|
-
/* @__PURE__ */ a.jsxs(
|
|
248
|
-
"div",
|
|
249
|
-
{
|
|
250
|
-
className: S(
|
|
251
|
-
"cursor-pointer w-full group rounded-md overflow-hidden h-[130px] border-2 flex items-center justify-center",
|
|
252
|
-
A ? "border-primary" : "border-gray-100"
|
|
253
|
-
),
|
|
254
|
-
onClick: () => {
|
|
255
|
-
var E;
|
|
256
|
-
return I({
|
|
257
|
-
id: r == null ? void 0 : r.id,
|
|
258
|
-
location: r == null ? void 0 : r.location,
|
|
259
|
-
mimetype: (E = r == null ? void 0 : r.metadata) == null ? void 0 : E.mimetype,
|
|
260
|
-
kind: r == null ? void 0 : r.kind,
|
|
261
|
-
srcset: r == null ? void 0 : r.srcset
|
|
262
|
-
});
|
|
263
|
-
},
|
|
264
|
-
children: [
|
|
265
|
-
/* @__PURE__ */ a.jsx(
|
|
266
|
-
"div",
|
|
267
|
-
{
|
|
268
|
-
className: S(
|
|
269
|
-
"rounded-md opacity-0 absolute left-0 right-0 top-0 w-full h-[42px] bg-[linear-gradient(0deg,_transparent_0%,_#000000_200%)]",
|
|
270
|
-
v ? "group-hover:opacity-100" : ""
|
|
271
|
-
)
|
|
272
|
-
}
|
|
273
|
-
),
|
|
274
|
-
v && /* @__PURE__ */ a.jsx(
|
|
275
|
-
ua,
|
|
276
|
-
{
|
|
277
|
-
name: "isFileIncluded",
|
|
278
|
-
className: "absolute top-[10px] left-[10px]",
|
|
279
|
-
checked: A
|
|
280
|
-
}
|
|
281
|
-
),
|
|
282
|
-
(r == null ? void 0 : r.kind) !== "image" ? /* @__PURE__ */ a.jsx(R, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ a.jsx(
|
|
283
|
-
"img",
|
|
284
|
-
{
|
|
285
|
-
className: "w-full h-full object-contain",
|
|
286
|
-
srcSet: (w = r == null ? void 0 : r.srcset) == null ? void 0 : w.path,
|
|
287
|
-
src: r == null ? void 0 : r.location
|
|
288
|
-
}
|
|
289
|
-
)
|
|
290
|
-
]
|
|
291
|
-
}
|
|
292
|
-
),
|
|
293
|
-
/* @__PURE__ */ a.jsxs("div", { className: "my-[10px]", children: [
|
|
294
|
-
/* @__PURE__ */ a.jsx("p", { className: "text-sm whitespace-nowrap overflow-hidden text-ellipsis", children: r == null ? void 0 : r.filename }),
|
|
295
|
-
/* @__PURE__ */ a.jsx("p", { className: "text-xs text-gray-500", children: ma(r == null ? void 0 : r.metadata.size) })
|
|
296
|
-
] })
|
|
297
|
-
]
|
|
298
|
-
},
|
|
299
|
-
`media-layout-file-${n}`
|
|
300
|
-
);
|
|
301
|
-
}),
|
|
302
|
-
T && /* @__PURE__ */ a.jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ a.jsx(G, {}) })
|
|
303
|
-
]
|
|
304
|
-
}
|
|
305
|
-
)
|
|
306
|
-
] });
|
|
307
|
-
}, va = ({
|
|
308
|
-
selectedFiles: s = [],
|
|
309
|
-
onChange: c,
|
|
310
|
-
isMultiple: g = !1,
|
|
311
|
-
kind: p
|
|
312
|
-
}) => {
|
|
313
|
-
const [l, i] = U("");
|
|
314
|
-
return M(() => {
|
|
315
|
-
var o, d;
|
|
316
|
-
!g && s[0] && !((o = s[0]) != null && o.location.includes("levo")) && i((d = s[0]) == null ? void 0 : d.location);
|
|
317
|
-
}, [s]), /* @__PURE__ */ a.jsxs("div", { className: "bg-white p-0 rounded-md w-full relative", children: [
|
|
318
|
-
/* @__PURE__ */ a.jsxs("div", { className: "flex gap-4 py-2 bg-white sticky top-0 z-50 w-full", children: [
|
|
319
|
-
/* @__PURE__ */ a.jsx(
|
|
320
|
-
K,
|
|
321
|
-
{
|
|
322
|
-
name: "searchText",
|
|
323
|
-
type: "text",
|
|
324
|
-
value: l,
|
|
325
|
-
placeholder: "Enter image URL...",
|
|
326
|
-
onChange: (o) => i(o.target.value)
|
|
327
|
-
}
|
|
328
|
-
),
|
|
329
|
-
/* @__PURE__ */ a.jsx(
|
|
330
|
-
P,
|
|
331
|
-
{
|
|
332
|
-
onClick: () => {
|
|
333
|
-
c && fetch(l).then((o) => o.blob()).then((o) => {
|
|
334
|
-
const d = o.type, x = ca(d);
|
|
335
|
-
x && c([
|
|
336
|
-
{
|
|
337
|
-
id: `external-${(/* @__PURE__ */ new Date()).getTime()}`,
|
|
338
|
-
location: l,
|
|
339
|
-
kind: x,
|
|
340
|
-
mimetype: d
|
|
341
|
-
}
|
|
342
|
-
]);
|
|
343
|
-
}).catch(
|
|
344
|
-
(o) => console.error("Error fetching file details:", o)
|
|
345
|
-
);
|
|
346
|
-
},
|
|
347
|
-
disabled: !l,
|
|
348
|
-
children: "Add"
|
|
349
|
-
}
|
|
350
|
-
)
|
|
351
|
-
] }),
|
|
352
|
-
/* @__PURE__ */ a.jsx("div", { className: "w-full grid gap-4 grid-cols-[repeat(auto-fit,_minmax(150px,_1fr))]", children: s == null ? void 0 : s.map((o) => {
|
|
353
|
-
var d;
|
|
354
|
-
return /* @__PURE__ */ a.jsxs(
|
|
355
|
-
"div",
|
|
356
|
-
{
|
|
357
|
-
className: "group relative w-full overflow-hidden h-auto max-h-[350px] rounded-md border border-gray-300",
|
|
358
|
-
style: {
|
|
359
|
-
background: "linear-gradient(to top, black -50%, transparent 45%)"
|
|
360
|
-
},
|
|
361
|
-
children: [
|
|
362
|
-
(o == null ? void 0 : o.kind) !== "image" ? /* @__PURE__ */ a.jsx("div", { className: "flex items-center h-[100px]", children: /* @__PURE__ */ a.jsx(R, { size: "60px", className: "text-gray-400 p-2" }) }) : /* @__PURE__ */ a.jsx(
|
|
363
|
-
"img",
|
|
364
|
-
{
|
|
365
|
-
className: "w-full h-full object-contain",
|
|
366
|
-
src: o == null ? void 0 : o.location
|
|
367
|
-
}
|
|
368
|
-
),
|
|
369
|
-
/* @__PURE__ */ a.jsx(
|
|
370
|
-
"div",
|
|
371
|
-
{
|
|
372
|
-
className: S(
|
|
373
|
-
"absolute left-0 right-0 bottom-0 h-16 bg-[linear-gradient(to-t,_rgba(0,_0,_10,_0.35),_transparent)]",
|
|
374
|
-
"group-hover:bg-[linear-gradient(to-t,_rgba(0,0,10,0.5),_transparent)] group-hover:h-[70%]"
|
|
375
|
-
)
|
|
376
|
-
}
|
|
377
|
-
),
|
|
378
|
-
/* @__PURE__ */ a.jsx("p", { className: "absolute left-4 bottom-2 text-base text-white", children: (d = o == null ? void 0 : o.location) == null ? void 0 : d.split("/").pop() }),
|
|
379
|
-
/* @__PURE__ */ a.jsx(
|
|
380
|
-
P,
|
|
381
|
-
{
|
|
382
|
-
className: "absolute right-4 top-4 z-10",
|
|
383
|
-
size: "icon",
|
|
384
|
-
variant: "secondary",
|
|
385
|
-
onClick: () => {
|
|
386
|
-
c == null || c(
|
|
387
|
-
s == null ? void 0 : s.filter((x) => (x == null ? void 0 : x.id) !== (o == null ? void 0 : o.id))
|
|
388
|
-
);
|
|
389
|
-
},
|
|
390
|
-
children: /* @__PURE__ */ a.jsx(X, { className: "text-primary" })
|
|
391
|
-
}
|
|
392
|
-
)
|
|
393
|
-
]
|
|
394
|
-
},
|
|
395
|
-
o == null ? void 0 : o.id
|
|
396
|
-
);
|
|
397
|
-
}) })
|
|
398
|
-
] });
|
|
399
|
-
}, Na = ({
|
|
400
|
-
isOpen: s,
|
|
401
|
-
onClose: c,
|
|
402
|
-
onChange: g,
|
|
403
|
-
value: p,
|
|
404
|
-
kind: l,
|
|
405
|
-
isMultiple: i = !1,
|
|
406
|
-
isExternal: o
|
|
407
|
-
}) => {
|
|
408
|
-
const [d, x] = U([]), T = () => {
|
|
409
|
-
c();
|
|
410
|
-
};
|
|
411
|
-
return M(() => {
|
|
412
|
-
x(p.filter((h) => !!h.location));
|
|
413
|
-
}, [p]), /* @__PURE__ */ a.jsxs(
|
|
414
|
-
sa,
|
|
415
|
-
{
|
|
416
|
-
title: (l == null ? void 0 : l.length) > 1 ? "Upload file" : `Upload ${l == null ? void 0 : l[0]}`,
|
|
417
|
-
isOpen: s,
|
|
418
|
-
onClose: () => T(),
|
|
419
|
-
contentClassName: "max-w-[60%]",
|
|
420
|
-
children: [
|
|
421
|
-
/* @__PURE__ */ a.jsxs(ea, { defaultValue: "upload", children: [
|
|
422
|
-
/* @__PURE__ */ a.jsxs(oa, { children: [
|
|
423
|
-
/* @__PURE__ */ a.jsx($, { value: "upload", children: "Local File" }),
|
|
424
|
-
!o && /* @__PURE__ */ a.jsx($, { value: "import", children: "Import from Gallery" }),
|
|
425
|
-
!o && l.includes("image") && /* @__PURE__ */ a.jsx($, { value: "external_url", children: "External URL" })
|
|
426
|
-
] }),
|
|
427
|
-
/* @__PURE__ */ a.jsx(V, { value: "upload", children: /* @__PURE__ */ a.jsx("div", { className: "mt-[20px] max-h-[70vh] overflow-y-auto", children: /* @__PURE__ */ a.jsx(
|
|
428
|
-
ba,
|
|
429
|
-
{
|
|
430
|
-
kind: l,
|
|
431
|
-
value: d,
|
|
432
|
-
onChange: (h) => x(h),
|
|
433
|
-
isMultiple: i
|
|
434
|
-
}
|
|
435
|
-
) }) }),
|
|
436
|
-
/* @__PURE__ */ a.jsx(V, { value: "import", children: /* @__PURE__ */ a.jsx(
|
|
437
|
-
ya,
|
|
438
|
-
{
|
|
439
|
-
onChange: (h) => x == null ? void 0 : x(h),
|
|
440
|
-
selectedFiles: d,
|
|
441
|
-
isMultiple: i,
|
|
442
|
-
kind: l
|
|
443
|
-
}
|
|
444
|
-
) }),
|
|
445
|
-
/* @__PURE__ */ a.jsx(V, { value: "external_url", children: /* @__PURE__ */ a.jsx(
|
|
446
|
-
va,
|
|
447
|
-
{
|
|
448
|
-
onChange: (h) => {
|
|
449
|
-
x == null || x(h);
|
|
450
|
-
},
|
|
451
|
-
selectedFiles: d,
|
|
452
|
-
isMultiple: i,
|
|
453
|
-
kind: l
|
|
454
|
-
}
|
|
455
|
-
) })
|
|
456
|
-
] }),
|
|
457
|
-
/* @__PURE__ */ a.jsx("div", { className: "flex justify-end mt-[20px]", children: /* @__PURE__ */ a.jsx(
|
|
458
|
-
P,
|
|
459
|
-
{
|
|
460
|
-
variant: "default",
|
|
461
|
-
onClick: () => {
|
|
462
|
-
d && (g == null || g(d)), T();
|
|
463
|
-
},
|
|
464
|
-
children: "Save"
|
|
465
|
-
}
|
|
466
|
-
) })
|
|
467
|
-
]
|
|
468
|
-
}
|
|
469
|
-
);
|
|
470
|
-
}, Oa = ({
|
|
471
|
-
field: s,
|
|
472
|
-
kind: c = F,
|
|
473
|
-
isMultiple: g,
|
|
474
|
-
isExternal: p = !1
|
|
475
|
-
}) => {
|
|
476
|
-
var W;
|
|
477
|
-
const { media: l } = k(), { key: i = "", label: o = "", helper_text: d = "", readonly: x = !1 } = s, {
|
|
478
|
-
field: { onBlur: T, onChange: h, value: N, disabled: t, ref: j },
|
|
479
|
-
fieldState: m
|
|
480
|
-
} = ta({
|
|
481
|
-
name: i,
|
|
482
|
-
rules: la(s)
|
|
483
|
-
}), _ = J(() => {
|
|
484
|
-
const e = [];
|
|
485
|
-
return c.forEach((L) => {
|
|
486
|
-
e.push(...C[L]);
|
|
487
|
-
}), e;
|
|
488
|
-
}, [c]), b = N ? Array.isArray(N) ? N : [N] : [], [I, r] = U(!1), n = () => r(!0), v = () => r(!1), [A, w] = U(!1), E = (e) => {
|
|
489
|
-
h && (g === !0 ? h(e) : g === !1 && h(e == null ? void 0 : e[0]));
|
|
490
|
-
}, Z = async (e) => {
|
|
491
|
-
const L = new FormData();
|
|
492
|
-
let u = [...e];
|
|
493
|
-
g || (u = e == null ? void 0 : e.slice(0, 1)), (u == null ? void 0 : u.length) > 0 && (u == null || u.forEach((y) => {
|
|
494
|
-
var q;
|
|
495
|
-
const z = y.name.split("."), B = (q = z[z.length - 1]) == null ? void 0 : q.toLowerCase();
|
|
496
|
-
c == null || c.forEach((f) => {
|
|
497
|
-
_.push(...C[f]);
|
|
498
|
-
}), B && _.includes(B) && L.append("media", y);
|
|
499
|
-
})), w(!0), await (l == null ? void 0 : l.mediaBulkUpload(L).then((y) => {
|
|
500
|
-
var z, B;
|
|
501
|
-
w(!1), (z = y == null ? void 0 : y.content) != null && z.data && E((B = y == null ? void 0 : y.content) == null ? void 0 : B.data);
|
|
502
|
-
}).catch((y) => {
|
|
503
|
-
Y(y);
|
|
504
|
-
}).finally(() => {
|
|
505
|
-
w(!1);
|
|
506
|
-
}));
|
|
507
|
-
};
|
|
508
|
-
return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
|
|
509
|
-
/* @__PURE__ */ a.jsx(
|
|
510
|
-
Na,
|
|
511
|
-
{
|
|
512
|
-
isOpen: I,
|
|
513
|
-
onClose: v,
|
|
514
|
-
onChange: (e) => {
|
|
515
|
-
E(e);
|
|
516
|
-
},
|
|
517
|
-
value: b,
|
|
518
|
-
kind: [...c],
|
|
519
|
-
isMultiple: g,
|
|
520
|
-
isExternal: p
|
|
521
|
-
}
|
|
522
|
-
),
|
|
523
|
-
/* @__PURE__ */ a.jsxs(
|
|
524
|
-
da,
|
|
525
|
-
{
|
|
526
|
-
error: (W = m == null ? void 0 : m.error) == null ? void 0 : W.message,
|
|
527
|
-
helperText: d,
|
|
528
|
-
readOnly: x,
|
|
529
|
-
children: [
|
|
530
|
-
o && /* @__PURE__ */ a.jsx(ia, { htmlFor: i, isRequired: s == null ? void 0 : s.required, children: o }),
|
|
531
|
-
/* @__PURE__ */ a.jsxs("div", { className: "flex gap-2", ref: j, children: [
|
|
532
|
-
/* @__PURE__ */ a.jsx(
|
|
533
|
-
P,
|
|
534
|
-
{
|
|
535
|
-
size: "icon-small",
|
|
536
|
-
variant: "outline",
|
|
537
|
-
disabled: t,
|
|
538
|
-
onClick: n,
|
|
539
|
-
children: /* @__PURE__ */ a.jsx(O, { size: 15 })
|
|
540
|
-
}
|
|
541
|
-
),
|
|
542
|
-
/* @__PURE__ */ a.jsxs("div", { className: "relative flex", children: [
|
|
543
|
-
/* @__PURE__ */ a.jsx(
|
|
544
|
-
K,
|
|
545
|
-
{
|
|
546
|
-
name: "pasteUrl",
|
|
547
|
-
placeholder: "Paste your files here...",
|
|
548
|
-
onBlur: () => T(),
|
|
549
|
-
onPaste: (e) => {
|
|
550
|
-
const L = e.clipboardData.items, u = [];
|
|
551
|
-
for (let y = 0; y < L.length; y++) {
|
|
552
|
-
const z = L[y];
|
|
553
|
-
if ((z == null ? void 0 : z.kind) === "file") {
|
|
554
|
-
const B = z == null ? void 0 : z.getAsFile();
|
|
555
|
-
B && u.push(B);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
(u == null ? void 0 : u.length) > 0 && Z(u);
|
|
559
|
-
},
|
|
560
|
-
disabled: t,
|
|
561
|
-
readOnly: x
|
|
562
|
-
}
|
|
563
|
-
),
|
|
564
|
-
A && /* @__PURE__ */ a.jsxs(
|
|
565
|
-
"div",
|
|
566
|
-
{
|
|
567
|
-
role: "status",
|
|
568
|
-
className: "absolute right-3 top-[50%] translate-y-[-50%]",
|
|
569
|
-
children: [
|
|
570
|
-
/* @__PURE__ */ a.jsx(ga, {}),
|
|
571
|
-
/* @__PURE__ */ a.jsx("span", { className: "sr-only", children: "Loading..." })
|
|
572
|
-
]
|
|
573
|
-
}
|
|
574
|
-
)
|
|
575
|
-
] })
|
|
576
|
-
] }),
|
|
577
|
-
(b == null ? void 0 : b.length) > 0 && /* @__PURE__ */ a.jsx("div", { className: "mt-3 w-full", children: /* @__PURE__ */ a.jsx("div", { className: "w-full grid gap-4 grid-cols-[repeat(auto-fill,_minmax(100px,_1fr))]", children: b == null ? void 0 : b.map((e, L) => e != null && e.location ? /* @__PURE__ */ a.jsxs(
|
|
578
|
-
"div",
|
|
579
|
-
{
|
|
580
|
-
className: "relative border overflow-hidden group w-full rounded-xl h-28 flex items-center justify-center",
|
|
581
|
-
children: [
|
|
582
|
-
/* @__PURE__ */ a.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__ */ a.jsx("a", { href: e == null ? void 0 : e.location, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ a.jsx(aa, { size: 24 }) }) }),
|
|
583
|
-
(e == null ? void 0 : e.kind) !== "image" ? /* @__PURE__ */ a.jsx(R, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ a.jsx(
|
|
584
|
-
"img",
|
|
585
|
-
{
|
|
586
|
-
className: "w-full h-full object-contain",
|
|
587
|
-
src: e == null ? void 0 : e.location,
|
|
588
|
-
alt: e == null ? void 0 : e.id
|
|
589
|
-
}
|
|
590
|
-
),
|
|
591
|
-
/* @__PURE__ */ a.jsx(
|
|
592
|
-
"button",
|
|
593
|
-
{
|
|
594
|
-
className: "absolute z-10 top-1 right-1 bg-white p-1 rounded-full focus:outline-none",
|
|
595
|
-
onClick: () => {
|
|
596
|
-
E(
|
|
597
|
-
b == null ? void 0 : b.filter((u) => (u == null ? void 0 : u.id) !== (e == null ? void 0 : e.id))
|
|
598
|
-
);
|
|
599
|
-
},
|
|
600
|
-
type: "button",
|
|
601
|
-
children: /* @__PURE__ */ a.jsx(ja, { className: "text-sm" })
|
|
602
|
-
}
|
|
603
|
-
)
|
|
604
|
-
]
|
|
605
|
-
},
|
|
606
|
-
`${e == null ? void 0 : e.location}-${L}`
|
|
607
|
-
) : null) }) })
|
|
608
|
-
]
|
|
609
|
-
}
|
|
610
|
-
)
|
|
611
|
-
] });
|
|
612
|
-
};
|
|
613
|
-
export {
|
|
614
|
-
Oa as UploadWidget,
|
|
615
|
-
Oa as default
|
|
616
|
-
};
|