UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

2 lines 17.5 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@angular/forms"),require("ng-zorro-antd/i18n"),require("ng-zorro-antd/radio"),require("ng-zorro-antd/select"),require("date-fns/set_month"),require("@angular/cdk/coercion"),require("date-fns/add_days"),require("date-fns/difference_in_calendar_days"),require("date-fns/difference_in_calendar_months"),require("date-fns/difference_in_calendar_weeks"),require("date-fns/end_of_month"),require("date-fns/is_same_day"),require("date-fns/is_same_month"),require("date-fns/is_same_year"),require("date-fns/is_this_month"),require("date-fns/is_this_year"),require("date-fns/set_year"),require("date-fns/start_of_month"),require("date-fns/start_of_week"),require("date-fns/start_of_year")):"function"==typeof define&&define.amd?define("ng-zorro-antd/calendar",["exports","@angular/common","@angular/core","@angular/forms","ng-zorro-antd/i18n","ng-zorro-antd/radio","ng-zorro-antd/select","date-fns/set_month","@angular/cdk/coercion","date-fns/add_days","date-fns/difference_in_calendar_days","date-fns/difference_in_calendar_months","date-fns/difference_in_calendar_weeks","date-fns/end_of_month","date-fns/is_same_day","date-fns/is_same_month","date-fns/is_same_year","date-fns/is_this_month","date-fns/is_this_year","date-fns/set_year","date-fns/start_of_month","date-fns/start_of_week","date-fns/start_of_year"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].calendar={}),e.ng.common,e.ng.core,e.ng.forms,e["ng-zorro-antd"].i18n,e["ng-zorro-antd"].radio,e["ng-zorro-antd"].select,e.setMonth,e.ng.cdk.coercion,e.addDays,e.differenceInCalendarDays,e.differenceInCalendarMonths,e.differenceInCalendarWeeks,e.endOfMonth,e.isSameDay,e.isSameMonth,e.isSameYear,e.isThisMonth,e.isThisYear,e.setYear,e.startOfMonth,e.startOfWeek,e.startOfYear)}(this,function(e,t,n,a,r,l,o,i,s,c,u,d,h,f,p,y,g,m,C,v,D,z,M){"use strict";i=i&&i.hasOwnProperty("default")?i["default"]:i,c=c&&c.hasOwnProperty("default")?c["default"]:c,u=u&&u.hasOwnProperty("default")?u["default"]:u,d=d&&d.hasOwnProperty("default")?d["default"]:d,h=h&&h.hasOwnProperty("default")?h["default"]:h,f=f&&f.hasOwnProperty("default")?f["default"]:f,p=p&&p.hasOwnProperty("default")?p["default"]:p,y=y&&y.hasOwnProperty("default")?y["default"]:y,g=g&&g.hasOwnProperty("default")?g["default"]:g,m=m&&m.hasOwnProperty("default")?m["default"]:m,C=C&&C.hasOwnProperty("default")?C["default"]:C,v=v&&v.hasOwnProperty("default")?v["default"]:v,D=D&&D.hasOwnProperty("default")?D["default"]:D,z=z&&z.hasOwnProperty("default")?z["default"]:z,M=M&&M.hasOwnProperty("default")?M["default"]:M;var b=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzDateCell]",exportAs:"nzDateCell"}]}],e}(),w=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzMonthCell]",exportAs:"nzMonthCell"}]}],e}(),O=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzDateFullCell]",exportAs:"nzDateFullCell"}]}],e}(),_=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzMonthFullCell]",exportAs:"nzMonthFullCell"}]}],e}(),F=function(){function e(e,t){this.i18n=e,this.dateHelper=t,this.mode="month",this.modeChange=new n.EventEmitter,this.fullscreen=!0,this.yearChange=new n.EventEmitter,this.monthChange=new n.EventEmitter,this._activeDate=new Date,this.yearOffset=10,this.yearTotal=20}return Object.defineProperty(e.prototype,"activeDate",{get:function(){return this._activeDate},set:function(e){this._activeDate=e,this.setUpYears()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeYear",{get:function(){return this.activeDate.getFullYear()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeMonth",{get:function(){return this.activeDate.getMonth()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.fullscreen?"default":"small"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"yearTypeText",{get:function(){return this.i18n.getLocale().Calendar.year},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"monthTypeText",{get:function(){return this.i18n.getLocale().Calendar.month},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.setUpYears(),this.setUpMonths()},e.prototype.updateYear=function(e){this.yearChange.emit(e),this.setUpYears(e)},e.prototype.setUpYears=function(e){var t=(e||this.activeYear)-this.yearOffset,n=t+this.yearTotal;this.years=[];for(var a=t;a<n;a++)this.years.push({label:""+a,value:a})},e.prototype.setUpMonths=function(){this.months=[];for(var e=0;e<12;e++){var t=i(this.activeDate,e),n=this.dateHelper.format(t,"MMM");this.months.push({label:n,value:e})}},e.decorators=[{type:n.Component,args:[{encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,selector:"nz-calendar-header",exportAs:"nzCalendarHeader",template:'<nz-select class="ant-fullcalendar-year-select" [nzSize]="size" [nzDropdownMatchSelectWidth]="false"\n [ngModel]="activeYear" (ngModelChange)="updateYear($event)">\n <nz-option *ngFor="let year of years" [nzLabel]="year.label" [nzValue]="year.value"></nz-option>\n</nz-select>\n\n<nz-select *ngIf="mode === \'month\'" class="ant-fullcalendar-month-select" [nzSize]="size" [nzDropdownMatchSelectWidth]="false"\n [ngModel]="activeMonth" (ngModelChange)="monthChange.emit($event)">\n <nz-option *ngFor="let month of months" [nzLabel]="month.label" [nzValue]="month.value"></nz-option>\n</nz-select>\n\n<nz-radio-group [(ngModel)]="mode" (ngModelChange)="modeChange.emit($event)" [nzSize]="size">\n <label nz-radio-button nzValue="month">{{ monthTypeText }}</label>\n <label nz-radio-button nzValue="year">{{ yearTypeText }}</label>\n</nz-radio-group>\n',host:{"[style.display]":"'block'","[class.ant-fullcalendar-header]":"true"}}]}],e.ctorParameters=function(){return[{type:r.NzI18nService},{type:r.DateHelperService}]},e.propDecorators={mode:[{type:n.Input}],modeChange:[{type:n.Output}],fullscreen:[{type:n.Input}],activeDate:[{type:n.Input}],yearChange:[{type:n.Output}],monthChange:[{type:n.Output}]},e}(),P=function(){function e(e,t,a){this.i18n=e,this.cdr=t,this.dateHelper=a,this.nzMode="month",this.nzModeChange=new n.EventEmitter,this.nzPanelChange=new n.EventEmitter,this.nzSelectChange=new n.EventEmitter,this.nzValueChange=new n.EventEmitter,this.fullscreen=!0,this.daysInWeek=[],this.monthsInYear=[],this.dateMatrix=[],this.activeDate=new Date,this.currentDateRow=-1,this.currentDateCol=-1,this.activeDateRow=-1,this.activeDateCol=-1,this.currentMonthRow=-1,this.currentMonthCol=-1,this.activeMonthRow=-1,this.activeMonthCol=-1,this.dateCell=null,this.dateFullCell=null,this.monthCell=null,this.monthFullCell=null,this.currentDate=new Date,this.onChangeFn=function(){},this.onTouchFn=function(){}}return Object.defineProperty(e.prototype,"nzValue",{set:function(e){this.updateDate(e,!1)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzDateCell",{set:function(e){this.dateCell=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzDateFullCell",{set:function(e){this.dateFullCell=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzMonthCell",{set:function(e){this.monthCell=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzMonthFullCell",{set:function(e){this.monthFullCell=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzFullscreen",{get:function(){return this.fullscreen},set:function(e){this.fullscreen=s.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzCard",{get:function(){return!this.fullscreen},set:function(e){this.fullscreen=!s.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dateCellChild",{set:function(e){e&&(this.dateCell=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dateFullCellChild",{set:function(e){e&&(this.dateFullCell=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"monthCellChild",{set:function(e){e&&(this.monthCell=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"monthFullCellChild",{set:function(e){e&&(this.monthFullCell=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"calendarStart",{get:function(){return z(D(this.activeDate),{weekStartsOn:this.dateHelper.getFirstDayOfWeek()})},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.setUpDaysInWeek(),this.setUpMonthsInYear(),this.setUpDateMatrix(),this.calculateCurrentDate(),this.calculateActiveDate(),this.calculateCurrentMonth(),this.calculateActiveMonth()},e.prototype.onModeChange=function(e){this.nzModeChange.emit(e),this.nzPanelChange.emit({date:this.activeDate,mode:e})},e.prototype.onDateSelect=function(e){this.updateDate(e),this.nzSelectChange.emit(e)},e.prototype.onYearSelect=function(e){var t=v(this.activeDate,e);this.updateDate(t),this.nzSelectChange.emit(t)},e.prototype.onMonthSelect=function(e){var t=i(this.activeDate,e);this.updateDate(t),this.nzSelectChange.emit(t)},e.prototype.writeValue=function(e){this.updateDate(e||new Date,!1),this.cdr.markForCheck()},e.prototype.registerOnChange=function(e){this.onChangeFn=e},e.prototype.registerOnTouched=function(e){this.onTouchFn=e},e.prototype.updateDate=function(e,t){void 0===t&&(t=!0);var n=!p(e,this.activeDate),a=!y(e,this.activeDate),r=!g(e,this.activeDate);this.activeDate=e,n&&this.calculateActiveDate(),a&&(this.setUpDateMatrix(),this.calculateCurrentDate(),this.calculateActiveMonth()),r&&this.calculateCurrentMonth(),t&&(this.onChangeFn(e),this.onTouchFn(),this.nzValueChange.emit(e))},e.prototype.setUpDaysInWeek=function(){this.daysInWeek=[];for(var e=z(this.activeDate,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),t=0;t<7;t++){var n=c(e,t),a=this.dateHelper.format(n,this.dateHelper.relyOnDatePipe?"E":"ddd"),r=this.dateHelper.format(n,this.dateHelper.relyOnDatePipe?"EEEEEE":"dd");this.daysInWeek.push({title:a,label:r})}},e.prototype.setUpMonthsInYear=function(){this.monthsInYear=[];for(var e=0;e<12;e++){var t=i(this.activeDate,e),n=this.dateHelper.format(t,"MMM"),a=this.dateHelper.format(t,"MMM"),r=D(t);this.monthsInYear.push({title:n,label:a,start:r})}},e.prototype.setUpDateMatrix=function(){this.dateMatrix=[];for(var e=D(this.activeDate),t=f(this.activeDate),n=h(t,e,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()})+2,a=0;a<n;a++){for(var r=[],l=c(this.calendarStart,7*a),o=0;o<7;o++){var i=c(l,o),s=d(i,this.activeDate),u=this.dateHelper.relyOnDatePipe?"longDate":this.i18n.getLocaleData("DatePicker.lang.dateFormat","YYYY-MM-DD"),p=this.dateHelper.format(i,u),y=this.dateHelper.format(i,this.dateHelper.relyOnDatePipe?"dd":"DD"),g=0===s?"current":s<0?"last":"next";r.push({title:p,label:y,rel:g,value:i})}this.dateMatrix.push(r)}},e.prototype.calculateCurrentDate=function(){m(this.activeDate)?(this.currentDateRow=h(this.currentDate,this.calendarStart,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),this.currentDateCol=u(this.currentDate,c(this.calendarStart,7*this.currentDateRow))):(this.currentDateRow=-1,this.currentDateCol=-1)},e.prototype.calculateActiveDate=function(){this.activeDateRow=h(this.activeDate,this.calendarStart,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),this.activeDateCol=u(this.activeDate,c(this.calendarStart,7*this.activeDateRow))},e.prototype.calculateCurrentMonth=function(){if(C(this.activeDate)){var e=M(this.currentDate),t=d(this.currentDate,e);this.currentMonthRow=Math.floor(t/3),this.currentMonthCol=t%3}else this.currentMonthRow=-1,this.currentMonthCol=-1},e.prototype.calculateActiveMonth=function(){this.activeMonthRow=Math.floor(this.activeDate.getMonth()/3),this.activeMonthCol=this.activeDate.getMonth()%3},e.decorators=[{type:n.Component,args:[{encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,selector:"nz-calendar",exportAs:"nzCalendar",template:'<nz-calendar-header [fullscreen]="fullscreen" [activeDate]="activeDate"\n [(mode)]="nzMode" (modeChange)="onModeChange($event)"\n (yearChange)="onYearSelect($event)" (monthChange)="onMonthSelect($event)">\n</nz-calendar-header>\n\n<div class="ant-fullcalendar ant-fullcalendar-full" [ngClass]="fullscreen ? \'ant-fullcalendar-fullscreen\' : \'\'">\n <div class="ant-fullcalendar-calendar-body">\n <ng-container *ngIf="nzMode === \'month\' then monthModeTable else yearModeTable"></ng-container>\n </div>\n</div>\n\n<ng-template #monthModeTable>\n <table class="ant-fullcalendar-table" cellspacing="0" role="grid">\n <thead>\n <tr role="row">\n <th *ngFor="let day of daysInWeek" class="ant-fullcalendar-column-header" role="columnheader" [title]="day.title">\n <span class="ant-fullcalendar-column-header-inner">{{ day.label }}</span>\n </th>\n </tr>\n </thead>\n <tbody class="ant-fullcalendar-tbody">\n <tr *ngFor="let week of dateMatrix; index as row"\n [class.ant-fullcalendar-current-week]="row === currentDateRow"\n [class.ant-fullcalendar-active-week]="row === activeDateRow">\n <td *ngFor="let day of week; index as col" role="gridcell" class="ant-fullcalendar-cell" [title]="day.title"\n [class.ant-fullcalendar-today]="row === currentDateRow && col === currentDateCol"\n [class.ant-fullcalendar-selected-day]="row === activeDateRow && col === activeDateCol"\n [class.ant-fullcalendar-last-month-cell]="day.rel === \'last\'"\n [class.ant-fullcalendar-next-month-btn-day]="day.rel === \'next\'"\n (click)="onDateSelect(day.value)">\n <div class="ant-fullcalendar-date">\n <ng-container *ngIf="dateFullCell else defaultCell">\n <ng-container *ngTemplateOutlet="dateFullCell; context: {$implicit: day.value}"></ng-container>\n </ng-container>\n <ng-template #defaultCell>\n <div class="ant-fullcalendar-value">{{ day.label }}</div>\n <div *ngIf="dateCell" class="ant-fullcalendar-content">\n <ng-container *ngTemplateOutlet="dateCell; context: {$implicit: day.value}"></ng-container>\n </div>\n </ng-template>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n</ng-template>\n\n<ng-template #yearModeTable>\n <table class="ant-fullcalendar-month-panel-table" cellspacing="0" role="grid">\n <tbody class="ant-fullcalendar-month-panel-tbody">\n <tr *ngFor="let row of [0, 1, 2, 3]" role="row">\n <td *ngFor="let col of [0, 1, 2]" role="gridcell" [title]="monthsInYear[row * 3 + col].title"\n class="ant-fullcalendar-month-panel-cell"\n [class.ant-fullcalendar-month-panel-current-cell]="row === currentMonthRow && col === currentMonthCol"\n [class.ant-fullcalendar-month-panel-selected-cell]="row === activeMonthRow && col === activeMonthCol"\n (click)="onMonthSelect(row * 3 + col)">\n <div class="ant-fullcalendar-month">\n <ng-container *ngIf="monthFullCell else defaultCell">\n <ng-container *ngTemplateOutlet="monthFullCell; context: {$implicit: monthsInYear[row * 3 + col].start}"></ng-container>\n </ng-container>\n <ng-template #defaultCell>\n <div class="ant-fullcalendar-value">{{ monthsInYear[row * 3 + col].label }}</div>\n <div *ngIf="monthCell" class="ant-fullcalendar-content">\n <ng-container *ngTemplateOutlet="monthCell; context: {$implicit: monthsInYear[row * 3 + col].start}"></ng-container>\n </div>\n </ng-template>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n</ng-template>\n',providers:[{provide:a.NG_VALUE_ACCESSOR,useExisting:n.forwardRef(function(){return e}),multi:!0}]}]}],e.ctorParameters=function(){return[{type:r.NzI18nService},{type:n.ChangeDetectorRef},{type:r.DateHelperService}]},e.propDecorators={nzMode:[{type:n.Input}],nzModeChange:[{type:n.Output}],nzPanelChange:[{type:n.Output}],nzSelectChange:[{type:n.Output}],nzValue:[{type:n.Input}],nzValueChange:[{type:n.Output}],nzDateCell:[{type:n.Input}],nzDateFullCell:[{type:n.Input}],nzMonthCell:[{type:n.Input}],nzMonthFullCell:[{type:n.Input}],nzFullscreen:[{type:n.Input}],nzCard:[{type:n.Input}],dateCellChild:[{type:n.ContentChild,args:[b,{"static":!1,read:n.TemplateRef}]}],dateFullCellChild:[{type:n.ContentChild,args:[O,{"static":!1,read:n.TemplateRef}]}],monthCellChild:[{type:n.ContentChild,args:[w,{"static":!1,read:n.TemplateRef}]}],monthFullCellChild:[{type:n.ContentChild,args:[_,{"static":!1,read:n.TemplateRef}]}],fullscreen:[{type:n.HostBinding,args:["class.ant-fullcalendar--fullscreen"]}]},e}(),I=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{declarations:[F,P,b,O,w,_],exports:[P,b,O,w,_],imports:[t.CommonModule,a.FormsModule,r.NzI18nModule,l.NzRadioModule,o.NzSelectModule]}]}],e}();e.NzCalendarComponent=P,e.NzCalendarHeaderComponent=F,e.NzCalendarModule=I,e.NzDateCellDirective=b,e.NzDateFullCellDirective=O,e.NzMonthCellDirective=w,e.NzMonthFullCellDirective=_,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-calendar.umd.min.js.map