@taiga-ui/kit
Version:
Taiga UI Angular main components kit
16 lines (14 loc) • 9.58 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@angular/forms"),require("@taiga-ui/cdk"),require("@taiga-ui/kit/abstract"),require("@taiga-ui/kit/constants"),require("@taiga-ui/kit/tokens"),require("rxjs"),require("@taiga-ui/core")):"function"==typeof define&&define.amd?define("@taiga-ui/kit/components/range",["exports","@angular/common","@angular/core","@angular/forms","@taiga-ui/cdk","@taiga-ui/kit/abstract","@taiga-ui/kit/constants","@taiga-ui/kit/tokens","rxjs","@taiga-ui/core"],t):t(((e=e||self)["taiga-ui"]=e["taiga-ui"]||{},e["taiga-ui"].kit=e["taiga-ui"].kit||{},e["taiga-ui"].kit.components=e["taiga-ui"].kit.components||{},e["taiga-ui"].kit.components.range={}),e.ng.common,e.ng.core,e.ng.forms,e.cdk,e["taiga-ui"].kit.abstract,e["taiga-ui"].kit.constants,e["taiga-ui"].kit.tokens,e.rxjs,e.core$1)}(this,(function(e,t,n,i,r,o,a,s,u,c){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function d(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function p(e,t){return function(n,i){t(n,i,e)}}var g=function(e){function c(t,n,i,r,o){var a=e.call(this,t,n,i,o)||this;return a.elementRef=r,a}var g;return function(e,t){function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(c,e),g=c,Object.defineProperty(c.prototype,"nativeFocusableElement",{get:function(){return!this.computedDisabled&&this.dotLeft&&this.dotRight?this.isLeftFocusable?this.dotLeft.nativeElement:this.dotRight.nativeElement:null},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"focused",{get:function(){return r.isNativeFocusedIn(this.elementRef.nativeElement)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"left",{get:function(){return 100*this.getFractionFromValue(this.value[0])},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"right",{get:function(){return 100-100*this.getFractionFromValue(this.value[1])},enumerable:!0,configurable:!0}),c.prototype.getFallbackValue=function(){return[0,0]},c.prototype.processStep=function(e,t){var n=this.getFractionFromValue(t?this.value[1]:this.value[0]),i=this.discrete?1/this.steps:o.SLIDER_KEYBOARD_STEP,r=this.getValueFromFraction(e?n+i:n-i);this.processValue(r,t)},c.prototype.processValue=function(e,t){!0===t?this.updateEnd(e):this.updateStart(e)},c.prototype.getCalibratedFractionFromEvents=function(e,t,n){var i=t-e.left-o.DOT_WIDTH[this.size]/2-(n?o.DOT_WIDTH[this.size]:0),s=e.width-2*o.DOT_WIDTH[this.size];return r.round(i/s,a.TUI_FLOATING_PRECISION)},c.prototype.updateStart=function(e){this.updateValue([Math.min(e,this.value[1]),this.value[1]])},c.prototype.updateEnd=function(e){this.updateValue([this.value[0],Math.max(e,this.value[0])])},c.ctorParameters=function(){return[{type:i.NgControl,decorators:[{type:n.Optional},{type:n.Self},{type:n.Inject,args:[i.NgControl]}]},{type:n.ChangeDetectorRef,decorators:[{type:n.Inject,args:[n.ChangeDetectorRef]}]},{type:Document,decorators:[{type:n.Inject,args:[t.DOCUMENT]}]},{type:n.ElementRef,decorators:[{type:n.Inject,args:[n.ElementRef]}]},{type:u.Observable,decorators:[{type:n.Inject,args:[s.TUI_FROM_TO_TEXTS]}]}]},c=g=d([n.Component({selector:"tui-range",template:'<div\n class="event-catcher"\n (tuiActiveZoneChange)="onActiveZone($event)"\n (mousedown)="onMouseDown($event)"\n (touchstart)="onTouchStart($event)"\n>\n <div class="wrapper">\n <div *ngIf="segmented" class="segments">\n <span\n *tuiRepeatTimes="let segmentIndex of segments + 1"\n class="segment"\n automation-id="tui-slider__segment"\n >\n <span *ngIf="fromToTexts$ | async as fromToText" class="number">\n {{getSegmentPrefix(segmentIndex, fromToText)}}\n {{getSegmentLabel(segmentIndex) | tuiFormatNumber}}\n <span *ngIf="isPluralized(pluralize)">\n {{getSegmentLabel(segmentIndex) | tuiPluralize:\n pluralize}}\n </span>\n </span>\n </span>\n </div>\n <div\n class="bar"\n automation-id="tui-slider__bar"\n [style.left.%]="left"\n [style.right.%]="right"\n >\n <div\n #dotLeft\n class="dot"\n automation-id="tui-slider__left"\n [class.dot_focus-visible]="focusVisibleLeft && computedFocused"\n [tuiFocusable]="isLeftFocusable"\n (tuiFocusVisibleChange)="onLeftFocusVisible($event)"\n (keydown.arrowLeft.prevent)="decrement(false)"\n (keydown.arrowDown.prevent)="decrement(false)"\n (keydown.arrowRight.prevent)="increment(false)"\n (keydown.arrowUp.prevent)="increment(false)"\n ></div>\n <div\n #dotRight\n class="dot"\n automation-id="tui-slider__right"\n [class.dot_focus-visible]="focusVisibleRight && computedFocused"\n [tuiFocusable]="isRightFocusable"\n (tuiFocusVisibleChange)="onRightFocusVisible($event)"\n (keydown.arrowLeft.prevent)="decrement(true)"\n (keydown.arrowDown.prevent)="decrement(true)"\n (keydown.arrowRight.prevent)="increment(true)"\n (keydown.arrowUp.prevent)="increment(true)"\n ></div>\n </div>\n </div>\n</div>\n',changeDetection:n.ChangeDetectionStrategy.OnPush,providers:[{provide:r.TUI_FOCUSABLE_ITEM_ACCESSOR,useExisting:n.forwardRef((function(){return g}))}],styles:[":host{display:block;border-radius:var(--tui-radius-m);color:var(--tui-base-03);min-height:2px;font-size:16px}:host[data-tui-host-size='s']{min-height:2px;font-size:8px}:host._segmented{padding-bottom:20px}:host._disabled{cursor:default;pointer-events:none;opacity:var(--tui-disabled-opacity)}.event-catcher{min-height:inherit;border-radius:inherit;padding:7px 0;cursor:pointer}.wrapper{position:relative;min-height:inherit;border-radius:inherit;background-color:currentColor;border:solid transparent;border-width:0 1em}.bar{position:absolute;top:0;bottom:0;margin:0 -1em;border-radius:inherit;background-color:var(--tui-primary)}:host-context(tui-input-slider) .bar{margin-left:calc(var(--tui-radius-m)/ 2);border-bottom-left-radius:calc(var(--tui-radius-m) * 5) calc(var(--tui-radius-m) * 1.5)}.dot{transition-property:background-color;transition-duration:.3s;transition-timing-function:ease-in-out;position:absolute;top:50%;z-index:1;width:1em;height:1em;transform:translate(0,-50%);border-radius:100%;background-color:var(--tui-primary);outline:0;cursor:ew-resize}.dot:last-child{right:0;transform:translate(0,-50%)}.dot:hover{background-color:var(--tui-primary-hover)}.dot:active{background-color:var(--tui-primary-active)}.dot_focus-visible{box-shadow:inset 0 0 0 2px var(--tui-focus)}.segments{position:relative;z-index:1;display:flex;justify-content:space-between;min-height:inherit;margin:0 -1em}.segments-spacer{height:26px}.segment{position:relative;height:inherit;width:4px;background-color:rgba(0,0,0,.36);pointer-events:none}.segment:first-of-type,.segment:last-of-type{background-color:transparent}.number{position:absolute;left:50%;transform:translate(-50%,0);font:var(--tui-font-text-s);top:100%;margin-top:8px;color:var(--tui-text-02);white-space:nowrap}.segment:first-of-type .number{left:-.05em;transform:none}.segment:last-of-type .number{left:auto;right:-.05em;transform:none}:host._disabled .number{color:var(--tui-text-01)}"]}),p(0,n.Optional()),p(0,n.Self()),p(0,n.Inject(i.NgControl)),p(1,n.Inject(n.ChangeDetectorRef)),p(2,n.Inject(t.DOCUMENT)),p(3,n.Inject(n.ElementRef)),p(4,n.Inject(s.TUI_FROM_TO_TEXTS))],c)}(o.AbstractTuiSlider),f=function(){function e(){}return e=d([n.NgModule({imports:[t.CommonModule,r.TuiRepeatTimesModule,r.TuiFocusableModule,r.TuiActiveZoneModule,r.TuiFocusVisibleModule,c.TuiPluralizePipeModule,c.TuiFormatNumberPipeModule],declarations:[g],exports:[g]})],e)}();e.TuiRangeComponent=g,e.TuiRangeModule=f,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=taiga-ui-kit-components-range.umd.min.js.map