mirror of https://github.com/grafana/grafana
parent
f74396b51d
commit
ec42a8f83f
@ -0,0 +1,23 @@ |
||||
import { ComboboxOption } from './Combobox'; |
||||
|
||||
export function itemToString<T extends string | number>(item?: ComboboxOption<T> | null) { |
||||
if (!item) { |
||||
return ''; |
||||
} |
||||
if (item.label?.includes('Custom value: ')) { |
||||
return item.value.toString(); |
||||
} |
||||
return item.label ?? item.value.toString(); |
||||
} |
||||
|
||||
export function itemFilter<T extends string | number>(inputValue: string) { |
||||
const lowerCasedInputValue = inputValue.toLowerCase(); |
||||
|
||||
return (item: ComboboxOption<T>) => { |
||||
return ( |
||||
!inputValue || |
||||
item.label?.toLowerCase().includes(lowerCasedInputValue) || |
||||
item.value?.toString().toLowerCase().includes(lowerCasedInputValue) |
||||
); |
||||
}; |
||||
} |
Loading…
Reference in new issue