// axi0 Motion 0.2.0: Carousel. Slides that share one frame and change by slide, fade, scale, flip, stack or depth, with swipes, dots and an autoplay timer that waits while you read.
// Generated from src/carousel/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 CarouselProps extends HTMLAttributes<HTMLElement> {
  /** how one slide gives way to the next (default "slide") */
  transition?: "slide" | "fade" | "scale" | "flip" | "stack" | "depth";
  /** time on each slide; 0 turns the timer off (default 5000) */
  autoplay?: number;
  /** go round from the last slide to the first (default true) */
  loop?: boolean;
  /** the name read out when the element has no aria-label (default "Carousel") */
  label?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function Carousel({ as = "div", transition, autoplay, loop, label, ...rest }: CarouselProps) {
  return createElement(as, { ...rest, "data-motion": "carousel", "data-motion-transition": s(transition), "data-motion-autoplay": s(autoplay), "data-motion-loop": s(loop), "data-motion-label": s(label) });
}

export default Carousel;
