// axi0 Motion 0.2.0: Slide confirm. A slide-to-confirm handle: drag it to the end, it spins while the action runs and unfurls into a done pill; Enter or Space confirms from the keyboard.
// Generated from src/slide-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 SlideConfirmProps extends HTMLAttributes<HTMLElement> {
  /** the label once the action finished (default "Done") */
  done?: string;
  /** how long the spinner shows when nobody answers the confirm event (default 1400) */
  wait?: number;
  /** when the done pill turns back into the slider; 0 keeps it (default 4000) */
  reset?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function SlideConfirm({ as = "div", done, wait, reset, ...rest }: SlideConfirmProps) {
  return createElement(as, { ...rest, "data-motion": "slide-confirm", "data-motion-done": s(done), "data-motion-wait": s(wait), "data-motion-reset": s(reset) });
}

export default SlideConfirm;
