ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
106 lines • 11.7 kB
JavaScript
import { __decorate } from "tslib";
/**
* 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
*/
/* eslint-disable @angular-eslint/component-selector */
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { InputBoolean } from 'ng-zorro-antd/core/util';
import { NzTableSelectionComponent } from '../addon/selection.component';
import * as i0 from "@angular/core";
export class NzThSelectionComponent {
constructor() {
this.nzSelections = [];
this.nzChecked = false;
this.nzDisabled = false;
this.nzIndeterminate = false;
this.nzLabel = null;
this.nzShowCheckbox = false;
this.nzShowRowSelection = false;
this.nzCheckedChange = new EventEmitter();
this.isNzShowExpandChanged = false;
this.isNzShowCheckboxChanged = false;
}
onCheckedChange(checked) {
this.nzChecked = checked;
this.nzCheckedChange.emit(checked);
}
ngOnChanges(changes) {
const isFirstChange = (value) => value && value.firstChange && value.currentValue !== undefined;
const { nzChecked, nzSelections, nzShowExpand, nzShowCheckbox } = changes;
if (nzShowExpand) {
this.isNzShowExpandChanged = true;
}
if (nzShowCheckbox) {
this.isNzShowCheckboxChanged = true;
}
if (isFirstChange(nzSelections) && !this.isNzShowExpandChanged) {
this.nzShowRowSelection = true;
}
if (isFirstChange(nzChecked) && !this.isNzShowCheckboxChanged) {
this.nzShowCheckbox = true;
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzThSelectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: NzThSelectionComponent, isStandalone: true, selector: "th[nzSelections],th[nzChecked],th[nzShowCheckbox],th[nzShowRowSelection]", inputs: { nzSelections: "nzSelections", nzChecked: "nzChecked", nzDisabled: "nzDisabled", nzIndeterminate: "nzIndeterminate", nzLabel: "nzLabel", nzShowCheckbox: "nzShowCheckbox", nzShowRowSelection: "nzShowRowSelection" }, outputs: { nzCheckedChange: "nzCheckedChange" }, host: { classAttribute: "ant-table-selection-column" }, usesOnChanges: true, ngImport: i0, template: `
<nz-table-selection
[checked]="nzChecked"
[disabled]="nzDisabled"
[indeterminate]="nzIndeterminate"
[label]="nzLabel"
[listOfSelections]="nzSelections"
[showCheckbox]="nzShowCheckbox"
[showRowSelection]="nzShowRowSelection"
(checkedChange)="onCheckedChange($event)"
></nz-table-selection>
<ng-content></ng-content>
`, isInline: true, dependencies: [{ kind: "component", type: NzTableSelectionComponent, selector: "nz-table-selection", inputs: ["listOfSelections", "checked", "disabled", "indeterminate", "label", "showCheckbox", "showRowSelection"], outputs: ["checkedChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
__decorate([
InputBoolean()
], NzThSelectionComponent.prototype, "nzShowCheckbox", void 0);
__decorate([
InputBoolean()
], NzThSelectionComponent.prototype, "nzShowRowSelection", void 0);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzThSelectionComponent, decorators: [{
type: Component,
args: [{
selector: 'th[nzSelections],th[nzChecked],th[nzShowCheckbox],th[nzShowRowSelection]',
preserveWhitespaces: false,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nz-table-selection
[checked]="nzChecked"
[disabled]="nzDisabled"
[indeterminate]="nzIndeterminate"
[label]="nzLabel"
[listOfSelections]="nzSelections"
[showCheckbox]="nzShowCheckbox"
[showRowSelection]="nzShowRowSelection"
(checkedChange)="onCheckedChange($event)"
></nz-table-selection>
<ng-content></ng-content>
`,
host: { class: 'ant-table-selection-column' },
imports: [NzTableSelectionComponent],
standalone: true
}]
}], ctorParameters: () => [], propDecorators: { nzSelections: [{
type: Input
}], nzChecked: [{
type: Input
}], nzDisabled: [{
type: Input
}], nzIndeterminate: [{
type: Input
}], nzLabel: [{
type: Input
}], nzShowCheckbox: [{
type: Input
}], nzShowRowSelection: [{
type: Input
}], nzCheckedChange: [{
type: Output
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGgtc2VsZWN0aW9uLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL2NvbXBvbmVudHMvdGFibGUvc3JjL2NlbGwvdGgtc2VsZWN0aW9uLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7OztHQUdHO0FBRUgsdURBQXVEO0FBQ3ZELE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsU0FBUyxFQUNULFlBQVksRUFDWixLQUFLLEVBRUwsTUFBTSxFQUdOLGlCQUFpQixFQUNsQixNQUFNLGVBQWUsQ0FBQztBQUd2QixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFdkQsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sOEJBQThCLENBQUM7O0FBd0J6RSxNQUFNLE9BQU8sc0JBQXNCO0lBZ0JqQztRQVpTLGlCQUFZLEdBQXVFLEVBQUUsQ0FBQztRQUN0RixjQUFTLEdBQUcsS0FBSyxDQUFDO1FBQ2xCLGVBQVUsR0FBRyxLQUFLLENBQUM7UUFDbkIsb0JBQWUsR0FBRyxLQUFLLENBQUM7UUFDeEIsWUFBTyxHQUFrQixJQUFJLENBQUM7UUFDZCxtQkFBYyxHQUFHLEtBQUssQ0FBQztRQUN2Qix1QkFBa0IsR0FBRyxLQUFLLENBQUM7UUFDakMsb0JBQWUsR0FBRyxJQUFJLFlBQVksRUFBVyxDQUFDO1FBRXpELDBCQUFxQixHQUFHLEtBQUssQ0FBQztRQUM5Qiw0QkFBdUIsR0FBRyxLQUFLLENBQUM7SUFFekIsQ0FBQztJQUVoQix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