material-tabs.umd.js 106 KB

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