core.es5.js 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { Version, NgModule, InjectionToken, Optional, Inject, isDevMode, inject, LOCALE_ID, Injectable, Directive, ElementRef, Input, NgZone, Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef, EventEmitter, Output, ɵɵdefineInjectable } from '@angular/core';
  9. import { HAMMER_LOADER, HammerGestureConfig } from '@angular/platform-browser';
  10. import { BidiModule } from '@angular/cdk/bidi';
  11. import { VERSION } from '@angular/cdk';
  12. import { __extends, __assign } from 'tslib';
  13. import { coerceBooleanProperty } from '@angular/cdk/coercion';
  14. import { Subject, Observable } from 'rxjs';
  15. import { Platform, PlatformModule, normalizePassiveListenerOptions } from '@angular/cdk/platform';
  16. import { startWith } from 'rxjs/operators';
  17. import { isFakeMousedownFromScreenReader } from '@angular/cdk/a11y';
  18. import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
  19. import { ENTER, SPACE, hasModifierKey } from '@angular/cdk/keycodes';
  20. import { CommonModule } from '@angular/common';
  21. /**
  22. * @fileoverview added by tsickle
  23. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  24. */
  25. /**
  26. * Current version of Angular Material.
  27. * @type {?}
  28. */
  29. var VERSION$1 = new Version('8.1.4');
  30. /**
  31. * @fileoverview added by tsickle
  32. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  33. */
  34. /**
  35. * \@docs-private
  36. */
  37. var AnimationCurves = /** @class */ (function () {
  38. function AnimationCurves() {
  39. }
  40. AnimationCurves.STANDARD_CURVE = 'cubic-bezier(0.4,0.0,0.2,1)';
  41. AnimationCurves.DECELERATION_CURVE = 'cubic-bezier(0.0,0.0,0.2,1)';
  42. AnimationCurves.ACCELERATION_CURVE = 'cubic-bezier(0.4,0.0,1,1)';
  43. AnimationCurves.SHARP_CURVE = 'cubic-bezier(0.4,0.0,0.6,1)';
  44. return AnimationCurves;
  45. }());
  46. /**
  47. * \@docs-private
  48. */
  49. var AnimationDurations = /** @class */ (function () {
  50. function AnimationDurations() {
  51. }
  52. AnimationDurations.COMPLEX = '375ms';
  53. AnimationDurations.ENTERING = '225ms';
  54. AnimationDurations.EXITING = '195ms';
  55. return AnimationDurations;
  56. }());
  57. /**
  58. * @fileoverview added by tsickle
  59. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  60. */
  61. // Private version constant to circumvent test/build issues,
  62. // i.e. avoid core to depend on the @angular/material primary entry-point
  63. // Can be removed once the Material primary entry-point no longer
  64. // re-exports all secondary entry-points
  65. /** @type {?} */
  66. var VERSION$2 = new Version('8.1.4');
  67. /**
  68. * Injection token that configures whether the Material sanity checks are enabled.
  69. * @type {?}
  70. */
  71. var MATERIAL_SANITY_CHECKS = new InjectionToken('mat-sanity-checks', {
  72. providedIn: 'root',
  73. factory: MATERIAL_SANITY_CHECKS_FACTORY,
  74. });
  75. /**
  76. * \@docs-private
  77. * @return {?}
  78. */
  79. function MATERIAL_SANITY_CHECKS_FACTORY() {
  80. return true;
  81. }
  82. /**
  83. * Module that captures anything that should be loaded and/or run for *all* Angular Material
  84. * components. This includes Bidi, etc.
  85. *
  86. * This module should be imported to each top-level component module (e.g., MatTabsModule).
  87. */
  88. var MatCommonModule = /** @class */ (function () {
  89. function MatCommonModule(_sanityChecksEnabled, _hammerLoader) {
  90. this._sanityChecksEnabled = _sanityChecksEnabled;
  91. this._hammerLoader = _hammerLoader;
  92. /**
  93. * Whether we've done the global sanity checks (e.g. a theme is loaded, there is a doctype).
  94. */
  95. this._hasDoneGlobalChecks = false;
  96. /**
  97. * Whether we've already checked for HammerJs availability.
  98. */
  99. this._hasCheckedHammer = false;
  100. /**
  101. * Reference to the global `document` object.
  102. */
  103. this._document = typeof document === 'object' && document ? document : null;
  104. /**
  105. * Reference to the global 'window' object.
  106. */
  107. this._window = typeof window === 'object' && window ? window : null;
  108. if (this._areChecksEnabled() && !this._hasDoneGlobalChecks) {
  109. this._checkDoctypeIsDefined();
  110. this._checkThemeIsPresent();
  111. this._checkCdkVersionMatch();
  112. this._hasDoneGlobalChecks = true;
  113. }
  114. }
  115. /** Whether any sanity checks are enabled */
  116. /**
  117. * Whether any sanity checks are enabled
  118. * @private
  119. * @return {?}
  120. */
  121. MatCommonModule.prototype._areChecksEnabled = /**
  122. * Whether any sanity checks are enabled
  123. * @private
  124. * @return {?}
  125. */
  126. function () {
  127. return this._sanityChecksEnabled && isDevMode() && !this._isTestEnv();
  128. };
  129. /** Whether the code is running in tests. */
  130. /**
  131. * Whether the code is running in tests.
  132. * @private
  133. * @return {?}
  134. */
  135. MatCommonModule.prototype._isTestEnv = /**
  136. * Whether the code is running in tests.
  137. * @private
  138. * @return {?}
  139. */
  140. function () {
  141. /** @type {?} */
  142. var window = (/** @type {?} */ (this._window));
  143. return window && (window.__karma__ || window.jasmine);
  144. };
  145. /**
  146. * @private
  147. * @return {?}
  148. */
  149. MatCommonModule.prototype._checkDoctypeIsDefined = /**
  150. * @private
  151. * @return {?}
  152. */
  153. function () {
  154. if (this._document && !this._document.doctype) {
  155. console.warn('Current document does not have a doctype. This may cause ' +
  156. 'some Angular Material components not to behave as expected.');
  157. }
  158. };
  159. /**
  160. * @private
  161. * @return {?}
  162. */
  163. MatCommonModule.prototype._checkThemeIsPresent = /**
  164. * @private
  165. * @return {?}
  166. */
  167. function () {
  168. // We need to assert that the `body` is defined, because these checks run very early
  169. // and the `body` won't be defined if the consumer put their scripts in the `head`.
  170. if (!this._document || !this._document.body || typeof getComputedStyle !== 'function') {
  171. return;
  172. }
  173. /** @type {?} */
  174. var testElement = this._document.createElement('div');
  175. testElement.classList.add('mat-theme-loaded-marker');
  176. this._document.body.appendChild(testElement);
  177. /** @type {?} */
  178. var computedStyle = getComputedStyle(testElement);
  179. // In some situations the computed style of the test element can be null. For example in
  180. // Firefox, the computed style is null if an application is running inside of a hidden iframe.
  181. // See: https://bugzilla.mozilla.org/show_bug.cgi?id=548397
  182. if (computedStyle && computedStyle.display !== 'none') {
  183. console.warn('Could not find Angular Material core theme. Most Material ' +
  184. 'components may not work as expected. For more info refer ' +
  185. 'to the theming guide: https://material.angular.io/guide/theming');
  186. }
  187. this._document.body.removeChild(testElement);
  188. };
  189. /** Checks whether the material version matches the cdk version */
  190. /**
  191. * Checks whether the material version matches the cdk version
  192. * @private
  193. * @return {?}
  194. */
  195. MatCommonModule.prototype._checkCdkVersionMatch = /**
  196. * Checks whether the material version matches the cdk version
  197. * @private
  198. * @return {?}
  199. */
  200. function () {
  201. if (VERSION$2.full !== VERSION.full) {
  202. console.warn('The Angular Material version (' + VERSION$2.full + ') does not match ' +
  203. 'the Angular CDK version (' + VERSION.full + ').\n' +
  204. 'Please ensure the versions of these two packages exactly match.');
  205. }
  206. };
  207. /** Checks whether HammerJS is available. */
  208. /**
  209. * Checks whether HammerJS is available.
  210. * @return {?}
  211. */
  212. MatCommonModule.prototype._checkHammerIsAvailable = /**
  213. * Checks whether HammerJS is available.
  214. * @return {?}
  215. */
  216. function () {
  217. if (this._hasCheckedHammer || !this._window) {
  218. return;
  219. }
  220. if (this._areChecksEnabled() && !((/** @type {?} */ (this._window)))['Hammer'] && !this._hammerLoader) {
  221. console.warn('Could not find HammerJS. Certain Angular Material components may not work correctly.');
  222. }
  223. this._hasCheckedHammer = true;
  224. };
  225. MatCommonModule.decorators = [
  226. { type: NgModule, args: [{
  227. imports: [BidiModule],
  228. exports: [BidiModule],
  229. },] },
  230. ];
  231. /** @nocollapse */
  232. MatCommonModule.ctorParameters = function () { return [
  233. { type: Boolean, decorators: [{ type: Optional }, { type: Inject, args: [MATERIAL_SANITY_CHECKS,] }] },
  234. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [HAMMER_LOADER,] }] }
  235. ]; };
  236. return MatCommonModule;
  237. }());
  238. /**
  239. * @fileoverview added by tsickle
  240. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  241. */
  242. /**
  243. * Mixin to augment a directive with a `disabled` property.
  244. * @template T
  245. * @param {?} base
  246. * @return {?}
  247. */
  248. function mixinDisabled(base) {
  249. return /** @class */ (function (_super) {
  250. __extends(class_1, _super);
  251. function class_1() {
  252. var args = [];
  253. for (var _i = 0; _i < arguments.length; _i++) {
  254. args[_i] = arguments[_i];
  255. }
  256. var _this = _super.apply(this, args) || this;
  257. _this._disabled = false;
  258. return _this;
  259. }
  260. Object.defineProperty(class_1.prototype, "disabled", {
  261. get: /**
  262. * @return {?}
  263. */
  264. function () { return this._disabled; },
  265. set: /**
  266. * @param {?} value
  267. * @return {?}
  268. */
  269. function (value) { this._disabled = coerceBooleanProperty(value); },
  270. enumerable: true,
  271. configurable: true
  272. });
  273. return class_1;
  274. }(base));
  275. }
  276. /**
  277. * @fileoverview added by tsickle
  278. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  279. */
  280. /**
  281. * Mixin to augment a directive with a `color` property.
  282. * @template T
  283. * @param {?} base
  284. * @param {?=} defaultColor
  285. * @return {?}
  286. */
  287. function mixinColor(base, defaultColor) {
  288. return /** @class */ (function (_super) {
  289. __extends(class_1, _super);
  290. function class_1() {
  291. var args = [];
  292. for (var _i = 0; _i < arguments.length; _i++) {
  293. args[_i] = arguments[_i];
  294. }
  295. var _this = _super.apply(this, args) || this;
  296. // Set the default color that can be specified from the mixin.
  297. _this.color = defaultColor;
  298. return _this;
  299. }
  300. Object.defineProperty(class_1.prototype, "color", {
  301. get: /**
  302. * @return {?}
  303. */
  304. function () { return this._color; },
  305. set: /**
  306. * @param {?} value
  307. * @return {?}
  308. */
  309. function (value) {
  310. /** @type {?} */
  311. var colorPalette = value || defaultColor;
  312. if (colorPalette !== this._color) {
  313. if (this._color) {
  314. this._elementRef.nativeElement.classList.remove("mat-" + this._color);
  315. }
  316. if (colorPalette) {
  317. this._elementRef.nativeElement.classList.add("mat-" + colorPalette);
  318. }
  319. this._color = colorPalette;
  320. }
  321. },
  322. enumerable: true,
  323. configurable: true
  324. });
  325. return class_1;
  326. }(base));
  327. }
  328. /**
  329. * @fileoverview added by tsickle
  330. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  331. */
  332. /**
  333. * Mixin to augment a directive with a `disableRipple` property.
  334. * @template T
  335. * @param {?} base
  336. * @return {?}
  337. */
  338. function mixinDisableRipple(base) {
  339. return /** @class */ (function (_super) {
  340. __extends(class_1, _super);
  341. function class_1() {
  342. var args = [];
  343. for (var _i = 0; _i < arguments.length; _i++) {
  344. args[_i] = arguments[_i];
  345. }
  346. var _this = _super.apply(this, args) || this;
  347. _this._disableRipple = false;
  348. return _this;
  349. }
  350. Object.defineProperty(class_1.prototype, "disableRipple", {
  351. /** Whether the ripple effect is disabled or not. */
  352. get: /**
  353. * Whether the ripple effect is disabled or not.
  354. * @return {?}
  355. */
  356. function () { return this._disableRipple; },
  357. set: /**
  358. * @param {?} value
  359. * @return {?}
  360. */
  361. function (value) { this._disableRipple = coerceBooleanProperty(value); },
  362. enumerable: true,
  363. configurable: true
  364. });
  365. return class_1;
  366. }(base));
  367. }
  368. /**
  369. * @fileoverview added by tsickle
  370. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  371. */
  372. /**
  373. * Mixin to augment a directive with a `tabIndex` property.
  374. * @template T
  375. * @param {?} base
  376. * @param {?=} defaultTabIndex
  377. * @return {?}
  378. */
  379. function mixinTabIndex(base, defaultTabIndex) {
  380. if (defaultTabIndex === void 0) { defaultTabIndex = 0; }
  381. return /** @class */ (function (_super) {
  382. __extends(class_1, _super);
  383. function class_1() {
  384. var args = [];
  385. for (var _i = 0; _i < arguments.length; _i++) {
  386. args[_i] = arguments[_i];
  387. }
  388. var _this = _super.apply(this, args) || this;
  389. _this._tabIndex = defaultTabIndex;
  390. return _this;
  391. }
  392. Object.defineProperty(class_1.prototype, "tabIndex", {
  393. get: /**
  394. * @return {?}
  395. */
  396. function () { return this.disabled ? -1 : this._tabIndex; },
  397. set: /**
  398. * @param {?} value
  399. * @return {?}
  400. */
  401. function (value) {
  402. // If the specified tabIndex value is null or undefined, fall back to the default value.
  403. this._tabIndex = value != null ? value : defaultTabIndex;
  404. },
  405. enumerable: true,
  406. configurable: true
  407. });
  408. return class_1;
  409. }(base));
  410. }
  411. /**
  412. * @fileoverview added by tsickle
  413. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  414. */
  415. /**
  416. * Mixin to augment a directive with updateErrorState method.
  417. * For component with `errorState` and need to update `errorState`.
  418. * @template T
  419. * @param {?} base
  420. * @return {?}
  421. */
  422. function mixinErrorState(base) {
  423. return /** @class */ (function (_super) {
  424. __extends(class_1, _super);
  425. function class_1() {
  426. var args = [];
  427. for (var _i = 0; _i < arguments.length; _i++) {
  428. args[_i] = arguments[_i];
  429. }
  430. var _this = _super.apply(this, args) || this;
  431. /**
  432. * Whether the component is in an error state.
  433. */
  434. _this.errorState = false;
  435. /**
  436. * Stream that emits whenever the state of the input changes such that the wrapping
  437. * `MatFormField` needs to run change detection.
  438. */
  439. _this.stateChanges = new Subject();
  440. return _this;
  441. }
  442. /**
  443. * @return {?}
  444. */
  445. class_1.prototype.updateErrorState = /**
  446. * @return {?}
  447. */
  448. function () {
  449. /** @type {?} */
  450. var oldState = this.errorState;
  451. /** @type {?} */
  452. var parent = this._parentFormGroup || this._parentForm;
  453. /** @type {?} */
  454. var matcher = this.errorStateMatcher || this._defaultErrorStateMatcher;
  455. /** @type {?} */
  456. var control = this.ngControl ? (/** @type {?} */ (this.ngControl.control)) : null;
  457. /** @type {?} */
  458. var newState = matcher.isErrorState(control, parent);
  459. if (newState !== oldState) {
  460. this.errorState = newState;
  461. this.stateChanges.next();
  462. }
  463. };
  464. return class_1;
  465. }(base));
  466. }
  467. /**
  468. * @fileoverview added by tsickle
  469. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  470. */
  471. /**
  472. * Mixin to augment a directive with an initialized property that will emits when ngOnInit ends.
  473. * @template T
  474. * @param {?} base
  475. * @return {?}
  476. */
  477. function mixinInitialized(base) {
  478. return /** @class */ (function (_super) {
  479. __extends(class_1, _super);
  480. function class_1() {
  481. var args = [];
  482. for (var _i = 0; _i < arguments.length; _i++) {
  483. args[_i] = arguments[_i];
  484. }
  485. var _this = _super.apply(this, args) || this;
  486. /**
  487. * Whether this directive has been marked as initialized.
  488. */
  489. _this._isInitialized = false;
  490. /**
  491. * List of subscribers that subscribed before the directive was initialized. Should be notified
  492. * during _markInitialized. Set to null after pending subscribers are notified, and should
  493. * not expect to be populated after.
  494. */
  495. _this._pendingSubscribers = [];
  496. /**
  497. * Observable stream that emits when the directive initializes. If already initialized, the
  498. * subscriber is stored to be notified once _markInitialized is called.
  499. */
  500. _this.initialized = new Observable((/**
  501. * @param {?} subscriber
  502. * @return {?}
  503. */
  504. function (subscriber) {
  505. // If initialized, immediately notify the subscriber. Otherwise store the subscriber to notify
  506. // when _markInitialized is called.
  507. if (_this._isInitialized) {
  508. _this._notifySubscriber(subscriber);
  509. }
  510. else {
  511. (/** @type {?} */ (_this._pendingSubscribers)).push(subscriber);
  512. }
  513. }));
  514. return _this;
  515. }
  516. /**
  517. * Marks the state as initialized and notifies pending subscribers. Should be called at the end
  518. * of ngOnInit.
  519. * @docs-private
  520. */
  521. /**
  522. * Marks the state as initialized and notifies pending subscribers. Should be called at the end
  523. * of ngOnInit.
  524. * \@docs-private
  525. * @return {?}
  526. */
  527. class_1.prototype._markInitialized = /**
  528. * Marks the state as initialized and notifies pending subscribers. Should be called at the end
  529. * of ngOnInit.
  530. * \@docs-private
  531. * @return {?}
  532. */
  533. function () {
  534. if (this._isInitialized) {
  535. throw Error('This directive has already been marked as initialized and ' +
  536. 'should not be called twice.');
  537. }
  538. this._isInitialized = true;
  539. (/** @type {?} */ (this._pendingSubscribers)).forEach(this._notifySubscriber);
  540. this._pendingSubscribers = null;
  541. };
  542. /** Emits and completes the subscriber stream (should only emit once). */
  543. /**
  544. * Emits and completes the subscriber stream (should only emit once).
  545. * @param {?} subscriber
  546. * @return {?}
  547. */
  548. class_1.prototype._notifySubscriber = /**
  549. * Emits and completes the subscriber stream (should only emit once).
  550. * @param {?} subscriber
  551. * @return {?}
  552. */
  553. function (subscriber) {
  554. subscriber.next();
  555. subscriber.complete();
  556. };
  557. return class_1;
  558. }(base));
  559. }
  560. /**
  561. * @fileoverview added by tsickle
  562. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  563. */
  564. /**
  565. * @fileoverview added by tsickle
  566. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  567. */
  568. /**
  569. * InjectionToken for datepicker that can be used to override default locale code.
  570. * @type {?}
  571. */
  572. var MAT_DATE_LOCALE = new InjectionToken('MAT_DATE_LOCALE', {
  573. providedIn: 'root',
  574. factory: MAT_DATE_LOCALE_FACTORY,
  575. });
  576. /**
  577. * \@docs-private
  578. * @return {?}
  579. */
  580. function MAT_DATE_LOCALE_FACTORY() {
  581. return inject(LOCALE_ID);
  582. }
  583. /**
  584. * No longer needed since MAT_DATE_LOCALE has been changed to a scoped injectable.
  585. * If you are importing and providing this in your code you can simply remove it.
  586. * @deprecated
  587. * \@breaking-change 8.0.0
  588. * @type {?}
  589. */
  590. var MAT_DATE_LOCALE_PROVIDER = { provide: MAT_DATE_LOCALE, useExisting: LOCALE_ID };
  591. /**
  592. * Adapts type `D` to be usable as a date by cdk-based components that work with dates.
  593. * @abstract
  594. * @template D
  595. */
  596. var /**
  597. * Adapts type `D` to be usable as a date by cdk-based components that work with dates.
  598. * @abstract
  599. * @template D
  600. */
  601. DateAdapter = /** @class */ (function () {
  602. function DateAdapter() {
  603. this._localeChanges = new Subject();
  604. }
  605. Object.defineProperty(DateAdapter.prototype, "localeChanges", {
  606. /** A stream that emits when the locale changes. */
  607. get: /**
  608. * A stream that emits when the locale changes.
  609. * @return {?}
  610. */
  611. function () { return this._localeChanges; },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. /**
  616. * Attempts to deserialize a value to a valid date object. This is different from parsing in that
  617. * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
  618. * string). The default implementation does not allow any deserialization, it simply checks that
  619. * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
  620. * method on all of it's `@Input()` properties that accept dates. It is therefore possible to
  621. * support passing values from your backend directly to these properties by overriding this method
  622. * to also deserialize the format used by your backend.
  623. * @param value The value to be deserialized into a date object.
  624. * @returns The deserialized date object, either a valid date, null if the value can be
  625. * deserialized into a null date (e.g. the empty string), or an invalid date.
  626. */
  627. /**
  628. * Attempts to deserialize a value to a valid date object. This is different from parsing in that
  629. * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
  630. * string). The default implementation does not allow any deserialization, it simply checks that
  631. * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
  632. * method on all of it's `\@Input()` properties that accept dates. It is therefore possible to
  633. * support passing values from your backend directly to these properties by overriding this method
  634. * to also deserialize the format used by your backend.
  635. * @param {?} value The value to be deserialized into a date object.
  636. * @return {?} The deserialized date object, either a valid date, null if the value can be
  637. * deserialized into a null date (e.g. the empty string), or an invalid date.
  638. */
  639. DateAdapter.prototype.deserialize = /**
  640. * Attempts to deserialize a value to a valid date object. This is different from parsing in that
  641. * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
  642. * string). The default implementation does not allow any deserialization, it simply checks that
  643. * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
  644. * method on all of it's `\@Input()` properties that accept dates. It is therefore possible to
  645. * support passing values from your backend directly to these properties by overriding this method
  646. * to also deserialize the format used by your backend.
  647. * @param {?} value The value to be deserialized into a date object.
  648. * @return {?} The deserialized date object, either a valid date, null if the value can be
  649. * deserialized into a null date (e.g. the empty string), or an invalid date.
  650. */
  651. function (value) {
  652. if (value == null || this.isDateInstance(value) && this.isValid(value)) {
  653. return value;
  654. }
  655. return this.invalid();
  656. };
  657. /**
  658. * Sets the locale used for all dates.
  659. * @param locale The new locale.
  660. */
  661. /**
  662. * Sets the locale used for all dates.
  663. * @param {?} locale The new locale.
  664. * @return {?}
  665. */
  666. DateAdapter.prototype.setLocale = /**
  667. * Sets the locale used for all dates.
  668. * @param {?} locale The new locale.
  669. * @return {?}
  670. */
  671. function (locale) {
  672. this.locale = locale;
  673. this._localeChanges.next();
  674. };
  675. /**
  676. * Compares two dates.
  677. * @param first The first date to compare.
  678. * @param second The second date to compare.
  679. * @returns 0 if the dates are equal, a number less than 0 if the first date is earlier,
  680. * a number greater than 0 if the first date is later.
  681. */
  682. /**
  683. * Compares two dates.
  684. * @param {?} first The first date to compare.
  685. * @param {?} second The second date to compare.
  686. * @return {?} 0 if the dates are equal, a number less than 0 if the first date is earlier,
  687. * a number greater than 0 if the first date is later.
  688. */
  689. DateAdapter.prototype.compareDate = /**
  690. * Compares two dates.
  691. * @param {?} first The first date to compare.
  692. * @param {?} second The second date to compare.
  693. * @return {?} 0 if the dates are equal, a number less than 0 if the first date is earlier,
  694. * a number greater than 0 if the first date is later.
  695. */
  696. function (first, second) {
  697. return this.getYear(first) - this.getYear(second) ||
  698. this.getMonth(first) - this.getMonth(second) ||
  699. this.getDate(first) - this.getDate(second);
  700. };
  701. /**
  702. * Checks if two dates are equal.
  703. * @param first The first date to check.
  704. * @param second The second date to check.
  705. * @returns Whether the two dates are equal.
  706. * Null dates are considered equal to other null dates.
  707. */
  708. /**
  709. * Checks if two dates are equal.
  710. * @param {?} first The first date to check.
  711. * @param {?} second The second date to check.
  712. * @return {?} Whether the two dates are equal.
  713. * Null dates are considered equal to other null dates.
  714. */
  715. DateAdapter.prototype.sameDate = /**
  716. * Checks if two dates are equal.
  717. * @param {?} first The first date to check.
  718. * @param {?} second The second date to check.
  719. * @return {?} Whether the two dates are equal.
  720. * Null dates are considered equal to other null dates.
  721. */
  722. function (first, second) {
  723. if (first && second) {
  724. /** @type {?} */
  725. var firstValid = this.isValid(first);
  726. /** @type {?} */
  727. var secondValid = this.isValid(second);
  728. if (firstValid && secondValid) {
  729. return !this.compareDate(first, second);
  730. }
  731. return firstValid == secondValid;
  732. }
  733. return first == second;
  734. };
  735. /**
  736. * Clamp the given date between min and max dates.
  737. * @param date The date to clamp.
  738. * @param min The minimum value to allow. If null or omitted no min is enforced.
  739. * @param max The maximum value to allow. If null or omitted no max is enforced.
  740. * @returns `min` if `date` is less than `min`, `max` if date is greater than `max`,
  741. * otherwise `date`.
  742. */
  743. /**
  744. * Clamp the given date between min and max dates.
  745. * @param {?} date The date to clamp.
  746. * @param {?=} min The minimum value to allow. If null or omitted no min is enforced.
  747. * @param {?=} max The maximum value to allow. If null or omitted no max is enforced.
  748. * @return {?} `min` if `date` is less than `min`, `max` if date is greater than `max`,
  749. * otherwise `date`.
  750. */
  751. DateAdapter.prototype.clampDate = /**
  752. * Clamp the given date between min and max dates.
  753. * @param {?} date The date to clamp.
  754. * @param {?=} min The minimum value to allow. If null or omitted no min is enforced.
  755. * @param {?=} max The maximum value to allow. If null or omitted no max is enforced.
  756. * @return {?} `min` if `date` is less than `min`, `max` if date is greater than `max`,
  757. * otherwise `date`.
  758. */
  759. function (date, min, max) {
  760. if (min && this.compareDate(date, min) < 0) {
  761. return min;
  762. }
  763. if (max && this.compareDate(date, max) > 0) {
  764. return max;
  765. }
  766. return date;
  767. };
  768. return DateAdapter;
  769. }());
  770. /**
  771. * @fileoverview added by tsickle
  772. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  773. */
  774. /** @type {?} */
  775. var MAT_DATE_FORMATS = new InjectionToken('mat-date-formats');
  776. /**
  777. * @fileoverview added by tsickle
  778. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  779. */
  780. // TODO(mmalerba): Remove when we no longer support safari 9.
  781. /**
  782. * Whether the browser supports the Intl API.
  783. * @type {?}
  784. */
  785. var SUPPORTS_INTL_API;
  786. // We need a try/catch around the reference to `Intl`, because accessing it in some cases can
  787. // cause IE to throw. These cases are tied to particular versions of Windows and can happen if
  788. // the consumer is providing a polyfilled `Map`. See:
  789. // https://github.com/Microsoft/ChakraCore/issues/3189
  790. // https://github.com/angular/components/issues/15687
  791. try {
  792. SUPPORTS_INTL_API = typeof Intl != 'undefined';
  793. }
  794. catch (_a) {
  795. SUPPORTS_INTL_API = false;
  796. }
  797. /**
  798. * The default month names to use if Intl API is not available.
  799. * @type {?}
  800. */
  801. var DEFAULT_MONTH_NAMES = {
  802. 'long': [
  803. 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September',
  804. 'October', 'November', 'December'
  805. ],
  806. 'short': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  807. 'narrow': ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D']
  808. };
  809. var ɵ0 = /**
  810. * @param {?} i
  811. * @return {?}
  812. */
  813. function (i) { return String(i + 1); };
  814. /**
  815. * The default date names to use if Intl API is not available.
  816. * @type {?}
  817. */
  818. var DEFAULT_DATE_NAMES = range(31, (ɵ0));
  819. /**
  820. * The default day of the week names to use if Intl API is not available.
  821. * @type {?}
  822. */
  823. var DEFAULT_DAY_OF_WEEK_NAMES = {
  824. 'long': ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  825. 'short': ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
  826. 'narrow': ['S', 'M', 'T', 'W', 'T', 'F', 'S']
  827. };
  828. /**
  829. * Matches strings that have the form of a valid RFC 3339 string
  830. * (https://tools.ietf.org/html/rfc3339). Note that the string may not actually be a valid date
  831. * because the regex will match strings an with out of bounds month, date, etc.
  832. * @type {?}
  833. */
  834. var ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;
  835. /**
  836. * Creates an array and fills it with values.
  837. * @template T
  838. * @param {?} length
  839. * @param {?} valueFunction
  840. * @return {?}
  841. */
  842. function range(length, valueFunction) {
  843. /** @type {?} */
  844. var valuesArray = Array(length);
  845. for (var i = 0; i < length; i++) {
  846. valuesArray[i] = valueFunction(i);
  847. }
  848. return valuesArray;
  849. }
  850. /**
  851. * Adapts the native JS Date for use with cdk-based components that work with dates.
  852. */
  853. var NativeDateAdapter = /** @class */ (function (_super) {
  854. __extends(NativeDateAdapter, _super);
  855. function NativeDateAdapter(matDateLocale, platform) {
  856. var _this = _super.call(this) || this;
  857. /**
  858. * Whether to use `timeZone: 'utc'` with `Intl.DateTimeFormat` when formatting dates.
  859. * Without this `Intl.DateTimeFormat` sometimes chooses the wrong timeZone, which can throw off
  860. * the result. (e.g. in the en-US locale `new Date(1800, 7, 14).toLocaleDateString()`
  861. * will produce `'8/13/1800'`.
  862. *
  863. * TODO(mmalerba): drop this variable. It's not being used in the code right now. We're now
  864. * getting the string representation of a Date object from it's utc representation. We're keeping
  865. * it here for sometime, just for precaution, in case we decide to revert some of these changes
  866. * though.
  867. */
  868. _this.useUtcForDisplay = true;
  869. _super.prototype.setLocale.call(_this, matDateLocale);
  870. // IE does its own time zone correction, so we disable this on IE.
  871. _this.useUtcForDisplay = !platform.TRIDENT;
  872. _this._clampDate = platform.TRIDENT || platform.EDGE;
  873. return _this;
  874. }
  875. /**
  876. * @param {?} date
  877. * @return {?}
  878. */
  879. NativeDateAdapter.prototype.getYear = /**
  880. * @param {?} date
  881. * @return {?}
  882. */
  883. function (date) {
  884. return date.getFullYear();
  885. };
  886. /**
  887. * @param {?} date
  888. * @return {?}
  889. */
  890. NativeDateAdapter.prototype.getMonth = /**
  891. * @param {?} date
  892. * @return {?}
  893. */
  894. function (date) {
  895. return date.getMonth();
  896. };
  897. /**
  898. * @param {?} date
  899. * @return {?}
  900. */
  901. NativeDateAdapter.prototype.getDate = /**
  902. * @param {?} date
  903. * @return {?}
  904. */
  905. function (date) {
  906. return date.getDate();
  907. };
  908. /**
  909. * @param {?} date
  910. * @return {?}
  911. */
  912. NativeDateAdapter.prototype.getDayOfWeek = /**
  913. * @param {?} date
  914. * @return {?}
  915. */
  916. function (date) {
  917. return date.getDay();
  918. };
  919. /**
  920. * @param {?} style
  921. * @return {?}
  922. */
  923. NativeDateAdapter.prototype.getMonthNames = /**
  924. * @param {?} style
  925. * @return {?}
  926. */
  927. function (style) {
  928. var _this = this;
  929. if (SUPPORTS_INTL_API) {
  930. /** @type {?} */
  931. var dtf_1 = new Intl.DateTimeFormat(this.locale, { month: style, timeZone: 'utc' });
  932. return range(12, (/**
  933. * @param {?} i
  934. * @return {?}
  935. */
  936. function (i) {
  937. return _this._stripDirectionalityCharacters(_this._format(dtf_1, new Date(2017, i, 1)));
  938. }));
  939. }
  940. return DEFAULT_MONTH_NAMES[style];
  941. };
  942. /**
  943. * @return {?}
  944. */
  945. NativeDateAdapter.prototype.getDateNames = /**
  946. * @return {?}
  947. */
  948. function () {
  949. var _this = this;
  950. if (SUPPORTS_INTL_API) {
  951. /** @type {?} */
  952. var dtf_2 = new Intl.DateTimeFormat(this.locale, { day: 'numeric', timeZone: 'utc' });
  953. return range(31, (/**
  954. * @param {?} i
  955. * @return {?}
  956. */
  957. function (i) { return _this._stripDirectionalityCharacters(_this._format(dtf_2, new Date(2017, 0, i + 1))); }));
  958. }
  959. return DEFAULT_DATE_NAMES;
  960. };
  961. /**
  962. * @param {?} style
  963. * @return {?}
  964. */
  965. NativeDateAdapter.prototype.getDayOfWeekNames = /**
  966. * @param {?} style
  967. * @return {?}
  968. */
  969. function (style) {
  970. var _this = this;
  971. if (SUPPORTS_INTL_API) {
  972. /** @type {?} */
  973. var dtf_3 = new Intl.DateTimeFormat(this.locale, { weekday: style, timeZone: 'utc' });
  974. return range(7, (/**
  975. * @param {?} i
  976. * @return {?}
  977. */
  978. function (i) { return _this._stripDirectionalityCharacters(_this._format(dtf_3, new Date(2017, 0, i + 1))); }));
  979. }
  980. return DEFAULT_DAY_OF_WEEK_NAMES[style];
  981. };
  982. /**
  983. * @param {?} date
  984. * @return {?}
  985. */
  986. NativeDateAdapter.prototype.getYearName = /**
  987. * @param {?} date
  988. * @return {?}
  989. */
  990. function (date) {
  991. if (SUPPORTS_INTL_API) {
  992. /** @type {?} */
  993. var dtf = new Intl.DateTimeFormat(this.locale, { year: 'numeric', timeZone: 'utc' });
  994. return this._stripDirectionalityCharacters(this._format(dtf, date));
  995. }
  996. return String(this.getYear(date));
  997. };
  998. /**
  999. * @return {?}
  1000. */
  1001. NativeDateAdapter.prototype.getFirstDayOfWeek = /**
  1002. * @return {?}
  1003. */
  1004. function () {
  1005. // We can't tell using native JS Date what the first day of the week is, we default to Sunday.
  1006. return 0;
  1007. };
  1008. /**
  1009. * @param {?} date
  1010. * @return {?}
  1011. */
  1012. NativeDateAdapter.prototype.getNumDaysInMonth = /**
  1013. * @param {?} date
  1014. * @return {?}
  1015. */
  1016. function (date) {
  1017. return this.getDate(this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + 1, 0));
  1018. };
  1019. /**
  1020. * @param {?} date
  1021. * @return {?}
  1022. */
  1023. NativeDateAdapter.prototype.clone = /**
  1024. * @param {?} date
  1025. * @return {?}
  1026. */
  1027. function (date) {
  1028. return new Date(date.getTime());
  1029. };
  1030. /**
  1031. * @param {?} year
  1032. * @param {?} month
  1033. * @param {?} date
  1034. * @return {?}
  1035. */
  1036. NativeDateAdapter.prototype.createDate = /**
  1037. * @param {?} year
  1038. * @param {?} month
  1039. * @param {?} date
  1040. * @return {?}
  1041. */
  1042. function (year, month, date) {
  1043. // Check for invalid month and date (except upper bound on date which we have to check after
  1044. // creating the Date).
  1045. if (month < 0 || month > 11) {
  1046. throw Error("Invalid month index \"" + month + "\". Month index has to be between 0 and 11.");
  1047. }
  1048. if (date < 1) {
  1049. throw Error("Invalid date \"" + date + "\". Date has to be greater than 0.");
  1050. }
  1051. /** @type {?} */
  1052. var result = this._createDateWithOverflow(year, month, date);
  1053. // Check that the date wasn't above the upper bound for the month, causing the month to overflow
  1054. if (result.getMonth() != month) {
  1055. throw Error("Invalid date \"" + date + "\" for month with index \"" + month + "\".");
  1056. }
  1057. return result;
  1058. };
  1059. /**
  1060. * @return {?}
  1061. */
  1062. NativeDateAdapter.prototype.today = /**
  1063. * @return {?}
  1064. */
  1065. function () {
  1066. return new Date();
  1067. };
  1068. /**
  1069. * @param {?} value
  1070. * @return {?}
  1071. */
  1072. NativeDateAdapter.prototype.parse = /**
  1073. * @param {?} value
  1074. * @return {?}
  1075. */
  1076. function (value) {
  1077. // We have no way using the native JS Date to set the parse format or locale, so we ignore these
  1078. // parameters.
  1079. if (typeof value == 'number') {
  1080. return new Date(value);
  1081. }
  1082. return value ? new Date(Date.parse(value)) : null;
  1083. };
  1084. /**
  1085. * @param {?} date
  1086. * @param {?} displayFormat
  1087. * @return {?}
  1088. */
  1089. NativeDateAdapter.prototype.format = /**
  1090. * @param {?} date
  1091. * @param {?} displayFormat
  1092. * @return {?}
  1093. */
  1094. function (date, displayFormat) {
  1095. if (!this.isValid(date)) {
  1096. throw Error('NativeDateAdapter: Cannot format invalid date.');
  1097. }
  1098. if (SUPPORTS_INTL_API) {
  1099. // On IE and Edge the i18n API will throw a hard error that can crash the entire app
  1100. // if we attempt to format a date whose year is less than 1 or greater than 9999.
  1101. if (this._clampDate && (date.getFullYear() < 1 || date.getFullYear() > 9999)) {
  1102. date = this.clone(date);
  1103. date.setFullYear(Math.max(1, Math.min(9999, date.getFullYear())));
  1104. }
  1105. displayFormat = __assign({}, displayFormat, { timeZone: 'utc' });
  1106. /** @type {?} */
  1107. var dtf = new Intl.DateTimeFormat(this.locale, displayFormat);
  1108. return this._stripDirectionalityCharacters(this._format(dtf, date));
  1109. }
  1110. return this._stripDirectionalityCharacters(date.toDateString());
  1111. };
  1112. /**
  1113. * @param {?} date
  1114. * @param {?} years
  1115. * @return {?}
  1116. */
  1117. NativeDateAdapter.prototype.addCalendarYears = /**
  1118. * @param {?} date
  1119. * @param {?} years
  1120. * @return {?}
  1121. */
  1122. function (date, years) {
  1123. return this.addCalendarMonths(date, years * 12);
  1124. };
  1125. /**
  1126. * @param {?} date
  1127. * @param {?} months
  1128. * @return {?}
  1129. */
  1130. NativeDateAdapter.prototype.addCalendarMonths = /**
  1131. * @param {?} date
  1132. * @param {?} months
  1133. * @return {?}
  1134. */
  1135. function (date, months) {
  1136. /** @type {?} */
  1137. var newDate = this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + months, this.getDate(date));
  1138. // It's possible to wind up in the wrong month if the original month has more days than the new
  1139. // month. In this case we want to go to the last day of the desired month.
  1140. // Note: the additional + 12 % 12 ensures we end up with a positive number, since JS % doesn't
  1141. // guarantee this.
  1142. if (this.getMonth(newDate) != ((this.getMonth(date) + months) % 12 + 12) % 12) {
  1143. newDate = this._createDateWithOverflow(this.getYear(newDate), this.getMonth(newDate), 0);
  1144. }
  1145. return newDate;
  1146. };
  1147. /**
  1148. * @param {?} date
  1149. * @param {?} days
  1150. * @return {?}
  1151. */
  1152. NativeDateAdapter.prototype.addCalendarDays = /**
  1153. * @param {?} date
  1154. * @param {?} days
  1155. * @return {?}
  1156. */
  1157. function (date, days) {
  1158. return this._createDateWithOverflow(this.getYear(date), this.getMonth(date), this.getDate(date) + days);
  1159. };
  1160. /**
  1161. * @param {?} date
  1162. * @return {?}
  1163. */
  1164. NativeDateAdapter.prototype.toIso8601 = /**
  1165. * @param {?} date
  1166. * @return {?}
  1167. */
  1168. function (date) {
  1169. return [
  1170. date.getUTCFullYear(),
  1171. this._2digit(date.getUTCMonth() + 1),
  1172. this._2digit(date.getUTCDate())
  1173. ].join('-');
  1174. };
  1175. /**
  1176. * Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings
  1177. * (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an
  1178. * invalid date for all other values.
  1179. */
  1180. /**
  1181. * Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings
  1182. * (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an
  1183. * invalid date for all other values.
  1184. * @param {?} value
  1185. * @return {?}
  1186. */
  1187. NativeDateAdapter.prototype.deserialize = /**
  1188. * Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings
  1189. * (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an
  1190. * invalid date for all other values.
  1191. * @param {?} value
  1192. * @return {?}
  1193. */
  1194. function (value) {
  1195. if (typeof value === 'string') {
  1196. if (!value) {
  1197. return null;
  1198. }
  1199. // The `Date` constructor accepts formats other than ISO 8601, so we need to make sure the
  1200. // string is the right format first.
  1201. if (ISO_8601_REGEX.test(value)) {
  1202. /** @type {?} */
  1203. var date = new Date(value);
  1204. if (this.isValid(date)) {
  1205. return date;
  1206. }
  1207. }
  1208. }
  1209. return _super.prototype.deserialize.call(this, value);
  1210. };
  1211. /**
  1212. * @param {?} obj
  1213. * @return {?}
  1214. */
  1215. NativeDateAdapter.prototype.isDateInstance = /**
  1216. * @param {?} obj
  1217. * @return {?}
  1218. */
  1219. function (obj) {
  1220. return obj instanceof Date;
  1221. };
  1222. /**
  1223. * @param {?} date
  1224. * @return {?}
  1225. */
  1226. NativeDateAdapter.prototype.isValid = /**
  1227. * @param {?} date
  1228. * @return {?}
  1229. */
  1230. function (date) {
  1231. return !isNaN(date.getTime());
  1232. };
  1233. /**
  1234. * @return {?}
  1235. */
  1236. NativeDateAdapter.prototype.invalid = /**
  1237. * @return {?}
  1238. */
  1239. function () {
  1240. return new Date(NaN);
  1241. };
  1242. /** Creates a date but allows the month and date to overflow. */
  1243. /**
  1244. * Creates a date but allows the month and date to overflow.
  1245. * @private
  1246. * @param {?} year
  1247. * @param {?} month
  1248. * @param {?} date
  1249. * @return {?}
  1250. */
  1251. NativeDateAdapter.prototype._createDateWithOverflow = /**
  1252. * Creates a date but allows the month and date to overflow.
  1253. * @private
  1254. * @param {?} year
  1255. * @param {?} month
  1256. * @param {?} date
  1257. * @return {?}
  1258. */
  1259. function (year, month, date) {
  1260. /** @type {?} */
  1261. var result = new Date(year, month, date);
  1262. // We need to correct for the fact that JS native Date treats years in range [0, 99] as
  1263. // abbreviations for 19xx.
  1264. if (year >= 0 && year < 100) {
  1265. result.setFullYear(this.getYear(result) - 1900);
  1266. }
  1267. return result;
  1268. };
  1269. /**
  1270. * Pads a number to make it two digits.
  1271. * @param n The number to pad.
  1272. * @returns The padded number.
  1273. */
  1274. /**
  1275. * Pads a number to make it two digits.
  1276. * @private
  1277. * @param {?} n The number to pad.
  1278. * @return {?} The padded number.
  1279. */
  1280. NativeDateAdapter.prototype._2digit = /**
  1281. * Pads a number to make it two digits.
  1282. * @private
  1283. * @param {?} n The number to pad.
  1284. * @return {?} The padded number.
  1285. */
  1286. function (n) {
  1287. return ('00' + n).slice(-2);
  1288. };
  1289. /**
  1290. * Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while
  1291. * other browsers do not. We remove them to make output consistent and because they interfere with
  1292. * date parsing.
  1293. * @param str The string to strip direction characters from.
  1294. * @returns The stripped string.
  1295. */
  1296. /**
  1297. * Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while
  1298. * other browsers do not. We remove them to make output consistent and because they interfere with
  1299. * date parsing.
  1300. * @private
  1301. * @param {?} str The string to strip direction characters from.
  1302. * @return {?} The stripped string.
  1303. */
  1304. NativeDateAdapter.prototype._stripDirectionalityCharacters = /**
  1305. * Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while
  1306. * other browsers do not. We remove them to make output consistent and because they interfere with
  1307. * date parsing.
  1308. * @private
  1309. * @param {?} str The string to strip direction characters from.
  1310. * @return {?} The stripped string.
  1311. */
  1312. function (str) {
  1313. return str.replace(/[\u200e\u200f]/g, '');
  1314. };
  1315. /**
  1316. * When converting Date object to string, javascript built-in functions may return wrong
  1317. * results because it applies its internal DST rules. The DST rules around the world change
  1318. * very frequently, and the current valid rule is not always valid in previous years though.
  1319. * We work around this problem building a new Date object which has its internal UTC
  1320. * representation with the local date and time.
  1321. * @param dtf Intl.DateTimeFormat object, containg the desired string format. It must have
  1322. * timeZone set to 'utc' to work fine.
  1323. * @param date Date from which we want to get the string representation according to dtf
  1324. * @returns A Date object with its UTC representation based on the passed in date info
  1325. */
  1326. /**
  1327. * When converting Date object to string, javascript built-in functions may return wrong
  1328. * results because it applies its internal DST rules. The DST rules around the world change
  1329. * very frequently, and the current valid rule is not always valid in previous years though.
  1330. * We work around this problem building a new Date object which has its internal UTC
  1331. * representation with the local date and time.
  1332. * @private
  1333. * @param {?} dtf Intl.DateTimeFormat object, containg the desired string format. It must have
  1334. * timeZone set to 'utc' to work fine.
  1335. * @param {?} date Date from which we want to get the string representation according to dtf
  1336. * @return {?} A Date object with its UTC representation based on the passed in date info
  1337. */
  1338. NativeDateAdapter.prototype._format = /**
  1339. * When converting Date object to string, javascript built-in functions may return wrong
  1340. * results because it applies its internal DST rules. The DST rules around the world change
  1341. * very frequently, and the current valid rule is not always valid in previous years though.
  1342. * We work around this problem building a new Date object which has its internal UTC
  1343. * representation with the local date and time.
  1344. * @private
  1345. * @param {?} dtf Intl.DateTimeFormat object, containg the desired string format. It must have
  1346. * timeZone set to 'utc' to work fine.
  1347. * @param {?} date Date from which we want to get the string representation according to dtf
  1348. * @return {?} A Date object with its UTC representation based on the passed in date info
  1349. */
  1350. function (dtf, date) {
  1351. /** @type {?} */
  1352. var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
  1353. return dtf.format(d);
  1354. };
  1355. NativeDateAdapter.decorators = [
  1356. { type: Injectable },
  1357. ];
  1358. /** @nocollapse */
  1359. NativeDateAdapter.ctorParameters = function () { return [
  1360. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DATE_LOCALE,] }] },
  1361. { type: Platform }
  1362. ]; };
  1363. return NativeDateAdapter;
  1364. }(DateAdapter));
  1365. /**
  1366. * @fileoverview added by tsickle
  1367. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1368. */
  1369. /** @type {?} */
  1370. var MAT_NATIVE_DATE_FORMATS = {
  1371. parse: {
  1372. dateInput: null,
  1373. },
  1374. display: {
  1375. dateInput: { year: 'numeric', month: 'numeric', day: 'numeric' },
  1376. monthYearLabel: { year: 'numeric', month: 'short' },
  1377. dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
  1378. monthYearA11yLabel: { year: 'numeric', month: 'long' },
  1379. }
  1380. };
  1381. /**
  1382. * @fileoverview added by tsickle
  1383. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1384. */
  1385. var NativeDateModule = /** @class */ (function () {
  1386. function NativeDateModule() {
  1387. }
  1388. NativeDateModule.decorators = [
  1389. { type: NgModule, args: [{
  1390. imports: [PlatformModule],
  1391. providers: [
  1392. { provide: DateAdapter, useClass: NativeDateAdapter },
  1393. ],
  1394. },] },
  1395. ];
  1396. return NativeDateModule;
  1397. }());
  1398. var ɵ0$1 = MAT_NATIVE_DATE_FORMATS;
  1399. var MatNativeDateModule = /** @class */ (function () {
  1400. function MatNativeDateModule() {
  1401. }
  1402. MatNativeDateModule.decorators = [
  1403. { type: NgModule, args: [{
  1404. imports: [NativeDateModule],
  1405. providers: [{ provide: MAT_DATE_FORMATS, useValue: ɵ0$1 }],
  1406. },] },
  1407. ];
  1408. return MatNativeDateModule;
  1409. }());
  1410. /**
  1411. * @fileoverview added by tsickle
  1412. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1413. */
  1414. /**
  1415. * Error state matcher that matches when a control is invalid and dirty.
  1416. */
  1417. var ShowOnDirtyErrorStateMatcher = /** @class */ (function () {
  1418. function ShowOnDirtyErrorStateMatcher() {
  1419. }
  1420. /**
  1421. * @param {?} control
  1422. * @param {?} form
  1423. * @return {?}
  1424. */
  1425. ShowOnDirtyErrorStateMatcher.prototype.isErrorState = /**
  1426. * @param {?} control
  1427. * @param {?} form
  1428. * @return {?}
  1429. */
  1430. function (control, form) {
  1431. return !!(control && control.invalid && (control.dirty || (form && form.submitted)));
  1432. };
  1433. ShowOnDirtyErrorStateMatcher.decorators = [
  1434. { type: Injectable },
  1435. ];
  1436. return ShowOnDirtyErrorStateMatcher;
  1437. }());
  1438. /**
  1439. * Provider that defines how form controls behave with regards to displaying error messages.
  1440. */
  1441. var ErrorStateMatcher = /** @class */ (function () {
  1442. function ErrorStateMatcher() {
  1443. }
  1444. /**
  1445. * @param {?} control
  1446. * @param {?} form
  1447. * @return {?}
  1448. */
  1449. ErrorStateMatcher.prototype.isErrorState = /**
  1450. * @param {?} control
  1451. * @param {?} form
  1452. * @return {?}
  1453. */
  1454. function (control, form) {
  1455. return !!(control && control.invalid && (control.touched || (form && form.submitted)));
  1456. };
  1457. ErrorStateMatcher.decorators = [
  1458. { type: Injectable, args: [{ providedIn: 'root' },] },
  1459. ];
  1460. /** @nocollapse */ ErrorStateMatcher.ngInjectableDef = ɵɵdefineInjectable({ factory: function ErrorStateMatcher_Factory() { return new ErrorStateMatcher(); }, token: ErrorStateMatcher, providedIn: "root" });
  1461. return ErrorStateMatcher;
  1462. }());
  1463. /**
  1464. * @fileoverview added by tsickle
  1465. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1466. */
  1467. /**
  1468. * @fileoverview added by tsickle
  1469. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1470. */
  1471. /**
  1472. * Injection token that can be used to provide options to the Hammerjs instance.
  1473. * More info at http://hammerjs.github.io/api/.
  1474. * @type {?}
  1475. */
  1476. var MAT_HAMMER_OPTIONS = new InjectionToken('MAT_HAMMER_OPTIONS');
  1477. /** @type {?} */
  1478. var ANGULAR_MATERIAL_SUPPORTED_HAMMER_GESTURES = [
  1479. 'longpress',
  1480. 'slide',
  1481. 'slidestart',
  1482. 'slideend',
  1483. 'slideright',
  1484. 'slideleft'
  1485. ];
  1486. var ɵ0$2 = /**
  1487. * @return {?}
  1488. */
  1489. function () { }, ɵ1 = /**
  1490. * @return {?}
  1491. */
  1492. function () { };
  1493. /**
  1494. * Fake HammerInstance that is used when a Hammer instance is requested when HammerJS has not
  1495. * been loaded on the page.
  1496. * @type {?}
  1497. */
  1498. var noopHammerInstance = {
  1499. on: (ɵ0$2),
  1500. off: (ɵ1),
  1501. };
  1502. /**
  1503. * Adjusts configuration of our gesture library, Hammer.
  1504. */
  1505. var GestureConfig = /** @class */ (function (_super) {
  1506. __extends(GestureConfig, _super);
  1507. function GestureConfig(_hammerOptions, commonModule) {
  1508. var _this = _super.call(this) || this;
  1509. _this._hammerOptions = _hammerOptions;
  1510. /**
  1511. * List of new event names to add to the gesture support list
  1512. */
  1513. _this.events = ANGULAR_MATERIAL_SUPPORTED_HAMMER_GESTURES;
  1514. if (commonModule) {
  1515. commonModule._checkHammerIsAvailable();
  1516. }
  1517. return _this;
  1518. }
  1519. /**
  1520. * Builds Hammer instance manually to add custom recognizers that match the Material Design spec.
  1521. *
  1522. * Our gesture names come from the Material Design gestures spec:
  1523. * https://material.io/design/#gestures-touch-mechanics
  1524. *
  1525. * More information on default recognizers can be found in Hammer docs:
  1526. * http://hammerjs.github.io/recognizer-pan/
  1527. * http://hammerjs.github.io/recognizer-press/
  1528. *
  1529. * @param element Element to which to assign the new HammerJS gestures.
  1530. * @returns Newly-created HammerJS instance.
  1531. */
  1532. /**
  1533. * Builds Hammer instance manually to add custom recognizers that match the Material Design spec.
  1534. *
  1535. * Our gesture names come from the Material Design gestures spec:
  1536. * https://material.io/design/#gestures-touch-mechanics
  1537. *
  1538. * More information on default recognizers can be found in Hammer docs:
  1539. * http://hammerjs.github.io/recognizer-pan/
  1540. * http://hammerjs.github.io/recognizer-press/
  1541. *
  1542. * @param {?} element Element to which to assign the new HammerJS gestures.
  1543. * @return {?} Newly-created HammerJS instance.
  1544. */
  1545. GestureConfig.prototype.buildHammer = /**
  1546. * Builds Hammer instance manually to add custom recognizers that match the Material Design spec.
  1547. *
  1548. * Our gesture names come from the Material Design gestures spec:
  1549. * https://material.io/design/#gestures-touch-mechanics
  1550. *
  1551. * More information on default recognizers can be found in Hammer docs:
  1552. * http://hammerjs.github.io/recognizer-pan/
  1553. * http://hammerjs.github.io/recognizer-press/
  1554. *
  1555. * @param {?} element Element to which to assign the new HammerJS gestures.
  1556. * @return {?} Newly-created HammerJS instance.
  1557. */
  1558. function (element) {
  1559. /** @type {?} */
  1560. var hammer = typeof window !== 'undefined' ? ((/** @type {?} */ (window))).Hammer : null;
  1561. if (!hammer) {
  1562. // If HammerJS is not loaded here, return the noop HammerInstance. This is necessary to
  1563. // ensure that omitting HammerJS completely will not cause any errors while *also* supporting
  1564. // the lazy-loading of HammerJS via the HAMMER_LOADER token introduced in Angular 6.1.
  1565. // Because we can't depend on HAMMER_LOADER's existance until 7.0, we have to always set
  1566. // `this.events` to the set we support, instead of conditionally setting it to `[]` if
  1567. // `HAMMER_LOADER` is present (and then throwing an Error here if `window.Hammer` is
  1568. // undefined).
  1569. // @breaking-change 8.0.0
  1570. return noopHammerInstance;
  1571. }
  1572. /** @type {?} */
  1573. var mc = new hammer(element, this._hammerOptions || undefined);
  1574. // Default Hammer Recognizers.
  1575. /** @type {?} */
  1576. var pan = new hammer.Pan();
  1577. /** @type {?} */
  1578. var swipe = new hammer.Swipe();
  1579. /** @type {?} */
  1580. var press = new hammer.Press();
  1581. // Notice that a HammerJS recognizer can only depend on one other recognizer once.
  1582. // Otherwise the previous `recognizeWith` will be dropped.
  1583. // TODO: Confirm threshold numbers with Material Design UX Team
  1584. /** @type {?} */
  1585. var slide = this._createRecognizer(pan, { event: 'slide', threshold: 0 }, swipe);
  1586. /** @type {?} */
  1587. var longpress = this._createRecognizer(press, { event: 'longpress', time: 500 });
  1588. // Overwrite the default `pan` event to use the swipe event.
  1589. pan.recognizeWith(swipe);
  1590. // Since the slide event threshold is set to zero, the slide recognizer can fire and
  1591. // accidentally reset the longpress recognizer. In order to make sure that the two
  1592. // recognizers can run simultaneously but don't affect each other, we allow the slide
  1593. // recognizer to recognize while a longpress is being processed.
  1594. // See: https://github.com/hammerjs/hammer.js/blob/master/src/manager.js#L123-L124
  1595. longpress.recognizeWith(slide);
  1596. // Add customized gestures to Hammer manager
  1597. mc.add([swipe, press, pan, slide, longpress]);
  1598. return (/** @type {?} */ (mc));
  1599. };
  1600. /** Creates a new recognizer, without affecting the default recognizers of HammerJS */
  1601. /**
  1602. * Creates a new recognizer, without affecting the default recognizers of HammerJS
  1603. * @private
  1604. * @param {?} base
  1605. * @param {?} options
  1606. * @param {...?} inheritances
  1607. * @return {?}
  1608. */
  1609. GestureConfig.prototype._createRecognizer = /**
  1610. * Creates a new recognizer, without affecting the default recognizers of HammerJS
  1611. * @private
  1612. * @param {?} base
  1613. * @param {?} options
  1614. * @param {...?} inheritances
  1615. * @return {?}
  1616. */
  1617. function (base, options) {
  1618. var inheritances = [];
  1619. for (var _i = 2; _i < arguments.length; _i++) {
  1620. inheritances[_i - 2] = arguments[_i];
  1621. }
  1622. /** @type {?} */
  1623. var recognizer = new ((/** @type {?} */ (base.constructor)))(options);
  1624. inheritances.push(base);
  1625. inheritances.forEach((/**
  1626. * @param {?} item
  1627. * @return {?}
  1628. */
  1629. function (item) { return recognizer.recognizeWith(item); }));
  1630. return recognizer;
  1631. };
  1632. GestureConfig.decorators = [
  1633. { type: Injectable },
  1634. ];
  1635. /** @nocollapse */
  1636. GestureConfig.ctorParameters = function () { return [
  1637. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_HAMMER_OPTIONS,] }] },
  1638. { type: MatCommonModule, decorators: [{ type: Optional }] }
  1639. ]; };
  1640. return GestureConfig;
  1641. }(HammerGestureConfig));
  1642. /**
  1643. * @fileoverview added by tsickle
  1644. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1645. */
  1646. /**
  1647. * Shared directive to count lines inside a text area, such as a list item.
  1648. * Line elements can be extracted with a \@ContentChildren(MatLine) query, then
  1649. * counted by checking the query list's length.
  1650. */
  1651. var MatLine = /** @class */ (function () {
  1652. function MatLine() {
  1653. }
  1654. MatLine.decorators = [
  1655. { type: Directive, args: [{
  1656. selector: '[mat-line], [matLine]',
  1657. host: { 'class': 'mat-line' }
  1658. },] },
  1659. ];
  1660. return MatLine;
  1661. }());
  1662. /**
  1663. * Helper that takes a query list of lines and sets the correct class on the host.
  1664. * \@docs-private
  1665. * @param {?} lines
  1666. * @param {?} element
  1667. * @return {?}
  1668. */
  1669. function setLines(lines, element) {
  1670. // Note: doesn't need to unsubscribe, because `changes`
  1671. // gets completed by Angular when the view is destroyed.
  1672. lines.changes.pipe(startWith(lines)).subscribe((/**
  1673. * @param {?} __0
  1674. * @return {?}
  1675. */
  1676. function (_a) {
  1677. var length = _a.length;
  1678. setClass(element, 'mat-2-line', false);
  1679. setClass(element, 'mat-3-line', false);
  1680. setClass(element, 'mat-multi-line', false);
  1681. if (length === 2 || length === 3) {
  1682. setClass(element, "mat-" + length + "-line", true);
  1683. }
  1684. else if (length > 3) {
  1685. setClass(element, "mat-multi-line", true);
  1686. }
  1687. }));
  1688. }
  1689. /**
  1690. * Adds or removes a class from an element.
  1691. * @param {?} element
  1692. * @param {?} className
  1693. * @param {?} isAdd
  1694. * @return {?}
  1695. */
  1696. function setClass(element, className, isAdd) {
  1697. /** @type {?} */
  1698. var classList = element.nativeElement.classList;
  1699. isAdd ? classList.add(className) : classList.remove(className);
  1700. }
  1701. /**
  1702. * Helper that takes a query list of lines and sets the correct class on the host.
  1703. * \@docs-private
  1704. * @deprecated Use `setLines` instead.
  1705. * \@breaking-change 8.0.0
  1706. */
  1707. var /**
  1708. * Helper that takes a query list of lines and sets the correct class on the host.
  1709. * \@docs-private
  1710. * @deprecated Use `setLines` instead.
  1711. * \@breaking-change 8.0.0
  1712. */
  1713. MatLineSetter = /** @class */ (function () {
  1714. function MatLineSetter(lines, element) {
  1715. setLines(lines, element);
  1716. }
  1717. return MatLineSetter;
  1718. }());
  1719. var MatLineModule = /** @class */ (function () {
  1720. function MatLineModule() {
  1721. }
  1722. MatLineModule.decorators = [
  1723. { type: NgModule, args: [{
  1724. imports: [MatCommonModule],
  1725. exports: [MatLine, MatCommonModule],
  1726. declarations: [MatLine],
  1727. },] },
  1728. ];
  1729. return MatLineModule;
  1730. }());
  1731. /**
  1732. * @fileoverview added by tsickle
  1733. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1734. */
  1735. /** @enum {number} */
  1736. var RippleState = {
  1737. FADING_IN: 0, VISIBLE: 1, FADING_OUT: 2, HIDDEN: 3,
  1738. };
  1739. RippleState[RippleState.FADING_IN] = 'FADING_IN';
  1740. RippleState[RippleState.VISIBLE] = 'VISIBLE';
  1741. RippleState[RippleState.FADING_OUT] = 'FADING_OUT';
  1742. RippleState[RippleState.HIDDEN] = 'HIDDEN';
  1743. /**
  1744. * Reference to a previously launched ripple element.
  1745. */
  1746. var /**
  1747. * Reference to a previously launched ripple element.
  1748. */
  1749. RippleRef = /** @class */ (function () {
  1750. function RippleRef(_renderer, element, config) {
  1751. this._renderer = _renderer;
  1752. this.element = element;
  1753. this.config = config;
  1754. /**
  1755. * Current state of the ripple.
  1756. */
  1757. this.state = RippleState.HIDDEN;
  1758. }
  1759. /** Fades out the ripple element. */
  1760. /**
  1761. * Fades out the ripple element.
  1762. * @return {?}
  1763. */
  1764. RippleRef.prototype.fadeOut = /**
  1765. * Fades out the ripple element.
  1766. * @return {?}
  1767. */
  1768. function () {
  1769. this._renderer.fadeOutRipple(this);
  1770. };
  1771. return RippleRef;
  1772. }());
  1773. /**
  1774. * @fileoverview added by tsickle
  1775. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1776. */
  1777. /**
  1778. * Default ripple animation configuration for ripples without an explicit
  1779. * animation config specified.
  1780. * @type {?}
  1781. */
  1782. var defaultRippleAnimationConfig = {
  1783. enterDuration: 450,
  1784. exitDuration: 400
  1785. };
  1786. /**
  1787. * Timeout for ignoring mouse events. Mouse events will be temporary ignored after touch
  1788. * events to avoid synthetic mouse events.
  1789. * @type {?}
  1790. */
  1791. var ignoreMouseEventsTimeout = 800;
  1792. /**
  1793. * Options that apply to all the event listeners that are bound by the ripple renderer.
  1794. * @type {?}
  1795. */
  1796. var passiveEventOptions = normalizePassiveListenerOptions({ passive: true });
  1797. /**
  1798. * Helper service that performs DOM manipulations. Not intended to be used outside this module.
  1799. * The constructor takes a reference to the ripple directive's host element and a map of DOM
  1800. * event handlers to be installed on the element that triggers ripple animations.
  1801. * This will eventually become a custom renderer once Angular support exists.
  1802. * \@docs-private
  1803. */
  1804. var /**
  1805. * Helper service that performs DOM manipulations. Not intended to be used outside this module.
  1806. * The constructor takes a reference to the ripple directive's host element and a map of DOM
  1807. * event handlers to be installed on the element that triggers ripple animations.
  1808. * This will eventually become a custom renderer once Angular support exists.
  1809. * \@docs-private
  1810. */
  1811. RippleRenderer = /** @class */ (function () {
  1812. function RippleRenderer(_target, _ngZone, elementRef, platform) {
  1813. var _this = this;
  1814. this._target = _target;
  1815. this._ngZone = _ngZone;
  1816. /**
  1817. * Whether the pointer is currently down or not.
  1818. */
  1819. this._isPointerDown = false;
  1820. /**
  1821. * Events to be registered on the trigger element.
  1822. */
  1823. this._triggerEvents = new Map();
  1824. /**
  1825. * Set of currently active ripple references.
  1826. */
  1827. this._activeRipples = new Set();
  1828. /**
  1829. * Function being called whenever the trigger is being pressed using mouse.
  1830. */
  1831. this._onMousedown = (/**
  1832. * @param {?} event
  1833. * @return {?}
  1834. */
  1835. function (event) {
  1836. // Screen readers will fire fake mouse events for space/enter. Skip launching a
  1837. // ripple in this case for consistency with the non-screen-reader experience.
  1838. /** @type {?} */
  1839. var isFakeMousedown = isFakeMousedownFromScreenReader(event);
  1840. /** @type {?} */
  1841. var isSyntheticEvent = _this._lastTouchStartEvent &&
  1842. Date.now() < _this._lastTouchStartEvent + ignoreMouseEventsTimeout;
  1843. if (!_this._target.rippleDisabled && !isFakeMousedown && !isSyntheticEvent) {
  1844. _this._isPointerDown = true;
  1845. _this.fadeInRipple(event.clientX, event.clientY, _this._target.rippleConfig);
  1846. }
  1847. });
  1848. /**
  1849. * Function being called whenever the trigger is being pressed using touch.
  1850. */
  1851. this._onTouchStart = (/**
  1852. * @param {?} event
  1853. * @return {?}
  1854. */
  1855. function (event) {
  1856. if (!_this._target.rippleDisabled) {
  1857. // Some browsers fire mouse events after a `touchstart` event. Those synthetic mouse
  1858. // events will launch a second ripple if we don't ignore mouse events for a specific
  1859. // time after a touchstart event.
  1860. _this._lastTouchStartEvent = Date.now();
  1861. _this._isPointerDown = true;
  1862. // Use `changedTouches` so we skip any touches where the user put
  1863. // their finger down, but used another finger to tap the element again.
  1864. /** @type {?} */
  1865. var touches = event.changedTouches;
  1866. for (var i = 0; i < touches.length; i++) {
  1867. _this.fadeInRipple(touches[i].clientX, touches[i].clientY, _this._target.rippleConfig);
  1868. }
  1869. }
  1870. });
  1871. /**
  1872. * Function being called whenever the trigger is being released.
  1873. */
  1874. this._onPointerUp = (/**
  1875. * @return {?}
  1876. */
  1877. function () {
  1878. if (!_this._isPointerDown) {
  1879. return;
  1880. }
  1881. _this._isPointerDown = false;
  1882. // Fade-out all ripples that are visible and not persistent.
  1883. _this._activeRipples.forEach((/**
  1884. * @param {?} ripple
  1885. * @return {?}
  1886. */
  1887. function (ripple) {
  1888. // By default, only ripples that are completely visible will fade out on pointer release.
  1889. // If the `terminateOnPointerUp` option is set, ripples that still fade in will also fade out.
  1890. /** @type {?} */
  1891. var isVisible = ripple.state === RippleState.VISIBLE ||
  1892. ripple.config.terminateOnPointerUp && ripple.state === RippleState.FADING_IN;
  1893. if (!ripple.config.persistent && isVisible) {
  1894. ripple.fadeOut();
  1895. }
  1896. }));
  1897. });
  1898. // Only do anything if we're on the browser.
  1899. if (platform.isBrowser) {
  1900. this._containerElement = elementRef.nativeElement;
  1901. // Specify events which need to be registered on the trigger.
  1902. this._triggerEvents
  1903. .set('mousedown', this._onMousedown)
  1904. .set('mouseup', this._onPointerUp)
  1905. .set('mouseleave', this._onPointerUp)
  1906. .set('touchstart', this._onTouchStart)
  1907. .set('touchend', this._onPointerUp)
  1908. .set('touchcancel', this._onPointerUp);
  1909. }
  1910. }
  1911. /**
  1912. * Fades in a ripple at the given coordinates.
  1913. * @param x Coordinate within the element, along the X axis at which to start the ripple.
  1914. * @param y Coordinate within the element, along the Y axis at which to start the ripple.
  1915. * @param config Extra ripple options.
  1916. */
  1917. /**
  1918. * Fades in a ripple at the given coordinates.
  1919. * @param {?} x Coordinate within the element, along the X axis at which to start the ripple.
  1920. * @param {?} y Coordinate within the element, along the Y axis at which to start the ripple.
  1921. * @param {?=} config Extra ripple options.
  1922. * @return {?}
  1923. */
  1924. RippleRenderer.prototype.fadeInRipple = /**
  1925. * Fades in a ripple at the given coordinates.
  1926. * @param {?} x Coordinate within the element, along the X axis at which to start the ripple.
  1927. * @param {?} y Coordinate within the element, along the Y axis at which to start the ripple.
  1928. * @param {?=} config Extra ripple options.
  1929. * @return {?}
  1930. */
  1931. function (x, y, config) {
  1932. var _this = this;
  1933. if (config === void 0) { config = {}; }
  1934. /** @type {?} */
  1935. var containerRect = this._containerRect =
  1936. this._containerRect || this._containerElement.getBoundingClientRect();
  1937. /** @type {?} */
  1938. var animationConfig = __assign({}, defaultRippleAnimationConfig, config.animation);
  1939. if (config.centered) {
  1940. x = containerRect.left + containerRect.width / 2;
  1941. y = containerRect.top + containerRect.height / 2;
  1942. }
  1943. /** @type {?} */
  1944. var radius = config.radius || distanceToFurthestCorner(x, y, containerRect);
  1945. /** @type {?} */
  1946. var offsetX = x - containerRect.left;
  1947. /** @type {?} */
  1948. var offsetY = y - containerRect.top;
  1949. /** @type {?} */
  1950. var duration = animationConfig.enterDuration;
  1951. /** @type {?} */
  1952. var ripple = document.createElement('div');
  1953. ripple.classList.add('mat-ripple-element');
  1954. ripple.style.left = offsetX - radius + "px";
  1955. ripple.style.top = offsetY - radius + "px";
  1956. ripple.style.height = radius * 2 + "px";
  1957. ripple.style.width = radius * 2 + "px";
  1958. // If the color is not set, the default CSS color will be used.
  1959. ripple.style.backgroundColor = config.color || null;
  1960. ripple.style.transitionDuration = duration + "ms";
  1961. this._containerElement.appendChild(ripple);
  1962. // By default the browser does not recalculate the styles of dynamically created
  1963. // ripple elements. This is critical because then the `scale` would not animate properly.
  1964. enforceStyleRecalculation(ripple);
  1965. ripple.style.transform = 'scale(1)';
  1966. // Exposed reference to the ripple that will be returned.
  1967. /** @type {?} */
  1968. var rippleRef = new RippleRef(this, ripple, config);
  1969. rippleRef.state = RippleState.FADING_IN;
  1970. // Add the ripple reference to the list of all active ripples.
  1971. this._activeRipples.add(rippleRef);
  1972. if (!config.persistent) {
  1973. this._mostRecentTransientRipple = rippleRef;
  1974. }
  1975. // Wait for the ripple element to be completely faded in.
  1976. // Once it's faded in, the ripple can be hidden immediately if the mouse is released.
  1977. this._runTimeoutOutsideZone((/**
  1978. * @return {?}
  1979. */
  1980. function () {
  1981. /** @type {?} */
  1982. var isMostRecentTransientRipple = rippleRef === _this._mostRecentTransientRipple;
  1983. rippleRef.state = RippleState.VISIBLE;
  1984. // When the timer runs out while the user has kept their pointer down, we want to
  1985. // keep only the persistent ripples and the latest transient ripple. We do this,
  1986. // because we don't want stacked transient ripples to appear after their enter
  1987. // animation has finished.
  1988. if (!config.persistent && (!isMostRecentTransientRipple || !_this._isPointerDown)) {
  1989. rippleRef.fadeOut();
  1990. }
  1991. }), duration);
  1992. return rippleRef;
  1993. };
  1994. /** Fades out a ripple reference. */
  1995. /**
  1996. * Fades out a ripple reference.
  1997. * @param {?} rippleRef
  1998. * @return {?}
  1999. */
  2000. RippleRenderer.prototype.fadeOutRipple = /**
  2001. * Fades out a ripple reference.
  2002. * @param {?} rippleRef
  2003. * @return {?}
  2004. */
  2005. function (rippleRef) {
  2006. /** @type {?} */
  2007. var wasActive = this._activeRipples.delete(rippleRef);
  2008. if (rippleRef === this._mostRecentTransientRipple) {
  2009. this._mostRecentTransientRipple = null;
  2010. }
  2011. // Clear out the cached bounding rect if we have no more ripples.
  2012. if (!this._activeRipples.size) {
  2013. this._containerRect = null;
  2014. }
  2015. // For ripples that are not active anymore, don't re-run the fade-out animation.
  2016. if (!wasActive) {
  2017. return;
  2018. }
  2019. /** @type {?} */
  2020. var rippleEl = rippleRef.element;
  2021. /** @type {?} */
  2022. var animationConfig = __assign({}, defaultRippleAnimationConfig, rippleRef.config.animation);
  2023. rippleEl.style.transitionDuration = animationConfig.exitDuration + "ms";
  2024. rippleEl.style.opacity = '0';
  2025. rippleRef.state = RippleState.FADING_OUT;
  2026. // Once the ripple faded out, the ripple can be safely removed from the DOM.
  2027. this._runTimeoutOutsideZone((/**
  2028. * @return {?}
  2029. */
  2030. function () {
  2031. rippleRef.state = RippleState.HIDDEN;
  2032. (/** @type {?} */ (rippleEl.parentNode)).removeChild(rippleEl);
  2033. }), animationConfig.exitDuration);
  2034. };
  2035. /** Fades out all currently active ripples. */
  2036. /**
  2037. * Fades out all currently active ripples.
  2038. * @return {?}
  2039. */
  2040. RippleRenderer.prototype.fadeOutAll = /**
  2041. * Fades out all currently active ripples.
  2042. * @return {?}
  2043. */
  2044. function () {
  2045. this._activeRipples.forEach((/**
  2046. * @param {?} ripple
  2047. * @return {?}
  2048. */
  2049. function (ripple) { return ripple.fadeOut(); }));
  2050. };
  2051. /** Sets up the trigger event listeners */
  2052. /**
  2053. * Sets up the trigger event listeners
  2054. * @param {?} element
  2055. * @return {?}
  2056. */
  2057. RippleRenderer.prototype.setupTriggerEvents = /**
  2058. * Sets up the trigger event listeners
  2059. * @param {?} element
  2060. * @return {?}
  2061. */
  2062. function (element) {
  2063. var _this = this;
  2064. if (!element || element === this._triggerElement) {
  2065. return;
  2066. }
  2067. // Remove all previously registered event listeners from the trigger element.
  2068. this._removeTriggerEvents();
  2069. this._ngZone.runOutsideAngular((/**
  2070. * @return {?}
  2071. */
  2072. function () {
  2073. _this._triggerEvents.forEach((/**
  2074. * @param {?} fn
  2075. * @param {?} type
  2076. * @return {?}
  2077. */
  2078. function (fn, type) {
  2079. element.addEventListener(type, fn, passiveEventOptions);
  2080. }));
  2081. }));
  2082. this._triggerElement = element;
  2083. };
  2084. /** Runs a timeout outside of the Angular zone to avoid triggering the change detection. */
  2085. /**
  2086. * Runs a timeout outside of the Angular zone to avoid triggering the change detection.
  2087. * @private
  2088. * @param {?} fn
  2089. * @param {?=} delay
  2090. * @return {?}
  2091. */
  2092. RippleRenderer.prototype._runTimeoutOutsideZone = /**
  2093. * Runs a timeout outside of the Angular zone to avoid triggering the change detection.
  2094. * @private
  2095. * @param {?} fn
  2096. * @param {?=} delay
  2097. * @return {?}
  2098. */
  2099. function (fn, delay) {
  2100. if (delay === void 0) { delay = 0; }
  2101. this._ngZone.runOutsideAngular((/**
  2102. * @return {?}
  2103. */
  2104. function () { return setTimeout(fn, delay); }));
  2105. };
  2106. /** Removes previously registered event listeners from the trigger element. */
  2107. /**
  2108. * Removes previously registered event listeners from the trigger element.
  2109. * @return {?}
  2110. */
  2111. RippleRenderer.prototype._removeTriggerEvents = /**
  2112. * Removes previously registered event listeners from the trigger element.
  2113. * @return {?}
  2114. */
  2115. function () {
  2116. var _this = this;
  2117. if (this._triggerElement) {
  2118. this._triggerEvents.forEach((/**
  2119. * @param {?} fn
  2120. * @param {?} type
  2121. * @return {?}
  2122. */
  2123. function (fn, type) {
  2124. (/** @type {?} */ (_this._triggerElement)).removeEventListener(type, fn, passiveEventOptions);
  2125. }));
  2126. }
  2127. };
  2128. return RippleRenderer;
  2129. }());
  2130. /**
  2131. * Enforces a style recalculation of a DOM element by computing its styles.
  2132. * @param {?} element
  2133. * @return {?}
  2134. */
  2135. function enforceStyleRecalculation(element) {
  2136. // Enforce a style recalculation by calling `getComputedStyle` and accessing any property.
  2137. // Calling `getPropertyValue` is important to let optimizers know that this is not a noop.
  2138. // See: https://gist.github.com/paulirish/5d52fb081b3570c81e3a
  2139. window.getComputedStyle(element).getPropertyValue('opacity');
  2140. }
  2141. /**
  2142. * Returns the distance from the point (x, y) to the furthest corner of a rectangle.
  2143. * @param {?} x
  2144. * @param {?} y
  2145. * @param {?} rect
  2146. * @return {?}
  2147. */
  2148. function distanceToFurthestCorner(x, y, rect) {
  2149. /** @type {?} */
  2150. var distX = Math.max(Math.abs(x - rect.left), Math.abs(x - rect.right));
  2151. /** @type {?} */
  2152. var distY = Math.max(Math.abs(y - rect.top), Math.abs(y - rect.bottom));
  2153. return Math.sqrt(distX * distX + distY * distY);
  2154. }
  2155. /**
  2156. * @fileoverview added by tsickle
  2157. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2158. */
  2159. /**
  2160. * Injection token that can be used to specify the global ripple options.
  2161. * @type {?}
  2162. */
  2163. var MAT_RIPPLE_GLOBAL_OPTIONS = new InjectionToken('mat-ripple-global-options');
  2164. var MatRipple = /** @class */ (function () {
  2165. function MatRipple(_elementRef, ngZone, platform, globalOptions, animationMode) {
  2166. this._elementRef = _elementRef;
  2167. /**
  2168. * If set, the radius in pixels of foreground ripples when fully expanded. If unset, the radius
  2169. * will be the distance from the center of the ripple to the furthest corner of the host element's
  2170. * bounding rectangle.
  2171. */
  2172. this.radius = 0;
  2173. this._disabled = false;
  2174. /**
  2175. * Whether ripple directive is initialized and the input bindings are set.
  2176. */
  2177. this._isInitialized = false;
  2178. this._globalOptions = globalOptions || {};
  2179. this._rippleRenderer = new RippleRenderer(this, ngZone, _elementRef, platform);
  2180. if (animationMode === 'NoopAnimations') {
  2181. this._globalOptions.animation = { enterDuration: 0, exitDuration: 0 };
  2182. }
  2183. }
  2184. Object.defineProperty(MatRipple.prototype, "disabled", {
  2185. /**
  2186. * Whether click events will not trigger the ripple. Ripples can be still launched manually
  2187. * by using the `launch()` method.
  2188. */
  2189. get: /**
  2190. * Whether click events will not trigger the ripple. Ripples can be still launched manually
  2191. * by using the `launch()` method.
  2192. * @return {?}
  2193. */
  2194. function () { return this._disabled; },
  2195. set: /**
  2196. * @param {?} value
  2197. * @return {?}
  2198. */
  2199. function (value) {
  2200. this._disabled = value;
  2201. this._setupTriggerEventsIfEnabled();
  2202. },
  2203. enumerable: true,
  2204. configurable: true
  2205. });
  2206. Object.defineProperty(MatRipple.prototype, "trigger", {
  2207. /**
  2208. * The element that triggers the ripple when click events are received.
  2209. * Defaults to the directive's host element.
  2210. */
  2211. get: /**
  2212. * The element that triggers the ripple when click events are received.
  2213. * Defaults to the directive's host element.
  2214. * @return {?}
  2215. */
  2216. function () { return this._trigger || this._elementRef.nativeElement; },
  2217. set: /**
  2218. * @param {?} trigger
  2219. * @return {?}
  2220. */
  2221. function (trigger) {
  2222. this._trigger = trigger;
  2223. this._setupTriggerEventsIfEnabled();
  2224. },
  2225. enumerable: true,
  2226. configurable: true
  2227. });
  2228. /**
  2229. * @return {?}
  2230. */
  2231. MatRipple.prototype.ngOnInit = /**
  2232. * @return {?}
  2233. */
  2234. function () {
  2235. this._isInitialized = true;
  2236. this._setupTriggerEventsIfEnabled();
  2237. };
  2238. /**
  2239. * @return {?}
  2240. */
  2241. MatRipple.prototype.ngOnDestroy = /**
  2242. * @return {?}
  2243. */
  2244. function () {
  2245. this._rippleRenderer._removeTriggerEvents();
  2246. };
  2247. /** Fades out all currently showing ripple elements. */
  2248. /**
  2249. * Fades out all currently showing ripple elements.
  2250. * @return {?}
  2251. */
  2252. MatRipple.prototype.fadeOutAll = /**
  2253. * Fades out all currently showing ripple elements.
  2254. * @return {?}
  2255. */
  2256. function () {
  2257. this._rippleRenderer.fadeOutAll();
  2258. };
  2259. Object.defineProperty(MatRipple.prototype, "rippleConfig", {
  2260. /**
  2261. * Ripple configuration from the directive's input values.
  2262. * @docs-private Implemented as part of RippleTarget
  2263. */
  2264. get: /**
  2265. * Ripple configuration from the directive's input values.
  2266. * \@docs-private Implemented as part of RippleTarget
  2267. * @return {?}
  2268. */
  2269. function () {
  2270. return {
  2271. centered: this.centered,
  2272. radius: this.radius,
  2273. color: this.color,
  2274. animation: __assign({}, this._globalOptions.animation, this.animation),
  2275. terminateOnPointerUp: this._globalOptions.terminateOnPointerUp,
  2276. };
  2277. },
  2278. enumerable: true,
  2279. configurable: true
  2280. });
  2281. Object.defineProperty(MatRipple.prototype, "rippleDisabled", {
  2282. /**
  2283. * Whether ripples on pointer-down are disabled or not.
  2284. * @docs-private Implemented as part of RippleTarget
  2285. */
  2286. get: /**
  2287. * Whether ripples on pointer-down are disabled or not.
  2288. * \@docs-private Implemented as part of RippleTarget
  2289. * @return {?}
  2290. */
  2291. function () {
  2292. return this.disabled || !!this._globalOptions.disabled;
  2293. },
  2294. enumerable: true,
  2295. configurable: true
  2296. });
  2297. /** Sets up the trigger event listeners if ripples are enabled. */
  2298. /**
  2299. * Sets up the trigger event listeners if ripples are enabled.
  2300. * @private
  2301. * @return {?}
  2302. */
  2303. MatRipple.prototype._setupTriggerEventsIfEnabled = /**
  2304. * Sets up the trigger event listeners if ripples are enabled.
  2305. * @private
  2306. * @return {?}
  2307. */
  2308. function () {
  2309. if (!this.disabled && this._isInitialized) {
  2310. this._rippleRenderer.setupTriggerEvents(this.trigger);
  2311. }
  2312. };
  2313. /** Launches a manual ripple at the specified coordinated or just by the ripple config. */
  2314. /**
  2315. * Launches a manual ripple at the specified coordinated or just by the ripple config.
  2316. * @param {?} configOrX
  2317. * @param {?=} y
  2318. * @param {?=} config
  2319. * @return {?}
  2320. */
  2321. MatRipple.prototype.launch = /**
  2322. * Launches a manual ripple at the specified coordinated or just by the ripple config.
  2323. * @param {?} configOrX
  2324. * @param {?=} y
  2325. * @param {?=} config
  2326. * @return {?}
  2327. */
  2328. function (configOrX, y, config) {
  2329. if (y === void 0) { y = 0; }
  2330. if (typeof configOrX === 'number') {
  2331. return this._rippleRenderer.fadeInRipple(configOrX, y, __assign({}, this.rippleConfig, config));
  2332. }
  2333. else {
  2334. return this._rippleRenderer.fadeInRipple(0, 0, __assign({}, this.rippleConfig, configOrX));
  2335. }
  2336. };
  2337. MatRipple.decorators = [
  2338. { type: Directive, args: [{
  2339. selector: '[mat-ripple], [matRipple]',
  2340. exportAs: 'matRipple',
  2341. host: {
  2342. 'class': 'mat-ripple',
  2343. '[class.mat-ripple-unbounded]': 'unbounded'
  2344. }
  2345. },] },
  2346. ];
  2347. /** @nocollapse */
  2348. MatRipple.ctorParameters = function () { return [
  2349. { type: ElementRef },
  2350. { type: NgZone },
  2351. { type: Platform },
  2352. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_RIPPLE_GLOBAL_OPTIONS,] }] },
  2353. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  2354. ]; };
  2355. MatRipple.propDecorators = {
  2356. color: [{ type: Input, args: ['matRippleColor',] }],
  2357. unbounded: [{ type: Input, args: ['matRippleUnbounded',] }],
  2358. centered: [{ type: Input, args: ['matRippleCentered',] }],
  2359. radius: [{ type: Input, args: ['matRippleRadius',] }],
  2360. animation: [{ type: Input, args: ['matRippleAnimation',] }],
  2361. disabled: [{ type: Input, args: ['matRippleDisabled',] }],
  2362. trigger: [{ type: Input, args: ['matRippleTrigger',] }]
  2363. };
  2364. return MatRipple;
  2365. }());
  2366. /**
  2367. * @fileoverview added by tsickle
  2368. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2369. */
  2370. var MatRippleModule = /** @class */ (function () {
  2371. function MatRippleModule() {
  2372. }
  2373. MatRippleModule.decorators = [
  2374. { type: NgModule, args: [{
  2375. imports: [MatCommonModule, PlatformModule],
  2376. exports: [MatRipple, MatCommonModule],
  2377. declarations: [MatRipple],
  2378. },] },
  2379. ];
  2380. return MatRippleModule;
  2381. }());
  2382. /**
  2383. * @fileoverview added by tsickle
  2384. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2385. */
  2386. /**
  2387. * Component that shows a simplified checkbox without including any kind of "real" checkbox.
  2388. * Meant to be used when the checkbox is purely decorative and a large number of them will be
  2389. * included, such as for the options in a multi-select. Uses no SVGs or complex animations.
  2390. * Note that theming is meant to be handled by the parent element, e.g.
  2391. * `mat-primary .mat-pseudo-checkbox`.
  2392. *
  2393. * Note that this component will be completely invisible to screen-reader users. This is *not*
  2394. * interchangeable with `<mat-checkbox>` and should *not* be used if the user would directly
  2395. * interact with the checkbox. The pseudo-checkbox should only be used as an implementation detail
  2396. * of more complex components that appropriately handle selected / checked state.
  2397. * \@docs-private
  2398. */
  2399. var MatPseudoCheckbox = /** @class */ (function () {
  2400. function MatPseudoCheckbox(_animationMode) {
  2401. this._animationMode = _animationMode;
  2402. /**
  2403. * Display state of the checkbox.
  2404. */
  2405. this.state = 'unchecked';
  2406. /**
  2407. * Whether the checkbox is disabled.
  2408. */
  2409. this.disabled = false;
  2410. }
  2411. MatPseudoCheckbox.decorators = [
  2412. { type: Component, args: [{encapsulation: ViewEncapsulation.None,
  2413. changeDetection: ChangeDetectionStrategy.OnPush,
  2414. selector: 'mat-pseudo-checkbox',
  2415. styles: [".mat-pseudo-checkbox{width:16px;height:16px;border:2px solid;border-radius:2px;cursor:pointer;display:inline-block;vertical-align:middle;box-sizing:border-box;position:relative;flex-shrink:0;transition:border-color 90ms cubic-bezier(0,0,.2,.1),background-color 90ms cubic-bezier(0,0,.2,.1)}.mat-pseudo-checkbox::after{position:absolute;opacity:0;content:'';border-bottom:2px solid currentColor;transition:opacity 90ms cubic-bezier(0,0,.2,.1)}.mat-pseudo-checkbox.mat-pseudo-checkbox-checked,.mat-pseudo-checkbox.mat-pseudo-checkbox-indeterminate{border-color:transparent}._mat-animation-noopable.mat-pseudo-checkbox{transition:none;animation:none}._mat-animation-noopable.mat-pseudo-checkbox::after{transition:none}.mat-pseudo-checkbox-disabled{cursor:default}.mat-pseudo-checkbox-indeterminate::after{top:5px;left:1px;width:10px;opacity:1;border-radius:2px}.mat-pseudo-checkbox-checked::after{top:2.4px;left:1px;width:8px;height:3px;border-left:2px solid currentColor;transform:rotate(-45deg);opacity:1;box-sizing:content-box}"],
  2416. template: '',
  2417. host: {
  2418. 'class': 'mat-pseudo-checkbox',
  2419. '[class.mat-pseudo-checkbox-indeterminate]': 'state === "indeterminate"',
  2420. '[class.mat-pseudo-checkbox-checked]': 'state === "checked"',
  2421. '[class.mat-pseudo-checkbox-disabled]': 'disabled',
  2422. '[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
  2423. },
  2424. },] },
  2425. ];
  2426. /** @nocollapse */
  2427. MatPseudoCheckbox.ctorParameters = function () { return [
  2428. { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
  2429. ]; };
  2430. MatPseudoCheckbox.propDecorators = {
  2431. state: [{ type: Input }],
  2432. disabled: [{ type: Input }]
  2433. };
  2434. return MatPseudoCheckbox;
  2435. }());
  2436. /**
  2437. * @fileoverview added by tsickle
  2438. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2439. */
  2440. var MatPseudoCheckboxModule = /** @class */ (function () {
  2441. function MatPseudoCheckboxModule() {
  2442. }
  2443. MatPseudoCheckboxModule.decorators = [
  2444. { type: NgModule, args: [{
  2445. exports: [MatPseudoCheckbox],
  2446. declarations: [MatPseudoCheckbox]
  2447. },] },
  2448. ];
  2449. return MatPseudoCheckboxModule;
  2450. }());
  2451. /**
  2452. * @fileoverview added by tsickle
  2453. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2454. */
  2455. // Boilerplate for applying mixins to MatOptgroup.
  2456. /**
  2457. * \@docs-private
  2458. */
  2459. var
  2460. // Boilerplate for applying mixins to MatOptgroup.
  2461. /**
  2462. * \@docs-private
  2463. */
  2464. MatOptgroupBase = /** @class */ (function () {
  2465. function MatOptgroupBase() {
  2466. }
  2467. return MatOptgroupBase;
  2468. }());
  2469. /** @type {?} */
  2470. var _MatOptgroupMixinBase = mixinDisabled(MatOptgroupBase);
  2471. // Counter for unique group ids.
  2472. /** @type {?} */
  2473. var _uniqueOptgroupIdCounter = 0;
  2474. /**
  2475. * Component that is used to group instances of `mat-option`.
  2476. */
  2477. var MatOptgroup = /** @class */ (function (_super) {
  2478. __extends(MatOptgroup, _super);
  2479. function MatOptgroup() {
  2480. var _this = _super !== null && _super.apply(this, arguments) || this;
  2481. /**
  2482. * Unique id for the underlying label.
  2483. */
  2484. _this._labelId = "mat-optgroup-label-" + _uniqueOptgroupIdCounter++;
  2485. return _this;
  2486. }
  2487. MatOptgroup.decorators = [
  2488. { type: Component, args: [{selector: 'mat-optgroup',
  2489. exportAs: 'matOptgroup',
  2490. template: "<label class=\"mat-optgroup-label\" [id]=\"_labelId\">{{ label }}<ng-content></ng-content></label><ng-content select=\"mat-option, ng-container\"></ng-content>",
  2491. encapsulation: ViewEncapsulation.None,
  2492. changeDetection: ChangeDetectionStrategy.OnPush,
  2493. inputs: ['disabled'],
  2494. styles: [".mat-optgroup-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;line-height:48px;height:48px;padding:0 16px;text-align:left;text-decoration:none;max-width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.mat-optgroup-label[disabled]{cursor:default}[dir=rtl] .mat-optgroup-label{text-align:right}.mat-optgroup-label .mat-icon{margin-right:16px;vertical-align:middle}.mat-optgroup-label .mat-icon svg{vertical-align:top}[dir=rtl] .mat-optgroup-label .mat-icon{margin-left:16px;margin-right:0}"],
  2495. host: {
  2496. 'class': 'mat-optgroup',
  2497. 'role': 'group',
  2498. '[class.mat-optgroup-disabled]': 'disabled',
  2499. '[attr.aria-disabled]': 'disabled.toString()',
  2500. '[attr.aria-labelledby]': '_labelId',
  2501. }
  2502. },] },
  2503. ];
  2504. MatOptgroup.propDecorators = {
  2505. label: [{ type: Input }]
  2506. };
  2507. return MatOptgroup;
  2508. }(_MatOptgroupMixinBase));
  2509. /**
  2510. * @fileoverview added by tsickle
  2511. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2512. */
  2513. /**
  2514. * Option IDs need to be unique across components, so this counter exists outside of
  2515. * the component definition.
  2516. * @type {?}
  2517. */
  2518. var _uniqueIdCounter = 0;
  2519. /**
  2520. * Event object emitted by MatOption when selected or deselected.
  2521. */
  2522. var /**
  2523. * Event object emitted by MatOption when selected or deselected.
  2524. */
  2525. MatOptionSelectionChange = /** @class */ (function () {
  2526. function MatOptionSelectionChange(source, isUserInput) {
  2527. if (isUserInput === void 0) { isUserInput = false; }
  2528. this.source = source;
  2529. this.isUserInput = isUserInput;
  2530. }
  2531. return MatOptionSelectionChange;
  2532. }());
  2533. /**
  2534. * Injection token used to provide the parent component to options.
  2535. * @type {?}
  2536. */
  2537. var MAT_OPTION_PARENT_COMPONENT = new InjectionToken('MAT_OPTION_PARENT_COMPONENT');
  2538. /**
  2539. * Single option inside of a `<mat-select>` element.
  2540. */
  2541. var MatOption = /** @class */ (function () {
  2542. function MatOption(_element, _changeDetectorRef, _parent, group) {
  2543. this._element = _element;
  2544. this._changeDetectorRef = _changeDetectorRef;
  2545. this._parent = _parent;
  2546. this.group = group;
  2547. this._selected = false;
  2548. this._active = false;
  2549. this._disabled = false;
  2550. this._mostRecentViewValue = '';
  2551. /**
  2552. * The unique ID of the option.
  2553. */
  2554. this.id = "mat-option-" + _uniqueIdCounter++;
  2555. /**
  2556. * Event emitted when the option is selected or deselected.
  2557. */
  2558. // tslint:disable-next-line:no-output-on-prefix
  2559. this.onSelectionChange = new EventEmitter();
  2560. /**
  2561. * Emits when the state of the option changes and any parents have to be notified.
  2562. */
  2563. this._stateChanges = new Subject();
  2564. }
  2565. Object.defineProperty(MatOption.prototype, "multiple", {
  2566. /** Whether the wrapping component is in multiple selection mode. */
  2567. get: /**
  2568. * Whether the wrapping component is in multiple selection mode.
  2569. * @return {?}
  2570. */
  2571. function () { return this._parent && this._parent.multiple; },
  2572. enumerable: true,
  2573. configurable: true
  2574. });
  2575. Object.defineProperty(MatOption.prototype, "selected", {
  2576. /** Whether or not the option is currently selected. */
  2577. get: /**
  2578. * Whether or not the option is currently selected.
  2579. * @return {?}
  2580. */
  2581. function () { return this._selected; },
  2582. enumerable: true,
  2583. configurable: true
  2584. });
  2585. Object.defineProperty(MatOption.prototype, "disabled", {
  2586. /** Whether the option is disabled. */
  2587. get: /**
  2588. * Whether the option is disabled.
  2589. * @return {?}
  2590. */
  2591. function () { return (this.group && this.group.disabled) || this._disabled; },
  2592. set: /**
  2593. * @param {?} value
  2594. * @return {?}
  2595. */
  2596. function (value) { this._disabled = coerceBooleanProperty(value); },
  2597. enumerable: true,
  2598. configurable: true
  2599. });
  2600. Object.defineProperty(MatOption.prototype, "disableRipple", {
  2601. /** Whether ripples for the option are disabled. */
  2602. get: /**
  2603. * Whether ripples for the option are disabled.
  2604. * @return {?}
  2605. */
  2606. function () { return this._parent && this._parent.disableRipple; },
  2607. enumerable: true,
  2608. configurable: true
  2609. });
  2610. Object.defineProperty(MatOption.prototype, "active", {
  2611. /**
  2612. * Whether or not the option is currently active and ready to be selected.
  2613. * An active option displays styles as if it is focused, but the
  2614. * focus is actually retained somewhere else. This comes in handy
  2615. * for components like autocomplete where focus must remain on the input.
  2616. */
  2617. get: /**
  2618. * Whether or not the option is currently active and ready to be selected.
  2619. * An active option displays styles as if it is focused, but the
  2620. * focus is actually retained somewhere else. This comes in handy
  2621. * for components like autocomplete where focus must remain on the input.
  2622. * @return {?}
  2623. */
  2624. function () {
  2625. return this._active;
  2626. },
  2627. enumerable: true,
  2628. configurable: true
  2629. });
  2630. Object.defineProperty(MatOption.prototype, "viewValue", {
  2631. /**
  2632. * The displayed value of the option. It is necessary to show the selected option in the
  2633. * select's trigger.
  2634. */
  2635. get: /**
  2636. * The displayed value of the option. It is necessary to show the selected option in the
  2637. * select's trigger.
  2638. * @return {?}
  2639. */
  2640. function () {
  2641. // TODO(kara): Add input property alternative for node envs.
  2642. return (this._getHostElement().textContent || '').trim();
  2643. },
  2644. enumerable: true,
  2645. configurable: true
  2646. });
  2647. /** Selects the option. */
  2648. /**
  2649. * Selects the option.
  2650. * @return {?}
  2651. */
  2652. MatOption.prototype.select = /**
  2653. * Selects the option.
  2654. * @return {?}
  2655. */
  2656. function () {
  2657. if (!this._selected) {
  2658. this._selected = true;
  2659. this._changeDetectorRef.markForCheck();
  2660. this._emitSelectionChangeEvent();
  2661. }
  2662. };
  2663. /** Deselects the option. */
  2664. /**
  2665. * Deselects the option.
  2666. * @return {?}
  2667. */
  2668. MatOption.prototype.deselect = /**
  2669. * Deselects the option.
  2670. * @return {?}
  2671. */
  2672. function () {
  2673. if (this._selected) {
  2674. this._selected = false;
  2675. this._changeDetectorRef.markForCheck();
  2676. this._emitSelectionChangeEvent();
  2677. }
  2678. };
  2679. /** Sets focus onto this option. */
  2680. /**
  2681. * Sets focus onto this option.
  2682. * @param {?=} _origin
  2683. * @param {?=} options
  2684. * @return {?}
  2685. */
  2686. MatOption.prototype.focus = /**
  2687. * Sets focus onto this option.
  2688. * @param {?=} _origin
  2689. * @param {?=} options
  2690. * @return {?}
  2691. */
  2692. function (_origin, options) {
  2693. // Note that we aren't using `_origin`, but we need to keep it because some internal consumers
  2694. // use `MatOption` in a `FocusKeyManager` and we need it to match `FocusableOption`.
  2695. /** @type {?} */
  2696. var element = this._getHostElement();
  2697. if (typeof element.focus === 'function') {
  2698. element.focus(options);
  2699. }
  2700. };
  2701. /**
  2702. * This method sets display styles on the option to make it appear
  2703. * active. This is used by the ActiveDescendantKeyManager so key
  2704. * events will display the proper options as active on arrow key events.
  2705. */
  2706. /**
  2707. * This method sets display styles on the option to make it appear
  2708. * active. This is used by the ActiveDescendantKeyManager so key
  2709. * events will display the proper options as active on arrow key events.
  2710. * @return {?}
  2711. */
  2712. MatOption.prototype.setActiveStyles = /**
  2713. * This method sets display styles on the option to make it appear
  2714. * active. This is used by the ActiveDescendantKeyManager so key
  2715. * events will display the proper options as active on arrow key events.
  2716. * @return {?}
  2717. */
  2718. function () {
  2719. if (!this._active) {
  2720. this._active = true;
  2721. this._changeDetectorRef.markForCheck();
  2722. }
  2723. };
  2724. /**
  2725. * This method removes display styles on the option that made it appear
  2726. * active. This is used by the ActiveDescendantKeyManager so key
  2727. * events will display the proper options as active on arrow key events.
  2728. */
  2729. /**
  2730. * This method removes display styles on the option that made it appear
  2731. * active. This is used by the ActiveDescendantKeyManager so key
  2732. * events will display the proper options as active on arrow key events.
  2733. * @return {?}
  2734. */
  2735. MatOption.prototype.setInactiveStyles = /**
  2736. * This method removes display styles on the option that made it appear
  2737. * active. This is used by the ActiveDescendantKeyManager so key
  2738. * events will display the proper options as active on arrow key events.
  2739. * @return {?}
  2740. */
  2741. function () {
  2742. if (this._active) {
  2743. this._active = false;
  2744. this._changeDetectorRef.markForCheck();
  2745. }
  2746. };
  2747. /** Gets the label to be used when determining whether the option should be focused. */
  2748. /**
  2749. * Gets the label to be used when determining whether the option should be focused.
  2750. * @return {?}
  2751. */
  2752. MatOption.prototype.getLabel = /**
  2753. * Gets the label to be used when determining whether the option should be focused.
  2754. * @return {?}
  2755. */
  2756. function () {
  2757. return this.viewValue;
  2758. };
  2759. /** Ensures the option is selected when activated from the keyboard. */
  2760. /**
  2761. * Ensures the option is selected when activated from the keyboard.
  2762. * @param {?} event
  2763. * @return {?}
  2764. */
  2765. MatOption.prototype._handleKeydown = /**
  2766. * Ensures the option is selected when activated from the keyboard.
  2767. * @param {?} event
  2768. * @return {?}
  2769. */
  2770. function (event) {
  2771. if ((event.keyCode === ENTER || event.keyCode === SPACE) && !hasModifierKey(event)) {
  2772. this._selectViaInteraction();
  2773. // Prevent the page from scrolling down and form submits.
  2774. event.preventDefault();
  2775. }
  2776. };
  2777. /**
  2778. * `Selects the option while indicating the selection came from the user. Used to
  2779. * determine if the select's view -> model callback should be invoked.`
  2780. */
  2781. /**
  2782. * `Selects the option while indicating the selection came from the user. Used to
  2783. * determine if the select's view -> model callback should be invoked.`
  2784. * @return {?}
  2785. */
  2786. MatOption.prototype._selectViaInteraction = /**
  2787. * `Selects the option while indicating the selection came from the user. Used to
  2788. * determine if the select's view -> model callback should be invoked.`
  2789. * @return {?}
  2790. */
  2791. function () {
  2792. if (!this.disabled) {
  2793. this._selected = this.multiple ? !this._selected : true;
  2794. this._changeDetectorRef.markForCheck();
  2795. this._emitSelectionChangeEvent(true);
  2796. }
  2797. };
  2798. /**
  2799. * Gets the `aria-selected` value for the option. We explicitly omit the `aria-selected`
  2800. * attribute from single-selection, unselected options. Including the `aria-selected="false"`
  2801. * attributes adds a significant amount of noise to screen-reader users without providing useful
  2802. * information.
  2803. */
  2804. /**
  2805. * Gets the `aria-selected` value for the option. We explicitly omit the `aria-selected`
  2806. * attribute from single-selection, unselected options. Including the `aria-selected="false"`
  2807. * attributes adds a significant amount of noise to screen-reader users without providing useful
  2808. * information.
  2809. * @return {?}
  2810. */
  2811. MatOption.prototype._getAriaSelected = /**
  2812. * Gets the `aria-selected` value for the option. We explicitly omit the `aria-selected`
  2813. * attribute from single-selection, unselected options. Including the `aria-selected="false"`
  2814. * attributes adds a significant amount of noise to screen-reader users without providing useful
  2815. * information.
  2816. * @return {?}
  2817. */
  2818. function () {
  2819. return this.selected || (this.multiple ? false : null);
  2820. };
  2821. /** Returns the correct tabindex for the option depending on disabled state. */
  2822. /**
  2823. * Returns the correct tabindex for the option depending on disabled state.
  2824. * @return {?}
  2825. */
  2826. MatOption.prototype._getTabIndex = /**
  2827. * Returns the correct tabindex for the option depending on disabled state.
  2828. * @return {?}
  2829. */
  2830. function () {
  2831. return this.disabled ? '-1' : '0';
  2832. };
  2833. /** Gets the host DOM element. */
  2834. /**
  2835. * Gets the host DOM element.
  2836. * @return {?}
  2837. */
  2838. MatOption.prototype._getHostElement = /**
  2839. * Gets the host DOM element.
  2840. * @return {?}
  2841. */
  2842. function () {
  2843. return this._element.nativeElement;
  2844. };
  2845. /**
  2846. * @return {?}
  2847. */
  2848. MatOption.prototype.ngAfterViewChecked = /**
  2849. * @return {?}
  2850. */
  2851. function () {
  2852. // Since parent components could be using the option's label to display the selected values
  2853. // (e.g. `mat-select`) and they don't have a way of knowing if the option's label has changed
  2854. // we have to check for changes in the DOM ourselves and dispatch an event. These checks are
  2855. // relatively cheap, however we still limit them only to selected options in order to avoid
  2856. // hitting the DOM too often.
  2857. if (this._selected) {
  2858. /** @type {?} */
  2859. var viewValue = this.viewValue;
  2860. if (viewValue !== this._mostRecentViewValue) {
  2861. this._mostRecentViewValue = viewValue;
  2862. this._stateChanges.next();
  2863. }
  2864. }
  2865. };
  2866. /**
  2867. * @return {?}
  2868. */
  2869. MatOption.prototype.ngOnDestroy = /**
  2870. * @return {?}
  2871. */
  2872. function () {
  2873. this._stateChanges.complete();
  2874. };
  2875. /** Emits the selection change event. */
  2876. /**
  2877. * Emits the selection change event.
  2878. * @private
  2879. * @param {?=} isUserInput
  2880. * @return {?}
  2881. */
  2882. MatOption.prototype._emitSelectionChangeEvent = /**
  2883. * Emits the selection change event.
  2884. * @private
  2885. * @param {?=} isUserInput
  2886. * @return {?}
  2887. */
  2888. function (isUserInput) {
  2889. if (isUserInput === void 0) { isUserInput = false; }
  2890. this.onSelectionChange.emit(new MatOptionSelectionChange(this, isUserInput));
  2891. };
  2892. MatOption.decorators = [
  2893. { type: Component, args: [{selector: 'mat-option',
  2894. exportAs: 'matOption',
  2895. host: {
  2896. 'role': 'option',
  2897. '[attr.tabindex]': '_getTabIndex()',
  2898. '[class.mat-selected]': 'selected',
  2899. '[class.mat-option-multiple]': 'multiple',
  2900. '[class.mat-active]': 'active',
  2901. '[id]': 'id',
  2902. '[attr.aria-selected]': '_getAriaSelected()',
  2903. '[attr.aria-disabled]': 'disabled.toString()',
  2904. '[class.mat-option-disabled]': 'disabled',
  2905. '(click)': '_selectViaInteraction()',
  2906. '(keydown)': '_handleKeydown($event)',
  2907. 'class': 'mat-option',
  2908. },
  2909. styles: [".mat-option{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;line-height:48px;height:48px;padding:0 16px;text-align:left;text-decoration:none;max-width:100%;position:relative;cursor:pointer;outline:0;display:flex;flex-direction:row;max-width:100%;box-sizing:border-box;align-items:center;-webkit-tap-highlight-color:transparent}.mat-option[disabled]{cursor:default}[dir=rtl] .mat-option{text-align:right}.mat-option .mat-icon{margin-right:16px;vertical-align:middle}.mat-option .mat-icon svg{vertical-align:top}[dir=rtl] .mat-option .mat-icon{margin-left:16px;margin-right:0}.mat-option[aria-disabled=true]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.mat-optgroup .mat-option:not(.mat-option-multiple){padding-left:32px}[dir=rtl] .mat-optgroup .mat-option:not(.mat-option-multiple){padding-left:16px;padding-right:32px}@media (-ms-high-contrast:active){.mat-option{margin:0 1px}.mat-option.mat-active{border:solid 1px currentColor;margin:0}}.mat-option-text{display:inline-block;flex-grow:1;overflow:hidden;text-overflow:ellipsis}.mat-option .mat-option-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}@media (-ms-high-contrast:active){.mat-option .mat-option-ripple{opacity:.5}}.mat-option-pseudo-checkbox{margin-right:8px}[dir=rtl] .mat-option-pseudo-checkbox{margin-left:8px;margin-right:0}"],
  2910. template: "<mat-pseudo-checkbox *ngIf=\"multiple\" class=\"mat-option-pseudo-checkbox\" [state]=\"selected ? 'checked' : ''\" [disabled]=\"disabled\"></mat-pseudo-checkbox><span class=\"mat-option-text\"><ng-content></ng-content></span><div class=\"mat-option-ripple\" mat-ripple [matRippleTrigger]=\"_getHostElement()\" [matRippleDisabled]=\"disabled || disableRipple\"></div>",
  2911. encapsulation: ViewEncapsulation.None,
  2912. changeDetection: ChangeDetectionStrategy.OnPush,
  2913. },] },
  2914. ];
  2915. /** @nocollapse */
  2916. MatOption.ctorParameters = function () { return [
  2917. { type: ElementRef },
  2918. { type: ChangeDetectorRef },
  2919. { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_OPTION_PARENT_COMPONENT,] }] },
  2920. { type: MatOptgroup, decorators: [{ type: Optional }] }
  2921. ]; };
  2922. MatOption.propDecorators = {
  2923. value: [{ type: Input }],
  2924. id: [{ type: Input }],
  2925. disabled: [{ type: Input }],
  2926. onSelectionChange: [{ type: Output }]
  2927. };
  2928. return MatOption;
  2929. }());
  2930. /**
  2931. * Counts the amount of option group labels that precede the specified option.
  2932. * \@docs-private
  2933. * @param {?} optionIndex Index of the option at which to start counting.
  2934. * @param {?} options Flat list of all of the options.
  2935. * @param {?} optionGroups Flat list of all of the option groups.
  2936. * @return {?}
  2937. */
  2938. function _countGroupLabelsBeforeOption(optionIndex, options, optionGroups) {
  2939. if (optionGroups.length) {
  2940. /** @type {?} */
  2941. var optionsArray = options.toArray();
  2942. /** @type {?} */
  2943. var groups = optionGroups.toArray();
  2944. /** @type {?} */
  2945. var groupCounter = 0;
  2946. for (var i = 0; i < optionIndex + 1; i++) {
  2947. if (optionsArray[i].group && optionsArray[i].group === groups[groupCounter]) {
  2948. groupCounter++;
  2949. }
  2950. }
  2951. return groupCounter;
  2952. }
  2953. return 0;
  2954. }
  2955. /**
  2956. * Determines the position to which to scroll a panel in order for an option to be into view.
  2957. * \@docs-private
  2958. * @param {?} optionIndex Index of the option to be scrolled into the view.
  2959. * @param {?} optionHeight Height of the options.
  2960. * @param {?} currentScrollPosition Current scroll position of the panel.
  2961. * @param {?} panelHeight Height of the panel.
  2962. * @return {?}
  2963. */
  2964. function _getOptionScrollPosition(optionIndex, optionHeight, currentScrollPosition, panelHeight) {
  2965. /** @type {?} */
  2966. var optionOffset = optionIndex * optionHeight;
  2967. if (optionOffset < currentScrollPosition) {
  2968. return optionOffset;
  2969. }
  2970. if (optionOffset + optionHeight > currentScrollPosition + panelHeight) {
  2971. return Math.max(0, optionOffset - panelHeight + optionHeight);
  2972. }
  2973. return currentScrollPosition;
  2974. }
  2975. /**
  2976. * @fileoverview added by tsickle
  2977. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2978. */
  2979. var MatOptionModule = /** @class */ (function () {
  2980. function MatOptionModule() {
  2981. }
  2982. MatOptionModule.decorators = [
  2983. { type: NgModule, args: [{
  2984. imports: [MatRippleModule, CommonModule, MatPseudoCheckboxModule],
  2985. exports: [MatOption, MatOptgroup],
  2986. declarations: [MatOption, MatOptgroup]
  2987. },] },
  2988. ];
  2989. return MatOptionModule;
  2990. }());
  2991. /**
  2992. * @fileoverview added by tsickle
  2993. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2994. */
  2995. /**
  2996. * InjectionToken that can be used to specify the global label options.
  2997. * @type {?}
  2998. */
  2999. var MAT_LABEL_GLOBAL_OPTIONS = new InjectionToken('mat-label-global-options');
  3000. /**
  3001. * @fileoverview added by tsickle
  3002. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3003. */
  3004. /**
  3005. * When constructing a Date, the month is zero-based. This can be confusing, since people are
  3006. * used to seeing them one-based. So we create these aliases to make writing the tests easier.
  3007. * \@docs-private
  3008. * \@breaking-change 8.0.0 Remove this with V8 since it was only targeted for testing.
  3009. * @type {?}
  3010. */
  3011. var JAN = 0;
  3012. /** @type {?} */
  3013. var FEB = 1;
  3014. /** @type {?} */
  3015. var MAR = 2;
  3016. /** @type {?} */
  3017. var APR = 3;
  3018. /** @type {?} */
  3019. var MAY = 4;
  3020. /** @type {?} */
  3021. var JUN = 5;
  3022. /** @type {?} */
  3023. var JUL = 6;
  3024. /** @type {?} */
  3025. var AUG = 7;
  3026. /** @type {?} */
  3027. var SEP = 8;
  3028. /** @type {?} */
  3029. var OCT = 9;
  3030. /** @type {?} */
  3031. var NOV = 10;
  3032. /** @type {?} */
  3033. var DEC = 11;
  3034. /**
  3035. * @fileoverview added by tsickle
  3036. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3037. */
  3038. /**
  3039. * @fileoverview added by tsickle
  3040. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3041. */
  3042. export { VERSION$1 as VERSION, AnimationCurves, AnimationDurations, MatCommonModule, MATERIAL_SANITY_CHECKS, mixinDisabled, mixinColor, mixinDisableRipple, mixinTabIndex, mixinErrorState, mixinInitialized, NativeDateModule, MatNativeDateModule, MAT_DATE_LOCALE_FACTORY, MAT_DATE_LOCALE, MAT_DATE_LOCALE_PROVIDER, DateAdapter, MAT_DATE_FORMATS, NativeDateAdapter, MAT_NATIVE_DATE_FORMATS, ShowOnDirtyErrorStateMatcher, ErrorStateMatcher, MAT_HAMMER_OPTIONS, GestureConfig, setLines, MatLine, MatLineSetter, MatLineModule, MatOptionModule, _countGroupLabelsBeforeOption, _getOptionScrollPosition, MatOptionSelectionChange, MAT_OPTION_PARENT_COMPONENT, MatOption, MatOptgroup, MAT_LABEL_GLOBAL_OPTIONS, MatRippleModule, MAT_RIPPLE_GLOBAL_OPTIONS, MatRipple, RippleState, RippleRef, defaultRippleAnimationConfig, RippleRenderer, MatPseudoCheckboxModule, MatPseudoCheckbox, JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC, MATERIAL_SANITY_CHECKS_FACTORY as ɵa1 };
  3043. //# sourceMappingURL=core.es5.js.map