File tree Expand file tree Collapse file tree 4 files changed +108
-19
lines changed Expand file tree Collapse file tree 4 files changed +108
-19
lines changed Original file line number Diff line number Diff line change 31
31
"babel-preset-es2015" : " 6.9.0" ,
32
32
"babel-preset-es2015-loose-rollup" : " ^7.0.0" ,
33
33
"babel-preset-stage-0" : " 6.5.0" ,
34
+ "babel-runtime" : " ^6.23.0" ,
34
35
"chai" : " 3.5.0" ,
35
36
"conventional-changelog-cli" : " 1.2.0" ,
36
37
"conventional-github-releaser" : " 1.1.3" ,
74
75
"sinon-chai" : " 2.8.0" ,
75
76
"style-loader" : " 0.13.1" ,
76
77
"uglify-js" : " ^2.6.4" ,
77
- "vue" : " ~2.0.0 " ,
78
- "vue-formly" : " ^2.3.9 " ,
78
+ "vue" : " ^2.2.6 " ,
79
+ "vue-formly" : " ^2.5.0 " ,
79
80
"vue-hot-reload-api" : " 1.3.2" ,
80
81
"vue-html-loader" : " 1.2.3" ,
81
82
"vue-loader" : " 8.5.3" ,
Original file line number Diff line number Diff line change
1
+ import baseField from './baseField' ;
2
+ export default {
3
+ render ( h ) {
4
+ const children = [ ] ;
5
+ const self = this ;
6
+
7
+ // add the label if it needs it
8
+ if ( this . to . label ) children . push (
9
+ h ( 'label' , {
10
+ attrs : {
11
+ 'for' : this . to . id
12
+ }
13
+ } , this . to . label )
14
+ ) ;
15
+
16
+ // add the input
17
+ children . push (
18
+ h ( 'input' , {
19
+ attrs : {
20
+ id : this . to . id ,
21
+ type : this . to . inputType || 'text' ,
22
+ ...this . to . atts
23
+ } ,
24
+ 'class' : {
25
+ 'form-control' : true ,
26
+ ...this . to . classes
27
+ } ,
28
+ domProps : {
29
+ value : self . value
30
+ } ,
31
+ on : {
32
+ input ( event ) {
33
+ self . value = event . target . value ;
34
+ self . $emit ( 'input' , event . target . value ) ;
35
+ } ,
36
+ blur : this . onBlur ,
37
+ focus : this . onFocus ,
38
+ click : this . onClick ,
39
+ change : this . onChange ,
40
+ keyup : this . onKeyup ,
41
+ keydown : this . onKeydown
42
+ }
43
+ } )
44
+ ) ;
45
+
46
+ // add the error element
47
+ children . push (
48
+ h ( 'error-display' , {
49
+ props : {
50
+ form : this . form ,
51
+ field : this . field . key
52
+ }
53
+ } )
54
+ ) ;
55
+ return h ( 'div' , {
56
+ 'class' : [
57
+ 'form-group formly-input' ,
58
+ this . to . inputType ,
59
+ this . to . wrapperClasses ,
60
+ {
61
+ 'formly-has-value' : this . model [ this . field . key ] ,
62
+ 'formly-has-focus' : this . form [ this . field . key ] . $active ,
63
+ 'has-error has-danger' : this . hasError
64
+ }
65
+ ]
66
+ } , children ) ;
67
+ } ,
68
+ mixins : [ baseField ] ,
69
+ methods : {
70
+ onChange : function ( e ) {
71
+
72
+ this . $set ( this . form [ this . field . key ] , '$dirty' , true ) ;
73
+ this . runFunction ( 'onChange' , e ) ;
74
+ if ( this . to . inputType == 'file' ) {
75
+ this . $set ( this . model , this . field . key , this . $el . querySelector ( 'input' ) . files ) ;
76
+ }
77
+
78
+ }
79
+ }
80
+ }
Original file line number Diff line number Diff line change 1
- let Fields = require . context ( "./fields/" , false , / ^ \. \/ f i e l d ( [ \w - _ ] + ) \. v u e $ / ) ;
1
+ let Fields = require . context ( "./fields/" , false , / ^ \. \/ f i e l d ( [ \w - _ ] + ) \. j s $ / ) ;
2
2
let FormlyBootstrap = {
3
- install ( Vue , options ) {
4
- Fields . keys ( ) . forEach ( ( key ) => {
5
- //remove all the .vue crap
6
- let component = key
7
- . replace ( / ^ \. \/ / , "" )
8
- . replace ( / \. v u e / , "" )
9
- . replace ( / ^ f i e l d / , "" ) ;
10
-
11
- //convert the first letter to lc
12
- component = component . charAt ( 0 ) . toLowerCase ( ) + component . slice ( 1 ) ;
3
+ install ( Vue , options ) {
4
+ Fields . keys ( ) . forEach ( ( key ) => {
5
+ //remove all the .vue crap
6
+ let component = key
7
+ . replace ( / ^ \. \/ / , "" )
8
+ . replace ( / \. j s / , "" )
9
+ . replace ( / ^ f i e l d / , "" ) ;
10
+ //convert the first letter to lc
11
+ component = component . charAt ( 0 ) . toLowerCase ( ) + component . slice ( 1 ) ;
13
12
14
- Vue . $formly . addType ( component , Fields ( key ) ) ;
15
- } ) ;
16
- }
13
+ Vue . $formly . addType ( component , Fields ( key ) . default ) ;
14
+ } ) ;
15
+ }
17
16
} ;
18
17
19
18
//auto install
20
19
if ( typeof window !== 'undefined' && window . Vue ) {
21
- window . Vue . use ( FormlyBootstrap ) ;
20
+ window . Vue . use ( FormlyBootstrap ) ;
22
21
}
23
22
24
23
export default FormlyBootstrap ;
Original file line number Diff line number Diff line change @@ -17,7 +17,15 @@ function createForm(){
17
17
//el.innerHTML = '<formly-form :form="form" :model="model" :fields="fields"></formly-form>';
18
18
vm = new Vue ( {
19
19
data : data ,
20
- template : '<formly-form :form="form" :model="model" :fields="fields"></formly-form>'
20
+ render ( h ) {
21
+ return h ( 'formly-form' , {
22
+ props : {
23
+ form : this . form ,
24
+ fields : this . fields ,
25
+ model : this . model
26
+ }
27
+ } ) ;
28
+ }
21
29
} ) . $mount ( el ) ;
22
30
23
31
return [ el , vm ] ;
@@ -226,7 +234,6 @@ describe('Bootstrap Field Inputs', () => {
226
234
} ) ;
227
235
} ) ;
228
236
229
-
230
237
describe ( 'conditional elements' , ( ) => {
231
238
describeConditional ( 'input' ) ;
232
239
} ) ;
@@ -293,6 +300,8 @@ describe('Bootstrap Field Inputs', () => {
293
300
} ) ;
294
301
295
302
} ) ;
303
+
304
+ return ;
296
305
297
306
describe ( 'Select' , ( ) => {
298
307
describe ( 'functions' , ( ) => {
You can’t perform that action at this time.
0 commit comments