UNPKG

ng-zorro-antd-yj

Version:

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

90 lines 7.47 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Input, Renderer2, ViewEncapsulation } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; export class NzCascaderOptionComponent { /** * @param {?} sanitizer * @param {?} cdr * @param {?} elementRef * @param {?} renderer */ constructor(sanitizer, cdr, elementRef, renderer) { this.sanitizer = sanitizer; this.cdr = cdr; this.activated = false; this.nzLabelProperty = 'label'; renderer.addClass(elementRef.nativeElement, 'ant-cascader-menu-item'); } /** * @return {?} */ getOptionLabel() { return this.option ? this.option[this.nzLabelProperty] : ''; } /** * @param {?} str * @return {?} */ renderHighlightString(str) { /** @type {?} */ const replaceStr = str.replace(new RegExp(this.highlightText, 'g'), `<span class="ant-cascader-menu-item-keyword">${this.highlightText}</span>`); return this.sanitizer.bypassSecurityTrustHtml(replaceStr); } /** * @return {?} */ markForCheck() { this.cdr.markForCheck(); } } NzCascaderOptionComponent.decorators = [ { type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: '[nz-cascader-option]', template: "<ng-container *ngIf=\"highlightText\">\n <span [innerHTML]=\"renderHighlightString(getOptionLabel())\"></span>\n</ng-container>\n<ng-container *ngIf=\"!highlightText\">{{ getOptionLabel() }}</ng-container>\n<span\n *ngIf=\"!option.isLeaf || option.children && option.children.length || option.loading\"\n class=\"ant-cascader-menu-item-expand-icon\">\n <i nz-icon [type]=\"option.loading ? 'loading' : 'right'\"></i>\n</span>\n", host: { '[attr.title]': 'option.title || getOptionLabel()', '[class.ant-cascader-menu-item-active]': 'activated', '[class.ant-cascader-menu-item-expand]': '!option.isLeaf', '[class.ant-cascader-menu-item-disabled]': 'option.disabled' } }] } ]; /** @nocollapse */ NzCascaderOptionComponent.ctorParameters = () => [ { type: DomSanitizer }, { type: ChangeDetectorRef }, { type: ElementRef }, { type: Renderer2 } ]; NzCascaderOptionComponent.propDecorators = { option: [{ type: Input }], activated: [{ type: Input }], highlightText: [{ type: Input }], nzLabelProperty: [{ type: Input }] }; if (false) { /** @type {?} */ NzCascaderOptionComponent.prototype.option; /** @type {?} */ NzCascaderOptionComponent.prototype.activated; /** @type {?} */ NzCascaderOptionComponent.prototype.highlightText; /** @type {?} */ NzCascaderOptionComponent.prototype.nzLabelProperty; /** * @type {?} * @private */ NzCascaderOptionComponent.prototype.sanitizer; /** * @type {?} * @private */ NzCascaderOptionComponent.prototype.cdr; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotY2FzY2FkZXItbGkuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC15ai8iLCJzb3VyY2VzIjpbImNhc2NhZGVyL256LWNhc2NhZGVyLWxpLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsT0FBTyxFQUNMLHVCQUF1QixFQUN2QixpQkFBaUIsRUFDakIsU0FBUyxFQUNULFVBQVUsRUFDVixLQUFLLEVBQ0wsU0FBUyxFQUNULGlCQUFpQixFQUNsQixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQUUsWUFBWSxFQUFZLE1BQU0sMkJBQTJCLENBQUM7QUFlbkUsTUFBTSxPQUFPLHlCQUF5Qjs7Ozs7OztJQU1wQyxZQUNVLFNBQXVCLEVBQ3ZCLEdBQXNCLEVBQzlCLFVBQXNCLEVBQ3RCLFFBQW1CO1FBSFgsY0FBUyxHQUFULFNBQVMsQ0FBYztRQUN2QixRQUFHLEdBQUgsR0FBRyxDQUFtQjtRQU52QixjQUFTLEdBQUcsS0FBSyxDQUFDO1FBRWxCLG9CQUFlLEdBQUcsT0FBTyxDQUFDO1FBUWpDLFFBQVEsQ0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