feat: popconfirm add disabled support
parent
2200cf0a03
commit
e7d935cfac
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
dev: {
|
dev: {
|
||||||
componentName: 'pagination', // dev components
|
componentName: 'popconfirm', // dev components
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,4 +72,27 @@ describe('Popconfirm', () => {
|
||||||
expect(popup.innerHTML).toMatchSnapshot();
|
expect(popup.innerHTML).toMatchSnapshot();
|
||||||
}, 1000);
|
}, 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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
## API
|
## API
|
||||||
|
|
||||||
| Param | Description | Type | Default value |
|
| Param | Description | Type | Default value | Version |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| cancelText | text of the Cancel button | string\|slot | `Cancel` |
|
| cancelText | text of the Cancel button | string\|slot | `Cancel` | |
|
||||||
| okText | text of the Confirm button | string\|slot | `Confirm` |
|
| okText | text of the Confirm button | string\|slot | `Confirm` | |
|
||||||
| okType | Button `type` of the Confirm button | string | `primary` |
|
| okType | Button `type` of the Confirm button | string | `primary` | |
|
||||||
| title | title of the confirmation box | string\|slot | - |
|
| title | title of the confirmation box | string\|slot | - | |
|
||||||
| icon | customize icon of confirmation | vNode\|slot | <Icon type="exclamation-circle" /> |
|
| icon | customize icon of confirmation | vNode\|slot | <Icon type="exclamation-circle" /> | |
|
||||||
|
| disabled | is show popconfirm when click its childrenNode | boolean | false | 1.5.0 |
|
||||||
|
|
||||||
### events
|
### events
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ const Popconfirm = {
|
||||||
title: PropTypes.any,
|
title: PropTypes.any,
|
||||||
trigger: tooltipProps.trigger.def('click'),
|
trigger: tooltipProps.trigger.def('click'),
|
||||||
okType: btnProps.type.def('primary'),
|
okType: btnProps.type.def('primary'),
|
||||||
|
disabled: PropTypes.bool.def(false),
|
||||||
okText: PropTypes.any,
|
okText: PropTypes.any,
|
||||||
cancelText: PropTypes.any,
|
cancelText: PropTypes.any,
|
||||||
icon: PropTypes.any,
|
icon: PropTypes.any,
|
||||||
|
@ -48,7 +49,8 @@ const Popconfirm = {
|
||||||
const state = { sVisible: false };
|
const state = { sVisible: false };
|
||||||
if ('visible' in props) {
|
if ('visible' in props) {
|
||||||
state.sVisible = props.visible;
|
state.sVisible = props.visible;
|
||||||
} else if ('defaultVisible' in props) {
|
}
|
||||||
|
if ('defaultVisible' in props) {
|
||||||
state.sVisible = props.defaultVisible;
|
state.sVisible = props.defaultVisible;
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
@ -65,6 +67,10 @@ const Popconfirm = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onVisibleChange(sVisible) {
|
onVisibleChange(sVisible) {
|
||||||
|
const { disabled } = this.$props;
|
||||||
|
if (disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setVisible(sVisible);
|
this.setVisible(sVisible);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
## API
|
## API
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
| ---------- | ------------------------ | ------------ | ---------------------------------------- |
|
| --- | --- | --- | --- | --- |
|
||||||
| cancelText | 取消按钮文字 | string\|slot | 取消 |
|
| cancelText | 取消按钮文字 | string\|slot | 取消 | |
|
||||||
| okText | 确认按钮文字 | string\|slot | 确定 |
|
| okText | 确认按钮文字 | string\|slot | 确定 | |
|
||||||
| okType | 确认按钮类型 | string | primary |
|
| okType | 确认按钮类型 | string | primary | |
|
||||||
| title | 确认框的描述 | string\|slot | 无 |
|
| title | 确认框的描述 | string\|slot | 无 | |
|
||||||
| icon | 自定义弹出气泡 Icon 图标 | vNode | <Icon type="exclamation-circle" /> |
|
| icon | 自定义弹出气泡 Icon 图标 | vNode | <Icon type="exclamation-circle" /> | |
|
||||||
|
| disabled | 点击 Popconfirm 子元素是否弹出气泡确认框 | boolean | false | 1.5.0 |
|
||||||
|
|
||||||
### 事件
|
### 事件
|
||||||
|
|
||||||
|
|
|
@ -38,4 +38,6 @@ export declare class Popconfirm extends TooltipCommon {
|
||||||
* @type any (VNode | slot)
|
* @type any (VNode | slot)
|
||||||
*/
|
*/
|
||||||
icon: any;
|
icon: any;
|
||||||
|
|
||||||
|
disabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue