UNPKG

ng-zorro-antd

Version:

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

67 lines 7.69 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, ChangeDetectorRef, Component, ElementRef, Input, Renderer2, ViewEncapsulation } from '@angular/core'; export class NzCascaderOptionComponent { constructor(cdr, elementRef, renderer) { this.cdr = cdr; this.optionTemplate = null; this.activated = false; this.nzLabelProperty = 'label'; this.expandIcon = 'right'; renderer.addClass(elementRef.nativeElement, 'ant-cascader-menu-item'); this.nativeElement = elementRef.nativeElement; } get optionLabel() { return this.option[this.nzLabelProperty]; } markForCheck() { this.cdr.markForCheck(); } } NzCascaderOptionComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: '[nz-cascader-option]', exportAs: 'nzCascaderOption', template: ` <ng-container *ngIf="optionTemplate; else defaultOptionTemplate"> <ng-template [ngTemplateOutlet]="optionTemplate" [ngTemplateOutletContext]="{ $implicit: option, index: columnIndex }"></ng-template> </ng-container> <ng-template #defaultOptionTemplate> <span [innerHTML]="optionLabel | nzHighlight: highlightText:'g':'ant-cascader-menu-item-keyword'"></span> </ng-template> <span *ngIf="!option.isLeaf || option.children?.length || option.loading" class="ant-cascader-menu-item-expand-icon"> <i *ngIf="option.loading; else icon" nz-icon nzType="loading"></i> <ng-template #icon> <ng-container *nzStringTemplateOutlet="expandIcon"> <i nz-icon [nzType]="$any(expandIcon)"></i> </ng-container> </ng-template> </span> `, host: { '[attr.title]': 'option.title || optionLabel', '[class.ant-cascader-menu-item-active]': 'activated', '[class.ant-cascader-menu-item-expand]': '!option.isLeaf', '[class.ant-cascader-menu-item-disabled]': 'option.disabled' } },] } ]; NzCascaderOptionComponent.ctorParameters = () => [ { type: ChangeDetectorRef }, { type: ElementRef }, { type: Renderer2 } ]; NzCascaderOptionComponent.propDecorators = { optionTemplate: [{ type: Input }], option: [{ type: Input }], activated: [{ type: Input }], highlightText: [{ type: Input }], nzLabelProperty: [{ type: Input }], columnIndex: [{ type: Input }], expandIcon: [{ type: Input }] }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FzY2FkZXItbGkuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Ii9ob21lL3ZzdHMvd29yay8xL3MvY29tcG9uZW50cy9jYXNjYWRlci8iLCJzb3VyY2VzIjpbImNhc2NhZGVyLWxpLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7O0dBR0c7QUFFSCxPQUFPLEVBQ0wsdUJBQXVCLEVBQ3ZCLGlCQUFpQixFQUNqQixTQUFTLEVBQ1QsVUFBVSxFQUNWLEtBQUssRUFDTCxTQUFTLEVBRVQsaUJBQWlCLEVBQ2xCLE1BQU0sZUFBZSxDQUFDO0FBZ0N2QixNQUFNLE9BQU8seUJBQXlCO0lBV3BDLFlBQW9CLEdBQXNCLEVBQUUsVUFBc0IsRUFBRSxRQUFtQjtRQUFuRSxRQUFHLEdBQUgsR0FBRyxDQUFtQjtRQVZqQyxtQkFBYyxHQUF5QyxJQUFJLENBQUM7UUFFNUQsY0FBUyxHQUFHLEtBQUssQ0FBQztRQUVsQixvQkFBZSxHQUFHLE9BQU8sQ0FBQztRQUcxQixlQUFVLEdBQStCLE9BQU8sQ0FBQztRQUl4RCxRQUFRLENBQUMsUUFBUSxDQUFDLFVBQVUsQ0FBQyxhQUFhLEVBQUUsd0JBQXdCLENBQUMsQ0FBQztRQUN0RSxJQUFJLENBQUMsYUFBYSxHQUFHLFVBQVUsQ0FBQyxhQUFhLENBQUM7SUFDaEQsQ0FBQztJQUVELElBQUksV0FBVztRQUNiLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsZUFBZSxDQUFDLENBQUM7SUFDM0MsQ0FBQztJQUVELFlBQVk7UUFDV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