Fuse button
An action button that becomes a timed undo surface, settling into a completed state when the fuse ends.
Implementation
1"use client";2 3import { useEffect, useRef, useState } from "react";4import { Archive, Check, Undo2 } from "lucide-react";5 6export type FuseButtonProps = {7 label?: string;8 undoLabel?: string;9 doneLabel?: string;10 undoWindow?: number;11 onCommit?: () => void;12 onUndo?: () => void;13 disabled?: boolean;14 className?: string;15};16 17type FusePhase = "idle" | "armed" | "settled";18 19/**20 * An action button that becomes an undo surface on a timed fuse. The fuse21 * pauses on hover and resumes when the pointer leaves; Escape undoes.22 */23export function FuseButton({24 label = "Archive",25 undoLabel = "Undo",26 doneLabel = "Archived",27 undoWindow = 4000,28 onCommit,