Skip to content

File List

FileList turns an injectable directory scan into a keyboard- and mouse-navigable two-column list. Files appear before directories, directories carry a separator, and the parent entry stays last. Changing its signals rescans automatically.

Usage

ts
import { FileList } from '@jsvision/files';
import { signal } from '@jsvision/ui';

const directory = signal('/workspace');
const list = new FileList({ fs: virtualFs, directory, wildcard: signal('*.ts') });

Live example

Rescan a two-column virtual directory as hidden-file, wildcard, and failure inputs change.

Props and public state

FileList exposes directory, wildcard, showHidden, the reactive entries signal, and focusedEntry(). Inherited ListView signals expose the focused and selected row indexes. Construction is described by FileListOptions; every row is a DirEntry, and scanDirectory defines the source ordering.

Configuration

FileListOptions fieldTypeDefaultPurpose
fsFileSystemrequiredSupplies the synchronous directory scan and separator.
directorySignal<string>requiredRescans the list whenever it changes.
wildcardSignal<string>internal '*'Filters files while leaving directories reachable.
showHiddenSignal<boolean>internal falseIncludes dot/hidden entries when true.
filter(entry: DirEntry) => booleannoneAdds a pure predicate to file filtering.
focusedSignal<number>internal 0Shares the keyboard focus cursor with other UI.
selectedSignal<number>internal -1Shares the selected row.
barScrollBarinternal vertical barConnects an externally laid-out scroll bar.
onOpenEntry(entry: DirEntry) => voidnoneReceives Enter/double-click activation.
commandstringnoneEmits an application command on activation.

Scanning and filtering

Wildcard and custom predicates apply to files, while directories remain navigable. Hidden entries are omitted by default. Any unreadable scan becomes a safe empty list rather than throwing during render.

scanDirectory returns files first, then directories, with .. last. The list preserves that ordering by disabling inherited sorting and renders directories with the filesystem separator.

Activation and focus

Arrow keys, type-ahead, clicks, and wheel behavior come from ListView. Enter or double-click activates the focused entry and calls onOpenEntry or emits the configured command.

Sizing and layout

Allocate enough width for two useful columns and multiple rows. A caller-supplied vertical bar can share scrolling state; otherwise the list creates its own.

Best practices

  • Navigate by updating directory; do not replace the widget.
  • Present an explicit empty/error message beside the list when a failed scan matters.
  • Keep filters pure because reactive rescans may call them repeatedly.

Theming

Rows use listNormal, listFocused, and listSelected, matching other list-based controls.