2016-09-21 11:54:53 +08:00
|
|
|
import React from 'react';
|
2016-03-21 21:16:38 +08:00
|
|
|
import Modal from './Modal';
|
2015-09-07 11:48:57 +08:00
|
|
|
import confirm from './confirm';
|
2016-06-22 13:18:43 +08:00
|
|
|
import assign from 'object-assign';
|
2016-08-15 12:00:05 +08:00
|
|
|
|
|
|
|
export interface ModalFuncProps {
|
|
|
|
visible?: boolean;
|
2016-09-19 10:17:07 +08:00
|
|
|
title?: React.ReactNode | string;
|
|
|
|
content?: React.ReactNode | string;
|
2016-08-15 12:00:05 +08:00
|
|
|
onOk?: (func: Function) => any;
|
|
|
|
onCancel?: (func: Function) => any;
|
|
|
|
width?: string | number;
|
|
|
|
iconClassName?: string;
|
|
|
|
okText?: string;
|
|
|
|
cancelText?: string;
|
2016-09-19 10:17:07 +08:00
|
|
|
iconType?: string;
|
2016-08-15 12:00:05 +08:00
|
|
|
}
|
|
|
|
Modal.info = function (props: ModalFuncProps) {
|
2016-06-22 13:18:43 +08:00
|
|
|
const config = assign({}, {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'info',
|
|
|
|
iconType: 'info-circle',
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: false,
|
2016-06-22 13:18:43 +08:00
|
|
|
}, props);
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2016-08-15 12:00:05 +08:00
|
|
|
Modal.success = function (props: ModalFuncProps) {
|
2016-06-22 13:18:43 +08:00
|
|
|
const config = assign({}, {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'success',
|
|
|
|
iconType: 'check-circle',
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: false,
|
2016-06-22 13:18:43 +08:00
|
|
|
}, props);
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2016-08-15 12:00:05 +08:00
|
|
|
Modal.error = function (props: ModalFuncProps) {
|
2016-06-22 13:18:43 +08:00
|
|
|
const config = assign({}, {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'error',
|
|
|
|
iconType: 'cross-circle',
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: false,
|
2016-06-22 13:18:43 +08:00
|
|
|
}, props);
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2016-08-15 12:00:05 +08:00
|
|
|
Modal.warning = Modal.warn = function (props: ModalFuncProps) {
|
2016-06-22 13:18:43 +08:00
|
|
|
const config = assign({}, {
|
2016-04-11 14:59:37 +08:00
|
|
|
type: 'warning',
|
|
|
|
iconType: 'exclamation-circle',
|
|
|
|
okCancel: false,
|
2016-06-22 13:18:43 +08:00
|
|
|
}, props);
|
2016-04-11 14:59:37 +08:00
|
|
|
return confirm(config);
|
|
|
|
};
|
|
|
|
|
2016-08-15 12:00:05 +08:00
|
|
|
Modal.confirm = function (props: ModalFuncProps) {
|
2016-06-22 13:18:43 +08:00
|
|
|
const config = assign({}, {
|
2016-04-11 14:57:29 +08:00
|
|
|
type: 'confirm',
|
2016-01-07 17:46:46 +08:00
|
|
|
okCancel: true,
|
2016-06-22 13:18:43 +08:00
|
|
|
}, props);
|
2016-01-07 17:46:46 +08:00
|
|
|
return confirm(config);
|
2015-09-07 11:48:57 +08:00
|
|
|
};
|
|
|
|
|
2016-03-21 21:16:38 +08:00
|
|
|
export default Modal;
|