import type { JSX } from "solid-js";
import { useInternalSelectContext } from "./select-context";

/** Hidden native input for form submission. */
export function SelectHiddenSelect(): JSX.Element {
  const ctx = useInternalSelectContext();

  return (
    <input
      type="hidden"
      name={ctx.name() ?? ""}
      value={ctx.selectedValue() ?? ""}
      aria-hidden="true"
      tabIndex={-1}
    />
  );
}
