@taiga-ui/kit
Version:
Taiga UI Angular main components kit
16 lines (14 loc) • 11.1 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@taiga-ui/cdk"),require("@taiga-ui/kit/tokens"),require("rxjs"),require("@angular/common"),require("@taiga-ui/core")):"function"==typeof define&&define.amd?define("@taiga-ui/kit/components/calendar-month",["exports","@angular/core","@taiga-ui/cdk","@taiga-ui/kit/tokens","rxjs","@angular/common","@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["calendar-month"]={}),e.ng.core,e.cdk,e["taiga-ui"].kit.tokens,e.rxjs,e.ng.common,e.core$1)}(this,(function(e,t,i,n,r,a,o){"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.
***************************************************************************** */function l(e,t,i,n){var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o}var u=i.TuiDay.currentLocal(),s=function(){function e(e){this.months$=e,this.value=null,this.year=u,this.disabledItemHandler=i.ALWAYS_FALSE_HANDLER,this.min=i.TUI_FIRST_DAY,this.max=i.TUI_LAST_DAY,this.monthClick=new t.EventEmitter,this.hoveredItemChange=new t.EventEmitter,this.yearChange=new t.EventEmitter,this.isYearPickerShown=!1,this.hoveredItem=null,this.pressedItem=null}var a,o;return Object.defineProperty(e.prototype,"isSingle",{get:function(){return null!==this.value&&(this.value instanceof i.TuiMonth||this.value.isSingleMonth)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"previousYearDisabled",{get:function(){return this.year.yearSameOrBefore(this.min)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nextYearDisabled",{get:function(){return this.year.yearSameOrAfter(this.max)},enumerable:!0,configurable:!0}),e.prototype.getItemState=function(e){var t=this.disabledItemHandlerWithMinMax,i=this.pressedItem,n=this.hoveredItem;return t(e)?"disabled":null!==i&&i.monthSame(e)?"pressed":null!==n&&n.monthSame(e)?"hovered":null},e.prototype.getItemRange=function(e){var t=this.value,n=this.hoveredItem;if(null===t)return null;if(t instanceof i.TuiMonth)return t.monthSame(e)?"single":null;var r=t.from.monthSame(e)&&!t.isSingleMonth,a=null!==n&&n.monthAfter(t.from)&&t.from.monthSame(e)&&t.isSingleMonth,o=null!==n&&n.monthSame(e)&&n.monthBefore(t.from)&&t.isSingleMonth;if(r||a||o)return"start";var l=t.to.monthSame(e)&&!t.isSingleMonth,u=t.to.monthSame(e)&&!t.isSingleMonth,s=null!==n&&n.monthSame(e)&&n.monthAfter(t.from)&&t.isSingleMonth;return l||u||s?"end":t.isSingleMonth&&t.from.monthSame(e)?"single":null},e.prototype.getTuiMonth=function(e,t){return new i.TuiMonth(t,e)},e.prototype.isItemToday=function(e){return u.monthSame(e)},e.prototype.isItemInsideRange=function(e){var t=this.value,n=this.hoveredItem;if(null===t||t instanceof i.TuiMonth)return!1;if(!t.isSingleMonth)return t.from.monthSameOrBefore(e)&&t.to.monthAfter(e);if(null===n)return!1;var r=i.TuiMonthRange.sort(t.from,n);return r.from.monthSameOrBefore(e)&&r.to.monthAfter(e)},e.prototype.onPickerYearClick=function(e){this.isYearPickerShown=!1,this.year.yearSame(e)||(this.year=e,this.yearChange.emit(e))},e.prototype.onItemClick=function(e){this.disabledItemHandlerWithMinMax(e)||this.monthClick.emit(e)},e.prototype.onYearClick=function(){this.isYearPickerShown=!0},e.prototype.onNextYear=function(){this.year=this.year.append({year:1})},e.prototype.onPreviousYear=function(){this.year=this.year.append({year:-1})},e.prototype.onItemHovered=function(e,t){this.updateHoveredItem(e?t:null)},e.prototype.onItemPressed=function(e,t){this.updatePressedItem(e?t:null)},Object.defineProperty(e.prototype,"disabledItemHandlerWithMinMax",{get:function(){return this.calculateDisabledItemHandlerWithMinMax(this.disabledItemHandler,this.value,this.min,this.max)},enumerable:!0,configurable:!0}),e.prototype.updateHoveredItem=function(e){i.nullableSame(this.hoveredItem,e,(function(e,t){return e.monthSame(t)}))||(this.hoveredItem=e,this.hoveredItemChange.emit(e))},e.prototype.updatePressedItem=function(e){this.pressedItem=e},e.prototype.calculateDisabledItemHandlerWithMinMax=function(e,t,i,n){return function(r){return r.monthBefore(i)||r.monthAfter(n)||e(r,{value:t})}},e.ctorParameters=function(){return[{type:r.Observable,decorators:[{type:t.Inject,args:[n.TUI_CALENDAR_MONTHS]}]}]},l([t.Input(),i.tuiDefaultProp()],e.prototype,"value",void 0),l([t.Input(),i.tuiDefaultProp()],e.prototype,"year",void 0),l([t.Input(),i.tuiDefaultProp()],e.prototype,"disabledItemHandler",void 0),l([t.Input(),i.tuiDefaultProp()],e.prototype,"min",void 0),l([t.Input(),i.tuiDefaultProp()],e.prototype,"max",void 0),l([t.Output()],e.prototype,"monthClick",void 0),l([t.Output()],e.prototype,"hoveredItemChange",void 0),l([t.Output()],e.prototype,"yearChange",void 0),l([t.HostBinding("class._single")],e.prototype,"isSingle",null),l([i.tuiPure],e.prototype,"calculateDisabledItemHandlerWithMinMax",null),e=l([t.Component({selector:"tui-calendar-month",template:'<tui-scrollbar *ngIf="isYearPickerShown; else monthSelect" class="scrollbar">\n <tui-primitive-year-picker\n [min]="min"\n [max]="max"\n [initialItem]="year"\n [value]="value"\n (yearClick)="onPickerYearClick($event)"\n ></tui-primitive-year-picker>\n</tui-scrollbar>\n<ng-template #monthSelect>\n <tui-primitive-spin-button\n [focusable]="false"\n [leftDisabled]="previousYearDisabled"\n [rightDisabled]="nextYearDisabled"\n (leftClick)="onPreviousYear()"\n (rightClick)="onNextYear()"\n >\n <button tuiLink [tuiFocusable]="false" (click)="onYearClick()">\n {{year.formattedYear}}\n </button>\n </tui-primitive-spin-button>\n <div class="row">\n <ng-container\n *ngFor="let month of (months$ | async); let index = index"\n >\n <div\n *tuiLet="getTuiMonth(index, year.year) as item"\n class="cell"\n [class.cell_today]="isItemToday(item)"\n [class.cell_interval]="isItemInsideRange(item)"\n [attr.data-tui-element-range]="getItemRange(item)"\n [attr.data-tui-element-state]="getItemState(item)"\n (tuiHoveredChange)="onItemHovered($event, item)"\n (tuiPressedChange)="onItemHovered($event, item)"\n (click)="onItemClick(item)"\n >\n <div class="item">{{month}}</div>\n </div>\n </ng-container>\n </div>\n</ng-template>\n',changeDetection:t.ChangeDetectionStrategy.OnPush,styles:[":host{font:var(--tui-font-text-m)}.row{position:relative;z-index:0;display:flex;justify-content:space-between;height:36px}.item{position:relative;flex:1;line-height:32px;border-radius:var(--tui-radius-m)}.item:after,.item:before{content:'';position:absolute;top:0;left:0;right:0;bottom:0;z-index:-1;border-radius:var(--tui-radius-m)}.cell{position:relative;display:flex;align-items:center;justify-content:center;width:59px;text-align:center;outline:0;cursor:pointer;background-clip:content-box;box-sizing:border-box;border:2px solid transparent;box-sizing:content-box}.cell:before{content:'';position:absolute;top:0;left:0;right:0;bottom:0;z-index:-1;border-radius:var(--tui-radius-m)}.cell_today:after{position:absolute;left:50%;transform:translate(-50%,0);content:'';bottom:5px;height:2px;width:12px;border-radius:6px;background-color:var(--tui-text-02)}.cell_interval:before{background:var(--tui-base-02)}:host._single .cell_interval:before{background:var(--tui-secondary-hover)}.cell_interval:not(:last-child):before{right:-59px}.cell_interval:last-child:first-child:before{right:0}.cell_interval:first-child>.item{border-top-left-radius:var(--tui-radius-m);border-bottom-left-radius:var(--tui-radius-m)}.cell_interval:last-child>.item{border-top-right-radius:var(--tui-radius-m);border-bottom-right-radius:var(--tui-radius-m)}.cell_interval>.item{border-radius:0}.cell[data-tui-element-range]:after{background-color:var(--tui-primary-text)}.cell[data-tui-element-range]>.item{color:var(--tui-primary-text)}.cell[data-tui-element-range]>.item:after,.cell[data-tui-element-range]>.item:before{background-color:var(--tui-primary)}.cell[data-tui-element-range][data-tui-element-state=hovered]>.item:after,.cell[data-tui-element-range][data-tui-element-state=hovered]>.item:before{background-color:var(--tui-primary-hover)}.cell[data-tui-element-range][data-tui-element-state=pressed]>.item:after,.cell[data-tui-element-range][data-tui-element-state=pressed]>.item:before{background-color:var(--tui-primary-active)}.cell[data-tui-element-range=end]>.item:before{left:4px}.cell[data-tui-element-range=end]>.item:after{left:-32px;right:100%;transform:translateX(23px) scaleY(.6) scaleX(.4) rotate(45deg)}.cell[data-tui-element-range=start]>.item:before{right:4px}.cell[data-tui-element-range=start]>.item:after{left:100%;right:-32px;transform:translateX(-23px) scaleY(.6) scaleX(.4) rotate(45deg)}.cell[data-tui-element-state=disabled]{pointer-events:none}.cell[data-tui-element-state=disabled]>.item{opacity:.36}.cell[data-tui-element-state=hovered]:hover:not([data-tui-element-range])>.item{background-color:var(--tui-secondary-hover)}.cell[data-tui-element-state=pressed]:hover:not([data-tui-element-range])>.item{background-color:var(--tui-secondary-active)}:host{display:block;height:218px;width:252px;padding:18px;box-sizing:content-box}.row{flex-wrap:wrap;margin-top:23px}.cell:nth-child(n+5){margin-top:28px}.cell_interval:nth-child(4n):before{right:0}.scrollbar{height:inherit;width:inherit}"]}),(a=0,o=t.Inject(n.TUI_CALENDAR_MONTHS),function(e,t){o(e,t,a)})],e)}(),m=function(){function e(){}return e=l([t.NgModule({imports:[a.CommonModule,o.TuiPrimitiveYearPickerModule,o.TuiPrimitiveSpinButtonModule,o.TuiScrollbarModule,o.TuiLinkModule,i.TuiLetModule,i.TuiHoveredModule,i.TuiPressedModule,i.TuiFocusableModule],declarations:[s],exports:[s]})],e)}();e.TuiCalendarMonthComponent=s,e.TuiCalendarMonthModule=m,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=taiga-ui-kit-components-calendar-month.umd.min.js.map