File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 2
2
<div class =" vfg-select" >
3
3
<span v-on-click-outside =" () => isOpened = false" class =" vfg-select-label" :class =" {'text-muted': !selectedNames.length}" @click.prevent =" onClickInput" >
4
4
<template v-if =" selectedNames .length " >
5
- <span v-for =" (selectedName, index) in selectedNames" :key =" selectedName" >
6
- <template v-if =" index !== 0 " >, </template >{{ selectedName }}
5
+ <span >
6
+ <template v-for =" (selectedName , index ) in selectedNames " :key =" selectedName " >
7
+ <template v-if =" index !== 0 " >, </template >{{ selectedName }}
8
+ </template >
7
9
</span >
8
10
</template >
9
11
<template v-else >{{ field.placeholder || 'Select an option' }}</template >
10
12
<span class =" vfg-fi vfg-fi-right" >
13
+ <!-- X-Mark Icon from https://heroicons.com -->
14
+ <span v-if =" hasValue" @click.prevent =" resetSelection" >
15
+ <svg
16
+ xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24"
17
+ stroke-width =" 1.5"
18
+ stroke =" currentColor"
19
+ >
20
+ <path stroke-linecap =" round" stroke-linejoin =" round" d =" M6 18 18 6M6 6l12 12" />
21
+ </svg >
22
+ </span >
11
23
<!-- ChevronDown from https://heroicons.com -->
12
24
<svg
13
25
xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24"
@@ -67,6 +79,9 @@ export default {
67
79
} else {
68
80
return [ this .field .options .find (o => o .value === this .currentModelValue ).name ]
69
81
}
82
+ },
83
+ hasValue () {
84
+ return this .field .multiple ? this .currentModelValue .length : this .currentModelValue
70
85
}
71
86
},
72
87
methods: {
@@ -77,6 +92,9 @@ export default {
77
92
}
78
93
this .isOpened = true
79
94
},
95
+ resetSelection () {
96
+ this .$emit (' onInput' , this .field .multiple ? [] : ' ' )
97
+ },
80
98
isSelected (option ) {
81
99
return this .currentModelValue ? .includes (option .value ) ?? false
82
100
},
You can’t perform that action at this time.
0 commit comments