Skip to main content

folder

Displays a list of files and folders in a grid layout. Supports drag and drop, context menus, fuzzy search, and file operations.

caution

This is a low-level component.
For a complete file explorer dialog, use the explorer component instead.

Usage

Modular:

import { folder } from "/42/ui/media/folder.js"

const myFolder = folder({
value: "~/documents/",
})

Plan:

{
tag: "ui-folder",
value: "~/documents/",
}

Props

PropertyTypeDescription
valueStringThe directory path to display.
globBooleanWhether to use glob pattern matching for the path.
filterStringA glob pattern or extension to filter files (e.g. "*.txt").
filterTypeStringSet to "disable" to disable filtered items instead of hiding them.

Properties

PropertyTypeDescription
valueStringGet or set the current directory path.
globBooleanGet or set glob pattern matching.
filterStringGet or set the file filter pattern.
filterTypeStringGet or set the filter type.
showHiddenFilesBooleanGet or set whether hidden files (starting with .) are shown. Default is false.
multiselectableBooleanGet or set whether multiple items can be selected.
selectionArrayGet or set the currently selected file paths.
virtualizableObjectThe virtualizable instance managing list rendering.
matrixableObjectThe matrixable instance managing grid layout and focus navigation.
transferableObjectThe transferable instance managing drag and drop.
fuzzySearchFunctionFuzzy search function initialized with current file basenames.

Methods

MethodDescription
refresh()Re-render the folder contents.
createFolder(options)Create a new folder and select it.
createFile(options)Create a new file and select it.
createShortcut(options)Create a shortcut and select it.
importFile(options)Import file(s) and select them.
selectAddedIcon(filenames)Select icons by their filenames after they are added.
displayContextMenu(e, addItems?)Show a context menu at the pointer position.

Events

EventDescription
ui:folder.exportDispatched when items are dragged out. Cancelable.
ui:folder.importDispatched when items are dropped in. Cancelable.
ui:folder.inexistentDispatched when the path does not exist. Cancelable.
ui:folder.icon-addedDispatched when new icons are added to the folder.
ui:folder.contextmenu-creationDispatched during context menu file creation.
ui:folder.itemsHook event fired with the current items list.
ui.selection.changeDispatched when the selection changes.

Context Menu

Right-clicking the folder background shows a context menu with options to create files, folders, shortcuts, paste from clipboard, and import files. Right-clicking an icon shows a file-specific context menu with open, cut, copy, rename, and delete options.

The displayContextMenu method accepts an optional addItems callback to inject custom menu items.