UNPKG

@flatbiz/antd

Version:
72 lines (69 loc) 2.48 kB
import { TAny, TPlainObject } from '@flatbiz/utils'; import { SelectProps } from 'antd'; import { ReactElement } from 'react'; export type TRequestStatus = "request-init" | "request-progress" | "request-success" | "request-error" | "request-search-keyword-empty" | "no-dependencies-params"; export type TRequestStatusProps = { status?: TRequestStatus; errorButton?: ReactElement; messageConfig?: Partial<Record<TRequestStatus, string>>; loading?: boolean; }; export type SelectorWrapperSearchServiceConfig = { params?: TPlainObject; onRequest: (params?: TAny) => TAny; /** 与 params 配合使用 */ requiredParamsKeys?: string[]; onRequestResultAdapter?: (respData: TAny) => TPlainObject[]; }; export type SelectorWrapperSearchProps = Omit<SelectProps, "onSearch" | "notFoundContent" | "options" | "fieldNames" | "loading"> & { /** * 参数Key映射 * ``` * 1. list 为 onRequest 返回数据中列表key值,可多级取值,例如:'a.b.c' * 2. 配置 serviceConfig.onRequestResultAdapter后,fieldNames.list配置失效 * ``` */ fieldNames?: { label: string; value: string; disabled?: string; searchKeyword?: string; list?: string; }; /** * 请求服务需求的数据 */ serviceConfig: SelectorWrapperSearchServiceConfig; /** * 添加全部选项 * ``` * 1. 默认值label="全部",value="" * 2. 可配置label、value * ``` */ showAllOption?: true | TPlainObject<string | number>; /** selectorList发生变更时触发,每次都会调用 */ onSelectorListChange?: (dataList: TPlainObject[]) => void; /** 通过服务获取数据异常回调 */ onSelectorRequestError?: (error: Error) => void; /** 交互文案配置 */ requestMessageConfig?: TRequestStatusProps["messageConfig"]; /** label渲染适配器 */ onLabelRenderAdapter?: (dataItem: TPlainObject) => string | ReactElement; /** 自定义keyword值, */ customKeyword?: string; }; /** * 选择器简单包装组件 * @param props * @returns * ``` * 1. 只支持 search + 服务 功能 * 2. 不会缓存接口数据 * 3. 不会对value、onChange做任何处理 * 4. 修改文案【未获取到必要的查询条件】,通过参数 requestMessageConfig={{'no-dependencies-params': '自定义文案'}} 配置 * 5. 通过设置 fieldNames.searchKeyword 可修改关键字key值,默认值:searchKeyword * ``` */ export declare const SelectorWrapperSearch: (props: SelectorWrapperSearchProps) => import("react").JSX.Element; export {};