2018-03-19 10:16:27 +08:00
|
|
|
|
2018-01-29 18:57:20 +08:00
|
|
|
import Button from '../button'
|
|
|
|
import { ButtonGroupProps } from '../button/button-group'
|
|
|
|
import Dropdown from './dropdown'
|
|
|
|
import PropTypes from '../_util/vue-types'
|
|
|
|
import { hasProp, getComponentFromProp } from '../_util/props-util'
|
|
|
|
import getDropdownProps from './getDropdownProps'
|
|
|
|
const DropdownProps = getDropdownProps()
|
|
|
|
const ButtonGroup = Button.Group
|
2018-01-31 10:30:09 +08:00
|
|
|
const DropdownButtonProps = {
|
|
|
|
...ButtonGroupProps,
|
|
|
|
...DropdownProps,
|
2018-09-11 21:38:22 +08:00
|
|
|
type: PropTypes.oneOf(['primary', 'ghost', 'dashed', 'danger', 'default']).def('default'),
|
2018-01-31 10:30:09 +08:00
|
|
|
disabled: PropTypes.bool,
|
|
|
|
prefixCls: PropTypes.string.def('ant-dropdown-button'),
|
|
|
|
placement: DropdownProps.placement.def('bottomRight'),
|
|
|
|
}
|
|
|
|
export { DropdownButtonProps }
|
2018-01-29 18:57:20 +08:00
|
|
|
export default {
|
2018-04-08 21:17:20 +08:00
|
|
|
name: 'ADropdownButton',
|
2018-01-31 10:30:09 +08:00
|
|
|
props: DropdownButtonProps,
|
2018-01-29 18:57:20 +08:00
|
|
|
methods: {
|
|
|
|
onClick (e) {
|
|
|
|
this.$emit('click', e)
|
|
|
|
},
|
|
|
|
onVisibleChange (val) {
|
|
|
|
this.$emit('visibleChange', val)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
model: {
|
|
|
|
prop: 'visible',
|
|
|
|
event: 'visibleChange',
|
|
|
|
},
|
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
type, disabled,
|
|
|
|
prefixCls, trigger, align,
|
|
|
|
visible, placement, getPopupContainer,
|
|
|
|
...restProps
|
|
|
|
} = this.$props
|
|
|
|
|
|
|
|
const dropdownProps = {
|
|
|
|
props: {
|
|
|
|
align,
|
|
|
|
disabled,
|
|
|
|
trigger: disabled ? [] : trigger,
|
|
|
|
placement,
|
|
|
|
getPopupContainer,
|
|
|
|
},
|
|
|
|
on: {
|
|
|
|
visibleChange: this.onVisibleChange,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
if (hasProp(this, 'visible')) {
|
2018-02-03 22:06:18 +08:00
|
|
|
dropdownProps.props.visible = visible
|
2018-01-29 18:57:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ButtonGroup
|
|
|
|
{...restProps}
|
|
|
|
class={prefixCls}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
type={type}
|
|
|
|
disabled={disabled}
|
|
|
|
onClick={this.onClick}
|
|
|
|
>
|
|
|
|
{this.$slots.default}
|
|
|
|
</Button>
|
|
|
|
<Dropdown {...dropdownProps}>
|
|
|
|
<template slot='overlay'>
|
|
|
|
{getComponentFromProp(this, 'overlay')}
|
|
|
|
</template>
|
2018-09-05 21:28:54 +08:00
|
|
|
<Button type={type} icon='ellipsis' />
|
2018-01-29 18:57:20 +08:00
|
|
|
</Dropdown>
|
|
|
|
</ButtonGroup>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|