2020-10-08 00:01:17 -04:00
|
|
|
<template>
|
2022-05-29 12:49:00 -04:00
|
|
|
<div
|
|
|
|
v-click-away="onClickOutside"
|
|
|
|
class="dropdown"
|
|
|
|
:class="{ 'is-active': is_active }"
|
|
|
|
>
|
2020-10-08 00:01:17 -04:00
|
|
|
<div class="dropdown-trigger">
|
2022-05-29 12:49:00 -04:00
|
|
|
<button
|
|
|
|
class="button"
|
|
|
|
aria-haspopup="true"
|
2023-07-08 08:43:38 -04:00
|
|
|
aria-controls="dropdown"
|
2022-05-29 12:49:00 -04:00
|
|
|
@click="is_active = !is_active"
|
|
|
|
>
|
2022-05-20 07:44:22 -04:00
|
|
|
<span v-text="option.name" />
|
2023-06-30 15:41:40 -04:00
|
|
|
<mdicon class="icon" name="chevron-down" size="16" />
|
2020-10-08 00:01:17 -04:00
|
|
|
</button>
|
|
|
|
</div>
|
2023-07-08 08:43:38 -04:00
|
|
|
<div id="dropdown" class="dropdown-menu" role="menu">
|
2020-10-08 00:01:17 -04:00
|
|
|
<div class="dropdown-content">
|
2022-05-29 12:49:00 -04:00
|
|
|
<a
|
|
|
|
v-for="o in options"
|
|
|
|
:key="o.id"
|
|
|
|
class="dropdown-item"
|
2023-07-08 08:43:38 -04:00
|
|
|
:class="{ 'is-active': value === o.id }"
|
2022-05-29 12:49:00 -04:00
|
|
|
@click="select(o)"
|
|
|
|
v-text="o.name"
|
|
|
|
/>
|
2020-10-08 00:01:17 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2023-07-08 08:43:38 -04:00
|
|
|
name: 'ControlDropdown',
|
|
|
|
props: ['value', 'options'],
|
|
|
|
emits: ['update:value'],
|
2020-10-08 00:01:17 -04:00
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
data() {
|
2020-10-08 00:01:17 -04:00
|
|
|
return {
|
|
|
|
is_active: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-05-20 07:44:22 -04:00
|
|
|
computed: {
|
|
|
|
option: {
|
|
|
|
get() {
|
2023-07-08 08:43:38 -04:00
|
|
|
return this.options.find((option) => option.id === this.value)
|
2022-05-20 07:44:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-08 00:01:17 -04:00
|
|
|
methods: {
|
2022-02-19 00:39:14 -05:00
|
|
|
onClickOutside(event) {
|
2020-10-08 00:01:17 -04:00
|
|
|
this.is_active = false
|
|
|
|
},
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
select(option) {
|
2020-10-08 00:01:17 -04:00
|
|
|
this.is_active = false
|
2023-07-08 08:43:38 -04:00
|
|
|
this.$emit('update:value', option.id)
|
2020-10-08 00:01:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
<style></style>
|