- Name
defaultSort- Kind
- parameter
- Type
string | null- Requirement
- optional
DocsAPI referenceUI machinesdata-table
data-table machine
The public state machine contract for @grassroot/ui-machines/data-table. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/data-table
Package
Service example
data-table.tsts
import { createService } from "@grassroot/statechart";import { dataTableMachine } from "@grassroot/ui-machines/data-table"; const service = createService(dataTableMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();28 of 28
Exports
createDataTableSortState
functionDuplicate of frozen `createDataTableSortState`.
createDataTableSortStatets
declare function createDataTableSortState(defaultSort?: string | null): DataTableSortState;Name
Kind
Type
Requirement
defaultSortparameter
string | nulloptional
returnreturn value
DataTableSortStaten/a
- Name
return- Kind
- return value
- Type
DataTableSortState- Requirement
- n/a
DataTableCommand
typeDataTableCommandts
type DataTableCommand = SelectionCommand;DataTableContext
typeDataTableContextts
type DataTableContext = { readonly sortKey: string | null; readonly dir: DataTableSortDir; readonly selection: SelectionMachineState;};Name
Kind
Type
Requirement
dirproperty
DataTableSortDirrequired
selectionproperty
SelectionMachineStaterequired
sortKeyproperty
string | nullrequired
- Name
dir- Kind
- property
- Type
DataTableSortDir- Requirement
- required
- Name
selection- Kind
- property
- Type
SelectionMachineState- Requirement
- required
- Name
sortKey- Kind
- property
- Type
string | null- Requirement
- required
DataTableDiagnosticCodes
valueDataTableDiagnosticCodests
export declare const DataTableDiagnosticCodes: readonly DiagnosticCatalogueEntry[];DataTableEvent
typeDataTableEventts
type DataTableEvent = SelectionEvent | { readonly type: "TOGGLE_SORT"; readonly key: string; readonly sortable: boolean;};DataTableInput
typeDataTableInputts
type DataTableInput = { readonly defaultSort?: string | null; readonly selectionMode?: SelectionMode; readonly selectedIds?: SelectionValue; readonly defaultSelectedIds?: SelectionValue; readonly orderedIds?: readonly string[]; readonly disabledIds?: readonly string[];};Name
Kind
Type
Requirement
defaultSelectedIdsproperty
SelectionValueoptional
defaultSortproperty
string | nulloptional
disabledIdsproperty
readonly string[]optional
orderedIdsproperty
readonly string[]optional
selectedIdsproperty
SelectionValueoptional
selectionModeproperty
SelectionModeoptional
- Name
defaultSelectedIds- Kind
- property
- Type
SelectionValue- Requirement
- optional
- Name
defaultSort- Kind
- property
- Type
string | null- Requirement
- optional
- Name
disabledIds- Kind
- property
- Type
readonly string[]- Requirement
- optional
- Name
orderedIds- Kind
- property
- Type
readonly string[]- Requirement
- optional
- Name
selectedIds- Kind
- property
- Type
SelectionValue- Requirement
- optional
- Name
selectionMode- Kind
- property
- Type
SelectionMode- Requirement
- optional
dataTableMachine
valuedataTableMachinets
export declare const dataTableMachine: DataTableMachine;DataTableMachine
typeDataTableMachinets
type DataTableMachine = Machine<DataTableInput, DataTableStateValue, DataTableContext, DataTableEvent, DataTableCommand>;DataTableMachineStatets
type DataTableMachineState = MachineState<DataTableStateValue, DataTableContext>;dataTableReplaySequence
valuedataTableReplaySequencets
export declare const dataTableReplaySequence: readonly DataTableEvent[];dataTableSelectors
valuedataTableSelectorsts
export declare const dataTableSelectors: { sortKey: (snapshot: DataTableSnapshot) => string | null; dir: (snapshot: DataTableSnapshot) => DataTableSortDir; selectedIds: (snapshot: DataTableSnapshot) => SelectionValue; anchorId: (snapshot: DataTableSnapshot) => string | null; bindingMode: (snapshot: DataTableSnapshot) => BindingMode; selection: (snapshot: DataTableSnapshot) => SelectionMachineState;};Name
Kind
Type
Requirement
anchorIdproperty
(snapshot: DataTableSnapshot) => string | nullrequired
bindingModeproperty
(snapshot: DataTableSnapshot) => BindingModerequired
dirproperty
(snapshot: DataTableSnapshot) => DataTableSortDirrequired
selectedIdsproperty
(snapshot: DataTableSnapshot) => SelectionValuerequired
selectionproperty
(snapshot: DataTableSnapshot) => SelectionMachineStaterequired
sortKeyproperty
(snapshot: DataTableSnapshot) => string | nullrequired
- Name
anchorId- Kind
- property
- Type
(snapshot: DataTableSnapshot) => string | null- Requirement
- required
- Name
bindingMode- Kind
- property
- Type
(snapshot: DataTableSnapshot) => BindingMode- Requirement
- required
- Name
dir- Kind
- property
- Type
(snapshot: DataTableSnapshot) => DataTableSortDir- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
(snapshot: DataTableSnapshot) => SelectionValue- Requirement
- required
- Name
selection- Kind
- property
- Type
(snapshot: DataTableSnapshot) => SelectionMachineState- Requirement
- required
- Name
sortKey- Kind
- property
- Type
(snapshot: DataTableSnapshot) => string | null- Requirement
- required
DataTableSnapshot
typeDataTableSnapshotts
type DataTableSnapshot = Snapshot<DataTableStateValue, DataTableContext>;DataTableSortAction
typeDataTableSortActionts
type DataTableSortAction = { readonly type: "toggle"; readonly key: string; readonly sortable: boolean;};Name
Kind
Type
Requirement
keyproperty
stringrequired
sortableproperty
booleanrequired
typeproperty
"toggle"required
- Name
key- Kind
- property
- Type
string- Requirement
- required
- Name
sortable- Kind
- property
- Type
boolean- Requirement
- required
- Name
type- Kind
- property
- Type
"toggle"- Requirement
- required
DataTableSortDir
typeDataTableSortDirts
type DataTableSortDir = "asc" | "desc";DataTableSortState
typeDataTableSortStatets
type DataTableSortState = { readonly sortKey: string | null; readonly dir: DataTableSortDir;};Name
Kind
Type
Requirement
dirproperty
DataTableSortDirrequired
sortKeyproperty
string | nullrequired
- Name
dir- Kind
- property
- Type
DataTableSortDir- Requirement
- required
- Name
sortKey- Kind
- property
- Type
string | null- Requirement
- required
DataTableStateValue
typeDataTableStateValuets
type DataTableStateValue = "active";EMPTY_SELECTION_IDS
valueEMPTY_SELECTION_IDSts
export declare const EMPTY_SELECTION_IDS: SelectionValue;reduceDataTableSort
functionDuplicate of frozen `reduceDataTableSort`.
reduceDataTableSortts
declare function reduceDataTableSort(state: DataTableSortState, action: DataTableSortAction): DataTableSortState;Name
Kind
Type
Requirement
stateparameter
DataTableSortStaterequired
actionparameter
DataTableSortActionrequired
returnreturn value
DataTableSortStaten/a
- Name
state- Kind
- parameter
- Type
DataTableSortState- Requirement
- required
- Name
action- Kind
- parameter
- Type
DataTableSortAction- Requirement
- required
- Name
return- Kind
- return value
- Type
DataTableSortState- Requirement
- n/a
sameSelectionIds
functionsameSelectionIdsts
declare function sameSelectionIds(left: SelectionValue, right: SelectionValue): boolean;Name
Kind
Type
Requirement
leftparameter
SelectionValuerequired
rightparameter
SelectionValuerequired
returnreturn value
booleann/a
- Name
left- Kind
- parameter
- Type
SelectionValue- Requirement
- required
- Name
right- Kind
- parameter
- Type
SelectionValue- Requirement
- required
- Name
return- Kind
- return value
- Type
boolean- Requirement
- n/a
SelectionChangeDetailts
type SelectionChangeDetail = { readonly selectedIds: SelectionValue; readonly reason: SelectionChangeReason;};Name
Kind
Type
Requirement
reasonproperty
SelectionChangeReasonrequired
selectedIdsproperty
SelectionValuerequired
- Name
reason- Kind
- property
- Type
SelectionChangeReason- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
SelectionValue- Requirement
- required
SelectionChangeReasonts
type SelectionChangeReason = "pointer" | "keyboard" | "programmatic";SelectionCommand
typeSelectionCommandts
type SelectionCommand = CommandObject & { readonly type: "SELECTION_CHANGE_REQUEST"; readonly selectedIds: SelectionValue; readonly reason: SelectionChangeReason;};Name
Kind
Type
Requirement
reasonproperty
SelectionChangeReasonrequired
selectedIdsproperty
SelectionValuerequired
typeproperty
stringrequired
- Name
reason- Kind
- property
- Type
SelectionChangeReason- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
SelectionValue- Requirement
- required
- Name
type- Kind
- property
- Type
string- Requirement
- required
selectionInputFromDataTable
functionselectionInputFromDataTablets
declare function selectionInputFromDataTable(input: DataTableInput): SelectionInput;Name
Kind
Type
Requirement
inputparameter
DataTableInputrequired
returnreturn value
SelectionInputn/a
- Name
input- Kind
- parameter
- Type
DataTableInput- Requirement
- required
- Name
return- Kind
- return value
- Type
SelectionInput- Requirement
- n/a
selectionMachine
valueselectionMachinets
export declare const selectionMachine: SelectionMachine;SelectionMode
typeSelectionModets
type SelectionMode = "none" | "single" | "multiple";selectionSelectors
valueselectionSelectorsts
export declare const selectionSelectors: { selectedIds: (snapshot: SelectionSnapshot) => SelectionValue; anchorId: (snapshot: SelectionSnapshot) => string | null; bindingMode: (snapshot: SelectionSnapshot) => BindingMode; isSelected: (snapshot: SelectionSnapshot, id: string) => boolean;};Name
Kind
Type
Requirement
anchorIdproperty
(snapshot: SelectionSnapshot) => string | nullrequired
bindingModeproperty
(snapshot: SelectionSnapshot) => BindingModerequired
isSelectedproperty
(snapshot: SelectionSnapshot, id: string) => booleanrequired
selectedIdsproperty
(snapshot: SelectionSnapshot) => SelectionValuerequired
- Name
anchorId- Kind
- property
- Type
(snapshot: SelectionSnapshot) => string | null- Requirement
- required
- Name
bindingMode- Kind
- property
- Type
(snapshot: SelectionSnapshot) => BindingMode- Requirement
- required
- Name
isSelected- Kind
- property
- Type
(snapshot: SelectionSnapshot, id: string) => boolean- Requirement
- required
- Name
selectedIds- Kind
- property
- Type
(snapshot: SelectionSnapshot) => SelectionValue- Requirement
- required
SelectionValue
typeSelectionValuets
type SelectionValue = readonly string[];sortDataTableRows
functionDuplicate of frozen `sortDataTableRows`.
sortDataTableRowsts
declare function sortDataTableRows<T>(data: readonly T[], column: { readonly key: keyof T & string; readonly num?: boolean; readonly sortable?: boolean; readonly compare?: (a: T, b: T) => number;} | undefined, direction: DataTableSortDir): T[];Name
Kind
Type
Requirement
dataparameter
readonly T[]required
columnparameter
{
readonly key: keyof T & string;
readonly num?: boolean;
readonly sortable?: boolean;
readonly compare?: (a: T, b: T) => number;
} | undefinedrequired
directionparameter
DataTableSortDirrequired
returnreturn value
T[]n/a
- Name
data- Kind
- parameter
- Type
readonly T[]- Requirement
- required
- Name
column- Kind
- parameter
- Type
{ readonly key: keyof T & string; readonly num?: boolean; readonly sortable?: boolean; readonly compare?: (a: T, b: T) => number; } | undefined- Requirement
- required
- Name
direction- Kind
- parameter
- Type
DataTableSortDir- Requirement
- required
- Name
return- Kind
- return value
- Type
T[]- Requirement
- n/a