@@ -5,6 +5,8 @@ import { defineComponent, PropType, computed, h } from 'vue';
5
5
import TextInput from ' ../text-input/TextInput.vue' ;
6
6
import SelectInput from ' ../select-input/SelectInput.vue' ;
7
7
import TextAreaInput from ' ../text-area-input/TextAreaInput.vue' ;
8
+ import CheckboxInput from ' ../checkbox-input/CheckboxInput.vue' ;
9
+ import RadioInput from ' ../radio-input/RadioInput.vue' ;
8
10
9
11
import { FormControl } from ' ../../core/models' ;
10
12
import { isEmpty , entries , values , keys } from ' ../../core/utils/helpers' ;
@@ -13,6 +15,8 @@ const components = {
13
15
TextInput ,
14
16
SelectInput ,
15
17
TextAreaInput ,
18
+ CheckboxInput ,
19
+ RadioInput ,
16
20
};
17
21
18
22
const props = {
@@ -32,6 +36,9 @@ export default defineComponent({
32
36
return [
33
37
' dynamic-input' ,
34
38
' form-group' ,
39
+ {
40
+ ' form-group--inline' : props ?.control ?.type === ' checkbox' ,
41
+ },
35
42
{
36
43
' form-group--error' : showErrors .value ,
37
44
},
@@ -103,6 +110,9 @@ export default defineComponent({
103
110
};
104
111
});
105
112
113
+ const hasLabel = computed (() => props ?.control ?.type !== ' checkbox' );
114
+ const isFieldSet = computed (() => props ?.control ?.type === ' radio' );
115
+
106
116
return () => {
107
117
switch (props ?.control ?.type ) {
108
118
case ' text' :
@@ -117,24 +127,32 @@ export default defineComponent({
117
127
case ' textarea' :
118
128
component = h (TextAreaInput , attributes .value );
119
129
break ;
120
-
130
+ case ' checkbox' :
131
+ component = h (CheckboxInput , attributes .value );
132
+ break ;
133
+ case ' radio' :
134
+ component = h (RadioInput , attributes .value );
135
+ break ;
121
136
default :
122
137
break ;
123
138
}
124
139
return h (
125
- ' div' ,
140
+ isFieldSet . value ? ' fieldset ' : ' div' ,
126
141
{
127
142
class: getClasses .value ,
143
+ role: isFieldSet .value ? undefined : ' group' ,
128
144
},
129
145
[
130
- h (
131
- ' label' ,
132
- {
133
- class: ' form-label' ,
134
- for: props ?.control ?.label ,
135
- },
136
- props ?.control ?.label ,
137
- ),
146
+ hasLabel .value
147
+ ? h (
148
+ isFieldSet .value ? ' legend' : ' label' ,
149
+ {
150
+ class: ' form-label' ,
151
+ for: props ?.control ?.label ,
152
+ },
153
+ props ?.control ?.label ,
154
+ )
155
+ : null ,
138
156
component ,
139
157
h (
140
158
' div' ,
0 commit comments