// axi0 Motion 0.2.0: Scrub number. A number field becomes a chip you drag sideways to change, with rubber-band ends and a fill for where the value sits; click it to type.
// Generated from src/scrub-number/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 ScrubNumberProps extends HTMLAttributes<HTMLElement> {
  /** Label in the chip (empty uses the field's aria-label) (default auto) */
  label?: string;
  /** Unit after the value (default auto) */
  unit?: string;
  /** Steps per 10 pixels of drag (default 2.5) */
  speed?: number;
  /** Fill and focus color (default "#f6a04d") */
  color?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function ScrubNumber({ as = "div", label, unit, speed, color, ...rest }: ScrubNumberProps) {
  return createElement(as, { ...rest, "data-motion": "scrub-number", "data-motion-label": s(label), "data-motion-unit": s(unit), "data-motion-speed": s(speed), "data-motion-color": s(color) });
}

export default ScrubNumber;
