UNPKG

ng-zorro-antd-yj

Version:

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

231 lines 19 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'; import { CandyDate } from '../candy-date'; /** @type {?} */ const MAX_ROW = 4; /** @type {?} */ const MAX_COL = 3; export class YearPanelComponent { constructor() { this.valueChange = new EventEmitter(); this.decadePanelShow = new EventEmitter(); this.prefixCls = 'ant-calendar-year-panel'; } /** * @return {?} */ get currentYear() { return this.value.getYear(); } /** * @return {?} */ get startYear() { return parseInt(`${this.currentYear / 10}`, 10) * 10; } /** * @return {?} */ get endYear() { return this.startYear + 9; } /** * @param {?} changes * @return {?} */ ngOnChanges(changes) { if (changes.value || changes.disabledDate) { this.render(); } } /** * @return {?} */ previousDecade() { this.gotoYear(-10); } /** * @return {?} */ nextDecade() { this.gotoYear(10); } /** * @param {?} _index * @param {?} yearData * @return {?} */ trackPanelYear(_index, yearData) { return yearData.content; } /** * @private * @return {?} */ render() { if (this.value) { this.panelYears = this.makePanelYears(); } } // Re-render panel content by the header's buttons (NOTE: Do not try to trigger final value change) /** * @private * @param {?} amount * @return {?} */ gotoYear(amount) { this.value = this.value.addYears(amount); // this.valueChange.emit(this.value); // Do not trigger final value change this.render(); } /** * @private * @param {?} year * @return {?} */ chooseYear(year) { this.value = this.value.setYear(year); this.valueChange.emit(this.value); this.render(); } /** * @private * @return {?} */ makePanelYears() { /** @type {?} */ const years = []; /** @type {?} */ const currentYear = this.currentYear; /** @type {?} */ const startYear = this.startYear; /** @type {?} */ const endYear = this.endYear; /** @type {?} */ const previousYear = startYear - 1; /** @type {?} */ let index = 0; for (let rowIndex = 0; rowIndex < MAX_ROW; rowIndex++) { years[rowIndex] = []; for (let colIndex = 0; colIndex < MAX_COL; colIndex++) { /** @type {?} */ const year = previousYear + index; /** @type {?} */ const content = String(year); /** @type {?} */ const disabled = this.disabledDate ? this.disabledDate(this.value.setYear(year).nativeDate) : false; /** @type {?} */ const cell = (years[rowIndex][colIndex] = { disabled, content, year, title: content, isCurrent: year === currentYear, isLowerThanStart: year < startYear, isBiggerThanEnd: year > endYear, classMap: null, onClick: null }); cell.classMap = { [`${this.prefixCls}-cell`]: true, [`${this.prefixCls}-selected-cell`]: cell.isCurrent, [`${this.prefixCls}-cell-disabled`]: disabled, [`${this.prefixCls}-last-decade-cell`]: cell.isLowerThanStart, [`${this.prefixCls}-next-decade-cell`]: cell.isBiggerThanEnd }; if (cell.isLowerThanStart) { cell.onClick = (/** * @return {?} */ () => this.previousDecade()); } else if (cell.isBiggerThanEnd) { cell.onClick = (/** * @return {?} */ () => this.nextDecade()); } else { cell.onClick = (/** * @return {?} */ () => this.chooseYear(cell.year)); } index++; } } return years; } } YearPanelComponent.decorators = [ { type: Component, args: [{ encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, // tslint:disable-next-line:component-selector selector: 'year-panel', template: "<div class=\"{{ prefixCls }}\">\n <div>\n <div class=\"{{ prefixCls }}-header\">\n <a\n class=\"{{ prefixCls }}-prev-decade-btn\"\n role=\"button\"\n (click)=\"previousDecade()\"\n title=\"{{ locale.previousDecade }}\"\n ></a>\n <a\n class=\"{{ prefixCls }}-decade-select\"\n role=\"button\"\n (click)=\"decadePanelShow.emit()\"\n title=\"{{ locale.decadeSelect }}\"\n >\n <span class=\"{{ prefixCls }}-decade-select-content\">\n {{ startYear }}-{{ endYear }}\n </span>\n <span class=\"{{ prefixCls }}-decade-select-arrow\">x</span>\n </a>\n\n <a class=\"{{ prefixCls }}-next-decade-btn\" (click)=\"nextDecade()\" title=\"{{ locale.nextDecade }}\" role=\"button\"></a>\n </div>\n <div class=\"{{ prefixCls }}-body\">\n <table class=\"{{ prefixCls }}-table\" cellSpacing=\"0\" role=\"grid\">\n <tbody class=\"{{ prefixCls }}-tbody\">\n <tr *ngFor=\"let row of panelYears\" role=\"row\">\n <td *ngFor=\"let yearCell of row; trackBy: trackPanelYear\"\n role=\"gridcell\"\n title=\"{{ yearCell.title }}\"\n (click)=\"yearCell.disabled ? null : yearCell.onClick()\"\n [ngClass]=\"yearCell.classMap\"\n >\n <a class=\"{{ prefixCls }}-year\">{{ yearCell.content }}</a>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </div>\n</div>", styles: [ // Support disabledDate ` .ant-calendar-year-panel-cell-disabled .ant-calendar-year-panel-year, .ant-calendar-year-panel-cell-disabled .ant-calendar-year-panel-year:hover { color: rgba(0, 0, 0, 0.25); background: #f5f5f5; cursor: not-allowed; } `] }] } ]; /** @nocollapse */ YearPanelComponent.ctorParameters = () => []; YearPanelComponent.propDecorators = { locale: [{ type: Input }], value: [{ type: Input }], valueChange: [{ type: Output }], disabledDate: [{ type: Input }], decadePanelShow: [{ type: Output }] }; if (false) { /** @type {?} */ YearPanelComponent.prototype.locale; /** @type {?} */ YearPanelComponent.prototype.value; /** @type {?} */ YearPanelComponent.prototype.valueChange; /** @type {?} */ YearPanelComponent.prototype.disabledDate; /** @type {?} */ YearPanelComponent.prototype.decadePanelShow; /** @type {?} */ YearPanelComponent.prototype.prefixCls; /** @type {?} */ YearPanelComponent.prototype.panelYears; } /** * @record */ export function PanelYearData() { } if (false) { /** @type {?} */ PanelYearData.prototype.disabled; /** @type {?} */ PanelYearData.prototype.content; /** @type {?} */ PanelYearData.prototype.year; /** @type {?} */ PanelYearData.prototype.title; /** @type {?} */ PanelYearData.prototype.isCurrent; /** @type {?} */ PanelYearData.prototype.isLowerThanStart; /** @type {?} */ PanelYearData.prototype.isBiggerThanEnd; /** @type {?} */ PanelYearData.prototype.classMap; /** @type {?} */ PanelYearData.prototype.onClick; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieWVhci1wYW5lbC5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXl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