This repository was archived by the owner on Nov 30, 2020. It is now read-only.
File tree 4 files changed +30
-5
lines changed
4 files changed +30
-5
lines changed Original file line number Diff line number Diff line change 35
35
</form-group >
36
36
<form-group >
37
37
<form-label >Valid State</form-label >
38
- <form-input placeholder =" Valid State.." />
39
- <form-input class =" mt-3" placeholder =" Valid State.. " />
38
+ <form-input valid placeholder =" Valid State.." />
39
+ <form-input tick class =" mt-3" value =" Valid state " />
40
40
</form-group >
41
41
<form-group >
42
42
<form-label >Invalid State</form-label >
43
- <form-input placeholder =" Invalid State.." />
44
- <form-input class =" mt-3" placeholder =" Invalid State.." />
43
+ <form-input invalid placeholder =" Invalid State.." />
44
+ <form-invalid-feedback feedback =" Invalid feedback" />
45
+ <form-input cross class =" mt-3" value =" Invalid state" />
45
46
</form-group >
46
47
<form-group >
47
48
<form-label >Country</form-label >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <input class =" form-control" v-model =" internalValue" @input =" onInput" >
2
+ <input class =" form-control" :class = " className " v-model =" internalValue" @input =" onInput" >
3
3
</template >
4
4
5
5
<script >
6
6
export default {
7
7
name: " form-input" ,
8
8
props: {
9
9
value: {},
10
+ invalid: { default: false , type: Boolean },
11
+ valid: { default: false , type: Boolean },
12
+ tick: {default: false , type: Boolean },
13
+ cross: {default: false , type: Boolean }
10
14
},
11
15
12
16
data : () => ({
13
17
internalValue: null
14
18
}),
15
19
20
+ computed: {
21
+ className () {
22
+ const className = {}
23
+ className[' is-valid' ] = this .valid
24
+ className[' state-valid' ] = this .tick
25
+ className[' is-invalid' ] = this .invalid
26
+ className[' state-invalid' ] = this .cross
27
+ return className
28
+ }
29
+ },
30
+
16
31
methods: {
17
32
onInput () {
18
33
this .$emit (' input' , this .internalValue )
Original file line number Diff line number Diff line change
1
+ export default {
2
+ name : 'form-invalid-feedback' ,
3
+ props : {
4
+ feedback : { default : '' , type : String }
5
+ } ,
6
+ template : `<div class="invalid-feedback"><slot>{{ feedback }}</slot></div>`
7
+ }
Original file line number Diff line number Diff line change 1
1
import FormGroup from './FormGroup'
2
2
import FormInput from './FormInput'
3
+ import FormInvalidFeedback from './FormInvalidFeedback'
3
4
import FormLabel from './FormLabel'
4
5
import FormStaticText from './FormStaticText'
5
6
import FormTextarea from './FormTextarea'
6
7
7
8
export {
8
9
FormGroup ,
9
10
FormInput ,
11
+ FormInvalidFeedback ,
10
12
FormLabel ,
11
13
FormStaticText ,
12
14
FormTextarea
You can’t perform that action at this time.
0 commit comments