Appearance
API Reference ​
Detailed API specification for @continuejs/core and @continuejs/ui.
@continuejs/core ​
createDraft(options) ​
Factory function to create a new Draft instance.
Parameters ​
typescript
interface DraftOptions {
id: string; // Unique draft identifier (Required)
retention?: '1h' | '1d' | '7d' | '30d' | 'forever'; // Default: '7d'
storage?: 'indexeddb' | 'session' | 'memory'; // Default: 'indexeddb'
autosave?: boolean; // Enable/disable autosave (Default: true)
debounceMs?: number; // Save debounce in ms (Default: 500)
encryption?: EncryptionConfig; // Optional Web Crypto AES-GCM settings
}Return Value ​
Returns a Draft instance.
attach(config) ​
Attaches a draft directly to an HTML form element or custom object.
Parameters ​
typescript
interface AttachOptions {
target: HTMLFormElement | object;
id: string;
options?: {
retention?: RetentionString;
storage?: StorageType;
debounceMs?: number;
excludeFields?: string[]; // Field names to ignore
includeFileMetadata?: boolean; // Save file names and size (Default: true)
encryption?: EncryptionConfig;
};
serialize?: () => any; // Custom serializer for non-form objects
deserialize?: (data: any) => void;// Custom deserializer
}Return Value ​
typescript
interface DetachmentHandle {
detach: () => void; // Disconnects event listeners and observers
draft: Draft; // The underlying Draft instance
}Draft Class Methods ​
set(key: string, value: any): this ​
Sets a key-value pair in the draft memory state.
setMultiple(fields: Record<string, any>): this ​
Merges an object of key-value pairs into the draft state.
get(key: string): any ​
Retrieves a value by key from the draft state.
getAll(): Record<string, any> ​
Returns a shallow copy of all draft data.
save(): Promise<void> ​
Persists current draft data to the configured storage engine.
restore(): Promise<Record<string, any> | null> ​
Loads the saved draft from storage, decrypts if necessary, populates local memory state, and dispatches the restore event.
delete(): Promise<void> ​
Purges the draft from local storage and resets internal state.
hasDraft(): Promise<boolean> ​
Returns true if a non-expired draft exists in storage.
lastSaved(): Promise<number | null> ​
Returns the UNIX timestamp (in milliseconds) of when the draft was last saved, or null.
getProgress(formElement?: HTMLFormElement, excludeFields?: string[]): number ​
Calculates completion progress as a float between 0.0 (0%) and 1.0 (100%).
@continuejs/ui Web Components ​
<continuejs-banner> ​
Framework-agnostic top/bottom notification banner.
Attributes ​
message: Custom notice message text.last-saved: UNIX timestamp string.restore-text: Label for restore button (Default:"Restore Progress").discard-text: Label for discard button (Default:"Discard").
Custom Events ​
continuejs-restore: Fired when the user clicks the restore button.continuejs-discard: Fired when the user clicks the discard button.
<continuejs-modal> ​
Framework-agnostic modal dialog.
Attributes ​
open: Present when the modal is visible.title: Modal heading.description: Modal text description.last-saved: UNIX timestamp string.
Custom Events ​
continuejs-restore: Fired on restore click.continuejs-discard: Fired on discard click.continuejs-close: Fired when the modal is closed or dismissed.
