// axi0 Motion 0.2.0: Segmented. A segmented control whose thumb stretches across the gap as it travels and squashes into place.
// Generated from src/segmented/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 SegmentedProps extends HTMLAttributes<HTMLElement> {
  /** how much the thumb stretches on its way (0: none) (default 1) */
  stretch?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function Segmented({ as = "div", stretch, ...rest }: SegmentedProps) {
  return createElement(as, { ...rest, "data-motion": "segmented", "data-motion-stretch": s(stretch) });
}

export default Segmented;
