16
16
theme.default.input,
17
17
theme.default.borderRadius,
18
18
{
19
- 'mb-2': index !== options.length,
20
19
'!ring-red-500 !ring-2 !border-transparent': hasError,
21
20
'!cursor-not-allowed !bg-gray-200': disabled,
22
21
},
23
22
]"
24
23
>
25
- <template
26
- v-if =" options && options .length "
27
- >
28
- <div
29
- v-for =" (option) in options"
30
- :key =" option[optionKey]"
31
- :role =" multiple?'checkbox':'radio'"
32
- :aria-checked =" isSelected(option[optionKey])"
33
- :class =" [
34
- theme.FlatSelectInput.spacing.vertical,
35
- theme.FlatSelectInput.fontSize,
36
- theme.FlatSelectInput.option,
37
- ]"
38
- @click =" onSelect(option[optionKey])"
24
+ <template
25
+ v-if =" options && options .length "
39
26
>
40
- <template v-if =" multiple " >
41
- <Icon
42
- v-if =" isSelected(option[optionKey])"
43
- name =" material-symbols:check-box"
44
- class =" text-inherit"
45
- :color =" color"
46
- :class =" [theme.FlatSelectInput.icon]"
47
- />
48
- <Icon
49
- v-else
50
- name =" material-symbols:check-box-outline-blank"
51
- :class =" [theme.FlatSelectInput.icon,theme.FlatSelectInput.unselectedIcon]"
52
- />
53
- </template >
54
- <template v-else >
55
- <Icon
56
- v-if =" isSelected(option[optionKey])"
57
- name =" material-symbols:radio-button-checked-outline"
58
- class =" text-inherit"
59
- :color =" color"
60
- :class =" [theme.FlatSelectInput.icon]"
61
- />
62
- <Icon
63
- v-else
64
- name =" material-symbols:radio-button-unchecked"
65
- :class =" [theme.FlatSelectInput.icon,theme.FlatSelectInput.unselectedIcon]"
66
- />
67
- </template >
68
- <p class =" flex-grow" >
69
- {{ option[displayKey] }}
70
- </p >
71
- </div >
72
- </template >
27
+ <div
28
+ v-for =" (option) in options"
29
+ :key =" option[optionKey]"
30
+ :role =" multiple?'checkbox':'radio'"
31
+ :aria-checked =" isSelected(option[optionKey])"
32
+ :class =" [
33
+ theme.FlatSelectInput.spacing.vertical,
34
+ theme.FlatSelectInput.fontSize,
35
+ theme.FlatSelectInput.option,
36
+ ]"
37
+ @click =" onSelect(option[optionKey])"
38
+ >
39
+ <template v-if =" multiple " >
40
+ <CheckboxIcon
41
+ :is-checked =" isSelected(option[optionKey])"
42
+ :color =" color"
43
+ :theme =" theme"
44
+ />
45
+ </template >
46
+ <template v-else >
47
+ <RadioButtonIcon
48
+ :is-checked =" isSelected(option[optionKey])"
49
+ :color =" color"
50
+ :theme =" theme"
51
+ />
52
+ </template >
53
+ <p class =" flex-grow" >
54
+ {{ option[displayKey] }}
55
+ </p >
56
+ </div >
57
+ </template >
73
58
<div
74
59
v-else
75
60
:class =" [
96
81
<script >
97
82
import {inputProps , useFormInput } from " ./useFormInput.js"
98
83
import InputWrapper from " ./components/InputWrapper.vue"
84
+ import RadioButtonIcon from " ./components/RadioButtonIcon.vue"
85
+ import CheckboxIcon from " ./components/CheckboxIcon.vue"
99
86
100
87
/**
101
88
* Options: {name,value} objects
102
89
*/
103
90
export default {
104
91
name: " FlatSelectInput" ,
105
- components: {InputWrapper},
92
+ components: {InputWrapper, RadioButtonIcon, CheckboxIcon },
106
93
107
94
props: {
108
95
... inputProps,
@@ -156,4 +143,4 @@ export default {
156
143
},
157
144
},
158
145
}
159
- </script >
146
+ </script >
0 commit comments