source: trip-planner-front/node_modules/@angular/material/fesm2015/tabs.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 85.9 KB
Line 
1import { FocusKeyManager, FocusMonitor, A11yModule } from '@angular/cdk/a11y';
2import { ObserversModule } from '@angular/cdk/observers';
3import { CdkPortal, TemplatePortal, CdkPortalOutlet, PortalModule } from '@angular/cdk/portal';
4import { DOCUMENT, CommonModule } from '@angular/common';
5import { InjectionToken, Directive, ElementRef, NgZone, Inject, Optional, TemplateRef, ViewContainerRef, Component, ChangeDetectionStrategy, ViewEncapsulation, ContentChild, ViewChild, Input, ComponentFactoryResolver, forwardRef, EventEmitter, ChangeDetectorRef, Output, QueryList, ContentChildren, Attribute, NgModule } from '@angular/core';
6import { mixinDisabled, mixinColor, mixinDisableRipple, mixinTabIndex, MAT_RIPPLE_GLOBAL_OPTIONS, RippleRenderer, MatCommonModule, MatRippleModule } from '@angular/material/core';
7import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
8import { Subject, Subscription, merge, fromEvent, of, timer } from 'rxjs';
9import { Directionality } from '@angular/cdk/bidi';
10import { trigger, state, style, transition, animate } from '@angular/animations';
11import { startWith, distinctUntilChanged, takeUntil } from 'rxjs/operators';
12import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
13import { ViewportRuler } from '@angular/cdk/scrolling';
14import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
15import { hasModifierKey, SPACE, ENTER } from '@angular/cdk/keycodes';
16
17/**
18 * @license
19 * Copyright Google LLC All Rights Reserved.
20 *
21 * Use of this source code is governed by an MIT-style license that can be
22 * found in the LICENSE file at https://angular.io/license
23 */
24/** Injection token for the MatInkBar's Positioner. */
25const _MAT_INK_BAR_POSITIONER = new InjectionToken('MatInkBarPositioner', {
26 providedIn: 'root',
27 factory: _MAT_INK_BAR_POSITIONER_FACTORY
28});
29/**
30 * The default positioner function for the MatInkBar.
31 * @docs-private
32 */
33function _MAT_INK_BAR_POSITIONER_FACTORY() {
34 const method = (element) => ({
35 left: element ? (element.offsetLeft || 0) + 'px' : '0',
36 width: element ? (element.offsetWidth || 0) + 'px' : '0',
37 });
38 return method;
39}
40/**
41 * The ink-bar is used to display and animate the line underneath the current active tab label.
42 * @docs-private
43 */
44class MatInkBar {
45 constructor(_elementRef, _ngZone, _inkBarPositioner, _animationMode) {
46 this._elementRef = _elementRef;
47 this._ngZone = _ngZone;
48 this._inkBarPositioner = _inkBarPositioner;
49 this._animationMode = _animationMode;
50 }
51 /**
52 * Calculates the styles from the provided element in order to align the ink-bar to that element.
53 * Shows the ink bar if previously set as hidden.
54 * @param element
55 */
56 alignToElement(element) {
57 this.show();
58 if (typeof requestAnimationFrame !== 'undefined') {
59 this._ngZone.runOutsideAngular(() => {
60 requestAnimationFrame(() => this._setStyles(element));
61 });
62 }
63 else {
64 this._setStyles(element);
65 }
66 }
67 /** Shows the ink bar. */
68 show() {
69 this._elementRef.nativeElement.style.visibility = 'visible';
70 }
71 /** Hides the ink bar. */
72 hide() {
73 this._elementRef.nativeElement.style.visibility = 'hidden';
74 }
75 /**
76 * Sets the proper styles to the ink bar element.
77 * @param element
78 */
79 _setStyles(element) {
80 const positions = this._inkBarPositioner(element);
81 const inkBar = this._elementRef.nativeElement;
82 inkBar.style.left = positions.left;
83 inkBar.style.width = positions.width;
84 }
85}
86MatInkBar.decorators = [
87 { type: Directive, args: [{
88 selector: 'mat-ink-bar',
89 host: {
90 'class': 'mat-ink-bar',
91 '[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`,
92 },
93 },] }
94];
95MatInkBar.ctorParameters = () => [
96 { type: ElementRef },
97 { type: NgZone },
98 { type: undefined, decorators: [{ type: Inject, args: [_MAT_INK_BAR_POSITIONER,] }] },
99 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
100];
101
102/**
103 * @license
104 * Copyright Google LLC All Rights Reserved.
105 *
106 * Use of this source code is governed by an MIT-style license that can be
107 * found in the LICENSE file at https://angular.io/license
108 */
109/**
110 * Injection token that can be used to reference instances of `MatTabContent`. It serves as
111 * alternative token to the actual `MatTabContent` class which could cause unnecessary
112 * retention of the class and its directive metadata.
113 */
114const MAT_TAB_CONTENT = new InjectionToken('MatTabContent');
115/** Decorates the `ng-template` tags and reads out the template from it. */
116class MatTabContent {
117 constructor(
118 /** Content for the tab. */ template) {
119 this.template = template;
120 }
121}
122MatTabContent.decorators = [
123 { type: Directive, args: [{
124 selector: '[matTabContent]',
125 providers: [{ provide: MAT_TAB_CONTENT, useExisting: MatTabContent }],
126 },] }
127];
128MatTabContent.ctorParameters = () => [
129 { type: TemplateRef }
130];
131
132/**
133 * @license
134 * Copyright Google LLC All Rights Reserved.
135 *
136 * Use of this source code is governed by an MIT-style license that can be
137 * found in the LICENSE file at https://angular.io/license
138 */
139/**
140 * Injection token that can be used to reference instances of `MatTabLabel`. It serves as
141 * alternative token to the actual `MatTabLabel` class which could cause unnecessary
142 * retention of the class and its directive metadata.
143 */
144const MAT_TAB_LABEL = new InjectionToken('MatTabLabel');
145/**
146 * Used to provide a tab label to a tab without causing a circular dependency.
147 * @docs-private
148 */
149const MAT_TAB = new InjectionToken('MAT_TAB');
150/** Used to flag tab labels for use with the portal directive */
151class MatTabLabel extends CdkPortal {
152 constructor(templateRef, viewContainerRef, _closestTab) {
153 super(templateRef, viewContainerRef);
154 this._closestTab = _closestTab;
155 }
156}
157MatTabLabel.decorators = [
158 { type: Directive, args: [{
159 selector: '[mat-tab-label], [matTabLabel]',
160 providers: [{ provide: MAT_TAB_LABEL, useExisting: MatTabLabel }],
161 },] }
162];
163MatTabLabel.ctorParameters = () => [
164 { type: TemplateRef },
165 { type: ViewContainerRef },
166 { type: undefined, decorators: [{ type: Inject, args: [MAT_TAB,] }, { type: Optional }] }
167];
168
169/**
170 * @license
171 * Copyright Google LLC All Rights Reserved.
172 *
173 * Use of this source code is governed by an MIT-style license that can be
174 * found in the LICENSE file at https://angular.io/license
175 */
176// Boilerplate for applying mixins to MatTab.
177/** @docs-private */
178const _MatTabBase = mixinDisabled(class {
179});
180/**
181 * Used to provide a tab group to a tab without causing a circular dependency.
182 * @docs-private
183 */
184const MAT_TAB_GROUP = new InjectionToken('MAT_TAB_GROUP');
185class MatTab extends _MatTabBase {
186 constructor(_viewContainerRef, _closestTabGroup) {
187 super();
188 this._viewContainerRef = _viewContainerRef;
189 this._closestTabGroup = _closestTabGroup;
190 /** Plain text label for the tab, used when there is no template label. */
191 this.textLabel = '';
192 /** Portal that will be the hosted content of the tab */
193 this._contentPortal = null;
194 /** Emits whenever the internal state of the tab changes. */
195 this._stateChanges = new Subject();
196 /**
197 * The relatively indexed position where 0 represents the center, negative is left, and positive
198 * represents the right.
199 */
200 this.position = null;
201 /**
202 * The initial relatively index origin of the tab if it was created and selected after there
203 * was already a selected tab. Provides context of what position the tab should originate from.
204 */
205 this.origin = null;
206 /**
207 * Whether the tab is currently active.
208 */
209 this.isActive = false;
210 }
211 /** Content for the tab label given by `<ng-template mat-tab-label>`. */
212 get templateLabel() { return this._templateLabel; }
213 set templateLabel(value) { this._setTemplateLabelInput(value); }
214 /** @docs-private */
215 get content() {
216 return this._contentPortal;
217 }
218 ngOnChanges(changes) {
219 if (changes.hasOwnProperty('textLabel') || changes.hasOwnProperty('disabled')) {
220 this._stateChanges.next();
221 }
222 }
223 ngOnDestroy() {
224 this._stateChanges.complete();
225 }
226 ngOnInit() {
227 this._contentPortal = new TemplatePortal(this._explicitContent || this._implicitContent, this._viewContainerRef);
228 }
229 /**
230 * This has been extracted to a util because of TS 4 and VE.
231 * View Engine doesn't support property rename inheritance.
232 * TS 4.0 doesn't allow properties to override accessors or vice-versa.
233 * @docs-private
234 */
235 _setTemplateLabelInput(value) {
236 // Only update the label if the query managed to find one. This works around an issue where a
237 // user may have manually set `templateLabel` during creation mode, which would then get
238 // clobbered by `undefined` when the query resolves. Also note that we check that the closest
239 // tab matches the current one so that we don't pick up labels from nested tabs.
240 if (value && value._closestTab === this) {
241 this._templateLabel = value;
242 }
243 }
244}
245MatTab.decorators = [
246 { type: Component, args: [{
247 selector: 'mat-tab',
248 template: "<!-- Create a template for the content of the <mat-tab> so that we can grab a reference to this\n TemplateRef and use it in a Portal to render the tab content in the appropriate place in the\n tab-group. -->\n<ng-template><ng-content></ng-content></ng-template>\n",
249 inputs: ['disabled'],
250 // tslint:disable-next-line:validate-decorators
251 changeDetection: ChangeDetectionStrategy.Default,
252 encapsulation: ViewEncapsulation.None,
253 exportAs: 'matTab',
254 providers: [{ provide: MAT_TAB, useExisting: MatTab }]
255 },] }
256];
257MatTab.ctorParameters = () => [
258 { type: ViewContainerRef },
259 { type: undefined, decorators: [{ type: Inject, args: [MAT_TAB_GROUP,] }, { type: Optional }] }
260];
261MatTab.propDecorators = {
262 templateLabel: [{ type: ContentChild, args: [MAT_TAB_LABEL,] }],
263 _explicitContent: [{ type: ContentChild, args: [MAT_TAB_CONTENT, { read: TemplateRef, static: true },] }],
264 _implicitContent: [{ type: ViewChild, args: [TemplateRef, { static: true },] }],
265 textLabel: [{ type: Input, args: ['label',] }],
266 ariaLabel: [{ type: Input, args: ['aria-label',] }],
267 ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }]
268};
269
270/**
271 * @license
272 * Copyright Google LLC All Rights Reserved.
273 *
274 * Use of this source code is governed by an MIT-style license that can be
275 * found in the LICENSE file at https://angular.io/license
276 */
277/**
278 * Animations used by the Material tabs.
279 * @docs-private
280 */
281const matTabsAnimations = {
282 /** Animation translates a tab along the X axis. */
283 translateTab: trigger('translateTab', [
284 // Note: transitions to `none` instead of 0, because some browsers might blur the content.
285 state('center, void, left-origin-center, right-origin-center', style({ transform: 'none' })),
286 // If the tab is either on the left or right, we additionally add a `min-height` of 1px
287 // in order to ensure that the element has a height before its state changes. This is
288 // necessary because Chrome does seem to skip the transition in RTL mode if the element does
289 // not have a static height and is not rendered. See related issue: #9465
290 state('left', style({ transform: 'translate3d(-100%, 0, 0)', minHeight: '1px' })),
291 state('right', style({ transform: 'translate3d(100%, 0, 0)', minHeight: '1px' })),
292 transition('* => left, * => right, left => center, right => center', animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)')),
293 transition('void => left-origin-center', [
294 style({ transform: 'translate3d(-100%, 0, 0)' }),
295 animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)')
296 ]),
297 transition('void => right-origin-center', [
298 style({ transform: 'translate3d(100%, 0, 0)' }),
299 animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)')
300 ])
301 ])
302};
303
304/**
305 * @license
306 * Copyright Google LLC All Rights Reserved.
307 *
308 * Use of this source code is governed by an MIT-style license that can be
309 * found in the LICENSE file at https://angular.io/license
310 */
311/**
312 * The portal host directive for the contents of the tab.
313 * @docs-private
314 */
315class MatTabBodyPortal extends CdkPortalOutlet {
316 constructor(componentFactoryResolver, viewContainerRef, _host, _document) {
317 super(componentFactoryResolver, viewContainerRef, _document);
318 this._host = _host;
319 /** Subscription to events for when the tab body begins centering. */
320 this._centeringSub = Subscription.EMPTY;
321 /** Subscription to events for when the tab body finishes leaving from center position. */
322 this._leavingSub = Subscription.EMPTY;
323 }
324 /** Set initial visibility or set up subscription for changing visibility. */
325 ngOnInit() {
326 super.ngOnInit();
327 this._centeringSub = this._host._beforeCentering
328 .pipe(startWith(this._host._isCenterPosition(this._host._position)))
329 .subscribe((isCentering) => {
330 if (isCentering && !this.hasAttached()) {
331 this.attach(this._host._content);
332 }
333 });
334 this._leavingSub = this._host._afterLeavingCenter.subscribe(() => {
335 this.detach();
336 });
337 }
338 /** Clean up centering subscription. */
339 ngOnDestroy() {
340 super.ngOnDestroy();
341 this._centeringSub.unsubscribe();
342 this._leavingSub.unsubscribe();
343 }
344}
345MatTabBodyPortal.decorators = [
346 { type: Directive, args: [{
347 selector: '[matTabBodyHost]'
348 },] }
349];
350MatTabBodyPortal.ctorParameters = () => [
351 { type: ComponentFactoryResolver },
352 { type: ViewContainerRef },
353 { type: MatTabBody, decorators: [{ type: Inject, args: [forwardRef(() => MatTabBody),] }] },
354 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
355];
356/**
357 * Base class with all of the `MatTabBody` functionality.
358 * @docs-private
359 */
360class _MatTabBodyBase {
361 constructor(_elementRef, _dir, changeDetectorRef) {
362 this._elementRef = _elementRef;
363 this._dir = _dir;
364 /** Subscription to the directionality change observable. */
365 this._dirChangeSubscription = Subscription.EMPTY;
366 /** Emits when an animation on the tab is complete. */
367 this._translateTabComplete = new Subject();
368 /** Event emitted when the tab begins to animate towards the center as the active tab. */
369 this._onCentering = new EventEmitter();
370 /** Event emitted before the centering of the tab begins. */
371 this._beforeCentering = new EventEmitter();
372 /** Event emitted before the centering of the tab begins. */
373 this._afterLeavingCenter = new EventEmitter();
374 /** Event emitted when the tab completes its animation towards the center. */
375 this._onCentered = new EventEmitter(true);
376 // Note that the default value will always be overwritten by `MatTabBody`, but we need one
377 // anyway to prevent the animations module from throwing an error if the body is used on its own.
378 /** Duration for the tab's animation. */
379 this.animationDuration = '500ms';
380 if (_dir) {
381 this._dirChangeSubscription = _dir.change.subscribe((dir) => {
382 this._computePositionAnimationState(dir);
383 changeDetectorRef.markForCheck();
384 });
385 }
386 // Ensure that we get unique animation events, because the `.done` callback can get
387 // invoked twice in some browsers. See https://github.com/angular/angular/issues/24084.
388 this._translateTabComplete.pipe(distinctUntilChanged((x, y) => {
389 return x.fromState === y.fromState && x.toState === y.toState;
390 })).subscribe(event => {
391 // If the transition to the center is complete, emit an event.
392 if (this._isCenterPosition(event.toState) && this._isCenterPosition(this._position)) {
393 this._onCentered.emit();
394 }
395 if (this._isCenterPosition(event.fromState) && !this._isCenterPosition(this._position)) {
396 this._afterLeavingCenter.emit();
397 }
398 });
399 }
400 /** The shifted index position of the tab body, where zero represents the active center tab. */
401 set position(position) {
402 this._positionIndex = position;
403 this._computePositionAnimationState();
404 }
405 /**
406 * After initialized, check if the content is centered and has an origin. If so, set the
407 * special position states that transition the tab from the left or right before centering.
408 */
409 ngOnInit() {
410 if (this._position == 'center' && this.origin != null) {
411 this._position = this._computePositionFromOrigin(this.origin);
412 }
413 }
414 ngOnDestroy() {
415 this._dirChangeSubscription.unsubscribe();
416 this._translateTabComplete.complete();
417 }
418 _onTranslateTabStarted(event) {
419 const isCentering = this._isCenterPosition(event.toState);
420 this._beforeCentering.emit(isCentering);
421 if (isCentering) {
422 this._onCentering.emit(this._elementRef.nativeElement.clientHeight);
423 }
424 }
425 /** The text direction of the containing app. */
426 _getLayoutDirection() {
427 return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
428 }
429 /** Whether the provided position state is considered center, regardless of origin. */
430 _isCenterPosition(position) {
431 return position == 'center' ||
432 position == 'left-origin-center' ||
433 position == 'right-origin-center';
434 }
435 /** Computes the position state that will be used for the tab-body animation trigger. */
436 _computePositionAnimationState(dir = this._getLayoutDirection()) {
437 if (this._positionIndex < 0) {
438 this._position = dir == 'ltr' ? 'left' : 'right';
439 }
440 else if (this._positionIndex > 0) {
441 this._position = dir == 'ltr' ? 'right' : 'left';
442 }
443 else {
444 this._position = 'center';
445 }
446 }
447 /**
448 * Computes the position state based on the specified origin position. This is used if the
449 * tab is becoming visible immediately after creation.
450 */
451 _computePositionFromOrigin(origin) {
452 const dir = this._getLayoutDirection();
453 if ((dir == 'ltr' && origin <= 0) || (dir == 'rtl' && origin > 0)) {
454 return 'left-origin-center';
455 }
456 return 'right-origin-center';
457 }
458}
459_MatTabBodyBase.decorators = [
460 { type: Directive }
461];
462_MatTabBodyBase.ctorParameters = () => [
463 { type: ElementRef },
464 { type: Directionality, decorators: [{ type: Optional }] },
465 { type: ChangeDetectorRef }
466];
467_MatTabBodyBase.propDecorators = {
468 _onCentering: [{ type: Output }],
469 _beforeCentering: [{ type: Output }],
470 _afterLeavingCenter: [{ type: Output }],
471 _onCentered: [{ type: Output }],
472 _content: [{ type: Input, args: ['content',] }],
473 origin: [{ type: Input }],
474 animationDuration: [{ type: Input }],
475 position: [{ type: Input }]
476};
477/**
478 * Wrapper for the contents of a tab.
479 * @docs-private
480 */
481class MatTabBody extends _MatTabBodyBase {
482 constructor(elementRef, dir, changeDetectorRef) {
483 super(elementRef, dir, changeDetectorRef);
484 }
485}
486MatTabBody.decorators = [
487 { type: Component, args: [{
488 selector: 'mat-tab-body',
489 template: "<div class=\"mat-tab-body-content\" #content\n [@translateTab]=\"{\n value: _position,\n params: {animationDuration: animationDuration}\n }\"\n (@translateTab.start)=\"_onTranslateTabStarted($event)\"\n (@translateTab.done)=\"_translateTabComplete.next($event)\"\n cdkScrollable>\n <ng-template matTabBodyHost></ng-template>\n</div>\n",
490 encapsulation: ViewEncapsulation.None,
491 // tslint:disable-next-line:validate-decorators
492 changeDetection: ChangeDetectionStrategy.Default,
493 animations: [matTabsAnimations.translateTab],
494 host: {
495 'class': 'mat-tab-body',
496 },
497 styles: [".mat-tab-body-content{height:100%;overflow:auto}.mat-tab-group-dynamic-height .mat-tab-body-content{overflow:hidden}\n"]
498 },] }
499];
500MatTabBody.ctorParameters = () => [
501 { type: ElementRef },
502 { type: Directionality, decorators: [{ type: Optional }] },
503 { type: ChangeDetectorRef }
504];
505MatTabBody.propDecorators = {
506 _portalHost: [{ type: ViewChild, args: [CdkPortalOutlet,] }]
507};
508
509/**
510 * @license
511 * Copyright Google LLC All Rights Reserved.
512 *
513 * Use of this source code is governed by an MIT-style license that can be
514 * found in the LICENSE file at https://angular.io/license
515 */
516/** Injection token that can be used to provide the default options the tabs module. */
517const MAT_TABS_CONFIG = new InjectionToken('MAT_TABS_CONFIG');
518
519/**
520 * @license
521 * Copyright Google LLC All Rights Reserved.
522 *
523 * Use of this source code is governed by an MIT-style license that can be
524 * found in the LICENSE file at https://angular.io/license
525 */
526/** Used to generate unique ID's for each tab component */
527let nextId = 0;
528/** A simple change event emitted on focus or selection changes. */
529class MatTabChangeEvent {
530}
531// Boilerplate for applying mixins to MatTabGroup.
532/** @docs-private */
533const _MatTabGroupMixinBase = mixinColor(mixinDisableRipple(class {
534 constructor(_elementRef) {
535 this._elementRef = _elementRef;
536 }
537}), 'primary');
538/**
539 * Base class with all of the `MatTabGroupBase` functionality.
540 * @docs-private
541 */
542class _MatTabGroupBase extends _MatTabGroupMixinBase {
543 constructor(elementRef, _changeDetectorRef, defaultConfig, _animationMode) {
544 var _a;
545 super(elementRef);
546 this._changeDetectorRef = _changeDetectorRef;
547 this._animationMode = _animationMode;
548 /** All of the tabs that belong to the group. */
549 this._tabs = new QueryList();
550 /** The tab index that should be selected after the content has been checked. */
551 this._indexToSelect = 0;
552 /** Snapshot of the height of the tab body wrapper before another tab is activated. */
553 this._tabBodyWrapperHeight = 0;
554 /** Subscription to tabs being added/removed. */
555 this._tabsSubscription = Subscription.EMPTY;
556 /** Subscription to changes in the tab labels. */
557 this._tabLabelSubscription = Subscription.EMPTY;
558 this._selectedIndex = null;
559 /** Position of the tab header. */
560 this.headerPosition = 'above';
561 /** Output to enable support for two-way binding on `[(selectedIndex)]` */
562 this.selectedIndexChange = new EventEmitter();
563 /** Event emitted when focus has changed within a tab group. */
564 this.focusChange = new EventEmitter();
565 /** Event emitted when the body animation has completed */
566 this.animationDone = new EventEmitter();
567 /** Event emitted when the tab selection has changed. */
568 this.selectedTabChange = new EventEmitter(true);
569 this._groupId = nextId++;
570 this.animationDuration = defaultConfig && defaultConfig.animationDuration ?
571 defaultConfig.animationDuration : '500ms';
572 this.disablePagination = defaultConfig && defaultConfig.disablePagination != null ?
573 defaultConfig.disablePagination : false;
574 this.dynamicHeight = defaultConfig && defaultConfig.dynamicHeight != null ?
575 defaultConfig.dynamicHeight : false;
576 this.contentTabIndex = (_a = defaultConfig === null || defaultConfig === void 0 ? void 0 : defaultConfig.contentTabIndex) !== null && _a !== void 0 ? _a : null;
577 }
578 /** Whether the tab group should grow to the size of the active tab. */
579 get dynamicHeight() { return this._dynamicHeight; }
580 set dynamicHeight(value) { this._dynamicHeight = coerceBooleanProperty(value); }
581 /** The index of the active tab. */
582 get selectedIndex() { return this._selectedIndex; }
583 set selectedIndex(value) {
584 this._indexToSelect = coerceNumberProperty(value, null);
585 }
586 /** Duration for the tab animation. Will be normalized to milliseconds if no units are set. */
587 get animationDuration() { return this._animationDuration; }
588 set animationDuration(value) {
589 this._animationDuration = /^\d+$/.test(value) ? value + 'ms' : value;
590 }
591 /**
592 * `tabindex` to be set on the inner element that wraps the tab content. Can be used for improved
593 * accessibility when the tab does not have focusable elements or if it has scrollable content.
594 * The `tabindex` will be removed automatically for inactive tabs.
595 * Read more at https://www.w3.org/TR/wai-aria-practices/examples/tabs/tabs-2/tabs.html
596 */
597 get contentTabIndex() { return this._contentTabIndex; }
598 set contentTabIndex(value) {
599 this._contentTabIndex = coerceNumberProperty(value, null);
600 }
601 /** Background color of the tab group. */
602 get backgroundColor() { return this._backgroundColor; }
603 set backgroundColor(value) {
604 const nativeElement = this._elementRef.nativeElement;
605 nativeElement.classList.remove(`mat-background-${this.backgroundColor}`);
606 if (value) {
607 nativeElement.classList.add(`mat-background-${value}`);
608 }
609 this._backgroundColor = value;
610 }
611 /**
612 * After the content is checked, this component knows what tabs have been defined
613 * and what the selected index should be. This is where we can know exactly what position
614 * each tab should be in according to the new selected index, and additionally we know how
615 * a new selected tab should transition in (from the left or right).
616 */
617 ngAfterContentChecked() {
618 // Don't clamp the `indexToSelect` immediately in the setter because it can happen that
619 // the amount of tabs changes before the actual change detection runs.
620 const indexToSelect = this._indexToSelect = this._clampTabIndex(this._indexToSelect);
621 // If there is a change in selected index, emit a change event. Should not trigger if
622 // the selected index has not yet been initialized.
623 if (this._selectedIndex != indexToSelect) {
624 const isFirstRun = this._selectedIndex == null;
625 if (!isFirstRun) {
626 this.selectedTabChange.emit(this._createChangeEvent(indexToSelect));
627 // Preserve the height so page doesn't scroll up during tab change.
628 // Fixes https://stackblitz.com/edit/mat-tabs-scroll-page-top-on-tab-change
629 const wrapper = this._tabBodyWrapper.nativeElement;
630 wrapper.style.minHeight = wrapper.clientHeight + 'px';
631 }
632 // Changing these values after change detection has run
633 // since the checked content may contain references to them.
634 Promise.resolve().then(() => {
635 this._tabs.forEach((tab, index) => tab.isActive = index === indexToSelect);
636 if (!isFirstRun) {
637 this.selectedIndexChange.emit(indexToSelect);
638 // Clear the min-height, this was needed during tab change to avoid
639 // unnecessary scrolling.
640 this._tabBodyWrapper.nativeElement.style.minHeight = '';
641 }
642 });
643 }
644 // Setup the position for each tab and optionally setup an origin on the next selected tab.
645 this._tabs.forEach((tab, index) => {
646 tab.position = index - indexToSelect;
647 // If there is already a selected tab, then set up an origin for the next selected tab
648 // if it doesn't have one already.
649 if (this._selectedIndex != null && tab.position == 0 && !tab.origin) {
650 tab.origin = indexToSelect - this._selectedIndex;
651 }
652 });
653 if (this._selectedIndex !== indexToSelect) {
654 this._selectedIndex = indexToSelect;
655 this._changeDetectorRef.markForCheck();
656 }
657 }
658 ngAfterContentInit() {
659 this._subscribeToAllTabChanges();
660 this._subscribeToTabLabels();
661 // Subscribe to changes in the amount of tabs, in order to be
662 // able to re-render the content as new tabs are added or removed.
663 this._tabsSubscription = this._tabs.changes.subscribe(() => {
664 const indexToSelect = this._clampTabIndex(this._indexToSelect);
665 // Maintain the previously-selected tab if a new tab is added or removed and there is no
666 // explicit change that selects a different tab.
667 if (indexToSelect === this._selectedIndex) {
668 const tabs = this._tabs.toArray();
669 for (let i = 0; i < tabs.length; i++) {
670 if (tabs[i].isActive) {
671 // Assign both to the `_indexToSelect` and `_selectedIndex` so we don't fire a changed
672 // event, otherwise the consumer may end up in an infinite loop in some edge cases like
673 // adding a tab within the `selectedIndexChange` event.
674 this._indexToSelect = this._selectedIndex = i;
675 break;
676 }
677 }
678 }
679 this._changeDetectorRef.markForCheck();
680 });
681 }
682 /** Listens to changes in all of the tabs. */
683 _subscribeToAllTabChanges() {
684 // Since we use a query with `descendants: true` to pick up the tabs, we may end up catching
685 // some that are inside of nested tab groups. We filter them out manually by checking that
686 // the closest group to the tab is the current one.
687 this._allTabs.changes
688 .pipe(startWith(this._allTabs))
689 .subscribe((tabs) => {
690 this._tabs.reset(tabs.filter(tab => {
691 return tab._closestTabGroup === this || !tab._closestTabGroup;
692 }));
693 this._tabs.notifyOnChanges();
694 });
695 }
696 ngOnDestroy() {
697 this._tabs.destroy();
698 this._tabsSubscription.unsubscribe();
699 this._tabLabelSubscription.unsubscribe();
700 }
701 /** Re-aligns the ink bar to the selected tab element. */
702 realignInkBar() {
703 if (this._tabHeader) {
704 this._tabHeader._alignInkBarToSelectedTab();
705 }
706 }
707 /**
708 * Sets focus to a particular tab.
709 * @param index Index of the tab to be focused.
710 */
711 focusTab(index) {
712 const header = this._tabHeader;
713 if (header) {
714 header.focusIndex = index;
715 }
716 }
717 _focusChanged(index) {
718 this.focusChange.emit(this._createChangeEvent(index));
719 }
720 _createChangeEvent(index) {
721 const event = new MatTabChangeEvent;
722 event.index = index;
723 if (this._tabs && this._tabs.length) {
724 event.tab = this._tabs.toArray()[index];
725 }
726 return event;
727 }
728 /**
729 * Subscribes to changes in the tab labels. This is needed, because the @Input for the label is
730 * on the MatTab component, whereas the data binding is inside the MatTabGroup. In order for the
731 * binding to be updated, we need to subscribe to changes in it and trigger change detection
732 * manually.
733 */
734 _subscribeToTabLabels() {
735 if (this._tabLabelSubscription) {
736 this._tabLabelSubscription.unsubscribe();
737 }
738 this._tabLabelSubscription = merge(...this._tabs.map(tab => tab._stateChanges))
739 .subscribe(() => this._changeDetectorRef.markForCheck());
740 }
741 /** Clamps the given index to the bounds of 0 and the tabs length. */
742 _clampTabIndex(index) {
743 // Note the `|| 0`, which ensures that values like NaN can't get through
744 // and which would otherwise throw the component into an infinite loop
745 // (since Math.max(NaN, 0) === NaN).
746 return Math.min(this._tabs.length - 1, Math.max(index || 0, 0));
747 }
748 /** Returns a unique id for each tab label element */
749 _getTabLabelId(i) {
750 return `mat-tab-label-${this._groupId}-${i}`;
751 }
752 /** Returns a unique id for each tab content element */
753 _getTabContentId(i) {
754 return `mat-tab-content-${this._groupId}-${i}`;
755 }
756 /**
757 * Sets the height of the body wrapper to the height of the activating tab if dynamic
758 * height property is true.
759 */
760 _setTabBodyWrapperHeight(tabHeight) {
761 if (!this._dynamicHeight || !this._tabBodyWrapperHeight) {
762 return;
763 }
764 const wrapper = this._tabBodyWrapper.nativeElement;
765 wrapper.style.height = this._tabBodyWrapperHeight + 'px';
766 // This conditional forces the browser to paint the height so that
767 // the animation to the new height can have an origin.
768 if (this._tabBodyWrapper.nativeElement.offsetHeight) {
769 wrapper.style.height = tabHeight + 'px';
770 }
771 }
772 /** Removes the height of the tab body wrapper. */
773 _removeTabBodyWrapperHeight() {
774 const wrapper = this._tabBodyWrapper.nativeElement;
775 this._tabBodyWrapperHeight = wrapper.clientHeight;
776 wrapper.style.height = '';
777 this.animationDone.emit();
778 }
779 /** Handle click events, setting new selected index if appropriate. */
780 _handleClick(tab, tabHeader, index) {
781 if (!tab.disabled) {
782 this.selectedIndex = tabHeader.focusIndex = index;
783 }
784 }
785 /** Retrieves the tabindex for the tab. */
786 _getTabIndex(tab, idx) {
787 if (tab.disabled) {
788 return null;
789 }
790 return this.selectedIndex === idx ? 0 : -1;
791 }
792 /** Callback for when the focused state of a tab has changed. */
793 _tabFocusChanged(focusOrigin, index) {
794 // Mouse/touch focus happens during the `mousedown`/`touchstart` phase which
795 // can cause the tab to be moved out from under the pointer, interrupting the
796 // click sequence (see #21898). We don't need to scroll the tab into view for
797 // such cases anyway, because it will be done when the tab becomes selected.
798 if (focusOrigin && focusOrigin !== 'mouse' && focusOrigin !== 'touch') {
799 this._tabHeader.focusIndex = index;
800 }
801 }
802}
803_MatTabGroupBase.decorators = [
804 { type: Directive }
805];
806_MatTabGroupBase.ctorParameters = () => [
807 { type: ElementRef },
808 { type: ChangeDetectorRef },
809 { type: undefined, decorators: [{ type: Inject, args: [MAT_TABS_CONFIG,] }, { type: Optional }] },
810 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
811];
812_MatTabGroupBase.propDecorators = {
813 dynamicHeight: [{ type: Input }],
814 selectedIndex: [{ type: Input }],
815 headerPosition: [{ type: Input }],
816 animationDuration: [{ type: Input }],
817 contentTabIndex: [{ type: Input }],
818 disablePagination: [{ type: Input }],
819 backgroundColor: [{ type: Input }],
820 selectedIndexChange: [{ type: Output }],
821 focusChange: [{ type: Output }],
822 animationDone: [{ type: Output }],
823 selectedTabChange: [{ type: Output }]
824};
825/**
826 * Material design tab-group component. Supports basic tab pairs (label + content) and includes
827 * animated ink-bar, keyboard navigation, and screen reader.
828 * See: https://material.io/design/components/tabs.html
829 */
830class MatTabGroup extends _MatTabGroupBase {
831 constructor(elementRef, changeDetectorRef, defaultConfig, animationMode) {
832 super(elementRef, changeDetectorRef, defaultConfig, animationMode);
833 }
834}
835MatTabGroup.decorators = [
836 { type: Component, args: [{
837 selector: 'mat-tab-group',
838 exportAs: 'matTabGroup',
839 template: "<mat-tab-header #tabHeader\n [selectedIndex]=\"selectedIndex || 0\"\n [disableRipple]=\"disableRipple\"\n [disablePagination]=\"disablePagination\"\n (indexFocused)=\"_focusChanged($event)\"\n (selectFocusedIndex)=\"selectedIndex = $event\">\n <div class=\"mat-tab-label mat-focus-indicator\" role=\"tab\" matTabLabelWrapper mat-ripple cdkMonitorElementFocus\n *ngFor=\"let tab of _tabs; let i = index\"\n [id]=\"_getTabLabelId(i)\"\n [attr.tabIndex]=\"_getTabIndex(tab, i)\"\n [attr.aria-posinset]=\"i + 1\"\n [attr.aria-setsize]=\"_tabs.length\"\n [attr.aria-controls]=\"_getTabContentId(i)\"\n [attr.aria-selected]=\"selectedIndex == i\"\n [attr.aria-label]=\"tab.ariaLabel || null\"\n [attr.aria-labelledby]=\"(!tab.ariaLabel && tab.ariaLabelledby) ? tab.ariaLabelledby : null\"\n [class.mat-tab-label-active]=\"selectedIndex == i\"\n [disabled]=\"tab.disabled\"\n [matRippleDisabled]=\"tab.disabled || disableRipple\"\n (click)=\"_handleClick(tab, tabHeader, i)\"\n (cdkFocusChange)=\"_tabFocusChanged($event, i)\">\n\n\n <div class=\"mat-tab-label-content\">\n <!-- If there is a label template, use it. -->\n <ng-template [ngIf]=\"tab.templateLabel\">\n <ng-template [cdkPortalOutlet]=\"tab.templateLabel\"></ng-template>\n </ng-template>\n\n <!-- If there is not a label template, fall back to the text label. -->\n <ng-template [ngIf]=\"!tab.templateLabel\">{{tab.textLabel}}</ng-template>\n </div>\n </div>\n</mat-tab-header>\n\n<div\n class=\"mat-tab-body-wrapper\"\n [class._mat-animation-noopable]=\"_animationMode === 'NoopAnimations'\"\n #tabBodyWrapper>\n <mat-tab-body role=\"tabpanel\"\n *ngFor=\"let tab of _tabs; let i = index\"\n [id]=\"_getTabContentId(i)\"\n [attr.tabindex]=\"(contentTabIndex != null && selectedIndex === i) ? contentTabIndex : null\"\n [attr.aria-labelledby]=\"_getTabLabelId(i)\"\n [class.mat-tab-body-active]=\"selectedIndex === i\"\n [content]=\"tab.content!\"\n [position]=\"tab.position!\"\n [origin]=\"tab.origin\"\n [animationDuration]=\"animationDuration\"\n (_onCentered)=\"_removeTabBodyWrapperHeight()\"\n (_onCentering)=\"_setTabBodyWrapperHeight($event)\">\n </mat-tab-body>\n</div>\n",
840 encapsulation: ViewEncapsulation.None,
841 // tslint:disable-next-line:validate-decorators
842 changeDetection: ChangeDetectionStrategy.Default,
843 inputs: ['color', 'disableRipple'],
844 providers: [{
845 provide: MAT_TAB_GROUP,
846 useExisting: MatTabGroup
847 }],
848 host: {
849 'class': 'mat-tab-group',
850 '[class.mat-tab-group-dynamic-height]': 'dynamicHeight',
851 '[class.mat-tab-group-inverted-header]': 'headerPosition === "below"',
852 },
853 styles: [".mat-tab-group{display:flex;flex-direction:column;max-width:100%}.mat-tab-group.mat-tab-group-inverted-header{flex-direction:column-reverse}.mat-tab-label{height:48px;padding:0 24px;cursor:pointer;box-sizing:border-box;opacity:.6;min-width:160px;text-align:center;display:inline-flex;justify-content:center;align-items:center;white-space:nowrap;position:relative}.mat-tab-label:focus{outline:none}.mat-tab-label:focus:not(.mat-tab-disabled){opacity:1}.cdk-high-contrast-active .mat-tab-label:focus{outline:dotted 2px;outline-offset:-2px}.mat-tab-label.mat-tab-disabled{cursor:default}.cdk-high-contrast-active .mat-tab-label.mat-tab-disabled{opacity:.5}.mat-tab-label .mat-tab-label-content{display:inline-flex;justify-content:center;align-items:center;white-space:nowrap}.cdk-high-contrast-active .mat-tab-label{opacity:1}@media(max-width: 599px){.mat-tab-label{padding:0 12px}}@media(max-width: 959px){.mat-tab-label{padding:0 12px}}.mat-tab-group[mat-stretch-tabs]>.mat-tab-header .mat-tab-label{flex-basis:0;flex-grow:1}.mat-tab-body-wrapper{position:relative;overflow:hidden;display:flex;transition:height 500ms cubic-bezier(0.35, 0, 0.25, 1)}._mat-animation-noopable.mat-tab-body-wrapper{transition:none;animation:none}.mat-tab-body{top:0;left:0;right:0;bottom:0;position:absolute;display:block;overflow:hidden;outline:0;flex-basis:100%}.mat-tab-body.mat-tab-body-active{position:relative;overflow-x:hidden;overflow-y:auto;z-index:1;flex-grow:1}.mat-tab-group.mat-tab-group-dynamic-height .mat-tab-body.mat-tab-body-active{overflow-y:hidden}\n"]
854 },] }
855];
856MatTabGroup.ctorParameters = () => [
857 { type: ElementRef },
858 { type: ChangeDetectorRef },
859 { type: undefined, decorators: [{ type: Inject, args: [MAT_TABS_CONFIG,] }, { type: Optional }] },
860 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
861];
862MatTabGroup.propDecorators = {
863 _allTabs: [{ type: ContentChildren, args: [MatTab, { descendants: true },] }],
864 _tabBodyWrapper: [{ type: ViewChild, args: ['tabBodyWrapper',] }],
865 _tabHeader: [{ type: ViewChild, args: ['tabHeader',] }]
866};
867
868/**
869 * @license
870 * Copyright Google LLC All Rights Reserved.
871 *
872 * Use of this source code is governed by an MIT-style license that can be
873 * found in the LICENSE file at https://angular.io/license
874 */
875// Boilerplate for applying mixins to MatTabLabelWrapper.
876/** @docs-private */
877const _MatTabLabelWrapperBase = mixinDisabled(class {
878});
879/**
880 * Used in the `mat-tab-group` view to display tab labels.
881 * @docs-private
882 */
883class MatTabLabelWrapper extends _MatTabLabelWrapperBase {
884 constructor(elementRef) {
885 super();
886 this.elementRef = elementRef;
887 }
888 /** Sets focus on the wrapper element */
889 focus() {
890 this.elementRef.nativeElement.focus();
891 }
892 getOffsetLeft() {
893 return this.elementRef.nativeElement.offsetLeft;
894 }
895 getOffsetWidth() {
896 return this.elementRef.nativeElement.offsetWidth;
897 }
898}
899MatTabLabelWrapper.decorators = [
900 { type: Directive, args: [{
901 selector: '[matTabLabelWrapper]',
902 inputs: ['disabled'],
903 host: {
904 '[class.mat-tab-disabled]': 'disabled',
905 '[attr.aria-disabled]': '!!disabled',
906 }
907 },] }
908];
909MatTabLabelWrapper.ctorParameters = () => [
910 { type: ElementRef }
911];
912
913/**
914 * @license
915 * Copyright Google LLC All Rights Reserved.
916 *
917 * Use of this source code is governed by an MIT-style license that can be
918 * found in the LICENSE file at https://angular.io/license
919 */
920/** Config used to bind passive event listeners */
921const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
922/**
923 * The distance in pixels that will be overshot when scrolling a tab label into view. This helps
924 * provide a small affordance to the label next to it.
925 */
926const EXAGGERATED_OVERSCROLL = 60;
927/**
928 * Amount of milliseconds to wait before starting to scroll the header automatically.
929 * Set a little conservatively in order to handle fake events dispatched on touch devices.
930 */
931const HEADER_SCROLL_DELAY = 650;
932/**
933 * Interval in milliseconds at which to scroll the header
934 * while the user is holding their pointer.
935 */
936const HEADER_SCROLL_INTERVAL = 100;
937/**
938 * Base class for a tab header that supported pagination.
939 * @docs-private
940 */
941class MatPaginatedTabHeader {
942 constructor(_elementRef, _changeDetectorRef, _viewportRuler, _dir, _ngZone, _platform, _animationMode) {
943 this._elementRef = _elementRef;
944 this._changeDetectorRef = _changeDetectorRef;
945 this._viewportRuler = _viewportRuler;
946 this._dir = _dir;
947 this._ngZone = _ngZone;
948 this._platform = _platform;
949 this._animationMode = _animationMode;
950 /** The distance in pixels that the tab labels should be translated to the left. */
951 this._scrollDistance = 0;
952 /** Whether the header should scroll to the selected index after the view has been checked. */
953 this._selectedIndexChanged = false;
954 /** Emits when the component is destroyed. */
955 this._destroyed = new Subject();
956 /** Whether the controls for pagination should be displayed */
957 this._showPaginationControls = false;
958 /** Whether the tab list can be scrolled more towards the end of the tab label list. */
959 this._disableScrollAfter = true;
960 /** Whether the tab list can be scrolled more towards the beginning of the tab label list. */
961 this._disableScrollBefore = true;
962 /** Stream that will stop the automated scrolling. */
963 this._stopScrolling = new Subject();
964 /**
965 * Whether pagination should be disabled. This can be used to avoid unnecessary
966 * layout recalculations if it's known that pagination won't be required.
967 */
968 this.disablePagination = false;
969 this._selectedIndex = 0;
970 /** Event emitted when the option is selected. */
971 this.selectFocusedIndex = new EventEmitter();
972 /** Event emitted when a label is focused. */
973 this.indexFocused = new EventEmitter();
974 // Bind the `mouseleave` event on the outside since it doesn't change anything in the view.
975 _ngZone.runOutsideAngular(() => {
976 fromEvent(_elementRef.nativeElement, 'mouseleave')
977 .pipe(takeUntil(this._destroyed))
978 .subscribe(() => {
979 this._stopInterval();
980 });
981 });
982 }
983 /** The index of the active tab. */
984 get selectedIndex() { return this._selectedIndex; }
985 set selectedIndex(value) {
986 value = coerceNumberProperty(value);
987 if (this._selectedIndex != value) {
988 this._selectedIndexChanged = true;
989 this._selectedIndex = value;
990 if (this._keyManager) {
991 this._keyManager.updateActiveItem(value);
992 }
993 }
994 }
995 ngAfterViewInit() {
996 // We need to handle these events manually, because we want to bind passive event listeners.
997 fromEvent(this._previousPaginator.nativeElement, 'touchstart', passiveEventListenerOptions)
998 .pipe(takeUntil(this._destroyed))
999 .subscribe(() => {
1000 this._handlePaginatorPress('before');
1001 });
1002 fromEvent(this._nextPaginator.nativeElement, 'touchstart', passiveEventListenerOptions)
1003 .pipe(takeUntil(this._destroyed))
1004 .subscribe(() => {
1005 this._handlePaginatorPress('after');
1006 });
1007 }
1008 ngAfterContentInit() {
1009 const dirChange = this._dir ? this._dir.change : of('ltr');
1010 const resize = this._viewportRuler.change(150);
1011 const realign = () => {
1012 this.updatePagination();
1013 this._alignInkBarToSelectedTab();
1014 };
1015 this._keyManager = new FocusKeyManager(this._items)
1016 .withHorizontalOrientation(this._getLayoutDirection())
1017 .withHomeAndEnd()
1018 .withWrap();
1019 this._keyManager.updateActiveItem(this._selectedIndex);
1020 // Defer the first call in order to allow for slower browsers to lay out the elements.
1021 // This helps in cases where the user lands directly on a page with paginated tabs.
1022 typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame(realign) : realign();
1023 // On dir change or window resize, realign the ink bar and update the orientation of
1024 // the key manager if the direction has changed.
1025 merge(dirChange, resize, this._items.changes).pipe(takeUntil(this._destroyed)).subscribe(() => {
1026 // We need to defer this to give the browser some time to recalculate
1027 // the element dimensions. The call has to be wrapped in `NgZone.run`,
1028 // because the viewport change handler runs outside of Angular.
1029 this._ngZone.run(() => Promise.resolve().then(realign));
1030 this._keyManager.withHorizontalOrientation(this._getLayoutDirection());
1031 });
1032 // If there is a change in the focus key manager we need to emit the `indexFocused`
1033 // event in order to provide a public event that notifies about focus changes. Also we realign
1034 // the tabs container by scrolling the new focused tab into the visible section.
1035 this._keyManager.change.pipe(takeUntil(this._destroyed)).subscribe(newFocusIndex => {
1036 this.indexFocused.emit(newFocusIndex);
1037 this._setTabFocus(newFocusIndex);
1038 });
1039 }
1040 ngAfterContentChecked() {
1041 // If the number of tab labels have changed, check if scrolling should be enabled
1042 if (this._tabLabelCount != this._items.length) {
1043 this.updatePagination();
1044 this._tabLabelCount = this._items.length;
1045 this._changeDetectorRef.markForCheck();
1046 }
1047 // If the selected index has changed, scroll to the label and check if the scrolling controls
1048 // should be disabled.
1049 if (this._selectedIndexChanged) {
1050 this._scrollToLabel(this._selectedIndex);
1051 this._checkScrollingControls();
1052 this._alignInkBarToSelectedTab();
1053 this._selectedIndexChanged = false;
1054 this._changeDetectorRef.markForCheck();
1055 }
1056 // If the scroll distance has been changed (tab selected, focused, scroll controls activated),
1057 // then translate the header to reflect this.
1058 if (this._scrollDistanceChanged) {
1059 this._updateTabScrollPosition();
1060 this._scrollDistanceChanged = false;
1061 this._changeDetectorRef.markForCheck();
1062 }
1063 }
1064 ngOnDestroy() {
1065 this._destroyed.next();
1066 this._destroyed.complete();
1067 this._stopScrolling.complete();
1068 }
1069 /** Handles keyboard events on the header. */
1070 _handleKeydown(event) {
1071 // We don't handle any key bindings with a modifier key.
1072 if (hasModifierKey(event)) {
1073 return;
1074 }
1075 switch (event.keyCode) {
1076 case ENTER:
1077 case SPACE:
1078 if (this.focusIndex !== this.selectedIndex) {
1079 this.selectFocusedIndex.emit(this.focusIndex);
1080 this._itemSelected(event);
1081 }
1082 break;
1083 default:
1084 this._keyManager.onKeydown(event);
1085 }
1086 }
1087 /**
1088 * Callback for when the MutationObserver detects that the content has changed.
1089 */
1090 _onContentChanges() {
1091 const textContent = this._elementRef.nativeElement.textContent;
1092 // We need to diff the text content of the header, because the MutationObserver callback
1093 // will fire even if the text content didn't change which is inefficient and is prone
1094 // to infinite loops if a poorly constructed expression is passed in (see #14249).
1095 if (textContent !== this._currentTextContent) {
1096 this._currentTextContent = textContent || '';
1097 // The content observer runs outside the `NgZone` by default, which
1098 // means that we need to bring the callback back in ourselves.
1099 this._ngZone.run(() => {
1100 this.updatePagination();
1101 this._alignInkBarToSelectedTab();
1102 this._changeDetectorRef.markForCheck();
1103 });
1104 }
1105 }
1106 /**
1107 * Updates the view whether pagination should be enabled or not.
1108 *
1109 * WARNING: Calling this method can be very costly in terms of performance. It should be called
1110 * as infrequently as possible from outside of the Tabs component as it causes a reflow of the
1111 * page.
1112 */
1113 updatePagination() {
1114 this._checkPaginationEnabled();
1115 this._checkScrollingControls();
1116 this._updateTabScrollPosition();
1117 }
1118 /** Tracks which element has focus; used for keyboard navigation */
1119 get focusIndex() {
1120 return this._keyManager ? this._keyManager.activeItemIndex : 0;
1121 }
1122 /** When the focus index is set, we must manually send focus to the correct label */
1123 set focusIndex(value) {
1124 if (!this._isValidIndex(value) || this.focusIndex === value || !this._keyManager) {
1125 return;
1126 }
1127 this._keyManager.setActiveItem(value);
1128 }
1129 /**
1130 * Determines if an index is valid. If the tabs are not ready yet, we assume that the user is
1131 * providing a valid index and return true.
1132 */
1133 _isValidIndex(index) {
1134 if (!this._items) {
1135 return true;
1136 }
1137 const tab = this._items ? this._items.toArray()[index] : null;
1138 return !!tab && !tab.disabled;
1139 }
1140 /**
1141 * Sets focus on the HTML element for the label wrapper and scrolls it into the view if
1142 * scrolling is enabled.
1143 */
1144 _setTabFocus(tabIndex) {
1145 if (this._showPaginationControls) {
1146 this._scrollToLabel(tabIndex);
1147 }
1148 if (this._items && this._items.length) {
1149 this._items.toArray()[tabIndex].focus();
1150 // Do not let the browser manage scrolling to focus the element, this will be handled
1151 // by using translation. In LTR, the scroll left should be 0. In RTL, the scroll width
1152 // should be the full width minus the offset width.
1153 const containerEl = this._tabListContainer.nativeElement;
1154 const dir = this._getLayoutDirection();
1155 if (dir == 'ltr') {
1156 containerEl.scrollLeft = 0;
1157 }
1158 else {
1159 containerEl.scrollLeft = containerEl.scrollWidth - containerEl.offsetWidth;
1160 }
1161 }
1162 }
1163 /** The layout direction of the containing app. */
1164 _getLayoutDirection() {
1165 return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
1166 }
1167 /** Performs the CSS transformation on the tab list that will cause the list to scroll. */
1168 _updateTabScrollPosition() {
1169 if (this.disablePagination) {
1170 return;
1171 }
1172 const scrollDistance = this.scrollDistance;
1173 const translateX = this._getLayoutDirection() === 'ltr' ? -scrollDistance : scrollDistance;
1174 // Don't use `translate3d` here because we don't want to create a new layer. A new layer
1175 // seems to cause flickering and overflow in Internet Explorer. For example, the ink bar
1176 // and ripples will exceed the boundaries of the visible tab bar.
1177 // See: https://github.com/angular/components/issues/10276
1178 // We round the `transform` here, because transforms with sub-pixel precision cause some
1179 // browsers to blur the content of the element.
1180 this._tabList.nativeElement.style.transform = `translateX(${Math.round(translateX)}px)`;
1181 // Setting the `transform` on IE will change the scroll offset of the parent, causing the
1182 // position to be thrown off in some cases. We have to reset it ourselves to ensure that
1183 // it doesn't get thrown off. Note that we scope it only to IE and Edge, because messing
1184 // with the scroll position throws off Chrome 71+ in RTL mode (see #14689).
1185 if (this._platform.TRIDENT || this._platform.EDGE) {
1186 this._tabListContainer.nativeElement.scrollLeft = 0;
1187 }
1188 }
1189 /** Sets the distance in pixels that the tab header should be transformed in the X-axis. */
1190 get scrollDistance() { return this._scrollDistance; }
1191 set scrollDistance(value) {
1192 this._scrollTo(value);
1193 }
1194 /**
1195 * Moves the tab list in the 'before' or 'after' direction (towards the beginning of the list or
1196 * the end of the list, respectively). The distance to scroll is computed to be a third of the
1197 * length of the tab list view window.
1198 *
1199 * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
1200 * should be called sparingly.
1201 */
1202 _scrollHeader(direction) {
1203 const viewLength = this._tabListContainer.nativeElement.offsetWidth;
1204 // Move the scroll distance one-third the length of the tab list's viewport.
1205 const scrollAmount = (direction == 'before' ? -1 : 1) * viewLength / 3;
1206 return this._scrollTo(this._scrollDistance + scrollAmount);
1207 }
1208 /** Handles click events on the pagination arrows. */
1209 _handlePaginatorClick(direction) {
1210 this._stopInterval();
1211 this._scrollHeader(direction);
1212 }
1213 /**
1214 * Moves the tab list such that the desired tab label (marked by index) is moved into view.
1215 *
1216 * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
1217 * should be called sparingly.
1218 */
1219 _scrollToLabel(labelIndex) {
1220 if (this.disablePagination) {
1221 return;
1222 }
1223 const selectedLabel = this._items ? this._items.toArray()[labelIndex] : null;
1224 if (!selectedLabel) {
1225 return;
1226 }
1227 // The view length is the visible width of the tab labels.
1228 const viewLength = this._tabListContainer.nativeElement.offsetWidth;
1229 const { offsetLeft, offsetWidth } = selectedLabel.elementRef.nativeElement;
1230 let labelBeforePos, labelAfterPos;
1231 if (this._getLayoutDirection() == 'ltr') {
1232 labelBeforePos = offsetLeft;
1233 labelAfterPos = labelBeforePos + offsetWidth;
1234 }
1235 else {
1236 labelAfterPos = this._tabList.nativeElement.offsetWidth - offsetLeft;
1237 labelBeforePos = labelAfterPos - offsetWidth;
1238 }
1239 const beforeVisiblePos = this.scrollDistance;
1240 const afterVisiblePos = this.scrollDistance + viewLength;
1241 if (labelBeforePos < beforeVisiblePos) {
1242 // Scroll header to move label to the before direction
1243 this.scrollDistance -= beforeVisiblePos - labelBeforePos + EXAGGERATED_OVERSCROLL;
1244 }
1245 else if (labelAfterPos > afterVisiblePos) {
1246 // Scroll header to move label to the after direction
1247 this.scrollDistance += labelAfterPos - afterVisiblePos + EXAGGERATED_OVERSCROLL;
1248 }
1249 }
1250 /**
1251 * Evaluate whether the pagination controls should be displayed. If the scroll width of the
1252 * tab list is wider than the size of the header container, then the pagination controls should
1253 * be shown.
1254 *
1255 * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
1256 * should be called sparingly.
1257 */
1258 _checkPaginationEnabled() {
1259 if (this.disablePagination) {
1260 this._showPaginationControls = false;
1261 }
1262 else {
1263 const isEnabled = this._tabList.nativeElement.scrollWidth > this._elementRef.nativeElement.offsetWidth;
1264 if (!isEnabled) {
1265 this.scrollDistance = 0;
1266 }
1267 if (isEnabled !== this._showPaginationControls) {
1268 this._changeDetectorRef.markForCheck();
1269 }
1270 this._showPaginationControls = isEnabled;
1271 }
1272 }
1273 /**
1274 * Evaluate whether the before and after controls should be enabled or disabled.
1275 * If the header is at the beginning of the list (scroll distance is equal to 0) then disable the
1276 * before button. If the header is at the end of the list (scroll distance is equal to the
1277 * maximum distance we can scroll), then disable the after button.
1278 *
1279 * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
1280 * should be called sparingly.
1281 */
1282 _checkScrollingControls() {
1283 if (this.disablePagination) {
1284 this._disableScrollAfter = this._disableScrollBefore = true;
1285 }
1286 else {
1287 // Check if the pagination arrows should be activated.
1288 this._disableScrollBefore = this.scrollDistance == 0;
1289 this._disableScrollAfter = this.scrollDistance == this._getMaxScrollDistance();
1290 this._changeDetectorRef.markForCheck();
1291 }
1292 }
1293 /**
1294 * Determines what is the maximum length in pixels that can be set for the scroll distance. This
1295 * is equal to the difference in width between the tab list container and tab header container.
1296 *
1297 * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
1298 * should be called sparingly.
1299 */
1300 _getMaxScrollDistance() {
1301 const lengthOfTabList = this._tabList.nativeElement.scrollWidth;
1302 const viewLength = this._tabListContainer.nativeElement.offsetWidth;
1303 return (lengthOfTabList - viewLength) || 0;
1304 }
1305 /** Tells the ink-bar to align itself to the current label wrapper */
1306 _alignInkBarToSelectedTab() {
1307 const selectedItem = this._items && this._items.length ?
1308 this._items.toArray()[this.selectedIndex] : null;
1309 const selectedLabelWrapper = selectedItem ? selectedItem.elementRef.nativeElement : null;
1310 if (selectedLabelWrapper) {
1311 this._inkBar.alignToElement(selectedLabelWrapper);
1312 }
1313 else {
1314 this._inkBar.hide();
1315 }
1316 }
1317 /** Stops the currently-running paginator interval. */
1318 _stopInterval() {
1319 this._stopScrolling.next();
1320 }
1321 /**
1322 * Handles the user pressing down on one of the paginators.
1323 * Starts scrolling the header after a certain amount of time.
1324 * @param direction In which direction the paginator should be scrolled.
1325 */
1326 _handlePaginatorPress(direction, mouseEvent) {
1327 // Don't start auto scrolling for right mouse button clicks. Note that we shouldn't have to
1328 // null check the `button`, but we do it so we don't break tests that use fake events.
1329 if (mouseEvent && mouseEvent.button != null && mouseEvent.button !== 0) {
1330 return;
1331 }
1332 // Avoid overlapping timers.
1333 this._stopInterval();
1334 // Start a timer after the delay and keep firing based on the interval.
1335 timer(HEADER_SCROLL_DELAY, HEADER_SCROLL_INTERVAL)
1336 // Keep the timer going until something tells it to stop or the component is destroyed.
1337 .pipe(takeUntil(merge(this._stopScrolling, this._destroyed)))
1338 .subscribe(() => {
1339 const { maxScrollDistance, distance } = this._scrollHeader(direction);
1340 // Stop the timer if we've reached the start or the end.
1341 if (distance === 0 || distance >= maxScrollDistance) {
1342 this._stopInterval();
1343 }
1344 });
1345 }
1346 /**
1347 * Scrolls the header to a given position.
1348 * @param position Position to which to scroll.
1349 * @returns Information on the current scroll distance and the maximum.
1350 */
1351 _scrollTo(position) {
1352 if (this.disablePagination) {
1353 return { maxScrollDistance: 0, distance: 0 };
1354 }
1355 const maxScrollDistance = this._getMaxScrollDistance();
1356 this._scrollDistance = Math.max(0, Math.min(maxScrollDistance, position));
1357 // Mark that the scroll distance has changed so that after the view is checked, the CSS
1358 // transformation can move the header.
1359 this._scrollDistanceChanged = true;
1360 this._checkScrollingControls();
1361 return { maxScrollDistance, distance: this._scrollDistance };
1362 }
1363}
1364MatPaginatedTabHeader.decorators = [
1365 { type: Directive }
1366];
1367MatPaginatedTabHeader.ctorParameters = () => [
1368 { type: ElementRef },
1369 { type: ChangeDetectorRef },
1370 { type: ViewportRuler },
1371 { type: Directionality, decorators: [{ type: Optional }] },
1372 { type: NgZone },
1373 { type: Platform },
1374 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
1375];
1376MatPaginatedTabHeader.propDecorators = {
1377 disablePagination: [{ type: Input }]
1378};
1379
1380/**
1381 * @license
1382 * Copyright Google LLC All Rights Reserved.
1383 *
1384 * Use of this source code is governed by an MIT-style license that can be
1385 * found in the LICENSE file at https://angular.io/license
1386 */
1387/**
1388 * Base class with all of the `MatTabHeader` functionality.
1389 * @docs-private
1390 */
1391class _MatTabHeaderBase extends MatPaginatedTabHeader {
1392 constructor(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode) {
1393 super(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode);
1394 this._disableRipple = false;
1395 }
1396 /** Whether the ripple effect is disabled or not. */
1397 get disableRipple() { return this._disableRipple; }
1398 set disableRipple(value) { this._disableRipple = coerceBooleanProperty(value); }
1399 _itemSelected(event) {
1400 event.preventDefault();
1401 }
1402}
1403_MatTabHeaderBase.decorators = [
1404 { type: Directive }
1405];
1406_MatTabHeaderBase.ctorParameters = () => [
1407 { type: ElementRef },
1408 { type: ChangeDetectorRef },
1409 { type: ViewportRuler },
1410 { type: Directionality, decorators: [{ type: Optional }] },
1411 { type: NgZone },
1412 { type: Platform },
1413 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
1414];
1415_MatTabHeaderBase.propDecorators = {
1416 disableRipple: [{ type: Input }]
1417};
1418/**
1419 * The header of the tab group which displays a list of all the tabs in the tab group. Includes
1420 * an ink bar that follows the currently selected tab. When the tabs list's width exceeds the
1421 * width of the header container, then arrows will be displayed to allow the user to scroll
1422 * left and right across the header.
1423 * @docs-private
1424 */
1425class MatTabHeader extends _MatTabHeaderBase {
1426 constructor(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode) {
1427 super(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode);
1428 }
1429}
1430MatTabHeader.decorators = [
1431 { type: Component, args: [{
1432 selector: 'mat-tab-header',
1433 template: "<div class=\"mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4\"\n #previousPaginator\n aria-hidden=\"true\"\n mat-ripple [matRippleDisabled]=\"_disableScrollBefore || disableRipple\"\n [class.mat-tab-header-pagination-disabled]=\"_disableScrollBefore\"\n (click)=\"_handlePaginatorClick('before')\"\n (mousedown)=\"_handlePaginatorPress('before', $event)\"\n (touchend)=\"_stopInterval()\">\n <div class=\"mat-tab-header-pagination-chevron\"></div>\n</div>\n\n<div class=\"mat-tab-label-container\" #tabListContainer (keydown)=\"_handleKeydown($event)\">\n <div\n #tabList\n class=\"mat-tab-list\"\n [class._mat-animation-noopable]=\"_animationMode === 'NoopAnimations'\"\n role=\"tablist\"\n (cdkObserveContent)=\"_onContentChanges()\">\n <div class=\"mat-tab-labels\">\n <ng-content></ng-content>\n </div>\n <mat-ink-bar></mat-ink-bar>\n </div>\n</div>\n\n<div class=\"mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4\"\n #nextPaginator\n aria-hidden=\"true\"\n mat-ripple [matRippleDisabled]=\"_disableScrollAfter || disableRipple\"\n [class.mat-tab-header-pagination-disabled]=\"_disableScrollAfter\"\n (mousedown)=\"_handlePaginatorPress('after', $event)\"\n (click)=\"_handlePaginatorClick('after')\"\n (touchend)=\"_stopInterval()\">\n <div class=\"mat-tab-header-pagination-chevron\"></div>\n</div>\n",
1434 inputs: ['selectedIndex'],
1435 outputs: ['selectFocusedIndex', 'indexFocused'],
1436 encapsulation: ViewEncapsulation.None,
1437 // tslint:disable-next-line:validate-decorators
1438 changeDetection: ChangeDetectionStrategy.Default,
1439 host: {
1440 'class': 'mat-tab-header',
1441 '[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',
1442 '[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'",
1443 },
1444 styles: [".mat-tab-header{display:flex;overflow:hidden;position:relative;flex-shrink:0}.mat-tab-header-pagination{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;display:none;justify-content:center;align-items:center;min-width:32px;cursor:pointer;z-index:2;-webkit-tap-highlight-color:transparent;touch-action:none}.mat-tab-header-pagination-controls-enabled .mat-tab-header-pagination{display:flex}.mat-tab-header-pagination-before,.mat-tab-header-rtl .mat-tab-header-pagination-after{padding-left:4px}.mat-tab-header-pagination-before .mat-tab-header-pagination-chevron,.mat-tab-header-rtl .mat-tab-header-pagination-after .mat-tab-header-pagination-chevron{transform:rotate(-135deg)}.mat-tab-header-rtl .mat-tab-header-pagination-before,.mat-tab-header-pagination-after{padding-right:4px}.mat-tab-header-rtl .mat-tab-header-pagination-before .mat-tab-header-pagination-chevron,.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron{transform:rotate(45deg)}.mat-tab-header-pagination-chevron{border-style:solid;border-width:2px 2px 0 0;content:\"\";height:8px;width:8px}.mat-tab-header-pagination-disabled{box-shadow:none;cursor:default}.mat-tab-list{flex-grow:1;position:relative;transition:transform 500ms cubic-bezier(0.35, 0, 0.25, 1)}.mat-ink-bar{position:absolute;bottom:0;height:2px;transition:500ms cubic-bezier(0.35, 0, 0.25, 1)}._mat-animation-noopable.mat-ink-bar{transition:none;animation:none}.mat-tab-group-inverted-header .mat-ink-bar{bottom:auto;top:0}.cdk-high-contrast-active .mat-ink-bar{outline:solid 2px;height:0}.mat-tab-labels{display:flex}[mat-align-tabs=center]>.mat-tab-header .mat-tab-labels{justify-content:center}[mat-align-tabs=end]>.mat-tab-header .mat-tab-labels{justify-content:flex-end}.mat-tab-label-container{display:flex;flex-grow:1;overflow:hidden;z-index:1}._mat-animation-noopable.mat-tab-list{transition:none;animation:none}.mat-tab-label{height:48px;padding:0 24px;cursor:pointer;box-sizing:border-box;opacity:.6;min-width:160px;text-align:center;display:inline-flex;justify-content:center;align-items:center;white-space:nowrap;position:relative}.mat-tab-label:focus{outline:none}.mat-tab-label:focus:not(.mat-tab-disabled){opacity:1}.cdk-high-contrast-active .mat-tab-label:focus{outline:dotted 2px;outline-offset:-2px}.mat-tab-label.mat-tab-disabled{cursor:default}.cdk-high-contrast-active .mat-tab-label.mat-tab-disabled{opacity:.5}.mat-tab-label .mat-tab-label-content{display:inline-flex;justify-content:center;align-items:center;white-space:nowrap}.cdk-high-contrast-active .mat-tab-label{opacity:1}@media(max-width: 599px){.mat-tab-label{min-width:72px}}\n"]
1445 },] }
1446];
1447MatTabHeader.ctorParameters = () => [
1448 { type: ElementRef },
1449 { type: ChangeDetectorRef },
1450 { type: ViewportRuler },
1451 { type: Directionality, decorators: [{ type: Optional }] },
1452 { type: NgZone },
1453 { type: Platform },
1454 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
1455];
1456MatTabHeader.propDecorators = {
1457 _items: [{ type: ContentChildren, args: [MatTabLabelWrapper, { descendants: false },] }],
1458 _inkBar: [{ type: ViewChild, args: [MatInkBar, { static: true },] }],
1459 _tabListContainer: [{ type: ViewChild, args: ['tabListContainer', { static: true },] }],
1460 _tabList: [{ type: ViewChild, args: ['tabList', { static: true },] }],
1461 _nextPaginator: [{ type: ViewChild, args: ['nextPaginator',] }],
1462 _previousPaginator: [{ type: ViewChild, args: ['previousPaginator',] }]
1463};
1464
1465/**
1466 * @license
1467 * Copyright Google LLC All Rights Reserved.
1468 *
1469 * Use of this source code is governed by an MIT-style license that can be
1470 * found in the LICENSE file at https://angular.io/license
1471 */
1472/**
1473 * Base class with all of the `MatTabNav` functionality.
1474 * @docs-private
1475 */
1476class _MatTabNavBase extends MatPaginatedTabHeader {
1477 constructor(elementRef, dir, ngZone, changeDetectorRef, viewportRuler, platform, animationMode) {
1478 super(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode);
1479 this._disableRipple = false;
1480 /** Theme color of the nav bar. */
1481 this.color = 'primary';
1482 }
1483 /** Background color of the tab nav. */
1484 get backgroundColor() { return this._backgroundColor; }
1485 set backgroundColor(value) {
1486 const classList = this._elementRef.nativeElement.classList;
1487 classList.remove(`mat-background-${this.backgroundColor}`);
1488 if (value) {
1489 classList.add(`mat-background-${value}`);
1490 }
1491 this._backgroundColor = value;
1492 }
1493 /** Whether the ripple effect is disabled or not. */
1494 get disableRipple() { return this._disableRipple; }
1495 set disableRipple(value) { this._disableRipple = coerceBooleanProperty(value); }
1496 _itemSelected() {
1497 // noop
1498 }
1499 ngAfterContentInit() {
1500 // We need this to run before the `changes` subscription in parent to ensure that the
1501 // selectedIndex is up-to-date by the time the super class starts looking for it.
1502 this._items.changes.pipe(startWith(null), takeUntil(this._destroyed)).subscribe(() => {
1503 this.updateActiveLink();
1504 });
1505 super.ngAfterContentInit();
1506 }
1507 /** Notifies the component that the active link has been changed. */
1508 updateActiveLink() {
1509 if (!this._items) {
1510 return;
1511 }
1512 const items = this._items.toArray();
1513 for (let i = 0; i < items.length; i++) {
1514 if (items[i].active) {
1515 this.selectedIndex = i;
1516 this._changeDetectorRef.markForCheck();
1517 return;
1518 }
1519 }
1520 // The ink bar should hide itself if no items are active.
1521 this.selectedIndex = -1;
1522 this._inkBar.hide();
1523 }
1524}
1525_MatTabNavBase.decorators = [
1526 { type: Directive }
1527];
1528_MatTabNavBase.ctorParameters = () => [
1529 { type: ElementRef },
1530 { type: Directionality, decorators: [{ type: Optional }] },
1531 { type: NgZone },
1532 { type: ChangeDetectorRef },
1533 { type: ViewportRuler },
1534 { type: Platform },
1535 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
1536];
1537_MatTabNavBase.propDecorators = {
1538 backgroundColor: [{ type: Input }],
1539 disableRipple: [{ type: Input }],
1540 color: [{ type: Input }]
1541};
1542/**
1543 * Navigation component matching the styles of the tab group header.
1544 * Provides anchored navigation with animated ink bar.
1545 */
1546class MatTabNav extends _MatTabNavBase {
1547 constructor(elementRef, dir, ngZone, changeDetectorRef, viewportRuler, platform, animationMode) {
1548 super(elementRef, dir, ngZone, changeDetectorRef, viewportRuler, platform, animationMode);
1549 }
1550}
1551MatTabNav.decorators = [
1552 { type: Component, args: [{
1553 selector: '[mat-tab-nav-bar]',
1554 exportAs: 'matTabNavBar, matTabNav',
1555 inputs: ['color'],
1556 template: "<div class=\"mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4\"\n #previousPaginator\n aria-hidden=\"true\"\n mat-ripple [matRippleDisabled]=\"_disableScrollBefore || disableRipple\"\n [class.mat-tab-header-pagination-disabled]=\"_disableScrollBefore\"\n (click)=\"_handlePaginatorClick('before')\"\n (mousedown)=\"_handlePaginatorPress('before', $event)\"\n (touchend)=\"_stopInterval()\">\n <div class=\"mat-tab-header-pagination-chevron\"></div>\n</div>\n\n<div class=\"mat-tab-link-container\" #tabListContainer (keydown)=\"_handleKeydown($event)\">\n <div\n class=\"mat-tab-list\"\n [class._mat-animation-noopable]=\"_animationMode === 'NoopAnimations'\"\n #tabList\n (cdkObserveContent)=\"_onContentChanges()\">\n <div class=\"mat-tab-links\">\n <ng-content></ng-content>\n </div>\n <mat-ink-bar></mat-ink-bar>\n </div>\n</div>\n\n<div class=\"mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4\"\n #nextPaginator\n aria-hidden=\"true\"\n mat-ripple [matRippleDisabled]=\"_disableScrollAfter || disableRipple\"\n [class.mat-tab-header-pagination-disabled]=\"_disableScrollAfter\"\n (mousedown)=\"_handlePaginatorPress('after', $event)\"\n (click)=\"_handlePaginatorClick('after')\"\n (touchend)=\"_stopInterval()\">\n <div class=\"mat-tab-header-pagination-chevron\"></div>\n</div>\n",
1557 host: {
1558 'class': 'mat-tab-nav-bar mat-tab-header',
1559 '[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',
1560 '[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'",
1561 '[class.mat-primary]': 'color !== "warn" && color !== "accent"',
1562 '[class.mat-accent]': 'color === "accent"',
1563 '[class.mat-warn]': 'color === "warn"',
1564 },
1565 encapsulation: ViewEncapsulation.None,
1566 // tslint:disable-next-line:validate-decorators
1567 changeDetection: ChangeDetectionStrategy.Default,
1568 styles: [".mat-tab-header{display:flex;overflow:hidden;position:relative;flex-shrink:0}.mat-tab-header-pagination{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;display:none;justify-content:center;align-items:center;min-width:32px;cursor:pointer;z-index:2;-webkit-tap-highlight-color:transparent;touch-action:none}.mat-tab-header-pagination-controls-enabled .mat-tab-header-pagination{display:flex}.mat-tab-header-pagination-before,.mat-tab-header-rtl .mat-tab-header-pagination-after{padding-left:4px}.mat-tab-header-pagination-before .mat-tab-header-pagination-chevron,.mat-tab-header-rtl .mat-tab-header-pagination-after .mat-tab-header-pagination-chevron{transform:rotate(-135deg)}.mat-tab-header-rtl .mat-tab-header-pagination-before,.mat-tab-header-pagination-after{padding-right:4px}.mat-tab-header-rtl .mat-tab-header-pagination-before .mat-tab-header-pagination-chevron,.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron{transform:rotate(45deg)}.mat-tab-header-pagination-chevron{border-style:solid;border-width:2px 2px 0 0;content:\"\";height:8px;width:8px}.mat-tab-header-pagination-disabled{box-shadow:none;cursor:default}.mat-tab-list{flex-grow:1;position:relative;transition:transform 500ms cubic-bezier(0.35, 0, 0.25, 1)}.mat-tab-links{display:flex}[mat-align-tabs=center]>.mat-tab-link-container .mat-tab-links{justify-content:center}[mat-align-tabs=end]>.mat-tab-link-container .mat-tab-links{justify-content:flex-end}.mat-ink-bar{position:absolute;bottom:0;height:2px;transition:500ms cubic-bezier(0.35, 0, 0.25, 1)}._mat-animation-noopable.mat-ink-bar{transition:none;animation:none}.mat-tab-group-inverted-header .mat-ink-bar{bottom:auto;top:0}.cdk-high-contrast-active .mat-ink-bar{outline:solid 2px;height:0}.mat-tab-link-container{display:flex;flex-grow:1;overflow:hidden;z-index:1}.mat-tab-link{height:48px;padding:0 24px;cursor:pointer;box-sizing:border-box;opacity:.6;min-width:160px;text-align:center;display:inline-flex;justify-content:center;align-items:center;white-space:nowrap;vertical-align:top;text-decoration:none;position:relative;overflow:hidden;-webkit-tap-highlight-color:transparent}.mat-tab-link:focus{outline:none}.mat-tab-link:focus:not(.mat-tab-disabled){opacity:1}.cdk-high-contrast-active .mat-tab-link:focus{outline:dotted 2px;outline-offset:-2px}.mat-tab-link.mat-tab-disabled{cursor:default}.cdk-high-contrast-active .mat-tab-link.mat-tab-disabled{opacity:.5}.mat-tab-link .mat-tab-label-content{display:inline-flex;justify-content:center;align-items:center;white-space:nowrap}.cdk-high-contrast-active .mat-tab-link{opacity:1}[mat-stretch-tabs] .mat-tab-link{flex-basis:0;flex-grow:1}.mat-tab-link.mat-tab-disabled{pointer-events:none}@media(max-width: 599px){.mat-tab-link{min-width:72px}}\n"]
1569 },] }
1570];
1571MatTabNav.ctorParameters = () => [
1572 { type: ElementRef },
1573 { type: Directionality, decorators: [{ type: Optional }] },
1574 { type: NgZone },
1575 { type: ChangeDetectorRef },
1576 { type: ViewportRuler },
1577 { type: Platform },
1578 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
1579];
1580MatTabNav.propDecorators = {
1581 _items: [{ type: ContentChildren, args: [forwardRef(() => MatTabLink), { descendants: true },] }],
1582 _inkBar: [{ type: ViewChild, args: [MatInkBar, { static: true },] }],
1583 _tabListContainer: [{ type: ViewChild, args: ['tabListContainer', { static: true },] }],
1584 _tabList: [{ type: ViewChild, args: ['tabList', { static: true },] }],
1585 _nextPaginator: [{ type: ViewChild, args: ['nextPaginator',] }],
1586 _previousPaginator: [{ type: ViewChild, args: ['previousPaginator',] }]
1587};
1588// Boilerplate for applying mixins to MatTabLink.
1589const _MatTabLinkMixinBase = mixinTabIndex(mixinDisableRipple(mixinDisabled(class {
1590})));
1591/** Base class with all of the `MatTabLink` functionality. */
1592class _MatTabLinkBase extends _MatTabLinkMixinBase {
1593 constructor(_tabNavBar,
1594 /** @docs-private */ elementRef, globalRippleOptions, tabIndex, _focusMonitor, animationMode) {
1595 super();
1596 this._tabNavBar = _tabNavBar;
1597 this.elementRef = elementRef;
1598 this._focusMonitor = _focusMonitor;
1599 /** Whether the tab link is active or not. */
1600 this._isActive = false;
1601 this.rippleConfig = globalRippleOptions || {};
1602 this.tabIndex = parseInt(tabIndex) || 0;
1603 if (animationMode === 'NoopAnimations') {
1604 this.rippleConfig.animation = { enterDuration: 0, exitDuration: 0 };
1605 }
1606 }
1607 /** Whether the link is active. */
1608 get active() { return this._isActive; }
1609 set active(value) {
1610 const newValue = coerceBooleanProperty(value);
1611 if (newValue !== this._isActive) {
1612 this._isActive = value;
1613 this._tabNavBar.updateActiveLink();
1614 }
1615 }
1616 /**
1617 * Whether ripples are disabled on interaction.
1618 * @docs-private
1619 */
1620 get rippleDisabled() {
1621 return this.disabled || this.disableRipple || this._tabNavBar.disableRipple ||
1622 !!this.rippleConfig.disabled;
1623 }
1624 /** Focuses the tab link. */
1625 focus() {
1626 this.elementRef.nativeElement.focus();
1627 }
1628 ngAfterViewInit() {
1629 this._focusMonitor.monitor(this.elementRef);
1630 }
1631 ngOnDestroy() {
1632 this._focusMonitor.stopMonitoring(this.elementRef);
1633 }
1634 _handleFocus() {
1635 // Since we allow navigation through tabbing in the nav bar, we
1636 // have to update the focused index whenever the link receives focus.
1637 this._tabNavBar.focusIndex = this._tabNavBar._items.toArray().indexOf(this);
1638 }
1639}
1640_MatTabLinkBase.decorators = [
1641 { type: Directive }
1642];
1643_MatTabLinkBase.ctorParameters = () => [
1644 { type: _MatTabNavBase },
1645 { type: ElementRef },
1646 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_RIPPLE_GLOBAL_OPTIONS,] }] },
1647 { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
1648 { type: FocusMonitor },
1649 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
1650];
1651_MatTabLinkBase.propDecorators = {
1652 active: [{ type: Input }]
1653};
1654/**
1655 * Link inside of a `mat-tab-nav-bar`.
1656 */
1657class MatTabLink extends _MatTabLinkBase {
1658 constructor(tabNavBar, elementRef, ngZone, platform, globalRippleOptions, tabIndex, focusMonitor, animationMode) {
1659 super(tabNavBar, elementRef, globalRippleOptions, tabIndex, focusMonitor, animationMode);
1660 this._tabLinkRipple = new RippleRenderer(this, ngZone, elementRef, platform);
1661 this._tabLinkRipple.setupTriggerEvents(elementRef.nativeElement);
1662 }
1663 ngOnDestroy() {
1664 super.ngOnDestroy();
1665 this._tabLinkRipple._removeTriggerEvents();
1666 }
1667}
1668MatTabLink.decorators = [
1669 { type: Directive, args: [{
1670 selector: '[mat-tab-link], [matTabLink]',
1671 exportAs: 'matTabLink',
1672 inputs: ['disabled', 'disableRipple', 'tabIndex'],
1673 host: {
1674 'class': 'mat-tab-link mat-focus-indicator',
1675 '[attr.aria-current]': 'active ? "page" : null',
1676 '[attr.aria-disabled]': 'disabled',
1677 '[attr.tabIndex]': 'tabIndex',
1678 '[class.mat-tab-disabled]': 'disabled',
1679 '[class.mat-tab-label-active]': 'active',
1680 '(focus)': '_handleFocus()'
1681 }
1682 },] }
1683];
1684MatTabLink.ctorParameters = () => [
1685 { type: MatTabNav },
1686 { type: ElementRef },
1687 { type: NgZone },
1688 { type: Platform },
1689 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_RIPPLE_GLOBAL_OPTIONS,] }] },
1690 { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
1691 { type: FocusMonitor },
1692 { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
1693];
1694
1695/**
1696 * @license
1697 * Copyright Google LLC All Rights Reserved.
1698 *
1699 * Use of this source code is governed by an MIT-style license that can be
1700 * found in the LICENSE file at https://angular.io/license
1701 */
1702class MatTabsModule {
1703}
1704MatTabsModule.decorators = [
1705 { type: NgModule, args: [{
1706 imports: [
1707 CommonModule,
1708 MatCommonModule,
1709 PortalModule,
1710 MatRippleModule,
1711 ObserversModule,
1712 A11yModule,
1713 ],
1714 // Don't export all components because some are only to be used internally.
1715 exports: [
1716 MatCommonModule,
1717 MatTabGroup,
1718 MatTabLabel,
1719 MatTab,
1720 MatTabNav,
1721 MatTabLink,
1722 MatTabContent,
1723 ],
1724 declarations: [
1725 MatTabGroup,
1726 MatTabLabel,
1727 MatTab,
1728 MatInkBar,
1729 MatTabLabelWrapper,
1730 MatTabNav,
1731 MatTabLink,
1732 MatTabBody,
1733 MatTabBodyPortal,
1734 MatTabHeader,
1735 MatTabContent,
1736 ],
1737 },] }
1738];
1739
1740/**
1741 * @license
1742 * Copyright Google LLC All Rights Reserved.
1743 *
1744 * Use of this source code is governed by an MIT-style license that can be
1745 * found in the LICENSE file at https://angular.io/license
1746 */
1747
1748/**
1749 * @license
1750 * Copyright Google LLC All Rights Reserved.
1751 *
1752 * Use of this source code is governed by an MIT-style license that can be
1753 * found in the LICENSE file at https://angular.io/license
1754 */
1755
1756/**
1757 * Generated bundle index. Do not edit.
1758 */
1759
1760export { MAT_TAB, MAT_TABS_CONFIG, MAT_TAB_GROUP, MatInkBar, MatTab, MatTabBody, MatTabBodyPortal, MatTabChangeEvent, MatTabContent, MatTabGroup, MatTabHeader, MatTabLabel, MatTabLabelWrapper, MatTabLink, MatTabNav, MatTabsModule, _MAT_INK_BAR_POSITIONER, _MatTabBodyBase, _MatTabGroupBase, _MatTabHeaderBase, _MatTabLinkBase, _MatTabNavBase, matTabsAnimations, _MAT_INK_BAR_POSITIONER_FACTORY as ɵangular_material_src_material_tabs_tabs_a, MAT_TAB_LABEL as ɵangular_material_src_material_tabs_tabs_b, MAT_TAB_CONTENT as ɵangular_material_src_material_tabs_tabs_c, MatPaginatedTabHeader as ɵangular_material_src_material_tabs_tabs_d };
1761//# sourceMappingURL=tabs.js.map
Note: See TracBrowser for help on using the repository browser.