@widgetic/file-browser 0.5.40 → 0.5.42
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/FileBrowser.svelte +157 -62
- package/dist/components/core/FileBrowser.svelte.d.ts +5 -1
- package/dist/components/core/FileUploader.svelte +49 -15
- package/dist/components/core/RecentFiles.svelte +23 -11
- package/dist/components/core/RecentFiles.svelte.d.ts +1 -0
- package/dist/components/core/SearchDropdown.svelte +124 -26
- package/dist/components/core/UploadPanel.svelte +1 -1
- package/dist/components/items/FileItem.svelte +12 -2
- package/dist/components/items/FolderItem.svelte +8 -1
- package/dist/components/modals/index.d.ts +0 -1
- package/dist/components/modals/index.js +0 -1
- package/dist/components/previews/FilePreview.svelte +226 -35
- package/dist/components/previews/FilePreview.svelte.d.ts +7 -3
- package/dist/components/previews/FontPreview.svelte +4 -1
- package/dist/components/previews/FontPreview.svelte.d.ts +2 -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 +33 -25
- package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +2 -0
- package/dist/components/ui/DragSelect.svelte +85 -67
- package/dist/components/ui/DragSelect.svelte.d.ts +1 -0
- package/dist/data/demoContent.json +13 -11
- package/dist/i18n/messages.d.ts +0 -1
- package/dist/i18n/messages.js +0 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/stores/navigationStore.d.ts +5 -0
- package/dist/stores/navigationStore.js +40 -67
- 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/uploadListReconcile.d.ts +11 -0
- package/dist/utils/uploadListReconcile.js +30 -0
- package/dist/utils/uploadPanelProgress.d.ts +5 -0
- package/dist/utils/uploadPanelProgress.js +17 -0
- package/dist/utils/userUploadsStorage.d.ts +8 -0
- package/dist/utils/userUploadsStorage.js +32 -0
- package/package.json +3 -3
- package/dist/components/modals/SearchModal.svelte +0 -296
- package/dist/components/modals/SearchModal.svelte.d.ts +0 -27
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
import { useI18n, type Translate } from '../../i18n';
|
|
11
11
|
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
12
12
|
import { FileIcon, SelectedBadge } from '../ui';
|
|
13
|
+
import { persistentSelectStore } from '../../stores/persistentSelectStore';
|
|
13
14
|
import { type FileFilterType } from '../../utils/fileTypes';
|
|
14
15
|
import { ThumbHashImage } from '@widgetic/design-system/components';
|
|
15
16
|
import { IconExclamationCircle, IconPlayerPlayFilled } from '@widgetic/design-system/icons';
|
|
16
17
|
import { browser } from '$app/environment';
|
|
18
|
+
import { recentFilesLimitForWidth } from '../../utils/recentFilesLimit';
|
|
17
19
|
|
|
18
20
|
let className = '';
|
|
19
21
|
export { className as class };
|
|
@@ -24,6 +26,8 @@
|
|
|
24
26
|
export let currentFilter: FileFilterType = 'all';
|
|
25
27
|
export let allowSelecting: boolean = false;
|
|
26
28
|
export let columnWidth: number = 40;
|
|
29
|
+
/** Cap from FileBrowser so the strip matches `getRecentFiles()`. */
|
|
30
|
+
export let visibleLimit: number | undefined = undefined;
|
|
27
31
|
|
|
28
32
|
const { t } = useI18n();
|
|
29
33
|
const textDirection = useTextDirection();
|
|
@@ -41,17 +45,19 @@
|
|
|
41
45
|
if (windowWidth > DESKTOP_BREAKPOINT) {
|
|
42
46
|
const availableWidth = windowWidth;
|
|
43
47
|
gridColumns = Math.min(6, Math.floor(availableWidth / 300));
|
|
44
|
-
maxRecentFiles = gridColumns * 2;
|
|
45
48
|
} else if (windowWidth > TABLET_BREAKPOINT) {
|
|
46
49
|
gridColumns = 3;
|
|
47
|
-
maxRecentFiles = 6;
|
|
48
50
|
} else {
|
|
49
51
|
gridColumns = 2;
|
|
50
|
-
maxRecentFiles = 4;
|
|
51
52
|
}
|
|
53
|
+
maxRecentFiles = visibleLimit ?? recentFilesLimitForWidth(windowWidth);
|
|
52
54
|
if (showLogs) console.log('Responsive layout updated:', { windowWidth, gridColumns, maxRecentFiles });
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
$: if (visibleLimit !== undefined) {
|
|
58
|
+
maxRecentFiles = visibleLimit;
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
// Figma Recent cards sit 24px apart (the tiles above them 16)
|
|
56
62
|
$: gridGap = 24;
|
|
57
63
|
$: numberOfColumns = gridColumns;
|
|
@@ -148,8 +154,14 @@
|
|
|
148
154
|
}
|
|
149
155
|
}
|
|
150
156
|
|
|
157
|
+
// Same ids as the grid: follow the persistent store so both strips stay in sync after rubber-band or tile selection.
|
|
158
|
+
$: selectedIdSet = new Set([
|
|
159
|
+
...($persistentSelectStore[currentFilter] ?? []),
|
|
160
|
+
...selectedFiles.map((selectedFile) => selectedFile.id)
|
|
161
|
+
]);
|
|
162
|
+
|
|
151
163
|
function isSelected(file: FileSystemItem): boolean {
|
|
152
|
-
return
|
|
164
|
+
return selectedIdSet.has(file.id);
|
|
153
165
|
}
|
|
154
166
|
|
|
155
167
|
function getFormattedDate(date: string | Date, translate: Translate): string {
|
|
@@ -190,14 +202,13 @@
|
|
|
190
202
|
}
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
function cardShellClass(file: FileSystemItem): string {
|
|
194
|
-
const selected = isSelected(file);
|
|
205
|
+
function cardShellClass(file: FileSystemItem, selected: boolean): string {
|
|
195
206
|
const interactive = !file.isMissing && !errorStates.get(file.id);
|
|
196
207
|
return [
|
|
197
208
|
'item-container group flex w-full flex-col gap-2 rounded-xl border bg-background p-2 transition-colors duration-fast',
|
|
198
209
|
selected
|
|
199
|
-
? 'border-brand bg-brand-subtle ring-1 ring-inset ring-brand'
|
|
200
|
-
: 'border-border hover:bg-accent',
|
|
210
|
+
? 'border-brand bg-brand-subtle ring-1 ring-inset ring-brand data-[drag-hover=true]:bg-brand-subtle'
|
|
211
|
+
: 'border-border hover:bg-accent data-[drag-hover=true]:bg-accent',
|
|
201
212
|
interactive ? 'cursor-pointer' : ''
|
|
202
213
|
]
|
|
203
214
|
.filter(Boolean)
|
|
@@ -216,12 +227,13 @@
|
|
|
216
227
|
style="grid-template-columns: repeat({numberOfColumns}, minmax(0, 1fr)); gap: {gridGap}px;"
|
|
217
228
|
>
|
|
218
229
|
{#each filteredRecentFiles as file (file.id)}
|
|
230
|
+
{@const fileSelected = selectedIdSet.has(file.id)}
|
|
219
231
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
220
232
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
221
233
|
<div
|
|
222
234
|
data-item-id={file.id}
|
|
223
|
-
data-selected={
|
|
224
|
-
class={cardShellClass(file)}
|
|
235
|
+
data-selected={fileSelected ? 'true' : undefined}
|
|
236
|
+
class={cardShellClass(file, fileSelected)}
|
|
225
237
|
onclick={(e) => handleRecentCardClick(e, file)}
|
|
226
238
|
>
|
|
227
239
|
<button
|
|
@@ -292,7 +304,7 @@
|
|
|
292
304
|
{getFormattedDate(file.modified || new Date(), $t)}
|
|
293
305
|
</p>
|
|
294
306
|
</div>
|
|
295
|
-
{#if allowSelecting &&
|
|
307
|
+
{#if allowSelecting && fileSelected}
|
|
296
308
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
297
309
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
298
310
|
<span data-fb-recent-badge class="shrink-0" onclick={(e) => e.stopPropagation()}>
|
|
@@ -25,6 +25,7 @@ declare const RecentFiles: $$__sveltets_2_IsomorphicComponent<{
|
|
|
25
25
|
currentFilter?: FileFilterType;
|
|
26
26
|
allowSelecting?: boolean;
|
|
27
27
|
columnWidth?: number;
|
|
28
|
+
/** Cap from FileBrowser so the strip matches `getRecentFiles()`. */ visibleLimit?: number | undefined;
|
|
28
29
|
}, {
|
|
29
30
|
fileClick: CustomEvent<any>;
|
|
30
31
|
select: CustomEvent<any>;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import type { FileSystemItem } from '../../types';
|
|
11
11
|
import type { FileFilterType } from '../../utils/fileTypes';
|
|
12
12
|
import { highlightMatchesAsHtml } from '../../utils/safeText';
|
|
13
|
+
import { searchEscapeAction } from '../../utils/searchEscapeAction';
|
|
13
14
|
import {
|
|
14
15
|
filterSearchResults,
|
|
15
16
|
findItemPath,
|
|
@@ -17,6 +18,15 @@
|
|
|
17
18
|
SEARCH_LOCATION_SEPARATOR,
|
|
18
19
|
searchFileSystem
|
|
19
20
|
} from '../../utils/searchItems';
|
|
21
|
+
import {
|
|
22
|
+
firstSearchIndex,
|
|
23
|
+
lastSearchIndex,
|
|
24
|
+
nextSearchIndex,
|
|
25
|
+
pageSearchIndex,
|
|
26
|
+
previousSearchIndex,
|
|
27
|
+
searchResultIds,
|
|
28
|
+
shouldResetActiveIndex
|
|
29
|
+
} from '../../utils/searchNavigation';
|
|
20
30
|
import { useI18n } from '../../i18n';
|
|
21
31
|
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
22
32
|
|
|
@@ -56,33 +66,67 @@
|
|
|
56
66
|
let searchInputElement: HTMLInputElement | null = null;
|
|
57
67
|
|
|
58
68
|
let searchDebounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
69
|
+
let debouncedResultIds = '';
|
|
70
|
+
let lastPointerClientX = -1;
|
|
71
|
+
let lastPointerClientY = -1;
|
|
72
|
+
let keyboardNavigationActive = false;
|
|
73
|
+
let keyboardNavigationClearTimer: ReturnType<typeof setTimeout> | null = null;
|
|
74
|
+
const searchPageStep = 10;
|
|
59
75
|
|
|
60
76
|
$: debouncedTermEmpty = !searchValue.trim();
|
|
61
77
|
$: showPanel = panelOpen && !debouncedTermEmpty;
|
|
62
78
|
|
|
63
|
-
|
|
64
|
-
const term = searchValue.trim();
|
|
79
|
+
function queueDebouncedSearch(term: string) {
|
|
65
80
|
if (searchDebounceTimer) {
|
|
66
81
|
clearTimeout(searchDebounceTimer);
|
|
67
82
|
searchDebounceTimer = null;
|
|
68
83
|
}
|
|
69
84
|
if (!term || !root) {
|
|
70
85
|
debouncedResults = [];
|
|
86
|
+
debouncedResultIds = '';
|
|
71
87
|
activeIndex = -1;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
activeIndex =
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
searchDebounceTimer = setTimeout(() => {
|
|
91
|
+
try {
|
|
92
|
+
const termLower = term.toLowerCase();
|
|
93
|
+
const raw = searchFileSystem(root, termLower, currentFilter);
|
|
94
|
+
const nextResults = filterSearchResults(raw, currentFilter);
|
|
95
|
+
const nextIds = searchResultIds(nextResults);
|
|
96
|
+
debouncedResults = nextResults;
|
|
97
|
+
if (shouldResetActiveIndex(debouncedResultIds, nextIds)) {
|
|
98
|
+
activeIndex = firstSearchIndex(nextResults.length);
|
|
99
|
+
} else if (activeIndex >= nextResults.length) {
|
|
100
|
+
activeIndex = lastSearchIndex(nextResults.length);
|
|
83
101
|
}
|
|
84
|
-
|
|
102
|
+
debouncedResultIds = nextIds;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (showLogs) console.error('[SearchDropdown] search failed:', error);
|
|
105
|
+
debouncedResults = [];
|
|
106
|
+
debouncedResultIds = '';
|
|
107
|
+
activeIndex = -1;
|
|
108
|
+
}
|
|
109
|
+
}, 150);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
$: {
|
|
113
|
+
const term = searchValue.trim();
|
|
114
|
+
const treeRoot = root;
|
|
115
|
+
const filter = currentFilter;
|
|
116
|
+
void filter;
|
|
117
|
+
void treeRoot;
|
|
118
|
+
queueDebouncedSearch(term);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function markKeyboardNavigation() {
|
|
122
|
+
keyboardNavigationActive = true;
|
|
123
|
+
if (keyboardNavigationClearTimer) {
|
|
124
|
+
clearTimeout(keyboardNavigationClearTimer);
|
|
85
125
|
}
|
|
126
|
+
keyboardNavigationClearTimer = setTimeout(() => {
|
|
127
|
+
keyboardNavigationActive = false;
|
|
128
|
+
keyboardNavigationClearTimer = null;
|
|
129
|
+
}, 400);
|
|
86
130
|
}
|
|
87
131
|
|
|
88
132
|
function highlightMatch(name: string, term: string): string {
|
|
@@ -105,10 +149,26 @@
|
|
|
105
149
|
if (!resultsInner || activeIndex < 0) return;
|
|
106
150
|
tick().then(() => {
|
|
107
151
|
const row = resultsInner?.querySelector(`[data-result-index="${activeIndex}"]`) as HTMLElement | null;
|
|
108
|
-
row?.scrollIntoView({ behavior: '
|
|
152
|
+
row?.scrollIntoView({ behavior: 'auto', block: 'nearest' });
|
|
109
153
|
});
|
|
110
154
|
}
|
|
111
155
|
|
|
156
|
+
function handleResultsPointerMove(event: PointerEvent) {
|
|
157
|
+
if (keyboardNavigationActive) return;
|
|
158
|
+
const moved =
|
|
159
|
+
event.clientX !== lastPointerClientX || event.clientY !== lastPointerClientY;
|
|
160
|
+
lastPointerClientX = event.clientX;
|
|
161
|
+
lastPointerClientY = event.clientY;
|
|
162
|
+
if (!moved) return;
|
|
163
|
+
const target = event.target as HTMLElement | null;
|
|
164
|
+
const row = target?.closest('[data-result-index]') as HTMLElement | null;
|
|
165
|
+
if (!row) return;
|
|
166
|
+
const index = Number(row.dataset.resultIndex);
|
|
167
|
+
if (Number.isFinite(index)) {
|
|
168
|
+
activeIndex = index;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
112
172
|
function openResult(item: FileSystemItem) {
|
|
113
173
|
if (!root) return;
|
|
114
174
|
try {
|
|
@@ -128,6 +188,7 @@
|
|
|
128
188
|
searchValue = '';
|
|
129
189
|
panelOpen = false;
|
|
130
190
|
debouncedResults = [];
|
|
191
|
+
debouncedResultIds = '';
|
|
131
192
|
activeIndex = -1;
|
|
132
193
|
// The focus leaves the field: the folder or preview that opens next owns the keyboard (Escape closes the preview)
|
|
133
194
|
searchInputElement?.blur();
|
|
@@ -144,6 +205,7 @@
|
|
|
144
205
|
function handleClear() {
|
|
145
206
|
searchValue = '';
|
|
146
207
|
debouncedResults = [];
|
|
208
|
+
debouncedResultIds = '';
|
|
147
209
|
activeIndex = -1;
|
|
148
210
|
panelOpen = false;
|
|
149
211
|
searchInputElement?.focus();
|
|
@@ -156,11 +218,15 @@
|
|
|
156
218
|
return;
|
|
157
219
|
}
|
|
158
220
|
if (e.key === 'Escape') {
|
|
221
|
+
// Escape closes the results, then clears the text. With nothing left to close or clear, the key is not taken
|
|
222
|
+
// here: it travels on, so a host that embeds the browser (the editor's picker) can close on it.
|
|
223
|
+
const escapeAction = searchEscapeAction({ panelOpen, searchValue });
|
|
224
|
+
if (escapeAction === 'pass-through') return;
|
|
159
225
|
e.preventDefault();
|
|
160
226
|
e.stopPropagation();
|
|
161
|
-
if (
|
|
227
|
+
if (escapeAction === 'close-results') {
|
|
162
228
|
panelOpen = false;
|
|
163
|
-
} else
|
|
229
|
+
} else {
|
|
164
230
|
handleClear();
|
|
165
231
|
}
|
|
166
232
|
return;
|
|
@@ -170,11 +236,33 @@
|
|
|
170
236
|
}
|
|
171
237
|
if (e.key === 'ArrowDown') {
|
|
172
238
|
e.preventDefault();
|
|
173
|
-
|
|
239
|
+
markKeyboardNavigation();
|
|
240
|
+
activeIndex = nextSearchIndex(activeIndex, debouncedResults.length);
|
|
174
241
|
scrollActiveIntoView();
|
|
175
242
|
} else if (e.key === 'ArrowUp') {
|
|
176
243
|
e.preventDefault();
|
|
177
|
-
|
|
244
|
+
markKeyboardNavigation();
|
|
245
|
+
activeIndex = previousSearchIndex(activeIndex, debouncedResults.length);
|
|
246
|
+
scrollActiveIntoView();
|
|
247
|
+
} else if (e.key === 'Home') {
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
markKeyboardNavigation();
|
|
250
|
+
activeIndex = firstSearchIndex(debouncedResults.length);
|
|
251
|
+
scrollActiveIntoView();
|
|
252
|
+
} else if (e.key === 'End') {
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
markKeyboardNavigation();
|
|
255
|
+
activeIndex = lastSearchIndex(debouncedResults.length);
|
|
256
|
+
scrollActiveIntoView();
|
|
257
|
+
} else if (e.key === 'PageDown') {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
markKeyboardNavigation();
|
|
260
|
+
activeIndex = pageSearchIndex(activeIndex, debouncedResults.length, searchPageStep, 'down');
|
|
261
|
+
scrollActiveIntoView();
|
|
262
|
+
} else if (e.key === 'PageUp') {
|
|
263
|
+
e.preventDefault();
|
|
264
|
+
markKeyboardNavigation();
|
|
265
|
+
activeIndex = pageSearchIndex(activeIndex, debouncedResults.length, searchPageStep, 'up');
|
|
178
266
|
scrollActiveIntoView();
|
|
179
267
|
} else if (e.key === 'Enter' && activeIndex >= 0) {
|
|
180
268
|
e.preventDefault();
|
|
@@ -212,6 +300,9 @@
|
|
|
212
300
|
if (searchDebounceTimer) {
|
|
213
301
|
clearTimeout(searchDebounceTimer);
|
|
214
302
|
}
|
|
303
|
+
if (keyboardNavigationClearTimer) {
|
|
304
|
+
clearTimeout(keyboardNavigationClearTimer);
|
|
305
|
+
}
|
|
215
306
|
});
|
|
216
307
|
|
|
217
308
|
$: ariaActivedescendant =
|
|
@@ -258,10 +349,20 @@
|
|
|
258
349
|
<WScrollArea
|
|
259
350
|
class="search-dropdown-scroll w-full"
|
|
260
351
|
style="max-height: {resultsScrollMaxHeightPx}px;"
|
|
261
|
-
scrollOutside={
|
|
352
|
+
scrollOutside={false}
|
|
262
353
|
>
|
|
263
|
-
|
|
354
|
+
<!-- The wrapper only hears the mouse move (to tell it from a still mouse); the listbox and the options carry the roles. -->
|
|
355
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
356
|
+
<div
|
|
357
|
+
class="flex flex-col gap-0 px-2 py-2"
|
|
358
|
+
bind:this={resultsInner}
|
|
359
|
+
onpointermove={handleResultsPointerMove}
|
|
360
|
+
>
|
|
264
361
|
{#each debouncedResults as result, index (result.id || `${result.type}-${index}`)}
|
|
362
|
+
<!--
|
|
363
|
+
The highlight is the active row only (the keys and a moving mouse set it). A hover colour of its own would
|
|
364
|
+
paint a second row when the mouse rests still while the keys move the highlight.
|
|
365
|
+
-->
|
|
265
366
|
<button
|
|
266
367
|
data-result-index={index}
|
|
267
368
|
id={`file-browser-search-opt-${uid}-${index}`}
|
|
@@ -269,12 +370,9 @@
|
|
|
269
370
|
role="option"
|
|
270
371
|
tabindex="-1"
|
|
271
372
|
aria-selected={index === activeIndex}
|
|
272
|
-
class="search-dropdown-result flex min-h-12 w-full cursor-pointer items-center gap-3 rounded-xl py-2 ps-2 pe-
|
|
373
|
+
class="search-dropdown-result box-border flex min-h-12 w-full max-w-full cursor-pointer items-center gap-3 rounded-xl py-2 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background {index === activeIndex
|
|
273
374
|
? 'bg-accent'
|
|
274
|
-
: '
|
|
275
|
-
onmouseenter={() => {
|
|
276
|
-
activeIndex = index;
|
|
277
|
-
}}
|
|
375
|
+
: ''}"
|
|
278
376
|
onclick={() => openResult(result)}
|
|
279
377
|
>
|
|
280
378
|
<FileIcon
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
</script>
|
|
72
72
|
|
|
73
73
|
<div
|
|
74
|
-
class="upload-panel flex w-full min-w-0
|
|
74
|
+
class="upload-panel flex w-full min-w-0 flex-col gap-2 rounded-xl border border-border bg-background p-3 shadow-floating"
|
|
75
75
|
role="region"
|
|
76
76
|
aria-label={$t('upload.panelTitle')}
|
|
77
77
|
>
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import { useI18n } from '../../i18n';
|
|
21
21
|
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
22
22
|
import { isKnownNonImageFile } from '../../utils/fileKinds';
|
|
23
|
+
import { shouldKeepKeydownInsideMenu } from '../../utils/menuKeydownBubble';
|
|
23
24
|
import { buildTransformedUrl } from '../../utils/imageTransform';
|
|
24
25
|
import type { FileFilterType } from '../../utils/fileTypes';
|
|
25
26
|
import { isMobileStore } from '../../stores/viewportStore';
|
|
@@ -218,11 +219,20 @@
|
|
|
218
219
|
event.stopPropagation();
|
|
219
220
|
}
|
|
220
221
|
|
|
222
|
+
/** Keys stay with the dots button, except Escape, which has to reach the file browser and its host. */
|
|
223
|
+
function stopMenuKeydownBubble(event: KeyboardEvent) {
|
|
224
|
+
if (!shouldKeepKeydownInsideMenu(event.key)) return;
|
|
225
|
+
event.stopPropagation();
|
|
226
|
+
}
|
|
227
|
+
|
|
221
228
|
$: tileShellClass = [
|
|
222
229
|
'flex w-full items-center gap-3 rounded-xl border border-border bg-background p-2 transition-colors duration-fast',
|
|
223
230
|
thumbnailOnly ? 'h-auto w-auto border-0 bg-transparent p-0' : 'h-16',
|
|
224
231
|
!thumbnailOnly && allowSelecting && !isMissing && !effectiveIsMobile && !isSelected
|
|
225
|
-
? 'hover:bg-accent has-[[data-state=open]]:bg-accent'
|
|
232
|
+
? 'hover:bg-accent group-data-[drag-hover=true]/file-tile:bg-accent has-[[data-state=open]]:bg-accent'
|
|
233
|
+
: '',
|
|
234
|
+
!thumbnailOnly && allowSelecting && !isMissing && !effectiveIsMobile && isSelected
|
|
235
|
+
? 'group-data-[drag-hover=true]/file-tile:bg-brand-subtle'
|
|
226
236
|
: '',
|
|
227
237
|
!thumbnailOnly && isSelected ? 'border-brand bg-brand-subtle ring-1 ring-inset ring-brand' : '',
|
|
228
238
|
!thumbnailOnly && !isMissing ? 'cursor-pointer' : ''
|
|
@@ -362,7 +372,7 @@
|
|
|
362
372
|
role="presentation"
|
|
363
373
|
data-fb-menu-root
|
|
364
374
|
onclick={stopMenuBubble}
|
|
365
|
-
onkeydown={
|
|
375
|
+
onkeydown={stopMenuKeydownBubble}
|
|
366
376
|
>
|
|
367
377
|
<DropdownMenu
|
|
368
378
|
isFolder={false}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { type FileFilterType } from '../../utils/fileTypes';
|
|
6
6
|
import { DropdownMenu, FileIcon } from '../ui';
|
|
7
7
|
import { isMobileStore } from '../../stores/viewportStore';
|
|
8
|
+
import { shouldKeepKeydownInsideMenu } from '../../utils/menuKeydownBubble';
|
|
8
9
|
import { useI18n } from '../../i18n';
|
|
9
10
|
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
10
11
|
|
|
@@ -55,6 +56,12 @@
|
|
|
55
56
|
event.stopPropagation();
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
/** Keys stay with the dots button, except Escape, which has to reach the file browser and its host. */
|
|
60
|
+
function stopMenuKeydownBubble(event: KeyboardEvent) {
|
|
61
|
+
if (!shouldKeepKeydownInsideMenu(event.key)) return;
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
// The dots show on hover or focus, always on touch screens, and while their menu is open
|
|
59
66
|
// (the menu's trigger carries data-state="open": the pointer is then over the menu, not over the tile)
|
|
60
67
|
$: menuVisibleClass = effectiveIsMobile
|
|
@@ -97,7 +104,7 @@
|
|
|
97
104
|
role="presentation"
|
|
98
105
|
data-fb-menu-root
|
|
99
106
|
onclick={stopMenuBubble}
|
|
100
|
-
onkeydown={
|
|
107
|
+
onkeydown={stopMenuKeydownBubble}
|
|
101
108
|
>
|
|
102
109
|
<DropdownMenu isFolder={true} itemId={item.id} on:action={handleDropdownAction} />
|
|
103
110
|
</div>
|