ant-design/components/modal/index.tsx

62 lines
1.4 KiB
TypeScript
Raw Normal View History

import * as React from 'react';
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';
export interface ModalFuncProps {
visible?: boolean;
title?: React.ReactNode;
content?: React.ReactNode;
onOk?: (func: Function) => any;
onCancel?: (func: Function) => any;
width?: string | number;
iconClassName?: string;
okText?: string;
cancelText?: string;
}
Modal.info = function (props: ModalFuncProps) {
2016-06-22 13:18:43 +08:00
const config = assign({}, {
type: 'info',
iconType: 'info-circle',
okCancel: false,
2016-06-22 13:18:43 +08:00
}, props);
return confirm(config);
2015-09-07 11:48:57 +08:00
};
Modal.success = function (props: ModalFuncProps) {
2016-06-22 13:18:43 +08:00
const config = assign({}, {
type: 'success',
iconType: 'check-circle',
okCancel: false,
2016-06-22 13:18:43 +08:00
}, props);
return confirm(config);
2015-09-07 11:48:57 +08:00
};
Modal.error = function (props: ModalFuncProps) {
2016-06-22 13:18:43 +08:00
const config = assign({}, {
type: 'error',
iconType: 'cross-circle',
okCancel: false,
2016-06-22 13:18:43 +08:00
}, props);
return confirm(config);
2015-09-07 11:48:57 +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);
};
Modal.confirm = function (props: ModalFuncProps) {
2016-06-22 13:18:43 +08:00
const config = assign({}, {
type: 'confirm',
okCancel: true,
2016-06-22 13:18:43 +08:00
}, props);
return confirm(config);
2015-09-07 11:48:57 +08:00
};
export default Modal;