forked from FreeTubeApp/FreeTube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft-select.js
79 lines (77 loc) · 1.67 KB
/
ft-select.js
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
import { defineComponent, nextTick } from 'vue'
import FtTooltip from '../ft-tooltip/ft-tooltip.vue'
import { sanitizeForHtmlId } from '../../helpers/accessibility'
export default defineComponent({
name: 'FtSelect',
components: {
'ft-tooltip': FtTooltip
},
props: {
placeholder: {
type: String,
required: true
},
value: {
type: [String, Number],
required: true
},
selectNames: {
type: Array,
required: true
},
selectValues: {
type: Array,
required: true
},
tooltip: {
type: String,
default: ''
},
disabled: {
type: Boolean,
default: false
},
sanitizedId: {
type: String,
default: null
},
describeById: {
type: String,
default: null
},
icon: {
type: Array,
required: true
},
iconColor: {
type: String,
default: null
},
isLocaleSelector: {
type: Boolean,
default: false
}
},
emits: ['change'],
computed: {
sanitizedPlaceholder: function() {
return sanitizeForHtmlId(this.placeholder)
}
},
watch: {
// update the selected value in the menu when the list of values changes
// e.g. when you change the display language, the locations list gets updated
// as the locations list is sorted alphabetically for the language, the ordering can be different
// so we need to ensure that the correct location is selected after a language change
selectValues: function () {
nextTick(() => {
this.$refs.select.value = this.value
})
}
},
methods: {
change: function(value) {
this.$emit('change', value)
}
}
})