API
const {
options,
activeValueIndex,
activeOptionIndex,
getDeleteButtonProps,
getInputProps,
getPopoverButtonProps,
getPopoverProps,
getOptionProps,
getWrapperProps,
} = useMultiComplete<TValue, TInputElement>({
values,
options,
onChange,
id,
isEqual,
queryOptionFilter,
filterValues,
isOpen,
onOpenChange,
})Options
type UseMultiCompleteOptions<TValue> = {
values: TValue[]
options: TValue[]
onChange: (values: TValue[]) => void
id: string
isEqual?: (a: TValue, b: TValue) => boolean
queryOptionFilter?: (option: TValue, query: string) => boolean
filterValues?: boolean
isOpen?: boolean
onOpenChange?: (value: boolean) => void
}values- The values that are currently selectedoptions- The options that can be selectedonChange- A callback that is called when the values changeid- The id of the componentisEqual- A function that is used to determine if two values are equal. Defaults to===queryOptionFilter- A function that is used to filter the options based on the query. Defaults to a case-insensitive string matchfilterValues- If true, the values will be filtered out of the options. Defaults totrueisOpen- If true, the popover will be open. Defaults tofalseonOpenChange- A callback that is called when the popover is opened or closed
Return Values
type ReturnValues<TValue> = {
options: TValue[],
activeValueIndex: number,
activeOptionIndex: number,
getDeleteButtonProps: (option: TValue) => React.HTMLProps<any>,
getInputProps: () => React.HTMLProps<any>,
getPopoverButtonProps: () => React.HTMLProps<any>,
getPopoverProps: () => React.HTMLProps<any>,
getOptionProps: (option: TValue, index: number) => React.HTMLProps<any>,
getWrapperProps: () => React.HTMLProps<any>,
}options- The options that can be selectedactiveValueIndex- The index of the currently active value.-1if none are activeactiveOptionIndex- The index of the currently active option.-1if none are activegetDeleteButtonProps- Property bag for a values delete buttongetInputProps- Property bag for the inputgetPopoverButtonProps- Property bag for the popover buttongetPopoverProps- Property bag for the popovergetOptionProps- Property bag for an optiongetWrapperProps- Property bag for the wrapper