fix
parent
f8be36593d
commit
98240df7a3
|
@ -33,6 +33,7 @@ export function cloneVNodes (vnodes, deep) {
|
||||||
export function cloneElement (node, nodeProps) {
|
export function cloneElement (node, nodeProps) {
|
||||||
const { props, key } = nodeProps
|
const { props, key } = nodeProps
|
||||||
if (node.componentOptions) {
|
if (node.componentOptions) {
|
||||||
|
node.componentOptions.propsData = node.componentOptions.propsData || {}
|
||||||
Object.assign(node.componentOptions.propsData, props)
|
Object.assign(node.componentOptions.propsData, props)
|
||||||
}
|
}
|
||||||
const data = node.data || {}
|
const data = node.data || {}
|
||||||
|
@ -44,6 +45,7 @@ export function cloneElement (node, nodeProps) {
|
||||||
node.data = Object.assign(data, { style, attrs, class: cls, on })
|
node.data = Object.assign(data, { style, attrs, class: cls, on })
|
||||||
if (key !== undefined) {
|
if (key !== undefined) {
|
||||||
node.key = key
|
node.key = key
|
||||||
|
node.data.key = key
|
||||||
}
|
}
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ const Menu = {
|
||||||
subMenuOpenDelay: PropTypes.number.def(0),
|
subMenuOpenDelay: PropTypes.number.def(0),
|
||||||
subMenuCloseDelay: PropTypes.number.def(0.1),
|
subMenuCloseDelay: PropTypes.number.def(0.1),
|
||||||
forceSubMenuRender: PropTypes.bool,
|
forceSubMenuRender: PropTypes.bool,
|
||||||
triggerSubMenuAction: PropTypes.string.def('hover'),
|
triggerSubMenuAction: PropTypes.string.def('click'),
|
||||||
level: PropTypes.number.def(1),
|
level: PropTypes.number.def(1),
|
||||||
selectable: PropTypes.bool.def(true),
|
selectable: PropTypes.bool.def(true),
|
||||||
multiple: PropTypes.bool,
|
multiple: PropTypes.bool,
|
||||||
|
@ -183,6 +183,7 @@ const Menu = {
|
||||||
openKeys: state.sOpenKeys,
|
openKeys: state.sOpenKeys,
|
||||||
selectedKeys: state.sSelectedKeys,
|
selectedKeys: state.sSelectedKeys,
|
||||||
triggerSubMenuAction: this.$props.triggerSubMenuAction,
|
triggerSubMenuAction: this.$props.triggerSubMenuAction,
|
||||||
|
isRootMenu: true,
|
||||||
}
|
}
|
||||||
return this.renderCommonMenuItem(c, i, subIndex, extraProps)
|
return this.renderCommonMenuItem(c, i, subIndex, extraProps)
|
||||||
},
|
},
|
||||||
|
@ -191,7 +192,7 @@ const Menu = {
|
||||||
render () {
|
render () {
|
||||||
const props = { ...this.$props }
|
const props = { ...this.$props }
|
||||||
props.class = ` ${props.prefixCls}-root`
|
props.class = ` ${props.prefixCls}-root`
|
||||||
return this.renderRoot(props)
|
return this.renderRoot(props, this.$slots.default)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
export default Menu
|
export default Menu
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import PropTypes from '../../_util/vue-types'
|
import PropTypes from '../../_util/vue-types'
|
||||||
import KeyCode from '../../_util/KeyCode'
|
import KeyCode from '../../_util/KeyCode'
|
||||||
|
import { noop } from './util'
|
||||||
|
|
||||||
const MenuItem = {
|
const MenuItem = {
|
||||||
name: 'MenuItem',
|
name: 'MenuItem',
|
||||||
|
@ -9,10 +10,12 @@ const MenuItem = {
|
||||||
rootPrefixCls: PropTypes.string,
|
rootPrefixCls: PropTypes.string,
|
||||||
eventKey: PropTypes.string,
|
eventKey: PropTypes.string,
|
||||||
active: PropTypes.bool,
|
active: PropTypes.bool,
|
||||||
children: PropTypes.any,
|
|
||||||
selectedKeys: PropTypes.array,
|
selectedKeys: PropTypes.array,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
|
inlineIndent: PropTypes.number.def(24),
|
||||||
|
level: PropTypes.number.def(1),
|
||||||
|
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']).def('vertical'),
|
||||||
// onItemHover: PropTypes.func,
|
// onItemHover: PropTypes.func,
|
||||||
// onSelect: PropTypes.func,
|
// onSelect: PropTypes.func,
|
||||||
// onClick: PropTypes.func,
|
// onClick: PropTypes.func,
|
||||||
|
@ -21,12 +24,18 @@ const MenuItem = {
|
||||||
// onDestroy: PropTypes.func,
|
// onDestroy: PropTypes.func,
|
||||||
// onMouseEnter: PropTypes.func,
|
// onMouseEnter: PropTypes.func,
|
||||||
// onMouseLeave: PropTypes.func,
|
// onMouseLeave: PropTypes.func,
|
||||||
|
clearSubMenuTimers: PropTypes.func.def(noop),
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
const props = this.$props
|
const props = this.$props
|
||||||
this.$emit('destroy', props.eventKey)
|
this.$emit('destroy', props.eventKey)
|
||||||
},
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isMenuItem: 1,
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onKeyDown (e) {
|
onKeyDown (e) {
|
||||||
const keyCode = e.keyCode
|
const keyCode = e.keyCode
|
||||||
|
@ -49,10 +58,8 @@ const MenuItem = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onMouseEnter (e) {
|
onMouseEnter (e) {
|
||||||
const { eventKey, parentMenu } = this.$props
|
const { eventKey } = this.$props
|
||||||
if (parentMenu.subMenuInstance) {
|
this.clearSubMenuTimers()
|
||||||
parentMenu.subMenuInstance.clearSubMenuTimers()
|
|
||||||
}
|
|
||||||
this.$emit('itemHover', {
|
this.$emit('itemHover', {
|
||||||
key: eventKey,
|
key: eventKey,
|
||||||
hover: true,
|
hover: true,
|
||||||
|
@ -151,7 +158,5 @@ const MenuItem = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem.isMenuItem = 1
|
|
||||||
|
|
||||||
export default MenuItem
|
export default MenuItem
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -12,7 +12,11 @@ const MenuItemGroup = {
|
||||||
disabled: PropTypes.bool.def(true),
|
disabled: PropTypes.bool.def(true),
|
||||||
title: PropTypes.any.def(''),
|
title: PropTypes.any.def(''),
|
||||||
},
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isMenuItemGroup: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
renderInnerMenuItem (item, subIndex) {
|
renderInnerMenuItem (item, subIndex) {
|
||||||
const { renderMenuItem, index } = this.$props
|
const { renderMenuItem, index } = this.$props
|
||||||
|
@ -40,7 +44,5 @@ const MenuItemGroup = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItemGroup.isMenuItemGroup = true
|
|
||||||
|
|
||||||
export default MenuItemGroup
|
export default MenuItemGroup
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -46,8 +46,9 @@ function getActiveKey (props, originalActiveKey) {
|
||||||
return activeKey
|
return activeKey
|
||||||
}
|
}
|
||||||
|
|
||||||
const MenuMixin = {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
test: PropTypes.any,
|
||||||
prefixCls: PropTypes.string.def('rc-menu'),
|
prefixCls: PropTypes.string.def('rc-menu'),
|
||||||
inlineIndent: PropTypes.number.def(24),
|
inlineIndent: PropTypes.number.def(24),
|
||||||
focusable: PropTypes.bool.def(true),
|
focusable: PropTypes.bool.def(true),
|
||||||
|
@ -59,6 +60,7 @@ const MenuMixin = {
|
||||||
defaultSelectedKeys: PropTypes.arrayOf(PropTypes.string),
|
defaultSelectedKeys: PropTypes.arrayOf(PropTypes.string),
|
||||||
defaultOpenKeys: PropTypes.arrayOf(PropTypes.string),
|
defaultOpenKeys: PropTypes.arrayOf(PropTypes.string),
|
||||||
openKeys: PropTypes.arrayOf(PropTypes.string),
|
openKeys: PropTypes.arrayOf(PropTypes.string),
|
||||||
|
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']).def('vertical'),
|
||||||
},
|
},
|
||||||
mixin: [StateMixin],
|
mixin: [StateMixin],
|
||||||
data () {
|
data () {
|
||||||
|
@ -186,7 +188,7 @@ const MenuMixin = {
|
||||||
renderMenuItem: this.renderMenuItem,
|
renderMenuItem: this.renderMenuItem,
|
||||||
rootPrefixCls: props.prefixCls,
|
rootPrefixCls: props.prefixCls,
|
||||||
index: i,
|
index: i,
|
||||||
parentMenu: this,
|
// parentMenu: this,
|
||||||
eventKey: key,
|
eventKey: key,
|
||||||
active: !childProps.disabled && isActive,
|
active: !childProps.disabled && isActive,
|
||||||
multiple: props.multiple,
|
multiple: props.multiple,
|
||||||
|
@ -201,24 +203,27 @@ const MenuMixin = {
|
||||||
on: {
|
on: {
|
||||||
click: this.onClick,
|
click: this.onClick,
|
||||||
itemHover: this.onItemHover,
|
itemHover: this.onItemHover,
|
||||||
// openChange: () => { console.log('openChange') },
|
openChange: () => { console.log('openChange') },
|
||||||
deselect: this.onDeselect,
|
deselect: this.onDeselect,
|
||||||
destroy: this.onDestroy,
|
destroy: this.onDestroy,
|
||||||
select: this.onSelect,
|
select: this.onSelect,
|
||||||
},
|
},
|
||||||
|
// ref: childProps.disabled ? undefined : child.ref,
|
||||||
ref: childProps.disabled ? undefined : child.ref,
|
|
||||||
// ref: childProps.disabled ? undefined
|
// ref: childProps.disabled ? undefined
|
||||||
// : createChainedFunction(child.ref, saveRef.bind(this, i, subIndex)),
|
// : createChainedFunction(child.ref, saveRef.bind(this, i, subIndex)),
|
||||||
}
|
}
|
||||||
!childProps.disabled && this.saveRef(i, subIndex, child.ref)
|
// !childProps.disabled && this.saveRef(i, subIndex, child.ref)
|
||||||
if (props.mode === 'inline') {
|
if (props.mode === 'inline') {
|
||||||
newChildProps.props.triggerSubMenuAction = 'click'
|
newChildProps.props.triggerSubMenuAction = 'click'
|
||||||
}
|
}
|
||||||
|
if (!extraProps.isRootMenu) {
|
||||||
|
newChildProps.props.clearSubMenuTimers = this.clearSubMenuTimers
|
||||||
|
}
|
||||||
|
// return this.$scopedSlots.default(newChildProps)
|
||||||
return cloneElement(child, newChildProps)
|
return cloneElement(child, newChildProps)
|
||||||
},
|
},
|
||||||
|
|
||||||
renderRoot (props) {
|
renderRoot (props, children = []) {
|
||||||
this.instanceArray = []
|
this.instanceArray = []
|
||||||
const className = {
|
const className = {
|
||||||
[props.prefixCls]: true,
|
[props.prefixCls]: true,
|
||||||
|
@ -237,7 +242,6 @@ const MenuMixin = {
|
||||||
},
|
},
|
||||||
class: className,
|
class: className,
|
||||||
on: {},
|
on: {},
|
||||||
// style:props.style,
|
|
||||||
}
|
}
|
||||||
if (props.id) {
|
if (props.id) {
|
||||||
domProps.id = props.id
|
domProps.id = props.id
|
||||||
|
@ -246,15 +250,13 @@ const MenuMixin = {
|
||||||
domProps.attrs.tabIndex = '0'
|
domProps.attrs.tabIndex = '0'
|
||||||
domProps.on.keydown = this.onKeyDown
|
domProps.on.keydown = this.onKeyDown
|
||||||
}
|
}
|
||||||
|
const newChildren = children.map(this.renderMenuItem)
|
||||||
return (
|
return (
|
||||||
// ESLint is not smart enough to know that the type of `children` was checked.
|
|
||||||
/* eslint-disable */
|
|
||||||
<DOMWrap
|
<DOMWrap
|
||||||
{...domProps}
|
{...domProps}
|
||||||
>
|
>
|
||||||
{this.$slots.default.map(this.renderMenuItem)}
|
{newChildren}
|
||||||
</DOMWrap>
|
</DOMWrap>
|
||||||
/*eslint -enable */
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -301,5 +303,3 @@ const MenuMixin = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MenuMixin
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Trigger from '../../trigger'
|
||||||
import KeyCode from '../../_util/KeyCode'
|
import KeyCode from '../../_util/KeyCode'
|
||||||
import SubPopupMenu from './SubPopupMenu'
|
import SubPopupMenu from './SubPopupMenu'
|
||||||
import placements from './placements'
|
import placements from './placements'
|
||||||
import { loopMenuItemRecusively } from './util'
|
import { loopMenuItemRecusively, noop } from './util'
|
||||||
import StateMixin from '../../_util/StateMixin'
|
import StateMixin from '../../_util/StateMixin'
|
||||||
|
|
||||||
let guid = 0
|
let guid = 0
|
||||||
|
@ -16,26 +16,27 @@ const popupPlacementMap = {
|
||||||
'vertical-right': 'leftTop',
|
'vertical-right': 'leftTop',
|
||||||
}
|
}
|
||||||
|
|
||||||
const SubMenu = {
|
export default {
|
||||||
name: 'SubMenu',
|
name: 'SubMenu',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
parentMenu: PropTypes.object,
|
|
||||||
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']).def('vertical'),
|
mode: PropTypes.oneOf(['horizontal', 'vertical', 'vertical-left', 'vertical-right', 'inline']).def('vertical'),
|
||||||
title: PropTypes.any.def(''),
|
title: PropTypes.any.def(''),
|
||||||
children: PropTypes.any,
|
selectedKeys: PropTypes.array.def([]),
|
||||||
selectedKeys: PropTypes.array,
|
openKeys: PropTypes.array.def([]),
|
||||||
openKeys: PropTypes.array,
|
|
||||||
// onClick: PropTypes.func,
|
// onClick: PropTypes.func,
|
||||||
openChange: PropTypes.func,
|
openChange: PropTypes.func.def(noop),
|
||||||
rootPrefixCls: PropTypes.string,
|
rootPrefixCls: PropTypes.string,
|
||||||
eventKey: PropTypes.string,
|
eventKey: PropTypes.string,
|
||||||
multiple: PropTypes.bool,
|
multiple: PropTypes.bool,
|
||||||
active: PropTypes.bool, // TODO: remove
|
active: PropTypes.bool, // TODO: remove
|
||||||
|
isRootMenu: PropTypes.bool,
|
||||||
// onItemHover: PropTypes.func,
|
// onItemHover: PropTypes.func,
|
||||||
// onSelect: PropTypes.func,
|
// onSelect: PropTypes.func,
|
||||||
triggerSubMenuAction: PropTypes.string,
|
triggerSubMenuAction: PropTypes.string,
|
||||||
popupClassName: PropTypes.string,
|
popupClassName: PropTypes.string,
|
||||||
|
getPopupContainer: PropTypes.func,
|
||||||
|
test: PropTypes.any,
|
||||||
// onDeselect: PropTypes.func,
|
// onDeselect: PropTypes.func,
|
||||||
// onDestroy: PropTypes.func,
|
// onDestroy: PropTypes.func,
|
||||||
// onMouseEnter: PropTypes.func,
|
// onMouseEnter: PropTypes.func,
|
||||||
|
@ -46,13 +47,19 @@ const SubMenu = {
|
||||||
},
|
},
|
||||||
mixins: [StateMixin],
|
mixins: [StateMixin],
|
||||||
data () {
|
data () {
|
||||||
this.isSubMenu = 1
|
|
||||||
this.isRootMenu = false
|
|
||||||
return {
|
return {
|
||||||
defaultActiveFirst: false,
|
defaultActiveFirst: false,
|
||||||
|
isSubMenu: 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
'$props': {
|
||||||
|
handler: function (nextProps) {
|
||||||
|
console.log(nextProps)
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.handleUpdated()
|
this.handleUpdated()
|
||||||
},
|
},
|
||||||
|
@ -62,16 +69,14 @@ const SubMenu = {
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
const { eventKey, parentMenu } = this.$props
|
const { eventKey } = this.$props
|
||||||
this.$emit('destroy', eventKey)
|
this.$emit('destroy', eventKey)
|
||||||
if (parentMenu.subMenuInstance === this) {
|
this.clearSubMenuTimers()
|
||||||
this.clearSubMenuTimers()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleUpdated () {
|
handleUpdated () {
|
||||||
const { mode, parentMenu } = this.$props
|
const { mode, isRootMenu } = this.$props
|
||||||
if (mode !== 'horizontal' || !parentMenu.isRootMenu || !this.isOpen()) {
|
if (mode !== 'horizontal' || !isRootMenu || !this.isOpen()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -155,11 +160,9 @@ const SubMenu = {
|
||||||
|
|
||||||
onMouseLeave (e) {
|
onMouseLeave (e) {
|
||||||
const {
|
const {
|
||||||
parentMenu,
|
|
||||||
eventKey,
|
eventKey,
|
||||||
} = this.$props
|
} = this.$props
|
||||||
parentMenu.subMenuInstance = this
|
this.subMenuLeaveFn = () => {
|
||||||
parentMenu.subMenuLeaveFn = () => {
|
|
||||||
// trigger mouseleave
|
// trigger mouseleave
|
||||||
this.$emit('mouseleave', {
|
this.$emit('mouseleave', {
|
||||||
key: eventKey,
|
key: eventKey,
|
||||||
|
@ -168,7 +171,7 @@ const SubMenu = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent popup menu and submenu gap
|
// prevent popup menu and submenu gap
|
||||||
parentMenu.subMenuLeaveTimer = setTimeout(parentMenu.subMenuLeaveFn, 100)
|
this.subMenuLeaveTimer = setTimeout(this.subMenuLeaveFn, 100)
|
||||||
},
|
},
|
||||||
|
|
||||||
onTitleMouseEnter (domEvent) {
|
onTitleMouseEnter (domEvent) {
|
||||||
|
@ -185,9 +188,8 @@ const SubMenu = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onTitleMouseLeave (e) {
|
onTitleMouseLeave (e) {
|
||||||
const { parentMenu, eventKey } = this.$props
|
const { eventKey } = this.$props
|
||||||
parentMenu.subMenuInstance = this
|
this.subMenuTitleLeaveFn = () => {
|
||||||
parentMenu.subMenuTitleLeaveFn = () => {
|
|
||||||
this.$emit('itemHover', {
|
this.$emit('itemHover', {
|
||||||
key: eventKey,
|
key: eventKey,
|
||||||
hover: false,
|
hover: false,
|
||||||
|
@ -197,7 +199,7 @@ const SubMenu = {
|
||||||
domEvent: e,
|
domEvent: e,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
parentMenu.subMenuTitleLeaveTimer = setTimeout(parentMenu.subMenuTitleLeaveFn, 100)
|
this.subMenuTitleLeaveTimer = setTimeout(this.subMenuTitleLeaveFn, 100)
|
||||||
},
|
},
|
||||||
|
|
||||||
onTitleClick (e) {
|
onTitleClick (e) {
|
||||||
|
@ -272,20 +274,18 @@ const SubMenu = {
|
||||||
},
|
},
|
||||||
|
|
||||||
clearSubMenuTitleLeaveTimer () {
|
clearSubMenuTitleLeaveTimer () {
|
||||||
const parentMenu = this.$props.parentMenu
|
if (this.subMenuTitleLeaveTimer) {
|
||||||
if (parentMenu.subMenuTitleLeaveTimer) {
|
clearTimeout(this.subMenuTitleLeaveTimer)
|
||||||
clearTimeout(parentMenu.subMenuTitleLeaveTimer)
|
this.subMenuTitleLeaveTimer = null
|
||||||
parentMenu.subMenuTitleLeaveTimer = null
|
this.subMenuTitleLeaveFn = null
|
||||||
parentMenu.subMenuTitleLeaveFn = null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clearSubMenuLeaveTimer () {
|
clearSubMenuLeaveTimer () {
|
||||||
const parentMenu = this.$props.parentMenu
|
if (this.subMenuLeaveTimer) {
|
||||||
if (parentMenu.subMenuLeaveTimer) {
|
clearTimeout(this.subMenuLeaveTimer)
|
||||||
clearTimeout(parentMenu.subMenuLeaveTimer)
|
this.subMenuLeaveTimer = null
|
||||||
parentMenu.subMenuLeaveTimer = null
|
this.subMenuLeaveFn = null
|
||||||
parentMenu.subMenuLeaveFn = null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -319,6 +319,7 @@ const SubMenu = {
|
||||||
defaultActiveFirst: this.$data.defaultActiveFirst,
|
defaultActiveFirst: this.$data.defaultActiveFirst,
|
||||||
multiple: props.multiple,
|
multiple: props.multiple,
|
||||||
prefixCls: props.rootPrefixCls,
|
prefixCls: props.rootPrefixCls,
|
||||||
|
clearSubMenuTimers: this.clearSubMenuTimers,
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
click: this.onSubMenuClick,
|
click: this.onSubMenuClick,
|
||||||
|
@ -404,24 +405,24 @@ const SubMenu = {
|
||||||
)
|
)
|
||||||
const children = this.renderChildren(this.$slots.default)
|
const children = this.renderChildren(this.$slots.default)
|
||||||
|
|
||||||
const getPopupContainer = props.parentMenu.isRootMenu
|
const getPopupContainer = this.isRootMenu
|
||||||
? props.parentMenu.getPopupContainer : triggerNode => triggerNode.parentNode
|
? this.getPopupContainer : triggerNode => triggerNode.parentNode
|
||||||
const popupPlacement = popupPlacementMap[props.mode]
|
const popupPlacement = popupPlacementMap[props.mode]
|
||||||
const popupClassName = props.mode === 'inline' ? '' : props.popupClassName
|
const popupClassName = props.mode === 'inline' ? '' : props.popupClassName
|
||||||
const liProps = {
|
const liProps = {
|
||||||
on: { ...mouseEvents },
|
on: { ...mouseEvents },
|
||||||
class: className,
|
class: className,
|
||||||
}
|
}
|
||||||
console.log(isOpen)
|
|
||||||
return (
|
return (
|
||||||
<li {...liProps}>
|
<li {...liProps}>
|
||||||
{isInlineMode && title}
|
{isInlineMode && title}
|
||||||
{isInlineMode && children}
|
{isInlineMode && children}
|
||||||
{!isInlineMode && (
|
{!isInlineMode && (
|
||||||
|
|
||||||
<Trigger
|
<Trigger
|
||||||
prefixCls={prefixCls}
|
prefixCls={prefixCls}
|
||||||
popupClassName={`${prefixCls}-popup ${popupClassName}`}
|
popupClassName={`${prefixCls}-popup ${popupClassName || ''}`}
|
||||||
// getPopupContainer={getPopupContainer}
|
getPopupContainer={getPopupContainer}
|
||||||
builtinPlacements={placements}
|
builtinPlacements={placements}
|
||||||
popupPlacement={popupPlacement}
|
popupPlacement={popupPlacement}
|
||||||
popupVisible={isOpen}
|
popupVisible={isOpen}
|
||||||
|
@ -441,8 +442,4 @@ const SubMenu = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
SubMenu.isSubMenu = 1
|
|
||||||
|
|
||||||
export default SubMenu
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,57 +5,57 @@ import MenuMixin from './MenuMixin'
|
||||||
export default {
|
export default {
|
||||||
name: 'SubPopupMenu',
|
name: 'SubPopupMenu',
|
||||||
props: {
|
props: {
|
||||||
onSelect: PropTypes.func,
|
// onSelect: PropTypes.func,
|
||||||
onClick: PropTypes.func,
|
// onClick: PropTypes.func,
|
||||||
onDeselect: PropTypes.func,
|
// onDeselect: PropTypes.func,
|
||||||
onOpenChange: PropTypes.func,
|
// onOpenChange: PropTypes.func,
|
||||||
onDestroy: PropTypes.func,
|
// onDestroy: PropTypes.func,
|
||||||
openTransitionName: PropTypes.string,
|
openTransitionName: PropTypes.string,
|
||||||
openAnimation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
openAnimation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
||||||
openKeys: PropTypes.arrayOf(PropTypes.string),
|
openKeys: PropTypes.arrayOf(PropTypes.string),
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
children: PropTypes.any,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [MenuMixin],
|
mixins: [MenuMixin],
|
||||||
|
methods: {
|
||||||
|
onDeselect (selectInfo) {
|
||||||
|
this.$emit('deselect', selectInfo)
|
||||||
|
},
|
||||||
|
|
||||||
onDeselect (selectInfo) {
|
onSelect (selectInfo) {
|
||||||
this.$emit('deselect', selectInfo)
|
this.$emit('select', selectInfo)
|
||||||
|
},
|
||||||
|
|
||||||
|
onClick (e) {
|
||||||
|
this.$emit('click', e)
|
||||||
|
},
|
||||||
|
|
||||||
|
onOpenChange (e) {
|
||||||
|
this.$emit('openChange', e)
|
||||||
|
},
|
||||||
|
|
||||||
|
onDestroy (key) {
|
||||||
|
this.$$emit('destroy', key)
|
||||||
|
},
|
||||||
|
|
||||||
|
getOpenTransitionName () {
|
||||||
|
return this.$props.openTransitionName
|
||||||
|
},
|
||||||
|
|
||||||
|
renderMenuItem (c, i, subIndex) {
|
||||||
|
if (!c) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const props = this.$props
|
||||||
|
const extraProps = {
|
||||||
|
openKeys: props.openKeys,
|
||||||
|
selectedKeys: props.selectedKeys,
|
||||||
|
triggerSubMenuAction: props.triggerSubMenuAction,
|
||||||
|
isRootMenu: false,
|
||||||
|
}
|
||||||
|
return this.renderCommonMenuItem(c, i, subIndex, extraProps)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
onSelect (selectInfo) {
|
|
||||||
this.$emit('select', selectInfo)
|
|
||||||
},
|
|
||||||
|
|
||||||
onClick (e) {
|
|
||||||
this.$emit('click', e)
|
|
||||||
},
|
|
||||||
|
|
||||||
onOpenChange (e) {
|
|
||||||
this.$emit('openChange', e)
|
|
||||||
},
|
|
||||||
|
|
||||||
onDestroy (key) {
|
|
||||||
this.$$emit('destroy', key)
|
|
||||||
},
|
|
||||||
|
|
||||||
getOpenTransitionName () {
|
|
||||||
return this.$props.openTransitionName
|
|
||||||
},
|
|
||||||
|
|
||||||
renderMenuItem (c, i, subIndex) {
|
|
||||||
if (!c) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
const props = this.$props
|
|
||||||
const extraProps = {
|
|
||||||
openKeys: props.openKeys,
|
|
||||||
selectedKeys: props.selectedKeys,
|
|
||||||
triggerSubMenuAction: props.triggerSubMenuAction,
|
|
||||||
}
|
|
||||||
return this.renderCommonMenuItem(c, i, subIndex, extraProps)
|
|
||||||
},
|
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const props = { ...this.$props }
|
const props = { ...this.$props }
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ export default {
|
||||||
|
|
||||||
const transitionAppear = !(!haveRendered && props.visible && props.mode === 'inline')
|
const transitionAppear = !(!haveRendered && props.visible && props.mode === 'inline')
|
||||||
|
|
||||||
props.className += ` ${props.prefixCls}-sub`
|
props.class = `${props.prefixCls}-sub`
|
||||||
const animProps = {}
|
const animProps = {}
|
||||||
if (props.openTransitionName) {
|
if (props.openTransitionName) {
|
||||||
animProps.transitionName = props.openTransitionName
|
animProps.transitionName = props.openTransitionName
|
||||||
|
@ -84,7 +84,7 @@ export default {
|
||||||
appear
|
appear
|
||||||
name={animProps.transitionName}
|
name={animProps.transitionName}
|
||||||
>
|
>
|
||||||
{this.renderRoot(props)}
|
{this.renderRoot(props, this.$slots.default)}
|
||||||
</transition>
|
</transition>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,6 +30,7 @@ export function loopMenuItemRecusively (children, keys, ret) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (c) {
|
if (c) {
|
||||||
|
console.log(c)
|
||||||
const construt = c.type
|
const construt = c.type
|
||||||
if (!construt || !(construt.isSubMenu || construt.isMenuItem || construt.isMenuItemGroup)) {
|
if (!construt || !(construt.isSubMenu || construt.isMenuItem || construt.isMenuItemGroup)) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -19,6 +19,7 @@ export default {
|
||||||
maskTransitionName: PropTypes.string,
|
maskTransitionName: PropTypes.string,
|
||||||
mask: PropTypes.bool,
|
mask: PropTypes.bool,
|
||||||
zIndex: PropTypes.number,
|
zIndex: PropTypes.number,
|
||||||
|
popupClassName: PropTypes.any,
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -81,7 +82,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
getClassName (currentAlignClassName) {
|
getClassName (currentAlignClassName) {
|
||||||
return `${this.$props.prefixCls} ${currentAlignClassName}`
|
return `${this.$props.prefixCls} ${this.$props.popupClassName} ${currentAlignClassName}`
|
||||||
},
|
},
|
||||||
onMouseEnter (e) {
|
onMouseEnter (e) {
|
||||||
this.$emit('mouseenter', e)
|
this.$emit('mouseenter', e)
|
||||||
|
@ -112,7 +113,7 @@ export default {
|
||||||
prefixCls,
|
prefixCls,
|
||||||
visible,
|
visible,
|
||||||
},
|
},
|
||||||
class: className,
|
class: `${className}`,
|
||||||
on: {
|
on: {
|
||||||
mouseenter: onMouseEnter,
|
mouseenter: onMouseEnter,
|
||||||
mouseleave: onMouseLeave,
|
mouseleave: onMouseLeave,
|
||||||
|
@ -142,7 +143,6 @@ export default {
|
||||||
{$slots.default}
|
{$slots.default}
|
||||||
</PopupInner>
|
</PopupInner>
|
||||||
</Align>
|
</Align>
|
||||||
|
|
||||||
</transition>)
|
</transition>)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -189,7 +189,8 @@ export default {
|
||||||
return (
|
return (
|
||||||
<div style='position: absolute; top: 0px; left: 0px; width: 100%;'>
|
<div style='position: absolute; top: 0px; left: 0px; width: 100%;'>
|
||||||
{getMaskElement()}
|
{getMaskElement()}
|
||||||
{destroyPopup ? null : getPopupElement()}
|
{ destroyPopup
|
||||||
|
? null : getPopupElement()}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -314,6 +314,7 @@ export default {
|
||||||
maskAnimation,
|
maskAnimation,
|
||||||
maskTransitionName,
|
maskTransitionName,
|
||||||
getContainer,
|
getContainer,
|
||||||
|
popupClassName,
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
align: onPopupAlign,
|
align: onPopupAlign,
|
||||||
|
@ -321,7 +322,6 @@ export default {
|
||||||
},
|
},
|
||||||
ref: 'popup',
|
ref: 'popup',
|
||||||
style: popupStyle,
|
style: popupStyle,
|
||||||
class: popupClassName,
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Popup
|
<Popup
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
"lodash.isplainobject": "^4.0.6",
|
"lodash.isplainobject": "^4.0.6",
|
||||||
"omit.js": "^1.0.0",
|
"omit.js": "^1.0.0",
|
||||||
|
"vue": "^2.5.13",
|
||||||
"vue-types": "^1.0.2",
|
"vue-types": "^1.0.2",
|
||||||
"warning": "^3.0.0"
|
"warning": "^3.0.0"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue