@widgetic/file-browser 0.5.36 → 0.5.38
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 +88 -98
- package/dist/components/core/FileUploader.svelte +307 -133
- package/dist/components/core/Header.svelte +1 -1
- package/dist/components/core/RecentFiles.svelte +21 -8
- package/dist/components/core/SearchDropdown.svelte +312 -0
- package/dist/components/core/SearchDropdown.svelte.d.ts +30 -0
- package/dist/components/core/UploadPanel.svelte +27 -15
- package/dist/components/core/UploadPanel.svelte.d.ts +3 -0
- package/dist/components/core/UploadRow.svelte +22 -1
- package/dist/components/core/UploadRow.svelte.d.ts +3 -0
- package/dist/components/core/index.d.ts +1 -0
- package/dist/components/core/index.js +1 -0
- package/dist/components/items/FileItem.svelte +28 -3
- package/dist/components/items/FolderItem.svelte +21 -2
- package/dist/components/modals/MoveDialog.svelte +16 -11
- package/dist/components/modals/MoveDialog.svelte.d.ts +1 -0
- package/dist/components/modals/SearchModal.svelte +4 -44
- package/dist/components/ui/DropdownMenu.svelte +7 -3
- package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -0
- package/dist/i18n/messages.d.ts +7 -1
- package/dist/i18n/messages.js +7 -1
- package/dist/utils/fileNames.d.ts +9 -0
- package/dist/utils/fileNames.js +19 -0
- package/dist/utils/libraryTree.d.ts +22 -0
- package/dist/utils/libraryTree.js +177 -0
- package/dist/utils/searchItems.d.ts +27 -0
- package/dist/utils/searchItems.js +77 -0
- package/dist/utils/uploadProgressMath.d.ts +29 -0
- package/dist/utils/uploadProgressMath.js +66 -0
- package/dist/utils/uploadResponseMapping.d.ts +11 -0
- package/dist/utils/uploadResponseMapping.js +51 -0
- package/dist/utils/uploadUiHelpers.d.ts +28 -0
- package/dist/utils/uploadUiHelpers.js +49 -0
- package/dist/utils/userUploadsStorage.d.ts +2 -2
- package/dist/utils/userUploadsStorage.js +25 -17
- package/dist/utils/widgeticTusUpload.d.ts +2 -0
- package/dist/utils/widgeticTusUpload.js +4 -20
- package/dist/utils/widgeticUpload.js +3 -66
- package/dist/utils/xhrMultipartUpload.d.ts +16 -0
- package/dist/utils/xhrMultipartUpload.js +125 -0
- package/package.json +3 -3
|
@@ -135,6 +135,19 @@
|
|
|
135
135
|
dispatch('select', file);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/** Same idea as FileItem.handleTileClick: card body selects or opens preview; preview button stays separate. */
|
|
139
|
+
function handleRecentCardClick(event: MouseEvent, file: FileSystemItem) {
|
|
140
|
+
const target = event.target as HTMLElement;
|
|
141
|
+
if (target.closest('.item-preview')) return;
|
|
142
|
+
if (target.closest('[data-fb-recent-badge]')) return;
|
|
143
|
+
if (file.isMissing || errorStates.get(file.id)) return;
|
|
144
|
+
if (allowSelecting) {
|
|
145
|
+
handleFileSelect(file);
|
|
146
|
+
} else {
|
|
147
|
+
handleFileClick(file);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
138
151
|
function isSelected(file: FileSystemItem): boolean {
|
|
139
152
|
return selectedFiles.some((selectedFile) => selectedFile.id === file.id);
|
|
140
153
|
}
|
|
@@ -179,12 +192,13 @@
|
|
|
179
192
|
|
|
180
193
|
function cardShellClass(file: FileSystemItem): string {
|
|
181
194
|
const selected = isSelected(file);
|
|
195
|
+
const interactive = !file.isMissing && !errorStates.get(file.id);
|
|
182
196
|
return [
|
|
183
197
|
'item-container group flex w-full flex-col gap-2 rounded-xl border bg-background p-2 transition-colors duration-fast',
|
|
184
198
|
selected
|
|
185
199
|
? 'border-brand bg-brand-subtle ring-1 ring-inset ring-brand'
|
|
186
200
|
: 'border-border hover:bg-accent',
|
|
187
|
-
|
|
201
|
+
interactive ? 'cursor-pointer' : ''
|
|
188
202
|
]
|
|
189
203
|
.filter(Boolean)
|
|
190
204
|
.join(' ');
|
|
@@ -208,12 +222,7 @@
|
|
|
208
222
|
data-item-id={file.id}
|
|
209
223
|
data-selected={isSelected(file) ? 'true' : undefined}
|
|
210
224
|
class={cardShellClass(file)}
|
|
211
|
-
onclick={(e) =>
|
|
212
|
-
const target = e.target as HTMLElement;
|
|
213
|
-
if (!target.closest('.item-preview')) {
|
|
214
|
-
handleFileSelect(file);
|
|
215
|
-
}
|
|
216
|
-
}}
|
|
225
|
+
onclick={(e) => handleRecentCardClick(e, file)}
|
|
217
226
|
>
|
|
218
227
|
<button
|
|
219
228
|
type="button"
|
|
@@ -284,7 +293,11 @@
|
|
|
284
293
|
</p>
|
|
285
294
|
</div>
|
|
286
295
|
{#if allowSelecting && isSelected(file)}
|
|
287
|
-
|
|
296
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
297
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
298
|
+
<span data-fb-recent-badge class="shrink-0" onclick={(e) => e.stopPropagation()}>
|
|
299
|
+
<SelectedBadge label={$t('action.selected')} />
|
|
300
|
+
</span>
|
|
288
301
|
{/if}
|
|
289
302
|
</div>
|
|
290
303
|
</div>
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Inline global search: type in place, results in a panel under the field (replaces the modal flow in FileBrowser).
|
|
4
|
+
*/
|
|
5
|
+
import { createEventDispatcher, onDestroy, onMount, tick } from 'svelte';
|
|
6
|
+
import { WScrollArea, EmptyState, SearchInput } from '@widgetic/design-system/components';
|
|
7
|
+
import { IconCornerUpRight } from '@widgetic/design-system/icons';
|
|
8
|
+
|
|
9
|
+
import { FileIcon } from '../ui';
|
|
10
|
+
import type { FileSystemItem } from '../../types';
|
|
11
|
+
import type { FileFilterType } from '../../utils/fileTypes';
|
|
12
|
+
import { highlightMatchesAsHtml } from '../../utils/safeText';
|
|
13
|
+
import {
|
|
14
|
+
filterSearchResults,
|
|
15
|
+
findItemPath,
|
|
16
|
+
parentFolderLocationLabel,
|
|
17
|
+
SEARCH_LOCATION_SEPARATOR,
|
|
18
|
+
searchFileSystem
|
|
19
|
+
} from '../../utils/searchItems';
|
|
20
|
+
import { useI18n } from '../../i18n';
|
|
21
|
+
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
22
|
+
|
|
23
|
+
const dispatch = createEventDispatcher<{
|
|
24
|
+
navigate: { path: string[]; preview?: FileSystemItem };
|
|
25
|
+
}>();
|
|
26
|
+
|
|
27
|
+
const { t } = useI18n();
|
|
28
|
+
const textDirection = useTextDirection();
|
|
29
|
+
$: nameDirection = dirForUserText($textDirection);
|
|
30
|
+
|
|
31
|
+
export let currentFilter: FileFilterType = 'all';
|
|
32
|
+
/** Tree root (Widgetic file store). */
|
|
33
|
+
export let root: FileSystemItem | null = null;
|
|
34
|
+
/** First segment of the location line: e.g. translated `library.defaultLabel` or `breadcrumbs.root`. */
|
|
35
|
+
export let rootDisplayLabel = '';
|
|
36
|
+
export let showLogs = false;
|
|
37
|
+
|
|
38
|
+
const matchHighlightClass = 'rounded-sm bg-brand-subtle px-0.5 text-body-medium';
|
|
39
|
+
const resultsScrollMaxHeightPx = 400;
|
|
40
|
+
const uid =
|
|
41
|
+
typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
|
42
|
+
? crypto.randomUUID()
|
|
43
|
+
: `fb-search-${Math.random().toString(36).slice(2)}`;
|
|
44
|
+
const listboxId = `file-browser-search-listbox-${uid}`;
|
|
45
|
+
const comboboxId = `file-browser-search-combobox-${uid}`;
|
|
46
|
+
|
|
47
|
+
let searchValue = '';
|
|
48
|
+
/** Results after debounce; drives the list. */
|
|
49
|
+
let debouncedResults: FileSystemItem[] = [];
|
|
50
|
+
let activeIndex = -1;
|
|
51
|
+
/** Panel is open while typing or after focus with a non-empty debounced term. */
|
|
52
|
+
let panelOpen = false;
|
|
53
|
+
let rootEl: HTMLDivElement | null = null;
|
|
54
|
+
let resultsInner: HTMLDivElement | null = null;
|
|
55
|
+
/** The field's native input (the design system's Search Field binds it), to put the focus back after a clear. */
|
|
56
|
+
let searchInputElement: HTMLInputElement | null = null;
|
|
57
|
+
|
|
58
|
+
let searchDebounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
59
|
+
|
|
60
|
+
$: debouncedTermEmpty = !searchValue.trim();
|
|
61
|
+
$: showPanel = panelOpen && !debouncedTermEmpty;
|
|
62
|
+
|
|
63
|
+
$: {
|
|
64
|
+
const term = searchValue.trim();
|
|
65
|
+
if (searchDebounceTimer) {
|
|
66
|
+
clearTimeout(searchDebounceTimer);
|
|
67
|
+
searchDebounceTimer = null;
|
|
68
|
+
}
|
|
69
|
+
if (!term || !root) {
|
|
70
|
+
debouncedResults = [];
|
|
71
|
+
activeIndex = -1;
|
|
72
|
+
} else {
|
|
73
|
+
searchDebounceTimer = setTimeout(() => {
|
|
74
|
+
try {
|
|
75
|
+
const termLower = term.toLowerCase();
|
|
76
|
+
const raw = searchFileSystem(root, termLower, currentFilter);
|
|
77
|
+
debouncedResults = filterSearchResults(raw, currentFilter);
|
|
78
|
+
activeIndex = debouncedResults.length > 0 ? 0 : -1;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (showLogs) console.error('[SearchDropdown] search failed:', error);
|
|
81
|
+
debouncedResults = [];
|
|
82
|
+
activeIndex = -1;
|
|
83
|
+
}
|
|
84
|
+
}, 150);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function highlightMatch(name: string, term: string): string {
|
|
89
|
+
return highlightMatchesAsHtml(name, term, matchHighlightClass);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function captionFor(item: FileSystemItem): string {
|
|
93
|
+
if (!root) return '';
|
|
94
|
+
try {
|
|
95
|
+
const idPath = findItemPath(root, item);
|
|
96
|
+
if (!idPath) return '';
|
|
97
|
+
return parentFolderLocationLabel(root, idPath, rootDisplayLabel, SEARCH_LOCATION_SEPARATOR);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (showLogs) console.error('[SearchDropdown] caption failed:', error);
|
|
100
|
+
return '';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function scrollActiveIntoView() {
|
|
105
|
+
if (!resultsInner || activeIndex < 0) return;
|
|
106
|
+
tick().then(() => {
|
|
107
|
+
const row = resultsInner?.querySelector(`[data-result-index="${activeIndex}"]`) as HTMLElement | null;
|
|
108
|
+
row?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function openResult(item: FileSystemItem) {
|
|
113
|
+
if (!root) return;
|
|
114
|
+
try {
|
|
115
|
+
const idPath = findItemPath(root, item);
|
|
116
|
+
if (!idPath) {
|
|
117
|
+
if (showLogs) console.error('[SearchDropdown] Path not found for item:', item);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const folderPath = idPath[0] === root.id ? idPath.slice(1) : idPath;
|
|
121
|
+
if (item.type === 'file') {
|
|
122
|
+
folderPath.pop();
|
|
123
|
+
}
|
|
124
|
+
dispatch('navigate', { path: folderPath, ...(item.type === 'file' ? { preview: item } : {}) });
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (showLogs) console.error('[SearchDropdown] openResult failed:', error);
|
|
127
|
+
}
|
|
128
|
+
searchValue = '';
|
|
129
|
+
panelOpen = false;
|
|
130
|
+
debouncedResults = [];
|
|
131
|
+
activeIndex = -1;
|
|
132
|
+
// The focus leaves the field: the folder or preview that opens next owns the keyboard (Escape closes the preview)
|
|
133
|
+
searchInputElement?.blur();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function handleSearchInput(event: Event) {
|
|
137
|
+
const input = event.target as HTMLInputElement;
|
|
138
|
+
searchValue = input.value.replace(/^\s+/, '');
|
|
139
|
+
if (searchValue.trim()) {
|
|
140
|
+
panelOpen = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function handleClear() {
|
|
145
|
+
searchValue = '';
|
|
146
|
+
debouncedResults = [];
|
|
147
|
+
activeIndex = -1;
|
|
148
|
+
panelOpen = false;
|
|
149
|
+
searchInputElement?.focus();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function handleInputKeydown(e: KeyboardEvent) {
|
|
153
|
+
const term = searchValue.trim();
|
|
154
|
+
if (e.key === 'Tab') {
|
|
155
|
+
panelOpen = false;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (e.key === 'Escape') {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
e.stopPropagation();
|
|
161
|
+
if (panelOpen) {
|
|
162
|
+
panelOpen = false;
|
|
163
|
+
} else if (searchValue) {
|
|
164
|
+
handleClear();
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!term || !debouncedResults.length) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (e.key === 'ArrowDown') {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
activeIndex = (activeIndex + 1) % debouncedResults.length;
|
|
174
|
+
scrollActiveIntoView();
|
|
175
|
+
} else if (e.key === 'ArrowUp') {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
activeIndex = activeIndex <= 0 ? debouncedResults.length - 1 : activeIndex - 1;
|
|
178
|
+
scrollActiveIntoView();
|
|
179
|
+
} else if (e.key === 'Enter' && activeIndex >= 0) {
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
openResult(debouncedResults[activeIndex]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function handleFocus() {
|
|
186
|
+
if (searchValue.trim()) {
|
|
187
|
+
panelOpen = true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function handleInputBlur() {
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
if (!rootEl?.contains(document.activeElement)) {
|
|
194
|
+
panelOpen = false;
|
|
195
|
+
}
|
|
196
|
+
}, 0);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function onDocPointerDown(e: MouseEvent) {
|
|
200
|
+
const t = e.target as Node | null;
|
|
201
|
+
if (t && rootEl && !rootEl.contains(t)) {
|
|
202
|
+
panelOpen = false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
onMount(() => {
|
|
207
|
+
document.addEventListener('pointerdown', onDocPointerDown, true);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
onDestroy(() => {
|
|
211
|
+
document.removeEventListener('pointerdown', onDocPointerDown, true);
|
|
212
|
+
if (searchDebounceTimer) {
|
|
213
|
+
clearTimeout(searchDebounceTimer);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
$: ariaActivedescendant =
|
|
218
|
+
showPanel && activeIndex >= 0 ? `file-browser-search-opt-${uid}-${activeIndex}` : undefined;
|
|
219
|
+
|
|
220
|
+
/** The field is the textbox of a combobox whose listbox is the panel under it (the Search Field takes these as they are). */
|
|
221
|
+
$: comboboxAttributes = {
|
|
222
|
+
id: comboboxId,
|
|
223
|
+
role: 'combobox',
|
|
224
|
+
'aria-haspopup': 'listbox',
|
|
225
|
+
'aria-autocomplete': 'list',
|
|
226
|
+
'aria-expanded': showPanel,
|
|
227
|
+
'aria-controls': listboxId,
|
|
228
|
+
'aria-activedescendant': ariaActivedescendant,
|
|
229
|
+
autocomplete: 'off',
|
|
230
|
+
spellcheck: false
|
|
231
|
+
};
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
235
|
+
<div bind:this={rootEl} class="relative w-full" tabindex="-1">
|
|
236
|
+
<!-- The field is the design system's Search Field (Figma 189:1138), the same one every screen uses -->
|
|
237
|
+
<SearchInput
|
|
238
|
+
bind:value={searchValue}
|
|
239
|
+
bind:inputElement={searchInputElement}
|
|
240
|
+
placeholder={$t('search.placeholder')}
|
|
241
|
+
clearLabel={$t('searchModal.clearQuery')}
|
|
242
|
+
inputAttributes={comboboxAttributes}
|
|
243
|
+
onInput={handleSearchInput}
|
|
244
|
+
onKeydown={handleInputKeydown}
|
|
245
|
+
onFocus={handleFocus}
|
|
246
|
+
onBlur={handleInputBlur}
|
|
247
|
+
onClear={handleClear}
|
|
248
|
+
/>
|
|
249
|
+
|
|
250
|
+
{#if showPanel}
|
|
251
|
+
<div
|
|
252
|
+
id={listboxId}
|
|
253
|
+
role="listbox"
|
|
254
|
+
aria-label={$t('search.placeholder')}
|
|
255
|
+
class="bg-popover text-popover-foreground border-border absolute start-0 top-full z-[60] mt-1 w-full overflow-hidden rounded-xl border shadow-md outline-hidden"
|
|
256
|
+
>
|
|
257
|
+
{#if debouncedResults.length > 0}
|
|
258
|
+
<WScrollArea
|
|
259
|
+
class="search-dropdown-scroll w-full"
|
|
260
|
+
style="max-height: {resultsScrollMaxHeightPx}px;"
|
|
261
|
+
scrollOutside={true}
|
|
262
|
+
>
|
|
263
|
+
<div class="flex flex-col py-2" bind:this={resultsInner}>
|
|
264
|
+
{#each debouncedResults as result, index (result.id || `${result.type}-${index}`)}
|
|
265
|
+
<button
|
|
266
|
+
data-result-index={index}
|
|
267
|
+
id={`file-browser-search-opt-${uid}-${index}`}
|
|
268
|
+
type="button"
|
|
269
|
+
role="option"
|
|
270
|
+
tabindex="-1"
|
|
271
|
+
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-3 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
|
+
? 'bg-accent'
|
|
274
|
+
: 'hover:bg-accent'}"
|
|
275
|
+
onmouseenter={() => {
|
|
276
|
+
activeIndex = index;
|
|
277
|
+
}}
|
|
278
|
+
onclick={() => openResult(result)}
|
|
279
|
+
>
|
|
280
|
+
<FileIcon
|
|
281
|
+
file={result}
|
|
282
|
+
kind={result.isMissing ? 'missing' : result.type === 'folder' ? 'folder' : undefined}
|
|
283
|
+
size="sm"
|
|
284
|
+
class="shrink-0 self-start pt-0.5"
|
|
285
|
+
/>
|
|
286
|
+
<div class="min-w-0 flex-1">
|
|
287
|
+
<div dir={nameDirection} class="truncate text-body">
|
|
288
|
+
<!-- Safe: highlightMatchesAsHtml escapes each part of the name and of the match (utils/safeText.ts) -->
|
|
289
|
+
{@html highlightMatch(result.name, searchValue.trim())}
|
|
290
|
+
</div>
|
|
291
|
+
<p dir={nameDirection} class="truncate text-caption text-muted-foreground">
|
|
292
|
+
{captionFor(result)}
|
|
293
|
+
</p>
|
|
294
|
+
</div>
|
|
295
|
+
{#if index === activeIndex}
|
|
296
|
+
<span class="hidden shrink-0 items-center gap-1 text-caption text-muted-foreground sm:flex">
|
|
297
|
+
{$t('searchModal.jumpToFolder')}
|
|
298
|
+
<IconCornerUpRight class="size-4 stroke-[1.333] rtl:rotate-180" aria-hidden="true" />
|
|
299
|
+
</span>
|
|
300
|
+
{/if}
|
|
301
|
+
</button>
|
|
302
|
+
{/each}
|
|
303
|
+
</div>
|
|
304
|
+
</WScrollArea>
|
|
305
|
+
{:else}
|
|
306
|
+
<div class="flex min-h-[200px] flex-col items-center justify-center px-6 py-8">
|
|
307
|
+
<EmptyState message={$t('searchModal.empty')} />
|
|
308
|
+
</div>
|
|
309
|
+
{/if}
|
|
310
|
+
</div>
|
|
311
|
+
{/if}
|
|
312
|
+
</div>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FileSystemItem } from '../../types';
|
|
2
|
+
import type { FileFilterType } from '../../utils/fileTypes';
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const SearchDropdown: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
currentFilter?: FileFilterType;
|
|
18
|
+
/** Tree root (Widgetic file store). */ root?: FileSystemItem | null;
|
|
19
|
+
/** First segment of the location line: e.g. translated `library.defaultLabel` or `breadcrumbs.root`. */ rootDisplayLabel?: string;
|
|
20
|
+
showLogs?: boolean;
|
|
21
|
+
}, {
|
|
22
|
+
navigate: CustomEvent<{
|
|
23
|
+
path: string[];
|
|
24
|
+
preview?: FileSystemItem;
|
|
25
|
+
}>;
|
|
26
|
+
} & {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
}, {}, {}, string>;
|
|
29
|
+
type SearchDropdown = InstanceType<typeof SearchDropdown>;
|
|
30
|
+
export default SearchDropdown;
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
fileName: string;
|
|
13
13
|
file: { name: string; url?: string; thumbnail?: string; mimeType?: string };
|
|
14
14
|
progress: number;
|
|
15
|
+
/** Full bar with pulse animation while the server finishes after 100% bytes sent */
|
|
16
|
+
progressIndeterminate?: boolean;
|
|
15
17
|
status: UploadRowState;
|
|
16
18
|
statusText: string;
|
|
17
19
|
errorMessage?: string;
|
|
@@ -24,6 +26,7 @@
|
|
|
24
26
|
summaryName: string;
|
|
25
27
|
summaryStatus: string;
|
|
26
28
|
progressValue: number;
|
|
29
|
+
progressIndeterminate?: boolean;
|
|
27
30
|
progressTone: 'default' | 'destructive';
|
|
28
31
|
progressDone?: boolean;
|
|
29
32
|
footerText: string;
|
|
@@ -47,6 +50,7 @@
|
|
|
47
50
|
summaryName,
|
|
48
51
|
summaryStatus,
|
|
49
52
|
progressValue,
|
|
53
|
+
progressIndeterminate = false,
|
|
50
54
|
progressTone = 'default',
|
|
51
55
|
progressDone = false,
|
|
52
56
|
footerText,
|
|
@@ -119,12 +123,16 @@
|
|
|
119
123
|
{/if}
|
|
120
124
|
</div>
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
{#if progressIndeterminate}
|
|
127
|
+
<div class="relative h-1 w-full overflow-hidden rounded-full bg-muted">
|
|
128
|
+
<div
|
|
129
|
+
class="animate-pulse absolute inset-y-0 start-0 w-1/3 rounded-full bg-primary motion-reduce:animate-none"
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
></div>
|
|
132
|
+
</div>
|
|
133
|
+
{:else}
|
|
134
|
+
<Progress value={progressDone ? 100 : progressValue} max={100} tone={progressTone} class="h-1" />
|
|
135
|
+
{/if}
|
|
128
136
|
|
|
129
137
|
<div class="flex flex-col items-center gap-1">
|
|
130
138
|
{#if footerAction}
|
|
@@ -154,15 +162,19 @@
|
|
|
154
162
|
{#if expanded && items.length > 1}
|
|
155
163
|
<div class="flex max-h-48 flex-col gap-2 overflow-y-auto border-t border-border pt-2">
|
|
156
164
|
{#each items as item (item.id)}
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
<div class="flex flex-col gap-1">
|
|
166
|
+
<UploadRow
|
|
167
|
+
scope="single"
|
|
168
|
+
state={item.status}
|
|
169
|
+
fileName={item.fileName}
|
|
170
|
+
file={item.file}
|
|
171
|
+
statusText={item.status === 'failed' ? item.errorMessage || item.statusText : item.statusText}
|
|
172
|
+
progressValue={item.status === 'uploading' ? item.progress : undefined}
|
|
173
|
+
progressIndeterminate={item.status === 'uploading' ? item.progressIndeterminate : false}
|
|
174
|
+
onCancel={() => onItemCancel?.(item.id)}
|
|
175
|
+
onRetry={() => onItemRetry?.(item.id)}
|
|
176
|
+
/>
|
|
177
|
+
</div>
|
|
166
178
|
{/each}
|
|
167
179
|
</div>
|
|
168
180
|
{/if}
|
|
@@ -9,6 +9,8 @@ export type UploadPanelItem = {
|
|
|
9
9
|
mimeType?: string;
|
|
10
10
|
};
|
|
11
11
|
progress: number;
|
|
12
|
+
/** Full bar with pulse animation while the server finishes after 100% bytes sent */
|
|
13
|
+
progressIndeterminate?: boolean;
|
|
12
14
|
status: UploadRowState;
|
|
13
15
|
statusText: string;
|
|
14
16
|
errorMessage?: string;
|
|
@@ -20,6 +22,7 @@ interface Props {
|
|
|
20
22
|
summaryName: string;
|
|
21
23
|
summaryStatus: string;
|
|
22
24
|
progressValue: number;
|
|
25
|
+
progressIndeterminate?: boolean;
|
|
23
26
|
progressTone: 'default' | 'destructive';
|
|
24
27
|
progressDone?: boolean;
|
|
25
28
|
footerText: string;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
-->
|
|
4
4
|
<script lang="ts">
|
|
5
5
|
import FileIcon from '../ui/FileIcon.svelte';
|
|
6
|
-
import { IconButton } from '@widgetic/design-system/components';
|
|
6
|
+
import { IconButton, Progress } from '@widgetic/design-system/components';
|
|
7
7
|
import { IconCheck, IconFiles, IconRefresh, IconX } from '@widgetic/design-system/icons';
|
|
8
8
|
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
9
9
|
import { useI18n } from '../../i18n/context';
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
file?: { name: string; url?: string; thumbnail?: string; mimeType?: string };
|
|
20
20
|
statusText?: string;
|
|
21
21
|
batchCount?: number;
|
|
22
|
+
/** 0–100 while uploading; omitted when not shown */
|
|
23
|
+
progressValue?: number;
|
|
24
|
+
progressIndeterminate?: boolean;
|
|
22
25
|
onCancel?: () => void;
|
|
23
26
|
onRetry?: () => void;
|
|
24
27
|
}
|
|
@@ -30,6 +33,8 @@
|
|
|
30
33
|
file,
|
|
31
34
|
statusText = '',
|
|
32
35
|
batchCount = 0,
|
|
36
|
+
progressValue,
|
|
37
|
+
progressIndeterminate = false,
|
|
33
38
|
onCancel,
|
|
34
39
|
onRetry
|
|
35
40
|
}: Props = $props();
|
|
@@ -46,6 +51,7 @@
|
|
|
46
51
|
const displayName = $derived(
|
|
47
52
|
scope === 'batch' ? $t('upload.filesTotal', { count: batchCount }) : fileName
|
|
48
53
|
);
|
|
54
|
+
const showBar = $derived(state === 'uploading' && progressValue !== undefined);
|
|
49
55
|
</script>
|
|
50
56
|
|
|
51
57
|
<div class="flex h-9 w-full min-w-0 items-center gap-3">
|
|
@@ -88,3 +94,18 @@
|
|
|
88
94
|
{/if}
|
|
89
95
|
</div>
|
|
90
96
|
</div>
|
|
97
|
+
|
|
98
|
+
{#if showBar}
|
|
99
|
+
<div class="mt-1 w-full ps-11">
|
|
100
|
+
{#if progressIndeterminate}
|
|
101
|
+
<div class="relative h-1 w-full overflow-hidden rounded-full bg-muted">
|
|
102
|
+
<div
|
|
103
|
+
class="animate-pulse absolute inset-y-0 start-0 w-1/3 rounded-full bg-primary motion-reduce:animate-none"
|
|
104
|
+
aria-hidden="true"
|
|
105
|
+
></div>
|
|
106
|
+
</div>
|
|
107
|
+
{:else}
|
|
108
|
+
<Progress value={progressValue ?? 0} max={100} class="h-1" />
|
|
109
|
+
{/if}
|
|
110
|
+
</div>
|
|
111
|
+
{/if}
|
|
@@ -2,3 +2,4 @@ export { default as FileBrowser } from './FileBrowser.svelte';
|
|
|
2
2
|
export { default as Header } from './Header.svelte';
|
|
3
3
|
export { default as FileUploader } from './FileUploader.svelte';
|
|
4
4
|
export { default as RecentFiles } from './RecentFiles.svelte';
|
|
5
|
+
export { default as SearchDropdown } from './SearchDropdown.svelte';
|
|
@@ -2,3 +2,4 @@ export { default as FileBrowser } from './FileBrowser.svelte';
|
|
|
2
2
|
export { default as Header } from './Header.svelte';
|
|
3
3
|
export { default as FileUploader } from './FileUploader.svelte';
|
|
4
4
|
export { default as RecentFiles } from './RecentFiles.svelte';
|
|
5
|
+
export { default as SearchDropdown } from './SearchDropdown.svelte';
|
|
@@ -176,6 +176,14 @@
|
|
|
176
176
|
isTransitioning = false;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
function isFromMenuOrThumbControl(event: Event): boolean {
|
|
180
|
+
const target = event.target as HTMLElement | null;
|
|
181
|
+
if (!target) return false;
|
|
182
|
+
if (target.closest('[data-fb-menu-root]')) return true;
|
|
183
|
+
if (target.closest('button[data-fb-action]')) return true;
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
179
187
|
function handleIconClick(event: Event) {
|
|
180
188
|
event.stopPropagation();
|
|
181
189
|
if (!isMissing) {
|
|
@@ -190,6 +198,17 @@
|
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
|
|
201
|
+
/** Pointer on the tile (not the preview button or item menu): same as the preview button — select in selection mode, else open preview. */
|
|
202
|
+
function handleTileClick(event: MouseEvent) {
|
|
203
|
+
if (thumbnailOnly || isMissing || isFromMenuOrThumbControl(event)) return;
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
if (allowSelecting) {
|
|
206
|
+
handleSelect(event);
|
|
207
|
+
} else {
|
|
208
|
+
dispatch('click');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
193
212
|
function handleDropdownAction(event: CustomEvent) {
|
|
194
213
|
const { action } = event.detail;
|
|
195
214
|
dispatch('action', { action, item });
|
|
@@ -206,7 +225,7 @@
|
|
|
206
225
|
? 'hover:bg-accent has-[[data-state=open]]:bg-accent'
|
|
207
226
|
: '',
|
|
208
227
|
!thumbnailOnly && isSelected ? 'border-brand bg-brand-subtle ring-1 ring-inset ring-brand' : '',
|
|
209
|
-
!thumbnailOnly &&
|
|
228
|
+
!thumbnailOnly && !isMissing ? 'cursor-pointer' : ''
|
|
210
229
|
]
|
|
211
230
|
.filter(Boolean)
|
|
212
231
|
.join(' ');
|
|
@@ -225,9 +244,13 @@
|
|
|
225
244
|
class:w-full={!thumbnailOnly}
|
|
226
245
|
bind:this={itemElement}
|
|
227
246
|
data-selected={isSelected ? 'true' : undefined}
|
|
228
|
-
onclick={!thumbnailOnly && allowSelecting && !isMissing ? handleSelect : undefined}
|
|
229
247
|
>
|
|
230
|
-
|
|
248
|
+
<!-- Whole tile activates like the preview thumb; preview button remains the keyboard focus target. -->
|
|
249
|
+
<div
|
|
250
|
+
class={tileShellClass}
|
|
251
|
+
onclick={!thumbnailOnly && !isMissing ? handleTileClick : undefined}
|
|
252
|
+
role="presentation"
|
|
253
|
+
>
|
|
231
254
|
<!-- 48×48 preview thumb (Figma File Thumb Large) -->
|
|
232
255
|
<button
|
|
233
256
|
type="button"
|
|
@@ -337,11 +360,13 @@
|
|
|
337
360
|
<div
|
|
338
361
|
class="fb-file-menu-ct shrink-0 transition-opacity duration-fast {menuVisibleClass}"
|
|
339
362
|
role="presentation"
|
|
363
|
+
data-fb-menu-root
|
|
340
364
|
onclick={stopMenuBubble}
|
|
341
365
|
onkeydown={stopMenuBubble}
|
|
342
366
|
>
|
|
343
367
|
<DropdownMenu
|
|
344
368
|
isFolder={false}
|
|
369
|
+
itemId={item.id}
|
|
345
370
|
fileUrl={item.url}
|
|
346
371
|
isMissing={isMissing}
|
|
347
372
|
on:action={handleDropdownAction}
|