From f5ade936e14b5cc9cba0220a1dbcd98ce9288b7d Mon Sep 17 00:00:00 2001 From: Eden Wang Date: Sun, 16 Jul 2017 16:52:06 +0800 Subject: [PATCH 01/20] add button type for ok and cancel in popconfirm --- components/popconfirm/demo/basic.md | 2 +- components/popconfirm/index.en-US.md | 2 ++ components/popconfirm/index.tsx | 11 +++++++---- components/popconfirm/index.zh-CN.md | 2 ++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/popconfirm/demo/basic.md b/components/popconfirm/demo/basic.md index f95cd2ecab..1942a898fd 100755 --- a/components/popconfirm/demo/basic.md +++ b/components/popconfirm/demo/basic.md @@ -27,7 +27,7 @@ function cancel(e) { } ReactDOM.render( - + Delete , mountNode); diff --git a/components/popconfirm/index.en-US.md b/components/popconfirm/index.en-US.md index ffe09127ca..2720fcffc0 100644 --- a/components/popconfirm/index.en-US.md +++ b/components/popconfirm/index.en-US.md @@ -20,7 +20,9 @@ The difference with `confirm` is more lightweight than the static popped full-sc | onConfirm | callback of confirmation | function(e) | none | | onCancel | callback of cancel | function(e) | none | | okText | text of the confirmation button | string | Confirm | +| okType | type of the confirmation button | string | primary | | cancelText| text of the cancel button | string | Cancel | +| cancelType| type of the confirmation button | string | none | Consult [Tooltip's documentation](https://ant.design/components/tooltip/#API) to find more APIs. diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index a949405c50..5a314bf97d 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import Tooltip, { AbstractTooltipProps } from '../tooltip'; import Icon from '../icon'; -import Button from '../button'; +import Button, { ButtonType } from '../button'; import injectLocale from '../locale-provider/injectLocale'; export interface PopconfirmProps extends AbstractTooltipProps { @@ -9,7 +9,9 @@ export interface PopconfirmProps extends AbstractTooltipProps { onConfirm?: (e: React.MouseEvent) => void; onCancel?: (e: React.MouseEvent) => void; okText?: React.ReactNode; + okType?: ButtonType; cancelText?: React.ReactNode; + cancelType?: ButtonType; } abstract class Popconfirm extends React.Component { @@ -18,6 +20,7 @@ abstract class Popconfirm extends React.Component { transitionName: 'zoom-big', placement: 'top', trigger: 'click', + okType: 'primary' }; refs: { @@ -79,7 +82,7 @@ abstract class Popconfirm extends React.Component { } render() { - const { prefixCls, title, placement, okText, cancelText, ...restProps } = this.props; + const { prefixCls, title, placement, okText, okType, cancelText, cancelType, ...restProps } = this.props; const popconfirmLocale = this.getLocale(); const overlay = ( @@ -90,10 +93,10 @@ abstract class Popconfirm extends React.Component {
{title}
- -
diff --git a/components/popconfirm/index.zh-CN.md b/components/popconfirm/index.zh-CN.md index 2bded6d4f4..a1c8779f5a 100644 --- a/components/popconfirm/index.zh-CN.md +++ b/components/popconfirm/index.zh-CN.md @@ -21,7 +21,9 @@ title: Popconfirm | onConfirm | 点击确认的回调 | function(e) | 无 | | onCancel | 点击取消的回调 | function(e) | 无 | | okText | 确认按钮文字 | string | 确定 | +| okType | 确认按钮类型 | string | primary | | cancelText| 取消按钮文字 | string | 取消 | +| cancelType| 取消按钮类型 | string | 无 | 更多属性请参考 [Tooltip](/components/tooltip/#API)。 From f2b987aaa96d7bbc4d21e091a099e447e9a799ab Mon Sep 17 00:00:00 2001 From: Eden Wang Date: Sun, 16 Jul 2017 17:42:02 +0800 Subject: [PATCH 02/20] update custom type for modal components --- components/modal/ActionButton.tsx | 4 ++-- components/modal/Modal.tsx | 14 +++++++++++--- components/modal/confirm.tsx | 7 ++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/components/modal/ActionButton.tsx b/components/modal/ActionButton.tsx index e4f8ffa468..e9ea59149d 100644 --- a/components/modal/ActionButton.tsx +++ b/components/modal/ActionButton.tsx @@ -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; diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 28d25dfd26..a90955465b 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -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 { maskTransitionName: 'fade', confirmLoading: false, visible: false, + okType: 'primary' }; static propTypes = { @@ -133,7 +140,7 @@ export default class Modal extends React.Component { } 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 { const defaultFooter = [( +
+ + +
, mountNode); ```` From ee176347ac6a61f3415859793ca6623f85631b7d Mon Sep 17 00:00:00 2001 From: Eden Wang Date: Mon, 17 Jul 2017 09:40:55 +0800 Subject: [PATCH 05/20] fix ci compile error --- components/modal/ActionButton.tsx | 3 ++- components/modal/Modal.tsx | 3 ++- components/popconfirm/index.tsx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/modal/ActionButton.tsx b/components/modal/ActionButton.tsx index e9ea59149d..2c220e7a6e 100644 --- a/components/modal/ActionButton.tsx +++ b/components/modal/ActionButton.tsx @@ -1,6 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import Button, { ButtonType } from '../button'; +import Button from '../button'; +import { ButtonType } from '../button/button'; export interface ActionButtonProps { type?: ButtonType; diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index a90955465b..5e823c92b7 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -2,7 +2,8 @@ import React from 'react'; import Dialog from 'rc-dialog'; import PropTypes from 'prop-types'; import addEventListener from 'rc-util/lib/Dom/addEventListener'; -import Button, { ButtonType } from '../button'; +import Button from '../button'; +import { ButtonType } from '../button/button'; let mousePosition; let mousePositionEventBinded; diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index 5a314bf97d..e3a03463f9 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -1,7 +1,8 @@ import React from 'react'; import Tooltip, { AbstractTooltipProps } from '../tooltip'; import Icon from '../icon'; -import Button, { ButtonType } from '../button'; +import Button from '../button'; +import { ButtonType } from '../button/button'; import injectLocale from '../locale-provider/injectLocale'; export interface PopconfirmProps extends AbstractTooltipProps { From 8f1dd9ccdaba05ca08c88d6e49b3656551350920 Mon Sep 17 00:00:00 2001 From: Eden Wang Date: Mon, 17 Jul 2017 09:50:24 +0800 Subject: [PATCH 06/20] add missing trailing comma --- components/modal/Modal.tsx | 2 +- components/popconfirm/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 5e823c92b7..971cc56b61 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -84,7 +84,7 @@ export default class Modal extends React.Component { maskTransitionName: 'fade', confirmLoading: false, visible: false, - okType: 'primary' + okType: 'primary', }; static propTypes = { diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index e3a03463f9..ac5224c3ea 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -21,7 +21,7 @@ abstract class Popconfirm extends React.Component { transitionName: 'zoom-big', placement: 'top', trigger: 'click', - okType: 'primary' + okType: 'primary', }; refs: { From a5a1458148a90077bbf8c3c0e5f88a6fcd4d3dd0 Mon Sep 17 00:00:00 2001 From: Eden Wang Date: Mon, 17 Jul 2017 10:01:23 +0800 Subject: [PATCH 07/20] add missing trailing commna --- components/modal/demo/confirm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/modal/demo/confirm.md b/components/modal/demo/confirm.md index a8c65beaef..c008299dd9 100644 --- a/components/modal/demo/confirm.md +++ b/components/modal/demo/confirm.md @@ -26,7 +26,7 @@ function showConfirm() { }, onCancel() { console.log('Cancel'); - } + }, }); } @@ -43,7 +43,7 @@ function showDeleteConfirm() { }, onCancel() { console.log('Cancel'); - } + }, }); } From 528a7645ca6d7639b530da7a9f7059c77ac06492 Mon Sep 17 00:00:00 2001 From: yociduo Date: Mon, 17 Jul 2017 10:50:58 +0800 Subject: [PATCH 08/20] remove cancel text --- components/modal/Modal.tsx | 6 +----- components/modal/confirm.tsx | 2 +- components/modal/demo/confirm.md | 1 - components/modal/index.en-US.md | 1 - components/modal/index.zh-CN.md | 1 - components/popconfirm/index.en-US.md | 1 - components/popconfirm/index.tsx | 5 ++--- components/popconfirm/index.zh-CN.md | 1 - 8 files changed, 4 insertions(+), 14 deletions(-) diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 971cc56b61..99b892828f 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -32,8 +32,6 @@ export interface ModalProps { okType?: ButtonType; /** 取消按钮文字*/ cancelText?: string; - /** 取消按钮类型*/ - cancelType?: ButtonType; /** 点击蒙层是否允许关闭*/ maskClosable?: boolean; style?: React.CSSProperties; @@ -61,7 +59,6 @@ export interface ModalFuncProps { okText?: string; okType?: ButtonType; cancelText?: string; - cancelType?: ButtonType; iconType?: string; maskClosable?: boolean; } @@ -141,7 +138,7 @@ export default class Modal extends React.Component { } render() { - let { okText, okType, cancelText, cancelType, confirmLoading, footer, visible } = this.props; + let { okText, okType, cancelText, confirmLoading, footer, visible } = this.props; if (this.context.antLocale && this.context.antLocale.Modal) { okText = okText || this.context.antLocale.Modal.okText; @@ -151,7 +148,6 @@ export default class Modal extends React.Component { const defaultFooter = [(