@@ -15,7 +15,11 @@ export default defineComponent({
1515 setup(props , { emit }) {
1616 return () => {
1717 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 );
1923
2024 const formattedOptions = computed (() => {
2125 if (isObject (props ?.control ?.options )) {
@@ -27,26 +31,39 @@ export default defineComponent({
2731 const options = formattedOptions .value .map (({ key , value , disabled }) =>
2832 h (' option' , { key , value: key , disabled }, value ),
2933 );
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+ ];
5067 };
5168 },
5269});
0 commit comments