@classic-homes/files-svelte 0.6.0 → 0.6.1

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/README.md CHANGED
@@ -25,6 +25,18 @@ Svelte 5 network-drive file browser for Classic Theme.
25
25
  <FileBrowser {source} {viewers} class="h-[80vh]" />
26
26
  ```
27
27
 
28
+ ### The header
29
+
30
+ From 768px up the header is one row: breadcrumbs (the drive's description
31
+ trailing them as muted text that truncates), the filter, "Show hidden files",
32
+ any write `toolbar` and Refresh. Below 768px it is two rows: a "Folders" button
33
+ (icon-only below 640px) and the breadcrumbs, then the filter, the `toolbar` and a
34
+ ⋯ "More options" menu holding "Show hidden files" (a checkable item) and
35
+ Refresh. On phones the description is the root crumb's tooltip, and the drives
36
+ are reached through the Folders sheet, so the drive picker only shows with
37
+ `navigationPane={false}` (when there is more than one drive). `/` focuses the
38
+ filter and Esc clears it at any width.
39
+
28
40
  ### Opening files in the pane
29
41
 
30
42
  By default a file opens in a modal dialog. With `preview="pane"` it opens in place
@@ -41,7 +53,9 @@ on one row at any width (the name truncates; below 640px Details and Download ar
41
53
  icons). Esc or Close return to the folder; changing folder or drive closes the
42
54
  file. The filter box hides while a file is open, so an active filter shows as a
43
55
  strip above the branch with a Clear button (the file stays open). Below 768px
44
- the document fills the browser and a "Files" button opens the branch in a sheet.
56
+ the document fills the browser and a "Files" button opens the branch in a sheet
57
+ (its tooltip and accessible description name the folder, e.g. "Files in Land
58
+ Development / 105 BREWERY").
45
59
 
46
60
  Bind `file` (the open file's name in the current folder) to keep it in the URL.
47
61
  Setting it opens that file, also when it is past the first page (looked up with
@@ -6,6 +6,8 @@
6
6
  interface Props {
7
7
  /** Label of the root crumb, e.g. the drive's name. */
8
8
  rootLabel: string;
9
+ /** Tooltip (`title`) on the root crumb, e.g. the drive's description. */
10
+ rootTitle?: string;
9
11
  /** Current folder, root-relative. */
10
12
  path: string;
11
13
  /** Called with the crumb's path (`''` for the root). */
@@ -19,6 +21,7 @@
19
21
 
20
22
  let {
21
23
  rootLabel,
24
+ rootTitle,
22
25
  path,
23
26
  onnavigate,
24
27
  maxItems = 4,
@@ -59,12 +62,13 @@
59
62
  <span
60
63
  aria-current="page"
61
64
  class="inline-flex items-center gap-1.5 px-1.5 py-1 font-medium text-foreground"
65
+ title={rootTitle}
62
66
  >
63
67
  <Icon name="home" size={16} />
64
68
  {rootLabel}
65
69
  </span>
66
70
  {:else}
67
- <button type="button" class={crumbClass} onclick={() => onnavigate?.('')}>
71
+ <button type="button" class={crumbClass} title={rootTitle} onclick={() => onnavigate?.('')}>
68
72
  <Icon name="home" size={16} />
69
73
  <span class="truncate">{rootLabel}</span>
70
74
  </button>
@@ -1,6 +1,8 @@
1
1
  interface Props {
2
2
  /** Label of the root crumb, e.g. the drive's name. */
3
3
  rootLabel: string;
4
+ /** Tooltip (`title`) on the root crumb, e.g. the drive's description. */
5
+ rootTitle?: string;
4
6
  /** Current folder, root-relative. */
5
7
  path: string;
6
8
  /** Called with the crumb's path (`''` for the root). */
@@ -1,11 +1,12 @@
1
1
  <script lang="ts">
2
- import type { Snippet } from 'svelte';
2
+ import type { ComponentProps, Snippet } from 'svelte';
3
3
  import { tick, untrack } from 'svelte';
4
4
  import { MediaQuery } from 'svelte/reactivity';
5
5
  import {
6
6
  Alert,
7
7
  Button,
8
8
  Dialog,
9
+ DropdownMenu,
9
10
  EmptyState,
10
11
  Icon,
11
12
  LiveRegion,
@@ -705,10 +706,27 @@
705
706
  };
706
707
  });
707
708
 
708
- const showPane = $derived(navigationPane && wide.current && roots.length > 0);
709
709
  // Two panes: the folder tree beside the list, or the folder's branch beside a document.
710
710
  const split = $derived(wide.current && roots.length > 0 && (navigationPane || docOpen));
711
711
  const rootOptions = $derived(roots.map((r) => ({ value: r.id, label: r.label })));
712
+ // Phones open the folder tree (which lists every drive) from a button beside the breadcrumbs.
713
+ const showFoldersButton = $derived(navigationPane && !wide.current && roots.length > 0);
714
+ // The drive picker, only where no folder tree lists the drives.
715
+ const showRootPicker = $derived(roots.length > 1 && !navigationPane);
716
+ /** Phones: the header's secondary controls, behind one ⋯ button. */
717
+ // The component's own item type: the package's exported `DropdownMenuItem` lacks `checked`.
718
+ const moreItems = $derived<ComponentProps<typeof DropdownMenu>['items']>([
719
+ {
720
+ label: 'Show hidden files',
721
+ checked: showHidden,
722
+ onSelect: () => (showHidden = !showHidden),
723
+ },
724
+ { label: 'Refresh', icon: 'refresh', onSelect: refresh },
725
+ ]);
726
+ /** The open folder as a path, for the phone "Files" button's tooltip. */
727
+ const folderTrail = $derived(
728
+ [rootLabel, ...(currentPath ? currentPath.split('/') : [])].join(' / ')
729
+ );
712
730
  const listLabel = $derived(`${folderName} contents`);
713
731
 
714
732
  const countText = $derived.by(() => {
@@ -762,13 +780,31 @@
762
780
  {:else}
763
781
  <!-- The open document's header carries the name; the branch beside it carries navigation. -->
764
782
  {#if !docOpen}
783
+ <!-- Phones: two rows (Folders + breadcrumbs; filter + toolbar + ⋯ menu). From md up: one row. -->
765
784
  <div
766
- class="flex flex-col gap-3 border-b border-border p-3 md:flex-row md:flex-wrap md:items-center md:gap-x-4 md:gap-y-2"
785
+ class="flex flex-col gap-2 border-b border-border p-3 md:flex-row md:flex-wrap md:items-center md:gap-x-4 md:gap-y-2"
767
786
  data-file-browser-header
768
787
  >
769
- <div class="flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center md:flex-[1_1_16rem]">
770
- {#if roots.length > 1 && !showPane}
771
- <div class="sm:w-64">
788
+ <div
789
+ class="flex min-w-0 flex-wrap items-center gap-2 md:flex-[1_1_16rem] md:flex-nowrap"
790
+ data-file-browser-location
791
+ >
792
+ {#if showFoldersButton}
793
+ <Button
794
+ variant="outline"
795
+ size="sm"
796
+ class="shrink-0 px-2 sm:px-3"
797
+ onclick={() => (foldersOpen = true)}
798
+ aria-haspopup="dialog"
799
+ aria-label="Folders"
800
+ title="Folders"
801
+ >
802
+ <Icon name="sidebar" size={16} />
803
+ <span class="hidden sm:inline">Folders</span>
804
+ </Button>
805
+ {/if}
806
+ {#if showRootPicker}
807
+ <div class="w-full sm:w-64 sm:shrink-0">
772
808
  <Select
773
809
  label="Drive"
774
810
  value={rootId}
@@ -781,20 +817,29 @@
781
817
  {#if root}
782
818
  <FileBreadcrumbs
783
819
  rootLabel={root.label}
820
+ rootTitle={root.description ?? undefined}
784
821
  path={currentPath}
785
822
  onnavigate={(p) => navigate(p)}
786
- class="min-w-0 flex-1"
823
+ class={cn('min-w-0', wide.current && root.description ? 'flex-[0_1_auto]' : 'flex-1')}
787
824
  />
825
+ {#if wide.current && root.description && !showRootPicker}
826
+ <!-- Secondary: takes only the room the breadcrumbs leave, truncating. -->
827
+ <p
828
+ class="min-w-0 flex-[1_1_0] truncate text-xs text-muted-foreground"
829
+ title={root.description}
830
+ data-file-browser-description
831
+ >
832
+ {root.description}
833
+ </p>
834
+ {/if}
788
835
  {/if}
789
836
  </div>
790
- {#if root?.description && (roots.length === 1 || showPane)}
791
- <p class="-mt-1 text-xs text-muted-foreground md:order-last md:basis-full">
792
- {root.description}
793
- </p>
794
- {/if}
795
837
 
796
- <div class="flex flex-wrap items-center gap-x-4 gap-y-2 md:flex-[0_1_auto]">
797
- <div class="relative min-w-[12rem] flex-1 md:w-56 md:flex-none">
838
+ <div
839
+ class="flex flex-wrap items-center gap-2 md:flex-[0_1_auto] md:gap-x-4"
840
+ data-file-browser-controls
841
+ >
842
+ <div class="relative min-w-[10rem] flex-1 md:w-56 md:flex-none">
798
843
  <label for={filterId} class="sr-only"
799
844
  >{source.search ? 'Search files' : 'Filter files in this folder'}</label
800
845
  >
@@ -817,29 +862,35 @@
817
862
  aria-hidden="true">/</kbd
818
863
  >
819
864
  </div>
820
- <div class="flex items-center gap-2">
821
- <Switch id={hiddenId} checked={showHidden} onchange={(v) => (showHidden = v)} />
822
- <label for={hiddenId} class="whitespace-nowrap text-sm">Show hidden files</label>
823
- </div>
865
+ {#if wide.current}
866
+ <div class="flex items-center gap-2">
867
+ <Switch id={hiddenId} checked={showHidden} onchange={(v) => (showHidden = v)} />
868
+ <label for={hiddenId} class="whitespace-nowrap text-sm">Show hidden files</label>
869
+ </div>
870
+ {/if}
824
871
  {#if toolbar && caps.any}
825
872
  <div class="flex items-center gap-2" data-file-browser-toolbar>
826
873
  {@render toolbar(context)}
827
874
  </div>
828
875
  {/if}
829
- {#if navigationPane && !wide.current && roots.length > 0}
830
- <Button
831
- variant="outline"
832
- size="sm"
833
- onclick={() => (foldersOpen = true)}
834
- aria-haspopup="dialog"
835
- >
836
- <Icon name="sidebar" size={16} />
837
- Folders
876
+ {#if wide.current}
877
+ <Button variant="ghost" size="icon" onclick={refresh} aria-label="Refresh">
878
+ <Icon name="refresh" size={16} />
838
879
  </Button>
880
+ {:else}
881
+ <DropdownMenu
882
+ items={moreItems}
883
+ align="end"
884
+ triggerVariant="ghost"
885
+ triggerSize="icon"
886
+ triggerClass="shrink-0"
887
+ triggerLabel="More options"
888
+ >
889
+ {#snippet trigger()}
890
+ <Icon name="more-horizontal" size={16} />
891
+ {/snippet}
892
+ </DropdownMenu>
839
893
  {/if}
840
- <Button variant="ghost" size="icon" onclick={refresh} aria-label="Refresh">
841
- <Icon name="refresh" size={16} />
842
- </Button>
843
894
  </div>
844
895
  </div>
845
896
  {/if}
@@ -971,7 +1022,13 @@
971
1022
  {/snippet}
972
1023
 
973
1024
  {#snippet filesButton()}
974
- <Button variant="outline" size="sm" onclick={() => (filesOpen = true)} aria-haspopup="dialog">
1025
+ <Button
1026
+ variant="outline"
1027
+ size="sm"
1028
+ onclick={() => (filesOpen = true)}
1029
+ aria-haspopup="dialog"
1030
+ title={`Files in ${folderTrail}`}
1031
+ >
975
1032
  <Icon name="list" size={16} />
976
1033
  Files
977
1034
  </Button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/files-svelte",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Svelte network-drive file browser for Classic Theme: FileBrowser plus FileList, FileBreadcrumbs, FileIcon, FilePreview and FileDetails, with previews through the document viewers",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",