@dimah-s3/ui 2.0.0-beta.0 → 2.0.0-beta.10
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-content.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-context.d.ts +118 -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 +5 -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 +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1744 -748
- 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,28 +3498,25 @@ function ObjectListItemMenu({
|
|
|
3389
3498
|
className
|
|
3390
3499
|
}) {
|
|
3391
3500
|
const t = useTranslations();
|
|
3392
|
-
const
|
|
3501
|
+
const scope = useOptionalObjectListEntryScope();
|
|
3393
3502
|
const entry = useObjectListEntry();
|
|
3394
3503
|
const triggerRef = useRef(null);
|
|
3395
3504
|
const file = entry?.kind === "file" ? entry : null;
|
|
3396
3505
|
const folder = entry?.kind === "folder" ? entry : null;
|
|
3397
3506
|
const objectKey = objectKeyProp ?? (file ? objectKeyOf(file) : "");
|
|
3398
|
-
const fileName = fileNameProp ?? file?.file.name;
|
|
3399
|
-
const fileSize = fileSizeProp ?? file?.file.size;
|
|
3400
3507
|
const isFile = objectKey !== "";
|
|
3401
|
-
const
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3508
|
+
const rows = {
|
|
3509
|
+
reveal: entry?.location != null && Boolean(scope?.search),
|
|
3510
|
+
// A folder takes uploads only when the source can place files in it.
|
|
3511
|
+
upload: folder != null && scope?.folderUploads === true,
|
|
3512
|
+
download: isFile && scope?.download === true,
|
|
3513
|
+
link: isFile && (shareProp != null || scope?.share === true),
|
|
3514
|
+
rename: entry != null && (entry.kind === "file" ? scope?.renameFile : scope?.renameFolder) === true,
|
|
3515
|
+
extra: (actions?.length ?? 0) > 0 || children != null,
|
|
3516
|
+
delete: isFile && scope?.delete === true
|
|
3517
|
+
};
|
|
3410
3518
|
if (!isFile && !folder) return null;
|
|
3411
|
-
if (!
|
|
3412
|
-
return null;
|
|
3413
|
-
}
|
|
3519
|
+
if (!Object.values(rows).some(Boolean)) return null;
|
|
3414
3520
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
3415
3521
|
/* @__PURE__ */ jsxs(
|
|
3416
3522
|
DropdownMenuTrigger,
|
|
@@ -3422,6 +3528,7 @@ function ObjectListItemMenu({
|
|
|
3422
3528
|
variant: "ghost",
|
|
3423
3529
|
size: "icon-sm",
|
|
3424
3530
|
"data-slot": "object-list-item-menu",
|
|
3531
|
+
tabIndex: entry ? -1 : void 0,
|
|
3425
3532
|
className
|
|
3426
3533
|
}
|
|
3427
3534
|
),
|
|
@@ -3431,8 +3538,60 @@ function ObjectListItemMenu({
|
|
|
3431
3538
|
]
|
|
3432
3539
|
}
|
|
3433
3540
|
),
|
|
3434
|
-
/* @__PURE__ */
|
|
3435
|
-
|
|
3541
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", className: "min-w-44", children: /* @__PURE__ */ jsx(
|
|
3542
|
+
ItemMenuItems,
|
|
3543
|
+
{
|
|
3544
|
+
rows,
|
|
3545
|
+
folderId: folder?.id ?? null,
|
|
3546
|
+
entryKey: entry?.key ?? null,
|
|
3547
|
+
objectKey,
|
|
3548
|
+
fileName: fileNameProp ?? file?.file.name,
|
|
3549
|
+
fileSize: fileSizeProp ?? file?.file.size,
|
|
3550
|
+
share: shareProp,
|
|
3551
|
+
expiresIn,
|
|
3552
|
+
actions,
|
|
3553
|
+
triggerRef,
|
|
3554
|
+
children
|
|
3555
|
+
}
|
|
3556
|
+
) })
|
|
3557
|
+
] });
|
|
3558
|
+
}
|
|
3559
|
+
function ItemMenuItems({
|
|
3560
|
+
rows,
|
|
3561
|
+
folderId,
|
|
3562
|
+
entryKey,
|
|
3563
|
+
objectKey,
|
|
3564
|
+
fileName,
|
|
3565
|
+
fileSize,
|
|
3566
|
+
share: shareProp,
|
|
3567
|
+
expiresIn,
|
|
3568
|
+
actions,
|
|
3569
|
+
triggerRef,
|
|
3570
|
+
children
|
|
3571
|
+
}) {
|
|
3572
|
+
const t = useTranslations();
|
|
3573
|
+
const context = useOptionalObjectListContext();
|
|
3574
|
+
const download = rows.download ? context?.download ?? null : null;
|
|
3575
|
+
const linkSource = rows.link ? shareProp ?? context?.share ?? (context?.download?.mode === "navigate" ? context.download : null) : null;
|
|
3576
|
+
const remove = rows.delete ? context?.delete ?? null : null;
|
|
3577
|
+
const listUpload = context?.upload ?? null;
|
|
3578
|
+
const folderCall = rows.upload && context && folderId != null ? folderUploadCall(context.list, folderId) : void 0;
|
|
3579
|
+
const uploadToFolder = listUpload && folderCall ? () => listUpload.open(folderCall) : null;
|
|
3580
|
+
const extra = actions ?? [];
|
|
3581
|
+
const showTransfer = download != null || linkSource != null;
|
|
3582
|
+
const showExtra = rows.extra;
|
|
3583
|
+
const canRename = rows.rename && context != null && entryKey != null;
|
|
3584
|
+
const entry = useObjectListEntry();
|
|
3585
|
+
const reveal = rows.reveal && context != null && entry != null ? () => context.revealEntry(entry) : null;
|
|
3586
|
+
const showMain = uploadToFolder != null || showTransfer || canRename;
|
|
3587
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3588
|
+
reveal ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: reveal, children: [
|
|
3589
|
+
/* @__PURE__ */ jsx(FolderOpenIcon, {}),
|
|
3590
|
+
t("Show in folder", { note: "object list menu" })
|
|
3591
|
+
] }) }) : null,
|
|
3592
|
+
reveal && (showMain || showExtra || rows.delete) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3593
|
+
uploadToFolder || showTransfer || canRename ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
3594
|
+
uploadToFolder ? /* @__PURE__ */ jsxs(
|
|
3436
3595
|
DropdownMenuItem,
|
|
3437
3596
|
{
|
|
3438
3597
|
disabled: listUpload?.disabled,
|
|
@@ -3442,57 +3601,65 @@ function ObjectListItemMenu({
|
|
|
3442
3601
|
t("Upload to this folder", { note: "object list menu" })
|
|
3443
3602
|
]
|
|
3444
3603
|
}
|
|
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,
|
|
3604
|
+
) : null,
|
|
3605
|
+
download ? /* @__PURE__ */ jsx(
|
|
3606
|
+
DownloadItem,
|
|
3488
3607
|
{
|
|
3608
|
+
download,
|
|
3489
3609
|
objectKey,
|
|
3490
3610
|
fileName,
|
|
3491
|
-
fileSize
|
|
3492
|
-
triggerRef
|
|
3611
|
+
fileSize
|
|
3493
3612
|
}
|
|
3494
|
-
)
|
|
3495
|
-
|
|
3613
|
+
) : null,
|
|
3614
|
+
linkSource ? /* @__PURE__ */ jsx(
|
|
3615
|
+
CopyLinkItem,
|
|
3616
|
+
{
|
|
3617
|
+
share: linkSource,
|
|
3618
|
+
objectKey,
|
|
3619
|
+
fileName,
|
|
3620
|
+
expiresIn
|
|
3621
|
+
}
|
|
3622
|
+
) : null,
|
|
3623
|
+
canRename ? /* @__PURE__ */ jsxs(
|
|
3624
|
+
DropdownMenuItem,
|
|
3625
|
+
{
|
|
3626
|
+
onClick: () => {
|
|
3627
|
+
if (entryKey != null) context?.startRename(entryKey);
|
|
3628
|
+
},
|
|
3629
|
+
children: [
|
|
3630
|
+
/* @__PURE__ */ jsx(PencilIcon, {}),
|
|
3631
|
+
t("Rename", { note: "object list menu" })
|
|
3632
|
+
]
|
|
3633
|
+
}
|
|
3634
|
+
) : null
|
|
3635
|
+
] }) : null,
|
|
3636
|
+
showExtra && (showTransfer || uploadToFolder || canRename) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3637
|
+
showExtra ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
3638
|
+
extra.map((action, index) => /* @__PURE__ */ jsxs(
|
|
3639
|
+
DropdownMenuItem,
|
|
3640
|
+
{
|
|
3641
|
+
variant: action.destructive ? "destructive" : "default",
|
|
3642
|
+
disabled: action.disabled,
|
|
3643
|
+
onClick: action.onClick,
|
|
3644
|
+
children: [
|
|
3645
|
+
action.icon,
|
|
3646
|
+
action.label
|
|
3647
|
+
]
|
|
3648
|
+
},
|
|
3649
|
+
`${action.label}-${index}`
|
|
3650
|
+
)),
|
|
3651
|
+
children
|
|
3652
|
+
] }) : null,
|
|
3653
|
+
remove && (showTransfer || uploadToFolder || canRename || showExtra) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3654
|
+
remove ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(
|
|
3655
|
+
DeleteItem,
|
|
3656
|
+
{
|
|
3657
|
+
objectKey,
|
|
3658
|
+
fileName,
|
|
3659
|
+
fileSize,
|
|
3660
|
+
triggerRef
|
|
3661
|
+
}
|
|
3662
|
+
) }) : null
|
|
3496
3663
|
] });
|
|
3497
3664
|
}
|
|
3498
3665
|
function DownloadItem({
|
|
@@ -3528,7 +3695,7 @@ function CopyLinkItem({
|
|
|
3528
3695
|
expiresIn
|
|
3529
3696
|
}) {
|
|
3530
3697
|
const t = useTranslations();
|
|
3531
|
-
const formatError =
|
|
3698
|
+
const formatError = useFormatError();
|
|
3532
3699
|
const expiryLabel = useShareExpiryLabel();
|
|
3533
3700
|
const report = useObjectListFeedback();
|
|
3534
3701
|
const [copying, setCopying] = useState(false);
|
|
@@ -3584,7 +3751,7 @@ function DeleteItem({
|
|
|
3584
3751
|
}) {
|
|
3585
3752
|
const t = useTranslations();
|
|
3586
3753
|
const { delete: del, request } = useDeleteContext();
|
|
3587
|
-
const deleting = del.
|
|
3754
|
+
const deleting = del.pendingKeys.includes(objectKey);
|
|
3588
3755
|
return /* @__PURE__ */ jsxs(
|
|
3589
3756
|
DropdownMenuItem,
|
|
3590
3757
|
{
|
|
@@ -3601,30 +3768,585 @@ function DeleteItem({
|
|
|
3601
3768
|
}
|
|
3602
3769
|
);
|
|
3603
3770
|
}
|
|
3604
|
-
function
|
|
3605
|
-
checked,
|
|
3606
|
-
indeterminate,
|
|
3607
|
-
label,
|
|
3608
|
-
onCheckedChange,
|
|
3609
|
-
className
|
|
3610
|
-
}) {
|
|
3611
|
-
const shiftRef = useRef(false);
|
|
3771
|
+
function Spinner({ className, ...props }) {
|
|
3612
3772
|
return /* @__PURE__ */ jsx(
|
|
3613
|
-
|
|
3773
|
+
Loader2Icon,
|
|
3614
3774
|
{
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
"aria-label":
|
|
3618
|
-
className: cn("
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3775
|
+
"data-slot": "spinner",
|
|
3776
|
+
role: "status",
|
|
3777
|
+
"aria-label": "Loading",
|
|
3778
|
+
className: cn("size-4 animate-spin", className),
|
|
3779
|
+
...props
|
|
3780
|
+
}
|
|
3781
|
+
);
|
|
3782
|
+
}
|
|
3783
|
+
function canRenameEntry(entry, list) {
|
|
3784
|
+
return entry.kind === "file" ? list.renameFile != null : list.renameFolder != null;
|
|
3785
|
+
}
|
|
3786
|
+
function ObjectListRenameField({
|
|
3787
|
+
entry
|
|
3788
|
+
}) {
|
|
3789
|
+
const t = useTranslations();
|
|
3790
|
+
const formatError = useFormatError();
|
|
3791
|
+
const { list, endRename } = useObjectListContext();
|
|
3792
|
+
const inputId = useId();
|
|
3793
|
+
const errorId = useId();
|
|
3794
|
+
const inputRef = useRef(null);
|
|
3795
|
+
const lock = useRef(false);
|
|
3796
|
+
const closed = useRef(false);
|
|
3797
|
+
const [name, setName] = useState(entry.name);
|
|
3798
|
+
const [pending, setPending] = useState(false);
|
|
3799
|
+
const [error, setError] = useState(null);
|
|
3800
|
+
const folder = entry.kind === "folder";
|
|
3801
|
+
const label = folder ? t("Folder name", { note: "object list new folder" }) : t("File name", { note: "object list rename" });
|
|
3802
|
+
useEffect(() => {
|
|
3803
|
+
const input = inputRef.current;
|
|
3804
|
+
if (!input) return;
|
|
3805
|
+
input.focus();
|
|
3806
|
+
const end = folder ? entry.name.length : splitFileName(entry.name).stem.length;
|
|
3807
|
+
input.setSelectionRange(0, end);
|
|
3808
|
+
}, [entry.name, folder]);
|
|
3809
|
+
function finish(focus) {
|
|
3810
|
+
if (closed.current) return;
|
|
3811
|
+
closed.current = true;
|
|
3812
|
+
endRename(entry.key, focus);
|
|
3813
|
+
}
|
|
3814
|
+
async function save(focus) {
|
|
3815
|
+
if (closed.current || lock.current) return;
|
|
3816
|
+
const trimmed = name.trim();
|
|
3817
|
+
if (!trimmed) {
|
|
3818
|
+
setError(
|
|
3819
|
+
folder ? t("Enter a folder name", { note: "object list new folder" }) : t("Enter a file name", { note: "object list rename" })
|
|
3820
|
+
);
|
|
3821
|
+
return;
|
|
3822
|
+
}
|
|
3823
|
+
if (trimmed === entry.name) {
|
|
3824
|
+
finish(focus);
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3827
|
+
lock.current = true;
|
|
3828
|
+
setPending(true);
|
|
3829
|
+
setError(null);
|
|
3830
|
+
try {
|
|
3831
|
+
if (entry.kind === "folder") {
|
|
3832
|
+
await list.renameFolder?.(entry.folder, trimmed);
|
|
3833
|
+
} else {
|
|
3834
|
+
await list.renameFile?.(entry.item, trimmed);
|
|
3835
|
+
}
|
|
3836
|
+
} catch (err) {
|
|
3837
|
+
lock.current = false;
|
|
3838
|
+
setPending(false);
|
|
3839
|
+
setError(formatError(err));
|
|
3840
|
+
if (focus) inputRef.current?.focus();
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
finish(focus);
|
|
3844
|
+
}
|
|
3845
|
+
function onBlur(event) {
|
|
3846
|
+
if (closed.current || lock.current) return;
|
|
3847
|
+
const next = event.relatedTarget;
|
|
3848
|
+
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
3849
|
+
const trimmed = name.trim();
|
|
3850
|
+
if (!trimmed || trimmed === entry.name) {
|
|
3851
|
+
finish(false);
|
|
3852
|
+
return;
|
|
3853
|
+
}
|
|
3854
|
+
void save(false);
|
|
3855
|
+
}
|
|
3856
|
+
const confirm = /* @__PURE__ */ jsx(
|
|
3857
|
+
Button,
|
|
3858
|
+
{
|
|
3859
|
+
type: "submit",
|
|
3860
|
+
variant: "ghost",
|
|
3861
|
+
size: "icon-sm",
|
|
3862
|
+
className: "shrink-0",
|
|
3863
|
+
"aria-label": t("Rename", { note: "object list menu" }),
|
|
3864
|
+
disabled: pending,
|
|
3865
|
+
focusableWhenDisabled: true,
|
|
3866
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3867
|
+
children: pending ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(CheckIcon, {})
|
|
3868
|
+
}
|
|
3869
|
+
);
|
|
3870
|
+
const cancel = /* @__PURE__ */ jsx(
|
|
3871
|
+
Button,
|
|
3872
|
+
{
|
|
3873
|
+
type: "button",
|
|
3874
|
+
variant: "ghost",
|
|
3875
|
+
size: "icon-sm",
|
|
3876
|
+
className: "shrink-0",
|
|
3877
|
+
"aria-label": t("Cancel", { note: "object list rename" }),
|
|
3878
|
+
disabled: pending,
|
|
3879
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3880
|
+
onClick: () => finish(true),
|
|
3881
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
3882
|
+
}
|
|
3883
|
+
);
|
|
3884
|
+
function onSubmit(event) {
|
|
3885
|
+
event.preventDefault();
|
|
3886
|
+
void save(true);
|
|
3887
|
+
}
|
|
3888
|
+
return /* @__PURE__ */ jsxs(
|
|
3889
|
+
"form",
|
|
3890
|
+
{
|
|
3891
|
+
"data-slot": "object-list-rename",
|
|
3892
|
+
"aria-busy": pending || void 0,
|
|
3893
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
3894
|
+
onSubmit,
|
|
3895
|
+
onBlur,
|
|
3896
|
+
children: [
|
|
3897
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3898
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "sr-only", children: label }),
|
|
3899
|
+
/* @__PURE__ */ jsx(
|
|
3900
|
+
"input",
|
|
3901
|
+
{
|
|
3902
|
+
ref: inputRef,
|
|
3903
|
+
id: inputId,
|
|
3904
|
+
value: name,
|
|
3905
|
+
dir: "auto",
|
|
3906
|
+
maxLength: 255,
|
|
3907
|
+
autoComplete: "off",
|
|
3908
|
+
readOnly: pending,
|
|
3909
|
+
"aria-invalid": error != null || void 0,
|
|
3910
|
+
"aria-describedby": error != null ? errorId : void 0,
|
|
3911
|
+
className: cn(
|
|
3912
|
+
"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"
|
|
3913
|
+
),
|
|
3914
|
+
onChange: (event) => {
|
|
3915
|
+
setName(event.target.value);
|
|
3916
|
+
setError(null);
|
|
3917
|
+
},
|
|
3918
|
+
onKeyDown: (event) => {
|
|
3919
|
+
if (event.key !== "Escape" || lock.current) return;
|
|
3920
|
+
event.preventDefault();
|
|
3921
|
+
finish(true);
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
),
|
|
3925
|
+
confirm,
|
|
3926
|
+
cancel
|
|
3927
|
+
] }),
|
|
3928
|
+
error != null ? /* @__PURE__ */ jsx(
|
|
3929
|
+
"p",
|
|
3930
|
+
{
|
|
3931
|
+
id: errorId,
|
|
3932
|
+
role: "alert",
|
|
3933
|
+
className: "text-xs [overflow-wrap:anywhere] text-dimah-s3-destructive",
|
|
3934
|
+
children: error
|
|
3935
|
+
}
|
|
3936
|
+
) : null
|
|
3937
|
+
]
|
|
3938
|
+
}
|
|
3939
|
+
);
|
|
3940
|
+
}
|
|
3941
|
+
var ENTRY_TRIGGER = "[data-slot=object-list-entry-trigger]";
|
|
3942
|
+
function canChooseSearchScope(list) {
|
|
3943
|
+
return list.parent != null && list.searchScopes.includes("folder") && list.searchScopes.includes("all");
|
|
3944
|
+
}
|
|
3945
|
+
function ObjectListSearch({
|
|
3946
|
+
placeholder,
|
|
3947
|
+
delay = 250,
|
|
3948
|
+
collapsible = true,
|
|
3949
|
+
className
|
|
3950
|
+
}) {
|
|
3951
|
+
const t = useTranslations();
|
|
3952
|
+
const { list } = useObjectListContext();
|
|
3953
|
+
const header = useOptionalObjectListHeader();
|
|
3954
|
+
const { setSearch } = list;
|
|
3955
|
+
const [draft, setDraft] = useState(null);
|
|
3956
|
+
const value = draft ?? list.search;
|
|
3957
|
+
const defaultLabel = useSearchPlaceholder(list);
|
|
3958
|
+
const label = placeholder ?? defaultLabel;
|
|
3959
|
+
const collapses = collapsible && header != null;
|
|
3960
|
+
const [open, setOpen] = useState(false);
|
|
3961
|
+
const expanded = !collapses || open || value !== "";
|
|
3962
|
+
const inputRef = useRef(null);
|
|
3963
|
+
const buttonRef = useRef(null);
|
|
3964
|
+
const rootRef = useRef(null);
|
|
3965
|
+
const focusRef = useRef(null);
|
|
3966
|
+
const loading = draft != null && draft.trim() !== list.search.trim() || list.isSearching && (list.isLoading || list.isRefreshing);
|
|
3967
|
+
useEffect(() => {
|
|
3968
|
+
if (draft == null) return;
|
|
3969
|
+
const timer = window.setTimeout(() => {
|
|
3970
|
+
setSearch(draft);
|
|
3971
|
+
setDraft(null);
|
|
3972
|
+
}, delay);
|
|
3973
|
+
return () => window.clearTimeout(timer);
|
|
3974
|
+
}, [delay, draft, setSearch]);
|
|
3975
|
+
const setSearchExpanded = header?.setSearchExpanded;
|
|
3976
|
+
useLayoutEffect(() => {
|
|
3977
|
+
if (!collapses || !setSearchExpanded) return;
|
|
3978
|
+
setSearchExpanded(expanded);
|
|
3979
|
+
return () => setSearchExpanded(false);
|
|
3980
|
+
}, [collapses, expanded, setSearchExpanded]);
|
|
3981
|
+
useEffect(() => {
|
|
3982
|
+
const target = focusRef.current;
|
|
3983
|
+
if (!target) return;
|
|
3984
|
+
focusRef.current = null;
|
|
3985
|
+
(target === "input" ? inputRef : buttonRef).current?.focus();
|
|
3986
|
+
});
|
|
3987
|
+
useEffect(() => {
|
|
3988
|
+
if (!collapses || !open || value !== "") return;
|
|
3989
|
+
if (rootRef.current?.contains(document.activeElement)) return;
|
|
3990
|
+
setOpen(false);
|
|
3991
|
+
}, [collapses, open, value]);
|
|
3992
|
+
function commit(next) {
|
|
3993
|
+
setDraft(null);
|
|
3994
|
+
setSearch(next);
|
|
3995
|
+
}
|
|
3996
|
+
function close() {
|
|
3997
|
+
commit("");
|
|
3998
|
+
setOpen(false);
|
|
3999
|
+
focusRef.current = "button";
|
|
4000
|
+
}
|
|
4001
|
+
function onKeyDown(event) {
|
|
4002
|
+
if (event.key === "Enter") commit(value);
|
|
4003
|
+
if (event.key === "ArrowDown") {
|
|
4004
|
+
event.preventDefault();
|
|
4005
|
+
if (loading) {
|
|
4006
|
+
if (draft != null) commit(draft);
|
|
4007
|
+
return;
|
|
4008
|
+
}
|
|
4009
|
+
const frame = event.currentTarget.closest("[data-slot=object-list]");
|
|
4010
|
+
const entry = frame?.querySelector(`${ENTRY_TRIGGER}[tabindex="0"]`) ?? frame?.querySelector(ENTRY_TRIGGER);
|
|
4011
|
+
entry?.focus();
|
|
4012
|
+
return;
|
|
4013
|
+
}
|
|
4014
|
+
if (event.key !== "Escape") return;
|
|
4015
|
+
if (value) {
|
|
4016
|
+
event.preventDefault();
|
|
4017
|
+
commit("");
|
|
4018
|
+
} else if (collapses) {
|
|
4019
|
+
event.preventDefault();
|
|
4020
|
+
close();
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
if (!expanded) {
|
|
4024
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4025
|
+
/* @__PURE__ */ jsx(
|
|
4026
|
+
TooltipTrigger,
|
|
4027
|
+
{
|
|
4028
|
+
render: /* @__PURE__ */ jsx(
|
|
4029
|
+
Button,
|
|
4030
|
+
{
|
|
4031
|
+
ref: buttonRef,
|
|
4032
|
+
type: "button",
|
|
4033
|
+
variant: "ghost",
|
|
4034
|
+
size: "icon-sm",
|
|
4035
|
+
"data-slot": "object-list-search",
|
|
4036
|
+
"aria-label": label,
|
|
4037
|
+
"aria-keyshortcuts": "/",
|
|
4038
|
+
className,
|
|
4039
|
+
onClick: () => {
|
|
4040
|
+
focusRef.current = "input";
|
|
4041
|
+
setOpen(true);
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
),
|
|
4045
|
+
children: /* @__PURE__ */ jsx(SearchIcon, {})
|
|
4046
|
+
}
|
|
4047
|
+
),
|
|
4048
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: label })
|
|
4049
|
+
] });
|
|
4050
|
+
}
|
|
4051
|
+
const spinner = loading ? /* @__PURE__ */ jsx(
|
|
4052
|
+
Spinner,
|
|
4053
|
+
{
|
|
4054
|
+
className: "size-3.5 text-dimah-s3-muted-foreground",
|
|
4055
|
+
"aria-label": t("Searching", { note: "object list search" })
|
|
4056
|
+
}
|
|
4057
|
+
) : null;
|
|
4058
|
+
return /* @__PURE__ */ jsxs(
|
|
4059
|
+
"div",
|
|
4060
|
+
{
|
|
4061
|
+
ref: rootRef,
|
|
4062
|
+
"data-slot": "object-list-search",
|
|
4063
|
+
"data-expanded": "",
|
|
4064
|
+
"data-loading": loading ? "" : void 0,
|
|
4065
|
+
className: cn(
|
|
4066
|
+
"relative flex min-w-0 items-center",
|
|
4067
|
+
collapses ? "w-full flex-1" : "w-40 sm:w-52",
|
|
4068
|
+
className
|
|
4069
|
+
),
|
|
4070
|
+
onBlur: (event) => {
|
|
4071
|
+
if (!collapses || value !== "") return;
|
|
4072
|
+
const next = event.relatedTarget;
|
|
4073
|
+
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
4074
|
+
setOpen(false);
|
|
4075
|
+
},
|
|
4076
|
+
children: [
|
|
4077
|
+
/* @__PURE__ */ jsx(
|
|
4078
|
+
SearchIcon,
|
|
4079
|
+
{
|
|
4080
|
+
"aria-hidden": true,
|
|
4081
|
+
className: "pointer-events-none absolute start-2.5 size-3.5 text-dimah-s3-muted-foreground"
|
|
4082
|
+
}
|
|
4083
|
+
),
|
|
4084
|
+
/* @__PURE__ */ jsx(
|
|
4085
|
+
"input",
|
|
4086
|
+
{
|
|
4087
|
+
ref: inputRef,
|
|
4088
|
+
type: "search",
|
|
4089
|
+
value,
|
|
4090
|
+
placeholder: label,
|
|
4091
|
+
"aria-label": label,
|
|
4092
|
+
"aria-keyshortcuts": "/",
|
|
4093
|
+
"aria-busy": loading || void 0,
|
|
4094
|
+
autoComplete: "off",
|
|
4095
|
+
spellCheck: false,
|
|
4096
|
+
enterKeyHint: "search",
|
|
4097
|
+
className: cn(
|
|
4098
|
+
"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",
|
|
4099
|
+
collapses ? "h-8 pe-14" : "h-7 pe-12"
|
|
4100
|
+
),
|
|
4101
|
+
onChange: (event) => setDraft(event.target.value),
|
|
4102
|
+
onKeyDown
|
|
4103
|
+
}
|
|
4104
|
+
),
|
|
4105
|
+
collapses ? /* @__PURE__ */ jsxs("div", { className: "absolute end-1.5 flex items-center gap-1", children: [
|
|
4106
|
+
spinner,
|
|
4107
|
+
/* @__PURE__ */ jsx(
|
|
4108
|
+
Button,
|
|
4109
|
+
{
|
|
4110
|
+
type: "button",
|
|
4111
|
+
variant: "ghost",
|
|
4112
|
+
size: "icon-xs",
|
|
4113
|
+
"aria-label": t("Close search", { note: "object list" }),
|
|
4114
|
+
onClick: close,
|
|
4115
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
4116
|
+
}
|
|
4117
|
+
)
|
|
4118
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "absolute end-1 flex items-center gap-1", children: [
|
|
4119
|
+
spinner,
|
|
4120
|
+
value ? /* @__PURE__ */ jsx(
|
|
4121
|
+
"button",
|
|
4122
|
+
{
|
|
4123
|
+
type: "button",
|
|
4124
|
+
"aria-label": t("Clear search", { note: "object list" }),
|
|
4125
|
+
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",
|
|
4126
|
+
onClick: () => commit(""),
|
|
4127
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3.5" })
|
|
4128
|
+
}
|
|
4129
|
+
) : null
|
|
4130
|
+
] })
|
|
4131
|
+
]
|
|
4132
|
+
}
|
|
4133
|
+
);
|
|
4134
|
+
}
|
|
4135
|
+
function useSearchPlaceholder(list) {
|
|
4136
|
+
const t = useTranslations();
|
|
4137
|
+
const folder = list.trail.at(-1);
|
|
4138
|
+
if (!folder || list.searchScopes.length === 0) {
|
|
4139
|
+
return t("Search files", { note: "object list" });
|
|
4140
|
+
}
|
|
4141
|
+
if (list.searchScope === "all" && canChooseSearchScope(list)) {
|
|
4142
|
+
return t("Search all files", { note: "object list search" });
|
|
4143
|
+
}
|
|
4144
|
+
return t("Search in \u201C{folder}\u201D", {
|
|
4145
|
+
note: "object list search",
|
|
4146
|
+
variables: { folder: folder.name }
|
|
4147
|
+
});
|
|
4148
|
+
}
|
|
4149
|
+
function useObjectListSearchStatus(list) {
|
|
4150
|
+
const t = useTranslations();
|
|
4151
|
+
const formatNumber = useFormatNumber();
|
|
4152
|
+
if (!list.isSearching) return null;
|
|
4153
|
+
if (list.isLoading || list.isRefreshing) {
|
|
4154
|
+
return {
|
|
4155
|
+
label: t("Searching\u2026", { note: "object list search" }),
|
|
4156
|
+
settled: false
|
|
4157
|
+
};
|
|
4158
|
+
}
|
|
4159
|
+
if (list.error) return null;
|
|
4160
|
+
const files = list.total ?? list.items.length;
|
|
4161
|
+
const count = list.folders.length + files;
|
|
4162
|
+
const more = list.total == null && list.hasMore;
|
|
4163
|
+
if (count === 0) {
|
|
4164
|
+
return { label: t("No results", { note: "object list" }), settled: true };
|
|
4165
|
+
}
|
|
4166
|
+
if (more) {
|
|
4167
|
+
return {
|
|
4168
|
+
label: t("{count}+ results", {
|
|
4169
|
+
note: "object list search",
|
|
4170
|
+
variables: { count: formatNumber(count) }
|
|
4171
|
+
}),
|
|
4172
|
+
settled: true
|
|
4173
|
+
};
|
|
4174
|
+
}
|
|
4175
|
+
return {
|
|
4176
|
+
label: count === 1 ? t("1 result", { note: "object list search" }) : t("{count} results", {
|
|
4177
|
+
note: "object list search",
|
|
4178
|
+
variables: { count: formatNumber(count) }
|
|
4179
|
+
}),
|
|
4180
|
+
settled: true
|
|
4181
|
+
};
|
|
4182
|
+
}
|
|
4183
|
+
function ObjectListSearchBar({ className }) {
|
|
4184
|
+
const t = useTranslations();
|
|
4185
|
+
const { list, label: rootLabel } = useObjectListContext();
|
|
4186
|
+
const status = useObjectListSearchStatus(list);
|
|
4187
|
+
if (!status) return null;
|
|
4188
|
+
const folder = list.trail.at(-1);
|
|
4189
|
+
const choose = canChooseSearchScope(list);
|
|
4190
|
+
const inLabel = t("Search in", { note: "object list search" });
|
|
4191
|
+
return /* @__PURE__ */ jsxs(
|
|
4192
|
+
"div",
|
|
4193
|
+
{
|
|
4194
|
+
"data-slot": "object-list-search-bar",
|
|
4195
|
+
className: cn(
|
|
4196
|
+
"flex min-h-9 min-w-0 items-center gap-2 px-2 py-1 text-xs text-dimah-s3-muted-foreground",
|
|
4197
|
+
className
|
|
4198
|
+
),
|
|
4199
|
+
children: [
|
|
4200
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0", children: inLabel }),
|
|
4201
|
+
choose && folder ? /* @__PURE__ */ jsxs(
|
|
4202
|
+
"div",
|
|
4203
|
+
{
|
|
4204
|
+
role: "radiogroup",
|
|
4205
|
+
"aria-label": inLabel,
|
|
4206
|
+
className: "flex min-w-0 items-center gap-0.5 rounded-lg border border-dimah-s3-border p-0.5",
|
|
4207
|
+
children: [
|
|
4208
|
+
/* @__PURE__ */ jsx(
|
|
4209
|
+
ScopeChoice,
|
|
4210
|
+
{
|
|
4211
|
+
scope: "folder",
|
|
4212
|
+
current: list.searchScope,
|
|
4213
|
+
onSelect: list.setSearchScope,
|
|
4214
|
+
icon: /* @__PURE__ */ jsx(FolderIcon, { "aria-hidden": true }),
|
|
4215
|
+
label: folder.name
|
|
4216
|
+
}
|
|
4217
|
+
),
|
|
4218
|
+
/* @__PURE__ */ jsx(
|
|
4219
|
+
ScopeChoice,
|
|
4220
|
+
{
|
|
4221
|
+
scope: "all",
|
|
4222
|
+
current: list.searchScope,
|
|
4223
|
+
onSelect: list.setSearchScope,
|
|
4224
|
+
icon: /* @__PURE__ */ jsx(HomeIcon, { "aria-hidden": true }),
|
|
4225
|
+
label: rootLabel
|
|
4226
|
+
}
|
|
4227
|
+
)
|
|
4228
|
+
]
|
|
4229
|
+
}
|
|
4230
|
+
) : /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1 font-medium text-dimah-s3-foreground", children: [
|
|
4231
|
+
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" }),
|
|
4232
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: /* @__PURE__ */ jsx("bdi", { children: folder?.name ?? rootLabel }) })
|
|
4233
|
+
] }),
|
|
4234
|
+
/* @__PURE__ */ jsx(
|
|
4235
|
+
"span",
|
|
4236
|
+
{
|
|
4237
|
+
"data-slot": "object-list-search-status",
|
|
4238
|
+
className: "ms-auto shrink-0 tabular-nums",
|
|
4239
|
+
children: status.label
|
|
4240
|
+
}
|
|
4241
|
+
)
|
|
4242
|
+
]
|
|
4243
|
+
}
|
|
4244
|
+
);
|
|
4245
|
+
}
|
|
4246
|
+
function ScopeChoice({
|
|
4247
|
+
scope,
|
|
4248
|
+
current,
|
|
4249
|
+
onSelect,
|
|
4250
|
+
icon,
|
|
4251
|
+
label
|
|
4252
|
+
}) {
|
|
4253
|
+
const checked = scope === current;
|
|
4254
|
+
return /* @__PURE__ */ jsxs(
|
|
4255
|
+
Button,
|
|
4256
|
+
{
|
|
4257
|
+
type: "button",
|
|
4258
|
+
variant: "ghost",
|
|
4259
|
+
size: "xs",
|
|
4260
|
+
role: "radio",
|
|
4261
|
+
"aria-checked": checked,
|
|
4262
|
+
tabIndex: checked ? 0 : -1,
|
|
4263
|
+
className: "min-w-0 aria-checked:bg-dimah-s3-muted aria-checked:text-dimah-s3-foreground",
|
|
4264
|
+
onClick: () => onSelect(scope),
|
|
4265
|
+
onKeyDown: (event) => {
|
|
4266
|
+
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(
|
|
4267
|
+
event.key
|
|
4268
|
+
)) {
|
|
4269
|
+
return;
|
|
4270
|
+
}
|
|
4271
|
+
event.preventDefault();
|
|
4272
|
+
const next = scope === "folder" ? "all" : "folder";
|
|
4273
|
+
onSelect(next);
|
|
4274
|
+
const group = event.currentTarget.parentElement;
|
|
4275
|
+
requestAnimationFrame(
|
|
4276
|
+
() => group?.querySelector("[role=radio][aria-checked=true]")?.focus()
|
|
4277
|
+
);
|
|
4278
|
+
},
|
|
4279
|
+
children: [
|
|
4280
|
+
icon,
|
|
4281
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-32 truncate", children: /* @__PURE__ */ jsx("bdi", { children: label }) })
|
|
4282
|
+
]
|
|
4283
|
+
}
|
|
4284
|
+
);
|
|
4285
|
+
}
|
|
4286
|
+
function ObjectListLocation({
|
|
4287
|
+
location,
|
|
4288
|
+
className
|
|
4289
|
+
}) {
|
|
4290
|
+
const { label: rootLabel } = useObjectListContext();
|
|
4291
|
+
const names = location.length === 0 ? [rootLabel] : location.map((folder) => folder.name);
|
|
4292
|
+
const shown = names.length > 2 ? ["\u2026", ...names.slice(-2)] : names;
|
|
4293
|
+
return /* @__PURE__ */ jsxs(
|
|
4294
|
+
"span",
|
|
4295
|
+
{
|
|
4296
|
+
"data-slot": "object-list-location",
|
|
4297
|
+
title: [rootLabel, ...location.map((folder) => folder.name)].join(" / "),
|
|
4298
|
+
className: cn("min-w-0", className),
|
|
4299
|
+
children: [
|
|
4300
|
+
/* @__PURE__ */ jsx(
|
|
4301
|
+
FolderIcon,
|
|
4302
|
+
{
|
|
4303
|
+
"aria-hidden": true,
|
|
4304
|
+
className: "me-1 inline-block size-3 shrink-0 align-[-0.125rem]"
|
|
4305
|
+
}
|
|
4306
|
+
),
|
|
4307
|
+
shown.map((name, index) => /* @__PURE__ */ jsxs("span", { children: [
|
|
4308
|
+
index > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4309
|
+
/* @__PURE__ */ jsx(
|
|
4310
|
+
ChevronRightIcon,
|
|
4311
|
+
{
|
|
4312
|
+
"aria-hidden": true,
|
|
4313
|
+
className: "mx-0.5 inline-block size-3 align-[-0.125rem] rtl:rotate-180"
|
|
4314
|
+
}
|
|
4315
|
+
),
|
|
4316
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: " / " })
|
|
4317
|
+
] }) : null,
|
|
4318
|
+
/* @__PURE__ */ jsx("bdi", { children: name })
|
|
4319
|
+
] }, index))
|
|
4320
|
+
]
|
|
4321
|
+
}
|
|
4322
|
+
);
|
|
4323
|
+
}
|
|
4324
|
+
function ObjectListCheckbox({
|
|
4325
|
+
checked,
|
|
4326
|
+
indeterminate,
|
|
4327
|
+
label,
|
|
4328
|
+
onCheckedChange,
|
|
4329
|
+
tabIndex,
|
|
4330
|
+
className
|
|
4331
|
+
}) {
|
|
4332
|
+
const shiftRef = useRef(false);
|
|
4333
|
+
return /* @__PURE__ */ jsx(
|
|
4334
|
+
Checkbox,
|
|
4335
|
+
{
|
|
4336
|
+
checked,
|
|
4337
|
+
indeterminate,
|
|
4338
|
+
tabIndex,
|
|
4339
|
+
"aria-label": label,
|
|
4340
|
+
className: cn("after:-inset-x-2 after:-inset-y-3", className),
|
|
4341
|
+
onPointerDown: (event) => {
|
|
4342
|
+
shiftRef.current = event.shiftKey;
|
|
4343
|
+
},
|
|
4344
|
+
onKeyDown: (event) => {
|
|
4345
|
+
if (event.key === " " || event.key === "Enter") {
|
|
4346
|
+
shiftRef.current = event.shiftKey;
|
|
4347
|
+
}
|
|
4348
|
+
},
|
|
4349
|
+
onCheckedChange: (value) => {
|
|
3628
4350
|
onCheckedChange(value, shiftRef.current);
|
|
3629
4351
|
shiftRef.current = false;
|
|
3630
4352
|
}
|
|
@@ -3632,7 +4354,8 @@ function ObjectListCheckbox({
|
|
|
3632
4354
|
);
|
|
3633
4355
|
}
|
|
3634
4356
|
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
|
-
|
|
4357
|
+
var REVEALED = "data-revealed:bg-dimah-s3-primary/15";
|
|
4358
|
+
var ObjectListRow = memo(function ObjectListRow2(props) {
|
|
3636
4359
|
const { entry, className } = props;
|
|
3637
4360
|
const parts = useEntryParts(props);
|
|
3638
4361
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3641,6 +4364,7 @@ function ObjectListRow(props) {
|
|
|
3641
4364
|
...parts.dropTarget,
|
|
3642
4365
|
"data-drop-name": parts.dropTarget ? entry.name : void 0,
|
|
3643
4366
|
"data-slot": "object-list-entry",
|
|
4367
|
+
"data-entry-key": entry.key,
|
|
3644
4368
|
"data-kind": entry.kind,
|
|
3645
4369
|
"data-view": "list",
|
|
3646
4370
|
"data-selected": parts.selected ? "" : void 0,
|
|
@@ -3649,11 +4373,15 @@ function ObjectListRow(props) {
|
|
|
3649
4373
|
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
4374
|
parts.selected ? "bg-dimah-s3-primary/10 hover:bg-dimah-s3-primary/15" : "hover:bg-dimah-s3-muted",
|
|
3651
4375
|
DROP_TARGET,
|
|
4376
|
+
REVEALED,
|
|
3652
4377
|
className
|
|
3653
4378
|
),
|
|
3654
4379
|
children: [
|
|
3655
4380
|
parts.checkbox,
|
|
3656
|
-
/* @__PURE__ */ jsxs(
|
|
4381
|
+
parts.renaming ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2.5 self-stretch", children: [
|
|
4382
|
+
/* @__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]" }) }),
|
|
4383
|
+
/* @__PURE__ */ jsx(ObjectListRenameField, { entry })
|
|
4384
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
3657
4385
|
EntryTrigger,
|
|
3658
4386
|
{
|
|
3659
4387
|
parts,
|
|
@@ -3669,7 +4397,14 @@ function ObjectListRow(props) {
|
|
|
3669
4397
|
),
|
|
3670
4398
|
children: [
|
|
3671
4399
|
/* @__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(
|
|
4400
|
+
/* @__PURE__ */ jsx("span", { className: "block w-full min-w-0 overflow-hidden text-sm leading-snug text-dimah-s3-foreground", children: /* @__PURE__ */ jsx(
|
|
4401
|
+
FileName,
|
|
4402
|
+
{
|
|
4403
|
+
name: entry.name,
|
|
4404
|
+
extension: entry.kind === "file",
|
|
4405
|
+
highlight: parts.highlight
|
|
4406
|
+
}
|
|
4407
|
+
) }),
|
|
3673
4408
|
parts.meta ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: parts.meta }) : null
|
|
3674
4409
|
] }),
|
|
3675
4410
|
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 +4418,8 @@ function ObjectListRow(props) {
|
|
|
3683
4418
|
]
|
|
3684
4419
|
}
|
|
3685
4420
|
);
|
|
3686
|
-
}
|
|
3687
|
-
|
|
4421
|
+
});
|
|
4422
|
+
var ObjectListTile = memo(function ObjectListTile2(props) {
|
|
3688
4423
|
const { entry, className } = props;
|
|
3689
4424
|
const parts = useEntryParts(props);
|
|
3690
4425
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3693,6 +4428,7 @@ function ObjectListTile(props) {
|
|
|
3693
4428
|
...parts.dropTarget,
|
|
3694
4429
|
"data-drop-name": parts.dropTarget ? entry.name : void 0,
|
|
3695
4430
|
"data-slot": "object-list-entry",
|
|
4431
|
+
"data-entry-key": entry.key,
|
|
3696
4432
|
"data-kind": entry.kind,
|
|
3697
4433
|
"data-view": "grid",
|
|
3698
4434
|
"data-selected": parts.selected ? "" : void 0,
|
|
@@ -3700,10 +4436,14 @@ function ObjectListTile(props) {
|
|
|
3700
4436
|
"group/entry relative flex h-full min-w-0 flex-col overflow-hidden rounded-lg border transition-colors duration-150",
|
|
3701
4437
|
parts.selected ? "border-dimah-s3-primary bg-dimah-s3-primary/10" : "border-dimah-s3-border hover:bg-dimah-s3-muted",
|
|
3702
4438
|
DROP_TARGET,
|
|
4439
|
+
REVEALED,
|
|
3703
4440
|
className
|
|
3704
4441
|
),
|
|
3705
4442
|
children: [
|
|
3706
|
-
/* @__PURE__ */ jsxs(
|
|
4443
|
+
parts.renaming ? /* @__PURE__ */ jsxs("div", { className: "flex h-full min-w-0 flex-col", children: [
|
|
4444
|
+
/* @__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 }) }),
|
|
4445
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 px-2 py-1.5", children: /* @__PURE__ */ jsx(ObjectListRenameField, { entry }) })
|
|
4446
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
3707
4447
|
EntryTrigger,
|
|
3708
4448
|
{
|
|
3709
4449
|
parts,
|
|
@@ -3712,7 +4452,14 @@ function ObjectListTile(props) {
|
|
|
3712
4452
|
/* @__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
4453
|
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col gap-0.5 px-2 py-1.5", children: [
|
|
3714
4454
|
/* @__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(
|
|
4455
|
+
/* @__PURE__ */ jsx("span", { className: "block min-w-0 flex-1 overflow-hidden text-sm leading-snug text-dimah-s3-foreground", children: /* @__PURE__ */ jsx(
|
|
4456
|
+
FileName,
|
|
4457
|
+
{
|
|
4458
|
+
name: entry.name,
|
|
4459
|
+
extension: entry.kind === "file",
|
|
4460
|
+
highlight: parts.highlight
|
|
4461
|
+
}
|
|
4462
|
+
) }),
|
|
3716
4463
|
parts.meta ? /* @__PURE__ */ jsx("span", { className: "shrink-0", children: parts.meta }) : null
|
|
3717
4464
|
] }),
|
|
3718
4465
|
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 +4481,7 @@ function ObjectListTile(props) {
|
|
|
3734
4481
|
]
|
|
3735
4482
|
}
|
|
3736
4483
|
);
|
|
3737
|
-
}
|
|
4484
|
+
});
|
|
3738
4485
|
function useEntryParts({
|
|
3739
4486
|
entry,
|
|
3740
4487
|
actions,
|
|
@@ -3743,50 +4490,55 @@ function useEntryParts({
|
|
|
3743
4490
|
media
|
|
3744
4491
|
}) {
|
|
3745
4492
|
const t = useTranslations();
|
|
3746
|
-
const
|
|
3747
|
-
const {
|
|
3748
|
-
const
|
|
3749
|
-
const
|
|
3750
|
-
const
|
|
3751
|
-
const
|
|
3752
|
-
const
|
|
3753
|
-
const
|
|
3754
|
-
const
|
|
4493
|
+
const scope = useObjectListEntryScope();
|
|
4494
|
+
const { selected, selectable, selecting, renaming, tabStop } = useObjectListEntryStatus(entry.key);
|
|
4495
|
+
const location = scope.search ? entry.location : void 0;
|
|
4496
|
+
const defaultDescription = useDefaultDescription(entry, location);
|
|
4497
|
+
const folder = entry.kind === "folder";
|
|
4498
|
+
const canRename = folder ? scope.renameFolder : scope.renameFile;
|
|
4499
|
+
const opens = folder || scope.opensFiles;
|
|
4500
|
+
const takesDrops = folder && scope.folderUploads;
|
|
4501
|
+
const hasMenu = location != null || (folder ? takesDrops || canRename : scope.download || scope.share || scope.delete || canRename);
|
|
4502
|
+
const resolvedActions = actions !== void 0 ? actions : scope.renderActions ? scope.renderActions(entry) : hasMenu ? /* @__PURE__ */ jsx(ObjectListItemMenu, {}) : null;
|
|
3755
4503
|
return {
|
|
3756
4504
|
selected,
|
|
3757
|
-
selecting
|
|
3758
|
-
|
|
4505
|
+
selecting,
|
|
4506
|
+
renaming,
|
|
4507
|
+
tabStop,
|
|
4508
|
+
checkbox: selectable ? /* @__PURE__ */ jsx(
|
|
3759
4509
|
ObjectListCheckbox,
|
|
3760
4510
|
{
|
|
3761
4511
|
checked: selected,
|
|
4512
|
+
tabIndex: -1,
|
|
3762
4513
|
label: t("Select {name}", {
|
|
3763
4514
|
note: "object list selection",
|
|
3764
4515
|
variables: { name: entry.name }
|
|
3765
4516
|
}),
|
|
3766
|
-
onCheckedChange: (checked, shiftKey) =>
|
|
4517
|
+
onCheckedChange: (checked, shiftKey) => scope.toggle(entry.key, { value: checked, range: shiftKey })
|
|
3767
4518
|
}
|
|
3768
4519
|
) : null,
|
|
3769
4520
|
actions: present(resolvedActions),
|
|
3770
4521
|
description: present(
|
|
3771
|
-
description !== void 0 ? description :
|
|
4522
|
+
description !== void 0 ? description : scope.renderDescription ? scope.renderDescription(entry) : defaultDescription
|
|
3772
4523
|
),
|
|
3773
|
-
meta: present(meta !== void 0 ? meta :
|
|
4524
|
+
meta: present(meta !== void 0 ? meta : scope.renderMeta?.(entry)),
|
|
3774
4525
|
media: present(media),
|
|
3775
|
-
dropTarget:
|
|
4526
|
+
dropTarget: takesDrops ? scope.folderDropTarget(entry.id) : null,
|
|
4527
|
+
highlight: scope.search || void 0,
|
|
3776
4528
|
entryKey: entry.key,
|
|
3777
|
-
onClick:
|
|
3778
|
-
if (selectable
|
|
4529
|
+
onClick: opens || selectable ? (event) => {
|
|
4530
|
+
if (selectable) {
|
|
3779
4531
|
if (event.metaKey || event.ctrlKey) {
|
|
3780
|
-
|
|
4532
|
+
scope.toggle(entry.key);
|
|
3781
4533
|
return;
|
|
3782
4534
|
}
|
|
3783
4535
|
if (event.shiftKey) {
|
|
3784
|
-
|
|
4536
|
+
scope.toggle(entry.key, { range: true, value: true });
|
|
3785
4537
|
return;
|
|
3786
4538
|
}
|
|
3787
4539
|
}
|
|
3788
|
-
if (
|
|
3789
|
-
else
|
|
4540
|
+
if (opens) scope.open(entry);
|
|
4541
|
+
else scope.toggle(entry.key);
|
|
3790
4542
|
} : null
|
|
3791
4543
|
};
|
|
3792
4544
|
}
|
|
@@ -3796,13 +4548,24 @@ function EntryTrigger({
|
|
|
3796
4548
|
children
|
|
3797
4549
|
}) {
|
|
3798
4550
|
const focusRing = "outline-none focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50";
|
|
4551
|
+
const tabIndex = parts.tabStop ? 0 : -1;
|
|
3799
4552
|
if (!parts.onClick) {
|
|
3800
|
-
return /* @__PURE__ */ jsx(
|
|
4553
|
+
return /* @__PURE__ */ jsx(
|
|
4554
|
+
"div",
|
|
4555
|
+
{
|
|
4556
|
+
tabIndex,
|
|
4557
|
+
"data-slot": "object-list-entry-trigger",
|
|
4558
|
+
"data-entry-key": parts.entryKey,
|
|
4559
|
+
className: cn(focusRing, className),
|
|
4560
|
+
children
|
|
4561
|
+
}
|
|
4562
|
+
);
|
|
3801
4563
|
}
|
|
3802
4564
|
return /* @__PURE__ */ jsx(
|
|
3803
4565
|
"button",
|
|
3804
4566
|
{
|
|
3805
4567
|
type: "button",
|
|
4568
|
+
tabIndex,
|
|
3806
4569
|
"data-slot": "object-list-entry-trigger",
|
|
3807
4570
|
"data-entry-key": parts.entryKey,
|
|
3808
4571
|
className: cn("cursor-pointer select-none", focusRing, className),
|
|
@@ -3842,15 +4605,19 @@ function EntryMedia({
|
|
|
3842
4605
|
}
|
|
3843
4606
|
);
|
|
3844
4607
|
}
|
|
3845
|
-
function useDefaultDescription(entry) {
|
|
4608
|
+
function useDefaultDescription(entry, location) {
|
|
3846
4609
|
const formatFileSize = useFormatFileSize();
|
|
3847
4610
|
const formatDate = useFormatDate();
|
|
3848
|
-
|
|
3849
|
-
const parts = [
|
|
4611
|
+
const parts = entry.kind === "folder" ? [] : [
|
|
3850
4612
|
entry.file.size != null ? formatFileSize(entry.file.size) : "",
|
|
3851
4613
|
formatDate(entry.file.updatedAt)
|
|
3852
4614
|
].filter(Boolean);
|
|
3853
|
-
|
|
4615
|
+
const details = parts.length > 0 ? parts.join(" \xB7 ") : null;
|
|
4616
|
+
if (!location) return details;
|
|
4617
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4618
|
+
/* @__PURE__ */ jsx(ObjectListLocation, { location }),
|
|
4619
|
+
details ? ` \xB7 ${details}` : null
|
|
4620
|
+
] });
|
|
3854
4621
|
}
|
|
3855
4622
|
function present(node) {
|
|
3856
4623
|
return node == null || node === false || node === "" ? null : node;
|
|
@@ -3912,10 +4679,7 @@ function EmptyTitle({ className, ...props }) {
|
|
|
3912
4679
|
"div",
|
|
3913
4680
|
{
|
|
3914
4681
|
"data-slot": "empty-title",
|
|
3915
|
-
className: cn(
|
|
3916
|
-
"cn-font-heading text-sm font-medium tracking-tight",
|
|
3917
|
-
className
|
|
3918
|
-
),
|
|
4682
|
+
className: cn("text-sm font-medium tracking-tight", className),
|
|
3919
4683
|
...props
|
|
3920
4684
|
}
|
|
3921
4685
|
);
|
|
@@ -3956,21 +4720,6 @@ function Skeleton({ className, ...props }) {
|
|
|
3956
4720
|
}
|
|
3957
4721
|
);
|
|
3958
4722
|
}
|
|
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
4723
|
function ObjectListEmpty({
|
|
3975
4724
|
title,
|
|
3976
4725
|
description,
|
|
@@ -3980,10 +4729,19 @@ function ObjectListEmpty({
|
|
|
3980
4729
|
const t = useTranslations();
|
|
3981
4730
|
const { list, upload } = useObjectListContext();
|
|
3982
4731
|
const search = list.search.trim();
|
|
4732
|
+
const folder = list.trail.at(-1);
|
|
4733
|
+
const recursive = list.searchScopes.length > 0;
|
|
4734
|
+
const everywhere = canChooseSearchScope(list) && list.searchScope === "folder";
|
|
3983
4735
|
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.", {
|
|
4736
|
+
const defaultDescription = search ? !recursive && folder ? t("Nothing in this folder matches \u201C{search}\u201D.", {
|
|
3985
4737
|
note: "object list",
|
|
3986
4738
|
variables: { search }
|
|
4739
|
+
}) : folder && list.searchScope === "folder" ? t("Nothing in \u201C{folder}\u201D or its folders matches \u201C{search}\u201D.", {
|
|
4740
|
+
note: "object list search",
|
|
4741
|
+
variables: { folder: folder.name, search }
|
|
4742
|
+
}) : t("Nothing matches \u201C{search}\u201D.", {
|
|
4743
|
+
note: "object list search",
|
|
4744
|
+
variables: { search }
|
|
3987
4745
|
}) : upload ? t("Drop files here to add them to this folder.", {
|
|
3988
4746
|
note: "object list"
|
|
3989
4747
|
}) : t("Files and folders you add here will show up in this list.", {
|
|
@@ -3995,7 +4753,18 @@ function ObjectListEmpty({
|
|
|
3995
4753
|
/* @__PURE__ */ jsx(EmptyTitle, { children: title ?? defaultTitle }),
|
|
3996
4754
|
/* @__PURE__ */ jsx(EmptyDescription, { className: "[overflow-wrap:anywhere]", children: description ?? defaultDescription })
|
|
3997
4755
|
] }),
|
|
3998
|
-
children ? /* @__PURE__ */ jsx(EmptyContent, { children }) :
|
|
4756
|
+
children ? /* @__PURE__ */ jsx(EmptyContent, { children }) : search ? /* @__PURE__ */ jsxs(EmptyContent, { className: "flex-row flex-wrap justify-center gap-2", children: [
|
|
4757
|
+
everywhere ? /* @__PURE__ */ jsx(
|
|
4758
|
+
Button,
|
|
4759
|
+
{
|
|
4760
|
+
variant: "outline",
|
|
4761
|
+
size: "sm",
|
|
4762
|
+
onClick: () => list.setSearchScope("all"),
|
|
4763
|
+
children: t("Search everywhere", { note: "object list search" })
|
|
4764
|
+
}
|
|
4765
|
+
) : null,
|
|
4766
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => list.setSearch(""), children: t("Clear search", { note: "object list" }) })
|
|
4767
|
+
] }) : null
|
|
3999
4768
|
] });
|
|
4000
4769
|
}
|
|
4001
4770
|
function ObjectListError({
|
|
@@ -4120,7 +4889,7 @@ function ObjectListPagination({
|
|
|
4120
4889
|
function ObjectListContent({ className }) {
|
|
4121
4890
|
const context = useObjectListContext();
|
|
4122
4891
|
const { list, view, sizing } = context;
|
|
4123
|
-
const formatError =
|
|
4892
|
+
const formatError = useFormatError();
|
|
4124
4893
|
const [scroller, setScroller] = useState(null);
|
|
4125
4894
|
const hasRows = list.entries.length > 0;
|
|
4126
4895
|
const errorMessage = list.error ? formatError(list.error) : null;
|
|
@@ -4145,12 +4914,19 @@ function ObjectListContent({ className }) {
|
|
|
4145
4914
|
list.isLoading ? /* @__PURE__ */ jsx(ObjectListSkeleton, { view }) : null,
|
|
4146
4915
|
list.error && !hasRows && !list.isLoading ? /* @__PURE__ */ jsx(ObjectListError, { message: errorMessage, onRetry: list.retry }) : null,
|
|
4147
4916
|
showEmpty ? context.empty ?? /* @__PURE__ */ jsx(ObjectListEmpty, {}) : null,
|
|
4148
|
-
hasRows ? /* @__PURE__ */ jsx(
|
|
4917
|
+
hasRows ? /* @__PURE__ */ jsx(
|
|
4918
|
+
ObjectListEntries,
|
|
4919
|
+
{
|
|
4920
|
+
entries: list.entries,
|
|
4921
|
+
view,
|
|
4922
|
+
renderEntry: context.renderEntry
|
|
4923
|
+
}
|
|
4924
|
+
) : null,
|
|
4149
4925
|
hasRows && errorMessage ? /* @__PURE__ */ jsx(ObjectListErrorBanner, { message: errorMessage, onRetry: list.retry }) : null,
|
|
4150
4926
|
/* @__PURE__ */ jsx(
|
|
4151
4927
|
ObjectListPagination,
|
|
4152
4928
|
{
|
|
4153
|
-
mode: context.
|
|
4929
|
+
mode: context.pagination,
|
|
4154
4930
|
root: sizing ? scroller : null,
|
|
4155
4931
|
ready: !sizing || scroller != null
|
|
4156
4932
|
}
|
|
@@ -4163,27 +4939,34 @@ var ENTRY_VISIBILITY = {
|
|
|
4163
4939
|
list: "[contain-intrinsic-block-size:auto_2.75rem] [content-visibility:auto]",
|
|
4164
4940
|
grid: "[contain-intrinsic-block-size:auto_9.5rem] [content-visibility:auto]"
|
|
4165
4941
|
};
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
"
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
}
|
|
4942
|
+
var ObjectListEntries = memo(function ObjectListEntries2({
|
|
4943
|
+
entries,
|
|
4944
|
+
view,
|
|
4945
|
+
renderEntry
|
|
4946
|
+
}) {
|
|
4947
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4948
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "object-list-entries-start", tabIndex: -1 }),
|
|
4949
|
+
/* @__PURE__ */ jsx(
|
|
4950
|
+
"div",
|
|
4951
|
+
{
|
|
4952
|
+
role: "list",
|
|
4953
|
+
"data-slot": "object-list-entries",
|
|
4954
|
+
"data-view": view,
|
|
4955
|
+
className: view === "grid" ? "grid grid-cols-[repeat(auto-fill,minmax(8.5rem,1fr))] gap-2 p-2" : "flex min-w-0 flex-col",
|
|
4956
|
+
children: entries.map((entry) => /* @__PURE__ */ jsx(
|
|
4957
|
+
"div",
|
|
4958
|
+
{
|
|
4959
|
+
role: "listitem",
|
|
4960
|
+
className: cn("min-w-0", ENTRY_VISIBILITY[view]),
|
|
4961
|
+
children: /* @__PURE__ */ jsx(ObjectListEntryProvider, { entry, children: renderEntry ? renderEntry(entry) : view === "grid" ? /* @__PURE__ */ jsx(ObjectListTile, { entry }) : /* @__PURE__ */ jsx(ObjectListRow, { entry }) })
|
|
4962
|
+
},
|
|
4963
|
+
entry.key
|
|
4964
|
+
))
|
|
4965
|
+
}
|
|
4966
|
+
),
|
|
4967
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "object-list-entries-end", tabIndex: -1 })
|
|
4968
|
+
] });
|
|
4969
|
+
});
|
|
4187
4970
|
function Breadcrumb({ className, ...props }) {
|
|
4188
4971
|
return /* @__PURE__ */ jsx(
|
|
4189
4972
|
"nav",
|
|
@@ -4400,15 +5183,12 @@ function PathMenu({
|
|
|
4400
5183
|
] }) })
|
|
4401
5184
|
] });
|
|
4402
5185
|
}
|
|
4403
|
-
var ObjectListHeaderContext = createContext(null);
|
|
4404
|
-
function useOptionalObjectListHeader() {
|
|
4405
|
-
return useContext(ObjectListHeaderContext);
|
|
4406
|
-
}
|
|
4407
5186
|
var OBJECT_LIST_HEADER_COMPACT_LABEL = "@max-[36rem]/object-list-header:sr-only";
|
|
4408
5187
|
var OBJECT_LIST_HEADER_COMPACT_BUTTON = "@max-[36rem]/object-list-header:aspect-square @max-[36rem]/object-list-header:px-0!";
|
|
4409
5188
|
function ObjectListHeader({
|
|
4410
5189
|
children,
|
|
4411
5190
|
breadcrumb,
|
|
5191
|
+
searchBar = true,
|
|
4412
5192
|
selectionActions,
|
|
4413
5193
|
className
|
|
4414
5194
|
}) {
|
|
@@ -4423,9 +5203,10 @@ function ObjectListHeader({
|
|
|
4423
5203
|
() => ({ setSearchExpanded, setFolderExpanded }),
|
|
4424
5204
|
[]
|
|
4425
5205
|
);
|
|
4426
|
-
const
|
|
4427
|
-
const
|
|
4428
|
-
|
|
5206
|
+
const replaced = selecting && !selection?.persist;
|
|
5207
|
+
const creatingFolder = folderExpanded && !replaced;
|
|
5208
|
+
const searching = searchExpanded && !creatingFolder && !replaced;
|
|
5209
|
+
return /* @__PURE__ */ jsx(ObjectListHeaderContext.Provider, { value: header, children: /* @__PURE__ */ jsxs(
|
|
4429
5210
|
"div",
|
|
4430
5211
|
{
|
|
4431
5212
|
"data-slot": "object-list-header",
|
|
@@ -4434,50 +5215,60 @@ function ObjectListHeader({
|
|
|
4434
5215
|
"data-folder-open": creatingFolder ? "" : void 0,
|
|
4435
5216
|
className: cn(
|
|
4436
5217
|
"group/object-list-header @container/object-list-header shrink-0 border-b border-dimah-s3-border",
|
|
4437
|
-
|
|
5218
|
+
replaced && "bg-dimah-s3-primary/10",
|
|
4438
5219
|
className
|
|
4439
5220
|
),
|
|
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",
|
|
5221
|
+
children: [
|
|
5222
|
+
replaced ? /* @__PURE__ */ jsx(
|
|
5223
|
+
ObjectListSelectionBar,
|
|
4448
5224
|
{
|
|
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
|
-
]
|
|
5225
|
+
actions: selectionActions ?? context.selectionActions
|
|
4462
5226
|
}
|
|
4463
|
-
),
|
|
4464
|
-
|
|
4465
|
-
|
|
5227
|
+
) : /* @__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: [
|
|
5228
|
+
/* @__PURE__ */ jsxs(
|
|
5229
|
+
"div",
|
|
5230
|
+
{
|
|
5231
|
+
"data-slot": "object-list-header-path",
|
|
5232
|
+
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",
|
|
5233
|
+
children: [
|
|
5234
|
+
selecting ? null : /* @__PURE__ */ jsx(ObjectListSelectAll, {}),
|
|
5235
|
+
showBreadcrumb ? /* @__PURE__ */ jsx(ObjectListBreadcrumb, {}) : /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1" }),
|
|
5236
|
+
list.isRefreshing ? /* @__PURE__ */ jsx(
|
|
5237
|
+
Spinner,
|
|
5238
|
+
{
|
|
5239
|
+
className: "shrink-0 text-dimah-s3-muted-foreground",
|
|
5240
|
+
"aria-label": t("Loading files", { note: "object list" })
|
|
5241
|
+
}
|
|
5242
|
+
) : null
|
|
5243
|
+
]
|
|
5244
|
+
}
|
|
5245
|
+
),
|
|
5246
|
+
/* @__PURE__ */ jsxs(
|
|
5247
|
+
"div",
|
|
5248
|
+
{
|
|
5249
|
+
"data-slot": "object-list-header-actions",
|
|
5250
|
+
className: cn(
|
|
5251
|
+
"ms-auto flex min-w-0 shrink-0 items-center gap-1",
|
|
5252
|
+
// While search or new folder is open, that field takes the bar alone.
|
|
5253
|
+
"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",
|
|
5254
|
+
"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"
|
|
5255
|
+
),
|
|
5256
|
+
children: [
|
|
5257
|
+
/* @__PURE__ */ jsx(ObjectListNewFolder, {}),
|
|
5258
|
+
children
|
|
5259
|
+
]
|
|
5260
|
+
}
|
|
5261
|
+
)
|
|
5262
|
+
] }),
|
|
5263
|
+
searchBar && list.isSearching ? /* @__PURE__ */ jsx(ObjectListSearchBar, { className: "border-t border-dimah-s3-border" }) : null,
|
|
5264
|
+
selecting && !replaced ? /* @__PURE__ */ jsx(
|
|
5265
|
+
ObjectListSelectionBar,
|
|
4466
5266
|
{
|
|
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
|
-
]
|
|
5267
|
+
className: "border-t border-dimah-s3-border bg-dimah-s3-primary/10",
|
|
5268
|
+
actions: selectionActions ?? context.selectionActions
|
|
4478
5269
|
}
|
|
4479
|
-
)
|
|
4480
|
-
]
|
|
5270
|
+
) : null
|
|
5271
|
+
]
|
|
4481
5272
|
}
|
|
4482
5273
|
) });
|
|
4483
5274
|
}
|
|
@@ -4506,10 +5297,9 @@ function ObjectListSelectionBar({
|
|
|
4506
5297
|
className
|
|
4507
5298
|
}) {
|
|
4508
5299
|
const t = useTranslations();
|
|
4509
|
-
const formatNumber = useFormatNumber();
|
|
4510
5300
|
const { list, selection, delete: del } = useObjectListContext();
|
|
5301
|
+
const count = useSelectionCount(list, selection);
|
|
4511
5302
|
if (!selection?.isSelecting) return null;
|
|
4512
|
-
const count = formatNumber(selection.count);
|
|
4513
5303
|
const busy = del != null && selection.selected.some(
|
|
4514
5304
|
(entry) => entry.kind === "file" && del.pendingKeys.includes(objectKeyOf(entry))
|
|
4515
5305
|
);
|
|
@@ -4523,20 +5313,7 @@ function ObjectListSelectionBar({
|
|
|
4523
5313
|
),
|
|
4524
5314
|
children: [
|
|
4525
5315
|
/* @__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
|
-
),
|
|
5316
|
+
/* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium text-dimah-s3-foreground tabular-nums", children: count }),
|
|
4540
5317
|
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
4541
5318
|
actions ? /* @__PURE__ */ jsx(
|
|
4542
5319
|
"div",
|
|
@@ -4562,6 +5339,19 @@ function ObjectListSelectionBar({
|
|
|
4562
5339
|
}
|
|
4563
5340
|
);
|
|
4564
5341
|
}
|
|
5342
|
+
function useSelectionCount(list, selection) {
|
|
5343
|
+
const t = useTranslations();
|
|
5344
|
+
const formatNumber = useFormatNumber();
|
|
5345
|
+
if (!selection?.isSelecting) return null;
|
|
5346
|
+
const count = formatNumber(selection.count);
|
|
5347
|
+
return selection.allSelected && list.hasMore && !selection.persist ? t("{count} selected on this page", {
|
|
5348
|
+
note: "object list selection",
|
|
5349
|
+
variables: { count }
|
|
5350
|
+
}) : t("{count} selected", {
|
|
5351
|
+
note: "object list selection",
|
|
5352
|
+
variables: { count }
|
|
5353
|
+
});
|
|
5354
|
+
}
|
|
4565
5355
|
function ObjectListBulkDelete() {
|
|
4566
5356
|
const { delete: del, selection } = useObjectListContext();
|
|
4567
5357
|
if (!del || !selection?.isSelecting) return null;
|
|
@@ -4569,6 +5359,7 @@ function ObjectListBulkDelete() {
|
|
|
4569
5359
|
}
|
|
4570
5360
|
function BulkDeleteControl() {
|
|
4571
5361
|
const t = useTranslations();
|
|
5362
|
+
const formatError = useFormatError();
|
|
4572
5363
|
const { selection, resolveFolderKeys } = useObjectListContext();
|
|
4573
5364
|
const { delete: del, request } = useDeleteContext();
|
|
4574
5365
|
const report = useObjectListFeedback();
|
|
@@ -4583,12 +5374,13 @@ function BulkDeleteControl() {
|
|
|
4583
5374
|
let plan;
|
|
4584
5375
|
try {
|
|
4585
5376
|
plan = await planBulkDelete(selection.selected, resolveFolderKeys);
|
|
4586
|
-
} catch {
|
|
5377
|
+
} catch (error) {
|
|
4587
5378
|
report({
|
|
4588
5379
|
type: "error",
|
|
4589
5380
|
title: t("Could not delete the selection", {
|
|
4590
5381
|
note: "object list selection"
|
|
4591
|
-
})
|
|
5382
|
+
}),
|
|
5383
|
+
description: formatError(error)
|
|
4592
5384
|
});
|
|
4593
5385
|
return;
|
|
4594
5386
|
} finally {
|
|
@@ -4605,7 +5397,20 @@ function BulkDeleteControl() {
|
|
|
4605
5397
|
return;
|
|
4606
5398
|
}
|
|
4607
5399
|
setRequested(plan.targets.map((target) => target.objectKey));
|
|
4608
|
-
request(plan.targets, {
|
|
5400
|
+
request(plan.targets, {
|
|
5401
|
+
note,
|
|
5402
|
+
trigger,
|
|
5403
|
+
onDeleted: (result) => {
|
|
5404
|
+
setRequested([]);
|
|
5405
|
+
const deleted = new Set(result.deleted);
|
|
5406
|
+
const emptied = plan.folders.filter(
|
|
5407
|
+
({ objectKeys }) => objectKeys.length > 0 && objectKeys.every((key) => deleted.has(key))
|
|
5408
|
+
);
|
|
5409
|
+
if (emptied.length > 0) {
|
|
5410
|
+
selection.deselect(emptied.map(({ entryKey }) => entryKey));
|
|
5411
|
+
}
|
|
5412
|
+
}
|
|
5413
|
+
});
|
|
4609
5414
|
}
|
|
4610
5415
|
return /* @__PURE__ */ jsxs(
|
|
4611
5416
|
Button,
|
|
@@ -4627,26 +5432,37 @@ function BulkDeleteControl() {
|
|
|
4627
5432
|
}
|
|
4628
5433
|
async function planBulkDelete(selected, resolveFolderKeys) {
|
|
4629
5434
|
const targets = /* @__PURE__ */ new Map();
|
|
4630
|
-
let skippedFolders = 0;
|
|
4631
5435
|
for (const entry of selected) {
|
|
4632
|
-
if (entry.kind
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
5436
|
+
if (entry.kind !== "file") continue;
|
|
5437
|
+
const objectKey = objectKeyOf(entry);
|
|
5438
|
+
targets.set(objectKey, {
|
|
5439
|
+
objectKey,
|
|
5440
|
+
fileName: entry.file.name,
|
|
5441
|
+
fileSize: entry.file.size
|
|
5442
|
+
});
|
|
5443
|
+
}
|
|
5444
|
+
const selectedFolders = selected.filter((entry) => entry.kind === "folder");
|
|
5445
|
+
if (!resolveFolderKeys) {
|
|
5446
|
+
return {
|
|
5447
|
+
targets: [...targets.values()],
|
|
5448
|
+
folders: [],
|
|
5449
|
+
skippedFolders: selectedFolders.length
|
|
5450
|
+
};
|
|
5451
|
+
}
|
|
5452
|
+
const folders = await Promise.all(
|
|
5453
|
+
selectedFolders.map(async (entry) => ({
|
|
5454
|
+
entryKey: entry.key,
|
|
5455
|
+
objectKeys: await resolveFolderKeys(entry.folder)
|
|
5456
|
+
}))
|
|
5457
|
+
);
|
|
5458
|
+
for (const { objectKeys } of folders) {
|
|
5459
|
+
for (const objectKey of objectKeys) {
|
|
5460
|
+
if (!targets.has(objectKey)) targets.set(objectKey, { objectKey });
|
|
4645
5461
|
}
|
|
4646
5462
|
}
|
|
4647
|
-
return { targets: [...targets.values()], skippedFolders };
|
|
5463
|
+
return { targets: [...targets.values()], folders, skippedFolders: 0 };
|
|
4648
5464
|
}
|
|
4649
|
-
function
|
|
5465
|
+
function ObjectListNewFolder({ className }) {
|
|
4650
5466
|
const t = useTranslations();
|
|
4651
5467
|
const { list } = useObjectListContext();
|
|
4652
5468
|
const header = useOptionalObjectListHeader();
|
|
@@ -4702,7 +5518,7 @@ function NewFolderForm({
|
|
|
4702
5518
|
className
|
|
4703
5519
|
}) {
|
|
4704
5520
|
const t = useTranslations();
|
|
4705
|
-
const formatError =
|
|
5521
|
+
const formatError = useFormatError();
|
|
4706
5522
|
const inputId = useId();
|
|
4707
5523
|
const errorId = useId();
|
|
4708
5524
|
const inputRef = useRef(null);
|
|
@@ -4848,10 +5664,16 @@ function NewFolderForm({
|
|
|
4848
5664
|
}
|
|
4849
5665
|
var ENTRY = "[data-slot=object-list-entry]";
|
|
4850
5666
|
var TRIGGER = "[data-slot=object-list-entry-trigger]";
|
|
5667
|
+
var RENAME = "[data-slot=object-list-rename]";
|
|
5668
|
+
var ENTRIES_START = "[data-slot=object-list-entries-start]";
|
|
5669
|
+
var ENTRIES_END = "[data-slot=object-list-entries-end]";
|
|
5670
|
+
var CONTROL = "button, a[href], input, select, textarea, [role=checkbox], [tabindex]";
|
|
4851
5671
|
function useObjectListKeyboard({
|
|
4852
5672
|
list,
|
|
4853
5673
|
selection,
|
|
4854
|
-
view
|
|
5674
|
+
view,
|
|
5675
|
+
store,
|
|
5676
|
+
startRename
|
|
4855
5677
|
}) {
|
|
4856
5678
|
const spaceRef = useRef(false);
|
|
4857
5679
|
function selectableKey(target) {
|
|
@@ -4867,13 +5689,19 @@ function useObjectListKeyboard({
|
|
|
4867
5689
|
if (!(target instanceof HTMLElement) || !frame.contains(target)) return;
|
|
4868
5690
|
if (isFieldTarget(target) || isOverlayTarget(target)) return;
|
|
4869
5691
|
const modifier = event.ctrlKey || event.metaKey;
|
|
5692
|
+
const entry = entryOf(frame, target);
|
|
5693
|
+
if (event.key === "Tab") {
|
|
5694
|
+
if (!entry || modifier || event.altKey || target.closest(RENAME)) return;
|
|
5695
|
+
tabFrom(frame, entry, target, event);
|
|
5696
|
+
return;
|
|
5697
|
+
}
|
|
4870
5698
|
if (event.key === "Escape") {
|
|
4871
5699
|
if (!selection?.isSelecting) return;
|
|
4872
5700
|
event.preventDefault();
|
|
4873
5701
|
selection.clear();
|
|
4874
5702
|
return;
|
|
4875
5703
|
}
|
|
4876
|
-
if (event
|
|
5704
|
+
if (isSelectAllKey(event) && modifier && !event.altKey && !event.shiftKey) {
|
|
4877
5705
|
if (!selection || selection.mode !== "multiple") return;
|
|
4878
5706
|
if (selection.selectableCount === 0) return;
|
|
4879
5707
|
event.preventDefault();
|
|
@@ -4886,6 +5714,24 @@ function useObjectListKeyboard({
|
|
|
4886
5714
|
list.goUp();
|
|
4887
5715
|
return;
|
|
4888
5716
|
}
|
|
5717
|
+
if (event.key === "F2" && !modifier && !event.altKey && !event.shiftKey) {
|
|
5718
|
+
const key = entry?.dataset.entryKey;
|
|
5719
|
+
const found = key ? list.entries.find((item) => item.key === key) : null;
|
|
5720
|
+
if (!found || !canRenameEntry(found, list)) return;
|
|
5721
|
+
event.preventDefault();
|
|
5722
|
+
startRename(found.key);
|
|
5723
|
+
return;
|
|
5724
|
+
}
|
|
5725
|
+
if (isSearchKey(event) && !modifier && !event.altKey) {
|
|
5726
|
+
const search = frame.querySelector(
|
|
5727
|
+
"[data-slot=object-list-search]"
|
|
5728
|
+
);
|
|
5729
|
+
if (!search) return;
|
|
5730
|
+
event.preventDefault();
|
|
5731
|
+
if (search instanceof HTMLButtonElement) search.click();
|
|
5732
|
+
else search.querySelector("input")?.focus();
|
|
5733
|
+
return;
|
|
5734
|
+
}
|
|
4889
5735
|
if (event.key === " " && !modifier) {
|
|
4890
5736
|
const key = selectableKey(target);
|
|
4891
5737
|
if (!key || !selection) return;
|
|
@@ -4895,7 +5741,15 @@ function useObjectListKeyboard({
|
|
|
4895
5741
|
return;
|
|
4896
5742
|
}
|
|
4897
5743
|
if (modifier || event.altKey) return;
|
|
4898
|
-
const
|
|
5744
|
+
const rtl = getComputedStyle(frame).direction === "rtl";
|
|
5745
|
+
if (view === "list" && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {
|
|
5746
|
+
if (!entry) return;
|
|
5747
|
+
event.preventDefault();
|
|
5748
|
+
const forward = event.key === "ArrowRight" ? !rtl : rtl;
|
|
5749
|
+
moveWithinEntry(entry, target, forward ? 1 : -1);
|
|
5750
|
+
return;
|
|
5751
|
+
}
|
|
5752
|
+
const step = focusStep(event.key, frame, view, rtl);
|
|
4899
5753
|
if (step == null) return;
|
|
4900
5754
|
event.preventDefault();
|
|
4901
5755
|
moveFocus(frame, target, step);
|
|
@@ -4905,11 +5759,15 @@ function useObjectListKeyboard({
|
|
|
4905
5759
|
spaceRef.current = false;
|
|
4906
5760
|
event.preventDefault();
|
|
4907
5761
|
}
|
|
4908
|
-
|
|
5762
|
+
function onFocus(event) {
|
|
5763
|
+
if (!(event.target instanceof HTMLElement)) return;
|
|
5764
|
+
const key = entryOf(event.currentTarget, event.target)?.dataset.entryKey;
|
|
5765
|
+
if (key) store.set({ tabStop: key });
|
|
5766
|
+
}
|
|
5767
|
+
return { onKeyDown, onKeyUp, onFocus };
|
|
4909
5768
|
}
|
|
4910
|
-
function focusStep(key, frame, view) {
|
|
5769
|
+
function focusStep(key, frame, view, rtl) {
|
|
4911
5770
|
const columns = view === "grid" ? gridColumns(frame) : 1;
|
|
4912
|
-
const rtl = getComputedStyle(frame).direction === "rtl";
|
|
4913
5771
|
switch (key) {
|
|
4914
5772
|
case "ArrowDown":
|
|
4915
5773
|
return columns;
|
|
@@ -4949,6 +5807,32 @@ function moveFocus(frame, target, step) {
|
|
|
4949
5807
|
trigger?.focus();
|
|
4950
5808
|
trigger?.scrollIntoView({ block: "nearest" });
|
|
4951
5809
|
}
|
|
5810
|
+
function entryOf(frame, target) {
|
|
5811
|
+
const entry = target.closest(ENTRY);
|
|
5812
|
+
return entry && frame.contains(entry) ? entry : null;
|
|
5813
|
+
}
|
|
5814
|
+
function entryControls(entry) {
|
|
5815
|
+
return [...entry.querySelectorAll(CONTROL)].filter(
|
|
5816
|
+
(control) => !control.matches(":disabled") && control.getAttribute("aria-hidden") !== "true" && !(control instanceof HTMLInputElement && control.type === "hidden") && !control.closest("[inert], [hidden]")
|
|
5817
|
+
);
|
|
5818
|
+
}
|
|
5819
|
+
function moveWithinEntry(entry, target, step) {
|
|
5820
|
+
const controls = entryControls(entry);
|
|
5821
|
+
const index = controls.findIndex((control) => control.contains(target));
|
|
5822
|
+
if (index < 0) return;
|
|
5823
|
+
controls[index + step]?.focus();
|
|
5824
|
+
}
|
|
5825
|
+
function tabFrom(frame, entry, target, event) {
|
|
5826
|
+
const controls = entryControls(entry);
|
|
5827
|
+
const index = controls.indexOf(target);
|
|
5828
|
+
const next = index < 0 ? void 0 : controls[index + (event.shiftKey ? -1 : 1)];
|
|
5829
|
+
if (next) {
|
|
5830
|
+
event.preventDefault();
|
|
5831
|
+
next.focus();
|
|
5832
|
+
return;
|
|
5833
|
+
}
|
|
5834
|
+
frame.querySelector(event.shiftKey ? ENTRIES_START : ENTRIES_END)?.focus({ preventScroll: true });
|
|
5835
|
+
}
|
|
4952
5836
|
function isOverlayTarget(target) {
|
|
4953
5837
|
return Boolean(
|
|
4954
5838
|
target.closest(
|
|
@@ -4956,6 +5840,14 @@ function isOverlayTarget(target) {
|
|
|
4956
5840
|
)
|
|
4957
5841
|
);
|
|
4958
5842
|
}
|
|
5843
|
+
function isSearchKey(event) {
|
|
5844
|
+
if (event.key === "/") return true;
|
|
5845
|
+
return event.code === "Slash" && !/^[\x20-\x7e]$/.test(event.key);
|
|
5846
|
+
}
|
|
5847
|
+
function isSelectAllKey(event) {
|
|
5848
|
+
if (/^[a-z]$/i.test(event.key)) return event.key.toLowerCase() === "a";
|
|
5849
|
+
return event.code === "KeyA";
|
|
5850
|
+
}
|
|
4959
5851
|
function ObjectListUsage({ className }) {
|
|
4960
5852
|
const t = useTranslations();
|
|
4961
5853
|
const { list } = useObjectListContext();
|
|
@@ -5065,7 +5957,7 @@ function ObjectList({
|
|
|
5065
5957
|
toolbar,
|
|
5066
5958
|
selectionActions,
|
|
5067
5959
|
empty,
|
|
5068
|
-
|
|
5960
|
+
pagination = "auto",
|
|
5069
5961
|
height,
|
|
5070
5962
|
maxHeight,
|
|
5071
5963
|
className,
|
|
@@ -5081,35 +5973,262 @@ function ObjectList({
|
|
|
5081
5973
|
useRefreshListAfterUpload(upload, list.refresh);
|
|
5082
5974
|
const deleteFocus = useFocusAfterDelete();
|
|
5083
5975
|
const { announcement, announce } = useObjectListAnnouncement();
|
|
5976
|
+
const selectionCount = useSelectionCount(list, selection ?? null);
|
|
5977
|
+
const searchStatus = useObjectListSearchStatus(list);
|
|
5978
|
+
const revealRef = useRef(null);
|
|
5979
|
+
const [renamingKey, setRenamingKey] = useState(null);
|
|
5980
|
+
const renameFocusKey = useRef(null);
|
|
5981
|
+
const previousRenaming = useRef(null);
|
|
5982
|
+
if (renamingKey != null && !list.entries.some((entry) => entry.key === renamingKey)) {
|
|
5983
|
+
setRenamingKey(null);
|
|
5984
|
+
}
|
|
5985
|
+
useEffect(() => {
|
|
5986
|
+
const previous = previousRenaming.current;
|
|
5987
|
+
previousRenaming.current = renamingKey;
|
|
5988
|
+
if (previous == null || renamingKey != null) return;
|
|
5989
|
+
const focusKey = renameFocusKey.current;
|
|
5990
|
+
renameFocusKey.current = null;
|
|
5991
|
+
if (focusKey !== previous) return;
|
|
5992
|
+
deleteFocus.frameRef.current?.querySelector(
|
|
5993
|
+
`[data-slot="object-list-entry-trigger"][data-entry-key="${CSS.escape(previous)}"]`
|
|
5994
|
+
)?.focus();
|
|
5995
|
+
}, [deleteFocus.frameRef, renamingKey]);
|
|
5084
5996
|
const frameHeight = cssLength(height);
|
|
5085
5997
|
const frameMaxHeight = cssLength(maxHeight);
|
|
5086
|
-
const
|
|
5998
|
+
const sizing = frameHeight != null ? "fixed" : frameMaxHeight != null ? "max" : null;
|
|
5999
|
+
const label = rootLabel ?? t("Files", { note: "object list" });
|
|
6000
|
+
const selectableKeys = useSelectableKeys(list.entries, selection ?? null);
|
|
6001
|
+
const selectedKeys = selection?.selectedKeys ?? NO_KEYS;
|
|
6002
|
+
const selecting = selection?.isSelecting === true;
|
|
6003
|
+
const [store] = useState(
|
|
6004
|
+
() => createObjectListEntryStore({
|
|
6005
|
+
selected: selectedKeys,
|
|
6006
|
+
selecting,
|
|
6007
|
+
renaming: null,
|
|
6008
|
+
tabStop: list.entries[0]?.key ?? null
|
|
6009
|
+
})
|
|
6010
|
+
);
|
|
6011
|
+
useLayoutEffect(() => {
|
|
6012
|
+
const { tabStop } = store.get();
|
|
6013
|
+
store.set({
|
|
6014
|
+
selected: selectedKeys,
|
|
6015
|
+
selecting,
|
|
6016
|
+
renaming: renamingKey,
|
|
6017
|
+
// The entry that had the tab stop left: the first one takes it.
|
|
6018
|
+
tabStop: tabStop != null && list.entries.some((entry) => entry.key === tabStop) ? tabStop : list.entries[0]?.key ?? null
|
|
6019
|
+
});
|
|
6020
|
+
}, [list.entries, renamingKey, selectedKeys, selecting, store]);
|
|
6021
|
+
const latest = useRef({
|
|
5087
6022
|
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,
|
|
6023
|
+
selection,
|
|
6024
|
+
upload,
|
|
5106
6025
|
onOpenItem,
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
6026
|
+
viewProp,
|
|
6027
|
+
onViewChange
|
|
6028
|
+
});
|
|
6029
|
+
useLayoutEffect(() => {
|
|
6030
|
+
latest.current = {
|
|
6031
|
+
list,
|
|
6032
|
+
selection,
|
|
6033
|
+
upload,
|
|
6034
|
+
onOpenItem,
|
|
6035
|
+
viewProp,
|
|
6036
|
+
onViewChange
|
|
6037
|
+
};
|
|
6038
|
+
});
|
|
6039
|
+
const setView = useCallback((next) => {
|
|
6040
|
+
if (latest.current.viewProp === void 0) setLocalView(next);
|
|
6041
|
+
latest.current.onViewChange?.(next);
|
|
6042
|
+
}, []);
|
|
6043
|
+
const startRename = useCallback(
|
|
6044
|
+
(key) => {
|
|
6045
|
+
const current = latest.current.list;
|
|
6046
|
+
const target = current.entries.find((entry) => entry.key === key);
|
|
6047
|
+
if (!target || !canRenameEntry(target, current)) return;
|
|
6048
|
+
setRenamingKey(key);
|
|
6049
|
+
store.set({ renaming: key });
|
|
6050
|
+
},
|
|
6051
|
+
[store]
|
|
6052
|
+
);
|
|
6053
|
+
const endRename = useCallback(
|
|
6054
|
+
(key, focus = false) => {
|
|
6055
|
+
if (focus) renameFocusKey.current = key;
|
|
6056
|
+
setRenamingKey((current) => current === key ? null : current);
|
|
6057
|
+
if (store.get().renaming === key) store.set({ renaming: null });
|
|
6058
|
+
},
|
|
6059
|
+
[store]
|
|
6060
|
+
);
|
|
6061
|
+
const revealEntry = useCallback((entry) => {
|
|
6062
|
+
const { location } = entry;
|
|
6063
|
+
if (!location) return;
|
|
6064
|
+
const current = latest.current.list;
|
|
6065
|
+
revealRef.current = entry.key;
|
|
6066
|
+
current.setSearch("");
|
|
6067
|
+
current.navigate(location);
|
|
6068
|
+
}, []);
|
|
6069
|
+
const open = useCallback((entry) => {
|
|
6070
|
+
const current = latest.current;
|
|
6071
|
+
if (entry.kind === "folder") current.list.openFolder(entry.folder);
|
|
6072
|
+
else current.onOpenItem?.(entry.item);
|
|
6073
|
+
}, []);
|
|
6074
|
+
const toggle = useCallback(
|
|
6075
|
+
(key, options) => {
|
|
6076
|
+
latest.current.selection?.toggle(key, options);
|
|
6077
|
+
},
|
|
6078
|
+
[]
|
|
6079
|
+
);
|
|
6080
|
+
const folderDropTarget = useCallback((id) => {
|
|
6081
|
+
const handler = (name) => (event) => {
|
|
6082
|
+
const current = latest.current;
|
|
6083
|
+
current.upload?.getDropTargetProps(
|
|
6084
|
+
{},
|
|
6085
|
+
() => folderUploadCall(current.list, id) ?? {}
|
|
6086
|
+
)[name]?.(event);
|
|
6087
|
+
};
|
|
6088
|
+
return {
|
|
6089
|
+
onDragEnter: handler("onDragEnter"),
|
|
6090
|
+
onDragOver: handler("onDragOver"),
|
|
6091
|
+
onDragLeave: handler("onDragLeave"),
|
|
6092
|
+
onDrop: handler("onDrop")
|
|
6093
|
+
};
|
|
6094
|
+
}, []);
|
|
6095
|
+
const context = useMemo(
|
|
6096
|
+
() => ({
|
|
6097
|
+
list,
|
|
6098
|
+
selection: selection ?? null,
|
|
6099
|
+
upload: upload ?? null,
|
|
6100
|
+
download: download ?? null,
|
|
6101
|
+
share: share ?? null,
|
|
6102
|
+
delete: del ?? null,
|
|
6103
|
+
toasts,
|
|
6104
|
+
announce,
|
|
6105
|
+
view,
|
|
6106
|
+
setView,
|
|
6107
|
+
label,
|
|
6108
|
+
sizing,
|
|
6109
|
+
showBreadcrumb: breadcrumb,
|
|
6110
|
+
selectionActions,
|
|
6111
|
+
empty,
|
|
6112
|
+
pagination,
|
|
6113
|
+
onOpenItem,
|
|
6114
|
+
resolveFolderKeys,
|
|
6115
|
+
renamingKey,
|
|
6116
|
+
startRename,
|
|
6117
|
+
endRename,
|
|
6118
|
+
revealEntry,
|
|
6119
|
+
renderEntry,
|
|
6120
|
+
renderActions,
|
|
6121
|
+
renderDescription,
|
|
6122
|
+
renderMeta
|
|
6123
|
+
}),
|
|
6124
|
+
[
|
|
6125
|
+
announce,
|
|
6126
|
+
breadcrumb,
|
|
6127
|
+
del,
|
|
6128
|
+
download,
|
|
6129
|
+
empty,
|
|
6130
|
+
endRename,
|
|
6131
|
+
label,
|
|
6132
|
+
list,
|
|
6133
|
+
onOpenItem,
|
|
6134
|
+
pagination,
|
|
6135
|
+
renamingKey,
|
|
6136
|
+
renderActions,
|
|
6137
|
+
renderDescription,
|
|
6138
|
+
renderEntry,
|
|
6139
|
+
renderMeta,
|
|
6140
|
+
resolveFolderKeys,
|
|
6141
|
+
revealEntry,
|
|
6142
|
+
selection,
|
|
6143
|
+
selectionActions,
|
|
6144
|
+
setView,
|
|
6145
|
+
share,
|
|
6146
|
+
sizing,
|
|
6147
|
+
startRename,
|
|
6148
|
+
toasts,
|
|
6149
|
+
upload,
|
|
6150
|
+
view
|
|
6151
|
+
]
|
|
6152
|
+
);
|
|
6153
|
+
useEffect(() => {
|
|
6154
|
+
const revealKey = revealRef.current;
|
|
6155
|
+
if (revealKey == null) return;
|
|
6156
|
+
if (list.isSearching || list.isLoading || list.isRefreshing) return;
|
|
6157
|
+
revealRef.current = null;
|
|
6158
|
+
const trigger = deleteFocus.frameRef.current?.querySelector(
|
|
6159
|
+
`[data-slot="object-list-entry-trigger"][data-entry-key="${CSS.escape(revealKey)}"]`
|
|
6160
|
+
);
|
|
6161
|
+
if (!trigger) return;
|
|
6162
|
+
store.set({ tabStop: revealKey });
|
|
6163
|
+
trigger.focus({ preventScroll: true });
|
|
6164
|
+
trigger.scrollIntoView({ block: "nearest" });
|
|
6165
|
+
const row = trigger.closest("[data-slot=object-list-entry]");
|
|
6166
|
+
row?.setAttribute("data-revealed", "");
|
|
6167
|
+
window.setTimeout(() => row?.removeAttribute("data-revealed"), 2e3);
|
|
6168
|
+
}, [
|
|
6169
|
+
deleteFocus.frameRef,
|
|
6170
|
+
list.entries,
|
|
6171
|
+
list.isLoading,
|
|
6172
|
+
list.isRefreshing,
|
|
6173
|
+
list.isSearching,
|
|
6174
|
+
store
|
|
6175
|
+
]);
|
|
6176
|
+
const opensFiles = onOpenItem != null;
|
|
6177
|
+
const folderUploads = upload != null && list.uploadOptions != null;
|
|
6178
|
+
const canDownload = download != null;
|
|
6179
|
+
const canShare = share != null || download?.mode === "navigate";
|
|
6180
|
+
const canDelete = del != null;
|
|
6181
|
+
const renameFile = list.renameFile != null;
|
|
6182
|
+
const renameFolder = list.renameFolder != null;
|
|
6183
|
+
const currentSearch = list.isSearching ? list.search.trim() : "";
|
|
6184
|
+
const [search, setShownSearch] = useState(currentSearch);
|
|
6185
|
+
if (!list.isLoading && !list.isRefreshing && search !== currentSearch) {
|
|
6186
|
+
setShownSearch(currentSearch);
|
|
6187
|
+
}
|
|
6188
|
+
const scope = useMemo(
|
|
6189
|
+
() => ({
|
|
6190
|
+
store,
|
|
6191
|
+
selectable: selectableKeys,
|
|
6192
|
+
opensFiles,
|
|
6193
|
+
folderUploads,
|
|
6194
|
+
download: canDownload,
|
|
6195
|
+
share: canShare,
|
|
6196
|
+
delete: canDelete,
|
|
6197
|
+
renameFile,
|
|
6198
|
+
renameFolder,
|
|
6199
|
+
search,
|
|
6200
|
+
open,
|
|
6201
|
+
toggle,
|
|
6202
|
+
folderDropTarget,
|
|
6203
|
+
startRename,
|
|
6204
|
+
endRename,
|
|
6205
|
+
revealEntry,
|
|
6206
|
+
renderActions,
|
|
6207
|
+
renderDescription,
|
|
6208
|
+
renderMeta
|
|
6209
|
+
}),
|
|
6210
|
+
[
|
|
6211
|
+
canDelete,
|
|
6212
|
+
canDownload,
|
|
6213
|
+
canShare,
|
|
6214
|
+
endRename,
|
|
6215
|
+
folderDropTarget,
|
|
6216
|
+
folderUploads,
|
|
6217
|
+
open,
|
|
6218
|
+
opensFiles,
|
|
6219
|
+
renameFile,
|
|
6220
|
+
renameFolder,
|
|
6221
|
+
renderActions,
|
|
6222
|
+
renderDescription,
|
|
6223
|
+
renderMeta,
|
|
6224
|
+
revealEntry,
|
|
6225
|
+
search,
|
|
6226
|
+
selectableKeys,
|
|
6227
|
+
startRename,
|
|
6228
|
+
store,
|
|
6229
|
+
toggle
|
|
6230
|
+
]
|
|
6231
|
+
);
|
|
5113
6232
|
function handleDeleted(result) {
|
|
5114
6233
|
if (result.deleted.length > 0) {
|
|
5115
6234
|
const gone = new Set(result.deleted);
|
|
@@ -5165,18 +6284,36 @@ function ObjectList({
|
|
|
5165
6284
|
}
|
|
5166
6285
|
if (download) content = /* @__PURE__ */ jsx(Download, { download, children: content });
|
|
5167
6286
|
if (upload) content = /* @__PURE__ */ jsx(Upload, { upload, children: content });
|
|
5168
|
-
return /* @__PURE__ */ jsxs(ObjectListProvider, { value: context, children: [
|
|
6287
|
+
return /* @__PURE__ */ jsxs(ObjectListProvider, { value: context, scope, children: [
|
|
5169
6288
|
content,
|
|
5170
6289
|
toasts ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5171
6290
|
upload ? /* @__PURE__ */ jsx(BuiltInUploadToasts, { upload }) : null,
|
|
5172
6291
|
download ? /* @__PURE__ */ jsx(BuiltInDownloadToasts, { download }) : null,
|
|
5173
6292
|
del ? /* @__PURE__ */ jsx(ObjectListDeleteToasts, { delete: del }) : null
|
|
5174
|
-
] }) : /* @__PURE__ */
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
6293
|
+
] }) : del ? /* @__PURE__ */ jsx(ObjectListDeleteToasts, { delete: del, report: announce }) : null,
|
|
6294
|
+
/* @__PURE__ */ jsx(
|
|
6295
|
+
ObjectListAnnouncer,
|
|
6296
|
+
{
|
|
6297
|
+
announcement,
|
|
6298
|
+
status: selectionCount,
|
|
6299
|
+
search: searchStatus?.settled ? searchStatus.label : null
|
|
6300
|
+
}
|
|
6301
|
+
)
|
|
5178
6302
|
] });
|
|
5179
6303
|
}
|
|
6304
|
+
var NO_KEYS = /* @__PURE__ */ new Set();
|
|
6305
|
+
function useSelectableKeys(entries, selection) {
|
|
6306
|
+
const keys = selection ? entries.flatMap(
|
|
6307
|
+
(entry) => selection.canSelect(entry) ? [entry.key] : []
|
|
6308
|
+
) : [];
|
|
6309
|
+
const [kept, setKept] = useState(() => new Set(keys));
|
|
6310
|
+
if (kept.size === keys.length && keys.every((key) => kept.has(key))) {
|
|
6311
|
+
return kept;
|
|
6312
|
+
}
|
|
6313
|
+
const next = new Set(keys);
|
|
6314
|
+
setKept(next);
|
|
6315
|
+
return next;
|
|
6316
|
+
}
|
|
5180
6317
|
function useFocusAfterDelete() {
|
|
5181
6318
|
const frameRef = useRef(null);
|
|
5182
6319
|
const lastFocusRef = useRef(null);
|
|
@@ -5218,8 +6355,15 @@ function ObjectListFrame({
|
|
|
5218
6355
|
style,
|
|
5219
6356
|
children
|
|
5220
6357
|
}) {
|
|
5221
|
-
const { list, selection, upload, view, label, sizing } = useObjectListContext();
|
|
5222
|
-
const
|
|
6358
|
+
const { list, selection, upload, view, label, sizing, startRename } = useObjectListContext();
|
|
6359
|
+
const { store } = useObjectListEntryScope();
|
|
6360
|
+
const keyboard = useObjectListKeyboard({
|
|
6361
|
+
list,
|
|
6362
|
+
selection,
|
|
6363
|
+
view,
|
|
6364
|
+
store,
|
|
6365
|
+
startRename
|
|
6366
|
+
});
|
|
5223
6367
|
const busy = list.isLoading || list.isRefreshing || list.isLoadingMore;
|
|
5224
6368
|
const call = folderUploadCall(list, list.parent);
|
|
5225
6369
|
const takesFiles = upload != null && !upload.disabled;
|
|
@@ -5264,7 +6408,10 @@ function ObjectListFrame({
|
|
|
5264
6408
|
className
|
|
5265
6409
|
),
|
|
5266
6410
|
style,
|
|
5267
|
-
onFocus
|
|
6411
|
+
onFocus: (event) => {
|
|
6412
|
+
onFocus(event);
|
|
6413
|
+
keyboard.onFocus(event);
|
|
6414
|
+
},
|
|
5268
6415
|
onPaste,
|
|
5269
6416
|
onDragEnter: (event) => {
|
|
5270
6417
|
if (!takesFiles) return;
|
|
@@ -5320,157 +6467,6 @@ function cssLength(value) {
|
|
|
5320
6467
|
const trimmed = value.trim();
|
|
5321
6468
|
return trimmed.length > 0 ? trimmed : void 0;
|
|
5322
6469
|
}
|
|
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
6470
|
function ObjectListSortMenu({
|
|
5475
6471
|
options,
|
|
5476
6472
|
className
|
|
@@ -5589,6 +6585,6 @@ function ObjectListViewToggle({ className }) {
|
|
|
5589
6585
|
);
|
|
5590
6586
|
}
|
|
5591
6587
|
|
|
5592
|
-
export { AttachmentAction, AttachmentGroup, AttachmentTrigger, AvatarUpload, CircleProgress, Delete, DeleteConfirmDialog, DeleteToasts, DeleteTrigger, DismissAttachmentAction, Download, DownloadProgress, DownloadToasts, DownloadTrigger, FileAttachment, FileName, FileTypeGlyph, FolderGlyph,
|
|
6588
|
+
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, useObjectListContext, useObjectListEntry, usePasteFiles, useToastOwner, useUploadContext, useUploadFieldContext, useUploadHints };
|
|
5593
6589
|
//# sourceMappingURL=index.js.map
|
|
5594
6590
|
//# sourceMappingURL=index.js.map
|