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