ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
140 lines • 11.3 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import * as tslib_1 from "tslib";
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { NzUpdateHostClassService } from '../core/services/update-host-class.service';
import { isNotNil } from '../core/util/check';
import { InputBoolean } from '../core/util/convert';
export class NzTdComponent {
/**
* @param {?} elementRef
* @param {?} nzUpdateHostClassService
*/
constructor(elementRef, nzUpdateHostClassService) {
this.elementRef = elementRef;
this.nzUpdateHostClassService = nzUpdateHostClassService;
this.nzChecked = false;
this.nzDisabled = false;
this.nzIndeterminate = false;
this.nzExpand = false;
this.nzShowExpand = false;
this.nzShowCheckbox = false;
this.nzCheckedChange = new EventEmitter();
this.nzExpandChange = new EventEmitter();
}
/**
* @param {?} e
* @return {?}
*/
expandChange(e) {
e.stopPropagation();
this.nzExpand = !this.nzExpand;
this.nzExpandChange.emit(this.nzExpand);
}
/**
* @return {?}
*/
setClassMap() {
this.nzUpdateHostClassService.updateHostClass(this.elementRef.nativeElement, {
[`ant-table-row-expand-icon-cell`]: this.nzShowExpand && !isNotNil(this.nzIndentSize),
[`ant-table-selection-column`]: this.nzShowCheckbox,
[`ant-table-td-left-sticky`]: isNotNil(this.nzLeft),
[`ant-table-td-right-sticky`]: isNotNil(this.nzRight)
});
}
/**
* @param {?} changes
* @return {?}
*/
ngOnChanges(changes) {
if (changes.nzIndentSize || changes.nzShowExpand || changes.nzShowCheckbox || changes.nzRight || changes.nzLeft) {
this.setClassMap();
}
}
}
NzTdComponent.decorators = [
{ type: Component, args: [{
// tslint:disable-next-line:component-selector
selector: 'td:not(.nz-disable-td)',
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [NzUpdateHostClassService],
preserveWhitespaces: false,
encapsulation: ViewEncapsulation.None,
template: "<span class=\"ant-table-row-indent\" *ngIf=\"nzIndentSize >= 0\" [style.padding-left.px]=\"nzIndentSize\"></span>\n<label *ngIf=\"nzShowCheckbox\"\n nz-checkbox\n [nzDisabled]=\"nzDisabled\"\n [(ngModel)]=\"nzChecked\"\n [nzIndeterminate]=\"nzIndeterminate\"\n (ngModelChange)=\"nzCheckedChange.emit($event)\">\n</label>\n<span *ngIf=\"!nzShowExpand && nzIndentSize >= 0\"\n class=\"ant-table-row-expand-icon ant-table-row-spaced\">\n</span>\n<span *ngIf=\"nzShowExpand\"\n class=\"ant-table-row-expand-icon\"\n [class.ant-table-row-expanded]=\"nzExpand\"\n [class.ant-table-row-collapsed]=\"!nzExpand\"\n (click)=\"expandChange($event)\">\n</span>\n<ng-content></ng-content>",
host: {
'[style.left]': 'nzLeft',
'[style.right]': 'nzRight',
'[style.text-align]': 'nzAlign'
}
}] }
];
/** @nocollapse */
NzTdComponent.ctorParameters = () => [
{ type: ElementRef },
{ type: NzUpdateHostClassService }
];
NzTdComponent.propDecorators = {
nzChecked: [{ type: Input }],
nzDisabled: [{ type: Input }],
nzIndeterminate: [{ type: Input }],
nzLeft: [{ type: Input }],
nzRight: [{ type: Input }],
nzAlign: [{ type: Input }],
nzIndentSize: [{ type: Input }],
nzExpand: [{ type: Input }],
nzShowExpand: [{ type: Input }],
nzShowCheckbox: [{ type: Input }],
nzCheckedChange: [{ type: Output }],
nzExpandChange: [{ type: Output }]
};
tslib_1.__decorate([
InputBoolean(),
tslib_1.__metadata("design:type", Object)
], NzTdComponent.prototype, "nzExpand", void 0);
tslib_1.__decorate([
InputBoolean(),
tslib_1.__metadata("design:type", Object)
], NzTdComponent.prototype, "nzShowExpand", void 0);
tslib_1.__decorate([
InputBoolean(),
tslib_1.__metadata("design:type", Object)
], NzTdComponent.prototype, "nzShowCheckbox", void 0);
if (false) {
/** @type {?} */
NzTdComponent.prototype.nzChecked;
/** @type {?} */
NzTdComponent.prototype.nzDisabled;
/** @type {?} */
NzTdComponent.prototype.nzIndeterminate;
/** @type {?} */
NzTdComponent.prototype.nzLeft;
/** @type {?} */
NzTdComponent.prototype.nzRight;
/** @type {?} */
NzTdComponent.prototype.nzAlign;
/** @type {?} */
NzTdComponent.prototype.nzIndentSize;
/** @type {?} */
NzTdComponent.prototype.nzExpand;
/** @type {?} */
NzTdComponent.prototype.nzShowExpand;
/** @type {?} */
NzTdComponent.prototype.nzShowCheckbox;
/** @type {?} */
NzTdComponent.prototype.nzCheckedChange;
/** @type {?} */
NzTdComponent.prototype.nzExpandChange;
/**
* @type {?}
* @private
*/
NzTdComponent.prototype.elementRef;
/**
* @type {?}
* @private
*/
NzTdComponent.prototype.nzUpdateHostClassService;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotdGQuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC15ai8iLCJzb3VyY2VzIjpbInRhYmxlL256LXRkLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsU0FBUyxFQUNULFVBQVUsRUFDVixZQUFZLEVBQ1osS0FBSyxFQUVMLE1BQU0sRUFFTixpQkFBaUIsRUFDbEIsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sNENBQTRDLENBQUM7QUFFdEYsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQzlDLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQWdCcEQsTUFBTSxPQUFPLGFBQWE7Ozs7O0lBNkJ4QixZQUFvQixVQUFzQixFQUFVLHdCQUFrRDtRQUFsRixlQUFVLEdBQVYsVUFBVSxDQUFZO1FBQVUsNkJBQXdCLEdBQXhCLHdCQUF3QixDQUEwQjtRQTVCN0YsY0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