-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathslds-button-group-dropdown.vue
55 lines (49 loc) · 1.62 KB
/
slds-button-group-dropdown.vue
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
<template>
<transition name="dropdown-right">
<div v-if="isOpen" class="slds-dropdown slds-dropdown_right slds-dropdown_actions">
<ul class="slds-dropdown__list" role="menu">
<li
v-for="(option, index) in dropdownOptions"
:key="index"
class="slds-dropdown__item"
role="presentation"
@click="handleClickOption(option)"
>
<a role="menuitem" tabindex="0">
<span class="slds-truncate">
{{ option.label }}
</span>
</a>
</li>
</ul>
</div>
</transition>
</template>
<script lang="ts">
import { defineComponent, PropType } from "vue"
import { DropdownOption } from "../slds-dropdown/dropdown-option"
import { EVENTS } from "../../constants"
export default defineComponent({
name: "SldsButtonGroupDropdown",
props: {
/**
* Dropdown options.
*/
dropdownOptions: { type: Array as PropType<DropdownOption[]>, default: () => [] as DropdownOption[] },
/**
* Indicates whether the dropdown is open.
*/
isOpen: { type: Boolean, required: true },
},
methods: {
/**
* Handles the click event on the option.
* @param option Clicked option.
*/
handleClickOption(option: DropdownOption): void {
if (option.isDivider || option.isHeading) return
this.$emit(EVENTS.CLICK_OPTION, option)
},
},
})
</script>