@dimah-s3/ui 2.0.0-beta.3 → 2.0.0-beta.5

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 (72) hide show
  1. package/README.md +5 -5
  2. package/dist/components/dimah-s3/attachment/file-attachment.d.ts +7 -1
  3. package/dist/components/dimah-s3/attachment/file-attachment.d.ts.map +1 -1
  4. package/dist/components/dimah-s3/attachment/file-type-glyph.d.ts +17 -4
  5. package/dist/components/dimah-s3/attachment/file-type-glyph.d.ts.map +1 -1
  6. package/dist/components/dimah-s3/delete/delete-confirm-dialog.d.ts.map +1 -1
  7. package/dist/components/dimah-s3/delete/delete-toasts.d.ts.map +1 -1
  8. package/dist/components/dimah-s3/delete/delete-trigger.d.ts +6 -4
  9. package/dist/components/dimah-s3/delete/delete-trigger.d.ts.map +1 -1
  10. package/dist/components/dimah-s3/delete/delete.d.ts +22 -9
  11. package/dist/components/dimah-s3/delete/delete.d.ts.map +1 -1
  12. package/dist/components/dimah-s3/download/download-progress.d.ts +2 -2
  13. package/dist/components/dimah-s3/download/download-progress.d.ts.map +1 -1
  14. package/dist/components/dimah-s3/download/download-trigger.d.ts +1 -0
  15. package/dist/components/dimah-s3/download/download-trigger.d.ts.map +1 -1
  16. package/dist/components/dimah-s3/list/object-list-content.d.ts.map +1 -1
  17. package/dist/components/dimah-s3/list/object-list-context.d.ts +87 -6
  18. package/dist/components/dimah-s3/list/object-list-context.d.ts.map +1 -1
  19. package/dist/components/dimah-s3/list/object-list-entry.d.ts +10 -5
  20. package/dist/components/dimah-s3/list/object-list-entry.d.ts.map +1 -1
  21. package/dist/components/dimah-s3/list/object-list-feedback.d.ts +8 -2
  22. package/dist/components/dimah-s3/list/object-list-feedback.d.ts.map +1 -1
  23. package/dist/components/dimah-s3/list/object-list-header.d.ts +9 -3
  24. package/dist/components/dimah-s3/list/object-list-header.d.ts.map +1 -1
  25. package/dist/components/dimah-s3/list/object-list-item-menu.d.ts.map +1 -1
  26. package/dist/components/dimah-s3/list/object-list-keyboard.d.ts +10 -3
  27. package/dist/components/dimah-s3/list/object-list-keyboard.d.ts.map +1 -1
  28. package/dist/components/dimah-s3/list/object-list-rename.d.ts.map +1 -1
  29. package/dist/components/dimah-s3/list/object-list.d.ts +5 -5
  30. package/dist/components/dimah-s3/list/object-list.d.ts.map +1 -1
  31. package/dist/components/dimah-s3/preview/object-card.d.ts.map +1 -1
  32. package/dist/components/dimah-s3/preview/object-image.d.ts +6 -4
  33. package/dist/components/dimah-s3/preview/object-image.d.ts.map +1 -1
  34. package/dist/components/dimah-s3/upload/avatar-upload.d.ts.map +1 -1
  35. package/dist/components/dimah-s3/upload/upload-field.d.ts +22 -13
  36. package/dist/components/dimah-s3/upload/upload-field.d.ts.map +1 -1
  37. package/dist/components/dimah-s3/upload/upload-file-list.d.ts +3 -1
  38. package/dist/components/dimah-s3/upload/upload-file-list.d.ts.map +1 -1
  39. package/dist/components/dimah-s3/upload/upload-status.d.ts +4 -2
  40. package/dist/components/dimah-s3/upload/upload-status.d.ts.map +1 -1
  41. package/dist/components/dimah-s3/upload/upload-toasts.d.ts.map +1 -1
  42. package/dist/components/dimah-s3/upload/upload.d.ts +7 -6
  43. package/dist/components/dimah-s3/upload/upload.d.ts.map +1 -1
  44. package/dist/components/ui/alert-dialog.d.ts +1 -1
  45. package/dist/components/ui/alert-dialog.d.ts.map +1 -1
  46. package/dist/components/ui/attachment.d.ts +1 -1
  47. package/dist/components/ui/attachment.d.ts.map +1 -1
  48. package/dist/components/ui/breadcrumb.d.ts +1 -1
  49. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  50. package/dist/components/ui/checkbox.d.ts.map +1 -1
  51. package/dist/components/ui/dropdown-menu.d.ts +1 -1
  52. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  53. package/dist/components/ui/empty.d.ts +6 -7
  54. package/dist/components/ui/empty.d.ts.map +1 -1
  55. package/dist/components/ui/item.d.ts +1 -1
  56. package/dist/components/ui/item.d.ts.map +1 -1
  57. package/dist/components/ui/skeleton.d.ts +1 -2
  58. package/dist/components/ui/skeleton.d.ts.map +1 -1
  59. package/dist/components/ui/spinner.d.ts +1 -3
  60. package/dist/components/ui/spinner.d.ts.map +1 -1
  61. package/dist/components/ui/toast.d.ts +1 -1
  62. package/dist/components/ui/toast.d.ts.map +1 -1
  63. package/dist/{lib/format-expires-in.d.ts → hooks/use-share-expiry-label.d.ts} +1 -1
  64. package/dist/hooks/use-share-expiry-label.d.ts.map +1 -0
  65. package/dist/index.d.ts +3 -3
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1239 -838
  68. package/dist/index.js.map +1 -1
  69. package/dist/lib/toast-content.d.ts +19 -0
  70. package/dist/lib/toast-content.d.ts.map +1 -0
  71. package/package.json +8 -8
  72. package/dist/lib/format-expires-in.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use client";
2
- import { createContext, useContext, useMemo, useId, useRef, useCallback, useEffect, useState, useSyncExternalStore, useEffectEvent, useLayoutEffect } from 'react';
3
- import { truncateFileName, objectKeyOf, mergeUploadRequest } from '@dimah-s3/react/engine';
4
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
- import { CloudUpload, XIcon, RotateCwIcon, PauseIcon, BanIcon, FileUpIcon, CameraIcon, Trash2Icon, LoaderIcon, DownloadIcon, MoreHorizontalIcon, PencilIcon, LinkIcon, SearchIcon, HomeIcon, FolderIcon, FolderPlusIcon, CheckIcon, ArrowDownUpIcon, ListIcon, LayoutGridIcon, UserIcon, LoaderCircleIcon, AlertCircleIcon, CheckCircleIcon, MinusIcon, ChevronRightIcon, Loader2Icon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
2
+ import { createContext, memo, useId, useRef, useState, useEffect, useSyncExternalStore, useContext, useCallback, useMemo, useEffectEvent, useLayoutEffect } from 'react';
3
+ import { objectKeyOf, truncateFileName, mergeUploadRequest } from '@dimah-s3/react/engine';
4
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
+ import { CheckIcon, XIcon, MoreHorizontalIcon, Loader2Icon, CloudUpload, PencilIcon, LoaderIcon, DownloadIcon, LinkIcon, Trash2Icon, RotateCwIcon, PauseIcon, BanIcon, FileUpIcon, CameraIcon, SearchIcon, HomeIcon, FolderIcon, FolderPlusIcon, ArrowDownUpIcon, ListIcon, LayoutGridIcon, UserIcon, LoaderCircleIcon, AlertCircleIcon, CheckCircleIcon, ChevronRightIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
6
6
  import { useTranslations } from '@fuma-translate/react';
7
7
  import { cn } from 'cn';
8
8
  import { Button as Button$1 } from '@base-ui/react/button';
9
9
  import { cva } from 'class-variance-authority';
10
10
  import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
11
- import { useFormatNumber, useFormatDimahError, useFormatFileSize, useFormatEta, useFormatAcceptLabels, useObjectUrl, useFormatDate } from '@dimah-s3/react';
11
+ import { useFormatFileSize, useFormatDate, useFormatError, useFormatNumber, useFormatEta, useFormatAcceptLabels, useUploadLimit, useObjectUrl } from '@dimah-s3/react';
12
12
  import { mergeProps } from '@base-ui/react/merge-props';
13
13
  import { useRender } from '@base-ui/react/use-render';
14
14
  import { FileIcon, defaultStyles } from 'react-file-icon';
@@ -19,21 +19,49 @@ import { Checkbox as Checkbox$1 } from '@base-ui/react/checkbox';
19
19
  import { Menu } from '@base-ui/react/menu';
20
20
 
21
21
  // src/components/dimah-s3/upload/upload.tsx
22
+ function createObjectListEntryStore(initial) {
23
+ let state = initial;
24
+ const listeners2 = /* @__PURE__ */ new Set();
25
+ return {
26
+ get: () => state,
27
+ set(next) {
28
+ const merged = { ...state, ...next };
29
+ const keys = Object.keys(merged);
30
+ if (keys.every((key) => Object.is(merged[key], state[key]))) return;
31
+ state = merged;
32
+ for (const listener of listeners2) listener();
33
+ },
34
+ subscribe(listener) {
35
+ listeners2.add(listener);
36
+ return () => {
37
+ listeners2.delete(listener);
38
+ };
39
+ }
40
+ };
41
+ }
22
42
  var ObjectListContext = createContext(
23
43
  null
24
44
  );
45
+ var ObjectListEntryScopeContext = createContext(null);
25
46
  var ObjectListEntryContext = createContext(
26
47
  null
27
48
  );
28
49
  function ObjectListProvider({
29
50
  value,
51
+ scope,
30
52
  children
31
53
  }) {
32
54
  return /* @__PURE__ */ jsx(
33
55
  ObjectListContext.Provider,
34
56
  {
35
57
  value,
36
- children
58
+ children: /* @__PURE__ */ jsx(
59
+ ObjectListEntryScopeContext.Provider,
60
+ {
61
+ value: scope ?? null,
62
+ children
63
+ }
64
+ )
37
65
  }
38
66
  );
39
67
  }
@@ -58,6 +86,40 @@ function useOptionalObjectListContext() {
58
86
  function useObjectListEntry() {
59
87
  return useContext(ObjectListEntryContext);
60
88
  }
89
+ function useOptionalObjectListEntryScope() {
90
+ return useContext(
91
+ ObjectListEntryScopeContext
92
+ );
93
+ }
94
+ function useObjectListEntryScope() {
95
+ const scope = useOptionalObjectListEntryScope();
96
+ if (!scope) {
97
+ throw new Error(
98
+ "[dimah-s3] Object list parts must be rendered inside <ObjectList>."
99
+ );
100
+ }
101
+ return scope;
102
+ }
103
+ var SELECTED = 1;
104
+ var SELECTING = 2;
105
+ var RENAMING = 4;
106
+ var TAB_STOP = 8;
107
+ function useObjectListEntryStatus(key) {
108
+ const { store, selectable } = useObjectListEntryScope();
109
+ const read = () => entryFlags(store.get(), key);
110
+ const flags = useSyncExternalStore(store.subscribe, read, read);
111
+ const canSelect = selectable.has(key);
112
+ return {
113
+ selectable: canSelect,
114
+ selected: canSelect && (flags & SELECTED) !== 0,
115
+ selecting: (flags & SELECTING) !== 0,
116
+ renaming: (flags & RENAMING) !== 0,
117
+ tabStop: (flags & TAB_STOP) !== 0
118
+ };
119
+ }
120
+ function entryFlags(state, key) {
121
+ return (state.selected.has(key) ? SELECTED : 0) | (state.selecting ? SELECTING : 0) | (state.renaming === key ? RENAMING : 0) | (state.tabStop === key ? TAB_STOP : 0);
122
+ }
61
123
  var UploadContext = createContext(null);
62
124
  var INTAKE_ATTRIBUTE = "data-dimah-s3-upload-intake";
63
125
  var UploadFocusContext = createContext(null);
@@ -89,7 +151,7 @@ function Upload({
89
151
  if (handoff.from.isConnected && active === handoff.from) return;
90
152
  handoffRef.current = null;
91
153
  if (active instanceof HTMLElement && active !== document.body) return;
92
- handoffTarget(handoff, rootId)?.focus();
154
+ focusFirst(handoffTargets(handoff, rootId));
93
155
  });
94
156
  return /* @__PURE__ */ jsx(UploadContext.Provider, { value, children: /* @__PURE__ */ jsxs(UploadFocusContext.Provider, { value: focus, children: [
95
157
  /* @__PURE__ */ jsx("input", { ...upload.getInputProps() }),
@@ -139,7 +201,7 @@ function focusHandoff() {
139
201
  focusRoot: scope.closest(FOCUS_ROOT)
140
202
  };
141
203
  }
142
- function handoffTarget(handoff, rootId) {
204
+ function handoffTargets(handoff, rootId) {
143
205
  const intake = document.querySelectorAll(
144
206
  `[${INTAKE_ATTRIBUTE}="${CSS.escape(rootId)}"]`
145
207
  );
@@ -149,12 +211,15 @@ function handoffTarget(handoff, rootId) {
149
211
  ...handoff.scope.isConnected ? handoff.scope.querySelectorAll("button") : [],
150
212
  ...intake,
151
213
  handoff.focusRoot
152
- ].find(
153
- (element) => element != null && element.isConnected && isFocusable(element)
154
- ) ?? null;
214
+ ].filter(
215
+ (element) => element != null && element.isConnected
216
+ );
155
217
  }
156
- function isFocusable(element) {
157
- return !(element instanceof HTMLButtonElement && element.disabled);
218
+ function focusFirst(elements) {
219
+ for (const element of elements) {
220
+ element.focus();
221
+ if (document.activeElement === element) return;
222
+ }
158
223
  }
159
224
  function useUploadCall(upload, call) {
160
225
  const objectList = useOptionalObjectListContext();
@@ -631,64 +696,11 @@ function FileName({
631
696
  }
632
697
  );
633
698
  }
634
- var CURATED_EXTS = [
635
- // documents
636
- "pdf",
637
- "doc",
638
- "docx",
639
- "txt",
640
- "md",
641
- // sheets / slides
642
- "xls",
643
- "xlsx",
644
- "csv",
645
- "ppt",
646
- "pptx",
647
- // archives
648
- "zip",
649
- "rar",
650
- "7z",
651
- "tar",
652
- "gz",
653
- // audio / video
654
- "mp3",
655
- "wav",
656
- "m4a",
657
- "mp4",
658
- "mov",
659
- "webm",
660
- "mkv",
661
- // images
662
- "png",
663
- "jpg",
664
- "gif",
665
- "webp",
666
- "svg",
667
- "heic",
668
- // code / data
669
- "json",
670
- "js",
671
- "ts",
672
- "jsx",
673
- "html",
674
- "css"
675
- ];
676
- var CURATED = new Set(CURATED_EXTS);
677
- var EXT_ALIASES = {
678
- jpeg: "jpg",
679
- jpe: "jpg",
680
- "7zip": "7z",
681
- m4v: "mp4",
682
- aac: "m4a",
683
- flac: "mp3",
684
- ogg: "mp3",
685
- avi: "mp4",
686
- bmp: "png",
687
- tif: "png",
688
- tiff: "png"
689
- };
690
699
  var STYLE_ALIASES = {
691
- "7z": "7zip"
700
+ "7z": "7zip",
701
+ jpe: "jpg",
702
+ markdown: "md",
703
+ yaml: "yml"
692
704
  };
693
705
  var MIME_TO_EXT = {
694
706
  "application/pdf": "pdf",
@@ -708,8 +720,10 @@ var MIME_TO_EXT = {
708
720
  "application/gzip": "gz",
709
721
  "audio/mpeg": "mp3",
710
722
  "audio/wav": "wav",
723
+ "audio/flac": "flac",
724
+ "audio/ogg": "ogg",
711
725
  "audio/mp4": "m4a",
712
- "audio/aac": "m4a",
726
+ "audio/aac": "aac",
713
727
  "video/mp4": "mp4",
714
728
  "video/quicktime": "mov",
715
729
  "video/webm": "webm",
@@ -718,57 +732,41 @@ var MIME_TO_EXT = {
718
732
  "image/jpeg": "jpg",
719
733
  "image/gif": "gif",
720
734
  "image/webp": "webp",
735
+ "image/avif": "avif",
721
736
  "image/svg+xml": "svg",
722
737
  "image/heic": "heic",
738
+ "image/tiff": "tiff",
723
739
  "application/json": "json",
724
740
  "text/javascript": "js",
725
741
  "application/javascript": "js",
726
- "text/typescript": "ts",
727
- "application/typescript": "ts",
728
- "text/jsx": "jsx",
729
742
  "text/html": "html",
730
743
  "text/css": "css",
731
744
  "text/plain": "txt",
732
745
  "text/markdown": "md"
733
746
  };
747
+ function familyStyle(mime) {
748
+ if (mime.startsWith("image/")) return { type: "image" };
749
+ if (mime.startsWith("audio/")) return { type: "audio" };
750
+ if (mime.startsWith("video/")) return { type: "video" };
751
+ if (mime.startsWith("font/")) return { type: "font" };
752
+ if (mime.startsWith("text/")) return { type: "document" };
753
+ return null;
754
+ }
734
755
  function extensionOf(fileName) {
735
756
  const base = fileName.split(/[/\\]/).pop() ?? fileName;
736
757
  const dot = base.lastIndexOf(".");
737
758
  if (dot <= 0 || dot === base.length - 1) return null;
738
759
  return base.slice(dot + 1).toLowerCase();
739
760
  }
740
- function mimeFamilyExt(mime) {
741
- if (mime.startsWith("image/")) return "png";
742
- if (mime.startsWith("audio/")) return "mp3";
743
- if (mime.startsWith("video/")) return "mp4";
744
- if (mime.startsWith("text/")) return "txt";
745
- return null;
746
- }
747
- function normalizeExt(ext) {
748
- if (CURATED.has(ext)) return ext;
749
- const aliased = EXT_ALIASES[ext];
750
- if (aliased && CURATED.has(aliased)) return aliased;
751
- return null;
761
+ function stylesOf(ext) {
762
+ return defaultStyles[STYLE_ALIASES[ext] ?? ext] ?? null;
752
763
  }
753
- function resolveFileTypeExtension(fileName, contentType) {
754
- const mime = contentType?.trim().toLowerCase();
755
- if (mime) {
756
- const fromMime = MIME_TO_EXT[mime];
757
- if (fromMime) return fromMime;
758
- const family = mimeFamilyExt(mime);
759
- if (family) return family;
760
- }
764
+ function resolveFileTypeGlyph(fileName, contentType) {
765
+ const mime = contentType?.trim().toLowerCase() ?? "";
761
766
  const ext = extensionOf(fileName);
762
- if (!ext) return null;
763
- return normalizeExt(ext);
764
- }
765
- function stylesFor(ext) {
766
- const key = STYLE_ALIASES[ext] ?? ext;
767
- const fromDefaults = defaultStyles[key];
768
- if (fromDefaults) return fromDefaults;
769
- if (ext === "heic") return { type: "image" };
770
- if (ext === "7z") return { type: "compressed" };
771
- return {};
767
+ const mimeExt = MIME_TO_EXT[mime] ?? null;
768
+ const styles = (mimeExt ? stylesOf(mimeExt) : null) ?? (ext ? stylesOf(ext) : null) ?? familyStyle(mime) ?? { type: "document" };
769
+ return { label: mimeExt ?? ext, styles };
772
770
  }
773
771
  function FileTypeGlyph({
774
772
  fileName,
@@ -776,9 +774,7 @@ function FileTypeGlyph({
776
774
  layout = "fill",
777
775
  className
778
776
  }) {
779
- const ext = resolveFileTypeExtension(fileName, contentType);
780
- const label = ext ?? extensionOf(fileName) ?? void 0;
781
- const styles = ext ? stylesFor(ext) : { type: "document" };
777
+ const { label, styles } = resolveFileTypeGlyph(fileName, contentType);
782
778
  return /* @__PURE__ */ jsx(
783
779
  "span",
784
780
  {
@@ -788,7 +784,7 @@ function FileTypeGlyph({
788
784
  className
789
785
  ),
790
786
  "aria-hidden": true,
791
- children: /* @__PURE__ */ jsx(FileIcon, { extension: label, ...styles })
787
+ children: /* @__PURE__ */ jsx(FileIcon, { extension: label ?? void 0, ...styles })
792
788
  }
793
789
  );
794
790
  }
@@ -803,6 +799,7 @@ function FileAttachment({
803
799
  error,
804
800
  onCancel,
805
801
  onRetry,
802
+ retryDisabled = false,
806
803
  onDismiss,
807
804
  actions,
808
805
  trigger,
@@ -810,12 +807,13 @@ function FileAttachment({
810
807
  ...props
811
808
  }) {
812
809
  const t = useTranslations();
813
- const formatError = useFormatDimahError();
810
+ const formatError = useFormatError();
814
811
  const formatFileSize = useFormatFileSize();
815
812
  const errorText = error == null ? null : typeof error === "string" ? error : formatError(error);
816
- const resolvedDescription = description ?? (state === "error" ? errorText ?? t("Upload failed", { note: "status" }) : fileSize != null ? formatFileSize(fileSize) : null);
813
+ const resolvedDescription = description ?? (state === "error" ? errorText ?? t("Failed", { note: "status" }) : fileSize != null ? formatFileSize(fileSize) : null);
817
814
  const showCancel = (state === "idle" || state === "uploading" || state === "processing") && onCancel != null;
818
815
  const showRetry = state === "error" && onRetry != null;
816
+ const retryUnavailable = showRetry && !showCancel && retryDisabled;
819
817
  const showDismiss = (state === "done" || state === "error") && onDismiss != null;
820
818
  const mediaOverlay = state === "idle" || state === "uploading" ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-dimah-s3-background/60", children: /* @__PURE__ */ jsx(
821
819
  CircleProgress,
@@ -871,6 +869,9 @@ function FileAttachment({
871
869
  AttachmentAction,
872
870
  {
873
871
  type: "button",
872
+ disabled: retryUnavailable,
873
+ focusableWhenDisabled: retryUnavailable,
874
+ className: "aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
874
875
  "aria-label": showCancel ? t("Cancel {name}", {
875
876
  note: "attachment action",
876
877
  variables: { name: fileName }
@@ -909,7 +910,7 @@ function UploadFileItem({
909
910
  const t = useTranslations();
910
911
  const formatEta = useFormatEta();
911
912
  const formatFileSize = useFormatFileSize();
912
- const { upload } = useUploadContext();
913
+ const { upload, isFull } = useUploadContext();
913
914
  const { keepFocus } = useUploadFocus();
914
915
  const eta = file.phase === "uploading" ? formatEta(file.progress) : null;
915
916
  const phaseDescription = file.phase === "preparing" || file.phase === "presigning" ? t("Preparing\u2026", { note: "upload status" }) : file.phase === "finalizing" ? t("Finishing\u2026", { note: "upload status" }) : eta ? `${formatFileSize(file.fileSize)} \xB7 ${eta}` : void 0;
@@ -929,6 +930,7 @@ function UploadFileItem({
929
930
  upload.cancel(file.id);
930
931
  },
931
932
  onRetry: () => void upload.retry(file.id),
933
+ retryDisabled: isFull,
932
934
  ...props
933
935
  }
934
936
  );
@@ -1022,7 +1024,7 @@ function UploadStatus({
1022
1024
  state: "processing",
1023
1025
  title: t("Preparing\u2026", { note: "upload status" })
1024
1026
  }
1025
- ) : files.length === 1 && layout === "list" ? /* @__PURE__ */ jsx(UploadFileItem, { file: files[0], actions: pause, onDismiss }) : /* @__PURE__ */ jsxs(
1027
+ ) : shown.length === 1 && layout === "list" ? /* @__PURE__ */ jsx(UploadFileItem, { file: shown[0], actions: pause, onDismiss }) : /* @__PURE__ */ jsxs(
1026
1028
  "div",
1027
1029
  {
1028
1030
  "data-slot": "upload-status-panel",
@@ -1051,16 +1053,27 @@ function UploadSummary({
1051
1053
  onDismiss
1052
1054
  }) {
1053
1055
  const t = useTranslations();
1054
- const formatError = useFormatDimahError();
1056
+ const formatError = useFormatError();
1055
1057
  const formatEta = useFormatEta();
1056
1058
  const formatFileSize = useFormatFileSize();
1057
1059
  const formatNumber = useFormatNumber();
1058
- const { upload } = useUploadContext();
1060
+ const { upload, isFull } = useUploadContext();
1059
1061
  const { keepFocus } = useUploadFocus();
1060
1062
  const { files, progress } = upload;
1061
- const summaryActions = (label, icon, onClick) => /* @__PURE__ */ jsxs(Fragment, { children: [
1063
+ const summaryActions = (label, icon, onClick, disabled = false) => /* @__PURE__ */ jsxs(Fragment, { children: [
1062
1064
  pause,
1063
- /* @__PURE__ */ jsx(AttachmentAction, { type: "button", "aria-label": label, onClick, children: icon })
1065
+ /* @__PURE__ */ jsx(
1066
+ AttachmentAction,
1067
+ {
1068
+ type: "button",
1069
+ "aria-label": label,
1070
+ disabled,
1071
+ focusableWhenDisabled: disabled,
1072
+ className: "aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
1073
+ onClick,
1074
+ children: icon
1075
+ }
1076
+ )
1064
1077
  ] });
1065
1078
  if (upload.phase === "success") {
1066
1079
  return /* @__PURE__ */ jsx(
@@ -1090,7 +1103,8 @@ function UploadSummary({
1090
1103
  actions: summaryActions(
1091
1104
  t("Retry failed uploads", { note: "upload control" }),
1092
1105
  /* @__PURE__ */ jsx(RotateCwIcon, {}),
1093
- () => void upload.retry()
1106
+ () => void upload.retry(),
1107
+ isFull
1094
1108
  ),
1095
1109
  onDismiss
1096
1110
  }
@@ -1327,7 +1341,7 @@ function UploadDropzoneTrigger({
1327
1341
  "flex size-10 shrink-0 items-center justify-center rounded-full border border-dimah-s3-border bg-dimah-s3-card text-dimah-s3-muted-foreground shadow-xs transition-colors",
1328
1342
  dragActive && (dragReject ? "border-dimah-s3-destructive/30 bg-dimah-s3-destructive/10 text-dimah-s3-destructive" : "border-dimah-s3-primary/30 bg-dimah-s3-primary/10 text-dimah-s3-primary")
1329
1343
  ),
1330
- children: /* @__PURE__ */ jsx(Icon, { className: "size-5", strokeWidth: 1.75 })
1344
+ children: /* @__PURE__ */ jsx(Icon, { className: "pointer-events-none size-5", strokeWidth: 1.75 })
1331
1345
  }
1332
1346
  ),
1333
1347
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
@@ -1577,6 +1591,29 @@ function useToastOwner(instanceId, options = {}) {
1577
1591
  () => false
1578
1592
  );
1579
1593
  }
1594
+ function ToastText({ children }) {
1595
+ return /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children });
1596
+ }
1597
+ function ToastNumbers({ children }) {
1598
+ return /* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children });
1599
+ }
1600
+ function ToastFile({
1601
+ name,
1602
+ detail,
1603
+ error
1604
+ }) {
1605
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1606
+ /* @__PURE__ */ jsxs("span", { className: "block", children: [
1607
+ /* @__PURE__ */ jsx(FileName, { name }),
1608
+ detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
1609
+ " ",
1610
+ "\xB7 ",
1611
+ /* @__PURE__ */ jsx(ToastNumbers, { children: detail })
1612
+ ] }) : null
1613
+ ] }),
1614
+ error ? /* @__PURE__ */ jsx(ToastText, { children: error }) : null
1615
+ ] });
1616
+ }
1580
1617
  function UploadToasts({ upload }) {
1581
1618
  const active = useToastOwner(upload.instanceId);
1582
1619
  return active ? /* @__PURE__ */ jsx(ActiveUploadToasts, { upload }) : null;
@@ -1585,15 +1622,12 @@ function BuiltInUploadToasts({ upload }) {
1585
1622
  const active = useToastOwner(upload.instanceId, { weak: true });
1586
1623
  return active ? /* @__PURE__ */ jsx(ActiveUploadToasts, { upload }) : null;
1587
1624
  }
1588
- function numbers(text) {
1589
- return /* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children: text });
1590
- }
1591
1625
  function isSettled(file) {
1592
1626
  return file.phase === "success" || file.phase === "error";
1593
1627
  }
1594
1628
  function ActiveUploadToasts({ upload }) {
1595
1629
  const t = useTranslations();
1596
- const formatError = useFormatDimahError();
1630
+ const formatError = useFormatError();
1597
1631
  const formatFileSize = useFormatFileSize();
1598
1632
  const formatNumber = useFormatNumber();
1599
1633
  const { files, isPending, progress, fileRejections } = upload;
@@ -1631,9 +1665,13 @@ function ActiveUploadToasts({ upload }) {
1631
1665
  total: formatNumber(files.length)
1632
1666
  }
1633
1667
  }) : t("Uploading", { note: "toast" }),
1634
- description: numbers(
1635
- `${formatFileSize(progress.loaded)} / ${formatFileSize(progress.total)}`
1636
- ),
1668
+ description: /* @__PURE__ */ jsx(ToastNumbers, { children: t("{loaded} of {total}", {
1669
+ note: "transfer progress",
1670
+ variables: {
1671
+ loaded: formatFileSize(progress.loaded),
1672
+ total: formatFileSize(progress.total)
1673
+ }
1674
+ }) }),
1637
1675
  actionProps: {
1638
1676
  children: t("Cancel", { note: "toast action" }),
1639
1677
  onClick: () => actionsRef.current.cancel()
@@ -1666,11 +1704,23 @@ function ActiveUploadToasts({ upload }) {
1666
1704
  failed.length === 0 ? {
1667
1705
  type: "success",
1668
1706
  title: t("Upload complete", { note: "toast" }),
1669
- description: numbers(formatFileSize(first.fileSize))
1707
+ description: /* @__PURE__ */ jsx(
1708
+ ToastFile,
1709
+ {
1710
+ name: first.fileName,
1711
+ detail: formatFileSize(first.fileSize)
1712
+ }
1713
+ )
1670
1714
  } : {
1671
1715
  type: "error",
1672
1716
  title: t("Upload failed", { note: "toast" }),
1673
- description: wrapText(formatError(first.error)),
1717
+ description: /* @__PURE__ */ jsx(
1718
+ ToastFile,
1719
+ {
1720
+ name: first.fileName,
1721
+ error: formatError(first.error)
1722
+ }
1723
+ ),
1674
1724
  actionProps: retryAction(first.id)
1675
1725
  }
1676
1726
  );
@@ -1683,11 +1733,9 @@ function ActiveUploadToasts({ upload }) {
1683
1733
  note: "toast",
1684
1734
  variables: { count: formatNumber(fresh.length) }
1685
1735
  }),
1686
- description: numbers(
1687
- formatFileSize(
1688
- fresh.reduce((total, file) => total + file.fileSize, 0)
1689
- )
1690
- )
1736
+ description: /* @__PURE__ */ jsx(ToastNumbers, { children: formatFileSize(
1737
+ fresh.reduce((total, file) => total + file.fileSize, 0)
1738
+ ) })
1691
1739
  } : {
1692
1740
  type: "error",
1693
1741
  title: t("Upload finished with errors", { note: "toast" }),
@@ -1723,13 +1771,7 @@ function ActiveUploadToasts({ upload }) {
1723
1771
  fileRejections.length === 1 ? {
1724
1772
  type: "error",
1725
1773
  title: t("File not accepted", { note: "toast" }),
1726
- description: wrapText(
1727
- /* @__PURE__ */ jsxs(Fragment, { children: [
1728
- /* @__PURE__ */ jsx("bdi", { children: first.file.name }),
1729
- ": ",
1730
- reason
1731
- ] })
1732
- )
1774
+ description: /* @__PURE__ */ jsx(ToastFile, { name: first.file.name, error: reason })
1733
1775
  } : {
1734
1776
  type: "error",
1735
1777
  title: t("{count} files were rejected", {
@@ -1737,15 +1779,12 @@ function ActiveUploadToasts({ upload }) {
1737
1779
  variables: { count: formatNumber(fileRejections.length) }
1738
1780
  }),
1739
1781
  // One shared reason is worth showing; a mix of reasons is not.
1740
- description: reasons.size === 1 ? wrapText(reason) : void 0
1782
+ description: reasons.size === 1 ? /* @__PURE__ */ jsx(ToastText, { children: reason }) : void 0
1741
1783
  }
1742
1784
  );
1743
1785
  }, [fileRejections, t, formatError, formatNumber]);
1744
1786
  return null;
1745
1787
  }
1746
- function wrapText(content) {
1747
- return /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: content });
1748
- }
1749
1788
 
1750
1789
  // src/lib/is-field-target.ts
1751
1790
  function isFieldTarget(target) {
@@ -1875,13 +1914,14 @@ function UploadField({
1875
1914
  (key) => setValue(value.filter((item) => item !== key)),
1876
1915
  [setValue, value]
1877
1916
  );
1878
- const inFlight = upload.files.filter(
1879
- (file) => file.phase !== "success" && file.phase !== "error" && !seen.has(file.id)
1880
- ).length;
1881
- const remaining = maxFiles == null ? null : Math.max(0, maxFiles - value.length - inFlight);
1917
+ const remaining = useUploadLimit(
1918
+ upload,
1919
+ maxFiles == null ? null : { available: Math.max(0, maxFiles - value.length), counted: seen }
1920
+ );
1921
+ const isFull = remaining === 0;
1882
1922
  const fieldUpload = useMemo(
1883
- () => remaining == null ? upload : capUpload(upload, remaining),
1884
- [remaining, upload]
1923
+ () => fieldUploadOf(upload, isFull),
1924
+ [isFull, upload]
1885
1925
  );
1886
1926
  const contextValue = useMemo(
1887
1927
  () => ({
@@ -1904,7 +1944,7 @@ function UploadField({
1904
1944
  return /* @__PURE__ */ jsxs(UploadFieldContext.Provider, { value: contextValue, children: [
1905
1945
  /* @__PURE__ */ jsx("input", { ref: anchorRef, type: "hidden" }),
1906
1946
  value.map((key) => /* @__PURE__ */ jsx("input", { type: "hidden", name, value: key }, key)),
1907
- /* @__PURE__ */ jsx(Upload, { upload: fieldUpload, isFull: remaining === 0, hideUploaded: true, children })
1947
+ /* @__PURE__ */ jsx(Upload, { upload: fieldUpload, isFull, hideUploaded: true, children })
1908
1948
  ] });
1909
1949
  }
1910
1950
  function useUploadFieldContext() {
@@ -1975,51 +2015,27 @@ function withDetails(details, uploaded) {
1975
2015
  }
1976
2016
  return next;
1977
2017
  }
1978
- function emptyBatch() {
1979
- return Promise.resolve({
1980
- uploaded: [],
1981
- failed: [],
1982
- blocked: [],
1983
- aborted: []
1984
- });
1985
- }
1986
- function retryFitting(upload, remaining) {
1987
- const failed = upload.files.filter((file) => file.phase === "error");
1988
- if (failed.length <= remaining) return upload.retry();
1989
- return Promise.all(
1990
- failed.slice(0, remaining).map((file) => upload.retry(file.id))
1991
- ).then((results) => ({
1992
- uploaded: results.flatMap((result) => result.uploaded),
1993
- failed: results.flatMap((result) => result.failed),
1994
- blocked: results.flatMap((result) => result.blocked),
1995
- aborted: results.flatMap((result) => result.aborted)
1996
- }));
1997
- }
1998
- function capUpload(upload, remaining) {
1999
- if (remaining === 0) {
2000
- return {
2001
- ...upload,
2002
- handleFiles: emptyBatch,
2003
- retry: emptyBatch,
2004
- open: () => {
2005
- },
2006
- // Not `upload.getRootProps`: that would wire the uncapped intake back.
2007
- getRootProps: (props) => ({ tabIndex: 0, ...props, "aria-disabled": true }),
2008
- getDropTargetProps: (props) => ({ ...props })
2009
- };
2010
- }
2011
- const cap = (call) => ({
2018
+ function fieldUploadOf(upload, isFull) {
2019
+ const queued = (call) => ({
2012
2020
  ...call,
2013
- maxFiles: Math.min(call?.maxFiles ?? remaining, remaining)
2021
+ queue: true
2014
2022
  });
2015
- const capInput = (call) => typeof call === "function" ? () => cap(call()) : cap(call);
2016
- return {
2023
+ const queuedInput = (call) => typeof call === "function" ? () => queued(call()) : queued(call);
2024
+ const fieldUpload = {
2017
2025
  ...upload,
2018
- handleFiles: (files, call) => upload.handleFiles(files, cap(call)),
2019
- retry: (id) => id === void 0 ? retryFitting(upload, remaining) : upload.retry(id),
2020
- open: (call) => upload.open(cap(call)),
2021
- getRootProps: (props, call) => upload.getRootProps(props, capInput(call)),
2022
- getDropTargetProps: (props, call) => upload.getDropTargetProps(props, capInput(call))
2026
+ handleFiles: (files, call) => upload.handleFiles(files, queued(call)),
2027
+ open: (call) => upload.open(queued(call)),
2028
+ getRootProps: (props, call) => upload.getRootProps(props, queuedInput(call)),
2029
+ getDropTargetProps: (props, call) => upload.getDropTargetProps(props, queuedInput(call))
2030
+ };
2031
+ if (!isFull) return fieldUpload;
2032
+ return {
2033
+ ...fieldUpload,
2034
+ open: () => {
2035
+ },
2036
+ // Not `upload.getRootProps`: its handlers would open the picker.
2037
+ getRootProps: (props) => ({ tabIndex: 0, ...props, "aria-disabled": true }),
2038
+ getDropTargetProps: (props) => ({ ...props })
2023
2039
  };
2024
2040
  }
2025
2041
  function ObjectImage({
@@ -2029,11 +2045,12 @@ function ObjectImage({
2029
2045
  api,
2030
2046
  fallback = null,
2031
2047
  onError,
2048
+ onLoad,
2032
2049
  ...props
2033
2050
  }) {
2034
- const { url } = useObjectUrl({ api, route, objectKey });
2035
- const [brokenUrl, setBrokenUrl] = useState(null);
2036
- if (url == null || url === brokenUrl) return fallback;
2051
+ const { url, refresh } = useObjectUrl({ api, route, objectKey });
2052
+ const [failure, setFailure] = useState(null);
2053
+ if (url == null || failure?.url === url) return fallback;
2037
2054
  return /* @__PURE__ */ jsx(
2038
2055
  "img",
2039
2056
  {
@@ -2041,9 +2058,15 @@ function ObjectImage({
2041
2058
  ...props,
2042
2059
  src: url,
2043
2060
  alt,
2061
+ onLoad: (event) => {
2062
+ if (failure) setFailure(null);
2063
+ onLoad?.(event);
2064
+ },
2044
2065
  onError: (event) => {
2045
- setBrokenUrl(url);
2046
2066
  onError?.(event);
2067
+ const retried = failure?.objectKey === objectKey && failure.retried;
2068
+ setFailure({ objectKey, url, retried: true });
2069
+ if (!retried) refresh();
2047
2070
  }
2048
2071
  }
2049
2072
  );
@@ -2071,7 +2094,12 @@ function AvatarUpload({
2071
2094
  }) {
2072
2095
  const { file } = upload;
2073
2096
  const inFlight = file != null && IN_FLIGHT.has(file.phase);
2074
- const previewUrl = file?.phase === "error" ? null : file?.previewUrl ?? null;
2097
+ const [uploaded, setUploaded] = useState(null);
2098
+ if (file?.phase === "success" && uploaded?.id !== file.id) {
2099
+ setUploaded({ id: file.id, objectKey });
2100
+ }
2101
+ const previewCurrent = file?.phase === "success" && (uploaded?.id !== file.id || objectKey === uploaded.objectKey || objectKey === file.result?.key);
2102
+ const previewUrl = inFlight || previewCurrent ? file?.previewUrl ?? null : null;
2075
2103
  const announcement = useAnnouncement(upload);
2076
2104
  const reportUploaded = useEffectEvent((result) => {
2077
2105
  onChange?.(result);
@@ -2158,7 +2186,7 @@ function AvatarUpload({
2158
2186
  }
2159
2187
  function useAnnouncement(upload) {
2160
2188
  const t = useTranslations();
2161
- const formatError = useFormatDimahError();
2189
+ const formatError = useFormatError();
2162
2190
  const rejection = upload.fileRejections[0]?.errors[0];
2163
2191
  if (rejection) return formatError(rejection);
2164
2192
  const { file } = upload;
@@ -2340,26 +2368,24 @@ function DeleteConfirmDialog({
2340
2368
  const t = useTranslations();
2341
2369
  const formatFileSize = useFormatFileSize();
2342
2370
  const formatNumber = useFormatNumber();
2343
- const { pending, confirm, cancel } = useDeleteContext();
2371
+ const {
2372
+ confirmation,
2373
+ isDeleting: busy,
2374
+ confirm,
2375
+ dismiss
2376
+ } = useDeleteContext();
2344
2377
  const cancelRef = useRef(null);
2345
- const [busy, setBusy] = useState(false);
2346
- const [shown, setShown] = useState(pending);
2347
- if (pending && pending !== shown) setShown(pending);
2348
- const current = pending ?? shown;
2378
+ const [shown, setShown] = useState(confirmation);
2379
+ if (confirmation && confirmation !== shown) setShown(confirmation);
2380
+ const current = confirmation ?? shown;
2349
2381
  const targets = current?.targets ?? [];
2350
2382
  const single = targets.length === 1 ? targets[0] : void 0;
2351
- function onConfirm() {
2352
- setBusy(true);
2353
- void confirm().finally(() => {
2354
- setBusy(false);
2355
- });
2356
- }
2357
2383
  return /* @__PURE__ */ jsx(
2358
2384
  AlertDialog,
2359
2385
  {
2360
- open: pending != null,
2386
+ open: confirmation != null,
2361
2387
  onOpenChange: (open) => {
2362
- if (!open) cancel();
2388
+ if (!open) dismiss();
2363
2389
  },
2364
2390
  children: /* @__PURE__ */ jsxs(AlertDialogContent, { initialFocus: cancelRef, finalFocus: false, children: [
2365
2391
  /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
@@ -2397,7 +2423,7 @@ function DeleteConfirmDialog({
2397
2423
  disabled: busy,
2398
2424
  focusableWhenDisabled: true,
2399
2425
  "aria-busy": busy || void 0,
2400
- onClick: onConfirm,
2426
+ onClick: () => void confirm(),
2401
2427
  children: [
2402
2428
  busy ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : null,
2403
2429
  confirmLabel ?? t("Delete", { note: "dialog confirm" })
@@ -2418,6 +2444,7 @@ function fileLabel(target, formatFileSize) {
2418
2444
  return target.fileSize != null ? `${name} (${isolateText(formatFileSize(target.fileSize))})` : name;
2419
2445
  }
2420
2446
  var FOCUS_ROOT2 = "[data-dimah-s3-focus-root]";
2447
+ var EMPTY_RESULT = { deleted: [], failed: [], blocked: [] };
2421
2448
  var DeleteContext = createContext(null);
2422
2449
  function Delete({
2423
2450
  delete: del,
@@ -2428,6 +2455,7 @@ function Delete({
2428
2455
  children
2429
2456
  }) {
2430
2457
  const [active, setActive] = useState(null);
2458
+ const [isDeleting, setDeleting] = useState(false);
2431
2459
  const [focusReturn, setFocusReturn] = useState(null);
2432
2460
  const activeRef = useRef(null);
2433
2461
  const runningRef = useRef(null);
@@ -2437,13 +2465,25 @@ function Delete({
2437
2465
  });
2438
2466
  const removeTargets = useCallback(
2439
2467
  async (request2) => {
2440
- const result = await latest.current.del.removeMany(
2441
- request2.targets.map(({ objectKey, fileName }) => ({
2442
- key: objectKey,
2443
- fileName
2444
- }))
2445
- );
2446
- latest.current.onDeleted?.(result);
2468
+ let result;
2469
+ try {
2470
+ result = await latest.current.del.removeMany(
2471
+ request2.targets.map(({ objectKey, fileName }) => ({
2472
+ key: objectKey,
2473
+ fileName
2474
+ }))
2475
+ );
2476
+ } catch (error) {
2477
+ reportError(error);
2478
+ return EMPTY_RESULT;
2479
+ }
2480
+ for (const onDeleted2 of [latest.current.onDeleted, request2.onDeleted]) {
2481
+ try {
2482
+ onDeleted2?.(result);
2483
+ } catch (error) {
2484
+ reportError(error);
2485
+ }
2486
+ }
2447
2487
  return result;
2448
2488
  },
2449
2489
  []
@@ -2462,6 +2502,7 @@ function Delete({
2462
2502
  const next = {
2463
2503
  targets,
2464
2504
  note: options.note,
2505
+ onDeleted: options.onDeleted,
2465
2506
  trigger,
2466
2507
  focusRoot: trigger?.closest(FOCUS_ROOT2) ?? null
2467
2508
  };
@@ -2470,7 +2511,7 @@ function Delete({
2470
2511
  setActive(next);
2471
2512
  return;
2472
2513
  }
2473
- void removeTargets(next).finally(() => {
2514
+ void removeTargets(next).then(() => {
2474
2515
  setFocusReturn({ ...next, always: false });
2475
2516
  });
2476
2517
  },
@@ -2479,17 +2520,18 @@ function Delete({
2479
2520
  const confirm = useCallback(() => {
2480
2521
  if (runningRef.current) return runningRef.current;
2481
2522
  const current = activeRef.current;
2482
- if (!current) {
2483
- return Promise.resolve({ deleted: [], failed: [], blocked: [] });
2484
- }
2485
- const running = removeTargets(current).finally(() => {
2523
+ if (!current) return Promise.resolve(EMPTY_RESULT);
2524
+ setDeleting(true);
2525
+ const running = removeTargets(current).then((result) => {
2486
2526
  runningRef.current = null;
2527
+ setDeleting(false);
2487
2528
  close(current);
2529
+ return result;
2488
2530
  });
2489
2531
  runningRef.current = running;
2490
2532
  return running;
2491
2533
  }, [close, removeTargets]);
2492
- const cancel = useCallback(() => {
2534
+ const dismiss = useCallback(() => {
2493
2535
  if (runningRef.current || !activeRef.current) return;
2494
2536
  close(activeRef.current);
2495
2537
  }, [close]);
@@ -2502,13 +2544,20 @@ function Delete({
2502
2544
  ].find((element) => element?.isConnected);
2503
2545
  target?.focus();
2504
2546
  }, [focusReturn]);
2505
- const pending = useMemo(
2547
+ const confirmation = useMemo(
2506
2548
  () => active ? { targets: active.targets, note: active.note } : null,
2507
2549
  [active]
2508
2550
  );
2509
2551
  const value = useMemo(
2510
- () => ({ delete: del, pending, request, confirm, cancel }),
2511
- [del, pending, request, confirm, cancel]
2552
+ () => ({
2553
+ delete: del,
2554
+ confirmation,
2555
+ isDeleting,
2556
+ request,
2557
+ confirm,
2558
+ dismiss
2559
+ }),
2560
+ [del, confirmation, isDeleting, request, confirm, dismiss]
2512
2561
  );
2513
2562
  return /* @__PURE__ */ jsxs(DeleteContext.Provider, { value, children: [
2514
2563
  children,
@@ -2527,6 +2576,13 @@ function useDeleteContext() {
2527
2576
  function isTargetList(input) {
2528
2577
  return Array.isArray(input);
2529
2578
  }
2579
+ function reportError(error) {
2580
+ if (typeof globalThis.reportError === "function") {
2581
+ globalThis.reportError(error);
2582
+ } else {
2583
+ console.error(error);
2584
+ }
2585
+ }
2530
2586
  function focusedElement() {
2531
2587
  const element = document.activeElement;
2532
2588
  return element instanceof HTMLElement && element !== document.body ? element : null;
@@ -2541,6 +2597,7 @@ function DeleteTrigger({
2541
2597
  note,
2542
2598
  tooltip,
2543
2599
  variant = "destructive",
2600
+ size,
2544
2601
  disabled,
2545
2602
  focusableWhenDisabled,
2546
2603
  onClick,
@@ -2549,14 +2606,18 @@ function DeleteTrigger({
2549
2606
  }) {
2550
2607
  const t = useTranslations();
2551
2608
  const { delete: del, request } = useDeleteContext();
2552
- const deleting = del.get(objectKey)?.phase === "deleting";
2609
+ const deleting = del.pendingKeys.includes(objectKey);
2610
+ const iconOnly = size?.startsWith("icon") ?? false;
2611
+ const icon = deleting ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : /* @__PURE__ */ jsx(Trash2Icon, { "data-icon": "inline-start" });
2553
2612
  const button = /* @__PURE__ */ jsx(
2554
2613
  Button,
2555
2614
  {
2556
2615
  "data-slot": "delete-trigger",
2616
+ "data-phase": del.get(objectKey)?.phase,
2557
2617
  "aria-busy": deleting || void 0,
2558
- ...props,
2559
2618
  variant,
2619
+ size,
2620
+ ...props,
2560
2621
  disabled: Boolean(disabled) || deleting,
2561
2622
  focusableWhenDisabled: focusableWhenDisabled ?? deleting,
2562
2623
  onClick: (event) => {
@@ -2567,10 +2628,10 @@ function DeleteTrigger({
2567
2628
  { note, trigger: event.currentTarget }
2568
2629
  );
2569
2630
  },
2570
- children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
2571
- deleting ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : /* @__PURE__ */ jsx(Trash2Icon, { "data-icon": "inline-start" }),
2631
+ children: children ?? (iconOnly ? icon : /* @__PURE__ */ jsxs(Fragment, { children: [
2632
+ icon,
2572
2633
  t("Delete", { note: "button" })
2573
- ] })
2634
+ ] }))
2574
2635
  }
2575
2636
  );
2576
2637
  if (tooltip == null) return button;
@@ -2606,7 +2667,7 @@ function useFormatDownloadedBytes() {
2606
2667
  ({ loaded, total }) => {
2607
2668
  if (total > 0) {
2608
2669
  return t("{loaded} of {total}", {
2609
- note: "download progress",
2670
+ note: "transfer progress",
2610
2671
  variables: {
2611
2672
  loaded: formatFileSize(loaded),
2612
2673
  total: formatFileSize(total)
@@ -2642,17 +2703,23 @@ function DownloadTrigger({
2642
2703
  const progress = cancellable && operation?.phase === "downloading" ? operation.progress : null;
2643
2704
  const fillPercent = progress && progress.total > 0 ? Math.min(100, Math.max(0, progress.percent)) : null;
2644
2705
  const iconOnly = size?.startsWith("icon") ?? false;
2645
- const content = cancellable ? iconOnly ? /* @__PURE__ */ jsx(XIcon, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
2706
+ const withLabel = (icon, label) => iconOnly ? icon : /* @__PURE__ */ jsxs(Fragment, { children: [
2707
+ icon,
2708
+ label
2709
+ ] });
2710
+ const content = cancellable ? withLabel(
2646
2711
  /* @__PURE__ */ jsx(XIcon, { "data-icon": "inline-start" }),
2647
2712
  t("Cancel", { note: "download control" })
2648
- ] }) : children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
2713
+ ) : children ?? withLabel(
2649
2714
  signing ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : /* @__PURE__ */ jsx(DownloadIcon, { "data-icon": "inline-start" }),
2650
2715
  t("Download", { note: "button" })
2651
- ] });
2716
+ );
2652
2717
  const button = /* @__PURE__ */ jsxs(
2653
2718
  Button,
2654
2719
  {
2655
2720
  "data-slot": "download-trigger",
2721
+ "data-phase": operation?.phase,
2722
+ "aria-busy": signing || void 0,
2656
2723
  variant,
2657
2724
  size,
2658
2725
  ...props,
@@ -2662,10 +2729,8 @@ function DownloadTrigger({
2662
2729
  name: fileName ?? fileNameFromKey(objectKey) ?? objectKey
2663
2730
  }
2664
2731
  }) : ariaLabel,
2665
- "aria-busy": signing || void 0,
2666
- "data-phase": operation?.phase,
2667
2732
  disabled: Boolean(disabled) || signing,
2668
- focusableWhenDisabled: Boolean(focusableWhenDisabled) || signing,
2733
+ focusableWhenDisabled: focusableWhenDisabled ?? signing,
2669
2734
  className: cn("relative isolate overflow-hidden", className),
2670
2735
  onClick: (event) => {
2671
2736
  onClick?.(event);
@@ -2719,7 +2784,7 @@ function ObjectCard({
2719
2784
  const name = fileName ?? fileNameFromKey(objectKey) ?? objectKey;
2720
2785
  const operation = download?.mode === "fetch" ? download.get(objectKey) : void 0;
2721
2786
  const downloading = operation != null && isDownloadRunning(operation);
2722
- const deleting = del?.get(objectKey)?.phase === "deleting";
2787
+ const deleting = del?.pendingKeys.includes(objectKey) ?? false;
2723
2788
  const state = deleting ? "processing" : downloading ? "uploading" : "done";
2724
2789
  const percent = downloading && operation.phase === "downloading" && operation.progress.total > 0 ? operation.progress.percent : 0;
2725
2790
  let card = /* @__PURE__ */ jsx(
@@ -2744,8 +2809,7 @@ function ObjectCard({
2744
2809
  note: "attachment action",
2745
2810
  variables: { name }
2746
2811
  }),
2747
- tooltip: t("Download", { note: "button" }),
2748
- children: /* @__PURE__ */ jsx(DownloadIcon, {})
2812
+ tooltip: t("Download", { note: "button" })
2749
2813
  }
2750
2814
  ) : null,
2751
2815
  del ? /* @__PURE__ */ jsx(
@@ -2761,8 +2825,7 @@ function ObjectCard({
2761
2825
  note: "attachment action",
2762
2826
  variables: { name }
2763
2827
  }),
2764
- tooltip: t("Delete", { note: "button" }),
2765
- children: /* @__PURE__ */ jsx(Trash2Icon, {})
2828
+ tooltip: t("Delete", { note: "button" })
2766
2829
  }
2767
2830
  ) : null
2768
2831
  ] }) : void 0,
@@ -2840,7 +2903,7 @@ function isFetchOperation(operation) {
2840
2903
  }
2841
2904
  function ActiveDownloadToasts({ download }) {
2842
2905
  const t = useTranslations();
2843
- const formatDimahError = useFormatDimahError();
2906
+ const formatError = useFormatError();
2844
2907
  const formatFileSize = useFormatFileSize();
2845
2908
  const formatDownloadedBytes = useFormatDownloadedBytes();
2846
2909
  const { operations, cancel } = download;
@@ -2853,15 +2916,14 @@ function ActiveDownloadToasts({ download }) {
2853
2916
  const done = announced.current;
2854
2917
  const open = loading.current;
2855
2918
  const current = new Set(operations.map((op) => op.id));
2856
- const describe = (operation, detail) => /* @__PURE__ */ jsxs("span", { className: "block", children: [
2857
- /* @__PURE__ */ jsx(FileName, { name: downloadDisplayName(operation) }),
2858
- detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
2859
- " ",
2860
- "\xB7",
2861
- " ",
2862
- /* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children: detail })
2863
- ] }) : null
2864
- ] });
2919
+ const describe = (operation, detail, error) => /* @__PURE__ */ jsx(
2920
+ ToastFile,
2921
+ {
2922
+ name: downloadDisplayName(operation),
2923
+ detail,
2924
+ error
2925
+ }
2926
+ );
2865
2927
  const showProgress = (operation) => {
2866
2928
  const options = {
2867
2929
  type: "loading",
@@ -2869,7 +2931,7 @@ function ActiveDownloadToasts({ download }) {
2869
2931
  title: t("Downloading", { note: "toast" }),
2870
2932
  description: describe(
2871
2933
  operation,
2872
- formatDownloadedBytes(operation.progress) ?? void 0
2934
+ formatDownloadedBytes(operation.progress)
2873
2935
  ),
2874
2936
  actionProps: {
2875
2937
  children: t("Cancel", { note: "toast action" }),
@@ -2902,7 +2964,11 @@ function ActiveDownloadToasts({ download }) {
2902
2964
  toast.add({
2903
2965
  type: "error",
2904
2966
  title: t("Download failed", { note: "toast" }),
2905
- description: /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: formatDimahError(operation.error) })
2967
+ description: describe(
2968
+ operation,
2969
+ null,
2970
+ formatError(operation.error)
2971
+ )
2906
2972
  });
2907
2973
  return;
2908
2974
  case "aborted":
@@ -2943,7 +3009,7 @@ function ActiveDownloadToasts({ download }) {
2943
3009
  operations,
2944
3010
  cancel,
2945
3011
  t,
2946
- formatDimahError,
3012
+ formatError,
2947
3013
  formatFileSize,
2948
3014
  formatDownloadedBytes
2949
3015
  ]);
@@ -2962,7 +3028,7 @@ function DeleteToasts({ delete: del }) {
2962
3028
  }
2963
3029
  function useDeleteToasts(del, options = {}) {
2964
3030
  const t = useTranslations();
2965
- const formatError = useFormatDimahError();
3031
+ const formatError = useFormatError();
2966
3032
  const formatNumber = useFormatNumber();
2967
3033
  const active = useToastOwner(del.instanceId, { weak: options.weak });
2968
3034
  const report = options.report ?? addToast;
@@ -2982,7 +3048,7 @@ function useDeleteToasts(del, options = {}) {
2982
3048
  note: "toast",
2983
3049
  variables: { count: formatNumber(deleted.length) }
2984
3050
  }),
2985
- description: deleted.length === 1 ? /* @__PURE__ */ jsx(FileName, { name: displayName(firstDeleted) }) : void 0
3051
+ description: deleted.length === 1 ? /* @__PURE__ */ jsx(ToastFile, { name: displayName(firstDeleted) }) : void 0
2986
3052
  });
2987
3053
  }
2988
3054
  const [firstFailed] = failed;
@@ -2996,7 +3062,13 @@ function useDeleteToasts(del, options = {}) {
2996
3062
  note: "toast",
2997
3063
  variables: { count: formatNumber(failed.length) }
2998
3064
  }),
2999
- description: sameCause ? /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: formatError(firstFailed.error) }) : void 0
3065
+ description: failed.length === 1 ? /* @__PURE__ */ jsx(
3066
+ ToastFile,
3067
+ {
3068
+ name: displayName(firstFailed),
3069
+ error: formatError(firstFailed.error)
3070
+ }
3071
+ ) : sameCause ? /* @__PURE__ */ jsx(ToastText, { children: formatError(firstFailed.error) }) : void 0
3000
3072
  });
3001
3073
  }
3002
3074
  }
@@ -3043,15 +3115,12 @@ function Checkbox({ className, ...props }) {
3043
3115
  className
3044
3116
  ),
3045
3117
  ...props,
3046
- children: /* @__PURE__ */ jsxs(
3118
+ children: /* @__PURE__ */ jsx(
3047
3119
  Checkbox$1.Indicator,
3048
3120
  {
3049
3121
  "data-slot": "checkbox-indicator",
3050
3122
  className: "grid place-content-center text-current transition-none [&>svg]:size-3.5",
3051
- children: [
3052
- /* @__PURE__ */ jsx(CheckIcon, { className: "in-data-indeterminate:hidden" }),
3053
- /* @__PURE__ */ jsx(MinusIcon, { className: "hidden in-data-indeterminate:block" })
3054
- ]
3123
+ children: /* @__PURE__ */ jsx(CheckIcon, {})
3055
3124
  }
3056
3125
  )
3057
3126
  }
@@ -3110,7 +3179,7 @@ function DropdownMenuContent({
3110
3179
  {
3111
3180
  "data-slot": "dropdown-menu-content",
3112
3181
  className: cn(
3113
- "cn-menu-target cn-menu-translucent z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",
3182
+ "z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",
3114
3183
  className
3115
3184
  ),
3116
3185
  ...props
@@ -3181,7 +3250,7 @@ function DropdownMenuRadioItem({
3181
3250
  "data-slot": "dropdown-menu-radio-item",
3182
3251
  "data-inset": inset,
3183
3252
  className: cn(
3184
- "relative flex cursor-default items-center gap-1.5 rounded-md py-1 ps-1.5 pe-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:ps-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
3253
+ "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pe-8 ps-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:ps-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
3185
3254
  className
3186
3255
  ),
3187
3256
  ...props,
@@ -3234,270 +3303,101 @@ function useObjectListAnnouncement() {
3234
3303
  return { announcement, announce };
3235
3304
  }
3236
3305
  function ObjectListAnnouncer({
3237
- announcement
3306
+ announcement,
3307
+ status
3238
3308
  }) {
3239
- return /* @__PURE__ */ jsx(
3309
+ return /* @__PURE__ */ jsxs(
3240
3310
  "div",
3241
3311
  {
3242
3312
  "data-slot": "object-list-announcer",
3243
3313
  className: "sr-only",
3244
3314
  "aria-live": "polite",
3245
- children: announcement ? /* @__PURE__ */ jsxs("p", { children: [
3246
- announcement.feedback.title,
3247
- announcement.feedback.description != null ? /* @__PURE__ */ jsxs(Fragment, { children: [
3248
- " ",
3249
- announcement.feedback.description
3250
- ] }) : null
3251
- ] }, announcement.id) : null
3315
+ children: [
3316
+ /* @__PURE__ */ jsx("p", { "data-slot": "object-list-status", children: status }),
3317
+ announcement ? /* @__PURE__ */ jsxs("p", { children: [
3318
+ announcement.feedback.title,
3319
+ announcement.feedback.description != null ? /* @__PURE__ */ jsxs(Fragment, { children: [
3320
+ " ",
3321
+ announcement.feedback.description
3322
+ ] }) : null
3323
+ ] }, announcement.id) : null
3324
+ ]
3252
3325
  }
3253
3326
  );
3254
3327
  }
3255
- function Spinner({
3256
- className,
3257
- ...props
3258
- }) {
3328
+ function folderUploadCall(list, parent) {
3329
+ return list.uploadOptions ? { uploadOptions: list.uploadOptions(parent) } : void 0;
3330
+ }
3331
+ function useRefreshListAfterUpload(upload, refresh) {
3332
+ const reload = useEffectEvent(() => {
3333
+ void refresh();
3334
+ });
3335
+ const seenRef = useRef(null);
3336
+ const files = upload?.files;
3337
+ const settled = upload != null && !upload.isPending;
3338
+ useEffect(() => {
3339
+ if (!files) return;
3340
+ const succeeded = files.filter((file) => file.phase === "success").map((file) => file.id);
3341
+ seenRef.current ??= new Set(succeeded);
3342
+ const seen = seenRef.current;
3343
+ const listed = new Set(files.map((file) => file.id));
3344
+ for (const id of seen) {
3345
+ if (!listed.has(id)) seen.delete(id);
3346
+ }
3347
+ if (!settled) return;
3348
+ const fresh = succeeded.filter((id) => !seen.has(id));
3349
+ if (fresh.length === 0) return;
3350
+ for (const id of fresh) seen.add(id);
3351
+ reload();
3352
+ }, [files, settled]);
3353
+ }
3354
+ function ObjectListUploadStatus({ className }) {
3355
+ const { upload } = useObjectListContext();
3356
+ if (!upload || upload.phase === "idle" || upload.phase === "success") {
3357
+ return null;
3358
+ }
3259
3359
  return /* @__PURE__ */ jsx(
3260
- Loader2Icon,
3360
+ "div",
3261
3361
  {
3262
- "data-slot": "spinner",
3263
- role: "status",
3264
- "aria-label": "Loading",
3265
- className: cn("size-4 animate-spin", className),
3266
- ...props
3362
+ "data-slot": "object-list-upload-status",
3363
+ className: cn(
3364
+ "shrink-0 border-b border-dimah-s3-border px-3 py-2",
3365
+ className
3366
+ ),
3367
+ children: /* @__PURE__ */ jsx(UploadStatus, {})
3267
3368
  }
3268
3369
  );
3269
3370
  }
3270
- function canRenameEntry(entry, list) {
3271
- return entry.kind === "file" ? list.renameFile != null : list.renameFolder != null;
3272
- }
3273
- function ObjectListRenameField({
3274
- entry
3371
+ function ObjectListDropOverlay({
3372
+ upload,
3373
+ active,
3374
+ target = "frame",
3375
+ folder = null
3275
3376
  }) {
3276
3377
  const t = useTranslations();
3277
- const formatError = useFormatDimahError();
3278
- const { list, cancelRename } = useObjectListContext();
3279
- const inputId = useId();
3280
- const errorId = useId();
3281
- const inputRef = useRef(null);
3282
- const lock = useRef(false);
3283
- const closed = useRef(false);
3284
- const [name, setName] = useState(entry.name);
3285
- const [pending, setPending] = useState(false);
3286
- const [error, setError] = useState(null);
3287
- const folder = entry.kind === "folder";
3288
- const label = folder ? t("Folder name", { note: "object list new folder" }) : t("File name", { note: "object list rename" });
3289
- useEffect(() => {
3290
- const input = inputRef.current;
3291
- if (!input) return;
3292
- input.focus();
3293
- const end = folder ? entry.name.length : splitFileName(entry.name).stem.length;
3294
- input.setSelectionRange(0, end);
3295
- }, [entry.name, folder]);
3296
- function finish(focus) {
3297
- if (closed.current) return;
3298
- closed.current = true;
3299
- cancelRename(focus);
3300
- }
3301
- async function save(focus) {
3302
- if (closed.current || lock.current) return;
3303
- const trimmed = name.trim();
3304
- if (!trimmed) {
3305
- setError(
3306
- folder ? t("Enter a folder name", { note: "object list new folder" }) : t("Enter a file name", { note: "object list rename" })
3307
- );
3308
- return;
3309
- }
3310
- if (trimmed === entry.name) {
3311
- finish(focus);
3312
- return;
3313
- }
3314
- lock.current = true;
3315
- setPending(true);
3316
- setError(null);
3317
- try {
3318
- if (entry.kind === "folder") {
3319
- await list.renameFolder?.(entry.folder, trimmed);
3320
- } else {
3321
- await list.renameFile?.(entry.item, trimmed);
3322
- }
3323
- } catch (err) {
3324
- lock.current = false;
3325
- setPending(false);
3326
- setError(formatError(err));
3327
- inputRef.current?.focus();
3328
- return;
3329
- }
3330
- finish(focus);
3331
- }
3332
- function onBlur(event) {
3333
- if (closed.current || lock.current) return;
3334
- const next = event.relatedTarget;
3335
- if (next instanceof Node && event.currentTarget.contains(next)) return;
3336
- const trimmed = name.trim();
3337
- if (!trimmed || trimmed === entry.name) {
3338
- finish(false);
3339
- return;
3340
- }
3341
- void save(false);
3342
- }
3343
- const confirm = /* @__PURE__ */ jsx(
3344
- Button,
3345
- {
3346
- type: "submit",
3347
- variant: "ghost",
3348
- size: "icon-sm",
3349
- className: "shrink-0",
3350
- "aria-label": t("Rename", { note: "object list menu" }),
3351
- disabled: pending,
3352
- focusableWhenDisabled: true,
3353
- onMouseDown: (event) => event.preventDefault(),
3354
- children: pending ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(CheckIcon, {})
3355
- }
3356
- );
3357
- const cancel = /* @__PURE__ */ jsx(
3358
- Button,
3359
- {
3360
- type: "button",
3361
- variant: "ghost",
3362
- size: "icon-sm",
3363
- className: "shrink-0",
3364
- "aria-label": t("Cancel", { note: "object list rename" }),
3365
- disabled: pending,
3366
- onMouseDown: (event) => event.preventDefault(),
3367
- onClick: () => finish(true),
3368
- children: /* @__PURE__ */ jsx(XIcon, {})
3369
- }
3370
- );
3371
- function onSubmit(event) {
3372
- event.preventDefault();
3373
- void save(true);
3374
- }
3375
- return /* @__PURE__ */ jsxs(
3376
- "form",
3377
- {
3378
- "data-slot": "object-list-rename",
3379
- "aria-busy": pending || void 0,
3380
- className: "flex min-w-0 flex-1 flex-col gap-1",
3381
- onSubmit,
3382
- onBlur,
3383
- children: [
3384
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [
3385
- /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "sr-only", children: label }),
3386
- /* @__PURE__ */ jsx(
3387
- "input",
3388
- {
3389
- ref: inputRef,
3390
- id: inputId,
3391
- value: name,
3392
- dir: "auto",
3393
- maxLength: 255,
3394
- autoComplete: "off",
3395
- readOnly: pending,
3396
- "aria-invalid": error != null || void 0,
3397
- "aria-describedby": error != null ? errorId : void 0,
3398
- className: cn(
3399
- "h-7 min-w-0 flex-1 rounded-md border border-dimah-s3-border bg-transparent px-2 text-sm text-dimah-s3-foreground outline-none focus-visible:border-dimah-s3-ring focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50 aria-invalid:border-dimah-s3-destructive aria-invalid:ring-dimah-s3-destructive/20"
3400
- ),
3401
- onChange: (event) => {
3402
- setName(event.target.value);
3403
- setError(null);
3404
- },
3405
- onKeyDown: (event) => {
3406
- if (event.key !== "Escape" || lock.current) return;
3407
- event.preventDefault();
3408
- finish(true);
3409
- }
3410
- }
3411
- ),
3412
- confirm,
3413
- cancel
3414
- ] }),
3415
- error != null ? /* @__PURE__ */ jsx(
3416
- "p",
3417
- {
3418
- id: errorId,
3419
- role: "alert",
3420
- className: "text-xs [overflow-wrap:anywhere] text-dimah-s3-destructive",
3421
- children: error
3422
- }
3423
- ) : null
3424
- ]
3425
- }
3426
- );
3427
- }
3428
- function folderUploadCall(list, parent) {
3429
- return list.uploadOptions ? { uploadOptions: list.uploadOptions(parent) } : void 0;
3430
- }
3431
- function useRefreshListAfterUpload(upload, refresh) {
3432
- const reload = useEffectEvent(() => {
3433
- void refresh();
3434
- });
3435
- const seenRef = useRef(null);
3436
- const files = upload?.files;
3437
- const settled = upload != null && !upload.isPending;
3438
- useEffect(() => {
3439
- if (!files) return;
3440
- const succeeded = files.filter((file) => file.phase === "success").map((file) => file.id);
3441
- seenRef.current ??= new Set(succeeded);
3442
- const seen = seenRef.current;
3443
- const listed = new Set(files.map((file) => file.id));
3444
- for (const id of seen) {
3445
- if (!listed.has(id)) seen.delete(id);
3446
- }
3447
- if (!settled) return;
3448
- const fresh = succeeded.filter((id) => !seen.has(id));
3449
- if (fresh.length === 0) return;
3450
- for (const id of fresh) seen.add(id);
3451
- reload();
3452
- }, [files, settled]);
3453
- }
3454
- function ObjectListUploadStatus({ className }) {
3455
- const { upload } = useObjectListContext();
3456
- if (!upload || upload.phase === "idle" || upload.phase === "success") {
3457
- return null;
3458
- }
3459
- return /* @__PURE__ */ jsx(
3460
- "div",
3461
- {
3462
- "data-slot": "object-list-upload-status",
3463
- className: cn(
3464
- "shrink-0 border-b border-dimah-s3-border px-3 py-2",
3465
- className
3466
- ),
3467
- children: /* @__PURE__ */ jsx(UploadStatus, {})
3468
- }
3469
- );
3470
- }
3471
- function ObjectListDropOverlay({
3472
- upload,
3473
- active,
3474
- target = "frame",
3475
- folder = null
3476
- }) {
3477
- const t = useTranslations();
3478
- const shown = active && target === "frame";
3479
- const dropLabel = upload.isDragReject ? t("These files cannot be uploaded", { note: "object list" }) : t("Drop to upload into this folder", { note: "object list" });
3480
- const message = !active || target === "dropzone" ? "" : target === "folder" && folder && !upload.isDragReject ? t("Drop to upload into {name}", {
3481
- note: "object list",
3482
- variables: { name: folder }
3483
- }) : dropLabel;
3484
- return /* @__PURE__ */ jsxs(Fragment, { children: [
3485
- shown ? /* @__PURE__ */ jsx(
3486
- "div",
3487
- {
3488
- "aria-hidden": true,
3489
- "data-slot": "object-list-drop-overlay",
3490
- className: "pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-dimah-s3-card/80 p-6 group-has-[[data-slot=object-list-entry][data-drag-active]]/object-list:hidden",
3491
- children: /* @__PURE__ */ jsx(
3492
- "p",
3493
- {
3494
- className: cn(
3495
- "rounded-md border border-dashed px-3 py-2 text-sm",
3496
- upload.isDragReject ? "border-dimah-s3-destructive text-dimah-s3-destructive" : "border-dimah-s3-primary text-dimah-s3-primary"
3497
- ),
3498
- children: dropLabel
3499
- }
3500
- )
3378
+ const shown = active && target === "frame";
3379
+ const dropLabel = upload.isDragReject ? t("These files cannot be uploaded", { note: "object list" }) : t("Drop to upload into this folder", { note: "object list" });
3380
+ const message = !active || target === "dropzone" ? "" : target === "folder" && folder && !upload.isDragReject ? t("Drop to upload into {name}", {
3381
+ note: "object list",
3382
+ variables: { name: folder }
3383
+ }) : dropLabel;
3384
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3385
+ shown ? /* @__PURE__ */ jsx(
3386
+ "div",
3387
+ {
3388
+ "aria-hidden": true,
3389
+ "data-slot": "object-list-drop-overlay",
3390
+ className: "pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-dimah-s3-card/80 p-6 group-has-[[data-slot=object-list-entry][data-drag-active]]/object-list:hidden",
3391
+ children: /* @__PURE__ */ jsx(
3392
+ "p",
3393
+ {
3394
+ className: cn(
3395
+ "rounded-md border border-dashed px-3 py-2 text-sm",
3396
+ upload.isDragReject ? "border-dimah-s3-destructive text-dimah-s3-destructive" : "border-dimah-s3-primary text-dimah-s3-primary"
3397
+ ),
3398
+ children: dropLabel
3399
+ }
3400
+ )
3501
3401
  }
3502
3402
  ) : null,
3503
3403
  /* @__PURE__ */ jsx("div", { className: "sr-only", "aria-live": "polite", children: message })
@@ -3519,37 +3419,40 @@ function durationParts(seconds) {
3519
3419
  function useShareExpiryLabel() {
3520
3420
  const t = useTranslations();
3521
3421
  const formatNumber = useFormatNumber();
3522
- return (seconds) => {
3523
- if (seconds === null) {
3524
- return t("This link works while you can access this file.", {
3525
- note: "object list menu"
3526
- });
3527
- }
3528
- const { unit, count } = durationParts(seconds);
3529
- const value = formatNumber(count);
3530
- if (unit === "day") {
3531
- return count === 1 ? t("Expires in 1 day", { note: "object list menu" }) : t("Expires in {count} days", {
3532
- note: "object list menu",
3533
- variables: { count: value }
3534
- });
3535
- }
3536
- if (unit === "hour") {
3537
- return count === 1 ? t("Expires in 1 hour", { note: "object list menu" }) : t("Expires in {count} hours", {
3538
- note: "object list menu",
3539
- variables: { count: value }
3540
- });
3541
- }
3542
- if (unit === "minute") {
3543
- return count === 1 ? t("Expires in 1 minute", { note: "object list menu" }) : t("Expires in {count} minutes", {
3422
+ return useCallback(
3423
+ (seconds) => {
3424
+ if (seconds === null) {
3425
+ return t("This link works while you can access this file.", {
3426
+ note: "object list menu"
3427
+ });
3428
+ }
3429
+ const { unit, count } = durationParts(seconds);
3430
+ const value = formatNumber(count);
3431
+ if (unit === "day") {
3432
+ return count === 1 ? t("Expires in 1 day", { note: "object list menu" }) : t("Expires in {count} days", {
3433
+ note: "object list menu",
3434
+ variables: { count: value }
3435
+ });
3436
+ }
3437
+ if (unit === "hour") {
3438
+ return count === 1 ? t("Expires in 1 hour", { note: "object list menu" }) : t("Expires in {count} hours", {
3439
+ note: "object list menu",
3440
+ variables: { count: value }
3441
+ });
3442
+ }
3443
+ if (unit === "minute") {
3444
+ return count === 1 ? t("Expires in 1 minute", { note: "object list menu" }) : t("Expires in {count} minutes", {
3445
+ note: "object list menu",
3446
+ variables: { count: value }
3447
+ });
3448
+ }
3449
+ return count === 1 ? t("Expires in 1 second", { note: "object list menu" }) : t("Expires in {count} seconds", {
3544
3450
  note: "object list menu",
3545
3451
  variables: { count: value }
3546
3452
  });
3547
- }
3548
- return count === 1 ? t("Expires in 1 second", { note: "object list menu" }) : t("Expires in {count} seconds", {
3549
- note: "object list menu",
3550
- variables: { count: value }
3551
- });
3552
- };
3453
+ },
3454
+ [t, formatNumber]
3455
+ );
3553
3456
  }
3554
3457
  function ObjectListItemMenu({
3555
3458
  objectKey: objectKeyProp,
@@ -3562,29 +3465,24 @@ function ObjectListItemMenu({
3562
3465
  className
3563
3466
  }) {
3564
3467
  const t = useTranslations();
3565
- const context = useOptionalObjectListContext();
3468
+ const scope = useOptionalObjectListEntryScope();
3566
3469
  const entry = useObjectListEntry();
3567
3470
  const triggerRef = useRef(null);
3568
3471
  const file = entry?.kind === "file" ? entry : null;
3569
3472
  const folder = entry?.kind === "folder" ? entry : null;
3570
3473
  const objectKey = objectKeyProp ?? (file ? objectKeyOf(file) : "");
3571
- const fileName = fileNameProp ?? file?.file.name;
3572
- const fileSize = fileSizeProp ?? file?.file.size;
3573
3474
  const isFile = objectKey !== "";
3574
- const download = isFile ? context?.download ?? null : null;
3575
- const linkSource = isFile ? shareProp ?? context?.share ?? (download?.mode === "navigate" ? download : null) : null;
3576
- const remove = isFile ? context?.delete ?? null : null;
3577
- const listUpload = context?.upload ?? null;
3578
- const folderCall = folder && listUpload && context ? folderUploadCall(context.list, folder.id) : void 0;
3579
- const uploadToFolder = listUpload && folderCall ? () => listUpload.open(folderCall) : null;
3580
- const extra = actions ?? [];
3581
- const showTransfer = download != null || linkSource != null;
3582
- const showExtra = extra.length > 0 || children != null;
3583
- const canRename = context != null && entry != null && canRenameEntry(entry, context.list);
3475
+ const rows = {
3476
+ // A folder takes uploads only when the source can place files in it.
3477
+ upload: folder != null && scope?.folderUploads === true,
3478
+ download: isFile && scope?.download === true,
3479
+ link: isFile && (shareProp != null || scope?.share === true),
3480
+ rename: entry != null && (entry.kind === "file" ? scope?.renameFile : scope?.renameFolder) === true,
3481
+ extra: (actions?.length ?? 0) > 0 || children != null,
3482
+ delete: isFile && scope?.delete === true
3483
+ };
3584
3484
  if (!isFile && !folder) return null;
3585
- if (!showTransfer && !showExtra && !uploadToFolder && !canRename && remove == null) {
3586
- return null;
3587
- }
3485
+ if (!Object.values(rows).some(Boolean)) return null;
3588
3486
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3589
3487
  /* @__PURE__ */ jsxs(
3590
3488
  DropdownMenuTrigger,
@@ -3596,6 +3494,7 @@ function ObjectListItemMenu({
3596
3494
  variant: "ghost",
3597
3495
  size: "icon-sm",
3598
3496
  "data-slot": "object-list-item-menu",
3497
+ tabIndex: entry ? -1 : void 0,
3599
3498
  className
3600
3499
  }
3601
3500
  ),
@@ -3605,80 +3504,120 @@ function ObjectListItemMenu({
3605
3504
  ]
3606
3505
  }
3607
3506
  ),
3608
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-44", children: [
3609
- uploadToFolder || showTransfer || canRename ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
3610
- uploadToFolder ? /* @__PURE__ */ jsxs(
3611
- DropdownMenuItem,
3612
- {
3613
- disabled: listUpload?.disabled,
3614
- onClick: uploadToFolder,
3615
- children: [
3616
- /* @__PURE__ */ jsx(CloudUpload, {}),
3617
- t("Upload to this folder", { note: "object list menu" })
3618
- ]
3619
- }
3620
- ) : null,
3621
- download ? /* @__PURE__ */ jsx(
3622
- DownloadItem,
3623
- {
3624
- download,
3625
- objectKey,
3626
- fileName,
3627
- fileSize
3628
- }
3629
- ) : null,
3630
- linkSource ? /* @__PURE__ */ jsx(
3631
- CopyLinkItem,
3632
- {
3633
- share: linkSource,
3634
- objectKey,
3635
- fileName,
3636
- expiresIn
3637
- }
3638
- ) : null,
3639
- canRename ? /* @__PURE__ */ jsxs(
3640
- DropdownMenuItem,
3641
- {
3642
- onClick: () => {
3643
- if (entry) context?.startRename(entry.key);
3644
- },
3645
- children: [
3646
- /* @__PURE__ */ jsx(PencilIcon, {}),
3647
- t("Rename", { note: "object list menu" })
3648
- ]
3649
- }
3650
- ) : null
3651
- ] }) : null,
3652
- showExtra && (showTransfer || uploadToFolder || canRename) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
3653
- showExtra ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
3654
- extra.map((action, index) => /* @__PURE__ */ jsxs(
3655
- DropdownMenuItem,
3656
- {
3657
- variant: action.destructive ? "destructive" : "default",
3658
- disabled: action.disabled,
3659
- onClick: () => {
3660
- action.onClick();
3661
- },
3662
- children: [
3663
- action.icon,
3664
- action.label
3665
- ]
3666
- },
3667
- `${action.label}-${index}`
3668
- )),
3507
+ /* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", className: "min-w-44", children: /* @__PURE__ */ jsx(
3508
+ ItemMenuItems,
3509
+ {
3510
+ rows,
3511
+ folderId: folder?.id ?? null,
3512
+ entryKey: entry?.key ?? null,
3513
+ objectKey,
3514
+ fileName: fileNameProp ?? file?.file.name,
3515
+ fileSize: fileSizeProp ?? file?.file.size,
3516
+ share: shareProp,
3517
+ expiresIn,
3518
+ actions,
3519
+ triggerRef,
3669
3520
  children
3670
- ] }) : null,
3671
- remove && (showTransfer || uploadToFolder || canRename || showExtra) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
3672
- remove ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(
3673
- DeleteItem,
3521
+ }
3522
+ ) })
3523
+ ] });
3524
+ }
3525
+ function ItemMenuItems({
3526
+ rows,
3527
+ folderId,
3528
+ entryKey,
3529
+ objectKey,
3530
+ fileName,
3531
+ fileSize,
3532
+ share: shareProp,
3533
+ expiresIn,
3534
+ actions,
3535
+ triggerRef,
3536
+ children
3537
+ }) {
3538
+ const t = useTranslations();
3539
+ const context = useOptionalObjectListContext();
3540
+ const download = rows.download ? context?.download ?? null : null;
3541
+ const linkSource = rows.link ? shareProp ?? context?.share ?? (context?.download?.mode === "navigate" ? context.download : null) : null;
3542
+ const remove = rows.delete ? context?.delete ?? null : null;
3543
+ const listUpload = context?.upload ?? null;
3544
+ const folderCall = rows.upload && context && folderId != null ? folderUploadCall(context.list, folderId) : void 0;
3545
+ const uploadToFolder = listUpload && folderCall ? () => listUpload.open(folderCall) : null;
3546
+ const extra = actions ?? [];
3547
+ const showTransfer = download != null || linkSource != null;
3548
+ const showExtra = rows.extra;
3549
+ const canRename = rows.rename && context != null && entryKey != null;
3550
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3551
+ uploadToFolder || showTransfer || canRename ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
3552
+ uploadToFolder ? /* @__PURE__ */ jsxs(
3553
+ DropdownMenuItem,
3554
+ {
3555
+ disabled: listUpload?.disabled,
3556
+ onClick: uploadToFolder,
3557
+ children: [
3558
+ /* @__PURE__ */ jsx(CloudUpload, {}),
3559
+ t("Upload to this folder", { note: "object list menu" })
3560
+ ]
3561
+ }
3562
+ ) : null,
3563
+ download ? /* @__PURE__ */ jsx(
3564
+ DownloadItem,
3674
3565
  {
3566
+ download,
3675
3567
  objectKey,
3676
3568
  fileName,
3677
- fileSize,
3678
- triggerRef
3569
+ fileSize
3679
3570
  }
3680
- ) }) : null
3681
- ] })
3571
+ ) : null,
3572
+ linkSource ? /* @__PURE__ */ jsx(
3573
+ CopyLinkItem,
3574
+ {
3575
+ share: linkSource,
3576
+ objectKey,
3577
+ fileName,
3578
+ expiresIn
3579
+ }
3580
+ ) : null,
3581
+ canRename ? /* @__PURE__ */ jsxs(
3582
+ DropdownMenuItem,
3583
+ {
3584
+ onClick: () => {
3585
+ if (entryKey != null) context?.startRename(entryKey);
3586
+ },
3587
+ children: [
3588
+ /* @__PURE__ */ jsx(PencilIcon, {}),
3589
+ t("Rename", { note: "object list menu" })
3590
+ ]
3591
+ }
3592
+ ) : null
3593
+ ] }) : null,
3594
+ showExtra && (showTransfer || uploadToFolder || canRename) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
3595
+ showExtra ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
3596
+ extra.map((action, index) => /* @__PURE__ */ jsxs(
3597
+ DropdownMenuItem,
3598
+ {
3599
+ variant: action.destructive ? "destructive" : "default",
3600
+ disabled: action.disabled,
3601
+ onClick: action.onClick,
3602
+ children: [
3603
+ action.icon,
3604
+ action.label
3605
+ ]
3606
+ },
3607
+ `${action.label}-${index}`
3608
+ )),
3609
+ children
3610
+ ] }) : null,
3611
+ remove && (showTransfer || uploadToFolder || canRename || showExtra) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
3612
+ remove ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(
3613
+ DeleteItem,
3614
+ {
3615
+ objectKey,
3616
+ fileName,
3617
+ fileSize,
3618
+ triggerRef
3619
+ }
3620
+ ) }) : null
3682
3621
  ] });
3683
3622
  }
3684
3623
  function DownloadItem({
@@ -3714,7 +3653,7 @@ function CopyLinkItem({
3714
3653
  expiresIn
3715
3654
  }) {
3716
3655
  const t = useTranslations();
3717
- const formatError = useFormatDimahError();
3656
+ const formatError = useFormatError();
3718
3657
  const expiryLabel = useShareExpiryLabel();
3719
3658
  const report = useObjectListFeedback();
3720
3659
  const [copying, setCopying] = useState(false);
@@ -3757,32 +3696,202 @@ function CopyLinkItem({
3757
3696
  setCopying(false);
3758
3697
  }
3759
3698
  }
3760
- return /* @__PURE__ */ jsxs(DropdownMenuItem, { disabled: copying, onClick: () => void copyLink(), children: [
3761
- copying ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin" }) : /* @__PURE__ */ jsx(LinkIcon, {}),
3762
- t("Copy link", { note: "object list menu" })
3763
- ] });
3764
- }
3765
- function DeleteItem({
3766
- objectKey,
3767
- fileName,
3768
- fileSize,
3769
- triggerRef
3770
- }) {
3771
- const t = useTranslations();
3772
- const { delete: del, request } = useDeleteContext();
3773
- const deleting = del.get(objectKey)?.phase === "deleting";
3699
+ return /* @__PURE__ */ jsxs(DropdownMenuItem, { disabled: copying, onClick: () => void copyLink(), children: [
3700
+ copying ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin" }) : /* @__PURE__ */ jsx(LinkIcon, {}),
3701
+ t("Copy link", { note: "object list menu" })
3702
+ ] });
3703
+ }
3704
+ function DeleteItem({
3705
+ objectKey,
3706
+ fileName,
3707
+ fileSize,
3708
+ triggerRef
3709
+ }) {
3710
+ const t = useTranslations();
3711
+ const { delete: del, request } = useDeleteContext();
3712
+ const deleting = del.pendingKeys.includes(objectKey);
3713
+ return /* @__PURE__ */ jsxs(
3714
+ DropdownMenuItem,
3715
+ {
3716
+ variant: "destructive",
3717
+ disabled: deleting,
3718
+ onClick: () => request(
3719
+ { objectKey, fileName, fileSize },
3720
+ { trigger: triggerRef.current }
3721
+ ),
3722
+ children: [
3723
+ deleting ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin" }) : /* @__PURE__ */ jsx(Trash2Icon, {}),
3724
+ t("Delete", { note: "button" })
3725
+ ]
3726
+ }
3727
+ );
3728
+ }
3729
+ function Spinner({ className, ...props }) {
3730
+ return /* @__PURE__ */ jsx(
3731
+ Loader2Icon,
3732
+ {
3733
+ "data-slot": "spinner",
3734
+ role: "status",
3735
+ "aria-label": "Loading",
3736
+ className: cn("size-4 animate-spin", className),
3737
+ ...props
3738
+ }
3739
+ );
3740
+ }
3741
+ function canRenameEntry(entry, list) {
3742
+ return entry.kind === "file" ? list.renameFile != null : list.renameFolder != null;
3743
+ }
3744
+ function ObjectListRenameField({
3745
+ entry
3746
+ }) {
3747
+ const t = useTranslations();
3748
+ const formatError = useFormatError();
3749
+ const { list, endRename } = useObjectListContext();
3750
+ const inputId = useId();
3751
+ const errorId = useId();
3752
+ const inputRef = useRef(null);
3753
+ const lock = useRef(false);
3754
+ const closed = useRef(false);
3755
+ const [name, setName] = useState(entry.name);
3756
+ const [pending, setPending] = useState(false);
3757
+ const [error, setError] = useState(null);
3758
+ const folder = entry.kind === "folder";
3759
+ const label = folder ? t("Folder name", { note: "object list new folder" }) : t("File name", { note: "object list rename" });
3760
+ useEffect(() => {
3761
+ const input = inputRef.current;
3762
+ if (!input) return;
3763
+ input.focus();
3764
+ const end = folder ? entry.name.length : splitFileName(entry.name).stem.length;
3765
+ input.setSelectionRange(0, end);
3766
+ }, [entry.name, folder]);
3767
+ function finish(focus) {
3768
+ if (closed.current) return;
3769
+ closed.current = true;
3770
+ endRename(entry.key, focus);
3771
+ }
3772
+ async function save(focus) {
3773
+ if (closed.current || lock.current) return;
3774
+ const trimmed = name.trim();
3775
+ if (!trimmed) {
3776
+ setError(
3777
+ folder ? t("Enter a folder name", { note: "object list new folder" }) : t("Enter a file name", { note: "object list rename" })
3778
+ );
3779
+ return;
3780
+ }
3781
+ if (trimmed === entry.name) {
3782
+ finish(focus);
3783
+ return;
3784
+ }
3785
+ lock.current = true;
3786
+ setPending(true);
3787
+ setError(null);
3788
+ try {
3789
+ if (entry.kind === "folder") {
3790
+ await list.renameFolder?.(entry.folder, trimmed);
3791
+ } else {
3792
+ await list.renameFile?.(entry.item, trimmed);
3793
+ }
3794
+ } catch (err) {
3795
+ lock.current = false;
3796
+ setPending(false);
3797
+ setError(formatError(err));
3798
+ if (focus) inputRef.current?.focus();
3799
+ return;
3800
+ }
3801
+ finish(focus);
3802
+ }
3803
+ function onBlur(event) {
3804
+ if (closed.current || lock.current) return;
3805
+ const next = event.relatedTarget;
3806
+ if (next instanceof Node && event.currentTarget.contains(next)) return;
3807
+ const trimmed = name.trim();
3808
+ if (!trimmed || trimmed === entry.name) {
3809
+ finish(false);
3810
+ return;
3811
+ }
3812
+ void save(false);
3813
+ }
3814
+ const confirm = /* @__PURE__ */ jsx(
3815
+ Button,
3816
+ {
3817
+ type: "submit",
3818
+ variant: "ghost",
3819
+ size: "icon-sm",
3820
+ className: "shrink-0",
3821
+ "aria-label": t("Rename", { note: "object list menu" }),
3822
+ disabled: pending,
3823
+ focusableWhenDisabled: true,
3824
+ onMouseDown: (event) => event.preventDefault(),
3825
+ children: pending ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(CheckIcon, {})
3826
+ }
3827
+ );
3828
+ const cancel = /* @__PURE__ */ jsx(
3829
+ Button,
3830
+ {
3831
+ type: "button",
3832
+ variant: "ghost",
3833
+ size: "icon-sm",
3834
+ className: "shrink-0",
3835
+ "aria-label": t("Cancel", { note: "object list rename" }),
3836
+ disabled: pending,
3837
+ onMouseDown: (event) => event.preventDefault(),
3838
+ onClick: () => finish(true),
3839
+ children: /* @__PURE__ */ jsx(XIcon, {})
3840
+ }
3841
+ );
3842
+ function onSubmit(event) {
3843
+ event.preventDefault();
3844
+ void save(true);
3845
+ }
3774
3846
  return /* @__PURE__ */ jsxs(
3775
- DropdownMenuItem,
3847
+ "form",
3776
3848
  {
3777
- variant: "destructive",
3778
- disabled: deleting,
3779
- onClick: () => request(
3780
- { objectKey, fileName, fileSize },
3781
- { trigger: triggerRef.current }
3782
- ),
3849
+ "data-slot": "object-list-rename",
3850
+ "aria-busy": pending || void 0,
3851
+ className: "flex min-w-0 flex-1 flex-col gap-1",
3852
+ onSubmit,
3853
+ onBlur,
3783
3854
  children: [
3784
- deleting ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin" }) : /* @__PURE__ */ jsx(Trash2Icon, {}),
3785
- t("Delete", { note: "button" })
3855
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [
3856
+ /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "sr-only", children: label }),
3857
+ /* @__PURE__ */ jsx(
3858
+ "input",
3859
+ {
3860
+ ref: inputRef,
3861
+ id: inputId,
3862
+ value: name,
3863
+ dir: "auto",
3864
+ maxLength: 255,
3865
+ autoComplete: "off",
3866
+ readOnly: pending,
3867
+ "aria-invalid": error != null || void 0,
3868
+ "aria-describedby": error != null ? errorId : void 0,
3869
+ className: cn(
3870
+ "h-7 min-w-0 flex-1 rounded-md border border-dimah-s3-border bg-transparent px-2 text-sm text-dimah-s3-foreground outline-none focus-visible:border-dimah-s3-ring focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50 aria-invalid:border-dimah-s3-destructive aria-invalid:ring-dimah-s3-destructive/20"
3871
+ ),
3872
+ onChange: (event) => {
3873
+ setName(event.target.value);
3874
+ setError(null);
3875
+ },
3876
+ onKeyDown: (event) => {
3877
+ if (event.key !== "Escape" || lock.current) return;
3878
+ event.preventDefault();
3879
+ finish(true);
3880
+ }
3881
+ }
3882
+ ),
3883
+ confirm,
3884
+ cancel
3885
+ ] }),
3886
+ error != null ? /* @__PURE__ */ jsx(
3887
+ "p",
3888
+ {
3889
+ id: errorId,
3890
+ role: "alert",
3891
+ className: "text-xs [overflow-wrap:anywhere] text-dimah-s3-destructive",
3892
+ children: error
3893
+ }
3894
+ ) : null
3786
3895
  ]
3787
3896
  }
3788
3897
  );
@@ -3792,6 +3901,7 @@ function ObjectListCheckbox({
3792
3901
  indeterminate,
3793
3902
  label,
3794
3903
  onCheckedChange,
3904
+ tabIndex,
3795
3905
  className
3796
3906
  }) {
3797
3907
  const shiftRef = useRef(false);
@@ -3800,6 +3910,7 @@ function ObjectListCheckbox({
3800
3910
  {
3801
3911
  checked,
3802
3912
  indeterminate,
3913
+ tabIndex,
3803
3914
  "aria-label": label,
3804
3915
  className: cn("after:-inset-x-2 after:-inset-y-3", className),
3805
3916
  onPointerDown: (event) => {
@@ -3818,7 +3929,7 @@ function ObjectListCheckbox({
3818
3929
  );
3819
3930
  }
3820
3931
  var DROP_TARGET = "data-drag-active:bg-dimah-s3-primary/10 data-drag-active:ring-2 data-drag-active:ring-dimah-s3-primary data-drag-active:ring-inset";
3821
- function ObjectListRow(props) {
3932
+ var ObjectListRow = memo(function ObjectListRow2(props) {
3822
3933
  const { entry, className } = props;
3823
3934
  const parts = useEntryParts(props);
3824
3935
  return /* @__PURE__ */ jsxs(
@@ -3827,6 +3938,7 @@ function ObjectListRow(props) {
3827
3938
  ...parts.dropTarget,
3828
3939
  "data-drop-name": parts.dropTarget ? entry.name : void 0,
3829
3940
  "data-slot": "object-list-entry",
3941
+ "data-entry-key": entry.key,
3830
3942
  "data-kind": entry.kind,
3831
3943
  "data-view": "list",
3832
3944
  "data-selected": parts.selected ? "" : void 0,
@@ -3872,8 +3984,8 @@ function ObjectListRow(props) {
3872
3984
  ]
3873
3985
  }
3874
3986
  );
3875
- }
3876
- function ObjectListTile(props) {
3987
+ });
3988
+ var ObjectListTile = memo(function ObjectListTile2(props) {
3877
3989
  const { entry, className } = props;
3878
3990
  const parts = useEntryParts(props);
3879
3991
  return /* @__PURE__ */ jsxs(
@@ -3882,6 +3994,7 @@ function ObjectListTile(props) {
3882
3994
  ...parts.dropTarget,
3883
3995
  "data-drop-name": parts.dropTarget ? entry.name : void 0,
3884
3996
  "data-slot": "object-list-entry",
3997
+ "data-entry-key": entry.key,
3885
3998
  "data-kind": entry.kind,
3886
3999
  "data-view": "grid",
3887
4000
  "data-selected": parts.selected ? "" : void 0,
@@ -3926,7 +4039,7 @@ function ObjectListTile(props) {
3926
4039
  ]
3927
4040
  }
3928
4041
  );
3929
- }
4042
+ });
3930
4043
  function useEntryParts({
3931
4044
  entry,
3932
4045
  actions,
@@ -3935,53 +4048,53 @@ function useEntryParts({
3935
4048
  media
3936
4049
  }) {
3937
4050
  const t = useTranslations();
3938
- const context = useObjectListContext();
3939
- const { list, selection, upload, onOpenItem } = context;
4051
+ const scope = useObjectListEntryScope();
4052
+ const { selected, selectable, selecting, renaming, tabStop } = useObjectListEntryStatus(entry.key);
3940
4053
  const defaultDescription = useDefaultDescription(entry);
3941
- const selectable = selection != null && selection.canSelect(entry);
3942
- const selected = selectable && selection.isSelected(entry.key);
3943
- const renaming = context.renamingKey === entry.key;
3944
- const canRename = canRenameEntry(entry, list);
3945
- const open = entry.kind === "folder" ? () => list.openFolder(entry.folder) : onOpenItem ? () => onOpenItem(entry.item) : null;
3946
- const folderCall = entry.kind === "folder" && upload ? folderUploadCall(list, entry.id) : void 0;
3947
- const hasMenu = entry.kind === "file" ? context.download != null || context.share != null || context.delete != null || canRename : folderCall != null || canRename;
3948
- const resolvedActions = actions !== void 0 ? actions : context.renderActions ? context.renderActions(entry) : hasMenu ? /* @__PURE__ */ jsx(ObjectListItemMenu, {}) : null;
4054
+ const folder = entry.kind === "folder";
4055
+ const canRename = folder ? scope.renameFolder : scope.renameFile;
4056
+ const opens = folder || scope.opensFiles;
4057
+ const takesDrops = folder && scope.folderUploads;
4058
+ const hasMenu = folder ? takesDrops || canRename : scope.download || scope.share || scope.delete || canRename;
4059
+ const resolvedActions = actions !== void 0 ? actions : scope.renderActions ? scope.renderActions(entry) : hasMenu ? /* @__PURE__ */ jsx(ObjectListItemMenu, {}) : null;
3949
4060
  return {
3950
4061
  selected,
3951
- selecting: selection?.isSelecting === true,
4062
+ selecting,
3952
4063
  renaming,
3953
- checkbox: selectable && selection ? /* @__PURE__ */ jsx(
4064
+ tabStop,
4065
+ checkbox: selectable ? /* @__PURE__ */ jsx(
3954
4066
  ObjectListCheckbox,
3955
4067
  {
3956
4068
  checked: selected,
4069
+ tabIndex: -1,
3957
4070
  label: t("Select {name}", {
3958
4071
  note: "object list selection",
3959
4072
  variables: { name: entry.name }
3960
4073
  }),
3961
- onCheckedChange: (checked, shiftKey) => selection.toggle(entry.key, { value: checked, range: shiftKey })
4074
+ onCheckedChange: (checked, shiftKey) => scope.toggle(entry.key, { value: checked, range: shiftKey })
3962
4075
  }
3963
4076
  ) : null,
3964
4077
  actions: present(resolvedActions),
3965
4078
  description: present(
3966
- description !== void 0 ? description : context.renderDescription ? context.renderDescription(entry) : defaultDescription
4079
+ description !== void 0 ? description : scope.renderDescription ? scope.renderDescription(entry) : defaultDescription
3967
4080
  ),
3968
- meta: present(meta !== void 0 ? meta : context.renderMeta?.(entry)),
4081
+ meta: present(meta !== void 0 ? meta : scope.renderMeta?.(entry)),
3969
4082
  media: present(media),
3970
- dropTarget: upload && folderCall ? upload.getDropTargetProps({}, folderCall) : null,
4083
+ dropTarget: takesDrops ? scope.folderDropTarget(entry.id) : null,
3971
4084
  entryKey: entry.key,
3972
- onClick: open || selectable ? (event) => {
3973
- if (selectable && selection) {
4085
+ onClick: opens || selectable ? (event) => {
4086
+ if (selectable) {
3974
4087
  if (event.metaKey || event.ctrlKey) {
3975
- selection.toggle(entry.key);
4088
+ scope.toggle(entry.key);
3976
4089
  return;
3977
4090
  }
3978
4091
  if (event.shiftKey) {
3979
- selection.toggle(entry.key, { range: true, value: true });
4092
+ scope.toggle(entry.key, { range: true, value: true });
3980
4093
  return;
3981
4094
  }
3982
4095
  }
3983
- if (open) open();
3984
- else selection?.toggle(entry.key);
4096
+ if (opens) scope.open(entry);
4097
+ else scope.toggle(entry.key);
3985
4098
  } : null
3986
4099
  };
3987
4100
  }
@@ -3991,13 +4104,24 @@ function EntryTrigger({
3991
4104
  children
3992
4105
  }) {
3993
4106
  const focusRing = "outline-none focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50";
4107
+ const tabIndex = parts.tabStop ? 0 : -1;
3994
4108
  if (!parts.onClick) {
3995
- return /* @__PURE__ */ jsx("div", { className, children });
4109
+ return /* @__PURE__ */ jsx(
4110
+ "div",
4111
+ {
4112
+ tabIndex,
4113
+ "data-slot": "object-list-entry-trigger",
4114
+ "data-entry-key": parts.entryKey,
4115
+ className: cn(focusRing, className),
4116
+ children
4117
+ }
4118
+ );
3996
4119
  }
3997
4120
  return /* @__PURE__ */ jsx(
3998
4121
  "button",
3999
4122
  {
4000
4123
  type: "button",
4124
+ tabIndex,
4001
4125
  "data-slot": "object-list-entry-trigger",
4002
4126
  "data-entry-key": parts.entryKey,
4003
4127
  className: cn("cursor-pointer select-none", focusRing, className),
@@ -4107,10 +4231,7 @@ function EmptyTitle({ className, ...props }) {
4107
4231
  "div",
4108
4232
  {
4109
4233
  "data-slot": "empty-title",
4110
- className: cn(
4111
- "cn-font-heading text-sm font-medium tracking-tight",
4112
- className
4113
- ),
4234
+ className: cn("text-sm font-medium tracking-tight", className),
4114
4235
  ...props
4115
4236
  }
4116
4237
  );
@@ -4300,7 +4421,7 @@ function ObjectListPagination({
4300
4421
  function ObjectListContent({ className }) {
4301
4422
  const context = useObjectListContext();
4302
4423
  const { list, view, sizing } = context;
4303
- const formatError = useFormatDimahError();
4424
+ const formatError = useFormatError();
4304
4425
  const [scroller, setScroller] = useState(null);
4305
4426
  const hasRows = list.entries.length > 0;
4306
4427
  const errorMessage = list.error ? formatError(list.error) : null;
@@ -4325,12 +4446,19 @@ function ObjectListContent({ className }) {
4325
4446
  list.isLoading ? /* @__PURE__ */ jsx(ObjectListSkeleton, { view }) : null,
4326
4447
  list.error && !hasRows && !list.isLoading ? /* @__PURE__ */ jsx(ObjectListError, { message: errorMessage, onRetry: list.retry }) : null,
4327
4448
  showEmpty ? context.empty ?? /* @__PURE__ */ jsx(ObjectListEmpty, {}) : null,
4328
- hasRows ? /* @__PURE__ */ jsx(ObjectListEntries, {}) : null,
4449
+ hasRows ? /* @__PURE__ */ jsx(
4450
+ ObjectListEntries,
4451
+ {
4452
+ entries: list.entries,
4453
+ view,
4454
+ renderEntry: context.renderEntry
4455
+ }
4456
+ ) : null,
4329
4457
  hasRows && errorMessage ? /* @__PURE__ */ jsx(ObjectListErrorBanner, { message: errorMessage, onRetry: list.retry }) : null,
4330
4458
  /* @__PURE__ */ jsx(
4331
4459
  ObjectListPagination,
4332
4460
  {
4333
- mode: context.loadMore,
4461
+ mode: context.pagination,
4334
4462
  root: sizing ? scroller : null,
4335
4463
  ready: !sizing || scroller != null
4336
4464
  }
@@ -4343,27 +4471,34 @@ var ENTRY_VISIBILITY = {
4343
4471
  list: "[contain-intrinsic-block-size:auto_2.75rem] [content-visibility:auto]",
4344
4472
  grid: "[contain-intrinsic-block-size:auto_9.5rem] [content-visibility:auto]"
4345
4473
  };
4346
- function ObjectListEntries() {
4347
- const { list, view, renderEntry } = useObjectListContext();
4348
- return /* @__PURE__ */ jsx(
4349
- "div",
4350
- {
4351
- role: "list",
4352
- "data-slot": "object-list-entries",
4353
- "data-view": view,
4354
- className: view === "grid" ? "grid grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] gap-2 p-2" : "flex min-w-0 flex-col",
4355
- children: list.entries.map((entry) => /* @__PURE__ */ jsx(
4356
- "div",
4357
- {
4358
- role: "listitem",
4359
- className: cn("min-w-0", ENTRY_VISIBILITY[view]),
4360
- children: /* @__PURE__ */ jsx(ObjectListEntryProvider, { entry, children: renderEntry ? renderEntry(entry) : view === "grid" ? /* @__PURE__ */ jsx(ObjectListTile, { entry }) : /* @__PURE__ */ jsx(ObjectListRow, { entry }) })
4361
- },
4362
- entry.key
4363
- ))
4364
- }
4365
- );
4366
- }
4474
+ var ObjectListEntries = memo(function ObjectListEntries2({
4475
+ entries,
4476
+ view,
4477
+ renderEntry
4478
+ }) {
4479
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4480
+ /* @__PURE__ */ jsx("span", { "data-slot": "object-list-entries-start", tabIndex: -1 }),
4481
+ /* @__PURE__ */ jsx(
4482
+ "div",
4483
+ {
4484
+ role: "list",
4485
+ "data-slot": "object-list-entries",
4486
+ "data-view": view,
4487
+ className: view === "grid" ? "grid grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] gap-2 p-2" : "flex min-w-0 flex-col",
4488
+ children: entries.map((entry) => /* @__PURE__ */ jsx(
4489
+ "div",
4490
+ {
4491
+ role: "listitem",
4492
+ className: cn("min-w-0", ENTRY_VISIBILITY[view]),
4493
+ children: /* @__PURE__ */ jsx(ObjectListEntryProvider, { entry, children: renderEntry ? renderEntry(entry) : view === "grid" ? /* @__PURE__ */ jsx(ObjectListTile, { entry }) : /* @__PURE__ */ jsx(ObjectListRow, { entry }) })
4494
+ },
4495
+ entry.key
4496
+ ))
4497
+ }
4498
+ ),
4499
+ /* @__PURE__ */ jsx("span", { "data-slot": "object-list-entries-end", tabIndex: -1 })
4500
+ ] });
4501
+ });
4367
4502
  function Breadcrumb({ className, ...props }) {
4368
4503
  return /* @__PURE__ */ jsx(
4369
4504
  "nav",
@@ -4603,9 +4738,10 @@ function ObjectListHeader({
4603
4738
  () => ({ setSearchExpanded, setFolderExpanded }),
4604
4739
  []
4605
4740
  );
4606
- const creatingFolder = folderExpanded && !selecting;
4607
- const searching = searchExpanded && !creatingFolder && !selecting;
4608
- return /* @__PURE__ */ jsx(ObjectListHeaderContext.Provider, { value: header, children: /* @__PURE__ */ jsx(
4741
+ const replaced = selecting && !selection?.persist;
4742
+ const creatingFolder = folderExpanded && !replaced;
4743
+ const searching = searchExpanded && !creatingFolder && !replaced;
4744
+ return /* @__PURE__ */ jsx(ObjectListHeaderContext.Provider, { value: header, children: /* @__PURE__ */ jsxs(
4609
4745
  "div",
4610
4746
  {
4611
4747
  "data-slot": "object-list-header",
@@ -4614,50 +4750,59 @@ function ObjectListHeader({
4614
4750
  "data-folder-open": creatingFolder ? "" : void 0,
4615
4751
  className: cn(
4616
4752
  "group/object-list-header @container/object-list-header shrink-0 border-b border-dimah-s3-border",
4617
- selecting && "bg-dimah-s3-primary/10",
4753
+ replaced && "bg-dimah-s3-primary/10",
4618
4754
  className
4619
4755
  ),
4620
- children: selecting ? /* @__PURE__ */ jsx(
4621
- ObjectListSelectionBar,
4622
- {
4623
- actions: selectionActions ?? context.selectionActions
4624
- }
4625
- ) : /* @__PURE__ */ jsxs("div", { className: "flex min-h-11 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 px-1.5 py-1.5", children: [
4626
- /* @__PURE__ */ jsxs(
4627
- "div",
4756
+ children: [
4757
+ replaced ? /* @__PURE__ */ jsx(
4758
+ ObjectListSelectionBar,
4628
4759
  {
4629
- "data-slot": "object-list-header-path",
4630
- className: "flex min-w-0 flex-[1_1_11rem] items-center gap-2 group-data-folder-open/object-list-header:hidden group-data-search-open/object-list-header:hidden",
4631
- children: [
4632
- /* @__PURE__ */ jsx(ObjectListSelectAll, {}),
4633
- showBreadcrumb ? /* @__PURE__ */ jsx(ObjectListBreadcrumb, {}) : /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1" }),
4634
- list.isRefreshing ? /* @__PURE__ */ jsx(
4635
- Spinner,
4636
- {
4637
- className: "shrink-0 text-dimah-s3-muted-foreground",
4638
- "aria-label": t("Loading files", { note: "object list" })
4639
- }
4640
- ) : null
4641
- ]
4760
+ actions: selectionActions ?? context.selectionActions
4642
4761
  }
4643
- ),
4644
- /* @__PURE__ */ jsxs(
4645
- "div",
4762
+ ) : /* @__PURE__ */ jsxs("div", { className: "flex min-h-11 min-w-0 flex-wrap items-center gap-x-2 gap-y-1 px-1.5 py-1.5", children: [
4763
+ /* @__PURE__ */ jsxs(
4764
+ "div",
4765
+ {
4766
+ "data-slot": "object-list-header-path",
4767
+ className: "flex min-w-0 flex-[1_1_11rem] items-center gap-2 group-data-folder-open/object-list-header:hidden group-data-search-open/object-list-header:hidden",
4768
+ children: [
4769
+ selecting ? null : /* @__PURE__ */ jsx(ObjectListSelectAll, {}),
4770
+ showBreadcrumb ? /* @__PURE__ */ jsx(ObjectListBreadcrumb, {}) : /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1" }),
4771
+ list.isRefreshing ? /* @__PURE__ */ jsx(
4772
+ Spinner,
4773
+ {
4774
+ className: "shrink-0 text-dimah-s3-muted-foreground",
4775
+ "aria-label": t("Loading files", { note: "object list" })
4776
+ }
4777
+ ) : null
4778
+ ]
4779
+ }
4780
+ ),
4781
+ /* @__PURE__ */ jsxs(
4782
+ "div",
4783
+ {
4784
+ "data-slot": "object-list-header-actions",
4785
+ className: cn(
4786
+ "ms-auto flex min-w-0 shrink-0 items-center gap-1",
4787
+ // While search or new folder is open, that field takes the bar alone.
4788
+ "group-data-search-open/object-list-header:ms-0 group-data-search-open/object-list-header:flex-1 group-data-search-open/object-list-header:[&>*:not([data-slot=object-list-search])]:hidden",
4789
+ "group-data-folder-open/object-list-header:ms-0 group-data-folder-open/object-list-header:flex-1 group-data-folder-open/object-list-header:[&>*:not([data-slot=object-list-new-folder])]:hidden"
4790
+ ),
4791
+ children: [
4792
+ /* @__PURE__ */ jsx(ObjectListNewFolder, {}),
4793
+ children
4794
+ ]
4795
+ }
4796
+ )
4797
+ ] }),
4798
+ selecting && !replaced ? /* @__PURE__ */ jsx(
4799
+ ObjectListSelectionBar,
4646
4800
  {
4647
- "data-slot": "object-list-header-actions",
4648
- className: cn(
4649
- "ms-auto flex min-w-0 shrink-0 items-center gap-1",
4650
- // While search or new folder is open, that field takes the bar alone.
4651
- "group-data-search-open/object-list-header:ms-0 group-data-search-open/object-list-header:flex-1 group-data-search-open/object-list-header:[&>*:not([data-slot=object-list-search])]:hidden",
4652
- "group-data-folder-open/object-list-header:ms-0 group-data-folder-open/object-list-header:flex-1 group-data-folder-open/object-list-header:[&>*:not([data-slot=object-list-new-folder])]:hidden"
4653
- ),
4654
- children: [
4655
- /* @__PURE__ */ jsx(NewFolderControl, {}),
4656
- children
4657
- ]
4801
+ className: "border-t border-dimah-s3-border bg-dimah-s3-primary/10",
4802
+ actions: selectionActions ?? context.selectionActions
4658
4803
  }
4659
- )
4660
- ] })
4804
+ ) : null
4805
+ ]
4661
4806
  }
4662
4807
  ) });
4663
4808
  }
@@ -4686,10 +4831,9 @@ function ObjectListSelectionBar({
4686
4831
  className
4687
4832
  }) {
4688
4833
  const t = useTranslations();
4689
- const formatNumber = useFormatNumber();
4690
4834
  const { list, selection, delete: del } = useObjectListContext();
4835
+ const count = useSelectionCount(list, selection);
4691
4836
  if (!selection?.isSelecting) return null;
4692
- const count = formatNumber(selection.count);
4693
4837
  const busy = del != null && selection.selected.some(
4694
4838
  (entry) => entry.kind === "file" && del.pendingKeys.includes(objectKeyOf(entry))
4695
4839
  );
@@ -4703,20 +4847,7 @@ function ObjectListSelectionBar({
4703
4847
  ),
4704
4848
  children: [
4705
4849
  /* @__PURE__ */ jsx(ObjectListSelectAll, {}),
4706
- /* @__PURE__ */ jsx(
4707
- "p",
4708
- {
4709
- "aria-live": "polite",
4710
- className: "min-w-0 flex-1 truncate text-sm font-medium text-dimah-s3-foreground tabular-nums",
4711
- children: selection.allSelected && list.hasMore && !selection.persist ? t("{count} selected on this page", {
4712
- note: "object list selection",
4713
- variables: { count }
4714
- }) : t("{count} selected", {
4715
- note: "object list selection",
4716
- variables: { count }
4717
- })
4718
- }
4719
- ),
4850
+ /* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium text-dimah-s3-foreground tabular-nums", children: count }),
4720
4851
  /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
4721
4852
  actions ? /* @__PURE__ */ jsx(
4722
4853
  "div",
@@ -4742,6 +4873,19 @@ function ObjectListSelectionBar({
4742
4873
  }
4743
4874
  );
4744
4875
  }
4876
+ function useSelectionCount(list, selection) {
4877
+ const t = useTranslations();
4878
+ const formatNumber = useFormatNumber();
4879
+ if (!selection?.isSelecting) return null;
4880
+ const count = formatNumber(selection.count);
4881
+ return selection.allSelected && list.hasMore && !selection.persist ? t("{count} selected on this page", {
4882
+ note: "object list selection",
4883
+ variables: { count }
4884
+ }) : t("{count} selected", {
4885
+ note: "object list selection",
4886
+ variables: { count }
4887
+ });
4888
+ }
4745
4889
  function ObjectListBulkDelete() {
4746
4890
  const { delete: del, selection } = useObjectListContext();
4747
4891
  if (!del || !selection?.isSelecting) return null;
@@ -4749,6 +4893,7 @@ function ObjectListBulkDelete() {
4749
4893
  }
4750
4894
  function BulkDeleteControl() {
4751
4895
  const t = useTranslations();
4896
+ const formatError = useFormatError();
4752
4897
  const { selection, resolveFolderKeys } = useObjectListContext();
4753
4898
  const { delete: del, request } = useDeleteContext();
4754
4899
  const report = useObjectListFeedback();
@@ -4763,12 +4908,13 @@ function BulkDeleteControl() {
4763
4908
  let plan;
4764
4909
  try {
4765
4910
  plan = await planBulkDelete(selection.selected, resolveFolderKeys);
4766
- } catch {
4911
+ } catch (error) {
4767
4912
  report({
4768
4913
  type: "error",
4769
4914
  title: t("Could not delete the selection", {
4770
4915
  note: "object list selection"
4771
- })
4916
+ }),
4917
+ description: formatError(error)
4772
4918
  });
4773
4919
  return;
4774
4920
  } finally {
@@ -4785,7 +4931,20 @@ function BulkDeleteControl() {
4785
4931
  return;
4786
4932
  }
4787
4933
  setRequested(plan.targets.map((target) => target.objectKey));
4788
- request(plan.targets, { note, trigger });
4934
+ request(plan.targets, {
4935
+ note,
4936
+ trigger,
4937
+ onDeleted: (result) => {
4938
+ setRequested([]);
4939
+ const deleted = new Set(result.deleted);
4940
+ const emptied = plan.folders.filter(
4941
+ ({ objectKeys }) => objectKeys.length > 0 && objectKeys.every((key) => deleted.has(key))
4942
+ );
4943
+ if (emptied.length > 0) {
4944
+ selection.deselect(emptied.map(({ entryKey }) => entryKey));
4945
+ }
4946
+ }
4947
+ });
4789
4948
  }
4790
4949
  return /* @__PURE__ */ jsxs(
4791
4950
  Button,
@@ -4807,26 +4966,37 @@ function BulkDeleteControl() {
4807
4966
  }
4808
4967
  async function planBulkDelete(selected, resolveFolderKeys) {
4809
4968
  const targets = /* @__PURE__ */ new Map();
4810
- let skippedFolders = 0;
4811
4969
  for (const entry of selected) {
4812
- if (entry.kind === "file") {
4813
- const objectKey = objectKeyOf(entry);
4814
- targets.set(objectKey, {
4815
- objectKey,
4816
- fileName: entry.file.name,
4817
- fileSize: entry.file.size
4818
- });
4819
- } else if (resolveFolderKeys) {
4820
- for (const objectKey of await resolveFolderKeys(entry.folder)) {
4821
- if (!targets.has(objectKey)) targets.set(objectKey, { objectKey });
4822
- }
4823
- } else {
4824
- skippedFolders += 1;
4970
+ if (entry.kind !== "file") continue;
4971
+ const objectKey = objectKeyOf(entry);
4972
+ targets.set(objectKey, {
4973
+ objectKey,
4974
+ fileName: entry.file.name,
4975
+ fileSize: entry.file.size
4976
+ });
4977
+ }
4978
+ const selectedFolders = selected.filter((entry) => entry.kind === "folder");
4979
+ if (!resolveFolderKeys) {
4980
+ return {
4981
+ targets: [...targets.values()],
4982
+ folders: [],
4983
+ skippedFolders: selectedFolders.length
4984
+ };
4985
+ }
4986
+ const folders = await Promise.all(
4987
+ selectedFolders.map(async (entry) => ({
4988
+ entryKey: entry.key,
4989
+ objectKeys: await resolveFolderKeys(entry.folder)
4990
+ }))
4991
+ );
4992
+ for (const { objectKeys } of folders) {
4993
+ for (const objectKey of objectKeys) {
4994
+ if (!targets.has(objectKey)) targets.set(objectKey, { objectKey });
4825
4995
  }
4826
4996
  }
4827
- return { targets: [...targets.values()], skippedFolders };
4997
+ return { targets: [...targets.values()], folders, skippedFolders: 0 };
4828
4998
  }
4829
- function NewFolderControl({ className }) {
4999
+ function ObjectListNewFolder({ className }) {
4830
5000
  const t = useTranslations();
4831
5001
  const { list } = useObjectListContext();
4832
5002
  const header = useOptionalObjectListHeader();
@@ -4882,7 +5052,7 @@ function NewFolderForm({
4882
5052
  className
4883
5053
  }) {
4884
5054
  const t = useTranslations();
4885
- const formatError = useFormatDimahError();
5055
+ const formatError = useFormatError();
4886
5056
  const inputId = useId();
4887
5057
  const errorId = useId();
4888
5058
  const inputRef = useRef(null);
@@ -5028,10 +5198,15 @@ function NewFolderForm({
5028
5198
  }
5029
5199
  var ENTRY = "[data-slot=object-list-entry]";
5030
5200
  var TRIGGER = "[data-slot=object-list-entry-trigger]";
5201
+ var RENAME = "[data-slot=object-list-rename]";
5202
+ var ENTRIES_START = "[data-slot=object-list-entries-start]";
5203
+ var ENTRIES_END = "[data-slot=object-list-entries-end]";
5204
+ var CONTROL = "button, a[href], input, select, textarea, [role=checkbox], [tabindex]";
5031
5205
  function useObjectListKeyboard({
5032
5206
  list,
5033
5207
  selection,
5034
5208
  view,
5209
+ store,
5035
5210
  startRename
5036
5211
  }) {
5037
5212
  const spaceRef = useRef(false);
@@ -5048,13 +5223,19 @@ function useObjectListKeyboard({
5048
5223
  if (!(target instanceof HTMLElement) || !frame.contains(target)) return;
5049
5224
  if (isFieldTarget(target) || isOverlayTarget(target)) return;
5050
5225
  const modifier = event.ctrlKey || event.metaKey;
5226
+ const entry = entryOf(frame, target);
5227
+ if (event.key === "Tab") {
5228
+ if (!entry || modifier || event.altKey || target.closest(RENAME)) return;
5229
+ tabFrom(frame, entry, target, event);
5230
+ return;
5231
+ }
5051
5232
  if (event.key === "Escape") {
5052
5233
  if (!selection?.isSelecting) return;
5053
5234
  event.preventDefault();
5054
5235
  selection.clear();
5055
5236
  return;
5056
5237
  }
5057
- if (event.code === "KeyA" && modifier && !event.altKey && !event.shiftKey) {
5238
+ if (isSelectAllKey(event) && modifier && !event.altKey && !event.shiftKey) {
5058
5239
  if (!selection || selection.mode !== "multiple") return;
5059
5240
  if (selection.selectableCount === 0) return;
5060
5241
  event.preventDefault();
@@ -5068,12 +5249,11 @@ function useObjectListKeyboard({
5068
5249
  return;
5069
5250
  }
5070
5251
  if (event.key === "F2" && !modifier && !event.altKey && !event.shiftKey) {
5071
- if (!target.matches(TRIGGER)) return;
5072
- const key = target.dataset.entryKey;
5073
- const entry = key ? list.entries.find((item) => item.key === key) : null;
5074
- if (!entry || !canRenameEntry(entry, list)) return;
5252
+ const key = entry?.dataset.entryKey;
5253
+ const found = key ? list.entries.find((item) => item.key === key) : null;
5254
+ if (!found || !canRenameEntry(found, list)) return;
5075
5255
  event.preventDefault();
5076
- startRename(entry.key);
5256
+ startRename(found.key);
5077
5257
  return;
5078
5258
  }
5079
5259
  if (event.key === " " && !modifier) {
@@ -5085,7 +5265,15 @@ function useObjectListKeyboard({
5085
5265
  return;
5086
5266
  }
5087
5267
  if (modifier || event.altKey) return;
5088
- const step = focusStep(event.key, frame, view);
5268
+ const rtl = getComputedStyle(frame).direction === "rtl";
5269
+ if (view === "list" && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {
5270
+ if (!entry) return;
5271
+ event.preventDefault();
5272
+ const forward = event.key === "ArrowRight" ? !rtl : rtl;
5273
+ moveWithinEntry(entry, target, forward ? 1 : -1);
5274
+ return;
5275
+ }
5276
+ const step = focusStep(event.key, frame, view, rtl);
5089
5277
  if (step == null) return;
5090
5278
  event.preventDefault();
5091
5279
  moveFocus(frame, target, step);
@@ -5095,11 +5283,15 @@ function useObjectListKeyboard({
5095
5283
  spaceRef.current = false;
5096
5284
  event.preventDefault();
5097
5285
  }
5098
- return { onKeyDown, onKeyUp };
5286
+ function onFocus(event) {
5287
+ if (!(event.target instanceof HTMLElement)) return;
5288
+ const key = entryOf(event.currentTarget, event.target)?.dataset.entryKey;
5289
+ if (key) store.set({ tabStop: key });
5290
+ }
5291
+ return { onKeyDown, onKeyUp, onFocus };
5099
5292
  }
5100
- function focusStep(key, frame, view) {
5293
+ function focusStep(key, frame, view, rtl) {
5101
5294
  const columns = view === "grid" ? gridColumns(frame) : 1;
5102
- const rtl = getComputedStyle(frame).direction === "rtl";
5103
5295
  switch (key) {
5104
5296
  case "ArrowDown":
5105
5297
  return columns;
@@ -5139,6 +5331,32 @@ function moveFocus(frame, target, step) {
5139
5331
  trigger?.focus();
5140
5332
  trigger?.scrollIntoView({ block: "nearest" });
5141
5333
  }
5334
+ function entryOf(frame, target) {
5335
+ const entry = target.closest(ENTRY);
5336
+ return entry && frame.contains(entry) ? entry : null;
5337
+ }
5338
+ function entryControls(entry) {
5339
+ return [...entry.querySelectorAll(CONTROL)].filter(
5340
+ (control) => !control.matches(":disabled") && control.getAttribute("aria-hidden") !== "true" && !(control instanceof HTMLInputElement && control.type === "hidden") && !control.closest("[inert], [hidden]")
5341
+ );
5342
+ }
5343
+ function moveWithinEntry(entry, target, step) {
5344
+ const controls = entryControls(entry);
5345
+ const index = controls.findIndex((control) => control.contains(target));
5346
+ if (index < 0) return;
5347
+ controls[index + step]?.focus();
5348
+ }
5349
+ function tabFrom(frame, entry, target, event) {
5350
+ const controls = entryControls(entry);
5351
+ const index = controls.indexOf(target);
5352
+ const next = index < 0 ? void 0 : controls[index + (event.shiftKey ? -1 : 1)];
5353
+ if (next) {
5354
+ event.preventDefault();
5355
+ next.focus();
5356
+ return;
5357
+ }
5358
+ frame.querySelector(event.shiftKey ? ENTRIES_START : ENTRIES_END)?.focus({ preventScroll: true });
5359
+ }
5142
5360
  function isOverlayTarget(target) {
5143
5361
  return Boolean(
5144
5362
  target.closest(
@@ -5146,6 +5364,10 @@ function isOverlayTarget(target) {
5146
5364
  )
5147
5365
  );
5148
5366
  }
5367
+ function isSelectAllKey(event) {
5368
+ if (/^[a-z]$/i.test(event.key)) return event.key.toLowerCase() === "a";
5369
+ return event.code === "KeyA";
5370
+ }
5149
5371
  function ObjectListUsage({ className }) {
5150
5372
  const t = useTranslations();
5151
5373
  const { list } = useObjectListContext();
@@ -5255,7 +5477,7 @@ function ObjectList({
5255
5477
  toolbar,
5256
5478
  selectionActions,
5257
5479
  empty,
5258
- loadMore = "auto",
5480
+ pagination = "auto",
5259
5481
  height,
5260
5482
  maxHeight,
5261
5483
  className,
@@ -5271,6 +5493,7 @@ function ObjectList({
5271
5493
  useRefreshListAfterUpload(upload, list.refresh);
5272
5494
  const deleteFocus = useFocusAfterDelete();
5273
5495
  const { announcement, announce } = useObjectListAnnouncement();
5496
+ const selectionCount = useSelectionCount(list, selection ?? null);
5274
5497
  const [renamingKey, setRenamingKey] = useState(null);
5275
5498
  const renameFocusKey = useRef(null);
5276
5499
  const previousRenaming = useRef(null);
@@ -5281,51 +5504,207 @@ function ObjectList({
5281
5504
  const previous = previousRenaming.current;
5282
5505
  previousRenaming.current = renamingKey;
5283
5506
  if (previous == null || renamingKey != null) return;
5284
- if (renameFocusKey.current !== previous) return;
5507
+ const focusKey = renameFocusKey.current;
5285
5508
  renameFocusKey.current = null;
5286
- document.querySelector(
5509
+ if (focusKey !== previous) return;
5510
+ deleteFocus.frameRef.current?.querySelector(
5287
5511
  `[data-slot="object-list-entry-trigger"][data-entry-key="${CSS.escape(previous)}"]`
5288
5512
  )?.focus();
5289
- }, [renamingKey]);
5513
+ }, [deleteFocus.frameRef, renamingKey]);
5290
5514
  const frameHeight = cssLength(height);
5291
5515
  const frameMaxHeight = cssLength(maxHeight);
5292
- const context = {
5516
+ const sizing = frameHeight != null ? "fixed" : frameMaxHeight != null ? "max" : null;
5517
+ const label = rootLabel ?? t("Files", { note: "object list" });
5518
+ const selectableKeys = useSelectableKeys(list.entries, selection ?? null);
5519
+ const selectedKeys = selection?.selectedKeys ?? NO_KEYS;
5520
+ const selecting = selection?.isSelecting === true;
5521
+ const [store] = useState(
5522
+ () => createObjectListEntryStore({
5523
+ selected: selectedKeys,
5524
+ selecting,
5525
+ renaming: null,
5526
+ tabStop: list.entries[0]?.key ?? null
5527
+ })
5528
+ );
5529
+ useLayoutEffect(() => {
5530
+ const { tabStop } = store.get();
5531
+ store.set({
5532
+ selected: selectedKeys,
5533
+ selecting,
5534
+ renaming: renamingKey,
5535
+ // The entry that had the tab stop left: the first one takes it.
5536
+ tabStop: tabStop != null && list.entries.some((entry) => entry.key === tabStop) ? tabStop : list.entries[0]?.key ?? null
5537
+ });
5538
+ }, [list.entries, renamingKey, selectedKeys, selecting, store]);
5539
+ const latest = useRef({
5293
5540
  list,
5294
- selection: selection ?? null,
5295
- upload: upload ?? null,
5296
- download: download ?? null,
5297
- share: share ?? null,
5298
- delete: del ?? null,
5299
- toasts,
5300
- announce,
5301
- view,
5302
- setView(next) {
5303
- if (viewProp === void 0) setLocalView(next);
5304
- onViewChange?.(next);
5305
- },
5306
- label: rootLabel ?? t("Files", { note: "object list" }),
5307
- sizing: frameHeight != null ? "fixed" : frameMaxHeight != null ? "max" : null,
5308
- showBreadcrumb: breadcrumb,
5309
- selectionActions,
5310
- empty,
5311
- loadMore,
5541
+ selection,
5542
+ upload,
5312
5543
  onOpenItem,
5313
- resolveFolderKeys,
5314
- renamingKey,
5315
- startRename(key) {
5316
- const target = list.entries.find((entry) => entry.key === key);
5317
- if (!target || !canRenameEntry(target, list)) return;
5544
+ viewProp,
5545
+ onViewChange
5546
+ });
5547
+ useLayoutEffect(() => {
5548
+ latest.current = {
5549
+ list,
5550
+ selection,
5551
+ upload,
5552
+ onOpenItem,
5553
+ viewProp,
5554
+ onViewChange
5555
+ };
5556
+ });
5557
+ const setView = useCallback((next) => {
5558
+ if (latest.current.viewProp === void 0) setLocalView(next);
5559
+ latest.current.onViewChange?.(next);
5560
+ }, []);
5561
+ const startRename = useCallback(
5562
+ (key) => {
5563
+ const current = latest.current.list;
5564
+ const target = current.entries.find((entry) => entry.key === key);
5565
+ if (!target || !canRenameEntry(target, current)) return;
5318
5566
  setRenamingKey(key);
5567
+ store.set({ renaming: key });
5319
5568
  },
5320
- cancelRename(focus = false) {
5321
- if (focus) renameFocusKey.current = renamingKey;
5322
- setRenamingKey(null);
5569
+ [store]
5570
+ );
5571
+ const endRename = useCallback(
5572
+ (key, focus = false) => {
5573
+ if (focus) renameFocusKey.current = key;
5574
+ setRenamingKey((current) => current === key ? null : current);
5575
+ if (store.get().renaming === key) store.set({ renaming: null });
5323
5576
  },
5324
- renderEntry,
5325
- renderActions,
5326
- renderDescription,
5327
- renderMeta
5328
- };
5577
+ [store]
5578
+ );
5579
+ const open = useCallback((entry) => {
5580
+ const current = latest.current;
5581
+ if (entry.kind === "folder") current.list.openFolder(entry.folder);
5582
+ else current.onOpenItem?.(entry.item);
5583
+ }, []);
5584
+ const toggle = useCallback(
5585
+ (key, options) => {
5586
+ latest.current.selection?.toggle(key, options);
5587
+ },
5588
+ []
5589
+ );
5590
+ const folderDropTarget = useCallback((id) => {
5591
+ const handler = (name) => (event) => {
5592
+ const current = latest.current;
5593
+ current.upload?.getDropTargetProps(
5594
+ {},
5595
+ () => folderUploadCall(current.list, id) ?? {}
5596
+ )[name]?.(event);
5597
+ };
5598
+ return {
5599
+ onDragEnter: handler("onDragEnter"),
5600
+ onDragOver: handler("onDragOver"),
5601
+ onDragLeave: handler("onDragLeave"),
5602
+ onDrop: handler("onDrop")
5603
+ };
5604
+ }, []);
5605
+ const context = useMemo(
5606
+ () => ({
5607
+ list,
5608
+ selection: selection ?? null,
5609
+ upload: upload ?? null,
5610
+ download: download ?? null,
5611
+ share: share ?? null,
5612
+ delete: del ?? null,
5613
+ toasts,
5614
+ announce,
5615
+ view,
5616
+ setView,
5617
+ label,
5618
+ sizing,
5619
+ showBreadcrumb: breadcrumb,
5620
+ selectionActions,
5621
+ empty,
5622
+ pagination,
5623
+ onOpenItem,
5624
+ resolveFolderKeys,
5625
+ renamingKey,
5626
+ startRename,
5627
+ endRename,
5628
+ renderEntry,
5629
+ renderActions,
5630
+ renderDescription,
5631
+ renderMeta
5632
+ }),
5633
+ [
5634
+ announce,
5635
+ breadcrumb,
5636
+ del,
5637
+ download,
5638
+ empty,
5639
+ endRename,
5640
+ label,
5641
+ list,
5642
+ onOpenItem,
5643
+ pagination,
5644
+ renamingKey,
5645
+ renderActions,
5646
+ renderDescription,
5647
+ renderEntry,
5648
+ renderMeta,
5649
+ resolveFolderKeys,
5650
+ selection,
5651
+ selectionActions,
5652
+ setView,
5653
+ share,
5654
+ sizing,
5655
+ startRename,
5656
+ toasts,
5657
+ upload,
5658
+ view
5659
+ ]
5660
+ );
5661
+ const opensFiles = onOpenItem != null;
5662
+ const folderUploads = upload != null && list.uploadOptions != null;
5663
+ const canDownload = download != null;
5664
+ const canShare = share != null || download?.mode === "navigate";
5665
+ const canDelete = del != null;
5666
+ const renameFile = list.renameFile != null;
5667
+ const renameFolder = list.renameFolder != null;
5668
+ const scope = useMemo(
5669
+ () => ({
5670
+ store,
5671
+ selectable: selectableKeys,
5672
+ opensFiles,
5673
+ folderUploads,
5674
+ download: canDownload,
5675
+ share: canShare,
5676
+ delete: canDelete,
5677
+ renameFile,
5678
+ renameFolder,
5679
+ open,
5680
+ toggle,
5681
+ folderDropTarget,
5682
+ startRename,
5683
+ endRename,
5684
+ renderActions,
5685
+ renderDescription,
5686
+ renderMeta
5687
+ }),
5688
+ [
5689
+ canDelete,
5690
+ canDownload,
5691
+ canShare,
5692
+ endRename,
5693
+ folderDropTarget,
5694
+ folderUploads,
5695
+ open,
5696
+ opensFiles,
5697
+ renameFile,
5698
+ renameFolder,
5699
+ renderActions,
5700
+ renderDescription,
5701
+ renderMeta,
5702
+ selectableKeys,
5703
+ startRename,
5704
+ store,
5705
+ toggle
5706
+ ]
5707
+ );
5329
5708
  function handleDeleted(result) {
5330
5709
  if (result.deleted.length > 0) {
5331
5710
  const gone = new Set(result.deleted);
@@ -5381,18 +5760,35 @@ function ObjectList({
5381
5760
  }
5382
5761
  if (download) content = /* @__PURE__ */ jsx(Download, { download, children: content });
5383
5762
  if (upload) content = /* @__PURE__ */ jsx(Upload, { upload, children: content });
5384
- return /* @__PURE__ */ jsxs(ObjectListProvider, { value: context, children: [
5763
+ return /* @__PURE__ */ jsxs(ObjectListProvider, { value: context, scope, children: [
5385
5764
  content,
5386
5765
  toasts ? /* @__PURE__ */ jsxs(Fragment, { children: [
5387
5766
  upload ? /* @__PURE__ */ jsx(BuiltInUploadToasts, { upload }) : null,
5388
5767
  download ? /* @__PURE__ */ jsx(BuiltInDownloadToasts, { download }) : null,
5389
5768
  del ? /* @__PURE__ */ jsx(ObjectListDeleteToasts, { delete: del }) : null
5390
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5391
- del ? /* @__PURE__ */ jsx(ObjectListDeleteToasts, { delete: del, report: announce }) : null,
5392
- /* @__PURE__ */ jsx(ObjectListAnnouncer, { announcement })
5393
- ] })
5769
+ ] }) : del ? /* @__PURE__ */ jsx(ObjectListDeleteToasts, { delete: del, report: announce }) : null,
5770
+ /* @__PURE__ */ jsx(
5771
+ ObjectListAnnouncer,
5772
+ {
5773
+ announcement,
5774
+ status: selectionCount
5775
+ }
5776
+ )
5394
5777
  ] });
5395
5778
  }
5779
+ var NO_KEYS = /* @__PURE__ */ new Set();
5780
+ function useSelectableKeys(entries, selection) {
5781
+ const keys = selection ? entries.flatMap(
5782
+ (entry) => selection.canSelect(entry) ? [entry.key] : []
5783
+ ) : [];
5784
+ const [kept, setKept] = useState(() => new Set(keys));
5785
+ if (kept.size === keys.length && keys.every((key) => kept.has(key))) {
5786
+ return kept;
5787
+ }
5788
+ const next = new Set(keys);
5789
+ setKept(next);
5790
+ return next;
5791
+ }
5396
5792
  function useFocusAfterDelete() {
5397
5793
  const frameRef = useRef(null);
5398
5794
  const lastFocusRef = useRef(null);
@@ -5435,10 +5831,12 @@ function ObjectListFrame({
5435
5831
  children
5436
5832
  }) {
5437
5833
  const { list, selection, upload, view, label, sizing, startRename } = useObjectListContext();
5834
+ const { store } = useObjectListEntryScope();
5438
5835
  const keyboard = useObjectListKeyboard({
5439
5836
  list,
5440
5837
  selection,
5441
5838
  view,
5839
+ store,
5442
5840
  startRename
5443
5841
  });
5444
5842
  const busy = list.isLoading || list.isRefreshing || list.isLoadingMore;
@@ -5485,7 +5883,10 @@ function ObjectListFrame({
5485
5883
  className
5486
5884
  ),
5487
5885
  style,
5488
- onFocus,
5886
+ onFocus: (event) => {
5887
+ onFocus(event);
5888
+ keyboard.onFocus(event);
5889
+ },
5489
5890
  onPaste,
5490
5891
  onDragEnter: (event) => {
5491
5892
  if (!takesFiles) return;
@@ -5810,6 +6211,6 @@ function ObjectListViewToggle({ className }) {
5810
6211
  );
5811
6212
  }
5812
6213
 
5813
- export { AttachmentAction, AttachmentGroup, AttachmentTrigger, AvatarUpload, CircleProgress, Delete, DeleteConfirmDialog, DeleteToasts, DeleteTrigger, DismissAttachmentAction, Download, DownloadProgress, DownloadToasts, DownloadTrigger, FileAttachment, FileName, FileTypeGlyph, FolderGlyph, NewFolderControl, ObjectCard, ObjectImage, ObjectList, ObjectListBreadcrumb, ObjectListBulkDelete, ObjectListCheckbox, ObjectListContent, ObjectListEmpty, ObjectListHeader, ObjectListItemMenu, ObjectListRow, ObjectListSearch, ObjectListSelectAll, ObjectListSelectionBar, ObjectListSortMenu, ObjectListTile, ObjectListUploadStatus, ObjectListUsage, ObjectListViewToggle, StatusAttachment, Toaster, Upload, UploadDropzone, UploadDropzoneTrigger, UploadField, UploadFieldValue, UploadFileItem, UploadFileList, UploadStatus, UploadToasts, UploadTrigger, toast, useDeleteContext, useDownloadContext, useObjectListContext, useObjectListEntry, usePasteFiles, useToastOwner, useUploadContext, useUploadFieldContext, useUploadHints };
6214
+ export { AttachmentAction, AttachmentGroup, AttachmentTrigger, AvatarUpload, CircleProgress, Delete, DeleteConfirmDialog, DeleteToasts, DeleteTrigger, DismissAttachmentAction, Download, DownloadProgress, DownloadToasts, DownloadTrigger, FileAttachment, FileName, FileTypeGlyph, FolderGlyph, ObjectCard, ObjectImage, ObjectList, ObjectListBreadcrumb, ObjectListBulkDelete, ObjectListCheckbox, ObjectListContent, ObjectListEmpty, ObjectListHeader, ObjectListItemMenu, ObjectListNewFolder, ObjectListRow, ObjectListSearch, ObjectListSelectAll, ObjectListSelectionBar, ObjectListSortMenu, ObjectListTile, ObjectListUploadStatus, ObjectListUsage, ObjectListViewToggle, StatusAttachment, Toaster, Upload, UploadDropzone, UploadDropzoneTrigger, UploadField, UploadFieldValue, UploadFileItem, UploadFileList, UploadStatus, UploadToasts, UploadTrigger, toast, useDeleteContext, useDownloadContext, useObjectListContext, useObjectListEntry, usePasteFiles, useToastOwner, useUploadContext, useUploadFieldContext, useUploadHints };
5814
6215
  //# sourceMappingURL=index.js.map
5815
6216
  //# sourceMappingURL=index.js.map