@flatbiz/antd
Version:
113 lines (110 loc) • 4.19 kB
TypeScript
import { TAny, TNoopDefine, TPlainObject } from '@flatbiz/utils';
import { ButtonProps, FormInstance, ModalProps } from 'antd';
import { ConfigProviderProps } from 'antd/es/config-provider';
import { ReactElement } from 'react';
export type ButtonWrapperProps = Omit<ButtonProps, "onClick" | "color"> & {
/** 当返回 Promise 时,按钮自动loading */
onClick?: (e: React.MouseEvent<HTMLElement>) => Promise<TAny> | void;
/** 重复点击间隙,单位毫秒 默认值:500 */
debounceDuration?: number;
/** 基于GLOBAL中elemAclLimits按钮权限列表,控制按钮显示、隐藏 */
permission?: string;
/** 是否隐藏按钮 */
hidden?: boolean;
/** loading 显示位置,默认值:left */
loadingPosition?: "left" | "center";
/** 移除按钮内边距,一般用于 type=link 类型下 */
removeGap?: boolean;
color?: string;
};
export type TLocale = "en" | "zh-cn";
export type TFbaLocale = {
TreeWrapper?: {
/** 数据加载异常默认文案 */
requestError?: string;
};
FbaDialogModal?: {
cancelText?: string;
};
};
export type ConfigProviderWrapperProps = Omit<ConfigProviderProps, "locale"> & {
locale?: TLocale;
/** 自定义国际化数据 */
customLocaleMessage?: Partial<TFbaLocale>;
/** 同 fbaHooks.useCopyRemoveSpace[ignoreClass] */
copyOperateIgnoreClass?: string[];
};
export type DialogModalProps = Omit<ModalProps, "onOk" | "onCancel" | "getContainer" | "open" | "open" | "okButtonProps" | "cancelButtonProps" | "footer"> & {
/**
* 内置尺寸,根据比例固定高度、宽度,默认:无
* ```
* 1. 如果自定义了width、bodyHeight属性,size中的height、width将对应失效
* 2. 不传、传null值可取消内置尺寸
* ```
*/
size?: "small" | "middle" | "large" | null;
onOk?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;
onCancel?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;
content: string | ReactElement | ((form: FormInstance, operate: {
onClose: TNoopDefine;
}) => ReactElement);
configProviderProps?: ConfigProviderWrapperProps;
okHidden?: boolean;
cancelHidden?: boolean;
okButtonProps?: Omit<ButtonWrapperProps, "hidden" | "children" | "onClick">;
cancelButtonProps?: Omit<ButtonWrapperProps, "hidden" | "children" | "onClick">;
/**
* 设置modal body height 为当前窗口height的百分比,例如:30
* @deprecated 已失效,可通过size属性设置
* ```
* 1. 最大值:80
* 1. 设置bodyStyle.height 后,bodyHeightPercent失效
* ```
*/
bodyHeightPercent?: number;
titleExtra?: ReactElement;
/**
* null则隐藏footer
* ```
* extraData 为外部通过 useDialogModal.rerenderFooter 重新渲染footer携带的数据
* ```
*/
footer?: null | ReactElement | ReactElement[] | ((form: FormInstance, extraData?: TPlainObject) => ReactElement);
/** 内容高度,为styles.body.height快捷配置,优先级低于styles.body.height */
bodyHeight?: number;
};
/**
* 居中弹框
* ```
* 1. 可嵌套使用
* 2. 为什么不推荐使用
* dialogModal.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化
* 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)
* 3. 需要修改默认主题风格的场景,请使用
* const { appDialogModal } = FbaApp.useDialogModal();
* appDialogModal.open({})
* 4. size属性可使用预设的弹窗尺寸(默认值middle),如果不使用内置尺寸可设置 size = null
* ```
*/
export declare const dialogModal: {
open: (props: DialogModalProps) => {
close: () => void;
};
/**
* ```
* 1. 关闭最新弹框,如果有多个弹框只能关闭最后一个
* 2. 多个弹框主动关闭,只能使用 dialogModal.open()返回值中的close
* ```
*/
close: () => void;
/**
* ```
* 1. rerenderFooter 携带指定数据重新渲染 footer,可用于切换footer中的按钮状态
* ```
*/
useDialogModal: () => {
/** 重新渲染 footer, data为携带的数据,是footer的第二个参数 */
rerenderFooter: (data?: TPlainObject) => void;
};
};
export {};