DocsAPI referenceUI machinesrating

rating machine

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

@grassroot/ui-machines/rating

Package

10 exports
View source packages/ui-machines/src/rating/index.ts

Service example

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

Exports

DeclarationView source
RatingCommandts
type RatingCommand = CommandObject & {
readonly type: "VALUE_CHANGE_REQUEST";
readonly value: number;
readonly reason: RatingReason;
};
Name
Kind
Type
Requirement
reason
property
RatingReason
required
type
property
string
required
value
property
number
required
Name
reason
Kind
property
Type
RatingReason
Requirement
required
Name
type
Kind
property
Type
string
Requirement
required
Name
value
Kind
property
Type
number
Requirement
required
DeclarationView source
RatingContextts
type RatingContext = {
readonly value: number;
readonly mode: BindingMode;
};
Name
Kind
Type
Requirement
mode
property
BindingMode
required
value
property
number
required
Name
mode
Kind
property
Type
BindingMode
Requirement
required
Name
value
Kind
property
Type
number
Requirement
required
DeclarationView source
RatingDiagnosticCodests
export declare const RatingDiagnosticCodes: readonly DiagnosticCatalogueEntry[];
DeclarationView source
RatingEventts
type RatingEvent = {
readonly type: "SET";
readonly value: number;
readonly reason: RatingReason;
} | {
readonly type: "RESET";
};
DeclarationView source
RatingInputts
type RatingInput = {
readonly max?: number;
readonly value?: number;
readonly defaultValue?: number;
readonly readOnly?: boolean;
};
Name
Kind
Type
Requirement
defaultValue
property
number
optional
max
property
number
optional
readOnly
property
boolean
optional
value
property
number
optional
Name
defaultValue
Kind
property
Type
number
Requirement
optional
Name
max
Kind
property
Type
number
Requirement
optional
Name
readOnly
Kind
property
Type
boolean
Requirement
optional
Name
value
Kind
property
Type
number
Requirement
optional
DeclarationView source
ratingMachinets
export declare const ratingMachine: Machine<RatingInput, "ready", RatingContext, RatingEvent, RatingCommand>;
DeclarationView source
RatingReasonts
type RatingReason = "pointer" | "keyboard" | "programmatic";
DeclarationView source
ratingReplaySequencets
export declare const ratingReplaySequence: readonly RatingEvent[];
DeclarationView source
ratingSelectorsts
export declare const ratingSelectors: {
value: (snapshot: RatingSnapshot) => number;
};
Name
Kind
Type
Requirement
value
property
(snapshot: RatingSnapshot) => number
required
Name
value
Kind
property
Type
(snapshot: RatingSnapshot) => number
Requirement
required
DeclarationView source
RatingSnapshotts
type RatingSnapshot = Snapshot<"ready", RatingContext>;