diff --git a/src/components/TagMultiSelect.tsx b/src/components/TagMultiSelect.tsx index 627ce4f1..64116807 100644 --- a/src/components/TagMultiSelect.tsx +++ b/src/components/TagMultiSelect.tsx @@ -21,25 +21,33 @@ export type MultiSelectTag = { const matchOptions = [ { label: 'All', value: 'AND' }, { label: 'Any', value: 'OR' }, -] +] as const -export function TagMultiSelect({ - options, - loading, - onSelectedTagsChange, - onFilterChange, -}: { +type TagMultiSelectProps = { options: string[] loading: boolean + selectedMatchType?: 'AND' | 'OR' onSelectedTagsChange?: (keys: Set) => void onFilterChange?: (value: string) => void -}) { + onChangeMatchType?: (value: 'AND' | 'OR') => void +} + +function TagMultiSelect({ + options, + loading, + selectedMatchType, + onSelectedTagsChange, + onFilterChange, + onChangeMatchType, +}: TagMultiSelectProps) { const theme = useTheme() const [selectedTagKeys, setSelectedTagKeys] = useState(new Set()) const selectedTagArr = useMemo(() => [...selectedTagKeys], [selectedTagKeys]) const [inputValue, setInputValue] = useState('') const [isOpen, setIsOpen] = useState(false) - const [searchLogic, setSearchLogic] = useState(matchOptions[0].value) + const [searchLogic, setSearchLogic] = useState( + selectedMatchType || matchOptions[0].value + ) const onSelectionChange: ComponentProps< typeof ComboBox @@ -72,8 +80,9 @@ export function TagMultiSelect({