/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ChangeDetectorRef, ElementRef, NgZone, Optional, EventEmitter, Directive, Inject, Input, } from '@angular/core'; import { Directionality } from '@angular/cdk/bidi'; import { coerceBooleanProperty, coerceNumberProperty, } from '@angular/cdk/coercion'; import { ViewportRuler } from '@angular/cdk/scrolling'; import { FocusKeyManager } from '@angular/cdk/a11y'; import { ENTER, SPACE, hasModifierKey } from '@angular/cdk/keycodes'; import { merge, of as observableOf, Subject, EMPTY, Observable, timer, fromEvent, } from 'rxjs'; import { take, switchMap, startWith, skip, takeUntil, filter } from 'rxjs/operators'; import { Platform, normalizePassiveListenerOptions } from '@angular/cdk/platform'; import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/scrolling"; import * as i2 from "@angular/cdk/bidi"; import * as i3 from "@angular/cdk/platform"; /** Config used to bind passive event listeners */ const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true, }); /** * Amount of milliseconds to wait before starting to scroll the header automatically. * Set a little conservatively in order to handle fake events dispatched on touch devices. */ const HEADER_SCROLL_DELAY = 650; /** * Interval in milliseconds at which to scroll the header * while the user is holding their pointer. */ const HEADER_SCROLL_INTERVAL = 100; /** * Base class for a tab header that supported pagination. * @docs-private */ export class MatPaginatedTabHeader { /** * Whether pagination should be disabled. This can be used to avoid unnecessary * layout recalculations if it's known that pagination won't be required. */ get disablePagination() { return this._disablePagination; } set disablePagination(value) { this._disablePagination = coerceBooleanProperty(value); } /** The index of the active tab. */ get selectedIndex() { return this._selectedIndex; } set selectedIndex(value) { value = coerceNumberProperty(value); if (this._selectedIndex != value) { this._selectedIndexChanged = true; this._selectedIndex = value; if (this._keyManager) { this._keyManager.updateActiveItem(value); } } } constructor(_elementRef, _changeDetectorRef, _viewportRuler, _dir, _ngZone, _platform, _animationMode) { this._elementRef = _elementRef; this._changeDetectorRef = _changeDetectorRef; this._viewportRuler = _viewportRuler; this._dir = _dir; this._ngZone = _ngZone; this._platform = _platform; this._animationMode = _animationMode; /** The distance in pixels that the tab labels should be translated to the left. */ this._scrollDistance = 0; /** Whether the header should scroll to the selected index after the view has been checked. */ this._selectedIndexChanged = false; /** Emits when the component is destroyed. */ this._destroyed = new Subject(); /** Whether the controls for pagination should be displayed */ this._showPaginationControls = false; /** Whether the tab list can be scrolled more towards the end of the tab label list. */ this._disableScrollAfter = true; /** Whether the tab list can be scrolled more towards the beginning of the tab label list. */ this._disableScrollBefore = true; /** Stream that will stop the automated scrolling. */ this._stopScrolling = new Subject(); this._disablePagination = false; this._selectedIndex = 0; /** Event emitted when the option is selected. */ this.selectFocusedIndex = new EventEmitter(); /** Event emitted when a label is focused. */ this.indexFocused = new EventEmitter(); // Bind the `mouseleave` event on the outside since it doesn't change anything in the view. _ngZone.runOutsideAngular(() => { fromEvent(_elementRef.nativeElement, 'mouseleave') .pipe(takeUntil(this._destroyed)) .subscribe(() => { this._stopInterval(); }); }); } ngAfterViewInit() { // We need to handle these events manually, because we want to bind passive event listeners. fromEvent(this._previousPaginator.nativeElement, 'touchstart', passiveEventListenerOptions) .pipe(takeUntil(this._destroyed)) .subscribe(() => { this._handlePaginatorPress('before'); }); fromEvent(this._nextPaginator.nativeElement, 'touchstart', passiveEventListenerOptions) .pipe(takeUntil(this._destroyed)) .subscribe(() => { this._handlePaginatorPress('after'); }); } ngAfterContentInit() { const dirChange = this._dir ? this._dir.change : observableOf('ltr'); const resize = this._viewportRuler.change(150); const realign = () => { this.updatePagination(); this._alignInkBarToSelectedTab(); }; this._keyManager = new FocusKeyManager(this._items) .withHorizontalOrientation(this._getLayoutDirection()) .withHomeAndEnd() .withWrap() // Allow focus to land on disabled tabs, as per https://w3c.github.io/aria-practices/#kbd_disabled_controls .skipPredicate(() => false); this._keyManager.updateActiveItem(this._selectedIndex); // Defer the first call in order to allow for slower browsers to lay out the elements. // This helps in cases where the user lands directly on a page with paginated tabs. // Note that we use `onStable` instead of `requestAnimationFrame`, because the latter // can hold up tests that are in a background tab. this._ngZone.onStable.pipe(take(1)).subscribe(realign); // On dir change or window resize, realign the ink bar and update the orientation of // the key manager if the direction has changed. merge(dirChange, resize, this._items.changes, this._itemsResized()) .pipe(takeUntil(this._destroyed)) .subscribe(() => { // We need to defer this to give the browser some time to recalculate // the element dimensions. The call has to be wrapped in `NgZone.run`, // because the viewport change handler runs outside of Angular. this._ngZone.run(() => { Promise.resolve().then(() => { // Clamp the scroll distance, because it can change with the number of tabs. this._scrollDistance = Math.max(0, Math.min(this._getMaxScrollDistance(), this._scrollDistance)); realign(); }); }); this._keyManager.withHorizontalOrientation(this._getLayoutDirection()); }); // If there is a change in the focus key manager we need to emit the `indexFocused` // event in order to provide a public event that notifies about focus changes. Also we realign // the tabs container by scrolling the new focused tab into the visible section. this._keyManager.change.subscribe(newFocusIndex => { this.indexFocused.emit(newFocusIndex); this._setTabFocus(newFocusIndex); }); } /** Sends any changes that could affect the layout of the items. */ _itemsResized() { if (typeof ResizeObserver !== 'function') { return EMPTY; } return this._items.changes.pipe(startWith(this._items), switchMap((tabItems) => new Observable((observer) => this._ngZone.runOutsideAngular(() => { const resizeObserver = new ResizeObserver(entries => observer.next(entries)); tabItems.forEach(item => resizeObserver.observe(item.elementRef.nativeElement)); return () => { resizeObserver.disconnect(); }; }))), // Skip the first emit since the resize observer emits when an item // is observed for new items when the tab is already inserted skip(1), // Skip emissions where all the elements are invisible since we don't want // the header to try and re-render with invalid measurements. See #25574. filter(entries => entries.some(e => e.contentRect.width > 0 && e.contentRect.height > 0))); } ngAfterContentChecked() { // If the number of tab labels have changed, check if scrolling should be enabled if (this._tabLabelCount != this._items.length) { this.updatePagination(); this._tabLabelCount = this._items.length; this._changeDetectorRef.markForCheck(); } // If the selected index has changed, scroll to the label and check if the scrolling controls // should be disabled. if (this._selectedIndexChanged) { this._scrollToLabel(this._selectedIndex); this._checkScrollingControls(); this._alignInkBarToSelectedTab(); this._selectedIndexChanged = false; this._changeDetectorRef.markForCheck(); } // If the scroll distance has been changed (tab selected, focused, scroll controls activated), // then translate the header to reflect this. if (this._scrollDistanceChanged) { this._updateTabScrollPosition(); this._scrollDistanceChanged = false; this._changeDetectorRef.markForCheck(); } } ngOnDestroy() { this._keyManager?.destroy(); this._destroyed.next(); this._destroyed.complete(); this._stopScrolling.complete(); } /** Handles keyboard events on the header. */ _handleKeydown(event) { // We don't handle any key bindings with a modifier key. if (hasModifierKey(event)) { return; } switch (event.keyCode) { case ENTER: case SPACE: if (this.focusIndex !== this.selectedIndex) { const item = this._items.get(this.focusIndex); if (item && !item.disabled) { this.selectFocusedIndex.emit(this.focusIndex); this._itemSelected(event); } } break; default: this._keyManager.onKeydown(event); } } /** * Callback for when the MutationObserver detects that the content has changed. */ _onContentChanges() { const textContent = this._elementRef.nativeElement.textContent; // We need to diff the text content of the header, because the MutationObserver callback // will fire even if the text content didn't change which is inefficient and is prone // to infinite loops if a poorly constructed expression is passed in (see #14249). if (textContent !== this._currentTextContent) { this._currentTextContent = textContent || ''; // The content observer runs outside the `NgZone` by default, which // means that we need to bring the callback back in ourselves. this._ngZone.run(() => { this.updatePagination(); this._alignInkBarToSelectedTab(); this._changeDetectorRef.markForCheck(); }); } } /** * Updates the view whether pagination should be enabled or not. * * WARNING: Calling this method can be very costly in terms of performance. It should be called * as infrequently as possible from outside of the Tabs component as it causes a reflow of the * page. */ updatePagination() { this._checkPaginationEnabled(); this._checkScrollingControls(); this._updateTabScrollPosition(); } /** Tracks which element has focus; used for keyboard navigation */ get focusIndex() { return this._keyManager ? this._keyManager.activeItemIndex : 0; } /** When the focus index is set, we must manually send focus to the correct label */ set focusIndex(value) { if (!this._isValidIndex(value) || this.focusIndex === value || !this._keyManager) { return; } this._keyManager.setActiveItem(value); } /** * Determines if an index is valid. If the tabs are not ready yet, we assume that the user is * providing a valid index and return true. */ _isValidIndex(index) { return this._items ? !!this._items.toArray()[index] : true; } /** * Sets focus on the HTML element for the label wrapper and scrolls it into the view if * scrolling is enabled. */ _setTabFocus(tabIndex) { if (this._showPaginationControls) { this._scrollToLabel(tabIndex); } if (this._items && this._items.length) { this._items.toArray()[tabIndex].focus(); // Do not let the browser manage scrolling to focus the element, this will be handled // by using translation. In LTR, the scroll left should be 0. In RTL, the scroll width // should be the full width minus the offset width. const containerEl = this._tabListContainer.nativeElement; const dir = this._getLayoutDirection(); if (dir == 'ltr') { containerEl.scrollLeft = 0; } else { containerEl.scrollLeft = containerEl.scrollWidth - containerEl.offsetWidth; } } } /** The layout direction of the containing app. */ _getLayoutDirection() { return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr'; } /** Performs the CSS transformation on the tab list that will cause the list to scroll. */ _updateTabScrollPosition() { if (this.disablePagination) { return; } const scrollDistance = this.scrollDistance; const translateX = this._getLayoutDirection() === 'ltr' ? -scrollDistance : scrollDistance; // Don't use `translate3d` here because we don't want to create a new layer. A new layer // seems to cause flickering and overflow in Internet Explorer. For example, the ink bar // and ripples will exceed the boundaries of the visible tab bar. // See: https://github.com/angular/components/issues/10276 // We round the `transform` here, because transforms with sub-pixel precision cause some // browsers to blur the content of the element. this._tabList.nativeElement.style.transform = `translateX(${Math.round(translateX)}px)`; // Setting the `transform` on IE will change the scroll offset of the parent, causing the // position to be thrown off in some cases. We have to reset it ourselves to ensure that // it doesn't get thrown off. Note that we scope it only to IE and Edge, because messing // with the scroll position throws off Chrome 71+ in RTL mode (see #14689). if (this._platform.TRIDENT || this._platform.EDGE) { this._tabListContainer.nativeElement.scrollLeft = 0; } } /** Sets the distance in pixels that the tab header should be transformed in the X-axis. */ get scrollDistance() { return this._scrollDistance; } set scrollDistance(value) { this._scrollTo(value); } /** * Moves the tab list in the 'before' or 'after' direction (towards the beginning of the list or * the end of the list, respectively). The distance to scroll is computed to be a third of the * length of the tab list view window. * * This is an expensive call that forces a layout reflow to compute box and scroll metrics and * should be called sparingly. */ _scrollHeader(direction) { const viewLength = this._tabListContainer.nativeElement.offsetWidth; // Move the scroll distance one-third the length of the tab list's viewport. const scrollAmount = ((direction == 'before' ? -1 : 1) * viewLength) / 3; return this._scrollTo(this._scrollDistance + scrollAmount); } /** Handles click events on the pagination arrows. */ _handlePaginatorClick(direction) { this._stopInterval(); this._scrollHeader(direction); } /** * Moves the tab list such that the desired tab label (marked by index) is moved into view. * * This is an expensive call that forces a layout reflow to compute box and scroll metrics and * should be called sparingly. */ _scrollToLabel(labelIndex) { if (this.disablePagination) { return; } const selectedLabel = this._items ? this._items.toArray()[labelIndex] : null; if (!selectedLabel) { return; } // The view length is the visible width of the tab labels. const viewLength = this._tabListContainer.nativeElement.offsetWidth; const { offsetLeft, offsetWidth } = selectedLabel.elementRef.nativeElement; let labelBeforePos, labelAfterPos; if (this._getLayoutDirection() == 'ltr') { labelBeforePos = offsetLeft; labelAfterPos = labelBeforePos + offsetWidth; } else { labelAfterPos = this._tabListInner.nativeElement.offsetWidth - offsetLeft; labelBeforePos = labelAfterPos - offsetWidth; } const beforeVisiblePos = this.scrollDistance; const afterVisiblePos = this.scrollDistance + viewLength; if (labelBeforePos < beforeVisiblePos) { // Scroll header to move label to the before direction this.scrollDistance -= beforeVisiblePos - labelBeforePos; } else if (labelAfterPos > afterVisiblePos) { // Scroll header to move label to the after direction this.scrollDistance += Math.min(labelAfterPos - afterVisiblePos, labelBeforePos - beforeVisiblePos); } } /** * Evaluate whether the pagination controls should be displayed. If the scroll width of the * tab list is wider than the size of the header container, then the pagination controls should * be shown. * * This is an expensive call that forces a layout reflow to compute box and scroll metrics and * should be called sparingly. */ _checkPaginationEnabled() { if (this.disablePagination) { this._showPaginationControls = false; } else { const isEnabled = this._tabListInner.nativeElement.scrollWidth > this._elementRef.nativeElement.offsetWidth; if (!isEnabled) { this.scrollDistance = 0; } if (isEnabled !== this._showPaginationControls) { this._changeDetectorRef.markForCheck(); } this._showPaginationControls = isEnabled; } } /** * Evaluate whether the before and after controls should be enabled or disabled. * If the header is at the beginning of the list (scroll distance is equal to 0) then disable the * before button. If the header is at the end of the list (scroll distance is equal to the * maximum distance we can scroll), then disable the after button. * * This is an expensive call that forces a layout reflow to compute box and scroll metrics and * should be called sparingly. */ _checkScrollingControls() { if (this.disablePagination) { this._disableScrollAfter = this._disableScrollBefore = true; } else { // Check if the pagination arrows should be activated. this._disableScrollBefore = this.scrollDistance == 0; this._disableScrollAfter = this.scrollDistance == this._getMaxScrollDistance(); this._changeDetectorRef.markForCheck(); } } /** * Determines what is the maximum length in pixels that can be set for the scroll distance. This * is equal to the difference in width between the tab list container and tab header container. * * This is an expensive call that forces a layout reflow to compute box and scroll metrics and * should be called sparingly. */ _getMaxScrollDistance() { const lengthOfTabList = this._tabListInner.nativeElement.scrollWidth; const viewLength = this._tabListContainer.nativeElement.offsetWidth; return lengthOfTabList - viewLength || 0; } /** Tells the ink-bar to align itself to the current label wrapper */ _alignInkBarToSelectedTab() { const selectedItem = this._items && this._items.length ? this._items.toArray()[this.selectedIndex] : null; const selectedLabelWrapper = selectedItem ? selectedItem.elementRef.nativeElement : null; if (selectedLabelWrapper) { this._inkBar.alignToElement(selectedLabelWrapper); } else { this._inkBar.hide(); } } /** Stops the currently-running paginator interval. */ _stopInterval() { this._stopScrolling.next(); } /** * Handles the user pressing down on one of the paginators. * Starts scrolling the header after a certain amount of time. * @param direction In which direction the paginator should be scrolled. */ _handlePaginatorPress(direction, mouseEvent) { // Don't start auto scrolling for right mouse button clicks. Note that we shouldn't have to // null check the `button`, but we do it so we don't break tests that use fake events. if (mouseEvent && mouseEvent.button != null && mouseEvent.button !== 0) { return; } // Avoid overlapping timers. this._stopInterval(); // Start a timer after the delay and keep firing based on the interval. timer(HEADER_SCROLL_DELAY, HEADER_SCROLL_INTERVAL) // Keep the timer going until something tells it to stop or the component is destroyed. .pipe(takeUntil(merge(this._stopScrolling, this._destroyed))) .subscribe(() => { const { maxScrollDistance, distance } = this._scrollHeader(direction); // Stop the timer if we've reached the start or the end. if (distance === 0 || distance >= maxScrollDistance) { this._stopInterval(); } }); } /** * Scrolls the header to a given position. * @param position Position to which to scroll. * @returns Information on the current scroll distance and the maximum. */ _scrollTo(position) { if (this.disablePagination) { return { maxScrollDistance: 0, distance: 0 }; } const maxScrollDistance = this._getMaxScrollDistance(); this._scrollDistance = Math.max(0, Math.min(maxScrollDistance, position)); // Mark that the scroll distance has changed so that after the view is checked, the CSS // transformation can move the header. this._scrollDistanceChanged = true; this._checkScrollingControls(); return { maxScrollDistance, distance: this._scrollDistance }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatPaginatedTabHeader, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.ViewportRuler }, { token: i2.Directionality, optional: true }, { token: i0.NgZone }, { token: i3.Platform }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatPaginatedTabHeader, inputs: { disablePagination: "disablePagination" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatPaginatedTabHeader, decorators: [{ type: Directive }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.ViewportRuler }, { type: i2.Directionality, decorators: [{ type: Optional }] }, { type: i0.NgZone }, { type: i3.Platform }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE] }] }]; }, propDecorators: { disablePagination: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFnaW5hdGVkLXRhYi1oZWFkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvdGFicy9wYWdpbmF0ZWQtdGFiLWhlYWRlci50cyJdLCJuYW1lcyI6W10sIm1h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