File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ import { defineComponent , h } from 'vue'
2+
3+ const CFormFeedback = defineComponent ( {
4+ name : 'CFormFeedback' ,
5+ props : {
6+ /**
7+ * Component used for the root node. Either a string to use a HTML element or a component.
8+ *
9+ * @default 'div'
10+ */
11+ component : {
12+ type : String ,
13+ required : false ,
14+ default : 'div' ,
15+ } ,
16+ /**
17+ * Method called immediately after the `value` prop changes.
18+ */
19+ invalid : Boolean ,
20+ /**
21+ * If your form layout allows it, you can display validation feedback in a styled tooltip.
22+ */
23+ tooltip : Boolean ,
24+ /**
25+ * Set component validation state to valid.
26+ */
27+ valid : Boolean ,
28+ } ,
29+ setup ( props , { slots } ) {
30+ return ( ) =>
31+ h (
32+ props . component ,
33+ {
34+ class : [
35+ {
36+ [ `invalid-${ props . tooltip ? 'tooltip' : 'feedback' } ` ] : props . invalid ,
37+ [ `valid-${ props . tooltip ? 'tooltip' : 'feedback' } ` ] : props . valid ,
38+ } ,
39+ ] ,
40+ } ,
41+ slots . default && slots . default ( ) ,
42+ )
43+ } ,
44+ } )
45+
46+ export { CFormFeedback }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { App } from 'vue'
22import { CForm } from './CForm'
33import { CFormCheck } from './CFormCheck'
44import { CFormControl } from './CFormControl'
5+ import { CFormFeedback } from './CFormFeedback'
56import { CFormFloating } from './CFormFloating'
67import { CFormInput } from './CFormInput'
78import { CFormLabel } from './CFormLabel'
@@ -18,6 +19,7 @@ const CFormPlugin = {
1819 app . component ( CForm . name , CForm )
1920 app . component ( CFormCheck . name , CFormCheck )
2021 app . component ( CFormControl . name , CFormControl )
22+ app . component ( CFormFeedback . name , CFormFeedback )
2123 app . component ( CFormFloating . name , CFormFloating )
2224 app . component ( CFormInput . name , CFormInput )
2325 app . component ( CFormLabel . name , CFormLabel )
@@ -36,6 +38,7 @@ export {
3638 CForm ,
3739 CFormCheck ,
3840 CFormControl ,
41+ CFormFeedback ,
3942 CFormFloating ,
4043 CFormInput ,
4144 CFormLabel ,
You can’t perform that action at this time.
0 commit comments