11import React from 'react' ;
2- import createClass from 'create-react-class' ;
32import PropTypes from 'prop-types' ;
43import classNames from 'classnames' ;
54
6- const Value = createClass ( {
5+ class Value extends React . Component {
76
8- displayName : 'Value' ,
7+ constructor ( props ) {
8+ super ( props ) ;
99
10- propTypes : {
11- children : PropTypes . node ,
12- disabled : PropTypes . bool , // disabled prop passed to ReactSelect
13- id : PropTypes . string , // Unique id for the value - used for aria
14- onClick : PropTypes . func , // method to handle click on value label
15- onRemove : PropTypes . func , // method to handle removal of the value
16- value : PropTypes . object . isRequired , // the option object for this value
17- } ,
10+ this . handleMouseDown = this . handleMouseDown . bind ( this ) ;
11+ this . onRemove = this . onRemove . bind ( this ) ;
12+ this . handleTouchEndRemove = this . handleTouchEndRemove . bind ( this ) ;
13+ this . handleTouchMove = this . handleTouchMove . bind ( this ) ;
14+ this . handleTouchStart = this . handleTouchStart . bind ( this ) ;
15+ }
1816
1917 handleMouseDown ( event ) {
2018 if ( event . type === 'mousedown' && event . button !== 0 ) {
@@ -28,13 +26,13 @@ const Value = createClass({
2826 if ( this . props . value . href ) {
2927 event . stopPropagation ( ) ;
3028 }
31- } ,
29+ }
3230
3331 onRemove ( event ) {
3432 event . preventDefault ( ) ;
3533 event . stopPropagation ( ) ;
3634 this . props . onRemove ( this . props . value ) ;
37- } ,
35+ }
3836
3937 handleTouchEndRemove ( event ) {
4038 // Check if the view is being dragged, In this case
@@ -43,17 +41,17 @@ const Value = createClass({
4341
4442 // Fire the mouse events
4543 this . onRemove ( event ) ;
46- } ,
44+ }
4745
4846 handleTouchMove ( event ) {
4947 // Set a flag that the view is being dragged
5048 this . dragging = true ;
51- } ,
49+ }
5250
5351 handleTouchStart ( event ) {
5452 // Set a flag that the view is not being dragged
5553 this . dragging = false ;
56- } ,
54+ }
5755
5856 renderRemoveIcon ( ) {
5957 if ( this . props . disabled || ! this . props . onRemove ) return ;
@@ -67,7 +65,7 @@ const Value = createClass({
6765 ×
6866 </ span >
6967 ) ;
70- } ,
68+ }
7169
7270 renderLabel ( ) {
7371 let className = 'Select-value-label' ;
@@ -80,7 +78,7 @@ const Value = createClass({
8078 { this . props . children }
8179 </ span >
8280 ) ;
83- } ,
81+ }
8482
8583 render ( ) {
8684 return (
@@ -93,7 +91,16 @@ const Value = createClass({
9391 </ div >
9492 ) ;
9593 }
94+ } ;
95+
9696
97- } ) ;
97+ Value . propTypes = {
98+ children : PropTypes . node ,
99+ disabled : PropTypes . bool , // disabled prop passed to ReactSelect
100+ id : PropTypes . string , // Unique id for the value - used for aria
101+ onClick : PropTypes . func , // method to handle click on value label
102+ onRemove : PropTypes . func , // method to handle removal of the value
103+ value : PropTypes . object . isRequired , // the option object for this value
104+ } ;
98105
99106module . exports = Value ;
0 commit comments