ant-design/components/modal/index.tsx

56 lines
1.2 KiB
TypeScript
Raw Normal View History

import OriginModal, { ModalFuncProps, destroyFns } from './Modal';
import confirm, {
withWarn,
withInfo,
withSuccess,
withError,
withConfirm,
ModalStaticFunctions,
modalGlobalConfig,
} from './confirm';
export { ActionButtonProps } from './ActionButton';
export { ModalProps, ModalFuncProps } from './Modal';
2019-08-05 18:38:10 +08:00
function modalWarn(props: ModalFuncProps) {
return confirm(withWarn(props));
2019-08-05 18:38:10 +08:00
}
type ModalType = typeof OriginModal &
ModalStaticFunctions & { destroyAll: () => void; config: typeof modalGlobalConfig };
const Modal = OriginModal as ModalType;
2019-08-11 19:38:08 +08:00
Modal.info = function infoFn(props: ModalFuncProps) {
return confirm(withInfo(props));
2015-09-07 11:48:57 +08:00
};
2019-08-11 19:38:08 +08:00
Modal.success = function successFn(props: ModalFuncProps) {
return confirm(withSuccess(props));
2015-09-07 11:48:57 +08:00
};
2019-08-11 19:38:08 +08:00
Modal.error = function errorFn(props: ModalFuncProps) {
return confirm(withError(props));
2015-09-07 11:48:57 +08:00
};
2019-08-05 18:38:10 +08:00
Modal.warning = modalWarn;
Modal.warn = modalWarn;
2016-04-11 14:59:37 +08:00
2019-08-11 19:38:08 +08:00
Modal.confirm = function confirmFn(props: ModalFuncProps) {
return confirm(withConfirm(props));
2015-09-07 11:48:57 +08:00
};
2019-08-11 19:38:08 +08:00
Modal.destroyAll = function destroyAllFn() {
while (destroyFns.length) {
const close = destroyFns.pop();
if (close) {
close();
}
}
};
Modal.config = modalGlobalConfig;
export default Modal;