From 2c164770b6ac4cc9c8a9741042ac694e31cffc54 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Tue, 9 Jan 2018 14:21:15 +0800 Subject: [PATCH 1/7] add keydown --- components/_util/cloneElement.js | 8 ---- components/_util/vnode.js | 7 ++++ components/menu/demo/antd.vue | 12 +++--- components/menu/src/DOMWrap.vue | 1 + components/menu/src/Menu.vue | 2 +- components/menu/src/MenuItem.vue | 1 + components/menu/src/MenuMixin.js | 65 +++++++------------------------- components/menu/src/SubMenu.vue | 3 +- components/trigger/index.vue | 1 - package.json | 4 +- 10 files changed, 33 insertions(+), 71 deletions(-) delete mode 100644 components/_util/cloneElement.js 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/vnode.js b/components/_util/vnode.js index e3225d29a..8068ea46f 100644 --- a/components/_util/vnode.js +++ b/components/_util/vnode.js @@ -78,11 +78,18 @@ 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) +} diff --git a/components/menu/demo/antd.vue b/components/menu/demo/antd.vue index 841b2cfe4..e1083b02e 100644 --- a/components/menu/demo/antd.vue +++ b/components/menu/demo/antd.vue @@ -1,8 +1,6 @@ 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/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..5d13ae671 --- /dev/null +++ b/components/tooltip/src/Tooltip.vue @@ -0,0 +1,108 @@ + 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..6c19912d2 100644 --- a/components/tooltip/tooltip.vue +++ b/components/tooltip/tooltip.vue @@ -1,121 +1,137 @@ diff --git a/components/trigger/Popup.vue b/components/trigger/Popup.vue index 1e68745ad..38a314044 100644 --- a/components/trigger/Popup.vue +++ b/components/trigger/Popup.vue @@ -56,11 +56,9 @@ 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) }, @@ -101,14 +99,6 @@ export default { 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 @@ -117,8 +107,8 @@ export default { getPopupElement () { const { $props: props, onMouseEnter, onMouseLeave, $slots } = this const { align, visible, prefixCls, animation } = props - const className = this.getClassName(this.currentAlignClassName || - props.getClassNameFromAlign(align)) + this.currentAlignClassName = this.currentAlignClassName || props.getClassNameFromAlign(align) + const className = this.getClassName(this.currentAlignClassName) // const hiddenClassName = `${prefixCls}-hidden` if (!visible) { this.currentAlignClassName = null @@ -144,7 +134,6 @@ export default { } return ( builtin placement align map. used by placement prop - popupVisibleChange - $emit(visible) + onPopupVisibleChange + function call when popup visible is changed - popupAlign - $emit(popupDomNode, align) + onPopupAlign + function callback when popup node is aligned diff --git a/components/trigger/index.vue b/components/trigger/index.vue index 3313d0aba..a56b5310c 100644 --- a/components/trigger/index.vue +++ b/components/trigger/index.vue @@ -5,7 +5,7 @@ import hasProp from '../_util/hasProp' import addEventListener from '../_util/Dom/addEventListener' import warning from '../_util/warning' import Popup from './Popup' -import { getAlignFromPlacement, getPopupClassNameFromAlign } from './utils' +import { getAlignFromPlacement, getPopupClassNameFromAlign, noop } from './utils' import StateMixin from '../_util/StateMixin' import { cloneElement, cloneVNode } from '../_util/vnode' @@ -27,8 +27,8 @@ export default { showAction: PropTypes.any.def([]), hideAction: PropTypes.any.def([]), getPopupClassNameFromAlign: PropTypes.any.def(returnEmptyString), - // onPopupVisibleChange: PropTypes.func, - // afterPopupVisibleChange: PropTypes.func, + // onPopupVisibleChange: PropTypes.func.def(noop), + afterPopupVisibleChange: PropTypes.func.def(noop), popup: PropTypes.any, popupStyle: PropTypes.object.def({}), prefixCls: PropTypes.string.def('rc-trigger-popup'), @@ -51,7 +51,7 @@ export default { destroyPopupOnHide: PropTypes.bool.def(false), mask: PropTypes.bool.def(false), maskClosable: PropTypes.bool.def(true), - // onPopupAlign: PropTypes.func, + // onPopupAlign: PropTypes.func.def(noop), popupAlign: PropTypes.object.def({}), popupVisible: PropTypes.bool, defaultPopupVisible: PropTypes.bool.def(false), @@ -96,7 +96,7 @@ export default { }, sPopupVisible (val) { this.$nextTick(() => { - this.$emit('afterPopupVisibleChange', val) + this.afterPopupVisibleChange(val) }) }, }, @@ -261,7 +261,7 @@ export default { return this.$el.children ? this.$el.children[0] : this.$el }, - getPopupClassFromAlign (align) { + handleGetPopupClassFromAlign (align) { const className = [] const props = this.$props const { popupPlacement, builtinPlacements, prefixCls } = props @@ -285,7 +285,7 @@ export default { onPopupAlign () { this.$emit('popupAlign', ...arguments) }, - getComponent () { + getComponent (h) { const mouseProps = {} if (this.isMouseEnterToShow()) { mouseProps.mouseenter = this.onPopupMouseenter @@ -295,7 +295,7 @@ export default { } const { prefixCls, destroyPopupOnHide, sPopupVisible, popupStyle, popupClassName, action, onPopupAlign, - popupAnimation, getPopupClassFromAlign, getRootDomNode, + popupAnimation, handleGetPopupClassFromAlign, getRootDomNode, mask, zIndex, popupTransitionName, getPopupAlign, maskAnimation, maskTransitionName, popup, $slots, getContainer } = this const popupProps = { @@ -306,7 +306,7 @@ export default { action, align: getPopupAlign(), animation: popupAnimation, - getClassNameFromAlign: getPopupClassFromAlign, + getClassNameFromAlign: handleGetPopupClassFromAlign, getRootDomNode, mask, zIndex, @@ -328,7 +328,7 @@ export default { {...popupProps} ref='popup' > - {typeof popup === 'function' ? popup() : popup} + {typeof popup === 'function' ? popup(h) : popup} {popup === undefined ? $slots.popup : null} ) @@ -472,7 +472,7 @@ export default { this.setPopupVisible(false) }, }, - render () { + render (h) { const children = this.$slots.default if (children.length > 1) { warning(false, 'Trigger $slots.default.length > 1, just support only one default', true) @@ -521,7 +521,7 @@ export default { const trigger = cloneElement(cloneVNode(child), newChildProps) const { sPopupVisible, forceRender } = this if (sPopupVisible || forceRender || this._component) { - this._component = this.getComponent() + this._component = this.getComponent(h) } else { this._component = null } diff --git a/components/trigger/utils.js b/components/trigger/utils.js index e2af70378..eddd8178f 100644 --- a/components/trigger/utils.js +++ b/components/trigger/utils.js @@ -21,7 +21,5 @@ export function getPopupClassNameFromAlign (builtinPlacements, prefixCls, align) } return '' } - -export function saveRef (name, component) { - this[name] = component +export function noop () { } diff --git a/examples/index.less b/examples/index.less index 89a9f27d5..ac6ec4a44 100644 --- a/examples/index.less +++ b/examples/index.less @@ -1,3 +1,3 @@ -.icon-test{ - font-size: 35px; +#app { + padding: 50px; } diff --git a/examples/md.vue b/examples/md.vue index 9dcad410f..c907d5dda 100644 --- a/examples/md.vue +++ b/examples/md.vue @@ -1,5 +1,5 @@ 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..da31a1806 --- /dev/null +++ b/components/popover/index.vue @@ -0,0 +1,67 @@ + 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/popconfirm/index.vue b/components/popconfirm/index.vue index e69de29bb..9807ce386 100644 --- a/components/popconfirm/index.vue +++ 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 index bbdf06f3a..9442b1fac 100644 --- a/components/popconfirm/index.zh-CN.md +++ b/components/popconfirm/index.zh-CN.md @@ -17,8 +17,8 @@ title: Popconfirm | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| cancelText | 取消按钮文字 | string | 取消 | -| okText | 确认按钮文字 | string | 确定 | +| cancelText | 取消按钮文字 | string\|function\|slot | 取消 | +| okText | 确认按钮文字 | string\|function\|slot | 确定 | | okType | 确认按钮类型 | string | primary | | title | 确认框的描述 | string\|function\|slot | 无 | diff --git a/components/popover/index.vue b/components/popover/index.vue index da31a1806..1089d6f0f 100644 --- a/components/popover/index.vue +++ b/components/popover/index.vue @@ -2,7 +2,7 @@ import Tooltip from '../tooltip' import abstractTooltipProps from '../tooltip/abstractTooltipProps' import PropTypes from '../_util/vue-types' -import { getOptionProps } from '../_util/props-util' +import { getOptionProps, getComponentFromProp } from '../_util/props-util' export default { name: 'popover', @@ -21,26 +21,10 @@ export default { getPopupDomNode () { return this.$refs.tooltip.getPopupDomNode() }, - getOverlay (h) { - const { title, prefixCls, content, $slots } = this - return ( -
- {(title || $slots.title) && -
- {typeof title === 'function' ? title(h) : title} - {$slots.title} -
- } -
- {typeof content === 'function' ? content(h) : content} - {$slots.content} -
-
- ) - }, }, render (h) { + const { title, prefixCls, content, $slots } = this const props = getOptionProps(this) delete props.title delete props.content @@ -56,7 +40,16 @@ export default { {...tooltipProps} > {this.$slots.default} diff --git a/components/style.js b/components/style.js index 82780a16e..108572eed 100644 --- a/components/style.js +++ b/components/style.js @@ -12,5 +12,6 @@ import './tabs/style' import './input/style' import './tooltip/style' import './popover/style' +import './popconfirm/style' import './menu/style' diff --git a/contributors.md b/contributors.md index a87464170..483bcb023 100644 --- a/contributors.md +++ b/contributors.md @@ -9,7 +9,7 @@ Tabs | done Tag | done ToolTip | done Popconfirm -Popover +Popover | done Menu Carousel Mention