2020-02-03 13:00:35 +08:00
|
|
|
import OriginModal, { ModalFuncProps, destroyFns } from './Modal';
|
|
|
|
import confirm, {
|
|
|
|
withWarn,
|
|
|
|
withInfo,
|
|
|
|
withSuccess,
|
|
|
|
withError,
|
|
|
|
withConfirm,
|
|
|
|
ModalStaticFunctions,
|
|
|
|
} from './confirm';
|
2016-08-15 12:00:05 +08:00
|
|
|
|
2017-09-25 22:14:49 +08:00
|
|
|
export { ActionButtonProps } from './ActionButton';
|
|
|
|
export { ModalProps, ModalFuncProps } from './Modal';
|
2017-03-03 11:40:54 +08:00
|
|
|
|
2019-08-05 18:38:10 +08:00
|
|
|
function modalWarn(props: ModalFuncProps) {
|
2020-02-03 13:00:35 +08:00
|
|
|
return confirm(withWarn(props));
|
2019-08-05 18:38:10 +08:00
|
|
|
}
|
|
|
|
|
2020-05-19 20:15:51 +08:00
|
|
|
type Modal = typeof OriginModal & ModalStaticFunctions & { destroyAll: () => void };
|
2020-02-03 13:00:35 +08:00
|
|
|
const Modal = OriginModal as Modal;
|
|
|
|
|
2019-08-11 19:38:08 +08:00
|
|
|
Modal.info = function infoFn(props: ModalFuncProps) {
|
2020-02-03 13:00:35 +08:00
|
|
|
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) {
|
2020-02-03 13:00:35 +08:00
|
|
|
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) {
|
2020-02-03 13:00:35 +08:00
|
|
|
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) {
|
2020-02-03 13:00:35 +08:00
|
|
|
return confirm(withConfirm(props));
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2019-08-11 19:38:08 +08:00
|
|
|
Modal.destroyAll = function destroyAllFn() {
|
2018-12-03 17:08:48 +08:00
|
|
|
while (destroyFns.length) {
|
|
|
|
const close = destroyFns.pop();
|
|
|
|
if (close) {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-21 21:16:38 +08:00
|
|
|
export default Modal;
|