feat: update dropdown to 2.2.1
parent
26186d7aad
commit
b755860ebc
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
import Button from '../button'
|
import Button from '../button'
|
||||||
import { ButtonGroupProps } from '../button/button-group'
|
import { ButtonGroupProps } from '../button/button-group'
|
||||||
import Icon from '../icon'
|
|
||||||
import Dropdown from './dropdown'
|
import Dropdown from './dropdown'
|
||||||
import PropTypes from '../_util/vue-types'
|
import PropTypes from '../_util/vue-types'
|
||||||
import { hasProp, getComponentFromProp } from '../_util/props-util'
|
import { hasProp, getComponentFromProp } from '../_util/props-util'
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
import RcDropdown from './src/index'
|
import RcDropdown from '../vc-dropdown/src/index'
|
||||||
import DropdownButton from './dropdown-button'
|
import DropdownButton from './dropdown-button'
|
||||||
// import warning from '../_util/warning'
|
|
||||||
import PropTypes from '../_util/vue-types'
|
import PropTypes from '../_util/vue-types'
|
||||||
import { cloneElement } from '../_util/vnode'
|
import { cloneElement } from '../_util/vnode'
|
||||||
import { getOptionProps, getPropsData } from '../_util/props-util'
|
import { getOptionProps, getPropsData } from '../_util/props-util'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import PropTypes from '../../_util/vue-types'
|
import PropTypes from '../../_util/vue-types'
|
||||||
import Trigger from '../../trigger'
|
import Trigger from '../../trigger'
|
||||||
import placements from './placements'
|
import placements from './placements'
|
||||||
import { hasProp, getEvents } from '../../_util/props-util'
|
import { hasProp, getEvents, getOptionProps } from '../../_util/props-util'
|
||||||
import BaseMixin from '../../_util/BaseMixin'
|
import BaseMixin from '../../_util/BaseMixin'
|
||||||
import { cloneElement } from '../../_util/vnode'
|
import { cloneElement } from '../../_util/vnode'
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ export default {
|
||||||
overlayStyle: PropTypes.object.def({}),
|
overlayStyle: PropTypes.object.def({}),
|
||||||
placement: PropTypes.string.def('bottomLeft'),
|
placement: PropTypes.string.def('bottomLeft'),
|
||||||
trigger: PropTypes.array.def(['hover']),
|
trigger: PropTypes.array.def(['hover']),
|
||||||
|
alignPoint: PropTypes.bool,
|
||||||
showAction: PropTypes.array.def([]),
|
showAction: PropTypes.array.def([]),
|
||||||
hideAction: PropTypes.array.def([]),
|
hideAction: PropTypes.array.def([]),
|
||||||
getPopupContainer: PropTypes.func,
|
getPopupContainer: PropTypes.func,
|
||||||
|
@ -67,6 +68,16 @@ export default {
|
||||||
this.__emit('visibleChange', visible)
|
this.__emit('visibleChange', visible)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getMinOverlayWidthMatchTrigger () {
|
||||||
|
const props = getOptionProps(this)
|
||||||
|
const { minOverlayWidthMatchTrigger, alignPoint } = props
|
||||||
|
if ('minOverlayWidthMatchTrigger' in props) {
|
||||||
|
return minOverlayWidthMatchTrigger
|
||||||
|
}
|
||||||
|
|
||||||
|
return !alignPoint
|
||||||
|
},
|
||||||
|
|
||||||
getMenuElement () {
|
getMenuElement () {
|
||||||
const { onClick, prefixCls, $slots } = this
|
const { onClick, prefixCls, $slots } = this
|
||||||
this.childOriginEvents = getEvents($slots.overlay[0])
|
this.childOriginEvents = getEvents($slots.overlay[0])
|
||||||
|
@ -87,7 +98,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
afterVisibleChange (visible) {
|
afterVisibleChange (visible) {
|
||||||
if (visible && this.$props.minOverlayWidthMatchTrigger) {
|
if (visible && this.getMinOverlayWidthMatchTrigger()) {
|
||||||
const overlayNode = this.getPopupDomNode()
|
const overlayNode = this.getPopupDomNode()
|
||||||
const rootNode = this.$el
|
const rootNode = this.$el
|
||||||
if (rootNode && overlayNode && rootNode.offsetWidth > overlayNode.offsetWidth) {
|
if (rootNode && overlayNode && rootNode.offsetWidth > overlayNode.offsetWidth) {
|
||||||
|
@ -111,6 +122,10 @@ export default {
|
||||||
overlayClassName, overlayStyle,
|
overlayClassName, overlayStyle,
|
||||||
trigger, ...otherProps
|
trigger, ...otherProps
|
||||||
} = this.$props
|
} = this.$props
|
||||||
|
let triggerHideAction = hideAction
|
||||||
|
if (!triggerHideAction && trigger.indexOf('contextmenu') !== -1) {
|
||||||
|
triggerHideAction = ['click']
|
||||||
|
}
|
||||||
|
|
||||||
const triggerProps = {
|
const triggerProps = {
|
||||||
props: {
|
props: {
|
||||||
|
@ -121,7 +136,7 @@ export default {
|
||||||
builtinPlacements: placements,
|
builtinPlacements: placements,
|
||||||
action: trigger,
|
action: trigger,
|
||||||
showAction,
|
showAction,
|
||||||
hideAction,
|
hideAction: triggerHideAction || [],
|
||||||
popupPlacement: placement,
|
popupPlacement: placement,
|
||||||
popupAlign: align,
|
popupAlign: align,
|
||||||
popupTransitionName: transitionName,
|
popupTransitionName: transitionName,
|
|
@ -1,2 +1,3 @@
|
||||||
|
// base in 2.2.1
|
||||||
import Dropdown from './Dropdown'
|
import Dropdown from './Dropdown'
|
||||||
export default Dropdown
|
export default Dropdown
|
Loading…
Reference in New Issue