UNPKG

@flatbiz/antd

Version:
99 lines (96 loc) 3.78 kB
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; }; export type DialogAlertProps = Omit<DialogModalProps, "onOk" | "cancelHidden" | "cancelButtonProps" | "onCancel" | "onClick"> & { onClick?: (e: React.MouseEvent<HTMLElement>) => void | Promise<void>; }; /** * 确认弹框 * ``` * 1. 可嵌套使用 * 2. 为什么不推荐使用 * dialogAlert.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化 * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn) * 3. 需要修改默认主题风格的场景,请使用 * const { appDialogAlert } = FbaApp.useDialogAlert(); * appDialogAlert.open({}) * ``` */ export declare const dialogAlert: { open: (props: DialogAlertProps) => { close: () => void; }; }; export {};