import type { DocumentNode } from '@apollo/client'; import type { SelectProps } from 'antd'; import type { DefaultOptionType } from 'antd/es/select'; import type { PropertyPath } from 'lodash'; export type SelectValueType = string | number | null | undefined; export interface AsyncSelectProps extends SelectProps { /** * 网路请求和格式化函数配置 */ remote: { gql: DocumentNode; gqlKey: PropertyPath; extraParams?: any; /** * 格式化函数 */ normalize?: (val: any) => DefaultOptionType[]; }; /** * 是否自动选择第一个 * @default false */ autoSelect?: boolean; /** * 是否有空选项 * @default false */ hasAny?: boolean; /** * 空选项的文字描述 */ anyText?: string; value?: SelectValueType; onChange?: (obj: SelectValueType) => void; /** * 当 select 中值改变时往外暴露 value 和 dateSet */ onChoose?: (value: SelectValueType, dataSet: any[]) => void; /** * 不禁用 */ noDisable?: boolean; /** * 默认值 */ defaultValue?: any; }