react-input-range
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -47,2 +47,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.InputRange = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var internals = new WeakMap(); | ||
var KeyCode = { | ||
@@ -75,2 +77,8 @@ LEFT_ARROW: 37, | ||
function getDocument(inputRange) { | ||
var ownerDocument = inputRange.refs.inputRange.ownerDocument; | ||
return ownerDocument; | ||
} | ||
function getComponentClassName(inputRange) { | ||
@@ -222,3 +230,5 @@ var props = inputRange.props; | ||
(0, _util.autobind)(['handleSliderMouseMove', 'handleSliderKeyDown', 'handleTrackMouseDown'], this); | ||
internals.set(this, {}); | ||
(0, _util.autobind)(['handleInteractionEnd', 'handleInteractionStart', 'handleKeyDown', 'handleKeyUp', 'handleMouseDown', 'handleMouseUp', 'handleSliderKeyDown', 'handleSliderMouseMove', 'handleTouchStart', 'handleTouchEnd', 'handleTrackMouseDown'], this); | ||
} | ||
@@ -291,3 +301,3 @@ | ||
key: 'handleSliderMouseMove', | ||
value: function handleSliderMouseMove(slider, event) { | ||
value: function handleSliderMouseMove(event, slider) { | ||
if (this.props.disabled) { | ||
@@ -304,3 +314,3 @@ return; | ||
key: 'handleSliderKeyDown', | ||
value: function handleSliderKeyDown(slider, event) { | ||
value: function handleSliderKeyDown(event, slider) { | ||
if (this.props.disabled) { | ||
@@ -327,3 +337,3 @@ return; | ||
key: 'handleTrackMouseDown', | ||
value: function handleTrackMouseDown(track, position) { | ||
value: function handleTrackMouseDown(event, track, position) { | ||
if (this.props.disabled) { | ||
@@ -338,2 +348,74 @@ return; | ||
}, { | ||
key: 'handleInteractionStart', | ||
value: function handleInteractionStart() { | ||
var _this = internals.get(this); | ||
if (!this.props.onChangeComplete || (0, _util.isDefined)(_this.startValue)) { | ||
return; | ||
} | ||
_this.startValue = this.props.value; | ||
} | ||
}, { | ||
key: 'handleInteractionEnd', | ||
value: function handleInteractionEnd() { | ||
var _this = internals.get(this); | ||
if (!this.props.onChangeComplete || !(0, _util.isDefined)(_this.startValue)) { | ||
return; | ||
} | ||
if (_this.startValue !== this.props.value) { | ||
this.props.onChangeComplete(this, this.props.value); | ||
} | ||
_this.startValue = null; | ||
} | ||
}, { | ||
key: 'handleKeyDown', | ||
value: function handleKeyDown(event) { | ||
this.handleInteractionStart(event); | ||
} | ||
}, { | ||
key: 'handleKeyUp', | ||
value: function handleKeyUp(event) { | ||
this.handleInteractionEnd(event); | ||
} | ||
}, { | ||
key: 'handleMouseDown', | ||
value: function handleMouseDown(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionStart(event); | ||
document.addEventListener('mouseup', this.handleMouseUp); | ||
} | ||
}, { | ||
key: 'handleMouseUp', | ||
value: function handleMouseUp(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionEnd(event); | ||
document.removeEventListener('mouseup', this.handleMouseUp); | ||
} | ||
}, { | ||
key: 'handleTouchStart', | ||
value: function handleTouchStart(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionStart(event); | ||
document.addEventListener('touchend', this.handleTouchEnd); | ||
} | ||
}, { | ||
key: 'handleTouchEnd', | ||
value: function handleTouchEnd(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionEnd(event); | ||
document.removeEventListener('touchend', this.handleTouchEnd); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -352,3 +434,7 @@ value: function render() { | ||
ref: 'inputRange', | ||
className: componentClassName }, | ||
className: componentClassName, | ||
onKeyDown: this.handleKeyDown, | ||
onKeyUp: this.handleKeyUp, | ||
onMouseDown: this.handleMouseDown, | ||
onTouchStart: this.handleTouchStart }, | ||
_react2['default'].createElement( | ||
@@ -415,2 +501,3 @@ _Label2['default'], | ||
onChange: _react2['default'].PropTypes.func.isRequired, | ||
onChangeComplete: _react2['default'].PropTypes.func, | ||
step: _react2['default'].PropTypes.number, | ||
@@ -576,3 +663,3 @@ value: _propTypes.maxMinValuePropType | ||
value: function handleMouseMove(event) { | ||
this.props.onSliderMouseMove(this, event); | ||
this.props.onSliderMouseMove(event, this); | ||
} | ||
@@ -592,3 +679,3 @@ }, { | ||
value: function handleTouchMove(event) { | ||
this.props.onSliderMouseMove(this, event); | ||
this.props.onSliderMouseMove(event, this); | ||
} | ||
@@ -608,3 +695,3 @@ }, { | ||
value: function handleKeyDown(event) { | ||
this.props.onSliderKeyDown(this, event); | ||
this.props.onSliderKeyDown(event, this); | ||
} | ||
@@ -729,3 +816,3 @@ }, { | ||
this.props.onTrackMouseDown(this, position); | ||
this.props.onTrackMouseDown(event, this, position); | ||
} | ||
@@ -899,2 +986,6 @@ }, { | ||
function isDefined(value) { | ||
return value !== undefined && value !== null; | ||
} | ||
function isEmpty(obj) { | ||
@@ -957,2 +1048,3 @@ if (!obj) { | ||
extend: extend, | ||
isDefined: isDefined, | ||
isEmpty: isEmpty, | ||
@@ -959,0 +1051,0 @@ isNumber: isNumber, |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.InputRange=e()}}(function(){return function e(t,n,r){function a(u,i){if(!n[u]){if(!t[u]){var l="function"==typeof require&&require;if(!i&&l)return l(u,!0);if(o)return o(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return a(n?n:e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)a(r[u]);return a}({1:[function(e,t,n){(function(r){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){var n=e.props;return e.isMultiValue?t.min>=n.minValue&&t.max<=n.maxValue&&t.min<t.max:t.max>=n.minValue&&t.max<=n.maxValue}function l(e,t){var n=e.props,r=R["default"].valuesFromProps(e);return(0,_.length)(t.min,r.min)>=n.step||(0,_.length)(t.max,r.max)>=n.step}function s(e,t){return i(e,t)&&l(e,t)}function f(e){var t=e.props;return t.disabled?t.classNames.component+" is-disabled":t.classNames.component}function p(e,t){return t===e.refs.sliderMin?"min":"max"}function c(e){return e.isMultiValue?["min","max"]:["max"]}function d(e,t){var n=R["default"].valuesFromProps(e),r=R["default"].positionsFromValues(e,n);if(e.isMultiValue){var a=(0,_.distanceTo)(t,r.min),o=(0,_.distanceTo)(t,r.max);if(o>a)return"min"}return"max"}function m(e){var t=e.props.classNames,n=[],r=c(e),a=R["default"].valuesFromProps(e),o=R["default"].percentagesFromValues(e,a),u=!0,i=!1,l=void 0;try{for(var s,f=r[Symbol.iterator]();!(u=(s=f.next()).done);u=!0){var p=s.value,d=a[p],m=o[p],h="slider"+(0,_.captialize)(p),v=e.props,y=v.maxValue,b=v.minValue;"min"===p?y=a.max:b=a.min;var g=w["default"].createElement(M["default"],{classNames:t,key:p,maxValue:y,minValue:b,onSliderKeyDown:e.handleSliderKeyDown,onSliderMouseMove:e.handleSliderMouseMove,percentage:m,ref:h,type:p,value:d});n.push(g)}}catch(O){i=!0,l=O}finally{try{!u&&f["return"]&&f["return"]()}finally{if(i)throw l}}return n}function h(e){var t=[],n=c(e),r=!0,a=!1,o=void 0;try{for(var u,i=n[Symbol.iterator]();!(r=(u=i.next()).done);r=!0){var l=u.value,s=e.isMultiValue?""+e.props.name+(0,_.captialize)(l):e.props.name;w["default"].createElement("input",{type:"hidden",name:s})}}catch(f){a=!0,o=f}finally{try{!r&&i["return"]&&i["return"]()}finally{if(a)throw o}}return t}Object.defineProperty(n,"__esModule",{value:!0});var v=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),y=function(e,t,n){for(var r=!0;r;){var a=e,o=t,u=n;r=!1,null===a&&(a=Function.prototype);var i=Object.getOwnPropertyDescriptor(a,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(a);if(null===s)return;e=s,t=o,n=u,r=!0,i=s=void 0}},b="undefined"!=typeof window?window.React:"undefined"!=typeof r?r.React:null,w=a(b),g=e("./Slider"),M=a(g),O=e("./Track"),P=a(O),V=e("./Label"),T=a(V),x=e("./defaultClassNames"),k=a(x),j=e("./valueTransformer"),R=a(j),_=e("./util"),E=e("./propTypes"),C={LEFT_ARROW:37,RIGHT_ARROW:39},N=function(e){function t(e){o(this,t),y(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),(0,_.autobind)(["handleSliderMouseMove","handleSliderKeyDown","handleTrackMouseDown"],this)}return u(t,e),v(t,[{key:"updatePosition",value:function(e,t){var n=R["default"].valuesFromProps(this),r=R["default"].positionsFromValues(this,n);r[e]=t,this.updatePositions(r)}},{key:"updatePositions",value:function(e){var t={min:R["default"].valueFromPosition(this,e.min),max:R["default"].valueFromPosition(this,e.max)},n={min:R["default"].stepValueFromValue(this,t.min),max:R["default"].stepValueFromValue(this,t.max)};this.updateValues(n)}},{key:"updateValue",value:function(e,t){var n=R["default"].valuesFromProps(this);n[e]=t,this.updateValues(n)}},{key:"updateValues",value:function(e){s(this,e)&&(this.isMultiValue?this.props.onChange(this,e):this.props.onChange(this,e.max))}},{key:"incrementValue",value:function(e){var t=R["default"].valuesFromProps(this),n=t[e]+this.props.step;this.updateValue(e,n)}},{key:"decrementValue",value:function(e){var t=R["default"].valuesFromProps(this),n=t[e]-this.props.step;this.updateValue(e,n)}},{key:"handleSliderMouseMove",value:function(e,t){if(!this.props.disabled){var n=p(this,e),r=R["default"].positionFromEvent(this,t);this.updatePosition(n,r)}}},{key:"handleSliderKeyDown",value:function(e,t){if(!this.props.disabled){var n=p(this,e);switch(t.keyCode){case C.LEFT_ARROW:this.decrementValue(n);break;case C.RIGHT_ARROW:this.incrementValue(n)}}}},{key:"handleTrackMouseDown",value:function(e,t){if(!this.props.disabled){var n=d(this,t);this.updatePosition(n,t)}}},{key:"render",value:function(){var e=this.props.classNames,t=f(this),n=R["default"].valuesFromProps(this),r=R["default"].percentagesFromValues(this,n);return w["default"].createElement("div",{"aria-disabled":this.props.disabled,ref:"inputRange",className:t},w["default"].createElement(T["default"],{className:e.labelMin,containerClassName:e.labelContainer},this.props.minValue),w["default"].createElement(P["default"],{classNames:e,ref:"track",percentages:r,onTrackMouseDown:this.handleTrackMouseDown},m(this)),w["default"].createElement(T["default"],{className:e.labelMax,containerClassName:e.labelContainer},this.props.maxValue),h(this))}},{key:"trackClientRect",get:function(){var e=this.refs.track;return e?e.clientRect:{height:0,left:0,top:0,width:0}}},{key:"isMultiValue",get:function(){return(0,_.isObject)(this.props.value)||(0,_.isObject)(this.props.defaultValue)}}]),t}(w["default"].Component);N.propTypes={ariaLabelledby:w["default"].PropTypes.string,classNames:w["default"].PropTypes.objectOf(w["default"].PropTypes.string),defaultValue:E.maxMinValuePropType,disabled:w["default"].PropTypes.bool,maxValue:E.maxMinValuePropType,minValue:E.maxMinValuePropType,name:w["default"].PropTypes.string,onChange:w["default"].PropTypes.func.isRequired,step:w["default"].PropTypes.number,value:E.maxMinValuePropType},N.defaultProps={classNames:k["default"],defaultValue:0,disabled:!1,maxValue:10,minValue:0,step:1,value:null},n["default"]=N,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Label":2,"./Slider":3,"./Track":4,"./defaultClassNames":5,"./propTypes":6,"./util":7,"./valueTransformer":8}],2:[function(e,t,n){(function(e){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(e,t,n){for(var r=!0;r;){var a=e,o=t,u=n;r=!1,null===a&&(a=Function.prototype);var i=Object.getOwnPropertyDescriptor(a,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(a);if(null===s)return;e=s,t=o,n=u,r=!0,i=s=void 0}},l="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,s=r(l),f=function(e){function t(){a(this,t),i(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return o(t,e),u(t,[{key:"render",value:function(){var e=this.props,t=e.className,n=e.containerClassName;return s["default"].createElement("span",{className:t},s["default"].createElement("span",{className:n},this.props.children))}}]),t}(s["default"].Component);f.propTypes={children:s["default"].PropTypes.node,className:s["default"].PropTypes.string,containerClassName:s["default"].PropTypes.string},n["default"]=f,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(r){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){var t=e.refs.slider.ownerDocument;return t}function l(e){var t=100*(e.props.percentage||0),n={position:"absolute",left:t+"%"};return n}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=function(e,t,n){for(var r=!0;r;){var a=e,o=t,u=n;r=!1,null===a&&(a=Function.prototype);var i=Object.getOwnPropertyDescriptor(a,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(a);if(null===s)return;e=s,t=o,n=u,r=!0,i=s=void 0}},p="undefined"!=typeof window?window.React:"undefined"!=typeof r?r.React:null,c=a(p),d=e("./Label"),m=a(d),h=e("./util"),v=function(e){function t(e){o(this,t),f(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),(0,h.autobind)(["handleClick","handleMouseDown","handleMouseUp","handleMouseMove","handleTouchStart","handleTouchEnd","handleTouchMove","handleKeyDown"],this)}return u(t,e),s(t,[{key:"handleClick",value:function(e){e.preventDefault()}},{key:"handleMouseDown",value:function(){var e=i(this);e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseup",this.handleMouseUp)}},{key:"handleMouseUp",value:function(){var e=i(this);e.removeEventListener("mousemove",this.handleMouseMove),e.removeEventListener("mouseup",this.handleMouseUp)}},{key:"handleMouseMove",value:function(e){this.props.onSliderMouseMove(this,e)}},{key:"handleTouchStart",value:function(e){var t=i(this);e.preventDefault(),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)}},{key:"handleTouchMove",value:function(e){this.props.onSliderMouseMove(this,e)}},{key:"handleTouchEnd",value:function(){var e=i(this);event.preventDefault(),e.removeEventListener("touchmove",this.handleTouchMove),e.removeEventListener("touchend",this.handleTouchEnd)}},{key:"handleKeyDown",value:function(e){this.props.onSliderKeyDown(this,e)}},{key:"render",value:function(){var e=this.props.classNames,t=l(this);return c["default"].createElement("span",{className:e.sliderContainer,ref:"slider",style:t},c["default"].createElement(m["default"],{className:e.labelValue,containerClassName:e.labelContainer},this.props.value),c["default"].createElement("a",{"aria-labelledby":this.props.ariaLabelledby,"aria-valuemax":this.props.maxValue,"aria-valuemin":this.props.minValue,"aria-valuenow":this.props.value,className:e.slider,draggable:"false",href:"#",onClick:this.handleClick,onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onTouchStart:this.handleTouchStart,role:"slider"}))}}]),t}(c["default"].Component);v.propTypes={ariaLabelledby:c["default"].PropTypes.string,classNames:c["default"].PropTypes.objectOf(c["default"].PropTypes.string),maxValue:c["default"].PropTypes.number,minValue:c["default"].PropTypes.number,onSliderKeyDown:c["default"].PropTypes.func.isRequired,onSliderMouseMove:c["default"].PropTypes.func.isRequired,percentage:c["default"].PropTypes.number.isRequired,type:c["default"].PropTypes.string.isRequired,value:c["default"].PropTypes.number.isRequired},n["default"]=v,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Label":2,"./util":7}],4:[function(e,t,n){(function(r){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){var t=e.props,n=100*(t.percentages.max-t.percentages.min)+"%",r=100*t.percentages.min+"%",a={left:r,width:n};return a}Object.defineProperty(n,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(e,t,n){for(var r=!0;r;){var a=e,o=t,u=n;r=!1,null===a&&(a=Function.prototype);var i=Object.getOwnPropertyDescriptor(a,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(a);if(null===s)return;e=s,t=o,n=u,r=!0,i=s=void 0}},f="undefined"!=typeof window?window.React:"undefined"!=typeof r?r.React:null,p=a(f),c=e("./util"),d=function(e){function t(e){o(this,t),s(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),(0,c.autobind)(["handleMouseDown","handleTouchStart"],this)}return u(t,e),l(t,[{key:"handleMouseDown",value:function(e){var t=this.clientRect,n=e.touches?e.touches[0]:e,r=n.clientX,a={x:r-t.left,y:0};this.props.onTrackMouseDown(this,a)}},{key:"handleTouchStart",value:function(e){e.preventDefault(),this.handleMouseDown(e)}},{key:"render",value:function(){var e=i(this),t=this.props.classNames;return p["default"].createElement("div",{className:t.trackContainer,onMouseDown:this.handleMouseDown,onTouchStart:this.handleTouchStart,ref:"track"},p["default"].createElement("div",{style:e,className:t.trackActive}),this.props.children)}},{key:"clientRect",get:function(){var e=this.refs.track,t=e.getClientRects()[0];return t}}]),t}(p["default"].Component);d.propTypes={children:p["default"].PropTypes.node,classNames:p["default"].PropTypes.objectOf(p["default"].PropTypes.string),onTrackMouseDown:p["default"].PropTypes.func.isRequired,percentages:p["default"].PropTypes.objectOf(p["default"].PropTypes.number).isRequired},n["default"]=d,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./util":7}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r={component:"InputRange",labelContainer:"InputRange-labelContainer",labelMax:"InputRange-label InputRange-label--max",labelMin:"InputRange-label InputRange-label--min",labelValue:"InputRange-label InputRange-label--value",slider:"InputRange-slider",sliderContainer:"InputRange-sliderContainer",trackActive:"InputRange-track InputRange-track--active",trackContainer:"InputRange-track InputRange-track--container"};n["default"]=r,t.exports=n["default"]},{}],6:[function(e,t,n){"use strict";function r(e){var t=e.maxValue,n=e.minValue,r=e.value,o=e.defaultValue,u=(0,a.isNumber)(r),i=(0,a.isNumber)(o),l=(0,a.objectOf)(r,a.isNumber),s=(0,a.objectOf)(o,a.isNumber);return void 0===r?new Error("`value` must be defined"):u||i||l||s?n>=t?new Error("`minValue` must be smaller than `maxValue`"):n>=t?new Error("`maxValue` must be larger than `minValue`"):n>r||r>t?new Error("`value` must be within `minValue` and `maxValue`"):void 0:new Error("`value` or `defaultValue` must be a number or an array")}Object.defineProperty(n,"__esModule",{value:!0});var a=e("./util");n.maxMinValuePropType=r},{"./util":7}],7:[function(e,t,n){"use strict";function r(e,t,n){return Math.min(Math.max(e,t),n)}function a(){return Object.assign.apply(Object,arguments)}function o(e,t){return e.indexOf(t)>-1}function u(e,t){var n=Object.keys(e),r={};return n.forEach(function(n){o(t,n)||(r[n]=e[n])}),r}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function s(e,t){return Math.abs(e-t)}function f(e){return"number"==typeof e}function p(e){return null!==e&&"object"==typeof e}function c(e){return e?Array.isArray(e)?0===e.length:0===Object.keys(e).length:!0}function d(e,t){if(!Array.isArray(e))return!1;for(var n=0,r=e.length;r>n;n++)if(!t(e[n]))return!1;return!0}function m(e,t,n){if(!p(e))return!1;for(var r=n||Object.keys(e),a=0,o=r.length;o>a;a++){var u=r[a];if(!t(e[u]))return!1}return!0}function h(e,t){e.forEach(function(e){t[e]=t[e].bind(t)})}Object.defineProperty(n,"__esModule",{value:!0});var v={arrayOf:d,autobind:h,captialize:i,clamp:r,distanceTo:l,extend:a,isEmpty:c,isNumber:f,isObject:p,length:s,objectOf:m,omit:u};n["default"]=v,t.exports=n["default"]},{}],8:[function(e,t,n){"use strict";function r(e,t){var n=e.trackClientRect.width,r=t.x/n;return r||0}function a(e,t){var n=r(e,t),a=e.props.maxValue-e.props.minValue,o=e.props.minValue+a*n;return o}function o(e){var t=arguments.length<=1||void 0===arguments[1]?e:arguments[1],n=t.props;return function(){if(e.isMultiValue){var t=n.value;return((0,c.isEmpty)(t)||!(0,c.objectOf)(t,c.isNumber))&&(t=n.defaultValue),Object.create(t)}var r=(0,c.isNumber)(n.value)?n.value:n.defaultValue;return{min:n.minValue,max:r}}()}function u(e,t){var n=(0,c.clamp)(t,e.props.minValue,e.props.maxValue),r=e.props.maxValue-e.props.minValue,a=(n-e.props.minValue)/r;return a||0}function i(e,t){var n={min:u(e,t.min),max:u(e,t.max)};return n}function l(e,t){var n=e.trackClientRect.width,r=u(e,t),a=r*n;return{x:a,y:0}}function s(e,t){var n={min:l(e,t.min),max:l(e,t.max)};return n}function f(e,t){var n=e.trackClientRect,r=n.width,a=t.touches?t.touches[0]:t,o=a.clientX,u={x:(0,c.clamp)(o-n.left,0,r),y:0};return u}function p(e,t){return Math.round(t/e.props.step)*e.props.step}Object.defineProperty(n,"__esModule",{value:!0});var c=e("./util"),d={percentageFromPosition:r,percentageFromValue:u,percentagesFromValues:i,positionFromEvent:f,positionFromValue:l,positionsFromValues:s,stepValueFromValue:p,valueFromPosition:a,valuesFromProps:o};n["default"]=d,t.exports=n["default"]},{"./util":7}],9:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var a=e("./InputRange"),o=r(a);n["default"]=o["default"],t.exports=n["default"]},{"./InputRange":1}]},{},[9])(9)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.InputRange=e()}}(function(){return function e(t,n,a){function r(u,i){if(!n[u]){if(!t[u]){var l="function"==typeof require&&require;if(!i&&l)return l(u,!0);if(o)return o(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var p=n[u]={exports:{}};t[u][0].call(p.exports,function(e){var n=t[u][1][e];return r(n?n:e)},p,p.exports,e,t,n,a)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<a.length;u++)r(a[u]);return r}({1:[function(e,t,n){(function(a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){var n=e.props;return e.isMultiValue?t.min>=n.minValue&&t.max<=n.maxValue&&t.min<t.max:t.max>=n.minValue&&t.max<=n.maxValue}function l(e,t){var n=e.props,a=R["default"].valuesFromProps(e);return(0,_.length)(t.min,a.min)>=n.step||(0,_.length)(t.max,a.max)>=n.step}function s(e,t){return i(e,t)&&l(e,t)}function p(e){var t=e.refs.inputRange.ownerDocument;return t}function f(e){var t=e.props;return t.disabled?t.classNames.component+" is-disabled":t.classNames.component}function c(e,t){return t===e.refs.sliderMin?"min":"max"}function d(e){return e.isMultiValue?["min","max"]:["max"]}function h(e,t){var n=R["default"].valuesFromProps(e),a=R["default"].positionsFromValues(e,n);if(e.isMultiValue){var r=(0,_.distanceTo)(t,a.min),o=(0,_.distanceTo)(t,a.max);if(o>r)return"min"}return"max"}function v(e){var t=e.props.classNames,n=[],a=d(e),r=R["default"].valuesFromProps(e),o=R["default"].percentagesFromValues(e,r),u=!0,i=!1,l=void 0;try{for(var s,p=a[Symbol.iterator]();!(u=(s=p.next()).done);u=!0){var f=s.value,c=r[f],h=o[f],v="slider"+(0,_.captialize)(f),m=e.props,y=m.maxValue,b=m.minValue;"min"===f?y=r.max:b=r.min;var w=g["default"].createElement(T["default"],{classNames:t,key:f,maxValue:y,minValue:b,onSliderKeyDown:e.handleSliderKeyDown,onSliderMouseMove:e.handleSliderMouseMove,percentage:h,ref:v,type:f,value:c});n.push(w)}}catch(M){i=!0,l=M}finally{try{!u&&p["return"]&&p["return"]()}finally{if(i)throw l}}return n}function m(e){var t=[],n=d(e),a=!0,r=!1,o=void 0;try{for(var u,i=n[Symbol.iterator]();!(a=(u=i.next()).done);a=!0){var l=u.value,s=e.isMultiValue?""+e.props.name+(0,_.captialize)(l):e.props.name;g["default"].createElement("input",{type:"hidden",name:s})}}catch(p){r=!0,o=p}finally{try{!a&&i["return"]&&i["return"]()}finally{if(r)throw o}}return t}Object.defineProperty(n,"__esModule",{value:!0});var y=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),b=function(e,t,n){for(var a=!0;a;){var r=e,o=t,u=n;a=!1,null===r&&(r=Function.prototype);var i=Object.getOwnPropertyDescriptor(r,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(r);if(null===s)return;e=s,t=o,n=u,a=!0,i=s=void 0}},w="undefined"!=typeof window?window.React:"undefined"!=typeof a?a.React:null,g=r(w),M=e("./Slider"),T=r(M),V=e("./Track"),P=r(V),O=e("./Label"),x=r(O),k=e("./defaultClassNames"),E=r(k),j=e("./valueTransformer"),R=r(j),_=e("./util"),C=e("./propTypes"),D=new WeakMap,N={LEFT_ARROW:37,RIGHT_ARROW:39},S=function(e){function t(e){o(this,t),b(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),D.set(this,{}),(0,_.autobind)(["handleInteractionEnd","handleInteractionStart","handleKeyDown","handleKeyUp","handleMouseDown","handleMouseUp","handleSliderKeyDown","handleSliderMouseMove","handleTouchStart","handleTouchEnd","handleTrackMouseDown"],this)}return u(t,e),y(t,[{key:"updatePosition",value:function(e,t){var n=R["default"].valuesFromProps(this),a=R["default"].positionsFromValues(this,n);a[e]=t,this.updatePositions(a)}},{key:"updatePositions",value:function(e){var t={min:R["default"].valueFromPosition(this,e.min),max:R["default"].valueFromPosition(this,e.max)},n={min:R["default"].stepValueFromValue(this,t.min),max:R["default"].stepValueFromValue(this,t.max)};this.updateValues(n)}},{key:"updateValue",value:function(e,t){var n=R["default"].valuesFromProps(this);n[e]=t,this.updateValues(n)}},{key:"updateValues",value:function(e){s(this,e)&&(this.isMultiValue?this.props.onChange(this,e):this.props.onChange(this,e.max))}},{key:"incrementValue",value:function(e){var t=R["default"].valuesFromProps(this),n=t[e]+this.props.step;this.updateValue(e,n)}},{key:"decrementValue",value:function(e){var t=R["default"].valuesFromProps(this),n=t[e]-this.props.step;this.updateValue(e,n)}},{key:"handleSliderMouseMove",value:function(e,t){if(!this.props.disabled){var n=c(this,t),a=R["default"].positionFromEvent(this,e);this.updatePosition(n,a)}}},{key:"handleSliderKeyDown",value:function(e,t){if(!this.props.disabled){var n=c(this,t);switch(e.keyCode){case N.LEFT_ARROW:this.decrementValue(n);break;case N.RIGHT_ARROW:this.incrementValue(n)}}}},{key:"handleTrackMouseDown",value:function(e,t,n){if(!this.props.disabled){var a=h(this,n);this.updatePosition(a,n)}}},{key:"handleInteractionStart",value:function(){var e=D.get(this);this.props.onChangeComplete&&!(0,_.isDefined)(e.startValue)&&(e.startValue=this.props.value)}},{key:"handleInteractionEnd",value:function(){var e=D.get(this);this.props.onChangeComplete&&(0,_.isDefined)(e.startValue)&&(e.startValue!==this.props.value&&this.props.onChangeComplete(this,this.props.value),e.startValue=null)}},{key:"handleKeyDown",value:function(e){this.handleInteractionStart(e)}},{key:"handleKeyUp",value:function(e){this.handleInteractionEnd(e)}},{key:"handleMouseDown",value:function(e){var t=p(this);this.handleInteractionStart(e),t.addEventListener("mouseup",this.handleMouseUp)}},{key:"handleMouseUp",value:function(e){var t=p(this);this.handleInteractionEnd(e),t.removeEventListener("mouseup",this.handleMouseUp)}},{key:"handleTouchStart",value:function(e){var t=p(this);this.handleInteractionStart(e),t.addEventListener("touchend",this.handleTouchEnd)}},{key:"handleTouchEnd",value:function(e){var t=p(this);this.handleInteractionEnd(e),t.removeEventListener("touchend",this.handleTouchEnd)}},{key:"render",value:function(){var e=this.props.classNames,t=f(this),n=R["default"].valuesFromProps(this),a=R["default"].percentagesFromValues(this,n);return g["default"].createElement("div",{"aria-disabled":this.props.disabled,ref:"inputRange",className:t,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onMouseDown:this.handleMouseDown,onTouchStart:this.handleTouchStart},g["default"].createElement(x["default"],{className:e.labelMin,containerClassName:e.labelContainer},this.props.minValue),g["default"].createElement(P["default"],{classNames:e,ref:"track",percentages:a,onTrackMouseDown:this.handleTrackMouseDown},v(this)),g["default"].createElement(x["default"],{className:e.labelMax,containerClassName:e.labelContainer},this.props.maxValue),m(this))}},{key:"trackClientRect",get:function(){var e=this.refs.track;return e?e.clientRect:{height:0,left:0,top:0,width:0}}},{key:"isMultiValue",get:function(){return(0,_.isObject)(this.props.value)||(0,_.isObject)(this.props.defaultValue)}}]),t}(g["default"].Component);S.propTypes={ariaLabelledby:g["default"].PropTypes.string,classNames:g["default"].PropTypes.objectOf(g["default"].PropTypes.string),defaultValue:C.maxMinValuePropType,disabled:g["default"].PropTypes.bool,maxValue:C.maxMinValuePropType,minValue:C.maxMinValuePropType,name:g["default"].PropTypes.string,onChange:g["default"].PropTypes.func.isRequired,onChangeComplete:g["default"].PropTypes.func,step:g["default"].PropTypes.number,value:C.maxMinValuePropType},S.defaultProps={classNames:E["default"],defaultValue:0,disabled:!1,maxValue:10,minValue:0,step:1,value:null},n["default"]=S,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Label":2,"./Slider":3,"./Track":4,"./defaultClassNames":5,"./propTypes":6,"./util":7,"./valueTransformer":8}],2:[function(e,t,n){(function(e){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),i=function(e,t,n){for(var a=!0;a;){var r=e,o=t,u=n;a=!1,null===r&&(r=Function.prototype);var i=Object.getOwnPropertyDescriptor(r,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(r);if(null===s)return;e=s,t=o,n=u,a=!0,i=s=void 0}},l="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,s=a(l),p=function(e){function t(){r(this,t),i(Object.getPrototypeOf(t.prototype),"constructor",this).apply(this,arguments)}return o(t,e),u(t,[{key:"render",value:function(){var e=this.props,t=e.className,n=e.containerClassName;return s["default"].createElement("span",{className:t},s["default"].createElement("span",{className:n},this.props.children))}}]),t}(s["default"].Component);p.propTypes={children:s["default"].PropTypes.node,className:s["default"].PropTypes.string,containerClassName:s["default"].PropTypes.string},n["default"]=p,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){(function(a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){var t=e.refs.slider.ownerDocument;return t}function l(e){var t=100*(e.props.percentage||0),n={position:"absolute",left:t+"%"};return n}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),p=function(e,t,n){for(var a=!0;a;){var r=e,o=t,u=n;a=!1,null===r&&(r=Function.prototype);var i=Object.getOwnPropertyDescriptor(r,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(r);if(null===s)return;e=s,t=o,n=u,a=!0,i=s=void 0}},f="undefined"!=typeof window?window.React:"undefined"!=typeof a?a.React:null,c=r(f),d=e("./Label"),h=r(d),v=e("./util"),m=function(e){function t(e){o(this,t),p(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),(0,v.autobind)(["handleClick","handleMouseDown","handleMouseUp","handleMouseMove","handleTouchStart","handleTouchEnd","handleTouchMove","handleKeyDown"],this)}return u(t,e),s(t,[{key:"handleClick",value:function(e){e.preventDefault()}},{key:"handleMouseDown",value:function(){var e=i(this);e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseup",this.handleMouseUp)}},{key:"handleMouseUp",value:function(){var e=i(this);e.removeEventListener("mousemove",this.handleMouseMove),e.removeEventListener("mouseup",this.handleMouseUp)}},{key:"handleMouseMove",value:function(e){this.props.onSliderMouseMove(e,this)}},{key:"handleTouchStart",value:function(e){var t=i(this);e.preventDefault(),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)}},{key:"handleTouchMove",value:function(e){this.props.onSliderMouseMove(e,this)}},{key:"handleTouchEnd",value:function(){var e=i(this);event.preventDefault(),e.removeEventListener("touchmove",this.handleTouchMove),e.removeEventListener("touchend",this.handleTouchEnd)}},{key:"handleKeyDown",value:function(e){this.props.onSliderKeyDown(e,this)}},{key:"render",value:function(){var e=this.props.classNames,t=l(this);return c["default"].createElement("span",{className:e.sliderContainer,ref:"slider",style:t},c["default"].createElement(h["default"],{className:e.labelValue,containerClassName:e.labelContainer},this.props.value),c["default"].createElement("a",{"aria-labelledby":this.props.ariaLabelledby,"aria-valuemax":this.props.maxValue,"aria-valuemin":this.props.minValue,"aria-valuenow":this.props.value,className:e.slider,draggable:"false",href:"#",onClick:this.handleClick,onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onTouchStart:this.handleTouchStart,role:"slider"}))}}]),t}(c["default"].Component);m.propTypes={ariaLabelledby:c["default"].PropTypes.string,classNames:c["default"].PropTypes.objectOf(c["default"].PropTypes.string),maxValue:c["default"].PropTypes.number,minValue:c["default"].PropTypes.number,onSliderKeyDown:c["default"].PropTypes.func.isRequired,onSliderMouseMove:c["default"].PropTypes.func.isRequired,percentage:c["default"].PropTypes.number.isRequired,type:c["default"].PropTypes.string.isRequired,value:c["default"].PropTypes.number.isRequired},n["default"]=m,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./Label":2,"./util":7}],4:[function(e,t,n){(function(a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){var t=e.props,n=100*(t.percentages.max-t.percentages.min)+"%",a=100*t.percentages.min+"%",r={left:a,width:n};return r}Object.defineProperty(n,"__esModule",{value:!0});var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),s=function(e,t,n){for(var a=!0;a;){var r=e,o=t,u=n;a=!1,null===r&&(r=Function.prototype);var i=Object.getOwnPropertyDescriptor(r,o);if(void 0!==i){if("value"in i)return i.value;var l=i.get;if(void 0===l)return;return l.call(u)}var s=Object.getPrototypeOf(r);if(null===s)return;e=s,t=o,n=u,a=!0,i=s=void 0}},p="undefined"!=typeof window?window.React:"undefined"!=typeof a?a.React:null,f=r(p),c=e("./util"),d=function(e){function t(e){o(this,t),s(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),(0,c.autobind)(["handleMouseDown","handleTouchStart"],this)}return u(t,e),l(t,[{key:"handleMouseDown",value:function(e){var t=this.clientRect,n=e.touches?e.touches[0]:e,a=n.clientX,r={x:a-t.left,y:0};this.props.onTrackMouseDown(e,this,r)}},{key:"handleTouchStart",value:function(e){e.preventDefault(),this.handleMouseDown(e)}},{key:"render",value:function(){var e=i(this),t=this.props.classNames;return f["default"].createElement("div",{className:t.trackContainer,onMouseDown:this.handleMouseDown,onTouchStart:this.handleTouchStart,ref:"track"},f["default"].createElement("div",{style:e,className:t.trackActive}),this.props.children)}},{key:"clientRect",get:function(){var e=this.refs.track,t=e.getClientRects()[0];return t}}]),t}(f["default"].Component);d.propTypes={children:f["default"].PropTypes.node,classNames:f["default"].PropTypes.objectOf(f["default"].PropTypes.string),onTrackMouseDown:f["default"].PropTypes.func.isRequired,percentages:f["default"].PropTypes.objectOf(f["default"].PropTypes.number).isRequired},n["default"]=d,t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./util":7}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var a={component:"InputRange",labelContainer:"InputRange-labelContainer",labelMax:"InputRange-label InputRange-label--max",labelMin:"InputRange-label InputRange-label--min",labelValue:"InputRange-label InputRange-label--value",slider:"InputRange-slider",sliderContainer:"InputRange-sliderContainer",trackActive:"InputRange-track InputRange-track--active",trackContainer:"InputRange-track InputRange-track--container"};n["default"]=a,t.exports=n["default"]},{}],6:[function(e,t,n){"use strict";function a(e){var t=e.maxValue,n=e.minValue,a=e.value,o=e.defaultValue,u=(0,r.isNumber)(a),i=(0,r.isNumber)(o),l=(0,r.objectOf)(a,r.isNumber),s=(0,r.objectOf)(o,r.isNumber);return void 0===a?new Error("`value` must be defined"):u||i||l||s?n>=t?new Error("`minValue` must be smaller than `maxValue`"):n>=t?new Error("`maxValue` must be larger than `minValue`"):n>a||a>t?new Error("`value` must be within `minValue` and `maxValue`"):void 0:new Error("`value` or `defaultValue` must be a number or an array")}Object.defineProperty(n,"__esModule",{value:!0});var r=e("./util");n.maxMinValuePropType=a},{"./util":7}],7:[function(e,t,n){"use strict";function a(e,t,n){return Math.min(Math.max(e,t),n)}function r(){return Object.assign.apply(Object,arguments)}function o(e,t){return e.indexOf(t)>-1}function u(e,t){var n=Object.keys(e),a={};return n.forEach(function(n){o(t,n)||(a[n]=e[n])}),a}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function s(e,t){return Math.abs(e-t)}function p(e){return"number"==typeof e}function f(e){return null!==e&&"object"==typeof e}function c(e){return void 0!==e&&null!==e}function d(e){return e?Array.isArray(e)?0===e.length:0===Object.keys(e).length:!0}function h(e,t){if(!Array.isArray(e))return!1;for(var n=0,a=e.length;a>n;n++)if(!t(e[n]))return!1;return!0}function v(e,t,n){if(!f(e))return!1;for(var a=n||Object.keys(e),r=0,o=a.length;o>r;r++){var u=a[r];if(!t(e[u]))return!1}return!0}function m(e,t){e.forEach(function(e){t[e]=t[e].bind(t)})}Object.defineProperty(n,"__esModule",{value:!0});var y={arrayOf:h,autobind:m,captialize:i,clamp:a,distanceTo:l,extend:r,isDefined:c,isEmpty:d,isNumber:p,isObject:f,length:s,objectOf:v,omit:u};n["default"]=y,t.exports=n["default"]},{}],8:[function(e,t,n){"use strict";function a(e,t){var n=e.trackClientRect.width,a=t.x/n;return a||0}function r(e,t){var n=a(e,t),r=e.props.maxValue-e.props.minValue,o=e.props.minValue+r*n;return o}function o(e){var t=arguments.length<=1||void 0===arguments[1]?e:arguments[1],n=t.props;return function(){if(e.isMultiValue){var t=n.value;return((0,c.isEmpty)(t)||!(0,c.objectOf)(t,c.isNumber))&&(t=n.defaultValue),Object.create(t)}var a=(0,c.isNumber)(n.value)?n.value:n.defaultValue;return{min:n.minValue,max:a}}()}function u(e,t){var n=(0,c.clamp)(t,e.props.minValue,e.props.maxValue),a=e.props.maxValue-e.props.minValue,r=(n-e.props.minValue)/a;return r||0}function i(e,t){var n={min:u(e,t.min),max:u(e,t.max)};return n}function l(e,t){var n=e.trackClientRect.width,a=u(e,t),r=a*n;return{x:r,y:0}}function s(e,t){var n={min:l(e,t.min),max:l(e,t.max)};return n}function p(e,t){var n=e.trackClientRect,a=n.width,r=t.touches?t.touches[0]:t,o=r.clientX,u={x:(0,c.clamp)(o-n.left,0,a),y:0};return u}function f(e,t){return Math.round(t/e.props.step)*e.props.step}Object.defineProperty(n,"__esModule",{value:!0});var c=e("./util"),d={percentageFromPosition:a,percentageFromValue:u,percentagesFromValues:i,positionFromEvent:p,positionFromValue:l,positionsFromValues:s,stepValueFromValue:f,valueFromPosition:r,valuesFromProps:o};n["default"]=d,t.exports=n["default"]},{"./util":7}],9:[function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r=e("./InputRange"),o=a(r);n["default"]=o["default"],t.exports=n["default"]},{"./InputRange":1}]},{},[9])(9)}); |
@@ -46,2 +46,4 @@ 'use strict'; | ||
// Constants | ||
var internals = new WeakMap(); | ||
var KeyCode = { | ||
@@ -75,2 +77,8 @@ LEFT_ARROW: 37, | ||
function getDocument(inputRange) { | ||
var ownerDocument = inputRange.refs.inputRange.ownerDocument; | ||
return ownerDocument; | ||
} | ||
function getComponentClassName(inputRange) { | ||
@@ -224,4 +232,7 @@ var props = inputRange.props; | ||
// Private | ||
internals.set(this, {}); | ||
// Auto-bind | ||
(0, _util.autobind)(['handleSliderMouseMove', 'handleSliderKeyDown', 'handleTrackMouseDown'], this); | ||
(0, _util.autobind)(['handleInteractionEnd', 'handleInteractionStart', 'handleKeyDown', 'handleKeyUp', 'handleMouseDown', 'handleMouseUp', 'handleSliderKeyDown', 'handleSliderMouseMove', 'handleTouchStart', 'handleTouchEnd', 'handleTrackMouseDown'], this); | ||
} | ||
@@ -300,3 +311,3 @@ | ||
key: 'handleSliderMouseMove', | ||
value: function handleSliderMouseMove(slider, event) { | ||
value: function handleSliderMouseMove(event, slider) { | ||
if (this.props.disabled) { | ||
@@ -313,3 +324,3 @@ return; | ||
key: 'handleSliderKeyDown', | ||
value: function handleSliderKeyDown(slider, event) { | ||
value: function handleSliderKeyDown(event, slider) { | ||
if (this.props.disabled) { | ||
@@ -336,3 +347,3 @@ return; | ||
key: 'handleTrackMouseDown', | ||
value: function handleTrackMouseDown(track, position) { | ||
value: function handleTrackMouseDown(event, track, position) { | ||
if (this.props.disabled) { | ||
@@ -346,3 +357,75 @@ return; | ||
} | ||
}, { | ||
key: 'handleInteractionStart', | ||
value: function handleInteractionStart() { | ||
var _this = internals.get(this); | ||
if (!this.props.onChangeComplete || (0, _util.isDefined)(_this.startValue)) { | ||
return; | ||
} | ||
_this.startValue = this.props.value; | ||
} | ||
}, { | ||
key: 'handleInteractionEnd', | ||
value: function handleInteractionEnd() { | ||
var _this = internals.get(this); | ||
if (!this.props.onChangeComplete || !(0, _util.isDefined)(_this.startValue)) { | ||
return; | ||
} | ||
if (_this.startValue !== this.props.value) { | ||
this.props.onChangeComplete(this, this.props.value); | ||
} | ||
_this.startValue = null; | ||
} | ||
}, { | ||
key: 'handleKeyDown', | ||
value: function handleKeyDown(event) { | ||
this.handleInteractionStart(event); | ||
} | ||
}, { | ||
key: 'handleKeyUp', | ||
value: function handleKeyUp(event) { | ||
this.handleInteractionEnd(event); | ||
} | ||
}, { | ||
key: 'handleMouseDown', | ||
value: function handleMouseDown(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionStart(event); | ||
document.addEventListener('mouseup', this.handleMouseUp); | ||
} | ||
}, { | ||
key: 'handleMouseUp', | ||
value: function handleMouseUp(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionEnd(event); | ||
document.removeEventListener('mouseup', this.handleMouseUp); | ||
} | ||
}, { | ||
key: 'handleTouchStart', | ||
value: function handleTouchStart(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionStart(event); | ||
document.addEventListener('touchend', this.handleTouchEnd); | ||
} | ||
}, { | ||
key: 'handleTouchEnd', | ||
value: function handleTouchEnd(event) { | ||
var document = getDocument(this); | ||
this.handleInteractionEnd(event); | ||
document.removeEventListener('touchend', this.handleTouchEnd); | ||
} | ||
// Render | ||
@@ -363,3 +446,7 @@ }, { | ||
ref: 'inputRange', | ||
className: componentClassName }, | ||
className: componentClassName, | ||
onKeyDown: this.handleKeyDown, | ||
onKeyUp: this.handleKeyUp, | ||
onMouseDown: this.handleMouseDown, | ||
onTouchStart: this.handleTouchStart }, | ||
_react2['default'].createElement( | ||
@@ -426,2 +513,3 @@ _Label2['default'], | ||
onChange: _react2['default'].PropTypes.func.isRequired, | ||
onChangeComplete: _react2['default'].PropTypes.func, | ||
step: _react2['default'].PropTypes.number, | ||
@@ -428,0 +516,0 @@ value: _propTypes.maxMinValuePropType |
@@ -86,3 +86,3 @@ 'use strict'; | ||
value: function handleMouseMove(event) { | ||
this.props.onSliderMouseMove(this, event); | ||
this.props.onSliderMouseMove(event, this); | ||
} | ||
@@ -102,3 +102,3 @@ }, { | ||
value: function handleTouchMove(event) { | ||
this.props.onSliderMouseMove(this, event); | ||
this.props.onSliderMouseMove(event, this); | ||
} | ||
@@ -118,3 +118,3 @@ }, { | ||
value: function handleKeyDown(event) { | ||
this.props.onSliderKeyDown(this, event); | ||
this.props.onSliderKeyDown(event, this); | ||
} | ||
@@ -121,0 +121,0 @@ |
@@ -57,4 +57,2 @@ 'use strict'; | ||
// Methods | ||
// Handlers | ||
@@ -73,3 +71,3 @@ value: function handleMouseDown(event) { | ||
this.props.onTrackMouseDown(this, position); | ||
this.props.onTrackMouseDown(event, this, position); | ||
} | ||
@@ -76,0 +74,0 @@ }, { |
@@ -52,2 +52,6 @@ // Functions | ||
function isDefined(value) { | ||
return value !== undefined && value !== null; | ||
} | ||
function isEmpty(obj) { | ||
@@ -111,2 +115,3 @@ if (!obj) { | ||
extend: extend, | ||
isDefined: isDefined, | ||
isEmpty: isEmpty, | ||
@@ -113,0 +118,0 @@ isNumber: isNumber, |
{ | ||
"name": "react-input-range", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "React component for inputting numeric values within a range", | ||
@@ -30,2 +30,3 @@ "keywords": [ | ||
"del": "^1.2.0", | ||
"es5-shim": "^4.4.1", | ||
"eslint": "^1.10.2", | ||
@@ -54,5 +55,4 @@ "eslint-config-airbnb": "^1.0.2", | ||
"karma-browserify": "^4.3.0", | ||
"karma-es6-shim": "^0.1.3", | ||
"karma-jasmine": "^0.3.6", | ||
"karma-phantomjs2-launcher": "^0.3.2", | ||
"karma-phantomjs-launcher": "^0.2.1", | ||
"lodash": "^3.10.0", | ||
@@ -59,0 +59,0 @@ "phantomjs": "^1.9.17", |
@@ -81,2 +81,3 @@ # react-input-range | ||
onChange |Function |`onChange` callback (required) | ||
onChangeComplete |Function |`onChangeComplete` callback | ||
step |number |Increment/decrement value | ||
@@ -83,0 +84,0 @@ value |number | Object.<number> |Current value(s) (required) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111126
1957
98