DocsAPI referenceUI machinesthread-list

thread-list machine

The public state machine contract for @grassroot/ui-machines/thread-list. The machine owns behaviour; the matching headless layer owns composition.

@grassroot/ui-machines/thread-list

Package

16 exports
View source packages/ui-machines/src/thread-list/index.ts

Service example

thread-list.tsts
import { createService } from "@grassroot/statechart";
import { threadListMachine } from "@grassroot/ui-machines/thread-list";
const service = createService(threadListMachine, { input: {} });
service.start();
service.send({ type: "…" });
service.stop();

Exports

DeclarationView source
ThreadListCommandts
type ThreadListCommand = (CommandObject & {
readonly type: "LOAD_REQUEST";
}) | (CommandObject & {
readonly type: "LOAD_MORE_REQUEST";
readonly after: string;
}) | (CommandObject & {
readonly type: "SELECT_REQUEST";
readonly id: string | null;
}) | (CommandObject & {
readonly type: "RENAME_REQUEST";
readonly id: string;
readonly title: string;
}) | (CommandObject & {
readonly type: "DELETE_REQUEST";
readonly id: string;
}) | (CommandObject & {
readonly type: "RESTORE_REQUEST";
readonly id: string;
}) | ScheduleCommand<ThreadListEvent> | CancelCommand;
DeclarationView source
ThreadListContextts
type ThreadListContext = {
readonly threads: readonly ThreadListItem[];
readonly selectedThreadId: string | null;
readonly renameId?: string;
readonly renameTitle?: string;
readonly deleteId?: string;
readonly undo?: ThreadListUndo;
readonly nextCursor?: string;
readonly error?: unknown;
};
Name
Kind
Type
Requirement
deleteId
property
string
optional
error
property
unknown
optional
nextCursor
property
string
optional
renameId
property
string
optional
renameTitle
property
string
optional
selectedThreadId
property
string | null
required
threads
property
readonly ThreadListItem[]
required
undo
property
ThreadListUndo
optional
Name
deleteId
Kind
property
Type
string
Requirement
optional
Name
error
Kind
property
Type
unknown
Requirement
optional
Name
nextCursor
Kind
property
Type
string
Requirement
optional
Name
renameId
Kind
property
Type
string
Requirement
optional
Name
renameTitle
Kind
property
Type
string
Requirement
optional
Name
selectedThreadId
Kind
property
Type
string | null
Requirement
required
Name
threads
Kind
property
Type
readonly ThreadListItem[]
Requirement
required
Name
undo
Kind
property
Type
ThreadListUndo
Requirement
optional
DeclarationView source
ThreadListDiagnosticCodests
export declare const ThreadListDiagnosticCodes: readonly DiagnosticCatalogueEntry[];
DeclarationView source
ThreadListEventts
type ThreadListEvent = {
readonly type: "LOAD";
} | {
readonly type: "LOAD_SUCCEEDED";
readonly threads: readonly ThreadListItem[];
readonly nextCursor?: string;
} | {
readonly type: "LOAD_FAILED";
readonly error?: JsonValue;
} | {
readonly type: "LOAD_MORE";
} | {
readonly type: "LOAD_MORE_SUCCEEDED";
readonly threads: readonly ThreadListItem[];
readonly nextCursor?: string;
} | {
readonly type: "LOAD_MORE_FAILED";
readonly error?: JsonValue;
} | {
readonly type: "SET_THREADS";
readonly threads: readonly ThreadListItem[];
readonly nextCursor?: string;
} | {
readonly type: "SELECT";
readonly id: string | null;
} | {
readonly type: "BEGIN_RENAME";
readonly id: string;
} | {
readonly type: "SET_RENAME_TITLE";
readonly title: string;
} | {
readonly type: "COMMIT_RENAME";
readonly title?: string;
} | {
readonly type: "CANCEL_RENAME";
} | {
readonly type: "BEGIN_DELETE";
readonly id: string;
} | {
readonly type: "CANCEL_DELETE";
} | {
readonly type: "DELETE";
} | {
readonly type: "UNDO_DELETE";
} | {
readonly type: "DELETE_UNDO_EXPIRED";
readonly id: string;
} | {
readonly type: "RESET";
};
DeclarationView source
ThreadListInputts
type ThreadListInput = {
readonly threads?: readonly ThreadListItem[];
readonly defaultThreads?: readonly ThreadListItem[];
readonly selectedThreadId?: string | null;
readonly defaultSelectedThreadId?: string | null;
readonly undoDelayMs?: number;
};
Name
Kind
Type
Requirement
defaultSelectedThreadId
property
string | null
optional
defaultThreads
property
readonly ThreadListItem[]
optional
selectedThreadId
property
string | null
optional
threads
property
readonly ThreadListItem[]
optional
undoDelayMs
property
number
optional
Name
defaultSelectedThreadId
Kind
property
Type
string | null
Requirement
optional
Name
defaultThreads
Kind
property
Type
readonly ThreadListItem[]
Requirement
optional
Name
selectedThreadId
Kind
property
Type
string | null
Requirement
optional
Name
threads
Kind
property
Type
readonly ThreadListItem[]
Requirement
optional
Name
undoDelayMs
Kind
property
Type
number
Requirement
optional
DeclarationView source
ThreadListItemts
type ThreadListItem = {
readonly id: string;
readonly remoteId?: string;
readonly externalId?: string;
readonly status: ThreadListItemStatus;
readonly title?: string;
readonly custom?: Readonly<Record<string, JsonValue>>;
};
Name
Kind
Type
Requirement
custom
property
Readonly<Record<string, JsonValue>>
optional
externalId
property
string
optional
id
property
string
required
remoteId
property
string
optional
status
property
ThreadListItemStatus
required
title
property
string
optional
Name
custom
Kind
property
Type
Readonly<Record<string, JsonValue>>
Requirement
optional
Name
externalId
Kind
property
Type
string
Requirement
optional
Name
id
Kind
property
Type
string
Requirement
required
Name
remoteId
Kind
property
Type
string
Requirement
optional
Name
status
Kind
property
Type
ThreadListItemStatus
Requirement
required
Name
title
Kind
property
Type
string
Requirement
optional
DeclarationView source
ThreadListItemStatusts
type ThreadListItemStatus = "regular" | "archived";
DeclarationView source
ThreadListLoadStatets
type ThreadListLoadState = "idle" | "loading" | "loadingMore";
DeclarationView source
threadListMachinets
export declare const threadListMachine: ThreadListMachine;
DeclarationView source
ThreadListMachinets
type ThreadListMachine = Machine<ThreadListInput, ThreadListStateValue, ThreadListContext, ThreadListEvent, ThreadListCommand>;
DeclarationView source
ThreadListModets
type ThreadListMode = "browsing" | "renaming" | "confirming-delete";
DeclarationView source
threadListReplaySequencets
export declare const threadListReplaySequence: readonly ThreadListEvent[];
DeclarationView source
threadListSelectorsts
export declare const threadListSelectors: {
mode: (snapshot: ThreadListSnapshot) => ThreadListMode;
load: (snapshot: ThreadListSnapshot) => ThreadListLoadState;
threads: (snapshot: ThreadListSnapshot) => readonly ThreadListItem[];
selectedThreadId: (snapshot: ThreadListSnapshot) => string | null;
isLoading: (snapshot: ThreadListSnapshot) => boolean;
hasMore: (snapshot: ThreadListSnapshot) => boolean;
isRenaming: (snapshot: ThreadListSnapshot) => boolean;
isConfirmingDelete: (snapshot: ThreadListSnapshot) => boolean;
undo: (snapshot: ThreadListSnapshot) => ThreadListUndo | undefined;
};
Name
Kind
Type
Requirement
hasMore
property
(snapshot: ThreadListSnapshot) => boolean
required
isConfirmingDelete
property
(snapshot: ThreadListSnapshot) => boolean
required
isLoading
property
(snapshot: ThreadListSnapshot) => boolean
required
isRenaming
property
(snapshot: ThreadListSnapshot) => boolean
required
load
property
(snapshot: ThreadListSnapshot) => ThreadListLoadState
required
mode
property
(snapshot: ThreadListSnapshot) => ThreadListMode
required
selectedThreadId
property
(snapshot: ThreadListSnapshot) => string | null
required
threads
property
(snapshot: ThreadListSnapshot) => readonly ThreadListItem[]
required
undo
property
(snapshot: ThreadListSnapshot) => ThreadListUndo | undefined
required
Name
hasMore
Kind
property
Type
(snapshot: ThreadListSnapshot) => boolean
Requirement
required
Name
isConfirmingDelete
Kind
property
Type
(snapshot: ThreadListSnapshot) => boolean
Requirement
required
Name
isLoading
Kind
property
Type
(snapshot: ThreadListSnapshot) => boolean
Requirement
required
Name
isRenaming
Kind
property
Type
(snapshot: ThreadListSnapshot) => boolean
Requirement
required
Name
load
Kind
property
Type
(snapshot: ThreadListSnapshot) => ThreadListLoadState
Requirement
required
Name
mode
Kind
property
Type
(snapshot: ThreadListSnapshot) => ThreadListMode
Requirement
required
Name
selectedThreadId
Kind
property
Type
(snapshot: ThreadListSnapshot) => string | null
Requirement
required
Name
threads
Kind
property
Type
(snapshot: ThreadListSnapshot) => readonly ThreadListItem[]
Requirement
required
Name
undo
Kind
property
Type
(snapshot: ThreadListSnapshot) => ThreadListUndo | undefined
Requirement
required
DeclarationView source
ThreadListSnapshotts
type ThreadListSnapshot = Snapshot<ThreadListStateValue, ThreadListContext>;
DeclarationView source
ThreadListStateValuets
type ThreadListStateValue = {
readonly mode: ThreadListMode;
readonly load: ThreadListLoadState;
};
Name
Kind
Type
Requirement
load
property
ThreadListLoadState
required
mode
property
ThreadListMode
required
Name
load
Kind
property
Type
ThreadListLoadState
Requirement
required
Name
mode
Kind
property
Type
ThreadListMode
Requirement
required
DeclarationView source
ThreadListUndots
type ThreadListUndo = {
readonly thread: ThreadListItem;
readonly index: number;
};
Name
Kind
Type
Requirement
index
property
number
required
thread
property
ThreadListItem
required
Name
index
Kind
property
Type
number
Requirement
required
Name
thread
Kind
property
Type
ThreadListItem
Requirement
required