import { type ReactNode, useRef } from "react"; import type { View as RNView } from "react-native"; import { AccentScope } from "../containers/AccentScope"; import { Popover } from "../containers/Popover"; import { View } from "../primitives/View"; import { InputText } from "./InputText"; import { AutocompleteMenu, type InputTextAutocompleteProps, defaultFilterOption, useAutocomplete, } from "./InputTextAutocomplete.shared"; export function InputTextAutocomplete({ filterOption = defaultFilterOption, emptyLabel = "No result", placeholder, disabled, invalid, accent, mode, className, testID, "aria-describedby": ariaDescribedby, "aria-required": ariaRequired, ...rest }: InputTextAutocompleteProps): ReactNode { const anchorRef = useRef(null); const { isOpen, inputProps, closeMenu, ...menu } = useAutocomplete({ ...rest, disabled, filterOption, scrollIntoView: true, inputInPopover: false, }); const { ref: inputRef, onKeyDown, onClick, ...restInputProps } = inputProps; return ( <> {/* The anchor has to be a real box (its rect positions the popover), so it — not the input — takes `className`: it is the element the parent lays out, and native has no wrapper at all. The input then stretches to it. */} ); }