Skip to content
API reference

components/undo-action

Import
import * as api from "@fungi.computer/caps/components/undo-action";
Kind Export Description
type alias FuseProps Props accepted by Fuse.
type alias UndoActionProps Props accepted by UndoAction.
constant UndoAction A destructive action that waits for its undo window instead of asking first. Pressing it turns the same button into Undo with a fuse burning along its edge; Undo or Escape cancels, and the action commits when the fuse runs out. Resting the pointer on it holds the fuse.
function Fuse() A hairline that burns down over its duration, then calls onBurnt. Its thickness is the theme’s --stipe-motion-fuse (0 hides it but the window still runs). Under reduced motion it ticks down once a second instead of burning smoothly.

FusePropstype alias

Section titled “FuseProps”
Signature
type FuseProps = object;

Props accepted by Fuse.

Signature
duration: number;

How long the fuse burns, in milliseconds: a decision window, not motion.

Signature
optional paused?: boolean;

Hold the burn, for example while the pointer rests on the action.

Signature
onBurnt: () => void;

Called once when the fuse has burnt down.

void

Signature
optional className?: string;

UndoActionPropstype alias

Section titled “UndoActionProps”
Signature
type UndoActionProps = object &
Omit<ButtonProps, "children" | "onClick" | "result" | "resultLabel">;

Props accepted by UndoAction.

Name Type Description
children ReactNode The action’s label, such as “Stop”.
onCommit() () => void Runs when the undo window closes without an undo: the action happens then.
armedAnnouncement string Spoken when the action is armed, such as “Port 5173 stops in 5 seconds”.
undoneAnnouncement string Spoken after an undo, such as “Port 5173 kept open”.
undoLabel? ReactNode -
undoMs? number The undo window in milliseconds.

UndoActionconstant

Section titled “UndoAction”
Signature
const UndoAction: ForwardRefExoticComponent<
object &
Omit<ButtonProps, "children" | "onClick" | "result" | "resultLabel"> &
RefAttributes<HTMLButtonElement>
>;

A destructive action that waits for its undo window instead of asking first. Pressing it turns the same button into Undo with a fuse burning along its edge; Undo or Escape cancels, and the action commits when the fuse runs out. Resting the pointer on it holds the fuse.

Signature
function Fuse(__namedParameters): Element;

A hairline that burns down over its duration, then calls onBurnt. Its thickness is the theme’s --stipe-motion-fuse (0 hides it but the window still runs). Under reduced motion it ticks down once a second instead of burning smoothly.

Parameter Type
__namedParameters FuseProps

Element