2018-12-26 21:36:36 +08:00
|
|
|
import * as React from 'react';
|
2018-12-03 17:08:48 +08:00
|
|
|
import Modal, { ModalFuncProps, destroyFns } from './Modal';
|
2015-09-07 11:48:57 +08:00
|
|
|
import confirm from './confirm';
|
2018-12-26 21:36:36 +08:00
|
|
|
import Icon from '../icon';
|
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) {
|
|
|
|
const config = {
|
|
|
|
type: 'warning',
|
|
|
|
icon: <Icon type="exclamation-circle" />,
|
|
|
|
okCancel: false,
|
|
|
|
...props,
|
|
|
|
};
|
|
|
|
return confirm(config);
|
|
|
|
}
|
|
|
|
|
2018-12-07 20:02:01 +08:00
|
|
|
Modal.info = function(props: ModalFuncProps) {
|
2017-07-03 16:57:11 +08:00
|
|
|
const config = {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'info',
|
2018-12-26 21:36:36 +08:00
|
|
|
icon: <Icon type="info-circle" />,
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: false,
|
2017-07-03 16:57:11 +08:00
|
|
|
...props,
|
|
|
|
};
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2018-12-07 20:02:01 +08:00
|
|
|
Modal.success = function(props: ModalFuncProps) {
|
2017-07-03 16:57:11 +08:00
|
|
|
const config = {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'success',
|
2018-12-26 21:36:36 +08:00
|
|
|
icon: <Icon type="check-circle" />,
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: false,
|
2017-07-03 16:57:11 +08:00
|
|
|
...props,
|
|
|
|
};
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2018-12-07 20:02:01 +08:00
|
|
|
Modal.error = function(props: ModalFuncProps) {
|
2017-07-03 16:57:11 +08:00
|
|
|
const config = {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'error',
|
2018-12-26 21:36:36 +08:00
|
|
|
icon: <Icon type="close-circle" />,
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: false,
|
2017-07-03 16:57:11 +08:00
|
|
|
...props,
|
|
|
|
};
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
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
|
|
|
|
2018-12-07 20:02:01 +08:00
|
|
|
Modal.confirm = function(props: ModalFuncProps) {
|
2017-07-03 16:57:11 +08:00
|
|
|
const config = {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'confirm',
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: true,
|
2017-07-03 16:57:11 +08:00
|
|
|
...props,
|
|
|
|
};
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2018-12-26 21:36:36 +08:00
|
|
|
Modal.destroyAll = function() {
|
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;
|