@taiga-ui/kit
Version:
Taiga UI Angular main components kit
16 lines (14 loc) • 13.3 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/forms"),require("@taiga-ui/cdk"),require("@taiga-ui/core"),require("@taiga-ui/kit/constants"),require("@taiga-ui/kit/providers"),require("@taiga-ui/kit/tokens"),require("@taiga-ui/kit/utils/mask"),require("@taiga-ui/kit/utils/miscellaneous"),require("@tinkoff/ng-polymorpheus"),require("rxjs/operators"),require("@angular/common"),require("@taiga-ui/kit/components/calendar-range"),require("@taiga-ui/kit/directives"),require("angular2-text-mask")):"function"==typeof define&&define.amd?define("@taiga-ui/kit/components/input-date-range",["exports","@angular/core","@angular/forms","@taiga-ui/cdk","@taiga-ui/core","@taiga-ui/kit/constants","@taiga-ui/kit/providers","@taiga-ui/kit/tokens","@taiga-ui/kit/utils/mask","@taiga-ui/kit/utils/miscellaneous","@tinkoff/ng-polymorpheus","rxjs/operators","@angular/common","@taiga-ui/kit/components/calendar-range","@taiga-ui/kit/directives","angular2-text-mask"],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["input-date-range"]={}),e.ng.core,e.ng.forms,e.cdk,e.core$1,e["taiga-ui"].kit.constants,e["taiga-ui"].kit.providers,e["taiga-ui"].kit.tokens,e["taiga-ui"].kit.utils.mask,e["taiga-ui"].kit.utils.miscellaneous,e.ngPolymorpheus,e.rxjs.operators,e.ng.common,e["taiga-ui"].kit.components["calendar-range"],e["taiga-ui"].kit.directives,e.angular2TextMask)}(this,(function(e,t,n,i,o,a,r,u,l,s,p,c,d,g,m,f){"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 h=function(e,t){return(h=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 y(e,t,n,i){var o,a=arguments.length,r=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(r=(a<3?o(r):a>3?o(t,n,r):o(t,n))||r);return a>3&&r&&Object.defineProperty(t,n,r),r}function v(e,t){return function(n,i){t(n,i,e)}}var I=s.TuiReplayControlValueChangesFactory,b=function(e){function s(t,n,r,u,s,p,c,d,g,m){var f=e.call(this,t,n)||this;return f.injector=r,f.isMobile=u,f.dialogService=s,f.mobileCalendar=p,f.textfieldSize=c,f.textfieldExampleText=d,f.filler=g,f.rangeFiller=m,f.disabledItemHandler=i.ALWAYS_FALSE_HANDLER,f.markerHandler=o.TUI_DEFAULT_MARKER_HANDLER,f.defaultViewedMonth=i.TuiMonth.currentLocal(),f.items=[],f.min=i.TUI_FIRST_DAY,f.max=i.TUI_LAST_DAY,f.minLength=null,f.maxLength=null,f.open=!1,f.maxLengthMapper=a.MAX_DAY_RANGE_LENGTH_MAPPER,f.textMaskOptions={mask:a.TUI_DATE_RANGE_MASK,pipe:l.tuiCreateAutoCorrectedDateRangePipe(f),guide:!1},f}var d;return function(e,t){function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(s,e),d=s,Object.defineProperty(s.prototype,"nativeFocusableElement",{get:function(){return this.textfield?this.textfield.nativeFocusableElement:null},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"focused",{get:function(){return!!this.textfield&&this.textfield.focused},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedMobile",{get:function(){return this.isMobile&&!!this.mobileCalendar},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"calendarIcon",{get:function(){return o.sizeBigger(this.textfieldSize.size)?"tuiIconCalendarLarge":"tuiIconCalendar"},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"canOpen",{get:function(){return!this.computedDisabled&&!this.readOnly&&!this.computedMobile},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedExampleText",{get:function(){return this.items.length?this.textfieldExampleText.exampleText:""},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedFiller",{get:function(){return this.activePeriod?"":this.rangeFiller},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedMask",{get:function(){return this.activePeriod?a.EMPTY_MASK:this.textMaskOptions},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"activePeriod",{get:function(){var e=this;return this.items.find((function(t){return i.nullableSame(e.value,t.range,(function(t,n){return t.from.daySame(n.from.dayLimit(e.min,e.max))&&t.to.daySame(n.to.dayLimit(e.min,e.max))}))}))||null},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedValue",{get:function(){var e=this.value,t=this.nativeValue,n=this.activePeriod;return n?String(n):e?e.formattedDayRange:t},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"innerPseudoFocused",{get:function(){return!1!==this.pseudoFocused&&(!(!this.open&&!this.computedFocused)||null)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"nativeValue",{get:function(){return this.nativeFocusableElement?this.nativeFocusableElement.value:""},set:function(e){this.nativeFocusableElement&&(this.nativeFocusableElement.value=e)},enumerable:!0,configurable:!0}),s.prototype.onMobileClick=function(){var e=this;this.mobileCalendar?this.dialogService.open(new p.PolymorpheusComponent(this.mobileCalendar,this.injector),{size:"fullscreen",closeable:!1,data:{single:!1,min:this.maxLengthMapper(this.min,this.value,this.maxLength,!0),max:this.maxLengthMapper(this.max,this.value,this.maxLength,!1),disabledItemHandler:this.disabledItemHandler}}).pipe(c.takeUntil(this.destroy$)).subscribe((function(t){e.updateValue(t)})):this.toggle()},s.prototype.onClick=function(){this.isMobile||this.toggle()},s.prototype.onOpenChange=function(e){this.open=e},s.prototype.onValueChange=function(e){if(e&&this.control&&this.control.updateValueAndValidity(),e.length===this.rangeFiller.length){var t=i.TuiDayRange.normalizeParse(e,this.filler,this.rangeFiller);this.updateValue(this.minLength||this.maxLength?this.clampValue(t):t)}else this.updateValue(null)},s.prototype.onRangeChange=function(e){this.toggle(),this.focusInput(),i.nullableSame(this.value,e,(function(e,t){return e.daySame(t)}))||this.updateValue(e)},s.prototype.onItemSelect=function(e){this.toggle(),this.focusInput(),"string"==typeof e?null!==this.activePeriod&&(this.updateValue(null),this.nativeValue=""):this.updateValue(e.range.dayLimit(this.min,this.max))},s.prototype.onHovered=function(e){this.updateHovered(e)},s.prototype.onPressed=function(e){this.updatePressed(e)},s.prototype.onActiveZone=function(e){this.updateFocused(e),e||this.itemSelected||this.nativeValue.length!==this.filler.length&&this.nativeValue.length!==this.filler.length+i.RANGE_SEPARATOR_CHAR.length||this.updateValue(i.TuiDayRange.normalizeParse(this.nativeValue,this.filler,this.rangeFiller))},s.prototype.writeValue=function(t){e.prototype.writeValue.call(this,t),this.nativeValue=t?this.computedValue:""},Object.defineProperty(s.prototype,"itemSelected",{get:function(){var e=this;return-1!==this.items.findIndex((function(t){return String(t)===e.nativeValue}))},enumerable:!0,configurable:!0}),s.prototype.toggle=function(){this.open=!this.open},s.prototype.focusInput=function(e){void 0===e&&(e=!1),this.nativeFocusableElement&&i.setNativeFocused(this.nativeFocusableElement,!0,e)},s.prototype.clampValue=function(e){var t=this.minLength&&e.from.append(this.minLength).dayAfter(e.to)?new i.TuiDayRange(e.from,e.from.append(this.minLength).append({day:-1})):e,n=this.maxLength?t.from.append(this.maxLength).append({day:-1}):this.max;return t.to.dayAfter(n)?new i.TuiDayRange(t.from,n):t},s.ctorParameters=function(){return[{type:n.NgControl,decorators:[{type:t.Optional},{type:t.Self},{type:t.Inject,args:[n.NgControl]}]},{type:t.ChangeDetectorRef,decorators:[{type:t.Inject,args:[t.ChangeDetectorRef]}]},{type:t.Injector,decorators:[{type:t.Inject,args:[t.Injector]}]},{type:Boolean,decorators:[{type:t.Inject,args:[i.TUI_IS_MOBILE]}]},{type:o.TuiDialogService,decorators:[{type:t.Inject,args:[o.TuiDialogService]}]},{type:t.Type,decorators:[{type:t.Optional},{type:t.Inject,args:[u.TUI_MOBILE_CALENDAR]}]},{type:o.TuiTextfieldSizeDirective,decorators:[{type:t.Inject,args:[o.TUI_TEXTFIELD_SIZE]}]},{type:o.TuiTextfieldExampleTextDirective,decorators:[{type:t.Inject,args:[o.TUI_TEXTFIELD_EXAMPLE_TEXT]}]},{type:String,decorators:[{type:t.Inject,args:[i.TUI_DATE_FILLER]}]},{type:String,decorators:[{type:t.Inject,args:[i.TUI_DATE_RANGE_FILLER]}]}]},y([t.Input(),i.tuiDefaultProp()],s.prototype,"disabledItemHandler",void 0),y([t.Input(),i.tuiDefaultProp()],s.prototype,"markerHandler",void 0),y([t.Input(),i.tuiDefaultProp()],s.prototype,"defaultViewedMonth",void 0),y([t.Input(),i.tuiDefaultProp()],s.prototype,"items",void 0),y([t.Input(),i.tuiDefaultProp()],s.prototype,"min",void 0),y([t.Input(),i.tuiDefaultProp()],s.prototype,"max",void 0),y([t.Input(),i.tuiDefaultProp()],s.prototype,"minLength",void 0),y([t.Input(),i.tuiDefaultProp()],s.prototype,"maxLength",void 0),y([t.ViewChild(o.TuiPrimitiveTextfieldComponent)],s.prototype,"textfield",void 0),y([t.HostListener("click")],s.prototype,"onClick",null),s=d=y([t.Component({selector:"tui-input-date-range",template:'<tui-hosted-dropdown\n class="hosted"\n [canOpen]="canOpen"\n [content]="dropdown"\n [open]="open && canOpen"\n (openChange)="onOpenChange($event)"\n (tuiActiveZoneChange)="onActiveZone($event)"\n>\n <tui-primitive-textfield\n automation-id="tui-input-date-range__textfield"\n class="textfield"\n tuiValueAccessor\n [pseudoFocused]="innerPseudoFocused"\n [pseudoHovered]="pseudoHovered"\n [pseudoPressed]="pseudoPressed"\n [invalid]="computedInvalid"\n [tuiTextfieldExampleText]="computedExampleText"\n [nativeId]="nativeId"\n [filler]="computedFiller"\n [readOnly]="readOnly"\n [iconContent]="computedMobile ? iconContent : calendarIcon"\n [disabled]="computedDisabled"\n [textMask]="computedMask"\n [value]="computedValue"\n (valueChange)="onValueChange($event)"\n (hoveredChange)="onHovered($event)"\n (pressedChange)="onPressed($event)"\n >\n <ng-content></ng-content>\n </tui-primitive-textfield>\n\n <ng-template #iconContent>\n <tui-svg\n automation-id="tui-input-date-range__icon"\n [class.icon]="!computedDisabled"\n [src]="calendarIcon"\n (click)="onMobileClick()"\n ></tui-svg>\n </ng-template>\n\n <ng-template #dropdown>\n <tui-calendar-range\n [defaultViewedMonth]="defaultViewedMonth"\n [disabledItemHandler]="disabledItemHandler"\n [items]="items"\n [min]="min"\n [max]="max"\n [markerHandler]="markerHandler"\n [minLength]="minLength"\n [maxLength]="maxLength"\n (rangeChange)="onRangeChange($event)"\n ></tui-calendar-range>\n </ng-template>\n</tui-hosted-dropdown>\n',providers:[{provide:i.TUI_FOCUSABLE_ITEM_ACCESSOR,useExisting:t.forwardRef((function(){return d}))},{provide:u.TUI_CALENDAR_DATA_STREAM,deps:[[new t.Optional,new t.Self,n.NgControl]],useFactory:I},r.LEFT_ALIGNED_DROPDOWN_CONTROLLER_PROVIDER],styles:[":host{display:block;border-radius:var(--tui-radius-m)}:host._disabled{pointer-events:none}.hosted{display:block;border-radius:inherit}.textfield{border-radius:inherit}.icon{pointer-events:auto}"]}),v(0,t.Optional()),v(0,t.Self()),v(0,t.Inject(n.NgControl)),v(1,t.Inject(t.ChangeDetectorRef)),v(2,t.Inject(t.Injector)),v(3,t.Inject(i.TUI_IS_MOBILE)),v(4,t.Inject(o.TuiDialogService)),v(5,t.Optional()),v(5,t.Inject(u.TUI_MOBILE_CALENDAR)),v(6,t.Inject(o.TUI_TEXTFIELD_SIZE)),v(7,t.Inject(o.TUI_TEXTFIELD_EXAMPLE_TEXT)),v(8,t.Inject(i.TUI_DATE_FILLER)),v(9,t.Inject(i.TUI_DATE_RANGE_FILLER))],s)}(i.AbstractTuiNullableControl),T=function(){function e(){}return e=y([t.NgModule({imports:[d.CommonModule,f.TextMaskModule,i.TuiActiveZoneModule,i.TuiLetModule,p.PolymorpheusModule,o.TuiPrimitiveTextfieldModule,o.TuiTextfieldControllerModule,o.TuiHostedDropdownModule,o.TuiSvgModule,g.TuiCalendarRangeModule,m.TuiValueAccessorModule],declarations:[b],exports:[b]})],e)}();e.TuiInputDateRangeComponent=b,e.TuiInputDateRangeModule=T,e.ɵ0=I,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=taiga-ui-kit-components-input-date-range.umd.min.js.map