pickerSearch.ts 460 Bytes
/**
 * Select支持搜索
 */
export const createPickerSearch = (searchValue = false) => {
  return {
    showSearch: true,
    filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => {
      let { label, value } = option
      label = label.toLowerCase()
      value = value.toLowerCase()
      inputValue = inputValue.toLowerCase()
      return label.includes(inputValue) || (searchValue && value.includes(inputValue))
    },
  }
}