ant-design/components/modal/index.tsx
偏右 481fd209e2
chore: 🆙 upgrade typescript-eslint (#26600)
* chore: 🆙 upgrade typescript-eslint

* fix some lint

* fix: some eslint errors

* Update package.json

* chore: 🆙 upgrade typescript-eslint

* fix some lint

* fix: some eslint errors

* Update package.json

* fix no use before define

* Update package.json

* fix lint

Co-authored-by: yoyo837 <yoyo837@hotmail.com>
Co-authored-by: Tom Xu <ycxzhkx@gmail.com>
2020-09-16 11:43:55 +08:00

56 lines
1.2 KiB
TypeScript

import OriginModal, { ModalFuncProps, destroyFns } from './Modal';
import confirm, {
withWarn,
withInfo,
withSuccess,
withError,
withConfirm,
ModalStaticFunctions,
globalConfig,
} from './confirm';
export { ActionButtonProps } from './ActionButton';
export { ModalProps, ModalFuncProps } from './Modal';
function modalWarn(props: ModalFuncProps) {
return confirm(withWarn(props));
}
type ModalType = typeof OriginModal &
ModalStaticFunctions & { destroyAll: () => void; config: typeof globalConfig };
const Modal = OriginModal as ModalType;
Modal.info = function infoFn(props: ModalFuncProps) {
return confirm(withInfo(props));
};
Modal.success = function successFn(props: ModalFuncProps) {
return confirm(withSuccess(props));
};
Modal.error = function errorFn(props: ModalFuncProps) {
return confirm(withError(props));
};
Modal.warning = modalWarn;
Modal.warn = modalWarn;
Modal.confirm = function confirmFn(props: ModalFuncProps) {
return confirm(withConfirm(props));
};
Modal.destroyAll = function destroyAllFn() {
while (destroyFns.length) {
const close = destroyFns.pop();
if (close) {
close();
}
}
};
Modal.config = globalConfig;
export default Modal;