ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
132 lines • 11.3 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, Input, Renderer2, TemplateRef, ViewEncapsulation } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { isNotNil } from '../core/util/check';
import { NzOptionComponent } from './nz-option.component';
import { NzSelectService } from './nz-select.service';
var NzOptionLiComponent = /** @class */ (function () {
function NzOptionLiComponent(elementRef, nzSelectService, cdr, renderer) {
this.elementRef = elementRef;
this.nzSelectService = nzSelectService;
this.cdr = cdr;
this.el = this.elementRef.nativeElement;
this.selected = false;
this.active = false;
this.destroy$ = new Subject();
renderer.addClass(elementRef.nativeElement, 'ant-select-dropdown-menu-item');
}
/**
* @return {?}
*/
NzOptionLiComponent.prototype.clickOption = /**
* @return {?}
*/
function () {
this.nzSelectService.clickOption(this.nzOption);
};
/**
* @return {?}
*/
NzOptionLiComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.nzSelectService.listOfSelectedValue$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} list
* @return {?}
*/
function (list) {
_this.selected = isNotNil(list.find((/**
* @param {?} v
* @return {?}
*/
function (v) { return _this.nzSelectService.compareWith(v, _this.nzOption.nzValue); })));
_this.cdr.markForCheck();
}));
this.nzSelectService.activatedOption$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} option
* @return {?}
*/
function (option) {
if (option) {
_this.active = _this.nzSelectService.compareWith(option.nzValue, _this.nzOption.nzValue);
}
else {
_this.active = false;
}
_this.cdr.markForCheck();
}));
};
/**
* @return {?}
*/
NzOptionLiComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.destroy$.next();
this.destroy$.complete();
};
NzOptionLiComponent.decorators = [
{ type: Component, args: [{
selector: '[nz-option-li]',
template: "<ng-container *ngIf=\"!nzOption.nzCustomContent; else nzOption.template\">\n {{nzOption.nzLabel}}\n</ng-container>\n<ng-container *ngIf=\"nzSelectService.isMultipleOrTags\">\n <i nz-icon type=\"check\" class=\"ant-select-selected-icon\" *ngIf=\"!nzMenuItemSelectedIcon; else nzMenuItemSelectedIcon\"></i>\n</ng-container>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
host: {
'[class.ant-select-dropdown-menu-item-selected]': 'selected && !nzOption.nzDisabled',
'[class.ant-select-dropdown-menu-item-disabled]': 'nzOption.nzDisabled',
'[class.ant-select-dropdown-menu-item-active]': 'active && !nzOption.nzDisabled',
'[attr.unselectable]': '"unselectable"',
'[style.user-select]': '"none"',
'(click)': 'clickOption()',
'(mousedown)': '$event.preventDefault()'
}
}] }
];
/** @nocollapse */
NzOptionLiComponent.ctorParameters = function () { return [
{ type: ElementRef },
{ type: NzSelectService },
{ type: ChangeDetectorRef },
{ type: Renderer2 }
]; };
NzOptionLiComponent.propDecorators = {
nzOption: [{ type: Input }],
nzMenuItemSelectedIcon: [{ type: Input }]
};
return NzOptionLiComponent;
}());
export { NzOptionLiComponent };
if (false) {
/** @type {?} */
NzOptionLiComponent.prototype.el;
/** @type {?} */
NzOptionLiComponent.prototype.selected;
/** @type {?} */
NzOptionLiComponent.prototype.active;
/** @type {?} */
NzOptionLiComponent.prototype.destroy$;
/** @type {?} */
NzOptionLiComponent.prototype.nzOption;
/** @type {?} */
NzOptionLiComponent.prototype.nzMenuItemSelectedIcon;
/**
* @type {?}
* @private
*/
NzOptionLiComponent.prototype.elementRef;
/** @type {?} */
NzOptionLiComponent.prototype.nzSelectService;
/**
* @type {?}
* @private
*/
NzOptionLiComponent.prototype.cdr;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotb3B0aW9uLWxpLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOi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