@dimah-s3/ui 2.0.0-beta.1 → 2.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/components/dimah-s3/attachment/file-attachment.d.ts +7 -1
- package/dist/components/dimah-s3/attachment/file-attachment.d.ts.map +1 -1
- package/dist/components/dimah-s3/attachment/file-name.d.ts +11 -1
- package/dist/components/dimah-s3/attachment/file-name.d.ts.map +1 -1
- package/dist/components/dimah-s3/attachment/file-type-glyph.d.ts +17 -4
- package/dist/components/dimah-s3/attachment/file-type-glyph.d.ts.map +1 -1
- package/dist/components/dimah-s3/delete/delete-confirm-dialog.d.ts.map +1 -1
- package/dist/components/dimah-s3/delete/delete-toasts.d.ts.map +1 -1
- package/dist/components/dimah-s3/delete/delete-trigger.d.ts +6 -4
- package/dist/components/dimah-s3/delete/delete-trigger.d.ts.map +1 -1
- package/dist/components/dimah-s3/delete/delete.d.ts +22 -9
- package/dist/components/dimah-s3/delete/delete.d.ts.map +1 -1
- package/dist/components/dimah-s3/download/download-progress.d.ts +2 -2
- package/dist/components/dimah-s3/download/download-progress.d.ts.map +1 -1
- package/dist/components/dimah-s3/download/download-trigger.d.ts +1 -0
- package/dist/components/dimah-s3/download/download-trigger.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-commands.d.ts +26 -0
- package/dist/components/dimah-s3/list/object-list-commands.d.ts.map +1 -0
- package/dist/components/dimah-s3/list/object-list-content.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-context.d.ts +124 -5
- package/dist/components/dimah-s3/list/object-list-context.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-controls.d.ts +0 -24
- package/dist/components/dimah-s3/list/object-list-controls.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-entry.d.ts +10 -5
- package/dist/components/dimah-s3/list/object-list-entry.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-feedback.d.ts +9 -2
- package/dist/components/dimah-s3/list/object-list-feedback.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-header.d.ts +18 -14
- package/dist/components/dimah-s3/list/object-list-header.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-item-menu.d.ts +8 -4
- package/dist/components/dimah-s3/list/object-list-item-menu.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-keyboard.d.ts +13 -3
- package/dist/components/dimah-s3/list/object-list-keyboard.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-rename.d.ts +11 -0
- package/dist/components/dimah-s3/list/object-list-rename.d.ts.map +1 -0
- package/dist/components/dimah-s3/list/object-list-search.d.ts +75 -0
- package/dist/components/dimah-s3/list/object-list-search.d.ts.map +1 -0
- package/dist/components/dimah-s3/list/object-list-states.d.ts +7 -2
- package/dist/components/dimah-s3/list/object-list-states.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list.d.ts +11 -5
- package/dist/components/dimah-s3/list/object-list.d.ts.map +1 -1
- package/dist/components/dimah-s3/preview/object-card.d.ts.map +1 -1
- package/dist/components/dimah-s3/preview/object-image.d.ts +6 -4
- package/dist/components/dimah-s3/preview/object-image.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/avatar-upload.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/upload-field.d.ts +22 -13
- package/dist/components/dimah-s3/upload/upload-field.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/upload-file-list.d.ts +3 -1
- package/dist/components/dimah-s3/upload/upload-file-list.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/upload-status.d.ts +4 -2
- package/dist/components/dimah-s3/upload/upload-status.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/upload-toasts.d.ts.map +1 -1
- package/dist/components/dimah-s3/upload/upload.d.ts +7 -6
- package/dist/components/dimah-s3/upload/upload.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.d.ts +1 -1
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts +1 -1
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/empty.d.ts +6 -7
- package/dist/components/ui/empty.d.ts.map +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/item.d.ts.map +1 -1
- package/dist/components/ui/skeleton.d.ts +1 -2
- package/dist/components/ui/skeleton.d.ts.map +1 -1
- package/dist/components/ui/spinner.d.ts +1 -3
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/toast.d.ts +1 -1
- package/dist/components/ui/toast.d.ts.map +1 -1
- package/dist/{lib/format-expires-in.d.ts → hooks/use-share-expiry-label.d.ts} +1 -1
- package/dist/hooks/use-share-expiry-label.d.ts.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1835 -770
- package/dist/index.js.map +1 -1
- package/dist/lib/toast-content.d.ts +19 -0
- package/dist/lib/toast-content.d.ts.map +1 -0
- package/package.json +14 -14
- package/dist/lib/format-expires-in.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,39 +1,71 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createContext,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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, FolderIcon, ChevronRightIcon, Loader2Icon, FolderOpenIcon, CloudUpload, PencilIcon, LoaderIcon, DownloadIcon, LinkIcon, Trash2Icon, RotateCwIcon, PauseIcon, BanIcon, FileUpIcon, CameraIcon, SearchIcon, HomeIcon, FolderPlusIcon, ArrowDownUpIcon, ListIcon, LayoutGridIcon, UserIcon, LoaderCircleIcon, AlertCircleIcon, CheckCircleIcon, 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 {
|
|
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
|
+
import { findSearchMatches, fileNameFromKey, isS3ErrorCode } from '@dimah-s3/core';
|
|
14
15
|
import { FileIcon, defaultStyles } from 'react-file-icon';
|
|
15
16
|
import { Toast as Toast$1 } from '@base-ui/react/toast';
|
|
16
|
-
import { fileNameFromKey, isS3ErrorCode } from '@dimah-s3/core';
|
|
17
17
|
import { AlertDialog as AlertDialog$1 } from '@base-ui/react/alert-dialog';
|
|
18
18
|
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
|
+
}
|
|
42
|
+
var ObjectListHeaderContext = createContext(null);
|
|
43
|
+
function useOptionalObjectListHeader() {
|
|
44
|
+
return useContext(ObjectListHeaderContext);
|
|
45
|
+
}
|
|
22
46
|
var ObjectListContext = createContext(
|
|
23
47
|
null
|
|
24
48
|
);
|
|
49
|
+
var ObjectListEntryScopeContext = createContext(null);
|
|
25
50
|
var ObjectListEntryContext = createContext(
|
|
26
51
|
null
|
|
27
52
|
);
|
|
28
53
|
function ObjectListProvider({
|
|
29
54
|
value,
|
|
55
|
+
scope,
|
|
30
56
|
children
|
|
31
57
|
}) {
|
|
32
58
|
return /* @__PURE__ */ jsx(
|
|
33
59
|
ObjectListContext.Provider,
|
|
34
60
|
{
|
|
35
61
|
value,
|
|
36
|
-
children
|
|
62
|
+
children: /* @__PURE__ */ jsx(
|
|
63
|
+
ObjectListEntryScopeContext.Provider,
|
|
64
|
+
{
|
|
65
|
+
value: scope ?? null,
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
)
|
|
37
69
|
}
|
|
38
70
|
);
|
|
39
71
|
}
|
|
@@ -58,6 +90,40 @@ function useOptionalObjectListContext() {
|
|
|
58
90
|
function useObjectListEntry() {
|
|
59
91
|
return useContext(ObjectListEntryContext);
|
|
60
92
|
}
|
|
93
|
+
function useOptionalObjectListEntryScope() {
|
|
94
|
+
return useContext(
|
|
95
|
+
ObjectListEntryScopeContext
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function useObjectListEntryScope() {
|
|
99
|
+
const scope = useOptionalObjectListEntryScope();
|
|
100
|
+
if (!scope) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
"[dimah-s3] Object list parts must be rendered inside <ObjectList>."
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return scope;
|
|
106
|
+
}
|
|
107
|
+
var SELECTED = 1;
|
|
108
|
+
var SELECTING = 2;
|
|
109
|
+
var RENAMING = 4;
|
|
110
|
+
var TAB_STOP = 8;
|
|
111
|
+
function useObjectListEntryStatus(key) {
|
|
112
|
+
const { store, selectable } = useObjectListEntryScope();
|
|
113
|
+
const read = () => entryFlags(store.get(), key);
|
|
114
|
+
const flags = useSyncExternalStore(store.subscribe, read, read);
|
|
115
|
+
const canSelect = selectable.has(key);
|
|
116
|
+
return {
|
|
117
|
+
selectable: canSelect,
|
|
118
|
+
selected: canSelect && (flags & SELECTED) !== 0,
|
|
119
|
+
selecting: (flags & SELECTING) !== 0,
|
|
120
|
+
renaming: (flags & RENAMING) !== 0,
|
|
121
|
+
tabStop: (flags & TAB_STOP) !== 0
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function entryFlags(state, key) {
|
|
125
|
+
return (state.selected.has(key) ? SELECTED : 0) | (state.selecting ? SELECTING : 0) | (state.renaming === key ? RENAMING : 0) | (state.tabStop === key ? TAB_STOP : 0);
|
|
126
|
+
}
|
|
61
127
|
var UploadContext = createContext(null);
|
|
62
128
|
var INTAKE_ATTRIBUTE = "data-dimah-s3-upload-intake";
|
|
63
129
|
var UploadFocusContext = createContext(null);
|
|
@@ -89,7 +155,7 @@ function Upload({
|
|
|
89
155
|
if (handoff.from.isConnected && active === handoff.from) return;
|
|
90
156
|
handoffRef.current = null;
|
|
91
157
|
if (active instanceof HTMLElement && active !== document.body) return;
|
|
92
|
-
|
|
158
|
+
focusFirst(handoffTargets(handoff, rootId));
|
|
93
159
|
});
|
|
94
160
|
return /* @__PURE__ */ jsx(UploadContext.Provider, { value, children: /* @__PURE__ */ jsxs(UploadFocusContext.Provider, { value: focus, children: [
|
|
95
161
|
/* @__PURE__ */ jsx("input", { ...upload.getInputProps() }),
|
|
@@ -139,7 +205,7 @@ function focusHandoff() {
|
|
|
139
205
|
focusRoot: scope.closest(FOCUS_ROOT)
|
|
140
206
|
};
|
|
141
207
|
}
|
|
142
|
-
function
|
|
208
|
+
function handoffTargets(handoff, rootId) {
|
|
143
209
|
const intake = document.querySelectorAll(
|
|
144
210
|
`[${INTAKE_ATTRIBUTE}="${CSS.escape(rootId)}"]`
|
|
145
211
|
);
|
|
@@ -149,12 +215,15 @@ function handoffTarget(handoff, rootId) {
|
|
|
149
215
|
...handoff.scope.isConnected ? handoff.scope.querySelectorAll("button") : [],
|
|
150
216
|
...intake,
|
|
151
217
|
handoff.focusRoot
|
|
152
|
-
].
|
|
153
|
-
(element) => element != null && element.isConnected
|
|
154
|
-
)
|
|
218
|
+
].filter(
|
|
219
|
+
(element) => element != null && element.isConnected
|
|
220
|
+
);
|
|
155
221
|
}
|
|
156
|
-
function
|
|
157
|
-
|
|
222
|
+
function focusFirst(elements) {
|
|
223
|
+
for (const element of elements) {
|
|
224
|
+
element.focus();
|
|
225
|
+
if (document.activeElement === element) return;
|
|
226
|
+
}
|
|
158
227
|
}
|
|
159
228
|
function useUploadCall(upload, call) {
|
|
160
229
|
const objectList = useOptionalObjectListContext();
|
|
@@ -609,13 +678,40 @@ function splitFileName(name) {
|
|
|
609
678
|
if (!FILE_EXTENSION.test(extension)) return { stem: name, extension: "" };
|
|
610
679
|
return { stem: name.slice(0, dot), extension };
|
|
611
680
|
}
|
|
681
|
+
function markMatches(text, offset, ranges) {
|
|
682
|
+
if (ranges.length === 0) return text;
|
|
683
|
+
const parts = [];
|
|
684
|
+
let at = 0;
|
|
685
|
+
for (const [start, end] of ranges) {
|
|
686
|
+
const from = Math.max(start - offset, at);
|
|
687
|
+
const to = Math.min(end - offset, text.length);
|
|
688
|
+
if (to <= from) continue;
|
|
689
|
+
if (from > at) parts.push(text.slice(at, from));
|
|
690
|
+
parts.push(
|
|
691
|
+
/* @__PURE__ */ jsx(
|
|
692
|
+
"mark",
|
|
693
|
+
{
|
|
694
|
+
"data-slot": "file-name-match",
|
|
695
|
+
className: "rounded-[2px] bg-dimah-s3-warning/30 text-inherit",
|
|
696
|
+
children: text.slice(from, to)
|
|
697
|
+
},
|
|
698
|
+
from
|
|
699
|
+
)
|
|
700
|
+
);
|
|
701
|
+
at = to;
|
|
702
|
+
}
|
|
703
|
+
if (at < text.length) parts.push(text.slice(at));
|
|
704
|
+
return parts;
|
|
705
|
+
}
|
|
612
706
|
function FileName({
|
|
613
707
|
name,
|
|
614
708
|
extension: keepExtension = true,
|
|
709
|
+
highlight,
|
|
615
710
|
className,
|
|
616
711
|
...props
|
|
617
712
|
}) {
|
|
618
713
|
const { stem, extension } = keepExtension ? splitFileName(name) : { stem: name, extension: "" };
|
|
714
|
+
const ranges = highlight ? findSearchMatches(name, highlight) : [];
|
|
619
715
|
return /* @__PURE__ */ jsxs(
|
|
620
716
|
"span",
|
|
621
717
|
{
|
|
@@ -625,70 +721,17 @@ function FileName({
|
|
|
625
721
|
...props,
|
|
626
722
|
className: cn("inline-flex max-w-full min-w-0 align-top", className),
|
|
627
723
|
children: [
|
|
628
|
-
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: stem }),
|
|
629
|
-
extension ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: extension }) : null
|
|
724
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: markMatches(stem, 0, ranges) }),
|
|
725
|
+
extension ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: markMatches(extension, stem.length, ranges) }) : null
|
|
630
726
|
]
|
|
631
727
|
}
|
|
632
728
|
);
|
|
633
729
|
}
|
|
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
730
|
var STYLE_ALIASES = {
|
|
691
|
-
"7z": "7zip"
|
|
731
|
+
"7z": "7zip",
|
|
732
|
+
jpe: "jpg",
|
|
733
|
+
markdown: "md",
|
|
734
|
+
yaml: "yml"
|
|
692
735
|
};
|
|
693
736
|
var MIME_TO_EXT = {
|
|
694
737
|
"application/pdf": "pdf",
|
|
@@ -708,8 +751,10 @@ var MIME_TO_EXT = {
|
|
|
708
751
|
"application/gzip": "gz",
|
|
709
752
|
"audio/mpeg": "mp3",
|
|
710
753
|
"audio/wav": "wav",
|
|
754
|
+
"audio/flac": "flac",
|
|
755
|
+
"audio/ogg": "ogg",
|
|
711
756
|
"audio/mp4": "m4a",
|
|
712
|
-
"audio/aac": "
|
|
757
|
+
"audio/aac": "aac",
|
|
713
758
|
"video/mp4": "mp4",
|
|
714
759
|
"video/quicktime": "mov",
|
|
715
760
|
"video/webm": "webm",
|
|
@@ -718,57 +763,41 @@ var MIME_TO_EXT = {
|
|
|
718
763
|
"image/jpeg": "jpg",
|
|
719
764
|
"image/gif": "gif",
|
|
720
765
|
"image/webp": "webp",
|
|
766
|
+
"image/avif": "avif",
|
|
721
767
|
"image/svg+xml": "svg",
|
|
722
768
|
"image/heic": "heic",
|
|
769
|
+
"image/tiff": "tiff",
|
|
723
770
|
"application/json": "json",
|
|
724
771
|
"text/javascript": "js",
|
|
725
772
|
"application/javascript": "js",
|
|
726
|
-
"text/typescript": "ts",
|
|
727
|
-
"application/typescript": "ts",
|
|
728
|
-
"text/jsx": "jsx",
|
|
729
773
|
"text/html": "html",
|
|
730
774
|
"text/css": "css",
|
|
731
775
|
"text/plain": "txt",
|
|
732
776
|
"text/markdown": "md"
|
|
733
777
|
};
|
|
778
|
+
function familyStyle(mime) {
|
|
779
|
+
if (mime.startsWith("image/")) return { type: "image" };
|
|
780
|
+
if (mime.startsWith("audio/")) return { type: "audio" };
|
|
781
|
+
if (mime.startsWith("video/")) return { type: "video" };
|
|
782
|
+
if (mime.startsWith("font/")) return { type: "font" };
|
|
783
|
+
if (mime.startsWith("text/")) return { type: "document" };
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
734
786
|
function extensionOf(fileName) {
|
|
735
787
|
const base = fileName.split(/[/\\]/).pop() ?? fileName;
|
|
736
788
|
const dot = base.lastIndexOf(".");
|
|
737
789
|
if (dot <= 0 || dot === base.length - 1) return null;
|
|
738
790
|
return base.slice(dot + 1).toLowerCase();
|
|
739
791
|
}
|
|
740
|
-
function
|
|
741
|
-
|
|
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;
|
|
792
|
+
function stylesOf(ext) {
|
|
793
|
+
return defaultStyles[STYLE_ALIASES[ext] ?? ext] ?? null;
|
|
752
794
|
}
|
|
753
|
-
function
|
|
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
|
-
}
|
|
795
|
+
function resolveFileTypeGlyph(fileName, contentType) {
|
|
796
|
+
const mime = contentType?.trim().toLowerCase() ?? "";
|
|
761
797
|
const ext = extensionOf(fileName);
|
|
762
|
-
|
|
763
|
-
|
|
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 {};
|
|
798
|
+
const mimeExt = MIME_TO_EXT[mime] ?? null;
|
|
799
|
+
const styles = (mimeExt ? stylesOf(mimeExt) : null) ?? (ext ? stylesOf(ext) : null) ?? familyStyle(mime) ?? { type: "document" };
|
|
800
|
+
return { label: mimeExt ?? ext, styles };
|
|
772
801
|
}
|
|
773
802
|
function FileTypeGlyph({
|
|
774
803
|
fileName,
|
|
@@ -776,9 +805,7 @@ function FileTypeGlyph({
|
|
|
776
805
|
layout = "fill",
|
|
777
806
|
className
|
|
778
807
|
}) {
|
|
779
|
-
const
|
|
780
|
-
const label = ext ?? extensionOf(fileName) ?? void 0;
|
|
781
|
-
const styles = ext ? stylesFor(ext) : { type: "document" };
|
|
808
|
+
const { label, styles } = resolveFileTypeGlyph(fileName, contentType);
|
|
782
809
|
return /* @__PURE__ */ jsx(
|
|
783
810
|
"span",
|
|
784
811
|
{
|
|
@@ -788,7 +815,7 @@ function FileTypeGlyph({
|
|
|
788
815
|
className
|
|
789
816
|
),
|
|
790
817
|
"aria-hidden": true,
|
|
791
|
-
children: /* @__PURE__ */ jsx(FileIcon, { extension: label, ...styles })
|
|
818
|
+
children: /* @__PURE__ */ jsx(FileIcon, { extension: label ?? void 0, ...styles })
|
|
792
819
|
}
|
|
793
820
|
);
|
|
794
821
|
}
|
|
@@ -803,6 +830,7 @@ function FileAttachment({
|
|
|
803
830
|
error,
|
|
804
831
|
onCancel,
|
|
805
832
|
onRetry,
|
|
833
|
+
retryDisabled = false,
|
|
806
834
|
onDismiss,
|
|
807
835
|
actions,
|
|
808
836
|
trigger,
|
|
@@ -810,12 +838,13 @@ function FileAttachment({
|
|
|
810
838
|
...props
|
|
811
839
|
}) {
|
|
812
840
|
const t = useTranslations();
|
|
813
|
-
const formatError =
|
|
841
|
+
const formatError = useFormatError();
|
|
814
842
|
const formatFileSize = useFormatFileSize();
|
|
815
843
|
const errorText = error == null ? null : typeof error === "string" ? error : formatError(error);
|
|
816
|
-
const resolvedDescription = description ?? (state === "error" ? errorText ?? t("
|
|
844
|
+
const resolvedDescription = description ?? (state === "error" ? errorText ?? t("Failed", { note: "status" }) : fileSize != null ? formatFileSize(fileSize) : null);
|
|
817
845
|
const showCancel = (state === "idle" || state === "uploading" || state === "processing") && onCancel != null;
|
|
818
846
|
const showRetry = state === "error" && onRetry != null;
|
|
847
|
+
const retryUnavailable = showRetry && !showCancel && retryDisabled;
|
|
819
848
|
const showDismiss = (state === "done" || state === "error") && onDismiss != null;
|
|
820
849
|
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
850
|
CircleProgress,
|
|
@@ -871,6 +900,9 @@ function FileAttachment({
|
|
|
871
900
|
AttachmentAction,
|
|
872
901
|
{
|
|
873
902
|
type: "button",
|
|
903
|
+
disabled: retryUnavailable,
|
|
904
|
+
focusableWhenDisabled: retryUnavailable,
|
|
905
|
+
className: "aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
|
|
874
906
|
"aria-label": showCancel ? t("Cancel {name}", {
|
|
875
907
|
note: "attachment action",
|
|
876
908
|
variables: { name: fileName }
|
|
@@ -909,7 +941,7 @@ function UploadFileItem({
|
|
|
909
941
|
const t = useTranslations();
|
|
910
942
|
const formatEta = useFormatEta();
|
|
911
943
|
const formatFileSize = useFormatFileSize();
|
|
912
|
-
const { upload } = useUploadContext();
|
|
944
|
+
const { upload, isFull } = useUploadContext();
|
|
913
945
|
const { keepFocus } = useUploadFocus();
|
|
914
946
|
const eta = file.phase === "uploading" ? formatEta(file.progress) : null;
|
|
915
947
|
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 +961,7 @@ function UploadFileItem({
|
|
|
929
961
|
upload.cancel(file.id);
|
|
930
962
|
},
|
|
931
963
|
onRetry: () => void upload.retry(file.id),
|
|
964
|
+
retryDisabled: isFull,
|
|
932
965
|
...props
|
|
933
966
|
}
|
|
934
967
|
);
|
|
@@ -1022,7 +1055,7 @@ function UploadStatus({
|
|
|
1022
1055
|
state: "processing",
|
|
1023
1056
|
title: t("Preparing\u2026", { note: "upload status" })
|
|
1024
1057
|
}
|
|
1025
|
-
) :
|
|
1058
|
+
) : shown.length === 1 && layout === "list" ? /* @__PURE__ */ jsx(UploadFileItem, { file: shown[0], actions: pause, onDismiss }) : /* @__PURE__ */ jsxs(
|
|
1026
1059
|
"div",
|
|
1027
1060
|
{
|
|
1028
1061
|
"data-slot": "upload-status-panel",
|
|
@@ -1051,16 +1084,27 @@ function UploadSummary({
|
|
|
1051
1084
|
onDismiss
|
|
1052
1085
|
}) {
|
|
1053
1086
|
const t = useTranslations();
|
|
1054
|
-
const formatError =
|
|
1087
|
+
const formatError = useFormatError();
|
|
1055
1088
|
const formatEta = useFormatEta();
|
|
1056
1089
|
const formatFileSize = useFormatFileSize();
|
|
1057
1090
|
const formatNumber = useFormatNumber();
|
|
1058
|
-
const { upload } = useUploadContext();
|
|
1091
|
+
const { upload, isFull } = useUploadContext();
|
|
1059
1092
|
const { keepFocus } = useUploadFocus();
|
|
1060
1093
|
const { files, progress } = upload;
|
|
1061
|
-
const summaryActions = (label, icon, onClick) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1094
|
+
const summaryActions = (label, icon, onClick, disabled = false) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1062
1095
|
pause,
|
|
1063
|
-
/* @__PURE__ */ jsx(
|
|
1096
|
+
/* @__PURE__ */ jsx(
|
|
1097
|
+
AttachmentAction,
|
|
1098
|
+
{
|
|
1099
|
+
type: "button",
|
|
1100
|
+
"aria-label": label,
|
|
1101
|
+
disabled,
|
|
1102
|
+
focusableWhenDisabled: disabled,
|
|
1103
|
+
className: "aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
|
|
1104
|
+
onClick,
|
|
1105
|
+
children: icon
|
|
1106
|
+
}
|
|
1107
|
+
)
|
|
1064
1108
|
] });
|
|
1065
1109
|
if (upload.phase === "success") {
|
|
1066
1110
|
return /* @__PURE__ */ jsx(
|
|
@@ -1090,7 +1134,8 @@ function UploadSummary({
|
|
|
1090
1134
|
actions: summaryActions(
|
|
1091
1135
|
t("Retry failed uploads", { note: "upload control" }),
|
|
1092
1136
|
/* @__PURE__ */ jsx(RotateCwIcon, {}),
|
|
1093
|
-
() => void upload.retry()
|
|
1137
|
+
() => void upload.retry(),
|
|
1138
|
+
isFull
|
|
1094
1139
|
),
|
|
1095
1140
|
onDismiss
|
|
1096
1141
|
}
|
|
@@ -1327,7 +1372,7 @@ function UploadDropzoneTrigger({
|
|
|
1327
1372
|
"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
1373
|
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
1374
|
),
|
|
1330
|
-
children: /* @__PURE__ */ jsx(Icon, { className: "size-5", strokeWidth: 1.75 })
|
|
1375
|
+
children: /* @__PURE__ */ jsx(Icon, { className: "pointer-events-none size-5", strokeWidth: 1.75 })
|
|
1331
1376
|
}
|
|
1332
1377
|
),
|
|
1333
1378
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
@@ -1577,6 +1622,29 @@ function useToastOwner(instanceId, options = {}) {
|
|
|
1577
1622
|
() => false
|
|
1578
1623
|
);
|
|
1579
1624
|
}
|
|
1625
|
+
function ToastText({ children }) {
|
|
1626
|
+
return /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children });
|
|
1627
|
+
}
|
|
1628
|
+
function ToastNumbers({ children }) {
|
|
1629
|
+
return /* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children });
|
|
1630
|
+
}
|
|
1631
|
+
function ToastFile({
|
|
1632
|
+
name,
|
|
1633
|
+
detail,
|
|
1634
|
+
error
|
|
1635
|
+
}) {
|
|
1636
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1637
|
+
/* @__PURE__ */ jsxs("span", { className: "block", children: [
|
|
1638
|
+
/* @__PURE__ */ jsx(FileName, { name }),
|
|
1639
|
+
detail ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1640
|
+
" ",
|
|
1641
|
+
"\xB7 ",
|
|
1642
|
+
/* @__PURE__ */ jsx(ToastNumbers, { children: detail })
|
|
1643
|
+
] }) : null
|
|
1644
|
+
] }),
|
|
1645
|
+
error ? /* @__PURE__ */ jsx(ToastText, { children: error }) : null
|
|
1646
|
+
] });
|
|
1647
|
+
}
|
|
1580
1648
|
function UploadToasts({ upload }) {
|
|
1581
1649
|
const active = useToastOwner(upload.instanceId);
|
|
1582
1650
|
return active ? /* @__PURE__ */ jsx(ActiveUploadToasts, { upload }) : null;
|
|
@@ -1585,15 +1653,12 @@ function BuiltInUploadToasts({ upload }) {
|
|
|
1585
1653
|
const active = useToastOwner(upload.instanceId, { weak: true });
|
|
1586
1654
|
return active ? /* @__PURE__ */ jsx(ActiveUploadToasts, { upload }) : null;
|
|
1587
1655
|
}
|
|
1588
|
-
function numbers(text) {
|
|
1589
|
-
return /* @__PURE__ */ jsx("bdi", { className: "inline-block whitespace-nowrap tabular-nums", children: text });
|
|
1590
|
-
}
|
|
1591
1656
|
function isSettled(file) {
|
|
1592
1657
|
return file.phase === "success" || file.phase === "error";
|
|
1593
1658
|
}
|
|
1594
1659
|
function ActiveUploadToasts({ upload }) {
|
|
1595
1660
|
const t = useTranslations();
|
|
1596
|
-
const formatError =
|
|
1661
|
+
const formatError = useFormatError();
|
|
1597
1662
|
const formatFileSize = useFormatFileSize();
|
|
1598
1663
|
const formatNumber = useFormatNumber();
|
|
1599
1664
|
const { files, isPending, progress, fileRejections } = upload;
|
|
@@ -1631,9 +1696,13 @@ function ActiveUploadToasts({ upload }) {
|
|
|
1631
1696
|
total: formatNumber(files.length)
|
|
1632
1697
|
}
|
|
1633
1698
|
}) : t("Uploading", { note: "toast" }),
|
|
1634
|
-
description:
|
|
1635
|
-
|
|
1636
|
-
|
|
1699
|
+
description: /* @__PURE__ */ jsx(ToastNumbers, { children: t("{loaded} of {total}", {
|
|
1700
|
+
note: "transfer progress",
|
|
1701
|
+
variables: {
|
|
1702
|
+
loaded: formatFileSize(progress.loaded),
|
|
1703
|
+
total: formatFileSize(progress.total)
|
|
1704
|
+
}
|
|
1705
|
+
}) }),
|
|
1637
1706
|
actionProps: {
|
|
1638
1707
|
children: t("Cancel", { note: "toast action" }),
|
|
1639
1708
|
onClick: () => actionsRef.current.cancel()
|
|
@@ -1666,11 +1735,23 @@ function ActiveUploadToasts({ upload }) {
|
|
|
1666
1735
|
failed.length === 0 ? {
|
|
1667
1736
|
type: "success",
|
|
1668
1737
|
title: t("Upload complete", { note: "toast" }),
|
|
1669
|
-
description:
|
|
1738
|
+
description: /* @__PURE__ */ jsx(
|
|
1739
|
+
ToastFile,
|
|
1740
|
+
{
|
|
1741
|
+
name: first.fileName,
|
|
1742
|
+
detail: formatFileSize(first.fileSize)
|
|
1743
|
+
}
|
|
1744
|
+
)
|
|
1670
1745
|
} : {
|
|
1671
1746
|
type: "error",
|
|
1672
1747
|
title: t("Upload failed", { note: "toast" }),
|
|
1673
|
-
description:
|
|
1748
|
+
description: /* @__PURE__ */ jsx(
|
|
1749
|
+
ToastFile,
|
|
1750
|
+
{
|
|
1751
|
+
name: first.fileName,
|
|
1752
|
+
error: formatError(first.error)
|
|
1753
|
+
}
|
|
1754
|
+
),
|
|
1674
1755
|
actionProps: retryAction(first.id)
|
|
1675
1756
|
}
|
|
1676
1757
|
);
|
|
@@ -1683,11 +1764,9 @@ function ActiveUploadToasts({ upload }) {
|
|
|
1683
1764
|
note: "toast",
|
|
1684
1765
|
variables: { count: formatNumber(fresh.length) }
|
|
1685
1766
|
}),
|
|
1686
|
-
description:
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
)
|
|
1690
|
-
)
|
|
1767
|
+
description: /* @__PURE__ */ jsx(ToastNumbers, { children: formatFileSize(
|
|
1768
|
+
fresh.reduce((total, file) => total + file.fileSize, 0)
|
|
1769
|
+
) })
|
|
1691
1770
|
} : {
|
|
1692
1771
|
type: "error",
|
|
1693
1772
|
title: t("Upload finished with errors", { note: "toast" }),
|
|
@@ -1723,13 +1802,7 @@ function ActiveUploadToasts({ upload }) {
|
|
|
1723
1802
|
fileRejections.length === 1 ? {
|
|
1724
1803
|
type: "error",
|
|
1725
1804
|
title: t("File not accepted", { note: "toast" }),
|
|
1726
|
-
description:
|
|
1727
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1728
|
-
/* @__PURE__ */ jsx("bdi", { children: first.file.name }),
|
|
1729
|
-
": ",
|
|
1730
|
-
reason
|
|
1731
|
-
] })
|
|
1732
|
-
)
|
|
1805
|
+
description: /* @__PURE__ */ jsx(ToastFile, { name: first.file.name, error: reason })
|
|
1733
1806
|
} : {
|
|
1734
1807
|
type: "error",
|
|
1735
1808
|
title: t("{count} files were rejected", {
|
|
@@ -1737,15 +1810,12 @@ function ActiveUploadToasts({ upload }) {
|
|
|
1737
1810
|
variables: { count: formatNumber(fileRejections.length) }
|
|
1738
1811
|
}),
|
|
1739
1812
|
// One shared reason is worth showing; a mix of reasons is not.
|
|
1740
|
-
description: reasons.size === 1 ?
|
|
1813
|
+
description: reasons.size === 1 ? /* @__PURE__ */ jsx(ToastText, { children: reason }) : void 0
|
|
1741
1814
|
}
|
|
1742
1815
|
);
|
|
1743
1816
|
}, [fileRejections, t, formatError, formatNumber]);
|
|
1744
1817
|
return null;
|
|
1745
1818
|
}
|
|
1746
|
-
function wrapText(content) {
|
|
1747
|
-
return /* @__PURE__ */ jsx("span", { className: "block [overflow-wrap:anywhere]", children: content });
|
|
1748
|
-
}
|
|
1749
1819
|
|
|
1750
1820
|
// src/lib/is-field-target.ts
|
|
1751
1821
|
function isFieldTarget(target) {
|
|
@@ -1875,13 +1945,14 @@ function UploadField({
|
|
|
1875
1945
|
(key) => setValue(value.filter((item) => item !== key)),
|
|
1876
1946
|
[setValue, value]
|
|
1877
1947
|
);
|
|
1878
|
-
const
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1948
|
+
const remaining = useUploadLimit(
|
|
1949
|
+
upload,
|
|
1950
|
+
maxFiles == null ? null : { available: Math.max(0, maxFiles - value.length), counted: seen }
|
|
1951
|
+
);
|
|
1952
|
+
const isFull = remaining === 0;
|
|
1882
1953
|
const fieldUpload = useMemo(
|
|
1883
|
-
() =>
|
|
1884
|
-
[
|
|
1954
|
+
() => fieldUploadOf(upload, isFull),
|
|
1955
|
+
[isFull, upload]
|
|
1885
1956
|
);
|
|
1886
1957
|
const contextValue = useMemo(
|
|
1887
1958
|
() => ({
|
|
@@ -1904,7 +1975,7 @@ function UploadField({
|
|
|
1904
1975
|
return /* @__PURE__ */ jsxs(UploadFieldContext.Provider, { value: contextValue, children: [
|
|
1905
1976
|
/* @__PURE__ */ jsx("input", { ref: anchorRef, type: "hidden" }),
|
|
1906
1977
|
value.map((key) => /* @__PURE__ */ jsx("input", { type: "hidden", name, value: key }, key)),
|
|
1907
|
-
/* @__PURE__ */ jsx(Upload, { upload: fieldUpload, isFull
|
|
1978
|
+
/* @__PURE__ */ jsx(Upload, { upload: fieldUpload, isFull, hideUploaded: true, children })
|
|
1908
1979
|
] });
|
|
1909
1980
|
}
|
|
1910
1981
|
function useUploadFieldContext() {
|
|
@@ -1975,51 +2046,27 @@ function withDetails(details, uploaded) {
|
|
|
1975
2046
|
}
|
|
1976
2047
|
return next;
|
|
1977
2048
|
}
|
|
1978
|
-
function
|
|
1979
|
-
|
|
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) => ({
|
|
2049
|
+
function fieldUploadOf(upload, isFull) {
|
|
2050
|
+
const queued = (call) => ({
|
|
2012
2051
|
...call,
|
|
2013
|
-
|
|
2052
|
+
queue: true
|
|
2014
2053
|
});
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2054
|
+
const queuedInput = (call) => typeof call === "function" ? () => queued(call()) : queued(call);
|
|
2055
|
+
const fieldUpload = {
|
|
2017
2056
|
...upload,
|
|
2018
|
-
handleFiles: (files, call) => upload.handleFiles(files,
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2057
|
+
handleFiles: (files, call) => upload.handleFiles(files, queued(call)),
|
|
2058
|
+
open: (call) => upload.open(queued(call)),
|
|
2059
|
+
getRootProps: (props, call) => upload.getRootProps(props, queuedInput(call)),
|
|
2060
|
+
getDropTargetProps: (props, call) => upload.getDropTargetProps(props, queuedInput(call))
|
|
2061
|
+
};
|
|
2062
|
+
if (!isFull) return fieldUpload;
|
|
2063
|
+
return {
|
|
2064
|
+
...fieldUpload,
|
|
2065
|
+
open: () => {
|
|
2066
|
+
},
|
|
2067
|
+
// Not `upload.getRootProps`: its handlers would open the picker.
|
|
2068
|
+
getRootProps: (props) => ({ tabIndex: 0, ...props, "aria-disabled": true }),
|
|
2069
|
+
getDropTargetProps: (props) => ({ ...props })
|
|
2023
2070
|
};
|
|
2024
2071
|
}
|
|
2025
2072
|
function ObjectImage({
|
|
@@ -2029,11 +2076,12 @@ function ObjectImage({
|
|
|
2029
2076
|
api,
|
|
2030
2077
|
fallback = null,
|
|
2031
2078
|
onError,
|
|
2079
|
+
onLoad,
|
|
2032
2080
|
...props
|
|
2033
2081
|
}) {
|
|
2034
|
-
const { url } = useObjectUrl({ api, route, objectKey });
|
|
2035
|
-
const [
|
|
2036
|
-
if (url == null || url ===
|
|
2082
|
+
const { url, refresh } = useObjectUrl({ api, route, objectKey });
|
|
2083
|
+
const [failure, setFailure] = useState(null);
|
|
2084
|
+
if (url == null || failure?.url === url) return fallback;
|
|
2037
2085
|
return /* @__PURE__ */ jsx(
|
|
2038
2086
|
"img",
|
|
2039
2087
|
{
|
|
@@ -2041,9 +2089,15 @@ function ObjectImage({
|
|
|
2041
2089
|
...props,
|
|
2042
2090
|
src: url,
|
|
2043
2091
|
alt,
|
|
2092
|
+
onLoad: (event) => {
|
|
2093
|
+
if (failure) setFailure(null);
|
|
2094
|
+
onLoad?.(event);
|
|
2095
|
+
},
|
|
2044
2096
|
onError: (event) => {
|
|
2045
|
-
setBrokenUrl(url);
|
|
2046
2097
|
onError?.(event);
|
|
2098
|
+
const retried = failure?.objectKey === objectKey && failure.retried;
|
|
2099
|
+
setFailure({ objectKey, url, retried: true });
|
|
2100
|
+
if (!retried) refresh();
|
|
2047
2101
|
}
|
|
2048
2102
|
}
|
|
2049
2103
|
);
|
|
@@ -2071,7 +2125,12 @@ function AvatarUpload({
|
|
|
2071
2125
|
}) {
|
|
2072
2126
|
const { file } = upload;
|
|
2073
2127
|
const inFlight = file != null && IN_FLIGHT.has(file.phase);
|
|
2074
|
-
const
|
|
2128
|
+
const [uploaded, setUploaded] = useState(null);
|
|
2129
|
+
if (file?.phase === "success" && uploaded?.id !== file.id) {
|
|
2130
|
+
setUploaded({ id: file.id, objectKey });
|
|
2131
|
+
}
|
|
2132
|
+
const previewCurrent = file?.phase === "success" && (uploaded?.id !== file.id || objectKey === uploaded.objectKey || objectKey === file.result?.key);
|
|
2133
|
+
const previewUrl = inFlight || previewCurrent ? file?.previewUrl ?? null : null;
|
|
2075
2134
|
const announcement = useAnnouncement(upload);
|
|
2076
2135
|
const reportUploaded = useEffectEvent((result) => {
|
|
2077
2136
|
onChange?.(result);
|
|
@@ -2158,7 +2217,7 @@ function AvatarUpload({
|
|
|
2158
2217
|
}
|
|
2159
2218
|
function useAnnouncement(upload) {
|
|
2160
2219
|
const t = useTranslations();
|
|
2161
|
-
const formatError =
|
|
2220
|
+
const formatError = useFormatError();
|
|
2162
2221
|
const rejection = upload.fileRejections[0]?.errors[0];
|
|
2163
2222
|
if (rejection) return formatError(rejection);
|
|
2164
2223
|
const { file } = upload;
|
|
@@ -2340,26 +2399,24 @@ function DeleteConfirmDialog({
|
|
|
2340
2399
|
const t = useTranslations();
|
|
2341
2400
|
const formatFileSize = useFormatFileSize();
|
|
2342
2401
|
const formatNumber = useFormatNumber();
|
|
2343
|
-
const {
|
|
2402
|
+
const {
|
|
2403
|
+
confirmation,
|
|
2404
|
+
isDeleting: busy,
|
|
2405
|
+
confirm,
|
|
2406
|
+
dismiss
|
|
2407
|
+
} = useDeleteContext();
|
|
2344
2408
|
const cancelRef = useRef(null);
|
|
2345
|
-
const [
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
const current = pending ?? shown;
|
|
2409
|
+
const [shown, setShown] = useState(confirmation);
|
|
2410
|
+
if (confirmation && confirmation !== shown) setShown(confirmation);
|
|
2411
|
+
const current = confirmation ?? shown;
|
|
2349
2412
|
const targets = current?.targets ?? [];
|
|
2350
2413
|
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
2414
|
return /* @__PURE__ */ jsx(
|
|
2358
2415
|
AlertDialog,
|
|
2359
2416
|
{
|
|
2360
|
-
open:
|
|
2417
|
+
open: confirmation != null,
|
|
2361
2418
|
onOpenChange: (open) => {
|
|
2362
|
-
if (!open)
|
|
2419
|
+
if (!open) dismiss();
|
|
2363
2420
|
},
|
|
2364
2421
|
children: /* @__PURE__ */ jsxs(AlertDialogContent, { initialFocus: cancelRef, finalFocus: false, children: [
|
|
2365
2422
|
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
@@ -2397,7 +2454,7 @@ function DeleteConfirmDialog({
|
|
|
2397
2454
|
disabled: busy,
|
|
2398
2455
|
focusableWhenDisabled: true,
|
|
2399
2456
|
"aria-busy": busy || void 0,
|
|
2400
|
-
onClick:
|
|
2457
|
+
onClick: () => void confirm(),
|
|
2401
2458
|
children: [
|
|
2402
2459
|
busy ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : null,
|
|
2403
2460
|
confirmLabel ?? t("Delete", { note: "dialog confirm" })
|
|
@@ -2418,6 +2475,7 @@ function fileLabel(target, formatFileSize) {
|
|
|
2418
2475
|
return target.fileSize != null ? `${name} (${isolateText(formatFileSize(target.fileSize))})` : name;
|
|
2419
2476
|
}
|
|
2420
2477
|
var FOCUS_ROOT2 = "[data-dimah-s3-focus-root]";
|
|
2478
|
+
var EMPTY_RESULT = { deleted: [], failed: [], blocked: [] };
|
|
2421
2479
|
var DeleteContext = createContext(null);
|
|
2422
2480
|
function Delete({
|
|
2423
2481
|
delete: del,
|
|
@@ -2428,6 +2486,7 @@ function Delete({
|
|
|
2428
2486
|
children
|
|
2429
2487
|
}) {
|
|
2430
2488
|
const [active, setActive] = useState(null);
|
|
2489
|
+
const [isDeleting, setDeleting] = useState(false);
|
|
2431
2490
|
const [focusReturn, setFocusReturn] = useState(null);
|
|
2432
2491
|
const activeRef = useRef(null);
|
|
2433
2492
|
const runningRef = useRef(null);
|
|
@@ -2437,13 +2496,25 @@ function Delete({
|
|
|
2437
2496
|
});
|
|
2438
2497
|
const removeTargets = useCallback(
|
|
2439
2498
|
async (request2) => {
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
fileName
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2499
|
+
let result;
|
|
2500
|
+
try {
|
|
2501
|
+
result = await latest.current.del.removeMany(
|
|
2502
|
+
request2.targets.map(({ objectKey, fileName }) => ({
|
|
2503
|
+
key: objectKey,
|
|
2504
|
+
fileName
|
|
2505
|
+
}))
|
|
2506
|
+
);
|
|
2507
|
+
} catch (error) {
|
|
2508
|
+
reportError(error);
|
|
2509
|
+
return EMPTY_RESULT;
|
|
2510
|
+
}
|
|
2511
|
+
for (const onDeleted2 of [latest.current.onDeleted, request2.onDeleted]) {
|
|
2512
|
+
try {
|
|
2513
|
+
onDeleted2?.(result);
|
|
2514
|
+
} catch (error) {
|
|
2515
|
+
reportError(error);
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2447
2518
|
return result;
|
|
2448
2519
|
},
|
|
2449
2520
|
[]
|
|
@@ -2462,6 +2533,7 @@ function Delete({
|
|
|
2462
2533
|
const next = {
|
|
2463
2534
|
targets,
|
|
2464
2535
|
note: options.note,
|
|
2536
|
+
onDeleted: options.onDeleted,
|
|
2465
2537
|
trigger,
|
|
2466
2538
|
focusRoot: trigger?.closest(FOCUS_ROOT2) ?? null
|
|
2467
2539
|
};
|
|
@@ -2470,7 +2542,7 @@ function Delete({
|
|
|
2470
2542
|
setActive(next);
|
|
2471
2543
|
return;
|
|
2472
2544
|
}
|
|
2473
|
-
void removeTargets(next).
|
|
2545
|
+
void removeTargets(next).then(() => {
|
|
2474
2546
|
setFocusReturn({ ...next, always: false });
|
|
2475
2547
|
});
|
|
2476
2548
|
},
|
|
@@ -2479,17 +2551,18 @@ function Delete({
|
|
|
2479
2551
|
const confirm = useCallback(() => {
|
|
2480
2552
|
if (runningRef.current) return runningRef.current;
|
|
2481
2553
|
const current = activeRef.current;
|
|
2482
|
-
if (!current)
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
const running = removeTargets(current).finally(() => {
|
|
2554
|
+
if (!current) return Promise.resolve(EMPTY_RESULT);
|
|
2555
|
+
setDeleting(true);
|
|
2556
|
+
const running = removeTargets(current).then((result) => {
|
|
2486
2557
|
runningRef.current = null;
|
|
2558
|
+
setDeleting(false);
|
|
2487
2559
|
close(current);
|
|
2560
|
+
return result;
|
|
2488
2561
|
});
|
|
2489
2562
|
runningRef.current = running;
|
|
2490
2563
|
return running;
|
|
2491
2564
|
}, [close, removeTargets]);
|
|
2492
|
-
const
|
|
2565
|
+
const dismiss = useCallback(() => {
|
|
2493
2566
|
if (runningRef.current || !activeRef.current) return;
|
|
2494
2567
|
close(activeRef.current);
|
|
2495
2568
|
}, [close]);
|
|
@@ -2502,13 +2575,20 @@ function Delete({
|
|
|
2502
2575
|
].find((element) => element?.isConnected);
|
|
2503
2576
|
target?.focus();
|
|
2504
2577
|
}, [focusReturn]);
|
|
2505
|
-
const
|
|
2578
|
+
const confirmation = useMemo(
|
|
2506
2579
|
() => active ? { targets: active.targets, note: active.note } : null,
|
|
2507
2580
|
[active]
|
|
2508
2581
|
);
|
|
2509
2582
|
const value = useMemo(
|
|
2510
|
-
() => ({
|
|
2511
|
-
|
|
2583
|
+
() => ({
|
|
2584
|
+
delete: del,
|
|
2585
|
+
confirmation,
|
|
2586
|
+
isDeleting,
|
|
2587
|
+
request,
|
|
2588
|
+
confirm,
|
|
2589
|
+
dismiss
|
|
2590
|
+
}),
|
|
2591
|
+
[del, confirmation, isDeleting, request, confirm, dismiss]
|
|
2512
2592
|
);
|
|
2513
2593
|
return /* @__PURE__ */ jsxs(DeleteContext.Provider, { value, children: [
|
|
2514
2594
|
children,
|
|
@@ -2527,6 +2607,13 @@ function useDeleteContext() {
|
|
|
2527
2607
|
function isTargetList(input) {
|
|
2528
2608
|
return Array.isArray(input);
|
|
2529
2609
|
}
|
|
2610
|
+
function reportError(error) {
|
|
2611
|
+
if (typeof globalThis.reportError === "function") {
|
|
2612
|
+
globalThis.reportError(error);
|
|
2613
|
+
} else {
|
|
2614
|
+
console.error(error);
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2530
2617
|
function focusedElement() {
|
|
2531
2618
|
const element = document.activeElement;
|
|
2532
2619
|
return element instanceof HTMLElement && element !== document.body ? element : null;
|
|
@@ -2541,6 +2628,7 @@ function DeleteTrigger({
|
|
|
2541
2628
|
note,
|
|
2542
2629
|
tooltip,
|
|
2543
2630
|
variant = "destructive",
|
|
2631
|
+
size,
|
|
2544
2632
|
disabled,
|
|
2545
2633
|
focusableWhenDisabled,
|
|
2546
2634
|
onClick,
|
|
@@ -2549,14 +2637,18 @@ function DeleteTrigger({
|
|
|
2549
2637
|
}) {
|
|
2550
2638
|
const t = useTranslations();
|
|
2551
2639
|
const { delete: del, request } = useDeleteContext();
|
|
2552
|
-
const deleting = del.
|
|
2640
|
+
const deleting = del.pendingKeys.includes(objectKey);
|
|
2641
|
+
const iconOnly = size?.startsWith("icon") ?? false;
|
|
2642
|
+
const icon = deleting ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : /* @__PURE__ */ jsx(Trash2Icon, { "data-icon": "inline-start" });
|
|
2553
2643
|
const button = /* @__PURE__ */ jsx(
|
|
2554
2644
|
Button,
|
|
2555
2645
|
{
|
|
2556
2646
|
"data-slot": "delete-trigger",
|
|
2647
|
+
"data-phase": del.get(objectKey)?.phase,
|
|
2557
2648
|
"aria-busy": deleting || void 0,
|
|
2558
|
-
...props,
|
|
2559
2649
|
variant,
|
|
2650
|
+
size,
|
|
2651
|
+
...props,
|
|
2560
2652
|
disabled: Boolean(disabled) || deleting,
|
|
2561
2653
|
focusableWhenDisabled: focusableWhenDisabled ?? deleting,
|
|
2562
2654
|
onClick: (event) => {
|
|
@@ -2567,10 +2659,10 @@ function DeleteTrigger({
|
|
|
2567
2659
|
{ note, trigger: event.currentTarget }
|
|
2568
2660
|
);
|
|
2569
2661
|
},
|
|
2570
|
-
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2571
|
-
|
|
2662
|
+
children: children ?? (iconOnly ? icon : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2663
|
+
icon,
|
|
2572
2664
|
t("Delete", { note: "button" })
|
|
2573
|
-
] })
|
|
2665
|
+
] }))
|
|
2574
2666
|
}
|
|
2575
2667
|
);
|
|
2576
2668
|
if (tooltip == null) return button;
|
|
@@ -2606,7 +2698,7 @@ function useFormatDownloadedBytes() {
|
|
|
2606
2698
|
({ loaded, total }) => {
|
|
2607
2699
|
if (total > 0) {
|
|
2608
2700
|
return t("{loaded} of {total}", {
|
|
2609
|
-
note: "
|
|
2701
|
+
note: "transfer progress",
|
|
2610
2702
|
variables: {
|
|
2611
2703
|
loaded: formatFileSize(loaded),
|
|
2612
2704
|
total: formatFileSize(total)
|
|
@@ -2642,17 +2734,23 @@ function DownloadTrigger({
|
|
|
2642
2734
|
const progress = cancellable && operation?.phase === "downloading" ? operation.progress : null;
|
|
2643
2735
|
const fillPercent = progress && progress.total > 0 ? Math.min(100, Math.max(0, progress.percent)) : null;
|
|
2644
2736
|
const iconOnly = size?.startsWith("icon") ?? false;
|
|
2645
|
-
const
|
|
2737
|
+
const withLabel = (icon, label) => iconOnly ? icon : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2738
|
+
icon,
|
|
2739
|
+
label
|
|
2740
|
+
] });
|
|
2741
|
+
const content = cancellable ? withLabel(
|
|
2646
2742
|
/* @__PURE__ */ jsx(XIcon, { "data-icon": "inline-start" }),
|
|
2647
2743
|
t("Cancel", { note: "download control" })
|
|
2648
|
-
|
|
2744
|
+
) : children ?? withLabel(
|
|
2649
2745
|
signing ? /* @__PURE__ */ jsx(LoaderIcon, { className: "animate-spin", "data-icon": "inline-start" }) : /* @__PURE__ */ jsx(DownloadIcon, { "data-icon": "inline-start" }),
|
|
2650
2746
|
t("Download", { note: "button" })
|
|
2651
|
-
|
|
2747
|
+
);
|
|
2652
2748
|
const button = /* @__PURE__ */ jsxs(
|
|
2653
2749
|
Button,
|
|
2654
2750
|
{
|
|
2655
2751
|
"data-slot": "download-trigger",
|
|
2752
|
+
"data-phase": operation?.phase,
|
|
2753
|
+
"aria-busy": signing || void 0,
|
|
2656
2754
|
variant,
|
|
2657
2755
|
size,
|
|
2658
2756
|
...props,
|
|
@@ -2662,10 +2760,8 @@ function DownloadTrigger({
|
|
|
2662
2760
|
name: fileName ?? fileNameFromKey(objectKey) ?? objectKey
|
|
2663
2761
|
}
|
|
2664
2762
|
}) : ariaLabel,
|
|
2665
|
-
"aria-busy": signing || void 0,
|
|
2666
|
-
"data-phase": operation?.phase,
|
|
2667
2763
|
disabled: Boolean(disabled) || signing,
|
|
2668
|
-
focusableWhenDisabled:
|
|
2764
|
+
focusableWhenDisabled: focusableWhenDisabled ?? signing,
|
|
2669
2765
|
className: cn("relative isolate overflow-hidden", className),
|
|
2670
2766
|
onClick: (event) => {
|
|
2671
2767
|
onClick?.(event);
|
|
@@ -2719,7 +2815,7 @@ function ObjectCard({
|
|
|
2719
2815
|
const name = fileName ?? fileNameFromKey(objectKey) ?? objectKey;
|
|
2720
2816
|
const operation = download?.mode === "fetch" ? download.get(objectKey) : void 0;
|
|
2721
2817
|
const downloading = operation != null && isDownloadRunning(operation);
|
|
2722
|
-
const deleting = del?.
|
|
2818
|
+
const deleting = del?.pendingKeys.includes(objectKey) ?? false;
|
|
2723
2819
|
const state = deleting ? "processing" : downloading ? "uploading" : "done";
|
|
2724
2820
|
const percent = downloading && operation.phase === "downloading" && operation.progress.total > 0 ? operation.progress.percent : 0;
|
|
2725
2821
|
let card = /* @__PURE__ */ jsx(
|
|
@@ -2744,8 +2840,7 @@ function ObjectCard({
|
|
|
2744
2840
|
note: "attachment action",
|
|
2745
2841
|
variables: { name }
|
|
2746
2842
|
}),
|
|
2747
|
-
tooltip: t("Download", { note: "button" })
|
|
2748
|
-
children: /* @__PURE__ */ jsx(DownloadIcon, {})
|
|
2843
|
+
tooltip: t("Download", { note: "button" })
|
|
2749
2844
|
}
|
|
2750
2845
|
) : null,
|
|
2751
2846
|
del ? /* @__PURE__ */ jsx(
|
|
@@ -2761,8 +2856,7 @@ function ObjectCard({
|
|
|
2761
2856
|
note: "attachment action",
|
|
2762
2857
|
variables: { name }
|
|
2763
2858
|
}),
|
|
2764
|
-
tooltip: t("Delete", { note: "button" })
|
|
2765
|
-
children: /* @__PURE__ */ jsx(Trash2Icon, {})
|
|
2859
|
+
tooltip: t("Delete", { note: "button" })
|
|
2766
2860
|
}
|
|
2767
2861
|
) : null
|
|
2768
2862
|
] }) : void 0,
|
|
@@ -2840,7 +2934,7 @@ function isFetchOperation(operation) {
|
|
|
2840
2934
|
}
|
|
2841
2935
|
function ActiveDownloadToasts({ download }) {
|
|
2842
2936
|
const t = useTranslations();
|
|
2843
|
-
const
|
|
2937
|
+
const formatError = useFormatError();
|
|
2844
2938
|
const formatFileSize = useFormatFileSize();
|
|
2845
2939
|
const formatDownloadedBytes = useFormatDownloadedBytes();
|
|
2846
2940
|
const { operations, cancel } = download;
|
|
@@ -2853,15 +2947,14 @@ function ActiveDownloadToasts({ download }) {
|
|
|
2853
2947
|
const done = announced.current;
|
|
2854
2948
|
const open = loading.current;
|
|
2855
2949
|
const current = new Set(operations.map((op) => op.id));
|
|
2856
|
-
const describe = (operation, detail) => /* @__PURE__ */
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
] });
|
|
2950
|
+
const describe = (operation, detail, error) => /* @__PURE__ */ jsx(
|
|
2951
|
+
ToastFile,
|
|
2952
|
+
{
|
|
2953
|
+
name: downloadDisplayName(operation),
|
|
2954
|
+
detail,
|
|
2955
|
+
error
|
|
2956
|
+
}
|
|
2957
|
+
);
|
|
2865
2958
|
const showProgress = (operation) => {
|
|
2866
2959
|
const options = {
|
|
2867
2960
|
type: "loading",
|
|
@@ -2869,7 +2962,7 @@ function ActiveDownloadToasts({ download }) {
|
|
|
2869
2962
|
title: t("Downloading", { note: "toast" }),
|
|
2870
2963
|
description: describe(
|
|
2871
2964
|
operation,
|
|
2872
|
-
formatDownloadedBytes(operation.progress)
|
|
2965
|
+
formatDownloadedBytes(operation.progress)
|
|
2873
2966
|
),
|
|
2874
2967
|
actionProps: {
|
|
2875
2968
|
children: t("Cancel", { note: "toast action" }),
|
|
@@ -2902,7 +2995,11 @@ function ActiveDownloadToasts({ download }) {
|
|
|
2902
2995
|
toast.add({
|
|
2903
2996
|
type: "error",
|
|
2904
2997
|
title: t("Download failed", { note: "toast" }),
|
|
2905
|
-
description:
|
|
2998
|
+
description: describe(
|
|
2999
|
+
operation,
|
|
3000
|
+
null,
|
|
3001
|
+
formatError(operation.error)
|
|
3002
|
+
)
|
|
2906
3003
|
});
|
|
2907
3004
|
return;
|
|
2908
3005
|
case "aborted":
|
|
@@ -2943,7 +3040,7 @@ function ActiveDownloadToasts({ download }) {
|
|
|
2943
3040
|
operations,
|
|
2944
3041
|
cancel,
|
|
2945
3042
|
t,
|
|
2946
|
-
|
|
3043
|
+
formatError,
|
|
2947
3044
|
formatFileSize,
|
|
2948
3045
|
formatDownloadedBytes
|
|
2949
3046
|
]);
|
|
@@ -2962,7 +3059,7 @@ function DeleteToasts({ delete: del }) {
|
|
|
2962
3059
|
}
|
|
2963
3060
|
function useDeleteToasts(del, options = {}) {
|
|
2964
3061
|
const t = useTranslations();
|
|
2965
|
-
const formatError =
|
|
3062
|
+
const formatError = useFormatError();
|
|
2966
3063
|
const formatNumber = useFormatNumber();
|
|
2967
3064
|
const active = useToastOwner(del.instanceId, { weak: options.weak });
|
|
2968
3065
|
const report = options.report ?? addToast;
|
|
@@ -2982,7 +3079,7 @@ function useDeleteToasts(del, options = {}) {
|
|
|
2982
3079
|
note: "toast",
|
|
2983
3080
|
variables: { count: formatNumber(deleted.length) }
|
|
2984
3081
|
}),
|
|
2985
|
-
description: deleted.length === 1 ? /* @__PURE__ */ jsx(
|
|
3082
|
+
description: deleted.length === 1 ? /* @__PURE__ */ jsx(ToastFile, { name: displayName(firstDeleted) }) : void 0
|
|
2986
3083
|
});
|
|
2987
3084
|
}
|
|
2988
3085
|
const [firstFailed] = failed;
|
|
@@ -2996,7 +3093,13 @@ function useDeleteToasts(del, options = {}) {
|
|
|
2996
3093
|
note: "toast",
|
|
2997
3094
|
variables: { count: formatNumber(failed.length) }
|
|
2998
3095
|
}),
|
|
2999
|
-
description:
|
|
3096
|
+
description: failed.length === 1 ? /* @__PURE__ */ jsx(
|
|
3097
|
+
ToastFile,
|
|
3098
|
+
{
|
|
3099
|
+
name: displayName(firstFailed),
|
|
3100
|
+
error: formatError(firstFailed.error)
|
|
3101
|
+
}
|
|
3102
|
+
) : sameCause ? /* @__PURE__ */ jsx(ToastText, { children: formatError(firstFailed.error) }) : void 0
|
|
3000
3103
|
});
|
|
3001
3104
|
}
|
|
3002
3105
|
}
|
|
@@ -3043,15 +3146,12 @@ function Checkbox({ className, ...props }) {
|
|
|
3043
3146
|
className
|
|
3044
3147
|
),
|
|
3045
3148
|
...props,
|
|
3046
|
-
children: /* @__PURE__ */
|
|
3149
|
+
children: /* @__PURE__ */ jsx(
|
|
3047
3150
|
Checkbox$1.Indicator,
|
|
3048
3151
|
{
|
|
3049
3152
|
"data-slot": "checkbox-indicator",
|
|
3050
3153
|
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
|
-
]
|
|
3154
|
+
children: /* @__PURE__ */ jsx(CheckIcon, {})
|
|
3055
3155
|
}
|
|
3056
3156
|
)
|
|
3057
3157
|
}
|
|
@@ -3110,7 +3210,7 @@ function DropdownMenuContent({
|
|
|
3110
3210
|
{
|
|
3111
3211
|
"data-slot": "dropdown-menu-content",
|
|
3112
3212
|
className: cn(
|
|
3113
|
-
"
|
|
3213
|
+
"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
3214
|
className
|
|
3115
3215
|
),
|
|
3116
3216
|
...props
|
|
@@ -3181,7 +3281,7 @@ function DropdownMenuRadioItem({
|
|
|
3181
3281
|
"data-slot": "dropdown-menu-radio-item",
|
|
3182
3282
|
"data-inset": inset,
|
|
3183
3283
|
className: cn(
|
|
3184
|
-
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 ps-1.5
|
|
3284
|
+
"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
3285
|
className
|
|
3186
3286
|
),
|
|
3187
3287
|
...props,
|
|
@@ -3234,21 +3334,27 @@ function useObjectListAnnouncement() {
|
|
|
3234
3334
|
return { announcement, announce };
|
|
3235
3335
|
}
|
|
3236
3336
|
function ObjectListAnnouncer({
|
|
3237
|
-
announcement
|
|
3337
|
+
announcement,
|
|
3338
|
+
status,
|
|
3339
|
+
search = null
|
|
3238
3340
|
}) {
|
|
3239
|
-
return /* @__PURE__ */
|
|
3341
|
+
return /* @__PURE__ */ jsxs(
|
|
3240
3342
|
"div",
|
|
3241
3343
|
{
|
|
3242
3344
|
"data-slot": "object-list-announcer",
|
|
3243
3345
|
className: "sr-only",
|
|
3244
3346
|
"aria-live": "polite",
|
|
3245
|
-
children:
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
announcement.feedback.
|
|
3250
|
-
|
|
3251
|
-
|
|
3347
|
+
children: [
|
|
3348
|
+
/* @__PURE__ */ jsx("p", { "data-slot": "object-list-status", children: status }),
|
|
3349
|
+
/* @__PURE__ */ jsx("p", { "data-slot": "object-list-search-announcement", children: search }),
|
|
3350
|
+
announcement ? /* @__PURE__ */ jsxs("p", { children: [
|
|
3351
|
+
announcement.feedback.title,
|
|
3352
|
+
announcement.feedback.description != null ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3353
|
+
" ",
|
|
3354
|
+
announcement.feedback.description
|
|
3355
|
+
] }) : null
|
|
3356
|
+
] }, announcement.id) : null
|
|
3357
|
+
]
|
|
3252
3358
|
}
|
|
3253
3359
|
);
|
|
3254
3360
|
}
|
|
@@ -3346,37 +3452,40 @@ function durationParts(seconds) {
|
|
|
3346
3452
|
function useShareExpiryLabel() {
|
|
3347
3453
|
const t = useTranslations();
|
|
3348
3454
|
const formatNumber = useFormatNumber();
|
|
3349
|
-
return (
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
note: "object list menu",
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
note: "object list menu",
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3455
|
+
return useCallback(
|
|
3456
|
+
(seconds) => {
|
|
3457
|
+
if (seconds === null) {
|
|
3458
|
+
return t("This link works while you can access this file.", {
|
|
3459
|
+
note: "object list menu"
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
const { unit, count } = durationParts(seconds);
|
|
3463
|
+
const value = formatNumber(count);
|
|
3464
|
+
if (unit === "day") {
|
|
3465
|
+
return count === 1 ? t("Expires in 1 day", { note: "object list menu" }) : t("Expires in {count} days", {
|
|
3466
|
+
note: "object list menu",
|
|
3467
|
+
variables: { count: value }
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3470
|
+
if (unit === "hour") {
|
|
3471
|
+
return count === 1 ? t("Expires in 1 hour", { note: "object list menu" }) : t("Expires in {count} hours", {
|
|
3472
|
+
note: "object list menu",
|
|
3473
|
+
variables: { count: value }
|
|
3474
|
+
});
|
|
3475
|
+
}
|
|
3476
|
+
if (unit === "minute") {
|
|
3477
|
+
return count === 1 ? t("Expires in 1 minute", { note: "object list menu" }) : t("Expires in {count} minutes", {
|
|
3478
|
+
note: "object list menu",
|
|
3479
|
+
variables: { count: value }
|
|
3480
|
+
});
|
|
3481
|
+
}
|
|
3482
|
+
return count === 1 ? t("Expires in 1 second", { note: "object list menu" }) : t("Expires in {count} seconds", {
|
|
3371
3483
|
note: "object list menu",
|
|
3372
3484
|
variables: { count: value }
|
|
3373
3485
|
});
|
|
3374
|
-
}
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
variables: { count: value }
|
|
3378
|
-
});
|
|
3379
|
-
};
|
|
3486
|
+
},
|
|
3487
|
+
[t, formatNumber]
|
|
3488
|
+
);
|
|
3380
3489
|
}
|
|
3381
3490
|
function ObjectListItemMenu({
|
|
3382
3491
|
objectKey: objectKeyProp,
|
|
@@ -3389,50 +3498,119 @@ function ObjectListItemMenu({
|
|
|
3389
3498
|
className
|
|
3390
3499
|
}) {
|
|
3391
3500
|
const t = useTranslations();
|
|
3392
|
-
const
|
|
3501
|
+
const scope = useOptionalObjectListEntryScope();
|
|
3393
3502
|
const entry = useObjectListEntry();
|
|
3503
|
+
const entryKey = entry?.key ?? null;
|
|
3504
|
+
const menuStore = scope?.store;
|
|
3505
|
+
const menuOpen = useSyncExternalStore(
|
|
3506
|
+
menuStore?.subscribe ?? subscribeNothing,
|
|
3507
|
+
() => entryKey != null && menuStore?.get().menu === entryKey,
|
|
3508
|
+
() => false
|
|
3509
|
+
);
|
|
3394
3510
|
const triggerRef = useRef(null);
|
|
3395
3511
|
const file = entry?.kind === "file" ? entry : null;
|
|
3396
3512
|
const folder = entry?.kind === "folder" ? entry : null;
|
|
3397
3513
|
const objectKey = objectKeyProp ?? (file ? objectKeyOf(file) : "");
|
|
3398
|
-
const fileName = fileNameProp ?? file?.file.name;
|
|
3399
|
-
const fileSize = fileSizeProp ?? file?.file.size;
|
|
3400
3514
|
const isFile = objectKey !== "";
|
|
3401
|
-
const
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3515
|
+
const rows = {
|
|
3516
|
+
reveal: entry?.location != null && Boolean(scope?.search),
|
|
3517
|
+
// A folder takes uploads only when the source can place files in it.
|
|
3518
|
+
upload: folder != null && scope?.folderUploads === true,
|
|
3519
|
+
download: isFile && scope?.download === true,
|
|
3520
|
+
link: isFile && (shareProp != null || scope?.share === true),
|
|
3521
|
+
rename: entry != null && (entry.kind === "file" ? scope?.renameFile : scope?.renameFolder) === true,
|
|
3522
|
+
extra: (actions?.length ?? 0) > 0 || children != null,
|
|
3523
|
+
delete: isFile && scope?.delete === true
|
|
3524
|
+
};
|
|
3410
3525
|
if (!isFile && !folder) return null;
|
|
3411
|
-
if (!
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
{
|
|
3418
|
-
|
|
3419
|
-
|
|
3526
|
+
if (!Object.values(rows).some(Boolean)) return null;
|
|
3527
|
+
const inRow = entryKey != null && menuStore != null;
|
|
3528
|
+
return /* @__PURE__ */ jsxs(
|
|
3529
|
+
DropdownMenu,
|
|
3530
|
+
{
|
|
3531
|
+
open: inRow ? menuOpen : void 0,
|
|
3532
|
+
onOpenChange: inRow ? (open) => menuStore.set({ menu: open ? entryKey : null }) : void 0,
|
|
3533
|
+
children: [
|
|
3534
|
+
/* @__PURE__ */ jsxs(
|
|
3535
|
+
DropdownMenuTrigger,
|
|
3420
3536
|
{
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3537
|
+
render: /* @__PURE__ */ jsx(
|
|
3538
|
+
Button,
|
|
3539
|
+
{
|
|
3540
|
+
ref: triggerRef,
|
|
3541
|
+
variant: "ghost",
|
|
3542
|
+
size: "icon-sm",
|
|
3543
|
+
"data-slot": "object-list-item-menu",
|
|
3544
|
+
tabIndex: entry ? -1 : void 0,
|
|
3545
|
+
className
|
|
3546
|
+
}
|
|
3547
|
+
),
|
|
3548
|
+
children: [
|
|
3549
|
+
/* @__PURE__ */ jsx(MoreHorizontalIcon, {}),
|
|
3550
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: folder ? t("Folder actions", { note: "object list menu" }) : t("File actions", { note: "object list menu" }) })
|
|
3551
|
+
]
|
|
3426
3552
|
}
|
|
3427
3553
|
),
|
|
3428
|
-
children:
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3554
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", className: "min-w-44", children: /* @__PURE__ */ jsx(
|
|
3555
|
+
ItemMenuItems,
|
|
3556
|
+
{
|
|
3557
|
+
rows,
|
|
3558
|
+
folderId: folder?.id ?? null,
|
|
3559
|
+
entryKey: entry?.key ?? null,
|
|
3560
|
+
objectKey,
|
|
3561
|
+
fileName: fileNameProp ?? file?.file.name,
|
|
3562
|
+
fileSize: fileSizeProp ?? file?.file.size,
|
|
3563
|
+
share: shareProp,
|
|
3564
|
+
expiresIn,
|
|
3565
|
+
actions,
|
|
3566
|
+
triggerRef,
|
|
3567
|
+
children
|
|
3568
|
+
}
|
|
3569
|
+
) })
|
|
3570
|
+
]
|
|
3571
|
+
}
|
|
3572
|
+
);
|
|
3573
|
+
}
|
|
3574
|
+
function subscribeNothing() {
|
|
3575
|
+
return () => {
|
|
3576
|
+
};
|
|
3577
|
+
}
|
|
3578
|
+
function ItemMenuItems({
|
|
3579
|
+
rows,
|
|
3580
|
+
folderId,
|
|
3581
|
+
entryKey,
|
|
3582
|
+
objectKey,
|
|
3583
|
+
fileName,
|
|
3584
|
+
fileSize,
|
|
3585
|
+
share: shareProp,
|
|
3586
|
+
expiresIn,
|
|
3587
|
+
actions,
|
|
3588
|
+
triggerRef,
|
|
3589
|
+
children
|
|
3590
|
+
}) {
|
|
3591
|
+
const t = useTranslations();
|
|
3592
|
+
const context = useOptionalObjectListContext();
|
|
3593
|
+
const download = rows.download ? context?.download ?? null : null;
|
|
3594
|
+
const linkSource = rows.link ? shareProp ?? context?.share ?? (context?.download?.mode === "navigate" ? context.download : null) : null;
|
|
3595
|
+
const remove = rows.delete ? context?.delete ?? null : null;
|
|
3596
|
+
const listUpload = context?.upload ?? null;
|
|
3597
|
+
const folderCall = rows.upload && context && folderId != null ? folderUploadCall(context.list, folderId) : void 0;
|
|
3598
|
+
const uploadToFolder = listUpload && folderCall ? () => listUpload.open(folderCall) : null;
|
|
3599
|
+
const extra = actions ?? [];
|
|
3600
|
+
const showTransfer = download != null || linkSource != null;
|
|
3601
|
+
const showExtra = rows.extra;
|
|
3602
|
+
const canRename = rows.rename && context != null && entryKey != null;
|
|
3603
|
+
const entry = useObjectListEntry();
|
|
3604
|
+
const reveal = rows.reveal && context != null && entry != null ? () => context.revealEntry(entry) : null;
|
|
3605
|
+
const showMain = uploadToFolder != null || showTransfer || canRename;
|
|
3606
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3607
|
+
reveal ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: reveal, children: [
|
|
3608
|
+
/* @__PURE__ */ jsx(FolderOpenIcon, {}),
|
|
3609
|
+
t("Show in folder", { note: "object list menu" })
|
|
3610
|
+
] }) }) : null,
|
|
3611
|
+
reveal && (showMain || showExtra || rows.delete) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3612
|
+
uploadToFolder || showTransfer || canRename ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
3613
|
+
uploadToFolder ? /* @__PURE__ */ jsxs(
|
|
3436
3614
|
DropdownMenuItem,
|
|
3437
3615
|
{
|
|
3438
3616
|
disabled: listUpload?.disabled,
|
|
@@ -3442,74 +3620,82 @@ function ObjectListItemMenu({
|
|
|
3442
3620
|
t("Upload to this folder", { note: "object list menu" })
|
|
3443
3621
|
]
|
|
3444
3622
|
}
|
|
3445
|
-
)
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
DownloadItem,
|
|
3449
|
-
{
|
|
3450
|
-
download,
|
|
3451
|
-
objectKey,
|
|
3452
|
-
fileName,
|
|
3453
|
-
fileSize
|
|
3454
|
-
}
|
|
3455
|
-
) : null,
|
|
3456
|
-
linkSource ? /* @__PURE__ */ jsx(
|
|
3457
|
-
CopyLinkItem,
|
|
3458
|
-
{
|
|
3459
|
-
share: linkSource,
|
|
3460
|
-
objectKey,
|
|
3461
|
-
fileName,
|
|
3462
|
-
expiresIn
|
|
3463
|
-
}
|
|
3464
|
-
) : null
|
|
3465
|
-
] }) : null,
|
|
3466
|
-
showExtra && (showTransfer || uploadToFolder) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3467
|
-
showExtra ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
3468
|
-
extra.map((action, index) => /* @__PURE__ */ jsxs(
|
|
3469
|
-
DropdownMenuItem,
|
|
3470
|
-
{
|
|
3471
|
-
variant: action.destructive ? "destructive" : "default",
|
|
3472
|
-
disabled: action.disabled,
|
|
3473
|
-
onClick: () => {
|
|
3474
|
-
action.onClick();
|
|
3475
|
-
},
|
|
3476
|
-
children: [
|
|
3477
|
-
action.icon,
|
|
3478
|
-
action.label
|
|
3479
|
-
]
|
|
3480
|
-
},
|
|
3481
|
-
`${action.label}-${index}`
|
|
3482
|
-
)),
|
|
3483
|
-
children
|
|
3484
|
-
] }) : null,
|
|
3485
|
-
remove && (showTransfer || showExtra) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3486
|
-
remove ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(
|
|
3487
|
-
DeleteItem,
|
|
3623
|
+
) : null,
|
|
3624
|
+
download ? /* @__PURE__ */ jsx(
|
|
3625
|
+
DownloadItem,
|
|
3488
3626
|
{
|
|
3627
|
+
download,
|
|
3489
3628
|
objectKey,
|
|
3490
3629
|
fileName,
|
|
3491
|
-
fileSize
|
|
3492
|
-
triggerRef
|
|
3630
|
+
fileSize
|
|
3493
3631
|
}
|
|
3494
|
-
)
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3632
|
+
) : null,
|
|
3633
|
+
linkSource ? /* @__PURE__ */ jsx(
|
|
3634
|
+
CopyLinkItem,
|
|
3635
|
+
{
|
|
3636
|
+
share: linkSource,
|
|
3637
|
+
objectKey,
|
|
3638
|
+
fileName,
|
|
3639
|
+
expiresIn
|
|
3640
|
+
}
|
|
3641
|
+
) : null,
|
|
3642
|
+
canRename ? /* @__PURE__ */ jsxs(
|
|
3643
|
+
DropdownMenuItem,
|
|
3644
|
+
{
|
|
3645
|
+
onClick: () => {
|
|
3646
|
+
if (entryKey != null) context?.startRename(entryKey);
|
|
3647
|
+
},
|
|
3648
|
+
children: [
|
|
3649
|
+
/* @__PURE__ */ jsx(PencilIcon, {}),
|
|
3650
|
+
t("Rename", { note: "object list menu" })
|
|
3651
|
+
]
|
|
3652
|
+
}
|
|
3653
|
+
) : null
|
|
3654
|
+
] }) : null,
|
|
3655
|
+
showExtra && (showTransfer || uploadToFolder || canRename) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3656
|
+
showExtra ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
3657
|
+
extra.map((action, index) => /* @__PURE__ */ jsxs(
|
|
3658
|
+
DropdownMenuItem,
|
|
3659
|
+
{
|
|
3660
|
+
variant: action.destructive ? "destructive" : "default",
|
|
3661
|
+
disabled: action.disabled,
|
|
3662
|
+
onClick: action.onClick,
|
|
3663
|
+
children: [
|
|
3664
|
+
action.icon,
|
|
3665
|
+
action.label
|
|
3666
|
+
]
|
|
3667
|
+
},
|
|
3668
|
+
`${action.label}-${index}`
|
|
3669
|
+
)),
|
|
3670
|
+
children
|
|
3671
|
+
] }) : null,
|
|
3672
|
+
remove && (showTransfer || uploadToFolder || canRename || showExtra) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3673
|
+
remove ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(
|
|
3674
|
+
DeleteItem,
|
|
3675
|
+
{
|
|
3676
|
+
objectKey,
|
|
3677
|
+
fileName,
|
|
3678
|
+
fileSize,
|
|
3679
|
+
triggerRef
|
|
3680
|
+
}
|
|
3681
|
+
) }) : null
|
|
3682
|
+
] });
|
|
3683
|
+
}
|
|
3684
|
+
function DownloadItem({
|
|
3685
|
+
download,
|
|
3686
|
+
objectKey,
|
|
3687
|
+
fileName,
|
|
3688
|
+
fileSize
|
|
3689
|
+
}) {
|
|
3690
|
+
const t = useTranslations();
|
|
3691
|
+
const pending = download.pendingKeys.includes(objectKey);
|
|
3692
|
+
return /* @__PURE__ */ jsxs(
|
|
3693
|
+
DropdownMenuItem,
|
|
3694
|
+
{
|
|
3695
|
+
disabled: pending,
|
|
3696
|
+
onClick: () => {
|
|
3697
|
+
if (download.mode === "fetch") {
|
|
3698
|
+
void download.download(objectKey, { fileName, fileSize });
|
|
3513
3699
|
} else {
|
|
3514
3700
|
void download.download(objectKey, { fileName });
|
|
3515
3701
|
}
|
|
@@ -3528,7 +3714,7 @@ function CopyLinkItem({
|
|
|
3528
3714
|
expiresIn
|
|
3529
3715
|
}) {
|
|
3530
3716
|
const t = useTranslations();
|
|
3531
|
-
const formatError =
|
|
3717
|
+
const formatError = useFormatError();
|
|
3532
3718
|
const expiryLabel = useShareExpiryLabel();
|
|
3533
3719
|
const report = useObjectListFeedback();
|
|
3534
3720
|
const [copying, setCopying] = useState(false);
|
|
@@ -3584,7 +3770,7 @@ function DeleteItem({
|
|
|
3584
3770
|
}) {
|
|
3585
3771
|
const t = useTranslations();
|
|
3586
3772
|
const { delete: del, request } = useDeleteContext();
|
|
3587
|
-
const deleting = del.
|
|
3773
|
+
const deleting = del.pendingKeys.includes(objectKey);
|
|
3588
3774
|
return /* @__PURE__ */ jsxs(
|
|
3589
3775
|
DropdownMenuItem,
|
|
3590
3776
|
{
|
|
@@ -3601,11 +3787,565 @@ function DeleteItem({
|
|
|
3601
3787
|
}
|
|
3602
3788
|
);
|
|
3603
3789
|
}
|
|
3790
|
+
function Spinner({ className, ...props }) {
|
|
3791
|
+
return /* @__PURE__ */ jsx(
|
|
3792
|
+
Loader2Icon,
|
|
3793
|
+
{
|
|
3794
|
+
"data-slot": "spinner",
|
|
3795
|
+
role: "status",
|
|
3796
|
+
"aria-label": "Loading",
|
|
3797
|
+
className: cn("size-4 animate-spin", className),
|
|
3798
|
+
...props
|
|
3799
|
+
}
|
|
3800
|
+
);
|
|
3801
|
+
}
|
|
3802
|
+
function canRenameEntry(entry, list) {
|
|
3803
|
+
return entry.kind === "file" ? list.renameFile != null : list.renameFolder != null;
|
|
3804
|
+
}
|
|
3805
|
+
function ObjectListRenameField({
|
|
3806
|
+
entry
|
|
3807
|
+
}) {
|
|
3808
|
+
const t = useTranslations();
|
|
3809
|
+
const formatError = useFormatError();
|
|
3810
|
+
const { list, endRename } = useObjectListContext();
|
|
3811
|
+
const inputId = useId();
|
|
3812
|
+
const errorId = useId();
|
|
3813
|
+
const inputRef = useRef(null);
|
|
3814
|
+
const lock = useRef(false);
|
|
3815
|
+
const closed = useRef(false);
|
|
3816
|
+
const [name, setName] = useState(entry.name);
|
|
3817
|
+
const [pending, setPending] = useState(false);
|
|
3818
|
+
const [error, setError] = useState(null);
|
|
3819
|
+
const folder = entry.kind === "folder";
|
|
3820
|
+
const label = folder ? t("Folder name", { note: "object list new folder" }) : t("File name", { note: "object list rename" });
|
|
3821
|
+
useEffect(() => {
|
|
3822
|
+
const input = inputRef.current;
|
|
3823
|
+
if (!input) return;
|
|
3824
|
+
input.focus();
|
|
3825
|
+
const end = folder ? entry.name.length : splitFileName(entry.name).stem.length;
|
|
3826
|
+
input.setSelectionRange(0, end);
|
|
3827
|
+
}, [entry.name, folder]);
|
|
3828
|
+
function finish(focus) {
|
|
3829
|
+
if (closed.current) return;
|
|
3830
|
+
closed.current = true;
|
|
3831
|
+
endRename(entry.key, focus);
|
|
3832
|
+
}
|
|
3833
|
+
async function save(focus) {
|
|
3834
|
+
if (closed.current || lock.current) return;
|
|
3835
|
+
const trimmed = name.trim();
|
|
3836
|
+
if (!trimmed) {
|
|
3837
|
+
setError(
|
|
3838
|
+
folder ? t("Enter a folder name", { note: "object list new folder" }) : t("Enter a file name", { note: "object list rename" })
|
|
3839
|
+
);
|
|
3840
|
+
return;
|
|
3841
|
+
}
|
|
3842
|
+
if (trimmed === entry.name) {
|
|
3843
|
+
finish(focus);
|
|
3844
|
+
return;
|
|
3845
|
+
}
|
|
3846
|
+
lock.current = true;
|
|
3847
|
+
setPending(true);
|
|
3848
|
+
setError(null);
|
|
3849
|
+
try {
|
|
3850
|
+
if (entry.kind === "folder") {
|
|
3851
|
+
await list.renameFolder?.(entry.folder, trimmed);
|
|
3852
|
+
} else {
|
|
3853
|
+
await list.renameFile?.(entry.item, trimmed);
|
|
3854
|
+
}
|
|
3855
|
+
} catch (err) {
|
|
3856
|
+
lock.current = false;
|
|
3857
|
+
setPending(false);
|
|
3858
|
+
setError(formatError(err));
|
|
3859
|
+
if (focus) inputRef.current?.focus();
|
|
3860
|
+
return;
|
|
3861
|
+
}
|
|
3862
|
+
finish(focus);
|
|
3863
|
+
}
|
|
3864
|
+
function onBlur(event) {
|
|
3865
|
+
if (closed.current || lock.current) return;
|
|
3866
|
+
const next = event.relatedTarget;
|
|
3867
|
+
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
3868
|
+
const trimmed = name.trim();
|
|
3869
|
+
if (!trimmed || trimmed === entry.name) {
|
|
3870
|
+
finish(false);
|
|
3871
|
+
return;
|
|
3872
|
+
}
|
|
3873
|
+
void save(false);
|
|
3874
|
+
}
|
|
3875
|
+
const confirm = /* @__PURE__ */ jsx(
|
|
3876
|
+
Button,
|
|
3877
|
+
{
|
|
3878
|
+
type: "submit",
|
|
3879
|
+
variant: "ghost",
|
|
3880
|
+
size: "icon-sm",
|
|
3881
|
+
className: "shrink-0",
|
|
3882
|
+
"aria-label": t("Rename", { note: "object list menu" }),
|
|
3883
|
+
disabled: pending,
|
|
3884
|
+
focusableWhenDisabled: true,
|
|
3885
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3886
|
+
children: pending ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(CheckIcon, {})
|
|
3887
|
+
}
|
|
3888
|
+
);
|
|
3889
|
+
const cancel = /* @__PURE__ */ jsx(
|
|
3890
|
+
Button,
|
|
3891
|
+
{
|
|
3892
|
+
type: "button",
|
|
3893
|
+
variant: "ghost",
|
|
3894
|
+
size: "icon-sm",
|
|
3895
|
+
className: "shrink-0",
|
|
3896
|
+
"aria-label": t("Cancel", { note: "object list rename" }),
|
|
3897
|
+
disabled: pending,
|
|
3898
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3899
|
+
onClick: () => finish(true),
|
|
3900
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
3901
|
+
}
|
|
3902
|
+
);
|
|
3903
|
+
function onSubmit(event) {
|
|
3904
|
+
event.preventDefault();
|
|
3905
|
+
void save(true);
|
|
3906
|
+
}
|
|
3907
|
+
return /* @__PURE__ */ jsxs(
|
|
3908
|
+
"form",
|
|
3909
|
+
{
|
|
3910
|
+
"data-slot": "object-list-rename",
|
|
3911
|
+
"aria-busy": pending || void 0,
|
|
3912
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
3913
|
+
onSubmit,
|
|
3914
|
+
onBlur,
|
|
3915
|
+
children: [
|
|
3916
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3917
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "sr-only", children: label }),
|
|
3918
|
+
/* @__PURE__ */ jsx(
|
|
3919
|
+
"input",
|
|
3920
|
+
{
|
|
3921
|
+
ref: inputRef,
|
|
3922
|
+
id: inputId,
|
|
3923
|
+
value: name,
|
|
3924
|
+
dir: "auto",
|
|
3925
|
+
maxLength: 255,
|
|
3926
|
+
autoComplete: "off",
|
|
3927
|
+
readOnly: pending,
|
|
3928
|
+
"aria-invalid": error != null || void 0,
|
|
3929
|
+
"aria-describedby": error != null ? errorId : void 0,
|
|
3930
|
+
className: cn(
|
|
3931
|
+
"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"
|
|
3932
|
+
),
|
|
3933
|
+
onChange: (event) => {
|
|
3934
|
+
setName(event.target.value);
|
|
3935
|
+
setError(null);
|
|
3936
|
+
},
|
|
3937
|
+
onKeyDown: (event) => {
|
|
3938
|
+
if (event.key !== "Escape" || lock.current) return;
|
|
3939
|
+
event.preventDefault();
|
|
3940
|
+
finish(true);
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
),
|
|
3944
|
+
confirm,
|
|
3945
|
+
cancel
|
|
3946
|
+
] }),
|
|
3947
|
+
error != null ? /* @__PURE__ */ jsx(
|
|
3948
|
+
"p",
|
|
3949
|
+
{
|
|
3950
|
+
id: errorId,
|
|
3951
|
+
role: "alert",
|
|
3952
|
+
className: "text-xs [overflow-wrap:anywhere] text-dimah-s3-destructive",
|
|
3953
|
+
children: error
|
|
3954
|
+
}
|
|
3955
|
+
) : null
|
|
3956
|
+
]
|
|
3957
|
+
}
|
|
3958
|
+
);
|
|
3959
|
+
}
|
|
3960
|
+
var ENTRY_TRIGGER = "[data-slot=object-list-entry-trigger]";
|
|
3961
|
+
function canChooseSearchScope(list) {
|
|
3962
|
+
return list.parent != null && list.searchScopes.includes("folder") && list.searchScopes.includes("all");
|
|
3963
|
+
}
|
|
3964
|
+
function ObjectListSearch({
|
|
3965
|
+
placeholder,
|
|
3966
|
+
delay = 250,
|
|
3967
|
+
collapsible = true,
|
|
3968
|
+
className
|
|
3969
|
+
}) {
|
|
3970
|
+
const t = useTranslations();
|
|
3971
|
+
const { list } = useObjectListContext();
|
|
3972
|
+
const header = useOptionalObjectListHeader();
|
|
3973
|
+
const { setSearch } = list;
|
|
3974
|
+
const [draft, setDraft] = useState(null);
|
|
3975
|
+
const value = draft ?? list.search;
|
|
3976
|
+
const defaultLabel = useSearchPlaceholder(list);
|
|
3977
|
+
const label = placeholder ?? defaultLabel;
|
|
3978
|
+
const collapses = collapsible && header != null;
|
|
3979
|
+
const [open, setOpen] = useState(false);
|
|
3980
|
+
const expanded = !collapses || open || value !== "";
|
|
3981
|
+
const inputRef = useRef(null);
|
|
3982
|
+
const buttonRef = useRef(null);
|
|
3983
|
+
const rootRef = useRef(null);
|
|
3984
|
+
const focusRef = useRef(null);
|
|
3985
|
+
const loading = draft != null && draft.trim() !== list.search.trim() || list.isSearching && (list.isLoading || list.isRefreshing);
|
|
3986
|
+
useEffect(() => {
|
|
3987
|
+
if (draft == null) return;
|
|
3988
|
+
const timer = window.setTimeout(() => {
|
|
3989
|
+
setSearch(draft);
|
|
3990
|
+
setDraft(null);
|
|
3991
|
+
}, delay);
|
|
3992
|
+
return () => window.clearTimeout(timer);
|
|
3993
|
+
}, [delay, draft, setSearch]);
|
|
3994
|
+
const setSearchExpanded = header?.setSearchExpanded;
|
|
3995
|
+
useLayoutEffect(() => {
|
|
3996
|
+
if (!collapses || !setSearchExpanded) return;
|
|
3997
|
+
setSearchExpanded(expanded);
|
|
3998
|
+
return () => setSearchExpanded(false);
|
|
3999
|
+
}, [collapses, expanded, setSearchExpanded]);
|
|
4000
|
+
useEffect(() => {
|
|
4001
|
+
const target = focusRef.current;
|
|
4002
|
+
if (!target) return;
|
|
4003
|
+
focusRef.current = null;
|
|
4004
|
+
(target === "input" ? inputRef : buttonRef).current?.focus();
|
|
4005
|
+
});
|
|
4006
|
+
useEffect(() => {
|
|
4007
|
+
if (!collapses || !open || value !== "") return;
|
|
4008
|
+
if (rootRef.current?.contains(document.activeElement)) return;
|
|
4009
|
+
setOpen(false);
|
|
4010
|
+
}, [collapses, open, value]);
|
|
4011
|
+
function commit(next) {
|
|
4012
|
+
setDraft(null);
|
|
4013
|
+
setSearch(next);
|
|
4014
|
+
}
|
|
4015
|
+
function close() {
|
|
4016
|
+
commit("");
|
|
4017
|
+
setOpen(false);
|
|
4018
|
+
focusRef.current = "button";
|
|
4019
|
+
}
|
|
4020
|
+
function onKeyDown(event) {
|
|
4021
|
+
if (event.key === "Enter") commit(value);
|
|
4022
|
+
if (event.key === "ArrowDown") {
|
|
4023
|
+
event.preventDefault();
|
|
4024
|
+
if (loading) {
|
|
4025
|
+
if (draft != null) commit(draft);
|
|
4026
|
+
return;
|
|
4027
|
+
}
|
|
4028
|
+
const frame = event.currentTarget.closest("[data-slot=object-list]");
|
|
4029
|
+
const entry = frame?.querySelector(`${ENTRY_TRIGGER}[tabindex="0"]`) ?? frame?.querySelector(ENTRY_TRIGGER);
|
|
4030
|
+
entry?.focus();
|
|
4031
|
+
return;
|
|
4032
|
+
}
|
|
4033
|
+
if (event.key !== "Escape") return;
|
|
4034
|
+
if (value) {
|
|
4035
|
+
event.preventDefault();
|
|
4036
|
+
commit("");
|
|
4037
|
+
} else if (collapses) {
|
|
4038
|
+
event.preventDefault();
|
|
4039
|
+
close();
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4042
|
+
if (!expanded) {
|
|
4043
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4044
|
+
/* @__PURE__ */ jsx(
|
|
4045
|
+
TooltipTrigger,
|
|
4046
|
+
{
|
|
4047
|
+
render: /* @__PURE__ */ jsx(
|
|
4048
|
+
Button,
|
|
4049
|
+
{
|
|
4050
|
+
ref: buttonRef,
|
|
4051
|
+
type: "button",
|
|
4052
|
+
variant: "ghost",
|
|
4053
|
+
size: "icon-sm",
|
|
4054
|
+
"data-slot": "object-list-search",
|
|
4055
|
+
"aria-label": label,
|
|
4056
|
+
"aria-keyshortcuts": "/",
|
|
4057
|
+
className,
|
|
4058
|
+
onClick: () => {
|
|
4059
|
+
focusRef.current = "input";
|
|
4060
|
+
setOpen(true);
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
),
|
|
4064
|
+
children: /* @__PURE__ */ jsx(SearchIcon, {})
|
|
4065
|
+
}
|
|
4066
|
+
),
|
|
4067
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: label })
|
|
4068
|
+
] });
|
|
4069
|
+
}
|
|
4070
|
+
const spinner = loading ? /* @__PURE__ */ jsx(
|
|
4071
|
+
Spinner,
|
|
4072
|
+
{
|
|
4073
|
+
className: "size-3.5 text-dimah-s3-muted-foreground",
|
|
4074
|
+
"aria-label": t("Searching", { note: "object list search" })
|
|
4075
|
+
}
|
|
4076
|
+
) : null;
|
|
4077
|
+
return /* @__PURE__ */ jsxs(
|
|
4078
|
+
"div",
|
|
4079
|
+
{
|
|
4080
|
+
ref: rootRef,
|
|
4081
|
+
"data-slot": "object-list-search",
|
|
4082
|
+
"data-expanded": "",
|
|
4083
|
+
"data-loading": loading ? "" : void 0,
|
|
4084
|
+
className: cn(
|
|
4085
|
+
"relative flex min-w-0 items-center",
|
|
4086
|
+
collapses ? "w-full flex-1" : "w-40 sm:w-52",
|
|
4087
|
+
className
|
|
4088
|
+
),
|
|
4089
|
+
onBlur: (event) => {
|
|
4090
|
+
if (!collapses || value !== "") return;
|
|
4091
|
+
const next = event.relatedTarget;
|
|
4092
|
+
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
4093
|
+
setOpen(false);
|
|
4094
|
+
},
|
|
4095
|
+
children: [
|
|
4096
|
+
/* @__PURE__ */ jsx(
|
|
4097
|
+
SearchIcon,
|
|
4098
|
+
{
|
|
4099
|
+
"aria-hidden": true,
|
|
4100
|
+
className: "pointer-events-none absolute start-2.5 size-3.5 text-dimah-s3-muted-foreground"
|
|
4101
|
+
}
|
|
4102
|
+
),
|
|
4103
|
+
/* @__PURE__ */ jsx(
|
|
4104
|
+
"input",
|
|
4105
|
+
{
|
|
4106
|
+
ref: inputRef,
|
|
4107
|
+
type: "search",
|
|
4108
|
+
value,
|
|
4109
|
+
placeholder: label,
|
|
4110
|
+
"aria-label": label,
|
|
4111
|
+
"aria-keyshortcuts": "/",
|
|
4112
|
+
"aria-busy": loading || void 0,
|
|
4113
|
+
autoComplete: "off",
|
|
4114
|
+
spellCheck: false,
|
|
4115
|
+
enterKeyHint: "search",
|
|
4116
|
+
className: cn(
|
|
4117
|
+
"w-full min-w-0 rounded-md border border-dimah-s3-border bg-transparent ps-8 text-sm text-dimah-s3-foreground outline-none placeholder:text-dimah-s3-muted-foreground focus-visible:border-dimah-s3-ring focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50 [&::-webkit-search-cancel-button]:appearance-none",
|
|
4118
|
+
collapses ? "h-8 pe-14" : "h-7 pe-12"
|
|
4119
|
+
),
|
|
4120
|
+
onChange: (event) => setDraft(event.target.value),
|
|
4121
|
+
onKeyDown
|
|
4122
|
+
}
|
|
4123
|
+
),
|
|
4124
|
+
collapses ? /* @__PURE__ */ jsxs("div", { className: "absolute end-1.5 flex items-center gap-1", children: [
|
|
4125
|
+
spinner,
|
|
4126
|
+
/* @__PURE__ */ jsx(
|
|
4127
|
+
Button,
|
|
4128
|
+
{
|
|
4129
|
+
type: "button",
|
|
4130
|
+
variant: "ghost",
|
|
4131
|
+
size: "icon-xs",
|
|
4132
|
+
"aria-label": t("Close search", { note: "object list" }),
|
|
4133
|
+
onClick: close,
|
|
4134
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
4135
|
+
}
|
|
4136
|
+
)
|
|
4137
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "absolute end-1 flex items-center gap-1", children: [
|
|
4138
|
+
spinner,
|
|
4139
|
+
value ? /* @__PURE__ */ jsx(
|
|
4140
|
+
"button",
|
|
4141
|
+
{
|
|
4142
|
+
type: "button",
|
|
4143
|
+
"aria-label": t("Clear search", { note: "object list" }),
|
|
4144
|
+
className: "flex size-5 items-center justify-center rounded-sm text-dimah-s3-muted-foreground outline-none hover:text-dimah-s3-foreground focus-visible:ring-2 focus-visible:ring-dimah-s3-ring/50",
|
|
4145
|
+
onClick: () => commit(""),
|
|
4146
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3.5" })
|
|
4147
|
+
}
|
|
4148
|
+
) : null
|
|
4149
|
+
] })
|
|
4150
|
+
]
|
|
4151
|
+
}
|
|
4152
|
+
);
|
|
4153
|
+
}
|
|
4154
|
+
function useSearchPlaceholder(list) {
|
|
4155
|
+
const t = useTranslations();
|
|
4156
|
+
const folder = list.trail.at(-1);
|
|
4157
|
+
if (!folder || list.searchScopes.length === 0) {
|
|
4158
|
+
return t("Search files", { note: "object list" });
|
|
4159
|
+
}
|
|
4160
|
+
if (list.searchScope === "all" && canChooseSearchScope(list)) {
|
|
4161
|
+
return t("Search all files", { note: "object list search" });
|
|
4162
|
+
}
|
|
4163
|
+
return t("Search in \u201C{folder}\u201D", {
|
|
4164
|
+
note: "object list search",
|
|
4165
|
+
variables: { folder: folder.name }
|
|
4166
|
+
});
|
|
4167
|
+
}
|
|
4168
|
+
function useObjectListSearchStatus(list) {
|
|
4169
|
+
const t = useTranslations();
|
|
4170
|
+
const formatNumber = useFormatNumber();
|
|
4171
|
+
if (!list.isSearching) return null;
|
|
4172
|
+
if (list.isLoading || list.isRefreshing) {
|
|
4173
|
+
return {
|
|
4174
|
+
label: t("Searching\u2026", { note: "object list search" }),
|
|
4175
|
+
settled: false
|
|
4176
|
+
};
|
|
4177
|
+
}
|
|
4178
|
+
if (list.error) return null;
|
|
4179
|
+
const files = list.total ?? list.items.length;
|
|
4180
|
+
const count = list.folders.length + files;
|
|
4181
|
+
const more = list.total == null && list.hasMore;
|
|
4182
|
+
if (count === 0) {
|
|
4183
|
+
return { label: t("No results", { note: "object list" }), settled: true };
|
|
4184
|
+
}
|
|
4185
|
+
if (more) {
|
|
4186
|
+
return {
|
|
4187
|
+
label: t("{count}+ results", {
|
|
4188
|
+
note: "object list search",
|
|
4189
|
+
variables: { count: formatNumber(count) }
|
|
4190
|
+
}),
|
|
4191
|
+
settled: true
|
|
4192
|
+
};
|
|
4193
|
+
}
|
|
4194
|
+
return {
|
|
4195
|
+
label: count === 1 ? t("1 result", { note: "object list search" }) : t("{count} results", {
|
|
4196
|
+
note: "object list search",
|
|
4197
|
+
variables: { count: formatNumber(count) }
|
|
4198
|
+
}),
|
|
4199
|
+
settled: true
|
|
4200
|
+
};
|
|
4201
|
+
}
|
|
4202
|
+
function ObjectListSearchBar({ className }) {
|
|
4203
|
+
const t = useTranslations();
|
|
4204
|
+
const { list, label: rootLabel } = useObjectListContext();
|
|
4205
|
+
const status = useObjectListSearchStatus(list);
|
|
4206
|
+
if (!status) return null;
|
|
4207
|
+
const folder = list.trail.at(-1);
|
|
4208
|
+
const choose = canChooseSearchScope(list);
|
|
4209
|
+
const inLabel = t("Search in", { note: "object list search" });
|
|
4210
|
+
return /* @__PURE__ */ jsxs(
|
|
4211
|
+
"div",
|
|
4212
|
+
{
|
|
4213
|
+
"data-slot": "object-list-search-bar",
|
|
4214
|
+
className: cn(
|
|
4215
|
+
"flex min-h-9 min-w-0 items-center gap-2 px-2 py-1 text-xs text-dimah-s3-muted-foreground",
|
|
4216
|
+
className
|
|
4217
|
+
),
|
|
4218
|
+
children: [
|
|
4219
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0", children: inLabel }),
|
|
4220
|
+
choose && folder ? /* @__PURE__ */ jsxs(
|
|
4221
|
+
"div",
|
|
4222
|
+
{
|
|
4223
|
+
role: "radiogroup",
|
|
4224
|
+
"aria-label": inLabel,
|
|
4225
|
+
className: "flex min-w-0 items-center gap-0.5 rounded-lg border border-dimah-s3-border p-0.5",
|
|
4226
|
+
children: [
|
|
4227
|
+
/* @__PURE__ */ jsx(
|
|
4228
|
+
ScopeChoice,
|
|
4229
|
+
{
|
|
4230
|
+
scope: "folder",
|
|
4231
|
+
current: list.searchScope,
|
|
4232
|
+
onSelect: list.setSearchScope,
|
|
4233
|
+
icon: /* @__PURE__ */ jsx(FolderIcon, { "aria-hidden": true }),
|
|
4234
|
+
label: folder.name
|
|
4235
|
+
}
|
|
4236
|
+
),
|
|
4237
|
+
/* @__PURE__ */ jsx(
|
|
4238
|
+
ScopeChoice,
|
|
4239
|
+
{
|
|
4240
|
+
scope: "all",
|
|
4241
|
+
current: list.searchScope,
|
|
4242
|
+
onSelect: list.setSearchScope,
|
|
4243
|
+
icon: /* @__PURE__ */ jsx(HomeIcon, { "aria-hidden": true }),
|
|
4244
|
+
label: rootLabel
|
|
4245
|
+
}
|
|
4246
|
+
)
|
|
4247
|
+
]
|
|
4248
|
+
}
|
|
4249
|
+
) : /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1 font-medium text-dimah-s3-foreground", children: [
|
|
4250
|
+
folder ? /* @__PURE__ */ jsx(FolderIcon, { "aria-hidden": true, className: "size-3.5 shrink-0" }) : /* @__PURE__ */ jsx(HomeIcon, { "aria-hidden": true, className: "size-3.5 shrink-0" }),
|
|
4251
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: /* @__PURE__ */ jsx("bdi", { children: folder?.name ?? rootLabel }) })
|
|
4252
|
+
] }),
|
|
4253
|
+
/* @__PURE__ */ jsx(
|
|
4254
|
+
"span",
|
|
4255
|
+
{
|
|
4256
|
+
"data-slot": "object-list-search-status",
|
|
4257
|
+
className: "ms-auto shrink-0 tabular-nums",
|
|
4258
|
+
children: status.label
|
|
4259
|
+
}
|
|
4260
|
+
)
|
|
4261
|
+
]
|
|
4262
|
+
}
|
|
4263
|
+
);
|
|
4264
|
+
}
|
|
4265
|
+
function ScopeChoice({
|
|
4266
|
+
scope,
|
|
4267
|
+
current,
|
|
4268
|
+
onSelect,
|
|
4269
|
+
icon,
|
|
4270
|
+
label
|
|
4271
|
+
}) {
|
|
4272
|
+
const checked = scope === current;
|
|
4273
|
+
return /* @__PURE__ */ jsxs(
|
|
4274
|
+
Button,
|
|
4275
|
+
{
|
|
4276
|
+
type: "button",
|
|
4277
|
+
variant: "ghost",
|
|
4278
|
+
size: "xs",
|
|
4279
|
+
role: "radio",
|
|
4280
|
+
"aria-checked": checked,
|
|
4281
|
+
tabIndex: checked ? 0 : -1,
|
|
4282
|
+
className: "min-w-0 aria-checked:bg-dimah-s3-muted aria-checked:text-dimah-s3-foreground",
|
|
4283
|
+
onClick: () => onSelect(scope),
|
|
4284
|
+
onKeyDown: (event) => {
|
|
4285
|
+
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(
|
|
4286
|
+
event.key
|
|
4287
|
+
)) {
|
|
4288
|
+
return;
|
|
4289
|
+
}
|
|
4290
|
+
event.preventDefault();
|
|
4291
|
+
const next = scope === "folder" ? "all" : "folder";
|
|
4292
|
+
onSelect(next);
|
|
4293
|
+
const group = event.currentTarget.parentElement;
|
|
4294
|
+
requestAnimationFrame(
|
|
4295
|
+
() => group?.querySelector("[role=radio][aria-checked=true]")?.focus()
|
|
4296
|
+
);
|
|
4297
|
+
},
|
|
4298
|
+
children: [
|
|
4299
|
+
icon,
|
|
4300
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-32 truncate", children: /* @__PURE__ */ jsx("bdi", { children: label }) })
|
|
4301
|
+
]
|
|
4302
|
+
}
|
|
4303
|
+
);
|
|
4304
|
+
}
|
|
4305
|
+
function ObjectListLocation({
|
|
4306
|
+
location,
|
|
4307
|
+
className
|
|
4308
|
+
}) {
|
|
4309
|
+
const { label: rootLabel } = useObjectListContext();
|
|
4310
|
+
const names = location.length === 0 ? [rootLabel] : location.map((folder) => folder.name);
|
|
4311
|
+
const shown = names.length > 2 ? ["\u2026", ...names.slice(-2)] : names;
|
|
4312
|
+
return /* @__PURE__ */ jsxs(
|
|
4313
|
+
"span",
|
|
4314
|
+
{
|
|
4315
|
+
"data-slot": "object-list-location",
|
|
4316
|
+
title: [rootLabel, ...location.map((folder) => folder.name)].join(" / "),
|
|
4317
|
+
className: cn("min-w-0", className),
|
|
4318
|
+
children: [
|
|
4319
|
+
/* @__PURE__ */ jsx(
|
|
4320
|
+
FolderIcon,
|
|
4321
|
+
{
|
|
4322
|
+
"aria-hidden": true,
|
|
4323
|
+
className: "me-1 inline-block size-3 shrink-0 align-[-0.125rem]"
|
|
4324
|
+
}
|
|
4325
|
+
),
|
|
4326
|
+
shown.map((name, index) => /* @__PURE__ */ jsxs("span", { children: [
|
|
4327
|
+
index > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4328
|
+
/* @__PURE__ */ jsx(
|
|
4329
|
+
ChevronRightIcon,
|
|
4330
|
+
{
|
|
4331
|
+
"aria-hidden": true,
|
|
4332
|
+
className: "mx-0.5 inline-block size-3 align-[-0.125rem] rtl:rotate-180"
|
|
4333
|
+
}
|
|
4334
|
+
),
|
|
4335
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: " / " })
|
|
4336
|
+
] }) : null,
|
|
4337
|
+
/* @__PURE__ */ jsx("bdi", { children: name })
|
|
4338
|
+
] }, index))
|
|
4339
|
+
]
|
|
4340
|
+
}
|
|
4341
|
+
);
|
|
4342
|
+
}
|
|
3604
4343
|
function ObjectListCheckbox({
|
|
3605
4344
|
checked,
|
|
3606
4345
|
indeterminate,
|
|
3607
4346
|
label,
|
|
3608
4347
|
onCheckedChange,
|
|
4348
|
+
tabIndex,
|
|
3609
4349
|
className
|
|
3610
4350
|
}) {
|
|
3611
4351
|
const shiftRef = useRef(false);
|
|
@@ -3614,6 +4354,7 @@ function ObjectListCheckbox({
|
|
|
3614
4354
|
{
|
|
3615
4355
|
checked,
|
|
3616
4356
|
indeterminate,
|
|
4357
|
+
tabIndex,
|
|
3617
4358
|
"aria-label": label,
|
|
3618
4359
|
className: cn("after:-inset-x-2 after:-inset-y-3", className),
|
|
3619
4360
|
onPointerDown: (event) => {
|
|
@@ -3632,7 +4373,8 @@ function ObjectListCheckbox({
|
|
|
3632
4373
|
);
|
|
3633
4374
|
}
|
|
3634
4375
|
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";
|
|
3635
|
-
|
|
4376
|
+
var REVEALED = "data-revealed:bg-dimah-s3-primary/15";
|
|
4377
|
+
var ObjectListRow = memo(function ObjectListRow2(props) {
|
|
3636
4378
|
const { entry, className } = props;
|
|
3637
4379
|
const parts = useEntryParts(props);
|
|
3638
4380
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3641,19 +4383,25 @@ function ObjectListRow(props) {
|
|
|
3641
4383
|
...parts.dropTarget,
|
|
3642
4384
|
"data-drop-name": parts.dropTarget ? entry.name : void 0,
|
|
3643
4385
|
"data-slot": "object-list-entry",
|
|
4386
|
+
"data-entry-key": entry.key,
|
|
3644
4387
|
"data-kind": entry.kind,
|
|
3645
4388
|
"data-view": "list",
|
|
3646
4389
|
"data-selected": parts.selected ? "" : void 0,
|
|
4390
|
+
onContextMenu: parts.onContextMenu,
|
|
3647
4391
|
className: cn(
|
|
3648
4392
|
"grid min-h-11 min-w-0 items-center gap-2 overflow-hidden py-1 ps-1.5 pe-1 transition-colors duration-150",
|
|
3649
4393
|
parts.checkbox ? parts.actions ? "grid-cols-[auto_minmax(0,1fr)_auto]" : "grid-cols-[auto_minmax(0,1fr)]" : parts.actions ? "grid-cols-[minmax(0,1fr)_auto]" : "grid-cols-[minmax(0,1fr)]",
|
|
3650
4394
|
parts.selected ? "bg-dimah-s3-primary/10 hover:bg-dimah-s3-primary/15" : "hover:bg-dimah-s3-muted",
|
|
3651
4395
|
DROP_TARGET,
|
|
4396
|
+
REVEALED,
|
|
3652
4397
|
className
|
|
3653
4398
|
),
|
|
3654
4399
|
children: [
|
|
3655
4400
|
parts.checkbox,
|
|
3656
|
-
/* @__PURE__ */ jsxs(
|
|
4401
|
+
parts.renaming ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2.5 self-stretch", children: [
|
|
4402
|
+
/* @__PURE__ */ jsx("span", { className: "flex size-8 shrink-0 items-center justify-center", children: parts.media ?? /* @__PURE__ */ jsx(EntryMedia, { entry, className: "size-8 rounded-[4px]" }) }),
|
|
4403
|
+
/* @__PURE__ */ jsx(ObjectListRenameField, { entry })
|
|
4404
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
3657
4405
|
EntryTrigger,
|
|
3658
4406
|
{
|
|
3659
4407
|
parts,
|
|
@@ -3669,7 +4417,14 @@ function ObjectListRow(props) {
|
|
|
3669
4417
|
),
|
|
3670
4418
|
children: [
|
|
3671
4419
|
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
3672
|
-
/* @__PURE__ */ jsx("span", { className: "block w-full min-w-0 overflow-hidden text-sm leading-snug text-dimah-s3-foreground", children: /* @__PURE__ */ jsx(
|
|
4420
|
+
/* @__PURE__ */ jsx("span", { className: "block w-full min-w-0 overflow-hidden text-sm leading-snug text-dimah-s3-foreground", children: /* @__PURE__ */ jsx(
|
|
4421
|
+
FileName,
|
|
4422
|
+
{
|
|
4423
|
+
name: entry.name,
|
|
4424
|
+
extension: entry.kind === "file",
|
|
4425
|
+
highlight: parts.highlight
|
|
4426
|
+
}
|
|
4427
|
+
) }),
|
|
3673
4428
|
parts.meta ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: parts.meta }) : null
|
|
3674
4429
|
] }),
|
|
3675
4430
|
parts.description ? /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-xs leading-4 text-dimah-s3-muted-foreground", children: parts.description }) : null
|
|
@@ -3683,8 +4438,8 @@ function ObjectListRow(props) {
|
|
|
3683
4438
|
]
|
|
3684
4439
|
}
|
|
3685
4440
|
);
|
|
3686
|
-
}
|
|
3687
|
-
|
|
4441
|
+
});
|
|
4442
|
+
var ObjectListTile = memo(function ObjectListTile2(props) {
|
|
3688
4443
|
const { entry, className } = props;
|
|
3689
4444
|
const parts = useEntryParts(props);
|
|
3690
4445
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3693,17 +4448,23 @@ function ObjectListTile(props) {
|
|
|
3693
4448
|
...parts.dropTarget,
|
|
3694
4449
|
"data-drop-name": parts.dropTarget ? entry.name : void 0,
|
|
3695
4450
|
"data-slot": "object-list-entry",
|
|
4451
|
+
"data-entry-key": entry.key,
|
|
3696
4452
|
"data-kind": entry.kind,
|
|
3697
4453
|
"data-view": "grid",
|
|
3698
4454
|
"data-selected": parts.selected ? "" : void 0,
|
|
4455
|
+
onContextMenu: parts.onContextMenu,
|
|
3699
4456
|
className: cn(
|
|
3700
4457
|
"group/entry relative flex h-full min-w-0 flex-col overflow-hidden rounded-lg border transition-colors duration-150",
|
|
3701
4458
|
parts.selected ? "border-dimah-s3-primary bg-dimah-s3-primary/10" : "border-dimah-s3-border hover:bg-dimah-s3-muted",
|
|
3702
4459
|
DROP_TARGET,
|
|
4460
|
+
REVEALED,
|
|
3703
4461
|
className
|
|
3704
4462
|
),
|
|
3705
4463
|
children: [
|
|
3706
|
-
/* @__PURE__ */ jsxs(
|
|
4464
|
+
parts.renaming ? /* @__PURE__ */ jsxs("div", { className: "flex h-full min-w-0 flex-col", children: [
|
|
4465
|
+
/* @__PURE__ */ jsx("span", { className: "flex aspect-[4/3] w-full items-center justify-center overflow-hidden bg-dimah-s3-muted/60", children: parts.media ?? /* @__PURE__ */ jsx(EntryMedia, { entry, tile: true }) }),
|
|
4466
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 px-2 py-1.5", children: /* @__PURE__ */ jsx(ObjectListRenameField, { entry }) })
|
|
4467
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
3707
4468
|
EntryTrigger,
|
|
3708
4469
|
{
|
|
3709
4470
|
parts,
|
|
@@ -3712,7 +4473,14 @@ function ObjectListTile(props) {
|
|
|
3712
4473
|
/* @__PURE__ */ jsx("span", { className: "flex aspect-[4/3] w-full items-center justify-center overflow-hidden bg-dimah-s3-muted/60", children: parts.media ?? /* @__PURE__ */ jsx(EntryMedia, { entry, tile: true }) }),
|
|
3713
4474
|
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col gap-0.5 px-2 py-1.5", children: [
|
|
3714
4475
|
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
3715
|
-
/* @__PURE__ */ jsx("span", { className: "block min-w-0 flex-1 overflow-hidden text-sm leading-snug text-dimah-s3-foreground", children: /* @__PURE__ */ jsx(
|
|
4476
|
+
/* @__PURE__ */ jsx("span", { className: "block min-w-0 flex-1 overflow-hidden text-sm leading-snug text-dimah-s3-foreground", children: /* @__PURE__ */ jsx(
|
|
4477
|
+
FileName,
|
|
4478
|
+
{
|
|
4479
|
+
name: entry.name,
|
|
4480
|
+
extension: entry.kind === "file",
|
|
4481
|
+
highlight: parts.highlight
|
|
4482
|
+
}
|
|
4483
|
+
) }),
|
|
3716
4484
|
parts.meta ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: parts.meta }) : null
|
|
3717
4485
|
] }),
|
|
3718
4486
|
parts.description ? /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-xs leading-4 text-dimah-s3-muted-foreground", children: parts.description }) : null
|
|
@@ -3734,7 +4502,7 @@ function ObjectListTile(props) {
|
|
|
3734
4502
|
]
|
|
3735
4503
|
}
|
|
3736
4504
|
);
|
|
3737
|
-
}
|
|
4505
|
+
});
|
|
3738
4506
|
function useEntryParts({
|
|
3739
4507
|
entry,
|
|
3740
4508
|
actions,
|
|
@@ -3743,51 +4511,65 @@ function useEntryParts({
|
|
|
3743
4511
|
media
|
|
3744
4512
|
}) {
|
|
3745
4513
|
const t = useTranslations();
|
|
3746
|
-
const
|
|
3747
|
-
const {
|
|
3748
|
-
const
|
|
3749
|
-
const
|
|
3750
|
-
const
|
|
3751
|
-
const
|
|
3752
|
-
const
|
|
3753
|
-
const
|
|
3754
|
-
const
|
|
4514
|
+
const scope = useObjectListEntryScope();
|
|
4515
|
+
const { selected, selectable, selecting, renaming, tabStop } = useObjectListEntryStatus(entry.key);
|
|
4516
|
+
const location = scope.search ? entry.location : void 0;
|
|
4517
|
+
const defaultDescription = useDefaultDescription(entry, location);
|
|
4518
|
+
const folder = entry.kind === "folder";
|
|
4519
|
+
const canRename = folder ? scope.renameFolder : scope.renameFile;
|
|
4520
|
+
const opens = folder || scope.opensFiles;
|
|
4521
|
+
const takesDrops = folder && scope.folderUploads;
|
|
4522
|
+
const hasMenu = location != null || (folder ? takesDrops || canRename : scope.download || scope.share || scope.delete || canRename);
|
|
4523
|
+
const resolvedActions = actions !== void 0 ? actions : scope.renderActions ? scope.renderActions(entry) : hasMenu ? /* @__PURE__ */ jsx(ObjectListItemMenu, {}) : null;
|
|
4524
|
+
const usesDefaultMenu = actions === void 0 && scope.renderActions == null && hasMenu;
|
|
3755
4525
|
return {
|
|
3756
4526
|
selected,
|
|
3757
|
-
selecting
|
|
3758
|
-
|
|
4527
|
+
selecting,
|
|
4528
|
+
renaming,
|
|
4529
|
+
tabStop,
|
|
4530
|
+
checkbox: selectable ? /* @__PURE__ */ jsx(
|
|
3759
4531
|
ObjectListCheckbox,
|
|
3760
4532
|
{
|
|
3761
4533
|
checked: selected,
|
|
4534
|
+
tabIndex: -1,
|
|
3762
4535
|
label: t("Select {name}", {
|
|
3763
4536
|
note: "object list selection",
|
|
3764
4537
|
variables: { name: entry.name }
|
|
3765
4538
|
}),
|
|
3766
|
-
onCheckedChange: (checked, shiftKey) =>
|
|
4539
|
+
onCheckedChange: (checked, shiftKey) => scope.toggle(entry.key, { value: checked, range: shiftKey })
|
|
3767
4540
|
}
|
|
3768
4541
|
) : null,
|
|
3769
4542
|
actions: present(resolvedActions),
|
|
3770
4543
|
description: present(
|
|
3771
|
-
description !== void 0 ? description :
|
|
4544
|
+
description !== void 0 ? description : scope.renderDescription ? scope.renderDescription(entry) : defaultDescription
|
|
3772
4545
|
),
|
|
3773
|
-
meta: present(meta !== void 0 ? meta :
|
|
4546
|
+
meta: present(meta !== void 0 ? meta : scope.renderMeta?.(entry)),
|
|
3774
4547
|
media: present(media),
|
|
3775
|
-
dropTarget:
|
|
4548
|
+
dropTarget: takesDrops ? scope.folderDropTarget(entry.id) : null,
|
|
4549
|
+
highlight: scope.search || void 0,
|
|
3776
4550
|
entryKey: entry.key,
|
|
3777
|
-
onClick:
|
|
3778
|
-
if (selectable
|
|
4551
|
+
onClick: opens || selectable ? (event) => {
|
|
4552
|
+
if (selectable) {
|
|
3779
4553
|
if (event.metaKey || event.ctrlKey) {
|
|
3780
|
-
|
|
4554
|
+
scope.toggle(entry.key);
|
|
3781
4555
|
return;
|
|
3782
4556
|
}
|
|
3783
4557
|
if (event.shiftKey) {
|
|
3784
|
-
|
|
4558
|
+
scope.toggle(entry.key, { range: true, value: true });
|
|
3785
4559
|
return;
|
|
3786
4560
|
}
|
|
3787
4561
|
}
|
|
3788
|
-
if (
|
|
3789
|
-
else
|
|
3790
|
-
} : null
|
|
4562
|
+
if (opens) scope.open(entry);
|
|
4563
|
+
else scope.toggle(entry.key);
|
|
4564
|
+
} : null,
|
|
4565
|
+
onContextMenu: usesDefaultMenu ? (event) => {
|
|
4566
|
+
const target = event.target;
|
|
4567
|
+
if (!(target instanceof Element) || target.closest("input, textarea")) {
|
|
4568
|
+
return;
|
|
4569
|
+
}
|
|
4570
|
+
event.preventDefault();
|
|
4571
|
+
scope.store.set({ menu: entry.key });
|
|
4572
|
+
} : void 0
|
|
3791
4573
|
};
|
|
3792
4574
|
}
|
|
3793
4575
|
function EntryTrigger({
|
|
@@ -3796,13 +4578,24 @@ function EntryTrigger({
|
|
|
3796
4578
|
children
|
|
3797
4579
|
}) {
|
|
3798
4580
|
const focusRing = "outline-none focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50";
|
|
4581
|
+
const tabIndex = parts.tabStop ? 0 : -1;
|
|
3799
4582
|
if (!parts.onClick) {
|
|
3800
|
-
return /* @__PURE__ */ jsx(
|
|
4583
|
+
return /* @__PURE__ */ jsx(
|
|
4584
|
+
"div",
|
|
4585
|
+
{
|
|
4586
|
+
tabIndex,
|
|
4587
|
+
"data-slot": "object-list-entry-trigger",
|
|
4588
|
+
"data-entry-key": parts.entryKey,
|
|
4589
|
+
className: cn(focusRing, className),
|
|
4590
|
+
children
|
|
4591
|
+
}
|
|
4592
|
+
);
|
|
3801
4593
|
}
|
|
3802
4594
|
return /* @__PURE__ */ jsx(
|
|
3803
4595
|
"button",
|
|
3804
4596
|
{
|
|
3805
4597
|
type: "button",
|
|
4598
|
+
tabIndex,
|
|
3806
4599
|
"data-slot": "object-list-entry-trigger",
|
|
3807
4600
|
"data-entry-key": parts.entryKey,
|
|
3808
4601
|
className: cn("cursor-pointer select-none", focusRing, className),
|
|
@@ -3842,15 +4635,19 @@ function EntryMedia({
|
|
|
3842
4635
|
}
|
|
3843
4636
|
);
|
|
3844
4637
|
}
|
|
3845
|
-
function useDefaultDescription(entry) {
|
|
4638
|
+
function useDefaultDescription(entry, location) {
|
|
3846
4639
|
const formatFileSize = useFormatFileSize();
|
|
3847
4640
|
const formatDate = useFormatDate();
|
|
3848
|
-
|
|
3849
|
-
const parts = [
|
|
4641
|
+
const parts = entry.kind === "folder" ? [] : [
|
|
3850
4642
|
entry.file.size != null ? formatFileSize(entry.file.size) : "",
|
|
3851
4643
|
formatDate(entry.file.updatedAt)
|
|
3852
4644
|
].filter(Boolean);
|
|
3853
|
-
|
|
4645
|
+
const details = parts.length > 0 ? parts.join(" \xB7 ") : null;
|
|
4646
|
+
if (!location) return details;
|
|
4647
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4648
|
+
/* @__PURE__ */ jsx(ObjectListLocation, { location }),
|
|
4649
|
+
details ? ` \xB7 ${details}` : null
|
|
4650
|
+
] });
|
|
3854
4651
|
}
|
|
3855
4652
|
function present(node) {
|
|
3856
4653
|
return node == null || node === false || node === "" ? null : node;
|
|
@@ -3912,10 +4709,7 @@ function EmptyTitle({ className, ...props }) {
|
|
|
3912
4709
|
"div",
|
|
3913
4710
|
{
|
|
3914
4711
|
"data-slot": "empty-title",
|
|
3915
|
-
className: cn(
|
|
3916
|
-
"cn-font-heading text-sm font-medium tracking-tight",
|
|
3917
|
-
className
|
|
3918
|
-
),
|
|
4712
|
+
className: cn("text-sm font-medium tracking-tight", className),
|
|
3919
4713
|
...props
|
|
3920
4714
|
}
|
|
3921
4715
|
);
|
|
@@ -3956,21 +4750,6 @@ function Skeleton({ className, ...props }) {
|
|
|
3956
4750
|
}
|
|
3957
4751
|
);
|
|
3958
4752
|
}
|
|
3959
|
-
function Spinner({
|
|
3960
|
-
className,
|
|
3961
|
-
...props
|
|
3962
|
-
}) {
|
|
3963
|
-
return /* @__PURE__ */ jsx(
|
|
3964
|
-
Loader2Icon,
|
|
3965
|
-
{
|
|
3966
|
-
"data-slot": "spinner",
|
|
3967
|
-
role: "status",
|
|
3968
|
-
"aria-label": "Loading",
|
|
3969
|
-
className: cn("size-4 animate-spin", className),
|
|
3970
|
-
...props
|
|
3971
|
-
}
|
|
3972
|
-
);
|
|
3973
|
-
}
|
|
3974
4753
|
function ObjectListEmpty({
|
|
3975
4754
|
title,
|
|
3976
4755
|
description,
|
|
@@ -3980,10 +4759,19 @@ function ObjectListEmpty({
|
|
|
3980
4759
|
const t = useTranslations();
|
|
3981
4760
|
const { list, upload } = useObjectListContext();
|
|
3982
4761
|
const search = list.search.trim();
|
|
4762
|
+
const folder = list.trail.at(-1);
|
|
4763
|
+
const recursive = list.searchScopes.length > 0;
|
|
4764
|
+
const everywhere = canChooseSearchScope(list) && list.searchScope === "folder";
|
|
3983
4765
|
const defaultTitle = search ? t("No results", { note: "object list" }) : t("This folder is empty", { note: "object list" });
|
|
3984
|
-
const defaultDescription = search ? t("Nothing in this folder matches \u201C{search}\u201D.", {
|
|
4766
|
+
const defaultDescription = search ? !recursive && folder ? t("Nothing in this folder matches \u201C{search}\u201D.", {
|
|
3985
4767
|
note: "object list",
|
|
3986
4768
|
variables: { search }
|
|
4769
|
+
}) : folder && list.searchScope === "folder" ? t("Nothing in \u201C{folder}\u201D or its folders matches \u201C{search}\u201D.", {
|
|
4770
|
+
note: "object list search",
|
|
4771
|
+
variables: { folder: folder.name, search }
|
|
4772
|
+
}) : t("Nothing matches \u201C{search}\u201D.", {
|
|
4773
|
+
note: "object list search",
|
|
4774
|
+
variables: { search }
|
|
3987
4775
|
}) : upload ? t("Drop files here to add them to this folder.", {
|
|
3988
4776
|
note: "object list"
|
|
3989
4777
|
}) : t("Files and folders you add here will show up in this list.", {
|
|
@@ -3995,7 +4783,18 @@ function ObjectListEmpty({
|
|
|
3995
4783
|
/* @__PURE__ */ jsx(EmptyTitle, { children: title ?? defaultTitle }),
|
|
3996
4784
|
/* @__PURE__ */ jsx(EmptyDescription, { className: "[overflow-wrap:anywhere]", children: description ?? defaultDescription })
|
|
3997
4785
|
] }),
|
|
3998
|
-
children ? /* @__PURE__ */ jsx(EmptyContent, { children }) :
|
|
4786
|
+
children ? /* @__PURE__ */ jsx(EmptyContent, { children }) : search ? /* @__PURE__ */ jsxs(EmptyContent, { className: "flex-row flex-wrap justify-center gap-2", children: [
|
|
4787
|
+
everywhere ? /* @__PURE__ */ jsx(
|
|
4788
|
+
Button,
|
|
4789
|
+
{
|
|
4790
|
+
variant: "outline",
|
|
4791
|
+
size: "sm",
|
|
4792
|
+
onClick: () => list.setSearchScope("all"),
|
|
4793
|
+
children: t("Search everywhere", { note: "object list search" })
|
|
4794
|
+
}
|
|
4795
|
+
) : null,
|
|
4796
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => list.setSearch(""), children: t("Clear search", { note: "object list" }) })
|
|
4797
|
+
] }) : null
|
|
3999
4798
|
] });
|
|
4000
4799
|
}
|
|
4001
4800
|
function ObjectListError({
|
|
@@ -4120,7 +4919,7 @@ function ObjectListPagination({
|
|
|
4120
4919
|
function ObjectListContent({ className }) {
|
|
4121
4920
|
const context = useObjectListContext();
|
|
4122
4921
|
const { list, view, sizing } = context;
|
|
4123
|
-
const formatError =
|
|
4922
|
+
const formatError = useFormatError();
|
|
4124
4923
|
const [scroller, setScroller] = useState(null);
|
|
4125
4924
|
const hasRows = list.entries.length > 0;
|
|
4126
4925
|
const errorMessage = list.error ? formatError(list.error) : null;
|
|
@@ -4145,12 +4944,19 @@ function ObjectListContent({ className }) {
|
|
|
4145
4944
|
list.isLoading ? /* @__PURE__ */ jsx(ObjectListSkeleton, { view }) : null,
|
|
4146
4945
|
list.error && !hasRows && !list.isLoading ? /* @__PURE__ */ jsx(ObjectListError, { message: errorMessage, onRetry: list.retry }) : null,
|
|
4147
4946
|
showEmpty ? context.empty ?? /* @__PURE__ */ jsx(ObjectListEmpty, {}) : null,
|
|
4148
|
-
hasRows ? /* @__PURE__ */ jsx(
|
|
4947
|
+
hasRows ? /* @__PURE__ */ jsx(
|
|
4948
|
+
ObjectListEntries,
|
|
4949
|
+
{
|
|
4950
|
+
entries: list.entries,
|
|
4951
|
+
view,
|
|
4952
|
+
renderEntry: context.renderEntry
|
|
4953
|
+
}
|
|
4954
|
+
) : null,
|
|
4149
4955
|
hasRows && errorMessage ? /* @__PURE__ */ jsx(ObjectListErrorBanner, { message: errorMessage, onRetry: list.retry }) : null,
|
|
4150
4956
|
/* @__PURE__ */ jsx(
|
|
4151
4957
|
ObjectListPagination,
|
|
4152
4958
|
{
|
|
4153
|
-
mode: context.
|
|
4959
|
+
mode: context.pagination,
|
|
4154
4960
|
root: sizing ? scroller : null,
|
|
4155
4961
|
ready: !sizing || scroller != null
|
|
4156
4962
|
}
|
|
@@ -4163,27 +4969,34 @@ var ENTRY_VISIBILITY = {
|
|
|
4163
4969
|
list: "[contain-intrinsic-block-size:auto_2.75rem] [content-visibility:auto]",
|
|
4164
4970
|
grid: "[contain-intrinsic-block-size:auto_9.5rem] [content-visibility:auto]"
|
|
4165
4971
|
};
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
"
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
}
|
|
4972
|
+
var ObjectListEntries = memo(function ObjectListEntries2({
|
|
4973
|
+
entries,
|
|
4974
|
+
view,
|
|
4975
|
+
renderEntry
|
|
4976
|
+
}) {
|
|
4977
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4978
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "object-list-entries-start", tabIndex: -1 }),
|
|
4979
|
+
/* @__PURE__ */ jsx(
|
|
4980
|
+
"div",
|
|
4981
|
+
{
|
|
4982
|
+
role: "list",
|
|
4983
|
+
"data-slot": "object-list-entries",
|
|
4984
|
+
"data-view": view,
|
|
4985
|
+
className: view === "grid" ? "grid grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] gap-2 p-2" : "flex min-w-0 flex-col",
|
|
4986
|
+
children: entries.map((entry) => /* @__PURE__ */ jsx(
|
|
4987
|
+
"div",
|
|
4988
|
+
{
|
|
4989
|
+
role: "listitem",
|
|
4990
|
+
className: cn("min-w-0", ENTRY_VISIBILITY[view]),
|
|
4991
|
+
children: /* @__PURE__ */ jsx(ObjectListEntryProvider, { entry, children: renderEntry ? renderEntry(entry) : view === "grid" ? /* @__PURE__ */ jsx(ObjectListTile, { entry }) : /* @__PURE__ */ jsx(ObjectListRow, { entry }) })
|
|
4992
|
+
},
|
|
4993
|
+
entry.key
|
|
4994
|
+
))
|
|
4995
|
+
}
|
|
4996
|
+
),
|
|
4997
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "object-list-entries-end", tabIndex: -1 })
|
|
4998
|
+
] });
|
|
4999
|
+
});
|
|
4187
5000
|
function Breadcrumb({ className, ...props }) {
|
|
4188
5001
|
return /* @__PURE__ */ jsx(
|
|
4189
5002
|
"nav",
|
|
@@ -4400,15 +5213,12 @@ function PathMenu({
|
|
|
4400
5213
|
] }) })
|
|
4401
5214
|
] });
|
|
4402
5215
|
}
|
|
4403
|
-
var ObjectListHeaderContext = createContext(null);
|
|
4404
|
-
function useOptionalObjectListHeader() {
|
|
4405
|
-
return useContext(ObjectListHeaderContext);
|
|
4406
|
-
}
|
|
4407
5216
|
var OBJECT_LIST_HEADER_COMPACT_LABEL = "@max-[36rem]/object-list-header:sr-only";
|
|
4408
5217
|
var OBJECT_LIST_HEADER_COMPACT_BUTTON = "@max-[36rem]/object-list-header:aspect-square @max-[36rem]/object-list-header:px-0!";
|
|
4409
5218
|
function ObjectListHeader({
|
|
4410
5219
|
children,
|
|
4411
5220
|
breadcrumb,
|
|
5221
|
+
searchBar = true,
|
|
4412
5222
|
selectionActions,
|
|
4413
5223
|
className
|
|
4414
5224
|
}) {
|
|
@@ -4423,9 +5233,10 @@ function ObjectListHeader({
|
|
|
4423
5233
|
() => ({ setSearchExpanded, setFolderExpanded }),
|
|
4424
5234
|
[]
|
|
4425
5235
|
);
|
|
4426
|
-
const
|
|
4427
|
-
const
|
|
4428
|
-
|
|
5236
|
+
const replaced = selecting && !selection?.persist;
|
|
5237
|
+
const creatingFolder = folderExpanded && !replaced;
|
|
5238
|
+
const searching = searchExpanded && !creatingFolder && !replaced;
|
|
5239
|
+
return /* @__PURE__ */ jsx(ObjectListHeaderContext.Provider, { value: header, children: /* @__PURE__ */ jsxs(
|
|
4429
5240
|
"div",
|
|
4430
5241
|
{
|
|
4431
5242
|
"data-slot": "object-list-header",
|
|
@@ -4434,50 +5245,60 @@ function ObjectListHeader({
|
|
|
4434
5245
|
"data-folder-open": creatingFolder ? "" : void 0,
|
|
4435
5246
|
className: cn(
|
|
4436
5247
|
"group/object-list-header @container/object-list-header shrink-0 border-b border-dimah-s3-border",
|
|
4437
|
-
|
|
5248
|
+
replaced && "bg-dimah-s3-primary/10",
|
|
4438
5249
|
className
|
|
4439
5250
|
),
|
|
4440
|
-
children:
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
actions: selectionActions ?? context.selectionActions
|
|
4444
|
-
}
|
|
4445
|
-
) : /* @__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: [
|
|
4446
|
-
/* @__PURE__ */ jsxs(
|
|
4447
|
-
"div",
|
|
5251
|
+
children: [
|
|
5252
|
+
replaced ? /* @__PURE__ */ jsx(
|
|
5253
|
+
ObjectListSelectionBar,
|
|
4448
5254
|
{
|
|
4449
|
-
|
|
4450
|
-
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",
|
|
4451
|
-
children: [
|
|
4452
|
-
/* @__PURE__ */ jsx(ObjectListSelectAll, {}),
|
|
4453
|
-
showBreadcrumb ? /* @__PURE__ */ jsx(ObjectListBreadcrumb, {}) : /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1" }),
|
|
4454
|
-
list.isRefreshing ? /* @__PURE__ */ jsx(
|
|
4455
|
-
Spinner,
|
|
4456
|
-
{
|
|
4457
|
-
className: "shrink-0 text-dimah-s3-muted-foreground",
|
|
4458
|
-
"aria-label": t("Loading files", { note: "object list" })
|
|
4459
|
-
}
|
|
4460
|
-
) : null
|
|
4461
|
-
]
|
|
5255
|
+
actions: selectionActions ?? context.selectionActions
|
|
4462
5256
|
}
|
|
4463
|
-
),
|
|
4464
|
-
|
|
4465
|
-
|
|
5257
|
+
) : /* @__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: [
|
|
5258
|
+
/* @__PURE__ */ jsxs(
|
|
5259
|
+
"div",
|
|
5260
|
+
{
|
|
5261
|
+
"data-slot": "object-list-header-path",
|
|
5262
|
+
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",
|
|
5263
|
+
children: [
|
|
5264
|
+
selecting ? null : /* @__PURE__ */ jsx(ObjectListSelectAll, {}),
|
|
5265
|
+
showBreadcrumb ? /* @__PURE__ */ jsx(ObjectListBreadcrumb, {}) : /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1" }),
|
|
5266
|
+
list.isRefreshing ? /* @__PURE__ */ jsx(
|
|
5267
|
+
Spinner,
|
|
5268
|
+
{
|
|
5269
|
+
className: "shrink-0 text-dimah-s3-muted-foreground",
|
|
5270
|
+
"aria-label": t("Loading files", { note: "object list" })
|
|
5271
|
+
}
|
|
5272
|
+
) : null
|
|
5273
|
+
]
|
|
5274
|
+
}
|
|
5275
|
+
),
|
|
5276
|
+
/* @__PURE__ */ jsxs(
|
|
5277
|
+
"div",
|
|
5278
|
+
{
|
|
5279
|
+
"data-slot": "object-list-header-actions",
|
|
5280
|
+
className: cn(
|
|
5281
|
+
"ms-auto flex min-w-0 shrink-0 items-center gap-1",
|
|
5282
|
+
// While search or new folder is open, that field takes the bar alone.
|
|
5283
|
+
"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",
|
|
5284
|
+
"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"
|
|
5285
|
+
),
|
|
5286
|
+
children: [
|
|
5287
|
+
/* @__PURE__ */ jsx(ObjectListNewFolder, {}),
|
|
5288
|
+
children
|
|
5289
|
+
]
|
|
5290
|
+
}
|
|
5291
|
+
)
|
|
5292
|
+
] }),
|
|
5293
|
+
searchBar && list.isSearching ? /* @__PURE__ */ jsx(ObjectListSearchBar, { className: "border-t border-dimah-s3-border" }) : null,
|
|
5294
|
+
selecting && !replaced ? /* @__PURE__ */ jsx(
|
|
5295
|
+
ObjectListSelectionBar,
|
|
4466
5296
|
{
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
"ms-auto flex min-w-0 shrink-0 items-center gap-1",
|
|
4470
|
-
// While search or new folder is open, that field takes the bar alone.
|
|
4471
|
-
"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",
|
|
4472
|
-
"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"
|
|
4473
|
-
),
|
|
4474
|
-
children: [
|
|
4475
|
-
/* @__PURE__ */ jsx(NewFolderControl, {}),
|
|
4476
|
-
children
|
|
4477
|
-
]
|
|
5297
|
+
className: "border-t border-dimah-s3-border bg-dimah-s3-primary/10",
|
|
5298
|
+
actions: selectionActions ?? context.selectionActions
|
|
4478
5299
|
}
|
|
4479
|
-
)
|
|
4480
|
-
]
|
|
5300
|
+
) : null
|
|
5301
|
+
]
|
|
4481
5302
|
}
|
|
4482
5303
|
) });
|
|
4483
5304
|
}
|
|
@@ -4506,10 +5327,9 @@ function ObjectListSelectionBar({
|
|
|
4506
5327
|
className
|
|
4507
5328
|
}) {
|
|
4508
5329
|
const t = useTranslations();
|
|
4509
|
-
const formatNumber = useFormatNumber();
|
|
4510
5330
|
const { list, selection, delete: del } = useObjectListContext();
|
|
5331
|
+
const count = useSelectionCount(list, selection);
|
|
4511
5332
|
if (!selection?.isSelecting) return null;
|
|
4512
|
-
const count = formatNumber(selection.count);
|
|
4513
5333
|
const busy = del != null && selection.selected.some(
|
|
4514
5334
|
(entry) => entry.kind === "file" && del.pendingKeys.includes(objectKeyOf(entry))
|
|
4515
5335
|
);
|
|
@@ -4523,20 +5343,7 @@ function ObjectListSelectionBar({
|
|
|
4523
5343
|
),
|
|
4524
5344
|
children: [
|
|
4525
5345
|
/* @__PURE__ */ jsx(ObjectListSelectAll, {}),
|
|
4526
|
-
/* @__PURE__ */ jsx(
|
|
4527
|
-
"p",
|
|
4528
|
-
{
|
|
4529
|
-
"aria-live": "polite",
|
|
4530
|
-
className: "min-w-0 flex-1 truncate text-sm font-medium text-dimah-s3-foreground tabular-nums",
|
|
4531
|
-
children: selection.allSelected && list.hasMore && !selection.persist ? t("{count} selected on this page", {
|
|
4532
|
-
note: "object list selection",
|
|
4533
|
-
variables: { count }
|
|
4534
|
-
}) : t("{count} selected", {
|
|
4535
|
-
note: "object list selection",
|
|
4536
|
-
variables: { count }
|
|
4537
|
-
})
|
|
4538
|
-
}
|
|
4539
|
-
),
|
|
5346
|
+
/* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium text-dimah-s3-foreground tabular-nums", children: count }),
|
|
4540
5347
|
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
4541
5348
|
actions ? /* @__PURE__ */ jsx(
|
|
4542
5349
|
"div",
|
|
@@ -4562,6 +5369,19 @@ function ObjectListSelectionBar({
|
|
|
4562
5369
|
}
|
|
4563
5370
|
);
|
|
4564
5371
|
}
|
|
5372
|
+
function useSelectionCount(list, selection) {
|
|
5373
|
+
const t = useTranslations();
|
|
5374
|
+
const formatNumber = useFormatNumber();
|
|
5375
|
+
if (!selection?.isSelecting) return null;
|
|
5376
|
+
const count = formatNumber(selection.count);
|
|
5377
|
+
return selection.allSelected && list.hasMore && !selection.persist ? t("{count} selected on this page", {
|
|
5378
|
+
note: "object list selection",
|
|
5379
|
+
variables: { count }
|
|
5380
|
+
}) : t("{count} selected", {
|
|
5381
|
+
note: "object list selection",
|
|
5382
|
+
variables: { count }
|
|
5383
|
+
});
|
|
5384
|
+
}
|
|
4565
5385
|
function ObjectListBulkDelete() {
|
|
4566
5386
|
const { delete: del, selection } = useObjectListContext();
|
|
4567
5387
|
if (!del || !selection?.isSelecting) return null;
|
|
@@ -4569,6 +5389,7 @@ function ObjectListBulkDelete() {
|
|
|
4569
5389
|
}
|
|
4570
5390
|
function BulkDeleteControl() {
|
|
4571
5391
|
const t = useTranslations();
|
|
5392
|
+
const formatError = useFormatError();
|
|
4572
5393
|
const { selection, resolveFolderKeys } = useObjectListContext();
|
|
4573
5394
|
const { delete: del, request } = useDeleteContext();
|
|
4574
5395
|
const report = useObjectListFeedback();
|
|
@@ -4583,12 +5404,13 @@ function BulkDeleteControl() {
|
|
|
4583
5404
|
let plan;
|
|
4584
5405
|
try {
|
|
4585
5406
|
plan = await planBulkDelete(selection.selected, resolveFolderKeys);
|
|
4586
|
-
} catch {
|
|
5407
|
+
} catch (error) {
|
|
4587
5408
|
report({
|
|
4588
5409
|
type: "error",
|
|
4589
5410
|
title: t("Could not delete the selection", {
|
|
4590
5411
|
note: "object list selection"
|
|
4591
|
-
})
|
|
5412
|
+
}),
|
|
5413
|
+
description: formatError(error)
|
|
4592
5414
|
});
|
|
4593
5415
|
return;
|
|
4594
5416
|
} finally {
|
|
@@ -4605,7 +5427,20 @@ function BulkDeleteControl() {
|
|
|
4605
5427
|
return;
|
|
4606
5428
|
}
|
|
4607
5429
|
setRequested(plan.targets.map((target) => target.objectKey));
|
|
4608
|
-
request(plan.targets, {
|
|
5430
|
+
request(plan.targets, {
|
|
5431
|
+
note,
|
|
5432
|
+
trigger,
|
|
5433
|
+
onDeleted: (result) => {
|
|
5434
|
+
setRequested([]);
|
|
5435
|
+
const deleted = new Set(result.deleted);
|
|
5436
|
+
const emptied = plan.folders.filter(
|
|
5437
|
+
({ objectKeys }) => objectKeys.length > 0 && objectKeys.every((key) => deleted.has(key))
|
|
5438
|
+
);
|
|
5439
|
+
if (emptied.length > 0) {
|
|
5440
|
+
selection.deselect(emptied.map(({ entryKey }) => entryKey));
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
});
|
|
4609
5444
|
}
|
|
4610
5445
|
return /* @__PURE__ */ jsxs(
|
|
4611
5446
|
Button,
|
|
@@ -4627,45 +5462,55 @@ function BulkDeleteControl() {
|
|
|
4627
5462
|
}
|
|
4628
5463
|
async function planBulkDelete(selected, resolveFolderKeys) {
|
|
4629
5464
|
const targets = /* @__PURE__ */ new Map();
|
|
4630
|
-
let skippedFolders = 0;
|
|
4631
5465
|
for (const entry of selected) {
|
|
4632
|
-
if (entry.kind
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
5466
|
+
if (entry.kind !== "file") continue;
|
|
5467
|
+
const objectKey = objectKeyOf(entry);
|
|
5468
|
+
targets.set(objectKey, {
|
|
5469
|
+
objectKey,
|
|
5470
|
+
fileName: entry.file.name,
|
|
5471
|
+
fileSize: entry.file.size
|
|
5472
|
+
});
|
|
5473
|
+
}
|
|
5474
|
+
const selectedFolders = selected.filter((entry) => entry.kind === "folder");
|
|
5475
|
+
if (!resolveFolderKeys) {
|
|
5476
|
+
return {
|
|
5477
|
+
targets: [...targets.values()],
|
|
5478
|
+
folders: [],
|
|
5479
|
+
skippedFolders: selectedFolders.length
|
|
5480
|
+
};
|
|
5481
|
+
}
|
|
5482
|
+
const folders = await Promise.all(
|
|
5483
|
+
selectedFolders.map(async (entry) => ({
|
|
5484
|
+
entryKey: entry.key,
|
|
5485
|
+
objectKeys: await resolveFolderKeys(entry.folder)
|
|
5486
|
+
}))
|
|
5487
|
+
);
|
|
5488
|
+
for (const { objectKeys } of folders) {
|
|
5489
|
+
for (const objectKey of objectKeys) {
|
|
5490
|
+
if (!targets.has(objectKey)) targets.set(objectKey, { objectKey });
|
|
4645
5491
|
}
|
|
4646
5492
|
}
|
|
4647
|
-
return { targets: [...targets.values()], skippedFolders };
|
|
5493
|
+
return { targets: [...targets.values()], folders, skippedFolders: 0 };
|
|
4648
5494
|
}
|
|
4649
|
-
function
|
|
5495
|
+
function ObjectListNewFolder({ className }) {
|
|
4650
5496
|
const t = useTranslations();
|
|
4651
|
-
const { list } = useObjectListContext();
|
|
5497
|
+
const { list, newFolderOpen, setNewFolderOpen } = useObjectListContext();
|
|
4652
5498
|
const header = useOptionalObjectListHeader();
|
|
4653
|
-
const [editing, setEditing] = useState(false);
|
|
4654
5499
|
const buttonRef = useRef(null);
|
|
4655
5500
|
const returnFocusRef = useRef(false);
|
|
4656
5501
|
const setFolderExpanded = header?.setFolderExpanded;
|
|
4657
5502
|
useEffect(() => {
|
|
4658
|
-
if (
|
|
5503
|
+
if (newFolderOpen || !returnFocusRef.current) return;
|
|
4659
5504
|
returnFocusRef.current = false;
|
|
4660
5505
|
buttonRef.current?.focus();
|
|
4661
|
-
}, [
|
|
5506
|
+
}, [newFolderOpen]);
|
|
4662
5507
|
useLayoutEffect(() => {
|
|
4663
5508
|
if (!setFolderExpanded) return;
|
|
4664
|
-
setFolderExpanded(
|
|
5509
|
+
setFolderExpanded(newFolderOpen);
|
|
4665
5510
|
return () => setFolderExpanded(false);
|
|
4666
|
-
}, [
|
|
5511
|
+
}, [newFolderOpen, setFolderExpanded]);
|
|
4667
5512
|
if (!list.createFolder) return null;
|
|
4668
|
-
if (
|
|
5513
|
+
if (newFolderOpen) {
|
|
4669
5514
|
return /* @__PURE__ */ jsx(
|
|
4670
5515
|
NewFolderForm,
|
|
4671
5516
|
{
|
|
@@ -4673,7 +5518,7 @@ function NewFolderControl({ className }) {
|
|
|
4673
5518
|
wide: header != null,
|
|
4674
5519
|
onClose: () => {
|
|
4675
5520
|
returnFocusRef.current = true;
|
|
4676
|
-
|
|
5521
|
+
setNewFolderOpen(false);
|
|
4677
5522
|
},
|
|
4678
5523
|
className
|
|
4679
5524
|
}
|
|
@@ -4687,7 +5532,7 @@ function NewFolderControl({ className }) {
|
|
|
4687
5532
|
size: "sm",
|
|
4688
5533
|
"data-slot": "object-list-new-folder",
|
|
4689
5534
|
className: cn(OBJECT_LIST_HEADER_COMPACT_BUTTON, className),
|
|
4690
|
-
onClick: () =>
|
|
5535
|
+
onClick: () => setNewFolderOpen(true),
|
|
4691
5536
|
children: [
|
|
4692
5537
|
/* @__PURE__ */ jsx(FolderPlusIcon, { "data-icon": "inline-start" }),
|
|
4693
5538
|
/* @__PURE__ */ jsx("span", { className: OBJECT_LIST_HEADER_COMPACT_LABEL, children: t("New folder", { note: "object list" }) })
|
|
@@ -4702,7 +5547,7 @@ function NewFolderForm({
|
|
|
4702
5547
|
className
|
|
4703
5548
|
}) {
|
|
4704
5549
|
const t = useTranslations();
|
|
4705
|
-
const formatError =
|
|
5550
|
+
const formatError = useFormatError();
|
|
4706
5551
|
const inputId = useId();
|
|
4707
5552
|
const errorId = useId();
|
|
4708
5553
|
const inputRef = useRef(null);
|
|
@@ -4846,12 +5691,36 @@ function NewFolderForm({
|
|
|
4846
5691
|
}
|
|
4847
5692
|
);
|
|
4848
5693
|
}
|
|
5694
|
+
var hosts = /* @__PURE__ */ new WeakMap();
|
|
5695
|
+
function createCommands() {
|
|
5696
|
+
const host = { current: null };
|
|
5697
|
+
const commands = {
|
|
5698
|
+
startNewFolder: () => host.current?.startNewFolder(),
|
|
5699
|
+
openMenu: (entryKey) => host.current?.openMenu(entryKey)
|
|
5700
|
+
};
|
|
5701
|
+
hosts.set(commands, host);
|
|
5702
|
+
return commands;
|
|
5703
|
+
}
|
|
5704
|
+
function useObjectListCommands() {
|
|
5705
|
+
const [commands] = useState(createCommands);
|
|
5706
|
+
return commands;
|
|
5707
|
+
}
|
|
5708
|
+
function bindObjectListCommands(commands, host) {
|
|
5709
|
+
const slot = hosts.get(commands);
|
|
5710
|
+
if (slot) slot.current = host;
|
|
5711
|
+
}
|
|
4849
5712
|
var ENTRY = "[data-slot=object-list-entry]";
|
|
4850
5713
|
var TRIGGER = "[data-slot=object-list-entry-trigger]";
|
|
5714
|
+
var RENAME = "[data-slot=object-list-rename]";
|
|
5715
|
+
var ENTRIES_START = "[data-slot=object-list-entries-start]";
|
|
5716
|
+
var ENTRIES_END = "[data-slot=object-list-entries-end]";
|
|
5717
|
+
var CONTROL = "button, a[href], input, select, textarea, [role=checkbox], [tabindex]";
|
|
4851
5718
|
function useObjectListKeyboard({
|
|
4852
5719
|
list,
|
|
4853
5720
|
selection,
|
|
4854
|
-
view
|
|
5721
|
+
view,
|
|
5722
|
+
store,
|
|
5723
|
+
startRename
|
|
4855
5724
|
}) {
|
|
4856
5725
|
const spaceRef = useRef(false);
|
|
4857
5726
|
function selectableKey(target) {
|
|
@@ -4867,13 +5736,19 @@ function useObjectListKeyboard({
|
|
|
4867
5736
|
if (!(target instanceof HTMLElement) || !frame.contains(target)) return;
|
|
4868
5737
|
if (isFieldTarget(target) || isOverlayTarget(target)) return;
|
|
4869
5738
|
const modifier = event.ctrlKey || event.metaKey;
|
|
5739
|
+
const entry = entryOf(frame, target);
|
|
5740
|
+
if (event.key === "Tab") {
|
|
5741
|
+
if (!entry || modifier || event.altKey || target.closest(RENAME)) return;
|
|
5742
|
+
tabFrom(frame, entry, target, event);
|
|
5743
|
+
return;
|
|
5744
|
+
}
|
|
4870
5745
|
if (event.key === "Escape") {
|
|
4871
5746
|
if (!selection?.isSelecting) return;
|
|
4872
5747
|
event.preventDefault();
|
|
4873
5748
|
selection.clear();
|
|
4874
5749
|
return;
|
|
4875
5750
|
}
|
|
4876
|
-
if (event
|
|
5751
|
+
if (isSelectAllKey(event) && modifier && !event.altKey && !event.shiftKey) {
|
|
4877
5752
|
if (!selection || selection.mode !== "multiple") return;
|
|
4878
5753
|
if (selection.selectableCount === 0) return;
|
|
4879
5754
|
event.preventDefault();
|
|
@@ -4886,6 +5761,24 @@ function useObjectListKeyboard({
|
|
|
4886
5761
|
list.goUp();
|
|
4887
5762
|
return;
|
|
4888
5763
|
}
|
|
5764
|
+
if (event.key === "F2" && !modifier && !event.altKey && !event.shiftKey) {
|
|
5765
|
+
const key = entry?.dataset.entryKey;
|
|
5766
|
+
const found = key ? list.entries.find((item) => item.key === key) : null;
|
|
5767
|
+
if (!found || !canRenameEntry(found, list)) return;
|
|
5768
|
+
event.preventDefault();
|
|
5769
|
+
startRename(found.key);
|
|
5770
|
+
return;
|
|
5771
|
+
}
|
|
5772
|
+
if (isSearchKey(event) && !modifier && !event.altKey) {
|
|
5773
|
+
const search = frame.querySelector(
|
|
5774
|
+
"[data-slot=object-list-search]"
|
|
5775
|
+
);
|
|
5776
|
+
if (!search) return;
|
|
5777
|
+
event.preventDefault();
|
|
5778
|
+
if (search instanceof HTMLButtonElement) search.click();
|
|
5779
|
+
else search.querySelector("input")?.focus();
|
|
5780
|
+
return;
|
|
5781
|
+
}
|
|
4889
5782
|
if (event.key === " " && !modifier) {
|
|
4890
5783
|
const key = selectableKey(target);
|
|
4891
5784
|
if (!key || !selection) return;
|
|
@@ -4895,7 +5788,15 @@ function useObjectListKeyboard({
|
|
|
4895
5788
|
return;
|
|
4896
5789
|
}
|
|
4897
5790
|
if (modifier || event.altKey) return;
|
|
4898
|
-
const
|
|
5791
|
+
const rtl = getComputedStyle(frame).direction === "rtl";
|
|
5792
|
+
if (view === "list" && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {
|
|
5793
|
+
if (!entry) return;
|
|
5794
|
+
event.preventDefault();
|
|
5795
|
+
const forward = event.key === "ArrowRight" ? !rtl : rtl;
|
|
5796
|
+
moveWithinEntry(entry, target, forward ? 1 : -1);
|
|
5797
|
+
return;
|
|
5798
|
+
}
|
|
5799
|
+
const step = focusStep(event.key, frame, view, rtl);
|
|
4899
5800
|
if (step == null) return;
|
|
4900
5801
|
event.preventDefault();
|
|
4901
5802
|
moveFocus(frame, target, step);
|
|
@@ -4905,11 +5806,15 @@ function useObjectListKeyboard({
|
|
|
4905
5806
|
spaceRef.current = false;
|
|
4906
5807
|
event.preventDefault();
|
|
4907
5808
|
}
|
|
4908
|
-
|
|
5809
|
+
function onFocus(event) {
|
|
5810
|
+
if (!(event.target instanceof HTMLElement)) return;
|
|
5811
|
+
const key = entryOf(event.currentTarget, event.target)?.dataset.entryKey;
|
|
5812
|
+
if (key) store.set({ tabStop: key });
|
|
5813
|
+
}
|
|
5814
|
+
return { onKeyDown, onKeyUp, onFocus };
|
|
4909
5815
|
}
|
|
4910
|
-
function focusStep(key, frame, view) {
|
|
5816
|
+
function focusStep(key, frame, view, rtl) {
|
|
4911
5817
|
const columns = view === "grid" ? gridColumns(frame) : 1;
|
|
4912
|
-
const rtl = getComputedStyle(frame).direction === "rtl";
|
|
4913
5818
|
switch (key) {
|
|
4914
5819
|
case "ArrowDown":
|
|
4915
5820
|
return columns;
|
|
@@ -4949,6 +5854,32 @@ function moveFocus(frame, target, step) {
|
|
|
4949
5854
|
trigger?.focus();
|
|
4950
5855
|
trigger?.scrollIntoView({ block: "nearest" });
|
|
4951
5856
|
}
|
|
5857
|
+
function entryOf(frame, target) {
|
|
5858
|
+
const entry = target.closest(ENTRY);
|
|
5859
|
+
return entry && frame.contains(entry) ? entry : null;
|
|
5860
|
+
}
|
|
5861
|
+
function entryControls(entry) {
|
|
5862
|
+
return [...entry.querySelectorAll(CONTROL)].filter(
|
|
5863
|
+
(control) => !control.matches(":disabled") && control.getAttribute("aria-hidden") !== "true" && !(control instanceof HTMLInputElement && control.type === "hidden") && !control.closest("[inert], [hidden]")
|
|
5864
|
+
);
|
|
5865
|
+
}
|
|
5866
|
+
function moveWithinEntry(entry, target, step) {
|
|
5867
|
+
const controls = entryControls(entry);
|
|
5868
|
+
const index = controls.findIndex((control) => control.contains(target));
|
|
5869
|
+
if (index < 0) return;
|
|
5870
|
+
controls[index + step]?.focus();
|
|
5871
|
+
}
|
|
5872
|
+
function tabFrom(frame, entry, target, event) {
|
|
5873
|
+
const controls = entryControls(entry);
|
|
5874
|
+
const index = controls.indexOf(target);
|
|
5875
|
+
const next = index < 0 ? void 0 : controls[index + (event.shiftKey ? -1 : 1)];
|
|
5876
|
+
if (next) {
|
|
5877
|
+
event.preventDefault();
|
|
5878
|
+
next.focus();
|
|
5879
|
+
return;
|
|
5880
|
+
}
|
|
5881
|
+
frame.querySelector(event.shiftKey ? ENTRIES_START : ENTRIES_END)?.focus({ preventScroll: true });
|
|
5882
|
+
}
|
|
4952
5883
|
function isOverlayTarget(target) {
|
|
4953
5884
|
return Boolean(
|
|
4954
5885
|
target.closest(
|
|
@@ -4956,6 +5887,14 @@ function isOverlayTarget(target) {
|
|
|
4956
5887
|
)
|
|
4957
5888
|
);
|
|
4958
5889
|
}
|
|
5890
|
+
function isSearchKey(event) {
|
|
5891
|
+
if (event.key === "/") return true;
|
|
5892
|
+
return event.code === "Slash" && !event.shiftKey && !/^[\x20-\x7e]$/.test(event.key);
|
|
5893
|
+
}
|
|
5894
|
+
function isSelectAllKey(event) {
|
|
5895
|
+
if (/^[a-z]$/i.test(event.key)) return event.key.toLowerCase() === "a";
|
|
5896
|
+
return event.code === "KeyA";
|
|
5897
|
+
}
|
|
4959
5898
|
function ObjectListUsage({ className }) {
|
|
4960
5899
|
const t = useTranslations();
|
|
4961
5900
|
const { list } = useObjectListContext();
|
|
@@ -5064,8 +6003,9 @@ function ObjectList({
|
|
|
5064
6003
|
breadcrumb = true,
|
|
5065
6004
|
toolbar,
|
|
5066
6005
|
selectionActions,
|
|
6006
|
+
commands,
|
|
5067
6007
|
empty,
|
|
5068
|
-
|
|
6008
|
+
pagination = "auto",
|
|
5069
6009
|
height,
|
|
5070
6010
|
maxHeight,
|
|
5071
6011
|
className,
|
|
@@ -5081,35 +6021,283 @@ function ObjectList({
|
|
|
5081
6021
|
useRefreshListAfterUpload(upload, list.refresh);
|
|
5082
6022
|
const deleteFocus = useFocusAfterDelete();
|
|
5083
6023
|
const { announcement, announce } = useObjectListAnnouncement();
|
|
6024
|
+
const selectionCount = useSelectionCount(list, selection ?? null);
|
|
6025
|
+
const searchStatus = useObjectListSearchStatus(list);
|
|
6026
|
+
const revealRef = useRef(null);
|
|
6027
|
+
const [renamingKey, setRenamingKey] = useState(null);
|
|
6028
|
+
const [newFolderOpen, setNewFolderOpen] = useState(false);
|
|
6029
|
+
const renameFocusKey = useRef(null);
|
|
6030
|
+
const previousRenaming = useRef(null);
|
|
6031
|
+
if (renamingKey != null && !list.entries.some((entry) => entry.key === renamingKey)) {
|
|
6032
|
+
setRenamingKey(null);
|
|
6033
|
+
}
|
|
6034
|
+
useEffect(() => {
|
|
6035
|
+
const previous = previousRenaming.current;
|
|
6036
|
+
previousRenaming.current = renamingKey;
|
|
6037
|
+
if (previous == null || renamingKey != null) return;
|
|
6038
|
+
const focusKey = renameFocusKey.current;
|
|
6039
|
+
renameFocusKey.current = null;
|
|
6040
|
+
if (focusKey !== previous) return;
|
|
6041
|
+
deleteFocus.frameRef.current?.querySelector(
|
|
6042
|
+
`[data-slot="object-list-entry-trigger"][data-entry-key="${CSS.escape(previous)}"]`
|
|
6043
|
+
)?.focus();
|
|
6044
|
+
}, [deleteFocus.frameRef, renamingKey]);
|
|
5084
6045
|
const frameHeight = cssLength(height);
|
|
5085
6046
|
const frameMaxHeight = cssLength(maxHeight);
|
|
5086
|
-
const
|
|
6047
|
+
const sizing = frameHeight != null ? "fixed" : frameMaxHeight != null ? "max" : null;
|
|
6048
|
+
const label = rootLabel ?? t("Files", { note: "object list" });
|
|
6049
|
+
const selectableKeys = useSelectableKeys(list.entries, selection ?? null);
|
|
6050
|
+
const selectedKeys = selection?.selectedKeys ?? NO_KEYS;
|
|
6051
|
+
const selecting = selection?.isSelecting === true;
|
|
6052
|
+
const [store] = useState(
|
|
6053
|
+
() => createObjectListEntryStore({
|
|
6054
|
+
selected: selectedKeys,
|
|
6055
|
+
selecting,
|
|
6056
|
+
renaming: null,
|
|
6057
|
+
menu: null,
|
|
6058
|
+
tabStop: list.entries[0]?.key ?? null
|
|
6059
|
+
})
|
|
6060
|
+
);
|
|
6061
|
+
useLayoutEffect(() => {
|
|
6062
|
+
const { tabStop, menu } = store.get();
|
|
6063
|
+
const present2 = (key) => key != null && list.entries.some((entry) => entry.key === key);
|
|
6064
|
+
store.set({
|
|
6065
|
+
selected: selectedKeys,
|
|
6066
|
+
selecting,
|
|
6067
|
+
renaming: renamingKey,
|
|
6068
|
+
menu: present2(menu) ? menu : null,
|
|
6069
|
+
// The entry that had the tab stop left: the first one takes it.
|
|
6070
|
+
tabStop: present2(tabStop) ? tabStop : list.entries[0]?.key ?? null
|
|
6071
|
+
});
|
|
6072
|
+
}, [list.entries, renamingKey, selectedKeys, selecting, store]);
|
|
6073
|
+
const latest = useRef({
|
|
5087
6074
|
list,
|
|
5088
|
-
selection
|
|
5089
|
-
upload
|
|
5090
|
-
download: download ?? null,
|
|
5091
|
-
share: share ?? null,
|
|
5092
|
-
delete: del ?? null,
|
|
5093
|
-
toasts,
|
|
5094
|
-
announce,
|
|
5095
|
-
view,
|
|
5096
|
-
setView(next) {
|
|
5097
|
-
if (viewProp === void 0) setLocalView(next);
|
|
5098
|
-
onViewChange?.(next);
|
|
5099
|
-
},
|
|
5100
|
-
label: rootLabel ?? t("Files", { note: "object list" }),
|
|
5101
|
-
sizing: frameHeight != null ? "fixed" : frameMaxHeight != null ? "max" : null,
|
|
5102
|
-
showBreadcrumb: breadcrumb,
|
|
5103
|
-
selectionActions,
|
|
5104
|
-
empty,
|
|
5105
|
-
loadMore,
|
|
6075
|
+
selection,
|
|
6076
|
+
upload,
|
|
5106
6077
|
onOpenItem,
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
6078
|
+
viewProp,
|
|
6079
|
+
onViewChange
|
|
6080
|
+
});
|
|
6081
|
+
useLayoutEffect(() => {
|
|
6082
|
+
latest.current = {
|
|
6083
|
+
list,
|
|
6084
|
+
selection,
|
|
6085
|
+
upload,
|
|
6086
|
+
onOpenItem,
|
|
6087
|
+
viewProp,
|
|
6088
|
+
onViewChange
|
|
6089
|
+
};
|
|
6090
|
+
});
|
|
6091
|
+
useLayoutEffect(() => {
|
|
6092
|
+
if (!commands) return;
|
|
6093
|
+
bindObjectListCommands(commands, {
|
|
6094
|
+
startNewFolder() {
|
|
6095
|
+
if (latest.current.list.createFolder) setNewFolderOpen(true);
|
|
6096
|
+
},
|
|
6097
|
+
openMenu(entryKey) {
|
|
6098
|
+
const entries = latest.current.list.entries;
|
|
6099
|
+
if (!entries.some((entry) => entry.key === entryKey)) return;
|
|
6100
|
+
store.set({ menu: entryKey });
|
|
6101
|
+
}
|
|
6102
|
+
});
|
|
6103
|
+
return () => bindObjectListCommands(commands, null);
|
|
6104
|
+
}, [commands, store]);
|
|
6105
|
+
const setView = useCallback((next) => {
|
|
6106
|
+
if (latest.current.viewProp === void 0) setLocalView(next);
|
|
6107
|
+
latest.current.onViewChange?.(next);
|
|
6108
|
+
}, []);
|
|
6109
|
+
const startRename = useCallback(
|
|
6110
|
+
(key) => {
|
|
6111
|
+
const current = latest.current.list;
|
|
6112
|
+
const target = current.entries.find((entry) => entry.key === key);
|
|
6113
|
+
if (!target || !canRenameEntry(target, current)) return;
|
|
6114
|
+
setRenamingKey(key);
|
|
6115
|
+
store.set({ renaming: key });
|
|
6116
|
+
},
|
|
6117
|
+
[store]
|
|
6118
|
+
);
|
|
6119
|
+
const endRename = useCallback(
|
|
6120
|
+
(key, focus = false) => {
|
|
6121
|
+
if (focus) renameFocusKey.current = key;
|
|
6122
|
+
setRenamingKey((current) => current === key ? null : current);
|
|
6123
|
+
if (store.get().renaming === key) store.set({ renaming: null });
|
|
6124
|
+
},
|
|
6125
|
+
[store]
|
|
6126
|
+
);
|
|
6127
|
+
const revealEntry = useCallback((entry) => {
|
|
6128
|
+
const { location } = entry;
|
|
6129
|
+
if (!location) return;
|
|
6130
|
+
const current = latest.current.list;
|
|
6131
|
+
revealRef.current = entry.key;
|
|
6132
|
+
current.setSearch("");
|
|
6133
|
+
current.navigate(location);
|
|
6134
|
+
}, []);
|
|
6135
|
+
const open = useCallback((entry) => {
|
|
6136
|
+
const current = latest.current;
|
|
6137
|
+
if (entry.kind === "folder") current.list.openFolder(entry.folder);
|
|
6138
|
+
else current.onOpenItem?.(entry.item);
|
|
6139
|
+
}, []);
|
|
6140
|
+
const toggle = useCallback(
|
|
6141
|
+
(key, options) => {
|
|
6142
|
+
latest.current.selection?.toggle(key, options);
|
|
6143
|
+
},
|
|
6144
|
+
[]
|
|
6145
|
+
);
|
|
6146
|
+
const folderDropTarget = useCallback((id) => {
|
|
6147
|
+
const handler = (name) => (event) => {
|
|
6148
|
+
const current = latest.current;
|
|
6149
|
+
current.upload?.getDropTargetProps(
|
|
6150
|
+
{},
|
|
6151
|
+
() => folderUploadCall(current.list, id) ?? {}
|
|
6152
|
+
)[name]?.(event);
|
|
6153
|
+
};
|
|
6154
|
+
return {
|
|
6155
|
+
onDragEnter: handler("onDragEnter"),
|
|
6156
|
+
onDragOver: handler("onDragOver"),
|
|
6157
|
+
onDragLeave: handler("onDragLeave"),
|
|
6158
|
+
onDrop: handler("onDrop")
|
|
6159
|
+
};
|
|
6160
|
+
}, []);
|
|
6161
|
+
const context = useMemo(
|
|
6162
|
+
() => ({
|
|
6163
|
+
list,
|
|
6164
|
+
selection: selection ?? null,
|
|
6165
|
+
upload: upload ?? null,
|
|
6166
|
+
download: download ?? null,
|
|
6167
|
+
share: share ?? null,
|
|
6168
|
+
delete: del ?? null,
|
|
6169
|
+
toasts,
|
|
6170
|
+
announce,
|
|
6171
|
+
view,
|
|
6172
|
+
setView,
|
|
6173
|
+
label,
|
|
6174
|
+
sizing,
|
|
6175
|
+
showBreadcrumb: breadcrumb,
|
|
6176
|
+
selectionActions,
|
|
6177
|
+
empty,
|
|
6178
|
+
pagination,
|
|
6179
|
+
onOpenItem,
|
|
6180
|
+
resolveFolderKeys,
|
|
6181
|
+
renamingKey,
|
|
6182
|
+
newFolderOpen,
|
|
6183
|
+
setNewFolderOpen,
|
|
6184
|
+
startRename,
|
|
6185
|
+
endRename,
|
|
6186
|
+
revealEntry,
|
|
6187
|
+
renderEntry,
|
|
6188
|
+
renderActions,
|
|
6189
|
+
renderDescription,
|
|
6190
|
+
renderMeta
|
|
6191
|
+
}),
|
|
6192
|
+
[
|
|
6193
|
+
announce,
|
|
6194
|
+
breadcrumb,
|
|
6195
|
+
del,
|
|
6196
|
+
download,
|
|
6197
|
+
empty,
|
|
6198
|
+
endRename,
|
|
6199
|
+
label,
|
|
6200
|
+
list,
|
|
6201
|
+
onOpenItem,
|
|
6202
|
+
newFolderOpen,
|
|
6203
|
+
pagination,
|
|
6204
|
+
renamingKey,
|
|
6205
|
+
renderActions,
|
|
6206
|
+
renderDescription,
|
|
6207
|
+
renderEntry,
|
|
6208
|
+
renderMeta,
|
|
6209
|
+
resolveFolderKeys,
|
|
6210
|
+
revealEntry,
|
|
6211
|
+
selection,
|
|
6212
|
+
selectionActions,
|
|
6213
|
+
setView,
|
|
6214
|
+
share,
|
|
6215
|
+
sizing,
|
|
6216
|
+
startRename,
|
|
6217
|
+
toasts,
|
|
6218
|
+
upload,
|
|
6219
|
+
view
|
|
6220
|
+
]
|
|
6221
|
+
);
|
|
6222
|
+
useEffect(() => {
|
|
6223
|
+
const revealKey = revealRef.current;
|
|
6224
|
+
if (revealKey == null) return;
|
|
6225
|
+
if (list.isSearching || list.isLoading || list.isRefreshing) return;
|
|
6226
|
+
revealRef.current = null;
|
|
6227
|
+
const trigger = deleteFocus.frameRef.current?.querySelector(
|
|
6228
|
+
`[data-slot="object-list-entry-trigger"][data-entry-key="${CSS.escape(revealKey)}"]`
|
|
6229
|
+
);
|
|
6230
|
+
if (!trigger) return;
|
|
6231
|
+
store.set({ tabStop: revealKey });
|
|
6232
|
+
trigger.focus({ preventScroll: true });
|
|
6233
|
+
trigger.scrollIntoView({ block: "nearest" });
|
|
6234
|
+
const row = trigger.closest("[data-slot=object-list-entry]");
|
|
6235
|
+
row?.setAttribute("data-revealed", "");
|
|
6236
|
+
window.setTimeout(() => row?.removeAttribute("data-revealed"), 2e3);
|
|
6237
|
+
}, [
|
|
6238
|
+
deleteFocus.frameRef,
|
|
6239
|
+
list.entries,
|
|
6240
|
+
list.isLoading,
|
|
6241
|
+
list.isRefreshing,
|
|
6242
|
+
list.isSearching,
|
|
6243
|
+
store
|
|
6244
|
+
]);
|
|
6245
|
+
const opensFiles = onOpenItem != null;
|
|
6246
|
+
const folderUploads = upload != null && list.uploadOptions != null;
|
|
6247
|
+
const canDownload = download != null;
|
|
6248
|
+
const canShare = share != null || download?.mode === "navigate";
|
|
6249
|
+
const canDelete = del != null;
|
|
6250
|
+
const renameFile = list.renameFile != null;
|
|
6251
|
+
const renameFolder = list.renameFolder != null;
|
|
6252
|
+
const currentSearch = list.isSearching ? list.search.trim() : "";
|
|
6253
|
+
const [search, setShownSearch] = useState(currentSearch);
|
|
6254
|
+
if (!list.isLoading && !list.isRefreshing && search !== currentSearch) {
|
|
6255
|
+
setShownSearch(currentSearch);
|
|
6256
|
+
}
|
|
6257
|
+
const scope = useMemo(
|
|
6258
|
+
() => ({
|
|
6259
|
+
store,
|
|
6260
|
+
selectable: selectableKeys,
|
|
6261
|
+
opensFiles,
|
|
6262
|
+
folderUploads,
|
|
6263
|
+
download: canDownload,
|
|
6264
|
+
share: canShare,
|
|
6265
|
+
delete: canDelete,
|
|
6266
|
+
renameFile,
|
|
6267
|
+
renameFolder,
|
|
6268
|
+
search,
|
|
6269
|
+
open,
|
|
6270
|
+
toggle,
|
|
6271
|
+
folderDropTarget,
|
|
6272
|
+
startRename,
|
|
6273
|
+
endRename,
|
|
6274
|
+
revealEntry,
|
|
6275
|
+
renderActions,
|
|
6276
|
+
renderDescription,
|
|
6277
|
+
renderMeta
|
|
6278
|
+
}),
|
|
6279
|
+
[
|
|
6280
|
+
canDelete,
|
|
6281
|
+
canDownload,
|
|
6282
|
+
canShare,
|
|
6283
|
+
endRename,
|
|
6284
|
+
folderDropTarget,
|
|
6285
|
+
folderUploads,
|
|
6286
|
+
open,
|
|
6287
|
+
opensFiles,
|
|
6288
|
+
renameFile,
|
|
6289
|
+
renameFolder,
|
|
6290
|
+
renderActions,
|
|
6291
|
+
renderDescription,
|
|
6292
|
+
renderMeta,
|
|
6293
|
+
revealEntry,
|
|
6294
|
+
search,
|
|
6295
|
+
selectableKeys,
|
|
6296
|
+
startRename,
|
|
6297
|
+
store,
|
|
6298
|
+
toggle
|
|
6299
|
+
]
|
|
6300
|
+
);
|
|
5113
6301
|
function handleDeleted(result) {
|
|
5114
6302
|
if (result.deleted.length > 0) {
|
|
5115
6303
|
const gone = new Set(result.deleted);
|
|
@@ -5165,18 +6353,36 @@ function ObjectList({
|
|
|
5165
6353
|
}
|
|
5166
6354
|
if (download) content = /* @__PURE__ */ jsx(Download, { download, children: content });
|
|
5167
6355
|
if (upload) content = /* @__PURE__ */ jsx(Upload, { upload, children: content });
|
|
5168
|
-
return /* @__PURE__ */ jsxs(ObjectListProvider, { value: context, children: [
|
|
6356
|
+
return /* @__PURE__ */ jsxs(ObjectListProvider, { value: context, scope, children: [
|
|
5169
6357
|
content,
|
|
5170
6358
|
toasts ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5171
6359
|
upload ? /* @__PURE__ */ jsx(BuiltInUploadToasts, { upload }) : null,
|
|
5172
6360
|
download ? /* @__PURE__ */ jsx(BuiltInDownloadToasts, { download }) : null,
|
|
5173
6361
|
del ? /* @__PURE__ */ jsx(ObjectListDeleteToasts, { delete: del }) : null
|
|
5174
|
-
] }) : /* @__PURE__ */
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
6362
|
+
] }) : del ? /* @__PURE__ */ jsx(ObjectListDeleteToasts, { delete: del, report: announce }) : null,
|
|
6363
|
+
/* @__PURE__ */ jsx(
|
|
6364
|
+
ObjectListAnnouncer,
|
|
6365
|
+
{
|
|
6366
|
+
announcement,
|
|
6367
|
+
status: selectionCount,
|
|
6368
|
+
search: searchStatus?.settled ? searchStatus.label : null
|
|
6369
|
+
}
|
|
6370
|
+
)
|
|
5178
6371
|
] });
|
|
5179
6372
|
}
|
|
6373
|
+
var NO_KEYS = /* @__PURE__ */ new Set();
|
|
6374
|
+
function useSelectableKeys(entries, selection) {
|
|
6375
|
+
const keys = selection ? entries.flatMap(
|
|
6376
|
+
(entry) => selection.canSelect(entry) ? [entry.key] : []
|
|
6377
|
+
) : [];
|
|
6378
|
+
const [kept, setKept] = useState(() => new Set(keys));
|
|
6379
|
+
if (kept.size === keys.length && keys.every((key) => kept.has(key))) {
|
|
6380
|
+
return kept;
|
|
6381
|
+
}
|
|
6382
|
+
const next = new Set(keys);
|
|
6383
|
+
setKept(next);
|
|
6384
|
+
return next;
|
|
6385
|
+
}
|
|
5180
6386
|
function useFocusAfterDelete() {
|
|
5181
6387
|
const frameRef = useRef(null);
|
|
5182
6388
|
const lastFocusRef = useRef(null);
|
|
@@ -5218,8 +6424,15 @@ function ObjectListFrame({
|
|
|
5218
6424
|
style,
|
|
5219
6425
|
children
|
|
5220
6426
|
}) {
|
|
5221
|
-
const { list, selection, upload, view, label, sizing } = useObjectListContext();
|
|
5222
|
-
const
|
|
6427
|
+
const { list, selection, upload, view, label, sizing, startRename } = useObjectListContext();
|
|
6428
|
+
const { store } = useObjectListEntryScope();
|
|
6429
|
+
const keyboard = useObjectListKeyboard({
|
|
6430
|
+
list,
|
|
6431
|
+
selection,
|
|
6432
|
+
view,
|
|
6433
|
+
store,
|
|
6434
|
+
startRename
|
|
6435
|
+
});
|
|
5223
6436
|
const busy = list.isLoading || list.isRefreshing || list.isLoadingMore;
|
|
5224
6437
|
const call = folderUploadCall(list, list.parent);
|
|
5225
6438
|
const takesFiles = upload != null && !upload.disabled;
|
|
@@ -5264,7 +6477,10 @@ function ObjectListFrame({
|
|
|
5264
6477
|
className
|
|
5265
6478
|
),
|
|
5266
6479
|
style,
|
|
5267
|
-
onFocus
|
|
6480
|
+
onFocus: (event) => {
|
|
6481
|
+
onFocus(event);
|
|
6482
|
+
keyboard.onFocus(event);
|
|
6483
|
+
},
|
|
5268
6484
|
onPaste,
|
|
5269
6485
|
onDragEnter: (event) => {
|
|
5270
6486
|
if (!takesFiles) return;
|
|
@@ -5320,157 +6536,6 @@ function cssLength(value) {
|
|
|
5320
6536
|
const trimmed = value.trim();
|
|
5321
6537
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
5322
6538
|
}
|
|
5323
|
-
function ObjectListSearch({
|
|
5324
|
-
placeholder,
|
|
5325
|
-
delay = 250,
|
|
5326
|
-
collapsible = true,
|
|
5327
|
-
className
|
|
5328
|
-
}) {
|
|
5329
|
-
const t = useTranslations();
|
|
5330
|
-
const { list } = useObjectListContext();
|
|
5331
|
-
const header = useOptionalObjectListHeader();
|
|
5332
|
-
const { setSearch } = list;
|
|
5333
|
-
const [draft, setDraft] = useState(null);
|
|
5334
|
-
const value = draft ?? list.search;
|
|
5335
|
-
const label = placeholder ?? t("Search files", { note: "object list" });
|
|
5336
|
-
const collapses = collapsible && header != null;
|
|
5337
|
-
const [open, setOpen] = useState(false);
|
|
5338
|
-
const expanded = !collapses || open || value !== "";
|
|
5339
|
-
const inputRef = useRef(null);
|
|
5340
|
-
const buttonRef = useRef(null);
|
|
5341
|
-
const focusRef = useRef(null);
|
|
5342
|
-
useEffect(() => {
|
|
5343
|
-
if (draft == null) return;
|
|
5344
|
-
const timer = window.setTimeout(() => {
|
|
5345
|
-
setSearch(draft);
|
|
5346
|
-
setDraft(null);
|
|
5347
|
-
}, delay);
|
|
5348
|
-
return () => window.clearTimeout(timer);
|
|
5349
|
-
}, [delay, draft, setSearch]);
|
|
5350
|
-
const setSearchExpanded = header?.setSearchExpanded;
|
|
5351
|
-
useLayoutEffect(() => {
|
|
5352
|
-
if (!collapses || !setSearchExpanded) return;
|
|
5353
|
-
setSearchExpanded(expanded);
|
|
5354
|
-
return () => setSearchExpanded(false);
|
|
5355
|
-
}, [collapses, expanded, setSearchExpanded]);
|
|
5356
|
-
useEffect(() => {
|
|
5357
|
-
const target = focusRef.current;
|
|
5358
|
-
if (!target) return;
|
|
5359
|
-
focusRef.current = null;
|
|
5360
|
-
(target === "input" ? inputRef : buttonRef).current?.focus();
|
|
5361
|
-
});
|
|
5362
|
-
function commit(next) {
|
|
5363
|
-
setDraft(null);
|
|
5364
|
-
setSearch(next);
|
|
5365
|
-
}
|
|
5366
|
-
function close() {
|
|
5367
|
-
commit("");
|
|
5368
|
-
setOpen(false);
|
|
5369
|
-
focusRef.current = "button";
|
|
5370
|
-
}
|
|
5371
|
-
if (!expanded) {
|
|
5372
|
-
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5373
|
-
/* @__PURE__ */ jsx(
|
|
5374
|
-
TooltipTrigger,
|
|
5375
|
-
{
|
|
5376
|
-
render: /* @__PURE__ */ jsx(
|
|
5377
|
-
Button,
|
|
5378
|
-
{
|
|
5379
|
-
ref: buttonRef,
|
|
5380
|
-
type: "button",
|
|
5381
|
-
variant: "ghost",
|
|
5382
|
-
size: "icon-sm",
|
|
5383
|
-
"data-slot": "object-list-search",
|
|
5384
|
-
"aria-label": label,
|
|
5385
|
-
className,
|
|
5386
|
-
onClick: () => {
|
|
5387
|
-
focusRef.current = "input";
|
|
5388
|
-
setOpen(true);
|
|
5389
|
-
}
|
|
5390
|
-
}
|
|
5391
|
-
),
|
|
5392
|
-
children: /* @__PURE__ */ jsx(SearchIcon, {})
|
|
5393
|
-
}
|
|
5394
|
-
),
|
|
5395
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: label })
|
|
5396
|
-
] });
|
|
5397
|
-
}
|
|
5398
|
-
return /* @__PURE__ */ jsxs(
|
|
5399
|
-
"div",
|
|
5400
|
-
{
|
|
5401
|
-
"data-slot": "object-list-search",
|
|
5402
|
-
"data-expanded": "",
|
|
5403
|
-
className: cn(
|
|
5404
|
-
"relative flex min-w-0 items-center",
|
|
5405
|
-
collapses ? "w-full flex-1" : "w-40 sm:w-52",
|
|
5406
|
-
className
|
|
5407
|
-
),
|
|
5408
|
-
onBlur: (event) => {
|
|
5409
|
-
if (!collapses || value !== "") return;
|
|
5410
|
-
const next = event.relatedTarget;
|
|
5411
|
-
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
5412
|
-
setOpen(false);
|
|
5413
|
-
},
|
|
5414
|
-
children: [
|
|
5415
|
-
/* @__PURE__ */ jsx(
|
|
5416
|
-
SearchIcon,
|
|
5417
|
-
{
|
|
5418
|
-
"aria-hidden": true,
|
|
5419
|
-
className: "pointer-events-none absolute start-2.5 size-3.5 text-dimah-s3-muted-foreground"
|
|
5420
|
-
}
|
|
5421
|
-
),
|
|
5422
|
-
/* @__PURE__ */ jsx(
|
|
5423
|
-
"input",
|
|
5424
|
-
{
|
|
5425
|
-
ref: inputRef,
|
|
5426
|
-
type: "search",
|
|
5427
|
-
value,
|
|
5428
|
-
placeholder: label,
|
|
5429
|
-
"aria-label": label,
|
|
5430
|
-
autoComplete: "off",
|
|
5431
|
-
className: cn(
|
|
5432
|
-
"w-full min-w-0 rounded-md border border-dimah-s3-border bg-transparent ps-8 text-sm text-dimah-s3-foreground outline-none placeholder:text-dimah-s3-muted-foreground focus-visible:border-dimah-s3-ring focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50 [&::-webkit-search-cancel-button]:appearance-none",
|
|
5433
|
-
collapses ? "h-8 pe-9" : "h-7 pe-7"
|
|
5434
|
-
),
|
|
5435
|
-
onChange: (event) => setDraft(event.target.value),
|
|
5436
|
-
onKeyDown: (event) => {
|
|
5437
|
-
if (event.key === "Enter") commit(value);
|
|
5438
|
-
if (event.key !== "Escape") return;
|
|
5439
|
-
if (value) {
|
|
5440
|
-
event.preventDefault();
|
|
5441
|
-
commit("");
|
|
5442
|
-
} else if (collapses) {
|
|
5443
|
-
event.preventDefault();
|
|
5444
|
-
close();
|
|
5445
|
-
}
|
|
5446
|
-
}
|
|
5447
|
-
}
|
|
5448
|
-
),
|
|
5449
|
-
collapses ? /* @__PURE__ */ jsx(
|
|
5450
|
-
Button,
|
|
5451
|
-
{
|
|
5452
|
-
type: "button",
|
|
5453
|
-
variant: "ghost",
|
|
5454
|
-
size: "icon-xs",
|
|
5455
|
-
"aria-label": t("Close search", { note: "object list" }),
|
|
5456
|
-
className: "absolute end-1.5",
|
|
5457
|
-
onClick: close,
|
|
5458
|
-
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
5459
|
-
}
|
|
5460
|
-
) : value ? /* @__PURE__ */ jsx(
|
|
5461
|
-
"button",
|
|
5462
|
-
{
|
|
5463
|
-
type: "button",
|
|
5464
|
-
"aria-label": t("Clear search", { note: "object list" }),
|
|
5465
|
-
className: "absolute end-1 flex size-5 items-center justify-center rounded-sm text-dimah-s3-muted-foreground outline-none hover:text-dimah-s3-foreground focus-visible:ring-2 focus-visible:ring-dimah-s3-ring/50",
|
|
5466
|
-
onClick: () => commit(""),
|
|
5467
|
-
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3.5" })
|
|
5468
|
-
}
|
|
5469
|
-
) : null
|
|
5470
|
-
]
|
|
5471
|
-
}
|
|
5472
|
-
);
|
|
5473
|
-
}
|
|
5474
6539
|
function ObjectListSortMenu({
|
|
5475
6540
|
options,
|
|
5476
6541
|
className
|
|
@@ -5589,6 +6654,6 @@ function ObjectListViewToggle({ className }) {
|
|
|
5589
6654
|
);
|
|
5590
6655
|
}
|
|
5591
6656
|
|
|
5592
|
-
export { AttachmentAction, AttachmentGroup, AttachmentTrigger, AvatarUpload, CircleProgress, Delete, DeleteConfirmDialog, DeleteToasts, DeleteTrigger, DismissAttachmentAction, Download, DownloadProgress, DownloadToasts, DownloadTrigger, FileAttachment, FileName, FileTypeGlyph, FolderGlyph,
|
|
6657
|
+
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, ObjectListLocation, ObjectListNewFolder, ObjectListRow, ObjectListSearch, ObjectListSearchBar, ObjectListSelectAll, ObjectListSelectionBar, ObjectListSortMenu, ObjectListTile, ObjectListUploadStatus, ObjectListUsage, ObjectListViewToggle, StatusAttachment, Toaster, Upload, UploadDropzone, UploadDropzoneTrigger, UploadField, UploadFieldValue, UploadFileItem, UploadFileList, UploadStatus, UploadToasts, UploadTrigger, toast, useDeleteContext, useDownloadContext, useObjectListCommands, useObjectListContext, useObjectListEntry, usePasteFiles, useToastOwner, useUploadContext, useUploadFieldContext, useUploadHints };
|
|
5593
6658
|
//# sourceMappingURL=index.js.map
|
|
5594
6659
|
//# sourceMappingURL=index.js.map
|