@@ -549,8 +549,7 @@ return /******/ (function(modules) { // webpackBootstrap
549
549
value : function _inputHtml ( ) {
550
550
return Object . assign ( { } , this . props . inputHtml , {
551
551
type : 'checkbox' ,
552
- value : this . props . key ,
553
- checked : this . props . value ,
552
+ value : this . props . value ,
554
553
onChange : this . props . onChange
555
554
} ) ;
556
555
}
@@ -1331,12 +1330,13 @@ return /******/ (function(modules) { // webpackBootstrap
1331
1330
return Label ;
1332
1331
} ( _react2 . default . Component ) , _class . displayName = 'FriggingBootstrap.Label' , _class . propTypes = {
1333
1332
labelWidth : _react2 . default . PropTypes . object . isRequired ,
1334
- layout : _react2 . default . PropTypes . string . isRequired ,
1333
+ layout : _react2 . default . PropTypes . string ,
1335
1334
block : _react2 . default . PropTypes . bool ,
1336
1335
label : _react2 . default . PropTypes . oneOfType ( [ _react2 . default . PropTypes . string , _react2 . default . PropTypes . element , _react2 . default . PropTypes . bool ] )
1337
1336
} , _class . defaultProps = {
1338
1337
block : false ,
1339
- label : ''
1338
+ label : '' ,
1339
+ layout : 'vertical'
1340
1340
} , _temp ) ;
1341
1341
exports . default = Label ;
1342
1342
@@ -1425,7 +1425,6 @@ return /******/ (function(modules) { // webpackBootstrap
1425
1425
{
1426
1426
className : ( 0 , _classnames2 . default ) ( {
1427
1427
'frigb-map' : true ,
1428
- 'frigb-active' : this . props . active ,
1429
1428
'frigb-dark' : luminosity <= 128 ,
1430
1429
'frigb-light' : luminosity > 128
1431
1430
} ) ,
@@ -1462,8 +1461,7 @@ return /******/ (function(modules) { // webpackBootstrap
1462
1461
requestChange : _react2 . default . PropTypes . func . isRequired
1463
1462
} ) . isRequired ,
1464
1463
1465
- active : _react2 . default . PropTypes . bool . isRequired ,
1466
- startDragging : _react2 . default . PropTypes . bool . isRequired ,
1464
+ startDragging : _react2 . default . PropTypes . func . isRequired ,
1467
1465
getPercentageValue : _react2 . default . PropTypes . func . isRequired
1468
1466
} , _temp ) ) || _class ) ;
1469
1467
exports . default = ColorMap ;
@@ -1694,7 +1692,7 @@ return /******/ (function(modules) { // webpackBootstrap
1694
1692
h : _react2 . default . PropTypes . number . isRequired
1695
1693
} ) . isRequired ,
1696
1694
1697
- startDragging : _react2 . default . PropTypes . bool . isRequired ,
1695
+ startDragging : _react2 . default . PropTypes . func . isRequired ,
1698
1696
getPercentageValue : _react2 . default . PropTypes . func . isRequired
1699
1697
} , _temp ) ) || _class ) ;
1700
1698
exports . default = HueSlider ;
@@ -2125,18 +2123,23 @@ return /******/ (function(modules) { // webpackBootstrap
2125
2123
labelWidth : this . props . labelWidth ,
2126
2124
layout : this . props . layout
2127
2125
} ;
2128
- var inputLabel = _react2 . default . createElement ( _label2 . default , this . props ) ;
2126
+ var inputLabel = _react2 . default . createElement ( _label2 . default , labelProps ) ;
2129
2127
var saved = _react2 . default . createElement ( _saved2 . default , { saved : this . props . saved } ) ;
2130
2128
2131
2129
if ( this . props . prefix || this . props . suffix ) {
2132
- return [ inputLabel , _react2 . default . createElement (
2130
+ return _react2 . default . createElement (
2133
2131
'div' ,
2134
- { className : 'input-group' } ,
2135
- this . _inputPrefix ( ) ,
2136
- this . _input ( ) ,
2137
- saved ,
2138
- this . _inputSuffix ( )
2139
- ) ] ;
2132
+ null ,
2133
+ inputLabel ,
2134
+ _react2 . default . createElement (
2135
+ 'div' ,
2136
+ { className : 'input-group' } ,
2137
+ this . _inputPrefix ( ) ,
2138
+ this . _input ( ) ,
2139
+ saved ,
2140
+ this . _inputSuffix ( )
2141
+ )
2142
+ ) ;
2140
2143
}
2141
2144
2142
2145
return _react2 . default . createElement (
@@ -2365,12 +2368,14 @@ return /******/ (function(modules) { // webpackBootstrap
2365
2368
2366
2369
var _react2 = _interopRequireDefault ( _react ) ;
2367
2370
2371
+ var _reactDom = __webpack_require__ ( 18 ) ;
2372
+
2373
+ var _reactDom2 = _interopRequireDefault ( _reactDom ) ;
2374
+
2368
2375
var _classnames = __webpack_require__ ( 7 ) ;
2369
2376
2370
2377
var _classnames2 = _interopRequireDefault ( _classnames ) ;
2371
2378
2372
- var _frig = __webpack_require__ ( 8 ) ;
2373
-
2374
2379
var _input_error_list = __webpack_require__ ( 9 ) ;
2375
2380
2376
2381
var _input_error_list2 = _interopRequireDefault ( _input_error_list ) ;
@@ -2411,16 +2416,109 @@ return /******/ (function(modules) { // webpackBootstrap
2411
2416
}
2412
2417
2413
2418
_createClass ( Select , [ {
2419
+ key : 'componentWillMount' ,
2420
+ value : function componentWillMount ( ) {
2421
+ var hasOptions = this . props . options . length !== 0 ;
2422
+ if ( hasOptions && this . props . value === '' ) {
2423
+ this . _setInitialValue ( this . props ) ;
2424
+ }
2425
+ }
2426
+ } , {
2427
+ key : 'componentWillReceiveProps' ,
2428
+ value : function componentWillReceiveProps ( nextProps ) {
2429
+ var hasOptions = nextProps . options . length !== 0 ;
2430
+ // Setting the intial value of the select when the options load
2431
+ if ( hasOptions && nextProps . value === '' ) {
2432
+ this . _setInitialValue ( nextProps ) ;
2433
+ }
2434
+ // Blanking the select's value when the options are removed
2435
+ if ( ! hasOptions && nextProps . value !== '' ) {
2436
+ nextProps . onChange ( undefined , { setModified : false } ) ;
2437
+ }
2438
+ }
2439
+
2440
+ // Default a blank value to the first option (if there are no blank options)
2441
+
2442
+ } , {
2443
+ key : '_setInitialValue' ,
2444
+ value : function _setInitialValue ( nextProps ) {
2445
+ if ( nextProps . options . filter ( function ( _ref ) {
2446
+ var value = _ref . value ;
2447
+ return value === '' ;
2448
+ } ) . length > 0 ) {
2449
+ return ;
2450
+ }
2451
+ var value = nextProps . value || nextProps . options [ 0 ] . value ;
2452
+ nextProps . onChange ( value , { setModified : false } ) ;
2453
+ }
2454
+
2455
+ // Reads the value from the DOM for the select input fields
2456
+
2457
+ } , {
2458
+ key : '_getValue' ,
2459
+ value : function _getValue ( ) {
2460
+ var el = _reactDom2 . default . findDOMNode ( this . refs . input ) ;
2461
+ // The value is cast to a string when we get it from DOM.value. This is a
2462
+ // mapping of those strings to their original values in the options list.
2463
+ var originalValues = { } ;
2464
+ var _iteratorNormalCompletion = true ;
2465
+ var _didIteratorError = false ;
2466
+ var _iteratorError = undefined ;
2467
+
2468
+ try {
2469
+ for ( var _iterator = this . props . options [ Symbol . iterator ] ( ) , _step ; ! ( _iteratorNormalCompletion = ( _step = _iterator . next ( ) ) . done ) ; _iteratorNormalCompletion = true ) {
2470
+ var option = _step . value ;
2471
+
2472
+ var valueHash = option . value . toString ( ) ;
2473
+ originalValues [ valueHash ] = option . value ;
2474
+ }
2475
+ } catch ( err ) {
2476
+ _didIteratorError = true ;
2477
+ _iteratorError = err ;
2478
+ } finally {
2479
+ try {
2480
+ if ( ! _iteratorNormalCompletion && _iterator . return ) {
2481
+ _iterator . return ( ) ;
2482
+ }
2483
+ } finally {
2484
+ if ( _didIteratorError ) {
2485
+ throw _iteratorError ;
2486
+ }
2487
+ }
2488
+ }
2489
+
2490
+ return originalValues [ el . value ] || el . value ;
2491
+ }
2492
+ } , {
2493
+ key : '_onChange' ,
2494
+ value : function _onChange ( ) {
2495
+ this . props . onChange ( this . _getValue ( ) ) ;
2496
+ }
2497
+ } , {
2414
2498
key : '_inputHtml' ,
2415
2499
value : function _inputHtml ( ) {
2416
2500
return Object . assign ( { } , this . props . inputHtml , {
2417
2501
key : 'input' ,
2502
+ ref : 'input' ,
2418
2503
className : 'form-control' ,
2419
2504
value : this . props . value ,
2420
2505
onChange : this . props . onChange ,
2421
2506
options : this . props . options
2422
2507
} ) ;
2423
2508
}
2509
+ } , {
2510
+ key : '_selectOption' ,
2511
+ value : function _selectOption ( o ) {
2512
+ var attrs = {
2513
+ key : 'option-' + o . label ,
2514
+ value : o . value || ''
2515
+ } ;
2516
+ return _react2 . default . createElement (
2517
+ 'option' ,
2518
+ attrs ,
2519
+ o . label
2520
+ ) ;
2521
+ }
2424
2522
} , {
2425
2523
key : 'render' ,
2426
2524
value : function render ( ) {
@@ -2435,7 +2533,11 @@ return /******/ (function(modules) { // webpackBootstrap
2435
2533
_react2 . default . createElement (
2436
2534
'div' ,
2437
2535
{ className : 'controls' } ,
2438
- _react2 . default . createElement ( _frig . ValueLinkedSelect , this . _inputHtml ( ) ) ,
2536
+ _react2 . default . createElement (
2537
+ 'select' ,
2538
+ this . _inputHtml ( ) ,
2539
+ this . props . options . map ( this . _selectOption )
2540
+ ) ,
2439
2541
_react2 . default . createElement ( _input_error_list2 . default , { errors : this . props . errors } )
2440
2542
) ,
2441
2543
_react2 . default . createElement ( _saved2 . default , { saved : this . props . saved } )
@@ -2446,9 +2548,12 @@ return /******/ (function(modules) { // webpackBootstrap
2446
2548
2447
2549
return Select ;
2448
2550
} ( _react2 . default . Component ) , _class . displayName = 'FriggingBootstrap.Select' , _class . defaultProps = Object . assign ( { } , _default_props2 . default , {
2449
- options : { }
2551
+ options : [ ]
2450
2552
} ) , _class . propTypes = Object . assign ( { } , _default_prop_types2 . default , {
2451
- options : _react2 . default . PropTypes . oneOfType ( [ _react2 . default . PropTypes . array , _react2 . default . PropTypes . object , _react2 . default . PropTypes . string ] )
2553
+ options : _react2 . default . PropTypes . arrayOf ( _react2 . default . PropTypes . shape ( {
2554
+ value : _react2 . default . PropTypes . any . isRequired ,
2555
+ label : _react2 . default . PropTypes . string . isRequired
2556
+ } ) . isRequired )
2452
2557
} ) , _temp ) ;
2453
2558
exports . default = Select ;
2454
2559
0 commit comments