// axi0 Motion 0.2.0: Count up. A number counts up to its value when it scrolls into view, in the page's own format.
// Generated from src/count-up/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 CountUpProps extends HTMLAttributes<HTMLElement> {
  /** the starting number (default 0) */
  from?: number;
  /** milliseconds (default 1800) */
  duration?: number;
  /** milliseconds before it starts (default 0) */
  delay?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function CountUp({ as = "div", from, duration, delay, ...rest }: CountUpProps) {
  return createElement(as, { ...rest, "data-motion": "count-up", "data-motion-from": s(from), "data-motion-duration": s(duration), "data-motion-delay": s(delay) });
}

export default CountUp;
