@@ -15,7 +15,11 @@ export default defineComponent({
15
15
setup(props , { emit }) {
16
16
return () => {
17
17
const { onInput, onFocus, onBlur } = useInputEvents (props , emit );
18
- const { isRequired } = useInputValidation (props , emit );
18
+ const {
19
+ isRequired,
20
+ errorMessages,
21
+ isPendingValidation,
22
+ } = useInputValidation (props , emit );
19
23
20
24
const formattedOptions = computed (() => {
21
25
if (isObject (props ?.control ?.options )) {
@@ -27,26 +31,39 @@ export default defineComponent({
27
31
const options = formattedOptions .value .map (({ key , value , disabled }) =>
28
32
h (' option' , { key , value: key , disabled }, value ),
29
33
);
30
- return h (
31
- ' select' ,
32
- {
33
- id: props .control .name ,
34
- name: props ?.control ?.name || ' ' ,
35
- class: [' form-control' ],
36
- value: props ?.control ?.value ,
37
- disabled: props ?.control ?.disabled ,
38
- placeholder: props ?.control ?.placeholder ,
39
- required: isRequired .value ,
40
- readonly: props ?.control .readonly ,
41
- ariaLabel: props .control .ariaLabel ,
42
- ariaLabelledBy: props .control .ariaLabelledBy ,
43
- ariaRequired: isRequired .value ,
44
- onFocus ,
45
- onBlur ,
46
- onInput ,
47
- },
48
- options ,
49
- );
34
+ return [
35
+ h (
36
+ ' select' ,
37
+ {
38
+ id: props .control .name ,
39
+ name: props ?.control ?.name || ' ' ,
40
+ class: [' form-control' ],
41
+ value: props ?.control ?.value ,
42
+ disabled: props ?.control ?.disabled ,
43
+ placeholder: props ?.control ?.placeholder ,
44
+ required: isRequired .value ,
45
+ readonly: props ?.control .readonly ,
46
+ ariaLabel: props .control .ariaLabel ,
47
+ ariaLabelledBy: props .control .ariaLabelledBy ,
48
+ ariaRequired: isRequired .value ,
49
+ onFocus ,
50
+ onBlur ,
51
+ onInput ,
52
+ },
53
+ options ,
54
+ ),
55
+ isPendingValidation .value
56
+ ? null
57
+ : h (
58
+ ' div' ,
59
+ {
60
+ class: ' form-errors' ,
61
+ },
62
+ errorMessages .value .map (error =>
63
+ h (' p' , { class: ' form-error' }, error ),
64
+ ),
65
+ ),
66
+ ];
50
67
};
51
68
},
52
69
});
0 commit comments