@levo-so/react 0.1.2 → 0.1.5
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-BV2nPDdB.js → CheckboxWidget-Bnx-S2j2.js} +7 -7
- package/dist/{CollectionFormBuilder-uvr15jvu.js → CollectionFormBuilder-B_dXpvPN.js} +87 -88
- package/dist/{CurrencyWidget-VzBWDdzQ.js → CurrencyWidget-6Ov8DZpo.js} +6 -6
- package/dist/{DateTimeWidget-QmZXdxzS.js → DateTimeWidget-DI98zHMn.js} +7 -7
- package/dist/{DefaultFormVariant-DyyCGXvB.js → DefaultFormVariant-Bxbh1yc0.js} +22 -22
- package/dist/{DropdownWidget-CxWQF6r3.js → DropdownWidget-DrMkD9vK.js} +2 -2
- package/dist/{EmailWidget-BxxtgUGU.js → EmailWidget-DHjXwVCL.js} +2 -2
- package/dist/{GeocoderWidget-lh46EUHn.js → GeocoderWidget-D8GsLWkV.js} +83 -82
- package/dist/LevoProvider-Cp0CKrgY.js +212 -0
- package/dist/{MultiGeocoderWidget-C84ZYxpR.js → MultiGeocoderWidget-WzlKESyZ.js} +8 -8
- package/dist/{PhoneWidget-_-cBcZ_D.js → PhoneWidget-DQSo_DPX.js} +1 -1
- package/dist/{RadioWidget-BJ1qwTRO.js → RadioWidget-C8sTnz9B.js} +3 -3
- package/dist/{RichTextWidget-CC6uShje.js → RichTextWidget-DOMiJ9pX.js} +2 -2
- package/dist/{Spinner-CuUosd-S.js → Spinner-DzGH5rKe.js} +49 -49
- package/dist/{StepsFormVariant-BxANsU4Z.js → StepsFormVariant-CzS2wbMD.js} +8 -8
- package/dist/{SwitchWidget-CbCYweyx.js → SwitchWidget-CBottoNO.js} +1 -1
- package/dist/TextWidget-Dg-ZYJI2.js +33 -0
- package/dist/{TextareaWidget-Dqt4CVV-.js → TextareaWidget-wsUSnO28.js} +6 -6
- package/dist/{ToggleCheckboxWidget-D8CxllEX.js → ToggleCheckboxWidget-IeHYCie0.js} +1 -1
- package/dist/{URLWidget-C07DCMOd.js → URLWidget-BsIEpzV3.js} +2 -2
- package/dist/{UploadWidget-DoY_CPLy.js → UploadWidget-BJPmoAW-.js} +170 -168
- package/dist/audience/components/component.d.ts.map +1 -1
- package/dist/audience/index.js +1 -1
- package/dist/collection/components/CollectionFormBuilder.d.ts.map +1 -1
- package/dist/collection/components/renderer/RenderArrayWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts +1 -1
- package/dist/collection/components/widgets/dateTimeWidget/DateTimeWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/multiGeocoderWidget/MultiGeocoderWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/phoneWidget/PhoneWidget.d.ts.map +1 -1
- package/dist/collection/components/widgets/textWidget/TextWidget.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/collection/lib/FormBuilder.d.ts.map +1 -1
- package/dist/collection/lib/hooks/useLevoForm.d.ts.map +1 -1
- package/dist/collection/utils/formHelpers.d.ts +1 -0
- package/dist/collection/utils/formHelpers.d.ts.map +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/{index-wTf_TtOG.js → index-BFJ48R-4.js} +1 -1
- package/dist/index.css +1 -0
- package/dist/index.js +5 -5
- package/dist/libs.css +1 -0
- package/dist/libs.d.ts +1 -0
- package/dist/membership/components/OAuth/Button.d.ts +1 -1
- package/dist/membership/components/OAuth/Button.d.ts.map +1 -1
- package/dist/membership/components/OAuth/Container.d.ts +1 -1
- package/dist/membership/components/OAuth/Container.d.ts.map +1 -1
- package/dist/membership/index.js +1 -1
- package/dist/page-YRcNFGqi.js +205 -0
- package/dist/providers/LevoProvider.d.ts +7 -7
- package/dist/providers/LevoProvider.d.ts.map +1 -1
- package/dist/{useLevoForm-B4Dmf73H.js → useLevoForm-HS_d5OoW.js} +7 -7
- package/package.json +72 -71
- package/dist/LevoProvider-DNbYyEaf.js +0 -21
- package/dist/TextWidget-CfEeuyFV.js +0 -33
- package/dist/page-CxaKoH22.js +0 -205
- package/dist/style.css +0 -1
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { j as
|
|
2
|
+
import { j as a } from "./jsx-runtime-B6kdoens.js";
|
|
3
3
|
import { createSrcSet as f, MediaKindList as k } from "@levo-so/core";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
4
|
+
import { X as rr, Upload as D, ExternalLink as ar } from "lucide-react";
|
|
5
|
+
import { useMemo as Q, useState as S, useRef as tr, useEffect as M } from "react";
|
|
6
|
+
import { useController as sr } from "react-hook-form";
|
|
7
|
+
import { G as R, B as P, S as W, T as er, a as or, c as q, d as G } from "./Spinner-DzGH5rKe.js";
|
|
8
|
+
import { m as cr, g as K } from "./fileUploadPresets-2raQmHT0.js";
|
|
9
|
+
import { u as V } from "./LevoProvider-Cp0CKrgY.js";
|
|
10
|
+
import { e as X } from "./errorHandler-BJcFS2qV.js";
|
|
11
|
+
import { h as nr, j as lr, k as dr } from "./CollectionFormBuilder-B_dXpvPN.js";
|
|
12
|
+
import { I as J } from "./Input-2CvZ90f8.js";
|
|
13
|
+
import { l as ir, S as F, i as xr } from "./Tooltip-CI4i4mYr.js";
|
|
14
|
+
import { useDropzone as pr } from "react-dropzone";
|
|
13
15
|
import { e as O } from "./Sonner-t6JVKA0a.js";
|
|
14
|
-
import { c as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { C as ma } from "./Checbox-sq-atGlJ.js";
|
|
19
|
-
import { b as ha } from "./byteToSize-BFKZSBu1.js";
|
|
16
|
+
import { c as I } from "./cn-C9QoOYNG.js";
|
|
17
|
+
import { useDebouncedCallback as hr } from "use-debounce";
|
|
18
|
+
import { b as mr } from "./byteToSize-BFKZSBu1.js";
|
|
19
|
+
import { C as ur } from "./Checbox-sq-atGlJ.js";
|
|
20
20
|
function $(e) {
|
|
21
21
|
return R({ 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: [] }] })(e);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function gr(e) {
|
|
24
24
|
return R({ 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: [] }] })(e);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function jr(e) {
|
|
27
27
|
return R({ 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: [] }] })(e);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const yr = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
30
30
|
const { media: c } = V(), n = Array.isArray(o) ? o : [], _ = Q(() => {
|
|
31
31
|
let t = {};
|
|
32
|
-
return j.forEach((
|
|
32
|
+
return j.forEach((h) => {
|
|
33
33
|
t = {
|
|
34
34
|
...t,
|
|
35
|
-
...
|
|
35
|
+
...cr[h]
|
|
36
36
|
};
|
|
37
37
|
}), t;
|
|
38
38
|
}, [j]), g = (t) => {
|
|
@@ -42,42 +42,42 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
42
42
|
O("No file selected. Please select one file.");
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const h = new FormData();
|
|
46
46
|
t == null || t.forEach((p) => {
|
|
47
|
-
|
|
48
|
-
}), await (c == null ? void 0 : c.mediaBulkUpload(
|
|
49
|
-
var
|
|
50
|
-
const w = (E = (
|
|
51
|
-
(
|
|
47
|
+
h.append("media", p);
|
|
48
|
+
}), await (c == null ? void 0 : c.mediaBulkUpload(h).then((p) => {
|
|
49
|
+
var m, E;
|
|
50
|
+
const w = (E = (m = p == null ? void 0 : p.content) == null ? void 0 : m.data) == null ? void 0 : E.map(
|
|
51
|
+
(r) => {
|
|
52
52
|
var l;
|
|
53
53
|
return {
|
|
54
|
-
id:
|
|
55
|
-
kind:
|
|
56
|
-
location:
|
|
57
|
-
mimetype: (l =
|
|
58
|
-
srcset:
|
|
54
|
+
id: r == null ? void 0 : r.id,
|
|
55
|
+
kind: r == null ? void 0 : r.kind,
|
|
56
|
+
location: r == null ? void 0 : r.location,
|
|
57
|
+
mimetype: (l = r == null ? void 0 : r.metadata) == null ? void 0 : l.mimetype,
|
|
58
|
+
srcset: r == null ? void 0 : r.srcset
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
);
|
|
62
62
|
g([...n, ...w]);
|
|
63
|
-
}).catch(
|
|
64
|
-
}, { getRootProps: z, getInputProps:
|
|
63
|
+
}).catch(X));
|
|
64
|
+
}, { getRootProps: z, getInputProps: x, isDragActive: v } = pr({
|
|
65
65
|
onDrop: y,
|
|
66
66
|
accept: _,
|
|
67
67
|
multiple: d,
|
|
68
68
|
maxSize: 25 * 1024 * 1024,
|
|
69
69
|
onDropRejected: (t) => {
|
|
70
|
-
t.forEach((
|
|
71
|
-
|
|
72
|
-
p.code === "file-too-large" && O(`${
|
|
70
|
+
t.forEach((h) => {
|
|
71
|
+
h.errors.forEach((p) => {
|
|
72
|
+
p.code === "file-too-large" && O(`${h.file.name} is bigger than 25MB`);
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
-
return /* @__PURE__ */
|
|
77
|
+
return /* @__PURE__ */ a.jsx(ir, { children: /* @__PURE__ */ a.jsx("div", { className: "w-full min-h-[150px]", children: (n == null ? void 0 : n.length) > 0 ? /* @__PURE__ */ a.jsxs("div", { className: "w-full grid gap-4 grid-cols-[repeat(auto-fit,_minmax(150px,_1fr))]", children: [
|
|
78
78
|
n == null ? void 0 : n.map((t) => {
|
|
79
|
-
var
|
|
80
|
-
return /* @__PURE__ */
|
|
79
|
+
var h, p;
|
|
80
|
+
return /* @__PURE__ */ a.jsxs(
|
|
81
81
|
"div",
|
|
82
82
|
{
|
|
83
83
|
className: "group relative w-full overflow-hidden h-auto max-[350px] rounded-md border border-gray-300",
|
|
@@ -85,31 +85,31 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
85
85
|
background: "linear-gradient(to top, black -50%, transparent 45%)"
|
|
86
86
|
},
|
|
87
87
|
children: [
|
|
88
|
-
(t == null ? void 0 : t.kind) !== "image" ? /* @__PURE__ */
|
|
88
|
+
(t == null ? void 0 : t.kind) !== "image" ? /* @__PURE__ */ a.jsx("div", { className: "flex items-center h-[100px]", children: /* @__PURE__ */ a.jsx(
|
|
89
89
|
$,
|
|
90
90
|
{
|
|
91
91
|
size: "60px",
|
|
92
92
|
className: "text-gray-400 p-2"
|
|
93
93
|
}
|
|
94
|
-
) }) : /* @__PURE__ */
|
|
94
|
+
) }) : /* @__PURE__ */ a.jsx(
|
|
95
95
|
"img",
|
|
96
96
|
{
|
|
97
97
|
className: "w-full h-full object-contain",
|
|
98
98
|
src: t == null ? void 0 : t.location
|
|
99
99
|
}
|
|
100
100
|
),
|
|
101
|
-
/* @__PURE__ */
|
|
101
|
+
/* @__PURE__ */ a.jsx(
|
|
102
102
|
"div",
|
|
103
103
|
{
|
|
104
|
-
className:
|
|
104
|
+
className: I(
|
|
105
105
|
"absolute left-0 right-0 bottom-0 h-16 bg-[linear-gradient(to-t,_rgba(0,_0,_10,_0.35),_transparent)]",
|
|
106
106
|
"group-hover:bg-[linear-gradient(to-t,_rgba(0,0,10,0.5),_transparent)] group-hover:h-[70%]"
|
|
107
107
|
)
|
|
108
108
|
}
|
|
109
109
|
),
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
|
|
110
|
+
/* @__PURE__ */ a.jsx("p", { className: "absolute left-4 bottom-2 text-base text-white", children: (p = t == null ? void 0 : t.location) == null ? void 0 : p.split("/")[((h = t == null ? void 0 : t.location) == null ? void 0 : h.split("/").length) - 1] }),
|
|
111
|
+
/* @__PURE__ */ a.jsx(
|
|
112
|
+
P,
|
|
113
113
|
{
|
|
114
114
|
className: "absolute right-4 top-4 z-10",
|
|
115
115
|
size: "icon",
|
|
@@ -119,7 +119,7 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
119
119
|
n == null ? void 0 : n.filter((w) => (w == null ? void 0 : w.id) !== (t == null ? void 0 : t.id))
|
|
120
120
|
);
|
|
121
121
|
},
|
|
122
|
-
children: /* @__PURE__ */
|
|
122
|
+
children: /* @__PURE__ */ a.jsx(rr, { className: "text-primary" })
|
|
123
123
|
}
|
|
124
124
|
)
|
|
125
125
|
]
|
|
@@ -127,175 +127,175 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
127
127
|
t == null ? void 0 : t.id
|
|
128
128
|
);
|
|
129
129
|
}),
|
|
130
|
-
d && /* @__PURE__ */
|
|
130
|
+
d && /* @__PURE__ */ a.jsxs(
|
|
131
131
|
"div",
|
|
132
132
|
{
|
|
133
133
|
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",
|
|
134
134
|
...z(),
|
|
135
135
|
children: [
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-xl text-center my-2", children: v ? "Drop your files here..." : "Drag & Drop here to upload!" }),
|
|
137
|
+
/* @__PURE__ */ a.jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ a.jsx(F, { label: "Upload a file", children: /* @__PURE__ */ a.jsxs(P, { size: "icon", className: "text-md", children: [
|
|
138
|
+
/* @__PURE__ */ a.jsx("input", { ...x() }),
|
|
139
|
+
/* @__PURE__ */ a.jsx(D, { size: 20 })
|
|
140
140
|
] }) }) })
|
|
141
141
|
]
|
|
142
142
|
}
|
|
143
143
|
)
|
|
144
|
-
] }) : /* @__PURE__ */
|
|
144
|
+
] }) : /* @__PURE__ */ a.jsxs(
|
|
145
145
|
"div",
|
|
146
146
|
{
|
|
147
147
|
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",
|
|
148
148
|
...z(),
|
|
149
149
|
children: [
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-xl my-2", children: v ? "Drop your files here..." : "Drag & Drop here to upload!" }),
|
|
151
|
+
/* @__PURE__ */ a.jsx("div", { className: "flex gap-4", children: /* @__PURE__ */ a.jsx(F, { label: "Upload a file", children: /* @__PURE__ */ a.jsxs(P, { size: "icon", className: "text-md", children: [
|
|
152
|
+
/* @__PURE__ */ a.jsx("input", { ...x() }),
|
|
153
|
+
/* @__PURE__ */ a.jsx(D, { size: 20 })
|
|
154
154
|
] }) }) })
|
|
155
155
|
]
|
|
156
156
|
}
|
|
157
157
|
) }) });
|
|
158
|
-
},
|
|
158
|
+
}, br = ({
|
|
159
159
|
selectedFiles: e = [],
|
|
160
160
|
onChange: o,
|
|
161
161
|
isMultiple: j = !1,
|
|
162
162
|
kind: d
|
|
163
163
|
}) => {
|
|
164
|
-
const { media: c } = V(), [n, _] = S(1), [g, y] = S([]), [z,
|
|
164
|
+
const { media: c } = V(), [n, _] = S(1), [g, y] = S([]), [z, x] = S(!1), v = tr(null), [t, h] = S({
|
|
165
165
|
searchText: "",
|
|
166
166
|
currentPage: 1
|
|
167
|
-
}), p =
|
|
168
|
-
|
|
167
|
+
}), p = hr(() => {
|
|
168
|
+
x(!0), c == null || c.getAllMedia({
|
|
169
169
|
page: t.currentPage,
|
|
170
170
|
limit: 24,
|
|
171
171
|
sort: {
|
|
172
172
|
created_at: "desc"
|
|
173
173
|
},
|
|
174
174
|
search: t.searchText || void 0
|
|
175
|
-
}).then((
|
|
175
|
+
}).then((r) => {
|
|
176
176
|
var l, A;
|
|
177
|
-
_((A = (l =
|
|
177
|
+
_((A = (l = r == null ? void 0 : r.content) == null ? void 0 : l.meta) == null ? void 0 : A.pages), y((L) => {
|
|
178
178
|
var b;
|
|
179
|
-
return [...L, ...((b =
|
|
179
|
+
return [...L, ...((b = r == null ? void 0 : r.content) == null ? void 0 : b.data) || []];
|
|
180
180
|
});
|
|
181
|
-
}).catch((
|
|
182
|
-
console.error(
|
|
181
|
+
}).catch((r) => {
|
|
182
|
+
console.error(r);
|
|
183
183
|
}).finally(() => {
|
|
184
|
-
|
|
184
|
+
x(!1);
|
|
185
185
|
});
|
|
186
186
|
}, 500);
|
|
187
|
-
|
|
187
|
+
M(() => {
|
|
188
188
|
p();
|
|
189
|
-
}, [t]),
|
|
190
|
-
const
|
|
191
|
-
if (
|
|
192
|
-
return
|
|
189
|
+
}, [t]), M(() => {
|
|
190
|
+
const r = v.current;
|
|
191
|
+
if (r)
|
|
192
|
+
return r.addEventListener("scroll", w), () => r.removeEventListener("scroll", w);
|
|
193
193
|
}, [v, t.currentPage, n]);
|
|
194
194
|
const w = () => {
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
},
|
|
198
|
-
t.currentPage < n &&
|
|
199
|
-
searchText:
|
|
200
|
-
currentPage:
|
|
195
|
+
const r = v.current;
|
|
196
|
+
r && r.scrollTop + r.clientHeight + 1 >= r.scrollHeight && m();
|
|
197
|
+
}, m = () => {
|
|
198
|
+
t.currentPage < n && h((r) => ({
|
|
199
|
+
searchText: r.searchText,
|
|
200
|
+
currentPage: r.currentPage + 1
|
|
201
201
|
}));
|
|
202
|
-
}, E = (
|
|
203
|
-
if (!(d != null && d.includes(
|
|
202
|
+
}, E = (r) => {
|
|
203
|
+
if (!(d != null && d.includes(r == null ? void 0 : r.kind))) {
|
|
204
204
|
O(`Only ${d == null ? void 0 : d.join(", ")}s are allowed.`);
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
j ? (e == null ? void 0 : e.findIndex((l) => (l == null ? void 0 : l.id) === (
|
|
207
|
+
j ? (e == null ? void 0 : e.findIndex((l) => (l == null ? void 0 : l.id) === (r == null ? void 0 : r.id))) >= 0 ? o == null || o(e == null ? void 0 : e.filter((l) => (l == null ? void 0 : l.id) !== (r == null ? void 0 : r.id))) : o == null || o([...e || [], r]) : o == null || o([r]);
|
|
208
208
|
};
|
|
209
|
-
return /* @__PURE__ */
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
|
|
209
|
+
return /* @__PURE__ */ a.jsxs("div", { className: "bg-white p-0 rounded-md w-full relative", children: [
|
|
210
|
+
/* @__PURE__ */ a.jsx("div", { className: "py-2 bg-white sticky top-0 z-50 w-full", children: /* @__PURE__ */ a.jsx(
|
|
211
|
+
J,
|
|
212
212
|
{
|
|
213
213
|
name: "searchText",
|
|
214
214
|
type: "text",
|
|
215
215
|
placeholder: "Search...",
|
|
216
216
|
value: t.searchText,
|
|
217
|
-
onChange: (
|
|
218
|
-
|
|
217
|
+
onChange: (r) => {
|
|
218
|
+
x(!0), h({ currentPage: 1, searchText: r.target.value }), y([]);
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
) }),
|
|
222
|
-
z && !g.length ? /* @__PURE__ */
|
|
222
|
+
z && !g.length ? /* @__PURE__ */ a.jsx("div", { className: "w-full h-full min-h-[30rem] flex items-center justify-center", children: /* @__PURE__ */ a.jsx(W, {}) }) : /* @__PURE__ */ a.jsxs(
|
|
223
223
|
"div",
|
|
224
224
|
{
|
|
225
225
|
ref: v,
|
|
226
226
|
className: "w-full h-[30rem] overflow-y-auto overflow-x-hidden grid lg:grid-cols-4 gap-6 p-2",
|
|
227
227
|
children: [
|
|
228
|
-
g == null ? void 0 : g.map((
|
|
229
|
-
const A = d == null ? void 0 : d.includes(
|
|
230
|
-
return /* @__PURE__ */
|
|
228
|
+
g == null ? void 0 : g.map((r, l) => {
|
|
229
|
+
const A = d == null ? void 0 : d.includes(r == null ? void 0 : r.kind), L = (e == null ? void 0 : e.findIndex((b) => (b == null ? void 0 : b.id) === (r == null ? void 0 : r.id))) >= 0;
|
|
230
|
+
return /* @__PURE__ */ a.jsxs(
|
|
231
231
|
"div",
|
|
232
232
|
{
|
|
233
|
-
className:
|
|
233
|
+
className: I(
|
|
234
234
|
"relative w-full",
|
|
235
235
|
A ? "opacity-100" : "opacity-50"
|
|
236
236
|
),
|
|
237
237
|
children: [
|
|
238
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ a.jsxs(
|
|
239
239
|
"div",
|
|
240
240
|
{
|
|
241
|
-
className:
|
|
241
|
+
className: I(
|
|
242
242
|
"cursor-pointer w-full group rounded-md overflow-hidden h-[130px] border-2 flex items-center justify-center",
|
|
243
243
|
L ? "border-primary" : "border-gray-100"
|
|
244
244
|
),
|
|
245
245
|
onClick: () => {
|
|
246
246
|
var b;
|
|
247
247
|
return E({
|
|
248
|
-
id:
|
|
249
|
-
location:
|
|
250
|
-
mimetype: (b =
|
|
251
|
-
kind:
|
|
252
|
-
srcset:
|
|
248
|
+
id: r == null ? void 0 : r.id,
|
|
249
|
+
location: r == null ? void 0 : r.location,
|
|
250
|
+
mimetype: (b = r == null ? void 0 : r.metadata) == null ? void 0 : b.mimetype,
|
|
251
|
+
kind: r == null ? void 0 : r.kind,
|
|
252
|
+
srcset: r == null ? void 0 : r.srcset
|
|
253
253
|
});
|
|
254
254
|
},
|
|
255
255
|
children: [
|
|
256
|
-
/* @__PURE__ */
|
|
256
|
+
/* @__PURE__ */ a.jsx(
|
|
257
257
|
"div",
|
|
258
258
|
{
|
|
259
|
-
className:
|
|
259
|
+
className: I(
|
|
260
260
|
"rounded-md opacity-0 absolute left-0 right-0 top-0 w-full h-[42px] bg-[linear-gradient(0deg,_transparent_0%,_#000000_200%)]",
|
|
261
261
|
A ? "group-hover:opacity-100" : ""
|
|
262
262
|
)
|
|
263
263
|
}
|
|
264
264
|
),
|
|
265
|
-
A && /* @__PURE__ */
|
|
266
|
-
|
|
265
|
+
A && /* @__PURE__ */ a.jsx(
|
|
266
|
+
ur,
|
|
267
267
|
{
|
|
268
268
|
name: "isFileIncluded",
|
|
269
269
|
className: "absolute top-[10px] left-[10px]",
|
|
270
270
|
checked: L
|
|
271
271
|
}
|
|
272
272
|
),
|
|
273
|
-
(
|
|
273
|
+
(r == null ? void 0 : r.kind) !== "image" ? /* @__PURE__ */ a.jsx($, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ a.jsx(
|
|
274
274
|
"img",
|
|
275
275
|
{
|
|
276
276
|
className: "w-full h-full object-contain",
|
|
277
|
-
srcSet: f(
|
|
278
|
-
src:
|
|
277
|
+
srcSet: f(r == null ? void 0 : r.srcset),
|
|
278
|
+
src: r == null ? void 0 : r.location
|
|
279
279
|
}
|
|
280
280
|
)
|
|
281
281
|
]
|
|
282
282
|
}
|
|
283
283
|
),
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
284
|
+
/* @__PURE__ */ a.jsxs("div", { className: "my-[10px]", children: [
|
|
285
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-sm whitespace-nowrap overflow-hidden text-ellipsis", children: r == null ? void 0 : r.filename }),
|
|
286
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-xs text-gray-500", children: mr(r == null ? void 0 : r.metadata.size) })
|
|
287
287
|
] })
|
|
288
288
|
]
|
|
289
289
|
},
|
|
290
290
|
`media-layout-file-${l}`
|
|
291
291
|
);
|
|
292
292
|
}),
|
|
293
|
-
z && /* @__PURE__ */
|
|
293
|
+
z && /* @__PURE__ */ a.jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ a.jsx(W, {}) })
|
|
294
294
|
]
|
|
295
295
|
}
|
|
296
296
|
)
|
|
297
297
|
] });
|
|
298
|
-
},
|
|
298
|
+
}, vr = ({
|
|
299
299
|
isOpen: e,
|
|
300
300
|
onClose: o,
|
|
301
301
|
onChange: j,
|
|
@@ -307,35 +307,35 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
307
307
|
const [g, y] = S([]), z = () => {
|
|
308
308
|
o();
|
|
309
309
|
};
|
|
310
|
-
return
|
|
311
|
-
y(d.filter((
|
|
312
|
-
}, [d]), /* @__PURE__ */
|
|
313
|
-
|
|
310
|
+
return M(() => {
|
|
311
|
+
y(d.filter((x) => !!x.location));
|
|
312
|
+
}, [d]), /* @__PURE__ */ a.jsxs(
|
|
313
|
+
xr,
|
|
314
314
|
{
|
|
315
315
|
title: (c == null ? void 0 : c.length) > 1 ? "Upload file" : `Upload ${c == null ? void 0 : c[0]}`,
|
|
316
316
|
isOpen: e,
|
|
317
317
|
onClose: () => z(),
|
|
318
318
|
contentClassName: "max-w-[60%]",
|
|
319
319
|
children: [
|
|
320
|
-
/* @__PURE__ */
|
|
321
|
-
/* @__PURE__ */
|
|
322
|
-
/* @__PURE__ */
|
|
323
|
-
!_ && /* @__PURE__ */
|
|
320
|
+
/* @__PURE__ */ a.jsxs(er, { defaultValue: "upload", children: [
|
|
321
|
+
/* @__PURE__ */ a.jsxs(or, { children: [
|
|
322
|
+
/* @__PURE__ */ a.jsx(q, { value: "upload", children: "Local File" }),
|
|
323
|
+
!_ && /* @__PURE__ */ a.jsx(q, { value: "import", children: "Import from Gallery" })
|
|
324
324
|
] }),
|
|
325
|
-
/* @__PURE__ */
|
|
326
|
-
|
|
325
|
+
/* @__PURE__ */ a.jsx(G, { value: "upload", children: /* @__PURE__ */ a.jsx("div", { className: "mt-[20px] max-h-[70vh] overflow-y-auto", children: /* @__PURE__ */ a.jsx(
|
|
326
|
+
yr,
|
|
327
327
|
{
|
|
328
328
|
kind: c,
|
|
329
329
|
value: g,
|
|
330
|
-
onChange: (
|
|
330
|
+
onChange: (x) => y(x),
|
|
331
331
|
isMultiple: n
|
|
332
332
|
}
|
|
333
333
|
) }) }),
|
|
334
|
-
/* @__PURE__ */
|
|
335
|
-
|
|
334
|
+
/* @__PURE__ */ a.jsx(G, { value: "import", children: /* @__PURE__ */ a.jsx(
|
|
335
|
+
br,
|
|
336
336
|
{
|
|
337
|
-
onChange: (
|
|
338
|
-
y == null || y(
|
|
337
|
+
onChange: (x) => {
|
|
338
|
+
y == null || y(x);
|
|
339
339
|
},
|
|
340
340
|
selectedFiles: g,
|
|
341
341
|
isMultiple: n,
|
|
@@ -343,8 +343,8 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
343
343
|
}
|
|
344
344
|
) })
|
|
345
345
|
] }),
|
|
346
|
-
/* @__PURE__ */
|
|
347
|
-
|
|
346
|
+
/* @__PURE__ */ a.jsx("div", { className: "flex justify-end mt-[20px]", children: /* @__PURE__ */ a.jsx(
|
|
347
|
+
P,
|
|
348
348
|
{
|
|
349
349
|
variant: "default",
|
|
350
350
|
onClick: () => {
|
|
@@ -356,7 +356,7 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
356
356
|
]
|
|
357
357
|
}
|
|
358
358
|
);
|
|
359
|
-
},
|
|
359
|
+
}, $r = ({
|
|
360
360
|
field: e,
|
|
361
361
|
kind: o = k,
|
|
362
362
|
isMultiple: j,
|
|
@@ -364,110 +364,112 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
364
364
|
}) => {
|
|
365
365
|
var H;
|
|
366
366
|
const { media: c } = V(), { key: n = "", label: _ = "", helper_text: g = "", readonly: y = !1 } = e, {
|
|
367
|
-
field: { onBlur: z, onChange:
|
|
367
|
+
field: { onBlur: z, onChange: x, value: v, disabled: t, ref: h },
|
|
368
368
|
fieldState: p
|
|
369
|
-
} =
|
|
369
|
+
} = sr({
|
|
370
370
|
name: n,
|
|
371
|
-
rules:
|
|
371
|
+
rules: nr(e)
|
|
372
372
|
}), w = Q(() => {
|
|
373
373
|
const s = [];
|
|
374
374
|
return o.forEach((T) => {
|
|
375
|
-
s.push(...
|
|
375
|
+
s.push(...K[T]);
|
|
376
376
|
}), s;
|
|
377
|
-
}, [o]),
|
|
378
|
-
|
|
377
|
+
}, [o]), m = v ? Array.isArray(v) ? v : [v] : [], [E, r] = S(!1), l = () => r(!0), A = () => r(!1), [L, b] = S(!1), U = (s) => {
|
|
378
|
+
x && (j === !0 ? x(s) : j === !1 && x(s == null ? void 0 : s[0]));
|
|
379
379
|
}, Y = async (s) => {
|
|
380
380
|
const T = new FormData();
|
|
381
|
-
let
|
|
382
|
-
j || (
|
|
381
|
+
let i = [...s];
|
|
382
|
+
j || (i = s == null ? void 0 : s.slice(0, 1)), (i == null ? void 0 : i.length) > 0 && (i == null || i.forEach((u) => {
|
|
383
383
|
var C;
|
|
384
384
|
const N = u.name.split("."), B = (C = N[N.length - 1]) == null ? void 0 : C.toLowerCase();
|
|
385
385
|
o == null || o.forEach((Z) => {
|
|
386
|
-
w.push(...
|
|
386
|
+
w.push(...K[Z]);
|
|
387
387
|
}), B && w.includes(B) && T.append("media", u);
|
|
388
388
|
})), b(!0), await (c == null ? void 0 : c.mediaBulkUpload(T).then((u) => {
|
|
389
389
|
var N, B;
|
|
390
390
|
b(!1), (N = u == null ? void 0 : u.content) != null && N.data && U((B = u == null ? void 0 : u.content) == null ? void 0 : B.data);
|
|
391
391
|
}).catch((u) => {
|
|
392
|
-
|
|
392
|
+
X(u);
|
|
393
393
|
}).finally(() => {
|
|
394
394
|
b(!1);
|
|
395
395
|
}));
|
|
396
396
|
};
|
|
397
|
-
return /* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
|
|
397
|
+
return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
|
|
398
|
+
/* @__PURE__ */ a.jsx(
|
|
399
|
+
vr,
|
|
400
400
|
{
|
|
401
401
|
isOpen: E,
|
|
402
402
|
onClose: A,
|
|
403
403
|
onChange: (s) => {
|
|
404
404
|
U(s);
|
|
405
405
|
},
|
|
406
|
-
value:
|
|
406
|
+
value: m,
|
|
407
407
|
kind: [...o],
|
|
408
408
|
isMultiple: j,
|
|
409
409
|
isExternal: d
|
|
410
410
|
}
|
|
411
411
|
),
|
|
412
|
-
/* @__PURE__ */
|
|
413
|
-
|
|
412
|
+
/* @__PURE__ */ a.jsxs(
|
|
413
|
+
lr,
|
|
414
414
|
{
|
|
415
415
|
error: (H = p == null ? void 0 : p.error) == null ? void 0 : H.message,
|
|
416
416
|
helperText: g,
|
|
417
417
|
readOnly: y,
|
|
418
418
|
children: [
|
|
419
|
-
_ && /* @__PURE__ */
|
|
420
|
-
/* @__PURE__ */
|
|
421
|
-
/* @__PURE__ */
|
|
422
|
-
|
|
419
|
+
_ && /* @__PURE__ */ a.jsx(dr, { htmlFor: n, isRequired: e == null ? void 0 : e.required, children: _ }),
|
|
420
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex gap-2", ref: h, children: [
|
|
421
|
+
/* @__PURE__ */ a.jsx(
|
|
422
|
+
P,
|
|
423
423
|
{
|
|
424
424
|
size: "icon-small",
|
|
425
425
|
variant: "outline",
|
|
426
426
|
disabled: t,
|
|
427
427
|
onClick: l,
|
|
428
|
-
children: /* @__PURE__ */
|
|
428
|
+
children: /* @__PURE__ */ a.jsx(D, { size: 15 })
|
|
429
429
|
}
|
|
430
430
|
),
|
|
431
|
-
/* @__PURE__ */
|
|
432
|
-
/* @__PURE__ */
|
|
433
|
-
|
|
431
|
+
/* @__PURE__ */ a.jsxs("div", { className: "relative flex", children: [
|
|
432
|
+
/* @__PURE__ */ a.jsx(
|
|
433
|
+
J,
|
|
434
434
|
{
|
|
435
435
|
name: "pasteUrl",
|
|
436
|
+
placeholder: "Paste your files here...",
|
|
436
437
|
onBlur: () => z(),
|
|
437
438
|
onPaste: (s) => {
|
|
438
|
-
const T = s.clipboardData.items,
|
|
439
|
+
const T = s.clipboardData.items, i = [];
|
|
439
440
|
for (let u = 0; u < T.length; u++) {
|
|
440
441
|
const N = T[u];
|
|
441
442
|
if ((N == null ? void 0 : N.kind) === "file") {
|
|
442
443
|
const B = N == null ? void 0 : N.getAsFile();
|
|
443
|
-
B &&
|
|
444
|
+
B && i.push(B);
|
|
444
445
|
}
|
|
445
446
|
}
|
|
446
|
-
(
|
|
447
|
+
(i == null ? void 0 : i.length) > 0 && Y(i);
|
|
447
448
|
},
|
|
448
449
|
disabled: t,
|
|
449
450
|
readOnly: y
|
|
450
451
|
}
|
|
451
452
|
),
|
|
452
|
-
L && /* @__PURE__ */
|
|
453
|
+
L && /* @__PURE__ */ a.jsxs(
|
|
453
454
|
"div",
|
|
454
455
|
{
|
|
455
456
|
role: "status",
|
|
456
457
|
className: "absolute right-3 top-[50%] translate-y-[-50%]",
|
|
457
458
|
children: [
|
|
458
|
-
/* @__PURE__ */
|
|
459
|
-
/* @__PURE__ */
|
|
459
|
+
/* @__PURE__ */ a.jsx(gr, {}),
|
|
460
|
+
/* @__PURE__ */ a.jsx("span", { className: "sr-only", children: "Loading..." })
|
|
460
461
|
]
|
|
461
462
|
}
|
|
462
463
|
)
|
|
463
464
|
] })
|
|
464
465
|
] }),
|
|
465
|
-
(
|
|
466
|
+
(m == null ? void 0 : m.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: m == null ? void 0 : m.map((s, T) => s != null && s.location ? /* @__PURE__ */ a.jsxs(
|
|
466
467
|
"div",
|
|
467
468
|
{
|
|
468
|
-
className: "relative border overflow-hidden group w-full rounded-xl h-
|
|
469
|
+
className: "relative border overflow-hidden group w-full rounded-xl h-28 flex items-center justify-center",
|
|
469
470
|
children: [
|
|
470
|
-
(
|
|
471
|
+
/* @__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: s == null ? void 0 : s.location, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ a.jsx(ar, { size: 24 }) }) }),
|
|
472
|
+
(s == null ? void 0 : s.kind) !== "image" ? /* @__PURE__ */ a.jsx($, { size: "60px", className: "text-gray-400" }) : /* @__PURE__ */ a.jsx(
|
|
471
473
|
"img",
|
|
472
474
|
{
|
|
473
475
|
className: "w-full h-full object-contain",
|
|
@@ -475,17 +477,17 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
475
477
|
alt: s == null ? void 0 : s.id
|
|
476
478
|
}
|
|
477
479
|
),
|
|
478
|
-
/* @__PURE__ */
|
|
480
|
+
/* @__PURE__ */ a.jsx(
|
|
479
481
|
"button",
|
|
480
482
|
{
|
|
481
|
-
className: "absolute top-1 right-1 bg-white p-1 rounded-full focus:outline-none",
|
|
483
|
+
className: "absolute z-10 top-1 right-1 bg-white p-1 rounded-full focus:outline-none",
|
|
482
484
|
onClick: () => {
|
|
483
485
|
U(
|
|
484
|
-
|
|
486
|
+
m == null ? void 0 : m.filter((i) => (i == null ? void 0 : i.id) !== (s == null ? void 0 : s.id))
|
|
485
487
|
);
|
|
486
488
|
},
|
|
487
489
|
type: "button",
|
|
488
|
-
children: /* @__PURE__ */
|
|
490
|
+
children: /* @__PURE__ */ a.jsx(jr, { className: "text-sm" })
|
|
489
491
|
}
|
|
490
492
|
)
|
|
491
493
|
]
|
|
@@ -498,6 +500,6 @@ const ja = ({ onChange: e, value: o, kind: j, isMultiple: d = !1 }) => {
|
|
|
498
500
|
] });
|
|
499
501
|
};
|
|
500
502
|
export {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
+
$r as UploadWidget,
|
|
504
|
+
$r as default
|
|
503
505
|
};
|