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