// axi0 Motion 0.2.0: Hold confirm. A button you press and hold to confirm: a fill sweeps across while you hold, drains back if you let go early and fires the action when it is full.
// Generated from src/hold-confirm/meta.json by motion-pack: a thin wrapper. The loader (motion.js) must be on the page once;
// it starts the effect on the element this renders. Options left out keep the effect's own defaults.
import { createElement } from "react";
import type { HTMLAttributes, ReactNode } from "react";

export interface HoldConfirmProps extends HTMLAttributes<HTMLElement> {
  /** how long to hold (default 1200) */
  hold?: number;
  /** the label once confirmed (default "Deleted") */
  done?: string;
  /** the fill (default "#d63c41") */
  color?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

const s = (v: unknown) => (v === undefined ? undefined : String(v));

export function HoldConfirm({ as = "div", hold, done, color, ...rest }: HoldConfirmProps) {
  return createElement(as, { ...rest, "data-motion": "hold-confirm", "data-motion-hold": s(hold), "data-motion-done": s(done), "data-motion-color": s(color) });
}

export default HoldConfirm;
