@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
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
export let meta = '';
|
|
17
17
|
export let showMeta = true;
|
|
18
18
|
export let allowSelecting = false;
|
|
19
|
+
/** When true, the preview shows the picker Select control (editor embed mode). */
|
|
20
|
+
export let showSelectInPreview = false;
|
|
19
21
|
export let isSelected = false;
|
|
20
22
|
export let canGoPrevious = false;
|
|
21
23
|
export let canGoNext = false;
|
|
24
|
+
/** When false, previous/next controls are not shown (single item in folder). */
|
|
25
|
+
export let showNavigation = true;
|
|
22
26
|
// What a screen reader says for the close button
|
|
23
27
|
export let closeLabel = '';
|
|
24
28
|
</script>
|
|
@@ -35,36 +39,40 @@
|
|
|
35
39
|
{/if}
|
|
36
40
|
</div>
|
|
37
41
|
|
|
38
|
-
{#if allowSelecting}
|
|
42
|
+
{#if allowSelecting && (showNavigation || showSelectInPreview)}
|
|
39
43
|
<div class="flex shrink-0 items-center gap-1">
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
44
|
+
{#if showNavigation}
|
|
45
|
+
<IconButton
|
|
46
|
+
variant="ghost"
|
|
47
|
+
label={$t('preview.previousFile')}
|
|
48
|
+
disabled={!canGoPrevious}
|
|
49
|
+
onclick={() => dispatch('previous')}
|
|
50
|
+
>
|
|
51
|
+
<IconChevronLeft class="size-4 stroke-2 rtl:rotate-180" />
|
|
52
|
+
</IconButton>
|
|
53
|
+
<IconButton
|
|
54
|
+
variant="ghost"
|
|
55
|
+
label={$t('preview.nextFile')}
|
|
56
|
+
disabled={!canGoNext}
|
|
57
|
+
onclick={() => dispatch('next')}
|
|
58
|
+
>
|
|
59
|
+
<IconChevronRight class="size-4 stroke-2 rtl:rotate-180" />
|
|
60
|
+
</IconButton>
|
|
61
|
+
{/if}
|
|
62
|
+
{#if showSelectInPreview}
|
|
63
|
+
<Button
|
|
64
|
+
variant="outline"
|
|
65
|
+
size="sm"
|
|
66
|
+
class="press-feedback"
|
|
67
|
+
onclick={() => dispatch('select')}
|
|
68
|
+
>
|
|
69
|
+
{isSelected ? $t('action.selected') : $t('action.select')}
|
|
70
|
+
</Button>
|
|
71
|
+
{/if}
|
|
64
72
|
</div>
|
|
65
73
|
{/if}
|
|
66
74
|
|
|
67
75
|
<IconButton variant="ghost" label={closeLabel} onclick={() => dispatch('close')}>
|
|
68
|
-
<IconX class="size-4 stroke-
|
|
76
|
+
<IconX class="size-4 stroke-2" />
|
|
69
77
|
</IconButton>
|
|
70
78
|
</div>
|
|
@@ -16,9 +16,11 @@ declare const PreviewHeaderBar: $$__sveltets_2_IsomorphicComponent<{
|
|
|
16
16
|
meta?: string;
|
|
17
17
|
showMeta?: boolean;
|
|
18
18
|
allowSelecting?: boolean;
|
|
19
|
+
/** When true, the preview shows the picker Select control (editor embed mode). */ showSelectInPreview?: boolean;
|
|
19
20
|
isSelected?: boolean;
|
|
20
21
|
canGoPrevious?: boolean;
|
|
21
22
|
canGoNext?: boolean;
|
|
23
|
+
/** When false, previous/next controls are not shown (single item in folder). */ showNavigation?: boolean;
|
|
22
24
|
closeLabel?: string;
|
|
23
25
|
}, {
|
|
24
26
|
previous: CustomEvent<void>;
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
<div class="text-preview-container w-full" style="max-height: {scrolledAreaMaxHeight}px">
|
|
66
66
|
{#if isLoading}
|
|
67
67
|
<div class="flex min-h-[16rem] items-center justify-center gap-3 text-caption text-muted-foreground">
|
|
68
|
-
<IconLoader2 class="size-5 animate-spin stroke-[1.
|
|
68
|
+
<IconLoader2 class="size-5 animate-spin stroke-[1.6] motion-reduce:animate-none" />
|
|
69
69
|
{$t('preview.loading')}
|
|
70
70
|
</div>
|
|
71
71
|
{:else if loadFailed}
|
|
@@ -196,9 +196,9 @@
|
|
|
196
196
|
onclick={togglePlay}
|
|
197
197
|
>
|
|
198
198
|
{#if isPlaying}
|
|
199
|
-
<IconPlayerPause class="size-4 stroke-
|
|
199
|
+
<IconPlayerPause class="size-4 stroke-2" />
|
|
200
200
|
{:else}
|
|
201
|
-
<IconPlayerPlay class="size-4 stroke-
|
|
201
|
+
<IconPlayerPlay class="size-4 stroke-2" />
|
|
202
202
|
{/if}
|
|
203
203
|
</IconButton>
|
|
204
204
|
|
|
@@ -237,9 +237,9 @@
|
|
|
237
237
|
onclick={toggleMute}
|
|
238
238
|
>
|
|
239
239
|
{#if isMuted}
|
|
240
|
-
<IconVolumeOff class="size-4 stroke-
|
|
240
|
+
<IconVolumeOff class="size-4 stroke-2" />
|
|
241
241
|
{:else}
|
|
242
|
-
<IconVolume class="size-4 stroke-
|
|
242
|
+
<IconVolume class="size-4 stroke-2" />
|
|
243
243
|
{/if}
|
|
244
244
|
</IconButton>
|
|
245
245
|
</div>
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
label={$t('action.clearItems')}
|
|
94
94
|
onclick={handleClearItems}
|
|
95
95
|
>
|
|
96
|
-
<IconX class="size-4 stroke-
|
|
96
|
+
<IconX class="size-4 stroke-2" aria-hidden="true" />
|
|
97
97
|
</IconButton>
|
|
98
98
|
</div>
|
|
99
99
|
|
|
@@ -103,11 +103,11 @@
|
|
|
103
103
|
{#if capabilities.rename}
|
|
104
104
|
{#if compact}
|
|
105
105
|
<IconButton variant="ghost" size="default" label={$t('action.rename')} onclick={handleRename}>
|
|
106
|
-
<IconPencil class="size-4 stroke-
|
|
106
|
+
<IconPencil class="size-4 stroke-2" aria-hidden="true" />
|
|
107
107
|
</IconButton>
|
|
108
108
|
{:else}
|
|
109
109
|
<Button variant="ghost" size="sm" onclick={handleRename} aria-label={$t('action.rename')}>
|
|
110
|
-
<IconPencil class="size-4 shrink-0 stroke-
|
|
110
|
+
<IconPencil class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
111
111
|
{$t('action.rename')}
|
|
112
112
|
</Button>
|
|
113
113
|
{/if}
|
|
@@ -115,11 +115,11 @@
|
|
|
115
115
|
{#if capabilities.download}
|
|
116
116
|
{#if compact}
|
|
117
117
|
<IconButton variant="ghost" size="default" label={$t('action.download')} onclick={handleDownload}>
|
|
118
|
-
<IconDownload class="size-4 stroke-
|
|
118
|
+
<IconDownload class="size-4 stroke-2" aria-hidden="true" />
|
|
119
119
|
</IconButton>
|
|
120
120
|
{:else}
|
|
121
121
|
<Button variant="ghost" size="sm" onclick={handleDownload} aria-label={$t('action.download')}>
|
|
122
|
-
<IconDownload class="size-4 shrink-0 stroke-
|
|
122
|
+
<IconDownload class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
123
123
|
{$t('action.download')}
|
|
124
124
|
</Button>
|
|
125
125
|
{/if}
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
label={isSingle ? $t('action.move') : $t('toolbar.moveMany', { count: selectedFiles.length })}
|
|
135
135
|
onclick={handleMove}
|
|
136
136
|
>
|
|
137
|
-
<IconArrowsMove class="size-4 stroke-
|
|
137
|
+
<IconArrowsMove class="size-4 stroke-2" aria-hidden="true" />
|
|
138
138
|
</IconButton>
|
|
139
139
|
{:else}
|
|
140
140
|
<Button
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
onclick={handleMove}
|
|
144
144
|
aria-label={isSingle ? $t('action.move') : $t('toolbar.moveMany', { count: selectedFiles.length })}
|
|
145
145
|
>
|
|
146
|
-
<IconArrowsMove class="size-4 shrink-0 stroke-
|
|
146
|
+
<IconArrowsMove class="size-4 shrink-0 stroke-2 rtl:-scale-x-100" aria-hidden="true" />
|
|
147
147
|
{isSingle ? $t('action.move') : $t('toolbar.moveMany', { count: selectedFiles.length })}
|
|
148
148
|
</Button>
|
|
149
149
|
{/if}
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
onclick={handleDelete}
|
|
159
159
|
class="text-destructive hover:text-destructive"
|
|
160
160
|
>
|
|
161
|
-
<IconTrash class="size-4 stroke-
|
|
161
|
+
<IconTrash class="size-4 stroke-2" aria-hidden="true" />
|
|
162
162
|
</IconButton>
|
|
163
163
|
{:else}
|
|
164
164
|
<Button
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
onclick={handleDelete}
|
|
169
169
|
aria-label={isSingle ? $t('action.delete') : $t('toolbar.deleteMany', { count: selectedFiles.length })}
|
|
170
170
|
>
|
|
171
|
-
<IconTrash class="size-4 shrink-0 stroke-
|
|
171
|
+
<IconTrash class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
172
172
|
{isSingle ? $t('action.delete') : $t('toolbar.deleteMany', { count: selectedFiles.length })}
|
|
173
173
|
</Button>
|
|
174
174
|
{/if}
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
aria-label={confirmAddLabel}
|
|
183
183
|
disabled={confirmAddDisabled}
|
|
184
184
|
>
|
|
185
|
-
<IconCheck class="size-4 shrink-0 stroke-
|
|
185
|
+
<IconCheck class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
186
186
|
{confirmAddLabel}
|
|
187
187
|
</Button>
|
|
188
188
|
{/if}
|
|
@@ -18,11 +18,17 @@
|
|
|
18
18
|
|
|
19
19
|
let selectionBox: HTMLDivElement;
|
|
20
20
|
let isDragging = false;
|
|
21
|
+
/** Parent reads whether a rubber-band drag is active (Escape cancels the drag, not the selection). */
|
|
22
|
+
export let dragBandActive = false;
|
|
23
|
+
$: dragBandActive = isDragging;
|
|
21
24
|
let startX = 0;
|
|
22
25
|
let startY = 0;
|
|
23
26
|
let currentX = 0;
|
|
24
27
|
let currentY = 0;
|
|
25
28
|
let scrollStartY = 0;
|
|
29
|
+
/** Where the pointer is in the viewport: the auto-scroll reads it while the pointer rests and the list moves under it. */
|
|
30
|
+
let lastPointerClientX = 0;
|
|
31
|
+
let lastPointerClientY = 0;
|
|
26
32
|
let autoScrollInterval: number | null = null;
|
|
27
33
|
let selectedItemIds = new Set<string>();
|
|
28
34
|
let cleanup: (() => void) | null = null;
|
|
@@ -47,6 +53,12 @@
|
|
|
47
53
|
return element.getAttribute('data-selected') === 'true';
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
function clearDragHoverMarkup(element: Element) {
|
|
57
|
+
element.classList.remove('hover-effect');
|
|
58
|
+
element.classList.remove('recent-file-selected');
|
|
59
|
+
element.removeAttribute('data-drag-hover');
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
function cacheItems() {
|
|
51
63
|
if (!container) return;
|
|
52
64
|
const alreadySelectedInStore = persistentSelectStore.getSelected(currentFilter);
|
|
@@ -119,6 +131,7 @@
|
|
|
119
131
|
|
|
120
132
|
function handleKeyDown(e: KeyboardEvent) {
|
|
121
133
|
if (e.key === 'Escape' && isDragging) {
|
|
134
|
+
e.stopPropagation();
|
|
122
135
|
mouseIsDown = false;
|
|
123
136
|
isDragging = false;
|
|
124
137
|
|
|
@@ -128,9 +141,7 @@
|
|
|
128
141
|
|
|
129
142
|
stopAutoScroll();
|
|
130
143
|
|
|
131
|
-
container.querySelectorAll('.hover-effect').forEach(
|
|
132
|
-
element.classList.remove('hover-effect');
|
|
133
|
-
});
|
|
144
|
+
container.querySelectorAll('.hover-effect').forEach(clearDragHoverMarkup);
|
|
134
145
|
|
|
135
146
|
hasMovedEnough = false;
|
|
136
147
|
startItemId = null;
|
|
@@ -209,15 +220,17 @@
|
|
|
209
220
|
.filter((id): id is string => id !== null)
|
|
210
221
|
);
|
|
211
222
|
|
|
212
|
-
scrollStartY = container.scrollTop || 0;
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
startX = e.clientX -
|
|
217
|
-
startY = e.clientY -
|
|
223
|
+
scrollStartY = getScrollableElement()?.scrollTop || container.scrollTop || 0;
|
|
224
|
+
|
|
225
|
+
const containerRect = container.getBoundingClientRect();
|
|
226
|
+
|
|
227
|
+
startX = e.clientX - containerRect.left;
|
|
228
|
+
startY = e.clientY - containerRect.top;
|
|
218
229
|
|
|
219
230
|
currentX = startX;
|
|
220
231
|
currentY = startY;
|
|
232
|
+
lastPointerClientX = e.clientX;
|
|
233
|
+
lastPointerClientY = e.clientY;
|
|
221
234
|
};
|
|
222
235
|
|
|
223
236
|
const handleMouseMove = (e: MouseEvent) => {
|
|
@@ -230,10 +243,12 @@
|
|
|
230
243
|
e.preventDefault();
|
|
231
244
|
e.stopPropagation();
|
|
232
245
|
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
currentX = e.clientX -
|
|
236
|
-
currentY = e.clientY -
|
|
246
|
+
const containerRect = container.getBoundingClientRect();
|
|
247
|
+
|
|
248
|
+
currentX = e.clientX - containerRect.left;
|
|
249
|
+
currentY = e.clientY - containerRect.top;
|
|
250
|
+
lastPointerClientX = e.clientX;
|
|
251
|
+
lastPointerClientY = e.clientY;
|
|
237
252
|
|
|
238
253
|
if (scrollContainer) {
|
|
239
254
|
const bounds = scrollContainer.getBoundingClientRect();
|
|
@@ -317,10 +332,7 @@
|
|
|
317
332
|
resetSelectionBox();
|
|
318
333
|
stopAutoScroll();
|
|
319
334
|
|
|
320
|
-
container.querySelectorAll('.hover-effect').forEach(
|
|
321
|
-
element.classList.remove('hover-effect');
|
|
322
|
-
element.classList.remove('recent-file-selected');
|
|
323
|
-
});
|
|
335
|
+
container.querySelectorAll('.hover-effect').forEach(clearDragHoverMarkup);
|
|
324
336
|
|
|
325
337
|
hasMovedEnough = false;
|
|
326
338
|
startItemId = null;
|
|
@@ -403,15 +415,14 @@
|
|
|
403
415
|
});
|
|
404
416
|
}
|
|
405
417
|
|
|
406
|
-
container.querySelectorAll('.hover-effect').forEach(element => {
|
|
407
|
-
element.classList.remove('hover-effect');
|
|
408
|
-
|
|
418
|
+
container.querySelectorAll('.hover-effect').forEach((element) => {
|
|
409
419
|
const itemId = element.getAttribute('data-item-id');
|
|
410
|
-
const isAlreadySelected =
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
420
|
+
const isAlreadySelected =
|
|
421
|
+
isItemSelectedInDom(element as HTMLElement) ||
|
|
422
|
+
(itemId != null && alreadySelectedInStore.includes(itemId));
|
|
423
|
+
clearDragHoverMarkup(element);
|
|
424
|
+
if (isAlreadySelected && element instanceof HTMLElement) {
|
|
425
|
+
element.setAttribute('data-selected', 'true');
|
|
415
426
|
}
|
|
416
427
|
});
|
|
417
428
|
|
|
@@ -478,19 +489,13 @@
|
|
|
478
489
|
let width = Math.abs(currentX - startX);
|
|
479
490
|
let height = Math.abs(currentY - startY);
|
|
480
491
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
left = Math.max(left, scrollLeft);
|
|
490
|
-
top = Math.max(top, scrollTop);
|
|
491
|
-
width = Math.min(width, scrollRight - left);
|
|
492
|
-
height = Math.min(height, scrollBottom - top);
|
|
493
|
-
}
|
|
492
|
+
// Clamp within the content container (grid + recent), not only the scroll viewport.
|
|
493
|
+
const maxWidth = container.clientWidth;
|
|
494
|
+
const maxHeight = container.clientHeight;
|
|
495
|
+
left = Math.max(left, 0);
|
|
496
|
+
top = Math.max(top, 0);
|
|
497
|
+
width = Math.min(width, maxWidth - left);
|
|
498
|
+
height = Math.min(height, maxHeight - top);
|
|
494
499
|
|
|
495
500
|
selectionBox.style.display = 'block';
|
|
496
501
|
// rtl-ok: rubber-band box between two pointer positions in the scroll container's coordinate space
|
|
@@ -525,50 +530,73 @@
|
|
|
525
530
|
const isMarked = intersectsSelection || item.isSelectedInStore || item.isSelectedInDom;
|
|
526
531
|
|
|
527
532
|
if (isMarked) {
|
|
528
|
-
if (!
|
|
533
|
+
if (!item.element.classList.contains('hover-effect')) {
|
|
529
534
|
selectedItemIds.add(item.id);
|
|
530
535
|
item.element.classList.add('hover-effect');
|
|
536
|
+
item.element.setAttribute('data-drag-hover', 'true');
|
|
531
537
|
if (item.isInRecentFiles) {
|
|
532
538
|
item.element.classList.add('recent-file-selected');
|
|
533
539
|
}
|
|
534
540
|
}
|
|
535
|
-
} else
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
541
|
+
} else if (
|
|
542
|
+
!initiallySelectedItems.has(item.id) &&
|
|
543
|
+
!item.isSelectedInStore &&
|
|
544
|
+
!item.isSelectedInDom
|
|
545
|
+
) {
|
|
546
|
+
if (item.element.classList.contains('hover-effect')) {
|
|
547
|
+
selectedItemIds.delete(item.id);
|
|
548
|
+
clearDragHoverMarkup(item.element);
|
|
542
549
|
}
|
|
543
550
|
}
|
|
544
551
|
}
|
|
545
552
|
}
|
|
546
553
|
|
|
554
|
+
/**
|
|
555
|
+
* The element that really scrolls. `scrollContainer` is the root of the scroll area, which never scrolls itself:
|
|
556
|
+
* the list moves inside the viewport element in it, so writing `scrollTop` on the root did nothing and the drag
|
|
557
|
+
* could not reach files below the fold (the recent files) at all.
|
|
558
|
+
*/
|
|
559
|
+
function getScrollableElement(): HTMLElement | null {
|
|
560
|
+
if (!scrollContainer) return null;
|
|
561
|
+
return scrollContainer.querySelector<HTMLElement>('[data-scroll-area-viewport]') ?? scrollContainer;
|
|
562
|
+
}
|
|
563
|
+
|
|
547
564
|
function startAutoScroll() {
|
|
548
565
|
if (!scrollContainer) return;
|
|
549
566
|
|
|
550
|
-
|
|
567
|
+
// Already running: it reads the pointer from lastPointerClientX/Y on every tick, so every pointer move restarting
|
|
568
|
+
// it only kept it from ever firing while the pointer moved.
|
|
569
|
+
if (autoScrollInterval !== null) return;
|
|
551
570
|
|
|
552
571
|
autoScrollInterval = window.setInterval(() => {
|
|
553
|
-
|
|
572
|
+
const scrollableElement = getScrollableElement();
|
|
573
|
+
if (!isDragging || !scrollContainer || !scrollableElement || !container) return;
|
|
554
574
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
const
|
|
575
|
+
// The pointer is read in the viewport (where the user holds it), not rebuilt from the box coordinates: those move
|
|
576
|
+
// with the content, so after the first few steps of scrolling they put the pointer in the wrong place and the
|
|
577
|
+
// list stopped scrolling long before the recent files were reached.
|
|
578
|
+
const scrollRect = scrollContainer.getBoundingClientRect();
|
|
579
|
+
const distanceFromTop = lastPointerClientY - scrollRect.top;
|
|
580
|
+
const distanceFromBottom = scrollRect.bottom - lastPointerClientY;
|
|
560
581
|
|
|
561
582
|
let scrolled = false;
|
|
562
583
|
|
|
563
584
|
if (distanceFromTop < SCROLL_THRESHOLD) {
|
|
564
|
-
|
|
565
|
-
|
|
585
|
+
const previousScrollTop = scrollableElement.scrollTop;
|
|
586
|
+
scrollableElement.scrollTop -= SCROLL_SPEED;
|
|
587
|
+
scrolled = scrollableElement.scrollTop !== previousScrollTop;
|
|
566
588
|
} else if (distanceFromBottom < SCROLL_THRESHOLD) {
|
|
567
|
-
|
|
568
|
-
|
|
589
|
+
const previousScrollTop = scrollableElement.scrollTop;
|
|
590
|
+
scrollableElement.scrollTop += SCROLL_SPEED;
|
|
591
|
+
scrolled = scrollableElement.scrollTop !== previousScrollTop;
|
|
569
592
|
}
|
|
570
593
|
|
|
571
594
|
if (scrolled) {
|
|
595
|
+
// The content moved under a resting pointer: the box grows to where the pointer now is in the content.
|
|
596
|
+
const containerRect = container.getBoundingClientRect();
|
|
597
|
+
currentX = lastPointerClientX - containerRect.left;
|
|
598
|
+
currentY = lastPointerClientY - containerRect.top;
|
|
599
|
+
updateSelectionBox();
|
|
572
600
|
cacheItems();
|
|
573
601
|
checkIntersections();
|
|
574
602
|
}
|
|
@@ -592,16 +620,6 @@
|
|
|
592
620
|
{/if}
|
|
593
621
|
|
|
594
622
|
<style>
|
|
595
|
-
:global(.hover-effect > *) {
|
|
596
|
-
background-color: var(--accent) !important;
|
|
597
|
-
border-radius: var(--radius-xl) !important;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
:global(.recent-file-selected.hover-effect > *) {
|
|
601
|
-
background-color: var(--brand-subtle) !important;
|
|
602
|
-
box-shadow: inset 0 0 0 1px var(--brand) !important;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
623
|
:global(.modal-content-inner-container),
|
|
606
624
|
:global(.base-modal-portal),
|
|
607
625
|
:global(.modal-content-root-container),
|
|
@@ -19,6 +19,7 @@ declare const DragSelect: $$__sveltets_2_IsomorphicComponent<{
|
|
|
19
19
|
items?: FileSystemItem[];
|
|
20
20
|
scrollContainer?: HTMLElement | null;
|
|
21
21
|
currentFilter?: FileFilterType;
|
|
22
|
+
/** Parent reads whether a rubber-band drag is active (Escape cancels the drag, not the selection). */ dragBandActive?: boolean;
|
|
22
23
|
}, {
|
|
23
24
|
select: CustomEvent<{
|
|
24
25
|
added: FileSystemItem[];
|
|
@@ -50,25 +50,25 @@
|
|
|
50
50
|
<div class="dropdown-wrapper relative">
|
|
51
51
|
<DropdownMenu.Root>
|
|
52
52
|
<DropdownMenu.Trigger class={triggerClass} aria-label={$t('menu.open')}>
|
|
53
|
-
<IconDots class="size-4 stroke-
|
|
53
|
+
<IconDots class="size-4 stroke-2" aria-hidden="true" />
|
|
54
54
|
<span class="sr-only">{$t('menu.moreOptions')}</span>
|
|
55
55
|
</DropdownMenu.Trigger>
|
|
56
56
|
<DropdownMenu.Content class="more-options-content w-[200px]" align="end" sideOffset={4}>
|
|
57
57
|
{#if canRename}
|
|
58
58
|
<DropdownMenu.Item onclick={() => handleAction('rename')}>
|
|
59
|
-
<IconPencil class="stroke-
|
|
59
|
+
<IconPencil class="stroke-2" />
|
|
60
60
|
{$t('action.rename')}
|
|
61
61
|
</DropdownMenu.Item>
|
|
62
62
|
{/if}
|
|
63
63
|
{#if canDownload}
|
|
64
64
|
<DropdownMenu.Item onclick={() => handleAction('download')}>
|
|
65
|
-
<IconDownload class="stroke-
|
|
65
|
+
<IconDownload class="stroke-2" />
|
|
66
66
|
{$t('action.download')}
|
|
67
67
|
</DropdownMenu.Item>
|
|
68
68
|
{/if}
|
|
69
69
|
{#if canMove}
|
|
70
70
|
<DropdownMenu.Item onclick={() => handleAction('move')}>
|
|
71
|
-
<IconArrowsMove class="stroke-
|
|
71
|
+
<IconArrowsMove class="stroke-2" />
|
|
72
72
|
{$t('action.move')}
|
|
73
73
|
</DropdownMenu.Item>
|
|
74
74
|
{/if}
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
class="text-destructive data-highlighted:text-destructive"
|
|
81
81
|
onclick={() => handleAction('delete')}
|
|
82
82
|
>
|
|
83
|
-
<IconTrash class="stroke-
|
|
83
|
+
<IconTrash class="stroke-2" />
|
|
84
84
|
{$t('action.delete')}
|
|
85
85
|
</DropdownMenu.Item>
|
|
86
86
|
{/if}
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
const SQUARE_CLASSES = { lg: 'size-12', md: 'size-10', sm: 'size-8' } as const;
|
|
84
84
|
const ICON_CLASSES = {
|
|
85
85
|
lg: 'size-5 stroke-[1.667]',
|
|
86
|
-
md: 'size-4 stroke-
|
|
87
|
-
sm: 'size-4 stroke-
|
|
86
|
+
md: 'size-4 stroke-2',
|
|
87
|
+
sm: 'size-4 stroke-2'
|
|
88
88
|
} as const;
|
|
89
89
|
const GLYPH_CLASSES = {
|
|
90
90
|
lg: 'text-heading-page',
|
|
@@ -477,13 +477,15 @@
|
|
|
477
477
|
},
|
|
478
478
|
{
|
|
479
479
|
"id": "file_pqr844",
|
|
480
|
-
"name": "
|
|
480
|
+
"name": "image 30.jpg",
|
|
481
481
|
"type": "file",
|
|
482
|
-
"size":
|
|
482
|
+
"size": 2400000,
|
|
483
|
+
"width": 1024,
|
|
484
|
+
"height": 683,
|
|
483
485
|
"modified": "2023-09-24T16:30:00Z",
|
|
484
|
-
"url": "
|
|
485
|
-
"thumbnail": "
|
|
486
|
-
"hash": "
|
|
486
|
+
"url": "image/image 30.jpg",
|
|
487
|
+
"thumbnail": "thumbnail/image 30.jpg",
|
|
488
|
+
"hash": "C4 B7 05 05 80 F5 1A C7 7E 76 89 83 83 8C A6 86 05 71 7A 12 F8"
|
|
487
489
|
},
|
|
488
490
|
{
|
|
489
491
|
"id": "folder_stu910",
|
|
@@ -1156,15 +1158,15 @@
|
|
|
1156
1158
|
},
|
|
1157
1159
|
{
|
|
1158
1160
|
"id": "file_stu364",
|
|
1159
|
-
"name": "image
|
|
1161
|
+
"name": "image 29.jpg",
|
|
1160
1162
|
"type": "file",
|
|
1161
|
-
"size":
|
|
1163
|
+
"size": 3050000,
|
|
1162
1164
|
"width": 1024,
|
|
1163
1165
|
"height": 683,
|
|
1164
|
-
"modified": "2024-09-27T11:
|
|
1165
|
-
"url": "image/image
|
|
1166
|
-
"thumbnail": "thumbnail/image
|
|
1167
|
-
"hash": "
|
|
1166
|
+
"modified": "2024-09-27T11:50:00Z",
|
|
1167
|
+
"url": "image/image 29.jpg",
|
|
1168
|
+
"thumbnail": "thumbnail/image 29.jpg",
|
|
1169
|
+
"hash": "E2 B7 05 05 80 F5 1A C7 7E 76 89 83 83 8C A6 86 05 71 7A 12 F9"
|
|
1168
1170
|
}
|
|
1169
1171
|
]
|
|
1170
1172
|
}
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -230,7 +230,6 @@ export declare const FILE_BROWSER_MESSAGES: {
|
|
|
230
230
|
readonly 'selectedFiles.count': "{count, plural, one {# file selected} other {# files selected}}";
|
|
231
231
|
readonly 'selectedFiles.confirmMany': "{count, plural, one {Use # file} other {Use # files}}";
|
|
232
232
|
readonly 'selectedFiles.remove': "Remove from selection";
|
|
233
|
-
readonly 'searchModal.placeholder': "Search files and folders…";
|
|
234
233
|
readonly 'searchModal.jumpToFolder': "Jump to folder";
|
|
235
234
|
readonly 'searchModal.empty': "No files found";
|
|
236
235
|
readonly 'searchModal.clearQuery': "Clear search";
|
package/dist/i18n/messages.js
CHANGED
|
@@ -242,7 +242,6 @@ export const FILE_BROWSER_MESSAGES = {
|
|
|
242
242
|
'selectedFiles.confirmMany': '{count, plural, one {Use # file} other {Use # files}}',
|
|
243
243
|
'selectedFiles.remove': 'Remove from selection',
|
|
244
244
|
// ===== Search window =====
|
|
245
|
-
'searchModal.placeholder': 'Search files and folders…',
|
|
246
245
|
'searchModal.jumpToFolder': 'Jump to folder',
|
|
247
246
|
'searchModal.empty': 'No files found',
|
|
248
247
|
'searchModal.clearQuery': 'Clear search',
|
|
@@ -5,7 +5,7 @@ export declare const fileStore: {
|
|
|
5
5
|
update: (this: void, updater: import("svelte/store").Updater<FileSystemRoot>) => void;
|
|
6
6
|
};
|
|
7
7
|
export declare const currentFolder: import("svelte/store").Writable<string[]>;
|
|
8
|
-
export declare const sortCriteria: import("svelte/store").Writable<"name" | "
|
|
8
|
+
export declare const sortCriteria: import("svelte/store").Writable<"name" | "size" | "date">;
|
|
9
9
|
export declare const sortDirection: import("svelte/store").Writable<"desc" | "asc">;
|
|
10
10
|
export declare const selectedFiles: import("svelte/store").Writable<FileSystemItem[]>;
|
|
11
11
|
export declare const fileFilter: import("svelte/store").Writable<string[]>;
|
|
@@ -13,7 +13,7 @@ export declare const fileFilter: import("svelte/store").Writable<string[]>;
|
|
|
13
13
|
* Derived store that automatically sorts files based on criteria
|
|
14
14
|
* Maintains folder priority (folders always appear before files)
|
|
15
15
|
*/
|
|
16
|
-
export declare const sortedFiles: import("svelte/store").Readable<
|
|
16
|
+
export declare const sortedFiles: import("svelte/store").Readable<FileSystemRoot>;
|
|
17
17
|
/**
|
|
18
18
|
* Initializes or updates the file store with new data
|
|
19
19
|
* Includes validation and error handling
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { currentFolder } from './fileStore';
|
|
2
|
-
export declare const currentPathNames: import("svelte/store").Readable<
|
|
2
|
+
export declare const currentPathNames: import("svelte/store").Readable<string[]>;
|
|
3
3
|
export { currentFolder };
|
|
4
4
|
export declare const navigationActions: import("svelte/store").Writable<{
|
|
5
5
|
navigateToPath: (path: string[]) => void;
|
|
@@ -11,6 +11,11 @@ export type NavigationState = {
|
|
|
11
11
|
currentIndex: number;
|
|
12
12
|
};
|
|
13
13
|
export declare function getStorageKey(instanceId?: string): string;
|
|
14
|
+
/** Shared localStorage id for file pickers inside the Widgetic editor (folder path only, not filter/sort). */
|
|
15
|
+
export declare const WIDGETIC_EDITOR_FILE_PICKER_INSTANCE_ID = "widgetic-editor-file-picker";
|
|
16
|
+
/** Toggles whether this instance may write its folder path to localStorage (set from FileBrowser props). */
|
|
17
|
+
export declare function setPersistFolderPath(instanceId: string, enabled: boolean): void;
|
|
18
|
+
export declare function shouldPersistFolderPath(instanceId: string): boolean;
|
|
14
19
|
declare function createNavigationStore(instanceId?: string): {
|
|
15
20
|
subscribe: (this: void, run: import("svelte/store").Subscriber<NavigationState>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
16
21
|
navigateToFolder: (newPath: string[], forceNavigation?: boolean) => void;
|