// axi0 Motion 0.2.0: Card deck. A 3D stack of cards set up and back from one another; on a timer, a fling or Next the front card drops away and slides in at the back.
// Generated from src/card-deck/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 CardDeckProps extends HTMLAttributes<HTMLElement> {
  /** time on each card; 0 turns the timer off (default 5000) */
  delay?: number;
  /** how far right each card behind sits (default 56) */
  dx?: number;
  /** how far up each card behind sits (default 48) */
  dy?: number;
  /** the slant of the deck (default 4) */
  skew?: number;
  /** the name read out when the element has no aria-label (default "Cards") */
  label?: string;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function CardDeck({ as = "div", delay, dx, dy, skew, label, ...rest }: CardDeckProps) {
  return createElement(as, { ...rest, "data-motion": "card-deck", "data-motion-delay": s(delay), "data-motion-dx": s(dx), "data-motion-dy": s(dy), "data-motion-skew": s(skew), "data-motion-label": s(label) });
}

export default CardDeck;
