@dimah-s3/ui 0.6.3 → 0.7.1
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 +13 -1
- package/css/shadcn.css +30 -0
- package/dist/components/{ui → dimah-s3/attachment}/circle-progress.d.ts +2 -1
- package/dist/components/dimah-s3/attachment/circle-progress.d.ts.map +1 -0
- package/dist/components/dimah-s3/attachment/file-attachment.d.ts +25 -0
- package/dist/components/dimah-s3/attachment/file-attachment.d.ts.map +1 -0
- package/dist/components/dimah-s3/attachment/status-attachment.d.ts +20 -0
- package/dist/components/dimah-s3/attachment/status-attachment.d.ts.map +1 -0
- package/dist/components/{delete → dimah-s3/delete}/delete-button.d.ts +11 -5
- package/dist/components/dimah-s3/delete/delete-button.d.ts.map +1 -0
- package/dist/components/{download → dimah-s3/download}/download-button.d.ts +11 -5
- package/dist/components/dimah-s3/download/download-button.d.ts.map +1 -0
- package/dist/components/{download → dimah-s3/download}/progress-download-button.d.ts +11 -5
- package/dist/components/dimah-s3/download/progress-download-button.d.ts.map +1 -0
- package/dist/components/dimah-s3/upload/multi-upload-status.d.ts +12 -0
- package/dist/components/dimah-s3/upload/multi-upload-status.d.ts.map +1 -0
- package/dist/components/dimah-s3/upload/upload-button.d.ts +36 -0
- package/dist/components/dimah-s3/upload/upload-button.d.ts.map +1 -0
- package/dist/components/dimah-s3/upload/upload-dropzone.d.ts +31 -0
- package/dist/components/dimah-s3/upload/upload-dropzone.d.ts.map +1 -0
- package/dist/components/{upload → dimah-s3/upload}/upload-status-block.d.ts +5 -7
- package/dist/components/dimah-s3/upload/upload-status-block.d.ts.map +1 -0
- package/dist/components/dimah-s3/upload/upload-status.d.ts +14 -0
- package/dist/components/dimah-s3/upload/upload-status.d.ts.map +1 -0
- package/dist/components/ui/attachment.d.ts +24 -0
- package/dist/components/ui/attachment.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/hooks/use-file-reject-toast.d.ts +7 -0
- package/dist/hooks/use-file-reject-toast.d.ts.map +1 -0
- package/dist/hooks/use-upload-toast.d.ts +2 -5
- package/dist/hooks/use-upload-toast.d.ts.map +1 -1
- package/dist/index.d.ts +12 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1073 -333
- package/dist/index.js.map +1 -1
- package/dist/lib/attachment.d.ts +45 -0
- package/dist/lib/attachment.d.ts.map +1 -0
- package/dist/lib/file-type-icon.d.ts +13 -0
- package/dist/lib/file-type-icon.d.ts.map +1 -0
- package/package.json +19 -11
- package/styles.css +8 -2
- package/dist/components/delete/delete-button.d.ts.map +0 -1
- package/dist/components/download/download-button.d.ts.map +0 -1
- package/dist/components/download/progress-download-button.d.ts.map +0 -1
- package/dist/components/ui/circle-progress.d.ts.map +0 -1
- package/dist/components/upload/multi-upload-status.d.ts +0 -9
- package/dist/components/upload/multi-upload-status.d.ts.map +0 -1
- package/dist/components/upload/upload-button.d.ts +0 -30
- package/dist/components/upload/upload-button.d.ts.map +0 -1
- package/dist/components/upload/upload-dropzone.d.ts +0 -22
- package/dist/components/upload/upload-dropzone.d.ts.map +0 -1
- package/dist/components/upload/upload-status-block.d.ts.map +0 -1
- package/dist/components/upload/upload-status.d.ts +0 -14
- package/dist/components/upload/upload-status.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +1,52 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { PauseIcon, XIcon,
|
|
2
|
+
import { AlertCircleIcon, PauseIcon, XIcon, LoaderIcon, DownloadIcon, Trash2Icon, CheckCircleIcon, LoaderCircleIcon, CloudUpload, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from 'lucide-react';
|
|
3
3
|
import { useTranslations } from '@fuma-translate/react';
|
|
4
|
-
import { formatEta,
|
|
4
|
+
import { formatEta, useDownload, useFetchDownload, useDelete, useMultiUpload, useUpload, useFormatDimahError, formatAcceptLabels } from '@dimah-s3/react';
|
|
5
5
|
import { cn } from 'cnfast';
|
|
6
6
|
import { Button as Button$1 } from '@base-ui/react/button';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
|
-
import {
|
|
8
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
|
|
10
|
-
import {
|
|
10
|
+
import { formatFileSize, truncateFileName } from '@dimah-s3/core';
|
|
11
|
+
import '@base-ui/react/merge-props';
|
|
12
|
+
import '@base-ui/react/use-render';
|
|
13
|
+
import { FileIcon, defaultStyles } from 'react-file-icon';
|
|
11
14
|
import { Progress as Progress$1 } from '@base-ui/react/progress';
|
|
12
|
-
import {
|
|
15
|
+
import { useRef, useLayoutEffect, useEffect } from 'react';
|
|
13
16
|
import { Toast as Toast$1 } from '@base-ui/react/toast';
|
|
14
17
|
import { AlertDialog as AlertDialog$1 } from '@base-ui/react/alert-dialog';
|
|
15
18
|
|
|
16
|
-
// src/components/upload/upload-button.tsx
|
|
19
|
+
// src/components/dimah-s3/upload/upload-button.tsx
|
|
20
|
+
|
|
21
|
+
// src/lib/attachment.ts
|
|
22
|
+
var ATTACHMENT_ERROR_DESCRIPTION_CLASS = "overflow-visible whitespace-normal [overflow-wrap:anywhere]";
|
|
23
|
+
var ATTACHMENT_TITLE_CLASS = "max-w-[48ch] dark:shimmer-color-dimah-s3-muted-foreground";
|
|
24
|
+
function resolveStatusSlot(slot = true, node) {
|
|
25
|
+
if (slot === false) return null;
|
|
26
|
+
if (typeof slot === "function") return slot(node);
|
|
27
|
+
return node;
|
|
28
|
+
}
|
|
17
29
|
var buttonVariants = cva(
|
|
18
|
-
"group/button inline-flex shrink-0 items-center justify-center rounded-
|
|
30
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
19
31
|
{
|
|
20
32
|
variants: {
|
|
21
33
|
variant: {
|
|
22
34
|
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
23
|
-
outline: "border-border hover:bg-
|
|
24
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary
|
|
35
|
+
outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
36
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
25
37
|
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
26
38
|
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
27
39
|
link: "text-primary underline-offset-4 hover:underline"
|
|
28
40
|
},
|
|
29
41
|
size: {
|
|
30
|
-
default: "h-
|
|
31
|
-
xs: "h-
|
|
32
|
-
sm: "h-
|
|
33
|
-
lg: "h-
|
|
34
|
-
icon: "size-
|
|
35
|
-
"icon-xs": "size-
|
|
36
|
-
"icon-sm": "size-
|
|
37
|
-
"icon-lg": "size-
|
|
42
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",
|
|
43
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
44
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
45
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",
|
|
46
|
+
icon: "size-8",
|
|
47
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
48
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
49
|
+
"icon-lg": "size-9"
|
|
38
50
|
}
|
|
39
51
|
},
|
|
40
52
|
defaultVariants: {
|
|
@@ -99,43 +111,490 @@ function TooltipContent({
|
|
|
99
111
|
}
|
|
100
112
|
) });
|
|
101
113
|
}
|
|
114
|
+
var attachmentVariants = cva(
|
|
115
|
+
"group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed",
|
|
116
|
+
{
|
|
117
|
+
variants: {
|
|
118
|
+
size: {
|
|
119
|
+
default: "gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2",
|
|
120
|
+
sm: "gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",
|
|
121
|
+
xs: "gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"
|
|
122
|
+
},
|
|
123
|
+
orientation: {
|
|
124
|
+
horizontal: "min-w-40 items-center",
|
|
125
|
+
vertical: "w-24 flex-col has-data-[slot=attachment-content]:w-30"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
function Attachment({
|
|
131
|
+
className,
|
|
132
|
+
state = "done",
|
|
133
|
+
size = "default",
|
|
134
|
+
orientation = "horizontal",
|
|
135
|
+
...props
|
|
136
|
+
}) {
|
|
137
|
+
return /* @__PURE__ */ jsx(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
"data-slot": "attachment",
|
|
141
|
+
"data-state": state,
|
|
142
|
+
"data-size": size,
|
|
143
|
+
"data-orientation": orientation,
|
|
144
|
+
className: cn(attachmentVariants({ size, orientation }), className),
|
|
145
|
+
...props
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
var attachmentMediaVariants = cva(
|
|
150
|
+
"relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5",
|
|
151
|
+
{
|
|
152
|
+
variants: {
|
|
153
|
+
variant: {
|
|
154
|
+
icon: "",
|
|
155
|
+
image: "opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
defaultVariants: {
|
|
159
|
+
variant: "icon"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
function AttachmentMedia({
|
|
164
|
+
className,
|
|
165
|
+
variant = "icon",
|
|
166
|
+
...props
|
|
167
|
+
}) {
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
"div",
|
|
170
|
+
{
|
|
171
|
+
"data-slot": "attachment-media",
|
|
172
|
+
"data-variant": variant,
|
|
173
|
+
className: cn(attachmentMediaVariants({ variant }), className),
|
|
174
|
+
...props
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
function AttachmentContent({
|
|
179
|
+
className,
|
|
180
|
+
...props
|
|
181
|
+
}) {
|
|
182
|
+
return /* @__PURE__ */ jsx(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
"data-slot": "attachment-content",
|
|
186
|
+
className: cn(
|
|
187
|
+
"max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",
|
|
188
|
+
className
|
|
189
|
+
),
|
|
190
|
+
...props
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
function AttachmentTitle({
|
|
195
|
+
className,
|
|
196
|
+
...props
|
|
197
|
+
}) {
|
|
198
|
+
return /* @__PURE__ */ jsx(
|
|
199
|
+
"span",
|
|
200
|
+
{
|
|
201
|
+
"data-slot": "attachment-title",
|
|
202
|
+
className: cn(
|
|
203
|
+
"block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer",
|
|
204
|
+
className
|
|
205
|
+
),
|
|
206
|
+
...props
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
function AttachmentDescription({
|
|
211
|
+
className,
|
|
212
|
+
...props
|
|
213
|
+
}) {
|
|
214
|
+
return /* @__PURE__ */ jsx(
|
|
215
|
+
"span",
|
|
216
|
+
{
|
|
217
|
+
"data-slot": "attachment-description",
|
|
218
|
+
className: cn(
|
|
219
|
+
"mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80",
|
|
220
|
+
"max-w-full",
|
|
221
|
+
className
|
|
222
|
+
),
|
|
223
|
+
...props
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
function AttachmentActions({
|
|
228
|
+
className,
|
|
229
|
+
...props
|
|
230
|
+
}) {
|
|
231
|
+
return /* @__PURE__ */ jsx(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
"data-slot": "attachment-actions",
|
|
235
|
+
className: cn(
|
|
236
|
+
"relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:end-3 group-data-[orientation=vertical]/attachment:gap-1",
|
|
237
|
+
className
|
|
238
|
+
),
|
|
239
|
+
...props
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
function AttachmentAction({
|
|
244
|
+
className,
|
|
245
|
+
variant,
|
|
246
|
+
size = "icon-xs",
|
|
247
|
+
...props
|
|
248
|
+
}) {
|
|
249
|
+
return /* @__PURE__ */ jsx(
|
|
250
|
+
Button,
|
|
251
|
+
{
|
|
252
|
+
"data-slot": "attachment-action",
|
|
253
|
+
variant: variant ?? "ghost",
|
|
254
|
+
size,
|
|
255
|
+
className: cn(className),
|
|
256
|
+
...props
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
}
|
|
102
260
|
function CircleProgress({
|
|
103
261
|
percent,
|
|
104
262
|
size = 20,
|
|
105
|
-
strokeWidth = 2.5
|
|
263
|
+
strokeWidth = 2.5,
|
|
264
|
+
className
|
|
106
265
|
}) {
|
|
107
266
|
const r = (size - strokeWidth) / 2;
|
|
108
267
|
const c = 2 * Math.PI * r;
|
|
109
268
|
const offset = c - percent / 100 * c;
|
|
110
|
-
return /* @__PURE__ */ jsxs(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
269
|
+
return /* @__PURE__ */ jsxs(
|
|
270
|
+
"svg",
|
|
271
|
+
{
|
|
272
|
+
width: size,
|
|
273
|
+
height: size,
|
|
274
|
+
className: cn("shrink-0 -rotate-90", className),
|
|
275
|
+
style: { width: size, height: size },
|
|
276
|
+
"aria-hidden": true,
|
|
277
|
+
children: [
|
|
278
|
+
/* @__PURE__ */ jsx(
|
|
279
|
+
"circle",
|
|
280
|
+
{
|
|
281
|
+
cx: size / 2,
|
|
282
|
+
cy: size / 2,
|
|
283
|
+
r,
|
|
284
|
+
fill: "none",
|
|
285
|
+
stroke: "currentColor",
|
|
286
|
+
strokeWidth,
|
|
287
|
+
className: "text-dimah-s3-muted-foreground/60"
|
|
288
|
+
}
|
|
289
|
+
),
|
|
290
|
+
/* @__PURE__ */ jsx(
|
|
291
|
+
"circle",
|
|
292
|
+
{
|
|
293
|
+
cx: size / 2,
|
|
294
|
+
cy: size / 2,
|
|
295
|
+
r,
|
|
296
|
+
fill: "none",
|
|
297
|
+
stroke: "currentColor",
|
|
298
|
+
strokeWidth,
|
|
299
|
+
strokeDasharray: c,
|
|
300
|
+
strokeDashoffset: offset,
|
|
301
|
+
strokeLinecap: "round",
|
|
302
|
+
className: "text-dimah-s3-primary transition-[stroke-dashoffset] duration-200"
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
var CURATED_EXTS = [
|
|
310
|
+
// documents
|
|
311
|
+
"pdf",
|
|
312
|
+
"doc",
|
|
313
|
+
"docx",
|
|
314
|
+
"txt",
|
|
315
|
+
"md",
|
|
316
|
+
// sheets / slides
|
|
317
|
+
"xls",
|
|
318
|
+
"xlsx",
|
|
319
|
+
"csv",
|
|
320
|
+
"ppt",
|
|
321
|
+
"pptx",
|
|
322
|
+
// archives
|
|
323
|
+
"zip",
|
|
324
|
+
"rar",
|
|
325
|
+
"7z",
|
|
326
|
+
"tar",
|
|
327
|
+
"gz",
|
|
328
|
+
// audio / video
|
|
329
|
+
"mp3",
|
|
330
|
+
"wav",
|
|
331
|
+
"m4a",
|
|
332
|
+
"mp4",
|
|
333
|
+
"mov",
|
|
334
|
+
"webm",
|
|
335
|
+
"mkv",
|
|
336
|
+
// images
|
|
337
|
+
"png",
|
|
338
|
+
"jpg",
|
|
339
|
+
"gif",
|
|
340
|
+
"webp",
|
|
341
|
+
"svg",
|
|
342
|
+
"heic",
|
|
343
|
+
// code / data
|
|
344
|
+
"json",
|
|
345
|
+
"js",
|
|
346
|
+
"ts",
|
|
347
|
+
"jsx",
|
|
348
|
+
"html",
|
|
349
|
+
"css"
|
|
350
|
+
];
|
|
351
|
+
var CURATED = new Set(CURATED_EXTS);
|
|
352
|
+
var EXT_ALIASES = {
|
|
353
|
+
jpeg: "jpg",
|
|
354
|
+
jpe: "jpg",
|
|
355
|
+
"7zip": "7z",
|
|
356
|
+
m4v: "mp4",
|
|
357
|
+
aac: "m4a",
|
|
358
|
+
flac: "mp3",
|
|
359
|
+
ogg: "mp3",
|
|
360
|
+
avi: "mp4",
|
|
361
|
+
bmp: "png",
|
|
362
|
+
tif: "png",
|
|
363
|
+
tiff: "png"
|
|
364
|
+
};
|
|
365
|
+
var STYLE_ALIASES = {
|
|
366
|
+
"7z": "7zip"
|
|
367
|
+
};
|
|
368
|
+
var MIME_TO_EXT = {
|
|
369
|
+
"application/pdf": "pdf",
|
|
370
|
+
"application/msword": "doc",
|
|
371
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
372
|
+
"application/vnd.ms-excel": "xls",
|
|
373
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
374
|
+
"text/csv": "csv",
|
|
375
|
+
"application/vnd.ms-powerpoint": "ppt",
|
|
376
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
|
377
|
+
"application/zip": "zip",
|
|
378
|
+
"application/x-zip-compressed": "zip",
|
|
379
|
+
"application/x-rar-compressed": "rar",
|
|
380
|
+
"application/vnd.rar": "rar",
|
|
381
|
+
"application/x-7z-compressed": "7z",
|
|
382
|
+
"application/x-tar": "tar",
|
|
383
|
+
"application/gzip": "gz",
|
|
384
|
+
"audio/mpeg": "mp3",
|
|
385
|
+
"audio/wav": "wav",
|
|
386
|
+
"audio/mp4": "m4a",
|
|
387
|
+
"audio/aac": "m4a",
|
|
388
|
+
"video/mp4": "mp4",
|
|
389
|
+
"video/quicktime": "mov",
|
|
390
|
+
"video/webm": "webm",
|
|
391
|
+
"video/x-matroska": "mkv",
|
|
392
|
+
"image/png": "png",
|
|
393
|
+
"image/jpeg": "jpg",
|
|
394
|
+
"image/gif": "gif",
|
|
395
|
+
"image/webp": "webp",
|
|
396
|
+
"image/svg+xml": "svg",
|
|
397
|
+
"image/heic": "heic",
|
|
398
|
+
"application/json": "json",
|
|
399
|
+
"text/javascript": "js",
|
|
400
|
+
"application/javascript": "js",
|
|
401
|
+
"text/typescript": "ts",
|
|
402
|
+
"application/typescript": "ts",
|
|
403
|
+
"text/jsx": "jsx",
|
|
404
|
+
"text/html": "html",
|
|
405
|
+
"text/css": "css",
|
|
406
|
+
"text/plain": "txt",
|
|
407
|
+
"text/markdown": "md"
|
|
408
|
+
};
|
|
409
|
+
function extensionOf(fileName) {
|
|
410
|
+
const base = fileName.split(/[/\\]/).pop() ?? fileName;
|
|
411
|
+
const dot = base.lastIndexOf(".");
|
|
412
|
+
if (dot <= 0 || dot === base.length - 1) return null;
|
|
413
|
+
return base.slice(dot + 1).toLowerCase();
|
|
414
|
+
}
|
|
415
|
+
function mimeFamilyExt(mime) {
|
|
416
|
+
if (mime.startsWith("image/")) return "png";
|
|
417
|
+
if (mime.startsWith("audio/")) return "mp3";
|
|
418
|
+
if (mime.startsWith("video/")) return "mp4";
|
|
419
|
+
if (mime.startsWith("text/")) return "txt";
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
function normalizeExt(ext) {
|
|
423
|
+
if (CURATED.has(ext)) return ext;
|
|
424
|
+
const aliased = EXT_ALIASES[ext];
|
|
425
|
+
if (aliased && CURATED.has(aliased)) return aliased;
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
function resolveFileTypeExtension(fileName, mimeType) {
|
|
429
|
+
const mime = mimeType?.trim().toLowerCase();
|
|
430
|
+
if (mime) {
|
|
431
|
+
const fromMime = MIME_TO_EXT[mime];
|
|
432
|
+
if (fromMime) return fromMime;
|
|
433
|
+
const family = mimeFamilyExt(mime);
|
|
434
|
+
if (family) return family;
|
|
435
|
+
}
|
|
436
|
+
const ext = extensionOf(fileName);
|
|
437
|
+
if (!ext) return null;
|
|
438
|
+
return normalizeExt(ext);
|
|
439
|
+
}
|
|
440
|
+
function stylesFor(ext) {
|
|
441
|
+
const key = STYLE_ALIASES[ext] ?? ext;
|
|
442
|
+
const fromDefaults = defaultStyles[key];
|
|
443
|
+
if (fromDefaults) return fromDefaults;
|
|
444
|
+
if (ext === "heic") return { type: "image" };
|
|
445
|
+
if (ext === "7z") return { type: "compressed" };
|
|
446
|
+
return {};
|
|
447
|
+
}
|
|
448
|
+
function FileTypeGlyph({
|
|
449
|
+
fileName,
|
|
450
|
+
fileType,
|
|
451
|
+
className
|
|
452
|
+
}) {
|
|
453
|
+
const ext = resolveFileTypeExtension(fileName, fileType);
|
|
454
|
+
const label = ext ?? extensionOf(fileName) ?? void 0;
|
|
455
|
+
const styles = ext ? stylesFor(ext) : { type: "document" };
|
|
456
|
+
return /* @__PURE__ */ jsx(
|
|
457
|
+
"span",
|
|
458
|
+
{
|
|
459
|
+
className: cn(
|
|
460
|
+
// Fill the media box so the glyph tracks Attachment size/orientation
|
|
461
|
+
// (vertical media can grow well past the default icon rem sizes).
|
|
462
|
+
"flex size-full items-center justify-center [&_svg]:size-[min(76%,8rem)]!",
|
|
463
|
+
className
|
|
464
|
+
),
|
|
465
|
+
"aria-hidden": true,
|
|
466
|
+
children: /* @__PURE__ */ jsx(FileIcon, { extension: label, ...styles })
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
var PROGRESS_BY_SIZE = {
|
|
471
|
+
default: { size: 20, strokeWidth: 2.5, className: "size-5" },
|
|
472
|
+
sm: { size: 16, strokeWidth: 2, className: "size-4" },
|
|
473
|
+
xs: { size: 14, strokeWidth: 1.5, className: "size-3.5" }
|
|
474
|
+
};
|
|
475
|
+
function FileAttachment({
|
|
476
|
+
state,
|
|
477
|
+
fileName,
|
|
478
|
+
fileSize,
|
|
479
|
+
fileType,
|
|
480
|
+
previewUrl,
|
|
481
|
+
percent = 0,
|
|
482
|
+
description,
|
|
483
|
+
error,
|
|
484
|
+
onCancel,
|
|
485
|
+
onPause,
|
|
486
|
+
size = "sm",
|
|
487
|
+
orientation = "horizontal",
|
|
488
|
+
className
|
|
489
|
+
}) {
|
|
490
|
+
const t = useTranslations();
|
|
491
|
+
const hasPreview = Boolean(previewUrl);
|
|
492
|
+
const progress = PROGRESS_BY_SIZE[size];
|
|
493
|
+
const resolvedDescription = description ?? (state === "error" ? error ?? t("Upload failed", { note: "status" }) : fileSize != null ? formatFileSize(fileSize) : null);
|
|
494
|
+
const showActions = (state === "uploading" || state === "processing") && (onCancel != null || onPause != null);
|
|
495
|
+
const showProgressOverlay = state === "uploading" || state === "processing" || state === "idle";
|
|
496
|
+
const mediaOverlay = showProgressOverlay ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-dimah-s3-background/60", children: /* @__PURE__ */ jsx(
|
|
497
|
+
CircleProgress,
|
|
498
|
+
{
|
|
499
|
+
percent: state === "uploading" ? percent : 0,
|
|
500
|
+
size: progress.size,
|
|
501
|
+
strokeWidth: progress.strokeWidth,
|
|
502
|
+
className: progress.className
|
|
503
|
+
}
|
|
504
|
+
) }) : state === "error" ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-dimah-s3-destructive/20 text-dimah-s3-destructive", children: /* @__PURE__ */ jsx(AlertCircleIcon, {}) }) : null;
|
|
505
|
+
return /* @__PURE__ */ jsxs(
|
|
506
|
+
Attachment,
|
|
507
|
+
{
|
|
508
|
+
state,
|
|
509
|
+
size,
|
|
510
|
+
orientation,
|
|
511
|
+
className: cn(
|
|
512
|
+
orientation === "horizontal" && "w-full max-w-full",
|
|
513
|
+
className
|
|
514
|
+
),
|
|
515
|
+
children: [
|
|
516
|
+
hasPreview ? /* @__PURE__ */ jsxs(AttachmentMedia, { variant: "image", children: [
|
|
517
|
+
/* @__PURE__ */ jsx("img", { src: previewUrl, alt: "" }),
|
|
518
|
+
mediaOverlay
|
|
519
|
+
] }) : /* @__PURE__ */ jsxs(AttachmentMedia, { children: [
|
|
520
|
+
/* @__PURE__ */ jsx(FileTypeGlyph, { fileName, fileType }),
|
|
521
|
+
mediaOverlay
|
|
522
|
+
] }),
|
|
523
|
+
/* @__PURE__ */ jsxs(AttachmentContent, { children: [
|
|
524
|
+
/* @__PURE__ */ jsx(AttachmentTitle, { className: ATTACHMENT_TITLE_CLASS, children: truncateFileName(fileName) }),
|
|
525
|
+
resolvedDescription != null ? /* @__PURE__ */ jsx(
|
|
526
|
+
AttachmentDescription,
|
|
527
|
+
{
|
|
528
|
+
className: state === "error" ? ATTACHMENT_ERROR_DESCRIPTION_CLASS : void 0,
|
|
529
|
+
children: resolvedDescription
|
|
530
|
+
}
|
|
531
|
+
) : null
|
|
532
|
+
] }),
|
|
533
|
+
showActions ? /* @__PURE__ */ jsxs(AttachmentActions, { children: [
|
|
534
|
+
onPause ? /* @__PURE__ */ jsx(
|
|
535
|
+
AttachmentAction,
|
|
536
|
+
{
|
|
537
|
+
"aria-label": t("Pause", { note: "upload control" }),
|
|
538
|
+
onClick: (e) => {
|
|
539
|
+
e.stopPropagation();
|
|
540
|
+
onPause();
|
|
541
|
+
},
|
|
542
|
+
children: /* @__PURE__ */ jsx(PauseIcon, {})
|
|
543
|
+
}
|
|
544
|
+
) : null,
|
|
545
|
+
onCancel ? /* @__PURE__ */ jsx(
|
|
546
|
+
AttachmentAction,
|
|
547
|
+
{
|
|
548
|
+
"aria-label": t("Cancel", { note: "upload control" }),
|
|
549
|
+
onClick: (e) => {
|
|
550
|
+
e.stopPropagation();
|
|
551
|
+
onCancel();
|
|
552
|
+
},
|
|
553
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
554
|
+
}
|
|
555
|
+
) : null
|
|
556
|
+
] }) : null
|
|
557
|
+
]
|
|
558
|
+
}
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
function StatusAttachment({
|
|
562
|
+
state,
|
|
563
|
+
title,
|
|
564
|
+
description,
|
|
565
|
+
media,
|
|
566
|
+
actions,
|
|
567
|
+
size = "sm",
|
|
568
|
+
orientation = "horizontal",
|
|
569
|
+
className
|
|
570
|
+
}) {
|
|
571
|
+
const defaultMedia = state === "error" ? /* @__PURE__ */ jsx(AlertCircleIcon, {}) : state === "done" ? /* @__PURE__ */ jsx(CheckCircleIcon, {}) : state === "processing" || state === "uploading" ? /* @__PURE__ */ jsx(LoaderCircleIcon, { className: "animate-spin", "data-slot": "spinner" }) : null;
|
|
572
|
+
return /* @__PURE__ */ jsxs(
|
|
573
|
+
Attachment,
|
|
574
|
+
{
|
|
575
|
+
state,
|
|
576
|
+
size,
|
|
577
|
+
orientation,
|
|
578
|
+
className: cn(
|
|
579
|
+
orientation === "horizontal" && "w-full max-w-full",
|
|
580
|
+
className
|
|
581
|
+
),
|
|
582
|
+
children: [
|
|
583
|
+
/* @__PURE__ */ jsx(AttachmentMedia, { children: media ?? defaultMedia }),
|
|
584
|
+
/* @__PURE__ */ jsxs(AttachmentContent, { children: [
|
|
585
|
+
title != null ? /* @__PURE__ */ jsx(AttachmentTitle, { className: ATTACHMENT_TITLE_CLASS, children: title }) : null,
|
|
586
|
+
description != null ? /* @__PURE__ */ jsx(
|
|
587
|
+
AttachmentDescription,
|
|
588
|
+
{
|
|
589
|
+
className: state === "error" ? ATTACHMENT_ERROR_DESCRIPTION_CLASS : void 0,
|
|
590
|
+
children: description
|
|
591
|
+
}
|
|
592
|
+
) : null
|
|
593
|
+
] }),
|
|
594
|
+
actions ? /* @__PURE__ */ jsx(AttachmentActions, { children: actions }) : null
|
|
595
|
+
]
|
|
596
|
+
}
|
|
597
|
+
);
|
|
139
598
|
}
|
|
140
599
|
function UploadStatus({
|
|
141
600
|
phase,
|
|
@@ -143,67 +602,93 @@ function UploadStatus({
|
|
|
143
602
|
error,
|
|
144
603
|
fileInfo,
|
|
145
604
|
onCancel,
|
|
146
|
-
onPause
|
|
605
|
+
onPause,
|
|
606
|
+
size,
|
|
607
|
+
orientation,
|
|
608
|
+
className
|
|
147
609
|
}) {
|
|
148
610
|
const t = useTranslations();
|
|
611
|
+
const layout = { size, orientation, className };
|
|
149
612
|
if (phase === "idle") return null;
|
|
150
613
|
if (phase === "uploading" && fileInfo) {
|
|
151
614
|
const eta = progress.speed && progress.total ? formatEta(progress.total - progress.loaded, progress.speed) : null;
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
className: "size-6 shrink-0",
|
|
168
|
-
"aria-label": t("Pause", { note: "upload control" }),
|
|
169
|
-
onClick: (e) => {
|
|
170
|
-
e.stopPropagation();
|
|
171
|
-
onPause();
|
|
172
|
-
},
|
|
173
|
-
children: /* @__PURE__ */ jsx(PauseIcon, { className: "size-3.5" })
|
|
174
|
-
}
|
|
175
|
-
) : null,
|
|
176
|
-
/* @__PURE__ */ jsx(
|
|
177
|
-
Button,
|
|
178
|
-
{
|
|
179
|
-
variant: "ghost",
|
|
180
|
-
size: "icon",
|
|
181
|
-
className: "size-6 shrink-0",
|
|
182
|
-
"aria-label": t("Cancel", { note: "upload control" }),
|
|
183
|
-
onClick: (e) => {
|
|
184
|
-
e.stopPropagation();
|
|
185
|
-
onCancel?.();
|
|
186
|
-
},
|
|
187
|
-
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3.5" })
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
] });
|
|
615
|
+
return /* @__PURE__ */ jsx(
|
|
616
|
+
FileAttachment,
|
|
617
|
+
{
|
|
618
|
+
state: "uploading",
|
|
619
|
+
fileName: fileInfo.name,
|
|
620
|
+
fileSize: fileInfo.size,
|
|
621
|
+
fileType: fileInfo.type,
|
|
622
|
+
previewUrl: fileInfo.previewUrl,
|
|
623
|
+
percent: progress.percent,
|
|
624
|
+
description: eta ? `${formatFileSize(fileInfo.size)} \xB7 ${eta}` : void 0,
|
|
625
|
+
onCancel,
|
|
626
|
+
onPause,
|
|
627
|
+
...layout
|
|
628
|
+
}
|
|
629
|
+
);
|
|
191
630
|
}
|
|
192
631
|
if (phase === "success" && fileInfo) {
|
|
193
|
-
return /* @__PURE__ */
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
632
|
+
return /* @__PURE__ */ jsx(
|
|
633
|
+
FileAttachment,
|
|
634
|
+
{
|
|
635
|
+
state: "done",
|
|
636
|
+
fileName: fileInfo.name,
|
|
637
|
+
fileSize: fileInfo.size,
|
|
638
|
+
fileType: fileInfo.type,
|
|
639
|
+
previewUrl: fileInfo.previewUrl,
|
|
640
|
+
...layout
|
|
641
|
+
}
|
|
642
|
+
);
|
|
198
643
|
}
|
|
199
644
|
if (phase === "error") {
|
|
200
|
-
|
|
201
|
-
/* @__PURE__ */ jsx(
|
|
202
|
-
|
|
203
|
-
|
|
645
|
+
if (fileInfo) {
|
|
646
|
+
return /* @__PURE__ */ jsx(
|
|
647
|
+
FileAttachment,
|
|
648
|
+
{
|
|
649
|
+
state: "error",
|
|
650
|
+
fileName: fileInfo.name,
|
|
651
|
+
fileSize: fileInfo.size,
|
|
652
|
+
fileType: fileInfo.type,
|
|
653
|
+
previewUrl: fileInfo.previewUrl,
|
|
654
|
+
error,
|
|
655
|
+
...layout
|
|
656
|
+
}
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
return /* @__PURE__ */ jsx(
|
|
660
|
+
StatusAttachment,
|
|
661
|
+
{
|
|
662
|
+
state: "error",
|
|
663
|
+
title: t("Upload failed", { note: "status" }),
|
|
664
|
+
description: error ?? void 0,
|
|
665
|
+
...layout
|
|
666
|
+
}
|
|
667
|
+
);
|
|
204
668
|
}
|
|
205
669
|
if (phase === "validating" || phase === "presigning") {
|
|
206
|
-
|
|
670
|
+
if (fileInfo) {
|
|
671
|
+
return /* @__PURE__ */ jsx(
|
|
672
|
+
FileAttachment,
|
|
673
|
+
{
|
|
674
|
+
state: "processing",
|
|
675
|
+
fileName: fileInfo.name,
|
|
676
|
+
fileSize: fileInfo.size,
|
|
677
|
+
fileType: fileInfo.type,
|
|
678
|
+
previewUrl: fileInfo.previewUrl,
|
|
679
|
+
description: t("Preparing\u2026", { note: "upload status" }),
|
|
680
|
+
...layout
|
|
681
|
+
}
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
return /* @__PURE__ */ jsx(
|
|
685
|
+
StatusAttachment,
|
|
686
|
+
{
|
|
687
|
+
state: "processing",
|
|
688
|
+
title: t("Preparing\u2026", { note: "upload status" }),
|
|
689
|
+
...layout
|
|
690
|
+
}
|
|
691
|
+
);
|
|
207
692
|
}
|
|
208
693
|
return null;
|
|
209
694
|
}
|
|
@@ -232,7 +717,7 @@ function ProgressTrack({ className, ...props }) {
|
|
|
232
717
|
Progress$1.Track,
|
|
233
718
|
{
|
|
234
719
|
className: cn(
|
|
235
|
-
"relative flex h-1 w-full items-center overflow-x-hidden rounded-
|
|
720
|
+
"relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",
|
|
236
721
|
className
|
|
237
722
|
),
|
|
238
723
|
"data-slot": "progress-track",
|
|
@@ -257,7 +742,7 @@ function ProgressLabel({ className, ...props }) {
|
|
|
257
742
|
return /* @__PURE__ */ jsx(
|
|
258
743
|
Progress$1.Label,
|
|
259
744
|
{
|
|
260
|
-
className: cn("text-
|
|
745
|
+
className: cn("text-sm font-medium", className),
|
|
261
746
|
"data-slot": "progress-label",
|
|
262
747
|
...props
|
|
263
748
|
}
|
|
@@ -268,7 +753,7 @@ function ProgressValue({ className, ...props }) {
|
|
|
268
753
|
Progress$1.Value,
|
|
269
754
|
{
|
|
270
755
|
className: cn(
|
|
271
|
-
"ms-auto text-
|
|
756
|
+
"ms-auto text-sm text-muted-foreground tabular-nums",
|
|
272
757
|
className
|
|
273
758
|
),
|
|
274
759
|
"data-slot": "progress-value",
|
|
@@ -281,16 +766,20 @@ function MultiUploadStatus({
|
|
|
281
766
|
files,
|
|
282
767
|
totalProgress,
|
|
283
768
|
error,
|
|
284
|
-
onCancel
|
|
769
|
+
onCancel,
|
|
770
|
+
size,
|
|
771
|
+
orientation,
|
|
772
|
+
className
|
|
285
773
|
}) {
|
|
286
774
|
const t = useTranslations();
|
|
775
|
+
const layout = { size, orientation };
|
|
287
776
|
if (phase === "idle") return null;
|
|
288
777
|
if (phase === "uploading") {
|
|
289
778
|
const eta = totalProgress.speed && totalProgress.total ? formatEta(
|
|
290
779
|
totalProgress.total - totalProgress.loaded,
|
|
291
780
|
totalProgress.speed
|
|
292
781
|
) : null;
|
|
293
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-2", children: [
|
|
782
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col gap-2", className), children: [
|
|
294
783
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-1.5", children: [
|
|
295
784
|
/* @__PURE__ */ jsxs(Progress, { value: totalProgress.percent, className: "flex-1", children: [
|
|
296
785
|
/* @__PURE__ */ jsxs(ProgressLabel, { children: [
|
|
@@ -303,7 +792,7 @@ function MultiUploadStatus({
|
|
|
303
792
|
total: String(files.length)
|
|
304
793
|
}
|
|
305
794
|
}),
|
|
306
|
-
eta ? /* @__PURE__ */ jsxs("span", { className: "font-normal text-muted-foreground", children: [
|
|
795
|
+
eta ? /* @__PURE__ */ jsxs("span", { className: "font-normal text-dimah-s3-muted-foreground", children: [
|
|
307
796
|
" ",
|
|
308
797
|
"\xB7 ",
|
|
309
798
|
eta
|
|
@@ -311,64 +800,101 @@ function MultiUploadStatus({
|
|
|
311
800
|
] }),
|
|
312
801
|
/* @__PURE__ */ jsx(ProgressValue, {})
|
|
313
802
|
] }),
|
|
314
|
-
/* @__PURE__ */ jsx(
|
|
315
|
-
|
|
803
|
+
onCancel ? /* @__PURE__ */ jsx(
|
|
804
|
+
AttachmentAction,
|
|
316
805
|
{
|
|
317
|
-
|
|
318
|
-
size: "icon",
|
|
319
|
-
className: "size-7 shrink-0",
|
|
806
|
+
className: "shrink-0",
|
|
320
807
|
"aria-label": t("Cancel", { note: "upload control" }),
|
|
321
808
|
onClick: (e) => {
|
|
322
809
|
e.stopPropagation();
|
|
323
|
-
onCancel
|
|
810
|
+
onCancel();
|
|
324
811
|
},
|
|
325
|
-
children: /* @__PURE__ */ jsx(XIcon, {
|
|
812
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
326
813
|
}
|
|
327
|
-
)
|
|
814
|
+
) : null
|
|
328
815
|
] }),
|
|
329
|
-
/* @__PURE__ */ jsx(FileList, { files })
|
|
816
|
+
/* @__PURE__ */ jsx(FileList, { files, ...layout })
|
|
330
817
|
] });
|
|
331
818
|
}
|
|
332
819
|
if (phase === "success") {
|
|
333
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-
|
|
334
|
-
/* @__PURE__ */ jsx(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
820
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col gap-2", className), children: [
|
|
821
|
+
/* @__PURE__ */ jsx(
|
|
822
|
+
StatusAttachment,
|
|
823
|
+
{
|
|
824
|
+
state: "done",
|
|
825
|
+
title: t("All {count} file(s) uploaded", {
|
|
826
|
+
note: "status",
|
|
827
|
+
variables: { count: String(files.length) }
|
|
828
|
+
}),
|
|
829
|
+
...layout
|
|
830
|
+
}
|
|
831
|
+
),
|
|
832
|
+
/* @__PURE__ */ jsx(FileList, { files, ...layout })
|
|
339
833
|
] });
|
|
340
834
|
}
|
|
341
835
|
if (phase === "error") {
|
|
342
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-
|
|
343
|
-
/* @__PURE__ */ jsx(
|
|
344
|
-
|
|
836
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col gap-2", className), children: [
|
|
837
|
+
/* @__PURE__ */ jsx(
|
|
838
|
+
StatusAttachment,
|
|
839
|
+
{
|
|
840
|
+
state: "error",
|
|
841
|
+
title: t("Upload failed", { note: "status" }),
|
|
842
|
+
description: error ?? void 0,
|
|
843
|
+
...layout
|
|
844
|
+
}
|
|
845
|
+
),
|
|
846
|
+
files.length > 0 ? /* @__PURE__ */ jsx(FileList, { files, ...layout }) : null
|
|
345
847
|
] });
|
|
346
848
|
}
|
|
347
849
|
if (phase === "validating") {
|
|
348
|
-
return /* @__PURE__ */ jsx(
|
|
850
|
+
return /* @__PURE__ */ jsx(
|
|
851
|
+
StatusAttachment,
|
|
852
|
+
{
|
|
853
|
+
state: "processing",
|
|
854
|
+
title: t("Validating\u2026", { note: "upload status" }),
|
|
855
|
+
className,
|
|
856
|
+
...layout
|
|
857
|
+
}
|
|
858
|
+
);
|
|
349
859
|
}
|
|
350
860
|
return null;
|
|
351
861
|
}
|
|
352
|
-
function
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
862
|
+
function fileAttachmentState(status) {
|
|
863
|
+
switch (status) {
|
|
864
|
+
case "pending":
|
|
865
|
+
return "idle";
|
|
866
|
+
case "uploading":
|
|
867
|
+
return "uploading";
|
|
868
|
+
case "error":
|
|
869
|
+
return "error";
|
|
870
|
+
case "success":
|
|
871
|
+
return "done";
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
function FileList({
|
|
875
|
+
files,
|
|
876
|
+
size,
|
|
877
|
+
orientation
|
|
878
|
+
}) {
|
|
879
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-2", children: files.map((f) => /* @__PURE__ */ jsx(
|
|
880
|
+
FileAttachment,
|
|
881
|
+
{
|
|
882
|
+
state: fileAttachmentState(f.status),
|
|
883
|
+
fileName: f.fileName,
|
|
884
|
+
fileSize: f.fileSize,
|
|
885
|
+
fileType: f.fileType,
|
|
886
|
+
previewUrl: f.previewUrl,
|
|
887
|
+
percent: f.progress.percent,
|
|
888
|
+
error: f.error,
|
|
889
|
+
size,
|
|
890
|
+
orientation
|
|
891
|
+
},
|
|
892
|
+
f.id
|
|
893
|
+
)) });
|
|
370
894
|
}
|
|
371
895
|
function UploadStatusBlock(props) {
|
|
896
|
+
const { size, orientation } = props;
|
|
897
|
+
const layout = { size, orientation };
|
|
372
898
|
if (props.mode === "multi" && props.files.length === 1) {
|
|
373
899
|
const f = props.files[0];
|
|
374
900
|
return /* @__PURE__ */ jsx(
|
|
@@ -377,9 +903,15 @@ function UploadStatusBlock(props) {
|
|
|
377
903
|
phase: props.phase,
|
|
378
904
|
progress: f.progress,
|
|
379
905
|
error: f.error ?? props.error,
|
|
380
|
-
fileInfo: {
|
|
906
|
+
fileInfo: {
|
|
907
|
+
name: f.fileName,
|
|
908
|
+
size: f.fileSize,
|
|
909
|
+
type: f.fileType,
|
|
910
|
+
previewUrl: f.previewUrl
|
|
911
|
+
},
|
|
381
912
|
onCancel: props.onCancel,
|
|
382
|
-
onPause: props.onPause
|
|
913
|
+
onPause: props.onPause,
|
|
914
|
+
...layout
|
|
383
915
|
}
|
|
384
916
|
);
|
|
385
917
|
}
|
|
@@ -391,7 +923,8 @@ function UploadStatusBlock(props) {
|
|
|
391
923
|
files: props.files,
|
|
392
924
|
totalProgress: props.totalProgress,
|
|
393
925
|
error: props.error,
|
|
394
|
-
onCancel: props.onCancel
|
|
926
|
+
onCancel: props.onCancel,
|
|
927
|
+
...layout
|
|
395
928
|
}
|
|
396
929
|
);
|
|
397
930
|
}
|
|
@@ -403,7 +936,8 @@ function UploadStatusBlock(props) {
|
|
|
403
936
|
error: props.error,
|
|
404
937
|
fileInfo: props.fileInfo,
|
|
405
938
|
onCancel: props.onCancel,
|
|
406
|
-
onPause: props.onPause
|
|
939
|
+
onPause: props.onPause,
|
|
940
|
+
...layout
|
|
407
941
|
}
|
|
408
942
|
);
|
|
409
943
|
}
|
|
@@ -420,7 +954,7 @@ function ToastViewport({ className, ...props }) {
|
|
|
420
954
|
{
|
|
421
955
|
"data-slot": "toast-viewport",
|
|
422
956
|
className: cn(
|
|
423
|
-
"pointer-events-none fixed inset-x-4 bottom-4 z-50 mx-auto w-auto max-w-sm outline-none sm:
|
|
957
|
+
"pointer-events-none fixed inset-x-4 bottom-4 z-50 mx-auto w-auto max-w-sm outline-none sm:end-4 sm:start-auto sm:mx-0 sm:w-full",
|
|
424
958
|
className
|
|
425
959
|
),
|
|
426
960
|
...props
|
|
@@ -433,10 +967,10 @@ function Toast({ className, ...props }) {
|
|
|
433
967
|
{
|
|
434
968
|
"data-slot": "toast",
|
|
435
969
|
className: cn(
|
|
436
|
-
"group/toast pointer-events-auto absolute end-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-
|
|
970
|
+
"group/toast pointer-events-auto absolute end-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-2xl border bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
437
971
|
"[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]",
|
|
438
972
|
"h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]",
|
|
439
|
-
"after:absolute after:
|
|
973
|
+
"after:absolute after:top-full after:start-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
|
|
440
974
|
"data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]",
|
|
441
975
|
"data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]",
|
|
442
976
|
"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]",
|
|
@@ -705,72 +1239,91 @@ function useUploadToast(ctrl, enabled) {
|
|
|
705
1239
|
}
|
|
706
1240
|
}, [enabled, phase, mode, fileInfo, files, progress, totalProgress, t]);
|
|
707
1241
|
}
|
|
1242
|
+
function rejectionSummary(rejections, t) {
|
|
1243
|
+
const first = rejections[0];
|
|
1244
|
+
if (!first) {
|
|
1245
|
+
return t("Some files were rejected", { note: "toast" });
|
|
1246
|
+
}
|
|
1247
|
+
const detail = first.errors[0]?.message ?? t("File type or size not allowed", { note: "toast" });
|
|
1248
|
+
if (rejections.length === 1) {
|
|
1249
|
+
return `${first.file.name}: ${detail}`;
|
|
1250
|
+
}
|
|
1251
|
+
return t("{count} files were rejected", {
|
|
1252
|
+
note: "toast",
|
|
1253
|
+
variables: { count: String(rejections.length) }
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
function useFileRejectToast(fileRejections, enabled) {
|
|
1257
|
+
const t = useTranslations();
|
|
1258
|
+
const prevRef = useRef([]);
|
|
1259
|
+
useEffect(() => {
|
|
1260
|
+
if (!enabled) return;
|
|
1261
|
+
if (fileRejections.length === 0) {
|
|
1262
|
+
prevRef.current = fileRejections;
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
if (fileRejections === prevRef.current) return;
|
|
1266
|
+
prevRef.current = fileRejections;
|
|
1267
|
+
toast.add({
|
|
1268
|
+
type: "error",
|
|
1269
|
+
title: t("File not accepted", { note: "toast" }),
|
|
1270
|
+
description: /* @__PURE__ */ jsx("span", { dir: "auto", className: "block [overflow-wrap:anywhere]", children: rejectionSummary(fileRejections, t) })
|
|
1271
|
+
});
|
|
1272
|
+
}, [enabled, fileRejections, t]);
|
|
1273
|
+
}
|
|
708
1274
|
var EMPTY_PROGRESS = { loaded: 0, total: 0, percent: 0 };
|
|
709
1275
|
var EMPTY_FILES = [];
|
|
710
|
-
function
|
|
1276
|
+
function UploadButtonSingle({
|
|
711
1277
|
className,
|
|
712
1278
|
label,
|
|
713
1279
|
children,
|
|
714
1280
|
disabled,
|
|
715
1281
|
tooltipText,
|
|
716
1282
|
toast: enableToast = true,
|
|
717
|
-
|
|
718
|
-
multiple,
|
|
1283
|
+
status: statusSlot = true,
|
|
719
1284
|
variant = "default",
|
|
720
1285
|
size = "default",
|
|
721
1286
|
buttonClassName,
|
|
1287
|
+
attachmentSize,
|
|
1288
|
+
attachmentOrientation,
|
|
722
1289
|
...options
|
|
723
1290
|
}) {
|
|
724
1291
|
const t = useTranslations();
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
1292
|
+
const ctrl = useUpload({
|
|
1293
|
+
...options,
|
|
1294
|
+
disabled,
|
|
1295
|
+
noDrag: true,
|
|
1296
|
+
noClick: true,
|
|
1297
|
+
noKeyboard: true
|
|
1298
|
+
});
|
|
730
1299
|
const canPause = options.uploadStore != null && options.uploadStore !== false;
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
phase: multi.phase,
|
|
734
|
-
files: multi.files,
|
|
735
|
-
totalProgress: multi.totalProgress,
|
|
736
|
-
error: multi.error,
|
|
737
|
-
cancel: multi.cancel
|
|
738
|
-
} : {
|
|
1300
|
+
const isDisabled = disabled || ctrl.isUploading;
|
|
1301
|
+
const toastCtrl = {
|
|
739
1302
|
mode: "single",
|
|
740
|
-
phase:
|
|
741
|
-
fileInfo:
|
|
742
|
-
progress:
|
|
743
|
-
error:
|
|
744
|
-
cancel:
|
|
1303
|
+
phase: ctrl.phase,
|
|
1304
|
+
fileInfo: ctrl.fileInfo,
|
|
1305
|
+
progress: ctrl.progress,
|
|
1306
|
+
error: ctrl.error,
|
|
1307
|
+
cancel: ctrl.cancel
|
|
745
1308
|
};
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
const
|
|
749
|
-
UploadStatusBlock,
|
|
750
|
-
{
|
|
751
|
-
mode: "multi",
|
|
752
|
-
phase: multi.phase,
|
|
753
|
-
files: multi.files ?? EMPTY_FILES,
|
|
754
|
-
totalProgress: multi.totalProgress ?? EMPTY_PROGRESS,
|
|
755
|
-
error: multi.error,
|
|
756
|
-
onCancel: multi.cancel,
|
|
757
|
-
onPause: canPause ? multi.detach : void 0
|
|
758
|
-
}
|
|
759
|
-
) : /* @__PURE__ */ jsx(
|
|
1309
|
+
useUploadToast(toastCtrl, enableToast);
|
|
1310
|
+
useFileRejectToast(ctrl.fileRejections, enableToast);
|
|
1311
|
+
const statusNode = statusSlot === false ? null : /* @__PURE__ */ jsx(
|
|
760
1312
|
UploadStatusBlock,
|
|
761
1313
|
{
|
|
762
1314
|
mode: "single",
|
|
763
|
-
phase:
|
|
764
|
-
progress:
|
|
765
|
-
error:
|
|
766
|
-
fileInfo:
|
|
767
|
-
onCancel:
|
|
768
|
-
onPause: canPause ?
|
|
1315
|
+
phase: ctrl.phase,
|
|
1316
|
+
progress: ctrl.progress,
|
|
1317
|
+
error: ctrl.error,
|
|
1318
|
+
fileInfo: ctrl.fileInfo,
|
|
1319
|
+
onCancel: ctrl.cancel,
|
|
1320
|
+
onPause: canPause ? ctrl.detach : void 0,
|
|
1321
|
+
size: attachmentSize,
|
|
1322
|
+
orientation: attachmentOrientation
|
|
769
1323
|
}
|
|
770
|
-
)
|
|
771
|
-
const
|
|
772
|
-
const
|
|
773
|
-
const buttonLabel = label ?? (isMulti ? t("Upload files", { note: "button" }) : t("Upload file", { note: "button" }));
|
|
1324
|
+
);
|
|
1325
|
+
const status = resolveStatusSlot(statusSlot, statusNode);
|
|
1326
|
+
const buttonLabel = label ?? t("Upload file", { note: "button" });
|
|
774
1327
|
const buttonContent = children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
775
1328
|
/* @__PURE__ */ jsx(CloudUpload, { "data-icon": "inline-start" }),
|
|
776
1329
|
buttonLabel
|
|
@@ -782,13 +1335,13 @@ function UploadButton({
|
|
|
782
1335
|
size,
|
|
783
1336
|
className: buttonClassName,
|
|
784
1337
|
disabled: isDisabled,
|
|
785
|
-
onClick:
|
|
1338
|
+
onClick: ctrl.open,
|
|
786
1339
|
children: buttonContent
|
|
787
1340
|
}
|
|
788
1341
|
);
|
|
789
1342
|
return /* @__PURE__ */ jsxs("div", { className: cn("inline-flex flex-col gap-2", className), children: [
|
|
790
1343
|
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-2", children: [
|
|
791
|
-
/* @__PURE__ */ jsx("input", { ...
|
|
1344
|
+
/* @__PURE__ */ jsx("input", { ...ctrl.getInputProps() }),
|
|
792
1345
|
tooltipText ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
793
1346
|
/* @__PURE__ */ jsx(TooltipTrigger, { render: button }),
|
|
794
1347
|
/* @__PURE__ */ jsx(TooltipContent, { children: tooltipText })
|
|
@@ -797,46 +1350,98 @@ function UploadButton({
|
|
|
797
1350
|
status
|
|
798
1351
|
] });
|
|
799
1352
|
}
|
|
800
|
-
|
|
801
|
-
var EMPTY_FILES2 = [];
|
|
802
|
-
function UploadDropzone({
|
|
1353
|
+
function UploadButtonMulti({
|
|
803
1354
|
className,
|
|
804
1355
|
label,
|
|
805
1356
|
children,
|
|
806
1357
|
disabled,
|
|
1358
|
+
tooltipText,
|
|
807
1359
|
toast: enableToast = true,
|
|
808
|
-
|
|
809
|
-
|
|
1360
|
+
status: statusSlot = true,
|
|
1361
|
+
variant = "default",
|
|
1362
|
+
size = "default",
|
|
1363
|
+
buttonClassName,
|
|
1364
|
+
attachmentSize,
|
|
1365
|
+
attachmentOrientation,
|
|
810
1366
|
...options
|
|
811
1367
|
}) {
|
|
812
1368
|
const t = useTranslations();
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1369
|
+
const ctrl = useMultiUpload({
|
|
1370
|
+
...options,
|
|
1371
|
+
disabled,
|
|
1372
|
+
noDrag: true,
|
|
1373
|
+
noClick: true,
|
|
1374
|
+
noKeyboard: true
|
|
1375
|
+
});
|
|
818
1376
|
const canPause = options.uploadStore != null && options.uploadStore !== false;
|
|
819
|
-
const
|
|
1377
|
+
const isDisabled = disabled || ctrl.isUploading;
|
|
1378
|
+
const toastCtrl = {
|
|
820
1379
|
mode: "multi",
|
|
821
|
-
phase:
|
|
822
|
-
files:
|
|
823
|
-
totalProgress:
|
|
824
|
-
error:
|
|
825
|
-
cancel:
|
|
826
|
-
} : {
|
|
827
|
-
mode: "single",
|
|
828
|
-
phase: single.phase,
|
|
829
|
-
fileInfo: single.fileInfo,
|
|
830
|
-
progress: single.progress,
|
|
831
|
-
error: single.error,
|
|
832
|
-
cancel: single.cancel
|
|
1380
|
+
phase: ctrl.phase,
|
|
1381
|
+
files: ctrl.files,
|
|
1382
|
+
totalProgress: ctrl.totalProgress,
|
|
1383
|
+
error: ctrl.error,
|
|
1384
|
+
cancel: ctrl.cancel
|
|
833
1385
|
};
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1386
|
+
useUploadToast(toastCtrl, enableToast);
|
|
1387
|
+
useFileRejectToast(ctrl.fileRejections, enableToast);
|
|
1388
|
+
const statusNode = statusSlot === false ? null : /* @__PURE__ */ jsx(
|
|
1389
|
+
UploadStatusBlock,
|
|
1390
|
+
{
|
|
1391
|
+
mode: "multi",
|
|
1392
|
+
phase: ctrl.phase,
|
|
1393
|
+
files: ctrl.files ?? EMPTY_FILES,
|
|
1394
|
+
totalProgress: ctrl.totalProgress ?? EMPTY_PROGRESS,
|
|
1395
|
+
error: ctrl.error,
|
|
1396
|
+
onCancel: ctrl.cancel,
|
|
1397
|
+
onPause: canPause ? ctrl.detach : void 0,
|
|
1398
|
+
size: attachmentSize,
|
|
1399
|
+
orientation: attachmentOrientation
|
|
1400
|
+
}
|
|
1401
|
+
);
|
|
1402
|
+
const status = resolveStatusSlot(statusSlot, statusNode);
|
|
1403
|
+
const buttonLabel = label ?? t("Upload files", { note: "button" });
|
|
1404
|
+
const buttonContent = children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1405
|
+
/* @__PURE__ */ jsx(CloudUpload, { "data-icon": "inline-start" }),
|
|
1406
|
+
buttonLabel
|
|
1407
|
+
] });
|
|
1408
|
+
const button = /* @__PURE__ */ jsx(
|
|
1409
|
+
Button,
|
|
1410
|
+
{
|
|
1411
|
+
variant,
|
|
1412
|
+
size,
|
|
1413
|
+
className: buttonClassName,
|
|
1414
|
+
disabled: isDisabled,
|
|
1415
|
+
onClick: ctrl.open,
|
|
1416
|
+
children: buttonContent
|
|
1417
|
+
}
|
|
1418
|
+
);
|
|
1419
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("inline-flex flex-col gap-2", className), children: [
|
|
1420
|
+
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-2", children: [
|
|
1421
|
+
/* @__PURE__ */ jsx("input", { ...ctrl.getInputProps() }),
|
|
1422
|
+
tooltipText ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1423
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { render: button }),
|
|
1424
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: tooltipText })
|
|
1425
|
+
] }) : button
|
|
1426
|
+
] }),
|
|
1427
|
+
status
|
|
1428
|
+
] });
|
|
1429
|
+
}
|
|
1430
|
+
function UploadButton({ multiple, ...props }) {
|
|
1431
|
+
const isMulti = multiple === true || (props.maxFiles ?? 1) > 1;
|
|
1432
|
+
if (isMulti) {
|
|
1433
|
+
return /* @__PURE__ */ jsx(
|
|
1434
|
+
UploadButtonMulti,
|
|
1435
|
+
{
|
|
1436
|
+
...props
|
|
1437
|
+
}
|
|
1438
|
+
);
|
|
1439
|
+
}
|
|
1440
|
+
return /* @__PURE__ */ jsx(UploadButtonSingle, { ...props });
|
|
1441
|
+
}
|
|
1442
|
+
var EMPTY_PROGRESS2 = { loaded: 0, total: 0, percent: 0 };
|
|
1443
|
+
var EMPTY_FILES2 = [];
|
|
1444
|
+
function dropzoneHints(options, t) {
|
|
840
1445
|
const acceptLabels = formatAcceptLabels(options.accept);
|
|
841
1446
|
const maxFiles = options.maxFiles;
|
|
842
1447
|
const limitParts = [];
|
|
@@ -865,96 +1470,200 @@ function UploadDropzone({
|
|
|
865
1470
|
note: "dropzone hint",
|
|
866
1471
|
variables: { types: acceptLabels.join(", ") }
|
|
867
1472
|
}) : null;
|
|
868
|
-
|
|
1473
|
+
return { limitsLine, acceptLine };
|
|
1474
|
+
}
|
|
1475
|
+
function DropzoneChrome({
|
|
1476
|
+
label,
|
|
1477
|
+
limitsLine,
|
|
1478
|
+
acceptLine,
|
|
1479
|
+
isDisabled,
|
|
1480
|
+
children
|
|
1481
|
+
}) {
|
|
1482
|
+
if (children != null) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1483
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1484
|
+
/* @__PURE__ */ jsx(
|
|
1485
|
+
CloudUpload,
|
|
1486
|
+
{
|
|
1487
|
+
className: cn("size-6", isDisabled && "opacity-50"),
|
|
1488
|
+
strokeWidth: 1.5
|
|
1489
|
+
}
|
|
1490
|
+
),
|
|
1491
|
+
/* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1", isDisabled && "opacity-50"), children: [
|
|
1492
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: label }),
|
|
1493
|
+
limitsLine && /* @__PURE__ */ jsx("p", { className: "text-xs text-dimah-s3-muted-foreground", children: limitsLine }),
|
|
1494
|
+
acceptLine && /* @__PURE__ */ jsx("p", { className: "text-xs text-dimah-s3-muted-foreground", children: acceptLine })
|
|
1495
|
+
] })
|
|
1496
|
+
] });
|
|
1497
|
+
}
|
|
1498
|
+
function UploadDropzoneSingle({
|
|
1499
|
+
className,
|
|
1500
|
+
label,
|
|
1501
|
+
children,
|
|
1502
|
+
disabled,
|
|
1503
|
+
toast: enableToast = true,
|
|
1504
|
+
status: statusSlot = true,
|
|
1505
|
+
attachmentSize,
|
|
1506
|
+
attachmentOrientation,
|
|
1507
|
+
...options
|
|
1508
|
+
}) {
|
|
1509
|
+
const t = useTranslations();
|
|
1510
|
+
const ctrl = useUpload({ ...options, disabled });
|
|
1511
|
+
const canPause = options.uploadStore != null && options.uploadStore !== false;
|
|
1512
|
+
const isDisabled = disabled || ctrl.isUploading;
|
|
1513
|
+
const hasCustomChrome = children != null;
|
|
869
1514
|
const dropzoneLabel = label ?? t("Drag and drop files here", { note: "dropzone" });
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1515
|
+
const { limitsLine, acceptLine } = dropzoneHints(options, t);
|
|
1516
|
+
const toastCtrl = {
|
|
1517
|
+
mode: "single",
|
|
1518
|
+
phase: ctrl.phase,
|
|
1519
|
+
fileInfo: ctrl.fileInfo,
|
|
1520
|
+
progress: ctrl.progress,
|
|
1521
|
+
error: ctrl.error,
|
|
1522
|
+
cancel: ctrl.cancel
|
|
1523
|
+
};
|
|
1524
|
+
useUploadToast(toastCtrl, enableToast);
|
|
1525
|
+
useFileRejectToast(ctrl.fileRejections, enableToast);
|
|
1526
|
+
const statusNode = statusSlot === false ? null : /* @__PURE__ */ jsx(
|
|
882
1527
|
UploadStatusBlock,
|
|
883
1528
|
{
|
|
884
1529
|
mode: "single",
|
|
885
|
-
phase:
|
|
886
|
-
progress:
|
|
887
|
-
error:
|
|
888
|
-
fileInfo:
|
|
889
|
-
onCancel:
|
|
890
|
-
onPause: canPause ?
|
|
1530
|
+
phase: ctrl.phase,
|
|
1531
|
+
progress: ctrl.progress,
|
|
1532
|
+
error: ctrl.error,
|
|
1533
|
+
fileInfo: ctrl.fileInfo,
|
|
1534
|
+
onCancel: ctrl.cancel,
|
|
1535
|
+
onPause: canPause ? ctrl.detach : void 0,
|
|
1536
|
+
size: attachmentSize,
|
|
1537
|
+
orientation: attachmentOrientation
|
|
891
1538
|
}
|
|
892
|
-
)
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1539
|
+
);
|
|
1540
|
+
const defaultStatus = statusNode == null ? null : /* @__PURE__ */ jsx("div", { className: cn("w-full text-start", hasCustomChrome && "px-3 pb-3"), children: statusNode });
|
|
1541
|
+
const status = typeof statusSlot === "function" ? statusSlot(statusNode) : resolveStatusSlot(statusSlot, defaultStatus);
|
|
1542
|
+
return /* @__PURE__ */ jsxs(
|
|
1543
|
+
"div",
|
|
1544
|
+
{
|
|
1545
|
+
...ctrl.getRootProps({
|
|
1546
|
+
"aria-label": dropzoneLabel,
|
|
1547
|
+
className: cn(
|
|
1548
|
+
"rounded-lg border-2 border-dashed transition-colors",
|
|
1549
|
+
hasCustomChrome ? "flex flex-col items-stretch justify-stretch gap-3 p-0" : "flex flex-col items-center justify-center gap-3 p-6 text-center",
|
|
1550
|
+
isDisabled ? "cursor-not-allowed border-dimah-s3-muted-foreground/25" : "cursor-pointer border-dimah-s3-muted-foreground/25 hover:border-dimah-s3-primary/50",
|
|
1551
|
+
!isDisabled && ctrl.isDragReject && "border-dimah-s3-destructive bg-dimah-s3-destructive/5",
|
|
1552
|
+
!isDisabled && ctrl.isDragAccept && "border-dimah-s3-primary bg-dimah-s3-primary/5",
|
|
1553
|
+
!isDisabled && ctrl.isDragActive && !ctrl.isDragAccept && !ctrl.isDragReject && "border-dimah-s3-primary/50",
|
|
1554
|
+
className
|
|
1555
|
+
)
|
|
1556
|
+
}),
|
|
1557
|
+
children: [
|
|
1558
|
+
/* @__PURE__ */ jsx("input", { ...ctrl.getInputProps() }),
|
|
1559
|
+
/* @__PURE__ */ jsx(
|
|
1560
|
+
DropzoneChrome,
|
|
1561
|
+
{
|
|
1562
|
+
label: dropzoneLabel,
|
|
1563
|
+
limitsLine,
|
|
1564
|
+
acceptLine,
|
|
1565
|
+
isDisabled,
|
|
1566
|
+
children
|
|
1567
|
+
}
|
|
1568
|
+
),
|
|
1569
|
+
status
|
|
1570
|
+
]
|
|
898
1571
|
}
|
|
1572
|
+
);
|
|
1573
|
+
}
|
|
1574
|
+
function UploadDropzoneMulti({
|
|
1575
|
+
className,
|
|
1576
|
+
label,
|
|
1577
|
+
children,
|
|
1578
|
+
disabled,
|
|
1579
|
+
toast: enableToast = true,
|
|
1580
|
+
status: statusSlot = true,
|
|
1581
|
+
attachmentSize,
|
|
1582
|
+
attachmentOrientation,
|
|
1583
|
+
...options
|
|
1584
|
+
}) {
|
|
1585
|
+
const t = useTranslations();
|
|
1586
|
+
const ctrl = useMultiUpload({ ...options, disabled });
|
|
1587
|
+
const canPause = options.uploadStore != null && options.uploadStore !== false;
|
|
1588
|
+
const isDisabled = disabled || ctrl.isUploading;
|
|
1589
|
+
const hasCustomChrome = children != null;
|
|
1590
|
+
const dropzoneLabel = label ?? t("Drag and drop files here", { note: "dropzone" });
|
|
1591
|
+
const { limitsLine, acceptLine } = dropzoneHints(options, t);
|
|
1592
|
+
const toastCtrl = {
|
|
1593
|
+
mode: "multi",
|
|
1594
|
+
phase: ctrl.phase,
|
|
1595
|
+
files: ctrl.files,
|
|
1596
|
+
totalProgress: ctrl.totalProgress,
|
|
1597
|
+
error: ctrl.error,
|
|
1598
|
+
cancel: ctrl.cancel
|
|
899
1599
|
};
|
|
1600
|
+
useUploadToast(toastCtrl, enableToast);
|
|
1601
|
+
useFileRejectToast(ctrl.fileRejections, enableToast);
|
|
1602
|
+
const statusNode = statusSlot === false ? null : /* @__PURE__ */ jsx(
|
|
1603
|
+
UploadStatusBlock,
|
|
1604
|
+
{
|
|
1605
|
+
mode: "multi",
|
|
1606
|
+
phase: ctrl.phase,
|
|
1607
|
+
files: ctrl.files ?? EMPTY_FILES2,
|
|
1608
|
+
totalProgress: ctrl.totalProgress ?? EMPTY_PROGRESS2,
|
|
1609
|
+
error: ctrl.error,
|
|
1610
|
+
onCancel: ctrl.cancel,
|
|
1611
|
+
onPause: canPause ? ctrl.detach : void 0,
|
|
1612
|
+
size: attachmentSize,
|
|
1613
|
+
orientation: attachmentOrientation
|
|
1614
|
+
}
|
|
1615
|
+
);
|
|
1616
|
+
const defaultStatus = statusNode == null ? null : /* @__PURE__ */ jsx("div", { className: cn("w-full text-start", hasCustomChrome && "px-3 pb-3"), children: statusNode });
|
|
1617
|
+
const status = typeof statusSlot === "function" ? statusSlot(statusNode) : resolveStatusSlot(statusSlot, defaultStatus);
|
|
900
1618
|
return /* @__PURE__ */ jsxs(
|
|
901
1619
|
"div",
|
|
902
1620
|
{
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
onKeyDown,
|
|
916
|
-
...isDisabled ? {} : {
|
|
917
|
-
...dropHandlers,
|
|
918
|
-
onDragEnter: (e) => {
|
|
919
|
-
if (e.dataTransfer.types.includes("Files")) setIsDragOver(true);
|
|
920
|
-
},
|
|
921
|
-
onDragLeave: (e) => {
|
|
922
|
-
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
923
|
-
setIsDragOver(false);
|
|
924
|
-
}
|
|
925
|
-
},
|
|
926
|
-
onDrop: (e) => {
|
|
927
|
-
setIsDragOver(false);
|
|
928
|
-
dropHandlers.onDrop(e);
|
|
929
|
-
}
|
|
930
|
-
},
|
|
1621
|
+
...ctrl.getRootProps({
|
|
1622
|
+
"aria-label": dropzoneLabel,
|
|
1623
|
+
className: cn(
|
|
1624
|
+
"rounded-lg border-2 border-dashed transition-colors",
|
|
1625
|
+
hasCustomChrome ? "flex flex-col items-stretch justify-stretch gap-3 p-0" : "flex flex-col items-center justify-center gap-3 p-6 text-center",
|
|
1626
|
+
isDisabled ? "cursor-not-allowed border-dimah-s3-muted-foreground/25" : "cursor-pointer border-dimah-s3-muted-foreground/25 hover:border-dimah-s3-primary/50",
|
|
1627
|
+
!isDisabled && ctrl.isDragReject && "border-dimah-s3-destructive bg-dimah-s3-destructive/5",
|
|
1628
|
+
!isDisabled && ctrl.isDragAccept && "border-dimah-s3-primary bg-dimah-s3-primary/5",
|
|
1629
|
+
!isDisabled && ctrl.isDragActive && !ctrl.isDragAccept && !ctrl.isDragReject && "border-dimah-s3-primary/50",
|
|
1630
|
+
className
|
|
1631
|
+
)
|
|
1632
|
+
}),
|
|
931
1633
|
children: [
|
|
932
|
-
/* @__PURE__ */ jsx("input", { ...
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
className: cn("flex flex-col gap-1", isDisabled && "opacity-50"),
|
|
945
|
-
children: [
|
|
946
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: dropzoneLabel }),
|
|
947
|
-
limitsLine && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: limitsLine }),
|
|
948
|
-
acceptLine && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: acceptLine })
|
|
949
|
-
]
|
|
950
|
-
}
|
|
951
|
-
),
|
|
952
|
-
status && /* @__PURE__ */ jsx("div", { className: "w-full text-start", children: status })
|
|
953
|
-
] })
|
|
1634
|
+
/* @__PURE__ */ jsx("input", { ...ctrl.getInputProps() }),
|
|
1635
|
+
/* @__PURE__ */ jsx(
|
|
1636
|
+
DropzoneChrome,
|
|
1637
|
+
{
|
|
1638
|
+
label: dropzoneLabel,
|
|
1639
|
+
limitsLine,
|
|
1640
|
+
acceptLine,
|
|
1641
|
+
isDisabled,
|
|
1642
|
+
children
|
|
1643
|
+
}
|
|
1644
|
+
),
|
|
1645
|
+
status
|
|
954
1646
|
]
|
|
955
1647
|
}
|
|
956
1648
|
);
|
|
957
1649
|
}
|
|
1650
|
+
function UploadDropzone({ multiple, ...props }) {
|
|
1651
|
+
const isMulti = multiple === true || (props.maxFiles ?? 1) > 1;
|
|
1652
|
+
if (isMulti) {
|
|
1653
|
+
return /* @__PURE__ */ jsx(
|
|
1654
|
+
UploadDropzoneMulti,
|
|
1655
|
+
{
|
|
1656
|
+
...props
|
|
1657
|
+
}
|
|
1658
|
+
);
|
|
1659
|
+
}
|
|
1660
|
+
return /* @__PURE__ */ jsx(
|
|
1661
|
+
UploadDropzoneSingle,
|
|
1662
|
+
{
|
|
1663
|
+
...props
|
|
1664
|
+
}
|
|
1665
|
+
);
|
|
1666
|
+
}
|
|
958
1667
|
function useDownloadToast({
|
|
959
1668
|
enabled = true,
|
|
960
1669
|
objectKey,
|
|
@@ -1035,10 +1744,12 @@ function DownloadButton({
|
|
|
1035
1744
|
className,
|
|
1036
1745
|
disabled,
|
|
1037
1746
|
toast: enableToast = true,
|
|
1038
|
-
|
|
1747
|
+
status: statusSlot = true,
|
|
1039
1748
|
variant = "outline",
|
|
1040
1749
|
size = "default",
|
|
1041
|
-
buttonClassName
|
|
1750
|
+
buttonClassName,
|
|
1751
|
+
attachmentSize,
|
|
1752
|
+
attachmentOrientation
|
|
1042
1753
|
}) {
|
|
1043
1754
|
const t = useTranslations();
|
|
1044
1755
|
const toastHandlers = useDownloadToast({
|
|
@@ -1060,7 +1771,17 @@ function DownloadButton({
|
|
|
1060
1771
|
isPending ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : /* @__PURE__ */ jsx(DownloadIcon, { "data-icon": "inline-start" }),
|
|
1061
1772
|
label ?? t("Download", { note: "button" })
|
|
1062
1773
|
] });
|
|
1063
|
-
|
|
1774
|
+
const statusNode = dl.phase === "error" ? /* @__PURE__ */ jsx(
|
|
1775
|
+
StatusAttachment,
|
|
1776
|
+
{
|
|
1777
|
+
state: "error",
|
|
1778
|
+
title: t("Download failed", { note: "status" }),
|
|
1779
|
+
description: dl.error ?? void 0,
|
|
1780
|
+
size: attachmentSize,
|
|
1781
|
+
orientation: attachmentOrientation
|
|
1782
|
+
}
|
|
1783
|
+
) : null;
|
|
1784
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("inline-flex flex-col gap-2", className), children: [
|
|
1064
1785
|
/* @__PURE__ */ jsx(
|
|
1065
1786
|
Button,
|
|
1066
1787
|
{
|
|
@@ -1072,10 +1793,7 @@ function DownloadButton({
|
|
|
1072
1793
|
children: buttonContent
|
|
1073
1794
|
}
|
|
1074
1795
|
),
|
|
1075
|
-
|
|
1076
|
-
/* @__PURE__ */ jsx(AlertCircleIcon, { className: "mt-0.5 size-3.5 shrink-0 text-destructive" }),
|
|
1077
|
-
/* @__PURE__ */ jsx("p", { className: "min-w-0 [overflow-wrap:anywhere] text-destructive", children: dl.error ?? t("Download failed", { note: "status" }) })
|
|
1078
|
-
] })
|
|
1796
|
+
resolveStatusSlot(statusSlot, statusNode)
|
|
1079
1797
|
] });
|
|
1080
1798
|
}
|
|
1081
1799
|
function ProgressDownloadButton({
|
|
@@ -1092,10 +1810,12 @@ function ProgressDownloadButton({
|
|
|
1092
1810
|
tooltipText,
|
|
1093
1811
|
cancelTooltipText,
|
|
1094
1812
|
toast: enableToast = true,
|
|
1095
|
-
|
|
1813
|
+
status: statusSlot = true,
|
|
1096
1814
|
variant = "outline",
|
|
1097
1815
|
size = "default",
|
|
1098
1816
|
buttonClassName,
|
|
1817
|
+
attachmentSize,
|
|
1818
|
+
attachmentOrientation,
|
|
1099
1819
|
beforeDownload,
|
|
1100
1820
|
onDownloadStart,
|
|
1101
1821
|
onProgress,
|
|
@@ -1144,7 +1864,17 @@ function ProgressDownloadButton({
|
|
|
1144
1864
|
!isDownloading && /* @__PURE__ */ jsx(DownloadIcon, { "data-icon": "inline-start" }),
|
|
1145
1865
|
isDownloading ? formatFileSize(dl.progress.loaded) : label ?? t("Download", { note: "button" })
|
|
1146
1866
|
] });
|
|
1147
|
-
|
|
1867
|
+
const statusNode = dl.phase === "error" ? /* @__PURE__ */ jsx(
|
|
1868
|
+
StatusAttachment,
|
|
1869
|
+
{
|
|
1870
|
+
state: "error",
|
|
1871
|
+
title: t("Download failed", { note: "status" }),
|
|
1872
|
+
description: dl.error ?? void 0,
|
|
1873
|
+
size: attachmentSize,
|
|
1874
|
+
orientation: attachmentOrientation
|
|
1875
|
+
}
|
|
1876
|
+
) : null;
|
|
1877
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("inline-flex flex-col items-center gap-2", className), children: [
|
|
1148
1878
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1149
1879
|
/* @__PURE__ */ jsxs(
|
|
1150
1880
|
TooltipTrigger,
|
|
@@ -1167,7 +1897,7 @@ function ProgressDownloadButton({
|
|
|
1167
1897
|
"span",
|
|
1168
1898
|
{
|
|
1169
1899
|
className: cn(
|
|
1170
|
-
"absolute inset-y-0 start-0 bg-primary/15",
|
|
1900
|
+
"absolute inset-y-0 start-0 bg-dimah-s3-primary/15",
|
|
1171
1901
|
fillPercent != null ? "transition-[width] duration-200" : "w-full animate-pulse",
|
|
1172
1902
|
fillClassName
|
|
1173
1903
|
),
|
|
@@ -1181,10 +1911,7 @@ function ProgressDownloadButton({
|
|
|
1181
1911
|
),
|
|
1182
1912
|
/* @__PURE__ */ jsx(TooltipContent, { children: isDownloading ? cancelTooltipText ?? t("Cancel download", { note: "tooltip" }) : tooltipText ?? t("Download file", { note: "tooltip" }) })
|
|
1183
1913
|
] }),
|
|
1184
|
-
|
|
1185
|
-
/* @__PURE__ */ jsx(AlertCircleIcon, { className: "mt-0.5 size-3.5 shrink-0 text-destructive" }),
|
|
1186
|
-
/* @__PURE__ */ jsx("p", { className: "min-w-0 [overflow-wrap:anywhere] text-destructive", children: dl.error ?? t("Download failed", { note: "status" }) })
|
|
1187
|
-
] })
|
|
1914
|
+
resolveStatusSlot(statusSlot, statusNode)
|
|
1188
1915
|
] });
|
|
1189
1916
|
}
|
|
1190
1917
|
function AlertDialog({ ...props }) {
|
|
@@ -1205,7 +1932,7 @@ function AlertDialogOverlay({
|
|
|
1205
1932
|
{
|
|
1206
1933
|
"data-slot": "alert-dialog-overlay",
|
|
1207
1934
|
className: cn(
|
|
1208
|
-
"fixed inset-0 isolate z-50 bg-black/
|
|
1935
|
+
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
1209
1936
|
className
|
|
1210
1937
|
),
|
|
1211
1938
|
...props
|
|
@@ -1225,7 +1952,7 @@ function AlertDialogContent({
|
|
|
1225
1952
|
"data-slot": "alert-dialog-content",
|
|
1226
1953
|
"data-size": size,
|
|
1227
1954
|
className: cn(
|
|
1228
|
-
"group/alert-dialog-content fixed top-1/2 start-1/2 z-50 grid w-full -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 gap-
|
|
1955
|
+
"group/alert-dialog-content fixed top-1/2 start-1/2 z-50 grid w-full -translate-x-1/2 rtl:translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
1229
1956
|
className
|
|
1230
1957
|
),
|
|
1231
1958
|
...props
|
|
@@ -1242,7 +1969,7 @@ function AlertDialogHeader({
|
|
|
1242
1969
|
{
|
|
1243
1970
|
"data-slot": "alert-dialog-header",
|
|
1244
1971
|
className: cn(
|
|
1245
|
-
"grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-start sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
|
|
1972
|
+
"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-start sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
|
|
1246
1973
|
className
|
|
1247
1974
|
),
|
|
1248
1975
|
...props
|
|
@@ -1258,7 +1985,7 @@ function AlertDialogFooter({
|
|
|
1258
1985
|
{
|
|
1259
1986
|
"data-slot": "alert-dialog-footer",
|
|
1260
1987
|
className: cn(
|
|
1261
|
-
"flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
|
|
1988
|
+
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
|
|
1262
1989
|
className
|
|
1263
1990
|
),
|
|
1264
1991
|
...props
|
|
@@ -1274,7 +2001,7 @@ function AlertDialogMedia({
|
|
|
1274
2001
|
{
|
|
1275
2002
|
"data-slot": "alert-dialog-media",
|
|
1276
2003
|
className: cn(
|
|
1277
|
-
"mb-2 inline-flex size-
|
|
2004
|
+
"mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",
|
|
1278
2005
|
className
|
|
1279
2006
|
),
|
|
1280
2007
|
...props
|
|
@@ -1290,7 +2017,7 @@ function AlertDialogTitle({
|
|
|
1290
2017
|
{
|
|
1291
2018
|
"data-slot": "alert-dialog-title",
|
|
1292
2019
|
className: cn(
|
|
1293
|
-
"
|
|
2020
|
+
"text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
|
|
1294
2021
|
className
|
|
1295
2022
|
),
|
|
1296
2023
|
...props
|
|
@@ -1306,7 +2033,7 @@ function AlertDialogDescription({
|
|
|
1306
2033
|
{
|
|
1307
2034
|
"data-slot": "alert-dialog-description",
|
|
1308
2035
|
className: cn(
|
|
1309
|
-
"text-
|
|
2036
|
+
"text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
1310
2037
|
className
|
|
1311
2038
|
),
|
|
1312
2039
|
...props
|
|
@@ -1381,12 +2108,14 @@ function DeleteButton({
|
|
|
1381
2108
|
disabled,
|
|
1382
2109
|
tooltipText,
|
|
1383
2110
|
toast: enableToast = true,
|
|
1384
|
-
|
|
2111
|
+
status: statusSlot = true,
|
|
1385
2112
|
confirmTitle,
|
|
1386
2113
|
confirmDescription,
|
|
1387
2114
|
variant = "destructive",
|
|
1388
2115
|
size = "default",
|
|
1389
2116
|
buttonClassName,
|
|
2117
|
+
attachmentSize,
|
|
2118
|
+
attachmentOrientation,
|
|
1390
2119
|
beforeDelete,
|
|
1391
2120
|
onDeleteStart,
|
|
1392
2121
|
onSuccess,
|
|
@@ -1426,7 +2155,28 @@ function DeleteButton({
|
|
|
1426
2155
|
variables: { name: isolateLtr(fileLabel) }
|
|
1427
2156
|
}
|
|
1428
2157
|
);
|
|
1429
|
-
|
|
2158
|
+
const statusNode = del.phase === "success" ? /* @__PURE__ */ jsx(
|
|
2159
|
+
StatusAttachment,
|
|
2160
|
+
{
|
|
2161
|
+
state: "done",
|
|
2162
|
+
title: t('"{name}" deleted', {
|
|
2163
|
+
note: "status",
|
|
2164
|
+
variables: { name: truncateFileName(displayName) }
|
|
2165
|
+
}),
|
|
2166
|
+
size: attachmentSize,
|
|
2167
|
+
orientation: attachmentOrientation
|
|
2168
|
+
}
|
|
2169
|
+
) : del.phase === "error" ? /* @__PURE__ */ jsx(
|
|
2170
|
+
StatusAttachment,
|
|
2171
|
+
{
|
|
2172
|
+
state: "error",
|
|
2173
|
+
title: t("Delete failed", { note: "status" }),
|
|
2174
|
+
description: del.error ?? void 0,
|
|
2175
|
+
size: attachmentSize,
|
|
2176
|
+
orientation: attachmentOrientation
|
|
2177
|
+
}
|
|
2178
|
+
) : null;
|
|
2179
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("inline-flex flex-col gap-2", className), children: [
|
|
1430
2180
|
/* @__PURE__ */ jsx("div", { className: "inline-flex items-center gap-2", children: /* @__PURE__ */ jsxs(
|
|
1431
2181
|
AlertDialog,
|
|
1432
2182
|
{
|
|
@@ -1488,20 +2238,10 @@ function DeleteButton({
|
|
|
1488
2238
|
]
|
|
1489
2239
|
}
|
|
1490
2240
|
) }),
|
|
1491
|
-
|
|
1492
|
-
/* @__PURE__ */ jsx(CheckCircle2Icon, { className: "size-3.5 shrink-0 text-green-600" }),
|
|
1493
|
-
/* @__PURE__ */ jsx("p", { className: "min-w-0 [overflow-wrap:anywhere] text-green-600", children: t('"{name}" deleted', {
|
|
1494
|
-
note: "status",
|
|
1495
|
-
variables: { name: truncateFileName(displayName) }
|
|
1496
|
-
}) })
|
|
1497
|
-
] }),
|
|
1498
|
-
showStatus && del.phase === "error" && /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start gap-1.5 text-xs", children: [
|
|
1499
|
-
/* @__PURE__ */ jsx(AlertCircleIcon, { className: "mt-0.5 size-3.5 shrink-0 text-destructive" }),
|
|
1500
|
-
/* @__PURE__ */ jsx("p", { className: "min-w-0 [overflow-wrap:anywhere] text-destructive", children: del.error ?? t("Delete failed", { note: "status" }) })
|
|
1501
|
-
] })
|
|
2241
|
+
resolveStatusSlot(statusSlot, statusNode)
|
|
1502
2242
|
] });
|
|
1503
2243
|
}
|
|
1504
2244
|
|
|
1505
|
-
export { DeleteButton, DownloadButton, MultiUploadStatus, ProgressDownloadButton, Toaster, UploadButton, UploadDropzone, UploadStatus, UploadStatusBlock, toast };
|
|
2245
|
+
export { DeleteButton, DownloadButton, FileAttachment, MultiUploadStatus, ProgressDownloadButton, StatusAttachment, Toaster, UploadButton, UploadDropzone, UploadStatus, UploadStatusBlock, resolveStatusSlot, toast };
|
|
1506
2246
|
//# sourceMappingURL=index.js.map
|
|
1507
2247
|
//# sourceMappingURL=index.js.map
|