diff --git a/components/_util/BaseMixin.js b/components/_util/BaseMixin.js new file mode 100644 index 000000000..66d6bfa94 --- /dev/null +++ b/components/_util/BaseMixin.js @@ -0,0 +1,16 @@ +export default { + methods: { + setState (state, callback) { + Object.assign(this.$data, state) + this.$nextTick(() => { + callback && callback() + }) + }, + __emit () { // 直接调用listeners,底层组件不需要vueTool记录events + const args = [].slice.call(arguments, 0) + if (args.length && this.$listeners[args[0]]) { + this.$listeners[args[0]](...args.slice(1)) + } + }, + }, +} diff --git a/components/_util/cloneElement.js b/components/_util/cloneElement.js deleted file mode 100644 index ec8b55c1f..000000000 --- a/components/_util/cloneElement.js +++ /dev/null @@ -1,8 +0,0 @@ -export default (node, nodeProps) => { - const { props, style, class: cls, attrs, key } = nodeProps - if (node.componentOptions) { - const propsData = node.componentOptions.propsData - Object.assign(propsData, nodeProps) - } - return node -} diff --git a/components/_util/props-util.js b/components/_util/props-util.js new file mode 100644 index 000000000..68e8f97b2 --- /dev/null +++ b/components/_util/props-util.js @@ -0,0 +1,30 @@ +const hasProp = (instance, prop) => { + const $options = instance.$options || {} + const propsData = $options.propsData || {} + return prop in propsData +} +const filterProps = (props, propsData = {}) => { + const res = {} + Object.keys(props).forEach((k) => { + if (k in propsData || props[k] !== undefined) { + res[k] = props[k] + } + }) + return res +} + +const getOptionProps = (instance) => { + const { $options = {}, $props = {}} = instance + return filterProps($props, $options.propsData) +} + +const getComponentFromProp = (instance, h, prop) => { + const temp = instance[prop] + if (temp !== undefined) { + return typeof temp === 'function' ? temp(h) : temp + } + return instance.$slots[prop] +} + +export { hasProp, filterProps, getOptionProps, getComponentFromProp } +export default hasProp diff --git a/components/_util/vnode.js b/components/_util/vnode.js index e3225d29a..ecf245b82 100644 --- a/components/_util/vnode.js +++ b/components/_util/vnode.js @@ -78,11 +78,30 @@ export function cloneElement (n, nodeProps, clone) { const { style = data.style, class: cls = data.class, attrs = data.attrs, + ref, } = nodeProps node.data = Object.assign(data, { style, attrs, class: cls, on: { ...(data.on || {}), ...on }}) if (key !== undefined) { node.key = key node.data.key = key } + if (typeof ref === 'string') { + node.data.ref = ref + } return node } +export function getComponentName (opts) { + return opts && (opts.Ctor.options.name || opts.tag) +} + +export function isValidElement (ele) { + return !!ele.tag +} + +export function getClass (ele) { + return ele.data && (ele.data.class || ele.data.staticClass) +} + +export function getStyle (ele) { + return ele.data && (ele.data.style || ele.data.staticStyle) +} diff --git a/components/align/Align.vue b/components/align/Align.vue index 36f1d9e6a..f4cdf0bb1 100644 --- a/components/align/Align.vue +++ b/components/align/Align.vue @@ -102,7 +102,8 @@ export default { const props = this.$props if (!props.disabled) { const source = this.$el - this.$emit('align', source, align(source, props.target(), props.align)) + // this.$emit('align', source, align(source, props.target(), props.align)) + this.$listeners.align && this.$listeners.align(source, align(source, props.target(), props.align)) } }, }, diff --git a/components/align/demo/simple.vue b/components/align/demo/simple.vue index 84b11f40f..7c5c991e2 100644 --- a/components/align/demo/simple.vue +++ b/components/align/demo/simple.vue @@ -1,9 +1,9 @@ diff --git a/components/popconfirm/index.vue b/components/popconfirm/index.vue new file mode 100644 index 000000000..9807ce386 --- /dev/null +++ b/components/popconfirm/index.vue @@ -0,0 +1,118 @@ + diff --git a/components/popconfirm/index.zh-CN.md b/components/popconfirm/index.zh-CN.md new file mode 100644 index 000000000..9442b1fac --- /dev/null +++ b/components/popconfirm/index.zh-CN.md @@ -0,0 +1,34 @@ +--- +category: Components +subtitle: 气泡确认框 +type: Feedback +title: Popconfirm +--- + +点击元素,弹出气泡式的确认框。 + +## 何时使用 + +目标元素的操作需要用户进一步的确认时,在目标元素附近弹出浮层提示,询问用户。 + +和 `confirm` 弹出的全屏居中模态对话框相比,交互形式更轻量。 + +## API + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| cancelText | 取消按钮文字 | string\|function\|slot | 取消 | +| okText | 确认按钮文字 | string\|function\|slot | 确定 | +| okType | 确认按钮类型 | string | primary | +| title | 确认框的描述 | string\|function\|slot | 无 | + +### 事件 +| 事件名称 | 说明 | 回调参数 | +| cancel | 点击取消时触发 | (e) | +| confirm | 点击确认时触发 | (e) | + +更多属性请参考 [Tooltip](/components/tooltip/#API)。 + +## 注意 + +请确保 `Popconfirm` 的子元素能接受 `mouseenter`、`mouseleave`、`focus`、`click` 事件。 diff --git a/components/popconfirm/style/index.js b/components/popconfirm/style/index.js new file mode 100644 index 000000000..a177f207f --- /dev/null +++ b/components/popconfirm/style/index.js @@ -0,0 +1,5 @@ +import '../../style/index.less' + +// style dependencies +import '../../popover/style' +import '../../button/style' diff --git a/components/popover/demo/arrow-point-at-center.vue b/components/popover/demo/arrow-point-at-center.vue new file mode 100644 index 000000000..096f076f5 --- /dev/null +++ b/components/popover/demo/arrow-point-at-center.vue @@ -0,0 +1,42 @@ + + + diff --git a/components/popover/demo/basic.vue b/components/popover/demo/basic.vue new file mode 100644 index 000000000..20cb76fd3 --- /dev/null +++ b/components/popover/demo/basic.vue @@ -0,0 +1,27 @@ + + + diff --git a/components/popover/demo/control.vue b/components/popover/demo/control.vue new file mode 100644 index 000000000..8d8fa9b47 --- /dev/null +++ b/components/popover/demo/control.vue @@ -0,0 +1,39 @@ + + + diff --git a/components/popover/demo/index.vue b/components/popover/demo/index.vue new file mode 100644 index 000000000..d6c50e639 --- /dev/null +++ b/components/popover/demo/index.vue @@ -0,0 +1,30 @@ + + diff --git a/components/popover/demo/placement.vue b/components/popover/demo/placement.vue new file mode 100644 index 000000000..2c80b16c6 --- /dev/null +++ b/components/popover/demo/placement.vue @@ -0,0 +1,184 @@ + + + + diff --git a/components/popover/demo/triggerType.vue b/components/popover/demo/triggerType.vue new file mode 100644 index 000000000..bbf14fb98 --- /dev/null +++ b/components/popover/demo/triggerType.vue @@ -0,0 +1,45 @@ + + + diff --git a/components/popover/index.vue b/components/popover/index.vue new file mode 100644 index 000000000..1089d6f0f --- /dev/null +++ b/components/popover/index.vue @@ -0,0 +1,60 @@ + diff --git a/components/popover/index.zh-CN.md b/components/popover/index.zh-CN.md new file mode 100644 index 000000000..986b670c5 --- /dev/null +++ b/components/popover/index.zh-CN.md @@ -0,0 +1,27 @@ +--- +category: Components +subtitle: 气泡卡片 +type: Data Display +title: Popover +--- + +点击/鼠标移入元素,弹出气泡式的卡片浮层。 + +## 何时使用 + +当目标元素有进一步的描述和相关操作时,可以收纳到卡片中,根据用户的操作行为进行展现。 + +和 `Tooltip` 的区别是,用户可以对浮层上的元素进行操作,因此它可以承载更复杂的内容,比如链接或按钮等。 + +## API + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| content | 卡片内容 | string\|function\|slot | 无 | +| title | 卡片标题 | string\|function\|slot | 无 | + +更多属性请参考 [Tooltip](/components/tooltip/#API)。 + +## 注意 + +请确保 `Popover` 的子元素能接受 `mouseenter`、`mouseleave`、`focus`、`click` 事件。 diff --git a/components/popover/style/index.js b/components/popover/style/index.js new file mode 100644 index 000000000..cf31ed80f --- /dev/null +++ b/components/popover/style/index.js @@ -0,0 +1,2 @@ +import '../../style/index.less' +import './index.less' diff --git a/components/popover/style/index.less b/components/popover/style/index.less new file mode 100644 index 000000000..227d2bc5a --- /dev/null +++ b/components/popover/style/index.less @@ -0,0 +1,221 @@ +@import "../../style/themes/default"; +@import "../../style/mixins/index"; + +@popover-prefix-cls: ~"@{ant-prefix}-popover"; + +.@{popover-prefix-cls} { + position: absolute; + top: 0; + left: 0; + z-index: @zindex-popover; + cursor: auto; + user-select: text; + white-space: normal; + font-size: @font-size-base; + line-height: @line-height-base; + font-weight: normal; + text-align: left; + + &:after { + content: ""; + position: absolute; + background: rgba(255, 255, 255, 0.01); + } + + &-hidden { + display: none; + } + + // Offset the popover to account for the popover arrow + &-placement-top, + &-placement-topLeft, + &-placement-topRight { + padding-bottom: @popover-distance; + } + + &-placement-right, + &-placement-rightTop, + &-placement-rightBottom { + padding-left: @popover-distance; + } + + &-placement-bottom, + &-placement-bottomLeft, + &-placement-bottomRight { + padding-top: @popover-distance; + } + + &-placement-left, + &-placement-leftTop, + &-placement-leftBottom { + padding-right: @popover-distance; + } + + &-inner { + background-color: @popover-bg; + background-clip: padding-box; + border-radius: @border-radius-base; + box-shadow: @box-shadow-base; + } + + &-title { + min-width: @popover-min-width; + margin: 0; // reset heading margin + padding: 8px 16px; + min-height: 32px; + border-bottom: 1px solid @border-color-split; + color: @popover-color; + font-weight: 500; + } + + &-inner-content { + padding: 8px 16px; + color: @popover-color; + } + + &-message { + padding: 8px 0 16px; + font-size: @font-size-base; + color: @popover-color; + > .@{iconfont-css-prefix} { + color: @warning-color; + line-height: 17px; + position: absolute; + } + &-title { + padding-left: 20px; + } + } + + &-buttons { + text-align: right; + margin-bottom: 8px; + button { + margin-left: 8px; + } + } + + // Arrows + // .popover-arrow is outer, .popover-arrow:after is inner + + &-arrow { + &, + &:after { + position: absolute; + display: block; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + } + } + + &-arrow { + border-width: @popover-arrow-outer-width; + } + + &-arrow:after { + border-width: @popover-arrow-width; + content: ""; + } + + &-placement-top > &-content > &-arrow, + &-placement-topLeft > &-content > &-arrow, + &-placement-topRight > &-content > &-arrow { + border-bottom-width: 0; + border-top-color: @popover-arrow-outer-color; + bottom: @popover-distance - @popover-arrow-outer-width; + &:after { + content: " "; + bottom: 1px; + margin-left: -@popover-arrow-width; + border-bottom-width: 0; + border-top-color: @popover-arrow-color; + } + } + &-placement-top > &-content > &-arrow { + left: 50%; + margin-left: -@popover-arrow-outer-width; + } + &-placement-topLeft > &-content > &-arrow { + left: 16px; + } + &-placement-topRight > &-content > &-arrow { + right: 16px; + } + + &-placement-right > &-content > &-arrow, + &-placement-rightTop > &-content > &-arrow, + &-placement-rightBottom > &-content > &-arrow { + left: @popover-distance - @popover-arrow-outer-width; + border-left-width: 0; + border-right-color: @popover-arrow-outer-color; + &:after { + content: " "; + left: 1px; + bottom: -@popover-arrow-width; + border-left-width: 0; + border-right-color: @popover-arrow-color; + } + } + &-placement-right > &-content > &-arrow { + top: 50%; + margin-top: -@popover-arrow-outer-width; + } + &-placement-rightTop > &-content > &-arrow { + top: 12px; + } + &-placement-rightBottom > &-content > &-arrow { + bottom: 12px; + } + + &-placement-bottom > &-content > &-arrow, + &-placement-bottomLeft > &-content > &-arrow, + &-placement-bottomRight > &-content > &-arrow { + border-top-width: 0; + border-bottom-color: @popover-arrow-outer-color; + top: @popover-distance - @popover-arrow-outer-width; + &:after { + content: " "; + top: 1px; + margin-left: -@popover-arrow-width; + border-top-width: 0; + border-bottom-color: @popover-arrow-color; + } + } + &-placement-bottom > &-content > &-arrow { + left: 50%; + margin-left: -@popover-arrow-outer-width; + } + &-placement-bottomLeft > &-content > &-arrow { + left: 16px; + } + &-placement-bottomRight > &-content > &-arrow { + right: 16px; + } + + &-placement-left > &-content > &-arrow, + &-placement-leftTop > &-content > &-arrow, + &-placement-leftBottom > &-content > &-arrow { + right: @popover-distance - @popover-arrow-outer-width; + border-right-width: 0; + border-left-color: @popover-arrow-outer-color; + &:after { + content: " "; + right: 1px; + border-right-width: 0; + border-left-color: @popover-arrow-color; + bottom: -@popover-arrow-width; + } + } + &-placement-left > &-content > &-arrow { + top: 50%; + margin-top: -@popover-arrow-outer-width; + } + &-placement-leftTop > &-content > &-arrow { + top: 12px; + } + &-placement-leftBottom > &-content > &-arrow { + bottom: 12px; + } +} diff --git a/components/radio/Radio.vue b/components/radio/Radio.vue index 60e4b6bfe..616f3c765 100644 --- a/components/radio/Radio.vue +++ b/components/radio/Radio.vue @@ -13,7 +13,7 @@ diff --git a/components/tooltip/demo/auto-adjust-overflow.vue b/components/tooltip/demo/auto-adjust-overflow.vue new file mode 100644 index 000000000..585815999 --- /dev/null +++ b/components/tooltip/demo/auto-adjust-overflow.vue @@ -0,0 +1,43 @@ + + + diff --git a/components/tooltip/demo/basic.vue b/components/tooltip/demo/basic.vue new file mode 100644 index 000000000..b60af9327 --- /dev/null +++ b/components/tooltip/demo/basic.vue @@ -0,0 +1,23 @@ + + + diff --git a/components/tooltip/demo/index.vue b/components/tooltip/demo/index.vue index 178db3bff..b8c54ed5b 100644 --- a/components/tooltip/demo/index.vue +++ b/components/tooltip/demo/index.vue @@ -1,97 +1,26 @@ - - diff --git a/components/tooltip/demo/placement.vue b/components/tooltip/demo/placement.vue new file mode 100644 index 000000000..36aec0438 --- /dev/null +++ b/components/tooltip/demo/placement.vue @@ -0,0 +1,112 @@ + + + + diff --git a/components/tooltip/index.js b/components/tooltip/index.js index b93dd566a..4b5f7d8bc 100644 --- a/components/tooltip/index.js +++ b/components/tooltip/index.js @@ -1,4 +1,3 @@ import ToolTip from './tooltip.vue' -import './style' export default ToolTip diff --git a/components/tooltip/index.zh-CN.md b/components/tooltip/index.zh-CN.md new file mode 100644 index 000000000..9cecf0f03 --- /dev/null +++ b/components/tooltip/index.zh-CN.md @@ -0,0 +1,45 @@ +--- +category: Components +subtitle: 文字提示 +type: Data Display +title: Tooltip +--- + +简单的文字提示气泡框。 + +## 何时使用 + +鼠标移入则显示提示,移出消失,气泡浮层不承载复杂文本和操作。 + +可用来代替系统默认的 `title` 提示,提供一个`按钮/文字/操作`的文案解释。 + +## API + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| title | 提示文字 | `string` `function` `slot` | 无 | + +### 共同的 API + +以下 API 为 Tooltip、Popconfirm、Popover 共享的 API。 + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| arrowPointAtCenter | 箭头是否指向目标元素中 | boolean | `false` | +| autoAdjustOverflow | 气泡被遮挡时自动调整位置 | boolean | `true` | +| getPopupContainer | 浮层渲染父节点,默认渲染到 body 上 | Function(triggerNode) | () => document.body | +| mouseEnterDelay | 鼠标移入后延时多少才显示 Tooltip,单位:秒 | number | 0 | +| mouseLeaveDelay | 鼠标移出后延时多少才隐藏 Tooltip,单位:秒 | number | 0.1 | +| overlayClassName | 卡片类名 | string | 无 | +| overlayStyle | 卡片样式 | object | 无 | +| placement | 气泡框位置,可选 `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom` | string | top | +| trigger | 触发行为,可选 `hover/focus/click` | string | hover | +| visible(v-model) | 用于手动控制浮层显隐 | boolean | false | + +### 事件 +| 事件名称 | 说明 | 回调参数 | +| visibleChange | 显示隐藏变换时触发 | (visible) | + +## 注意 + +请确保 `Tooltip` 的子元素能接受 `mouseenter`、`mouseleave`、`focus`、`click` 事件。 diff --git a/components/tooltip/placements.js b/components/tooltip/placements.js new file mode 100644 index 000000000..f3b6bd8e8 --- /dev/null +++ b/components/tooltip/placements.js @@ -0,0 +1,88 @@ +import { placements as rcPlacements } from './src/placements' + +const autoAdjustOverflowEnabled = { + adjustX: 1, + adjustY: 1, +} + +const autoAdjustOverflowDisabled = { + adjustX: 0, + adjustY: 0, +} + +const targetOffset = [0, 0] + +export function getOverflowOptions (autoAdjustOverflow) { + if (typeof autoAdjustOverflow === 'boolean') { + return autoAdjustOverflow ? autoAdjustOverflowEnabled : autoAdjustOverflowDisabled + } + return { + ...autoAdjustOverflowDisabled, + ...autoAdjustOverflow, + } +} + +export default function getPlacements (config) { + const { arrowWidth = 5, horizontalArrowShift = 16, verticalArrowShift = 12, autoAdjustOverflow = true } = config + const placementMap = { + left: { + points: ['cr', 'cl'], + offset: [-4, 0], + }, + right: { + points: ['cl', 'cr'], + offset: [4, 0], + }, + top: { + points: ['bc', 'tc'], + offset: [0, -4], + }, + bottom: { + points: ['tc', 'bc'], + offset: [0, 4], + }, + topLeft: { + points: ['bl', 'tc'], + offset: [-(horizontalArrowShift + arrowWidth), -4], + }, + leftTop: { + points: ['tr', 'cl'], + offset: [-4, -(verticalArrowShift + arrowWidth)], + }, + topRight: { + points: ['br', 'tc'], + offset: [horizontalArrowShift + arrowWidth, -4], + }, + rightTop: { + points: ['tl', 'cr'], + offset: [4, -(verticalArrowShift + arrowWidth)], + }, + bottomRight: { + points: ['tr', 'bc'], + offset: [horizontalArrowShift + arrowWidth, 4], + }, + rightBottom: { + points: ['bl', 'cr'], + offset: [4, verticalArrowShift + arrowWidth], + }, + bottomLeft: { + points: ['tl', 'bc'], + offset: [-(horizontalArrowShift + arrowWidth), 4], + }, + leftBottom: { + points: ['br', 'cl'], + offset: [-4, verticalArrowShift + arrowWidth], + }, + } + Object.keys(placementMap).forEach(key => { + placementMap[key] = config.arrowPointAtCenter ? { + ...placementMap[key], + overflow: getOverflowOptions(autoAdjustOverflow), + targetOffset, + } : { + ...rcPlacements[key], + overflow: getOverflowOptions(autoAdjustOverflow), + } + }) + return placementMap +} diff --git a/components/tooltip/src/Tooltip.vue b/components/tooltip/src/Tooltip.vue new file mode 100644 index 000000000..67577d786 --- /dev/null +++ b/components/tooltip/src/Tooltip.vue @@ -0,0 +1,101 @@ + diff --git a/components/tooltip/src/index.js b/components/tooltip/src/index.js new file mode 100644 index 000000000..331785904 --- /dev/null +++ b/components/tooltip/src/index.js @@ -0,0 +1,3 @@ +import Tooltip from './Tooltip' + +export default Tooltip diff --git a/components/tooltip/src/placements.js b/components/tooltip/src/placements.js new file mode 100644 index 000000000..80917822e --- /dev/null +++ b/components/tooltip/src/placements.js @@ -0,0 +1,83 @@ +const autoAdjustOverflow = { + adjustX: 1, + adjustY: 1, +} + +const targetOffset = [0, 0] + +export const placements = { + left: { + points: ['cr', 'cl'], + overflow: autoAdjustOverflow, + offset: [-4, 0], + targetOffset, + }, + right: { + points: ['cl', 'cr'], + overflow: autoAdjustOverflow, + offset: [4, 0], + targetOffset, + }, + top: { + points: ['bc', 'tc'], + overflow: autoAdjustOverflow, + offset: [0, -4], + targetOffset, + }, + bottom: { + points: ['tc', 'bc'], + overflow: autoAdjustOverflow, + offset: [0, 4], + targetOffset, + }, + topLeft: { + points: ['bl', 'tl'], + overflow: autoAdjustOverflow, + offset: [0, -4], + targetOffset, + }, + leftTop: { + points: ['tr', 'tl'], + overflow: autoAdjustOverflow, + offset: [-4, 0], + targetOffset, + }, + topRight: { + points: ['br', 'tr'], + overflow: autoAdjustOverflow, + offset: [0, -4], + targetOffset, + }, + rightTop: { + points: ['tl', 'tr'], + overflow: autoAdjustOverflow, + offset: [4, 0], + targetOffset, + }, + bottomRight: { + points: ['tr', 'br'], + overflow: autoAdjustOverflow, + offset: [0, 4], + targetOffset, + }, + rightBottom: { + points: ['bl', 'br'], + overflow: autoAdjustOverflow, + offset: [4, 0], + targetOffset, + }, + bottomLeft: { + points: ['tl', 'bl'], + overflow: autoAdjustOverflow, + offset: [0, 4], + targetOffset, + }, + leftBottom: { + points: ['br', 'bl'], + overflow: autoAdjustOverflow, + offset: [-4, 0], + targetOffset, + }, +} + +export default placements diff --git a/components/tooltip/tooltip.vue b/components/tooltip/tooltip.vue index 97065950d..c66fd4730 100644 --- a/components/tooltip/tooltip.vue +++ b/components/tooltip/tooltip.vue @@ -1,121 +1,127 @@ diff --git a/components/trigger/Popup.vue b/components/trigger/Popup.vue index 1e68745ad..4587ad612 100644 --- a/components/trigger/Popup.vue +++ b/components/trigger/Popup.vue @@ -3,6 +3,7 @@ import PropTypes from '../_util/vue-types' import Align from '../align' import PopupInner from './PopupInner' import LazyRenderBox from './LazyRenderBox' +import { noop } from './utils' export default { props: { @@ -56,13 +57,11 @@ export default { onAlign (popupDomNode, align) { const props = this.$props const currentAlignClassName = props.getClassNameFromAlign(align) - // FIX: https://github.com/react-component/trigger/issues/56 - // FIX: https://github.com/react-component/tooltip/issues/79 if (this.currentAlignClassName !== currentAlignClassName) { + popupDomNode.className = popupDomNode.className.replace(this.currentAlignClassName, currentAlignClassName) this.currentAlignClassName = currentAlignClassName - popupDomNode.className = this.getClassName(currentAlignClassName) } - this.$emit('align', popupDomNode, align) + this.$listeners.align && this.$listeners.align(popupDomNode, align) }, getPopupDomNode () { @@ -95,30 +94,17 @@ export default { getClassName (currentAlignClassName) { return `${this.$props.prefixCls} ${this.$props.popupClassName} ${currentAlignClassName}` }, - onMouseEnter (e) { - this.$emit('mouseenter', e) - }, - onMouseLeave (e) { - this.$emit('mouseleave', e) - }, - beforeEnter (el) { - try { - // this.$refs.alignInstance && this.$refs.alignInstance.forceAlign() - } catch (error) { - - } - this.$refs.alignInstance && this.$refs.alignInstance.forceAlign() - }, afterLeave (el) { if (this.destroyPopupOnHide) { this.destroyPopup = true } }, getPopupElement () { - const { $props: props, onMouseEnter, onMouseLeave, $slots } = this + const { $props: props, $slots, $listeners } = this const { align, visible, prefixCls, animation } = props - const className = this.getClassName(this.currentAlignClassName || - props.getClassNameFromAlign(align)) + const { mouseenter, mouseleave } = $listeners + this.currentAlignClassName = this.currentAlignClassName || props.getClassNameFromAlign(align) + const className = this.getClassName(this.currentAlignClassName) // const hiddenClassName = `${prefixCls}-hidden` if (!visible) { this.currentAlignClassName = null @@ -131,8 +117,8 @@ export default { }, class: `${className}`, on: { - mouseenter: onMouseEnter, - mouseleave: onMouseLeave, + mouseenter: mouseenter || noop, + mouseleave: mouseleave || noop, }, ref: 'popupInstance', style: { ...this.getZIndexStyle() }, @@ -144,7 +130,6 @@ export default { } return ( +
{this.$slots.default} diff --git a/components/trigger/index.md b/components/trigger/index.md index 6887d36f5..69f9cb643 100644 --- a/components/trigger/index.md +++ b/components/trigger/index.md @@ -140,13 +140,13 @@ popupVisibleChange - $emit(visible) + $emit call when popup visible is changed popupAlign - $emit(popupDomNode, align) + $emit callback when popup node is aligned diff --git a/components/trigger/index.vue b/components/trigger/index.vue index 4c08b339e..e65c0bc27 100644 --- a/components/trigger/index.vue +++ b/components/trigger/index.vue @@ -1,12 +1,12 @@