ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
127 lines • 10.2 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { ChangeDetectorRef, Component, Input } from '@angular/core';
import { NzNoAnimationDirective } from '../core/no-animation/nz-no-animation.directive';
import { valueFunctionProp } from '../core/util/convert';
import { DateHelperService } from '../i18n/date-helper.service';
import { NzI18nService } from '../i18n/nz-i18n.service';
import { AbstractPickerComponent } from './abstract-picker.component';
import { CandyDate } from './lib/candy-date';
/**
* The base picker for header panels, current support: Year/Month
*/
export class HeaderPickerComponent extends AbstractPickerComponent {
/**
* @param {?} i18n
* @param {?} cdr
* @param {?} dateHelper
* @param {?=} noAnimation
*/
constructor(i18n, cdr, dateHelper, noAnimation) {
super(i18n, cdr, dateHelper, noAnimation);
}
/**
* @return {?}
*/
ngOnInit() {
super.ngOnInit();
this.panelMode = this.endPanelMode;
/** @type {?} */
const allHeaderPanels = ['decade', 'year', 'month'];
this.supportPanels = allHeaderPanels.slice(0, allHeaderPanels.indexOf(this.endPanelMode) + 1);
}
/**
* @param {?} changes
* @return {?}
*/
ngOnChanges(changes) {
super.ngOnChanges(changes);
if (changes.nzRenderExtraFooter) {
this.extraFooter = valueFunctionProp(this.nzRenderExtraFooter);
}
}
/**
* @param {?} mode
* @return {?}
*/
onPanelModeChange(mode) {
if (this.supportPanels.indexOf(mode) > -1) {
this.panelMode = mode;
}
else {
// Since the default "click year" logic can be "year panel" -> "date panel", we need force to the end panel otherwise
this.panelMode = this.endPanelMode;
}
}
/**
* @param {?} mode
* @param {?} value
* @return {?}
*/
onChooseValue(mode, value) {
if (this.endPanelMode === mode) {
super.onValueChange(value);
this.closeOverlay();
}
}
/**
* @param {?} open
* @return {?}
*/
onOpenChange(open) {
if (!open) {
this.cleanUp();
}
this.nzOnOpenChange.emit(open);
}
// Restore some initial props to let open as new in next time
/**
* @private
* @return {?}
*/
cleanUp() {
this.panelMode = this.endPanelMode;
}
}
HeaderPickerComponent.decorators = [
{ type: Component, args: [{
template: ``
}] }
];
/** @nocollapse */
HeaderPickerComponent.ctorParameters = () => [
{ type: NzI18nService },
{ type: ChangeDetectorRef },
{ type: DateHelperService },
{ type: NzNoAnimationDirective }
];
HeaderPickerComponent.propDecorators = {
nzPlaceHolder: [{ type: Input }],
nzRenderExtraFooter: [{ type: Input }],
nzDefaultValue: [{ type: Input }],
nzFormat: [{ type: Input }]
};
if (false) {
/** @type {?} */
HeaderPickerComponent.prototype.nzPlaceHolder;
/** @type {?} */
HeaderPickerComponent.prototype.nzRenderExtraFooter;
/** @type {?} */
HeaderPickerComponent.prototype.nzDefaultValue;
/** @type {?} */
HeaderPickerComponent.prototype.nzFormat;
/** @type {?} */
HeaderPickerComponent.prototype.endPanelMode;
/** @type {?} */
HeaderPickerComponent.prototype.panelMode;
/** @type {?} */
HeaderPickerComponent.prototype.extraFooter;
/**
* @type {?}
* @private
*/
HeaderPickerComponent.prototype.supportPanels;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVhZGVyLXBpY2tlci5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXlqLyIsInNvdXJjZXMiOlsiZGF0ZS1waWNrZXIvaGVhZGVyLXBpY2tlci5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFpRCxNQUFNLGVBQWUsQ0FBQztBQUVuSCxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxnREFBZ0QsQ0FBQztBQUV4RixPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN6RCxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSw2QkFBNk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