@rpcbase/ui 0.263.0 → 0.264.0
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/index299.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { cn as e } from "./index12.js";
|
|
2
|
-
import { Image as t } from "./index297.js";
|
|
3
|
-
import
|
|
4
|
-
import { c as
|
|
5
|
-
import { useEffect as
|
|
6
|
-
import { Loader2 as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
import { createPortal as
|
|
9
|
-
import { DndContext as
|
|
10
|
-
import { SortableContext as
|
|
11
|
-
import { CSS as
|
|
2
|
+
import { Image as t, getImageSrcSet as n, isRpcbaseFileImageSrc as r, withImageWidth as i } from "./index297.js";
|
|
3
|
+
import a from "./index298.js";
|
|
4
|
+
import { c as o } from "react/compiler-runtime";
|
|
5
|
+
import { useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
6
|
+
import { Loader2 as d, Maximize2 as f, Plus as p, X as ee } from "lucide-react";
|
|
7
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal as te } from "react-dom";
|
|
9
|
+
import { DndContext as _, DragOverlay as v, KeyboardSensor as ne, PointerSensor as re, closestCenter as ie, defaultDropAnimationSideEffects as y, useSensor as b, useSensors as ae } from "@dnd-kit/core";
|
|
10
|
+
import { SortableContext as x, arrayMove as oe, rectSortingStrategy as se, sortableKeyboardCoordinates as ce, useSortable as S } from "@dnd-kit/sortable";
|
|
11
|
+
import { CSS as le } from "@dnd-kit/utilities";
|
|
12
12
|
//#region src/components/FilesUploadField/index.tsx
|
|
13
|
-
var
|
|
13
|
+
var C = async (e) => {
|
|
14
14
|
if (typeof crypto > "u" || crypto.subtle === void 0) return null;
|
|
15
15
|
try {
|
|
16
16
|
let t = await crypto.subtle.digest("SHA-256", e);
|
|
@@ -18,31 +18,31 @@ var se = async (e) => {
|
|
|
18
18
|
} catch {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, w = async (e, t) => {
|
|
22
22
|
if (typeof Worker > "u") throw Error("File hashing is not supported in this browser");
|
|
23
|
-
return new Promise((
|
|
24
|
-
let
|
|
25
|
-
t?.removeEventListener("abort", s),
|
|
23
|
+
return new Promise((n, r) => {
|
|
24
|
+
let i = new a(), o = () => {
|
|
25
|
+
t?.removeEventListener("abort", s), i.terminate();
|
|
26
26
|
}, s = () => {
|
|
27
27
|
o();
|
|
28
28
|
let e = /* @__PURE__ */ Error("Upload aborted");
|
|
29
|
-
e.name = "AbortError",
|
|
29
|
+
e.name = "AbortError", r(e);
|
|
30
30
|
};
|
|
31
31
|
if (t?.aborted) {
|
|
32
32
|
s();
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
t?.addEventListener("abort", s, { once: !0 }),
|
|
36
|
-
o(),
|
|
37
|
-
},
|
|
35
|
+
t?.addEventListener("abort", s, { once: !0 }), i.onerror = () => {
|
|
36
|
+
o(), r(/* @__PURE__ */ Error("Unable to hash file"));
|
|
37
|
+
}, i.onmessage = (e) => {
|
|
38
38
|
if (o(), e.data.ok) {
|
|
39
|
-
|
|
39
|
+
n(e.data.hash);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
},
|
|
42
|
+
r(/* @__PURE__ */ Error(e.data.error === "hash_unavailable" ? "File hashing is not supported in this browser" : "Unable to hash file"));
|
|
43
|
+
}, i.postMessage(e);
|
|
44
44
|
});
|
|
45
|
-
},
|
|
45
|
+
}, T = async (e, t, n) => {
|
|
46
46
|
let r = await fetch(e, {
|
|
47
47
|
method: "POST",
|
|
48
48
|
headers: {
|
|
@@ -58,7 +58,7 @@ var se = async (e) => {
|
|
|
58
58
|
status: r.status,
|
|
59
59
|
data: i
|
|
60
60
|
};
|
|
61
|
-
},
|
|
61
|
+
}, E = async (e, t) => {
|
|
62
62
|
let n = await fetch(e, {
|
|
63
63
|
credentials: "include",
|
|
64
64
|
headers: t?.headers,
|
|
@@ -69,7 +69,7 @@ var se = async (e) => {
|
|
|
69
69
|
status: n.status,
|
|
70
70
|
data: r
|
|
71
71
|
};
|
|
72
|
-
},
|
|
72
|
+
}, D = async ({ url: e, body: t, sha256: n, uploadKey: r, signal: i }) => {
|
|
73
73
|
let a = { "Content-Type": "application/octet-stream" };
|
|
74
74
|
n && (a["X-Chunk-SHA256"] = n), r && (a["X-Upload-Key"] = r);
|
|
75
75
|
let o = await fetch(e, {
|
|
@@ -83,8 +83,8 @@ var se = async (e) => {
|
|
|
83
83
|
ok: o.ok,
|
|
84
84
|
status: o.status
|
|
85
85
|
};
|
|
86
|
-
},
|
|
87
|
-
let r = n?.deduplicationNamespace?.trim(), i = r ? await
|
|
86
|
+
}, ue = async (e, t, n) => {
|
|
87
|
+
let r = n?.deduplicationNamespace?.trim(), i = r ? await w(e, n?.signal) : null, a = await T("/api/rb/file-uploads", {
|
|
88
88
|
filename: e.name,
|
|
89
89
|
mimeType: e.type || "application/octet-stream",
|
|
90
90
|
...n?.accessScope ? { accessScope: n.accessScope } : typeof n?.isPublic == "boolean" ? { isPublic: n.isPublic } : {},
|
|
@@ -106,24 +106,24 @@ var se = async (e) => {
|
|
|
106
106
|
...n ? { uploadKey: n } : {}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
let s = String(a.data?.uploadId ?? ""), c = typeof a.data?.uploadKey == "string" ? String(a.data.uploadKey) : null,
|
|
110
|
-
if (!s || !
|
|
111
|
-
let
|
|
112
|
-
let r = t *
|
|
109
|
+
let s = String(a.data?.uploadId ?? ""), c = typeof a.data?.uploadKey == "string" ? String(a.data.uploadKey) : null, l = Number(a.data?.chunkSize ?? 0), u = Number(a.data?.chunksTotal ?? 0);
|
|
110
|
+
if (!s || !l || !u) throw Error("Upload init missing required fields");
|
|
111
|
+
let d = async (t) => {
|
|
112
|
+
let r = t * l, i = Math.min(e.size, r + l), a = await e.slice(r, i).arrayBuffer(), o = await C(a), u = await D({
|
|
113
113
|
url: `/api/rb/file-uploads/${encodeURIComponent(s)}/chunks/${t}`,
|
|
114
114
|
body: a,
|
|
115
115
|
sha256: o ?? void 0,
|
|
116
116
|
uploadKey: c ?? void 0,
|
|
117
117
|
signal: n?.signal
|
|
118
118
|
});
|
|
119
|
-
if (
|
|
120
|
-
},
|
|
119
|
+
if (u.status !== 204) throw Error(`Chunk ${t} failed (${u.status})`);
|
|
120
|
+
}, f = async (e, n = 0) => {
|
|
121
121
|
let r = n;
|
|
122
|
-
for (let n of e) await
|
|
122
|
+
for (let n of e) await d(n), r += 1, t(Math.min(99, Math.floor(r / u * 99)));
|
|
123
123
|
};
|
|
124
|
-
await
|
|
125
|
-
let
|
|
126
|
-
let e = await
|
|
124
|
+
await f(Array.from({ length: u }, (e, t) => t), 0);
|
|
125
|
+
let p = async () => {
|
|
126
|
+
let e = await T(`/api/rb/file-uploads/${encodeURIComponent(s)}/complete`, {}, {
|
|
127
127
|
headers: c ? { "X-Upload-Key": c } : void 0,
|
|
128
128
|
signal: n?.signal
|
|
129
129
|
});
|
|
@@ -134,275 +134,287 @@ var se = async (e) => {
|
|
|
134
134
|
}
|
|
135
135
|
let t = String(e.data?.error ?? "");
|
|
136
136
|
if (e.status !== 409 || t !== "missing_chunks") throw Error(t || `Complete failed (${e.status})`);
|
|
137
|
-
let r = await
|
|
137
|
+
let r = await E(`/api/rb/file-uploads/${encodeURIComponent(s)}/status`, {
|
|
138
138
|
headers: c ? { "X-Upload-Key": c } : void 0,
|
|
139
139
|
signal: n?.signal
|
|
140
140
|
});
|
|
141
141
|
if (!r.ok || !r.data?.ok) throw Error(r.data?.error ?? `Status failed (${r.status})`);
|
|
142
142
|
let i = Array.isArray(r.data?.received) ? r.data.received : [], a = new Set(i), o = [];
|
|
143
|
-
for (let e = 0; e <
|
|
143
|
+
for (let e = 0; e < u; e += 1) a.has(e) || o.push(e);
|
|
144
144
|
if (!o.length) throw Error("missing_chunks");
|
|
145
|
-
return await
|
|
146
|
-
},
|
|
145
|
+
return await f(o, a.size), p();
|
|
146
|
+
}, ee = await p();
|
|
147
147
|
return t(100), {
|
|
148
|
-
id:
|
|
149
|
-
url: `/api/rb/files/${encodeURIComponent(
|
|
148
|
+
id: ee,
|
|
149
|
+
url: `/api/rb/files/${encodeURIComponent(ee)}`,
|
|
150
150
|
alt: e.name,
|
|
151
151
|
...c ? { uploadKey: c } : {}
|
|
152
152
|
};
|
|
153
153
|
};
|
|
154
|
-
function
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
id:
|
|
158
|
-
disabled:
|
|
159
|
-
},
|
|
160
|
-
let { setNodeRef:
|
|
161
|
-
|
|
162
|
-
let e =
|
|
154
|
+
function de(n) {
|
|
155
|
+
let r = o(82), { item: i, isHovered: a, enableImagePreview: c, renderItem: p, onHoverEnter: _, onHoverLeave: v, onRemove: ne, onRetry: re, startFullscreen: ie, isUploading: y, isError: b, tileClasses: ae, disabled: x, isDraggingExternal: oe, removeButtonAriaLabel: se } = n, ce;
|
|
156
|
+
r[0] !== x || r[1] !== i.id ? (ce = {
|
|
157
|
+
id: i.id,
|
|
158
|
+
disabled: x
|
|
159
|
+
}, r[0] = x, r[1] = i.id, r[2] = ce) : ce = r[2];
|
|
160
|
+
let { setNodeRef: C, attributes: w, listeners: T, transform: E, transition: D, isDragging: ue } = S(ce), de = l(null), fe = l(null), [O, pe] = u(null), k;
|
|
161
|
+
r[3] === Symbol.for("react.memo_cache_sentinel") ? (k = () => {
|
|
162
|
+
let e = de.current;
|
|
163
163
|
if (!e) return;
|
|
164
164
|
let t = e.getBoundingClientRect();
|
|
165
|
-
|
|
165
|
+
pe({
|
|
166
166
|
left: t.left + t.width / 2,
|
|
167
167
|
top: t.top - 10
|
|
168
168
|
});
|
|
169
|
-
},
|
|
170
|
-
let
|
|
171
|
-
|
|
172
|
-
if (!
|
|
173
|
-
|
|
169
|
+
}, r[3] = k) : k = r[3];
|
|
170
|
+
let A = k, j, he;
|
|
171
|
+
r[4] !== c || r[5] !== a ? (j = () => {
|
|
172
|
+
if (!c || !a) {
|
|
173
|
+
pe(null);
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
A();
|
|
177
177
|
let e = 0, t = () => {
|
|
178
178
|
e && cancelAnimationFrame(e), e = requestAnimationFrame(() => {
|
|
179
|
-
e = 0,
|
|
179
|
+
e = 0, A();
|
|
180
180
|
});
|
|
181
181
|
};
|
|
182
182
|
return window.addEventListener("resize", t), window.addEventListener("scroll", t, !0), () => {
|
|
183
183
|
e && cancelAnimationFrame(e), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
|
|
184
184
|
};
|
|
185
|
-
},
|
|
186
|
-
let j;
|
|
187
|
-
a[8] === le ? j = a[9] : (j = S.Transform.toString(le), a[8] = le, a[9] = j);
|
|
185
|
+
}, he = [c, a], r[4] = c, r[5] = a, r[6] = j, r[7] = he) : (j = r[6], he = r[7]), s(j, he);
|
|
188
186
|
let M;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
r[8] === E ? M = r[9] : (M = le.Transform.toString(E), r[8] = E, r[9] = M);
|
|
188
|
+
let ge;
|
|
189
|
+
r[10] !== M || r[11] !== D ? (ge = {
|
|
190
|
+
transform: M,
|
|
191
|
+
transition: D
|
|
192
|
+
}, r[10] = M, r[11] = D, r[12] = ge) : ge = r[12];
|
|
193
|
+
let N = ge, P;
|
|
194
|
+
r[13] !== c || r[14] !== b || r[15] !== y || r[16] !== i.alt || r[17] !== i.fileName || r[18] !== i.id || r[19] !== i.previewUrl || r[20] !== i.progress || r[21] !== i.status || r[22] !== i.uploadKey || r[23] !== i.url || r[24] !== p ? (P = p ? p({
|
|
195
195
|
file: {
|
|
196
|
-
id:
|
|
197
|
-
url:
|
|
198
|
-
alt:
|
|
199
|
-
uploadKey:
|
|
196
|
+
id: i.id,
|
|
197
|
+
url: i.url,
|
|
198
|
+
alt: i.alt,
|
|
199
|
+
uploadKey: i.uploadKey
|
|
200
200
|
},
|
|
201
|
-
previewUrl:
|
|
202
|
-
status:
|
|
203
|
-
progress:
|
|
204
|
-
fileName:
|
|
205
|
-
}) :
|
|
206
|
-
src:
|
|
207
|
-
alt:
|
|
201
|
+
previewUrl: i.previewUrl,
|
|
202
|
+
status: i.status,
|
|
203
|
+
progress: i.progress,
|
|
204
|
+
fileName: i.fileName
|
|
205
|
+
}) : c ? /* @__PURE__ */ h(t, {
|
|
206
|
+
src: i.previewUrl,
|
|
207
|
+
alt: i.alt ?? "Uploaded file",
|
|
208
208
|
sizes: "96px",
|
|
209
|
-
className: e("size-full rounded-md object-cover",
|
|
210
|
-
}) : /* @__PURE__ */
|
|
209
|
+
className: e("size-full rounded-md object-cover", y && "opacity-75", b && "grayscale")
|
|
210
|
+
}) : /* @__PURE__ */ h("div", {
|
|
211
211
|
className: "flex size-full items-center justify-center rounded-md bg-slate-100 px-2 text-center text-[10px] font-medium text-slate-700 dark:bg-slate-800 dark:text-slate-200",
|
|
212
|
-
children: /* @__PURE__ */
|
|
212
|
+
children: /* @__PURE__ */ h("span", {
|
|
213
213
|
className: "w-full truncate",
|
|
214
|
-
children:
|
|
214
|
+
children: i.fileName ?? i.alt ?? "Fichier"
|
|
215
215
|
})
|
|
216
|
-
}),
|
|
217
|
-
let
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
},
|
|
221
|
-
let
|
|
222
|
-
|
|
216
|
+
}), r[13] = c, r[14] = b, r[15] = y, r[16] = i.alt, r[17] = i.fileName, r[18] = i.id, r[19] = i.previewUrl, r[20] = i.progress, r[21] = i.status, r[22] = i.uploadKey, r[23] = i.url, r[24] = p, r[25] = P) : P = r[25];
|
|
217
|
+
let F = P, I;
|
|
218
|
+
r[26] === C ? I = r[27] : (I = (e) => {
|
|
219
|
+
de.current = e, C(e);
|
|
220
|
+
}, r[26] = C, r[27] = I);
|
|
221
|
+
let _e = ue && "z-20 ring-2 ring-primary shadow-xl", L = oe && "opacity-0", R = !x && "cursor-grab active:cursor-grabbing", ve = ue && "cursor-grabbing", z = x && "cursor-default", B;
|
|
222
|
+
r[28] !== L || r[29] !== R || r[30] !== ve || r[31] !== z || r[32] !== _e || r[33] !== ae ? (B = e(ae, _e, L, R, ve, z), r[28] = L, r[29] = R, r[30] = ve, r[31] = z, r[32] = _e, r[33] = ae, r[34] = B) : B = r[34];
|
|
223
223
|
let V;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
},
|
|
224
|
+
r[35] === _ ? V = r[36] : (V = () => {
|
|
225
|
+
A(), _();
|
|
226
|
+
}, r[35] = _, r[36] = V);
|
|
227
227
|
let H;
|
|
228
|
-
|
|
228
|
+
r[37] === v ? H = r[38] : (H = (e) => {
|
|
229
229
|
let t = e.relatedTarget;
|
|
230
|
-
t instanceof Node &&
|
|
231
|
-
},
|
|
230
|
+
t instanceof Node && fe.current?.contains(t) || v();
|
|
231
|
+
}, r[37] = v, r[38] = H);
|
|
232
232
|
let U;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
},
|
|
233
|
+
r[39] !== x || r[40] !== i.id || r[41] !== ne ? (U = () => {
|
|
234
|
+
x || ne(i.id);
|
|
235
|
+
}, r[39] = x, r[40] = i.id, r[41] = ne, r[42] = U) : U = r[42];
|
|
236
|
+
let ye;
|
|
237
|
+
r[43] === Symbol.for("react.memo_cache_sentinel") ? (ye = /* @__PURE__ */ h(ee, { className: "h-4 w-4" }), r[43] = ye) : ye = r[43];
|
|
236
238
|
let W;
|
|
237
|
-
|
|
238
|
-
let G;
|
|
239
|
-
a[44] !== b || a[45] !== C || a[46] !== U ? (G = /* @__PURE__ */ d("button", {
|
|
239
|
+
r[44] !== x || r[45] !== se || r[46] !== U ? (W = /* @__PURE__ */ h("button", {
|
|
240
240
|
type: "button",
|
|
241
241
|
onClick: U,
|
|
242
|
-
disabled:
|
|
242
|
+
disabled: x,
|
|
243
243
|
className: "absolute right-1 top-1 inline-flex size-6 items-center justify-center rounded-full bg-white text-slate-700 shadow-sm transition hover:scale-105 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:bg-slate-900 dark:text-slate-200",
|
|
244
|
-
"aria-label":
|
|
245
|
-
children:
|
|
246
|
-
}),
|
|
247
|
-
let
|
|
248
|
-
|
|
249
|
-
let e = /* @__PURE__ */
|
|
250
|
-
ref:
|
|
244
|
+
"aria-label": se,
|
|
245
|
+
children: ye
|
|
246
|
+
}), r[44] = x, r[45] = se, r[46] = U, r[47] = W) : W = r[47];
|
|
247
|
+
let G;
|
|
248
|
+
r[48] !== c || r[49] !== a || r[50] !== i.alt || r[51] !== i.id || r[52] !== i.url || r[53] !== _ || r[54] !== v || r[55] !== O || r[56] !== ie ? (G = c && a && O && (() => {
|
|
249
|
+
let e = /* @__PURE__ */ h(m, { children: /* @__PURE__ */ h("div", {
|
|
250
|
+
ref: fe,
|
|
251
251
|
className: "pointer-events-auto fixed z-[60] w-52 -translate-x-1/2 -translate-y-full rounded-xl border border-slate-200 bg-white/95 p-3 shadow-2xl backdrop-blur dark:border-slate-700 dark:bg-slate-900/95",
|
|
252
252
|
style: {
|
|
253
|
-
left:
|
|
254
|
-
top:
|
|
253
|
+
left: O.left,
|
|
254
|
+
top: O.top
|
|
255
255
|
},
|
|
256
256
|
onMouseEnter: () => {
|
|
257
|
-
|
|
257
|
+
A(), _();
|
|
258
258
|
},
|
|
259
259
|
onMouseLeave: (e) => {
|
|
260
260
|
let t = e.relatedTarget;
|
|
261
|
-
t instanceof Node &&
|
|
261
|
+
t instanceof Node && de.current?.contains(t) || v();
|
|
262
262
|
},
|
|
263
|
-
children: /* @__PURE__ */
|
|
263
|
+
children: /* @__PURE__ */ g("div", {
|
|
264
264
|
className: "relative overflow-hidden rounded-lg",
|
|
265
|
-
children: [/* @__PURE__ */
|
|
266
|
-
src:
|
|
267
|
-
alt:
|
|
265
|
+
children: [/* @__PURE__ */ h(t, {
|
|
266
|
+
src: i.url,
|
|
267
|
+
alt: i.alt ?? "Preview",
|
|
268
268
|
sizes: "208px",
|
|
269
269
|
className: "h-40 w-full object-cover"
|
|
270
|
-
}), /* @__PURE__ */
|
|
270
|
+
}), /* @__PURE__ */ h("button", {
|
|
271
271
|
type: "button",
|
|
272
|
-
onClick: () =>
|
|
272
|
+
onClick: () => ie(i.id),
|
|
273
273
|
className: "absolute right-2 top-2 inline-flex items-center justify-center rounded-full bg-black/70 p-2 text-white transition hover:bg-black",
|
|
274
274
|
"aria-label": "Plein écran",
|
|
275
|
-
children: /* @__PURE__ */
|
|
275
|
+
children: /* @__PURE__ */ h(f, { className: "h-3.5 w-3.5" })
|
|
276
276
|
})]
|
|
277
277
|
})
|
|
278
278
|
}) });
|
|
279
|
-
return typeof document > "u" ? e :
|
|
280
|
-
})(),
|
|
281
|
-
let
|
|
282
|
-
|
|
279
|
+
return typeof document > "u" ? e : te(e, document.body);
|
|
280
|
+
})(), r[48] = c, r[49] = a, r[50] = i.alt, r[51] = i.id, r[52] = i.url, r[53] = _, r[54] = v, r[55] = O, r[56] = ie, r[57] = G) : G = r[57];
|
|
281
|
+
let K;
|
|
282
|
+
r[58] !== y || r[59] !== i.alt || r[60] !== i.fileName || r[61] !== i.progress ? (K = y && /* @__PURE__ */ g("div", {
|
|
283
283
|
className: "absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-lg bg-black/40 text-white",
|
|
284
284
|
role: "progressbar",
|
|
285
|
-
"aria-label":
|
|
285
|
+
"aria-label": i.fileName ?? i.alt ?? "File",
|
|
286
286
|
"aria-valuemin": 0,
|
|
287
287
|
"aria-valuemax": 100,
|
|
288
|
-
"aria-valuenow":
|
|
288
|
+
"aria-valuenow": i.progress,
|
|
289
289
|
children: [
|
|
290
|
-
/* @__PURE__ */ d
|
|
290
|
+
/* @__PURE__ */ h(d, {
|
|
291
291
|
className: "h-5 w-5 animate-spin",
|
|
292
292
|
"aria-hidden": "true"
|
|
293
293
|
}),
|
|
294
|
-
/* @__PURE__ */
|
|
294
|
+
/* @__PURE__ */ h("div", {
|
|
295
295
|
className: "h-1.5 w-5/6 rounded-full bg-white/20",
|
|
296
|
-
children: /* @__PURE__ */
|
|
296
|
+
children: /* @__PURE__ */ h("div", {
|
|
297
297
|
className: "h-full rounded-full bg-primary",
|
|
298
|
-
style: { width: `${
|
|
298
|
+
style: { width: `${i.progress}%` }
|
|
299
299
|
})
|
|
300
300
|
}),
|
|
301
|
-
/* @__PURE__ */
|
|
301
|
+
/* @__PURE__ */ g("div", {
|
|
302
302
|
className: "text-xs font-semibold",
|
|
303
|
-
children: [
|
|
303
|
+
children: [i.progress, "%"]
|
|
304
304
|
})
|
|
305
305
|
]
|
|
306
|
-
}),
|
|
307
|
-
let
|
|
308
|
-
|
|
306
|
+
}), r[58] = y, r[59] = i.alt, r[60] = i.fileName, r[61] = i.progress, r[62] = K) : K = r[62];
|
|
307
|
+
let q;
|
|
308
|
+
r[63] !== x || r[64] !== b || r[65] !== i.errorMessage || r[66] !== i.id || r[67] !== re ? (q = b && /* @__PURE__ */ g("div", {
|
|
309
309
|
className: "absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 rounded-lg bg-red-600/70 text-white",
|
|
310
310
|
role: "alert",
|
|
311
|
-
children: [/* @__PURE__ */
|
|
311
|
+
children: [/* @__PURE__ */ h("div", {
|
|
312
312
|
className: "max-w-[92%] break-words text-center text-[10px] font-semibold leading-tight",
|
|
313
|
-
title:
|
|
314
|
-
children:
|
|
315
|
-
}), /* @__PURE__ */
|
|
313
|
+
title: i.errorMessage,
|
|
314
|
+
children: me(i.errorMessage)
|
|
315
|
+
}), /* @__PURE__ */ h("button", {
|
|
316
316
|
type: "button",
|
|
317
|
-
onClick: () =>
|
|
318
|
-
disabled:
|
|
317
|
+
onClick: () => re(i.id),
|
|
318
|
+
disabled: x,
|
|
319
319
|
className: "rounded-full bg-white/90 px-3 py-1 text-xs font-semibold text-red-700 shadow-sm transition hover:bg-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
|
|
320
320
|
children: "Réessayer"
|
|
321
321
|
})]
|
|
322
|
-
}),
|
|
323
|
-
let
|
|
324
|
-
return
|
|
325
|
-
ref:
|
|
322
|
+
}), r[63] = x, r[64] = b, r[65] = i.errorMessage, r[66] = i.id, r[67] = re, r[68] = q) : q = r[68];
|
|
323
|
+
let J;
|
|
324
|
+
return r[69] !== w || r[70] !== T || r[71] !== N || r[72] !== B || r[73] !== V || r[74] !== H || r[75] !== W || r[76] !== G || r[77] !== K || r[78] !== q || r[79] !== I || r[80] !== F ? (J = /* @__PURE__ */ g("div", {
|
|
325
|
+
ref: I,
|
|
326
326
|
style: N,
|
|
327
327
|
className: B,
|
|
328
328
|
onMouseEnter: V,
|
|
329
329
|
onMouseLeave: H,
|
|
330
|
-
...
|
|
331
|
-
...
|
|
330
|
+
...w,
|
|
331
|
+
...T,
|
|
332
332
|
children: [
|
|
333
|
-
|
|
333
|
+
F,
|
|
334
|
+
W,
|
|
334
335
|
G,
|
|
335
336
|
K,
|
|
336
|
-
q
|
|
337
|
-
J
|
|
337
|
+
q
|
|
338
338
|
]
|
|
339
|
-
}),
|
|
339
|
+
}), r[69] = w, r[70] = T, r[71] = N, r[72] = B, r[73] = V, r[74] = H, r[75] = W, r[76] = G, r[77] = K, r[78] = q, r[79] = I, r[80] = F, r[81] = J) : J = r[81], J;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function fe(e) {
|
|
342
342
|
return URL.createObjectURL(e);
|
|
343
343
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
344
|
+
async function O(e) {
|
|
345
|
+
let t = document.createElement("img"), a = n(e);
|
|
346
|
+
if (a && (t.srcset = a, t.sizes = "96px"), t.src = r(e) ? i(e, 960) : e, typeof t.decode == "function") {
|
|
347
|
+
await t.decode().catch(() => void 0);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
t.complete || await new Promise((e) => {
|
|
351
|
+
t.onload = () => e(), t.onerror = () => e();
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
var pe = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Upload failed", me = (e) => e ? e.startsWith("heif_decode_unsupported") ? "HEIC/HEVC non supporté" : e : "Échec", k = /\.(png|jpe?g|gif|webp|avif|heic|heif|svg|bmp)$/i, A = 350, j = y({ styles: { active: { opacity: "0" } } }), he = (e) => e.mimeType ? e.mimeType.startsWith("image/") : k.test(e.fileName ?? e.alt ?? "");
|
|
355
|
+
function M({ initialFiles: n = [], onChange: r, upload: i = ue, uploadIsPublic: a, uploadAccessScope: o, uploadDeduplicationNamespace: d, maxFiles: f, disabled: m = !1, onUploadingChange: y, accept: S, renderHeader: le, renderItem: C, addButtonAriaLabel: w = "Ajouter un fichier", removeButtonAriaLabel: T = "Supprimer le fichier", variant: E = "card" }) {
|
|
356
|
+
let D = l(null), [k, M] = u(() => n.map((e) => ({
|
|
347
357
|
...e,
|
|
358
|
+
renderKey: e.id,
|
|
348
359
|
previewUrl: e.url,
|
|
349
360
|
status: "uploaded",
|
|
350
361
|
progress: 100
|
|
351
|
-
}))), [
|
|
352
|
-
let t = String(e.active.id), n =
|
|
353
|
-
n?.id === t && (window.clearTimeout(n.timeout),
|
|
354
|
-
let r =
|
|
362
|
+
}))), [ge, N] = u(!1), [P, F] = u(null), [I, _e] = u(null), [L, R] = u(null), [ve, z] = u(null), B = l(null), V = l(null), H = l(!1), U = l(() => {}), ye = l({ sideEffects(e) {
|
|
363
|
+
let t = String(e.active.id), n = V.current;
|
|
364
|
+
n?.id === t && (window.clearTimeout(n.timeout), V.current = null);
|
|
365
|
+
let r = j(e);
|
|
355
366
|
return () => {
|
|
356
|
-
r?.(),
|
|
367
|
+
r?.(), U.current(t);
|
|
357
368
|
};
|
|
358
|
-
} }), W =
|
|
359
|
-
|
|
369
|
+
} }), W = l(!0), G = l([]), K = l(n), q = l(r), J = l(y), Y = l(/* @__PURE__ */ new Map()), X = l(/* @__PURE__ */ new Map()), Z = l(/* @__PURE__ */ new Map()), Q = l(/* @__PURE__ */ new Map()), be = ae(b(re, { activationConstraint: { distance: 6 } }), b(ne, { coordinateGetter: ce }));
|
|
370
|
+
s(() => () => {
|
|
360
371
|
for (let e of Z.current.values()) try {
|
|
361
372
|
e.abort();
|
|
362
373
|
} catch {}
|
|
363
|
-
Z.current.clear(),
|
|
374
|
+
Z.current.clear(), V.current !== null && (window.clearTimeout(V.current.timeout), V.current = null), X.current.clear(), Y.current.clear();
|
|
364
375
|
for (let e of Q.current.values()) if (typeof URL < "u") try {
|
|
365
376
|
URL.revokeObjectURL(e);
|
|
366
377
|
} catch {}
|
|
367
378
|
Q.current.clear();
|
|
368
|
-
}, []),
|
|
369
|
-
let t =
|
|
370
|
-
t?.id === e && (window.clearTimeout(t.timeout),
|
|
371
|
-
},
|
|
379
|
+
}, []), U.current = (e) => {
|
|
380
|
+
let t = V.current;
|
|
381
|
+
t?.id === e && (window.clearTimeout(t.timeout), V.current = null), z((t) => t === e ? null : t);
|
|
382
|
+
}, s(() => {
|
|
372
383
|
if (!(typeof document > "u")) {
|
|
373
|
-
if (
|
|
384
|
+
if (L) return document.body.style.cursor = "grabbing", () => {
|
|
374
385
|
document.body.style.cursor = "";
|
|
375
386
|
};
|
|
376
387
|
document.body.style.cursor = "";
|
|
377
388
|
}
|
|
378
|
-
}, [
|
|
389
|
+
}, [L]), s(() => {
|
|
379
390
|
G.current = k;
|
|
380
|
-
}, [k]),
|
|
391
|
+
}, [k]), s(() => {
|
|
381
392
|
q.current = r;
|
|
382
|
-
}, [r]),
|
|
383
|
-
J.current =
|
|
384
|
-
}, [
|
|
393
|
+
}, [r]), s(() => {
|
|
394
|
+
J.current = y;
|
|
395
|
+
}, [y]), s(() => {
|
|
385
396
|
let e = K.current;
|
|
386
397
|
if (e.length === n.length && e.every((e, t) => {
|
|
387
398
|
let r = n[t];
|
|
388
399
|
return r && e.id === r.id && e.url === r.url && e.alt === r.alt;
|
|
389
400
|
})) return;
|
|
390
401
|
K.current = n;
|
|
391
|
-
let t = n.map((e) => ({
|
|
402
|
+
let t = new Map(G.current.map((e) => [e.id, e.renderKey])), r = n.map((e) => ({
|
|
392
403
|
...e,
|
|
404
|
+
renderKey: t.get(e.id) ?? e.id,
|
|
393
405
|
previewUrl: e.url,
|
|
394
406
|
status: "uploaded",
|
|
395
407
|
progress: 100
|
|
396
|
-
})),
|
|
397
|
-
for (let [e, t] of Y.current.entries())
|
|
398
|
-
let
|
|
399
|
-
if (
|
|
408
|
+
})), i = new Set(r.map((e) => e.id));
|
|
409
|
+
for (let [e, t] of Y.current.entries()) i.has(t) && Y.current.delete(e);
|
|
410
|
+
let a = new Set(G.current.map((e) => e.id));
|
|
411
|
+
if (r.some((e) => {
|
|
400
412
|
let t = Y.current.get(e.id);
|
|
401
|
-
return t ?
|
|
413
|
+
return t ? a.has(t) : !1;
|
|
402
414
|
})) return;
|
|
403
|
-
let
|
|
415
|
+
let o = new Set(r.map((e) => e.id));
|
|
404
416
|
for (let e of G.current) {
|
|
405
|
-
if (
|
|
417
|
+
if (o.has(e.id)) continue;
|
|
406
418
|
let t = Z.current.get(e.id);
|
|
407
419
|
if (t) {
|
|
408
420
|
Z.current.delete(e.id);
|
|
@@ -419,11 +431,11 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
419
431
|
} catch {}
|
|
420
432
|
}
|
|
421
433
|
}
|
|
422
|
-
|
|
423
|
-
let
|
|
424
|
-
return
|
|
425
|
-
}) ? e : (W.current = !0,
|
|
426
|
-
}, [n]),
|
|
434
|
+
M((e) => e.length === r.length && e.every((e, t) => {
|
|
435
|
+
let n = r[t];
|
|
436
|
+
return n && e.id === n.id && e.url === n.url && e.alt === n.alt && e.uploadKey === n.uploadKey;
|
|
437
|
+
}) ? e : (W.current = !0, r));
|
|
438
|
+
}, [n]), s(() => {
|
|
427
439
|
if (W.current) {
|
|
428
440
|
W.current = !1;
|
|
429
441
|
return;
|
|
@@ -434,33 +446,34 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
434
446
|
alt: n,
|
|
435
447
|
uploadKey: r
|
|
436
448
|
})));
|
|
437
|
-
}, [k]),
|
|
449
|
+
}, [k]), s(() => {
|
|
438
450
|
J.current?.(k.some((e) => e.status === "uploading"));
|
|
439
|
-
}, [k]),
|
|
440
|
-
if (
|
|
451
|
+
}, [k]), s(() => {
|
|
452
|
+
if (P === null) return;
|
|
441
453
|
let e = (e) => {
|
|
442
454
|
if (e.key === "Escape") {
|
|
443
|
-
|
|
455
|
+
F(null);
|
|
444
456
|
return;
|
|
445
457
|
}
|
|
446
458
|
if (e.key === "ArrowRight") {
|
|
447
|
-
|
|
459
|
+
F((e) => e === null ? e : (e + 1) % k.length);
|
|
448
460
|
return;
|
|
449
461
|
}
|
|
450
|
-
e.key === "ArrowLeft" &&
|
|
462
|
+
e.key === "ArrowLeft" && F((e) => e === null ? e : (e - 1 + k.length) % k.length);
|
|
451
463
|
};
|
|
452
464
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
453
|
-
}, [
|
|
454
|
-
let
|
|
455
|
-
if (
|
|
456
|
-
let t = typeof
|
|
465
|
+
}, [P, k.length]);
|
|
466
|
+
let xe = async (e) => {
|
|
467
|
+
if (m) return;
|
|
468
|
+
let t = typeof f == "number" && Number.isFinite(f) && f > 0 ? Math.floor(f) : null, n = t === null ? Infinity : Math.max(0, t - G.current.length), r = Array.from(e).slice(0, n);
|
|
457
469
|
if (!r.length) return;
|
|
458
|
-
let
|
|
459
|
-
let t =
|
|
470
|
+
let s = r.map((e) => {
|
|
471
|
+
let t = fe(e), n = crypto.randomUUID();
|
|
460
472
|
Q.current.set(n, t), X.current.set(n, e);
|
|
461
473
|
let r = {
|
|
462
474
|
id: n,
|
|
463
475
|
url: t,
|
|
476
|
+
renderKey: n,
|
|
464
477
|
previewUrl: t,
|
|
465
478
|
alt: e.name,
|
|
466
479
|
status: "uploading",
|
|
@@ -468,10 +481,10 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
468
481
|
fileName: e.name,
|
|
469
482
|
mimeType: e.type
|
|
470
483
|
};
|
|
471
|
-
|
|
472
|
-
let
|
|
484
|
+
M((e) => [...e, r]);
|
|
485
|
+
let s = (e) => {
|
|
473
486
|
let t = Math.max(0, Math.min(99, e));
|
|
474
|
-
|
|
487
|
+
M((e) => e.map((e) => e.id === n ? {
|
|
475
488
|
...e,
|
|
476
489
|
progress: t,
|
|
477
490
|
status: "uploading"
|
|
@@ -481,20 +494,14 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
481
494
|
let t = new AbortController();
|
|
482
495
|
Z.current.set(n, t);
|
|
483
496
|
try {
|
|
484
|
-
let r = await
|
|
497
|
+
let r = await i(e, s, {
|
|
485
498
|
signal: t.signal,
|
|
486
|
-
...
|
|
487
|
-
...
|
|
499
|
+
...o ? { accessScope: o } : { isPublic: a ?? !1 },
|
|
500
|
+
...d ? { deduplicationNamespace: d } : {}
|
|
488
501
|
});
|
|
489
502
|
Y.current.set(n, r.id);
|
|
490
|
-
let
|
|
491
|
-
|
|
492
|
-
Q.current.delete(n);
|
|
493
|
-
try {
|
|
494
|
-
URL.revokeObjectURL(a);
|
|
495
|
-
} catch {}
|
|
496
|
-
}
|
|
497
|
-
Z.current.delete(n), X.current.delete(n), A((e) => e.map((e) => e.id === n ? {
|
|
503
|
+
let c = Q.current.get(n);
|
|
504
|
+
e.type.startsWith("image/") && await O(r.url), Z.current.delete(n), X.current.delete(n), M((e) => e.map((e) => e.id === n ? {
|
|
498
505
|
...e,
|
|
499
506
|
...r,
|
|
500
507
|
previewUrl: r.url,
|
|
@@ -502,7 +509,7 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
502
509
|
status: "uploaded",
|
|
503
510
|
progress: 100,
|
|
504
511
|
errorMessage: void 0
|
|
505
|
-
} : e));
|
|
512
|
+
} : e)), c && (Q.current.delete(n), window.requestAnimationFrame(() => URL.revokeObjectURL(c)));
|
|
506
513
|
} catch (e) {
|
|
507
514
|
if (Z.current.delete(n), t.signal.aborted) {
|
|
508
515
|
X.current.delete(n);
|
|
@@ -516,8 +523,8 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
516
523
|
return;
|
|
517
524
|
}
|
|
518
525
|
console.error("Upload failed", e);
|
|
519
|
-
let r =
|
|
520
|
-
|
|
526
|
+
let r = pe(e);
|
|
527
|
+
M((e) => e.map((e) => e.id === n ? {
|
|
521
528
|
...e,
|
|
522
529
|
status: "error",
|
|
523
530
|
progress: Math.max(0, Math.min(99, e.progress)),
|
|
@@ -526,12 +533,12 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
526
533
|
}
|
|
527
534
|
})();
|
|
528
535
|
});
|
|
529
|
-
await Promise.allSettled(
|
|
530
|
-
},
|
|
531
|
-
e.target.files && (
|
|
532
|
-
},
|
|
533
|
-
|
|
534
|
-
},
|
|
536
|
+
await Promise.allSettled(s);
|
|
537
|
+
}, Se = (e) => {
|
|
538
|
+
e.target.files && (xe(e.target.files), e.target.value = "");
|
|
539
|
+
}, Ce = () => {
|
|
540
|
+
m || D.current?.click();
|
|
541
|
+
}, we = (e) => {
|
|
535
542
|
let t = Z.current.get(e);
|
|
536
543
|
if (t) {
|
|
537
544
|
Z.current.delete(e);
|
|
@@ -547,9 +554,9 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
547
554
|
URL.revokeObjectURL(n);
|
|
548
555
|
} catch {}
|
|
549
556
|
}
|
|
550
|
-
|
|
551
|
-
},
|
|
552
|
-
if (
|
|
557
|
+
M((t) => t.filter((t) => t.id !== e));
|
|
558
|
+
}, Te = (e) => {
|
|
559
|
+
if (m) return;
|
|
553
560
|
let t = X.current.get(e);
|
|
554
561
|
if (!t) return;
|
|
555
562
|
let n = Z.current.get(e);
|
|
@@ -559,7 +566,7 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
559
566
|
} catch {}
|
|
560
567
|
Z.current.delete(e);
|
|
561
568
|
}
|
|
562
|
-
|
|
569
|
+
M((t) => t.map((t) => t.id === e ? {
|
|
563
570
|
...t,
|
|
564
571
|
status: "uploading",
|
|
565
572
|
progress: 0,
|
|
@@ -567,28 +574,22 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
567
574
|
} : t));
|
|
568
575
|
let r = (t) => {
|
|
569
576
|
let n = Math.max(0, Math.min(99, t));
|
|
570
|
-
|
|
577
|
+
M((t) => t.map((t) => t.id === e ? {
|
|
571
578
|
...t,
|
|
572
579
|
progress: n,
|
|
573
580
|
status: "uploading"
|
|
574
581
|
} : t));
|
|
575
|
-
},
|
|
576
|
-
Z.current.set(e,
|
|
582
|
+
}, s = new AbortController();
|
|
583
|
+
Z.current.set(e, s), (async () => {
|
|
577
584
|
try {
|
|
578
|
-
let n = await
|
|
579
|
-
signal:
|
|
580
|
-
...
|
|
581
|
-
...
|
|
585
|
+
let n = await i(t, r, {
|
|
586
|
+
signal: s.signal,
|
|
587
|
+
...o ? { accessScope: o } : { isPublic: a ?? !1 },
|
|
588
|
+
...d ? { deduplicationNamespace: d } : {}
|
|
582
589
|
});
|
|
583
590
|
Y.current.set(e, n.id);
|
|
584
|
-
let
|
|
585
|
-
|
|
586
|
-
Q.current.delete(e);
|
|
587
|
-
try {
|
|
588
|
-
URL.revokeObjectURL(a);
|
|
589
|
-
} catch {}
|
|
590
|
-
}
|
|
591
|
-
Z.current.delete(e), X.current.delete(e), A((t) => t.map((t) => t.id === e ? {
|
|
591
|
+
let c = Q.current.get(e);
|
|
592
|
+
t.type.startsWith("image/") && await O(n.url), Z.current.delete(e), X.current.delete(e), M((t) => t.map((t) => t.id === e ? {
|
|
592
593
|
...t,
|
|
593
594
|
...n,
|
|
594
595
|
previewUrl: n.url,
|
|
@@ -596,60 +597,60 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
596
597
|
status: "uploaded",
|
|
597
598
|
progress: 100,
|
|
598
599
|
errorMessage: void 0
|
|
599
|
-
} : t));
|
|
600
|
+
} : t)), c && (Q.current.delete(e), window.requestAnimationFrame(() => URL.revokeObjectURL(c)));
|
|
600
601
|
} catch (t) {
|
|
601
|
-
if (Z.current.delete(e),
|
|
602
|
+
if (Z.current.delete(e), s.signal.aborted) return;
|
|
602
603
|
console.error("Retry failed", t);
|
|
603
|
-
let n =
|
|
604
|
-
|
|
604
|
+
let n = pe(t);
|
|
605
|
+
M((t) => t.map((t) => t.id === e ? {
|
|
605
606
|
...t,
|
|
606
607
|
status: "error",
|
|
607
608
|
errorMessage: n
|
|
608
609
|
} : t));
|
|
609
610
|
}
|
|
610
611
|
})();
|
|
611
|
-
},
|
|
612
|
+
}, Ee = (e) => {
|
|
612
613
|
let t = k.findIndex((t) => t.id === e);
|
|
613
|
-
t !== -1 &&
|
|
614
|
-
},
|
|
615
|
-
|
|
616
|
-
},
|
|
617
|
-
|
|
614
|
+
t !== -1 && F(t);
|
|
615
|
+
}, De = () => {
|
|
616
|
+
V.current !== null && (window.clearTimeout(V.current.timeout), V.current = null), z(null);
|
|
617
|
+
}, Oe = (e) => {
|
|
618
|
+
V.current !== null && window.clearTimeout(V.current.timeout), V.current = {
|
|
618
619
|
id: e,
|
|
619
620
|
timeout: window.setTimeout(() => {
|
|
620
|
-
|
|
621
|
-
},
|
|
621
|
+
V.current = null, z((t) => t === e ? null : t);
|
|
622
|
+
}, A)
|
|
622
623
|
};
|
|
623
|
-
}, Oe = (e) => {
|
|
624
|
-
V.current && (R(e), De(e)), L(null);
|
|
625
624
|
}, ke = (e) => {
|
|
626
|
-
|
|
625
|
+
H.current && (z(e), Oe(e)), R(null);
|
|
627
626
|
}, Ae = (e) => {
|
|
627
|
+
De(), R(String(e.active.id));
|
|
628
|
+
}, je = (e) => {
|
|
628
629
|
let { active: t, over: n } = e, r = String(t.id);
|
|
629
630
|
if (!n) {
|
|
630
|
-
|
|
631
|
+
ke(r);
|
|
631
632
|
return;
|
|
632
633
|
}
|
|
633
634
|
let i = String(n.id);
|
|
634
|
-
r !== i &&
|
|
635
|
+
r !== i && M((e) => {
|
|
635
636
|
let t = e.findIndex((e) => e.id === r), n = e.findIndex((e) => e.id === i);
|
|
636
|
-
return t === -1 || n === -1 ? e :
|
|
637
|
-
}),
|
|
638
|
-
},
|
|
639
|
-
if (
|
|
640
|
-
|
|
637
|
+
return t === -1 || n === -1 ? e : oe(e, t, n);
|
|
638
|
+
}), ke(r);
|
|
639
|
+
}, Me = () => {
|
|
640
|
+
if (L) {
|
|
641
|
+
ke(L);
|
|
641
642
|
return;
|
|
642
643
|
}
|
|
643
|
-
|
|
644
|
-
},
|
|
645
|
-
|
|
646
|
-
},
|
|
647
|
-
if (
|
|
648
|
-
}, [
|
|
649
|
-
if (
|
|
650
|
-
let e =
|
|
644
|
+
R(null);
|
|
645
|
+
}, Ne = () => {
|
|
646
|
+
B.current !== null && (window.clearTimeout(B.current), B.current = null);
|
|
647
|
+
}, Pe = c(() => P === null ? null : k[P] ?? null, [P, k]), Fe = e(E === "bare" ? "rounded-lg transition-colors" : "rounded-xl border border-dashed border-slate-300 bg-white/70 p-4 shadow-sm transition-colors dark:border-slate-700 dark:bg-slate-900/60", ge && (E === "bare" ? "bg-primary/5 ring-2 ring-primary/50" : "border-primary ring-2 ring-primary/50"), m && "opacity-70"), Ie = "group relative size-20 overflow-visible rounded-lg border border-slate-200 bg-slate-50 shadow-inner transition hover:shadow md:size-24 dark:border-slate-700 dark:bg-slate-800", Le = c(() => {
|
|
648
|
+
if (S) return Array.isArray(S) ? S.join(",") : S;
|
|
649
|
+
}, [S]), Re = c(() => {
|
|
650
|
+
if (C || !Le) return !1;
|
|
651
|
+
let e = Le.split(",").map((e) => e.trim()).filter(Boolean);
|
|
651
652
|
return e.length ? e.every((e) => e === "image/*" || e.startsWith("image/") || e === ".heic" || e === ".heif" || e === ".heics" || e === ".heifs") : !1;
|
|
652
|
-
}, [
|
|
653
|
+
}, [Le, C]), ze = (e) => Re || !C && he(e), Be = typeof f == "number" && Number.isFinite(f) && f > 0 ? Math.floor(f) : null, Ve = !m && (Be === null || k.length < Be), $ = k.find((e) => e.status === "error") ?? k.find((e) => e.status === "uploading"), He = $ ? $.status === "error" ? me($.errorMessage) : `${$.fileName ?? $.alt ?? "File"}: ${$.progress}%` : "", Ue = (e) => ({
|
|
653
654
|
file: {
|
|
654
655
|
id: e.id,
|
|
655
656
|
url: e.url,
|
|
@@ -660,126 +661,126 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
660
661
|
status: e.status,
|
|
661
662
|
progress: e.progress,
|
|
662
663
|
fileName: e.fileName
|
|
663
|
-
}),
|
|
664
|
-
let e = k.find((e) => e.id ===
|
|
664
|
+
}), We = L ? (() => {
|
|
665
|
+
let e = k.find((e) => e.id === L);
|
|
665
666
|
if (!e) return null;
|
|
666
|
-
if (
|
|
667
|
-
let t =
|
|
668
|
-
return t == null || t === !1 ? null : /* @__PURE__ */
|
|
667
|
+
if (C) {
|
|
668
|
+
let t = C(Ue(e));
|
|
669
|
+
return t == null || t === !1 ? null : /* @__PURE__ */ h("div", {
|
|
669
670
|
className: "pointer-events-none",
|
|
670
|
-
children: /* @__PURE__ */
|
|
671
|
+
children: /* @__PURE__ */ h("div", {
|
|
671
672
|
className: "h-24 w-24 overflow-hidden rounded-lg shadow-2xl",
|
|
672
673
|
children: t
|
|
673
674
|
})
|
|
674
675
|
});
|
|
675
676
|
}
|
|
676
|
-
return
|
|
677
|
+
return ze(e) ? /* @__PURE__ */ h("div", {
|
|
677
678
|
className: "pointer-events-none",
|
|
678
|
-
children: /* @__PURE__ */
|
|
679
|
+
children: /* @__PURE__ */ h(t, {
|
|
679
680
|
src: e.previewUrl,
|
|
680
681
|
alt: e.alt ?? "Dragged image",
|
|
681
682
|
sizes: "96px",
|
|
682
683
|
className: "h-24 w-24 rounded-lg object-cover shadow-2xl"
|
|
683
684
|
})
|
|
684
685
|
}) : null;
|
|
685
|
-
})() : null,
|
|
686
|
-
return
|
|
686
|
+
})() : null, Ge = We != null, Ke = Ge ? L : ve;
|
|
687
|
+
return H.current = Ge, /* @__PURE__ */ g("div", {
|
|
687
688
|
onDragOver: (e) => {
|
|
688
|
-
e.preventDefault(),
|
|
689
|
+
e.preventDefault(), Ve && N(!0);
|
|
689
690
|
},
|
|
690
|
-
onDragLeave: () =>
|
|
691
|
+
onDragLeave: () => N(!1),
|
|
691
692
|
onDrop: (e) => {
|
|
692
|
-
e.preventDefault(),
|
|
693
|
+
e.preventDefault(), N(!1), Ve && e.dataTransfer.files?.length && xe(e.dataTransfer.files);
|
|
693
694
|
},
|
|
694
|
-
className:
|
|
695
|
+
className: Fe,
|
|
695
696
|
children: [
|
|
696
|
-
|
|
697
|
+
le ? /* @__PURE__ */ h("div", {
|
|
697
698
|
className: "mb-3",
|
|
698
|
-
children:
|
|
699
|
+
children: le()
|
|
699
700
|
}) : null,
|
|
700
|
-
/* @__PURE__ */
|
|
701
|
+
/* @__PURE__ */ h("div", {
|
|
701
702
|
role: "status",
|
|
702
703
|
className: "sr-only",
|
|
703
|
-
children:
|
|
704
|
+
children: He
|
|
704
705
|
}),
|
|
705
|
-
/* @__PURE__ */
|
|
706
|
-
sensors:
|
|
707
|
-
collisionDetection:
|
|
708
|
-
onDragStart:
|
|
709
|
-
onDragEnd:
|
|
710
|
-
onDragCancel:
|
|
711
|
-
children: [/* @__PURE__ */
|
|
706
|
+
/* @__PURE__ */ g(_, {
|
|
707
|
+
sensors: m ? void 0 : be,
|
|
708
|
+
collisionDetection: ie,
|
|
709
|
+
onDragStart: Ae,
|
|
710
|
+
onDragEnd: je,
|
|
711
|
+
onDragCancel: Me,
|
|
712
|
+
children: [/* @__PURE__ */ h(x, {
|
|
712
713
|
items: k.map((e) => e.id),
|
|
713
|
-
strategy:
|
|
714
|
-
children: /* @__PURE__ */
|
|
714
|
+
strategy: se,
|
|
715
|
+
children: /* @__PURE__ */ g("div", {
|
|
715
716
|
className: "flex flex-wrap gap-3",
|
|
716
717
|
children: [k.map((e) => {
|
|
717
718
|
let t = e.status === "uploading", n = e.status === "error";
|
|
718
|
-
return /* @__PURE__ */
|
|
719
|
+
return /* @__PURE__ */ h(de, {
|
|
719
720
|
item: e,
|
|
720
|
-
isHovered:
|
|
721
|
-
enableImagePreview:
|
|
722
|
-
renderItem:
|
|
721
|
+
isHovered: I === e.id,
|
|
722
|
+
enableImagePreview: ze(e),
|
|
723
|
+
renderItem: C,
|
|
723
724
|
onHoverEnter: () => {
|
|
724
|
-
|
|
725
|
+
Ne(), _e(e.id);
|
|
725
726
|
},
|
|
726
727
|
onHoverLeave: () => {
|
|
727
|
-
|
|
728
|
-
|
|
728
|
+
Ne(), B.current = window.setTimeout(() => {
|
|
729
|
+
_e((t) => t === e.id ? null : t), B.current = null;
|
|
729
730
|
}, 120);
|
|
730
731
|
},
|
|
731
|
-
onRemove:
|
|
732
|
-
onRetry:
|
|
733
|
-
startFullscreen:
|
|
732
|
+
onRemove: we,
|
|
733
|
+
onRetry: Te,
|
|
734
|
+
startFullscreen: Ee,
|
|
734
735
|
isUploading: t,
|
|
735
736
|
isError: n,
|
|
736
|
-
tileClasses:
|
|
737
|
-
disabled:
|
|
738
|
-
isDraggingExternal:
|
|
739
|
-
removeButtonAriaLabel:
|
|
740
|
-
}, e.
|
|
741
|
-
}),
|
|
737
|
+
tileClasses: Ie,
|
|
738
|
+
disabled: m,
|
|
739
|
+
isDraggingExternal: Ke === e.id,
|
|
740
|
+
removeButtonAriaLabel: T
|
|
741
|
+
}, e.renderKey);
|
|
742
|
+
}), Ve && (E === "bare" && k.length === 0 ? /* @__PURE__ */ g("button", {
|
|
742
743
|
type: "button",
|
|
743
|
-
onClick:
|
|
744
|
-
disabled:
|
|
744
|
+
onClick: Ce,
|
|
745
|
+
disabled: m,
|
|
745
746
|
className: "flex w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-slate-300 px-4 py-6 text-slate-500 transition-colors hover:border-slate-400 hover:bg-slate-50 hover:text-slate-600 dark:border-slate-700 dark:hover:bg-slate-800/50",
|
|
746
|
-
"aria-label":
|
|
747
|
+
"aria-label": w,
|
|
747
748
|
children: [
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
749
|
+
/* @__PURE__ */ h(p, { className: "h-5 w-5" }),
|
|
750
|
+
/* @__PURE__ */ h("span", {
|
|
750
751
|
className: "text-xs font-medium",
|
|
751
|
-
children:
|
|
752
|
+
children: w
|
|
752
753
|
}),
|
|
753
|
-
/* @__PURE__ */
|
|
754
|
+
/* @__PURE__ */ h("span", {
|
|
754
755
|
className: "text-[11px] text-slate-400 dark:text-slate-500",
|
|
755
756
|
children: "ou glissez-déposez ici"
|
|
756
757
|
})
|
|
757
758
|
]
|
|
758
|
-
}) :
|
|
759
|
+
}) : E === "bare" ? /* @__PURE__ */ h("button", {
|
|
759
760
|
type: "button",
|
|
760
|
-
onClick:
|
|
761
|
-
disabled:
|
|
761
|
+
onClick: Ce,
|
|
762
|
+
disabled: m,
|
|
762
763
|
className: "flex size-20 items-center justify-center rounded-lg border border-dashed border-slate-300 text-slate-400 transition-colors hover:border-slate-400 hover:bg-slate-50 hover:text-slate-600 md:size-24 dark:border-slate-700 dark:hover:bg-slate-800/50 dark:hover:text-slate-300",
|
|
763
|
-
"aria-label":
|
|
764
|
-
children: /* @__PURE__ */
|
|
764
|
+
"aria-label": w,
|
|
765
|
+
children: /* @__PURE__ */ g("div", {
|
|
765
766
|
className: "flex flex-col items-center gap-1",
|
|
766
|
-
children: [/* @__PURE__ */
|
|
767
|
+
children: [/* @__PURE__ */ h(p, { className: "h-4 w-4" }), /* @__PURE__ */ h("span", {
|
|
767
768
|
className: "text-[11px] font-medium",
|
|
768
769
|
children: "Ajouter"
|
|
769
770
|
})]
|
|
770
771
|
})
|
|
771
|
-
}) : /* @__PURE__ */
|
|
772
|
+
}) : /* @__PURE__ */ h("button", {
|
|
772
773
|
type: "button",
|
|
773
|
-
onClick:
|
|
774
|
-
disabled:
|
|
775
|
-
className: e(
|
|
776
|
-
"aria-label":
|
|
777
|
-
children: /* @__PURE__ */
|
|
774
|
+
onClick: Ce,
|
|
775
|
+
disabled: m,
|
|
776
|
+
className: e(Ie, "flex items-center justify-center border-dashed bg-white text-slate-500 hover:border-slate-300 dark:bg-slate-900"),
|
|
777
|
+
"aria-label": w,
|
|
778
|
+
children: /* @__PURE__ */ g("div", {
|
|
778
779
|
className: "flex flex-col items-center gap-1",
|
|
779
|
-
children: [/* @__PURE__ */
|
|
780
|
+
children: [/* @__PURE__ */ h("div", {
|
|
780
781
|
className: "flex size-9 items-center justify-center rounded-full border border-slate-300 bg-slate-100 text-slate-600 shadow-inner dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200",
|
|
781
|
-
children: /* @__PURE__ */
|
|
782
|
-
}), /* @__PURE__ */
|
|
782
|
+
children: /* @__PURE__ */ h(p, { className: "h-5 w-5" })
|
|
783
|
+
}), /* @__PURE__ */ h("span", {
|
|
783
784
|
className: "text-xs font-medium",
|
|
784
785
|
children: "Ajouter"
|
|
785
786
|
})]
|
|
@@ -787,71 +788,71 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
787
788
|
}))]
|
|
788
789
|
})
|
|
789
790
|
}), (() => {
|
|
790
|
-
let e = /* @__PURE__ */
|
|
791
|
-
dropAnimation:
|
|
792
|
-
children:
|
|
791
|
+
let e = /* @__PURE__ */ h(v, {
|
|
792
|
+
dropAnimation: ye.current,
|
|
793
|
+
children: We
|
|
793
794
|
});
|
|
794
|
-
return typeof document > "u" ? e :
|
|
795
|
+
return typeof document > "u" ? e : te(e, document.body);
|
|
795
796
|
})()]
|
|
796
797
|
}),
|
|
797
|
-
/* @__PURE__ */
|
|
798
|
-
ref:
|
|
798
|
+
/* @__PURE__ */ h("input", {
|
|
799
|
+
ref: D,
|
|
799
800
|
type: "file",
|
|
800
|
-
accept:
|
|
801
|
-
multiple:
|
|
802
|
-
disabled: !
|
|
801
|
+
accept: Le,
|
|
802
|
+
multiple: Be !== 1,
|
|
803
|
+
disabled: !Ve,
|
|
803
804
|
className: "hidden",
|
|
804
|
-
onChange:
|
|
805
|
+
onChange: Se,
|
|
805
806
|
"aria-hidden": !0
|
|
806
807
|
}),
|
|
807
|
-
|
|
808
|
+
Pe && ze(Pe) && /* @__PURE__ */ g("div", {
|
|
808
809
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/90",
|
|
809
810
|
children: [
|
|
810
|
-
/* @__PURE__ */
|
|
811
|
+
/* @__PURE__ */ h("button", {
|
|
811
812
|
type: "button",
|
|
812
813
|
className: "absolute left-6 top-1/2 -translate-y-1/2 rounded-full bg-white/10 p-3 text-white shadow-lg transition hover:bg-white/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
|
|
813
|
-
onClick: () =>
|
|
814
|
+
onClick: () => F((e) => e === null ? e : (e - 1 + k.length) % k.length),
|
|
814
815
|
"aria-label": "Précédent",
|
|
815
|
-
children: /* @__PURE__ */
|
|
816
|
+
children: /* @__PURE__ */ h("svg", {
|
|
816
817
|
viewBox: "0 0 24 24",
|
|
817
818
|
className: "h-6 w-6",
|
|
818
819
|
stroke: "currentColor",
|
|
819
820
|
strokeWidth: 2,
|
|
820
821
|
fill: "none",
|
|
821
|
-
children: /* @__PURE__ */
|
|
822
|
+
children: /* @__PURE__ */ h("path", {
|
|
822
823
|
d: "M15 18l-6-6 6-6",
|
|
823
824
|
strokeLinecap: "round",
|
|
824
825
|
strokeLinejoin: "round"
|
|
825
826
|
})
|
|
826
827
|
})
|
|
827
828
|
}),
|
|
828
|
-
/* @__PURE__ */
|
|
829
|
+
/* @__PURE__ */ g("div", {
|
|
829
830
|
className: "relative max-h-[80vh] max-w-4xl",
|
|
830
|
-
children: [/* @__PURE__ */
|
|
831
|
-
src:
|
|
832
|
-
alt:
|
|
831
|
+
children: [/* @__PURE__ */ h(t, {
|
|
832
|
+
src: Pe.url,
|
|
833
|
+
alt: Pe.alt ?? "Fullscreen",
|
|
833
834
|
sizes: "(max-width: 1024px) 100vw, 1024px",
|
|
834
835
|
className: "max-h-[80vh] max-w-full rounded-lg object-contain shadow-2xl"
|
|
835
|
-
}), /* @__PURE__ */
|
|
836
|
+
}), /* @__PURE__ */ h("button", {
|
|
836
837
|
type: "button",
|
|
837
838
|
className: "absolute right-3 top-3 inline-flex size-9 items-center justify-center rounded-full bg-black/70 text-white transition hover:bg-black focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
|
|
838
|
-
onClick: () =>
|
|
839
|
+
onClick: () => F(null),
|
|
839
840
|
"aria-label": "Fermer",
|
|
840
|
-
children: /* @__PURE__ */
|
|
841
|
+
children: /* @__PURE__ */ h(ee, { className: "h-5 w-5" })
|
|
841
842
|
})]
|
|
842
843
|
}),
|
|
843
|
-
/* @__PURE__ */
|
|
844
|
+
/* @__PURE__ */ h("button", {
|
|
844
845
|
type: "button",
|
|
845
846
|
className: "absolute right-6 top-1/2 -translate-y-1/2 rounded-full bg-white/10 p-3 text-white shadow-lg transition hover:bg-white/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
|
|
846
|
-
onClick: () =>
|
|
847
|
+
onClick: () => F((e) => e === null ? e : (e + 1) % k.length),
|
|
847
848
|
"aria-label": "Suivant",
|
|
848
|
-
children: /* @__PURE__ */
|
|
849
|
+
children: /* @__PURE__ */ h("svg", {
|
|
849
850
|
viewBox: "0 0 24 24",
|
|
850
851
|
className: "h-6 w-6",
|
|
851
852
|
stroke: "currentColor",
|
|
852
853
|
strokeWidth: 2,
|
|
853
854
|
fill: "none",
|
|
854
|
-
children: /* @__PURE__ */
|
|
855
|
+
children: /* @__PURE__ */ h("path", {
|
|
855
856
|
d: "M9 6l6 6-6 6",
|
|
856
857
|
strokeLinecap: "round",
|
|
857
858
|
strokeLinejoin: "round"
|
|
@@ -864,6 +865,6 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
|
|
|
864
865
|
});
|
|
865
866
|
}
|
|
866
867
|
//#endregion
|
|
867
|
-
export {
|
|
868
|
+
export { M as FilesUploadField };
|
|
868
869
|
|
|
869
870
|
//# sourceMappingURL=index299.js.map
|