feat: update tooltip
parent
05658b7165
commit
ab8768b19b
|
@ -1,5 +1,5 @@
|
|||
module.exports = {
|
||||
dev: {
|
||||
componentName: 'tag', // dev components
|
||||
componentName: 'tooltip', // dev components
|
||||
},
|
||||
};
|
||||
|
|
|
@ -78,9 +78,12 @@ export default {
|
|||
// mouse events don't trigger at disabled button in Chrome
|
||||
// https://github.com/react-component/tooltip/issues/18
|
||||
getDisabledCompatibleChildren(ele) {
|
||||
const isAntBtn = ele.componentOptions && ele.componentOptions.Ctor.options.__ANT_BUTTON;
|
||||
const options = (ele.componentOptions && ele.componentOptions.Ctor.options) || {};
|
||||
|
||||
if (
|
||||
(isAntBtn &&
|
||||
((options.__ANT_BUTTON === true ||
|
||||
options.__ANT_SWITCH === true ||
|
||||
options.__ANT_CHECKBOX === true) &&
|
||||
(ele.componentOptions.propsData.disabled ||
|
||||
ele.componentOptions.propsData.disabled === '')) ||
|
||||
(ele.tag === 'button' &&
|
||||
|
@ -125,8 +128,16 @@ export default {
|
|||
},
|
||||
|
||||
isNoTitle() {
|
||||
const { $slots, title } = this;
|
||||
return !$slots.title && !title;
|
||||
const title = getComponentFromProp(this, 'title');
|
||||
return !title && title !== 0;
|
||||
},
|
||||
|
||||
getOverlay() {
|
||||
const title = getComponentFromProp(this, 'title');
|
||||
if (title === 0) {
|
||||
return title;
|
||||
}
|
||||
return title || '';
|
||||
},
|
||||
|
||||
// 动态设置动画点
|
||||
|
@ -189,6 +200,7 @@ export default {
|
|||
prefixCls,
|
||||
getTooltipContainer: getPopupContainer || getContextPopupContainer,
|
||||
builtinPlacements: this.getPlacements(),
|
||||
overlay: this.getOverlay(),
|
||||
visible: sVisible,
|
||||
},
|
||||
ref: 'tooltip',
|
||||
|
@ -200,7 +212,6 @@ export default {
|
|||
};
|
||||
return (
|
||||
<VcTooltip {...tooltipProps}>
|
||||
<template slot="overlay">{getComponentFromProp(this, 'title')}</template>
|
||||
{sVisible ? cloneElement(child, { class: childCls }) : child}
|
||||
</VcTooltip>
|
||||
);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { asyncExpect } from '@/tests/utils';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import Tooltip from '..';
|
||||
import mountTest from '../../../tests/shared/mountTest';
|
||||
|
||||
describe('Tooltip', () => {
|
||||
mountTest(Tooltip);
|
||||
it('check `onVisibleChange` arguments', async () => {
|
||||
const onVisibleChange = jest.fn();
|
||||
const wrapper = mount(
|
||||
|
|
|
@ -37,15 +37,12 @@ export default {
|
|||
return (
|
||||
<div>
|
||||
<md cn={md.cn} us={md.us} />
|
||||
<br />
|
||||
<Basic />
|
||||
<br />
|
||||
<Placement />
|
||||
<br />
|
||||
<ArrowPointAtCenter />
|
||||
<br />
|
||||
<AutoAdjustOverflow />
|
||||
<br />
|
||||
<demo-sort cols="2">
|
||||
<Basic />
|
||||
<Placement />
|
||||
<ArrowPointAtCenter />
|
||||
<AutoAdjustOverflow />
|
||||
</demo-sort>
|
||||
<api>
|
||||
<template slot="cn">
|
||||
<CN />
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<us>
|
||||
#### Placement
|
||||
The ToolTip has 12 placements choice.
|
||||
There are 12 placement options available.
|
||||
</us>
|
||||
|
||||
```tpl
|
||||
|
|
|
@ -11,7 +11,7 @@ export default {
|
|||
props: {
|
||||
cols: {
|
||||
type: [Number, String],
|
||||
default: 1,
|
||||
default: 2,
|
||||
},
|
||||
},
|
||||
inject: {
|
||||
|
|
Loading…
Reference in New Issue