UNPKG

ngx-bootstrap

Version:
518 lines (517 loc) 47.8 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ // tslint:disable:max-file-line-count max-line-length import { ChangeDetectorRef, Component, ElementRef, HostListener, QueryList, Renderer2, ViewChild, ViewChildren, Output, EventEmitter } from '@angular/core'; import { isBs3, Utils } from 'ngx-bootstrap/utils'; import { PositioningService } from 'ngx-bootstrap/positioning'; import { latinize } from './typeahead-utils'; import { typeaheadAnimation } from './typeahead-animations'; /** @type {?} */ let nextWindowId = 0; export class TypeaheadContainerComponent { /** * @param {?} positionService * @param {?} renderer * @param {?} element * @param {?} changeDetectorRef */ constructor(positionService, renderer, element, changeDetectorRef) { this.positionService = positionService; this.renderer = renderer; this.element = element; this.changeDetectorRef = changeDetectorRef; // tslint:disable-next-line: no-output-rename this.activeChangeEvent = new EventEmitter(); this.isFocused = false; this.height = 0; this.popupId = `ngb-typeahead-${nextWindowId++}`; this._matches = []; this.isScrolledIntoView = (/** * @param {?} elem * @return {?} */ function (elem) { /** @type {?} */ const containerViewTop = this.ulElement.nativeElement.scrollTop; /** @type {?} */ const containerViewBottom = containerViewTop + Number(this.ulElement.nativeElement.offsetHeight); /** @type {?} */ const elemTop = elem.offsetTop; /** @type {?} */ const elemBottom = elemTop + elem.offsetHeight; return ((elemBottom <= containerViewBottom) && (elemTop >= containerViewTop)); }); this.renderer.setAttribute(this.element.nativeElement, 'id', this.popupId); this.positionServiceSubscription = this.positionService.event$.subscribe((/** * @return {?} */ () => { if (this.isAnimated) { this.animationState = this.isTopPosition ? 'animated-up' : 'animated-down'; this.changeDetectorRef.detectChanges(); return; } this.animationState = 'unanimated'; this.changeDetectorRef.detectChanges(); })); } /** * @return {?} */ get isBs4() { return !isBs3(); } /** * @return {?} */ get typeaheadTemplateMethods() { /* tslint:disable:no-this-assignment */ /** @type {?} */ const _that = this; return { selectMatch: this.selectMatch.bind(_that), selectActive: this.selectActive.bind(_that), isActive: this.isActive.bind(_that) }; } /** * @return {?} */ get active() { return this._active; } /** * @param {?} active * @return {?} */ set active(active) { this._active = active; this.activeChanged(); } /** * @return {?} */ get matches() { return this._matches; } /** * @param {?} value * @return {?} */ set matches(value) { this.positionService.setOptions({ modifiers: { flip: { enabled: this.adaptivePosition } }, allowedPositions: ['top', 'bottom'] }); this._matches = value; this.needScrollbar = this.typeaheadScrollable && this.typeaheadOptionsInScrollableView < this.matches.length; if (this.typeaheadScrollable) { setTimeout((/** * @return {?} */ () => { this.setScrollableMode(); })); } if (this.typeaheadIsFirstItemActive && this._matches.length > 0) { this.active = this._matches[0]; if (this._active.isHeader()) { this.nextActiveMatch(); } } if (this._active && !this.typeaheadIsFirstItemActive) { /** @type {?} */ const concurrency = this._matches.find((/** * @param {?} match * @return {?} */ match => match.value === this._active.value)); if (concurrency) { this.selectActive(concurrency); return; } this.active = null; } } /** * @return {?} */ get isTopPosition() { return this.element.nativeElement.classList.contains('top'); } // tslint:disable-next-line:no-any /** * @return {?} */ get optionsListTemplate() { return this.parent ? this.parent.optionsListTemplate : undefined; } /** * @return {?} */ get isAnimated() { return this.parent ? this.parent.isAnimated : false; } /** * @return {?} */ get adaptivePosition() { return this.parent ? this.parent.adaptivePosition : false; } /** * @return {?} */ get typeaheadScrollable() { return this.parent ? this.parent.typeaheadScrollable : false; } /** * @return {?} */ get typeaheadOptionsInScrollableView() { return this.parent ? this.parent.typeaheadOptionsInScrollableView : 5; } /** * @return {?} */ get typeaheadIsFirstItemActive() { return this.parent ? this.parent.typeaheadIsFirstItemActive : true; } // tslint:disable-next-line:no-any /** * @return {?} */ get itemTemplate() { return this.parent ? this.parent.typeaheadItemTemplate : undefined; } /** * @param {?=} isActiveItemChanged * @return {?} */ selectActiveMatch(isActiveItemChanged) { if (this._active && this.parent.typeaheadSelectFirstItem) { this.selectMatch(this._active); } if (!this.parent.typeaheadSelectFirstItem && isActiveItemChanged) { this.selectMatch(this._active); } } /** * @return {?} */ activeChanged() { /** @type {?} */ const index = this.matches.indexOf(this._active); this.activeChangeEvent.emit(`${this.popupId}-${index}`); } /** * @return {?} */ prevActiveMatch() { /** @type {?} */ const index = this.matches.indexOf(this._active); this.active = this.matches[index - 1 < 0 ? this.matches.length - 1 : index - 1]; if (this._active.isHeader()) { this.prevActiveMatch(); } if (this.typeaheadScrollable) { this.scrollPrevious(index); } } /** * @return {?} */ nextActiveMatch() { /** @type {?} */ const index = this.matches.indexOf(this._active); this.active = this.matches[index + 1 > this.matches.length - 1 ? 0 : index + 1]; if (this._active.isHeader()) { this.nextActiveMatch(); } if (this.typeaheadScrollable) { this.scrollNext(index); } } /** * @param {?} value * @return {?} */ selectActive(value) { this.isFocused = true; this.active = value; } /** * @param {?} match * @param {?} query * @return {?} */ highlight(match, query) { /** @type {?} */ let itemStr = match.value; /** @type {?} */ let itemStrHelper = (this.parent && this.parent.typeaheadLatinize ? latinize(itemStr) : itemStr).toLowerCase(); /** @type {?} */ let startIdx; /** @type {?} */ let tokenLen; // Replaces the capture string with the same string inside of a "strong" tag if (typeof query === 'object') { /** @type {?} */ const queryLen = query.length; for (let i = 0; i < queryLen; i += 1) { // query[i] is already latinized and lower case startIdx = itemStrHelper.indexOf(query[i]); tokenLen = query[i].length; if (startIdx >= 0 && tokenLen > 0) { itemStr = `${itemStr.substring(0, startIdx)}<strong>${itemStr.substring(startIdx, startIdx + tokenLen)}</strong>` + `${itemStr.substring(startIdx + tokenLen)}`; itemStrHelper = `${itemStrHelper.substring(0, startIdx)} ${' '.repeat(tokenLen)} ` + `${itemStrHelper.substring(startIdx + tokenLen)}`; } } } else if (query) { // query is already latinized and lower case startIdx = itemStrHelper.indexOf(query); tokenLen = query.length; if (startIdx >= 0 && tokenLen > 0) { itemStr = `${itemStr.substring(0, startIdx)}<strong>${itemStr.substring(startIdx, startIdx + tokenLen)}</strong>` + `${itemStr.substring(startIdx + tokenLen)}`; } } return itemStr; } /** * @return {?} */ focusLost() { this.isFocused = false; } /** * @param {?} value * @return {?} */ isActive(value) { return this.active === value; } /** * @param {?} value * @param {?=} e * @return {?} */ selectMatch(value, e = void 0) { if (e) { e.stopPropagation(); e.preventDefault(); } this.parent.changeModel(value); setTimeout((/** * @return {?} */ () => this.parent.typeaheadOnSelect.emit(value)), 0); return false; } /** * @return {?} */ setScrollableMode() { if (!this.ulElement) { this.ulElement = this.element; } if (this.liElements.first) { /** @type {?} */ const ulStyles = Utils.getStyles(this.ulElement.nativeElement); /** @type {?} */ const liStyles = Utils.getStyles(this.liElements.first.nativeElement); /** @type {?} */ const ulPaddingBottom = parseFloat((ulStyles['padding-bottom'] ? ulStyles['padding-bottom'] : '') .replace('px', '')); /** @type {?} */ const ulPaddingTop = parseFloat((ulStyles['padding-top'] ? ulStyles['padding-top'] : '0') .replace('px', '')); /** @type {?} */ const optionHeight = parseFloat((liStyles.height ? liStyles.height : '0') .replace('px', '')); /** @type {?} */ const height = this.typeaheadOptionsInScrollableView * optionHeight; this.guiHeight = `${height + ulPaddingTop + ulPaddingBottom}px`; } this.renderer.setStyle(this.element.nativeElement, 'visibility', 'visible'); } /** * @param {?} index * @return {?} */ scrollPrevious(index) { if (index === 0) { this.scrollToBottom(); return; } if (this.liElements) { /** @type {?} */ const liElement = this.liElements.toArray()[index - 1]; if (liElement && !this.isScrolledIntoView(liElement.nativeElement)) { this.ulElement.nativeElement.scrollTop = liElement.nativeElement.offsetTop; } } } /** * @param {?} index * @return {?} */ scrollNext(index) { if (index + 1 > this.matches.length - 1) { this.scrollToTop(); return; } if (this.liElements) { /** @type {?} */ const liElement = this.liElements.toArray()[index + 1]; if (liElement && !this.isScrolledIntoView(liElement.nativeElement)) { this.ulElement.nativeElement.scrollTop = liElement.nativeElement.offsetTop - Number(this.ulElement.nativeElement.offsetHeight) + Number(liElement.nativeElement.offsetHeight); } } } /** * @return {?} */ ngOnDestroy() { this.positionServiceSubscription.unsubscribe(); } /** * @private * @return {?} */ scrollToBottom() { this.ulElement.nativeElement.scrollTop = this.ulElement.nativeElement.scrollHeight; } /** * @private * @return {?} */ scrollToTop() { this.ulElement.nativeElement.scrollTop = 0; } } TypeaheadContainerComponent.decorators = [ { type: Component, args: [{ selector: 'typeahead-container', template: "<!-- inject options list template -->\n<ng-template [ngTemplateOutlet]=\"optionsListTemplate || (isBs4 ? bs4Template : bs3Template)\"\n [ngTemplateOutletContext]=\"{\n matches: matches,\n itemTemplate: itemTemplate || bsItemTemplate,\n query: query,\n $implicit: typeaheadTemplateMethods\n }\">\n</ng-template>\n\n<!-- default options item template -->\n<ng-template #bsItemTemplate let-match=\"match\" let-query=\"query\">\n <span [innerHtml]=\"highlight(match, query)\"></span>\n</ng-template>\n\n<!-- Bootstrap 3 options list template -->\n<ng-template #bs3Template>\n <ul class=\"dropdown-menu\"\n #ulElement\n role=\"listbox\"\n [style.overflow-y]=\"needScrollbar ? 'scroll': 'auto'\"\n [style.height]=\"needScrollbar ? guiHeight: 'auto'\">\n <ng-template ngFor let-match let-i=\"index\" [ngForOf]=\"matches\">\n <li #liElements *ngIf=\"match.isHeader()\" class=\"dropdown-header\">{{ match }}</li>\n <li #liElements\n *ngIf=\"!match.isHeader()\"\n [id]=\"popupId + '-' + i\"\n role=\"option\"\n [@typeaheadAnimation]=\"animationState\"\n [class.active]=\"isActive(match)\"\n (mouseenter)=\"selectActive(match)\">\n\n <a href=\"#\" (click)=\"selectMatch(match, $event)\" tabindex=\"-1\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate || bsItemTemplate\"\n [ngTemplateOutletContext]=\"{item: match.item, index: i, match: match, query: query}\">\n </ng-template>\n </a>\n </li>\n </ng-template>\n </ul>\n</ng-template>\n\n<!-- Bootstrap 4 options list template -->\n<ng-template #bs4Template>\n <ng-template ngFor let-match let-i=\"index\" [ngForOf]=\"matches\">\n <h6 *ngIf=\"match.isHeader()\" class=\"dropdown-header\">{{ match }}</h6>\n <ng-template [ngIf]=\"!match.isHeader()\">\n <button #liElements\n [id]=\"popupId + '-' + i\"\n role=\"option\"\n [@typeaheadAnimation]=\"animationState\"\n class=\"dropdown-item\"\n (click)=\"selectMatch(match, $event)\"\n (mouseenter)=\"selectActive(match)\"\n [class.active]=\"isActive(match)\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate || bsItemTemplate\"\n [ngTemplateOutletContext]=\"{item: match.item, index: i, match: match, query: query}\">\n </ng-template>\n </button>\n </ng-template>\n </ng-template>\n</ng-template>\n", host: { class: 'dropdown open bottom', '[class.dropdown-menu]': 'isBs4', '[style.height]': `isBs4 && needScrollbar ? guiHeight: 'auto'`, '[style.visibility]': `'inherit'`, '[class.dropup]': 'dropup', style: 'position: absolute;display: block;', '[attr.role]': `isBs4 ? 'listbox' : null ` }, animations: [typeaheadAnimation], styles: [` :host.dropdown { z-index: 1000; } :host.dropdown-menu, .dropdown-menu { overflow-y: auto; height: 100px; } `] }] } ]; /** @nocollapse */ TypeaheadContainerComponent.ctorParameters = () => [ { type: PositioningService }, { type: Renderer2 }, { type: ElementRef }, { type: ChangeDetectorRef } ]; TypeaheadContainerComponent.propDecorators = { activeChangeEvent: [{ type: Output, args: ['activeChange',] }], ulElement: [{ type: ViewChild, args: ['ulElement', { static: false },] }], liElements: [{ type: ViewChildren, args: ['liElements',] }], focusLost: [{ type: HostListener, args: ['mouseleave',] }, { type: HostListener, args: ['blur',] }] }; if (false) { /** @type {?} */ TypeaheadContainerComponent.prototype.activeChangeEvent; /** @type {?} */ TypeaheadContainerComponent.prototype.parent; /** @type {?} */ TypeaheadContainerComponent.prototype.query; /** @type {?} */ TypeaheadContainerComponent.prototype.isFocused; /** @type {?} */ TypeaheadContainerComponent.prototype.top; /** @type {?} */ TypeaheadContainerComponent.prototype.left; /** @type {?} */ TypeaheadContainerComponent.prototype.display; /** @type {?} */ TypeaheadContainerComponent.prototype.placement; /** @type {?} */ TypeaheadContainerComponent.prototype.dropup; /** @type {?} */ TypeaheadContainerComponent.prototype.guiHeight; /** @type {?} */ TypeaheadContainerComponent.prototype.needScrollbar; /** @type {?} */ TypeaheadContainerComponent.prototype.animationState; /** @type {?} */ TypeaheadContainerComponent.prototype.positionServiceSubscription; /** @type {?} */ TypeaheadContainerComponent.prototype.height; /** @type {?} */ TypeaheadContainerComponent.prototype.popupId; /** * @type {?} * @protected */ TypeaheadContainerComponent.prototype._active; /** * @type {?} * @protected */ TypeaheadContainerComponent.prototype._matches; /** * @type {?} * @private */ TypeaheadContainerComponent.prototype.ulElement; /** * @type {?} * @private */ TypeaheadContainerComponent.prototype.liElements; /** * @type {?} * @private */ TypeaheadContainerComponent.prototype.isScrolledIntoView; /** * @type {?} * @private */ TypeaheadContainerComponent.prototype.positionService; /** * @type {?} * @private */ TypeaheadContainerComponent.prototype.renderer; /** @type {?} */ TypeaheadContainerComponent.prototype.element; /** * @type {?} * @private */ TypeaheadContainerComponent.prototype.changeDetectorRef; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZWFoZWFkLWNvbnRhaW5lci5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZ3gtYm9vdHN0cmFwL3R5cGVhaGVhZC8iLCJzb3VyY2VzIjpbInR5cGVhaGVhZC1jb250YWluZXIuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQ0EsT0FBTyxFQUNMLGlCQUFpQixFQUNqQixTQUFTLEVBQ1QsVUFBVSxFQUNWLFlBQVksRUFFWixTQUFTLEVBQ1QsU0FBUyxFQUVULFNBQVMsRUFDVCxZQUFZLEVBQ1osTUFBTSxFQUNOLFlBQVksRUFDYixNQUFNLGVBQWUsQ0FBQztBQUV2QixPQUFPLEVBQUUsS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ25ELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRy9ELE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQ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