|
|
@ -13,15 +13,10 @@ import { Spinner } from '../Spinner/Spinner'; |
|
|
|
import { Text } from '../Text/Text'; |
|
|
|
import { Text } from '../Text/Text'; |
|
|
|
import { Tooltip } from '../Tooltip'; |
|
|
|
import { Tooltip } from '../Tooltip'; |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
import { ComboboxOption, ComboboxBaseProps, AutoSizeConditionals, VIRTUAL_OVERSCAN_ITEMS } from './Combobox'; |
|
|
|
ComboboxOption, |
|
|
|
|
|
|
|
ComboboxBaseProps, |
|
|
|
|
|
|
|
AutoSizeConditionals, |
|
|
|
|
|
|
|
itemToString, |
|
|
|
|
|
|
|
VIRTUAL_OVERSCAN_ITEMS, |
|
|
|
|
|
|
|
} from './Combobox'; |
|
|
|
|
|
|
|
import { OptionListItem } from './OptionListItem'; |
|
|
|
import { OptionListItem } from './OptionListItem'; |
|
|
|
import { ValuePill } from './ValuePill'; |
|
|
|
import { ValuePill } from './ValuePill'; |
|
|
|
|
|
|
|
import { itemFilter, itemToString } from './filter'; |
|
|
|
import { getComboboxStyles, MENU_OPTION_HEIGHT, MENU_OPTION_HEIGHT_DESCRIPTION } from './getComboboxStyles'; |
|
|
|
import { getComboboxStyles, MENU_OPTION_HEIGHT, MENU_OPTION_HEIGHT_DESCRIPTION } from './getComboboxStyles'; |
|
|
|
import { getMultiComboboxStyles } from './getMultiComboboxStyles'; |
|
|
|
import { getMultiComboboxStyles } from './getMultiComboboxStyles'; |
|
|
|
import { useComboboxFloat } from './useComboboxFloat'; |
|
|
|
import { useComboboxFloat } from './useComboboxFloat'; |
|
|
@ -48,8 +43,11 @@ export const MultiCombobox = <T extends string | number>(props: MultiComboboxPro |
|
|
|
}, [value, options, isAsync]); |
|
|
|
}, [value, options, isAsync]); |
|
|
|
|
|
|
|
|
|
|
|
const styles = useStyles2(getComboboxStyles); |
|
|
|
const styles = useStyles2(getComboboxStyles); |
|
|
|
|
|
|
|
const [inputValue, setInputValue] = useState(''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [baseItems, baseSetItems] = useState(isAsync ? [] : options); |
|
|
|
|
|
|
|
|
|
|
|
const [items, baseSetItems] = useState(isAsync ? [] : options); |
|
|
|
const items = useMemo(() => baseItems.filter(itemFilter(inputValue)), [baseItems, inputValue]); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Improve this with async
|
|
|
|
// TODO: Improve this with async
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
@ -73,8 +71,6 @@ export const MultiCombobox = <T extends string | number>(props: MultiComboboxPro |
|
|
|
[selectedItems] |
|
|
|
[selectedItems] |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const [inputValue, setInputValue] = useState(''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { getSelectedItemProps, getDropdownProps, removeSelectedItem } = useMultipleSelection({ |
|
|
|
const { getSelectedItemProps, getDropdownProps, removeSelectedItem } = useMultipleSelection({ |
|
|
|
selectedItems, //initally selected items,
|
|
|
|
selectedItems, //initally selected items,
|
|
|
|
onStateChange: ({ type, selectedItems: newSelectedItems }) => { |
|
|
|
onStateChange: ({ type, selectedItems: newSelectedItems }) => { |
|
|
@ -120,7 +116,6 @@ export const MultiCombobox = <T extends string | number>(props: MultiComboboxPro |
|
|
|
case useCombobox.stateChangeTypes.InputBlur: |
|
|
|
case useCombobox.stateChangeTypes.InputBlur: |
|
|
|
setInputValue(''); |
|
|
|
setInputValue(''); |
|
|
|
setIsOpen(false); |
|
|
|
setIsOpen(false); |
|
|
|
return changes; |
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
return changes; |
|
|
|
return changes; |
|
|
|
} |
|
|
|
} |
|
|
|