@vlrc-fe/components 1.0.9 → 1.0.11
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/Form/FormDatePicker/SingleDatePicker.d.ts.map +1 -1
- package/dist/index100.js +30 -17
- package/dist/index101.cjs +1 -1
- package/dist/index102.js +35 -19
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +29 -19
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +98 -55
- package/dist/index105.cjs +1 -1
- package/dist/index105.js +86 -48
- package/dist/index106.cjs +1 -1
- package/dist/index106.js +12 -6
- package/dist/index107.cjs +1 -1
- package/dist/index107.js +23 -16
- package/dist/index108.cjs +1 -1
- package/dist/index108.js +205 -120
- package/dist/index109.cjs +1 -1
- package/dist/index11.js +105 -53
- package/dist/index113.js +12 -6
- package/dist/index114.cjs +1 -1
- package/dist/index115.js +18 -10
- package/dist/index116.cjs +1 -1
- package/dist/index116.js +82 -41
- package/dist/index117.cjs +1 -1
- package/dist/index118.js +42 -21
- package/dist/index119.cjs +1 -1
- package/dist/index119.js +12 -6
- package/dist/index12.cjs +1 -1
- package/dist/index120.cjs +1 -1
- package/dist/index121.js +18 -12
- package/dist/index122.cjs +1 -1
- package/dist/index123.js +42 -28
- package/dist/index124.cjs +1 -1
- package/dist/index126.js +86 -57
- package/dist/index127.cjs +1 -1
- package/dist/index127.js +30 -17
- package/dist/index128.cjs +1 -1
- package/dist/index128.js +42 -27
- package/dist/index129.cjs +1 -1
- package/dist/index129.js +31 -18
- package/dist/index130.cjs +1 -1
- package/dist/index132.js +50 -23
- package/dist/index133.cjs +1 -1
- package/dist/index133.js +28 -14
- package/dist/index134.cjs +1 -1
- package/dist/index135.js +147 -99
- package/dist/index136.cjs +1 -1
- package/dist/index138.js +242 -170
- package/dist/index139.cjs +1 -1
- package/dist/index14.js +9 -5
- package/dist/index141.js +21 -10
- package/dist/index142.cjs +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index18.js +32 -16
- package/dist/index186.js +57 -44
- package/dist/index187.cjs +1 -1
- package/dist/index187.js +56 -48
- package/dist/index188.cjs +1 -1
- package/dist/index188.js +16 -12
- package/dist/index189.cjs +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index191.js +36 -23
- package/dist/index192.cjs +1 -1
- package/dist/index197.js +18 -15
- package/dist/index198.cjs +1 -1
- package/dist/index20.js +79 -41
- package/dist/index200.js +49 -33
- package/dist/index201.cjs +1 -1
- package/dist/index201.js +20 -11
- package/dist/index202.cjs +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +30 -23
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +75 -39
- package/dist/index23.cjs +1 -1
- package/dist/index26.js +39 -28
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +20 -12
- package/dist/index28.cjs +1 -1
- package/dist/index33.js +23 -13
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +87 -49
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +86 -45
- package/dist/index36.cjs +1 -1
- package/dist/index4.js +49 -26
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +34 -18
- package/dist/index6.cjs +1 -1
- package/dist/index75.js +142 -77
- package/dist/index76.cjs +1 -1
- package/dist/index77.js +96 -49
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +137 -77
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +13 -7
- package/dist/index80.cjs +1 -1
- package/dist/index81.js +130 -63
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +201 -158
- package/dist/index83.cjs +1 -1
- package/dist/index84.js +97 -59
- package/dist/index85.cjs +1 -1
- package/dist/index86.js +17 -10
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +13 -7
- package/dist/index88.cjs +1 -1
- package/dist/index89.js +54 -28
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +94 -53
- package/dist/index91.cjs +1 -1
- package/dist/index92.js +156 -89
- package/dist/index93.cjs +1 -1
- package/dist/index96.js +89 -47
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +78 -43
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +27 -17
- package/dist/index99.cjs +1 -1
- package/package.json +1 -1
package/dist/index82.js
CHANGED
|
@@ -3,15 +3,20 @@ import { cn as e } from "./index3.js";
|
|
|
3
3
|
import { FileArchiveIcon as t, FileAudioIcon as n, FileCodeIcon as r, FileCogIcon as i, FileIcon as a, FileTextIcon as o, FileVideoIcon as s } from "lucide-react";
|
|
4
4
|
import * as c from "react";
|
|
5
5
|
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { c as f } from "react/compiler-runtime";
|
|
7
|
+
import { Slot as p } from "@radix-ui/react-slot";
|
|
8
|
+
import { useDirection as m } from "@radix-ui/react-direction";
|
|
8
9
|
//#region src/ui/file-upload.tsx
|
|
9
|
-
var
|
|
10
|
-
function
|
|
11
|
-
let t = c.useRef(null);
|
|
12
|
-
|
|
10
|
+
var h = "FileUpload", g = "FileUploadDropzone", _ = "FileUploadTrigger", v = "FileUploadList", y = "FileUploadItem", b = "FileUploadItemPreview", x = "FileUploadItemMetadata", S = "FileUploadItemProgress", C = "FileUploadItemDelete", w = "FileUploadClear";
|
|
11
|
+
function T(e) {
|
|
12
|
+
let t = f(2), n = c.useRef(null);
|
|
13
|
+
if (n.current === null) {
|
|
14
|
+
let r;
|
|
15
|
+
t[0] === e ? r = t[1] : (r = e(), t[0] = e, t[1] = r), n.current = r;
|
|
16
|
+
}
|
|
17
|
+
return n;
|
|
13
18
|
}
|
|
14
|
-
function
|
|
19
|
+
function E(e, t, n, r, i) {
|
|
15
20
|
let a = {
|
|
16
21
|
files: t,
|
|
17
22
|
dragOver: !1,
|
|
@@ -121,42 +126,43 @@ function T(e, t, n, r, i) {
|
|
|
121
126
|
subscribe: l
|
|
122
127
|
};
|
|
123
128
|
}
|
|
124
|
-
var
|
|
125
|
-
function
|
|
126
|
-
let t = c.useContext(
|
|
127
|
-
if (!t) throw Error(`\`${e}\` must be used within \`${
|
|
129
|
+
var D = c.createContext(null);
|
|
130
|
+
function O(e) {
|
|
131
|
+
let t = c.useContext(D);
|
|
132
|
+
if (!t) throw Error(`\`${e}\` must be used within \`${h}\``);
|
|
128
133
|
return t;
|
|
129
134
|
}
|
|
130
|
-
function
|
|
131
|
-
let t =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
function k(e) {
|
|
136
|
+
let t = f(4), n = O("useStore"), r = T(A), i;
|
|
137
|
+
t[0] !== r || t[1] !== e || t[2] !== n ? (i = () => {
|
|
138
|
+
let t = n.getState(), i = r.current;
|
|
139
|
+
if (i && i.state === t) return i.value;
|
|
140
|
+
let a = e(t);
|
|
141
|
+
return r.current = {
|
|
136
142
|
value: a,
|
|
137
|
-
state:
|
|
143
|
+
state: t
|
|
138
144
|
}, a;
|
|
139
|
-
}, [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
n
|
|
143
|
-
]);
|
|
144
|
-
return c.useSyncExternalStore(t.subscribe, r, r);
|
|
145
|
+
}, t[0] = r, t[1] = e, t[2] = n, t[3] = i) : i = t[3];
|
|
146
|
+
let a = i;
|
|
147
|
+
return c.useSyncExternalStore(n.subscribe, a, a);
|
|
145
148
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
function A() {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
var j = c.createContext(null);
|
|
153
|
+
function M(e) {
|
|
154
|
+
let t = c.useContext(j);
|
|
155
|
+
if (!t) throw Error(`\`${e}\` must be used within \`${h}\``);
|
|
150
156
|
return t;
|
|
151
157
|
}
|
|
152
|
-
function
|
|
153
|
-
let { value: n, defaultValue: r, onValueChange: i, onAccept: a, onFileAccept: o, onFileReject: s, onFileValidate: l, onUpload:
|
|
158
|
+
function N(t) {
|
|
159
|
+
let { value: n, defaultValue: r, onValueChange: i, onAccept: a, onFileAccept: o, onFileReject: s, onFileValidate: l, onUpload: f, accept: h, maxFiles: g, maxSize: _, dir: v, label: y, name: b, asChild: x, disabled: S = !1, invalid: C = !1, multiple: w = !1, required: O = !1, children: k, className: A, ...M } = t, N = c.useId(), P = c.useId(), F = c.useId(), I = c.useId(), L = m(v), R = T(() => /* @__PURE__ */ new Set()).current, z = T(() => /* @__PURE__ */ new Map()).current, B = T(() => /* @__PURE__ */ new WeakMap()).current, V = c.useRef(null), H = n !== void 0, U = c.useMemo(() => E(R, z, B, C, i), [
|
|
154
160
|
R,
|
|
155
161
|
z,
|
|
156
162
|
C,
|
|
157
163
|
i,
|
|
158
164
|
B
|
|
159
|
-
]), W = c.useMemo(() => h?.split(",").map((e) => e.trim()) ?? null, [h]), G =
|
|
165
|
+
]), W = c.useMemo(() => h?.split(",").map((e) => e.trim()) ?? null, [h]), G = T(() => {
|
|
160
166
|
let e = 0;
|
|
161
167
|
return (t, n) => {
|
|
162
168
|
e ||= requestAnimationFrame(() => {
|
|
@@ -194,7 +200,7 @@ function j(t) {
|
|
|
194
200
|
file: t,
|
|
195
201
|
progress: 0
|
|
196
202
|
});
|
|
197
|
-
if (
|
|
203
|
+
if (f) await f(e, {
|
|
198
204
|
onProgress: G,
|
|
199
205
|
onSuccess: (e) => {
|
|
200
206
|
U.dispatch({
|
|
@@ -224,7 +230,7 @@ function j(t) {
|
|
|
224
230
|
}
|
|
225
231
|
}, [
|
|
226
232
|
U,
|
|
227
|
-
|
|
233
|
+
f,
|
|
228
234
|
G
|
|
229
235
|
]), q = c.useCallback((e) => {
|
|
230
236
|
if (S) return;
|
|
@@ -284,7 +290,7 @@ function j(t) {
|
|
|
284
290
|
files: r
|
|
285
291
|
}), H && i && i([...Array.from(U.getState().files.values()).map((e) => e.file)]), a && a(r);
|
|
286
292
|
for (let e of r) o?.(e);
|
|
287
|
-
|
|
293
|
+
f && requestAnimationFrame(() => {
|
|
288
294
|
K(r);
|
|
289
295
|
});
|
|
290
296
|
}
|
|
@@ -294,7 +300,7 @@ function j(t) {
|
|
|
294
300
|
i,
|
|
295
301
|
a,
|
|
296
302
|
o,
|
|
297
|
-
|
|
303
|
+
f,
|
|
298
304
|
K,
|
|
299
305
|
g,
|
|
300
306
|
l,
|
|
@@ -321,19 +327,19 @@ function j(t) {
|
|
|
321
327
|
L,
|
|
322
328
|
S,
|
|
323
329
|
B
|
|
324
|
-
]), X = x ?
|
|
325
|
-
return /* @__PURE__ */ u(
|
|
330
|
+
]), X = x ? p : "div";
|
|
331
|
+
return /* @__PURE__ */ u(D.Provider, {
|
|
326
332
|
value: U,
|
|
327
|
-
children: /* @__PURE__ */ u(
|
|
333
|
+
children: /* @__PURE__ */ u(j.Provider, {
|
|
328
334
|
value: Y,
|
|
329
335
|
children: /* @__PURE__ */ d(X, {
|
|
330
336
|
"data-disabled": S ? "" : void 0,
|
|
331
337
|
"data-slot": "file-upload",
|
|
332
338
|
dir: L,
|
|
333
339
|
...M,
|
|
334
|
-
className: e("relative flex flex-col gap-2",
|
|
340
|
+
className: e("relative flex flex-col gap-2", A),
|
|
335
341
|
children: [
|
|
336
|
-
|
|
342
|
+
k,
|
|
337
343
|
/* @__PURE__ */ u("input", {
|
|
338
344
|
type: "file",
|
|
339
345
|
id: N,
|
|
@@ -345,7 +351,7 @@ function j(t) {
|
|
|
345
351
|
name: b,
|
|
346
352
|
className: "sr-only",
|
|
347
353
|
disabled: S,
|
|
348
|
-
multiple:
|
|
354
|
+
multiple: w,
|
|
349
355
|
required: O,
|
|
350
356
|
onChange: J
|
|
351
357
|
}),
|
|
@@ -359,12 +365,12 @@ function j(t) {
|
|
|
359
365
|
})
|
|
360
366
|
});
|
|
361
367
|
}
|
|
362
|
-
function
|
|
363
|
-
let { asChild: n, className: r, onClick: i, onDragOver: a, onDragEnter: o, onDragLeave: s, onDrop: l, onPaste: d, onKeyDown:
|
|
368
|
+
function P(t) {
|
|
369
|
+
let { asChild: n, className: r, onClick: i, onDragOver: a, onDragEnter: o, onDragLeave: s, onDrop: l, onPaste: d, onKeyDown: f, ...m } = t, h = M(g), _ = O(g), v = k((e) => e.dragOver), y = k((e) => e.invalid), b = c.useCallback((e) => {
|
|
364
370
|
if (i?.(e), e.defaultPrevented) return;
|
|
365
371
|
let t = e.target;
|
|
366
|
-
t instanceof HTMLElement && t.closest("[data-slot=\"file-upload-trigger\"]") ||
|
|
367
|
-
}, [
|
|
372
|
+
t instanceof HTMLElement && t.closest("[data-slot=\"file-upload-trigger\"]") || h.inputRef.current?.click();
|
|
373
|
+
}, [h.inputRef, i]), x = c.useCallback((e) => {
|
|
368
374
|
a?.(e), !e.defaultPrevented && (e.preventDefault(), _.dispatch({
|
|
369
375
|
type: "SET_DRAG_OVER",
|
|
370
376
|
dragOver: !0
|
|
@@ -387,14 +393,14 @@ function M(t) {
|
|
|
387
393
|
type: "SET_DRAG_OVER",
|
|
388
394
|
dragOver: !1
|
|
389
395
|
});
|
|
390
|
-
let t = Array.from(e.dataTransfer.files), n =
|
|
396
|
+
let t = Array.from(e.dataTransfer.files), n = h.inputRef.current;
|
|
391
397
|
if (!n) return;
|
|
392
398
|
let r = new DataTransfer();
|
|
393
399
|
for (let e of t) r.items.add(e);
|
|
394
400
|
n.files = r.files, n.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
395
401
|
}, [
|
|
396
402
|
_,
|
|
397
|
-
|
|
403
|
+
h.inputRef,
|
|
398
404
|
l
|
|
399
405
|
]), T = c.useCallback((e) => {
|
|
400
406
|
if (d?.(e), e.defaultPrevented) return;
|
|
@@ -413,30 +419,30 @@ function M(t) {
|
|
|
413
419
|
}
|
|
414
420
|
}
|
|
415
421
|
if (n.length === 0) return;
|
|
416
|
-
let r =
|
|
422
|
+
let r = h.inputRef.current;
|
|
417
423
|
if (!r) return;
|
|
418
424
|
let i = new DataTransfer();
|
|
419
425
|
for (let e of n) i.items.add(e);
|
|
420
426
|
r.files = i.files, r.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
421
427
|
}, [
|
|
422
428
|
_,
|
|
423
|
-
|
|
429
|
+
h.inputRef,
|
|
424
430
|
d
|
|
425
431
|
]), E = c.useCallback((e) => {
|
|
426
|
-
|
|
427
|
-
}, [
|
|
428
|
-
return /* @__PURE__ */ u(n ?
|
|
432
|
+
f?.(e), !e.defaultPrevented && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), h.inputRef.current?.click());
|
|
433
|
+
}, [h.inputRef, f]);
|
|
434
|
+
return /* @__PURE__ */ u(n ? p : "div", {
|
|
429
435
|
role: "region",
|
|
430
|
-
id:
|
|
431
|
-
"aria-controls": `${
|
|
432
|
-
"aria-disabled":
|
|
436
|
+
id: h.dropzoneId,
|
|
437
|
+
"aria-controls": `${h.inputId} ${h.listId}`,
|
|
438
|
+
"aria-disabled": h.disabled,
|
|
433
439
|
"aria-invalid": y,
|
|
434
|
-
"data-disabled":
|
|
440
|
+
"data-disabled": h.disabled ? "" : void 0,
|
|
435
441
|
"data-dragging": v ? "" : void 0,
|
|
436
442
|
"data-invalid": y ? "" : void 0,
|
|
437
443
|
"data-slot": "file-upload-dropzone",
|
|
438
|
-
dir:
|
|
439
|
-
tabIndex:
|
|
444
|
+
dir: h.dir,
|
|
445
|
+
tabIndex: h.disabled ? void 0 : 0,
|
|
440
446
|
...m,
|
|
441
447
|
className: e("relative flex select-none flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 outline-none transition-colors hover:bg-accent/30 focus-visible:border-ring/50 data-disabled:pointer-events-none data-dragging:border-primary/30 data-invalid:border-destructive data-dragging:bg-accent/30 data-invalid:ring-destructive/20", r),
|
|
442
448
|
onClick: b,
|
|
@@ -448,23 +454,27 @@ function M(t) {
|
|
|
448
454
|
onPaste: T
|
|
449
455
|
});
|
|
450
456
|
}
|
|
451
|
-
function
|
|
452
|
-
let
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
457
|
+
function F(e) {
|
|
458
|
+
let t = f(14), n, r, i;
|
|
459
|
+
t[0] === e ? (n = t[1], r = t[2], i = t[3]) : ({asChild: n, onClick: r, ...i} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i);
|
|
460
|
+
let a = M(_), o;
|
|
461
|
+
t[4] !== a.inputRef || t[5] !== r ? (o = (e) => {
|
|
462
|
+
r?.(e), !e.defaultPrevented && a.inputRef.current?.click();
|
|
463
|
+
}, t[4] = a.inputRef, t[5] = r, t[6] = o) : o = t[6];
|
|
464
|
+
let s = o, c = n ? p : "button", l = a.disabled ? "" : void 0, d;
|
|
465
|
+
return t[7] !== c || t[8] !== a.disabled || t[9] !== a.inputId || t[10] !== s || t[11] !== l || t[12] !== i ? (d = /* @__PURE__ */ u(c, {
|
|
456
466
|
type: "button",
|
|
457
|
-
"aria-controls":
|
|
458
|
-
"data-disabled":
|
|
467
|
+
"aria-controls": a.inputId,
|
|
468
|
+
"data-disabled": l,
|
|
459
469
|
"data-slot": "file-upload-trigger",
|
|
460
|
-
...
|
|
461
|
-
disabled:
|
|
462
|
-
onClick:
|
|
463
|
-
});
|
|
470
|
+
...i,
|
|
471
|
+
disabled: a.disabled,
|
|
472
|
+
onClick: s
|
|
473
|
+
}), t[7] = c, t[8] = a.disabled, t[9] = a.inputId, t[10] = s, t[11] = l, t[12] = i, t[13] = d) : d = t[13], d;
|
|
464
474
|
}
|
|
465
|
-
function
|
|
466
|
-
let { className: n, orientation: r = "vertical", asChild: i, forceMount: a, ...o } = t, s =
|
|
467
|
-
return l ? /* @__PURE__ */ u(i ?
|
|
475
|
+
function I(t) {
|
|
476
|
+
let { className: n, orientation: r = "vertical", asChild: i, forceMount: a, ...o } = t, s = M(v), c = k((e) => e.files.size), l = a || c > 0;
|
|
477
|
+
return l ? /* @__PURE__ */ u(i ? p : "div", {
|
|
468
478
|
role: "list",
|
|
469
479
|
id: s.listId,
|
|
470
480
|
"aria-orientation": r,
|
|
@@ -476,52 +486,62 @@ function P(t) {
|
|
|
476
486
|
className: e("data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 flex flex-col gap-2 data-[state=active]:animate-in data-[state=inactive]:animate-out", r === "horizontal" && "flex-row overflow-x-auto p-1.5", n)
|
|
477
487
|
}) : null;
|
|
478
488
|
}
|
|
479
|
-
var
|
|
480
|
-
function
|
|
481
|
-
let t = c.useContext(
|
|
482
|
-
if (!t) throw Error(`\`${e}\` must be used within \`${
|
|
489
|
+
var L = c.createContext(null);
|
|
490
|
+
function R(e) {
|
|
491
|
+
let t = c.useContext(L);
|
|
492
|
+
if (!t) throw Error(`\`${e}\` must be used within \`${y}\``);
|
|
483
493
|
return t;
|
|
484
494
|
}
|
|
485
|
-
function
|
|
486
|
-
let
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
]);
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
495
|
+
function z(t) {
|
|
496
|
+
let n = f(36), r, i, a, o;
|
|
497
|
+
n[0] === t ? (r = n[1], i = n[2], a = n[3], o = n[4]) : ({value: o, asChild: r, className: i, ...a} = t, n[0] = t, n[1] = r, n[2] = i, n[3] = a, n[4] = o);
|
|
498
|
+
let s = c.useId(), l = `${s}-status`, m = `${s}-name`, h = `${s}-size`, g = `${s}-message`, _ = M(y), v;
|
|
499
|
+
n[5] === o ? v = n[6] : (v = (e) => e.files.get(o), n[5] = o, n[6] = v);
|
|
500
|
+
let b = k(v), x = k(B), S;
|
|
501
|
+
n[7] === o ? S = n[8] : (S = (e) => Array.from(e.files.keys()).indexOf(o) + 1, n[7] = o, n[8] = S);
|
|
502
|
+
let C = k(S), w;
|
|
503
|
+
n[9] !== b || n[10] !== s || n[11] !== g || n[12] !== m || n[13] !== h || n[14] !== l ? (w = {
|
|
504
|
+
id: s,
|
|
505
|
+
fileState: b,
|
|
506
|
+
nameId: m,
|
|
507
|
+
sizeId: h,
|
|
508
|
+
statusId: l,
|
|
509
|
+
messageId: g
|
|
510
|
+
}, n[9] = b, n[10] = s, n[11] = g, n[12] = m, n[13] = h, n[14] = l, n[15] = w) : w = n[15];
|
|
511
|
+
let T = w;
|
|
512
|
+
if (!b) return null;
|
|
513
|
+
let E = b.error ? `Error: ${b.error}` : b.status === "uploading" ? `Uploading: ${b.progress}% complete` : b.status === "success" ? "Upload complete" : "Ready to upload", D = r ? p : "div", O = `${m} ${h} ${l} ${b.error ? g : ""}`, A = _.dir, j;
|
|
514
|
+
n[16] === i ? j = n[17] : (j = e("relative flex items-center gap-2.5 rounded-md border p-3", i), n[16] = i, n[17] = j);
|
|
515
|
+
let N;
|
|
516
|
+
n[18] !== l || n[19] !== E ? (N = /* @__PURE__ */ u("span", {
|
|
517
|
+
id: l,
|
|
518
|
+
className: "sr-only",
|
|
519
|
+
children: E
|
|
520
|
+
}), n[18] = l, n[19] = E, n[20] = N) : N = n[20];
|
|
521
|
+
let P;
|
|
522
|
+
n[21] !== D || n[22] !== _.dir || n[23] !== x || n[24] !== C || n[25] !== s || n[26] !== a || n[27] !== m || n[28] !== t.children || n[29] !== O || n[30] !== j || n[31] !== N ? (P = /* @__PURE__ */ d(D, {
|
|
523
|
+
role: "listitem",
|
|
524
|
+
id: s,
|
|
525
|
+
"aria-setsize": x,
|
|
526
|
+
"aria-posinset": C,
|
|
527
|
+
"aria-describedby": O,
|
|
528
|
+
"aria-labelledby": m,
|
|
529
|
+
"data-slot": "file-upload-item",
|
|
530
|
+
dir: A,
|
|
531
|
+
...a,
|
|
532
|
+
className: j,
|
|
533
|
+
children: [t.children, N]
|
|
534
|
+
}), n[21] = D, n[22] = _.dir, n[23] = x, n[24] = C, n[25] = s, n[26] = a, n[27] = m, n[28] = t.children, n[29] = O, n[30] = j, n[31] = N, n[32] = P) : P = n[32];
|
|
535
|
+
let F;
|
|
536
|
+
return n[33] !== T || n[34] !== P ? (F = /* @__PURE__ */ u(L.Provider, {
|
|
537
|
+
value: T,
|
|
538
|
+
children: P
|
|
539
|
+
}), n[33] = T, n[34] = P, n[35] = F) : F = n[35], F;
|
|
523
540
|
}
|
|
524
|
-
function
|
|
541
|
+
function B(e) {
|
|
542
|
+
return e.files.size;
|
|
543
|
+
}
|
|
544
|
+
function V(e) {
|
|
525
545
|
if (e === 0) return "0 B";
|
|
526
546
|
let t = [
|
|
527
547
|
"B",
|
|
@@ -532,7 +552,7 @@ function R(e) {
|
|
|
532
552
|
], n = Math.floor(Math.log(e) / Math.log(1024));
|
|
533
553
|
return `${(e / 1024 ** n).toFixed(+!!n)} ${t[n]}`;
|
|
534
554
|
}
|
|
535
|
-
function
|
|
555
|
+
function H(e) {
|
|
536
556
|
let c = e.type, l = e.name.split(".").pop()?.toLowerCase() ?? "";
|
|
537
557
|
return c.startsWith("video/") ? /* @__PURE__ */ u(s, {}) : c.startsWith("audio/") ? /* @__PURE__ */ u(n, {}) : c.startsWith("text/") || [
|
|
538
558
|
"txt",
|
|
@@ -571,9 +591,12 @@ function z(e) {
|
|
|
571
591
|
"rpm"
|
|
572
592
|
].includes(l) || c.startsWith("application/") ? /* @__PURE__ */ u(i, {}) : /* @__PURE__ */ u(a, {});
|
|
573
593
|
}
|
|
574
|
-
function
|
|
575
|
-
let
|
|
576
|
-
|
|
594
|
+
function U(t) {
|
|
595
|
+
let n = f(24), r, i, a, o, s;
|
|
596
|
+
n[0] === t ? (r = n[1], i = n[2], a = n[3], o = n[4], s = n[5]) : ({render: s, asChild: r, children: i, className: a, ...o} = t, n[0] = t, n[1] = r, n[2] = i, n[3] = a, n[4] = o, n[5] = s);
|
|
597
|
+
let c = R(b), l = M(b), m;
|
|
598
|
+
n[6] !== l.urlCache || n[7] !== c.fileState?.file.type ? (m = (e) => {
|
|
599
|
+
if (c.fileState?.file.type.startsWith("image/")) {
|
|
577
600
|
let t = l.urlCache.get(e);
|
|
578
601
|
return t || (t = URL.createObjectURL(e), l.urlCache.set(e, t)), /* @__PURE__ */ u("img", {
|
|
579
602
|
src: t,
|
|
@@ -581,19 +604,28 @@ function B(t) {
|
|
|
581
604
|
className: "size-full object-cover"
|
|
582
605
|
});
|
|
583
606
|
}
|
|
584
|
-
return
|
|
585
|
-
}, [
|
|
586
|
-
|
|
587
|
-
|
|
607
|
+
return H(e);
|
|
608
|
+
}, n[6] = l.urlCache, n[7] = c.fileState?.file.type, n[8] = m) : m = n[8], c.fileState?.file.type;
|
|
609
|
+
let h = m, g;
|
|
610
|
+
n[9] !== h || n[10] !== s ? (g = (e) => s ? s(e, () => h(e)) : h(e), n[9] = h, n[10] = s, n[11] = g) : g = n[11];
|
|
611
|
+
let _ = g;
|
|
612
|
+
if (!c.fileState) return null;
|
|
613
|
+
let v = r ? p : "div", y = c.nameId, x;
|
|
614
|
+
n[12] === a ? x = n[13] : (x = e("relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10", a), n[12] = a, n[13] = x);
|
|
615
|
+
let S;
|
|
616
|
+
n[14] !== c.fileState.file || n[15] !== _ ? (S = _(c.fileState.file), n[14] = c.fileState.file, n[15] = _, n[16] = S) : S = n[16];
|
|
617
|
+
let C;
|
|
618
|
+
return n[17] !== v || n[18] !== i || n[19] !== c.nameId || n[20] !== o || n[21] !== x || n[22] !== S ? (C = /* @__PURE__ */ d(v, {
|
|
619
|
+
"aria-labelledby": y,
|
|
588
620
|
"data-slot": "file-upload-preview",
|
|
589
621
|
...o,
|
|
590
|
-
className:
|
|
591
|
-
children: [
|
|
592
|
-
}) :
|
|
622
|
+
className: x,
|
|
623
|
+
children: [S, i]
|
|
624
|
+
}), n[17] = v, n[18] = i, n[19] = c.nameId, n[20] = o, n[21] = x, n[22] = S, n[23] = C) : C = n[23], C;
|
|
593
625
|
}
|
|
594
|
-
function
|
|
595
|
-
let { asChild: n, size: r = "default", children: i, className: a, ...o } = t, s =
|
|
596
|
-
return c.fileState ? /* @__PURE__ */ u(n ?
|
|
626
|
+
function W(t) {
|
|
627
|
+
let { asChild: n, size: r = "default", children: i, className: a, ...o } = t, s = M(x), c = R(x);
|
|
628
|
+
return c.fileState ? /* @__PURE__ */ u(n ? p : "div", {
|
|
597
629
|
"data-slot": "file-upload-metadata",
|
|
598
630
|
dir: s.dir,
|
|
599
631
|
...o,
|
|
@@ -607,7 +639,7 @@ function V(t) {
|
|
|
607
639
|
/* @__PURE__ */ u("span", {
|
|
608
640
|
id: c.sizeId,
|
|
609
641
|
className: e("truncate text-muted-foreground text-xs", r === "sm" && "text-[11px] leading-snug"),
|
|
610
|
-
children:
|
|
642
|
+
children: V(c.fileState.file.size)
|
|
611
643
|
}),
|
|
612
644
|
c.fileState.error && /* @__PURE__ */ u("span", {
|
|
613
645
|
id: c.messageId,
|
|
@@ -617,10 +649,10 @@ function V(t) {
|
|
|
617
649
|
] })
|
|
618
650
|
}) : null;
|
|
619
651
|
}
|
|
620
|
-
function
|
|
621
|
-
let { variant: n = "linear", size: r = 40, asChild: i, forceMount: a, className: o, ...s } = t, c =
|
|
652
|
+
function G(t) {
|
|
653
|
+
let { variant: n = "linear", size: r = 40, asChild: i, forceMount: a, className: o, ...s } = t, c = R(S);
|
|
622
654
|
if (!c.fileState || !(a || c.fileState.progress !== 100)) return null;
|
|
623
|
-
let l = i ?
|
|
655
|
+
let l = i ? p : "div";
|
|
624
656
|
switch (n) {
|
|
625
657
|
case "circular": {
|
|
626
658
|
let t = 2 * Math.PI * ((r - 4) / 2), n = t - c.fileState.progress / 100 * t;
|
|
@@ -692,39 +724,50 @@ function H(t) {
|
|
|
692
724
|
});
|
|
693
725
|
}
|
|
694
726
|
}
|
|
695
|
-
function
|
|
696
|
-
let
|
|
697
|
-
|
|
727
|
+
function K(e) {
|
|
728
|
+
let t = f(14), n, r, i;
|
|
729
|
+
t[0] === e ? (n = t[1], r = t[2], i = t[3]) : ({asChild: n, onClick: i, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i);
|
|
730
|
+
let a = O(C), o = R(C), s;
|
|
731
|
+
t[4] !== o.fileState || t[5] !== i || t[6] !== a ? (s = (e) => {
|
|
732
|
+
i?.(e), !(!o.fileState || e.defaultPrevented) && a.dispatch({
|
|
698
733
|
type: "REMOVE_FILE",
|
|
699
|
-
file:
|
|
734
|
+
file: o.fileState.file
|
|
700
735
|
});
|
|
701
|
-
}, [
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
]
|
|
706
|
-
return a.fileState ? /* @__PURE__ */ u(t ? f : "button", {
|
|
736
|
+
}, t[4] = o.fileState, t[5] = i, t[6] = a, t[7] = s) : s = t[7];
|
|
737
|
+
let c = s;
|
|
738
|
+
if (!o.fileState) return null;
|
|
739
|
+
let l = n ? p : "button", d;
|
|
740
|
+
return t[8] !== l || t[9] !== r || t[10] !== o.id || t[11] !== o.nameId || t[12] !== c ? (d = /* @__PURE__ */ u(l, {
|
|
707
741
|
type: "button",
|
|
708
|
-
"aria-controls":
|
|
709
|
-
"aria-describedby":
|
|
742
|
+
"aria-controls": o.id,
|
|
743
|
+
"aria-describedby": o.nameId,
|
|
710
744
|
"data-slot": "file-upload-item-delete",
|
|
711
745
|
...r,
|
|
712
|
-
onClick:
|
|
713
|
-
}) :
|
|
746
|
+
onClick: c
|
|
747
|
+
}), t[8] = l, t[9] = r, t[10] = o.id, t[11] = o.nameId, t[12] = c, t[13] = d) : d = t[13], d;
|
|
714
748
|
}
|
|
715
|
-
function
|
|
716
|
-
let
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
749
|
+
function q(e) {
|
|
750
|
+
let t = f(16), n, r, i, a, o;
|
|
751
|
+
t[0] === e ? (n = t[1], r = t[2], i = t[3], a = t[4], o = t[5]) : ({asChild: n, forceMount: a, disabled: i, onClick: o, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i, t[4] = a, t[5] = o);
|
|
752
|
+
let s = M(w), c = O(w), l = k(J), d = i || s.disabled, m;
|
|
753
|
+
t[6] !== o || t[7] !== c ? (m = (e) => {
|
|
754
|
+
o?.(e), !e.defaultPrevented && c.dispatch({ type: "CLEAR" });
|
|
755
|
+
}, t[6] = o, t[7] = c, t[8] = m) : m = t[8];
|
|
756
|
+
let h = m;
|
|
757
|
+
if (!(a || l > 0)) return null;
|
|
758
|
+
let g = n ? p : "button", _ = d ? "" : void 0, v;
|
|
759
|
+
return t[9] !== g || t[10] !== r || t[11] !== s.listId || t[12] !== d || t[13] !== h || t[14] !== _ ? (v = /* @__PURE__ */ u(g, {
|
|
720
760
|
type: "button",
|
|
721
|
-
"aria-controls":
|
|
761
|
+
"aria-controls": s.listId,
|
|
722
762
|
"data-slot": "file-upload-clear",
|
|
723
|
-
"data-disabled":
|
|
724
|
-
...
|
|
763
|
+
"data-disabled": _,
|
|
764
|
+
...r,
|
|
725
765
|
disabled: d,
|
|
726
|
-
onClick:
|
|
727
|
-
}) :
|
|
766
|
+
onClick: h
|
|
767
|
+
}), t[9] = g, t[10] = r, t[11] = s.listId, t[12] = d, t[13] = h, t[14] = _, t[15] = v) : v = t[15], v;
|
|
768
|
+
}
|
|
769
|
+
function J(e) {
|
|
770
|
+
return e.files.size;
|
|
728
771
|
}
|
|
729
772
|
//#endregion
|
|
730
|
-
export {
|
|
773
|
+
export { q as FileUploadClear, P as FileUploadDropzone, z as FileUploadItem, K as FileUploadItemDelete, W as FileUploadItemMetadata, U as FileUploadItemPreview, G as FileUploadItemProgress, I as FileUploadList, N as FileUploadRoot, F as FileUploadTrigger, k as useStore };
|
package/dist/index83.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const e=require("./index2.cjs"),t=require("./index4.cjs");let n=require("lucide-react"),r=require("react");r=e.__toESM(r,1);let i=require("react/jsx-runtime"),a=require("@radix-ui/react-slot"),o=require("@radix-ui/react-direction");var s=`FileUpload`,c=`FileUploadDropzone`,l=`FileUploadTrigger`,u=`FileUploadList`,d=`FileUploadItem`,f=`FileUploadItemPreview`,p=`FileUploadItemMetadata`,m=`FileUploadItemProgress`,h=`FileUploadItemDelete`,g=`FileUploadClear`;function _(e){let t=r.useRef(null);return t.current===null&&(t.current=e()),t}function v(e,t,n,r,i){let a={files:t,dragOver:!1,invalid:r};function o(e,r){switch(r.type){case`ADD_FILES`:for(let e of r.files)t.set(e,{file:e,progress:0,status:`idle`});return i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_FILES`:{let n=new Set(r.files);for(let e of t.keys())n.has(e)||t.delete(e);for(let e of r.files)t.get(e)||t.set(e,{file:e,progress:0,status:`idle`});return{...e,files:t}}case`SET_PROGRESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:r.progress,status:`uploading`}),{...e,files:t}}case`SET_SUCCESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:100,status:`success`}),{...e,files:t}}case`SET_ERROR`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,error:r.error,status:`error`}),{...e,files:t}}case`REMOVE_FILE`:if(n){let e=n.get(r.file);e&&(URL.revokeObjectURL(e),n.delete(r.file))}return t.delete(r.file),i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_DRAG_OVER`:return{...e,dragOver:r.dragOver};case`SET_INVALID`:return{...e,invalid:r.invalid};case`CLEAR`:if(n)for(let e of t.keys()){let t=n.get(e);t&&(URL.revokeObjectURL(t),n.delete(e))}return t.clear(),i&&i([]),{...e,files:t,invalid:!1};default:return e}}function s(){return a}function c(t){a=o(a,t);for(let t of e)t()}function l(t){return e.add(t),()=>e.delete(t)}return{getState:s,dispatch:c,subscribe:l}}var y=r.createContext(null);function b(e){let t=r.useContext(y);if(!t)throw Error(`\`${e}\` must be used within \`${s}\``);return t}function x(e){let t=b(`useStore`),n=_(()=>null),i=r.useCallback(()=>{let r=t.getState(),i=n.current;if(i&&i.state===r)return i.value;let a=e(r);return n.current={value:a,state:r},a},[t,e,n]);return r.useSyncExternalStore(t.subscribe,i,i)}var S=r.createContext(null);function C(e){let t=r.useContext(S);if(!t)throw Error(`\`${e}\` must be used within \`${s}\``);return t}function w(e){let{value:n,defaultValue:s,onValueChange:c,onAccept:l,onFileAccept:u,onFileReject:d,onFileValidate:f,onUpload:p,accept:m,maxFiles:h,maxSize:g,dir:b,label:x,name:C,asChild:w,disabled:T=!1,invalid:E=!1,multiple:D=!1,required:O=!1,children:k,className:A,...j}=e,M=r.useId(),N=r.useId(),P=r.useId(),F=r.useId(),I=(0,o.useDirection)(b),L=_(()=>new Set).current,R=_(()=>new Map).current,z=_(()=>new WeakMap).current,B=r.useRef(null),V=n!==void 0,H=r.useMemo(()=>v(L,R,z,E,c),[L,R,E,c,z]),U=r.useMemo(()=>m?.split(`,`).map(e=>e.trim())??null,[m]),W=_(()=>{let e=0;return(t,n)=>{e||=requestAnimationFrame(()=>{e=0,H.dispatch({type:`SET_PROGRESS`,file:t,progress:Math.min(Math.max(0,n),100)})})}}).current;r.useEffect(()=>{V?H.dispatch({type:`SET_FILES`,files:n}):s&&s.length>0&&!H.getState().files.size&&H.dispatch({type:`SET_FILES`,files:s})},[n,s,V,H]),r.useEffect(()=>()=>{for(let e of R.keys()){let t=z.get(e);t&&URL.revokeObjectURL(t)}},[R,z]);let G=r.useCallback(async e=>{try{for(let t of e)H.dispatch({type:`SET_PROGRESS`,file:t,progress:0});if(p)await p(e,{onProgress:W,onSuccess:e=>{H.dispatch({type:`SET_SUCCESS`,file:e})},onError:(e,t)=>{H.dispatch({type:`SET_ERROR`,file:e,error:t.message??`Upload failed`})}});else for(let t of e)H.dispatch({type:`SET_SUCCESS`,file:t})}catch(t){let n=t instanceof Error?t.message:`Upload failed`;for(let t of e)H.dispatch({type:`SET_ERROR`,file:t,error:n})}},[H,p,W]),K=r.useCallback(e=>{if(T)return;let t=[...e],n=!1;if(h){let e=H.getState().files.size;if(h===1&&e>0&&t.length>0)H.dispatch({type:`CLEAR`});else{let r=Math.max(0,h-e);if(r<t.length){let e=t.slice(r);n=!0,t=t.slice(0,r);for(let t of e){let e=`Maximum ${h} files allowed`;if(f){let n=f(t);n&&(e=n)}d?.(t,e)}}}}let r=[],i=[];for(let e of t){let t=!1,a=``;if(f){let t=f(e);if(t){a=t,d?.(e,a),n=!0,i.push({file:e,message:a});continue}}if(U){let r=e.type,i=`.${e.name.split(`.`).pop()}`;U.some(e=>e===r||e===i||e.includes(`/*`)&&r.startsWith(e.replace(`/*`,`/`)))||(a=`File type not accepted`,d?.(e,a),t=!0,n=!0)}g&&e.size>g&&(a=`File too large`,d?.(e,a),t=!0,n=!0),t?i.push({file:e,message:a}):r.push(e)}if(n&&(H.dispatch({type:`SET_INVALID`,invalid:n}),setTimeout(()=>{H.dispatch({type:`SET_INVALID`,invalid:!1})},2e3)),r.length>0){H.dispatch({type:`ADD_FILES`,files:r}),V&&c&&c([...Array.from(H.getState().files.values()).map(e=>e.file)]),l&&l(r);for(let e of r)u?.(e);p&&requestAnimationFrame(()=>{G(r)})}},[H,V,c,l,u,p,G,h,f,d,U,g,T]),q=r.useCallback(e=>{K(Array.from(e.target.files??[])),e.target.value=``},[K]),J=r.useMemo(()=>({dropzoneId:N,inputId:M,listId:P,labelId:F,dir:I,disabled:T,inputRef:B,urlCache:z}),[N,M,P,F,I,T,z]),Y=w?a.Slot:`div`;return(0,i.jsx)(y.Provider,{value:H,children:(0,i.jsx)(S.Provider,{value:J,children:(0,i.jsxs)(Y,{"data-disabled":T?``:void 0,"data-slot":`file-upload`,dir:I,...j,className:t.cn(`relative flex flex-col gap-2`,A),children:[k,(0,i.jsx)(`input`,{type:`file`,id:M,"aria-labelledby":F,"aria-describedby":N,ref:B,tabIndex:-1,accept:m,name:C,className:`sr-only`,disabled:T,multiple:D,required:O,onChange:q}),(0,i.jsx)(`span`,{id:F,className:`sr-only`,children:x??`File upload`})]})})})}function T(e){let{asChild:n,className:o,onClick:s,onDragOver:l,onDragEnter:u,onDragLeave:d,onDrop:f,onPaste:p,onKeyDown:m,...h}=e,g=C(c),_=b(c),v=x(e=>e.dragOver),y=x(e=>e.invalid),S=r.useCallback(e=>{if(s?.(e),e.defaultPrevented)return;let t=e.target;t instanceof HTMLElement&&t.closest(`[data-slot="file-upload-trigger"]`)||g.inputRef.current?.click()},[g.inputRef,s]),w=r.useCallback(e=>{l?.(e),!e.defaultPrevented&&(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[_,l]),T=r.useCallback(e=>{u?.(e),!e.defaultPrevented&&(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[_,u]),E=r.useCallback(e=>{if(d?.(e),e.defaultPrevented)return;let t=e.relatedTarget;t&&t instanceof Node&&e.currentTarget.contains(t)||(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1}))},[_,d]),D=r.useCallback(e=>{if(f?.(e),e.defaultPrevented)return;e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=Array.from(e.dataTransfer.files),n=g.inputRef.current;if(!n)return;let r=new DataTransfer;for(let e of t)r.items.add(e);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))},[_,g.inputRef,f]),O=r.useCallback(e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r?.kind===`file`){let e=r.getAsFile();e&&n.push(e)}}if(n.length===0)return;let r=g.inputRef.current;if(!r)return;let i=new DataTransfer;for(let e of n)i.items.add(e);r.files=i.files,r.dispatchEvent(new Event(`change`,{bubbles:!0}))},[_,g.inputRef,p]),k=r.useCallback(e=>{m?.(e),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g.inputRef.current?.click())},[g.inputRef,m]);return(0,i.jsx)(n?a.Slot:`div`,{role:`region`,id:g.dropzoneId,"aria-controls":`${g.inputId} ${g.listId}`,"aria-disabled":g.disabled,"aria-invalid":y,"data-disabled":g.disabled?``:void 0,"data-dragging":v?``:void 0,"data-invalid":y?``:void 0,"data-slot":`file-upload-dropzone`,dir:g.dir,tabIndex:g.disabled?void 0:0,...h,className:t.cn(`relative flex select-none flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 outline-none transition-colors hover:bg-accent/30 focus-visible:border-ring/50 data-disabled:pointer-events-none data-dragging:border-primary/30 data-invalid:border-destructive data-dragging:bg-accent/30 data-invalid:ring-destructive/20`,o),onClick:S,onDragEnter:T,onDragLeave:E,onDragOver:w,onDrop:D,onKeyDown:k,onPaste:O})}function E(e){let{asChild:t,onClick:n,...o}=e,s=C(l),c=r.useCallback(e=>{n?.(e),!e.defaultPrevented&&s.inputRef.current?.click()},[s.inputRef,n]);return(0,i.jsx)(t?a.Slot:`button`,{type:`button`,"aria-controls":s.inputId,"data-disabled":s.disabled?``:void 0,"data-slot":`file-upload-trigger`,...o,disabled:s.disabled,onClick:c})}function D(e){let{className:n,orientation:r=`vertical`,asChild:o,forceMount:s,...c}=e,l=C(u),d=x(e=>e.files.size),f=s||d>0;return f?(0,i.jsx)(o?a.Slot:`div`,{role:`list`,id:l.listId,"aria-orientation":r,"data-orientation":r,"data-slot":`file-upload-list`,"data-state":f?`active`:`inactive`,dir:l.dir,...c,className:t.cn(`data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 flex flex-col gap-2 data-[state=active]:animate-in data-[state=inactive]:animate-out`,r===`horizontal`&&`flex-row overflow-x-auto p-1.5`,n)}):null}var O=r.createContext(null);function k(e){let t=r.useContext(O);if(!t)throw Error(`\`${e}\` must be used within \`${d}\``);return t}function A(e){let{value:n,asChild:o,className:s,...c}=e,l=r.useId(),u=`${l}-status`,f=`${l}-name`,p=`${l}-size`,m=`${l}-message`,h=C(d),g=x(e=>e.files.get(n)),_=x(e=>e.files.size),v=x(e=>Array.from(e.files.keys()).indexOf(n)+1),y=r.useMemo(()=>({id:l,fileState:g,nameId:f,sizeId:p,statusId:u,messageId:m}),[l,g,u,f,p,m]);if(!g)return null;let b=g.error?`Error: ${g.error}`:g.status===`uploading`?`Uploading: ${g.progress}% complete`:g.status===`success`?`Upload complete`:`Ready to upload`,S=o?a.Slot:`div`;return(0,i.jsx)(O.Provider,{value:y,children:(0,i.jsxs)(S,{role:`listitem`,id:l,"aria-setsize":_,"aria-posinset":v,"aria-describedby":`${f} ${p} ${u} ${g.error?m:``}`,"aria-labelledby":f,"data-slot":`file-upload-item`,dir:h.dir,...c,className:t.cn(`relative flex items-center gap-2.5 rounded-md border p-3`,s),children:[e.children,(0,i.jsx)(`span`,{id:u,className:`sr-only`,children:b})]})})}function j(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(+!!n)} ${t[n]}`}function M(e){let t=e.type,r=e.name.split(`.`).pop()?.toLowerCase()??``;return t.startsWith(`video/`)?(0,i.jsx)(n.FileVideoIcon,{}):t.startsWith(`audio/`)?(0,i.jsx)(n.FileAudioIcon,{}):t.startsWith(`text/`)||[`txt`,`md`,`rtf`,`pdf`].includes(r)?(0,i.jsx)(n.FileTextIcon,{}):[`html`,`css`,`js`,`jsx`,`ts`,`tsx`,`json`,`xml`,`php`,`py`,`rb`,`java`,`c`,`cpp`,`cs`].includes(r)?(0,i.jsx)(n.FileCodeIcon,{}):[`zip`,`rar`,`7z`,`tar`,`gz`,`bz2`].includes(r)?(0,i.jsx)(n.FileArchiveIcon,{}):[`exe`,`msi`,`app`,`apk`,`deb`,`rpm`].includes(r)||t.startsWith(`application/`)?(0,i.jsx)(n.FileCogIcon,{}):(0,i.jsx)(n.FileIcon,{})}function N(e){let{render:n,asChild:o,children:s,className:c,...l}=e,u=k(f),d=C(f),p=r.useCallback(e=>{if(u.fileState?.file.type.startsWith(`image/`)){let t=d.urlCache.get(e);return t||(t=URL.createObjectURL(e),d.urlCache.set(e,t)),(0,i.jsx)(`img`,{src:t,alt:e.name,className:`size-full object-cover`})}return M(e)},[u.fileState?.file.type,d.urlCache]),m=r.useCallback(e=>n?n(e,()=>p(e)):p(e),[n,p]);return u.fileState?(0,i.jsxs)(o?a.Slot:`div`,{"aria-labelledby":u.nameId,"data-slot":`file-upload-preview`,...l,className:t.cn(`relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10`,c),children:[m(u.fileState.file),s]}):null}function P(e){let{asChild:n,size:r=`default`,children:o,className:s,...c}=e,l=C(p),u=k(p);return u.fileState?(0,i.jsx)(n?a.Slot:`div`,{"data-slot":`file-upload-metadata`,dir:l.dir,...c,className:t.cn(`flex min-w-0 flex-1 flex-col`,s),children:o??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{id:u.nameId,className:t.cn(`truncate font-medium text-sm`,r===`sm`&&`font-normal text-[13px] leading-snug`),children:u.fileState.file.name}),(0,i.jsx)(`span`,{id:u.sizeId,className:t.cn(`truncate text-muted-foreground text-xs`,r===`sm`&&`text-[11px] leading-snug`),children:j(u.fileState.file.size)}),u.fileState.error&&(0,i.jsx)(`span`,{id:u.messageId,className:`text-destructive text-xs`,children:u.fileState.error})]})}):null}function F(e){let{variant:n=`linear`,size:r=40,asChild:o,forceMount:s,className:c,...l}=e,u=k(m);if(!u.fileState||!(s||u.fileState.progress!==100))return null;let d=o?a.Slot:`div`;switch(n){case`circular`:{let e=2*Math.PI*((r-4)/2),n=e-u.fileState.progress/100*e;return(0,i.jsx)(d,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u.fileState.progress,"aria-valuetext":`${u.fileState.progress}%`,"aria-labelledby":u.nameId,"data-slot":`file-upload-progress`,...l,className:t.cn(`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2`,c),children:(0,i.jsxs)(`svg`,{className:`-rotate-90 transform`,width:r,height:r,viewBox:`0 0 ${r} ${r}`,fill:`none`,stroke:`currentColor`,children:[(0,i.jsx)(`circle`,{className:`text-primary/20`,strokeWidth:`2`,cx:r/2,cy:r/2,r:(r-4)/2}),(0,i.jsx)(`circle`,{className:`text-primary transition-[stroke-dashoffset] duration-300 ease-linear`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:e,strokeDashoffset:n,cx:r/2,cy:r/2,r:(r-4)/2})]})})}case`fill`:{let e=u.fileState.progress,n=100-e;return(0,i.jsx)(d,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e,"aria-valuetext":`${e}%`,"aria-labelledby":u.nameId,"data-slot":`file-upload-progress`,...l,className:t.cn(`absolute inset-0 bg-primary/50 transition-[clip-path] duration-300 ease-linear`,c),style:{clipPath:`inset(${n}% 0% 0% 0%)`}})}default:return(0,i.jsx)(d,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u.fileState.progress,"aria-valuetext":`${u.fileState.progress}%`,"aria-labelledby":u.nameId,"data-slot":`file-upload-progress`,...l,className:t.cn(`relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20`,c),children:(0,i.jsx)(`div`,{className:`h-full w-full flex-1 bg-primary transition-transform duration-300 ease-linear`,style:{transform:`translateX(-${100-u.fileState.progress}%)`}})})}}function I(e){let{asChild:t,onClick:n,...o}=e,s=b(h),c=k(h),l=r.useCallback(e=>{n?.(e),!(!c.fileState||e.defaultPrevented)&&s.dispatch({type:`REMOVE_FILE`,file:c.fileState.file})},[s,c.fileState,n]);return c.fileState?(0,i.jsx)(t?a.Slot:`button`,{type:`button`,"aria-controls":c.id,"aria-describedby":c.nameId,"data-slot":`file-upload-item-delete`,...o,onClick:l}):null}function L(e){let{asChild:t,forceMount:n,disabled:o,onClick:s,...c}=e,l=C(g),u=b(g),d=x(e=>e.files.size),f=o||l.disabled,p=r.useCallback(e=>{s?.(e),!e.defaultPrevented&&u.dispatch({type:`CLEAR`})},[u,s]);return n||d>0?(0,i.jsx)(t?a.Slot:`button`,{type:`button`,"aria-controls":l.listId,"data-slot":`file-upload-clear`,"data-disabled":f?``:void 0,...c,disabled:f,onClick:p}):null}exports.FileUploadClear=L,exports.FileUploadDropzone=T,exports.FileUploadItem=A,exports.FileUploadItemDelete=I,exports.FileUploadItemMetadata=P,exports.FileUploadItemPreview=N,exports.FileUploadItemProgress=F,exports.FileUploadList=D,exports.FileUploadRoot=w,exports.FileUploadTrigger=E,exports.useStore=x;
|
|
1
|
+
"use client";const e=require("./index2.cjs"),t=require("./index4.cjs");let n=require("lucide-react"),r=require("react");r=e.__toESM(r,1);let i=require("react/jsx-runtime"),a=require("react/compiler-runtime"),o=require("@radix-ui/react-slot"),s=require("@radix-ui/react-direction");var c=`FileUpload`,l=`FileUploadDropzone`,u=`FileUploadTrigger`,d=`FileUploadList`,f=`FileUploadItem`,p=`FileUploadItemPreview`,m=`FileUploadItemMetadata`,h=`FileUploadItemProgress`,g=`FileUploadItemDelete`,_=`FileUploadClear`;function v(e){let t=(0,a.c)(2),n=r.useRef(null);if(n.current===null){let r;t[0]===e?r=t[1]:(r=e(),t[0]=e,t[1]=r),n.current=r}return n}function y(e,t,n,r,i){let a={files:t,dragOver:!1,invalid:r};function o(e,r){switch(r.type){case`ADD_FILES`:for(let e of r.files)t.set(e,{file:e,progress:0,status:`idle`});return i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_FILES`:{let n=new Set(r.files);for(let e of t.keys())n.has(e)||t.delete(e);for(let e of r.files)t.get(e)||t.set(e,{file:e,progress:0,status:`idle`});return{...e,files:t}}case`SET_PROGRESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:r.progress,status:`uploading`}),{...e,files:t}}case`SET_SUCCESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:100,status:`success`}),{...e,files:t}}case`SET_ERROR`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,error:r.error,status:`error`}),{...e,files:t}}case`REMOVE_FILE`:if(n){let e=n.get(r.file);e&&(URL.revokeObjectURL(e),n.delete(r.file))}return t.delete(r.file),i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_DRAG_OVER`:return{...e,dragOver:r.dragOver};case`SET_INVALID`:return{...e,invalid:r.invalid};case`CLEAR`:if(n)for(let e of t.keys()){let t=n.get(e);t&&(URL.revokeObjectURL(t),n.delete(e))}return t.clear(),i&&i([]),{...e,files:t,invalid:!1};default:return e}}function s(){return a}function c(t){a=o(a,t);for(let t of e)t()}function l(t){return e.add(t),()=>e.delete(t)}return{getState:s,dispatch:c,subscribe:l}}var b=r.createContext(null);function x(e){let t=r.useContext(b);if(!t)throw Error(`\`${e}\` must be used within \`${c}\``);return t}function S(e){let t=(0,a.c)(4),n=x(`useStore`),i=v(C),o;t[0]!==i||t[1]!==e||t[2]!==n?(o=()=>{let t=n.getState(),r=i.current;if(r&&r.state===t)return r.value;let a=e(t);return i.current={value:a,state:t},a},t[0]=i,t[1]=e,t[2]=n,t[3]=o):o=t[3];let s=o;return r.useSyncExternalStore(n.subscribe,s,s)}function C(){return null}var w=r.createContext(null);function T(e){let t=r.useContext(w);if(!t)throw Error(`\`${e}\` must be used within \`${c}\``);return t}function E(e){let{value:n,defaultValue:a,onValueChange:c,onAccept:l,onFileAccept:u,onFileReject:d,onFileValidate:f,onUpload:p,accept:m,maxFiles:h,maxSize:g,dir:_,label:x,name:S,asChild:C,disabled:T=!1,invalid:E=!1,multiple:D=!1,required:O=!1,children:k,className:A,...j}=e,M=r.useId(),N=r.useId(),P=r.useId(),F=r.useId(),I=(0,s.useDirection)(_),L=v(()=>new Set).current,R=v(()=>new Map).current,z=v(()=>new WeakMap).current,B=r.useRef(null),V=n!==void 0,H=r.useMemo(()=>y(L,R,z,E,c),[L,R,E,c,z]),U=r.useMemo(()=>m?.split(`,`).map(e=>e.trim())??null,[m]),W=v(()=>{let e=0;return(t,n)=>{e||=requestAnimationFrame(()=>{e=0,H.dispatch({type:`SET_PROGRESS`,file:t,progress:Math.min(Math.max(0,n),100)})})}}).current;r.useEffect(()=>{V?H.dispatch({type:`SET_FILES`,files:n}):a&&a.length>0&&!H.getState().files.size&&H.dispatch({type:`SET_FILES`,files:a})},[n,a,V,H]),r.useEffect(()=>()=>{for(let e of R.keys()){let t=z.get(e);t&&URL.revokeObjectURL(t)}},[R,z]);let G=r.useCallback(async e=>{try{for(let t of e)H.dispatch({type:`SET_PROGRESS`,file:t,progress:0});if(p)await p(e,{onProgress:W,onSuccess:e=>{H.dispatch({type:`SET_SUCCESS`,file:e})},onError:(e,t)=>{H.dispatch({type:`SET_ERROR`,file:e,error:t.message??`Upload failed`})}});else for(let t of e)H.dispatch({type:`SET_SUCCESS`,file:t})}catch(t){let n=t instanceof Error?t.message:`Upload failed`;for(let t of e)H.dispatch({type:`SET_ERROR`,file:t,error:n})}},[H,p,W]),K=r.useCallback(e=>{if(T)return;let t=[...e],n=!1;if(h){let e=H.getState().files.size;if(h===1&&e>0&&t.length>0)H.dispatch({type:`CLEAR`});else{let r=Math.max(0,h-e);if(r<t.length){let e=t.slice(r);n=!0,t=t.slice(0,r);for(let t of e){let e=`Maximum ${h} files allowed`;if(f){let n=f(t);n&&(e=n)}d?.(t,e)}}}}let r=[],i=[];for(let e of t){let t=!1,a=``;if(f){let t=f(e);if(t){a=t,d?.(e,a),n=!0,i.push({file:e,message:a});continue}}if(U){let r=e.type,i=`.${e.name.split(`.`).pop()}`;U.some(e=>e===r||e===i||e.includes(`/*`)&&r.startsWith(e.replace(`/*`,`/`)))||(a=`File type not accepted`,d?.(e,a),t=!0,n=!0)}g&&e.size>g&&(a=`File too large`,d?.(e,a),t=!0,n=!0),t?i.push({file:e,message:a}):r.push(e)}if(n&&(H.dispatch({type:`SET_INVALID`,invalid:n}),setTimeout(()=>{H.dispatch({type:`SET_INVALID`,invalid:!1})},2e3)),r.length>0){H.dispatch({type:`ADD_FILES`,files:r}),V&&c&&c([...Array.from(H.getState().files.values()).map(e=>e.file)]),l&&l(r);for(let e of r)u?.(e);p&&requestAnimationFrame(()=>{G(r)})}},[H,V,c,l,u,p,G,h,f,d,U,g,T]),q=r.useCallback(e=>{K(Array.from(e.target.files??[])),e.target.value=``},[K]),J=r.useMemo(()=>({dropzoneId:N,inputId:M,listId:P,labelId:F,dir:I,disabled:T,inputRef:B,urlCache:z}),[N,M,P,F,I,T,z]),Y=C?o.Slot:`div`;return(0,i.jsx)(b.Provider,{value:H,children:(0,i.jsx)(w.Provider,{value:J,children:(0,i.jsxs)(Y,{"data-disabled":T?``:void 0,"data-slot":`file-upload`,dir:I,...j,className:t.cn(`relative flex flex-col gap-2`,A),children:[k,(0,i.jsx)(`input`,{type:`file`,id:M,"aria-labelledby":F,"aria-describedby":N,ref:B,tabIndex:-1,accept:m,name:S,className:`sr-only`,disabled:T,multiple:D,required:O,onChange:q}),(0,i.jsx)(`span`,{id:F,className:`sr-only`,children:x??`File upload`})]})})})}function D(e){let{asChild:n,className:a,onClick:s,onDragOver:c,onDragEnter:u,onDragLeave:d,onDrop:f,onPaste:p,onKeyDown:m,...h}=e,g=T(l),_=x(l),v=S(e=>e.dragOver),y=S(e=>e.invalid),b=r.useCallback(e=>{if(s?.(e),e.defaultPrevented)return;let t=e.target;t instanceof HTMLElement&&t.closest(`[data-slot="file-upload-trigger"]`)||g.inputRef.current?.click()},[g.inputRef,s]),C=r.useCallback(e=>{c?.(e),!e.defaultPrevented&&(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[_,c]),w=r.useCallback(e=>{u?.(e),!e.defaultPrevented&&(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[_,u]),E=r.useCallback(e=>{if(d?.(e),e.defaultPrevented)return;let t=e.relatedTarget;t&&t instanceof Node&&e.currentTarget.contains(t)||(e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1}))},[_,d]),D=r.useCallback(e=>{if(f?.(e),e.defaultPrevented)return;e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=Array.from(e.dataTransfer.files),n=g.inputRef.current;if(!n)return;let r=new DataTransfer;for(let e of t)r.items.add(e);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))},[_,g.inputRef,f]),O=r.useCallback(e=>{if(p?.(e),e.defaultPrevented)return;e.preventDefault(),_.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r?.kind===`file`){let e=r.getAsFile();e&&n.push(e)}}if(n.length===0)return;let r=g.inputRef.current;if(!r)return;let i=new DataTransfer;for(let e of n)i.items.add(e);r.files=i.files,r.dispatchEvent(new Event(`change`,{bubbles:!0}))},[_,g.inputRef,p]),k=r.useCallback(e=>{m?.(e),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g.inputRef.current?.click())},[g.inputRef,m]);return(0,i.jsx)(n?o.Slot:`div`,{role:`region`,id:g.dropzoneId,"aria-controls":`${g.inputId} ${g.listId}`,"aria-disabled":g.disabled,"aria-invalid":y,"data-disabled":g.disabled?``:void 0,"data-dragging":v?``:void 0,"data-invalid":y?``:void 0,"data-slot":`file-upload-dropzone`,dir:g.dir,tabIndex:g.disabled?void 0:0,...h,className:t.cn(`relative flex select-none flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 outline-none transition-colors hover:bg-accent/30 focus-visible:border-ring/50 data-disabled:pointer-events-none data-dragging:border-primary/30 data-invalid:border-destructive data-dragging:bg-accent/30 data-invalid:ring-destructive/20`,a),onClick:b,onDragEnter:w,onDragLeave:E,onDragOver:C,onDrop:D,onKeyDown:k,onPaste:O})}function O(e){let t=(0,a.c)(14),n,r,s;t[0]===e?(n=t[1],r=t[2],s=t[3]):({asChild:n,onClick:r,...s}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=s);let c=T(u),l;t[4]!==c.inputRef||t[5]!==r?(l=e=>{r?.(e),!e.defaultPrevented&&c.inputRef.current?.click()},t[4]=c.inputRef,t[5]=r,t[6]=l):l=t[6];let d=l,f=n?o.Slot:`button`,p=c.disabled?``:void 0,m;return t[7]!==f||t[8]!==c.disabled||t[9]!==c.inputId||t[10]!==d||t[11]!==p||t[12]!==s?(m=(0,i.jsx)(f,{type:`button`,"aria-controls":c.inputId,"data-disabled":p,"data-slot":`file-upload-trigger`,...s,disabled:c.disabled,onClick:d}),t[7]=f,t[8]=c.disabled,t[9]=c.inputId,t[10]=d,t[11]=p,t[12]=s,t[13]=m):m=t[13],m}function k(e){let{className:n,orientation:r=`vertical`,asChild:a,forceMount:s,...c}=e,l=T(d),u=S(e=>e.files.size),f=s||u>0;return f?(0,i.jsx)(a?o.Slot:`div`,{role:`list`,id:l.listId,"aria-orientation":r,"data-orientation":r,"data-slot":`file-upload-list`,"data-state":f?`active`:`inactive`,dir:l.dir,...c,className:t.cn(`data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 flex flex-col gap-2 data-[state=active]:animate-in data-[state=inactive]:animate-out`,r===`horizontal`&&`flex-row overflow-x-auto p-1.5`,n)}):null}var A=r.createContext(null);function j(e){let t=r.useContext(A);if(!t)throw Error(`\`${e}\` must be used within \`${f}\``);return t}function M(e){let n=(0,a.c)(36),s,c,l,u;n[0]===e?(s=n[1],c=n[2],l=n[3],u=n[4]):({value:u,asChild:s,className:c,...l}=e,n[0]=e,n[1]=s,n[2]=c,n[3]=l,n[4]=u);let d=r.useId(),p=`${d}-status`,m=`${d}-name`,h=`${d}-size`,g=`${d}-message`,_=T(f),v;n[5]===u?v=n[6]:(v=e=>e.files.get(u),n[5]=u,n[6]=v);let y=S(v),b=S(N),x;n[7]===u?x=n[8]:(x=e=>Array.from(e.files.keys()).indexOf(u)+1,n[7]=u,n[8]=x);let C=S(x),w;n[9]!==y||n[10]!==d||n[11]!==g||n[12]!==m||n[13]!==h||n[14]!==p?(w={id:d,fileState:y,nameId:m,sizeId:h,statusId:p,messageId:g},n[9]=y,n[10]=d,n[11]=g,n[12]=m,n[13]=h,n[14]=p,n[15]=w):w=n[15];let E=w;if(!y)return null;let D=y.error?`Error: ${y.error}`:y.status===`uploading`?`Uploading: ${y.progress}% complete`:y.status===`success`?`Upload complete`:`Ready to upload`,O=s?o.Slot:`div`,k=`${m} ${h} ${p} ${y.error?g:``}`,j=_.dir,M;n[16]===c?M=n[17]:(M=t.cn(`relative flex items-center gap-2.5 rounded-md border p-3`,c),n[16]=c,n[17]=M);let P;n[18]!==p||n[19]!==D?(P=(0,i.jsx)(`span`,{id:p,className:`sr-only`,children:D}),n[18]=p,n[19]=D,n[20]=P):P=n[20];let F;n[21]!==O||n[22]!==_.dir||n[23]!==b||n[24]!==C||n[25]!==d||n[26]!==l||n[27]!==m||n[28]!==e.children||n[29]!==k||n[30]!==M||n[31]!==P?(F=(0,i.jsxs)(O,{role:`listitem`,id:d,"aria-setsize":b,"aria-posinset":C,"aria-describedby":k,"aria-labelledby":m,"data-slot":`file-upload-item`,dir:j,...l,className:M,children:[e.children,P]}),n[21]=O,n[22]=_.dir,n[23]=b,n[24]=C,n[25]=d,n[26]=l,n[27]=m,n[28]=e.children,n[29]=k,n[30]=M,n[31]=P,n[32]=F):F=n[32];let I;return n[33]!==E||n[34]!==F?(I=(0,i.jsx)(A.Provider,{value:E,children:F}),n[33]=E,n[34]=F,n[35]=I):I=n[35],I}function N(e){return e.files.size}function P(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(+!!n)} ${t[n]}`}function F(e){let t=e.type,r=e.name.split(`.`).pop()?.toLowerCase()??``;return t.startsWith(`video/`)?(0,i.jsx)(n.FileVideoIcon,{}):t.startsWith(`audio/`)?(0,i.jsx)(n.FileAudioIcon,{}):t.startsWith(`text/`)||[`txt`,`md`,`rtf`,`pdf`].includes(r)?(0,i.jsx)(n.FileTextIcon,{}):[`html`,`css`,`js`,`jsx`,`ts`,`tsx`,`json`,`xml`,`php`,`py`,`rb`,`java`,`c`,`cpp`,`cs`].includes(r)?(0,i.jsx)(n.FileCodeIcon,{}):[`zip`,`rar`,`7z`,`tar`,`gz`,`bz2`].includes(r)?(0,i.jsx)(n.FileArchiveIcon,{}):[`exe`,`msi`,`app`,`apk`,`deb`,`rpm`].includes(r)||t.startsWith(`application/`)?(0,i.jsx)(n.FileCogIcon,{}):(0,i.jsx)(n.FileIcon,{})}function I(e){let n=(0,a.c)(24),r,s,c,l,u;n[0]===e?(r=n[1],s=n[2],c=n[3],l=n[4],u=n[5]):({render:u,asChild:r,children:s,className:c,...l}=e,n[0]=e,n[1]=r,n[2]=s,n[3]=c,n[4]=l,n[5]=u);let d=j(p),f=T(p),m;n[6]!==f.urlCache||n[7]!==d.fileState?.file.type?(m=e=>{if(d.fileState?.file.type.startsWith(`image/`)){let t=f.urlCache.get(e);return t||(t=URL.createObjectURL(e),f.urlCache.set(e,t)),(0,i.jsx)(`img`,{src:t,alt:e.name,className:`size-full object-cover`})}return F(e)},n[6]=f.urlCache,n[7]=d.fileState?.file.type,n[8]=m):m=n[8],d.fileState?.file.type;let h=m,g;n[9]!==h||n[10]!==u?(g=e=>u?u(e,()=>h(e)):h(e),n[9]=h,n[10]=u,n[11]=g):g=n[11];let _=g;if(!d.fileState)return null;let v=r?o.Slot:`div`,y=d.nameId,b;n[12]===c?b=n[13]:(b=t.cn(`relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10`,c),n[12]=c,n[13]=b);let x;n[14]!==d.fileState.file||n[15]!==_?(x=_(d.fileState.file),n[14]=d.fileState.file,n[15]=_,n[16]=x):x=n[16];let S;return n[17]!==v||n[18]!==s||n[19]!==d.nameId||n[20]!==l||n[21]!==b||n[22]!==x?(S=(0,i.jsxs)(v,{"aria-labelledby":y,"data-slot":`file-upload-preview`,...l,className:b,children:[x,s]}),n[17]=v,n[18]=s,n[19]=d.nameId,n[20]=l,n[21]=b,n[22]=x,n[23]=S):S=n[23],S}function L(e){let{asChild:n,size:r=`default`,children:a,className:s,...c}=e,l=T(m),u=j(m);return u.fileState?(0,i.jsx)(n?o.Slot:`div`,{"data-slot":`file-upload-metadata`,dir:l.dir,...c,className:t.cn(`flex min-w-0 flex-1 flex-col`,s),children:a??(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{id:u.nameId,className:t.cn(`truncate font-medium text-sm`,r===`sm`&&`font-normal text-[13px] leading-snug`),children:u.fileState.file.name}),(0,i.jsx)(`span`,{id:u.sizeId,className:t.cn(`truncate text-muted-foreground text-xs`,r===`sm`&&`text-[11px] leading-snug`),children:P(u.fileState.file.size)}),u.fileState.error&&(0,i.jsx)(`span`,{id:u.messageId,className:`text-destructive text-xs`,children:u.fileState.error})]})}):null}function R(e){let{variant:n=`linear`,size:r=40,asChild:a,forceMount:s,className:c,...l}=e,u=j(h);if(!u.fileState||!(s||u.fileState.progress!==100))return null;let d=a?o.Slot:`div`;switch(n){case`circular`:{let e=2*Math.PI*((r-4)/2),n=e-u.fileState.progress/100*e;return(0,i.jsx)(d,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u.fileState.progress,"aria-valuetext":`${u.fileState.progress}%`,"aria-labelledby":u.nameId,"data-slot":`file-upload-progress`,...l,className:t.cn(`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2`,c),children:(0,i.jsxs)(`svg`,{className:`-rotate-90 transform`,width:r,height:r,viewBox:`0 0 ${r} ${r}`,fill:`none`,stroke:`currentColor`,children:[(0,i.jsx)(`circle`,{className:`text-primary/20`,strokeWidth:`2`,cx:r/2,cy:r/2,r:(r-4)/2}),(0,i.jsx)(`circle`,{className:`text-primary transition-[stroke-dashoffset] duration-300 ease-linear`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:e,strokeDashoffset:n,cx:r/2,cy:r/2,r:(r-4)/2})]})})}case`fill`:{let e=u.fileState.progress,n=100-e;return(0,i.jsx)(d,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e,"aria-valuetext":`${e}%`,"aria-labelledby":u.nameId,"data-slot":`file-upload-progress`,...l,className:t.cn(`absolute inset-0 bg-primary/50 transition-[clip-path] duration-300 ease-linear`,c),style:{clipPath:`inset(${n}% 0% 0% 0%)`}})}default:return(0,i.jsx)(d,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u.fileState.progress,"aria-valuetext":`${u.fileState.progress}%`,"aria-labelledby":u.nameId,"data-slot":`file-upload-progress`,...l,className:t.cn(`relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20`,c),children:(0,i.jsx)(`div`,{className:`h-full w-full flex-1 bg-primary transition-transform duration-300 ease-linear`,style:{transform:`translateX(-${100-u.fileState.progress}%)`}})})}}function z(e){let t=(0,a.c)(14),n,r,s;t[0]===e?(n=t[1],r=t[2],s=t[3]):({asChild:n,onClick:s,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=s);let c=x(g),l=j(g),u;t[4]!==l.fileState||t[5]!==s||t[6]!==c?(u=e=>{s?.(e),!(!l.fileState||e.defaultPrevented)&&c.dispatch({type:`REMOVE_FILE`,file:l.fileState.file})},t[4]=l.fileState,t[5]=s,t[6]=c,t[7]=u):u=t[7];let d=u;if(!l.fileState)return null;let f=n?o.Slot:`button`,p;return t[8]!==f||t[9]!==r||t[10]!==l.id||t[11]!==l.nameId||t[12]!==d?(p=(0,i.jsx)(f,{type:`button`,"aria-controls":l.id,"aria-describedby":l.nameId,"data-slot":`file-upload-item-delete`,...r,onClick:d}),t[8]=f,t[9]=r,t[10]=l.id,t[11]=l.nameId,t[12]=d,t[13]=p):p=t[13],p}function B(e){let t=(0,a.c)(16),n,r,s,c,l;t[0]===e?(n=t[1],r=t[2],s=t[3],c=t[4],l=t[5]):({asChild:n,forceMount:c,disabled:s,onClick:l,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=s,t[4]=c,t[5]=l);let u=T(_),d=x(_),f=S(V),p=s||u.disabled,m;t[6]!==l||t[7]!==d?(m=e=>{l?.(e),!e.defaultPrevented&&d.dispatch({type:`CLEAR`})},t[6]=l,t[7]=d,t[8]=m):m=t[8];let h=m;if(!(c||f>0))return null;let g=n?o.Slot:`button`,v=p?``:void 0,y;return t[9]!==g||t[10]!==r||t[11]!==u.listId||t[12]!==p||t[13]!==h||t[14]!==v?(y=(0,i.jsx)(g,{type:`button`,"aria-controls":u.listId,"data-slot":`file-upload-clear`,"data-disabled":v,...r,disabled:p,onClick:h}),t[9]=g,t[10]=r,t[11]=u.listId,t[12]=p,t[13]=h,t[14]=v,t[15]=y):y=t[15],y}function V(e){return e.files.size}exports.FileUploadClear=B,exports.FileUploadDropzone=D,exports.FileUploadItem=M,exports.FileUploadItemDelete=z,exports.FileUploadItemMetadata=L,exports.FileUploadItemPreview=I,exports.FileUploadItemProgress=R,exports.FileUploadList=k,exports.FileUploadRoot=E,exports.FileUploadTrigger=O,exports.useStore=S;
|