ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
201 lines • 14 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import * as tslib_1 from "tslib";
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { InputBoolean } from '../core/util/convert';
import { scrollIntoView } from '../core/util/scroll-into-view-if-needed';
var NzOptionSelectionChange = /** @class */ (function () {
function NzOptionSelectionChange(source, isUserInput) {
if (isUserInput === void 0) { isUserInput = false; }
this.source = source;
this.isUserInput = isUserInput;
}
return NzOptionSelectionChange;
}());
export { NzOptionSelectionChange };
if (false) {
/** @type {?} */
NzOptionSelectionChange.prototype.source;
/** @type {?} */
NzOptionSelectionChange.prototype.isUserInput;
}
var NzAutocompleteOptionComponent = /** @class */ (function () {
function NzAutocompleteOptionComponent(changeDetectorRef, element) {
this.changeDetectorRef = changeDetectorRef;
this.element = element;
this.nzDisabled = false;
this.selectionChange = new EventEmitter();
this.active = false;
this.selected = false;
}
/**
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.select = /**
* @return {?}
*/
function () {
this.selected = true;
this.changeDetectorRef.markForCheck();
this.emitSelectionChangeEvent();
};
/**
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.deselect = /**
* @return {?}
*/
function () {
this.selected = false;
this.changeDetectorRef.markForCheck();
this.emitSelectionChangeEvent();
};
/** Git display label */
/**
* Git display label
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.getLabel = /**
* Git display label
* @return {?}
*/
function () {
return this.nzLabel || this.nzValue.toString();
};
/** Set active (only styles) */
/**
* Set active (only styles)
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.setActiveStyles = /**
* Set active (only styles)
* @return {?}
*/
function () {
if (!this.active) {
this.active = true;
this.changeDetectorRef.markForCheck();
}
};
/** Unset active (only styles) */
/**
* Unset active (only styles)
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.setInactiveStyles = /**
* Unset active (only styles)
* @return {?}
*/
function () {
if (this.active) {
this.active = false;
this.changeDetectorRef.markForCheck();
}
};
/**
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.scrollIntoViewIfNeeded = /**
* @return {?}
*/
function () {
scrollIntoView(this.element.nativeElement);
};
/**
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.selectViaInteraction = /**
* @return {?}
*/
function () {
if (!this.nzDisabled) {
this.selected = !this.selected;
if (this.selected) {
this.setActiveStyles();
}
else {
this.setInactiveStyles();
}
this.emitSelectionChangeEvent(true);
this.changeDetectorRef.markForCheck();
}
};
/**
* @private
* @param {?=} isUserInput
* @return {?}
*/
NzAutocompleteOptionComponent.prototype.emitSelectionChangeEvent = /**
* @private
* @param {?=} isUserInput
* @return {?}
*/
function (isUserInput) {
if (isUserInput === void 0) { isUserInput = false; }
this.selectionChange.emit(new NzOptionSelectionChange(this, isUserInput));
};
NzAutocompleteOptionComponent.decorators = [
{ type: Component, args: [{
selector: 'nz-auto-option',
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: "<ng-content></ng-content>",
host: {
role: 'menuitem',
class: 'ant-select-dropdown-menu-item',
'[class.ant-select-dropdown-menu-item-selected]': 'selected',
'[class.ant-select-dropdown-menu-item-active]': 'active',
'[class.ant-select-dropdown-menu-item-disabled]': 'nzDisabled',
'[attr.aria-selected]': 'selected.toString()',
'[attr.aria-disabled]': 'nzDisabled.toString()',
'(click)': 'selectViaInteraction()',
'(mousedown)': '$event.preventDefault()'
}
}] }
];
/** @nocollapse */
NzAutocompleteOptionComponent.ctorParameters = function () { return [
{ type: ChangeDetectorRef },
{ type: ElementRef }
]; };
NzAutocompleteOptionComponent.propDecorators = {
nzValue: [{ type: Input }],
nzLabel: [{ type: Input }],
nzDisabled: [{ type: Input }],
selectionChange: [{ type: Output }]
};
tslib_1.__decorate([
InputBoolean(),
tslib_1.__metadata("design:type", Object)
], NzAutocompleteOptionComponent.prototype, "nzDisabled", void 0);
return NzAutocompleteOptionComponent;
}());
export { NzAutocompleteOptionComponent };
if (false) {
/** @type {?} */
NzAutocompleteOptionComponent.prototype.nzValue;
/** @type {?} */
NzAutocompleteOptionComponent.prototype.nzLabel;
/** @type {?} */
NzAutocompleteOptionComponent.prototype.nzDisabled;
/** @type {?} */
NzAutocompleteOptionComponent.prototype.selectionChange;
/** @type {?} */
NzAutocompleteOptionComponent.prototype.active;
/** @type {?} */
NzAutocompleteOptionComponent.prototype.selected;
/**
* @type {?}
* @private
*/
NzAutocompleteOptionComponent.prototype.changeDetectorRef;
/**
* @type {?}
* @private
*/
NzAutocompleteOptionComponent.prototype.element;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotYXV0b2NvbXBsZXRlLW9wdGlvbi5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXlqLyIsInNvdXJjZXMiOlsiYXV0by1jb21wbGV0ZS9uei1hdXRvY29tcGxldGUtb3B0aW9uLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsaUJBQWlCLEVBQ2pCLFNBQVMsRUFDVCxVQUFVLEVBQ1YsWUFBWSxFQUNaLEtBQUssRUFDTCxNQUFNLEVBQ04saUJBQWlCLEVBQ2xCLE1BQU0sZUFBZSxDQUFDO0FBRXZCLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNwRCxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0seUNBQXlDLENBQUM7QUFFekU7SUFDRSxpQ0FBbUIsTUFBcUMsRUFBUyxXQUE0QjtRQUE1Qiw0QkFBQSxFQUFBLG1CQUE0QjtRQUExRSxXQUFNLEdBQU4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