UNPKG

@taiga-ui/kit

Version:
16 lines (14 loc) 11.5 kB
!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/directives"),require("angular2-text-mask")):"function"==typeof define&&define.amd?define("@taiga-ui/kit/components/input-date",["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/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"]={}),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.directives,e.angular2TextMask)}(this,(function(e,t,n,i,o,a,r,u,l,s,c,p,d,f,m){"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 g=function(e,t){return(g=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 h(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 y(e,t){return function(n,i){t(n,i,e)}}var v=s.TuiReplayControlValueChangesFactory,b=function(e){function s(t,n,r,u,s,c,p,d){var f=e.call(this,t,n)||this;return f.injector=r,f.isMobile=u,f.dialogService=s,f.mobileCalendar=c,f.textfieldSize=p,f.filler=d,f.min=i.TUI_FIRST_DAY,f.max=i.TUI_LAST_DAY,f.disabledItemHandler=i.ALWAYS_FALSE_HANDLER,f.markerHandler=o.TUI_DEFAULT_MARKER_HANDLER,f.items=[],f.defaultActiveYearMonth=i.TuiMonth.currentLocal(),f.open=!1,f.month=null,f.textMaskOptions={mask:a.TUI_DATE_MASK,pipe:l.tuiCreateAutoCorrectedDatePipe(f),guide:!1},f}var d;return function(e,t){function n(){this.constructor=e}g(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,"computedFiller",{get:function(){return this.activeItem?"":this.filler},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedValue",{get:function(){var e=this.value,t=this.nativeValue,n=this.activeItem;return n?String(n):e?String(e):t},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedActiveYearMonth",{get:function(){return this.items[0]&&this.value&&this.value.daySame(this.items[0].day)?this.items[0].displayDay:this.month||this.value||this.defaultActiveYearMonth},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}),Object.defineProperty(s.prototype,"canOpen",{get:function(){return!this.computedDisabled&&!this.readOnly&&!this.computedMobile},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"computedMask",{get:function(){return this.activeItem?a.EMPTY_MASK:this.textMaskOptions},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"activeItem",{get:function(){var e=this.value;return e&&this.items.find((function(t){return t.day.daySame(e)}))||null},enumerable:!0,configurable:!0}),s.prototype.onMobileClick=function(){var e=this;this.mobileCalendar?this.dialogService.open(new c.PolymorpheusComponent(this.mobileCalendar,this.injector),{size:"fullscreen",closeable:!1,data:{single:!0,min:this.min,max:this.max,disabledItemHandler:this.disabledItemHandler}}).pipe(p.takeUntil(this.destroy$)).subscribe((function(t){e.updateValue(t)})):this.open=!this.open},s.prototype.onClick=function(){this.isMobile||(this.open=!this.open)},s.prototype.onValueChange=function(e){e&&this.control&&this.control.updateValueAndValidity(),this.updateValue(e.length!==this.filler.length?null:i.TuiDay.normalizeParse(e))},s.prototype.onDayClick=function(e){this.updateValue(e),this.open=!1},s.prototype.onHovered=function(e){this.updateHovered(e)},s.prototype.onMonthChange=function(e){this.month=e},s.prototype.onOpenChange=function(e){this.open=e},s.prototype.onFocused=function(e){this.updateFocused(e)},s.prototype.setDisabledState=function(){e.prototype.setDisabledState.call(this),this.open=!1},s.prototype.writeValue=function(t){e.prototype.writeValue.call(this,t),this.nativeValue=t?this.computedValue:""},s.prototype.valueIdenticalComparator=function(e,t){return i.nullableSame(e,t,(function(e,t){return e.daySame(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:String,decorators:[{type:t.Inject,args:[i.TUI_DATE_FILLER]}]}]},h([t.Input(),i.tuiDefaultProp()],s.prototype,"min",void 0),h([t.Input(),i.tuiDefaultProp()],s.prototype,"max",void 0),h([t.Input(),i.tuiDefaultProp()],s.prototype,"disabledItemHandler",void 0),h([t.Input(),i.tuiDefaultProp()],s.prototype,"markerHandler",void 0),h([t.Input(),i.tuiDefaultProp()],s.prototype,"items",void 0),h([t.Input(),i.tuiDefaultProp()],s.prototype,"defaultActiveYearMonth",void 0),h([t.ViewChild(o.TuiPrimitiveTextfieldComponent)],s.prototype,"textfield",void 0),h([t.HostListener("click")],s.prototype,"onClick",null),s=d=h([t.Component({selector:"tui-input-date",template:'<tui-hosted-dropdown\n class="hosted"\n [canOpen]="canOpen"\n [content]="dropdown"\n [open]="open && canOpen"\n (openChange)="onOpenChange($event)"\n>\n <tui-primitive-textfield\n automation-id="tui-input-date-range__textfield"\n class="textfield"\n tuiValueAccessor\n [pseudoFocused]="pseudoFocused"\n [pseudoHovered]="pseudoHovered"\n [invalid]="computedInvalid"\n [filler]="computedFiller"\n [nativeId]="nativeId"\n [readOnly]="readOnly"\n [focusable]="computedFocusable"\n [iconContent]="computedMobile ? iconContent : calendarIcon"\n [disabled]="computedDisabled"\n [textMask]="computedMask"\n [value]="computedValue"\n (valueChange)="onValueChange($event)"\n (hoveredChange)="onHovered($event)"\n (focusedChange)="onFocused($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="polymorpheus" polymorpheus>\n <tui-calendar\n tuiPreventDefault="mousedown"\n automation-id="tui-input-date__calendar"\n [min]="min"\n [max]="max"\n [markerHandler]="markerHandler"\n [disabledItemHandler]="disabledItemHandler"\n [month]="computedActiveYearMonth"\n [value]="value"\n (dayClick)="onDayClick($event)"\n (monthChange)="onMonthChange($event)"\n ></tui-calendar>\n <div\n *ngIf="items.length === 1"\n tuiPreventDefault="mousedown"\n class="button"\n >\n <button tuiLink type="button" (click)="onDayClick(items[0].day)">\n {{items[0]}}\n </button>\n </div>\n </ng-template>\n</tui-hosted-dropdown>\n',changeDetection:t.ChangeDetectionStrategy.OnPush,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:v},r.LEFT_ALIGNED_DROPDOWN_CONTROLLER_PROVIDER],styles:[":host{display:block;border-radius:var(--tui-radius-m)}.hosted{display:block;border-radius:inherit}.textfield{border-radius:inherit}.icon{pointer-events:auto}.button{display:flex;height:44px;justify-content:center;box-shadow:inset 0 1px var(--tui-base-03)}.button button{flex:1;text-align:center}"]}),y(0,t.Optional()),y(0,t.Self()),y(0,t.Inject(n.NgControl)),y(1,t.Inject(t.ChangeDetectorRef)),y(2,t.Inject(t.Injector)),y(3,t.Inject(i.TUI_IS_MOBILE)),y(4,t.Inject(o.TuiDialogService)),y(5,t.Optional()),y(5,t.Inject(u.TUI_MOBILE_CALENDAR)),y(6,t.Inject(o.TUI_TEXTFIELD_SIZE)),y(7,t.Inject(i.TUI_DATE_FILLER))],s)}(i.AbstractTuiNullableControl),I=function(){function e(){}return e=h([t.NgModule({imports:[d.CommonModule,m.TextMaskModule,c.PolymorpheusModule,i.TuiPreventDefaultModule,o.TuiCalendarModule,o.TuiSvgModule,o.TuiLinkModule,o.TuiHostedDropdownModule,o.TuiPrimitiveTextfieldModule,f.TuiValueAccessorModule],declarations:[b],exports:[b]})],e)}();e.TuiInputDateComponent=b,e.TuiInputDateModule=I,e.ɵ0=v,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=taiga-ui-kit-components-input-date.umd.min.js.map