@widgetic/file-browser 0.5.45 → 0.5.47
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/dist/components/core/Dropzone.svelte +15 -28
- package/dist/components/core/FileBrowser.svelte +111 -128
- package/dist/components/core/FileUploader.svelte +10 -13
- package/dist/components/core/Header.svelte +30 -39
- package/dist/components/core/RecentFiles.svelte +27 -40
- package/dist/components/core/RecentFiles.svelte.d.ts +2 -0
- package/dist/components/core/SearchDropdown.svelte +88 -26
- package/dist/components/core/SearchDropdown.svelte.d.ts +2 -0
- package/dist/components/core/UploadPanel.svelte +19 -24
- package/dist/components/previews/FilePreview.svelte +26 -50
- package/dist/components/previews/PreviewHeaderBar.svelte +1 -1
- package/dist/i18n/messages.d.ts +2 -1
- package/dist/i18n/messages.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/types.d.ts +2 -0
- package/dist/utils/brandKitLibraryTree.d.ts +23 -0
- package/dist/utils/brandKitLibraryTree.js +135 -0
- package/dist/utils/fileOperations.js +2 -3
- package/dist/utils/gridLayout.d.ts +14 -1
- package/dist/utils/gridLayout.js +27 -2
- package/dist/utils/libraryTree.js +13 -2
- package/dist/utils/previewListNavigation.d.ts +10 -0
- package/dist/utils/previewListNavigation.js +39 -0
- package/dist/utils/recentFilesLimit.js +2 -5
- package/dist/utils/searchDropdownPhase.d.ts +17 -0
- package/dist/utils/searchDropdownPhase.js +23 -0
- package/dist/utils/uploadPanelDismiss.d.ts +13 -0
- package/dist/utils/uploadPanelDismiss.js +11 -0
- package/dist/utils/widgeticUpload.js +2 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Figma: Dropzone (component set 271:971, page File Browser)
|
|
3
3
|
-->
|
|
4
4
|
<script lang="ts">
|
|
5
|
-
import { Button, IconButton,
|
|
5
|
+
import { Button, IconButton, HintTooltip } from '@widgetic/design-system/components';
|
|
6
6
|
import { IconCloudUpload, IconHelp } from '@widgetic/design-system/icons';
|
|
7
7
|
import { useI18n } from '../../i18n/context';
|
|
8
8
|
import { splitAround } from '../../i18n/text';
|
|
@@ -128,33 +128,20 @@
|
|
|
128
128
|
{/if}
|
|
129
129
|
</div>
|
|
130
130
|
|
|
131
|
-
<div class="absolute end-4 top-
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
<
|
|
135
|
-
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
{/snippet}
|
|
146
|
-
</Tooltip.Trigger>
|
|
147
|
-
<Tooltip.Portal>
|
|
148
|
-
<Tooltip.Content
|
|
149
|
-
side="top"
|
|
150
|
-
sideOffset={8}
|
|
151
|
-
class="max-w-[250px] whitespace-pre-line break-words"
|
|
152
|
-
>
|
|
153
|
-
<p class="text-caption">{tooltipTypesText}</p>
|
|
154
|
-
</Tooltip.Content>
|
|
155
|
-
</Tooltip.Portal>
|
|
156
|
-
</Tooltip.Root>
|
|
157
|
-
</Tooltip.Provider>
|
|
131
|
+
<div class="absolute end-4 top-4 z-[2]">
|
|
132
|
+
<HintTooltip content={tooltipTypesText} side="top" sideOffset={8} contentClass="max-w-[250px]">
|
|
133
|
+
{#snippet trigger({ props })}
|
|
134
|
+
<IconButton
|
|
135
|
+
{...props}
|
|
136
|
+
variant="ghost"
|
|
137
|
+
size="default"
|
|
138
|
+
class="fb-dropzone-help size-8 text-muted-foreground hover:text-foreground"
|
|
139
|
+
label={tooltipTypesText}
|
|
140
|
+
>
|
|
141
|
+
<IconHelp class="size-4 stroke-2" aria-hidden="true" />
|
|
142
|
+
</IconButton>
|
|
143
|
+
{/snippet}
|
|
144
|
+
</HintTooltip>
|
|
158
145
|
</div>
|
|
159
146
|
</div>
|
|
160
147
|
|
|
@@ -21,7 +21,22 @@
|
|
|
21
21
|
import '@widgetic/design-system/styles';
|
|
22
22
|
|
|
23
23
|
// Design system components
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
Alert,
|
|
26
|
+
Button,
|
|
27
|
+
DebugGrid,
|
|
28
|
+
WScrollArea,
|
|
29
|
+
EmptyState,
|
|
30
|
+
ErrorState,
|
|
31
|
+
ActionModal,
|
|
32
|
+
DropdownMenu,
|
|
33
|
+
FilterByButton,
|
|
34
|
+
SortDirectionButton,
|
|
35
|
+
HintTooltip,
|
|
36
|
+
toast,
|
|
37
|
+
type FilterByOption,
|
|
38
|
+
type SortDirection
|
|
39
|
+
} from '@widgetic/design-system/components';
|
|
25
40
|
import {
|
|
26
41
|
IconCheck,
|
|
27
42
|
IconPhoto,
|
|
@@ -35,8 +50,7 @@
|
|
|
35
50
|
IconFileUnknown,
|
|
36
51
|
IconInfoCircle,
|
|
37
52
|
IconArrowUp,
|
|
38
|
-
IconArrowDown
|
|
39
|
-
IconChevronDown
|
|
53
|
+
IconArrowDown
|
|
40
54
|
} from '@widgetic/design-system/icons';
|
|
41
55
|
|
|
42
56
|
// LOCAL COMPONENT IMPORTS
|
|
@@ -49,6 +63,7 @@
|
|
|
49
63
|
import { VirtualList, DragSelect, ControlToolbar } from '../ui';
|
|
50
64
|
import TileSkeleton from '../ui/TileSkeleton.svelte';
|
|
51
65
|
import { gridColumnsForWidth } from '../../utils/gridLayout';
|
|
66
|
+
import { previewNavigationFiles } from '../../utils/previewListNavigation';
|
|
52
67
|
|
|
53
68
|
// TYPE IMPORTS
|
|
54
69
|
import type { FileSystemItem, FileSystemRoot, FolderItemWithCount } from '../../types';
|
|
@@ -432,7 +447,8 @@
|
|
|
432
447
|
let contentContainer: HTMLElement | null = null;
|
|
433
448
|
|
|
434
449
|
// Add near other state variables
|
|
435
|
-
let previewSource: 'main' | 'recent' = 'main';
|
|
450
|
+
let previewSource: 'main' | 'recent' | 'search' = 'main';
|
|
451
|
+
let previewNavigationList: FileSystemItem[] = [];
|
|
436
452
|
|
|
437
453
|
// Add near other state variables
|
|
438
454
|
let tabletBreakpoint = 744; // Default value
|
|
@@ -659,7 +675,7 @@
|
|
|
659
675
|
}
|
|
660
676
|
|
|
661
677
|
/**
|
|
662
|
-
* Renames a file in the host's library
|
|
678
|
+
* Renames a file in the list at once and in the host's library right after; the old name comes back when the library refuses.
|
|
663
679
|
* Resolves `false` when there was nothing to change; throws a MediaLibraryError when the library refuses.
|
|
664
680
|
*/
|
|
665
681
|
async function renameInLibrary(itemId: string, newName: string): Promise<boolean> {
|
|
@@ -674,15 +690,31 @@
|
|
|
674
690
|
const finalName = item.type === 'file' ? getRenamedFileName(item.name, typedName) : typedName;
|
|
675
691
|
if (finalName === item.name) return false;
|
|
676
692
|
|
|
677
|
-
|
|
678
|
-
//
|
|
693
|
+
// The list shows the new name at once (the Recent files strip follows it, being built from the same list); the library is told
|
|
694
|
+
// in the same breath, and when it refuses the old name is put back.
|
|
695
|
+
const renamedLocally: FileSystemItem = { ...item, name: finalName, modified: new Date().toISOString() };
|
|
696
|
+
fileStore.update((store) => ({ ...store, root: replaceFile(store.root, itemId, renamedLocally) }));
|
|
697
|
+
selectedFiles.update((files) => files.map((file) => (file.id === itemId ? renamedLocally : file)));
|
|
698
|
+
|
|
699
|
+
let renamedFile: FileSystemItem | void;
|
|
700
|
+
try {
|
|
701
|
+
renamedFile = await library.rename({ id: itemId, name: finalName, signal: libraryActionsController.signal });
|
|
702
|
+
} catch (renameError) {
|
|
703
|
+
// The File Browser was closed while the library was working: its list is no longer ours to change.
|
|
704
|
+
if (!libraryActionsController.signal.aborted) {
|
|
705
|
+
fileStore.update((store) => ({ ...store, root: replaceFile(store.root, itemId, item) }));
|
|
706
|
+
selectedFiles.update((files) => files.map((file) => (file.id === itemId ? item : file)));
|
|
707
|
+
}
|
|
708
|
+
throw renameError;
|
|
709
|
+
}
|
|
679
710
|
if (libraryActionsController.signal.aborted) return false;
|
|
680
711
|
|
|
681
712
|
// The library may answer with the file as it is now (it can change the address or the id). When it only says
|
|
682
|
-
// "done", the file
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
713
|
+
// "done", the file keeps the name it already shows.
|
|
714
|
+
if (renamedFile) {
|
|
715
|
+
fileStore.update((store) => ({ ...store, root: replaceFile(store.root, itemId, renamedFile as FileSystemItem) }));
|
|
716
|
+
selectedFiles.update((files) => files.map((file) => (file.id === itemId ? (renamedFile as FileSystemItem) : file)));
|
|
717
|
+
}
|
|
686
718
|
return true;
|
|
687
719
|
}
|
|
688
720
|
|
|
@@ -1056,13 +1088,21 @@
|
|
|
1056
1088
|
|
|
1057
1089
|
// If there's a preview item, handle it the same way for both search and selected files
|
|
1058
1090
|
if (event.detail.preview) {
|
|
1091
|
+
const previewNavigationFromSearch = Array.isArray(event.detail.previewNavigationList)
|
|
1092
|
+
? event.detail.previewNavigationList
|
|
1093
|
+
: [];
|
|
1094
|
+
previewNavigationList =
|
|
1095
|
+
previewNavigationFromSearch.length > 0
|
|
1096
|
+
? previewNavigationFromSearch
|
|
1097
|
+
: previewNavigationFiles(sortedFilteredFiles);
|
|
1098
|
+
previewSource = previewNavigationFromSearch.length > 0 ? 'search' : 'main';
|
|
1059
1099
|
// Wait for the folder content to update
|
|
1060
1100
|
setTimeout(() => {
|
|
1061
1101
|
const file = event.detail.preview;
|
|
1062
1102
|
previewFile = file; // Open preview
|
|
1063
1103
|
scrollItemIntoView(file.id); // Scroll into view
|
|
1064
1104
|
}, 100);
|
|
1065
|
-
}
|
|
1105
|
+
}
|
|
1066
1106
|
}
|
|
1067
1107
|
|
|
1068
1108
|
/**
|
|
@@ -1307,6 +1347,7 @@
|
|
|
1307
1347
|
const file = event.detail;
|
|
1308
1348
|
previewFile = file;
|
|
1309
1349
|
previewSource = 'recent';
|
|
1350
|
+
previewNavigationList = recentFiles;
|
|
1310
1351
|
// No scrolling for recent files
|
|
1311
1352
|
}
|
|
1312
1353
|
|
|
@@ -1361,6 +1402,7 @@
|
|
|
1361
1402
|
function handleFileClick(file: FileSystemItem) {
|
|
1362
1403
|
previewFile = file;
|
|
1363
1404
|
previewSource = 'main';
|
|
1405
|
+
previewNavigationList = previewNavigationFiles(sortedFilteredFiles);
|
|
1364
1406
|
// Wait for the preview modal to open before scrolling
|
|
1365
1407
|
setTimeout(() => {
|
|
1366
1408
|
scrollItemIntoView(file.id);
|
|
@@ -1388,7 +1430,8 @@
|
|
|
1388
1430
|
}
|
|
1389
1431
|
setTimeout(() => {
|
|
1390
1432
|
previewFile = null;
|
|
1391
|
-
previewSource = 'main';
|
|
1433
|
+
previewSource = 'main';
|
|
1434
|
+
previewNavigationList = [];
|
|
1392
1435
|
}, 200);
|
|
1393
1436
|
}
|
|
1394
1437
|
}
|
|
@@ -1614,9 +1657,7 @@
|
|
|
1614
1657
|
|
|
1615
1658
|
// Store the item's ID before resetting selection
|
|
1616
1659
|
const itemId = selectedItem.id;
|
|
1617
|
-
const
|
|
1618
|
-
// The name the item ends up with: the dialog edits a file without its extension, which is always kept
|
|
1619
|
-
const finalName = selectedItem.type === 'file' ? getRenamedFileName(selectedItem.name, newName.trim()) : newName.trim();
|
|
1660
|
+
const renamedKind = selectedItem.type;
|
|
1620
1661
|
|
|
1621
1662
|
// Close the dialog and reset selection immediately to prevent UI blocking
|
|
1622
1663
|
showRenameDialog = false;
|
|
@@ -1624,12 +1665,6 @@
|
|
|
1624
1665
|
|
|
1625
1666
|
// console.log('call showToast method:', showToast);
|
|
1626
1667
|
|
|
1627
|
-
// Show initial toast notification
|
|
1628
|
-
showToast('success', $t('toast.rename.started', { name: oldName }), {
|
|
1629
|
-
description: $t('toast.inBackground'),
|
|
1630
|
-
// duration: 1500
|
|
1631
|
-
});
|
|
1632
|
-
|
|
1633
1668
|
// Perform the rename operation (through the host's media library when there is one)
|
|
1634
1669
|
(libraryMode ? renameInLibrary(itemId, newName) : renameItem(itemId, newName))
|
|
1635
1670
|
.then(success => {
|
|
@@ -1638,9 +1673,9 @@
|
|
|
1638
1673
|
if (success) {
|
|
1639
1674
|
// The new name is part of the saved tree of the Widgetic library
|
|
1640
1675
|
persistMyUploadsTree();
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1676
|
+
// Just the fact, with nothing about the background: the new name is already on the screen.
|
|
1677
|
+
if (renamedKind === 'folder') showToast('success', $t('toast.rename.folderDone'));
|
|
1678
|
+
else showToast('success', $t('toast.rename.done'));
|
|
1644
1679
|
} else {
|
|
1645
1680
|
showToast('error', $t('toast.rename.failed'), {
|
|
1646
1681
|
description: $t('toast.rename.noChange'),
|
|
@@ -2340,7 +2375,13 @@
|
|
|
2340
2375
|
updateFolderCounts($fileStore.root, filter);
|
|
2341
2376
|
}
|
|
2342
2377
|
|
|
2343
|
-
$: currentViewFiles = sortedFilteredFiles
|
|
2378
|
+
$: currentViewFiles = previewNavigationFiles(sortedFilteredFiles);
|
|
2379
|
+
$: previewListForModal =
|
|
2380
|
+
previewSource === 'recent'
|
|
2381
|
+
? recentFiles
|
|
2382
|
+
: previewSource === 'search' && previewNavigationList.length > 0
|
|
2383
|
+
? previewNavigationList
|
|
2384
|
+
: currentViewFiles;
|
|
2344
2385
|
|
|
2345
2386
|
// Add this reactive statement to update folderStructure
|
|
2346
2387
|
$: {
|
|
@@ -2801,6 +2842,14 @@
|
|
|
2801
2842
|
};
|
|
2802
2843
|
|
|
2803
2844
|
let filterOptions: FilterOptionRow[] = [];
|
|
2845
|
+
$: filterByOptions = filterOptions.map(
|
|
2846
|
+
(option): FilterByOption => ({
|
|
2847
|
+
value: option.value,
|
|
2848
|
+
label: option.label,
|
|
2849
|
+
icon: option.icon as unknown as FilterByOption['icon']
|
|
2850
|
+
})
|
|
2851
|
+
);
|
|
2852
|
+
$: filterByLabel = $t('filter.by', { type: '\u0001' }).split('\u0001')[0].trim();
|
|
2804
2853
|
$: filterOptions = [
|
|
2805
2854
|
{ value: 'all', label: $t('filterOption.all'), icon: IconFiles },
|
|
2806
2855
|
{ value: 'image', label: $t('filterOption.image'), icon: IconPhoto },
|
|
@@ -2833,6 +2882,12 @@
|
|
|
2833
2882
|
{ value: 'date', labelKey: 'sort.date' },
|
|
2834
2883
|
{ value: 'size', labelKey: 'sort.size' }
|
|
2835
2884
|
] as const;
|
|
2885
|
+
$: sortByOptions = sortOptions.map(
|
|
2886
|
+
(option): FilterByOption => ({
|
|
2887
|
+
value: option.value,
|
|
2888
|
+
label: $t(option.labelKey)
|
|
2889
|
+
})
|
|
2890
|
+
);
|
|
2836
2891
|
|
|
2837
2892
|
// Replace the existing reactive statement for filter
|
|
2838
2893
|
$: {
|
|
@@ -3048,11 +3103,11 @@ mainGridClass="app-main-grid"
|
|
|
3048
3103
|
title={libraryMode ? (resolvedMediaLibrary?.hasOwnLabel ? resolvedMediaLibrary.label : $t('library.defaultLabel')) : ''}
|
|
3049
3104
|
/>
|
|
3050
3105
|
|
|
3051
|
-
<!-- FILE BROWSER CONTROLS: Figma —
|
|
3106
|
+
<!-- FILE BROWSER CONTROLS: Figma — one row: search (flex-1), filter, sort, direction (291:1973) -->
|
|
3052
3107
|
<div
|
|
3053
|
-
class="file-browser-controls flex min-w-0 shrink-0 flex-
|
|
3108
|
+
class="file-browser-controls flex min-w-0 shrink-0 flex-nowrap max-[640px]:flex-wrap items-center gap-2 pb-4 {controlsTopPaddingClass} {edgePaddingClass}"
|
|
3054
3109
|
>
|
|
3055
|
-
<div class="search-bar-container relative z-[61] w-full min-w-
|
|
3110
|
+
<div class="search-bar-container relative z-[61] min-w-0 w-full min-w-[min(100%,280px)] flex-1 basis-[280px]">
|
|
3056
3111
|
<SearchDropdown
|
|
3057
3112
|
root={$fileStore.root}
|
|
3058
3113
|
currentFilter={filter}
|
|
@@ -3063,112 +3118,38 @@ mainGridClass="app-main-grid"
|
|
|
3063
3118
|
</div>
|
|
3064
3119
|
|
|
3065
3120
|
{#if controlsShowFilters || controlsShowSorting}
|
|
3066
|
-
<div class="controls-container flex min-w-0 max-w-full items-center gap-2
|
|
3121
|
+
<div class="controls-container flex min-w-0 max-w-full shrink-0 flex-wrap items-center gap-2">
|
|
3067
3122
|
|
|
3068
3123
|
{#if controlsShowFilters}
|
|
3069
3124
|
<div class="filter-controls-container relative z-10 flex items-center">
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
<!-- One arrow that turns up while the menu is open, with the motion of the accordion's arrow (it used to swap two icons and jumped). -->
|
|
3079
|
-
<IconChevronDown class="size-4 shrink-0 stroke-2 opacity-50 transition-transform duration-base group-data-[state=open]:rotate-180" aria-hidden="true" />
|
|
3080
|
-
</DropdownMenu.Trigger>
|
|
3081
|
-
<DropdownMenu.Content side="bottom" align="start" class="filter-dropdown w-[12.5rem] min-w-0">
|
|
3082
|
-
{#each filterOptions as option}
|
|
3083
|
-
{@const OptionIcon = option.icon}
|
|
3084
|
-
<DropdownMenu.Item
|
|
3085
|
-
class="filter-dropdown-item relative flex w-full items-center gap-2 rounded-lg px-2 py-1.5 ps-8 {filter === option.value ? 'bg-brand-subtle' : ''} data-highlighted:bg-accent"
|
|
3086
|
-
onclick={() => handleFilterChange(option.value as FileFilterType)}
|
|
3087
|
-
>
|
|
3088
|
-
<!-- The check slot: only the chosen option shows the check -->
|
|
3089
|
-
<span class="absolute start-2 flex size-4 items-center justify-center">
|
|
3090
|
-
{#if filter === option.value}
|
|
3091
|
-
<IconCheck class="size-4 stroke-2 text-foreground" aria-hidden="true" />
|
|
3092
|
-
{/if}
|
|
3093
|
-
</span>
|
|
3094
|
-
<OptionIcon class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
3095
|
-
<span class="text-body min-w-0 flex-1 truncate">{option.label}</span>
|
|
3096
|
-
</DropdownMenu.Item>
|
|
3097
|
-
{/each}
|
|
3098
|
-
</DropdownMenu.Content>
|
|
3099
|
-
</DropdownMenu.Root>
|
|
3100
|
-
{/key}
|
|
3125
|
+
<FilterByButton
|
|
3126
|
+
class="filter-button"
|
|
3127
|
+
label={filterByLabel}
|
|
3128
|
+
options={filterByOptions}
|
|
3129
|
+
value={filter}
|
|
3130
|
+
onValueChange={(next: string) => handleFilterChange(next as FileFilterType)}
|
|
3131
|
+
menuClass="filter-dropdown"
|
|
3132
|
+
/>
|
|
3101
3133
|
</div>
|
|
3102
3134
|
{/if}
|
|
3103
3135
|
|
|
3104
3136
|
{#if controlsShowSorting}
|
|
3105
3137
|
<div class="sort-controls-container flex items-center gap-2">
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
<!-- The check slot: only the chosen option shows the check -->
|
|
3122
|
-
<span class="absolute start-2 flex size-4 items-center justify-center">
|
|
3123
|
-
{#if $sortCriteria === option.value}
|
|
3124
|
-
<IconCheck class="size-4 stroke-2 text-foreground" aria-hidden="true" />
|
|
3125
|
-
{/if}
|
|
3126
|
-
</span>
|
|
3127
|
-
<span class="text-body">{$t(option.labelKey)}</span>
|
|
3128
|
-
</DropdownMenu.Item>
|
|
3129
|
-
{/each}
|
|
3130
|
-
</DropdownMenu.Content>
|
|
3131
|
-
</DropdownMenu.Root>
|
|
3132
|
-
{/key}
|
|
3133
|
-
|
|
3134
|
-
<Tooltip.Provider delayDuration={200}>
|
|
3135
|
-
<Tooltip.Root>
|
|
3136
|
-
<Tooltip.Trigger class="inline-flex">
|
|
3137
|
-
<!-- The trigger hands its props to the button itself: a button inside the trigger's own button is not valid HTML -->
|
|
3138
|
-
{#snippet child({ props }: { props: Record<string, unknown> })}
|
|
3139
|
-
<IconButton
|
|
3140
|
-
{...props}
|
|
3141
|
-
variant="outline"
|
|
3142
|
-
size="default"
|
|
3143
|
-
class="sort-order-button size-9"
|
|
3144
|
-
label={$sortDirection === 'asc' ? $t('sort.orderDescending') : $t('sort.orderAscending')}
|
|
3145
|
-
onclick={(event: MouseEvent) => {
|
|
3146
|
-
// The trigger's own click handler closes the tooltip, so it runs too
|
|
3147
|
-
(props.onclick as ((event: MouseEvent) => void) | undefined)?.(event);
|
|
3148
|
-
toggleSortDirection();
|
|
3149
|
-
}}
|
|
3150
|
-
>
|
|
3151
|
-
{#if $sortDirection === 'asc'}
|
|
3152
|
-
<IconArrowUp class="size-4 stroke-2" aria-hidden="true" />
|
|
3153
|
-
{:else}
|
|
3154
|
-
<IconArrowDown class="size-4 stroke-2" aria-hidden="true" />
|
|
3155
|
-
{/if}
|
|
3156
|
-
</IconButton>
|
|
3157
|
-
{/snippet}
|
|
3158
|
-
</Tooltip.Trigger>
|
|
3159
|
-
<Tooltip.Portal>
|
|
3160
|
-
<!-- Opens above the button. The page portal paints it over the module box. -->
|
|
3161
|
-
<Tooltip.Content
|
|
3162
|
-
side="top"
|
|
3163
|
-
align="end"
|
|
3164
|
-
sideOffset={8}
|
|
3165
|
-
class="sort-order-tooltip bg-foreground text-background z-[99999] whitespace-pre-line rounded-lg px-2 py-1 text-center text-caption"
|
|
3166
|
-
>
|
|
3167
|
-
{$sortDirection === 'asc' ? $t('sort.orderDescending') : $t('sort.orderAscending')}
|
|
3168
|
-
</Tooltip.Content>
|
|
3169
|
-
</Tooltip.Portal>
|
|
3170
|
-
</Tooltip.Root>
|
|
3171
|
-
</Tooltip.Provider>
|
|
3138
|
+
<FilterByButton
|
|
3139
|
+
class="sort-button"
|
|
3140
|
+
label={$t('sort.by')}
|
|
3141
|
+
options={sortByOptions}
|
|
3142
|
+
value={$sortCriteria}
|
|
3143
|
+
onValueChange={(next: string) => sortCriteria.set(next as 'name' | 'date' | 'size')}
|
|
3144
|
+
menuClass="sort-dropdown w-40"
|
|
3145
|
+
/>
|
|
3146
|
+
<SortDirectionButton
|
|
3147
|
+
class="sort-order-button"
|
|
3148
|
+
direction={$sortDirection}
|
|
3149
|
+
onDirectionChange={(next: SortDirection) => sortDirection.set(next)}
|
|
3150
|
+
ariaLabel={$sortDirection === 'asc' ? $t('sort.orderDescending') : $t('sort.orderAscending')}
|
|
3151
|
+
tooltipLabel={$sortDirection === 'asc' ? $t('sort.orderDescending') : $t('sort.orderAscending')}
|
|
3152
|
+
/>
|
|
3172
3153
|
</div>
|
|
3173
3154
|
{/if}
|
|
3174
3155
|
</div>
|
|
@@ -3314,6 +3295,7 @@ mainGridClass="app-main-grid"
|
|
|
3314
3295
|
<RecentFiles class="recent-files-container"
|
|
3315
3296
|
{recentFiles}
|
|
3316
3297
|
visibleLimit={numberOfRecentFiles}
|
|
3298
|
+
containerWidth={mainContainerWidth}
|
|
3317
3299
|
selectedFiles={allSelectedFiles}
|
|
3318
3300
|
currentFilter={filter}
|
|
3319
3301
|
{allowSelecting}
|
|
@@ -3321,6 +3303,7 @@ mainGridClass="app-main-grid"
|
|
|
3321
3303
|
on:fileClick={handleRecentFileClick}
|
|
3322
3304
|
on:select={handleRecentFileSelect}
|
|
3323
3305
|
on:action={handleRecentFileAction}
|
|
3306
|
+
on:delete={handleDelete}
|
|
3324
3307
|
/>
|
|
3325
3308
|
{/if}
|
|
3326
3309
|
|
|
@@ -3436,7 +3419,7 @@ mainGridClass="app-main-grid"
|
|
|
3436
3419
|
{allowSelecting}
|
|
3437
3420
|
{showAddToEditor}
|
|
3438
3421
|
currentFilter={filter}
|
|
3439
|
-
currentFiles={
|
|
3422
|
+
currentFiles={previewListForModal}
|
|
3440
3423
|
target={rootContainerClass}
|
|
3441
3424
|
on:select={(event : any) => handleFileSelect(event.detail)}
|
|
3442
3425
|
on:navigate={handlePreviewNavigate}
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
import { buildActiveRowStatusText, formatUploadPercent, type UploadPhase, updateThroughputEstimateState } from '../../utils/uploadUiHelpers';
|
|
42
42
|
import { monotonicDisplayProgress } from '../../utils/uploadDisplayProgress';
|
|
43
43
|
import { monotonicPanelProgress, nextUploadPanelPeak } from '../../utils/uploadPanelProgress';
|
|
44
|
+
import { shouldDismissUploadPanel } from '../../utils/uploadPanelDismiss';
|
|
44
45
|
|
|
45
46
|
// The host's media library, when the File Browser was given one. It then stores the files, instead of the
|
|
46
47
|
// Widgetic upload settings.
|
|
@@ -1102,23 +1103,19 @@
|
|
|
1102
1103
|
}
|
|
1103
1104
|
}
|
|
1104
1105
|
|
|
1105
|
-
/**
|
|
1106
|
+
/**
|
|
1107
|
+
* After uploads finish, close the dim overlay so the file grid is usable again.
|
|
1108
|
+
* Only when every file went through: a batch with a failed file keeps the panel open, so the person sees which ones failed
|
|
1109
|
+
* and can ask for another try (the summary and footer retry buttons, or the retry of a single file).
|
|
1110
|
+
*/
|
|
1106
1111
|
function scheduleUploadDrawerDismiss() {
|
|
1107
|
-
|
|
1108
|
-
(item) => item.status === 'complete' || item.status === 'failed',
|
|
1109
|
-
);
|
|
1110
|
-
if (!allDone) return;
|
|
1112
|
+
if (!shouldDismissUploadPanel(uploadItems)) return;
|
|
1111
1113
|
setTimeout(() => {
|
|
1112
|
-
|
|
1113
|
-
(item) => item.status === 'complete' || item.status === 'failed',
|
|
1114
|
-
);
|
|
1115
|
-
if (!stillDone) return;
|
|
1114
|
+
if (!shouldDismissUploadPanel(uploadItems)) return;
|
|
1116
1115
|
isUploadsModalOpen = false;
|
|
1117
1116
|
isUploadsDrawerCollapsed = true;
|
|
1118
|
-
uploadItems =
|
|
1119
|
-
|
|
1120
|
-
dispatch('uploadsCleared');
|
|
1121
|
-
}
|
|
1117
|
+
uploadItems = [];
|
|
1118
|
+
dispatch('uploadsCleared');
|
|
1122
1119
|
}, 600);
|
|
1123
1120
|
}
|
|
1124
1121
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
4
|
|
|
5
5
|
// Design system imports
|
|
6
|
-
import { Breadcrumbs, IconButton, Badge,
|
|
6
|
+
import { Breadcrumbs, IconButton, Badge, HintTooltip } from '@widgetic/design-system/components';
|
|
7
7
|
import { IconFiles } from '@widgetic/design-system/icons';
|
|
8
8
|
|
|
9
9
|
// Local stores imports
|
|
@@ -105,45 +105,36 @@
|
|
|
105
105
|
|
|
106
106
|
{#if showSelectedFiles && selectedFilesCount > 0}
|
|
107
107
|
<div class="header-actions-container flex shrink-0 items-center">
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
</IconButton>
|
|
133
|
-
{/snippet}
|
|
134
|
-
</Tooltip.Trigger>
|
|
135
|
-
<Tooltip.Portal>
|
|
136
|
-
<Tooltip.Content
|
|
137
|
-
side="bottom"
|
|
138
|
-
align="end"
|
|
139
|
-
sideOffset={6}
|
|
140
|
-
class="selected-files-tooltip bg-foreground text-background text-caption z-[200000] rounded-lg px-2 py-1"
|
|
108
|
+
<HintTooltip
|
|
109
|
+
content={$t('selectedFiles.title')}
|
|
110
|
+
side="bottom"
|
|
111
|
+
align="end"
|
|
112
|
+
sideOffset={6}
|
|
113
|
+
delayDuration={300}
|
|
114
|
+
contentClass="z-[200000]"
|
|
115
|
+
>
|
|
116
|
+
{#snippet trigger({ props })}
|
|
117
|
+
<IconButton
|
|
118
|
+
{...props}
|
|
119
|
+
variant="outline"
|
|
120
|
+
size="default"
|
|
121
|
+
label={$t('selectedFiles.title')}
|
|
122
|
+
class="selected-files-button relative"
|
|
123
|
+
onclick={(event: MouseEvent) => {
|
|
124
|
+
(props.onclick as ((event: MouseEvent) => void) | undefined)?.(event);
|
|
125
|
+
handleToggleSelectedFiles();
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
<IconFiles class="size-4 stroke-2" aria-hidden="true" />
|
|
129
|
+
<Badge
|
|
130
|
+
variant="default"
|
|
131
|
+
class="bg-primary text-primary-foreground absolute -top-1 -end-1 flex h-4 min-w-4 items-center justify-center px-1 text-caption-medium leading-none"
|
|
141
132
|
>
|
|
142
|
-
{
|
|
143
|
-
</
|
|
144
|
-
</
|
|
145
|
-
|
|
146
|
-
</
|
|
133
|
+
{selectedFilesCount}
|
|
134
|
+
</Badge>
|
|
135
|
+
</IconButton>
|
|
136
|
+
{/snippet}
|
|
137
|
+
</HintTooltip>
|
|
147
138
|
</div>
|
|
148
139
|
{/if}
|
|
149
140
|
</header>
|