UNPKG

ng-zorro-antd-yj

Version:

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

136 lines 11.3 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; import { ChangeDetectionStrategy, Component, ContentChildren, ElementRef, EventEmitter, Host, Input, Optional, Output, QueryList, Renderer2, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core'; import { merge, Subject } from 'rxjs'; import { flatMap, startWith, takeUntil } from 'rxjs/operators'; import { InputBoolean } from '../core/util/convert'; import { NzTableComponent } from './nz-table.component'; import { NzThComponent } from './nz-th.component'; var NzTheadComponent = /** @class */ (function () { // tslint:disable-next-line:no-any function NzTheadComponent(nzTableComponent, elementRef, renderer) { this.nzTableComponent = nzTableComponent; this.elementRef = elementRef; this.renderer = renderer; this.destroy$ = new Subject(); this.nzSingleSort = false; this.nzSortChange = new EventEmitter(); if (this.nzTableComponent) { this.nzTableComponent.nzTheadComponent = this; } } /** * @return {?} */ NzTheadComponent.prototype.ngAfterContentInit = /** * @return {?} */ function () { var _this = this; this.listOfNzThComponent.changes .pipe(startWith(true), flatMap((/** * @return {?} */ function () { return merge.apply(void 0, tslib_1.__spread(_this.listOfNzThComponent.map((/** * @param {?} th * @return {?} */ function (th) { return th.nzSortChangeWithKey; })))); })), takeUntil(this.destroy$)) .subscribe((/** * @param {?} data * @return {?} */ function (data) { _this.nzSortChange.emit(data); if (_this.nzSingleSort) { _this.listOfNzThComponent.forEach((/** * @param {?} th * @return {?} */ function (th) { th.nzSort = th.nzSortKey === data.key ? th.nzSort : null; th.marForCheck(); })); } })); }; /** * @return {?} */ NzTheadComponent.prototype.ngAfterViewInit = /** * @return {?} */ function () { if (this.nzTableComponent) { this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), this.elementRef.nativeElement); } }; /** * @return {?} */ NzTheadComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { this.destroy$.next(); this.destroy$.complete(); }; NzTheadComponent.decorators = [ { type: Component, args: [{ // tslint:disable-next-line:component-selector selector: 'thead:not(.ant-table-thead)', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<ng-template #contentTemplate>\n <ng-content></ng-content>\n</ng-template>\n<ng-container *ngIf=\"!nzTableComponent\">\n <ng-template [ngTemplateOutlet]=\"contentTemplate\"></ng-template>\n</ng-container>" }] } ]; /** @nocollapse */ NzTheadComponent.ctorParameters = function () { return [ { type: NzTableComponent, decorators: [{ type: Host }, { type: Optional }] }, { type: ElementRef }, { type: Renderer2 } ]; }; NzTheadComponent.propDecorators = { templateRef: [{ type: ViewChild, args: ['contentTemplate',] }], listOfNzThComponent: [{ type: ContentChildren, args: [NzThComponent, { descendants: true },] }], nzSingleSort: [{ type: Input }], nzSortChange: [{ type: Output }] }; tslib_1.__decorate([ InputBoolean(), tslib_1.__metadata("design:type", Object) ], NzTheadComponent.prototype, "nzSingleSort", void 0); return NzTheadComponent; }()); export { NzTheadComponent }; if (false) { /** * @type {?} * @private */ NzTheadComponent.prototype.destroy$; /** @type {?} */ NzTheadComponent.prototype.templateRef; /** @type {?} */ NzTheadComponent.prototype.listOfNzThComponent; /** @type {?} */ NzTheadComponent.prototype.nzSingleSort; /** @type {?} */ NzTheadComponent.prototype.nzSortChange; /** @type {?} */ NzTheadComponent.prototype.nzTableComponent; /** * @type {?} * @private */ NzTheadComponent.prototype.elementRef; /** * @type {?} * @private */ NzTheadComponent.prototype.renderer; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotdGhlYWQuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC15ai8iLCJzb3VyY2VzIjpbInRhYmxlL256LXRoZWFkLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLE9BQU8sRUFHTCx1QkFBdUIsRUFDdkIsU0F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