ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,159 lines (1,128 loc) • 180 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/overlay'), require('@angular/common'), require('@angular/core'), require('ng-zorro-antd/core'), require('ng-zorro-antd/icon'), require('@angular/forms'), require('ng-zorro-antd/i18n'), require('ng-zorro-antd/time-picker'), require('ng-zorro-antd/calendar'), require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('ng-zorro-antd/date-picker', ['exports', '@angular/cdk/overlay', '@angular/common', '@angular/core', 'ng-zorro-antd/core', 'ng-zorro-antd/icon', '@angular/forms', 'ng-zorro-antd/i18n', 'ng-zorro-antd/time-picker', 'ng-zorro-antd/calendar', 'rxjs', 'rxjs/operators'], factory) :
(global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd']['date-picker'] = {}), global.ng.cdk.overlay, global.ng.common, global.ng.core, global['ng-zorro-antd'].core, global['ng-zorro-antd'].icon, global.ng.forms, global['ng-zorro-antd'].i18n, global['ng-zorro-antd']['time-picker'], global['ng-zorro-antd'].calendar, global.rxjs, global.rxjs.operators));
}(this, function (exports, overlay, common, core, core$1, icon, forms, i18n, timePicker, calendar, rxjs, operators) { '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.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var CalendarFooterComponent = /** @class */ (function () {
function CalendarFooterComponent() {
this.showToday = false;
this.hasTimePicker = false;
this.isRange = false;
this.showTimePicker = false;
this.showTimePickerChange = new core.EventEmitter();
this.timePickerDisabled = false;
this.okDisabled = false;
this.clickOk = new core.EventEmitter();
this.clickToday = new core.EventEmitter();
this.prefixCls = 'ant-calendar';
this.isTemplateRef = core$1.isTemplateRef;
this.isNonEmptyString = core$1.isNonEmptyString;
}
CalendarFooterComponent.decorators = [
{ type: core.Component, args: [{
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line:component-selector
selector: 'calendar-footer',
exportAs: 'calendarFooter',
template: "<div class=\"{{ prefixCls }}-footer {{ isRange ? prefixCls + '-range-bottom' : '' }} {{ hasTimePicker ? prefixCls + '-footer-show-ok' : '' }}\">\n <div *ngIf=\"rangeQuickSelector\" class=\"{{ prefixCls }}-footer-extra {{ prefixCls }}-range-quick-selector\">\n <ng-container *ngTemplateOutlet=\"rangeQuickSelector\"></ng-container>\n </div>\n <div *ngIf=\"extraFooter\" class=\"{{ prefixCls }}-footer-extra {{ isRange ? prefixCls + '-range-quick-selector' : '' }}\">\n <ng-container [ngSwitch]=\"true\">\n <ng-container *ngSwitchCase=\"isTemplateRef(extraFooter)\">\n <ng-container *ngTemplateOutlet=\"extraFooter\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"isNonEmptyString(extraFooter)\">\n <span [innerHTML]=\"extraFooter\"></span>\n </ng-container>\n </ng-container>\n </div>\n <span *ngIf=\"showToday || hasTimePicker\" class=\"{{ prefixCls }}-footer-btn\">\n <today-button\n *ngIf=\"showToday\"\n [locale]=\"locale\"\n [disabledDate]=\"disabledDate\"\n [hasTimePicker]=\"hasTimePicker\"\n (clickToday)=\"clickToday.emit($event)\"\n ></today-button>\n <time-picker-button\n *ngIf=\"hasTimePicker\"\n [locale]=\"locale\"\n [timePickerDisabled]=\"timePickerDisabled\"\n [showTimePicker]=\"showTimePicker\"\n (showTimePickerChange)=\"showTimePickerChange.emit($event)\"\n ></time-picker-button>\n <ok-button\n *ngIf=\"hasTimePicker\"\n [okDisabled]=\"okDisabled\"\n [locale]=\"locale\"\n (clickOk)=\"clickOk.emit()\"\n ></ok-button>\n </span>\n</div>"
}] }
];
CalendarFooterComponent.propDecorators = {
locale: [{ type: core.Input }],
showToday: [{ type: core.Input }],
hasTimePicker: [{ type: core.Input }],
isRange: [{ type: core.Input }],
showTimePicker: [{ type: core.Input }],
showTimePickerChange: [{ type: core.Output }],
timePickerDisabled: [{ type: core.Input }],
okDisabled: [{ type: core.Input }],
disabledDate: [{ type: core.Input }],
extraFooter: [{ type: core.Input }],
rangeQuickSelector: [{ type: core.Input }],
clickOk: [{ type: core.Output }],
clickToday: [{ type: core.Output }]
};
return CalendarFooterComponent;
}());
if (false) {
/** @type {?} */
CalendarFooterComponent.prototype.locale;
/** @type {?} */
CalendarFooterComponent.prototype.showToday;
/** @type {?} */
CalendarFooterComponent.prototype.hasTimePicker;
/** @type {?} */
CalendarFooterComponent.prototype.isRange;
/** @type {?} */
CalendarFooterComponent.prototype.showTimePicker;
/** @type {?} */
CalendarFooterComponent.prototype.showTimePickerChange;
/** @type {?} */
CalendarFooterComponent.prototype.timePickerDisabled;
/** @type {?} */
CalendarFooterComponent.prototype.okDisabled;
/** @type {?} */
CalendarFooterComponent.prototype.disabledDate;
/** @type {?} */
CalendarFooterComponent.prototype.extraFooter;
/** @type {?} */
CalendarFooterComponent.prototype.rangeQuickSelector;
/** @type {?} */
CalendarFooterComponent.prototype.clickOk;
/** @type {?} */
CalendarFooterComponent.prototype.clickToday;
/** @type {?} */
CalendarFooterComponent.prototype.prefixCls;
/** @type {?} */
CalendarFooterComponent.prototype.isTemplateRef;
/** @type {?} */
CalendarFooterComponent.prototype.isNonEmptyString;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var CalendarHeaderComponent = /** @class */ (function () {
function CalendarHeaderComponent(dateHelper) {
this.dateHelper = dateHelper;
this.enablePrev = true;
this.enableNext = true;
this.showTimePicker = false;
this.valueChange = new core.EventEmitter();
this.panelModeChange = new core.EventEmitter();
this.chooseDecade = new core.EventEmitter();
this.chooseYear = new core.EventEmitter();
this.chooseMonth = new core.EventEmitter();
this.prefixCls = 'ant-calendar';
this.yearToMonth = false; // Indicate whether should change to month panel when current is year panel (if referer=month, it should show month panel when choosed a year)
}
/**
* @return {?}
*/
CalendarHeaderComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if (!this.value) {
this.value = new core$1.CandyDate(); // Show today by default
}
};
/**
* @param {?} changes
* @return {?}
*/
CalendarHeaderComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.value || changes.showTimePicker || changes.panelMode) {
this.render();
}
};
/**
* @return {?}
*/
CalendarHeaderComponent.prototype.previousYear = /**
* @return {?}
*/
function () {
this.gotoYear(-1);
};
/**
* @return {?}
*/
CalendarHeaderComponent.prototype.nextYear = /**
* @return {?}
*/
function () {
this.gotoYear(1);
};
/**
* @return {?}
*/
CalendarHeaderComponent.prototype.previousMonth = /**
* @return {?}
*/
function () {
this.gotoMonth(-1);
};
/**
* @return {?}
*/
CalendarHeaderComponent.prototype.nextMonth = /**
* @return {?}
*/
function () {
this.gotoMonth(1);
};
/**
* @param {?} mode
* @param {?=} value
* @return {?}
*/
CalendarHeaderComponent.prototype.changePanel = /**
* @param {?} mode
* @param {?=} value
* @return {?}
*/
function (mode, value) {
this.panelModeChange.emit(mode);
if (value) {
this.changeValueFromInside(value);
}
};
/**
* @param {?} value
* @return {?}
*/
CalendarHeaderComponent.prototype.onChooseDecade = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.changePanel('year', value);
this.chooseDecade.emit(value);
};
/**
* @param {?} value
* @return {?}
*/
CalendarHeaderComponent.prototype.onChooseYear = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.changePanel(this.yearToMonth ? 'month' : 'date', value);
this.yearToMonth = false; // Clear
this.chooseYear.emit(value);
};
/**
* @param {?} value
* @return {?}
*/
CalendarHeaderComponent.prototype.onChooseMonth = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.changePanel('date', value);
this.yearToMonth = false; // Clear
this.chooseMonth.emit(value);
};
/**
* @return {?}
*/
CalendarHeaderComponent.prototype.changeToMonthPanel = /**
* @return {?}
*/
function () {
this.changePanel('month');
this.yearToMonth = true;
};
/**
* @private
* @return {?}
*/
CalendarHeaderComponent.prototype.render = /**
* @private
* @return {?}
*/
function () {
if (this.value) {
this.yearMonthDaySelectors = this.createYearMonthDaySelectors();
}
};
/**
* @private
* @param {?} amount
* @return {?}
*/
CalendarHeaderComponent.prototype.gotoMonth = /**
* @private
* @param {?} amount
* @return {?}
*/
function (amount) {
this.changeValueFromInside(this.value.addMonths(amount));
};
/**
* @private
* @param {?} amount
* @return {?}
*/
CalendarHeaderComponent.prototype.gotoYear = /**
* @private
* @param {?} amount
* @return {?}
*/
function (amount) {
this.changeValueFromInside(this.value.addYears(amount));
};
/**
* @private
* @param {?} value
* @return {?}
*/
CalendarHeaderComponent.prototype.changeValueFromInside = /**
* @private
* @param {?} value
* @return {?}
*/
function (value) {
if (this.value !== value) {
this.value = value;
this.valueChange.emit(this.value);
this.render();
}
};
/**
* @private
* @param {?} localeFormat
* @return {?}
*/
CalendarHeaderComponent.prototype.formatDateTime = /**
* @private
* @param {?} localeFormat
* @return {?}
*/
function (localeFormat) {
return this.dateHelper.format(this.value.nativeDate, localeFormat);
};
/**
* @private
* @return {?}
*/
CalendarHeaderComponent.prototype.createYearMonthDaySelectors = /**
* @private
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var year;
/** @type {?} */
var month;
/** @type {?} */
var day;
// NOTE: Compat for DatePipe formatting rules
/** @type {?} */
var yearFormat = this.locale.yearFormat;
if (this.dateHelper.relyOnDatePipe) {
yearFormat = ((/** @type {?} */ (this.dateHelper))).transCompatFormat(yearFormat);
}
year = {
className: this.prefixCls + "-year-select",
title: this.locale.yearSelect,
onClick: (/**
* @return {?}
*/
function () { return (_this.showTimePicker ? null : _this.changePanel('year')); }),
label: this.formatDateTime(yearFormat)
};
month = {
className: this.prefixCls + "-month-select",
title: this.locale.monthSelect,
onClick: (/**
* @return {?}
*/
function () { return (_this.showTimePicker ? null : _this.changeToMonthPanel()); }),
label: this.formatDateTime(this.locale.monthFormat || 'MMM')
};
// NOTE: Compat for DatePipe formatting rules
/** @type {?} */
var dayFormat = this.locale.dayFormat;
if (this.dateHelper.relyOnDatePipe) {
dayFormat = ((/** @type {?} */ (this.dateHelper))).transCompatFormat(dayFormat);
}
if (this.showTimePicker) {
day = {
className: this.prefixCls + "-day-select",
label: this.formatDateTime(dayFormat)
};
}
/** @type {?} */
var result;
if (this.locale.monthBeforeYear) {
result = [month, (/** @type {?} */ (day)), year];
}
else {
result = [year, month, (/** @type {?} */ (day))];
}
return result.filter((/**
* @param {?} selector
* @return {?}
*/
function (selector) { return !!selector; }));
};
CalendarHeaderComponent.decorators = [
{ type: core.Component, args: [{
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line:component-selector
selector: 'calendar-header',
exportAs: 'calendarHeader',
template: "<div class=\"{{ prefixCls }}-header\">\n <div style=\"position: relative;\">\n <a *ngIf=\"enablePrev && !showTimePicker\"\n class=\"{{ prefixCls }}-prev-year-btn\"\n role=\"button\"\n (click)=\"previousYear()\"\n title=\"{{ locale.previousYear }}\"\n ></a>\n <a *ngIf=\"enablePrev && !showTimePicker\"\n class=\"{{ prefixCls }}-prev-month-btn\"\n role=\"button\"\n (click)=\"previousMonth()\"\n title=\"{{ locale.previousMonth }}\"\n ></a>\n\n <span class=\"{{ prefixCls }}-{{ locale.monthBeforeYear ? 'my-select' : 'ym-select' }}\">\n <ng-container *ngFor=\"let selector of yearMonthDaySelectors\">\n <a class=\"{{ selector.className }}\"\n role=\"button\"\n (click)=\"selector.onClick ? selector.onClick() : null\"\n title=\"{{ selector.title || null }}\"\n >\n {{ selector.label }}\n </a>\n </ng-container>\n </span>\n\n <a *ngIf=\"enableNext && !showTimePicker\"\n class=\"{{ prefixCls }}-next-month-btn\"\n role=\"button\"\n (click)=\"nextMonth()\"\n title=\"{{ locale.nextMonth }}\"\n ></a>\n <a *ngIf=\"enableNext && !showTimePicker\"\n class=\"{{ prefixCls }}-next-year-btn\"\n role=\"button\"\n (click)=\"nextYear()\"\n title=\"{{ locale.nextYear }}\"\n ></a>\n </div>\n\n <ng-container [ngSwitch]=\"panelMode\">\n <ng-container *ngSwitchCase=\"'decade'\">\n <decade-panel\n [locale]=\"locale\"\n [value]=\"value\"\n (valueChange)=\"onChooseDecade($event)\"\n ></decade-panel>\n </ng-container>\n <ng-container *ngSwitchCase=\"'year'\">\n <year-panel\n [locale]=\"locale\"\n [value]=\"value\"\n [disabledDate]=\"disabledYear\"\n (valueChange)=\"onChooseYear($event)\"\n (decadePanelShow)=\"changePanel('decade')\"\n ></year-panel>\n </ng-container>\n <ng-container *ngSwitchCase=\"'month'\">\n <month-panel\n [locale]=\"locale\"\n [value]=\"value\"\n [disabledDate]=\"disabledMonth\"\n (valueChange)=\"onChooseMonth($event)\"\n (yearPanelShow)=\"changePanel('year')\"\n ></month-panel>\n </ng-container>\n </ng-container>\n</div>"
}] }
];
/** @nocollapse */
CalendarHeaderComponent.ctorParameters = function () { return [
{ type: i18n.DateHelperService }
]; };
CalendarHeaderComponent.propDecorators = {
locale: [{ type: core.Input }],
enablePrev: [{ type: core.Input }],
enableNext: [{ type: core.Input }],
disabledMonth: [{ type: core.Input }],
disabledYear: [{ type: core.Input }],
showTimePicker: [{ type: core.Input }],
value: [{ type: core.Input }],
valueChange: [{ type: core.Output }],
panelMode: [{ type: core.Input }],
panelModeChange: [{ type: core.Output }],
chooseDecade: [{ type: core.Output }],
chooseYear: [{ type: core.Output }],
chooseMonth: [{ type: core.Output }]
};
return CalendarHeaderComponent;
}());
if (false) {
/** @type {?} */
CalendarHeaderComponent.prototype.locale;
/** @type {?} */
CalendarHeaderComponent.prototype.enablePrev;
/** @type {?} */
CalendarHeaderComponent.prototype.enableNext;
/** @type {?} */
CalendarHeaderComponent.prototype.disabledMonth;
/** @type {?} */
CalendarHeaderComponent.prototype.disabledYear;
/** @type {?} */
CalendarHeaderComponent.prototype.showTimePicker;
/** @type {?} */
CalendarHeaderComponent.prototype.value;
/** @type {?} */
CalendarHeaderComponent.prototype.valueChange;
/** @type {?} */
CalendarHeaderComponent.prototype.panelMode;
/** @type {?} */
CalendarHeaderComponent.prototype.panelModeChange;
/** @type {?} */
CalendarHeaderComponent.prototype.chooseDecade;
/** @type {?} */
CalendarHeaderComponent.prototype.chooseYear;
/** @type {?} */
CalendarHeaderComponent.prototype.chooseMonth;
/** @type {?} */
CalendarHeaderComponent.prototype.prefixCls;
/** @type {?} */
CalendarHeaderComponent.prototype.yearMonthDaySelectors;
/**
* @type {?}
* @private
*/
CalendarHeaderComponent.prototype.yearToMonth;
/**
* @type {?}
* @private
*/
CalendarHeaderComponent.prototype.dateHelper;
}
/**
* @record
*/
function YearMonthDaySelector() { }
if (false) {
/** @type {?} */
YearMonthDaySelector.prototype.className;
/** @type {?|undefined} */
YearMonthDaySelector.prototype.title;
/** @type {?} */
YearMonthDaySelector.prototype.label;
/**
* @return {?}
*/
YearMonthDaySelector.prototype.onClick = function () { };
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var CalendarInputComponent = /** @class */ (function () {
function CalendarInputComponent(dateHelper) {
this.dateHelper = dateHelper;
this.valueChange = new core.EventEmitter();
this.prefixCls = 'ant-calendar';
this.invalidInputClass = '';
}
/**
* @return {?}
*/
CalendarInputComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if (this.autoFocus) {
this.inputRef.nativeElement.focus();
}
};
/**
* @param {?} event
* @param {?=} isEnter
* @return {?}
*/
CalendarInputComponent.prototype.onInputKeyup = /**
* @param {?} event
* @param {?=} isEnter
* @return {?}
*/
function (event, isEnter) {
if (isEnter === void 0) { isEnter = false; }
/** @type {?} */
var date = this.checkValidInputDate(event);
if (!date || (this.disabledDate && this.disabledDate(date.nativeDate))) {
return;
}
this.value = date;
this.valueChange.emit({ date: date, isEnter: isEnter });
};
/**
* @param {?} value
* @return {?}
*/
CalendarInputComponent.prototype.toReadableInput = /**
* @param {?} value
* @return {?}
*/
function (value) {
return value ? this.dateHelper.format(value.nativeDate, this.format) : '';
};
/**
* @private
* @param {?} event
* @return {?}
*/
CalendarInputComponent.prototype.checkValidInputDate = /**
* @private
* @param {?} event
* @return {?}
*/
function (event) {
/** @type {?} */
var input = ((/** @type {?} */ (event.target))).value;
/** @type {?} */
var date = new core$1.CandyDate(input);
this.invalidInputClass = '';
if (!date.isValid() || input !== this.toReadableInput(date)) {
// Should also match the input format exactly
this.invalidInputClass = this.prefixCls + "-input-invalid";
return null;
}
return date;
};
CalendarInputComponent.decorators = [
{ type: core.Component, args: [{
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line:component-selector
selector: 'calendar-input',
exportAs: 'calendarInput',
template: "<div class=\"{{ prefixCls }}-input-wrap\">\n <div class=\"{{ prefixCls }}-date-input-wrap\">\n <input\n class=\"{{ prefixCls }}-input {{ invalidInputClass }}\"\n placeholder=\"{{ placeholder || locale.dateSelect }}\"\n value=\"{{ toReadableInput(value) }}\"\n (input)=\"onInputKeyup($event)\"\n (keyup.enter)=\"onInputKeyup($event, true)\"\n #inputElement\n />\n </div>\n <a class=\"{{ prefixCls }}-clear-btn\" role=\"button\" title=\"{{ locale.clear }}\"></a>\n</div>\n"
}] }
];
/** @nocollapse */
CalendarInputComponent.ctorParameters = function () { return [
{ type: i18n.DateHelperService }
]; };
CalendarInputComponent.propDecorators = {
locale: [{ type: core.Input }],
format: [{ type: core.Input }],
placeholder: [{ type: core.Input }],
disabledDate: [{ type: core.Input }],
value: [{ type: core.Input }],
autoFocus: [{ type: core.Input }],
inputRef: [{ type: core.ViewChild, args: ['inputElement', { static: true },] }],
valueChange: [{ type: core.Output }]
};
return CalendarInputComponent;
}());
if (false) {
/** @type {?} */
CalendarInputComponent.prototype.locale;
/** @type {?} */
CalendarInputComponent.prototype.format;
/** @type {?} */
CalendarInputComponent.prototype.placeholder;
/** @type {?} */
CalendarInputComponent.prototype.disabledDate;
/** @type {?} */
CalendarInputComponent.prototype.value;
/** @type {?} */
CalendarInputComponent.prototype.autoFocus;
/** @type {?} */
CalendarInputComponent.prototype.inputRef;
/** @type {?} */
CalendarInputComponent.prototype.valueChange;
/** @type {?} */
CalendarInputComponent.prototype.prefixCls;
/** @type {?} */
CalendarInputComponent.prototype.invalidInputClass;
/**
* @type {?}
* @private
*/
CalendarInputComponent.prototype.dateHelper;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var OkButtonComponent = /** @class */ (function () {
function OkButtonComponent() {
this.okDisabled = false;
this.clickOk = new core.EventEmitter();
this.prefixCls = 'ant-calendar';
}
OkButtonComponent.decorators = [
{ type: core.Component, args: [{
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line:component-selector
selector: 'ok-button',
exportAs: 'okButton',
template: "<a\n class=\"{{ prefixCls }}-ok-btn {{ okDisabled ? prefixCls + '-ok-btn-disabled' : '' }}\"\n role=\"button\"\n (click)=\"okDisabled ? null : clickOk.emit()\"\n >\n {{ locale.ok }}\n </a>"
}] }
];
OkButtonComponent.propDecorators = {
locale: [{ type: core.Input }],
okDisabled: [{ type: core.Input }],
clickOk: [{ type: core.Output }]
};
return OkButtonComponent;
}());
if (false) {
/** @type {?} */
OkButtonComponent.prototype.locale;
/** @type {?} */
OkButtonComponent.prototype.okDisabled;
/** @type {?} */
OkButtonComponent.prototype.clickOk;
/** @type {?} */
OkButtonComponent.prototype.prefixCls;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TimePickerButtonComponent = /** @class */ (function () {
function TimePickerButtonComponent() {
this.timePickerDisabled = false;
this.showTimePicker = false;
this.showTimePickerChange = new core.EventEmitter();
this.prefixCls = 'ant-calendar';
}
/**
* @return {?}
*/
TimePickerButtonComponent.prototype.onClick = /**
* @return {?}
*/
function () {
this.showTimePicker = !this.showTimePicker;
this.showTimePickerChange.emit(this.showTimePicker);
};
TimePickerButtonComponent.decorators = [
{ type: core.Component, args: [{
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line:component-selector
selector: 'time-picker-button',
exportAs: 'timePickerButton',
template: "<a\n class=\"{{ prefixCls }}-time-picker-btn {{ timePickerDisabled ? prefixCls + '-time-picker-btn-disabled' : '' }}\"\n role=\"button\"\n (click)=\"timePickerDisabled ? null : onClick()\"\n>\n {{ showTimePicker ? locale.dateSelect : locale.timeSelect }}\n</a>"
}] }
];
TimePickerButtonComponent.propDecorators = {
locale: [{ type: core.Input }],
timePickerDisabled: [{ type: core.Input }],
showTimePicker: [{ type: core.Input }],
showTimePickerChange: [{ type: core.Output }]
};
return TimePickerButtonComponent;
}());
if (false) {
/** @type {?} */
TimePickerButtonComponent.prototype.locale;
/** @type {?} */
TimePickerButtonComponent.prototype.timePickerDisabled;
/** @type {?} */
TimePickerButtonComponent.prototype.showTimePicker;
/** @type {?} */
TimePickerButtonComponent.prototype.showTimePickerChange;
/** @type {?} */
TimePickerButtonComponent.prototype.prefixCls;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TodayButtonComponent = /** @class */ (function () {
function TodayButtonComponent(dateHelper) {
this.dateHelper = dateHelper;
this.hasTimePicker = false;
this.clickToday = new core.EventEmitter();
this.prefixCls = 'ant-calendar';
this.isDisabled = false;
this.now = new core$1.CandyDate();
}
/**
* @param {?} changes
* @return {?}
*/
TodayButtonComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.disabledDate) {
this.isDisabled = this.disabledDate && this.disabledDate(this.now.nativeDate);
}
if (changes.locale) {
// NOTE: Compat for DatePipe formatting rules
/** @type {?} */
var dateFormat = this.locale.dateFormat;
if (this.dateHelper.relyOnDatePipe) {
dateFormat = ((/** @type {?} */ (this.dateHelper))).transCompatFormat(dateFormat);
}
this.title = this.dateHelper.format(this.now.nativeDate, dateFormat);
}
};
/**
* @return {?}
*/
TodayButtonComponent.prototype.onClickToday = /**
* @return {?}
*/
function () {
this.clickToday.emit(this.now.clone()); // To prevent the "now" being modified from outside, we use clone
};
TodayButtonComponent.decorators = [
{ type: core.Component, args: [{
encapsulation: core.ViewEncapsulation.None,
changeDetection: core.ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line:component-selector
selector: 'today-button',
exportAs: 'todayButton',
template: "<a\n class=\"{{ prefixCls }}-today-btn {{ isDisabled ? prefixCls + '-today-btn-disabled' : '' }}\"\n role=\"button\"\n (click)=\"isDisabled ? null : onClickToday()\"\n title=\"{{ title }}\"\n>\n {{ hasTimePicker ? locale.now : locale.today }}\n</a>"
}] }
];
/** @nocollapse */
TodayButtonComponent.ctorParameters = function () { return [
{ type: i18n.DateHelperService }
]; };
TodayButtonComponent.propDecorators = {
locale: [{ type: core.Input }],
hasTimePicker: [{ type: core.Input }],
disabledDate: [{ type: core.Input }],
clickToday: [{ type: core.Output }]
};
return TodayButtonComponent;
}());
if (false) {
/** @type {?} */
TodayButtonComponent.prototype.locale;
/** @type {?} */
TodayButtonComponent.prototype.hasTimePicker;
/** @type {?} */
TodayButtonComponent.prototype.disabledDate;
/** @type {?} */
TodayButtonComponent.prototype.clickToday;
/** @type {?} */
TodayButtonComponent.prototype.prefixCls;
/** @type {?} */
TodayButtonComponent.prototype.isDisabled;
/** @type {?} */
TodayButtonComponent.prototype.title;
/**
* @type {?}
* @private
*/
TodayButtonComponent.prototype.now;
/**
* @type {?}
* @private
*/
TodayButtonComponent.prototype.dateHelper;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var MAX_ROW = 4;
/** @type {?} */
var MAX_COL = 3;
var DecadePanelComponent = /** @class */ (function () {
function DecadePanelComponent() {
this.valueChange = new core.EventEmitter();
this.prefixCls = 'ant-calendar-decade-panel';
}
Object.defineProperty(DecadePanelComponent.prototype, "startYear", {
get: /**
* @return {?}
*/
function () {
return parseInt("" + this.value.getYear() / 100, 10) * 100;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DecadePanelComponent.prototype, "endYear", {
get: /**
* @return {?}
*/
function () {
return this.startYear + 99;
},
enumerable: true,
configurable: true
});
/**
* @param {?} changes
* @return {?}
*/
DecadePanelComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.value) {
this.render();
}
};
/**
* @return {?}
*/
DecadePanelComponent.prototype.previousCentury = /**
* @return {?}
*/
function () {
this.gotoYear(-100);
};
/**
* @return {?}
*/
DecadePanelComponent.prototype.nextCentury = /**
* @return {?}
*/
function () {
this.gotoYear(100);
};
/**
* @param {?} _index
* @param {?} decadeData
* @return {?}
*/
DecadePanelComponent.prototype.trackPanelDecade = /**
* @param {?} _index
* @param {?} decadeData
* @return {?}
*/
function (_index, decadeData) {
return decadeData.content;
};
/**
* @private
* @return {?}
*/
DecadePanelComponent.prototype.render = /**
* @private
* @return {?}
*/
function () {
if (this.value) {
this.panelDecades = this.makePanelDecades();
}
};
// Re-render panel content by the header's buttons (NOTE: Do not try to trigger final value change)
// Re-render panel content by the header's buttons (NOTE: Do not try to trigger final value change)
/**
* @private
* @param {?} amount
* @return {?}
*/
DecadePanelComponent.prototype.gotoYear =
// Re-render panel content by the header's buttons (NOTE: Do not try to trigger final value change)
/**
* @private
* @param {?} amount
* @return {?}
*/
function (amount) {
this.value = this.value.addYears(amount);
// this.valueChange.emit(this.value); // Do not try to trigger final value change
this.render();
};
/**
* @private
* @param {?} startYear
* @return {?}
*/
DecadePanelComponent.prototype.chooseDecade = /**
* @private
* @param {?} startYear
* @return {?}
*/
function (startYear) {
this.value = this.value.setYear(startYear);
this.valueChange.emit(this.value);
};
/**
* @private
* @return {?}
*/
DecadePanelComponent.prototype.makePanelDecades = /**
* @private
* @return {?}
*/
function () {
var _this = this;
/** @type {?} */
var decades = [];
/** @type {?} */
var currentYear = this.value.getYear();
/** @type {?} */
var startYear = this.startYear;
/** @type {?} */
var endYear = this.endYear;
/** @type {?} */
var previousYear = startYear - 10;
/** @type {?} */
var index = 0;
for (var rowIndex = 0; rowIndex < MAX_ROW; rowIndex++) {
decades[rowIndex] = [];
var _loop_1 = function (colIndex) {
var _a;
/** @type {?} */
var start = previousYear + index * 10;
/** @type {?} */
var end = previousYear + index * 10 + 9;
/** @type {?} */
var content = start + "-" + end;
/** @type {?} */
var cell = (decades[rowIndex][colIndex] = {
content: content,
title: content,
isCurrent: currentYear >= start && currentYear <= end,
isLowerThanStart: end < startYear,
isBiggerThanEnd: start > endYear,
classMap: null,
onClick: null
});
cell.classMap = (_a = {},
_a[this_1.prefixCls + "-cell"] = true,
_a[this_1.prefixCls + "-selected-cell"] = cell.isCurrent,
_a[this_1.prefixCls + "-last-century-cell"] = cell.isLowerThanStart,
_a[this_1.prefixCls + "-next-century-cell"] = cell.isBiggerThanEnd,
_a);
if (cell.isLowerThanStart) {
cell.onClick = (/**
* @return {?}
*/
function () { return _this.previousCentury(); });
}
else if (cell.isBiggerThanEnd) {
cell.onClick = (/**
* @return {?}
*/
function () { return _this.nextCentury(); });
}
else {
cell.onClick = (/**
* @return {?}
*/
function () { return _this.chooseDecade(start); });
}
index++;
};
var this_1 = this;
for (var colIndex = 0; colIndex < MAX_COL; colIndex++) {
_loop_1(colIndex);
}