// axi0 Motion 0.2.0: Word cycle. A word cycles through a list, letter by letter, on a colored pill that fits each word.
// Generated from src/word-cycle/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 WordCycleProps extends HTMLAttributes<HTMLElement> {
  /** The other words, separated by | (default auto) */
  words?: string;
  /** Time per word (default 2200) */
  interval?: number;
  /** Delay between letters (default 22) */
  stagger?: number;
  /** Letters arrive (default "below") */
  from?: "below" | "above" | "flip";
  /** Word inside its slot (default "start") */
  align?: "start" | "center" | "end";
  /** Colored pill (default true) */
  pill?: boolean;
  /** Pill color (default "#f6a04d") */
  color?: string;
  /** Text color on the pill (default "#111111") */
  ink?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function WordCycle({ as = "div", words, interval, stagger, from, align, pill, color, ink, ...rest }: WordCycleProps) {
  return createElement(as, { ...rest, "data-motion": "word-cycle", "data-motion-words": s(words), "data-motion-interval": s(interval), "data-motion-stagger": s(stagger), "data-motion-from": s(from), "data-motion-align": s(align), "data-motion-pill": s(pill), "data-motion-color": s(color), "data-motion-ink": s(ink) });
}

export default WordCycle;
