33import React from 'react' ;
44import PropTypes from 'prop-types' ;
55import classNames from 'classnames' ;
6- import { mapToCssModules , deprecated } from './utils' ;
6+ import { mapToCssModules , deprecated , warnOnce } from './utils' ;
77
88const propTypes = {
99 children : PropTypes . node ,
1010 type : PropTypes . string ,
1111 size : PropTypes . string ,
12+ bsSize : PropTypes . string ,
1213 state : deprecated ( PropTypes . string , 'Please use the prop "valid"' ) ,
1314 valid : PropTypes . bool ,
1415 tag : PropTypes . oneOfType ( [ PropTypes . func , PropTypes . string ] ) ,
@@ -31,7 +32,7 @@ class Input extends React.Component {
3132 className,
3233 cssModule,
3334 type,
34- size ,
35+ bsSize ,
3536 state,
3637 valid,
3738 tag,
@@ -43,6 +44,7 @@ class Input extends React.Component {
4344 } = this . props ;
4445
4546 const checkInput = [ 'radio' , 'checkbox' ] . indexOf ( type ) > - 1 ;
47+ const isNotaNumber = new RegExp ( '\\D' , 'g' ) ;
4648
4749 const fileInput = type === 'file' ;
4850 const textareaInput = type === 'textarea' ;
@@ -72,11 +74,17 @@ class Input extends React.Component {
7274 }
7375 }
7476
77+ if ( attributes . size && isNotaNumber . test ( attributes . size ) ) {
78+ warnOnce ( 'Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.' ) ;
79+ bsSize = attributes . size ;
80+ delete attributes . size ;
81+ }
82+
7583 const classes = mapToCssModules ( classNames (
7684 className ,
7785 valid === false && 'is-invalid' ,
7886 valid && 'is-valid' ,
79- size ? `form-control-${ size } ` : false ,
87+ bsSize ? `form-control-${ bsSize } ` : false ,
8088 formControlClass
8189 ) , cssModule ) ;
8290
0 commit comments