ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 20.2 kB
JavaScript
!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("ng-zorro-antd/core")):"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","ng-zorro-antd/core"],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["ng-zorro-antd"].core)}(this,function(e,t,n,a,l,r,o,i){"use strict";function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var c=function(){function e(){this.isTemplateRef=i.isTemplateRef,this.isNonEmptyString=i.isNonEmptyString}return e.decorators=[{type:n.Component,args:[{selector:"[date-table-cell]",exportAs:"dateTableCell",template:'<ng-container [ngSwitch]="prefixCls">\n <ng-container *ngSwitchCase="\'ant-calendar\'">\n <ng-container [ngSwitch]="true">\n <ng-container *ngSwitchCase="isTemplateRef(cell.dateCellRender)">\n <ng-container *ngTemplateOutlet="cell.dateCellRender; context: { $implicit: cell.value }"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase="isNonEmptyString(cell.dateCellRender)">\n <span [innerHTML]="cell.dateCellRender"></span>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <div class="{{ prefixCls }}-date" [attr.aria-selected]="cell.isSelected" [attr.aria-disabled]="cell.isDisabled">\n {{ cell.content }}\n </div>\n </ng-container>\n </ng-container>\n </ng-container>\n <ng-container *ngSwitchCase="\'ant-fullcalendar\'">\n <div class="ant-fullcalendar-date">\n <ng-container *ngIf="cell.dateFullCellRender else defaultCell">\n <ng-container *ngTemplateOutlet="cell.dateFullCellRender; context: {$implicit: cell.value}"></ng-container>\n </ng-container>\n <ng-template #defaultCell>\n <div class="{{ prefixCls }}-value">{{ cell.content }}</div>\n <div *ngIf="cell.dateCellRender" class="{{ prefixCls }}-content">\n <ng-container *ngTemplateOutlet="cell.dateCellRender; context: {$implicit: cell.value}"></ng-container>\n </div>\n </ng-template>\n </div>\n </ng-container>\n</ng-container>'}]}],e.propDecorators={prefixCls:[{type:n.Input}],cell:[{type:n.Input}]},e}();var u=function(){function e(e,t){this.i18n=e,this.dateHelper=t,this.prefixCls="ant-calendar",this.showWeek=!1,this.dayHover=new n.EventEmitter,this.valueChange=new n.EventEmitter}return Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(e){this._value=this.activeDate=e},enumerable:!0,configurable:!0}),e.prototype.ngOnChanges=function(e){(this.isDateRealChange(e.activeDate)||this.isDateRealChange(e.value)||this.isDateRealChange(e.selectedValue)||this.isDateRealChange(e.hoverValue))&&this.render()},e.prototype.isDateRealChange=function(e){if(e){var t=e.previousValue,n=e.currentValue;return Array.isArray(n)?!Array.isArray(t)||n.length!==t.length||n.some(function(e,n){var a=t[n];return a instanceof i.CandyDate?a.isSameDay(e):a!==e}):!this.isSameDate(t,n)}return!1},e.prototype.isSameDate=function(e,t){return!e&&!t||e&&t&&t.isSameDay(e)},e.prototype.render=function(){this.value&&(this.headWeekDays=this.makeHeadWeekDays(),this.weekRows=this.makeWeekRows())},e.prototype.changeValueFromInside=function(e){var t=this.value.setYear(e.getYear()).setMonth(e.getMonth()).setDate(e.getDate());this.valueChange.emit(t)},e.prototype.makeHeadWeekDays=function(){for(var e=[],t=this.activeDate.calendarStart({weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),n=0;n<7;n++){var a=t.addDays(n);e[n]={short:this.dateHelper.format(a.nativeDate,this.dateHelper.relyOnDatePipe?"E":"ddd"),veryShort:this.dateHelper.format(a.nativeDate,this.getVeryShortWeekFormat())}}return e},e.prototype.getVeryShortWeekFormat=function(){return this.dateHelper.relyOnDatePipe?0===this.i18n.getLocaleId().toLowerCase().indexOf("zh")?"EEEEE":"EEEEEE":"dd"},e.prototype.makeWeekRows=function(){for(var e,t=this,n=[],a=this.activeDate.calendarStart({weekStartsOn:this.dateHelper.getFirstDayOfWeek()}),l=0;l<6;l++){for(var r=a.addDays(7*l),o={isActive:!1,isCurrent:!1,dateCells:[],year:r.getYear()},s=function(e){var n,a=r.addDays(e),l=c.dateHelper.relyOnDatePipe?"longDate":c.i18n.getLocaleData("DatePicker.lang.dateFormat","YYYY-MM-DD"),s=c.dateHelper.format(a.nativeDate,l),u=c.dateHelper.format(a.nativeDate,c.dateHelper.relyOnDatePipe?"dd":"DD"),p={value:a.nativeDate,label:u,isSelected:!1,isDisabled:!1,isToday:!1,title:s,dateCellRender:i.valueFunctionProp(c.dateCellRender,a),dateFullCellRender:i.valueFunctionProp(c.dateFullCellRender,a),content:""+a.getDate(),onClick:function(){return t.changeValueFromInside(a)},onMouseEnter:function(){return t.dayHover.emit(a)}};if(c.showWeek&&!o.weekNum&&(o.weekNum=c.dateHelper.getISOWeek(a.nativeDate)),a.isToday()&&(p.isToday=!0,o.isCurrent=!0),Array.isArray(c.selectedValue)&&a.isSameMonth(c.activeDate)){var d=c.hoverValue&&c.hoverValue.length?c.hoverValue:c.selectedValue,h=d[0],g=d[1];h&&(h.isSameDay(a)&&(p.isSelectedStartDate=!0,p.isSelected=!0,o.isActive=!0),g&&(g.isSameDay(a)?(p.isSelectedEndDate=!0,p.isSelected=!0,o.isActive=!0):a.isAfterDay(h)&&a.isBeforeDay(g)&&(p.isInRange=!0)))}else a.isSameDay(c.value)&&(p.isSelected=!0,o.isActive=!0);c.disabledDate&&c.disabledDate(a.nativeDate)&&(p.isDisabled=!0),p.classMap=((n={})[c.prefixCls+"-cell"]=!0,n[c.prefixCls+"-today"]=p.isToday,n[c.prefixCls+"-last-month-cell"]=a.isBeforeMonth(c.activeDate),n[c.prefixCls+"-next-month-btn-day"]=a.isAfterMonth(c.activeDate),n[c.prefixCls+"-selected-day"]=p.isSelected,n[c.prefixCls+"-disabled-cell"]=p.isDisabled,n[c.prefixCls+"-selected-start-date"]=!!p.isSelectedStartDate,n[c.prefixCls+"-selected-end-date"]=!!p.isSelectedEndDate,n[c.prefixCls+"-in-range-cell"]=!!p.isInRange,n),o.dateCells.push(p)},c=this,u=0;u<7;u++)s(u);o.classMap=((e={})[this.prefixCls+"-current-week"]=o.isCurrent,e[this.prefixCls+"-active-week"]=o.isActive,e),n.push(o)}return n},e.prototype.trackByDateFn=function(e,t){return""+t.title},e.prototype.trackByWeekFn=function(e,t){return t.year+"-"+t.weekNum},e.decorators=[{type:n.Component,args:[{encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,selector:"date-table",exportAs:"dateTable",template:'<table class="{{ prefixCls }}-table" cellSpacing="0" role="grid">\n <thead>\n <tr role="row">\n <th *ngIf="showWeek" role="columnheader" class="{{ prefixCls }}-column-header {{ prefixCls }}-week-number-header">\n <span class="{{ prefixCls }}-column-header-inner">x</span>\n </th>\n <th *ngFor="let cell of headWeekDays" role="columnheader" title="{{ cell.short }}"\n class="{{ prefixCls }}-column-header">\n <span class="{{ prefixCls }}-column-header-inner">{{ cell.veryShort }}</span>\n </th>\n </tr>\n </thead>\n <tbody class="{{ prefixCls }}-tbody">\n <tr *ngFor="let row of weekRows;trackBy:trackByWeekFn" [ngClass]="row.classMap" role="row">\n <td *ngIf="row.weekNum" role="gridcell" class="{{ prefixCls }}-week-number-cell">\n {{ row.weekNum }}\n </td>\n <td *ngFor="let cell of row.dateCells;trackBy:trackByDateFn" title="{{ cell.title }}" role="gridcell" [ngClass]="cell.classMap"\n (click)="cell.isDisabled ? null : cell.onClick()" (mouseenter)="cell.isDisabled ? null : cell.onMouseEnter()"\n date-table-cell [prefixCls]="prefixCls" [cell]="cell">\n </td>\n </tr>\n </tbody>\n</table>'}]}],e.ctorParameters=function(){return[{type:l.NzI18nService},{type:l.DateHelperService}]},e.propDecorators={prefixCls:[{type:n.Input}],locale:[{type:n.Input}],selectedValue:[{type:n.Input}],hoverValue:[{type:n.Input}],value:[{type:n.Input}],activeDate:[{type:n.Input}],showWeek:[{type:n.Input}],disabledDate:[{type:n.Input}],dateCellRender:[{type:n.Input}],dateFullCellRender:[{type:n.Input}],dayHover:[{type:n.Output}],valueChange:[{type:n.Output}]},e}();var p=function(){function e(e){this.dateHelper=e,this.value=new i.CandyDate,this.prefixCls="ant-fullcalendar",this.valueChange=new n.EventEmitter}return e.prototype.ngOnChanges=function(e){(e.value||e.disabledDate)&&this.render()},e.prototype.trackYear=function(e){return this.value?this.value.getYear():e},e.prototype.trackPanelMonth=function(e,t){return t.content},e.prototype.render=function(){this.value&&(this.panelMonths=this.makePanelMonths())},e.prototype.makePanelMonths=function(){for(var e=this,t=[],n=this.value.getMonth(),a=new i.CandyDate,l=0,r=0;r<4;r++){t[r]=[];for(var o=function(o){var i,c=s.value.setMonth(l),u=!!s.disabledDate&&s.disabledDate(s.value.setMonth(l).nativeDate),p=s.dateHelper.format(c.nativeDate,"MMM"),d=t[r][o]={value:c.nativeDate,disabled:u,content:p,month:l,title:p,classMap:null,onClick:function(){return e.chooseMonth(d.month)}};d.classMap=((i={})[s.prefixCls+"-month-panel-cell"]=!0,i[s.prefixCls+"-month-panel-cell-disabled"]=u,i[s.prefixCls+"-month-panel-selected-cell"]=l===n,i[s.prefixCls+"-month-panel-current-cell"]=a.getYear()===s.value.getYear()&&l===a.getMonth(),i),l++},s=this,c=0;c<3;c++)o(c)}return t},e.prototype.chooseMonth=function(e){this.value=this.value.setMonth(e),this.valueChange.emit(this.value),this.render()},e.decorators=[{type:n.Component,args:[{encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,selector:"month-table",exportAs:"monthTable",template:'<table class="{{ prefixCls }}-month-panel-table" cellSpacing="0" role="grid">\n <tbody class="{{ prefixCls }}-month-panel-tbody">\n <tr *ngFor="let row of panelMonths; trackBy: trackYear" role="row">\n <td *ngFor="let monthCell of row; trackBy: trackPanelMonth" role="gridcell" title="{{ monthCell.title }}"\n (click)="monthCell.disabled ? null : monthCell.onClick()" [ngClass]="monthCell.classMap">\n <ng-container [ngSwitch]="prefixCls">\n <ng-container *ngSwitchCase="\'ant-fullcalendar\'">\n <div class="{{ prefixCls }}-month">\n <ng-container *ngIf="monthFullCellRender else defaultCell">\n <ng-container *ngTemplateOutlet="monthFullCellRender; context: { $implicit: monthCell.value }">\n </ng-container>\n </ng-container>\n <ng-template #defaultCell>\n <div class="{{prefixCls}}-value">{{ monthCell.content }}</div>\n <div *ngIf="monthCellRender" class="{{prefixCls}}-content">\n <ng-container *ngTemplateOutlet="monthCellRender; context: { $implicit: monthCell.value }">\n </ng-container>\n </div>\n </ng-template>\n </div>\n </ng-container>\n <ng-container *ngSwitchCase="\'ant-calendar\'">\n <a class="{{ prefixCls }}-month-panel-month">{{ monthCell.content }}</a>\n </ng-container>\n </ng-container>\n </td>\n </tr>\n </tbody>\n</table>'}]}],e.ctorParameters=function(){return[{type:l.DateHelperService}]},e.propDecorators={value:[{type:n.Input}],prefixCls:[{type:n.Input}],monthCellRender:[{type:n.Input}],monthFullCellRender:[{type:n.Input}],valueChange:[{type:n.Output}],disabledDate:[{type:n.Input}]},e}();var d=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzDateCell]",exportAs:"nzDateCell"}]}],e}(),h=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzMonthCell]",exportAs:"nzMonthCell"}]}],e}(),g=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzDateFullCell]",exportAs:"nzDateFullCell"}]}],e}(),f=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzMonthFullCell]",exportAs:"nzMonthFullCell"}]}],e}(),C=function(){function e(e,t){this.i18n=e,this.dateHelper=t,this.mode="month",this.fullscreen=!0,this.modeChange=new n.EventEmitter,this.activeDate=new i.CandyDate,this.yearChange=new n.EventEmitter,this.monthChange=new n.EventEmitter,this.yearOffset=10,this.yearTotal=20}return Object.defineProperty(e.prototype,"activeYear",{get:function(){return this.activeDate.getYear()},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=this.activeDate.setMonth(e),n=this.dateHelper.format(t.nativeDate,"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:l.NzI18nService},{type:l.DateHelperService}]},e.propDecorators={mode:[{type:n.Input}],fullscreen:[{type:n.Input}],modeChange:[{type:n.Output}],activeDate:[{type:n.Input}],yearChange:[{type:n.Output}],monthChange:[{type:n.Output}]},e}();var y=function(){function e(e){this.cdr=e,this.activeDate=new i.CandyDate,this.prefixCls="ant-fullcalendar",this.onChangeFn=function(){},this.onTouchFn=function(){},this.nzMode="month",this.nzModeChange=new n.EventEmitter,this.nzPanelChange=new n.EventEmitter,this.nzSelectChange=new n.EventEmitter,this.nzValueChange=new n.EventEmitter,this.nzFullscreen=!0}return Object.defineProperty(e.prototype,"nzValue",{set:function(e){this.updateDate(new i.CandyDate(e),!1)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dateCell",{get:function(){return this.nzDateCell||this.nzDateCellChild},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dateFullCell",{get:function(){return this.nzDateFullCell||this.nzDateFullCellChild},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"monthCell",{get:function(){return this.nzMonthCell||this.nzMonthCellChild},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"monthFullCell",{get:function(){return this.nzMonthFullCell||this.nzMonthFullCellChild},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nzCard",{get:function(){return!this.nzFullscreen},set:function(e){i.warnDeprecation("'nzCard' is going to be removed in 9.0.0. Please use 'nzFullscreen' instead."),this.nzFullscreen=!i.toBoolean(e)},enumerable:!0,configurable:!0}),e.prototype.onModeChange=function(e){this.nzModeChange.emit(e),this.nzPanelChange.emit({date:this.activeDate.nativeDate,mode:e})},e.prototype.onYearSelect=function(e){var t=this.activeDate.setYear(e);this.updateDate(t)},e.prototype.onMonthSelect=function(e){var t=this.activeDate.setMonth(e);this.updateDate(t)},e.prototype.onDateSelect=function(e){this.updateDate(e)},e.prototype.writeValue=function(e){this.updateDate(new i.CandyDate(e),!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),this.activeDate=e,t&&(this.onChangeFn(e.nativeDate),this.onTouchFn(),this.nzSelectChange.emit(e.nativeDate),this.nzValueChange.emit(e.nativeDate))},e.decorators=[{type:n.Component,args:[{encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,selector:"nz-calendar",exportAs:"nzCalendar",template:'<nz-calendar-header [fullscreen]="nzFullscreen" [activeDate]="activeDate" [(mode)]="nzMode"\n (modeChange)="onModeChange($event)" (yearChange)="onYearSelect($event)" (monthChange)="onMonthSelect($event)">\n</nz-calendar-header>\n\n<div class="{{prefixCls}} {{prefixCls}}-full" [class.ant-fullcalendar-fullscreen]="nzFullscreen">\n <div class="{{prefixCls}}-calendar-body">\n <ng-container *ngIf="nzMode === \'month\' then monthModeTable else yearModeTable"></ng-container>\n </div>\n</div>\n\n<ng-template #monthModeTable>\n <date-table [prefixCls]="prefixCls" [value]="activeDate" [dateCellRender]="dateCell"\n [dateFullCellRender]="dateFullCell" (valueChange)="onDateSelect($event)"></date-table>\n</ng-template>\n\n<ng-template #yearModeTable>\n <month-table [prefixCls]="prefixCls" [value]="activeDate" [monthCellRender]="monthCell"\n [monthFullCellRender]="monthFullCell" (valueChange)="onDateSelect($event)"></month-table>\n</ng-template>',providers:[{provide:a.NG_VALUE_ACCESSOR,useExisting:n.forwardRef(function(){return e}),multi:!0}]}]}],e.ctorParameters=function(){return[{type:n.ChangeDetectorRef}]},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}],nzDateCellChild:[{type:n.ContentChild,args:[d,{static:!1,read:n.TemplateRef}]}],nzDateFullCell:[{type:n.Input}],nzDateFullCellChild:[{type:n.ContentChild,args:[g,{static:!1,read:n.TemplateRef}]}],nzMonthCell:[{type:n.Input}],nzMonthCellChild:[{type:n.ContentChild,args:[h,{static:!1,read:n.TemplateRef}]}],nzMonthFullCell:[{type:n.Input}],nzMonthFullCellChild:[{type:n.ContentChild,args:[f,{static:!1,read:n.TemplateRef}]}],nzFullscreen:[{type:n.Input},{type:n.HostBinding,args:["class.ant-fullcalendar--fullscreen"]}],nzCard:[{type:n.Input}]},function(e,t,n,a){var l,r=arguments.length,o=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,a);else for(var i=e.length-1;i>=0;i--)(l=e[i])&&(o=(r<3?l(o):r>3?l(t,n,o):l(t,n))||o);r>3&&o&&Object.defineProperty(t,n,o)}([i.InputBoolean(),s("design:type",Boolean)],e.prototype,"nzFullscreen",void 0),e}();var m=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{declarations:[C,y,d,g,h,f,u,c,p],exports:[y,d,g,h,f,u,p],imports:[t.CommonModule,a.FormsModule,l.NzI18nModule,r.NzRadioModule,o.NzSelectModule]}]}],e}();e.DateTableCellComponent=c,e.DateTableComponent=u,e.MonthTableComponent=p,e.NzCalendarComponent=y,e.NzCalendarHeaderComponent=C,e.NzCalendarModule=m,e.NzDateCellDirective=d,e.NzDateFullCellDirective=g,e.NzMonthCellDirective=h,e.NzMonthFullCellDirective=f,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-calendar.umd.min.js.map