update custom type for modal components

pull/7129/merge
Eden Wang 8 years ago committed by 乐仪
parent f5ade936e1
commit f2b987aaa9

@ -1,9 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Button from '../button';
import Button, { ButtonType } from '../button';
export interface ActionButtonProps {
type?: 'primary' | 'dashed';
type?: ButtonType;
actionFn: Function;
closeModal: Function;
autoFocus?: Boolean;

@ -2,7 +2,7 @@ import React from 'react';
import Dialog from 'rc-dialog';
import PropTypes from 'prop-types';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import Button from '../button';
import Button, { ButtonType } from '../button';
let mousePosition;
let mousePositionEventBinded;
@ -27,8 +27,12 @@ export interface ModalProps {
footer?: React.ReactNode;
/** 确认按钮文字*/
okText?: string;
/** 确认按钮类型*/
okType?: ButtonType;
/** 取消按钮文字*/
cancelText?: string;
/** 取消按钮类型*/
cancelType?: ButtonType;
/** 点击蒙层是否允许关闭*/
maskClosable?: boolean;
style?: React.CSSProperties;
@ -54,7 +58,9 @@ export interface ModalFuncProps {
width?: string | number;
iconClassName?: string;
okText?: string;
okType?: ButtonType;
cancelText?: string;
cancelType?: ButtonType;
iconType?: string;
maskClosable?: boolean;
}
@ -77,6 +83,7 @@ export default class Modal extends React.Component<ModalProps, any> {
maskTransitionName: 'fade',
confirmLoading: false,
visible: false,
okType: 'primary'
};
static propTypes = {
@ -133,7 +140,7 @@ export default class Modal extends React.Component<ModalProps, any> {
}
render() {
let { okText, cancelText, confirmLoading, footer, visible } = this.props;
let { okText, okType, cancelText, cancelType, confirmLoading, footer, visible } = this.props;
if (this.context.antLocale && this.context.antLocale.Modal) {
okText = okText || this.context.antLocale.Modal.okText;
@ -143,6 +150,7 @@ export default class Modal extends React.Component<ModalProps, any> {
const defaultFooter = [(
<Button
key="cancel"
type={cancelType}
size="large"
onClick={this.handleCancel}
>
@ -151,7 +159,7 @@ export default class Modal extends React.Component<ModalProps, any> {
), (
<Button
key="confirm"
type="primary"
type={okType}
size="large"
loading={confirmLoading}
onClick={this.handleOk}

@ -9,6 +9,7 @@ import { getConfirmLocale } from './locale';
export default function confirm(config) {
const props = {
iconType: 'question-circle',
okType: 'primary',
...config,
};
const prefixCls = props.prefixCls || 'ant-confirm';
@ -56,10 +57,10 @@ export default function confirm(config) {
if (props.okCancel) {
footer = (
<div className={`${prefixCls}-btns`}>
<ActionButton actionFn={props.onCancel} closeModal={close}>
<ActionButton type={props.cancelType} actionFn={props.onCancel} closeModal={close}>
{props.cancelText}
</ActionButton>
<ActionButton type="primary" actionFn={props.onOk} closeModal={close} autoFocus>
<ActionButton type={props.okType} actionFn={props.onOk} closeModal={close} autoFocus>
{props.okText}
</ActionButton>
</div>
@ -67,7 +68,7 @@ export default function confirm(config) {
} else {
footer = (
<div className={`${prefixCls}-btns`}>
<ActionButton type="primary" actionFn={props.onOk} closeModal={close} autoFocus>
<ActionButton type={props.okType} actionFn={props.onOk} closeModal={close} autoFocus>
{props.okText}
</ActionButton>
</div>

Loading…
Cancel
Save