import * as React from "react"; import type { AriaSelectProps } from "@react-types/select"; import { useSelectState } from "react-stately"; import { useSelect, HiddenSelect, useButton, mergeProps, useFocusRing, } from "react-aria"; import ChevronDown from "@spectrum-icons/workflow/ChevronDown"; import { ListBox } from "./ListBox"; import { Popover } from "./Popover"; export { Item } from "react-stately"; export function Select(props: AriaSelectProps) { // Create state based on the incoming props let state = useSelectState(props); // Get props for child elements from useSelect let ref = React.useRef(null); let { labelProps, triggerProps, valueProps, menuProps } = useSelect( props, state, ref ); // Get props for the button based on the trigger props from useSelect let { buttonProps } = useButton(triggerProps, ref); let { focusProps, isFocusVisible } = useFocusRing(); return (
{props.label}
{state.isOpen && ( )}
); }