@blakesteve/roster 5.15.0 → 5.16.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/README.md +53 -1
- package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/molecules/FileUpload/FileUpload.d.ts +20 -3
- package/dist/components/molecules/FileUpload/FileUpload.js +266 -216
- package/dist/components/molecules/FileUpload/file-upload-rejection.cjs +1 -0
- package/dist/components/molecules/FileUpload/file-upload-rejection.d.ts +24 -0
- package/dist/components/molecules/FileUpload/file-upload-rejection.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/meta.json +3 -3
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +130 -128
- package/package.json +1 -1
|
@@ -1,219 +1,258 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useId as
|
|
2
|
+
import { jsxs as x, jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect as rt, useId as $t, useState as C, useRef as y, useCallback as F, useLayoutEffect as et } from "react";
|
|
4
4
|
import { cn as g } from "../../../lib/utils.js";
|
|
5
|
-
import { withLabels as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { Progress as
|
|
8
|
-
import { acceptList as
|
|
9
|
-
import {
|
|
10
|
-
|
|
5
|
+
import { withLabels as Lt } from "../../../lib/labels.js";
|
|
6
|
+
import { Button as K } from "../../atoms/Button/Button.js";
|
|
7
|
+
import { Progress as Mt } from "../../atoms/Progress/Progress.js";
|
|
8
|
+
import { acceptList as Dt, formatBytes as st, sameFile as nt, matchesType as Tt } from "./file-rules.js";
|
|
9
|
+
import { isFileUploadRejection as Rt } from "./file-upload-rejection.js";
|
|
10
|
+
import { useKeyFocus as Et } from "../../../internal/key-focus.js";
|
|
11
|
+
import { isDevelopment as qt } from "../../../internal/dev.js";
|
|
12
|
+
const Ct = {
|
|
11
13
|
choose: "Choose photos",
|
|
14
|
+
replace: "Replace photo",
|
|
12
15
|
dropHint: "or drag them here",
|
|
13
16
|
dropHere: "Drop to add them",
|
|
14
17
|
queued: "Waiting",
|
|
15
|
-
uploading: (
|
|
18
|
+
uploading: (e) => e === null ? "Uploading" : `Uploading, ${e}%`,
|
|
16
19
|
processing: "Finishing up",
|
|
17
20
|
done: "Uploaded",
|
|
18
21
|
failed: "Didn't upload.",
|
|
19
22
|
rejected: "Not added.",
|
|
20
|
-
remove: (
|
|
21
|
-
retry: (
|
|
23
|
+
remove: (e) => `Remove ${e}`,
|
|
24
|
+
retry: (e) => `Try ${e} again`,
|
|
22
25
|
wrongType: () => "That type of file isn't accepted.",
|
|
23
|
-
tooLarge: (
|
|
24
|
-
tooMany: (
|
|
26
|
+
tooLarge: (e, l) => `It's over ${st(l)}.`,
|
|
27
|
+
tooMany: (e) => `Only ${e} can be added.`,
|
|
25
28
|
duplicate: () => "It's already added.",
|
|
26
|
-
uploadError: (
|
|
27
|
-
size:
|
|
28
|
-
added: (
|
|
29
|
-
progress: (
|
|
30
|
-
failedNotice: (
|
|
31
|
-
rejectedNotice: (
|
|
32
|
-
removed: (
|
|
29
|
+
uploadError: (e) => e instanceof Error && e.message ? e.message : "Something went wrong.",
|
|
30
|
+
size: st,
|
|
31
|
+
added: (e) => `${e} ${e === 1 ? "photo" : "photos"} added.`,
|
|
32
|
+
progress: (e, l) => `${e} of ${l} uploaded.`,
|
|
33
|
+
failedNotice: (e, l) => `${e} didn't upload. ${l}`,
|
|
34
|
+
rejectedNotice: (e, l) => `${e} wasn't added. ${l}`,
|
|
35
|
+
removed: (e) => `${e} removed.`
|
|
33
36
|
};
|
|
34
|
-
function
|
|
35
|
-
const [
|
|
36
|
-
(
|
|
37
|
-
if (!
|
|
38
|
-
const
|
|
39
|
-
return
|
|
37
|
+
function ot(e) {
|
|
38
|
+
const [l, h] = C(!1), b = !l && (e.type.startsWith("image/") || /\.(jpe?g|png|gif|webp|avif|heic|heif)$/i.test(e.name)), w = F(
|
|
39
|
+
(m) => {
|
|
40
|
+
if (!m) return;
|
|
41
|
+
const p = URL.createObjectURL(e);
|
|
42
|
+
return m.src = p, () => URL.revokeObjectURL(p);
|
|
40
43
|
},
|
|
41
|
-
[
|
|
42
|
-
)
|
|
43
|
-
return
|
|
44
|
+
[e]
|
|
45
|
+
);
|
|
46
|
+
return { image: b, attach: w, broke: () => h(!0) };
|
|
47
|
+
}
|
|
48
|
+
const at = /* @__PURE__ */ x("svg", { viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
49
|
+
/* @__PURE__ */ n("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
50
|
+
/* @__PURE__ */ n("circle", { cx: "9", cy: "10", r: "1.6" }),
|
|
51
|
+
/* @__PURE__ */ n("path", { d: "m21 15-4.2-4.2a1.6 1.6 0 0 0-2.3 0L7 18" })
|
|
52
|
+
] });
|
|
53
|
+
function zt({ file: e, status: l }) {
|
|
54
|
+
const { image: h, attach: b, broke: w } = ot(e), m = "rst:h-14 rst:w-14 rst:shrink-0 rst:rounded-md rst:border rst:border-[var(--roster-card-border)]";
|
|
55
|
+
return h ? /* @__PURE__ */ n(
|
|
44
56
|
"img",
|
|
45
57
|
{
|
|
46
|
-
ref:
|
|
58
|
+
ref: b,
|
|
47
59
|
alt: "",
|
|
48
|
-
onError:
|
|
49
|
-
className: g(
|
|
60
|
+
onError: w,
|
|
61
|
+
className: g(m, "rst:object-cover", l === "rejected" && "rst:opacity-50"),
|
|
50
62
|
"data-file-thumb": "image"
|
|
51
63
|
}
|
|
52
64
|
) : /* @__PURE__ */ n(
|
|
53
65
|
"span",
|
|
54
66
|
{
|
|
55
67
|
"aria-hidden": "true",
|
|
56
|
-
className: g(
|
|
68
|
+
className: g(m, "rst:flex rst:items-center rst:justify-center rst:text-gray-500 rst:dark:text-gray-400"),
|
|
57
69
|
"data-file-thumb": "placeholder",
|
|
58
|
-
children:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
children: at
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function It({ file: e, status: l }) {
|
|
75
|
+
const { image: h, attach: b, broke: w } = ot(e);
|
|
76
|
+
return /* @__PURE__ */ n(
|
|
77
|
+
"span",
|
|
78
|
+
{
|
|
79
|
+
"aria-hidden": "true",
|
|
80
|
+
className: "rst:pointer-events-none rst:absolute rst:inset-3 rst:flex rst:items-center rst:justify-center",
|
|
81
|
+
"data-file-preview": h ? "image" : "placeholder",
|
|
82
|
+
children: h ? /* @__PURE__ */ n(
|
|
83
|
+
"img",
|
|
84
|
+
{
|
|
85
|
+
ref: b,
|
|
86
|
+
alt: "",
|
|
87
|
+
onError: w,
|
|
88
|
+
className: g("rst:h-full rst:w-full rst:rounded-md rst:object-contain", l === "rejected" && "rst:opacity-50")
|
|
89
|
+
}
|
|
90
|
+
) : /* @__PURE__ */ n("span", { className: "rst:text-gray-500 rst:dark:text-gray-400", children: at })
|
|
63
91
|
}
|
|
64
92
|
);
|
|
65
93
|
}
|
|
66
|
-
const
|
|
67
|
-
function
|
|
68
|
-
label:
|
|
69
|
-
upload:
|
|
70
|
-
onChange:
|
|
71
|
-
accept:
|
|
72
|
-
types:
|
|
73
|
-
maxSize:
|
|
74
|
-
maxFiles:
|
|
75
|
-
validate:
|
|
76
|
-
concurrency:
|
|
77
|
-
helperText:
|
|
78
|
-
errorMessage:
|
|
79
|
-
disabled:
|
|
80
|
-
strings:
|
|
81
|
-
className:
|
|
94
|
+
const V = "rst:cursor-not-allowed rst:opacity-50", B = { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" };
|
|
95
|
+
function Gt({
|
|
96
|
+
label: e,
|
|
97
|
+
upload: l,
|
|
98
|
+
onChange: h,
|
|
99
|
+
accept: b = "image/*",
|
|
100
|
+
types: w,
|
|
101
|
+
maxSize: m,
|
|
102
|
+
maxFiles: p,
|
|
103
|
+
validate: it,
|
|
104
|
+
concurrency: J = 3,
|
|
105
|
+
helperText: O,
|
|
106
|
+
errorMessage: z,
|
|
107
|
+
disabled: u = !1,
|
|
108
|
+
strings: ct,
|
|
109
|
+
className: dt,
|
|
110
|
+
preview: P = "row"
|
|
82
111
|
}) {
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
112
|
+
Et();
|
|
113
|
+
const E = P === "dropzone" && p === 1;
|
|
114
|
+
rt(() => {
|
|
115
|
+
P === "dropzone" && p !== 1 && qt() && console.warn(`FileUpload: preview="dropzone" shows one file, so it takes maxFiles={1}. With maxFiles=${p}, the pictures stay on the rows.`);
|
|
116
|
+
}, [P, p]);
|
|
117
|
+
const a = Lt(Ct, ct), I = $t(), S = `${I}-label`, Q = `${I}-help`, X = `${I}-error`, [q, lt] = C([]), f = y(q), ut = y(0), v = y(/* @__PURE__ */ new Map()), A = y(null), Y = y(null), j = y({ upload: l, onChange: h, concurrency: J, t: a, pump: () => {
|
|
118
|
+
} }), [H, ft] = C({ text: "", n: 0 }), M = y([]), D = y(null), N = F((t, s = !1) => {
|
|
119
|
+
s && (M.current = M.current.filter((r) => !r.count)), M.current.push({ text: t, count: s }), !D.current && (D.current = setTimeout(() => {
|
|
120
|
+
D.current = null;
|
|
121
|
+
const r = M.current.map((i) => i.text).join(" ");
|
|
122
|
+
M.current = [], ft((i) => ({ text: r, n: i.n + 1 }));
|
|
90
123
|
}, 0));
|
|
91
|
-
}, []),
|
|
92
|
-
|
|
124
|
+
}, []), W = y(null), [pt, gt] = C(0), Z = (t) => {
|
|
125
|
+
W.current = t, gt((s) => s + 1);
|
|
93
126
|
};
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
97
|
-
|
|
98
|
-
}, [
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
}, []),
|
|
102
|
-
(
|
|
103
|
-
|
|
127
|
+
et(() => {
|
|
128
|
+
const t = W.current;
|
|
129
|
+
if (!t) return;
|
|
130
|
+
W.current = null, (A.current?.querySelector(t) ?? A.current?.querySelector("[data-file-choose]"))?.focus();
|
|
131
|
+
}, [pt]);
|
|
132
|
+
const T = F((t) => {
|
|
133
|
+
f.current = t, lt(t), j.current.onChange?.(t);
|
|
134
|
+
}, []), $ = F(
|
|
135
|
+
(t, s) => {
|
|
136
|
+
f.current.some((r) => r.id === t) && T(f.current.map((r) => r.id === t ? { ...r, ...s } : r));
|
|
104
137
|
},
|
|
105
|
-
[
|
|
138
|
+
[T]
|
|
106
139
|
);
|
|
107
|
-
function
|
|
108
|
-
const { concurrency:
|
|
109
|
-
for (const
|
|
140
|
+
function R() {
|
|
141
|
+
const { concurrency: t } = j.current, s = f.current.filter((i) => i.status === "uploading" || i.status === "processing").length, r = f.current.filter((i) => i.status === "queued").slice(0, Math.max(0, Math.max(1, t) - s));
|
|
142
|
+
for (const i of r) ht(i);
|
|
110
143
|
}
|
|
111
|
-
function
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
onProgress: (
|
|
116
|
-
if (!
|
|
117
|
-
const
|
|
118
|
-
|
|
144
|
+
function ht(t) {
|
|
145
|
+
const s = new AbortController();
|
|
146
|
+
v.current.set(t.id, s), $(t.id, { status: "uploading", progress: null, reason: void 0 });
|
|
147
|
+
const r = () => !s.signal.aborted && v.current.get(t.id) === s, i = {
|
|
148
|
+
onProgress: (c) => {
|
|
149
|
+
if (!r()) return;
|
|
150
|
+
const d = Math.round(Math.min(1, Math.max(0, Number.isFinite(c) ? c : 0)) * 100) / 100, o = f.current.find((L) => L.id === t.id);
|
|
151
|
+
o?.status === "uploading" && o.progress !== d && $(t.id, { progress: d });
|
|
119
152
|
},
|
|
120
153
|
onProcessing: () => {
|
|
121
|
-
|
|
154
|
+
r() && $(t.id, { status: "processing" });
|
|
122
155
|
},
|
|
123
|
-
signal:
|
|
156
|
+
signal: s.signal
|
|
124
157
|
};
|
|
125
|
-
new Promise((
|
|
126
|
-
(
|
|
127
|
-
if (!
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
158
|
+
new Promise((c) => c(j.current.upload(t.file, i))).then(
|
|
159
|
+
(c) => {
|
|
160
|
+
if (!r()) return;
|
|
161
|
+
v.current.delete(t.id), $(t.id, { status: "done", progress: 1, result: c });
|
|
162
|
+
const d = f.current.filter((o) => o.status !== "rejected");
|
|
163
|
+
N(j.current.t.progress(d.filter((o) => o.status === "done").length, d.length), !0), R();
|
|
131
164
|
},
|
|
132
|
-
(
|
|
133
|
-
if (!
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
165
|
+
(c) => {
|
|
166
|
+
if (!r()) return;
|
|
167
|
+
v.current.delete(t.id);
|
|
168
|
+
const { t: d } = j.current;
|
|
169
|
+
if (Rt(c)) {
|
|
170
|
+
const o = c.message, L = typeof o == "string" && o ? o : d.uploadError(c);
|
|
171
|
+
$(t.id, { status: "rejected", progress: null, reason: L }), N(d.rejectedNotice(t.file.name, L));
|
|
172
|
+
} else {
|
|
173
|
+
const o = d.uploadError(c);
|
|
174
|
+
$(t.id, { status: "failed", reason: o }), N(d.failedNotice(t.file.name, o));
|
|
175
|
+
}
|
|
176
|
+
R();
|
|
137
177
|
}
|
|
138
178
|
);
|
|
139
179
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}),
|
|
143
|
-
const
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
(
|
|
180
|
+
et(() => {
|
|
181
|
+
j.current = { upload: l, onChange: h, concurrency: J, t: a, pump: R };
|
|
182
|
+
}), rt(() => {
|
|
183
|
+
const t = v.current;
|
|
184
|
+
return f.current.some((r) => (r.status === "uploading" || r.status === "processing") && !t.has(r.id)) && (T(
|
|
185
|
+
f.current.map(
|
|
186
|
+
(r) => (r.status === "uploading" || r.status === "processing") && !t.has(r.id) ? { ...r, status: "queued", progress: null } : r
|
|
147
187
|
)
|
|
148
|
-
),
|
|
149
|
-
for (const
|
|
150
|
-
|
|
188
|
+
), j.current.pump()), () => {
|
|
189
|
+
for (const r of t.values()) r.abort();
|
|
190
|
+
t.clear(), D.current && clearTimeout(D.current), D.current = null, M.current = [];
|
|
151
191
|
};
|
|
152
|
-
}, [
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
if (!
|
|
158
|
-
if (
|
|
159
|
-
if (
|
|
160
|
-
},
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
for (const o of
|
|
164
|
-
const
|
|
165
|
-
|
|
192
|
+
}, [T]);
|
|
193
|
+
const mt = w ?? Dt(b), vt = (t, s) => {
|
|
194
|
+
if (s.some((i) => nt(i.file, t))) return a.duplicate(t);
|
|
195
|
+
const r = it?.(t);
|
|
196
|
+
if (r) return r;
|
|
197
|
+
if (!Tt(t, mt)) return a.wrongType(t);
|
|
198
|
+
if (m !== void 0 && t.size > m) return a.tooLarge(t, m);
|
|
199
|
+
if (p !== void 0 && s.length >= p) return a.tooMany(p);
|
|
200
|
+
}, tt = (t) => {
|
|
201
|
+
if (u || t.length === 0) return;
|
|
202
|
+
const s = E ? f.current.find((o) => o.status !== "rejected") : void 0, r = f.current.filter((o) => o.status !== "rejected" && o !== s), i = [];
|
|
203
|
+
for (const o of t) {
|
|
204
|
+
const L = s && nt(s.file, o) ? a.duplicate(o) : vt(o, [...r, ...i.filter((Nt) => Nt.status !== "rejected")]);
|
|
205
|
+
i.push({ id: `${I}-file-${ut.current++}`, file: o, status: L ? "rejected" : "queued", progress: null, reason: L });
|
|
166
206
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
E(r) && (r.preventDefault(), P((e) => e + 1));
|
|
207
|
+
const c = i.filter((o) => o.status === "queued").length, d = c ? s : void 0;
|
|
208
|
+
d && (v.current.get(d.id)?.abort(), v.current.delete(d.id)), T([...f.current.filter((o) => o !== d), ...i]), d && N(a.removed(d.file.name)), c && N(a.added(c));
|
|
209
|
+
for (const o of i) o.reason && N(a.rejectedNotice(o.file.name, o.reason));
|
|
210
|
+
R();
|
|
211
|
+
}, yt = (t) => {
|
|
212
|
+
if (u) return;
|
|
213
|
+
const s = f.current, r = s.findIndex((c) => c.id === t);
|
|
214
|
+
if (r < 0) return;
|
|
215
|
+
v.current.get(t)?.abort(), v.current.delete(t);
|
|
216
|
+
const i = s[r + 1] ?? s[r - 1];
|
|
217
|
+
T(s.filter((c) => c.id !== t)), N(a.removed(s[r].file.name)), Z(i ? `[data-file-remove="${i.id}"]` : "[data-file-choose]"), R();
|
|
218
|
+
}, xt = (t) => {
|
|
219
|
+
u || ($(t, { status: "queued", progress: null, reason: void 0 }), Z(`[data-file-remove="${t}"]`), R());
|
|
220
|
+
}, [bt, _] = C(0), U = (t) => Array.from(t.dataTransfer?.types ?? []).includes("Files"), kt = {
|
|
221
|
+
onDragEnter: (t) => {
|
|
222
|
+
U(t) && (t.preventDefault(), _((s) => s + 1));
|
|
184
223
|
},
|
|
185
|
-
onDragOver: (
|
|
186
|
-
|
|
224
|
+
onDragOver: (t) => {
|
|
225
|
+
U(t) && (t.preventDefault(), t.dataTransfer.dropEffect = u ? "none" : "copy");
|
|
187
226
|
},
|
|
188
|
-
onDragLeave: (
|
|
189
|
-
|
|
227
|
+
onDragLeave: (t) => {
|
|
228
|
+
U(t) && _((s) => Math.max(0, s - 1));
|
|
190
229
|
},
|
|
191
|
-
onDrop: (
|
|
192
|
-
|
|
230
|
+
onDrop: (t) => {
|
|
231
|
+
U(t) && (t.preventDefault(), _(0), tt(Array.from(t.dataTransfer.files)));
|
|
193
232
|
}
|
|
194
|
-
},
|
|
195
|
-
switch (
|
|
233
|
+
}, G = bt > 0 && !u, wt = (t) => {
|
|
234
|
+
switch (t.status) {
|
|
196
235
|
case "queued":
|
|
197
236
|
return a.queued;
|
|
198
237
|
case "uploading":
|
|
199
|
-
return a.uploading(
|
|
238
|
+
return a.uploading(t.progress === null ? null : Math.round(t.progress * 100));
|
|
200
239
|
case "processing":
|
|
201
240
|
return a.processing;
|
|
202
241
|
case "done":
|
|
203
242
|
return a.done;
|
|
204
243
|
case "failed":
|
|
205
|
-
return `${a.failed} ${
|
|
244
|
+
return `${a.failed} ${t.reason ?? ""}`.trim();
|
|
206
245
|
case "rejected":
|
|
207
|
-
return `${a.rejected} ${
|
|
246
|
+
return `${a.rejected} ${t.reason ?? ""}`.trim();
|
|
208
247
|
}
|
|
209
|
-
},
|
|
210
|
-
return /* @__PURE__ */
|
|
248
|
+
}, jt = [O ? Q : null, z ? X : null].filter(Boolean).join(" ") || void 0, k = E ? q.find((t) => t.status !== "rejected") ?? q.at(-1) : void 0;
|
|
249
|
+
return /* @__PURE__ */ x(
|
|
211
250
|
"div",
|
|
212
251
|
{
|
|
213
|
-
ref:
|
|
252
|
+
ref: A,
|
|
214
253
|
role: "group",
|
|
215
254
|
"aria-labelledby": S,
|
|
216
|
-
className: g("rst:font-ui rst:w-full",
|
|
255
|
+
className: g("rst:font-ui rst:w-full", dt),
|
|
217
256
|
"data-file-upload": "",
|
|
218
257
|
children: [
|
|
219
258
|
/* @__PURE__ */ n(
|
|
@@ -222,58 +261,69 @@ function Ur({
|
|
|
222
261
|
id: S,
|
|
223
262
|
className: g(
|
|
224
263
|
"rst:mb-1.5 rst:text-left rst:text-sm rst:font-medium rst:leading-none rst:text-[var(--roster-control-text)]",
|
|
225
|
-
|
|
264
|
+
u && "rst:opacity-70"
|
|
226
265
|
),
|
|
227
|
-
children:
|
|
266
|
+
children: e
|
|
228
267
|
}
|
|
229
268
|
),
|
|
230
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ x(
|
|
231
270
|
"div",
|
|
232
271
|
{
|
|
233
|
-
...
|
|
272
|
+
...kt,
|
|
234
273
|
"data-file-drop": "",
|
|
235
|
-
"data-dragging":
|
|
274
|
+
"data-dragging": G ? "" : void 0,
|
|
236
275
|
className: g(
|
|
237
276
|
"rst:flex rst:flex-col rst:items-center rst:justify-center rst:gap-2 rst:rounded-lg rst:border-2 rst:border-dashed rst:px-4 rst:py-6 rst:text-center rst:transition-colors rst:motion-reduce:transition-none",
|
|
238
|
-
|
|
277
|
+
/* One height with a picture or without, so nothing below moves when
|
|
278
|
+
it arrives; the button sits at the foot of a picture. */
|
|
279
|
+
E && "rst:relative rst:h-[var(--roster-file-preview-height,13rem)]",
|
|
280
|
+
E && k && "rst:justify-end",
|
|
281
|
+
G ? "rst:border-primary-500 rst:bg-primary-500/10" : z ? "rst:border-error-500 rst:dark:border-error-400" : "rst:border-gray-300 rst:dark:border-gray-600"
|
|
239
282
|
),
|
|
240
283
|
children: [
|
|
284
|
+
k && /* @__PURE__ */ n(It, { file: k.file, status: k.status }, k.id),
|
|
241
285
|
/* @__PURE__ */ n(
|
|
242
|
-
|
|
286
|
+
K,
|
|
243
287
|
{
|
|
244
288
|
type: "button",
|
|
245
289
|
variant: "outline",
|
|
246
290
|
colorScheme: "neutral",
|
|
247
291
|
size: "lg",
|
|
248
|
-
className: g(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
292
|
+
className: g(
|
|
293
|
+
"rst:px-5",
|
|
294
|
+
u && V,
|
|
295
|
+
/* Over a picture: above it, on a surface of its own, so it reads
|
|
296
|
+
whatever the photo is. */
|
|
297
|
+
k && "rst:relative rst:z-10 rst:bg-[var(--roster-card-bg)] rst:dark:hover:bg-gray-800"
|
|
298
|
+
),
|
|
299
|
+
"aria-disabled": u || void 0,
|
|
300
|
+
"aria-describedby": jt,
|
|
301
|
+
onClick: () => Y.current?.click(),
|
|
252
302
|
"data-file-choose": "",
|
|
253
|
-
startIcon: /* @__PURE__ */ n("svg", { ...
|
|
254
|
-
children: a.choose
|
|
303
|
+
startIcon: /* @__PURE__ */ n("svg", { ...B, "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M12 16V4M7 9l5-5 5 5M5 20h14" }) }),
|
|
304
|
+
children: k ? a.replace : a.choose
|
|
255
305
|
}
|
|
256
306
|
),
|
|
257
|
-
/* @__PURE__ */ n(
|
|
307
|
+
!k && /* @__PURE__ */ n(
|
|
258
308
|
"p",
|
|
259
309
|
{
|
|
260
310
|
className: "rst:hidden rst:text-xs rst:text-gray-600 rst:pointer-fine:block rst:dark:text-gray-400",
|
|
261
311
|
"data-file-drop-hint": "",
|
|
262
|
-
children:
|
|
312
|
+
children: G ? a.dropHere : a.dropHint
|
|
263
313
|
}
|
|
264
314
|
),
|
|
265
315
|
/* @__PURE__ */ n(
|
|
266
316
|
"input",
|
|
267
317
|
{
|
|
268
|
-
ref:
|
|
318
|
+
ref: Y,
|
|
269
319
|
type: "file",
|
|
270
320
|
hidden: !0,
|
|
271
321
|
tabIndex: -1,
|
|
272
|
-
accept:
|
|
273
|
-
multiple:
|
|
274
|
-
disabled:
|
|
275
|
-
onChange: (
|
|
276
|
-
|
|
322
|
+
accept: b,
|
|
323
|
+
multiple: p !== 1,
|
|
324
|
+
disabled: u,
|
|
325
|
+
onChange: (t) => {
|
|
326
|
+
tt(Array.from(t.currentTarget.files ?? [])), t.currentTarget.value = "";
|
|
277
327
|
},
|
|
278
328
|
"data-file-input": ""
|
|
279
329
|
}
|
|
@@ -281,87 +331,87 @@ function Ur({
|
|
|
281
331
|
]
|
|
282
332
|
}
|
|
283
333
|
),
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
return /* @__PURE__ */
|
|
334
|
+
O && /* @__PURE__ */ n("p", { id: Q, className: "rst:mt-1.5 rst:text-left rst:text-xs rst:text-gray-500 rst:dark:text-gray-400", children: O }),
|
|
335
|
+
z && /* @__PURE__ */ n("p", { id: X, className: "rst:mt-1.5 rst:text-left rst:text-xs rst:font-medium rst:text-error-600 rst:dark:text-error-400", children: z }),
|
|
336
|
+
q.length > 0 && /* @__PURE__ */ n("ul", { className: "rst:mt-3 rst:flex rst:flex-col rst:gap-2", "aria-labelledby": S, children: q.map((t) => {
|
|
337
|
+
const s = t.status === "failed" || t.status === "rejected", r = t.status === "uploading" || t.status === "processing" || t.status === "queued";
|
|
338
|
+
return /* @__PURE__ */ x(
|
|
289
339
|
"li",
|
|
290
340
|
{
|
|
291
|
-
"data-file-item":
|
|
292
|
-
"data-status":
|
|
341
|
+
"data-file-item": t.id,
|
|
342
|
+
"data-status": t.status,
|
|
293
343
|
className: "rst:flex rst:items-center rst:gap-3 rst:rounded-md rst:border rst:border-[var(--roster-card-border)] rst:p-2",
|
|
294
344
|
children: [
|
|
295
|
-
/* @__PURE__ */ n(
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
/* @__PURE__ */ n("p", { className: "rst:truncate rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]", title:
|
|
298
|
-
/* @__PURE__ */
|
|
345
|
+
!E && /* @__PURE__ */ n(zt, { file: t.file, status: t.status }),
|
|
346
|
+
/* @__PURE__ */ x("div", { className: "rst:min-w-0 rst:flex-1 rst:text-left", children: [
|
|
347
|
+
/* @__PURE__ */ n("p", { className: "rst:truncate rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]", title: t.file.name, children: t.file.name }),
|
|
348
|
+
/* @__PURE__ */ x(
|
|
299
349
|
"p",
|
|
300
350
|
{
|
|
301
351
|
className: g(
|
|
302
352
|
"rst:mt-0.5 rst:flex rst:items-start rst:gap-1 rst:text-xs",
|
|
303
|
-
|
|
353
|
+
s ? "rst:text-error-600 rst:dark:text-error-400" : "rst:text-gray-600 rst:dark:text-gray-400"
|
|
304
354
|
),
|
|
305
355
|
"data-file-status": "",
|
|
306
356
|
children: [
|
|
307
|
-
|
|
308
|
-
/* @__PURE__ */
|
|
309
|
-
/* @__PURE__ */ n("span", { className: "rst:tabular-nums", children: a.size(
|
|
357
|
+
t.status === "done" && /* @__PURE__ */ n("svg", { ...B, width: 14, height: 14, "aria-hidden": "true", className: "rst:mt-px rst:shrink-0 rst:text-success-600 rst:dark:text-success-400", children: /* @__PURE__ */ n("path", { d: "M20 6 9 17l-5-5" }) }),
|
|
358
|
+
/* @__PURE__ */ x("span", { children: [
|
|
359
|
+
/* @__PURE__ */ n("span", { className: "rst:tabular-nums", children: a.size(t.file.size) }),
|
|
310
360
|
/* @__PURE__ */ n("span", { "aria-hidden": "true", children: " · " }),
|
|
311
|
-
|
|
361
|
+
wt(t)
|
|
312
362
|
] })
|
|
313
363
|
]
|
|
314
364
|
}
|
|
315
365
|
),
|
|
316
|
-
|
|
317
|
-
|
|
366
|
+
r && /* @__PURE__ */ n("div", { className: "rst:mt-1.5", "data-file-progress": "", children: /* @__PURE__ */ n(
|
|
367
|
+
Mt,
|
|
318
368
|
{
|
|
319
369
|
size: "sm",
|
|
320
|
-
value:
|
|
321
|
-
busy:
|
|
370
|
+
value: t.status === "processing" ? 100 : t.status === "uploading" ? (t.progress ?? 0) * 100 : 0,
|
|
371
|
+
busy: t.status === "processing" || t.status === "uploading" && t.progress === null,
|
|
322
372
|
announce: !1
|
|
323
373
|
}
|
|
324
374
|
) })
|
|
325
375
|
] }),
|
|
326
|
-
|
|
327
|
-
|
|
376
|
+
t.status === "failed" && /* @__PURE__ */ n(
|
|
377
|
+
K,
|
|
328
378
|
{
|
|
329
379
|
type: "button",
|
|
330
380
|
variant: "ghost",
|
|
331
381
|
colorScheme: "neutral",
|
|
332
382
|
size: "icon",
|
|
333
|
-
className: g("rst:h-11 rst:w-11",
|
|
334
|
-
"aria-disabled":
|
|
335
|
-
"aria-label": a.retry(
|
|
336
|
-
onClick: () =>
|
|
337
|
-
"data-file-retry":
|
|
338
|
-
children: /* @__PURE__ */
|
|
383
|
+
className: g("rst:h-11 rst:w-11", u && V),
|
|
384
|
+
"aria-disabled": u || void 0,
|
|
385
|
+
"aria-label": a.retry(t.file.name),
|
|
386
|
+
onClick: () => xt(t.id),
|
|
387
|
+
"data-file-retry": t.id,
|
|
388
|
+
children: /* @__PURE__ */ x("svg", { ...B, "aria-hidden": "true", children: [
|
|
339
389
|
/* @__PURE__ */ n("path", { d: "M3 12a9 9 0 1 0 3-6.7L3 8" }),
|
|
340
390
|
/* @__PURE__ */ n("path", { d: "M3 3v5h5" })
|
|
341
391
|
] })
|
|
342
392
|
}
|
|
343
393
|
),
|
|
344
394
|
/* @__PURE__ */ n(
|
|
345
|
-
|
|
395
|
+
K,
|
|
346
396
|
{
|
|
347
397
|
type: "button",
|
|
348
398
|
variant: "ghost",
|
|
349
399
|
colorScheme: "neutral",
|
|
350
400
|
size: "icon",
|
|
351
|
-
className: g("rst:h-11 rst:w-11",
|
|
352
|
-
"aria-disabled":
|
|
353
|
-
"aria-label": a.remove(
|
|
354
|
-
onClick: () =>
|
|
355
|
-
"data-file-remove":
|
|
356
|
-
children: /* @__PURE__ */ n("svg", { ...
|
|
401
|
+
className: g("rst:h-11 rst:w-11", u && V),
|
|
402
|
+
"aria-disabled": u || void 0,
|
|
403
|
+
"aria-label": a.remove(t.file.name),
|
|
404
|
+
onClick: () => yt(t.id),
|
|
405
|
+
"data-file-remove": t.id,
|
|
406
|
+
children: /* @__PURE__ */ n("svg", { ...B, "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
357
407
|
}
|
|
358
408
|
)
|
|
359
409
|
]
|
|
360
410
|
},
|
|
361
|
-
|
|
411
|
+
t.id
|
|
362
412
|
);
|
|
363
413
|
}) }),
|
|
364
|
-
/* @__PURE__ */
|
|
414
|
+
/* @__PURE__ */ x(
|
|
365
415
|
"div",
|
|
366
416
|
{
|
|
367
417
|
role: "status",
|
|
@@ -369,10 +419,10 @@ function Ur({
|
|
|
369
419
|
"aria-atomic": "true",
|
|
370
420
|
className: "rst:sr-only",
|
|
371
421
|
"data-file-live": "",
|
|
372
|
-
"data-file-live-n":
|
|
422
|
+
"data-file-live-n": H.n,
|
|
373
423
|
children: [
|
|
374
|
-
|
|
375
|
-
|
|
424
|
+
H.text,
|
|
425
|
+
H.n % 2 ? " " : ""
|
|
376
426
|
]
|
|
377
427
|
}
|
|
378
428
|
)
|
|
@@ -381,5 +431,5 @@ function Ur({
|
|
|
381
431
|
);
|
|
382
432
|
}
|
|
383
433
|
export {
|
|
384
|
-
|
|
434
|
+
Gt as FileUpload
|
|
385
435
|
};
|