UNPKG

ng-zorro-antd

Version:

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

16 lines (14 loc) 10.8 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/date-picker"),require("ng-zorro-antd/i18n"),require("ng-zorro-antd/radio"),require("ng-zorro-antd/select"),require("ng-zorro-antd/core/time"),require("ng-zorro-antd/core/util")):"function"==typeof define&&define.amd?define("ng-zorro-antd/calendar",["exports","@angular/common","@angular/core","@angular/forms","ng-zorro-antd/date-picker","ng-zorro-antd/i18n","ng-zorro-antd/radio","ng-zorro-antd/select","ng-zorro-antd/core/time","ng-zorro-antd/core/util"],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"]["date-picker"],e["ng-zorro-antd"].i18n,e["ng-zorro-antd"].radio,e["ng-zorro-antd"].select,e["ng-zorro-antd"].core.time,e["ng-zorro-antd"].core.util)}(this,(function(e,t,n,a,o,r,l,i,c,u){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function s(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var p=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzDateCell]",exportAs:"nzDateCell"}]}],e}(),d=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzMonthCell]",exportAs:"nzMonthCell"}]}],e}(),h=function(){function e(){}return e.decorators=[{type:n.Directive,args:[{selector:"[nzDateFullCell]",exportAs:"nzDateFullCell"}]}],e}(),g=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.fullscreen=!0,this.activeDate=new c.CandyDate,this.modeChange=new n.EventEmitter,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:'\n <div class="ant-picker-calendar-header">\n <nz-select\n class="ant-picker-calendar-year-select"\n [nzSize]="size"\n [nzDropdownMatchSelectWidth]="false"\n [ngModel]="activeYear"\n (ngModelChange)="updateYear($event)"\n >\n <nz-option *ngFor="let year of years" [nzLabel]="year.label" [nzValue]="year.value"></nz-option>\n </nz-select>\n\n <nz-select\n *ngIf="mode === \'month\'"\n class="ant-picker-calendar-month-select"\n [nzSize]="size"\n [nzDropdownMatchSelectWidth]="false"\n [ngModel]="activeMonth"\n (ngModelChange)="monthChange.emit($event)"\n >\n <nz-option *ngFor="let month of months" [nzLabel]="month.label" [nzValue]="month.value"></nz-option>\n </nz-select>\n\n <nz-radio-group class="ant-picker-calendar-mode-switch" [(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 </div>\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}],fullscreen:[{type:n.Input}],activeDate:[{type:n.Input}],modeChange:[{type:n.Output}],yearChange:[{type:n.Output}],monthChange:[{type:n.Output}]},e}();var z=function(){function e(e){this.cdr=e,this.activeDate=new c.CandyDate,this.prefixCls="ant-picker-calendar",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,"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}),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 c.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.prototype.ngOnChanges=function(e){e.nzValue&&this.updateDate(new c.CandyDate(this.nzValue),!1)},e.decorators=[{type:n.Component,args:[{encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,selector:"nz-calendar",exportAs:"nzCalendar",template:'\n <nz-calendar-header\n [fullscreen]="nzFullscreen"\n [activeDate]="activeDate"\n [(mode)]="nzMode"\n (modeChange)="onModeChange($event)"\n (yearChange)="onYearSelect($event)"\n (monthChange)="onMonthSelect($event)"\n >\n </nz-calendar-header>\n\n <div class="ant-picker-panel">\n <div class="ant-picker-{{ nzMode === \'month\' ? \'date\' : \'month\' }}-panel">\n <div class="ant-picker-body">\n <ng-container *ngIf="nzMode === \'month\'; then monthModeTable; else yearModeTable"></ng-container>\n </div>\n </div>\n </div>\n <ng-template #monthModeTable>\n <date-table\n [prefixCls]="prefixCls"\n [value]="activeDate"\n [activeDate]="activeDate"\n [cellRender]="dateCell"\n [fullCellRender]="dateFullCell"\n (valueChange)="onDateSelect($event)"\n ></date-table>\n </ng-template>\n\n <ng-template #yearModeTable>\n <month-table\n [prefixCls]="prefixCls"\n [value]="activeDate"\n [activeDate]="activeDate"\n [cellRender]="monthCell"\n [fullCellRender]="monthFullCell"\n (valueChange)="onDateSelect($event)"\n ></month-table>\n </ng-template>\n ',host:{"[class.ant-picker-calendar]":"true","[class.ant-picker-calendar-full]":"nzFullscreen","[class.ant-picker-calendar-mini]":"!nzFullscreen"},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}],nzValue:[{type:n.Input}],nzModeChange:[{type:n.Output}],nzPanelChange:[{type:n.Output}],nzSelectChange:[{type:n.Output}],nzValueChange:[{type:n.Output}],nzDateCell:[{type:n.Input}],nzDateCellChild:[{type:n.ContentChild,args:[p,{static:!1,read:n.TemplateRef}]}],nzDateFullCell:[{type:n.Input}],nzDateFullCellChild:[{type:n.ContentChild,args:[h,{static:!1,read:n.TemplateRef}]}],nzMonthCell:[{type:n.Input}],nzMonthCellChild:[{type:n.ContentChild,args:[d,{static:!1,read:n.TemplateRef}]}],nzMonthFullCell:[{type:n.Input}],nzMonthFullCellChild:[{type:n.ContentChild,args:[g,{static:!1,read:n.TemplateRef}]}],nzFullscreen:[{type:n.Input}]},function(e,t,n,a){var o,r=arguments.length,l=r<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,a);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(l=(r<3?o(l):r>3?o(t,n,l):o(t,n))||l);r>3&&l&&Object.defineProperty(t,n,l)}([u.InputBoolean(),s("design:type",Boolean)],e.prototype,"nzFullscreen",void 0),e}();var C=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{declarations:[f,z,p,h,d,g],exports:[z,p,h,d,g],imports:[t.CommonModule,a.FormsModule,r.NzI18nModule,l.NzRadioModule,i.NzSelectModule,o.LibPackerModule]}]}],e}();e.NzCalendarComponent=z,e.NzCalendarHeaderComponent=f,e.NzCalendarModule=C,e.NzDateCellDirective=p,e.NzDateFullCellDirective=h,e.NzMonthCellDirective=d,e.NzMonthFullCellDirective=g,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-calendar.umd.min.js.map