UNPKG

ng-zorro-antd

Version:

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

67 lines 6.82 kB
/** * 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 */ import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'; export class NzTableSelectionComponent { constructor(elementRef) { this.elementRef = elementRef; this.listOfSelections = []; this.checked = false; this.disabled = false; this.indeterminate = false; this.showCheckbox = false; this.showRowSelection = false; this.checkedChange = new EventEmitter(); // TODO: move to host after View Engine deprecation this.elementRef.nativeElement.classList.add('ant-table-selection'); } onCheckedChange(checked) { this.checked = checked; this.checkedChange.emit(checked); } } NzTableSelectionComponent.decorators = [ { type: Component, args: [{ selector: 'nz-table-selection', preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: ` <label *ngIf="showCheckbox" nz-checkbox [class.ant-table-selection-select-all-custom]="showRowSelection" [ngModel]="checked" [nzDisabled]="disabled" [nzIndeterminate]="indeterminate" (ngModelChange)="onCheckedChange($event)" ></label> <div class="ant-table-selection-extra" *ngIf="showRowSelection"> <span nz-dropdown class="ant-table-selection-down" nzPlacement="bottomLeft" [nzDropdownMenu]="selectionMenu"> <i nz-icon nzType="down"></i> </span> <nz-dropdown-menu #selectionMenu="nzDropdownMenu"> <ul nz-menu class="ant-table-selection-menu"> <li nz-menu-item *ngFor="let selection of listOfSelections" (click)="selection.onSelect()"> {{ selection.text }} </li> </ul> </nz-dropdown-menu> </div> ` },] } ]; NzTableSelectionComponent.ctorParameters = () => [ { type: ElementRef } ]; NzTableSelectionComponent.propDecorators = { listOfSelections: [{ type: Input }], checked: [{ type: Input }], disabled: [{ type: Input }], indeterminate: [{ type: Input }], showCheckbox: [{ type: Input }], showRowSelection: [{ type: Input }], checkedChange: [{ type: Output }] }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlI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