tabs.es5.js 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { Directive, ElementRef, Inject, InjectionToken, NgZone, Optional, TemplateRef, ChangeDetectionStrategy, Component, ContentChild, Input, ViewChild, ViewContainerRef, ViewEncapsulation, ChangeDetectorRef, Output, EventEmitter, ComponentFactoryResolver, forwardRef, ContentChildren, Attribute, NgModule } from '@angular/core';
  9. import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
  10. import { __extends } from 'tslib';
  11. import { CdkPortal, TemplatePortal, CdkPortalOutlet, PortalHostDirective, PortalModule } from '@angular/cdk/portal';
  12. import { mixinDisabled, mixinColor, mixinDisableRipple, MAT_RIPPLE_GLOBAL_OPTIONS, mixinTabIndex, RippleRenderer, MatCommonModule, MatRippleModule } from '@angular/material/core';
  13. import { Subject, Subscription, merge, of, timer, fromEvent } from 'rxjs';
  14. import { animate, state, style, transition, trigger } from '@angular/animations';
  15. import { Directionality } from '@angular/cdk/bidi';
  16. import { startWith, distinctUntilChanged, takeUntil } from 'rxjs/operators';
  17. import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
  18. import { ViewportRuler } from '@angular/cdk/scrolling';
  19. import { FocusKeyManager, FocusMonitor, A11yModule } from '@angular/cdk/a11y';
  20. import { END, ENTER, HOME, SPACE, hasModifierKey } from '@angular/cdk/keycodes';
  21. import { Platform, normalizePassiveListenerOptions } from '@angular/cdk/platform';
  22. import { ObserversModule } from '@angular/cdk/observers';
  23. import { CommonModule } from '@angular/common';
  24. /**
  25. * @fileoverview added by tsickle
  26. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  27. */
  28. /**
  29. * Injection token for the MatInkBar's Positioner.
  30. * @type {?}
  31. */
  32. var _MAT_INK_BAR_POSITIONER = new InjectionToken('MatInkBarPositioner', {
  33. providedIn: 'root',
  34. factory: _MAT_INK_BAR_POSITIONER_FACTORY
  35. });
  36. /**
  37. * The default positioner function for the MatInkBar.
  38. * \@docs-private
  39. * @return {?}
  40. */
  41. function _MAT_INK_BAR_POSITIONER_FACTORY() {
  42. /** @type {?} */
  43. var method = (/**
  44. * @param {?} element
  45. * @return {?}
  46. */
  47. function (element) { return ({
  48. left: element ? (element.offsetLeft || 0) + 'px' : '0',
  49. width: element ? (element.offsetWidth || 0) + 'px' : '0',
  50. }); });
  51. return method;
  52. }
  53. /**
  54. * The ink-bar is used to display and animate the line underneath the current active tab label.
  55. * \@docs-private
  56. */
  57. var MatInkBar = /** @class */ (function () {
  58. function MatInkBar(_elementRef, _ngZone, _inkBarPositioner, _animationMode) {
  59. this._elementRef = _elementRef;
  60. this._ngZone = _ngZone;
  61. this._inkBarPositioner = _inkBarPositioner;
  62. this._animationMode = _animationMode;
  63. }
  64. /**
  65. * Calculates the styles from the provided element in order to align the ink-bar to that element.
  66. * Shows the ink bar if previously set as hidden.
  67. * @param element
  68. */
  69. /**
  70. * Calculates the styles from the provided element in order to align the ink-bar to that element.
  71. * Shows the ink bar if previously set as hidden.
  72. * @param {?} element
  73. * @return {?}
  74. */
  75. MatInkBar.prototype.alignToElement = /**
  76. * Calculates the styles from the provided element in order to align the ink-bar to that element.
  77. * Shows the ink bar if previously set as hidden.
  78. * @param {?} element
  79. * @return {?}
  80. */
  81. function (element) {
  82. var _this = this;
  83. this.show();
  84. if (typeof requestAnimationFrame !== 'undefined') {
  85. this._ngZone.runOutsideAngular((/**
  86. * @return {?}
  87. */
  88. function () {
  89. requestAnimationFrame((/**
  90. * @return {?}
  91. */
  92. function () { return _this._setStyles(element); }));
  93. }));
  94. }
  95. else {
  96. this._setStyles(element);
  97. }
  98. };
  99. /** Shows the ink bar. */
  100. /**
  101. * Shows the ink bar.
  102. * @return {?}
  103. */
  104. MatInkBar.prototype.show = /**
  105. * Shows the ink bar.
  106. * @return {?}
  107. */
  108. function () {
  109. this._elementRef.nativeElement.style.visibility = 'visible';
  110. };
  111. /** Hides the ink bar. */
  112. /**
  113. * Hides the ink bar.
  114. * @return {?}
  115. */
  116. MatInkBar.prototype.hide = /**
  117. * Hides the ink bar.
  118. * @return {?}
  119. */
  120. function () {
  121. this._elementRef.nativeElement.style.visibility = 'hidden';
  122. };
  123. /**
  124. * Sets the proper styles to the ink bar element.
  125. * @param element
  126. */
  127. /**
  128. * Sets the proper styles to the ink bar element.
  129. * @private
  130. * @param {?} element
  131. * @return {?}
  132. */
  133. MatInkBar.prototype._setStyles = /**
  134. * Sets the proper styles to the ink bar element.
  135. * @private
  136. * @param {?} element
  137. * @return {?}
  138. */
  139. function (element) {
  140. /** @type {?} */
  141. var positions = this._inkBarPositioner(element);
  142. /** @type {?} */
  143. var inkBar = this._elementRef.nativeElement;
  144. inkBar.style.left = positions.left;
  145. inkBar.style.width = positions.width;
  146. };
  147. MatInkBar.decorators = [
  148. { type: Directive, args: [{
  149. selector: 'mat-ink-bar',
  150. host: {
  151. 'class': 'mat-ink-bar',
  152. '[class._mat-animation-noopable]': "_animationMode === 'NoopAnimations'",
  153. },
  154. },] },
  155. ];
  156. /** @nocollapse */
  157. MatInkBar.ctorParameters = function () { return [
  158. { type: ElementRef },
  159. { type: NgZone },
  160. { type: undefined, decorators: [{ type: Inject, args: [_MAT_INK_BAR_POSITIONER,] }] },
  161. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  162. ]; };
  163. return MatInkBar;
  164. }());
  165. /**
  166. * @fileoverview added by tsickle
  167. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  168. */
  169. /**
  170. * Decorates the `ng-template` tags and reads out the template from it.
  171. */
  172. var MatTabContent = /** @class */ (function () {
  173. function MatTabContent(template) {
  174. this.template = template;
  175. }
  176. MatTabContent.decorators = [
  177. { type: Directive, args: [{ selector: '[matTabContent]' },] },
  178. ];
  179. /** @nocollapse */
  180. MatTabContent.ctorParameters = function () { return [
  181. { type: TemplateRef }
  182. ]; };
  183. return MatTabContent;
  184. }());
  185. /**
  186. * @fileoverview added by tsickle
  187. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  188. */
  189. /**
  190. * Used to flag tab labels for use with the portal directive
  191. */
  192. var MatTabLabel = /** @class */ (function (_super) {
  193. __extends(MatTabLabel, _super);
  194. function MatTabLabel() {
  195. return _super !== null && _super.apply(this, arguments) || this;
  196. }
  197. MatTabLabel.decorators = [
  198. { type: Directive, args: [{
  199. selector: '[mat-tab-label], [matTabLabel]',
  200. },] },
  201. ];
  202. return MatTabLabel;
  203. }(CdkPortal));
  204. /**
  205. * @fileoverview added by tsickle
  206. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  207. */
  208. // Boilerplate for applying mixins to MatTab.
  209. /**
  210. * \@docs-private
  211. */
  212. var
  213. // Boilerplate for applying mixins to MatTab.
  214. /**
  215. * \@docs-private
  216. */
  217. MatTabBase = /** @class */ (function () {
  218. function MatTabBase() {
  219. }
  220. return MatTabBase;
  221. }());
  222. /** @type {?} */
  223. var _MatTabMixinBase = mixinDisabled(MatTabBase);
  224. var MatTab = /** @class */ (function (_super) {
  225. __extends(MatTab, _super);
  226. function MatTab(_viewContainerRef) {
  227. var _this = _super.call(this) || this;
  228. _this._viewContainerRef = _viewContainerRef;
  229. /**
  230. * Plain text label for the tab, used when there is no template label.
  231. */
  232. _this.textLabel = '';
  233. /**
  234. * Portal that will be the hosted content of the tab
  235. */
  236. _this._contentPortal = null;
  237. /**
  238. * Emits whenever the internal state of the tab changes.
  239. */
  240. _this._stateChanges = new Subject();
  241. /**
  242. * The relatively indexed position where 0 represents the center, negative is left, and positive
  243. * represents the right.
  244. */
  245. _this.position = null;
  246. /**
  247. * The initial relatively index origin of the tab if it was created and selected after there
  248. * was already a selected tab. Provides context of what position the tab should originate from.
  249. */
  250. _this.origin = null;
  251. /**
  252. * Whether the tab is currently active.
  253. */
  254. _this.isActive = false;
  255. return _this;
  256. }
  257. Object.defineProperty(MatTab.prototype, "content", {
  258. /** @docs-private */
  259. get: /**
  260. * \@docs-private
  261. * @return {?}
  262. */
  263. function () {
  264. return this._contentPortal;
  265. },
  266. enumerable: true,
  267. configurable: true
  268. });
  269. /**
  270. * @param {?} changes
  271. * @return {?}
  272. */
  273. MatTab.prototype.ngOnChanges = /**
  274. * @param {?} changes
  275. * @return {?}
  276. */
  277. function (changes) {
  278. if (changes.hasOwnProperty('textLabel') || changes.hasOwnProperty('disabled')) {
  279. this._stateChanges.next();
  280. }
  281. };
  282. /**
  283. * @return {?}
  284. */
  285. MatTab.prototype.ngOnDestroy = /**
  286. * @return {?}
  287. */
  288. function () {
  289. this._stateChanges.complete();
  290. };
  291. /**
  292. * @return {?}
  293. */
  294. MatTab.prototype.ngOnInit = /**
  295. * @return {?}
  296. */
  297. function () {
  298. this._contentPortal = new TemplatePortal(this._explicitContent || this._implicitContent, this._viewContainerRef);
  299. };
  300. MatTab.decorators = [
  301. { type: Component, args: [{selector: 'mat-tab',
  302. template: "<ng-template><ng-content></ng-content></ng-template>",
  303. inputs: ['disabled'],
  304. changeDetection: ChangeDetectionStrategy.OnPush,
  305. encapsulation: ViewEncapsulation.None,
  306. exportAs: 'matTab',
  307. },] },
  308. ];
  309. /** @nocollapse */
  310. MatTab.ctorParameters = function () { return [
  311. { type: ViewContainerRef }
  312. ]; };
  313. MatTab.propDecorators = {
  314. templateLabel: [{ type: ContentChild, args: [MatTabLabel, { static: false },] }],
  315. _explicitContent: [{ type: ContentChild, args: [MatTabContent, { read: TemplateRef, static: true },] }],
  316. _implicitContent: [{ type: ViewChild, args: [TemplateRef, { static: true },] }],
  317. textLabel: [{ type: Input, args: ['label',] }],
  318. ariaLabel: [{ type: Input, args: ['aria-label',] }],
  319. ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }]
  320. };
  321. return MatTab;
  322. }(_MatTabMixinBase));
  323. /**
  324. * @fileoverview added by tsickle
  325. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  326. */
  327. /**
  328. * Animations used by the Material tabs.
  329. * \@docs-private
  330. * @type {?}
  331. */
  332. var matTabsAnimations = {
  333. /**
  334. * Animation translates a tab along the X axis.
  335. */
  336. translateTab: trigger('translateTab', [
  337. // Note: transitions to `none` instead of 0, because some browsers might blur the content.
  338. state('center, void, left-origin-center, right-origin-center', style({ transform: 'none' })),
  339. // If the tab is either on the left or right, we additionally add a `min-height` of 1px
  340. // in order to ensure that the element has a height before its state changes. This is
  341. // necessary because Chrome does seem to skip the transition in RTL mode if the element does
  342. // not have a static height and is not rendered. See related issue: #9465
  343. state('left', style({ transform: 'translate3d(-100%, 0, 0)', minHeight: '1px' })),
  344. state('right', style({ transform: 'translate3d(100%, 0, 0)', minHeight: '1px' })),
  345. transition('* => left, * => right, left => center, right => center', animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)')),
  346. transition('void => left-origin-center', [
  347. style({ transform: 'translate3d(-100%, 0, 0)' }),
  348. animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)')
  349. ]),
  350. transition('void => right-origin-center', [
  351. style({ transform: 'translate3d(100%, 0, 0)' }),
  352. animate('{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)')
  353. ])
  354. ])
  355. };
  356. /**
  357. * @fileoverview added by tsickle
  358. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  359. */
  360. /**
  361. * The portal host directive for the contents of the tab.
  362. * \@docs-private
  363. */
  364. var MatTabBodyPortal = /** @class */ (function (_super) {
  365. __extends(MatTabBodyPortal, _super);
  366. function MatTabBodyPortal(componentFactoryResolver, viewContainerRef, _host) {
  367. var _this = _super.call(this, componentFactoryResolver, viewContainerRef) || this;
  368. _this._host = _host;
  369. /**
  370. * Subscription to events for when the tab body begins centering.
  371. */
  372. _this._centeringSub = Subscription.EMPTY;
  373. /**
  374. * Subscription to events for when the tab body finishes leaving from center position.
  375. */
  376. _this._leavingSub = Subscription.EMPTY;
  377. return _this;
  378. }
  379. /** Set initial visibility or set up subscription for changing visibility. */
  380. /**
  381. * Set initial visibility or set up subscription for changing visibility.
  382. * @return {?}
  383. */
  384. MatTabBodyPortal.prototype.ngOnInit = /**
  385. * Set initial visibility or set up subscription for changing visibility.
  386. * @return {?}
  387. */
  388. function () {
  389. var _this = this;
  390. _super.prototype.ngOnInit.call(this);
  391. this._centeringSub = this._host._beforeCentering
  392. .pipe(startWith(this._host._isCenterPosition(this._host._position)))
  393. .subscribe((/**
  394. * @param {?} isCentering
  395. * @return {?}
  396. */
  397. function (isCentering) {
  398. if (isCentering && !_this.hasAttached()) {
  399. _this.attach(_this._host._content);
  400. }
  401. }));
  402. this._leavingSub = this._host._afterLeavingCenter.subscribe((/**
  403. * @return {?}
  404. */
  405. function () {
  406. _this.detach();
  407. }));
  408. };
  409. /** Clean up centering subscription. */
  410. /**
  411. * Clean up centering subscription.
  412. * @return {?}
  413. */
  414. MatTabBodyPortal.prototype.ngOnDestroy = /**
  415. * Clean up centering subscription.
  416. * @return {?}
  417. */
  418. function () {
  419. _super.prototype.ngOnDestroy.call(this);
  420. this._centeringSub.unsubscribe();
  421. this._leavingSub.unsubscribe();
  422. };
  423. MatTabBodyPortal.decorators = [
  424. { type: Directive, args: [{
  425. selector: '[matTabBodyHost]'
  426. },] },
  427. ];
  428. /** @nocollapse */
  429. MatTabBodyPortal.ctorParameters = function () { return [
  430. { type: ComponentFactoryResolver },
  431. { type: ViewContainerRef },
  432. { type: MatTabBody, decorators: [{ type: Inject, args: [forwardRef((/**
  433. * @return {?}
  434. */
  435. function () { return MatTabBody; })),] }] }
  436. ]; };
  437. return MatTabBodyPortal;
  438. }(CdkPortalOutlet));
  439. /**
  440. * Wrapper for the contents of a tab.
  441. * \@docs-private
  442. */
  443. var MatTabBody = /** @class */ (function () {
  444. function MatTabBody(_elementRef, _dir, changeDetectorRef) {
  445. var _this = this;
  446. this._elementRef = _elementRef;
  447. this._dir = _dir;
  448. /**
  449. * Subscription to the directionality change observable.
  450. */
  451. this._dirChangeSubscription = Subscription.EMPTY;
  452. /**
  453. * Emits when an animation on the tab is complete.
  454. */
  455. this._translateTabComplete = new Subject();
  456. /**
  457. * Event emitted when the tab begins to animate towards the center as the active tab.
  458. */
  459. this._onCentering = new EventEmitter();
  460. /**
  461. * Event emitted before the centering of the tab begins.
  462. */
  463. this._beforeCentering = new EventEmitter();
  464. /**
  465. * Event emitted before the centering of the tab begins.
  466. */
  467. this._afterLeavingCenter = new EventEmitter();
  468. /**
  469. * Event emitted when the tab completes its animation towards the center.
  470. */
  471. this._onCentered = new EventEmitter(true);
  472. // Note that the default value will always be overwritten by `MatTabBody`, but we need one
  473. // anyway to prevent the animations module from throwing an error if the body is used on its own.
  474. /**
  475. * Duration for the tab's animation.
  476. */
  477. this.animationDuration = '500ms';
  478. if (_dir) {
  479. this._dirChangeSubscription = _dir.change.subscribe((/**
  480. * @param {?} dir
  481. * @return {?}
  482. */
  483. function (dir) {
  484. _this._computePositionAnimationState(dir);
  485. changeDetectorRef.markForCheck();
  486. }));
  487. }
  488. // Ensure that we get unique animation events, because the `.done` callback can get
  489. // invoked twice in some browsers. See https://github.com/angular/angular/issues/24084.
  490. this._translateTabComplete.pipe(distinctUntilChanged((/**
  491. * @param {?} x
  492. * @param {?} y
  493. * @return {?}
  494. */
  495. function (x, y) {
  496. return x.fromState === y.fromState && x.toState === y.toState;
  497. }))).subscribe((/**
  498. * @param {?} event
  499. * @return {?}
  500. */
  501. function (event) {
  502. // If the transition to the center is complete, emit an event.
  503. if (_this._isCenterPosition(event.toState) && _this._isCenterPosition(_this._position)) {
  504. _this._onCentered.emit();
  505. }
  506. if (_this._isCenterPosition(event.fromState) && !_this._isCenterPosition(_this._position)) {
  507. _this._afterLeavingCenter.emit();
  508. }
  509. }));
  510. }
  511. Object.defineProperty(MatTabBody.prototype, "position", {
  512. /** The shifted index position of the tab body, where zero represents the active center tab. */
  513. set: /**
  514. * The shifted index position of the tab body, where zero represents the active center tab.
  515. * @param {?} position
  516. * @return {?}
  517. */
  518. function (position) {
  519. this._positionIndex = position;
  520. this._computePositionAnimationState();
  521. },
  522. enumerable: true,
  523. configurable: true
  524. });
  525. /**
  526. * After initialized, check if the content is centered and has an origin. If so, set the
  527. * special position states that transition the tab from the left or right before centering.
  528. */
  529. /**
  530. * After initialized, check if the content is centered and has an origin. If so, set the
  531. * special position states that transition the tab from the left or right before centering.
  532. * @return {?}
  533. */
  534. MatTabBody.prototype.ngOnInit = /**
  535. * After initialized, check if the content is centered and has an origin. If so, set the
  536. * special position states that transition the tab from the left or right before centering.
  537. * @return {?}
  538. */
  539. function () {
  540. if (this._position == 'center' && this.origin != null) {
  541. this._position = this._computePositionFromOrigin();
  542. }
  543. };
  544. /**
  545. * @return {?}
  546. */
  547. MatTabBody.prototype.ngOnDestroy = /**
  548. * @return {?}
  549. */
  550. function () {
  551. this._dirChangeSubscription.unsubscribe();
  552. this._translateTabComplete.complete();
  553. };
  554. /**
  555. * @param {?} event
  556. * @return {?}
  557. */
  558. MatTabBody.prototype._onTranslateTabStarted = /**
  559. * @param {?} event
  560. * @return {?}
  561. */
  562. function (event) {
  563. /** @type {?} */
  564. var isCentering = this._isCenterPosition(event.toState);
  565. this._beforeCentering.emit(isCentering);
  566. if (isCentering) {
  567. this._onCentering.emit(this._elementRef.nativeElement.clientHeight);
  568. }
  569. };
  570. /** The text direction of the containing app. */
  571. /**
  572. * The text direction of the containing app.
  573. * @return {?}
  574. */
  575. MatTabBody.prototype._getLayoutDirection = /**
  576. * The text direction of the containing app.
  577. * @return {?}
  578. */
  579. function () {
  580. return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
  581. };
  582. /** Whether the provided position state is considered center, regardless of origin. */
  583. /**
  584. * Whether the provided position state is considered center, regardless of origin.
  585. * @param {?} position
  586. * @return {?}
  587. */
  588. MatTabBody.prototype._isCenterPosition = /**
  589. * Whether the provided position state is considered center, regardless of origin.
  590. * @param {?} position
  591. * @return {?}
  592. */
  593. function (position) {
  594. return position == 'center' ||
  595. position == 'left-origin-center' ||
  596. position == 'right-origin-center';
  597. };
  598. /** Computes the position state that will be used for the tab-body animation trigger. */
  599. /**
  600. * Computes the position state that will be used for the tab-body animation trigger.
  601. * @private
  602. * @param {?=} dir
  603. * @return {?}
  604. */
  605. MatTabBody.prototype._computePositionAnimationState = /**
  606. * Computes the position state that will be used for the tab-body animation trigger.
  607. * @private
  608. * @param {?=} dir
  609. * @return {?}
  610. */
  611. function (dir) {
  612. if (dir === void 0) { dir = this._getLayoutDirection(); }
  613. if (this._positionIndex < 0) {
  614. this._position = dir == 'ltr' ? 'left' : 'right';
  615. }
  616. else if (this._positionIndex > 0) {
  617. this._position = dir == 'ltr' ? 'right' : 'left';
  618. }
  619. else {
  620. this._position = 'center';
  621. }
  622. };
  623. /**
  624. * Computes the position state based on the specified origin position. This is used if the
  625. * tab is becoming visible immediately after creation.
  626. */
  627. /**
  628. * Computes the position state based on the specified origin position. This is used if the
  629. * tab is becoming visible immediately after creation.
  630. * @private
  631. * @return {?}
  632. */
  633. MatTabBody.prototype._computePositionFromOrigin = /**
  634. * Computes the position state based on the specified origin position. This is used if the
  635. * tab is becoming visible immediately after creation.
  636. * @private
  637. * @return {?}
  638. */
  639. function () {
  640. /** @type {?} */
  641. var dir = this._getLayoutDirection();
  642. if ((dir == 'ltr' && this.origin <= 0) || (dir == 'rtl' && this.origin > 0)) {
  643. return 'left-origin-center';
  644. }
  645. return 'right-origin-center';
  646. };
  647. MatTabBody.decorators = [
  648. { type: Component, args: [{selector: 'mat-tab-body',
  649. template: "<div class=\"mat-tab-body-content\" #content [@translateTab]=\"{ value: _position, params: {animationDuration: animationDuration} }\" (@translateTab.start)=\"_onTranslateTabStarted($event)\" (@translateTab.done)=\"_translateTabComplete.next($event)\"><ng-template matTabBodyHost></ng-template></div>",
  650. styles: [".mat-tab-body-content{height:100%;overflow:auto}.mat-tab-group-dynamic-height .mat-tab-body-content{overflow:hidden}"],
  651. encapsulation: ViewEncapsulation.None,
  652. changeDetection: ChangeDetectionStrategy.OnPush,
  653. animations: [matTabsAnimations.translateTab],
  654. host: {
  655. 'class': 'mat-tab-body',
  656. },
  657. },] },
  658. ];
  659. /** @nocollapse */
  660. MatTabBody.ctorParameters = function () { return [
  661. { type: ElementRef },
  662. { type: Directionality, decorators: [{ type: Optional }] },
  663. { type: ChangeDetectorRef }
  664. ]; };
  665. MatTabBody.propDecorators = {
  666. _onCentering: [{ type: Output }],
  667. _beforeCentering: [{ type: Output }],
  668. _afterLeavingCenter: [{ type: Output }],
  669. _onCentered: [{ type: Output }],
  670. _portalHost: [{ type: ViewChild, args: [PortalHostDirective, { static: false },] }],
  671. _content: [{ type: Input, args: ['content',] }],
  672. origin: [{ type: Input }],
  673. animationDuration: [{ type: Input }],
  674. position: [{ type: Input }]
  675. };
  676. return MatTabBody;
  677. }());
  678. /**
  679. * @fileoverview added by tsickle
  680. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  681. */
  682. // Boilerplate for applying mixins to MatTabLabelWrapper.
  683. /**
  684. * \@docs-private
  685. */
  686. var
  687. // Boilerplate for applying mixins to MatTabLabelWrapper.
  688. /**
  689. * \@docs-private
  690. */
  691. MatTabLabelWrapperBase = /** @class */ (function () {
  692. function MatTabLabelWrapperBase() {
  693. }
  694. return MatTabLabelWrapperBase;
  695. }());
  696. /** @type {?} */
  697. var _MatTabLabelWrapperMixinBase = mixinDisabled(MatTabLabelWrapperBase);
  698. /**
  699. * Used in the `mat-tab-group` view to display tab labels.
  700. * \@docs-private
  701. */
  702. var MatTabLabelWrapper = /** @class */ (function (_super) {
  703. __extends(MatTabLabelWrapper, _super);
  704. function MatTabLabelWrapper(elementRef) {
  705. var _this = _super.call(this) || this;
  706. _this.elementRef = elementRef;
  707. return _this;
  708. }
  709. /** Sets focus on the wrapper element */
  710. /**
  711. * Sets focus on the wrapper element
  712. * @return {?}
  713. */
  714. MatTabLabelWrapper.prototype.focus = /**
  715. * Sets focus on the wrapper element
  716. * @return {?}
  717. */
  718. function () {
  719. this.elementRef.nativeElement.focus();
  720. };
  721. /**
  722. * @return {?}
  723. */
  724. MatTabLabelWrapper.prototype.getOffsetLeft = /**
  725. * @return {?}
  726. */
  727. function () {
  728. return this.elementRef.nativeElement.offsetLeft;
  729. };
  730. /**
  731. * @return {?}
  732. */
  733. MatTabLabelWrapper.prototype.getOffsetWidth = /**
  734. * @return {?}
  735. */
  736. function () {
  737. return this.elementRef.nativeElement.offsetWidth;
  738. };
  739. MatTabLabelWrapper.decorators = [
  740. { type: Directive, args: [{
  741. selector: '[matTabLabelWrapper]',
  742. inputs: ['disabled'],
  743. host: {
  744. '[class.mat-tab-disabled]': 'disabled',
  745. '[attr.aria-disabled]': '!!disabled',
  746. }
  747. },] },
  748. ];
  749. /** @nocollapse */
  750. MatTabLabelWrapper.ctorParameters = function () { return [
  751. { type: ElementRef }
  752. ]; };
  753. return MatTabLabelWrapper;
  754. }(_MatTabLabelWrapperMixinBase));
  755. /**
  756. * @fileoverview added by tsickle
  757. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  758. */
  759. /**
  760. * Config used to bind passive event listeners
  761. * @type {?}
  762. */
  763. var passiveEventListenerOptions = (/** @type {?} */ (normalizePassiveListenerOptions({ passive: true })));
  764. /**
  765. * The distance in pixels that will be overshot when scrolling a tab label into view. This helps
  766. * provide a small affordance to the label next to it.
  767. * @type {?}
  768. */
  769. var EXAGGERATED_OVERSCROLL = 60;
  770. /**
  771. * Amount of milliseconds to wait before starting to scroll the header automatically.
  772. * Set a little conservatively in order to handle fake events dispatched on touch devices.
  773. * @type {?}
  774. */
  775. var HEADER_SCROLL_DELAY = 650;
  776. /**
  777. * Interval in milliseconds at which to scroll the header
  778. * while the user is holding their pointer.
  779. * @type {?}
  780. */
  781. var HEADER_SCROLL_INTERVAL = 100;
  782. /**
  783. * Base class for a tab header that supported pagination.
  784. * @abstract
  785. */
  786. var MatPaginatedTabHeader = /** @class */ (function () {
  787. function MatPaginatedTabHeader(_elementRef, _changeDetectorRef, _viewportRuler, _dir, _ngZone, _platform, _animationMode) {
  788. var _this = this;
  789. this._elementRef = _elementRef;
  790. this._changeDetectorRef = _changeDetectorRef;
  791. this._viewportRuler = _viewportRuler;
  792. this._dir = _dir;
  793. this._ngZone = _ngZone;
  794. this._platform = _platform;
  795. this._animationMode = _animationMode;
  796. /**
  797. * The distance in pixels that the tab labels should be translated to the left.
  798. */
  799. this._scrollDistance = 0;
  800. /**
  801. * Whether the header should scroll to the selected index after the view has been checked.
  802. */
  803. this._selectedIndexChanged = false;
  804. /**
  805. * Emits when the component is destroyed.
  806. */
  807. this._destroyed = new Subject();
  808. /**
  809. * Whether the controls for pagination should be displayed
  810. */
  811. this._showPaginationControls = false;
  812. /**
  813. * Whether the tab list can be scrolled more towards the end of the tab label list.
  814. */
  815. this._disableScrollAfter = true;
  816. /**
  817. * Whether the tab list can be scrolled more towards the beginning of the tab label list.
  818. */
  819. this._disableScrollBefore = true;
  820. /**
  821. * Stream that will stop the automated scrolling.
  822. */
  823. this._stopScrolling = new Subject();
  824. this._selectedIndex = 0;
  825. /**
  826. * Event emitted when the option is selected.
  827. */
  828. this.selectFocusedIndex = new EventEmitter();
  829. /**
  830. * Event emitted when a label is focused.
  831. */
  832. this.indexFocused = new EventEmitter();
  833. // Bind the `mouseleave` event on the outside since it doesn't change anything in the view.
  834. _ngZone.runOutsideAngular((/**
  835. * @return {?}
  836. */
  837. function () {
  838. fromEvent(_elementRef.nativeElement, 'mouseleave')
  839. .pipe(takeUntil(_this._destroyed))
  840. .subscribe((/**
  841. * @return {?}
  842. */
  843. function () {
  844. _this._stopInterval();
  845. }));
  846. }));
  847. }
  848. Object.defineProperty(MatPaginatedTabHeader.prototype, "selectedIndex", {
  849. /** The index of the active tab. */
  850. get: /**
  851. * The index of the active tab.
  852. * @return {?}
  853. */
  854. function () { return this._selectedIndex; },
  855. set: /**
  856. * @param {?} value
  857. * @return {?}
  858. */
  859. function (value) {
  860. value = coerceNumberProperty(value);
  861. if (this._selectedIndex != value) {
  862. this._selectedIndexChanged = true;
  863. this._selectedIndex = value;
  864. if (this._keyManager) {
  865. this._keyManager.updateActiveItemIndex(value);
  866. }
  867. }
  868. },
  869. enumerable: true,
  870. configurable: true
  871. });
  872. /**
  873. * @return {?}
  874. */
  875. MatPaginatedTabHeader.prototype.ngAfterViewInit = /**
  876. * @return {?}
  877. */
  878. function () {
  879. var _this = this;
  880. // We need to handle these events manually, because we want to bind passive event listeners.
  881. fromEvent(this._previousPaginator.nativeElement, 'touchstart', passiveEventListenerOptions)
  882. .pipe(takeUntil(this._destroyed))
  883. .subscribe((/**
  884. * @return {?}
  885. */
  886. function () {
  887. _this._handlePaginatorPress('before');
  888. }));
  889. fromEvent(this._nextPaginator.nativeElement, 'touchstart', passiveEventListenerOptions)
  890. .pipe(takeUntil(this._destroyed))
  891. .subscribe((/**
  892. * @return {?}
  893. */
  894. function () {
  895. _this._handlePaginatorPress('after');
  896. }));
  897. };
  898. /**
  899. * @return {?}
  900. */
  901. MatPaginatedTabHeader.prototype.ngAfterContentInit = /**
  902. * @return {?}
  903. */
  904. function () {
  905. var _this = this;
  906. /** @type {?} */
  907. var dirChange = this._dir ? this._dir.change : of(null);
  908. /** @type {?} */
  909. var resize = this._viewportRuler.change(150);
  910. /** @type {?} */
  911. var realign = (/**
  912. * @return {?}
  913. */
  914. function () {
  915. _this.updatePagination();
  916. _this._alignInkBarToSelectedTab();
  917. });
  918. this._keyManager = new FocusKeyManager(this._items)
  919. .withHorizontalOrientation(this._getLayoutDirection())
  920. .withWrap();
  921. this._keyManager.updateActiveItem(0);
  922. // Defer the first call in order to allow for slower browsers to lay out the elements.
  923. // This helps in cases where the user lands directly on a page with paginated tabs.
  924. typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame(realign) : realign();
  925. // On dir change or window resize, realign the ink bar and update the orientation of
  926. // the key manager if the direction has changed.
  927. merge(dirChange, resize, this._items.changes).pipe(takeUntil(this._destroyed)).subscribe((/**
  928. * @return {?}
  929. */
  930. function () {
  931. realign();
  932. _this._keyManager.withHorizontalOrientation(_this._getLayoutDirection());
  933. }));
  934. // If there is a change in the focus key manager we need to emit the `indexFocused`
  935. // event in order to provide a public event that notifies about focus changes. Also we realign
  936. // the tabs container by scrolling the new focused tab into the visible section.
  937. this._keyManager.change.pipe(takeUntil(this._destroyed)).subscribe((/**
  938. * @param {?} newFocusIndex
  939. * @return {?}
  940. */
  941. function (newFocusIndex) {
  942. _this.indexFocused.emit(newFocusIndex);
  943. _this._setTabFocus(newFocusIndex);
  944. }));
  945. };
  946. /**
  947. * @return {?}
  948. */
  949. MatPaginatedTabHeader.prototype.ngAfterContentChecked = /**
  950. * @return {?}
  951. */
  952. function () {
  953. // If the number of tab labels have changed, check if scrolling should be enabled
  954. if (this._tabLabelCount != this._items.length) {
  955. this.updatePagination();
  956. this._tabLabelCount = this._items.length;
  957. this._changeDetectorRef.markForCheck();
  958. }
  959. // If the selected index has changed, scroll to the label and check if the scrolling controls
  960. // should be disabled.
  961. if (this._selectedIndexChanged) {
  962. this._scrollToLabel(this._selectedIndex);
  963. this._checkScrollingControls();
  964. this._alignInkBarToSelectedTab();
  965. this._selectedIndexChanged = false;
  966. this._changeDetectorRef.markForCheck();
  967. }
  968. // If the scroll distance has been changed (tab selected, focused, scroll controls activated),
  969. // then translate the header to reflect this.
  970. if (this._scrollDistanceChanged) {
  971. this._updateTabScrollPosition();
  972. this._scrollDistanceChanged = false;
  973. this._changeDetectorRef.markForCheck();
  974. }
  975. };
  976. /**
  977. * @return {?}
  978. */
  979. MatPaginatedTabHeader.prototype.ngOnDestroy = /**
  980. * @return {?}
  981. */
  982. function () {
  983. this._destroyed.next();
  984. this._destroyed.complete();
  985. this._stopScrolling.complete();
  986. };
  987. /** Handles keyboard events on the header. */
  988. /**
  989. * Handles keyboard events on the header.
  990. * @param {?} event
  991. * @return {?}
  992. */
  993. MatPaginatedTabHeader.prototype._handleKeydown = /**
  994. * Handles keyboard events on the header.
  995. * @param {?} event
  996. * @return {?}
  997. */
  998. function (event) {
  999. // We don't handle any key bindings with a modifier key.
  1000. if (hasModifierKey(event)) {
  1001. return;
  1002. }
  1003. switch (event.keyCode) {
  1004. case HOME:
  1005. this._keyManager.setFirstItemActive();
  1006. event.preventDefault();
  1007. break;
  1008. case END:
  1009. this._keyManager.setLastItemActive();
  1010. event.preventDefault();
  1011. break;
  1012. case ENTER:
  1013. case SPACE:
  1014. this.selectFocusedIndex.emit(this.focusIndex);
  1015. this._itemSelected(event);
  1016. break;
  1017. default:
  1018. this._keyManager.onKeydown(event);
  1019. }
  1020. };
  1021. /**
  1022. * Callback for when the MutationObserver detects that the content has changed.
  1023. */
  1024. /**
  1025. * Callback for when the MutationObserver detects that the content has changed.
  1026. * @return {?}
  1027. */
  1028. MatPaginatedTabHeader.prototype._onContentChanges = /**
  1029. * Callback for when the MutationObserver detects that the content has changed.
  1030. * @return {?}
  1031. */
  1032. function () {
  1033. var _this = this;
  1034. /** @type {?} */
  1035. var textContent = this._elementRef.nativeElement.textContent;
  1036. // We need to diff the text content of the header, because the MutationObserver callback
  1037. // will fire even if the text content didn't change which is inefficient and is prone
  1038. // to infinite loops if a poorly constructed expression is passed in (see #14249).
  1039. if (textContent !== this._currentTextContent) {
  1040. this._currentTextContent = textContent || '';
  1041. // The content observer runs outside the `NgZone` by default, which
  1042. // means that we need to bring the callback back in ourselves.
  1043. this._ngZone.run((/**
  1044. * @return {?}
  1045. */
  1046. function () {
  1047. _this.updatePagination();
  1048. _this._alignInkBarToSelectedTab();
  1049. _this._changeDetectorRef.markForCheck();
  1050. }));
  1051. }
  1052. };
  1053. /**
  1054. * Updates the view whether pagination should be enabled or not.
  1055. *
  1056. * WARNING: Calling this method can be very costly in terms of performance. It should be called
  1057. * as infrequently as possible from outside of the Tabs component as it causes a reflow of the
  1058. * page.
  1059. */
  1060. /**
  1061. * Updates the view whether pagination should be enabled or not.
  1062. *
  1063. * WARNING: Calling this method can be very costly in terms of performance. It should be called
  1064. * as infrequently as possible from outside of the Tabs component as it causes a reflow of the
  1065. * page.
  1066. * @return {?}
  1067. */
  1068. MatPaginatedTabHeader.prototype.updatePagination = /**
  1069. * Updates the view whether pagination should be enabled or not.
  1070. *
  1071. * WARNING: Calling this method can be very costly in terms of performance. It should be called
  1072. * as infrequently as possible from outside of the Tabs component as it causes a reflow of the
  1073. * page.
  1074. * @return {?}
  1075. */
  1076. function () {
  1077. this._checkPaginationEnabled();
  1078. this._checkScrollingControls();
  1079. this._updateTabScrollPosition();
  1080. };
  1081. Object.defineProperty(MatPaginatedTabHeader.prototype, "focusIndex", {
  1082. /** Tracks which element has focus; used for keyboard navigation */
  1083. get: /**
  1084. * Tracks which element has focus; used for keyboard navigation
  1085. * @return {?}
  1086. */
  1087. function () {
  1088. return this._keyManager ? (/** @type {?} */ (this._keyManager.activeItemIndex)) : 0;
  1089. },
  1090. /** When the focus index is set, we must manually send focus to the correct label */
  1091. set: /**
  1092. * When the focus index is set, we must manually send focus to the correct label
  1093. * @param {?} value
  1094. * @return {?}
  1095. */
  1096. function (value) {
  1097. if (!this._isValidIndex(value) || this.focusIndex === value || !this._keyManager) {
  1098. return;
  1099. }
  1100. this._keyManager.setActiveItem(value);
  1101. },
  1102. enumerable: true,
  1103. configurable: true
  1104. });
  1105. /**
  1106. * Determines if an index is valid. If the tabs are not ready yet, we assume that the user is
  1107. * providing a valid index and return true.
  1108. */
  1109. /**
  1110. * Determines if an index is valid. If the tabs are not ready yet, we assume that the user is
  1111. * providing a valid index and return true.
  1112. * @param {?} index
  1113. * @return {?}
  1114. */
  1115. MatPaginatedTabHeader.prototype._isValidIndex = /**
  1116. * Determines if an index is valid. If the tabs are not ready yet, we assume that the user is
  1117. * providing a valid index and return true.
  1118. * @param {?} index
  1119. * @return {?}
  1120. */
  1121. function (index) {
  1122. if (!this._items) {
  1123. return true;
  1124. }
  1125. /** @type {?} */
  1126. var tab = this._items ? this._items.toArray()[index] : null;
  1127. return !!tab && !tab.disabled;
  1128. };
  1129. /**
  1130. * Sets focus on the HTML element for the label wrapper and scrolls it into the view if
  1131. * scrolling is enabled.
  1132. */
  1133. /**
  1134. * Sets focus on the HTML element for the label wrapper and scrolls it into the view if
  1135. * scrolling is enabled.
  1136. * @param {?} tabIndex
  1137. * @return {?}
  1138. */
  1139. MatPaginatedTabHeader.prototype._setTabFocus = /**
  1140. * Sets focus on the HTML element for the label wrapper and scrolls it into the view if
  1141. * scrolling is enabled.
  1142. * @param {?} tabIndex
  1143. * @return {?}
  1144. */
  1145. function (tabIndex) {
  1146. if (this._showPaginationControls) {
  1147. this._scrollToLabel(tabIndex);
  1148. }
  1149. if (this._items && this._items.length) {
  1150. this._items.toArray()[tabIndex].focus();
  1151. // Do not let the browser manage scrolling to focus the element, this will be handled
  1152. // by using translation. In LTR, the scroll left should be 0. In RTL, the scroll width
  1153. // should be the full width minus the offset width.
  1154. /** @type {?} */
  1155. var containerEl = this._tabListContainer.nativeElement;
  1156. /** @type {?} */
  1157. var dir = this._getLayoutDirection();
  1158. if (dir == 'ltr') {
  1159. containerEl.scrollLeft = 0;
  1160. }
  1161. else {
  1162. containerEl.scrollLeft = containerEl.scrollWidth - containerEl.offsetWidth;
  1163. }
  1164. }
  1165. };
  1166. /** The layout direction of the containing app. */
  1167. /**
  1168. * The layout direction of the containing app.
  1169. * @return {?}
  1170. */
  1171. MatPaginatedTabHeader.prototype._getLayoutDirection = /**
  1172. * The layout direction of the containing app.
  1173. * @return {?}
  1174. */
  1175. function () {
  1176. return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
  1177. };
  1178. /** Performs the CSS transformation on the tab list that will cause the list to scroll. */
  1179. /**
  1180. * Performs the CSS transformation on the tab list that will cause the list to scroll.
  1181. * @return {?}
  1182. */
  1183. MatPaginatedTabHeader.prototype._updateTabScrollPosition = /**
  1184. * Performs the CSS transformation on the tab list that will cause the list to scroll.
  1185. * @return {?}
  1186. */
  1187. function () {
  1188. /** @type {?} */
  1189. var scrollDistance = this.scrollDistance;
  1190. /** @type {?} */
  1191. var platform = this._platform;
  1192. /** @type {?} */
  1193. var translateX = this._getLayoutDirection() === 'ltr' ? -scrollDistance : scrollDistance;
  1194. // Don't use `translate3d` here because we don't want to create a new layer. A new layer
  1195. // seems to cause flickering and overflow in Internet Explorer. For example, the ink bar
  1196. // and ripples will exceed the boundaries of the visible tab bar.
  1197. // See: https://github.com/angular/components/issues/10276
  1198. // We round the `transform` here, because transforms with sub-pixel precision cause some
  1199. // browsers to blur the content of the element.
  1200. this._tabList.nativeElement.style.transform = "translateX(" + Math.round(translateX) + "px)";
  1201. // Setting the `transform` on IE will change the scroll offset of the parent, causing the
  1202. // position to be thrown off in some cases. We have to reset it ourselves to ensure that
  1203. // it doesn't get thrown off. Note that we scope it only to IE and Edge, because messing
  1204. // with the scroll position throws off Chrome 71+ in RTL mode (see #14689).
  1205. // @breaking-change 9.0.0 Remove null check for `platform` after it can no longer be undefined.
  1206. if (platform && (platform.TRIDENT || platform.EDGE)) {
  1207. this._tabListContainer.nativeElement.scrollLeft = 0;
  1208. }
  1209. };
  1210. Object.defineProperty(MatPaginatedTabHeader.prototype, "scrollDistance", {
  1211. /** Sets the distance in pixels that the tab header should be transformed in the X-axis. */
  1212. get: /**
  1213. * Sets the distance in pixels that the tab header should be transformed in the X-axis.
  1214. * @return {?}
  1215. */
  1216. function () { return this._scrollDistance; },
  1217. set: /**
  1218. * @param {?} value
  1219. * @return {?}
  1220. */
  1221. function (value) {
  1222. this._scrollTo(value);
  1223. },
  1224. enumerable: true,
  1225. configurable: true
  1226. });
  1227. /**
  1228. * Moves the tab list in the 'before' or 'after' direction (towards the beginning of the list or
  1229. * the end of the list, respectively). The distance to scroll is computed to be a third of the
  1230. * length of the tab list view window.
  1231. *
  1232. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1233. * should be called sparingly.
  1234. */
  1235. /**
  1236. * Moves the tab list in the 'before' or 'after' direction (towards the beginning of the list or
  1237. * the end of the list, respectively). The distance to scroll is computed to be a third of the
  1238. * length of the tab list view window.
  1239. *
  1240. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1241. * should be called sparingly.
  1242. * @param {?} direction
  1243. * @return {?}
  1244. */
  1245. MatPaginatedTabHeader.prototype._scrollHeader = /**
  1246. * Moves the tab list in the 'before' or 'after' direction (towards the beginning of the list or
  1247. * the end of the list, respectively). The distance to scroll is computed to be a third of the
  1248. * length of the tab list view window.
  1249. *
  1250. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1251. * should be called sparingly.
  1252. * @param {?} direction
  1253. * @return {?}
  1254. */
  1255. function (direction) {
  1256. /** @type {?} */
  1257. var viewLength = this._tabListContainer.nativeElement.offsetWidth;
  1258. // Move the scroll distance one-third the length of the tab list's viewport.
  1259. /** @type {?} */
  1260. var scrollAmount = (direction == 'before' ? -1 : 1) * viewLength / 3;
  1261. return this._scrollTo(this._scrollDistance + scrollAmount);
  1262. };
  1263. /** Handles click events on the pagination arrows. */
  1264. /**
  1265. * Handles click events on the pagination arrows.
  1266. * @param {?} direction
  1267. * @return {?}
  1268. */
  1269. MatPaginatedTabHeader.prototype._handlePaginatorClick = /**
  1270. * Handles click events on the pagination arrows.
  1271. * @param {?} direction
  1272. * @return {?}
  1273. */
  1274. function (direction) {
  1275. this._stopInterval();
  1276. this._scrollHeader(direction);
  1277. };
  1278. /**
  1279. * Moves the tab list such that the desired tab label (marked by index) is moved into view.
  1280. *
  1281. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1282. * should be called sparingly.
  1283. */
  1284. /**
  1285. * Moves the tab list such that the desired tab label (marked by index) is moved into view.
  1286. *
  1287. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1288. * should be called sparingly.
  1289. * @param {?} labelIndex
  1290. * @return {?}
  1291. */
  1292. MatPaginatedTabHeader.prototype._scrollToLabel = /**
  1293. * Moves the tab list such that the desired tab label (marked by index) is moved into view.
  1294. *
  1295. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1296. * should be called sparingly.
  1297. * @param {?} labelIndex
  1298. * @return {?}
  1299. */
  1300. function (labelIndex) {
  1301. /** @type {?} */
  1302. var selectedLabel = this._items ? this._items.toArray()[labelIndex] : null;
  1303. if (!selectedLabel) {
  1304. return;
  1305. }
  1306. // The view length is the visible width of the tab labels.
  1307. /** @type {?} */
  1308. var viewLength = this._tabListContainer.nativeElement.offsetWidth;
  1309. var _a = selectedLabel.elementRef.nativeElement, offsetLeft = _a.offsetLeft, offsetWidth = _a.offsetWidth;
  1310. /** @type {?} */
  1311. var labelBeforePos;
  1312. /** @type {?} */
  1313. var labelAfterPos;
  1314. if (this._getLayoutDirection() == 'ltr') {
  1315. labelBeforePos = offsetLeft;
  1316. labelAfterPos = labelBeforePos + offsetWidth;
  1317. }
  1318. else {
  1319. labelAfterPos = this._tabList.nativeElement.offsetWidth - offsetLeft;
  1320. labelBeforePos = labelAfterPos - offsetWidth;
  1321. }
  1322. /** @type {?} */
  1323. var beforeVisiblePos = this.scrollDistance;
  1324. /** @type {?} */
  1325. var afterVisiblePos = this.scrollDistance + viewLength;
  1326. if (labelBeforePos < beforeVisiblePos) {
  1327. // Scroll header to move label to the before direction
  1328. this.scrollDistance -= beforeVisiblePos - labelBeforePos + EXAGGERATED_OVERSCROLL;
  1329. }
  1330. else if (labelAfterPos > afterVisiblePos) {
  1331. // Scroll header to move label to the after direction
  1332. this.scrollDistance += labelAfterPos - afterVisiblePos + EXAGGERATED_OVERSCROLL;
  1333. }
  1334. };
  1335. /**
  1336. * Evaluate whether the pagination controls should be displayed. If the scroll width of the
  1337. * tab list is wider than the size of the header container, then the pagination controls should
  1338. * be shown.
  1339. *
  1340. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1341. * should be called sparingly.
  1342. */
  1343. /**
  1344. * Evaluate whether the pagination controls should be displayed. If the scroll width of the
  1345. * tab list is wider than the size of the header container, then the pagination controls should
  1346. * be shown.
  1347. *
  1348. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1349. * should be called sparingly.
  1350. * @return {?}
  1351. */
  1352. MatPaginatedTabHeader.prototype._checkPaginationEnabled = /**
  1353. * Evaluate whether the pagination controls should be displayed. If the scroll width of the
  1354. * tab list is wider than the size of the header container, then the pagination controls should
  1355. * be shown.
  1356. *
  1357. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1358. * should be called sparingly.
  1359. * @return {?}
  1360. */
  1361. function () {
  1362. /** @type {?} */
  1363. var isEnabled = this._tabList.nativeElement.scrollWidth > this._elementRef.nativeElement.offsetWidth;
  1364. if (!isEnabled) {
  1365. this.scrollDistance = 0;
  1366. }
  1367. if (isEnabled !== this._showPaginationControls) {
  1368. this._changeDetectorRef.markForCheck();
  1369. }
  1370. this._showPaginationControls = isEnabled;
  1371. };
  1372. /**
  1373. * Evaluate whether the before and after controls should be enabled or disabled.
  1374. * If the header is at the beginning of the list (scroll distance is equal to 0) then disable the
  1375. * before button. If the header is at the end of the list (scroll distance is equal to the
  1376. * maximum distance we can scroll), then disable the after button.
  1377. *
  1378. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1379. * should be called sparingly.
  1380. */
  1381. /**
  1382. * Evaluate whether the before and after controls should be enabled or disabled.
  1383. * If the header is at the beginning of the list (scroll distance is equal to 0) then disable the
  1384. * before button. If the header is at the end of the list (scroll distance is equal to the
  1385. * maximum distance we can scroll), then disable the after button.
  1386. *
  1387. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1388. * should be called sparingly.
  1389. * @return {?}
  1390. */
  1391. MatPaginatedTabHeader.prototype._checkScrollingControls = /**
  1392. * Evaluate whether the before and after controls should be enabled or disabled.
  1393. * If the header is at the beginning of the list (scroll distance is equal to 0) then disable the
  1394. * before button. If the header is at the end of the list (scroll distance is equal to the
  1395. * maximum distance we can scroll), then disable the after button.
  1396. *
  1397. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1398. * should be called sparingly.
  1399. * @return {?}
  1400. */
  1401. function () {
  1402. // Check if the pagination arrows should be activated.
  1403. this._disableScrollBefore = this.scrollDistance == 0;
  1404. this._disableScrollAfter = this.scrollDistance == this._getMaxScrollDistance();
  1405. this._changeDetectorRef.markForCheck();
  1406. };
  1407. /**
  1408. * Determines what is the maximum length in pixels that can be set for the scroll distance. This
  1409. * is equal to the difference in width between the tab list container and tab header container.
  1410. *
  1411. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1412. * should be called sparingly.
  1413. */
  1414. /**
  1415. * Determines what is the maximum length in pixels that can be set for the scroll distance. This
  1416. * is equal to the difference in width between the tab list container and tab header container.
  1417. *
  1418. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1419. * should be called sparingly.
  1420. * @return {?}
  1421. */
  1422. MatPaginatedTabHeader.prototype._getMaxScrollDistance = /**
  1423. * Determines what is the maximum length in pixels that can be set for the scroll distance. This
  1424. * is equal to the difference in width between the tab list container and tab header container.
  1425. *
  1426. * This is an expensive call that forces a layout reflow to compute box and scroll metrics and
  1427. * should be called sparingly.
  1428. * @return {?}
  1429. */
  1430. function () {
  1431. /** @type {?} */
  1432. var lengthOfTabList = this._tabList.nativeElement.scrollWidth;
  1433. /** @type {?} */
  1434. var viewLength = this._tabListContainer.nativeElement.offsetWidth;
  1435. return (lengthOfTabList - viewLength) || 0;
  1436. };
  1437. /** Tells the ink-bar to align itself to the current label wrapper */
  1438. /**
  1439. * Tells the ink-bar to align itself to the current label wrapper
  1440. * @return {?}
  1441. */
  1442. MatPaginatedTabHeader.prototype._alignInkBarToSelectedTab = /**
  1443. * Tells the ink-bar to align itself to the current label wrapper
  1444. * @return {?}
  1445. */
  1446. function () {
  1447. /** @type {?} */
  1448. var selectedItem = this._items && this._items.length ?
  1449. this._items.toArray()[this.selectedIndex] : null;
  1450. /** @type {?} */
  1451. var selectedLabelWrapper = selectedItem ? selectedItem.elementRef.nativeElement : null;
  1452. if (selectedLabelWrapper) {
  1453. this._inkBar.alignToElement(selectedLabelWrapper);
  1454. }
  1455. else {
  1456. this._inkBar.hide();
  1457. }
  1458. };
  1459. /** Stops the currently-running paginator interval. */
  1460. /**
  1461. * Stops the currently-running paginator interval.
  1462. * @return {?}
  1463. */
  1464. MatPaginatedTabHeader.prototype._stopInterval = /**
  1465. * Stops the currently-running paginator interval.
  1466. * @return {?}
  1467. */
  1468. function () {
  1469. this._stopScrolling.next();
  1470. };
  1471. /**
  1472. * Handles the user pressing down on one of the paginators.
  1473. * Starts scrolling the header after a certain amount of time.
  1474. * @param direction In which direction the paginator should be scrolled.
  1475. */
  1476. /**
  1477. * Handles the user pressing down on one of the paginators.
  1478. * Starts scrolling the header after a certain amount of time.
  1479. * @param {?} direction In which direction the paginator should be scrolled.
  1480. * @return {?}
  1481. */
  1482. MatPaginatedTabHeader.prototype._handlePaginatorPress = /**
  1483. * Handles the user pressing down on one of the paginators.
  1484. * Starts scrolling the header after a certain amount of time.
  1485. * @param {?} direction In which direction the paginator should be scrolled.
  1486. * @return {?}
  1487. */
  1488. function (direction) {
  1489. var _this = this;
  1490. // Avoid overlapping timers.
  1491. this._stopInterval();
  1492. // Start a timer after the delay and keep firing based on the interval.
  1493. timer(HEADER_SCROLL_DELAY, HEADER_SCROLL_INTERVAL)
  1494. // Keep the timer going until something tells it to stop or the component is destroyed.
  1495. .pipe(takeUntil(merge(this._stopScrolling, this._destroyed)))
  1496. .subscribe((/**
  1497. * @return {?}
  1498. */
  1499. function () {
  1500. var _a = _this._scrollHeader(direction), maxScrollDistance = _a.maxScrollDistance, distance = _a.distance;
  1501. // Stop the timer if we've reached the start or the end.
  1502. if (distance === 0 || distance >= maxScrollDistance) {
  1503. _this._stopInterval();
  1504. }
  1505. }));
  1506. };
  1507. /**
  1508. * Scrolls the header to a given position.
  1509. * @param position Position to which to scroll.
  1510. * @returns Information on the current scroll distance and the maximum.
  1511. */
  1512. /**
  1513. * Scrolls the header to a given position.
  1514. * @private
  1515. * @param {?} position Position to which to scroll.
  1516. * @return {?} Information on the current scroll distance and the maximum.
  1517. */
  1518. MatPaginatedTabHeader.prototype._scrollTo = /**
  1519. * Scrolls the header to a given position.
  1520. * @private
  1521. * @param {?} position Position to which to scroll.
  1522. * @return {?} Information on the current scroll distance and the maximum.
  1523. */
  1524. function (position) {
  1525. /** @type {?} */
  1526. var maxScrollDistance = this._getMaxScrollDistance();
  1527. this._scrollDistance = Math.max(0, Math.min(maxScrollDistance, position));
  1528. // Mark that the scroll distance has changed so that after the view is checked, the CSS
  1529. // transformation can move the header.
  1530. this._scrollDistanceChanged = true;
  1531. this._checkScrollingControls();
  1532. return { maxScrollDistance: maxScrollDistance, distance: this._scrollDistance };
  1533. };
  1534. /** @nocollapse */
  1535. MatPaginatedTabHeader.ctorParameters = function () { return [
  1536. { type: ElementRef },
  1537. { type: ChangeDetectorRef },
  1538. { type: ViewportRuler },
  1539. { type: Directionality, decorators: [{ type: Optional }] },
  1540. { type: NgZone },
  1541. { type: Platform },
  1542. { type: String }
  1543. ]; };
  1544. return MatPaginatedTabHeader;
  1545. }());
  1546. /**
  1547. * @fileoverview added by tsickle
  1548. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1549. */
  1550. /**
  1551. * The header of the tab group which displays a list of all the tabs in the tab group. Includes
  1552. * an ink bar that follows the currently selected tab. When the tabs list's width exceeds the
  1553. * width of the header container, then arrows will be displayed to allow the user to scroll
  1554. * left and right across the header.
  1555. * \@docs-private
  1556. */
  1557. var MatTabHeader = /** @class */ (function (_super) {
  1558. __extends(MatTabHeader, _super);
  1559. function MatTabHeader(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform,
  1560. // @breaking-change 9.0.0 `_animationMode` parameter to be made required.
  1561. animationMode) {
  1562. var _this = _super.call(this, elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode) || this;
  1563. _this._disableRipple = false;
  1564. return _this;
  1565. }
  1566. Object.defineProperty(MatTabHeader.prototype, "disableRipple", {
  1567. /** Whether the ripple effect is disabled or not. */
  1568. get: /**
  1569. * Whether the ripple effect is disabled or not.
  1570. * @return {?}
  1571. */
  1572. function () { return this._disableRipple; },
  1573. set: /**
  1574. * @param {?} value
  1575. * @return {?}
  1576. */
  1577. function (value) { this._disableRipple = coerceBooleanProperty(value); },
  1578. enumerable: true,
  1579. configurable: true
  1580. });
  1581. /**
  1582. * @protected
  1583. * @param {?} event
  1584. * @return {?}
  1585. */
  1586. MatTabHeader.prototype._itemSelected = /**
  1587. * @protected
  1588. * @param {?} event
  1589. * @return {?}
  1590. */
  1591. function (event) {
  1592. event.preventDefault();
  1593. };
  1594. MatTabHeader.decorators = [
  1595. { type: Component, args: [{selector: 'mat-tab-header',
  1596. template: "<div class=\"mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4\" #previousPaginator aria-hidden=\"true\" mat-ripple [matRippleDisabled]=\"_disableScrollBefore || disableRipple\" [class.mat-tab-header-pagination-disabled]=\"_disableScrollBefore\" (click)=\"_handlePaginatorClick('before')\" (mousedown)=\"_handlePaginatorPress('before')\" (touchend)=\"_stopInterval()\"><div class=\"mat-tab-header-pagination-chevron\"></div></div><div class=\"mat-tab-label-container\" #tabListContainer (keydown)=\"_handleKeydown($event)\"><div #tabList class=\"mat-tab-list\" [class._mat-animation-noopable]=\"_animationMode === 'NoopAnimations'\" role=\"tablist\" (cdkObserveContent)=\"_onContentChanges()\"><div class=\"mat-tab-labels\"><ng-content></ng-content></div><mat-ink-bar></mat-ink-bar></div></div><div class=\"mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4\" #nextPaginator aria-hidden=\"true\" mat-ripple [matRippleDisabled]=\"_disableScrollAfter || disableRipple\" [class.mat-tab-header-pagination-disabled]=\"_disableScrollAfter\" (mousedown)=\"_handlePaginatorPress('after')\" (click)=\"_handlePaginatorClick('after')\" (touchend)=\"_stopInterval()\"><div class=\"mat-tab-header-pagination-chevron\"></div></div>",
  1597. 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-pagination-after,.mat-tab-header-rtl .mat-tab-header-pagination-before{padding-right:4px}.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron,.mat-tab-header-rtl .mat-tab-header-pagination-before .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 .5s cubic-bezier(.35,0,.25,1)}.mat-ink-bar{position:absolute;bottom:0;height:2px;transition:.5s cubic-bezier(.35,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}@media (-ms-high-contrast:active){.mat-ink-bar{outline:solid 2px;height:0}}.mat-tab-labels{display:flex}[mat-align-tabs=center] .mat-tab-labels{justify-content:center}[mat-align-tabs=end] .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:0}.mat-tab-label:focus:not(.mat-tab-disabled){opacity:1}@media (-ms-high-contrast:active){.mat-tab-label:focus{outline:dotted 2px}}.mat-tab-label.mat-tab-disabled{cursor:default}@media (-ms-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}@media (-ms-high-contrast:active){.mat-tab-label{opacity:1}}@media (max-width:599px){.mat-tab-label{min-width:72px}}"],
  1598. inputs: ['selectedIndex'],
  1599. outputs: ['selectFocusedIndex', 'indexFocused'],
  1600. encapsulation: ViewEncapsulation.None,
  1601. changeDetection: ChangeDetectionStrategy.OnPush,
  1602. host: {
  1603. 'class': 'mat-tab-header',
  1604. '[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',
  1605. '[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'",
  1606. },
  1607. },] },
  1608. ];
  1609. /** @nocollapse */
  1610. MatTabHeader.ctorParameters = function () { return [
  1611. { type: ElementRef },
  1612. { type: ChangeDetectorRef },
  1613. { type: ViewportRuler },
  1614. { type: Directionality, decorators: [{ type: Optional }] },
  1615. { type: NgZone },
  1616. { type: Platform },
  1617. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  1618. ]; };
  1619. MatTabHeader.propDecorators = {
  1620. _items: [{ type: ContentChildren, args: [MatTabLabelWrapper,] }],
  1621. _inkBar: [{ type: ViewChild, args: [MatInkBar, { static: true },] }],
  1622. _tabListContainer: [{ type: ViewChild, args: ['tabListContainer', { static: true },] }],
  1623. _tabList: [{ type: ViewChild, args: ['tabList', { static: true },] }],
  1624. _nextPaginator: [{ type: ViewChild, args: ['nextPaginator', { static: false },] }],
  1625. _previousPaginator: [{ type: ViewChild, args: ['previousPaginator', { static: false },] }],
  1626. disableRipple: [{ type: Input }]
  1627. };
  1628. return MatTabHeader;
  1629. }(MatPaginatedTabHeader));
  1630. /**
  1631. * @fileoverview added by tsickle
  1632. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1633. */
  1634. /**
  1635. * Used to generate unique ID's for each tab component
  1636. * @type {?}
  1637. */
  1638. var nextId = 0;
  1639. /**
  1640. * A simple change event emitted on focus or selection changes.
  1641. */
  1642. var /**
  1643. * A simple change event emitted on focus or selection changes.
  1644. */
  1645. MatTabChangeEvent = /** @class */ (function () {
  1646. function MatTabChangeEvent() {
  1647. }
  1648. return MatTabChangeEvent;
  1649. }());
  1650. /**
  1651. * Injection token that can be used to provide the default options the tabs module.
  1652. * @type {?}
  1653. */
  1654. var MAT_TABS_CONFIG = new InjectionToken('MAT_TABS_CONFIG');
  1655. // Boilerplate for applying mixins to MatTabGroup.
  1656. /**
  1657. * \@docs-private
  1658. */
  1659. var
  1660. // Boilerplate for applying mixins to MatTabGroup.
  1661. /**
  1662. * \@docs-private
  1663. */
  1664. MatTabGroupBase = /** @class */ (function () {
  1665. function MatTabGroupBase(_elementRef) {
  1666. this._elementRef = _elementRef;
  1667. }
  1668. return MatTabGroupBase;
  1669. }());
  1670. /** @type {?} */
  1671. var _MatTabGroupMixinBase = mixinColor(mixinDisableRipple(MatTabGroupBase), 'primary');
  1672. /**
  1673. * Material design tab-group component. Supports basic tab pairs (label + content) and includes
  1674. * animated ink-bar, keyboard navigation, and screen reader.
  1675. * See: https://material.io/design/components/tabs.html
  1676. */
  1677. var MatTabGroup = /** @class */ (function (_super) {
  1678. __extends(MatTabGroup, _super);
  1679. function MatTabGroup(elementRef, _changeDetectorRef, defaultConfig, _animationMode) {
  1680. var _this = _super.call(this, elementRef) || this;
  1681. _this._changeDetectorRef = _changeDetectorRef;
  1682. _this._animationMode = _animationMode;
  1683. /**
  1684. * The tab index that should be selected after the content has been checked.
  1685. */
  1686. _this._indexToSelect = 0;
  1687. /**
  1688. * Snapshot of the height of the tab body wrapper before another tab is activated.
  1689. */
  1690. _this._tabBodyWrapperHeight = 0;
  1691. /**
  1692. * Subscription to tabs being added/removed.
  1693. */
  1694. _this._tabsSubscription = Subscription.EMPTY;
  1695. /**
  1696. * Subscription to changes in the tab labels.
  1697. */
  1698. _this._tabLabelSubscription = Subscription.EMPTY;
  1699. _this._dynamicHeight = false;
  1700. _this._selectedIndex = null;
  1701. /**
  1702. * Position of the tab header.
  1703. */
  1704. _this.headerPosition = 'above';
  1705. /**
  1706. * Output to enable support for two-way binding on `[(selectedIndex)]`
  1707. */
  1708. _this.selectedIndexChange = new EventEmitter();
  1709. /**
  1710. * Event emitted when focus has changed within a tab group.
  1711. */
  1712. _this.focusChange = new EventEmitter();
  1713. /**
  1714. * Event emitted when the body animation has completed
  1715. */
  1716. _this.animationDone = new EventEmitter();
  1717. /**
  1718. * Event emitted when the tab selection has changed.
  1719. */
  1720. _this.selectedTabChange = new EventEmitter(true);
  1721. _this._groupId = nextId++;
  1722. _this.animationDuration = defaultConfig && defaultConfig.animationDuration ?
  1723. defaultConfig.animationDuration : '500ms';
  1724. return _this;
  1725. }
  1726. Object.defineProperty(MatTabGroup.prototype, "dynamicHeight", {
  1727. /** Whether the tab group should grow to the size of the active tab. */
  1728. get: /**
  1729. * Whether the tab group should grow to the size of the active tab.
  1730. * @return {?}
  1731. */
  1732. function () { return this._dynamicHeight; },
  1733. set: /**
  1734. * @param {?} value
  1735. * @return {?}
  1736. */
  1737. function (value) { this._dynamicHeight = coerceBooleanProperty(value); },
  1738. enumerable: true,
  1739. configurable: true
  1740. });
  1741. Object.defineProperty(MatTabGroup.prototype, "selectedIndex", {
  1742. /** The index of the active tab. */
  1743. get: /**
  1744. * The index of the active tab.
  1745. * @return {?}
  1746. */
  1747. function () { return this._selectedIndex; },
  1748. set: /**
  1749. * @param {?} value
  1750. * @return {?}
  1751. */
  1752. function (value) {
  1753. this._indexToSelect = coerceNumberProperty(value, null);
  1754. },
  1755. enumerable: true,
  1756. configurable: true
  1757. });
  1758. Object.defineProperty(MatTabGroup.prototype, "animationDuration", {
  1759. /** Duration for the tab animation. Will be normalized to milliseconds if no units are set. */
  1760. get: /**
  1761. * Duration for the tab animation. Will be normalized to milliseconds if no units are set.
  1762. * @return {?}
  1763. */
  1764. function () { return this._animationDuration; },
  1765. set: /**
  1766. * @param {?} value
  1767. * @return {?}
  1768. */
  1769. function (value) {
  1770. this._animationDuration = /^\d+$/.test(value) ? value + 'ms' : value;
  1771. },
  1772. enumerable: true,
  1773. configurable: true
  1774. });
  1775. Object.defineProperty(MatTabGroup.prototype, "backgroundColor", {
  1776. /** Background color of the tab group. */
  1777. get: /**
  1778. * Background color of the tab group.
  1779. * @return {?}
  1780. */
  1781. function () { return this._backgroundColor; },
  1782. set: /**
  1783. * @param {?} value
  1784. * @return {?}
  1785. */
  1786. function (value) {
  1787. /** @type {?} */
  1788. var nativeElement = this._elementRef.nativeElement;
  1789. nativeElement.classList.remove("mat-background-" + this.backgroundColor);
  1790. if (value) {
  1791. nativeElement.classList.add("mat-background-" + value);
  1792. }
  1793. this._backgroundColor = value;
  1794. },
  1795. enumerable: true,
  1796. configurable: true
  1797. });
  1798. /**
  1799. * After the content is checked, this component knows what tabs have been defined
  1800. * and what the selected index should be. This is where we can know exactly what position
  1801. * each tab should be in according to the new selected index, and additionally we know how
  1802. * a new selected tab should transition in (from the left or right).
  1803. */
  1804. /**
  1805. * After the content is checked, this component knows what tabs have been defined
  1806. * and what the selected index should be. This is where we can know exactly what position
  1807. * each tab should be in according to the new selected index, and additionally we know how
  1808. * a new selected tab should transition in (from the left or right).
  1809. * @return {?}
  1810. */
  1811. MatTabGroup.prototype.ngAfterContentChecked = /**
  1812. * After the content is checked, this component knows what tabs have been defined
  1813. * and what the selected index should be. This is where we can know exactly what position
  1814. * each tab should be in according to the new selected index, and additionally we know how
  1815. * a new selected tab should transition in (from the left or right).
  1816. * @return {?}
  1817. */
  1818. function () {
  1819. var _this = this;
  1820. // Don't clamp the `indexToSelect` immediately in the setter because it can happen that
  1821. // the amount of tabs changes before the actual change detection runs.
  1822. /** @type {?} */
  1823. var indexToSelect = this._indexToSelect = this._clampTabIndex(this._indexToSelect);
  1824. // If there is a change in selected index, emit a change event. Should not trigger if
  1825. // the selected index has not yet been initialized.
  1826. if (this._selectedIndex != indexToSelect) {
  1827. /** @type {?} */
  1828. var isFirstRun_1 = this._selectedIndex == null;
  1829. if (!isFirstRun_1) {
  1830. this.selectedTabChange.emit(this._createChangeEvent(indexToSelect));
  1831. }
  1832. // Changing these values after change detection has run
  1833. // since the checked content may contain references to them.
  1834. Promise.resolve().then((/**
  1835. * @return {?}
  1836. */
  1837. function () {
  1838. _this._tabs.forEach((/**
  1839. * @param {?} tab
  1840. * @param {?} index
  1841. * @return {?}
  1842. */
  1843. function (tab, index) { return tab.isActive = index === indexToSelect; }));
  1844. if (!isFirstRun_1) {
  1845. _this.selectedIndexChange.emit(indexToSelect);
  1846. }
  1847. }));
  1848. }
  1849. // Setup the position for each tab and optionally setup an origin on the next selected tab.
  1850. this._tabs.forEach((/**
  1851. * @param {?} tab
  1852. * @param {?} index
  1853. * @return {?}
  1854. */
  1855. function (tab, index) {
  1856. tab.position = index - indexToSelect;
  1857. // If there is already a selected tab, then set up an origin for the next selected tab
  1858. // if it doesn't have one already.
  1859. if (_this._selectedIndex != null && tab.position == 0 && !tab.origin) {
  1860. tab.origin = indexToSelect - _this._selectedIndex;
  1861. }
  1862. }));
  1863. if (this._selectedIndex !== indexToSelect) {
  1864. this._selectedIndex = indexToSelect;
  1865. this._changeDetectorRef.markForCheck();
  1866. }
  1867. };
  1868. /**
  1869. * @return {?}
  1870. */
  1871. MatTabGroup.prototype.ngAfterContentInit = /**
  1872. * @return {?}
  1873. */
  1874. function () {
  1875. var _this = this;
  1876. this._subscribeToTabLabels();
  1877. // Subscribe to changes in the amount of tabs, in order to be
  1878. // able to re-render the content as new tabs are added or removed.
  1879. this._tabsSubscription = this._tabs.changes.subscribe((/**
  1880. * @return {?}
  1881. */
  1882. function () {
  1883. /** @type {?} */
  1884. var indexToSelect = _this._clampTabIndex(_this._indexToSelect);
  1885. // Maintain the previously-selected tab if a new tab is added or removed and there is no
  1886. // explicit change that selects a different tab.
  1887. if (indexToSelect === _this._selectedIndex) {
  1888. /** @type {?} */
  1889. var tabs = _this._tabs.toArray();
  1890. for (var i = 0; i < tabs.length; i++) {
  1891. if (tabs[i].isActive) {
  1892. // Assign both to the `_indexToSelect` and `_selectedIndex` so we don't fire a changed
  1893. // event, otherwise the consumer may end up in an infinite loop in some edge cases like
  1894. // adding a tab within the `selectedIndexChange` event.
  1895. _this._indexToSelect = _this._selectedIndex = i;
  1896. break;
  1897. }
  1898. }
  1899. }
  1900. _this._subscribeToTabLabels();
  1901. _this._changeDetectorRef.markForCheck();
  1902. }));
  1903. };
  1904. /**
  1905. * @return {?}
  1906. */
  1907. MatTabGroup.prototype.ngOnDestroy = /**
  1908. * @return {?}
  1909. */
  1910. function () {
  1911. this._tabsSubscription.unsubscribe();
  1912. this._tabLabelSubscription.unsubscribe();
  1913. };
  1914. /** Re-aligns the ink bar to the selected tab element. */
  1915. /**
  1916. * Re-aligns the ink bar to the selected tab element.
  1917. * @return {?}
  1918. */
  1919. MatTabGroup.prototype.realignInkBar = /**
  1920. * Re-aligns the ink bar to the selected tab element.
  1921. * @return {?}
  1922. */
  1923. function () {
  1924. if (this._tabHeader) {
  1925. this._tabHeader._alignInkBarToSelectedTab();
  1926. }
  1927. };
  1928. /**
  1929. * @param {?} index
  1930. * @return {?}
  1931. */
  1932. MatTabGroup.prototype._focusChanged = /**
  1933. * @param {?} index
  1934. * @return {?}
  1935. */
  1936. function (index) {
  1937. this.focusChange.emit(this._createChangeEvent(index));
  1938. };
  1939. /**
  1940. * @private
  1941. * @param {?} index
  1942. * @return {?}
  1943. */
  1944. MatTabGroup.prototype._createChangeEvent = /**
  1945. * @private
  1946. * @param {?} index
  1947. * @return {?}
  1948. */
  1949. function (index) {
  1950. /** @type {?} */
  1951. var event = new MatTabChangeEvent;
  1952. event.index = index;
  1953. if (this._tabs && this._tabs.length) {
  1954. event.tab = this._tabs.toArray()[index];
  1955. }
  1956. return event;
  1957. };
  1958. /**
  1959. * Subscribes to changes in the tab labels. This is needed, because the @Input for the label is
  1960. * on the MatTab component, whereas the data binding is inside the MatTabGroup. In order for the
  1961. * binding to be updated, we need to subscribe to changes in it and trigger change detection
  1962. * manually.
  1963. */
  1964. /**
  1965. * Subscribes to changes in the tab labels. This is needed, because the \@Input for the label is
  1966. * on the MatTab component, whereas the data binding is inside the MatTabGroup. In order for the
  1967. * binding to be updated, we need to subscribe to changes in it and trigger change detection
  1968. * manually.
  1969. * @private
  1970. * @return {?}
  1971. */
  1972. MatTabGroup.prototype._subscribeToTabLabels = /**
  1973. * Subscribes to changes in the tab labels. This is needed, because the \@Input for the label is
  1974. * on the MatTab component, whereas the data binding is inside the MatTabGroup. In order for the
  1975. * binding to be updated, we need to subscribe to changes in it and trigger change detection
  1976. * manually.
  1977. * @private
  1978. * @return {?}
  1979. */
  1980. function () {
  1981. var _this = this;
  1982. if (this._tabLabelSubscription) {
  1983. this._tabLabelSubscription.unsubscribe();
  1984. }
  1985. this._tabLabelSubscription = merge.apply(void 0, this._tabs.map((/**
  1986. * @param {?} tab
  1987. * @return {?}
  1988. */
  1989. function (tab) { return tab._stateChanges; }))).subscribe((/**
  1990. * @return {?}
  1991. */
  1992. function () { return _this._changeDetectorRef.markForCheck(); }));
  1993. };
  1994. /** Clamps the given index to the bounds of 0 and the tabs length. */
  1995. /**
  1996. * Clamps the given index to the bounds of 0 and the tabs length.
  1997. * @private
  1998. * @param {?} index
  1999. * @return {?}
  2000. */
  2001. MatTabGroup.prototype._clampTabIndex = /**
  2002. * Clamps the given index to the bounds of 0 and the tabs length.
  2003. * @private
  2004. * @param {?} index
  2005. * @return {?}
  2006. */
  2007. function (index) {
  2008. // Note the `|| 0`, which ensures that values like NaN can't get through
  2009. // and which would otherwise throw the component into an infinite loop
  2010. // (since Math.max(NaN, 0) === NaN).
  2011. return Math.min(this._tabs.length - 1, Math.max(index || 0, 0));
  2012. };
  2013. /** Returns a unique id for each tab label element */
  2014. /**
  2015. * Returns a unique id for each tab label element
  2016. * @param {?} i
  2017. * @return {?}
  2018. */
  2019. MatTabGroup.prototype._getTabLabelId = /**
  2020. * Returns a unique id for each tab label element
  2021. * @param {?} i
  2022. * @return {?}
  2023. */
  2024. function (i) {
  2025. return "mat-tab-label-" + this._groupId + "-" + i;
  2026. };
  2027. /** Returns a unique id for each tab content element */
  2028. /**
  2029. * Returns a unique id for each tab content element
  2030. * @param {?} i
  2031. * @return {?}
  2032. */
  2033. MatTabGroup.prototype._getTabContentId = /**
  2034. * Returns a unique id for each tab content element
  2035. * @param {?} i
  2036. * @return {?}
  2037. */
  2038. function (i) {
  2039. return "mat-tab-content-" + this._groupId + "-" + i;
  2040. };
  2041. /**
  2042. * Sets the height of the body wrapper to the height of the activating tab if dynamic
  2043. * height property is true.
  2044. */
  2045. /**
  2046. * Sets the height of the body wrapper to the height of the activating tab if dynamic
  2047. * height property is true.
  2048. * @param {?} tabHeight
  2049. * @return {?}
  2050. */
  2051. MatTabGroup.prototype._setTabBodyWrapperHeight = /**
  2052. * Sets the height of the body wrapper to the height of the activating tab if dynamic
  2053. * height property is true.
  2054. * @param {?} tabHeight
  2055. * @return {?}
  2056. */
  2057. function (tabHeight) {
  2058. if (!this._dynamicHeight || !this._tabBodyWrapperHeight) {
  2059. return;
  2060. }
  2061. /** @type {?} */
  2062. var wrapper = this._tabBodyWrapper.nativeElement;
  2063. wrapper.style.height = this._tabBodyWrapperHeight + 'px';
  2064. // This conditional forces the browser to paint the height so that
  2065. // the animation to the new height can have an origin.
  2066. if (this._tabBodyWrapper.nativeElement.offsetHeight) {
  2067. wrapper.style.height = tabHeight + 'px';
  2068. }
  2069. };
  2070. /** Removes the height of the tab body wrapper. */
  2071. /**
  2072. * Removes the height of the tab body wrapper.
  2073. * @return {?}
  2074. */
  2075. MatTabGroup.prototype._removeTabBodyWrapperHeight = /**
  2076. * Removes the height of the tab body wrapper.
  2077. * @return {?}
  2078. */
  2079. function () {
  2080. /** @type {?} */
  2081. var wrapper = this._tabBodyWrapper.nativeElement;
  2082. this._tabBodyWrapperHeight = wrapper.clientHeight;
  2083. wrapper.style.height = '';
  2084. this.animationDone.emit();
  2085. };
  2086. /** Handle click events, setting new selected index if appropriate. */
  2087. /**
  2088. * Handle click events, setting new selected index if appropriate.
  2089. * @param {?} tab
  2090. * @param {?} tabHeader
  2091. * @param {?} index
  2092. * @return {?}
  2093. */
  2094. MatTabGroup.prototype._handleClick = /**
  2095. * Handle click events, setting new selected index if appropriate.
  2096. * @param {?} tab
  2097. * @param {?} tabHeader
  2098. * @param {?} index
  2099. * @return {?}
  2100. */
  2101. function (tab, tabHeader, index) {
  2102. if (!tab.disabled) {
  2103. this.selectedIndex = tabHeader.focusIndex = index;
  2104. }
  2105. };
  2106. /** Retrieves the tabindex for the tab. */
  2107. /**
  2108. * Retrieves the tabindex for the tab.
  2109. * @param {?} tab
  2110. * @param {?} idx
  2111. * @return {?}
  2112. */
  2113. MatTabGroup.prototype._getTabIndex = /**
  2114. * Retrieves the tabindex for the tab.
  2115. * @param {?} tab
  2116. * @param {?} idx
  2117. * @return {?}
  2118. */
  2119. function (tab, idx) {
  2120. if (tab.disabled) {
  2121. return null;
  2122. }
  2123. return this.selectedIndex === idx ? 0 : -1;
  2124. };
  2125. MatTabGroup.decorators = [
  2126. { type: Component, args: [{selector: 'mat-tab-group',
  2127. exportAs: 'matTabGroup',
  2128. template: "<mat-tab-header #tabHeader [selectedIndex]=\"selectedIndex\" [disableRipple]=\"disableRipple\" (indexFocused)=\"_focusChanged($event)\" (selectFocusedIndex)=\"selectedIndex = $event\"><div class=\"mat-tab-label\" role=\"tab\" matTabLabelWrapper mat-ripple cdkMonitorElementFocus *ngFor=\"let tab of _tabs; let i = index\" [id]=\"_getTabLabelId(i)\" [attr.tabIndex]=\"_getTabIndex(tab, i)\" [attr.aria-posinset]=\"i + 1\" [attr.aria-setsize]=\"_tabs.length\" [attr.aria-controls]=\"_getTabContentId(i)\" [attr.aria-selected]=\"selectedIndex == i\" [attr.aria-label]=\"tab.ariaLabel || null\" [attr.aria-labelledby]=\"(!tab.ariaLabel && tab.ariaLabelledby) ? tab.ariaLabelledby : null\" [class.mat-tab-label-active]=\"selectedIndex == i\" [disabled]=\"tab.disabled\" [matRippleDisabled]=\"tab.disabled || disableRipple\" (click)=\"_handleClick(tab, tabHeader, i)\"><div class=\"mat-tab-label-content\"><ng-template [ngIf]=\"tab.templateLabel\"><ng-template [cdkPortalOutlet]=\"tab.templateLabel\"></ng-template></ng-template><ng-template [ngIf]=\"!tab.templateLabel\">{{tab.textLabel}}</ng-template></div></div></mat-tab-header><div class=\"mat-tab-body-wrapper\" [class._mat-animation-noopable]=\"_animationMode === 'NoopAnimations'\" #tabBodyWrapper><mat-tab-body role=\"tabpanel\" *ngFor=\"let tab of _tabs; let i = index\" [id]=\"_getTabContentId(i)\" [attr.aria-labelledby]=\"_getTabLabelId(i)\" [class.mat-tab-body-active]=\"selectedIndex == i\" [content]=\"tab.content\" [position]=\"tab.position\" [origin]=\"tab.origin\" [animationDuration]=\"animationDuration\" (_onCentered)=\"_removeTabBodyWrapperHeight()\" (_onCentering)=\"_setTabBodyWrapperHeight($event)\"></mat-tab-body></div>",
  2129. styles: [".mat-tab-group{display:flex;flex-direction:column}.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:0}.mat-tab-label:focus:not(.mat-tab-disabled){opacity:1}@media (-ms-high-contrast:active){.mat-tab-label:focus{outline:dotted 2px}}.mat-tab-label.mat-tab-disabled{cursor:default}@media (-ms-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}@media (-ms-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 .5s cubic-bezier(.35,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;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}"],
  2130. encapsulation: ViewEncapsulation.None,
  2131. changeDetection: ChangeDetectionStrategy.OnPush,
  2132. inputs: ['color', 'disableRipple'],
  2133. host: {
  2134. 'class': 'mat-tab-group',
  2135. '[class.mat-tab-group-dynamic-height]': 'dynamicHeight',
  2136. '[class.mat-tab-group-inverted-header]': 'headerPosition === "below"',
  2137. },
  2138. },] },
  2139. ];
  2140. /** @nocollapse */
  2141. MatTabGroup.ctorParameters = function () { return [
  2142. { type: ElementRef },
  2143. { type: ChangeDetectorRef },
  2144. { type: undefined, decorators: [{ type: Inject, args: [MAT_TABS_CONFIG,] }, { type: Optional }] },
  2145. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  2146. ]; };
  2147. MatTabGroup.propDecorators = {
  2148. _tabs: [{ type: ContentChildren, args: [MatTab,] }],
  2149. _tabBodyWrapper: [{ type: ViewChild, args: ['tabBodyWrapper', { static: false },] }],
  2150. _tabHeader: [{ type: ViewChild, args: ['tabHeader', { static: false },] }],
  2151. dynamicHeight: [{ type: Input }],
  2152. selectedIndex: [{ type: Input }],
  2153. headerPosition: [{ type: Input }],
  2154. animationDuration: [{ type: Input }],
  2155. backgroundColor: [{ type: Input }],
  2156. selectedIndexChange: [{ type: Output }],
  2157. focusChange: [{ type: Output }],
  2158. animationDone: [{ type: Output }],
  2159. selectedTabChange: [{ type: Output }]
  2160. };
  2161. return MatTabGroup;
  2162. }(_MatTabGroupMixinBase));
  2163. /**
  2164. * @fileoverview added by tsickle
  2165. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2166. */
  2167. /**
  2168. * Navigation component matching the styles of the tab group header.
  2169. * Provides anchored navigation with animated ink bar.
  2170. */
  2171. var MatTabNav = /** @class */ (function (_super) {
  2172. __extends(MatTabNav, _super);
  2173. function MatTabNav(elementRef, dir, ngZone, changeDetectorRef, viewportRuler,
  2174. /**
  2175. * @deprecated @breaking-change 9.0.0 `platform` parameter to become required.
  2176. */
  2177. platform, animationMode) {
  2178. var _this = _super.call(this, elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode) || this;
  2179. _this._disableRipple = false;
  2180. /**
  2181. * Theme color of the nav bar.
  2182. */
  2183. _this.color = 'primary';
  2184. return _this;
  2185. }
  2186. Object.defineProperty(MatTabNav.prototype, "backgroundColor", {
  2187. /** Background color of the tab nav. */
  2188. get: /**
  2189. * Background color of the tab nav.
  2190. * @return {?}
  2191. */
  2192. function () { return this._backgroundColor; },
  2193. set: /**
  2194. * @param {?} value
  2195. * @return {?}
  2196. */
  2197. function (value) {
  2198. /** @type {?} */
  2199. var classList = this._elementRef.nativeElement.classList;
  2200. classList.remove("mat-background-" + this.backgroundColor);
  2201. if (value) {
  2202. classList.add("mat-background-" + value);
  2203. }
  2204. this._backgroundColor = value;
  2205. },
  2206. enumerable: true,
  2207. configurable: true
  2208. });
  2209. Object.defineProperty(MatTabNav.prototype, "disableRipple", {
  2210. /** Whether the ripple effect is disabled or not. */
  2211. get: /**
  2212. * Whether the ripple effect is disabled or not.
  2213. * @return {?}
  2214. */
  2215. function () { return this._disableRipple; },
  2216. set: /**
  2217. * @param {?} value
  2218. * @return {?}
  2219. */
  2220. function (value) { this._disableRipple = coerceBooleanProperty(value); },
  2221. enumerable: true,
  2222. configurable: true
  2223. });
  2224. /**
  2225. * @protected
  2226. * @return {?}
  2227. */
  2228. MatTabNav.prototype._itemSelected = /**
  2229. * @protected
  2230. * @return {?}
  2231. */
  2232. function () {
  2233. // noop
  2234. };
  2235. /**
  2236. * @return {?}
  2237. */
  2238. MatTabNav.prototype.ngAfterContentInit = /**
  2239. * @return {?}
  2240. */
  2241. function () {
  2242. this.updateActiveLink();
  2243. _super.prototype.ngAfterContentInit.call(this);
  2244. };
  2245. /**
  2246. * Notifies the component that the active link has been changed.
  2247. * @breaking-change 8.0.0 `element` parameter to be removed.
  2248. */
  2249. /**
  2250. * Notifies the component that the active link has been changed.
  2251. * \@breaking-change 8.0.0 `element` parameter to be removed.
  2252. * @param {?=} _element
  2253. * @return {?}
  2254. */
  2255. MatTabNav.prototype.updateActiveLink = /**
  2256. * Notifies the component that the active link has been changed.
  2257. * \@breaking-change 8.0.0 `element` parameter to be removed.
  2258. * @param {?=} _element
  2259. * @return {?}
  2260. */
  2261. function (_element) {
  2262. if (!this._items) {
  2263. return;
  2264. }
  2265. /** @type {?} */
  2266. var items = this._items.toArray();
  2267. for (var i = 0; i < items.length; i++) {
  2268. if (items[i].active) {
  2269. this.selectedIndex = i;
  2270. this._changeDetectorRef.markForCheck();
  2271. return;
  2272. }
  2273. }
  2274. // The ink bar should hide itself if no items are active.
  2275. this.selectedIndex = -1;
  2276. this._inkBar.hide();
  2277. };
  2278. MatTabNav.decorators = [
  2279. { type: Component, args: [{selector: '[mat-tab-nav-bar]',
  2280. exportAs: 'matTabNavBar, matTabNav',
  2281. inputs: ['color'],
  2282. template: "<div class=\"mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4\" #previousPaginator aria-hidden=\"true\" mat-ripple [matRippleDisabled]=\"_disableScrollBefore || disableRipple\" [class.mat-tab-header-pagination-disabled]=\"_disableScrollBefore\" (click)=\"_handlePaginatorClick('before')\" (mousedown)=\"_handlePaginatorPress('before')\" (touchend)=\"_stopInterval()\"><div class=\"mat-tab-header-pagination-chevron\"></div></div><div class=\"mat-tab-link-container\" #tabListContainer (keydown)=\"_handleKeydown($event)\"><div class=\"mat-tab-list\" #tabList (cdkObserveContent)=\"_onContentChanges()\"><div class=\"mat-tab-links\"><ng-content></ng-content></div><mat-ink-bar></mat-ink-bar></div></div><div class=\"mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4\" #nextPaginator aria-hidden=\"true\" mat-ripple [matRippleDisabled]=\"_disableScrollAfter || disableRipple\" [class.mat-tab-header-pagination-disabled]=\"_disableScrollAfter\" (mousedown)=\"_handlePaginatorPress('after')\" (click)=\"_handlePaginatorClick('after')\" (touchend)=\"_stopInterval()\"><div class=\"mat-tab-header-pagination-chevron\"></div></div>",
  2283. 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-pagination-after,.mat-tab-header-rtl .mat-tab-header-pagination-before{padding-right:4px}.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron,.mat-tab-header-rtl .mat-tab-header-pagination-before .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 .5s cubic-bezier(.35,0,.25,1)}.mat-tab-links{display:flex}[mat-align-tabs=center] .mat-tab-links{justify-content:center}[mat-align-tabs=end] .mat-tab-links{justify-content:flex-end}.mat-ink-bar{position:absolute;bottom:0;height:2px;transition:.5s cubic-bezier(.35,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}@media (-ms-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:0}.mat-tab-link:focus:not(.mat-tab-disabled){opacity:1}@media (-ms-high-contrast:active){.mat-tab-link:focus{outline:dotted 2px}}.mat-tab-link.mat-tab-disabled{cursor:default}@media (-ms-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}@media (-ms-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}}"],
  2284. host: {
  2285. 'class': 'mat-tab-nav-bar mat-tab-header',
  2286. '[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',
  2287. '[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'",
  2288. '[class.mat-primary]': 'color !== "warn" && color !== "accent"',
  2289. '[class.mat-accent]': 'color === "accent"',
  2290. '[class.mat-warn]': 'color === "warn"',
  2291. },
  2292. encapsulation: ViewEncapsulation.None,
  2293. changeDetection: ChangeDetectionStrategy.OnPush,
  2294. },] },
  2295. ];
  2296. /** @nocollapse */
  2297. MatTabNav.ctorParameters = function () { return [
  2298. { type: ElementRef },
  2299. { type: Directionality, decorators: [{ type: Optional }] },
  2300. { type: NgZone },
  2301. { type: ChangeDetectorRef },
  2302. { type: ViewportRuler },
  2303. { type: Platform, decorators: [{ type: Optional }] },
  2304. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  2305. ]; };
  2306. MatTabNav.propDecorators = {
  2307. _items: [{ type: ContentChildren, args: [forwardRef((/**
  2308. * @return {?}
  2309. */
  2310. function () { return MatTabLink; })), { descendants: true },] }],
  2311. _inkBar: [{ type: ViewChild, args: [MatInkBar, { static: true },] }],
  2312. _tabListContainer: [{ type: ViewChild, args: ['tabListContainer', { static: true },] }],
  2313. _tabList: [{ type: ViewChild, args: ['tabList', { static: true },] }],
  2314. _nextPaginator: [{ type: ViewChild, args: ['nextPaginator', { static: false },] }],
  2315. _previousPaginator: [{ type: ViewChild, args: ['previousPaginator', { static: false },] }],
  2316. backgroundColor: [{ type: Input }],
  2317. disableRipple: [{ type: Input }],
  2318. color: [{ type: Input }]
  2319. };
  2320. return MatTabNav;
  2321. }(MatPaginatedTabHeader));
  2322. // Boilerplate for applying mixins to MatTabLink.
  2323. var
  2324. // Boilerplate for applying mixins to MatTabLink.
  2325. MatTabLinkBase = /** @class */ (function () {
  2326. function MatTabLinkBase() {
  2327. }
  2328. return MatTabLinkBase;
  2329. }());
  2330. /** @type {?} */
  2331. var _MatTabLinkMixinBase = mixinTabIndex(mixinDisableRipple(mixinDisabled(MatTabLinkBase)));
  2332. /**
  2333. * Link inside of a `mat-tab-nav-bar`.
  2334. */
  2335. var MatTabLink = /** @class */ (function (_super) {
  2336. __extends(MatTabLink, _super);
  2337. function MatTabLink(_tabNavBar, elementRef, ngZone, platform, globalRippleOptions, tabIndex, _focusMonitor, animationMode) {
  2338. var _this = _super.call(this) || this;
  2339. _this._tabNavBar = _tabNavBar;
  2340. _this.elementRef = elementRef;
  2341. _this._focusMonitor = _focusMonitor;
  2342. /**
  2343. * Whether the tab link is active or not.
  2344. */
  2345. _this._isActive = false;
  2346. _this._tabLinkRipple = new RippleRenderer(_this, ngZone, elementRef, platform);
  2347. _this._tabLinkRipple.setupTriggerEvents(elementRef.nativeElement);
  2348. _this.rippleConfig = globalRippleOptions || {};
  2349. _this.tabIndex = parseInt(tabIndex) || 0;
  2350. if (animationMode === 'NoopAnimations') {
  2351. _this.rippleConfig.animation = { enterDuration: 0, exitDuration: 0 };
  2352. }
  2353. _focusMonitor.monitor(elementRef);
  2354. return _this;
  2355. }
  2356. Object.defineProperty(MatTabLink.prototype, "active", {
  2357. /** Whether the link is active. */
  2358. get: /**
  2359. * Whether the link is active.
  2360. * @return {?}
  2361. */
  2362. function () { return this._isActive; },
  2363. set: /**
  2364. * @param {?} value
  2365. * @return {?}
  2366. */
  2367. function (value) {
  2368. if (value !== this._isActive) {
  2369. this._isActive = value;
  2370. this._tabNavBar.updateActiveLink(this.elementRef);
  2371. }
  2372. },
  2373. enumerable: true,
  2374. configurable: true
  2375. });
  2376. Object.defineProperty(MatTabLink.prototype, "rippleDisabled", {
  2377. /**
  2378. * Whether ripples are disabled on interaction.
  2379. * @docs-private
  2380. */
  2381. get: /**
  2382. * Whether ripples are disabled on interaction.
  2383. * \@docs-private
  2384. * @return {?}
  2385. */
  2386. function () {
  2387. return this.disabled || this.disableRipple || this._tabNavBar.disableRipple ||
  2388. !!this.rippleConfig.disabled;
  2389. },
  2390. enumerable: true,
  2391. configurable: true
  2392. });
  2393. /**
  2394. * @return {?}
  2395. */
  2396. MatTabLink.prototype.focus = /**
  2397. * @return {?}
  2398. */
  2399. function () {
  2400. this.elementRef.nativeElement.focus();
  2401. };
  2402. /**
  2403. * @return {?}
  2404. */
  2405. MatTabLink.prototype.ngOnDestroy = /**
  2406. * @return {?}
  2407. */
  2408. function () {
  2409. this._tabLinkRipple._removeTriggerEvents();
  2410. this._focusMonitor.stopMonitoring(this.elementRef);
  2411. };
  2412. MatTabLink.decorators = [
  2413. { type: Directive, args: [{
  2414. selector: '[mat-tab-link], [matTabLink]',
  2415. exportAs: 'matTabLink',
  2416. inputs: ['disabled', 'disableRipple', 'tabIndex'],
  2417. host: {
  2418. 'class': 'mat-tab-link',
  2419. '[attr.aria-current]': 'active ? "page" : null',
  2420. '[attr.aria-disabled]': 'disabled',
  2421. '[attr.tabIndex]': 'tabIndex',
  2422. '[class.mat-tab-disabled]': 'disabled',
  2423. '[class.mat-tab-label-active]': 'active',
  2424. }
  2425. },] },
  2426. ];
  2427. /** @nocollapse */
  2428. MatTabLink.ctorParameters = function () { return [
  2429. { type: MatTabNav },
  2430. { type: ElementRef },
  2431. { type: NgZone },
  2432. { type: Platform },
  2433. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_RIPPLE_GLOBAL_OPTIONS,] }] },
  2434. { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
  2435. { type: FocusMonitor },
  2436. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  2437. ]; };
  2438. MatTabLink.propDecorators = {
  2439. active: [{ type: Input }]
  2440. };
  2441. return MatTabLink;
  2442. }(_MatTabLinkMixinBase));
  2443. /**
  2444. * @fileoverview added by tsickle
  2445. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2446. */
  2447. var MatTabsModule = /** @class */ (function () {
  2448. function MatTabsModule() {
  2449. }
  2450. MatTabsModule.decorators = [
  2451. { type: NgModule, args: [{
  2452. imports: [
  2453. CommonModule,
  2454. MatCommonModule,
  2455. PortalModule,
  2456. MatRippleModule,
  2457. ObserversModule,
  2458. A11yModule,
  2459. ],
  2460. // Don't export all components because some are only to be used internally.
  2461. exports: [
  2462. MatCommonModule,
  2463. MatTabGroup,
  2464. MatTabLabel,
  2465. MatTab,
  2466. MatTabNav,
  2467. MatTabLink,
  2468. MatTabContent,
  2469. ],
  2470. declarations: [
  2471. MatTabGroup,
  2472. MatTabLabel,
  2473. MatTab,
  2474. MatInkBar,
  2475. MatTabLabelWrapper,
  2476. MatTabNav,
  2477. MatTabLink,
  2478. MatTabBody,
  2479. MatTabBodyPortal,
  2480. MatTabHeader,
  2481. MatTabContent,
  2482. ],
  2483. },] },
  2484. ];
  2485. return MatTabsModule;
  2486. }());
  2487. /**
  2488. * @fileoverview added by tsickle
  2489. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2490. */
  2491. /**
  2492. * @fileoverview added by tsickle
  2493. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2494. */
  2495. /**
  2496. * @fileoverview added by tsickle
  2497. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2498. */
  2499. export { MatInkBar, _MAT_INK_BAR_POSITIONER, MatTabBody, MatTabBodyPortal, MatTabHeader, MatTabLabelWrapper, MatTab, MatTabLabel, MatTabNav, MatTabLink, MatTabContent, MatTabsModule, MatTabChangeEvent, MAT_TABS_CONFIG, MatTabGroup, matTabsAnimations, _MAT_INK_BAR_POSITIONER_FACTORY as ɵa23, MatPaginatedTabHeader as ɵb23 };
  2500. //# sourceMappingURL=tabs.es5.js.map