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

15 exports
View source packages/ui-machines/src/file-tree/index.ts

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();

Exports

DeclarationView source
FileTreeChangeReasonts
type FileTreeChangeReason = "pointer" | "keyboard" | "programmatic";
DeclarationView source
FileTreeCommandts
type FileTreeCommand = CommandObject & ({
readonly type: "SELECT_CHANGE_REQUEST";
readonly value: string;
readonly reason: FileTreeChangeReason;
} | {
readonly type: "FOCUS_ROW";
readonly id: string;
});
DeclarationView source
FileTreeContextts
type FileTreeContext = {
readonly open: Readonly<Record<string, boolean>>;
readonly focusedId?: string;
readonly selected?: string;
readonly mode: "controlled" | "uncontrolled";
};
Name
Kind
Type
Requirement
focusedId
property
string
optional
mode
property
"controlled" | "uncontrolled"
required
open
property
Readonly<Record<string, boolean>>
required
selected
property
string
optional
Name
focusedId
Kind
property
Type
string
Requirement
optional
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
DeclarationView source
FileTreeDiagnosticCodests
export declare const FileTreeDiagnosticCodes: readonly DiagnosticCatalogueEntry[];
DeclarationView source
FileTreeEventts
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";
};
DeclarationView source
FileTreeGitStatusts
type FileTreeGitStatus = "M" | "A" | "D";

FileTreeInput

interface
DeclarationView source
FileTreeInputts
interface FileTreeInput {
readonly nodes: readonly FileTreeNode[];
readonly selected?: string;
readonly defaultSelected?: string;
}
Name
Kind
Type
Requirement
defaultSelected
property
string
optional
nodes
property
readonly FileTreeNode[]
required
selected
property
string
optional
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
DeclarationView source
fileTreeMachinets
export declare const fileTreeMachine: FileTreeMachine;
DeclarationView source
FileTreeMachinets
type FileTreeMachine = Machine<FileTreeInput, FileTreeStateValue, FileTreeContext, FileTreeEvent, FileTreeCommand>;

FileTreeNode

interface
DeclarationView source
FileTreeNodets
interface FileTreeNode {
readonly name: string;
readonly children?: readonly FileTreeNode[];
readonly defaultOpen?: boolean;
readonly git?: FileTreeGitStatus;
}
Name
Kind
Type
Requirement
children
property
readonly FileTreeNode[]
optional
defaultOpen
property
boolean
optional
git
property
FileTreeGitStatus
optional
name
property
string
required
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
DeclarationView source
fileTreeReplaySequencets
export declare const fileTreeReplaySequence: readonly FileTreeEvent[];

FileTreeRow

interface
DeclarationView source
FileTreeRowts
interface FileTreeRow {
readonly id: string;
readonly name: string;
readonly depth: number;
readonly isDir: boolean;
readonly open: boolean;
readonly git?: FileTreeGitStatus;
}
Name
Kind
Type
Requirement
depth
property
number
required
git
property
FileTreeGitStatus
optional
id
property
string
required
isDir
property
boolean
required
name
property
string
required
open
property
boolean
required
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
DeclarationView source
fileTreeSelectorsts
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
activeId
property
(snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => string | undefined
required
focusedId
property
(snapshot: FileTreeSnapshot) => string | undefined
required
open
property
(snapshot: FileTreeSnapshot, id: string) => boolean
required
rows
property
(snapshot: FileTreeSnapshot, nodes: readonly FileTreeNode[]) => FileTreeRow[]
required
selected
property
(snapshot: FileTreeSnapshot) => string | undefined
required
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
DeclarationView source
FileTreeSnapshotts
type FileTreeSnapshot = Snapshot<FileTreeStateValue, FileTreeContext>;
DeclarationView source
FileTreeStateValuets
type FileTreeStateValue = "ready";