import React, { useMemo } from 'react'; import { Select as SelectSource, TreeSelect as TreeSelectSource } from 'antd'; import { SelectProps, SelectValue } from 'antd/es/select'; import { TreeSelectProps } from 'antd/es/tree-select'; import { toOptions } from '../tool'; import { TOptionsProps } from '../types'; export type TSelectProps = Omit, 'options'> & TOptionsProps; /** * 下拉选择框过滤器 */ export const selectFilterOption: TSelectProps['filterOption'] = (input, option) => { return !!option && typeof option.children === 'string' && option.children.toLowerCase().includes(input.toLowerCase()); }; /** * 下拉选择框 */ export const Select: React.FC = ({ options = [], ...props }) => { const selectOption = useMemo(() => { return toOptions(options).map(({ label, ...i }) => ( {label} )); }, [JSON.stringify(options)]); return ( {selectOption} ); }; export type TTreeSelectProps = TreeSelectProps; /** * 树选择器 */ export const TreeSelect: React.FC = ({ value, ...props }) => { return ; };