@flatbiz/antd
Version:
64 lines (61 loc) • 1.96 kB
TypeScript
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 SelectorWrapperSimpleServiceConfig = {
params?: TPlainObject;
onRequest: (params?: TAny) => TAny;
onRequestResultAdapter?: (respData: TAny) => TPlainObject[];
};
export type SelectorWrapperSimpleProps = 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;
list?: string;
};
/**
* 请求服务需求的数据
*/
serviceConfig: SelectorWrapperSimpleServiceConfig;
/**
* 添加全部选项
* ```
* 1. 默认值label="全部",value=""
* 2. 可配置label、value
* ```
*/
showAllOption?: true | TPlainObject<string | number>;
/** selectorList发生变更时触发,每次都会调用 */
onSelectorListChange?: (dataList: TPlainObject[]) => void;
/**
* 通过服务获取数据异常回调
*/
onSelectorRequestError?: (error: Error) => void;
requestMessageConfig?: TRequestStatusProps["messageConfig"];
};
/**
* 选择器简单包装组件
* @param props
* @returns
* ```
* 1. 不支持search效果
* 2. 不会缓存接口数据
* 3. 不会对value、onChange做任何处理
* ```
*/
export declare const SelectorWrapperSimple: (props: SelectorWrapperSimpleProps) => import("react").JSX.Element;
export {};