// axi0 Motion 0.2.0: Code input. A one-time code field drawn as slots: digits spring into place as you type or paste, and the slots flash when the code is complete.
// Generated from src/code-input/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 CodeInputProps extends HTMLAttributes<HTMLElement> {
  /** how many characters (the input's maxlength wins) (default 6) */
  slots?: number;
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function CodeInput({ as = "div", slots, ...rest }: CodeInputProps) {
  return createElement(as, { ...rest, "data-motion": "code-input", "data-motion-slots": s(slots) });
}

export default CodeInput;
