ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
99 lines • 10.5 kB
JavaScript
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
/* tslint:disable:component-selector */
import { __decorate, __metadata } from "tslib";
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { InputBoolean } from 'ng-zorro-antd/core/util';
export class NzTdAddOnComponent {
constructor() {
this.nzChecked = false;
this.nzDisabled = false;
this.nzIndeterminate = false;
this.nzIndentSize = 0;
this.nzShowExpand = false;
this.nzShowCheckbox = false;
this.nzExpand = false;
this.nzCheckedChange = new EventEmitter();
this.nzExpandChange = new EventEmitter();
this.isNzShowExpandChanged = false;
this.isNzShowCheckboxChanged = false;
}
onCheckedChange(checked) {
this.nzChecked = checked;
this.nzCheckedChange.emit(checked);
}
onExpandChange(expand) {
this.nzExpand = expand;
this.nzExpandChange.emit(expand);
}
ngOnChanges(changes) {
const isFirstChange = (value) => value && value.firstChange && value.currentValue !== undefined;
const { nzExpand, nzChecked, nzShowExpand, nzShowCheckbox } = changes;
if (nzShowExpand) {
this.isNzShowExpandChanged = true;
}
if (nzShowCheckbox) {
this.isNzShowCheckboxChanged = true;
}
if (isFirstChange(nzExpand) && !this.isNzShowExpandChanged) {
this.nzShowExpand = true;
}
if (isFirstChange(nzChecked) && !this.isNzShowCheckboxChanged) {
this.nzShowCheckbox = true;
}
}
}
NzTdAddOnComponent.decorators = [
{ type: Component, args: [{
selector: 'td[nzChecked], td[nzDisabled], td[nzIndeterminate], td[nzIndentSize], td[nzExpand], td[nzShowExpand], td[nzShowCheckbox]',
changeDetection: ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
encapsulation: ViewEncapsulation.None,
template: `
<ng-container *ngIf="nzShowExpand || nzIndentSize > 0">
<nz-row-indent [indentSize]="nzIndentSize"></nz-row-indent>
<button nz-row-expand-button [expand]="nzExpand" (expandChange)="onExpandChange($event)" [spaceMode]="!nzShowExpand"></button>
</ng-container>
<label
nz-checkbox
*ngIf="nzShowCheckbox"
[nzDisabled]="nzDisabled"
[ngModel]="nzChecked"
[nzIndeterminate]="nzIndeterminate"
(ngModelChange)="onCheckedChange($event)"
>
</label>
<ng-content></ng-content>
`,
host: {
'[class.ant-table-cell-with-append]': `nzShowExpand || nzIndentSize > 0`,
'[class.ant-table-selection-column]': `nzShowCheckbox`
}
},] }
];
NzTdAddOnComponent.propDecorators = {
nzChecked: [{ type: Input }],
nzDisabled: [{ type: Input }],
nzIndeterminate: [{ type: Input }],
nzIndentSize: [{ type: Input }],
nzShowExpand: [{ type: Input }],
nzShowCheckbox: [{ type: Input }],
nzExpand: [{ type: Input }],
nzCheckedChange: [{ type: Output }],
nzExpandChange: [{ type: Output }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzTdAddOnComponent.prototype, "nzShowExpand", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzTdAddOnComponent.prototype, "nzShowCheckbox", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzTdAddOnComponent.prototype, "nzExpand", void 0);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGQtYWRkb24uY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Ii9ob21lL3ZzdHMvd29yay8xL3MvY29tcG9uZW50cy90YWJsZS8iLCJzb3VyY2VzIjpbInNyYy9jZWxsL3RkLWFkZG9uLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7O0dBR0c7QUFDSCx1Q0FBdUM7O0FBRXZDLE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsU0FBUyxFQUNULFlBQVksRUFDWixLQUFLLEVBRUwsTUFBTSxFQUdOLGlCQUFpQixFQUNsQixNQUFNLGVBQWUsQ0FBQztBQUV2QixPQUFPLEVBQUUsWUFBWSxFQUFFLE1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