2 lines
8.8 KiB
JavaScript
2 lines
8.8 KiB
JavaScript
|
import e,{Component as t}from"react";import{DomHandler as n,classNames as r}from"primereact/utils";function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e){if(Array.isArray(e))return i(e)}function o(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function a(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(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)}}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function g(e,t){if(t&&("object"===f(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function v(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var y,b,L,E=function(i){c(w,t);var d,f,y,b,L,E=(d=w,f=v(),function(){var e,t=m(d);if(f){var n=m(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function w(e){var t;return u(this,w),(t=E.call(this,e)).onBarClick=t.onBarClick.bind(p(t)),t.onKeyDown=t.onKeyDown.bind(p(t)),t.handleIndex=0,t}return y=w,(b=[{key:"value",get:function(){return this.props.range?this.props.value||[0,100]:this.props.value||0}},{key:"spin",value:function(e,t){this.updateValue(e,(this.props.range?this.value[this.handleIndex]:this.value)+(this.props.step||1)*t),e.preventDefault()}},{key:"onDragStart",value:function(e,t){this.props.disabled||(this.dragging=!0,this.updateDomData(),this.sliderHandleClick=!0,this.handleIndex=t)}},{key:"onMouseDown",value:function(e,t){this.bindDragListeners(),this.onDragStart(e,t)}},{key:"onTouchStart",value:function(e,t){this.bindTouchListeners(),this.onDragStart(e,t)}},{key:"onKeyDown",value:function(e,t){if(!this.props.disabled){this.handleIndex=t;var n=e.key;"ArrowRight"===n||"ArrowUp"===n?this.spin(e,1):"ArrowLeft"!==n&&"ArrowDown"!==n||this.spin(e,-1)}}},{key:"onBarClick",value:function(e){if(!this.props.disabled){if(!this.sliderHandleClick){this.updateDomData();var t=this.setValue(e);this.props.onSlideEnd&&this.props.onSlideEnd({originalEvent:e,value:t})}this.sliderHandleClick=!1}}},{key:"onDrag",value:function(e){this.dragging&&(this.setValue(e),e.preventDefault())}},{key:"onDragEnd",value:function(e){this.dragging&&(this.dragging=!1,this.props.onSlideEnd&&this.props.onSlideEnd({originalEvent:e,value:this.props.value}),this.unbindDragListeners(),this.unbindTouchListeners())}},{key:"bindDragListeners",value:function(){this.dragListener||(t
|