import { UseSelectGetItemPropsOptions } from "downshift"; import React, { Dispatch, HTMLAttributes, MutableRefObject, RefObject, SetStateAction, } from "react"; import { List } from "../../List"; import { CreatableOption } from "./CreatableOption"; import { SelectChildrenWithDefaultStatus } from "./SelectChildrenWithDefaultStatus"; import { SelectPortal } from "./SelectPortal"; import { SelectSearch } from "./SelectSearch"; import { SelectOption } from "./types"; import { useSelectLayout } from "../hooks/useSelectLayout"; interface SelectMenuProps extends HTMLAttributes { isOpen: boolean; callbackElementProps: ReturnType< typeof useSelectLayout >["callbackElementProps"]; menuProps: ReturnType["menuProps"]; onInputChange: ((newValue: string) => void) | undefined; inputRef: RefObject; inputValue: string | undefined; setInputHasFocus: Dispatch>; popperRef: RefObject; optionIndexRef: MutableRefObject; setOptionIndex: (newIndex: number) => void; highlightedIndex: number; creatableOption: T; isCreatable: boolean; getItemProps: (options: UseSelectGetItemPropsOptions) => any; onCreateOption: () => void; isLoading: boolean | undefined; } export function SelectMenu({ isOpen, callbackElementProps, onInputChange, inputRef, inputValue, setInputHasFocus, popperRef, optionIndexRef, setOptionIndex, highlightedIndex, creatableOption, isCreatable, getItemProps, onCreateOption, isLoading, children, menuProps, }: SelectMenuProps) { return ( {isOpen && ( <> {onInputChange && ( { onInputChange(e.currentTarget.value); }} setInputHasFocus={setInputHasFocus} popperRef={popperRef} /> )} {children} )} ); }