2021-05-22 15:29:06 -05:00
|
|
|
<template>
|
|
|
|
<div class="field">
|
2021-06-11 23:38:16 -05:00
|
|
|
<span class="field-title" v-if="title">{{ title }}</span>
|
2021-05-22 15:29:06 -05:00
|
|
|
<v-select :options="options" :value="value" @input="setSelected" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import vSelect from 'vue-select';
|
|
|
|
import './fields.css';
|
|
|
|
import 'vue-select/dist/vue-select.css';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Select',
|
|
|
|
props: {
|
|
|
|
title: String,
|
|
|
|
options: Array, // https://vue-select.org/guide/options.html#options-prop
|
2021-06-11 23:38:16 -05:00
|
|
|
value: [ String, Object ],
|
|
|
|
default: [ String, Object ]
|
2021-05-22 15:29:06 -05:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
vSelect
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setSelected(option) {
|
|
|
|
const value = option?.value || this.default;
|
|
|
|
this.$emit('change', value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
span {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.v-select {
|
|
|
|
width: 50%;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.v-select .vs__dropdown-toggle {
|
|
|
|
border-color: rgba(var(--color), .26);
|
|
|
|
}
|
|
|
|
|
|
|
|
.v-select .vs__selected {
|
|
|
|
color: var(--color);
|
|
|
|
}
|
|
|
|
|
|
|
|
.v-select .vs__clear,
|
|
|
|
.v-select .vs__open-indicator {
|
|
|
|
fill: var(--color);
|
|
|
|
opacity: .5;
|
|
|
|
}
|
|
|
|
|
|
|
|
.v-select .vs__dropdown-menu {
|
|
|
|
background: var(--background);
|
|
|
|
border-color: rgba(var(--color), .26);
|
|
|
|
}
|
|
|
|
|
|
|
|
.v-select .vs__dropdown-option {
|
|
|
|
color: var(--color);
|
|
|
|
}
|
|
|
|
</style>
|