@@ -157,6 +157,7 @@ function renderSliders(inputRange) {
157
157
ariaLabelledby : inputRange . props . ariaLabelledby ,
158
158
ariaControls : inputRange . props . ariaControls ,
159
159
classNames : classNames ,
160
+ formatLabel : inputRange . formatLabel ,
160
161
key : key ,
161
162
maxValue : maxValue ,
162
163
minValue : minValue ,
@@ -231,7 +232,7 @@ var InputRange = (function (_React$Component) {
231
232
232
233
internals . set ( this , { } ) ;
233
234
234
- ( 0 , _util . autobind ) ( [ 'handleInteractionEnd' , 'handleInteractionStart' , 'handleKeyDown' , 'handleKeyUp' , 'handleMouseDown' , 'handleMouseUp' , 'handleSliderKeyDown' , 'handleSliderMouseMove' , 'handleTouchStart' , 'handleTouchEnd' , 'handleTrackMouseDown' ] , this ) ;
235
+ ( 0 , _util . autobind ) ( [ 'formatLabel' , ' handleInteractionEnd', 'handleInteractionStart' , 'handleKeyDown' , 'handleKeyUp' , 'handleMouseDown' , 'handleMouseUp' , 'handleSliderKeyDown' , 'handleSliderMouseMove' , 'handleTouchStart' , 'handleTouchEnd' , 'handleTrackMouseDown' ] , this ) ;
235
236
}
236
237
237
238
_createClass ( InputRange , [ {
@@ -297,6 +298,20 @@ var InputRange = (function (_React$Component) {
297
298
298
299
this . updateValue ( key , value ) ;
299
300
}
301
+ } , {
302
+ key : 'formatLabel' ,
303
+ value : function formatLabel ( labelValue ) {
304
+ var _props = this . props ;
305
+ var formatLabel = _props . formatLabel ;
306
+ var labelPrefix = _props . labelPrefix ;
307
+ var labelSuffix = _props . labelSuffix ;
308
+
309
+ if ( formatLabel ) {
310
+ return formatLabel ( labelValue , { labelPrefix : labelPrefix , labelSuffix : labelSuffix } ) ;
311
+ }
312
+
313
+ return '' + labelPrefix + labelValue + labelSuffix ;
314
+ }
300
315
} , {
301
316
key : 'handleSliderMouseMove' ,
302
317
value : function handleSliderMouseMove ( event , slider ) {
@@ -443,7 +458,8 @@ var InputRange = (function (_React$Component) {
443
458
_Label2 [ 'default' ] ,
444
459
{
445
460
className : classNames . labelMin ,
446
- containerClassName : classNames . labelContainer } ,
461
+ containerClassName : classNames . labelContainer ,
462
+ formatLabel : this . formatLabel } ,
447
463
this . props . minValue
448
464
) ,
449
465
_react2 [ 'default' ] . createElement (
@@ -459,7 +475,8 @@ var InputRange = (function (_React$Component) {
459
475
_Label2 [ 'default' ] ,
460
476
{
461
477
className : classNames . labelMax ,
462
- containerClassName : classNames . labelContainer } ,
478
+ containerClassName : classNames . labelContainer ,
479
+ formatLabel : this . formatLabel } ,
463
480
this . props . maxValue
464
481
) ,
465
482
renderHiddenInputs ( this )
@@ -499,6 +516,9 @@ InputRange.propTypes = {
499
516
classNames : _react2 [ 'default' ] . PropTypes . objectOf ( _react2 [ 'default' ] . PropTypes . string ) ,
500
517
defaultValue : _propTypes . maxMinValuePropType ,
501
518
disabled : _react2 [ 'default' ] . PropTypes . bool ,
519
+ formatLabel : _react2 [ 'default' ] . PropTypes . func ,
520
+ labelPrefix : _react2 [ 'default' ] . PropTypes . string ,
521
+ labelSuffix : _react2 [ 'default' ] . PropTypes . string ,
502
522
maxValue : _propTypes . maxMinValuePropType ,
503
523
minValue : _propTypes . maxMinValuePropType ,
504
524
name : _react2 [ 'default' ] . PropTypes . string ,
@@ -512,6 +532,8 @@ InputRange.defaultProps = {
512
532
classNames : _defaultClassNames2 [ 'default' ] ,
513
533
defaultValue : 0 ,
514
534
disabled : false ,
535
+ labelPrefix : '' ,
536
+ labelSuffix : '' ,
515
537
maxValue : 10 ,
516
538
minValue : 0 ,
517
539
step : 1 ,
@@ -558,13 +580,15 @@ var Label = (function (_React$Component) {
558
580
var className = _props . className ;
559
581
var containerClassName = _props . containerClassName ;
560
582
583
+ var labelValue = this . props . formatLabel ? this . props . formatLabel ( this . props . children ) : this . props . children ;
584
+
561
585
return _react2 [ 'default' ] . createElement (
562
586
'span' ,
563
587
{ className : className } ,
564
588
_react2 [ 'default' ] . createElement (
565
589
'span' ,
566
590
{ className : containerClassName } ,
567
- this . props . children
591
+ labelValue
568
592
)
569
593
) ;
570
594
}
@@ -578,7 +602,8 @@ exports['default'] = Label;
578
602
Label . propTypes = {
579
603
children : _react2 [ 'default' ] . PropTypes . node ,
580
604
className : _react2 [ 'default' ] . PropTypes . string ,
581
- containerClassName : _react2 [ 'default' ] . PropTypes . string
605
+ containerClassName : _react2 [ 'default' ] . PropTypes . string ,
606
+ formatLabel : _react2 [ 'default' ] . PropTypes . func
582
607
} ;
583
608
module . exports = exports [ 'default' ] ;
584
609
@@ -710,7 +735,8 @@ var Slider = (function (_React$Component) {
710
735
_Label2 [ 'default' ] ,
711
736
{
712
737
className : classNames . labelValue ,
713
- containerClassName : classNames . labelContainer } ,
738
+ containerClassName : classNames . labelContainer ,
739
+ formatLabel : this . props . formatLabel } ,
714
740
this . props . value
715
741
) ,
716
742
_react2 [ 'default' ] . createElement ( 'a' , {
@@ -740,6 +766,7 @@ Slider.propTypes = {
740
766
ariaLabelledby : _react2 [ 'default' ] . PropTypes . string ,
741
767
ariaControls : _react2 [ 'default' ] . PropTypes . string ,
742
768
classNames : _react2 [ 'default' ] . PropTypes . objectOf ( _react2 [ 'default' ] . PropTypes . string ) ,
769
+ formatLabel : _react2 [ 'default' ] . PropTypes . func ,
743
770
maxValue : _react2 [ 'default' ] . PropTypes . number ,
744
771
minValue : _react2 [ 'default' ] . PropTypes . number ,
745
772
onSliderKeyDown : _react2 [ 'default' ] . PropTypes . func . isRequired ,
@@ -933,6 +960,20 @@ function maxMinValuePropType(props) {
933
960
Object . defineProperty ( exports , '__esModule' , {
934
961
value : true
935
962
} ) ;
963
+ exports . clamp = clamp ;
964
+ exports . extend = extend ;
965
+ exports . includes = includes ;
966
+ exports . omit = omit ;
967
+ exports . captialize = captialize ;
968
+ exports . distanceTo = distanceTo ;
969
+ exports . length = length ;
970
+ exports . isNumber = isNumber ;
971
+ exports . isObject = isObject ;
972
+ exports . isDefined = isDefined ;
973
+ exports . isEmpty = isEmpty ;
974
+ exports . arrayOf = arrayOf ;
975
+ exports . objectOf = objectOf ;
976
+ exports . autobind = autobind ;
936
977
937
978
function clamp ( value , min , max ) {
938
979
return Math . min ( Math . max ( value , min ) , max ) ;
@@ -1033,23 +1074,6 @@ function autobind(methodNames, instance) {
1033
1074
} ) ;
1034
1075
}
1035
1076
1036
- exports [ 'default' ] = {
1037
- arrayOf : arrayOf ,
1038
- autobind : autobind ,
1039
- captialize : captialize ,
1040
- clamp : clamp ,
1041
- distanceTo : distanceTo ,
1042
- extend : extend ,
1043
- isDefined : isDefined ,
1044
- isEmpty : isEmpty ,
1045
- isNumber : isNumber ,
1046
- isObject : isObject ,
1047
- length : length ,
1048
- objectOf : objectOf ,
1049
- omit : omit
1050
- } ;
1051
- module . exports = exports [ 'default' ] ;
1052
-
1053
1077
} , { } ] , 8 :[ function ( require , module , exports ) {
1054
1078
'use strict' ;
1055
1079
0 commit comments