TP_JO2024/home/dist/component/range/range.nomodule.min.js
2024-03-27 17:19:37 +01:00

3 lines
14 KiB
JavaScript

/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
!function(){"use strict";var t=window.dsfr,e={RANGE:t.internals.ns.selector("range"),RANGE_SM:t.internals.ns.selector("range--sm"),RANGE_STEP:t.internals.ns.selector("range--step"),RANGE_DOUBLE:t.internals.ns.selector("range--double"),RANGE_DOUBLE_STEP:t.internals.ns.selector("range--double")+t.internals.ns.selector("range--step"),RANGE_INPUT:t.internals.ns.selector("range input[type=range]:nth-of-type(1)"),RANGE_INPUT2:t.internals.ns.selector("range--double")+" input[type=range]:nth-of-type(2)",RANGE_OUTPUT:t.internals.ns.selector("range__output"),RANGE_MIN:t.internals.ns.selector("range__min"),RANGE_MAX:t.internals.ns.selector("range__max"),RANGE_PREFIX:t.internals.ns.attr("prefix"),RANGE_SUFFIX:t.internals.ns.attr("suffix")},i={VALUE:t.internals.ns.emission("range","value"),VALUE2:t.internals.ns.emission("range","value2"),OUTPUT:t.internals.ns.emission("range","output"),CONSTRAINTS:t.internals.ns.emission("range","constraints"),MIN:t.internals.ns.emission("range","min"),MAX:t.internals.ns.emission("range","max"),STEP:t.internals.ns.emission("range","step"),PREFIX:t.internals.ns.emission("range","prefix"),SUFFIX:t.internals.ns.emission("range","suffix"),DISABLED:t.internals.ns.emission("range","disabled"),ENABLE_POINTER:t.internals.ns.emission("range","enable_pointer")},s=function(){this._width=0,this._min=0,this._max=0,this._value=0,this._thumbSize=24,this._innerWidth=0,this._prefix="",this._suffix="",this._background={}},n={width:{configurable:!0},isSm:{configurable:!0},textValue:{configurable:!0},value:{configurable:!0},outputX:{configurable:!0},min:{configurable:!0},textMin:{configurable:!0},max:{configurable:!0},textMax:{configurable:!0},step:{configurable:!0},output:{configurable:!0},progress:{configurable:!0}};s.prototype.configure=function(t){t&&(this._prefix=t._prefix,this._suffix=t._suffix,this._width=t.width,this.setConstraints(t._constraints),this.value=t.value,this.update())},s.prototype.setPrefix=function(t){this._prefix=null!==t?t:""},s.prototype.setSuffix=function(t){this._suffix=null!==t?t:""},s.prototype._decorate=function(t){return""+this._prefix+t+this._suffix},n.width.get=function(){return this._width},n.width.set=function(t){this._width=t},n.isSm.get=function(){return this._isSm},n.isSm.set=function(t){this._isSm!==t&&(this._isSm=t,this.setThumbSize(t?16:24),this.update())},s.prototype.setThumbSize=function(t,e){void 0===e&&(e=1),this._thumbSize=t,this._innerPadding=t*e},n.textValue.get=function(){return this._decorate(this._value)},n.value.get=function(){return this._value},n.value.set=function(t){this._value=t},n.outputX.get=function(){return this._outputX},s.prototype.setConstraints=function(t){this._constraints=t,this._min=t.min,this._max=t.max,this._step=t.step,this._rangeWidth=t.rangeWidth},n.min.get=function(){return this._min},n.textMin.get=function(){return this._decorate(this._min)},n.max.get=function(){return this._max},n.textMax.get=function(){return this._decorate(this._max)},n.step.get=function(){return this._step},n.output.get=function(){return{text:this.textValue,transform:"translateX("+this._translateX+"px) translateX(-"+this._centerPercent+"%)"}},s.prototype._getRatio=function(t){return(t-this._min)/this._rangeWidth},n.progress.get=function(){return this._progress},s.prototype.update=function(){this._update()},s.prototype._update=function(){this._innerWidth=this._width-this._innerPadding;var t=this._getRatio(this._value);this._translateX=t*this._width,this._centerPercent=100*t,this._progress={right:(this._innerWidth*t+.5*this._innerPadding).toFixed(2)+"px"}},Object.defineProperties(s.prototype,n);var r=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={stepWidth:{configurable:!0}};return i.stepWidth.get=function(){return this._stepWidth.toFixed(3)+"px"},e.prototype._update=function(){t.prototype._update.call(this);var e=this._rangeWidth/this._step;for(this._stepWidth=this._innerWidth/e;this._stepWidth<4;)this._stepWidth*=2},Object.defineProperties(e.prototype,i),e}(s),o=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={value2:{configurable:!0},textValue:{configurable:!0}};return i.value2.get=function(){return this._value},i.value2.set=function(t){this._value2!==t&&(this._value2=t,this.update())},i.textValue.get=function(){return this._decorate(this._value)+" - "+this._decorate(this._value2)},e.prototype.setThumbSize=function(e){t.prototype.setThumbSize.call(this,e,2)},e.prototype._update=function(){t.prototype._update.call(this);var e=this._getRatio(.5*(this._value+this._value2));this._translateX=e*this._width,this._centerPercent=100*e;var i=this._getRatio(this._value),s=this._getRatio(this._value2);this._progress={left:(this._innerWidth*i+.25*this._innerPadding).toFixed(2)+"px",right:(this._innerWidth*s+.75*this._innerPadding).toFixed(2)+"px"}},Object.defineProperties(e.prototype,i),e}(s),a=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={stepWidth:{configurable:!0}};return i.stepWidth.get=function(){return this._stepWidth.toFixed(3)+"px"},e.prototype._update=function(){t.prototype._update.call(this);var e=this._rangeWidth/this._step;this._stepWidth=this._innerWidth/e,this._stepWidth<4&&(this._stepWidth*=Math.ceil(4/this._stepWidth))},Object.defineProperties(e.prototype,i),e}(o),h="step",p="double",u="double-step",c="default",_=function(t){function n(){t.apply(this,arguments)}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var _={type:{configurable:!0}},l={instanceClassName:{configurable:!0}};return l.instanceClassName.get=function(){return"Range"},n.prototype.init=function(){this._retrieveType(),this._retrieveSize(),this.isLegacy?(this.isResizing=!0,this.isMouseMoving=!0):(this._observer=new ResizeObserver(this.resize.bind(this)),this._observer.observe(this.node)),this.addAscent(i.CONSTRAINTS,this.setConstraints.bind(this)),this.addAscent(i.VALUE,this.setValue.bind(this)),this.addAscent(i.VALUE2,this.setValue2.bind(this)),this.getAttribute(e.RANGE_PREFIX)&&this.setPrefix(this.getAttribute(e.RANGE_PREFIX)),this.getAttribute(e.RANGE_SUFFIX)&&this.setSuffix(this.getAttribute(e.RANGE_SUFFIX)),this.update()},n.prototype._retrieveType=function(){switch(!0){case this.matches(e.RANGE_DOUBLE_STEP):case this.matches(e.RANGE_DOUBLE):this.type=p;break;case this.matches(e.RANGE_STEP):this.type=h;break;default:this.type=c}},_.type.set=function(t){if(this._type!==t){this._type=t;var e=this._model;switch(this._type){case u:this._model=new a;break;case p:this._model=new o;break;case h:this._model=new r;break;default:this._model=new s}this._model.configure(e)}},_.type.get=function(){return this._type},n.prototype._retrieveSize=function(){this._model.isSm=this.matches(e.RANGE_SM)},n.prototype.resize=function(){this._retrieveWidth(),this.update()},n.prototype._retrieveWidth=function(){this._model.width=this.getRect().width},n.prototype.setValue=function(t){switch(this._model.value=t,this._type){case u:case p:this.descend(i.VALUE,t)}this.update()},n.prototype.setValue2=function(t){this._model.value2=t,this.descend(i.VALUE2,t),this.update()},n.prototype.setConstraints=function(t){this._model.setConstraints(t),this.update(),this.descend(i.CONSTRAINTS,t)},n.prototype.setPrefix=function(t){this._model.setPrefix(t),this.update()},n.prototype.setSuffix=function(t){this._model.setSuffix(t),this.update()},n.prototype.mutate=function(t){switch(!0){case t.includes("class"):this._retrieveType(),this._retrieveSize();break;case t.includes(e.RANGE_PREFIX):case t.includes(e.RANGE_SUFFIX):this._model.setPrefix(this.getAttribute(e.RANGE_PREFIX)),this._model.setSuffix(this.getAttribute(e.RANGE_SUFFIX)),this.update()}},n.prototype.update=function(){this._model.update(),this.descend(i.OUTPUT,this._model.output),this.descend(i.MIN,this._model.textMin),this.descend(i.MAX,this._model.textMax);var t=this._model.progress;t.left?this.style.setProperty("--progress-left",t.left):this.style.removeProperty("--progress-left"),t.right?(this.style.setProperty("--progress-right",t.right),this.isLegacy&&t.left&&(this.style.setProperty("background-position-x",t.left),this.style.setProperty("background-size",parseFloat(t.right)-parseFloat(t.left)+"px "+(this._model.isSm?"8px":"12px")))):(this.style.removeProperty("--progress-right"),this.isLegacy&&(this.style.removeProperty("background-size"),this.style.removeProperty("background-position-x"))),this._model.stepWidth?this.style.setProperty("--step-width",this._model.stepWidth):this.style.removeProperty("--step-width")},n.prototype.mouseMove=function(t){if(this._type===p||this._type===u){var e=t.x-this.getRect().left;this.descend(i.ENABLE_POINTER,(parseFloat(this._model.progress.right)-parseFloat(this._model.progress.left))/2+parseFloat(this._model.progress.left)<e?2:1)}},n.prototype.dispose=function(){this._observer.disconnect()},Object.defineProperties(n.prototype,_),Object.defineProperties(n,l),n}(t.core.Instance),l=function(t){this._min=isNaN(t.min)?0:t.min,this._max=isNaN(t.max)?100:t.max,this._step=isNaN(t.step)?1:t.step,this._rangeWidth=this._max-this._min},d={min:{configurable:!0},max:{configurable:!0},step:{configurable:!0},rangeWidth:{configurable:!0}};d.min.get=function(){return this._min},d.max.get=function(){return this._max},d.step.get=function(){return this._step},d.rangeWidth.get=function(){return this._rangeWidth},l.prototype.test=function(t,e,i){return this._min===t&&this._max===e&&this._step===i},Object.defineProperties(l.prototype,d);var g=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"RangeInput"},e.prototype.init=function(){this._init(),this.node.value=this.getAttribute("value"),this._changing=this.change.bind(this),this._listenerType=this.isLegacy?"change":"input",this.listen(this._listenerType,this._changing),this.isLegacy&&this.addDescent(i.ENABLE_POINTER,this._enablePointer.bind(this)),this.change()},e.prototype._init=function(){var t=this;this._pointerId=1,this.request((function(){t.hasAttribute("min")||t.setAttribute("min",0),t.ascend(i.CONSTRAINTS,new l(t.node)),t.ascend(i.DISABLED,t.node.disabled)})),this.addDescent(i.VALUE2,this.setValue.bind(this))},e.prototype._enablePointer=function(t){var e=t===this._pointerId;this._isPointerEnabled!==e&&(this._isPointerEnabled=e,e?this.style.removeProperty("pointer-events"):this.style.setProperty("pointer-events","none"))},e.prototype.setValue=function(t){parseFloat(this.node.value)>t&&(this.node.value=t,this.change())},e.prototype.change=function(){this.ascend(i.VALUE,parseFloat(this.node.value))},e.prototype.mutate=function(t){t.includes("disabled")&&this.ascend(i.DISABLED,this.node.disabled),(t.includes("min")||t.includes("max")||t.includes("step"))&&(this.ascend(i.CONSTRAINTS,new l(this.node)),this.change())},e.prototype.dispose=function(){this._listenerType&&this.unlisten(this._listenerType,this._changing)},Object.defineProperties(e,s),e}(t.core.Instance),f=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"RangeInput2"},e.prototype._init=function(){this._pointerId=2,this.addDescent(i.CONSTRAINTS,this.setConstraints.bind(this)),this.addDescent(i.VALUE,this.setValue.bind(this))},e.prototype.setValue=function(t){parseFloat(this.node.value)<t&&(this.node.value=t,this.change())},e.prototype.change=function(){this.ascend(i.VALUE2,parseFloat(this.node.value))},e.prototype.setConstraints=function(t){this.node.min=t.min,this.node.max=t.max,this.node.step=t.step,this.change()},e.prototype.mutate=function(t){},Object.defineProperties(e,s),e}(g),y=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"RangeOutput"},e.prototype.init=function(){this.addDescent(i.OUTPUT,this.change.bind(this))},e.prototype.change=function(t){this.node.innerText=t.text,this.node.style.transform=t.transform},Object.defineProperties(e,s),e}(t.core.Instance),m=function(t){function s(){t.apply(this,arguments)}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"RangeLimit"},s.prototype.init=function(){switch(!0){case this.matches(e.RANGE_MIN):this.addDescent(i.MIN,this.change.bind(this));break;case this.matches(e.RANGE_MAX):this.addDescent(i.MAX,this.change.bind(this))}},s.prototype.change=function(t){this.node.innerText=t},Object.defineProperties(s,n),s}(t.core.Instance);t.range={Range:_,RangeInput:g,RangeInput2:f,RangeOutput:y,RangeLimit:m,RangeEmission:i,RangeSelector:e},t.internals.register(t.range.RangeSelector.RANGE,t.range.Range),t.internals.register(t.range.RangeSelector.RANGE_INPUT,t.range.RangeInput),t.internals.register(t.range.RangeSelector.RANGE_INPUT2,t.range.RangeInput2),t.internals.register(t.range.RangeSelector.RANGE_OUTPUT,t.range.RangeOutput),t.internals.register(t.range.RangeSelector.RANGE_MIN,t.range.RangeLimit),t.internals.register(t.range.RangeSelector.RANGE_MAX,t.range.RangeLimit)}();
//# sourceMappingURL=range.nomodule.min.js.map