ant-design-vue/components/modal/index.js

89 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-04-17 10:21:28 +08:00
import Modal, { destroyFns } from './Modal';
2019-01-12 11:33:27 +08:00
import modalConfirm from './confirm';
2019-05-13 19:09:21 +08:00
import Icon from '../icon';
import Base from '../base';
2018-03-06 19:14:41 +08:00
// export { ActionButtonProps } from './ActionButton'
// export { ModalProps, ModalFuncProps } from './Modal'
2019-01-12 11:33:27 +08:00
const info = function(props) {
2018-03-06 19:14:41 +08:00
const config = {
type: 'info',
2019-05-28 11:37:38 +08:00
icon: h => {
2019-05-13 19:09:21 +08:00
return <Icon type="info-circle" />;
},
2018-03-06 19:14:41 +08:00
okCancel: false,
...props,
2019-01-12 11:33:27 +08:00
};
return modalConfirm(config);
};
2018-03-06 19:14:41 +08:00
2019-01-12 11:33:27 +08:00
const success = function(props) {
2018-03-06 19:14:41 +08:00
const config = {
type: 'success',
2019-05-28 11:37:38 +08:00
icon: h => {
2019-05-13 19:09:21 +08:00
return <Icon type="check-circle" />;
},
2018-03-06 19:14:41 +08:00
okCancel: false,
...props,
2019-01-12 11:33:27 +08:00
};
return modalConfirm(config);
};
2018-03-06 19:14:41 +08:00
2019-01-12 11:33:27 +08:00
const error = function(props) {
2018-03-06 19:14:41 +08:00
const config = {
type: 'error',
2019-05-28 11:37:38 +08:00
icon: h => {
2019-05-13 19:09:21 +08:00
return <Icon type="close-circle" />;
},
2018-03-06 19:14:41 +08:00
okCancel: false,
...props,
2019-01-12 11:33:27 +08:00
};
return modalConfirm(config);
};
2018-03-06 19:14:41 +08:00
2019-01-12 11:33:27 +08:00
const warning = function(props) {
2018-03-06 19:14:41 +08:00
const config = {
type: 'warning',
2019-05-28 11:37:38 +08:00
icon: h => {
2019-05-13 19:09:21 +08:00
return <Icon type="exclamation-circle" />;
},
2018-03-06 19:14:41 +08:00
okCancel: false,
...props,
2019-01-12 11:33:27 +08:00
};
return modalConfirm(config);
};
const warn = warning;
2018-03-06 19:14:41 +08:00
2019-01-12 11:33:27 +08:00
const confirm = function(props) {
2018-03-06 19:14:41 +08:00
const config = {
type: 'confirm',
okCancel: true,
...props,
2019-01-12 11:33:27 +08:00
};
return modalConfirm(config);
};
Modal.info = info;
Modal.success = success;
Modal.error = error;
Modal.warning = warning;
Modal.warn = warn;
Modal.confirm = confirm;
2018-03-06 19:14:41 +08:00
2019-04-17 10:21:28 +08:00
Modal.destroyAll = function() {
while (destroyFns.length) {
const close = destroyFns.pop();
if (close) {
close();
}
}
};
/* istanbul ignore next */
2019-01-12 11:33:27 +08:00
Modal.install = function(Vue) {
Vue.use(Base);
2019-01-12 11:33:27 +08:00
Vue.component(Modal.name, Modal);
};
2019-01-12 11:33:27 +08:00
export default Modal;