@classic-homes/files-svelte 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,630 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { tick, untrack } from 'svelte';
4
+ import {
5
+ Alert,
6
+ Button,
7
+ Dialog,
8
+ EmptyState,
9
+ Icon,
10
+ LiveRegion,
11
+ Select,
12
+ Switch,
13
+ } from '@classic-homes/theme-svelte';
14
+ import type { ViewerRegistry } from '@classic-homes/viewer-svelte';
15
+ import {
16
+ describeFilesError,
17
+ filterEntries,
18
+ isAbortError,
19
+ isFilesError,
20
+ normalizePath,
21
+ parentPath,
22
+ writeCapabilities,
23
+ type FileEntry,
24
+ type FileRoot,
25
+ type FileSort,
26
+ type FilesSource,
27
+ } from '@classic-homes/files-core';
28
+ import FileBreadcrumbs from './FileBreadcrumbs.svelte';
29
+ import FileErrorState from './FileErrorState.svelte';
30
+ import FileList from './FileList.svelte';
31
+ import FilePreview from './FilePreview.svelte';
32
+ import type { FileBrowserContext } from './types.js';
33
+ import { cn, isTextInput } from './utils.js';
34
+
35
+ interface Props {
36
+ /** Where the data comes from: `createChapiFilesSource()`, `createMemoryFilesSource()` or your own. */
37
+ source: FilesSource;
38
+ /** Current root. Bindable; defaults to the first root the caller can read. */
39
+ rootId?: string;
40
+ /** Current folder, root-relative (`''` = the root). Bindable. */
41
+ path?: string;
42
+ /** The user picked another root. Put it in the URL to make Back/Forward work. */
43
+ onrootchange?: (rootId: string) => void;
44
+ /** The user opened another folder. */
45
+ onpathchange?: (path: string) => void;
46
+ /** Document viewers for previews, as lazy imports keyed by format. */
47
+ viewers?: ViewerRegistry;
48
+ /** Entries per page. Default 200. */
49
+ pageSize?: number;
50
+ /** Load the next page on scroll instead of only with "Load more". Default false. */
51
+ autoLoad?: boolean;
52
+ /** "Show hidden files". Bindable. */
53
+ showHidden?: boolean;
54
+ /** Filter text. Bindable. Narrows the loaded entries (or searches, when the source can). */
55
+ filter?: string;
56
+ /** Larger files are not fetched for preview. Default 100 MB. */
57
+ maxPreviewBytes?: number;
58
+ /** A request got a 401: hand it to the app's auth (re-login). */
59
+ onunauthorized?: (error: unknown) => void;
60
+ /** Any listing or preview error, for logging. */
61
+ onerror?: (error: unknown) => void;
62
+ /** A file was opened for preview. */
63
+ onpreview?: (entry: FileEntry) => void;
64
+ /**
65
+ * Write toolbar (upload, new folder…). Rendered only when the source has a
66
+ * write method AND the root's `canWrite` is true. The pilot shows nothing.
67
+ */
68
+ toolbar?: Snippet<[FileBrowserContext]>;
69
+ /** Per-row write actions, under the same rule as `toolbar`. */
70
+ rowActions?: Snippet<[FileEntry, FileBrowserContext]>;
71
+ /** Accessible name of the browser region. Default "File browser". */
72
+ label?: string;
73
+ locale?: string | string[];
74
+ class?: string;
75
+ }
76
+
77
+ let {
78
+ source,
79
+ rootId = $bindable(),
80
+ path = $bindable(''),
81
+ onrootchange,
82
+ onpathchange,
83
+ viewers = {},
84
+ pageSize = 200,
85
+ autoLoad = false,
86
+ showHidden = $bindable(false),
87
+ filter = $bindable(''),
88
+ maxPreviewBytes,
89
+ onunauthorized,
90
+ onerror,
91
+ onpreview,
92
+ toolbar,
93
+ rowActions,
94
+ label = 'File browser',
95
+ locale,
96
+ class: className,
97
+ }: Props = $props();
98
+
99
+ const uid = $props.id();
100
+ const filterId = `${uid}-filter`;
101
+ const hiddenId = `${uid}-hidden`;
102
+
103
+ // Roots
104
+ let roots = $state.raw<FileRoot[]>([]);
105
+ let rootsStatus = $state<'loading' | 'ready' | 'error'>('loading');
106
+ let rootsError = $state.raw<unknown>();
107
+ let rootsAttempt = $state(0);
108
+
109
+ // Listing
110
+ let entries = $state.raw<FileEntry[]>([]);
111
+ let total = $state<number>();
112
+ let nextCursor = $state<string | null>(null);
113
+ let status = $state<'idle' | 'loading' | 'ready' | 'error'>('idle');
114
+ let listError = $state.raw<unknown>();
115
+ let loadingMore = $state(false);
116
+ let moreError = $state.raw<unknown>();
117
+ let attempt = $state(0);
118
+ let listController: AbortController | undefined;
119
+
120
+ // Server search (only when the source offers it)
121
+ let searchResults = $state.raw<FileEntry[] | null>(null);
122
+ let searchStatus = $state<'idle' | 'loading' | 'ready' | 'error'>('idle');
123
+
124
+ let selected = $state<string>();
125
+ let sort = $state<FileSort | null>(null);
126
+ let previewEntry = $state.raw<FileEntry>();
127
+ let previewOpen = $state(false);
128
+ let announcement = $state('');
129
+ let online = $state(typeof navigator === 'undefined' ? true : navigator.onLine !== false);
130
+ let list = $state<FileList>();
131
+ /** Focus the list once the next listing lands (keyboard navigation). */
132
+ let focusAfterLoad = false;
133
+
134
+ const currentPath = $derived.by(() => {
135
+ try {
136
+ return normalizePath(path);
137
+ } catch {
138
+ return path ?? '';
139
+ }
140
+ });
141
+ const root = $derived(roots.find((r) => r.id === rootId));
142
+ const rootLabel = $derived(root?.label ?? '');
143
+ const caps = $derived(writeCapabilities(source, root));
144
+ const folderName = $derived(
145
+ currentPath ? currentPath.slice(currentPath.lastIndexOf('/') + 1) : rootLabel
146
+ );
147
+ const searching = $derived(!!source.search && filter.trim() !== '');
148
+ const shown = $derived(searching ? (searchResults ?? []) : filterEntries(entries, filter));
149
+ const hasMore = $derived(!searching && !!nextCursor);
150
+ const nf = $derived(new Intl.NumberFormat(locale));
151
+
152
+ const context: FileBrowserContext = {
153
+ get source() {
154
+ return source;
155
+ },
156
+ get root() {
157
+ return root;
158
+ },
159
+ get path() {
160
+ return currentPath;
161
+ },
162
+ get capabilities() {
163
+ return caps;
164
+ },
165
+ refresh: () => refresh(),
166
+ navigate: (p: string) => navigate(p),
167
+ };
168
+
169
+ function report(err: unknown) {
170
+ onerror?.(err);
171
+ if (isFilesError(err) && err.code === 'unauthorized') onunauthorized?.(err);
172
+ }
173
+
174
+ // Load roots whenever the source changes.
175
+ $effect(() => {
176
+ const src = source;
177
+ void rootsAttempt;
178
+ const controller = new AbortController();
179
+ untrack(() => {
180
+ rootsStatus = 'loading';
181
+ rootsError = undefined;
182
+ });
183
+ src.listRoots(controller.signal).then(
184
+ (list) => {
185
+ if (controller.signal.aborted) return;
186
+ roots = list;
187
+ rootsStatus = 'ready';
188
+ const current = untrack(() => rootId);
189
+ if (list.length && !list.some((r) => r.id === current)) {
190
+ // Unknown or missing root: start on the first one the caller can read.
191
+ rootId = list[0].id;
192
+ if (current !== undefined) path = '';
193
+ onrootchange?.(list[0].id);
194
+ }
195
+ },
196
+ (err) => {
197
+ if (controller.signal.aborted || isAbortError(err)) return;
198
+ rootsError = err;
199
+ rootsStatus = 'error';
200
+ report(err);
201
+ }
202
+ );
203
+ return () => controller.abort();
204
+ });
205
+
206
+ // List the current folder.
207
+ $effect(() => {
208
+ const src = source;
209
+ const id = rootId;
210
+ const folder = currentPath;
211
+ const includeHidden = showHidden;
212
+ const limit = pageSize;
213
+ const ready = rootsStatus === 'ready' && roots.some((r) => r.id === id);
214
+ void attempt;
215
+ if (!ready || id === undefined) return;
216
+
217
+ listController?.abort();
218
+ const controller = new AbortController();
219
+ listController = controller;
220
+ untrack(() => {
221
+ status = 'loading';
222
+ listError = undefined;
223
+ moreError = undefined;
224
+ loadingMore = false;
225
+ entries = [];
226
+ total = undefined;
227
+ nextCursor = null;
228
+ announcement = `Loading ${folderName}…`;
229
+ });
230
+
231
+ src.list(id, folder, { limit, includeHidden, signal: controller.signal }).then(
232
+ async (page) => {
233
+ if (controller.signal.aborted) return;
234
+ entries = page.entries;
235
+ total = page.total;
236
+ nextCursor = page.nextCursor ?? null;
237
+ status = 'ready';
238
+ announce();
239
+ if (focusAfterLoad) {
240
+ focusAfterLoad = false;
241
+ await tick();
242
+ list?.focus();
243
+ }
244
+ },
245
+ (err) => {
246
+ if (controller.signal.aborted || isAbortError(err)) return;
247
+ listError = err;
248
+ status = 'error';
249
+ announcement = describeFilesError(err).title;
250
+ report(err);
251
+ }
252
+ );
253
+ return () => controller.abort();
254
+ });
255
+
256
+ function announce() {
257
+ const count = total ?? entries.length;
258
+ announcement =
259
+ count === 0
260
+ ? `${folderName} is empty`
261
+ : `${folderName}: ${nf.format(count)} item${count === 1 ? '' : 's'}${
262
+ nextCursor ? `, showing ${nf.format(entries.length)}` : ''
263
+ }`;
264
+ }
265
+
266
+ async function loadMore() {
267
+ if (!nextCursor || loadingMore || rootId === undefined) return;
268
+ const controller = listController;
269
+ const id = rootId;
270
+ loadingMore = true;
271
+ moreError = undefined;
272
+ try {
273
+ const page = await source.list(id, currentPath, {
274
+ cursor: nextCursor,
275
+ limit: pageSize,
276
+ includeHidden: showHidden,
277
+ signal: controller?.signal,
278
+ });
279
+ if (controller?.signal.aborted) return;
280
+ const seen = new Set(entries.map((e) => e.path));
281
+ entries = [...entries, ...page.entries.filter((e) => !seen.has(e.path))];
282
+ total = page.total ?? total;
283
+ nextCursor = page.nextCursor ?? null;
284
+ announce();
285
+ } catch (err) {
286
+ if (controller?.signal.aborted || isAbortError(err)) return;
287
+ moreError = err;
288
+ report(err);
289
+ } finally {
290
+ if (!controller?.signal.aborted) loadingMore = false;
291
+ }
292
+ }
293
+
294
+ // Server search seam: debounced, only when the source implements search().
295
+ $effect(() => {
296
+ const query = filter.trim();
297
+ const src = source;
298
+ const id = rootId;
299
+ const folder = currentPath;
300
+ const includeHidden = showHidden;
301
+ if (!src.search || !query || id === undefined) {
302
+ searchResults = null;
303
+ searchStatus = 'idle';
304
+ return;
305
+ }
306
+ const controller = new AbortController();
307
+ const timer = setTimeout(() => {
308
+ searchStatus = 'loading';
309
+ src.search!(id, query, {
310
+ path: folder,
311
+ includeHidden,
312
+ limit: pageSize,
313
+ signal: controller.signal,
314
+ }).then(
315
+ (page) => {
316
+ if (controller.signal.aborted) return;
317
+ searchResults = page.entries;
318
+ searchStatus = 'ready';
319
+ announcement = `${nf.format(page.total ?? page.entries.length)} results for “${query}”`;
320
+ },
321
+ (err) => {
322
+ if (controller.signal.aborted || isAbortError(err)) return;
323
+ searchStatus = 'error';
324
+ searchResults = [];
325
+ report(err);
326
+ }
327
+ );
328
+ }, 300);
329
+ return () => {
330
+ clearTimeout(timer);
331
+ controller.abort();
332
+ };
333
+ });
334
+
335
+ function navigate(next: string, focusChild?: string) {
336
+ let target: string;
337
+ try {
338
+ target = normalizePath(next);
339
+ } catch {
340
+ target = '';
341
+ }
342
+ filter = '';
343
+ sort = null;
344
+ selected = focusChild;
345
+ if (target === currentPath) {
346
+ attempt++;
347
+ return;
348
+ }
349
+ path = target;
350
+ onpathchange?.(target);
351
+ }
352
+
353
+ function goUp() {
354
+ if (!currentPath) return;
355
+ focusAfterLoad = true;
356
+ navigate(parentPath(currentPath), currentPath);
357
+ }
358
+
359
+ function changeRoot(id: string) {
360
+ if (id === rootId) return;
361
+ rootId = id;
362
+ filter = '';
363
+ sort = null;
364
+ selected = undefined;
365
+ onrootchange?.(id);
366
+ if (currentPath !== '') {
367
+ path = '';
368
+ onpathchange?.('');
369
+ }
370
+ }
371
+
372
+ function refresh() {
373
+ attempt++;
374
+ }
375
+
376
+ function open(entry: FileEntry) {
377
+ if (entry.type === 'dir') {
378
+ focusAfterLoad = true;
379
+ navigate(entry.path);
380
+ } else if (entry.type === 'file') {
381
+ previewEntry = entry;
382
+ previewOpen = true;
383
+ onpreview?.(entry);
384
+ }
385
+ }
386
+
387
+ function onkeydown(event: KeyboardEvent) {
388
+ if (event.defaultPrevented) return;
389
+ if (previewOpen) return;
390
+ const typing = isTextInput(event.target);
391
+ if (event.key === '/' && !typing && !event.ctrlKey && !event.metaKey && !event.altKey) {
392
+ event.preventDefault();
393
+ document.getElementById(filterId)?.focus();
394
+ return;
395
+ }
396
+ if ((event.key === 'ArrowUp' && event.altKey) || (event.key === 'Backspace' && !typing)) {
397
+ if (!currentPath) return;
398
+ event.preventDefault();
399
+ goUp();
400
+ return;
401
+ }
402
+ if (
403
+ event.key === 'Escape' &&
404
+ typing &&
405
+ event.target instanceof HTMLInputElement &&
406
+ event.target.id === filterId
407
+ ) {
408
+ if (filter) {
409
+ event.preventDefault();
410
+ filter = '';
411
+ }
412
+ list?.focus();
413
+ }
414
+ }
415
+
416
+ // Offline banner; retry a failed listing when the connection comes back.
417
+ $effect(() => {
418
+ if (typeof window === 'undefined') return;
419
+ const up = () => {
420
+ online = true;
421
+ if (status === 'error' && isFilesError(listError) && listError.code === 'network') attempt++;
422
+ };
423
+ const down = () => (online = false);
424
+ window.addEventListener('online', up);
425
+ window.addEventListener('offline', down);
426
+ return () => {
427
+ window.removeEventListener('online', up);
428
+ window.removeEventListener('offline', down);
429
+ };
430
+ });
431
+
432
+ const rootOptions = $derived(roots.map((r) => ({ value: r.id, label: r.label })));
433
+ const listLabel = $derived(`${folderName} contents`);
434
+
435
+ const countText = $derived.by(() => {
436
+ if (status !== 'ready') return '';
437
+ const loaded = entries.length;
438
+ const all = total ?? loaded;
439
+ if (searching) {
440
+ return searchStatus === 'loading'
441
+ ? 'Searching…'
442
+ : `${nf.format(shown.length)} result${shown.length === 1 ? '' : 's'} in ${folderName}`;
443
+ }
444
+ if (filter.trim()) {
445
+ return `${nf.format(shown.length)} of ${nf.format(loaded)} loaded item${loaded === 1 ? '' : 's'} match${
446
+ hasMore ? ' (load more to filter the rest)' : ''
447
+ }`;
448
+ }
449
+ return loaded < all
450
+ ? `Showing ${nf.format(loaded)} of ${nf.format(all)}`
451
+ : `${nf.format(all)} item${all === 1 ? '' : 's'}`;
452
+ });
453
+ </script>
454
+
455
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
456
+ <section
457
+ aria-label={label}
458
+ class={cn('flex min-h-0 flex-col rounded-lg border border-border bg-background', className)}
459
+ {onkeydown}
460
+ data-file-browser
461
+ >
462
+ {#if !online}
463
+ <Alert variant="warning" class="m-3 mb-0" data-file-browser-offline>
464
+ You're offline. The network drive needs a connection; this list may be out of date.
465
+ </Alert>
466
+ {/if}
467
+
468
+ {#if rootsStatus === 'error'}
469
+ <FileErrorState error={rootsError} onretry={() => rootsAttempt++} class="py-12" />
470
+ {:else if rootsStatus === 'ready' && roots.length === 0}
471
+ <EmptyState
472
+ title="No network drives"
473
+ description="You don't have access to any shared drives yet. Ask IT if you need one."
474
+ icon="folder-minus"
475
+ class="py-12"
476
+ />
477
+ {:else}
478
+ <div class="flex flex-col gap-3 border-b border-border p-3">
479
+ <div class="flex flex-col gap-2 sm:flex-row sm:items-center">
480
+ {#if roots.length > 1}
481
+ <div class="sm:w-64">
482
+ <Select
483
+ label="Drive"
484
+ value={rootId}
485
+ options={rootOptions}
486
+ onValueChange={changeRoot}
487
+ hint={root?.description ?? undefined}
488
+ />
489
+ </div>
490
+ {/if}
491
+ {#if root}
492
+ <FileBreadcrumbs
493
+ rootLabel={root.label}
494
+ path={currentPath}
495
+ onnavigate={(p) => navigate(p)}
496
+ class="min-w-0 flex-1"
497
+ />
498
+ {/if}
499
+ </div>
500
+ {#if roots.length === 1 && root?.description}
501
+ <p class="-mt-1 text-xs text-muted-foreground">{root.description}</p>
502
+ {/if}
503
+
504
+ <div class="flex flex-wrap items-center gap-x-4 gap-y-2">
505
+ <div class="relative min-w-[12rem] flex-1">
506
+ <label for={filterId} class="sr-only"
507
+ >{source.search ? 'Search files' : 'Filter files in this folder'}</label
508
+ >
509
+ <Icon
510
+ name={source.search ? 'search' : 'filter'}
511
+ size={16}
512
+ class="pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"
513
+ />
514
+ <input
515
+ id={filterId}
516
+ type="search"
517
+ bind:value={filter}
518
+ placeholder={source.search ? 'Search files' : 'Filter this folder'}
519
+ autocomplete="off"
520
+ aria-keyshortcuts="/"
521
+ class="flex h-9 w-full rounded-md border border-input bg-background py-1 pl-8 pr-10 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
522
+ />
523
+ <kbd
524
+ class="pointer-events-none absolute right-2 top-1/2 hidden -translate-y-1/2 rounded border border-border px-1.5 text-xs text-muted-foreground sm:block"
525
+ aria-hidden="true">/</kbd
526
+ >
527
+ </div>
528
+ <div class="flex items-center gap-2">
529
+ <Switch id={hiddenId} checked={showHidden} onchange={(v) => (showHidden = v)} />
530
+ <label for={hiddenId} class="text-sm">Show hidden files</label>
531
+ </div>
532
+ {#if toolbar && caps.any}
533
+ <div class="flex items-center gap-2" data-file-browser-toolbar>
534
+ {@render toolbar(context)}
535
+ </div>
536
+ {/if}
537
+ <Button variant="ghost" size="icon" onclick={refresh} aria-label="Refresh">
538
+ <Icon name="refresh" size={16} />
539
+ </Button>
540
+ </div>
541
+ </div>
542
+
543
+ <div class="flex items-center justify-between gap-2 px-3 pt-2 text-xs text-muted-foreground">
544
+ <span data-file-browser-count>{countText}</span>
545
+ {#if currentPath}
546
+ <button
547
+ type="button"
548
+ class="inline-flex items-center gap-1 rounded px-1 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
549
+ onclick={goUp}
550
+ aria-keyshortcuts="Alt+ArrowUp Backspace"
551
+ >
552
+ <Icon name="corner-up-left" size={14} />
553
+ Up a folder
554
+ </button>
555
+ {/if}
556
+ </div>
557
+
558
+ <div class="min-h-0 flex-1 overflow-auto">
559
+ {#if status === 'error'}
560
+ <FileErrorState
561
+ error={listError}
562
+ onretry={refresh}
563
+ onroot={() => navigate('')}
564
+ rootLabel={currentPath ? rootLabel : undefined}
565
+ class="py-12"
566
+ />
567
+ {:else}
568
+ <FileList
569
+ bind:this={list}
570
+ bind:selected
571
+ bind:sort
572
+ entries={shown}
573
+ loading={rootsStatus === 'loading' ||
574
+ status === 'loading' ||
575
+ status === 'idle' ||
576
+ (searching && searchStatus === 'loading' && !searchResults)}
577
+ {loadingMore}
578
+ {hasMore}
579
+ {autoLoad}
580
+ onloadmore={loadMore}
581
+ onopen={open}
582
+ {total}
583
+ showCount={false}
584
+ label={listLabel}
585
+ {locale}
586
+ emptyTitle={filter.trim() ? `Nothing matches “${filter.trim()}”` : 'This folder is empty'}
587
+ rowActions={rowActions && caps.any ? actions : undefined}
588
+ />
589
+ {#if moreError}
590
+ <div class="px-3 pb-3">
591
+ <Alert variant="destructive">
592
+ {describeFilesError(moreError).title}.
593
+ <Button variant="link" size="sm" onclick={loadMore}>Try again</Button>
594
+ </Alert>
595
+ </div>
596
+ {/if}
597
+ {/if}
598
+ </div>
599
+ {/if}
600
+
601
+ <LiveRegion message={announcement} />
602
+ </section>
603
+
604
+ {#snippet actions(entry: FileEntry)}
605
+ {@render rowActions?.(entry, context)}
606
+ {/snippet}
607
+
608
+ {#if previewEntry && rootId !== undefined}
609
+ <Dialog
610
+ bind:open={previewOpen}
611
+ title={previewEntry.name}
612
+ size="full"
613
+ class="h-[100dvh] max-h-[100dvh] max-w-[100vw] gap-0 rounded-none sm:h-[90dvh] sm:max-h-[90dvh] sm:max-w-5xl sm:rounded-lg [&_.dialog-content]:flex [&_.dialog-content]:flex-col [&_.dialog-content]:p-0"
614
+ >
615
+ <FilePreview
616
+ {source}
617
+ {rootId}
618
+ {rootLabel}
619
+ entry={previewEntry}
620
+ {viewers}
621
+ maxBytes={maxPreviewBytes}
622
+ showTitle={false}
623
+ {locale}
624
+ ondownload={(_, err) => {
625
+ if (err) report(err);
626
+ }}
627
+ class="min-h-0 flex-1"
628
+ />
629
+ </Dialog>
630
+ {/if}
@@ -0,0 +1,48 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { ViewerRegistry } from '@classic-homes/viewer-svelte';
3
+ import { type FileEntry, type FilesSource } from '@classic-homes/files-core';
4
+ import type { FileBrowserContext } from './types.js';
5
+ interface Props {
6
+ /** Where the data comes from: `createChapiFilesSource()`, `createMemoryFilesSource()` or your own. */
7
+ source: FilesSource;
8
+ /** Current root. Bindable; defaults to the first root the caller can read. */
9
+ rootId?: string;
10
+ /** Current folder, root-relative (`''` = the root). Bindable. */
11
+ path?: string;
12
+ /** The user picked another root. Put it in the URL to make Back/Forward work. */
13
+ onrootchange?: (rootId: string) => void;
14
+ /** The user opened another folder. */
15
+ onpathchange?: (path: string) => void;
16
+ /** Document viewers for previews, as lazy imports keyed by format. */
17
+ viewers?: ViewerRegistry;
18
+ /** Entries per page. Default 200. */
19
+ pageSize?: number;
20
+ /** Load the next page on scroll instead of only with "Load more". Default false. */
21
+ autoLoad?: boolean;
22
+ /** "Show hidden files". Bindable. */
23
+ showHidden?: boolean;
24
+ /** Filter text. Bindable. Narrows the loaded entries (or searches, when the source can). */
25
+ filter?: string;
26
+ /** Larger files are not fetched for preview. Default 100 MB. */
27
+ maxPreviewBytes?: number;
28
+ /** A request got a 401: hand it to the app's auth (re-login). */
29
+ onunauthorized?: (error: unknown) => void;
30
+ /** Any listing or preview error, for logging. */
31
+ onerror?: (error: unknown) => void;
32
+ /** A file was opened for preview. */
33
+ onpreview?: (entry: FileEntry) => void;
34
+ /**
35
+ * Write toolbar (upload, new folder…). Rendered only when the source has a
36
+ * write method AND the root's `canWrite` is true. The pilot shows nothing.
37
+ */
38
+ toolbar?: Snippet<[FileBrowserContext]>;
39
+ /** Per-row write actions, under the same rule as `toolbar`. */
40
+ rowActions?: Snippet<[FileEntry, FileBrowserContext]>;
41
+ /** Accessible name of the browser region. Default "File browser". */
42
+ label?: string;
43
+ locale?: string | string[];
44
+ class?: string;
45
+ }
46
+ declare const FileBrowser: import("svelte").Component<Props, {}, "path" | "filter" | "rootId" | "showHidden">;
47
+ type FileBrowser = ReturnType<typeof FileBrowser>;
48
+ export default FileBrowser;