ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 17.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("date-fns/set_month"),require("ng-zorro-antd/i18n"),require("@angular/cdk/coercion"),require("@angular/forms"),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"),require("@angular/common"),require("ng-zorro-antd/radio"),require("ng-zorro-antd/select")):"function"==typeof define&&define.amd?define("ng-zorro-antd/calendar",["exports","@angular/core","date-fns/set_month","ng-zorro-antd/i18n","@angular/cdk/coercion","@angular/forms","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","@angular/common","ng-zorro-antd/radio","ng-zorro-antd/select"],t):t((e["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].calendar={}),e.ng.core,e.setMonth,e["ng-zorro-antd"].i18n,e.ng.cdk.coercion,e.ng.forms,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,e.ng.common,e["ng-zorro-antd"].radio,e["ng-zorro-antd"].select)}(this,function(e,a,l,t,n,r,f,o,p,y,g,i,s,c,u,d,h,m,C,v,D,z,M){"use strict";l=l&&l.hasOwnProperty("default")?l["default"]:l,f=f&&f.hasOwnProperty("default")?f["default"]:f,o=o&&o.hasOwnProperty("default")?o["default"]:o,p=p&&p.hasOwnProperty("default")?p["default"]:p,y=y&&y.hasOwnProperty("default")?y["default"]:y,g=g&&g.hasOwnProperty("default")?g["default"]:g,i=i&&i.hasOwnProperty("default")?i["default"]:i,s=s&&s.hasOwnProperty("default")?s["default"]:s,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,m=m&&m.hasOwnProperty("default")?m["default"]:m,C=C&&C.hasOwnProperty("default")?C["default"]:C,v=v&&v.hasOwnProperty("default")?v["default"]:v;var b=function(){function e(){}return e.decorators=[{type:a.Directive,args:[{selector:"[nzDateCell]",exportAs:"nzDateCell"}]}],e}(),w=function(){function e(){}return e.decorators=[{type:a.Directive,args:[{selector:"[nzMonthCell]",exportAs:"nzMonthCell"}]}],e}(),O=function(){function e(){}return e.decorators=[{type:a.Directive,args:[{selector:"[nzDateFullCell]",exportAs:"nzDateFullCell"}]}],e}(),_=function(){function e(){}return e.decorators=[{type:a.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 a.EventEmitter,this.fullscreen=!0,this.yearChange=new a.EventEmitter,this.monthChange=new a.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=l(this.activeDate,e),n=this.dateHelper.format(t,"MMM");this.months.push({label:n,value:e})}},e.decorators=[{type:a.Component,args:[{encapsulation:a.ViewEncapsulation.None,changeDetection:a.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:t.NzI18nService},{type:t.DateHelperService}]},e.propDecorators={mode:[{type:a.Input}],modeChange:[{type:a.Output}],fullscreen:[{type:a.Input}],activeDate:[{type:a.Input}],yearChange:[{type:a.Output}],monthChange:[{type:a.Output}]},e}(),P=function(){function e(e,t,n){this.i18n=e,this.cdr=t,this.dateHelper=n,this.nzMode="month",this.nzModeChange=new a.EventEmitter,this.nzPanelChange=new a.EventEmitter,this.nzSelectChange=new a.EventEmitter,this.nzValueChange=new a.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=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzCard",{get:function(){return!this.fullscreen},set:function(e){this.fullscreen=!n.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 C(m(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=h(this.activeDate,e);this.updateDate(t),this.nzSelectChange.emit(t)},e.prototype.onMonthSelect=function(e){var t=l(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=!i(e,this.activeDate),a=!s(e,this.activeDate),r=!c(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=C(this.activeDate,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),t=0;t<7;t++){var n=f(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=l(this.activeDate,e),n=this.dateHelper.format(t,"MMM"),a=this.dateHelper.format(t,"MMM"),r=m(t);this.monthsInYear.push({title:n,label:a,start:r})}},e.prototype.setUpDateMatrix=function(){this.dateMatrix=[];for(var e=m(this.activeDate),t=g(this.activeDate),n=y(t,e,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()})+2,a=0;a<n;a++){for(var r=[],l=f(this.calendarStart,7*a),o=0;o<7;o++){var i=f(l,o),s=p(i,this.activeDate),c=this.dateHelper.relyOnDatePipe?"longDate":this.i18n.getLocaleData("DatePicker.lang.dateFormat","YYYY-MM-DD"),u=this.dateHelper.format(i,c),d=this.dateHelper.format(i,this.dateHelper.relyOnDatePipe?"dd":"DD"),h=0===s?"current":s<0?"last":"next";r.push({title:u,label:d,rel:h,value:i})}this.dateMatrix.push(r)}},e.prototype.calculateCurrentDate=function(){u(this.activeDate)?(this.currentDateRow=y(this.currentDate,this.calendarStart,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),this.currentDateCol=o(this.currentDate,f(this.calendarStart,7*this.currentDateRow))):(this.currentDateRow=-1,this.currentDateCol=-1)},e.prototype.calculateActiveDate=function(){this.activeDateRow=y(this.activeDate,this.calendarStart,{weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),this.activeDateCol=o(this.activeDate,f(this.calendarStart,7*this.activeDateRow))},e.prototype.calculateCurrentMonth=function(){if(d(this.activeDate)){var e=v(this.currentDate),t=p(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:a.Component,args:[{encapsulation:a.ViewEncapsulation.None,changeDetection:a.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:r.NG_VALUE_ACCESSOR,useExisting:a.forwardRef(function(){return e}),multi:!0}]}]}],e.ctorParameters=function(){return[{type:t.NzI18nService},{type:a.ChangeDetectorRef},{type:t.DateHelperService}]},e.propDecorators={nzMode:[{type:a.Input}],nzModeChange:[{type:a.Output}],nzPanelChange:[{type:a.Output}],nzSelectChange:[{type:a.Output}],nzValue:[{type:a.Input}],nzValueChange:[{type:a.Output}],nzDateCell:[{type:a.Input}],nzDateFullCell:[{type:a.Input}],nzMonthCell:[{type:a.Input}],nzMonthFullCell:[{type:a.Input}],nzFullscreen:[{type:a.Input}],nzCard:[{type:a.Input}],dateCellChild:[{type:a.ContentChild,args:[b,{read:a.TemplateRef}]}],dateFullCellChild:[{type:a.ContentChild,args:[O,{read:a.TemplateRef}]}],monthCellChild:[{type:a.ContentChild,args:[w,{read:a.TemplateRef}]}],monthFullCellChild:[{type:a.ContentChild,args:[_,{read:a.TemplateRef}]}],fullscreen:[{type:a.HostBinding,args:["class.ant-fullcalendar--fullscreen"]}]},e}(),I=function(){function e(){}return e.decorators=[{type:a.NgModule,args:[{declarations:[F,P,b,O,w,_],exports:[P,b,O,w,_],imports:[D.CommonModule,r.FormsModule,t.NzI18nModule,z.NzRadioModule,M.NzSelectModule]}]}],e}();e.NzCalendarModule=I,e.NzCalendarComponent=P,e.NzDateCellDirective=b,e.NzMonthCellDirective=w,e.NzDateFullCellDirective=O,e.NzMonthFullCellDirective=_,e.NzCalendarHeaderComponent=F,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-calendar.umd.min.js.map