| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 |
| <template>
<div class="mu-icon-menu">
<icon-button :tooltip="tooltip" :tooltipPosition="tooltipPosition" :icon="icon" :iconClass="iconClass" @click="handleOpen">
<slot name="icon"></slot>
</icon-button>
<popover v-if="$slots && $slots.default && $slots.default.length > 0" :open="openMenu" :trigger="trigger" :scroller="scroller" :anchorOrigin="anchorOrigin"
:targetOrigin="targetOrigin" @close="handleClose">
<mu-menu @change="change" :popover="openMenu" :value="value" :class="menuClass" :listClass="menuListClass"
@itemClick="itemClick" :multiple="multiple" :desktop="desktop" :maxHeight="maxHeight">
<slot></slot>
</mu-menu>
</popover>
</div>
</template>
<script>
import iconButton from '../iconButton'
import popover from '../popover'
import {menu} from '../menu'
export default {
name: 'mu-icon-menu',
props: {
icon: {
type: String,
required: true
},
iconClass: {
type: [String, Array, Object]
},
menuClass: {
type: [String, Array, Object]
},
menuListClass: {
type: [String, Array, Object]
},
value: {},
multiple: {
type: Boolean,
default: false
},
desktop: {
type: Boolean,
default: false
},
open: {
type: Boolean,
default: false
},
maxHeight: {
type: Number
},
anchorOrigin: {
type: Object,
default () {
return {
vertical: 'top',
horizontal: 'left'
}
}
},
targetOrigin: {
type: Object,
default () {
return {
vertical: 'top',
horizontal: 'left'
}
}
},
scroller: {
type: [HTMLDocument, Element, Window]
},
itemClickClose: {
type: Boolean,
default: true
},
tooltip: {
type: String
},
tooltipPosition: {
type: String,
default: 'bottom-center'
}
},
data () {
return {
openMenu: this.open,
trigger: null
}
},
methods: {
handleOpen () {
this.openMenu = true
this.$emit('open')
},
handleClose () {
this.openMenu = false
this.$emit('close')
},
change (value) {
this.$emit('change', value)
},
itemClick (item) {
if (this.itemClickClose) {
this.handleClose()
}
this.$emit('itemClick', item)
this.$emit('item-click', item)
}
},
mounted () {
this.trigger = this.$el
},
watch: {
open (val, oldVal) {
if (val === oldVal) return
this.openMenu = val
}
},
components: {
'icon-button': iconButton,
popover,
'mu-menu': menu
}
}
</script>
<style lang="css">
.mu-icon-menu{
display: inline-block;
position: relative;
}
</style>
|