- Name
error- Kind
- property
- Type
unknown- Requirement
- optional
DocsAPI referenceUI machinesattachment
attachment machine
The public state machine contract for @grassroot/ui-machines/attachment. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/attachment
Package
Service example
attachment.tsts
import { createService } from "@grassroot/statechart";import { attachmentMachine } from "@grassroot/ui-machines/attachment"; const service = createService(attachmentMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();11 of 11
Exports
AttachmentCommand
typeAttachmentCommandts
type AttachmentCommand = CommandObject & ({ readonly type: "UPLOAD_REQUEST"; readonly id?: string;} | { readonly type: "ABORT_REQUEST"; readonly id?: string;});AttachmentContext
typeAttachmentContextts
type AttachmentContext = { readonly id?: string; readonly progress: number; readonly error?: unknown;};Name
Kind
Type
Requirement
errorproperty
unknownoptional
idproperty
stringoptional
progressproperty
numberrequired
- Name
id- Kind
- property
- Type
string- Requirement
- optional
- Name
progress- Kind
- property
- Type
number- Requirement
- required
AttachmentDiagnosticCodests
export declare const AttachmentDiagnosticCodes: readonly DiagnosticCatalogueEntry[];AttachmentEvent
typeAttachmentEventts
type AttachmentEvent = { readonly type: "START_UPLOAD";} | { readonly type: "UPLOAD_START";} | { readonly type: "PROGRESS"; readonly progress: number;} | { readonly type: "UPLOAD_SUCCEEDED";} | { readonly type: "UPLOAD_FAILED"; readonly error?: unknown;} | { readonly type: "RETRY";} | { readonly type: "ABORT";} | { readonly type: "RESET";};AttachmentInput
typeAttachmentInputts
type AttachmentInput = { readonly id?: string; readonly status?: AttachmentStateValue; readonly defaultStatus?: AttachmentStateValue; readonly progress?: number; readonly error?: unknown;};Name
Kind
Type
Requirement
defaultStatusproperty
AttachmentStateValueoptional
errorproperty
unknownoptional
idproperty
stringoptional
progressproperty
numberoptional
statusproperty
AttachmentStateValueoptional
- Name
defaultStatus- Kind
- property
- Type
AttachmentStateValue- Requirement
- optional
- Name
error- Kind
- property
- Type
unknown- Requirement
- optional
- Name
id- Kind
- property
- Type
string- Requirement
- optional
- Name
progress- Kind
- property
- Type
number- Requirement
- optional
- Name
status- Kind
- property
- Type
AttachmentStateValue- Requirement
- optional
attachmentMachine
valueattachmentMachinets
export declare const attachmentMachine: AttachmentMachine;AttachmentMachine
typeAttachmentMachinets
type AttachmentMachine = Machine<AttachmentInput, AttachmentStateValue, AttachmentContext, AttachmentEvent, AttachmentCommand>;attachmentReplaySequence
valueattachmentReplaySequencets
export declare const attachmentReplaySequence: readonly AttachmentEvent[];attachmentSelectors
valueattachmentSelectorsts
export declare const attachmentSelectors: { progress: (snapshot: AttachmentSnapshot) => number; error: (snapshot: AttachmentSnapshot) => unknown; isUploading: (snapshot: AttachmentSnapshot) => boolean; isReady: (snapshot: AttachmentSnapshot) => boolean; isFailed: (snapshot: AttachmentSnapshot) => boolean; canRetry: (snapshot: AttachmentSnapshot) => boolean;};Name
Kind
Type
Requirement
canRetryproperty
(snapshot: AttachmentSnapshot) => booleanrequired
errorproperty
(snapshot: AttachmentSnapshot) => unknownrequired
isFailedproperty
(snapshot: AttachmentSnapshot) => booleanrequired
isReadyproperty
(snapshot: AttachmentSnapshot) => booleanrequired
isUploadingproperty
(snapshot: AttachmentSnapshot) => booleanrequired
progressproperty
(snapshot: AttachmentSnapshot) => numberrequired
- Name
canRetry- Kind
- property
- Type
(snapshot: AttachmentSnapshot) => boolean- Requirement
- required
- Name
error- Kind
- property
- Type
(snapshot: AttachmentSnapshot) => unknown- Requirement
- required
- Name
isFailed- Kind
- property
- Type
(snapshot: AttachmentSnapshot) => boolean- Requirement
- required
- Name
isReady- Kind
- property
- Type
(snapshot: AttachmentSnapshot) => boolean- Requirement
- required
- Name
isUploading- Kind
- property
- Type
(snapshot: AttachmentSnapshot) => boolean- Requirement
- required
- Name
progress- Kind
- property
- Type
(snapshot: AttachmentSnapshot) => number- Requirement
- required
AttachmentSnapshot
typeAttachmentSnapshotts
type AttachmentSnapshot = Snapshot<AttachmentStateValue, AttachmentContext>;AttachmentStateValue
typeAttachmentStateValuets
type AttachmentStateValue = "queued" | "uploading" | "ready" | "failed";