- Name
focusedId- Kind
- property
- Type
string- Requirement
- optional
DocsAPI referenceUI machinesfile-tree
file-tree machine
The public state machine contract for @grassroot/ui-machines/file-tree. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/file-tree
Package
Service example
file-tree.tsts
import { createService } from "@grassroot/statechart";import { fileTreeMachine } from "@grassroot/ui-machines/file-tree"; const service = createService(fileTreeMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();15 of 15
Exports
FileTreeChangeReason
typeFileTreeChangeReasonts
type FileTreeChangeReason = "pointer" | "keyboard" | "programmatic";FileTreeCommand
typeFileTreeCommandts
type FileTreeCommand = CommandObject & ({ readonly type: "SELECT_CHANGE_REQUEST"; readonly value: string; readonly reason: FileTreeChangeReason;} | { readonly type: "FOCUS_ROW"; readonly id: string;});FileTreeContext
typeFileTreeContextts
type FileTreeContext = { readonly open: Readonly<Record<string, boolean>>; readonly focusedId?: string; readonly selected?: string; readonly mode: "controlled" | "uncontrolled";};Name
Kind
Type
Requirement
focusedIdproperty
stringoptional
modeproperty
"controlled" | "uncontrolled"required
openproperty
Readonly<Record<string, boolean>>required
selectedproperty
stringoptional
- Name
mode- Kind
- property
- Type
"controlled" | "uncontrolled"- Requirement
- required
- Name
open- Kind
- property
- Type
Readonly<Record<string, boolean>>- Requirement
- required
- Name
selected- Kind
- property
- Type
string- Requirement
- optional
FileTreeDiagnosticCodes
valueFileTreeDiagnosticCodests
export declare const FileTreeDiagnosticCodes: readonly DiagnosticCatalogueEntry[];FileTreeEvent
typeFileTreeEventts
type FileTreeEvent = { readonly type: "HIGHLIGHT"; readonly id: string; readonly reason: FileTreeChangeReason;} | { readonly type: "MOVE"; readonly direction: -1 | 1;} | { readonly type: "OPEN"; readonly id: string;} | { readonly type: "CLOSE"; readonly id: string;} | { readonly type: "TOGGLE"; readonly id: string;} | { readonly type: "FOCUS"; readonly id: string;} | { readonly type: "SELECT"; readonly value: string; readonly reason: FileTreeChangeReason;} | { readonly type: "RESET";};FileTreeGitStatus
typeFileTreeGitStatusts
type FileTreeGitStatus = "M" | "A" | "D";FileTreeInput
interfaceFileTreeInputts
interface FileTreeInput { readonly nodes: readonly FileTreeNode[]; readonly selected?: string; readonly defaultSelected?: string;}Name
Kind
Type
Requirement
defaultSelectedproperty
stringoptional
nodesproperty
readonly FileTreeNode[]required
selectedproperty
stringoptional
- Name
defaultSelected- Kind
- property
- Type
string- Requirement
- optional
- Name
nodes- Kind
- property
- Type
readonly FileTreeNode[]- Requirement
- required
- Name
selected- Kind
- property
- Type
string- Requirement
- optional
fileTreeMachine
valuefileTreeMachinets
export declare const fileTreeMachine: FileTreeMachine;FileTreeMachine
typeFileTreeMachinets
type FileTreeMachine = Machine<FileTreeInput, FileTreeStateValue, FileTreeContext, FileTreeEvent, FileTreeCommand>;FileTreeNode
interfaceFileTreeNodets
interface FileTreeNode { readonly name: string; readonly children?: readonly FileTreeNode[]; readonly defaultOpen?: boolean; readonly git?: FileTreeGitStatus;}Name
Kind
Type
Requirement
childrenproperty
readonly FileTreeNode[]optional
defaultOpenproperty
booleanoptional
gitproperty
FileTreeGitStatusoptional
nameproperty
stringrequired
- Name
children- Kind
- property
- Type
readonly FileTreeNode[]- Requirement
- optional
- Name
defaultOpen- Kind
- property
- Type
boolean- Requirement
- optional
- Name
git- Kind
- property
- Type
FileTreeGitStatus- Requirement
- optional
- Name
name- Kind
- property
- Type
string- Requirement
- required
fileTreeReplaySequence
valuefileTreeReplaySequencets
export declare const fileTreeReplaySequence: readonly FileTreeEvent[];FileTreeRow
interfaceFileTreeRowts
interface FileTreeRow { readonly id: string; readonly name: string; readonly depth: number; readonly isDir: boolean; readonly open: boolean; readonly git?: FileTreeGitStatus;}Name
Kind
Type
Requirement
depthproperty
numberrequired
gitproperty
FileTreeGitStatusoptional
idproperty
stringrequired
isDirproperty
booleanrequired
nameproperty
stringrequired
openproperty
booleanrequired
- Name
depth- Kind
- property
- Type
number- Requirement
- required
- Name
git- Kind
- property
- Type
FileTreeGitStatus- Requirement
- optional
- Name
id- Kind
- property
- Type
string- Requirement
- required
- Name
isDir- Kind
- property
- Type
boolean- Requirement
- required
- Name
name- Kind
- property
- Type
string- Requirement
- required
- Name
open- Kind
- property
- Type
boolean- Requirement
- required
fileTreeSelectors
valuefileTreeSelectorsts
export declare const fileTreeSelectors: { open: (snapshot: FileTreeSnapshot, id: string) => boolean; selected: (snapshot: FileTreeSnapshot) => string | undefined; focusedId: (snapshot: FileTreeSnapshot) => string | undefined; activeId: (snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => string | undefined; rows: (snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => FileTreeRow[];};Name
Kind
Type
Requirement
activeIdproperty
(snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => string | undefinedrequired
focusedIdproperty
(snapshot: FileTreeSnapshot) => string | undefinedrequired
openproperty
(snapshot: FileTreeSnapshot, id: string) => booleanrequired
rowsproperty
(snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => FileTreeRow[]required
selectedproperty
(snapshot: FileTreeSnapshot) => string | undefinedrequired
- Name
activeId- Kind
- property
- Type
(snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => string | undefined- Requirement
- required
- Name
focusedId- Kind
- property
- Type
(snapshot: FileTreeSnapshot) => string | undefined- Requirement
- required
- Name
open- Kind
- property
- Type
(snapshot: FileTreeSnapshot, id: string) => boolean- Requirement
- required
- Name
rows- Kind
- property
- Type
(snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => FileTreeRow[]- Requirement
- required
- Name
selected- Kind
- property
- Type
(snapshot: FileTreeSnapshot) => string | undefined- Requirement
- required
FileTreeSnapshot
typeFileTreeSnapshotts
type FileTreeSnapshot = Snapshot<FileTreeStateValue, FileTreeContext>;FileTreeStateValue
typeFileTreeStateValuets
type FileTreeStateValue = "ready";