@blakesteve/roster 5.5.0 → 5.7.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 +183 -2
- package/dist/components/atoms/LoadingDots/LoadingDots.cjs +1 -0
- package/dist/components/atoms/LoadingDots/LoadingDots.d.ts +20 -0
- package/dist/components/atoms/LoadingDots/LoadingDots.js +43 -0
- package/dist/components/atoms/Progress/Progress.cjs +1 -0
- package/dist/components/atoms/Progress/Progress.d.ts +61 -0
- package/dist/components/atoms/Progress/Progress.js +106 -0
- package/dist/components/atoms/Progress/progress-values.cjs +1 -0
- package/dist/components/atoms/Progress/progress-values.d.ts +26 -0
- package/dist/components/atoms/Progress/progress-values.js +12 -0
- package/dist/components/atoms/Skeleton/Skeleton.cjs +1 -0
- package/dist/components/atoms/Skeleton/Skeleton.d.ts +79 -0
- package/dist/components/atoms/Skeleton/Skeleton.js +80 -0
- package/dist/components/atoms/Stat/Stat.cjs +1 -1
- package/dist/components/atoms/Stat/Stat.js +19 -19
- package/dist/components/atoms/Stat/stat-variants.cjs +1 -1
- package/dist/components/atoms/Stat/stat-variants.d.ts +1 -0
- package/dist/components/atoms/Stat/stat-variants.js +5 -4
- package/dist/components/molecules/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/molecules/FileUpload/FileUpload.js +120 -141
- package/dist/components/molecules/Pagination/Pagination.cjs +1 -0
- package/dist/components/molecules/Pagination/Pagination.d.ts +116 -0
- package/dist/components/molecules/Pagination/Pagination.js +247 -0
- package/dist/components/molecules/Pagination/page-items.cjs +1 -0
- package/dist/components/molecules/Pagination/page-items.d.ts +13 -0
- package/dist/components/molecules/Pagination/page-items.js +11 -0
- package/dist/components/molecules/ProgressField/ProgressField.cjs +1 -0
- package/dist/components/molecules/ProgressField/ProgressField.d.ts +23 -0
- package/dist/components/molecules/ProgressField/ProgressField.js +32 -0
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.cjs +1 -0
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.d.ts +55 -0
- package/dist/components/molecules/SkeletonPresets/SkeletonPresets.js +45 -0
- package/dist/components/molecules/StepProgress/StepProgress.cjs +1 -0
- package/dist/components/molecules/StepProgress/StepProgress.d.ts +36 -0
- package/dist/components/molecules/StepProgress/StepProgress.js +89 -0
- package/dist/components/organisms/DataTable/DataTable.cjs +1 -1
- package/dist/components/organisms/DataTable/DataTable.d.ts +8 -1
- package/dist/components/organisms/DataTable/DataTable.js +61 -98
- package/dist/components/organisms/Dialog/Dialog.d.ts +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/meta.json +3 -3
- package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.cjs +1 -1
- package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js +30 -50
- package/dist/roster.cjs +1 -1
- package/dist/roster.css +1 -1
- package/dist/roster.js +178 -159
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useId as vr, useState as L, useRef as
|
|
4
|
-
import { cn as
|
|
2
|
+
import { jsxs as p, jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { useId as vr, useState as L, useRef as f, useCallback as U, useLayoutEffect as Y, useEffect as xr } from "react";
|
|
4
|
+
import { cn as g } from "../../../lib/utils.js";
|
|
5
5
|
import { Button as G } from "../../atoms/Button/Button.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { Progress as yr } from "../../atoms/Progress/Progress.js";
|
|
7
|
+
import { formatBytes as Z, acceptList as br, sameFile as kr, matchesType as Nr } from "./file-rules.js";
|
|
8
|
+
const wr = {
|
|
8
9
|
choose: "Choose photos",
|
|
9
10
|
dropHint: "or drag them here",
|
|
10
11
|
dropHere: "Drop to add them",
|
|
@@ -28,7 +29,7 @@ const Nr = {
|
|
|
28
29
|
rejectedNotice: (s, d) => `${s} wasn't added. ${d}`,
|
|
29
30
|
removed: (s) => `${s} removed.`
|
|
30
31
|
};
|
|
31
|
-
function
|
|
32
|
+
function $r({ file: s, status: d }) {
|
|
32
33
|
const [T, D] = L(!1), B = !T && (s.type.startsWith("image/") || /\.(jpe?g|png|gif|webp|avif|heic|heif)$/i.test(s.name)), $ = U(
|
|
33
34
|
(q) => {
|
|
34
35
|
if (!q) return;
|
|
@@ -43,16 +44,16 @@ function wr({ file: s, status: d }) {
|
|
|
43
44
|
ref: $,
|
|
44
45
|
alt: "",
|
|
45
46
|
onError: () => D(!0),
|
|
46
|
-
className:
|
|
47
|
+
className: g(v, "rst:object-cover", d === "rejected" && "rst:opacity-50"),
|
|
47
48
|
"data-file-thumb": "image"
|
|
48
49
|
}
|
|
49
50
|
) : /* @__PURE__ */ n(
|
|
50
51
|
"span",
|
|
51
52
|
{
|
|
52
53
|
"aria-hidden": "true",
|
|
53
|
-
className:
|
|
54
|
+
className: g(v, "rst:flex rst:items-center rst:justify-center rst:text-gray-500 rst:dark:text-gray-400"),
|
|
54
55
|
"data-file-thumb": "placeholder",
|
|
55
|
-
children: /* @__PURE__ */
|
|
56
|
+
children: /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
56
57
|
/* @__PURE__ */ n("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
57
58
|
/* @__PURE__ */ n("circle", { cx: "9", cy: "10", r: "1.6" }),
|
|
58
59
|
/* @__PURE__ */ n("path", { d: "m21 15-4.2-4.2a1.6 1.6 0 0 0-2.3 0L7 18" })
|
|
@@ -61,7 +62,7 @@ function wr({ file: s, status: d }) {
|
|
|
61
62
|
);
|
|
62
63
|
}
|
|
63
64
|
const V = "rst:cursor-not-allowed rst:opacity-50", I = { width: 20, height: 20, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" };
|
|
64
|
-
function
|
|
65
|
+
function Rr({
|
|
65
66
|
label: s,
|
|
66
67
|
upload: d,
|
|
67
68
|
onChange: T,
|
|
@@ -73,72 +74,72 @@ function Dr({
|
|
|
73
74
|
concurrency: j = 3,
|
|
74
75
|
helperText: S,
|
|
75
76
|
errorMessage: R,
|
|
76
|
-
disabled:
|
|
77
|
+
disabled: i = !1,
|
|
77
78
|
strings: rr,
|
|
78
79
|
className: tr
|
|
79
80
|
}) {
|
|
80
|
-
const
|
|
81
|
-
} }), [A, nr] = L({ text: "", n: 0 }), y =
|
|
81
|
+
const a = { ...wr, ...rr }, C = vr(), z = `${C}-label`, _ = `${C}-help`, J = `${C}-error`, [F, er] = L([]), u = f(F), sr = f(0), x = f(/* @__PURE__ */ new Map()), O = f(null), K = f(null), h = f({ upload: d, onChange: T, concurrency: j, t: a, pump: () => {
|
|
82
|
+
} }), [A, nr] = L({ text: "", n: 0 }), y = f([]), b = f(null), M = U((r, e = !1) => {
|
|
82
83
|
e && (y.current = y.current.filter((t) => !t.count)), y.current.push({ text: r, count: e }), !b.current && (b.current = setTimeout(() => {
|
|
83
84
|
b.current = null;
|
|
84
|
-
const t = y.current.map((
|
|
85
|
-
y.current = [], nr((
|
|
85
|
+
const t = y.current.map((c) => c.text).join(" ");
|
|
86
|
+
y.current = [], nr((c) => ({ text: t, n: c.n + 1 }));
|
|
86
87
|
}, 0));
|
|
87
|
-
}, []), H =
|
|
88
|
-
H.current = r,
|
|
88
|
+
}, []), H = f(null), [or, ar] = L(0), Q = (r) => {
|
|
89
|
+
H.current = r, ar((e) => e + 1);
|
|
89
90
|
};
|
|
90
91
|
Y(() => {
|
|
91
92
|
const r = H.current;
|
|
92
93
|
if (!r) return;
|
|
93
94
|
H.current = null, (O.current?.querySelector(r) ?? O.current?.querySelector("[data-file-choose]"))?.focus();
|
|
94
|
-
}, [
|
|
95
|
+
}, [or]);
|
|
95
96
|
const k = U((r) => {
|
|
96
|
-
|
|
97
|
+
u.current = r, er(r), h.current.onChange?.(r);
|
|
97
98
|
}, []), N = U(
|
|
98
99
|
(r, e) => {
|
|
99
|
-
|
|
100
|
+
u.current.some((t) => t.id === r) && k(u.current.map((t) => t.id === r ? { ...t, ...e } : t));
|
|
100
101
|
},
|
|
101
102
|
[k]
|
|
102
103
|
);
|
|
103
104
|
function w() {
|
|
104
|
-
const { concurrency: r } = h.current, e =
|
|
105
|
-
for (const
|
|
105
|
+
const { concurrency: r } = h.current, e = u.current.filter((c) => c.status === "uploading" || c.status === "processing").length, t = u.current.filter((c) => c.status === "queued").slice(0, Math.max(0, Math.max(1, r) - e));
|
|
106
|
+
for (const c of t) cr(c);
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function cr(r) {
|
|
108
109
|
const e = new AbortController();
|
|
109
110
|
x.current.set(r.id, e), N(r.id, { status: "uploading", progress: null, reason: void 0 });
|
|
110
|
-
const t = () => !e.signal.aborted && x.current.get(r.id) === e,
|
|
111
|
-
onProgress: (
|
|
111
|
+
const t = () => !e.signal.aborted && x.current.get(r.id) === e, c = {
|
|
112
|
+
onProgress: (o) => {
|
|
112
113
|
if (!t()) return;
|
|
113
|
-
const
|
|
114
|
-
m?.status === "uploading" && m.progress !==
|
|
114
|
+
const l = Math.round(Math.min(1, Math.max(0, Number.isFinite(o) ? o : 0)) * 100) / 100, m = u.current.find((mr) => mr.id === r.id);
|
|
115
|
+
m?.status === "uploading" && m.progress !== l && N(r.id, { progress: l });
|
|
115
116
|
},
|
|
116
117
|
onProcessing: () => {
|
|
117
118
|
t() && N(r.id, { status: "processing" });
|
|
118
119
|
},
|
|
119
120
|
signal: e.signal
|
|
120
121
|
};
|
|
121
|
-
new Promise((
|
|
122
|
-
(
|
|
122
|
+
new Promise((o) => o(h.current.upload(r.file, c))).then(
|
|
123
|
+
(o) => {
|
|
123
124
|
if (!t()) return;
|
|
124
|
-
x.current.delete(r.id), N(r.id, { status: "done", progress: 1, result:
|
|
125
|
-
const
|
|
126
|
-
M(h.current.t.progress(
|
|
125
|
+
x.current.delete(r.id), N(r.id, { status: "done", progress: 1, result: o });
|
|
126
|
+
const l = u.current.filter((m) => m.status !== "rejected");
|
|
127
|
+
M(h.current.t.progress(l.filter((m) => m.status === "done").length, l.length), !0), w();
|
|
127
128
|
},
|
|
128
|
-
(
|
|
129
|
+
(o) => {
|
|
129
130
|
if (!t()) return;
|
|
130
131
|
x.current.delete(r.id);
|
|
131
|
-
const
|
|
132
|
-
N(r.id, { status: "failed", reason:
|
|
132
|
+
const l = h.current.t.uploadError(o);
|
|
133
|
+
N(r.id, { status: "failed", reason: l }), M(h.current.t.failedNotice(r.file.name, l)), w();
|
|
133
134
|
}
|
|
134
135
|
);
|
|
135
136
|
}
|
|
136
137
|
Y(() => {
|
|
137
|
-
h.current = { upload: d, onChange: T, concurrency: j, t:
|
|
138
|
+
h.current = { upload: d, onChange: T, concurrency: j, t: a, pump: w };
|
|
138
139
|
}), xr(() => {
|
|
139
140
|
const r = x.current;
|
|
140
|
-
return
|
|
141
|
-
|
|
141
|
+
return u.current.some((t) => (t.status === "uploading" || t.status === "processing") && !r.has(t.id)) && (k(
|
|
142
|
+
u.current.map(
|
|
142
143
|
(t) => (t.status === "uploading" || t.status === "processing") && !r.has(t.id) ? { ...t, status: "queued", progress: null } : t
|
|
143
144
|
)
|
|
144
145
|
), h.current.pump()), () => {
|
|
@@ -146,92 +147,92 @@ function Dr({
|
|
|
146
147
|
r.clear(), b.current && clearTimeout(b.current), b.current = null, y.current = [];
|
|
147
148
|
};
|
|
148
149
|
}, [k]);
|
|
149
|
-
const
|
|
150
|
-
if (e.some((
|
|
150
|
+
const ir = B ?? br(D), dr = (r, e) => {
|
|
151
|
+
if (e.some((c) => kr(c.file, r))) return a.duplicate(r);
|
|
151
152
|
const t = q?.(r);
|
|
152
153
|
if (t) return t;
|
|
153
|
-
if (!
|
|
154
|
-
if ($ !== void 0 && r.size > $) return
|
|
155
|
-
if (v !== void 0 && e.length >= v) return
|
|
156
|
-
},
|
|
157
|
-
if (
|
|
158
|
-
const e =
|
|
159
|
-
for (const
|
|
160
|
-
const
|
|
161
|
-
t.push({ id: `${C}-file-${sr.current++}`, file:
|
|
154
|
+
if (!Nr(r, ir)) return a.wrongType(r);
|
|
155
|
+
if ($ !== void 0 && r.size > $) return a.tooLarge(r, $);
|
|
156
|
+
if (v !== void 0 && e.length >= v) return a.tooMany(v);
|
|
157
|
+
}, X = (r) => {
|
|
158
|
+
if (i || r.length === 0) return;
|
|
159
|
+
const e = u.current.filter((o) => o.status !== "rejected"), t = [];
|
|
160
|
+
for (const o of r) {
|
|
161
|
+
const l = dr(o, [...e, ...t.filter((m) => m.status !== "rejected")]);
|
|
162
|
+
t.push({ id: `${C}-file-${sr.current++}`, file: o, status: l ? "rejected" : "queued", progress: null, reason: l });
|
|
162
163
|
}
|
|
163
|
-
k([...
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
for (const
|
|
164
|
+
k([...u.current, ...t]);
|
|
165
|
+
const c = t.filter((o) => o.status === "queued").length;
|
|
166
|
+
c && M(a.added(c));
|
|
167
|
+
for (const o of t) o.reason && M(a.rejectedNotice(o.file.name, o.reason));
|
|
167
168
|
w();
|
|
168
|
-
},
|
|
169
|
-
if (
|
|
170
|
-
const e =
|
|
169
|
+
}, ur = (r) => {
|
|
170
|
+
if (i) return;
|
|
171
|
+
const e = u.current, t = e.findIndex((o) => o.id === r);
|
|
171
172
|
if (t < 0) return;
|
|
172
173
|
x.current.get(r)?.abort(), x.current.delete(r);
|
|
173
|
-
const
|
|
174
|
-
k(e.filter((
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
}, [fr,
|
|
174
|
+
const c = e[t + 1] ?? e[t - 1];
|
|
175
|
+
k(e.filter((o) => o.id !== r)), M(a.removed(e[t].file.name)), Q(c ? `[data-file-remove="${c.id}"]` : "[data-file-choose]"), w();
|
|
176
|
+
}, lr = (r) => {
|
|
177
|
+
i || (N(r, { status: "queued", progress: null, reason: void 0 }), Q(`[data-file-remove="${r}"]`), w());
|
|
178
|
+
}, [fr, P] = L(0), E = (r) => Array.from(r.dataTransfer?.types ?? []).includes("Files"), pr = {
|
|
178
179
|
onDragEnter: (r) => {
|
|
179
|
-
E(r) && (r.preventDefault(),
|
|
180
|
+
E(r) && (r.preventDefault(), P((e) => e + 1));
|
|
180
181
|
},
|
|
181
182
|
onDragOver: (r) => {
|
|
182
|
-
E(r) && (r.preventDefault(), r.dataTransfer.dropEffect =
|
|
183
|
+
E(r) && (r.preventDefault(), r.dataTransfer.dropEffect = i ? "none" : "copy");
|
|
183
184
|
},
|
|
184
185
|
onDragLeave: (r) => {
|
|
185
|
-
E(r) &&
|
|
186
|
+
E(r) && P((e) => Math.max(0, e - 1));
|
|
186
187
|
},
|
|
187
188
|
onDrop: (r) => {
|
|
188
|
-
E(r) && (r.preventDefault(),
|
|
189
|
+
E(r) && (r.preventDefault(), P(0), X(Array.from(r.dataTransfer.files)));
|
|
189
190
|
}
|
|
190
|
-
},
|
|
191
|
+
}, W = fr > 0 && !i, gr = (r) => {
|
|
191
192
|
switch (r.status) {
|
|
192
193
|
case "queued":
|
|
193
|
-
return
|
|
194
|
+
return a.queued;
|
|
194
195
|
case "uploading":
|
|
195
|
-
return
|
|
196
|
+
return a.uploading(r.progress === null ? null : Math.round(r.progress * 100));
|
|
196
197
|
case "processing":
|
|
197
|
-
return
|
|
198
|
+
return a.processing;
|
|
198
199
|
case "done":
|
|
199
|
-
return
|
|
200
|
+
return a.done;
|
|
200
201
|
case "failed":
|
|
201
|
-
return `${
|
|
202
|
+
return `${a.failed} ${r.reason ?? ""}`.trim();
|
|
202
203
|
case "rejected":
|
|
203
|
-
return `${
|
|
204
|
+
return `${a.rejected} ${r.reason ?? ""}`.trim();
|
|
204
205
|
}
|
|
205
|
-
}, hr = [S ?
|
|
206
|
-
return /* @__PURE__ */
|
|
206
|
+
}, hr = [S ? _ : null, R ? J : null].filter(Boolean).join(" ") || void 0;
|
|
207
|
+
return /* @__PURE__ */ p(
|
|
207
208
|
"div",
|
|
208
209
|
{
|
|
209
210
|
ref: O,
|
|
210
211
|
role: "group",
|
|
211
|
-
"aria-labelledby":
|
|
212
|
-
className:
|
|
212
|
+
"aria-labelledby": z,
|
|
213
|
+
className: g("rst:font-ui rst:w-full", tr),
|
|
213
214
|
"data-file-upload": "",
|
|
214
215
|
children: [
|
|
215
216
|
/* @__PURE__ */ n(
|
|
216
217
|
"p",
|
|
217
218
|
{
|
|
218
|
-
id:
|
|
219
|
-
className:
|
|
219
|
+
id: z,
|
|
220
|
+
className: g(
|
|
220
221
|
"rst:mb-1.5 rst:text-left rst:text-sm rst:font-medium rst:leading-none rst:text-[var(--roster-control-text)]",
|
|
221
|
-
|
|
222
|
+
i && "rst:opacity-70"
|
|
222
223
|
),
|
|
223
224
|
children: s
|
|
224
225
|
}
|
|
225
226
|
),
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
+
/* @__PURE__ */ p(
|
|
227
228
|
"div",
|
|
228
229
|
{
|
|
229
230
|
...pr,
|
|
230
231
|
"data-file-drop": "",
|
|
231
|
-
"data-dragging":
|
|
232
|
-
className:
|
|
232
|
+
"data-dragging": W ? "" : void 0,
|
|
233
|
+
className: g(
|
|
233
234
|
"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",
|
|
234
|
-
|
|
235
|
+
W ? "rst:border-primary-500 rst:bg-primary-500/10" : R ? "rst:border-error-500 rst:dark:border-error-400" : "rst:border-gray-300 rst:dark:border-gray-600"
|
|
235
236
|
),
|
|
236
237
|
children: [
|
|
237
238
|
/* @__PURE__ */ n(
|
|
@@ -241,13 +242,13 @@ function Dr({
|
|
|
241
242
|
variant: "outline",
|
|
242
243
|
colorScheme: "neutral",
|
|
243
244
|
size: "lg",
|
|
244
|
-
className:
|
|
245
|
-
"aria-disabled":
|
|
245
|
+
className: g("rst:px-5", i && V),
|
|
246
|
+
"aria-disabled": i || void 0,
|
|
246
247
|
"aria-describedby": hr,
|
|
247
|
-
onClick: () =>
|
|
248
|
+
onClick: () => K.current?.click(),
|
|
248
249
|
"data-file-choose": "",
|
|
249
250
|
startIcon: /* @__PURE__ */ n("svg", { ...I, "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M12 16V4M7 9l5-5 5 5M5 20h14" }) }),
|
|
250
|
-
children:
|
|
251
|
+
children: a.choose
|
|
251
252
|
}
|
|
252
253
|
),
|
|
253
254
|
/* @__PURE__ */ n(
|
|
@@ -255,21 +256,21 @@ function Dr({
|
|
|
255
256
|
{
|
|
256
257
|
className: "rst:hidden rst:text-xs rst:text-gray-600 rst:pointer-fine:block rst:dark:text-gray-400",
|
|
257
258
|
"data-file-drop-hint": "",
|
|
258
|
-
children:
|
|
259
|
+
children: W ? a.dropHere : a.dropHint
|
|
259
260
|
}
|
|
260
261
|
),
|
|
261
262
|
/* @__PURE__ */ n(
|
|
262
263
|
"input",
|
|
263
264
|
{
|
|
264
|
-
ref:
|
|
265
|
+
ref: K,
|
|
265
266
|
type: "file",
|
|
266
267
|
hidden: !0,
|
|
267
268
|
tabIndex: -1,
|
|
268
269
|
accept: D,
|
|
269
270
|
multiple: v !== 1,
|
|
270
|
-
disabled:
|
|
271
|
+
disabled: i,
|
|
271
272
|
onChange: (r) => {
|
|
272
|
-
|
|
273
|
+
X(Array.from(r.currentTarget.files ?? [])), r.currentTarget.value = "";
|
|
273
274
|
},
|
|
274
275
|
"data-file-input": ""
|
|
275
276
|
}
|
|
@@ -277,69 +278,47 @@ function Dr({
|
|
|
277
278
|
]
|
|
278
279
|
}
|
|
279
280
|
),
|
|
280
|
-
S && /* @__PURE__ */ n("p", { id:
|
|
281
|
-
R && /* @__PURE__ */ n("p", { id:
|
|
282
|
-
|
|
281
|
+
S && /* @__PURE__ */ n("p", { id: _, className: "rst:mt-1.5 rst:text-left rst:text-xs rst:text-gray-500 rst:dark:text-gray-400", children: S }),
|
|
282
|
+
R && /* @__PURE__ */ n("p", { id: J, className: "rst:mt-1.5 rst:text-left rst:text-xs rst:font-medium rst:text-error-600 rst:dark:text-error-400", children: R }),
|
|
283
|
+
F.length > 0 && /* @__PURE__ */ n("ul", { className: "rst:mt-3 rst:flex rst:flex-col rst:gap-2", "aria-labelledby": z, children: F.map((r) => {
|
|
283
284
|
const e = r.status === "failed" || r.status === "rejected", t = r.status === "uploading" || r.status === "processing" || r.status === "queued";
|
|
284
|
-
return /* @__PURE__ */
|
|
285
|
+
return /* @__PURE__ */ p(
|
|
285
286
|
"li",
|
|
286
287
|
{
|
|
287
288
|
"data-file-item": r.id,
|
|
288
289
|
"data-status": r.status,
|
|
289
290
|
className: "rst:flex rst:items-center rst:gap-3 rst:rounded-md rst:border rst:border-[var(--roster-card-border)] rst:p-2",
|
|
290
291
|
children: [
|
|
291
|
-
/* @__PURE__ */ n(
|
|
292
|
-
/* @__PURE__ */
|
|
292
|
+
/* @__PURE__ */ n($r, { file: r.file, status: r.status }),
|
|
293
|
+
/* @__PURE__ */ p("div", { className: "rst:min-w-0 rst:flex-1 rst:text-left", children: [
|
|
293
294
|
/* @__PURE__ */ n("p", { className: "rst:truncate rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]", title: r.file.name, children: r.file.name }),
|
|
294
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ p(
|
|
295
296
|
"p",
|
|
296
297
|
{
|
|
297
|
-
className:
|
|
298
|
+
className: g(
|
|
298
299
|
"rst:mt-0.5 rst:flex rst:items-start rst:gap-1 rst:text-xs",
|
|
299
300
|
e ? "rst:text-error-600 rst:dark:text-error-400" : "rst:text-gray-600 rst:dark:text-gray-400"
|
|
300
301
|
),
|
|
301
302
|
"data-file-status": "",
|
|
302
303
|
children: [
|
|
303
304
|
r.status === "done" && /* @__PURE__ */ n("svg", { ...I, 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" }) }),
|
|
304
|
-
/* @__PURE__ */
|
|
305
|
-
/* @__PURE__ */ n("span", { className: "rst:tabular-nums", children:
|
|
305
|
+
/* @__PURE__ */ p("span", { children: [
|
|
306
|
+
/* @__PURE__ */ n("span", { className: "rst:tabular-nums", children: a.size(r.file.size) }),
|
|
306
307
|
/* @__PURE__ */ n("span", { "aria-hidden": "true", children: " · " }),
|
|
307
308
|
gr(r)
|
|
308
309
|
] })
|
|
309
310
|
]
|
|
310
311
|
}
|
|
311
312
|
),
|
|
312
|
-
t && /* @__PURE__ */ n(
|
|
313
|
-
|
|
313
|
+
t && /* @__PURE__ */ n("div", { className: "rst:mt-1.5", "data-file-progress": "", children: /* @__PURE__ */ n(
|
|
314
|
+
yr,
|
|
314
315
|
{
|
|
315
|
-
|
|
316
|
-
"
|
|
317
|
-
"
|
|
318
|
-
|
|
319
|
-
"aria-valuenow": r.status === "uploading" && r.progress !== null ? Math.round(r.progress * 100) : void 0,
|
|
320
|
-
className: f(
|
|
321
|
-
"rst:mt-1.5 rst:h-1.5 rst:overflow-hidden rst:rounded-full rst:bg-gray-200 rst:dark:bg-gray-700",
|
|
322
|
-
/* Under way with no figure yet: the track pulses and the
|
|
323
|
-
fill waits at zero, so the first figure grows it
|
|
324
|
-
rather than shrinking a full bar. */
|
|
325
|
-
r.status === "uploading" && r.progress === null && "rst:animate-pulse rst:motion-reduce:animate-none"
|
|
326
|
-
),
|
|
327
|
-
"data-file-progress": "",
|
|
328
|
-
children: /* @__PURE__ */ n(
|
|
329
|
-
"div",
|
|
330
|
-
{
|
|
331
|
-
className: f(
|
|
332
|
-
"rst:h-full rst:origin-left rst:rounded-full rst:bg-primary-600 rst:transition-transform rst:motion-reduce:transition-none rst:dark:bg-primary-400",
|
|
333
|
-
/* On the server: full, and pulsing, since there's no figure to give. */
|
|
334
|
-
r.status === "processing" && "rst:animate-pulse rst:motion-reduce:animate-none"
|
|
335
|
-
),
|
|
336
|
-
style: {
|
|
337
|
-
transform: `scaleX(${r.status === "processing" ? 1 : r.status === "uploading" ? r.progress ?? 0 : 0})`
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
)
|
|
316
|
+
size: "sm",
|
|
317
|
+
value: r.status === "processing" ? 100 : r.status === "uploading" ? (r.progress ?? 0) * 100 : 0,
|
|
318
|
+
busy: r.status === "processing" || r.status === "uploading" && r.progress === null,
|
|
319
|
+
announce: !1
|
|
341
320
|
}
|
|
342
|
-
)
|
|
321
|
+
) })
|
|
343
322
|
] }),
|
|
344
323
|
r.status === "failed" && /* @__PURE__ */ n(
|
|
345
324
|
G,
|
|
@@ -348,12 +327,12 @@ function Dr({
|
|
|
348
327
|
variant: "ghost",
|
|
349
328
|
colorScheme: "neutral",
|
|
350
329
|
size: "icon",
|
|
351
|
-
className:
|
|
352
|
-
"aria-disabled":
|
|
353
|
-
"aria-label":
|
|
354
|
-
onClick: () =>
|
|
330
|
+
className: g("rst:h-11 rst:w-11", i && V),
|
|
331
|
+
"aria-disabled": i || void 0,
|
|
332
|
+
"aria-label": a.retry(r.file.name),
|
|
333
|
+
onClick: () => lr(r.id),
|
|
355
334
|
"data-file-retry": r.id,
|
|
356
|
-
children: /* @__PURE__ */
|
|
335
|
+
children: /* @__PURE__ */ p("svg", { ...I, "aria-hidden": "true", children: [
|
|
357
336
|
/* @__PURE__ */ n("path", { d: "M3 12a9 9 0 1 0 3-6.7L3 8" }),
|
|
358
337
|
/* @__PURE__ */ n("path", { d: "M3 3v5h5" })
|
|
359
338
|
] })
|
|
@@ -366,10 +345,10 @@ function Dr({
|
|
|
366
345
|
variant: "ghost",
|
|
367
346
|
colorScheme: "neutral",
|
|
368
347
|
size: "icon",
|
|
369
|
-
className:
|
|
370
|
-
"aria-disabled":
|
|
371
|
-
"aria-label":
|
|
372
|
-
onClick: () =>
|
|
348
|
+
className: g("rst:h-11 rst:w-11", i && V),
|
|
349
|
+
"aria-disabled": i || void 0,
|
|
350
|
+
"aria-label": a.remove(r.file.name),
|
|
351
|
+
onClick: () => ur(r.id),
|
|
373
352
|
"data-file-remove": r.id,
|
|
374
353
|
children: /* @__PURE__ */ n("svg", { ...I, "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
375
354
|
}
|
|
@@ -379,7 +358,7 @@ function Dr({
|
|
|
379
358
|
r.id
|
|
380
359
|
);
|
|
381
360
|
}) }),
|
|
382
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ p(
|
|
383
362
|
"div",
|
|
384
363
|
{
|
|
385
364
|
role: "status",
|
|
@@ -399,5 +378,5 @@ function Dr({
|
|
|
399
378
|
);
|
|
400
379
|
}
|
|
401
380
|
export {
|
|
402
|
-
|
|
381
|
+
Rr as FileUpload
|
|
403
382
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react"),v=require("../../../lib/utils.cjs"),ee=require("../../atoms/Button/Button.cjs"),te=require("../../atoms/Button/button-variants.cjs"),se=require("../../atoms/Select/select-variants.cjs"),Q=require("./page-items.cjs"),re={nav:"Pagination",page:t=>`Page ${t}`,number:t=>String(t),previous:"Previous",next:"Next",previousPage:t=>t===null?"Previous page":`Previous page (${t})`,nextPage:t=>t===null?"Next page":`Next page (${t})`,firstPage:t=>t===null?"First page":`First page (${t})`,lastPage:t=>t===null?"Last page":`Last page (${t})`,gap:"…",picker:"Page",of:t=>`of ${t}`,status:(t,i)=>`Page ${t} of ${i}`};function ae({href:t,className:i,children:c,onClick:o,...d}){return e.jsx("a",{href:t,className:i,onClick:o,"aria-label":d["aria-label"],"aria-current":d["aria-current"],"aria-disabled":d["aria-disabled"],children:c})}const ne="rst:h-11 rst:min-w-11 rst:px-2",ie="rst:cursor-not-allowed rst:opacity-50",le="rst:forced-colors:border-2 rst:forced-colors:underline rst:forced-colors:decoration-2 rst:forced-colors:underline-offset-4",X={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},F=({dir:t,double:i=!1})=>e.jsx("svg",{...X,className:"rst:shrink-0",children:t==="left"?i?e.jsx("path",{d:"m11 17-5-5 5-5M18 17l-5-5 5-5"}):e.jsx("path",{d:"m15 18-6-6 6-6"}):i?e.jsx("path",{d:"m13 17 5-5-5-5M6 17l5-5-5-5"}):e.jsx("path",{d:"m9 18 6-6-6-6"})});function oe({id:t,describedBy:i,page:c,pageCount:o,number:d,onCommit:k}){const[u,j]=w.useState(null),p=w.useRef(!1),x=u&&u.page===c?u.value:null,b=l=>{j(null),l!==c&&k(l)},P=w.useMemo(()=>Array.from({length:o},(l,f)=>e.jsx("option",{value:f+1,children:d(f+1)},f+1)),[o,d]);return e.jsx("select",{id:t,value:x??c,"aria-describedby":i,disabled:o<1,onKeyDown:l=>{if(l.key==="Enter"){x!==null&&(l.preventDefault(),b(x));return}if(l.key==="Escape"){j(null);return}p.current=!0,setTimeout(()=>{p.current=!1},0)},onChange:l=>{const f=Number(l.currentTarget.value);p.current?j({page:c,value:f}):b(f)},onBlur:()=>{x!==null&&b(x)},className:v.cn(se.selectTriggerVariants({variant:"outline"}),"rst:h-11 rst:w-auto rst:min-w-16 rst:appearance-none rst:pl-3 rst:pr-8 rst:text-base rst:tabular-nums"),"data-pagination-picker":"",children:P})}function ce({page:t,pageCount:i,onPageChange:c,getPageHref:o,linkComponent:d,navigate:k,layout:u="auto",siblings:j=1,edges:p=!0,align:x="center",variant:b="ghost",announce:P=!0,labels:l,className:f}){const a={...re,...l},m=Number.isFinite(i)?Math.max(0,Math.floor(i)):0,n=Q.clampPage(t,m),C=w.useId(),Y=d??ae,[E,Z]=w.useState({page:n,text:""});E.page!==n&&Z({page:n,text:P?a.status(n,m):""});const L=s=>{s!==Math.floor(t)&&c?.(s)},y=(s,r,N,A)=>{const h=s==="page"&&r===n,$=r===null,U=v.cn(ne,$&&ie,h&&le,A.className),W=s==="page"?`page-${r}`:s;if(o){const J=o(r??n);return e.jsx(Y,{href:J,to:J,className:v.cn(te.buttonVariants({variant:h?"solid":b,colorScheme:h?"primary":"neutral"}),U),"aria-label":A.label,"aria-current":h?"page":void 0,"aria-disabled":$?!0:void 0,onClick:g=>{if($){g.preventDefault();return}!g.defaultPrevented&&g.button===0&&!g.metaKey&&!g.ctrlKey&&!g.shiftKey&&!g.altKey&&r!==null&&L(r)},children:N},W)}return e.jsx(ee.Button,{type:"button",variant:h?"solid":b,colorScheme:h?"primary":"neutral",className:U,"aria-label":A.label,"aria-current":h?"page":void 0,"aria-disabled":$||void 0,onClick:()=>{r!==null&&L(r)},children:N},W)},I=n>1?n-1:null,R=n<m?n+1:null,T=n>1?1:null,B=n<m?m:null,M=s=>y("previous",I,e.jsxs(e.Fragment,{children:[e.jsx(F,{dir:"left"}),s&&e.jsx("span",{className:"rst:hidden rst:pr-1 rst:@[36rem]:inline",children:a.previous})]}),{label:a.previousPage(I)}),S=s=>y("next",R,e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{className:"rst:hidden rst:pl-1 rst:@[36rem]:inline",children:a.next}),e.jsx(F,{dir:"right"})]}),{label:a.nextPage(R)}),K=s=>y("first",T,e.jsx(F,{dir:"left",double:!0}),{label:a.firstPage(T),className:s?"rst:hidden rst:@[24rem]:inline-flex":void 0}),V=s=>y("last",B,e.jsx(F,{dir:"right",double:!0}),{label:a.lastPage(B),className:s?"rst:hidden rst:@[24rem]:inline-flex":void 0}),D="rst:flex rst:flex-wrap rst:items-center rst:gap-1",q={start:"rst:justify-start",center:"rst:justify-center",end:"rst:justify-end"}[x],O=s=>e.jsxs("div",{className:v.cn(D,q,s),"data-pagination-layout":"pages",children:[M(!0),Q.pageItems(n,m,j).map(r=>typeof r=="number"?y("page",r,a.number(r),{label:a.page(r)}):e.jsx("span",{"aria-hidden":"true",className:"rst:inline-flex rst:h-11 rst:w-11 rst:items-center rst:justify-center rst:text-sm rst:text-gray-500 rst:dark:text-gray-400",children:a.gap},r)),S(!0)]}),_=`${C}-picker`,z=`${C}-of`,G=s=>e.jsxs("div",{className:v.cn(D,q,s),"data-pagination-layout":"compact",children:[p&&K(!0),M(!1),e.jsxs("div",{className:"rst:flex rst:items-center rst:gap-2 rst:px-1 rst:text-sm rst:font-medium rst:text-[var(--roster-control-text)]",children:[e.jsx("label",{htmlFor:_,children:a.picker}),e.jsxs("span",{className:"rst:relative rst:inline-flex",children:[e.jsx(oe,{id:_,describedBy:z,page:n,pageCount:m,number:a.number,onCommit:r=>{if(o){c?.(r);const N=o(r);k?k(N):window.location.assign(N)}else L(r)}}),e.jsx("svg",{...X,width:16,height:16,className:"rst:pointer-events-none rst:absolute rst:right-2.5 rst:top-1/2 rst:-translate-y-1/2 rst:text-gray-500 rst:dark:text-gray-400",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),e.jsx("span",{id:z,className:"rst:tabular-nums",children:a.of(m)})]}),S(!1),p&&V(!0)]}),H=e.jsxs("div",{className:v.cn(D,q),"data-pagination-layout":"arrows",children:[p&&K(!1),M(!1),S(!1),p&&V(!1)]});return e.jsxs("nav",{"aria-label":a.nav,className:v.cn("rst:font-ui",u==="arrows"?"rst:w-fit":"rst:@container rst:w-full rst:[contain-intrinsic-inline-size:18rem]",f),"data-pagination":"",children:[u==="pages"&&O(),u==="compact"&&G(),u==="arrows"&&H,u==="auto"&&e.jsxs(e.Fragment,{children:[O("rst:hidden rst:@[28rem]:flex"),G("rst:@[28rem]:hidden")]}),P&&e.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"rst:sr-only","data-pagination-live":"",children:E.text})]})}exports.Pagination=ce;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ComponentType, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
/** Every word Pagination shows or says. Pass any of them in `labels` to replace it. */
|
|
3
|
+
export interface PaginationLabels {
|
|
4
|
+
/** The landmark's name. A page with two pagers needs each named. */
|
|
5
|
+
nav: string;
|
|
6
|
+
/** A page number's accessible name: "Page 40". */
|
|
7
|
+
page: (page: number) => string;
|
|
8
|
+
/** A page number as shown. */
|
|
9
|
+
number: (page: number) => string;
|
|
10
|
+
/** Shown beside the arrows where there's room. */
|
|
11
|
+
previous: string;
|
|
12
|
+
next: string;
|
|
13
|
+
/** Each arrow's accessible name, given the page it goes to, or `null` at the end it can't pass. */
|
|
14
|
+
previousPage: (target: number | null) => string;
|
|
15
|
+
nextPage: (target: number | null) => string;
|
|
16
|
+
firstPage: (target: number | null) => string;
|
|
17
|
+
lastPage: (target: number | null) => string;
|
|
18
|
+
/** Where pages are skipped. Hidden from screen readers, which hear the numbers either side. */
|
|
19
|
+
gap: string;
|
|
20
|
+
/** The page picker's label in the compact form: "Page". */
|
|
21
|
+
picker: string;
|
|
22
|
+
/** After the picker: "of 79". */
|
|
23
|
+
of: (pageCount: number) => string;
|
|
24
|
+
/** Said politely when the page changes: "Page 41 of 79". */
|
|
25
|
+
status: (page: number, pageCount: number) => string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The props every link is rendered with, in link mode.
|
|
29
|
+
*
|
|
30
|
+
* `href` and `to` carry the same value, so `next/link`, React Router's `Link`
|
|
31
|
+
* and a plain `<a>` all work without a wrapper.
|
|
32
|
+
*/
|
|
33
|
+
export interface PaginationLinkProps {
|
|
34
|
+
href: string;
|
|
35
|
+
to: string;
|
|
36
|
+
className: string;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
"aria-label": string;
|
|
39
|
+
"aria-current"?: "page";
|
|
40
|
+
"aria-disabled"?: true;
|
|
41
|
+
onClick: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
42
|
+
}
|
|
43
|
+
export interface PaginationProps {
|
|
44
|
+
/** The current page, from 1. */
|
|
45
|
+
page: number;
|
|
46
|
+
/** How many pages there are. */
|
|
47
|
+
pageCount: number;
|
|
48
|
+
/**
|
|
49
|
+
* Called with the page a control goes to.
|
|
50
|
+
*
|
|
51
|
+
* Without `getPageHref`, every control is a button and this is the only
|
|
52
|
+
* thing that changes the page: page in your own state.
|
|
53
|
+
*
|
|
54
|
+
* With `getPageHref`, the controls are links and navigate themselves; this
|
|
55
|
+
* is called first, on a plain left click (not one that opens a new tab),
|
|
56
|
+
* for an app that wants to do something as it goes.
|
|
57
|
+
*/
|
|
58
|
+
onPageChange?: (page: number) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Makes every control a real link to `getPageHref(page)`: crawlable,
|
|
61
|
+
* shareable, and openable in a new tab. Use it when your pages are URLs.
|
|
62
|
+
*/
|
|
63
|
+
getPageHref?: (page: number) => string;
|
|
64
|
+
/**
|
|
65
|
+
* Renders each link in link mode. Defaults to a plain `<a>`, which is right
|
|
66
|
+
* for a static site and wrong inside a router, where every hop becomes a
|
|
67
|
+
* full page load.
|
|
68
|
+
*
|
|
69
|
+
* **Pass it from a client component.** Functions can not cross the React
|
|
70
|
+
* Server Component boundary. Bind it in a small `"use client"` wrapper.
|
|
71
|
+
*/
|
|
72
|
+
linkComponent?: ComponentType<PaginationLinkProps>;
|
|
73
|
+
/**
|
|
74
|
+
* How the compact form's page picker goes to a page in link mode, where
|
|
75
|
+
* there's no link to follow. Defaults to a full page load
|
|
76
|
+
* (`location.assign`); pass your router's push to stay client-side.
|
|
77
|
+
*/
|
|
78
|
+
navigate?: (href: string) => void;
|
|
79
|
+
/**
|
|
80
|
+
* - `"pages"`: previous, page numbers with gaps, next.
|
|
81
|
+
* - `"compact"`: previous, a page picker ("Page 40 of 79"), next, and the
|
|
82
|
+
* first and last pages where there's room. Any page is two taps away.
|
|
83
|
+
* - `"arrows"`: first, previous, next, last, for a pager that shows its
|
|
84
|
+
* own position.
|
|
85
|
+
* - `"auto"` (the default): `"pages"` where the pager has room, `"compact"`
|
|
86
|
+
* where it doesn't. Decided by the pager's own width, not the screen's.
|
|
87
|
+
*/
|
|
88
|
+
layout?: "auto" | "pages" | "compact" | "arrows";
|
|
89
|
+
/** Page numbers shown either side of the current one. */
|
|
90
|
+
siblings?: number;
|
|
91
|
+
/** Whether the compact and arrow forms offer the first and last pages. */
|
|
92
|
+
edges?: boolean;
|
|
93
|
+
/** Where the controls sit in the pager's width. */
|
|
94
|
+
align?: "start" | "center" | "end";
|
|
95
|
+
/** How the controls other than the current page are drawn. */
|
|
96
|
+
variant?: "ghost" | "outline";
|
|
97
|
+
/** Say the new page in a polite live region when it changes. */
|
|
98
|
+
announce?: boolean;
|
|
99
|
+
labels?: Partial<PaginationLabels>;
|
|
100
|
+
className?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Moves through pages of a list.
|
|
104
|
+
*
|
|
105
|
+
* Controlled: you hold `page`, and the pager says which page a control goes
|
|
106
|
+
* to. Its controls are buttons that call `onPageChange`, or, with
|
|
107
|
+
* `getPageHref`, real links.
|
|
108
|
+
*
|
|
109
|
+
* **Focus.** A control keeps focus after the page changes: the number you
|
|
110
|
+
* pressed is the same element afterwards, and an arrow that reaches the end
|
|
111
|
+
* stays focusable, `aria-disabled`. Nothing moves focus for you. To take a
|
|
112
|
+
* reader to the top of the new page, focus your list's heading in
|
|
113
|
+
* `onPageChange`.
|
|
114
|
+
*/
|
|
115
|
+
declare function Pagination({ page: rawPage, pageCount: rawCount, onPageChange, getPageHref, linkComponent, navigate, layout, siblings, edges, align, variant, announce, labels: overrides, className, }: PaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
116
|
+
export { Pagination };
|