<!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->

[**@fungi.computer/caps**](../README.md)

---

[@fungi.computer/caps](../README.md) / components/undo-action

# components/undo-action

## Type Aliases

### FuseProps

```ts
type FuseProps = object;
```

Props accepted by Fuse.

#### Properties

##### duration

```ts
duration: number;
```

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

##### paused?

```ts
optional paused?: boolean;
```

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

##### onBurnt

```ts
onBurnt: () => void;
```

Called once when the fuse has burnt down.

###### Returns

`void`

##### className?

```ts
optional className?: string;
```

---

### UndoActionProps

```ts
type UndoActionProps = object &
  Omit<ButtonProps, "children" | "onClick" | "result" | "resultLabel">;
```

Props accepted by UndoAction.

#### Type Declaration

| 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.                                           |

## Variables

### UndoAction

```ts
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.

## Functions

### Fuse()

```ts
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.

#### Parameters

| Parameter           | Type                      |
| ------------------- | ------------------------- |
| `__namedParameters` | [`FuseProps`](#fuseprops) |

#### Returns

`Element`
