1
1
'use strict' ;
2
2
3
- var _reactTransformHmr2 = require ( 'react-transform-hmr' ) ;
4
-
5
- var _reactTransformHmr3 = _interopRequireDefault ( _reactTransformHmr2 ) ;
6
-
7
- var _react = require ( 'react' ) ;
8
-
9
3
Object . defineProperty ( exports , '__esModule' , {
10
4
value : true
11
5
} ) ;
@@ -14,53 +8,63 @@ var _createClass = (function () { function defineProperties(target, props) { for
14
8
15
9
var _get = function get ( _x , _x2 , _x3 ) { var _again = true ; _function: while ( _again ) { var object = _x , property = _x2 , receiver = _x3 ; _again = false ; if ( object === null ) object = Function . prototype ; var desc = Object . getOwnPropertyDescriptor ( object , property ) ; if ( desc === undefined ) { var parent = Object . getPrototypeOf ( object ) ; if ( parent === null ) { return undefined ; } else { _x = parent ; _x2 = property ; _x3 = receiver ; _again = true ; desc = parent = undefined ; continue _function; } } else if ( 'value' in desc ) { return desc . value ; } else { var getter = desc . get ; if ( getter === undefined ) { return undefined ; } return getter . call ( receiver ) ; } } } ;
16
10
17
- function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
18
-
19
- function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ; }
11
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { 'default' : obj } ; }
20
12
21
- var _react2 = _interopRequireDefault ( _react ) ;
13
+ function _defineProperty ( obj , key , value ) { if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
22
14
23
- var _classnames = require ( 'classnames ') ;
15
+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function ') ; } }
24
16
25
- var _classnames2 = _interopRequireDefault ( _classnames ) ;
17
+ function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ; }
26
18
27
- var _components = {
28
- _$ProgressBar : {
29
- displayName : 'ProgressBar'
30
- }
31
- } ;
19
+ var _react = require ( 'react' ) ;
32
20
33
- var _reactComponentWrapper = ( 0 , _reactTransformHmr3 [ 'default' ] ) ( {
34
- filename : '/home/dmitry/projects/react-progress-bar-plus/src/ProgressBar.js' ,
35
- components : _components ,
36
- locals : [ module ] ,
37
- imports : [ _react ]
38
- } ) ;
21
+ var _react2 = _interopRequireDefault ( _react ) ;
39
22
40
- function _wrapComponent ( uniqueId ) {
41
- return function ( ReactClass ) {
42
- return _reactComponentWrapper ( ReactClass , uniqueId ) ;
43
- } ;
44
- }
23
+ var _classnames2 = require ( 'classnames' ) ;
45
24
46
- function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { 'default' : obj } ; }
25
+ var _classnames3 = _interopRequireDefault ( _classnames2 ) ;
47
26
48
27
var ProgressBar = ( function ( _React$Component ) {
49
28
_inherits ( ProgressBar , _React$Component ) ;
50
29
51
30
function ProgressBar ( ) {
52
31
var _this = this ;
53
32
54
- _classCallCheck ( this , _ProgressBar ) ;
33
+ _classCallCheck ( this , ProgressBar ) ;
55
34
56
- _get ( Object . getPrototypeOf ( _ProgressBar . prototype ) , 'constructor' , this ) . apply ( this , arguments ) ;
35
+ _get ( Object . getPrototypeOf ( ProgressBar . prototype ) , 'constructor' , this ) . apply ( this , arguments ) ;
57
36
58
37
this . state = {
59
38
percent : this . props . percent
60
39
} ;
61
40
41
+ this . componentDidMount = function ( ) {
42
+ _this . handleProps ( _this . props ) ;
43
+ } ;
44
+
45
+ this . componentWillReceiveProps = function ( nextProps ) {
46
+ if ( _this . interval ) {
47
+ clearInterval ( _this . interval ) ;
48
+ }
49
+ if ( _this . timeout ) {
50
+ clearTimeout ( _this . timeout ) ;
51
+ }
52
+ _this . handleProps ( nextProps ) ;
53
+ } ;
54
+
55
+ this . componentWillUnmount = function ( ) {
56
+ if ( _this . interval ) {
57
+ clearInterval ( _this . interval ) ;
58
+ }
59
+ if ( _this . timeout ) {
60
+ clearTimeout ( _this . timeout ) ;
61
+ }
62
+ } ;
63
+
62
64
this . increment = function ( ) {
63
- var percent = _this . state . percent + ( Math . random ( ) + 1 - Math . random ( ) ) ;
65
+ var percent = _this . state . percent ;
66
+
67
+ percent = percent + ( Math . random ( ) + 1 - Math . random ( ) ) ;
64
68
percent = percent < 99 ? percent : 99 ;
65
69
_this . setState ( {
66
70
percent : percent
@@ -88,47 +92,29 @@ var ProgressBar = (function (_React$Component) {
88
92
} ) ;
89
93
}
90
94
} ;
91
-
92
- this . componentDidMount = function ( ) {
93
- _this . handleProps ( _this . props ) ;
94
- } ;
95
-
96
- this . componentWillReceiveProps = function ( nextProps ) {
97
- if ( _this . interval ) {
98
- clearInterval ( _this . interval ) ;
99
- }
100
- if ( _this . timeout ) {
101
- clearTimeout ( _this . timeout ) ;
102
- }
103
- _this . handleProps ( nextProps ) ;
104
- } ;
105
-
106
- this . componentWillUnmount = function ( ) {
107
- if ( _this . interval ) {
108
- clearInterval ( _this . interval ) ;
109
- }
110
- if ( _this . timeout ) {
111
- clearTimeout ( _this . timeout ) ;
112
- }
113
- } ;
114
95
}
115
96
116
97
_createClass ( ProgressBar , [ {
117
98
key : 'render' ,
118
99
value : function render ( ) {
119
- var className = ( 0 , _classnames2 [ 'default' ] ) ( {
120
- 'react-progress-bar' : true ,
121
- 'react-progress-bar-on-top' : this . props . onTop ,
122
- 'react-progress-bar-hide' : this . state . percent < 0 || this . state . percent >= 100
100
+ var _props = this . props ;
101
+ var onTop = _props . onTop ;
102
+ var spinner = _props . spinner ;
103
+ var percent = this . state . percent ;
104
+
105
+ var className = ( 0 , _classnames3 [ 'default' ] ) ( 'react-progress-bar' , {
106
+ 'react-progress-bar-on-top' : onTop ,
107
+ 'react-progress-bar-hide' : percent < 0 || percent >= 100
123
108
} ) ;
124
- var style = { width : ( this . state . percent < 0 ? 0 : this . state . percent ) + '%' } ;
109
+ var style = { width : ( percent < 0 ? 0 : percent ) + '%' } ;
110
+ var spinnerClassName = ( 0 , _classnames3 [ 'default' ] ) ( 'react-progress-bar-spinner' , _defineProperty ( { } , 'react-progress-bar-spinner-' + spinner , spinner ) ) ;
125
111
return _react2 [ 'default' ] . createElement (
126
112
'div' ,
127
113
{ className : className } ,
128
114
_react2 [ 'default' ] . createElement ( 'div' , { className : 'react-progress-bar-percent' , style : style } ) ,
129
- this . props . showSpinner ? _react2 [ 'default' ] . createElement (
115
+ spinner ? _react2 [ 'default' ] . createElement (
130
116
'div' ,
131
- { className : 'react-progress-bar-spinner' } ,
117
+ { className : spinnerClassName } ,
132
118
_react2 [ 'default' ] . createElement ( 'div' , { className : 'react-progress-bar-spinner-icon' } )
133
119
) : null
134
120
) ;
@@ -140,7 +126,7 @@ var ProgressBar = (function (_React$Component) {
140
126
onTop : _react2 [ 'default' ] . PropTypes . bool ,
141
127
autoIncrement : _react2 [ 'default' ] . PropTypes . bool ,
142
128
intervalTime : _react2 [ 'default' ] . PropTypes . number ,
143
- showSpinner : _react2 [ 'default' ] . PropTypes . bool
129
+ spinner : _react2 [ 'default' ] . PropTypes . oneOf ( [ false , 'left' , 'right' ] )
144
130
} ,
145
131
enumerable : true
146
132
} , {
@@ -150,13 +136,11 @@ var ProgressBar = (function (_React$Component) {
150
136
onTop : false ,
151
137
autoIncrement : false ,
152
138
intervalTime : 200 ,
153
- showSpinner : true
139
+ spinner : 'left'
154
140
} ,
155
141
enumerable : true
156
142
} ] ) ;
157
143
158
- var _ProgressBar = ProgressBar ;
159
- ProgressBar = _wrapComponent ( '_$ProgressBar' ) ( ProgressBar ) || ProgressBar ;
160
144
return ProgressBar ;
161
145
} ) ( _react2 [ 'default' ] . Component ) ;
162
146
0 commit comments