Browse Source

add left out event parameters for Modal[onOk] Popconfirm[onConfirm] Popconfirm[onCancel] (#5042)

pull/5039/head
ddcat1115 8 years ago
committed by 偏右
parent
commit
e07cdf5387
  1. 6
      components/modal/Modal.tsx
  2. 4
      components/modal/demo/basic.md
  3. 2
      components/modal/index.en-US.md
  4. 2
      components/modal/index.zh-CN.md
  5. 6
      components/popconfirm/demo/basic.md
  6. 4
      components/popconfirm/index.en-US.md
  7. 12
      components/popconfirm/index.tsx
  8. 4
      components/popconfirm/index.zh-CN.md

6
components/modal/Modal.tsx

@ -17,7 +17,7 @@ export interface ModalProps {
/** 是否显示右上角的关闭按钮*/ /** 是否显示右上角的关闭按钮*/
closable?: boolean; closable?: boolean;
/** 点击确定回调*/ /** 点击确定回调*/
onOk?: () => void; onOk?: (e: React.MouseEvent<any>) => void;
/** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调*/ /** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调*/
onCancel?: (e: React.MouseEvent<any>) => void; onCancel?: (e: React.MouseEvent<any>) => void;
afterClose?: () => void; afterClose?: () => void;
@ -89,10 +89,10 @@ export default class Modal extends React.Component<ModalProps, any> {
} }
} }
handleOk = () => { handleOk = (e) => {
const onOk = this.props.onOk; const onOk = this.props.onOk;
if (onOk) { if (onOk) {
onOk(); onOk(e);
} }
} }

4
components/modal/demo/basic.md

@ -23,8 +23,8 @@ class App extends React.Component {
visible: true, visible: true,
}); });
} }
handleOk = () => { handleOk = (e) => {
console.log('Clicked OK'); console.log(e);
this.setState({ this.setState({
visible: false, visible: false,
}); });

2
components/modal/index.en-US.md

@ -22,7 +22,7 @@ and so on.
| confirmLoading | Determine whether to apply loading visual effect for OK button or not | boolean | no | | confirmLoading | Determine whether to apply loading visual effect for OK button or not | boolean | no |
| title | The modal dialog's title | string\|ReactNode | no | | title | The modal dialog's title | string\|ReactNode | no |
| closable | Determine whether a close (x) button is visible on top right of the modal dialog or not | boolean | true | | closable | Determine whether a close (x) button is visible on top right of the modal dialog or not | boolean | true |
| onOk | Specify a function that will be called when a user clicked OK button | function | no | | onOk | Specify a function that will be called when a user clicked OK button | function(e) | no |
| onCancel | Specify a function that will be called when a user clicked mask, close button on top right or cancel button | function(e) | no | | onCancel | Specify a function that will be called when a user clicked mask, close button on top right or cancel button | function(e) | no |
| width | Width of a modal dialog | string\|number | 520 | | width | Width of a modal dialog | string\|number | 520 |
| footer | Footer content, set as `footer={null}` when you don't need default buttons | string\|ReactNode | OK and cancel button | | footer | Footer content, set as `footer={null}` when you don't need default buttons | string\|ReactNode | OK and cancel button |

2
components/modal/index.zh-CN.md

@ -21,7 +21,7 @@ title: Modal
| confirmLoading | 确定按钮 loading | boolean | 无 | | confirmLoading | 确定按钮 loading | boolean | 无 |
| title | 标题 | string\|ReactNode | 无 | | title | 标题 | string\|ReactNode | 无 |
| closable | 是否显示右上角的关闭按钮 | boolean | true | | closable | 是否显示右上角的关闭按钮 | boolean | true |
| onOk | 点击确定回调 | function | 无 | | onOk | 点击确定回调 | function(e) | 无 |
| onCancel | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) | 无 | | onCancel | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) | 无 |
| width | 宽度 | string\|number | 520 | | width | 宽度 | string\|number | 520 |
| footer | 底部内容,当不需要默认底部按钮时,可以设为 `footer={null}` | string\|ReactNode | 确定取消按钮 | | footer | 底部内容,当不需要默认底部按钮时,可以设为 `footer={null}` | string\|ReactNode | 确定取消按钮 |

6
components/popconfirm/demo/basic.md

@ -16,11 +16,13 @@ The basic example.
````jsx ````jsx
import { Popconfirm, message } from 'antd'; import { Popconfirm, message } from 'antd';
function confirm() { function confirm(e) {
console.log(e);
message.success('Click on Yes'); message.success('Click on Yes');
} }
function cancel() { function cancel(e) {
console.log(e);
message.error('Click on No'); message.error('Click on No');
} }

4
components/popconfirm/index.en-US.md

@ -17,8 +17,8 @@ The difference with `confirm` is more lightweight than the static popped full-sc
| Param | Description | Type | Default value | | Param | Description | Type | Default value |
|-----------|------------------------------------------|---------------|--------| |-----------|------------------------------------------|---------------|--------|
| title | title of the confirmation box | string\|ReactNode | none | | title | title of the confirmation box | string\|ReactNode | none |
| onConfirm | callback of confirmation | function | none | | onConfirm | callback of confirmation | function(e) | none |
| onCancel | callback of cancel | function | none | | onCancel | callback of cancel | function(e) | none |
| okText | text of the confirmation button | string | Confirm | | okText | text of the confirmation button | string | Confirm |
| cancelText| text of the cancel button | string | Cancel | | cancelText| text of the cancel button | string | Cancel |

12
components/popconfirm/index.tsx

@ -6,8 +6,8 @@ import Button from '../button';
export interface PopconfirmProps extends AbstractTooltipProps { export interface PopconfirmProps extends AbstractTooltipProps {
title: React.ReactNode; title: React.ReactNode;
onConfirm?: () => void; onConfirm?: (e: React.MouseEvent<any>) => void;
onCancel?: () => void; onCancel?: (e: React.MouseEvent<any>) => void;
okText?: React.ReactNode; okText?: React.ReactNode;
cancelText?: React.ReactNode; cancelText?: React.ReactNode;
} }
@ -46,21 +46,21 @@ export default class Popconfirm extends React.Component<PopconfirmProps, any> {
} }
} }
confirm = () => { confirm = (e) => {
this.setVisible(false); this.setVisible(false);
const onConfirm = this.props.onConfirm; const onConfirm = this.props.onConfirm;
if (onConfirm) { if (onConfirm) {
onConfirm.call(this); onConfirm.call(this, e);
} }
} }
cancel = () => { cancel = (e) => {
this.setVisible(false); this.setVisible(false);
const onCancel = this.props.onCancel; const onCancel = this.props.onCancel;
if (onCancel) { if (onCancel) {
onCancel.call(this); onCancel.call(this, e);
} }
} }

4
components/popconfirm/index.zh-CN.md

@ -18,8 +18,8 @@ title: Popconfirm
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
|-----------|------------------------------------------|---------------|--------| |-----------|------------------------------------------|---------------|--------|
| title | 确认框的描述 | string\|ReactNode | 无 | | title | 确认框的描述 | string\|ReactNode | 无 |
| onConfirm | 点击确认的回调 | function | 无 | | onConfirm | 点击确认的回调 | function(e) | 无 |
| onCancel | 点击取消的回调 | function | 无 | | onCancel | 点击取消的回调 | function(e) | 无 |
| okText | 确认按钮文字 | string | 确定 | | okText | 确认按钮文字 | string | 确定 |
| cancelText| 取消按钮文字 | string | 取消 | | cancelText| 取消按钮文字 | string | 取消 |

Loading…
Cancel
Save