// axi0 Motion 0.2.0: Needle field. A field of short needles that swing toward the pointer like compass needles, ripple outward and spin on click.
// Generated from src/needle-field/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 NeedleFieldProps extends HTMLAttributes<HTMLElement> {
  /** Needle spacing in CSS pixels (default 28) */
  spacing?: number;
  /** Needle length, as a share of the spacing (default 0.95) */
  length?: number;
  /** Needle width in CSS pixels (default 3) */
  width?: number;
  /** Point at the pointer or circle it (default "point") */
  mode?: "point" | "orbit";
  /** Colors, comma separated (empty: the palette for the page's theme) (default auto) */
  colors?: string;
  /** Background color (empty: the theme's) (default auto) */
  background?: string;
  /** How fast it moves (default 1) */
  speed?: number;
  /** Light or dark palette (auto: from the page behind it) (default "auto") */
  theme?: "auto" | "light" | "dark";
  /** Fill the nearest positioned parent, behind its content (default false) */
  cover?: boolean;
  children?: ReactNode;
}

const s = (v: unknown) => (v === undefined ? undefined : String(v));
// a present attribute is on; "false" turns off an option that is on by default
const flag = (v: boolean | undefined, d: boolean) => (v === undefined || v === d ? undefined : v ? "" : "false");

export function NeedleField({ spacing, length, width, mode, colors, background, speed, theme, cover, ...rest }: NeedleFieldProps) {
  return createElement("axi0-needle-field", { ...rest, "spacing": s(spacing), "length": s(length), "width": s(width), "mode": s(mode), "colors": s(colors), "background": s(background), "speed": s(speed), "theme": s(theme), "cover": flag(cover, false) });
}

export default NeedleField;
