import * as React from 'react' import { Popover, PopoverAnchor, PopoverPortal, PopoverContent, PopoverClose } from '@/components/ui/popover' import { cn } from '@/lib/utils' import { useCombobox } from 'downshift' import type { UseComboboxReturnValue, UseComboboxState, UseComboboxStateChangeOptions } from 'downshift' import Textarea from 'react-textarea-autosize' import { isNil, omitBy } from 'lodash-es' interface ComboboxContextValue extends UseComboboxReturnValue { open: boolean inputRef: React.RefObject anchorRef: React.RefObject } export const ComboboxContext = React.createContext({} as ComboboxContextValue) export const ComboboxClose = PopoverClose export const ComboboxAnchor = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >((props, forwardRef) => { return }) ComboboxAnchor.displayName = 'ComboboxAnchor' export const ComboboxTextarea = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >((props, forwardRef) => { const { getInputProps, open } = React.useContext(ComboboxContext) const { onKeyDown, onChange, onInput, onBlur, onClick, ...rest } = props return (