// axi0 Motion 0.2.0: Snap reticle. A reticle follows the pointer, spinning gently, and its corner brackets snap around buttons and links, matching their size and corners.
// Generated from src/snap-reticle/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 SnapReticleProps extends HTMLAttributes<HTMLElement> {
  /** What the brackets snap to (a CSS selector) (default "a, button, [data-reticle]") */
  targets?: string;
  /** Bracket color (empty: the text color) (default auto) */
  color?: string;
  /** Half the reticle's size while it is free (default 12) */
  size?: number;
  /** How fast the free reticle turns (0 stops it) (default 1) */
  spin?: number;
  /** Space between a target and the brackets (default 6) */
  pad?: number;
  /** Show the target's name above it (its data-reticle, aria-label or text) (default true) */
  label?: boolean;
  /** Keep the system cursor or hide it inside the area (default "keep") */
  cursor?: "keep" | "hide";
  /** The element to render (default "div") */
  as?: string;
  children?: ReactNode;
}

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

export function SnapReticle({ as = "div", targets, color, size, spin, pad, label, cursor, ...rest }: SnapReticleProps) {
  return createElement(as, { ...rest, "data-motion": "snap-reticle", "data-motion-targets": s(targets), "data-motion-color": s(color), "data-motion-size": s(size), "data-motion-spin": s(spin), "data-motion-pad": s(pad), "data-motion-label": s(label), "data-motion-cursor": s(cursor) });
}

export default SnapReticle;
