UNPKG

ng-zorro-antd

Version:

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

120 lines (118 loc) 12.9 kB
import { NgTemplateOutlet } from '@angular/common'; import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core'; import { NzHighlightModule } from 'ng-zorro-antd/core/highlight'; import { NzOutletModule } from 'ng-zorro-antd/core/outlet'; import { NzIconModule } from 'ng-zorro-antd/icon'; import * as i0 from "@angular/core"; import * as i1 from "ng-zorro-antd/core/highlight"; import * as i2 from "ng-zorro-antd/icon"; import * as i3 from "ng-zorro-antd/core/outlet"; export class NzCascaderOptionComponent { constructor(cdr, elementRef) { this.cdr = cdr; this.optionTemplate = null; this.activated = false; this.nzLabelProperty = 'label'; this.expandIcon = ''; this.dir = 'ltr'; this.nativeElement = elementRef.nativeElement; } ngOnInit() { if (this.expandIcon === '' && this.dir === 'rtl') { this.expandIcon = 'left'; } else if (this.expandIcon === '') { this.expandIcon = 'right'; } } get optionLabel() { return this.option[this.nzLabelProperty]; } markForCheck() { this.cdr.markForCheck(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzCascaderOptionComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.4", type: NzCascaderOptionComponent, isStandalone: true, selector: "[nz-cascader-option]", inputs: { optionTemplate: "optionTemplate", option: "option", activated: "activated", highlightText: "highlightText", nzLabelProperty: "nzLabelProperty", columnIndex: "columnIndex", expandIcon: "expandIcon", dir: "dir" }, host: { properties: { "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" }, classAttribute: "ant-cascader-menu-item ant-cascader-menu-item-expanded" }, exportAs: ["nzCascaderOption"], ngImport: i0, template: ` @if (optionTemplate) { <ng-template [ngTemplateOutlet]="optionTemplate" [ngTemplateOutletContext]="{ $implicit: option, index: columnIndex }" /> } @else { <div class="ant-cascader-menu-item-content" [innerHTML]="optionLabel | nzHighlight: highlightText : 'g' : 'ant-cascader-menu-item-keyword'" ></div> } @if (!option.isLeaf || option.children?.length || option.loading) { <div class="ant-cascader-menu-item-expand-icon"> @if (option.loading) { <span nz-icon nzType="loading"></span> } @else { <ng-container *nzStringTemplateOutlet="expandIcon"> <span nz-icon [nzType]="$any(expandIcon)"></span> </ng-container> } </div> } `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzHighlightModule }, { kind: "pipe", type: i1.NzHighlightPipe, name: "nzHighlight" }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzCascaderOptionComponent, decorators: [{ type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: '[nz-cascader-option]', exportAs: 'nzCascaderOption', template: ` @if (optionTemplate) { <ng-template [ngTemplateOutlet]="optionTemplate" [ngTemplateOutletContext]="{ $implicit: option, index: columnIndex }" /> } @else { <div class="ant-cascader-menu-item-content" [innerHTML]="optionLabel | nzHighlight: highlightText : 'g' : 'ant-cascader-menu-item-keyword'" ></div> } @if (!option.isLeaf || option.children?.length || option.loading) { <div class="ant-cascader-menu-item-expand-icon"> @if (option.loading) { <span nz-icon nzType="loading"></span> } @else { <ng-container *nzStringTemplateOutlet="expandIcon"> <span nz-icon [nzType]="$any(expandIcon)"></span> </ng-container> } </div> } `, host: { class: 'ant-cascader-menu-item ant-cascader-menu-item-expanded', '[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' }, imports: [NgTemplateOutlet, NzHighlightModule, NzIconModule, NzOutletModule], standalone: true }] }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }], propDecorators: { optionTemplate: [{ type: Input }], option: [{ type: Input }], activated: [{ type: Input }], highlightText: [{ type: Input }], nzLabelProperty: [{ type: Input }], columnIndex: [{ type: Input }], expandIcon: [{ type: Input }], dir: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FzY2FkZXItbGkuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vY29tcG9uZW50cy9jYXNjYWRlci9jYXNjYWRlci1saS5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBTUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDbkQsT0FBTyxFQUNMLHVCQUF1QixFQUV2QixTQUFTLEVBRVQsS0FBSyxFQUdMLGlCQUFpQixFQUNsQixNQUFNLGVBQWUsQ0FBQztBQUV2QixPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUNqRSxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDM0QsT0FBTyxFQUFFLFlBQVksRU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