DocsAPI referenceUI machinesgantt

gantt machine

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

@grassroot/ui-machines/gantt

Package

24 exports
View source packages/ui-machines/src/gantt/index.ts

Service example

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

Exports

blockedGanttIds

function

Empty and duplicate ids are blocked. All ids are blocked when step is invalid.

DeclarationView source
blockedGanttIdsts
declare function blockedGanttIds(input: GanttInput): ReadonlySet<string>;
Name
Kind
Type
Requirement
input
parameter
GanttInput
required
return
return value
ReadonlySet<string>
n/a
Name
input
Kind
parameter
Type
GanttInput
Requirement
required
Name
return
Kind
return value
Type
ReadonlySet<string>
Requirement
n/a

clampGanttRange

function

Translate a range by preserving width and clamping to `[0, columnCount]`. Returns `null` when the bar is wider than the domain (cannot move).

DeclarationView source
clampGanttRangets
declare function clampGanttRange(start: number, end: number, columnCount: number): {
readonly start: number;
readonly end: number;
} | null;
Name
Kind
Type
Requirement
start
parameter
number
required
end
parameter
number
required
columnCount
parameter
number
required
return
return value
{ readonly start: number; readonly end: number; } | null
n/a
Name
start
Kind
parameter
Type
number
Requirement
required
Name
end
Kind
parameter
Type
number
Requirement
required
Name
columnCount
Kind
parameter
Type
number
Requirement
required
Name
return
Kind
return value
Type
{ readonly start: number; readonly end: number; } | null
Requirement
n/a

columnCountOf

function
DeclarationView source
columnCountOfts
declare function columnCountOf(input: GanttInput): number;
Name
Kind
Type
Requirement
input
parameter
GanttInput
required
return
return value
number
n/a
Name
input
Kind
parameter
Type
GanttInput
Requirement
required
Name
return
Kind
return value
Type
number
Requirement
n/a
DeclarationView source
GANTT_DEFAULT_COLUMN_COUNTts
export declare const GANTT_DEFAULT_COLUMN_COUNT: 4;
DeclarationView source
GANTT_DEFAULT_STEPts
export declare const GANTT_DEFAULT_STEP: 1;
DeclarationView source
GanttBarRangets
type GanttBarRange = {
readonly id: string;
readonly start: number;
readonly end: number;
};
Name
Kind
Type
Requirement
end
property
number
required
id
property
string
required
start
property
number
required
Name
end
Kind
property
Type
number
Requirement
required
Name
id
Kind
property
Type
string
Requirement
required
Name
start
Kind
property
Type
number
Requirement
required
DeclarationView source
GanttChangeReasonts
type GanttChangeReason = "pointer" | "keyboard";
DeclarationView source
GanttCommandts
type GanttCommand = CommandObject & {
readonly type: "BAR_RANGE_CHANGE_REQUEST";
readonly id: string;
readonly start: number;
readonly end: number;
readonly reason: GanttChangeReason;
};
Name
Kind
Type
Requirement
end
property
number
required
id
property
string
required
reason
property
GanttChangeReason
required
start
property
number
required
type
property
string
required
Name
end
Kind
property
Type
number
Requirement
required
Name
id
Kind
property
Type
string
Requirement
required
Name
reason
Kind
property
Type
GanttChangeReason
Requirement
required
Name
start
Kind
property
Type
number
Requirement
required
Name
type
Kind
property
Type
string
Requirement
required
DeclarationView source
GanttContextts
type GanttContext = {
readonly focusedId: string | null;
readonly activeId: string | null;
readonly originStart: number | null;
readonly originEnd: number | null;
readonly draftStart: number | null;
readonly draftEnd: number | null;
readonly reason: GanttChangeReason | null;
};
Name
Kind
Type
Requirement
activeId
property
string | null
required
draftEnd
property
number | null
required
draftStart
property
number | null
required
focusedId
property
string | null
required
originEnd
property
number | null
required
originStart
property
number | null
required
reason
property
GanttChangeReason | null
required
Name
activeId
Kind
property
Type
string | null
Requirement
required
Name
draftEnd
Kind
property
Type
number | null
Requirement
required
Name
draftStart
Kind
property
Type
number | null
Requirement
required
Name
focusedId
Kind
property
Type
string | null
Requirement
required
Name
originEnd
Kind
property
Type
number | null
Requirement
required
Name
originStart
Kind
property
Type
number | null
Requirement
required
Name
reason
Kind
property
Type
GanttChangeReason | null
Requirement
required
DeclarationView source
GanttDiagnosticCodests
export declare const GanttDiagnosticCodes: readonly DiagnosticCatalogueEntry[];

GanttEvent

type
DeclarationView source
GanttEventts
type GanttEvent = {
readonly type: "FOCUS";
readonly id: string;
} | {
readonly type: "BLUR";
readonly id: string;
} | {
readonly type: "GRAB";
readonly id: string;
readonly start: number;
readonly end: number;
readonly reason: GanttChangeReason;
} | {
readonly type: "NUDGE";
readonly direction: -1 | 1;
} | {
readonly type: "DRAG";
readonly start: number;
readonly end: number;
} | {
readonly type: "DROP";
} | {
readonly type: "CANCEL";
};

GanttInput

type
DeclarationView source
GanttInputts
type GanttInput = {
/** Host-owned ranges. The machine never writes these back. */
readonly bars?: readonly GanttBarRange[];
/** Axis unit count. @default 4 */
readonly columnCount?: number;
/** Positive finite axis unit. @default 1 */
readonly step?: number;
/**
* When false, the shell is inert (live default). Styled callers without
* `getRowId` and a range callback pass false.
*/
readonly interactive?: boolean;
};
Name
Kind
Type
Requirement
Description
bars
property
readonly GanttBarRange[]
optional
Host-owned ranges. The machine never writes these back.
columnCount
property
number
optional
Axis unit count.
interactive
property
boolean
optional
When false, the shell is inert (live default). Styled callers without `getRowId` and a range callback pass false.
step
property
number
optional
Positive finite axis unit.
Name
bars
Kind
property
Type
readonly GanttBarRange[]
Requirement
optional
Description
Host-owned ranges. The machine never writes these back.
Name
columnCount
Kind
property
Type
number
Requirement
optional
Description
Axis unit count.
Name
interactive
Kind
property
Type
boolean
Requirement
optional
Description
When false, the shell is inert (live default). Styled callers without `getRowId` and a range callback pass false.
Name
step
Kind
property
Type
number
Requirement
optional
Description
Positive finite axis unit.

ganttMachine

value
DeclarationView source
ganttMachinets
export declare const ganttMachine: GanttMachine;
DeclarationView source
GanttMachinets
type GanttMachine = Machine<GanttInput, GanttStateValue, GanttContext, GanttEvent, GanttCommand>;
DeclarationView source
ganttReplaySequencets
export declare const ganttReplaySequence: readonly GanttEvent[];
DeclarationView source
ganttSelectorsts
export declare const ganttSelectors: {
value: (snapshot: GanttSnapshot) => GanttStateValue;
focusedId: (snapshot: GanttSnapshot) => string | null;
activeId: (snapshot: GanttSnapshot) => string | null;
draftStart: (snapshot: GanttSnapshot) => number | null;
draftEnd: (snapshot: GanttSnapshot) => number | null;
};
Name
Kind
Type
Requirement
activeId
property
(snapshot: GanttSnapshot) => string | null
required
draftEnd
property
(snapshot: GanttSnapshot) => number | null
required
draftStart
property
(snapshot: GanttSnapshot) => number | null
required
focusedId
property
(snapshot: GanttSnapshot) => string | null
required
value
property
(snapshot: GanttSnapshot) => GanttStateValue
required
Name
activeId
Kind
property
Type
(snapshot: GanttSnapshot) => string | null
Requirement
required
Name
draftEnd
Kind
property
Type
(snapshot: GanttSnapshot) => number | null
Requirement
required
Name
draftStart
Kind
property
Type
(snapshot: GanttSnapshot) => number | null
Requirement
required
Name
focusedId
Kind
property
Type
(snapshot: GanttSnapshot) => string | null
Requirement
required
Name
value
Kind
property
Type
(snapshot: GanttSnapshot) => GanttStateValue
Requirement
required
DeclarationView source
GanttSnapshotts
type GanttSnapshot = Snapshot<GanttStateValue, GanttContext>;
DeclarationView source
GanttStateValuets
type GanttStateValue = "idle" | "grabbed" | "dragging";
DeclarationView source
isGanttIdInteractivets
declare function isGanttIdInteractive(input: GanttInput, id: string): boolean;
Name
Kind
Type
Requirement
input
parameter
GanttInput
required
id
parameter
string
required
return
return value
boolean
n/a
Name
input
Kind
parameter
Type
GanttInput
Requirement
required
Name
id
Kind
parameter
Type
string
Requirement
required
Name
return
Kind
return value
Type
boolean
Requirement
n/a
DeclarationView source
isGanttInteractivets
declare function isGanttInteractive(input: GanttInput): boolean;
Name
Kind
Type
Requirement
input
parameter
GanttInput
required
return
return value
boolean
n/a
Name
input
Kind
parameter
Type
GanttInput
Requirement
required
Name
return
Kind
return value
Type
boolean
Requirement
n/a

isGanttStepValid

function
DeclarationView source
isGanttStepValidts
declare function isGanttStepValid(step: number | undefined): boolean;
Name
Kind
Type
Requirement
step
parameter
number | undefined
required
return
return value
boolean
n/a
Name
step
Kind
parameter
Type
number | undefined
Requirement
required
Name
return
Kind
return value
Type
boolean
Requirement
n/a

projectGanttBars

function
DeclarationView source
projectGanttBarsts
declare function projectGanttBars<T extends {
readonly start: number;
readonly end: number;
}>(rows: readonly T[], getRowId?: (row: T, index: number) => string): GanttBarRange[];
Name
Kind
Type
Requirement
rows
parameter
readonly T[]
required
getRowId
parameter
(row: T, index: number) => string
optional
return
return value
GanttBarRange[]
n/a
Name
rows
Kind
parameter
Type
readonly T[]
Requirement
required
Name
getRowId
Kind
parameter
Type
(row: T, index: number) => string
Requirement
optional
Name
return
Kind
return value
Type
GanttBarRange[]
Requirement
n/a

roundGanttUnit

function
DeclarationView source
roundGanttUnitts
declare function roundGanttUnit(value: number): number;
Name
Kind
Type
Requirement
value
parameter
number
required
return
return value
number
n/a
Name
value
Kind
parameter
Type
number
Requirement
required
Name
return
Kind
return value
Type
number
Requirement
n/a

stepOf

function
DeclarationView source
stepOfts
declare function stepOf(input: GanttInput): number;
Name
Kind
Type
Requirement
input
parameter
GanttInput
required
return
return value
number
n/a
Name
input
Kind
parameter
Type
GanttInput
Requirement
required
Name
return
Kind
return value
Type
number
Requirement
n/a