feat: popconfirm add disabled support

pull/1845/head
tangjinzhou 2020-02-22 18:55:00 +08:00
parent 2200cf0a03
commit e7d935cfac
6 changed files with 49 additions and 16 deletions

View File

@ -1,5 +1,5 @@
module.exports = {
dev: {
componentName: 'pagination', // dev components
componentName: 'popconfirm', // dev components
},
};

View File

@ -72,4 +72,27 @@ describe('Popconfirm', () => {
expect(popup.innerHTML).toMatchSnapshot();
}, 1000);
});
it('should not open in disabled', async () => {
const popconfirm = mount(
{
render() {
return (
<Popconfirm ref="popconfirm" title="code" disabled>
<span>click me</span>
</Popconfirm>
);
},
},
{ sync: false },
);
await asyncExpect(() => {
popconfirm.find('span').trigger('click');
}, 1000);
await asyncExpect(() => {
const popup = popconfirm.vm.$refs.popconfirm.getPopupDomNode();
expect(popup).toBeFalsy();
}, 1000);
});
});

View File

@ -1,12 +1,13 @@
## API
| Param | Description | Type | Default value |
| --- | --- | --- | --- |
| cancelText | text of the Cancel button | string\|slot | `Cancel` |
| okText | text of the Confirm button | string\|slot | `Confirm` |
| okType | Button `type` of the Confirm button | string | `primary` |
| title | title of the confirmation box | string\|slot | - |
| icon | customize icon of confirmation | vNode\|slot | &lt;Icon type="exclamation-circle" /&gt; |
| Param | Description | Type | Default value | Version |
| --- | --- | --- | --- | --- |
| cancelText | text of the Cancel button | string\|slot | `Cancel` | |
| okText | text of the Confirm button | string\|slot | `Confirm` | |
| okType | Button `type` of the Confirm button | string | `primary` | |
| title | title of the confirmation box | string\|slot | - | |
| icon | customize icon of confirmation | vNode\|slot | &lt;Icon type="exclamation-circle" /&gt; | |
| disabled | is show popconfirm when click its childrenNode | boolean | false | 1.5.0 |
### events

View File

@ -24,6 +24,7 @@ const Popconfirm = {
title: PropTypes.any,
trigger: tooltipProps.trigger.def('click'),
okType: btnProps.type.def('primary'),
disabled: PropTypes.bool.def(false),
okText: PropTypes.any,
cancelText: PropTypes.any,
icon: PropTypes.any,
@ -48,7 +49,8 @@ const Popconfirm = {
const state = { sVisible: false };
if ('visible' in props) {
state.sVisible = props.visible;
} else if ('defaultVisible' in props) {
}
if ('defaultVisible' in props) {
state.sVisible = props.defaultVisible;
}
return state;
@ -65,6 +67,10 @@ const Popconfirm = {
},
onVisibleChange(sVisible) {
const { disabled } = this.$props;
if (disabled) {
return;
}
this.setVisible(sVisible);
},

View File

@ -1,12 +1,13 @@
## API
| 参数 | 说明 | 类型 | 默认值 |
| ---------- | ------------------------ | ------------ | ---------------------------------------- |
| cancelText | 取消按钮文字 | string\|slot | 取消 |
| okText | 确认按钮文字 | string\|slot | 确定 |
| okType | 确认按钮类型 | string | primary |
| title | 确认框的描述 | string\|slot | 无 |
| icon | 自定义弹出气泡 Icon 图标 | vNode | &lt;Icon type="exclamation-circle" /&gt; |
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| cancelText | 取消按钮文字 | string\|slot | 取消 | |
| okText | 确认按钮文字 | string\|slot | 确定 | |
| okType | 确认按钮类型 | string | primary | |
| title | 确认框的描述 | string\|slot | 无 | |
| icon | 自定义弹出气泡 Icon 图标 | vNode | &lt;Icon type="exclamation-circle" /&gt; | |
| disabled | 点击 Popconfirm 子元素是否弹出气泡确认框 | boolean | false | 1.5.0 |
### 事件

View File

@ -38,4 +38,6 @@ export declare class Popconfirm extends TooltipCommon {
* @type any (VNode | slot)
*/
icon: any;
disabled: boolean;
}