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

11 exports
View source packages/ui-machines/src/attachment/index.ts

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();

Exports

DeclarationView source
AttachmentCommandts
type AttachmentCommand = CommandObject & ({
readonly type: "UPLOAD_REQUEST";
readonly id?: string;
} | {
readonly type: "ABORT_REQUEST";
readonly id?: string;
});
DeclarationView source
AttachmentContextts
type AttachmentContext = {
readonly id?: string;
readonly progress: number;
readonly error?: unknown;
};
Name
Kind
Type
Requirement
error
property
unknown
optional
id
property
string
optional
progress
property
number
required
Name
error
Kind
property
Type
unknown
Requirement
optional
Name
id
Kind
property
Type
string
Requirement
optional
Name
progress
Kind
property
Type
number
Requirement
required
DeclarationView source
AttachmentDiagnosticCodests
export declare const AttachmentDiagnosticCodes: readonly DiagnosticCatalogueEntry[];
DeclarationView source
AttachmentEventts
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";
};
DeclarationView source
AttachmentInputts
type AttachmentInput = {
readonly id?: string;
readonly status?: AttachmentStateValue;
readonly defaultStatus?: AttachmentStateValue;
readonly progress?: number;
readonly error?: unknown;
};
Name
Kind
Type
Requirement
defaultStatus
property
AttachmentStateValue
optional
error
property
unknown
optional
id
property
string
optional
progress
property
number
optional
status
property
AttachmentStateValue
optional
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
DeclarationView source
attachmentMachinets
export declare const attachmentMachine: AttachmentMachine;
DeclarationView source
AttachmentMachinets
type AttachmentMachine = Machine<AttachmentInput, AttachmentStateValue, AttachmentContext, AttachmentEvent, AttachmentCommand>;
DeclarationView source
attachmentReplaySequencets
export declare const attachmentReplaySequence: readonly AttachmentEvent[];
DeclarationView source
attachmentSelectorsts
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
canRetry
property
(snapshot: AttachmentSnapshot) => boolean
required
error
property
(snapshot: AttachmentSnapshot) => unknown
required
isFailed
property
(snapshot: AttachmentSnapshot) => boolean
required
isReady
property
(snapshot: AttachmentSnapshot) => boolean
required
isUploading
property
(snapshot: AttachmentSnapshot) => boolean
required
progress
property
(snapshot: AttachmentSnapshot) => number
required
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
DeclarationView source
AttachmentSnapshotts
type AttachmentSnapshot = Snapshot<AttachmentStateValue, AttachmentContext>;
DeclarationView source
AttachmentStateValuets
type AttachmentStateValue = "queued" | "uploading" | "ready" | "failed";