// axi0 Motion 0.2.0: Stretch switch. A switch whose thumb stretches with its speed and squashes against the end it hits; flick it, drag it or press Space.
// Generated from src/stretch-switch/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 StretchSwitchProps extends HTMLAttributes<HTMLElement> {
  /** how much the thumb stretches and squashes (0: none) (default 1) */
  stretch?: number;
  /** the track's color when on (empty: the accent) (default auto) */
  color?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function StretchSwitch({ as = "div", stretch, color, ...rest }: StretchSwitchProps) {
  return createElement(as, { ...rest, "data-motion": "stretch-switch", "data-motion-stretch": s(stretch), "data-motion-color": s(color) });
}

export default StretchSwitch;
