import { useRef } from "react";
import {
  type AriaNumberFieldProps,
  useNumberField,
} from "@react-aria/numberfield";
import { useNumberFieldState } from "@react-stately/numberfield";

export function useReactAriaNumberField(
  props: AriaNumberFieldProps & { locale: string }
) {
  const state = useNumberFieldState(props);
  const ref = useRef<HTMLInputElement>(null);

  const {
    labelProps: { color: _, ...labelProps },
    groupProps,
    inputProps,
  } = useNumberField(props, state, ref);

  return {
    state,
    ref,
    labelProps,
    groupProps,
    inputProps,
  };
}
