@widgetic/file-browser 0.5.39 → 0.5.41
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/FolderTree.svelte +1 -1
- package/dist/components/FolderTree.svelte.d.ts +6 -2
- package/dist/components/core/Dropzone.svelte +147 -109
- package/dist/components/core/FileBrowser.svelte +128 -99
- package/dist/components/core/FileBrowser.svelte.d.ts +5 -1
- package/dist/components/core/FileUploader.svelte +80 -51
- package/dist/components/core/Header.svelte +1 -1
- package/dist/components/core/RecentFiles.svelte +23 -11
- package/dist/components/core/RecentFiles.svelte.d.ts +1 -0
- package/dist/components/core/SearchDropdown.svelte +125 -27
- package/dist/components/core/UploadPanel.svelte +2 -2
- package/dist/components/core/UploadRow.svelte +5 -5
- package/dist/components/items/FileItem.svelte +13 -3
- package/dist/components/items/FolderItem.svelte +8 -1
- package/dist/components/modals/MoveDialog.svelte +1 -1
- package/dist/components/modals/SelectedFilesModal.svelte +2 -2
- package/dist/components/modals/index.d.ts +0 -1
- package/dist/components/modals/index.js +0 -1
- package/dist/components/previews/FilePreview.svelte +198 -31
- package/dist/components/previews/FilePreview.svelte.d.ts +1 -0
- package/dist/components/previews/ImagePreview.svelte +60 -31
- package/dist/components/previews/ImagePreview.svelte.d.ts +3 -0
- package/dist/components/previews/PreviewHeaderBar.svelte +34 -26
- package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +2 -0
- package/dist/components/previews/TextPreview.svelte +1 -1
- package/dist/components/previews/VideoPlayer.svelte +4 -4
- package/dist/components/ui/ControlToolbar.svelte +10 -10
- package/dist/components/ui/DragSelect.svelte +85 -67
- package/dist/components/ui/DragSelect.svelte.d.ts +1 -0
- package/dist/components/ui/DropdownMenu.svelte +5 -5
- package/dist/components/ui/FileIcon.svelte +2 -2
- package/dist/data/demoContent.json +13 -11
- package/dist/i18n/messages.d.ts +0 -1
- package/dist/i18n/messages.js +0 -1
- package/dist/stores/fileStore.d.ts +2 -2
- package/dist/stores/navigationStore.d.ts +6 -1
- package/dist/stores/navigationStore.js +40 -67
- package/dist/stores/persistentSelectStore.d.ts +1 -1
- package/dist/utils/escapeSelectionAction.d.ts +18 -0
- package/dist/utils/escapeSelectionAction.js +18 -0
- package/dist/utils/imagePreviewCache.d.ts +16 -0
- package/dist/utils/imagePreviewCache.js +78 -0
- package/dist/utils/imagePreviewVisualState.d.ts +19 -0
- package/dist/utils/imagePreviewVisualState.js +22 -0
- package/dist/utils/menuKeydownBubble.d.ts +9 -0
- package/dist/utils/menuKeydownBubble.js +11 -0
- package/dist/utils/previewNavigation.d.ts +4 -0
- package/dist/utils/previewNavigation.js +17 -0
- package/dist/utils/recentFiles.d.ts +6 -0
- package/dist/utils/recentFiles.js +21 -0
- package/dist/utils/recentFilesLimit.d.ts +8 -0
- package/dist/utils/recentFilesLimit.js +17 -0
- package/dist/utils/searchEscapeAction.d.ts +10 -0
- package/dist/utils/searchEscapeAction.js +12 -0
- package/dist/utils/searchItems.d.ts +2 -4
- package/dist/utils/searchItems.js +12 -5
- package/dist/utils/searchNavigation.d.ts +12 -0
- package/dist/utils/searchNavigation.js +42 -0
- package/dist/utils/uploadDisplayProgress.d.ts +4 -0
- package/dist/utils/uploadDisplayProgress.js +9 -0
- package/dist/utils/uploadPanelProgress.d.ts +5 -0
- package/dist/utils/uploadPanelProgress.js +17 -0
- package/package.json +1 -1
- package/dist/components/modals/SearchModal.svelte +0 -296
- package/dist/components/modals/SearchModal.svelte.d.ts +0 -27
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
import { fetchUserUploadsFromApi } from '../../utils/widgeticUpload';
|
|
77
77
|
import { get, writable } from 'svelte/store';
|
|
78
78
|
import { resolveFileItemUrl } from '../../utils/resolveFileUrl';
|
|
79
|
+
import { buildDeduplicatedRecentFiles } from '../../utils/recentFiles';
|
|
79
80
|
import { dev } from '$app/environment';
|
|
80
81
|
import demoContentData from '../../data/demoContent.json';
|
|
81
82
|
// import { showToast } from '../../utils/toastUtils';
|
|
@@ -102,7 +103,8 @@
|
|
|
102
103
|
createCanGoBackStore,
|
|
103
104
|
createCanGoForwardStore,
|
|
104
105
|
getStorageKey,
|
|
105
|
-
getStoredState
|
|
106
|
+
getStoredState,
|
|
107
|
+
setPersistFolderPath
|
|
106
108
|
} from '../../stores/navigationStore';
|
|
107
109
|
//
|
|
108
110
|
import { persistentSelectStore, validSelections } from '../../stores/persistentSelectStore';
|
|
@@ -117,6 +119,8 @@
|
|
|
117
119
|
import { appendNewFiles, createLibraryRoot, removeFiles, replaceFile, upsertFile } from '../../mediaLibrary/treeOps';
|
|
118
120
|
import type { MediaLibraryErrorCode, MediaLibraryProvider } from '../../mediaLibrary/types';
|
|
119
121
|
import { getRenamedFileName, splitFileName } from '../../utils/fileNames';
|
|
122
|
+
import { escapeSelectionAction } from '../../utils/escapeSelectionAction';
|
|
123
|
+
import { recentFilesLimitForWidth } from '../../utils/recentFilesLimit';
|
|
120
124
|
|
|
121
125
|
// I18N IMPORTS (the words of the File Browser, in the page's language)
|
|
122
126
|
import { provideI18n } from '../../i18n/context';
|
|
@@ -173,11 +177,23 @@
|
|
|
173
177
|
export let initialSortCriteria: 'name' | 'date' | 'size' = 'name'; // Default to date
|
|
174
178
|
// navigation settings
|
|
175
179
|
export let instanceId: string = 'default'; // Unique identifier for this file browser instance
|
|
176
|
-
|
|
180
|
+
/** Persists folder path, filter, and sort in localStorage (full-page browsers). Off in library mode. */
|
|
181
|
+
export let persistHistory = true;
|
|
182
|
+
/**
|
|
183
|
+
* Persists only the folder path in localStorage (single-file pickers). Does not save filter or sort — the control
|
|
184
|
+
* fixes the file type. Use with `persistHistory={false}` on a dedicated `instanceId`.
|
|
185
|
+
*/
|
|
186
|
+
export let rememberFolder = false;
|
|
177
187
|
export let showBreadcrumbs = true; // Whether to show breadcrumbs
|
|
178
188
|
// selection settings
|
|
179
189
|
export let allowSelecting = true; // Toggle file selection functionality by default
|
|
180
190
|
export let maxSelections: number | null = null; // null = unlimited; 1 = single-file picker
|
|
191
|
+
/** Single-file pickers (selectors) hide sort controls and keep the default name order. */
|
|
192
|
+
$: isSingleFilePicker = maxSelections === 1;
|
|
193
|
+
$: controlsShowSorting = showSorting && !isSingleFilePicker;
|
|
194
|
+
/** Fixed-type selectors never show the type filter, even if a host passes `showFilters={true}`. */
|
|
195
|
+
$: controlsShowFilters = showFilters && !(isSingleFilePicker && initialFilter !== 'all');
|
|
196
|
+
let rubberBandDragActive = false;
|
|
181
197
|
/** When set (single-file picker), disables confirm until user picks a different file. */
|
|
182
198
|
export let activeFileId: string | null = null;
|
|
183
199
|
export let showAddToEditor = false; // Toggle visibility of "Add to Editor" functionality
|
|
@@ -319,7 +335,7 @@
|
|
|
319
335
|
|
|
320
336
|
// Initialize filter with a function to check localStorage first
|
|
321
337
|
let filter: FileFilterType = (() => {
|
|
322
|
-
if (persistHistory) {
|
|
338
|
+
if (persistHistory && maxSelections !== 1) {
|
|
323
339
|
try {
|
|
324
340
|
if (isBrowser) {
|
|
325
341
|
const storedFilter = getFromStorage(FILTER_STORAGE_KEY(instanceId), null);
|
|
@@ -513,6 +529,10 @@
|
|
|
513
529
|
// The text of the confirm button: the page's label, or the message of the language in use.
|
|
514
530
|
$: addToEditorText = addToEditorLabel ?? $t('action.addToEditor');
|
|
515
531
|
|
|
532
|
+
$: shouldPersistFolderInStorage =
|
|
533
|
+
!libraryMode && (rememberFolder || (persistHistory && maxSelections !== 1));
|
|
534
|
+
$: setPersistFolderPath(instanceId, shouldPersistFolderInStorage);
|
|
535
|
+
|
|
516
536
|
// A shared browser must not show the next visitor the previous one's picks, so a library turns this off unless the
|
|
517
537
|
// host asks for it. Selecting still works; the picks just live in memory.
|
|
518
538
|
const selectionIsKept = persistSelection ?? !libraryMode;
|
|
@@ -861,7 +881,7 @@
|
|
|
861
881
|
let pathToNavigate: string[] = [];
|
|
862
882
|
|
|
863
883
|
// Check if we have a stored path to restore (a media library has no folders to go back to)
|
|
864
|
-
if (
|
|
884
|
+
if (shouldPersistFolderInStorage) {
|
|
865
885
|
const storedState = getStoredState(instanceId);
|
|
866
886
|
if (storedState) {
|
|
867
887
|
pathToNavigate = storedState.pathsArray[storedState.currentIndex] || [];
|
|
@@ -885,7 +905,7 @@
|
|
|
885
905
|
const navStartTime = performance.now();
|
|
886
906
|
|
|
887
907
|
// if there is no stored path, reset navigation to root
|
|
888
|
-
if (!
|
|
908
|
+
if (!shouldPersistFolderInStorage || pathToNavigate.length === 0) {
|
|
889
909
|
// if(showLogs) console.log('FileBrowser onMount: No valid stored path, resetting navigation to root');
|
|
890
910
|
navigationStore.reset();
|
|
891
911
|
currentFolder.set([]);
|
|
@@ -1125,7 +1145,10 @@
|
|
|
1125
1145
|
(isEmpty || hasNoMatchingFiles) && scrollAreaHeight > 0
|
|
1126
1146
|
? `min-height: ${Math.max(0, scrollAreaHeight - 24)}px;`
|
|
1127
1147
|
: '';
|
|
1128
|
-
|
|
1148
|
+
// Centred in the scroll viewport, not in the flow below folder tiles (selector empty views must not jump).
|
|
1149
|
+
$: showEmptyTypeOverlay = !isLoading && (isEmpty || hasNoMatchingFiles);
|
|
1150
|
+
$: emptyOverlayViewportHeight =
|
|
1151
|
+
scrollAreaHeight > 0 ? `${Math.max(0, scrollAreaHeight - 24)}px` : undefined;
|
|
1129
1152
|
// What an empty view says, and with which icon: a type filter that matches nothing, an empty media library,
|
|
1130
1153
|
// or an empty folder (Figma "Files / No matching files", "Empty library" and "Empty folder").
|
|
1131
1154
|
$: emptyViewMessage =
|
|
@@ -1186,16 +1209,14 @@
|
|
|
1186
1209
|
|
|
1187
1210
|
/**
|
|
1188
1211
|
* Filters and sorts current folder contents based on active filter and sort criteria.
|
|
1189
|
-
* Folders are always
|
|
1212
|
+
* Folders are always listed; files must match the filter.
|
|
1190
1213
|
*/
|
|
1191
1214
|
$: {
|
|
1192
1215
|
void $sortCriteria;
|
|
1193
1216
|
void $sortDirection;
|
|
1194
1217
|
if (filter && currentFolderContent?.children) {
|
|
1195
1218
|
filteredFiles = currentFolderContent.children.filter((item: FileSystemItem) => {
|
|
1196
|
-
if (item.type === 'folder')
|
|
1197
|
-
return true;
|
|
1198
|
-
}
|
|
1219
|
+
if (item.type === 'folder') return true;
|
|
1199
1220
|
return fileMatchesFilter(item);
|
|
1200
1221
|
});
|
|
1201
1222
|
} else {
|
|
@@ -1228,8 +1249,14 @@
|
|
|
1228
1249
|
function handleFolderClick(folder: FolderItemWithCount) {
|
|
1229
1250
|
}
|
|
1230
1251
|
|
|
1231
|
-
|
|
1232
|
-
$:
|
|
1252
|
+
// `$validSelections` is a store that changes whenever a selection does, so both lists follow every click, in every folder.
|
|
1253
|
+
$: allSelectedFiles = $fileStore?.root && filter ? $validSelections(filter, getAllFiles($fileStore.root)) : [];
|
|
1254
|
+
// Grid tiles and recent cards share one selection store; recent rows use the same ids as grid files when both lists show the file.
|
|
1255
|
+
$: selectionViewFiles =
|
|
1256
|
+
!isSingleFilePicker && currentPath.length === 0 && recentFiles.length > 0
|
|
1257
|
+
? [...sortedFilteredFiles, ...recentFiles]
|
|
1258
|
+
: sortedFilteredFiles;
|
|
1259
|
+
$: currentSelections = $fileStore?.root && filter ? $validSelections(filter, selectionViewFiles) : [];
|
|
1233
1260
|
|
|
1234
1261
|
function toggleFileSelection(file: FileSystemItem) {
|
|
1235
1262
|
if (!allowSelecting) return;
|
|
@@ -1339,10 +1366,11 @@
|
|
|
1339
1366
|
});
|
|
1340
1367
|
if(showLogs && showRecentFilesLogs) console.log('Files after type filtering:', typeFilteredFiles.length);
|
|
1341
1368
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1369
|
+
const result = buildDeduplicatedRecentFiles(
|
|
1370
|
+
typeFilteredFiles,
|
|
1371
|
+
(item) => getCorrectFileUrl(item),
|
|
1372
|
+
numberOfRecentFiles,
|
|
1373
|
+
);
|
|
1346
1374
|
|
|
1347
1375
|
if(showLogs && showRecentFilesLogs) console.log('Final recent files:', result.length);
|
|
1348
1376
|
return result;
|
|
@@ -1856,6 +1884,37 @@
|
|
|
1856
1884
|
handleNavigateBack();
|
|
1857
1885
|
}
|
|
1858
1886
|
|
|
1887
|
+
const clearableSelectionCount = allSelectedFiles.filter(
|
|
1888
|
+
(file) => !(maxSelections === 1 && activeFileId && file.id === activeFileId)
|
|
1889
|
+
).length;
|
|
1890
|
+
const innerEscapeHandlerOpen =
|
|
1891
|
+
filterDropdownOpen ||
|
|
1892
|
+
sortDropdownOpen ||
|
|
1893
|
+
showRenameDialog ||
|
|
1894
|
+
showNewFolderDialog ||
|
|
1895
|
+
showMoveDialog ||
|
|
1896
|
+
showDeleteConfirmation;
|
|
1897
|
+
const escapeAction = escapeSelectionAction({
|
|
1898
|
+
key: event.key,
|
|
1899
|
+
defaultPrevented: event.defaultPrevented,
|
|
1900
|
+
previewOpen: !!previewFile,
|
|
1901
|
+
designSystemModalOpen: $isModalOpen,
|
|
1902
|
+
inputFocused: !!isInputFocused(event),
|
|
1903
|
+
rubberBandDragActive,
|
|
1904
|
+
innerEscapeHandlerOpen,
|
|
1905
|
+
selectionCount: allSelectedFiles.length,
|
|
1906
|
+
clearableSelectionCount,
|
|
1907
|
+
singleFilePicker: maxSelections === 1,
|
|
1908
|
+
});
|
|
1909
|
+
if (escapeAction === 'clear-selection') {
|
|
1910
|
+
event.preventDefault();
|
|
1911
|
+
event.stopPropagation();
|
|
1912
|
+
persistentSelectStore.clearSelections(filter);
|
|
1913
|
+
selectedFiles.set([]);
|
|
1914
|
+
if (showLogs) console.log('FileBrowser: cleared selection via Escape');
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1859
1918
|
// rest of the key handlers
|
|
1860
1919
|
handleKeyboardShortcuts(event);
|
|
1861
1920
|
}
|
|
@@ -2321,7 +2380,7 @@
|
|
|
2321
2380
|
navigationStore.reset();
|
|
2322
2381
|
|
|
2323
2382
|
// Clear localStorage navigation history
|
|
2324
|
-
if (
|
|
2383
|
+
if (shouldPersistFolderInStorage) {
|
|
2325
2384
|
try {
|
|
2326
2385
|
removeFromStorage(instanceId);
|
|
2327
2386
|
if(showLogs) console.log('Cleared navigation history from localStorage');
|
|
@@ -2580,12 +2639,6 @@
|
|
|
2580
2639
|
{ value: 'size', labelKey: 'sort.size' }
|
|
2581
2640
|
] as const;
|
|
2582
2641
|
|
|
2583
|
-
$: widestFilterLabel = filterOptions.reduce((widest, option) => option.label.length > widest.length ? option.label : widest, '');
|
|
2584
|
-
$: widestSortLabel = sortOptions.reduce((widest, option) => {
|
|
2585
|
-
const label = $t(option.labelKey);
|
|
2586
|
-
return label.length > widest.length ? label : widest;
|
|
2587
|
-
}, '');
|
|
2588
|
-
|
|
2589
2642
|
// Replace the existing reactive statement for filter
|
|
2590
2643
|
$: {
|
|
2591
2644
|
if (persistHistory && filter) {
|
|
@@ -2685,21 +2738,6 @@
|
|
|
2685
2738
|
// Track if VirtualList is initialized
|
|
2686
2739
|
let isVirtualListInitialized = false;
|
|
2687
2740
|
|
|
2688
|
-
// Add a reactive statement to properly update visible selections when filter changes
|
|
2689
|
-
$: {
|
|
2690
|
-
if (filter) {
|
|
2691
|
-
// Force a recomputation of the current and all selected files when filter changes
|
|
2692
|
-
currentSelections = $fileStore?.root ? $validSelections(filter, sortedFilteredFiles) : [];
|
|
2693
|
-
allSelectedFiles = $fileStore?.root ? $validSelections(filter, getAllFiles($fileStore.root)) : [];
|
|
2694
|
-
// if(showLogs && showFiltersLogs) console.log(`Filter changed to ${filter}. Current visible selections:`, currentSelections.length);
|
|
2695
|
-
// if(showLogs && showFiltersLogs) console.log(`Total selected files of type ${filter} across all folders:`, allSelectedFiles.length);
|
|
2696
|
-
if (allSelectedFiles.length > 0) {
|
|
2697
|
-
// Since we don't have direct folder info on the FileSystemItem type, just log the selected files' IDs
|
|
2698
|
-
// if(showLogs && showFiltersLogs) console.log(`Selected files IDs:`, allSelectedFiles.map(f => f.id));
|
|
2699
|
-
}
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
|
|
2703
2741
|
// Add a reactive statement to update sourceItems when showMoveDialog changes
|
|
2704
2742
|
$: if (showMoveDialog && !selectedItem) {
|
|
2705
2743
|
const validFileSelections = allSelectedFiles.filter((item) => item?.type === 'file');
|
|
@@ -2712,7 +2750,7 @@
|
|
|
2712
2750
|
// Update the navigation history clearing code
|
|
2713
2751
|
function clearNavigationHistory() {
|
|
2714
2752
|
// Clear localStorage navigation history
|
|
2715
|
-
if (
|
|
2753
|
+
if (shouldPersistFolderInStorage) {
|
|
2716
2754
|
try {
|
|
2717
2755
|
removeFromStorage(instanceId);
|
|
2718
2756
|
if(showLogs) console.log('Cleared navigation history from localStorage');
|
|
@@ -2735,21 +2773,7 @@
|
|
|
2735
2773
|
|
|
2736
2774
|
// Update numberOfRecentFiles based on screen width
|
|
2737
2775
|
function updateNumberOfRecentFiles() {
|
|
2738
|
-
|
|
2739
|
-
// For large desktop screens, show more files
|
|
2740
|
-
const availableWidth = mainContainerWidth;
|
|
2741
|
-
// Calculate how many columns would fit nicely
|
|
2742
|
-
const gridColumns = Math.min(6, Math.floor(availableWidth / 300));
|
|
2743
|
-
// Set max files to fill at least one row
|
|
2744
|
-
numberOfRecentFiles = gridColumns * 2; // Two rows of content
|
|
2745
|
-
} else if (mainContainerWidth > tabletBreakpoint) {
|
|
2746
|
-
// Standard desktop
|
|
2747
|
-
numberOfRecentFiles = 6; // Two rows of 3
|
|
2748
|
-
} else {
|
|
2749
|
-
// Tablet and below
|
|
2750
|
-
numberOfRecentFiles = 4; // Two rows of 2
|
|
2751
|
-
}
|
|
2752
|
-
|
|
2776
|
+
numberOfRecentFiles = recentFilesLimitForWidth(mainContainerWidth);
|
|
2753
2777
|
if(showLogs && showRecentFilesLogs) console.log('Updated number of recent files:', numberOfRecentFiles);
|
|
2754
2778
|
}
|
|
2755
2779
|
|
|
@@ -2825,10 +2849,11 @@ mainGridClass="app-main-grid"
|
|
|
2825
2849
|
title={libraryMode ? (resolvedMediaLibrary?.hasOwnLabel ? resolvedMediaLibrary.label : $t('library.defaultLabel')) : ''}
|
|
2826
2850
|
/>
|
|
2827
2851
|
|
|
2828
|
-
<!-- FILE BROWSER CONTROLS
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2852
|
+
<!-- FILE BROWSER CONTROLS: Figma — full-width search, then compact filter/sort row -->
|
|
2853
|
+
<div
|
|
2854
|
+
class="file-browser-controls flex min-w-0 shrink-0 flex-col gap-2 pb-4 {controlsTopPaddingClass} {edgePaddingClass}"
|
|
2855
|
+
>
|
|
2856
|
+
<div class="search-bar-container relative z-[61] w-full min-w-0">
|
|
2832
2857
|
<SearchDropdown
|
|
2833
2858
|
root={$fileStore.root}
|
|
2834
2859
|
currentFilter={filter}
|
|
@@ -2838,10 +2863,10 @@ mainGridClass="app-main-grid"
|
|
|
2838
2863
|
/>
|
|
2839
2864
|
</div>
|
|
2840
2865
|
|
|
2841
|
-
{#if
|
|
2842
|
-
<div class="controls-container flex
|
|
2866
|
+
{#if controlsShowFilters || controlsShowSorting}
|
|
2867
|
+
<div class="controls-container flex min-w-0 max-w-full items-center gap-2 overflow-x-auto">
|
|
2843
2868
|
|
|
2844
|
-
{#if
|
|
2869
|
+
{#if controlsShowFilters}
|
|
2845
2870
|
<div class="filter-controls-container relative z-10 flex items-center">
|
|
2846
2871
|
{#key filterMenuKey}
|
|
2847
2872
|
<DropdownMenu.Root onOpenChange={setFilterMenuOpen}>
|
|
@@ -2849,12 +2874,10 @@ mainGridClass="app-main-grid"
|
|
|
2849
2874
|
class="filter-button group flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-lg border border-input bg-background px-3 text-start transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
2850
2875
|
>
|
|
2851
2876
|
<span class="text-body text-muted-foreground whitespace-nowrap">{$t('filter.by', { type: '\u0001' }).split('\u0001')[0].trim()}</span>
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
<span class="col-start-1 row-start-1 whitespace-nowrap text-body-medium text-foreground">{$t(`filterOption.${filter}`)}</span>
|
|
2855
|
-
</span>
|
|
2877
|
+
<!-- The chip is as wide as what it says (Figma: it hugs its text); it used to reserve the widest label and looked stretched. -->
|
|
2878
|
+
<span class="whitespace-nowrap text-body-medium text-foreground">{$t(`filterOption.${filter}`)}</span>
|
|
2856
2879
|
<!-- 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). -->
|
|
2857
|
-
<IconChevronDown class="size-4 shrink-0 stroke-
|
|
2880
|
+
<IconChevronDown class="size-4 shrink-0 stroke-2 opacity-50 transition-transform duration-base group-data-[state=open]:rotate-180" aria-hidden="true" />
|
|
2858
2881
|
</DropdownMenu.Trigger>
|
|
2859
2882
|
<DropdownMenu.Content side="bottom" align="start" class="filter-dropdown w-[12.5rem] min-w-0">
|
|
2860
2883
|
{#each filterOptions as option}
|
|
@@ -2866,10 +2889,10 @@ mainGridClass="app-main-grid"
|
|
|
2866
2889
|
<!-- The check slot: only the chosen option shows the check -->
|
|
2867
2890
|
<span class="absolute start-2 flex size-4 items-center justify-center">
|
|
2868
2891
|
{#if filter === option.value}
|
|
2869
|
-
<IconCheck class="size-4 stroke-
|
|
2892
|
+
<IconCheck class="size-4 stroke-2 text-foreground" aria-hidden="true" />
|
|
2870
2893
|
{/if}
|
|
2871
2894
|
</span>
|
|
2872
|
-
<OptionIcon class="size-4 shrink-0 stroke-
|
|
2895
|
+
<OptionIcon class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
2873
2896
|
<span class="text-body min-w-0 flex-1 truncate">{option.label}</span>
|
|
2874
2897
|
</DropdownMenu.Item>
|
|
2875
2898
|
{/each}
|
|
@@ -2879,7 +2902,7 @@ mainGridClass="app-main-grid"
|
|
|
2879
2902
|
</div>
|
|
2880
2903
|
{/if}
|
|
2881
2904
|
|
|
2882
|
-
{#if
|
|
2905
|
+
{#if controlsShowSorting}
|
|
2883
2906
|
<div class="sort-controls-container flex items-center gap-2">
|
|
2884
2907
|
{#key sortMenuKey}
|
|
2885
2908
|
<DropdownMenu.Root onOpenChange={setSortMenuOpen}>
|
|
@@ -2887,11 +2910,8 @@ mainGridClass="app-main-grid"
|
|
|
2887
2910
|
class="sort-button group flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-lg border border-input bg-background px-3 text-start transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
2888
2911
|
>
|
|
2889
2912
|
<span class="text-body text-muted-foreground whitespace-nowrap">{$t('sort.by')}</span>
|
|
2890
|
-
<span class="
|
|
2891
|
-
|
|
2892
|
-
<span class="col-start-1 row-start-1 whitespace-nowrap text-body-medium text-foreground">{$t(`sort.${$sortCriteria}`)}</span>
|
|
2893
|
-
</span>
|
|
2894
|
-
<IconChevronDown class="size-4 shrink-0 stroke-[1.333] opacity-50 transition-transform duration-base group-data-[state=open]:rotate-180" aria-hidden="true" />
|
|
2913
|
+
<span class="whitespace-nowrap text-body-medium text-foreground">{$t(`sort.${$sortCriteria}`)}</span>
|
|
2914
|
+
<IconChevronDown class="size-4 shrink-0 stroke-2 opacity-50 transition-transform duration-base group-data-[state=open]:rotate-180" aria-hidden="true" />
|
|
2895
2915
|
</DropdownMenu.Trigger>
|
|
2896
2916
|
<DropdownMenu.Content side="bottom" align="start" class="sort-dropdown w-40 min-w-0">
|
|
2897
2917
|
{#each sortOptions as option}
|
|
@@ -2902,7 +2922,7 @@ mainGridClass="app-main-grid"
|
|
|
2902
2922
|
<!-- The check slot: only the chosen option shows the check -->
|
|
2903
2923
|
<span class="absolute start-2 flex size-4 items-center justify-center">
|
|
2904
2924
|
{#if $sortCriteria === option.value}
|
|
2905
|
-
<IconCheck class="size-4 stroke-
|
|
2925
|
+
<IconCheck class="size-4 stroke-2 text-foreground" aria-hidden="true" />
|
|
2906
2926
|
{/if}
|
|
2907
2927
|
</span>
|
|
2908
2928
|
<span class="text-body">{$t(option.labelKey)}</span>
|
|
@@ -2930,9 +2950,9 @@ mainGridClass="app-main-grid"
|
|
|
2930
2950
|
}}
|
|
2931
2951
|
>
|
|
2932
2952
|
{#if $sortDirection === 'asc'}
|
|
2933
|
-
<IconArrowUp class="size-4 stroke-
|
|
2953
|
+
<IconArrowUp class="size-4 stroke-2" aria-hidden="true" />
|
|
2934
2954
|
{:else}
|
|
2935
|
-
<IconArrowDown class="size-4 stroke-
|
|
2955
|
+
<IconArrowDown class="size-4 stroke-2" aria-hidden="true" />
|
|
2936
2956
|
{/if}
|
|
2937
2957
|
</IconButton>
|
|
2938
2958
|
{/snippet}
|
|
@@ -3002,14 +3022,19 @@ mainGridClass="app-main-grid"
|
|
|
3002
3022
|
<!-- Files container -->
|
|
3003
3023
|
{:else}
|
|
3004
3024
|
<!-- Main content container with Files Inside --> <!-- {!showAddToEditor ? 'overflow-y-auto px-6' : ''} -->
|
|
3005
|
-
<WScrollArea class="scroll-area-container min-h-0 flex-1" bind:element={scrollContainer} type="always">
|
|
3025
|
+
<WScrollArea class="scroll-area-container min-h-0 min-w-0 flex-1" bind:element={scrollContainer} type="always">
|
|
3026
|
+
<div
|
|
3027
|
+
class="fb-scroll-content relative w-full min-w-full self-stretch"
|
|
3028
|
+
style={emptyViewMinHeightStyle}
|
|
3029
|
+
>
|
|
3006
3030
|
<!-- The padding is the same on both sides (Figma 24): the scrollbar sits in the end gutter, not on the tiles. -->
|
|
3007
|
-
<div class="main-content-container flex flex-col pb-6 {contentPaddingClass}"
|
|
3031
|
+
<div class="main-content-container relative flex w-full min-w-0 flex-col pb-6 {contentPaddingClass}" bind:this={contentContainer}>
|
|
3008
3032
|
|
|
3009
3033
|
<!-- Drag Select for selecting files -->
|
|
3010
3034
|
{#if allowSelecting}
|
|
3011
3035
|
<DragSelect
|
|
3012
3036
|
container={contentContainer}
|
|
3037
|
+
bind:dragBandActive={rubberBandDragActive}
|
|
3013
3038
|
enabled={allowSelecting && !$isModalOpen && maxSelections !== 1}
|
|
3014
3039
|
items={[...sortedFilteredFiles, ...recentFiles]}
|
|
3015
3040
|
{scrollContainer}
|
|
@@ -3057,7 +3082,7 @@ mainGridClass="app-main-grid"
|
|
|
3057
3082
|
<!-- Item content -->
|
|
3058
3083
|
<div
|
|
3059
3084
|
data-item-id={item.id}
|
|
3060
|
-
class="item-container"
|
|
3085
|
+
class="item-container group/file-tile"
|
|
3061
3086
|
data-selected={allowSelecting && currentSelections.some(f => f.id === item.id) ? 'true' : undefined}
|
|
3062
3087
|
>
|
|
3063
3088
|
{#if item.type === 'new-folder'}
|
|
@@ -3085,17 +3110,11 @@ mainGridClass="app-main-grid"
|
|
|
3085
3110
|
</div>
|
|
3086
3111
|
</VirtualList>
|
|
3087
3112
|
|
|
3088
|
-
{#if hasNoMatchingFiles}
|
|
3089
|
-
<!-- The folders stay on the page when a filter matches no file: the message is centred in the room under them -->
|
|
3090
|
-
<div class="no-matching-files-container flex min-h-0 w-full flex-1 items-center justify-center">
|
|
3091
|
-
<EmptyState message={emptyViewMessage} icon={emptyViewIcon} showActions={false} height="auto" />
|
|
3092
|
-
</div>
|
|
3093
|
-
{/if}
|
|
3094
|
-
|
|
3095
3113
|
<!-- Recent Files (a media library is one flat list, so they would only repeat the grid) -->
|
|
3096
|
-
{#if !libraryMode && currentPath.length === 0 && recentFiles.length > 0 && mainContainerWidth > tabletBreakpoint}
|
|
3114
|
+
{#if !libraryMode && !isSingleFilePicker && currentPath.length === 0 && recentFiles.length > 0 && mainContainerWidth > tabletBreakpoint}
|
|
3097
3115
|
<RecentFiles class="recent-files-container"
|
|
3098
|
-
{recentFiles}
|
|
3116
|
+
{recentFiles}
|
|
3117
|
+
visibleLimit={numberOfRecentFiles}
|
|
3099
3118
|
selectedFiles={allSelectedFiles}
|
|
3100
3119
|
currentFilter={filter}
|
|
3101
3120
|
{allowSelecting}
|
|
@@ -3107,10 +3126,8 @@ mainGridClass="app-main-grid"
|
|
|
3107
3126
|
{/if}
|
|
3108
3127
|
|
|
3109
3128
|
{:else}
|
|
3110
|
-
<!-- Empty view (Figma "Files / Empty folder" and "Empty library"): the "New folder" tile
|
|
3111
|
-
<div class="empty-content-container flex min-h-0 w-full flex-
|
|
3112
|
-
|
|
3113
|
-
<!-- New Folder Button -->
|
|
3129
|
+
<!-- Empty view (Figma "Files / Empty folder" and "Empty library"): the "New folder" tile only; the message is in the viewport overlay below -->
|
|
3130
|
+
<div class="empty-content-container flex min-h-0 w-full flex-col gap-3">
|
|
3114
3131
|
{#if libraryCapabilities.folders}
|
|
3115
3132
|
<div
|
|
3116
3133
|
class="grid w-full"
|
|
@@ -3119,14 +3136,25 @@ mainGridClass="app-main-grid"
|
|
|
3119
3136
|
<NewFolderButton on:click={handleNewFolderClick} />
|
|
3120
3137
|
</div>
|
|
3121
3138
|
{/if}
|
|
3122
|
-
|
|
3123
|
-
<!-- Empty State Container -->
|
|
3124
|
-
<div class="empty-state-wrapper flex min-h-0 w-full flex-1 items-center justify-center">
|
|
3125
|
-
<EmptyState message={emptyViewMessage} icon={emptyViewIcon} showActions={false} height="auto" />
|
|
3126
|
-
</div>
|
|
3127
3139
|
</div>
|
|
3128
3140
|
{/if}
|
|
3129
3141
|
</div> <!-- END OF MAIN CONTENT CONTAINER -->
|
|
3142
|
+
|
|
3143
|
+
{#if showEmptyTypeOverlay}
|
|
3144
|
+
<div
|
|
3145
|
+
class="empty-type-overlay pointer-events-none absolute inset-0 z-[2] flex items-center justify-center"
|
|
3146
|
+
style:height={emptyOverlayViewportHeight}
|
|
3147
|
+
>
|
|
3148
|
+
<EmptyState
|
|
3149
|
+
class="pointer-events-auto"
|
|
3150
|
+
message={emptyViewMessage}
|
|
3151
|
+
icon={emptyViewIcon}
|
|
3152
|
+
showActions={false}
|
|
3153
|
+
height="auto"
|
|
3154
|
+
/>
|
|
3155
|
+
</div>
|
|
3156
|
+
{/if}
|
|
3157
|
+
</div> <!-- fb-scroll-content: full viewport width for the empty overlay -->
|
|
3130
3158
|
</WScrollArea>
|
|
3131
3159
|
|
|
3132
3160
|
{/if}
|
|
@@ -3134,7 +3162,7 @@ mainGridClass="app-main-grid"
|
|
|
3134
3162
|
|
|
3135
3163
|
<!-- FILE BROWSER FOOTER (Figma: a divider, then the selection bar over the dropzone, 12px apart) -->
|
|
3136
3164
|
<div
|
|
3137
|
-
class="file-browser-footer relative z-20 flex shrink-0 flex-col {footerClass} {edgePaddingClass}"
|
|
3165
|
+
class="file-browser-footer relative z-20 flex shrink-0 flex-col overflow-visible {footerClass} {edgePaddingClass}"
|
|
3138
3166
|
bind:this={footerElement}
|
|
3139
3167
|
>
|
|
3140
3168
|
{#if allowSelecting && allSelectedFiles.length > 0}
|
|
@@ -3207,6 +3235,7 @@ mainGridClass="app-main-grid"
|
|
|
3207
3235
|
file={previewFile}
|
|
3208
3236
|
on:close={closePreview}
|
|
3209
3237
|
{allowSelecting}
|
|
3238
|
+
{showAddToEditor}
|
|
3210
3239
|
currentFilter={filter}
|
|
3211
3240
|
currentFiles={previewSource === 'recent' ? recentFiles : currentViewFiles}
|
|
3212
3241
|
target={rootContainerClass}
|
|
@@ -44,7 +44,11 @@ declare const FileBrowser: $$__sveltets_2_IsomorphicComponent<{
|
|
|
44
44
|
initialFilter?: FileFilterType;
|
|
45
45
|
initialSortCriteria?: "name" | "date" | "size";
|
|
46
46
|
instanceId?: string;
|
|
47
|
-
persistHistory?: boolean;
|
|
47
|
+
/** Persists folder path, filter, and sort in localStorage (full-page browsers). Off in library mode. */ persistHistory?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Persists only the folder path in localStorage (single-file pickers). Does not save filter or sort — the control
|
|
50
|
+
* fixes the file type. Use with `persistHistory={false}` on a dedicated `instanceId`.
|
|
51
|
+
*/ rememberFolder?: boolean;
|
|
48
52
|
showBreadcrumbs?: boolean;
|
|
49
53
|
allowSelecting?: boolean;
|
|
50
54
|
maxSelections?: number | null;
|