material-core.umd.js 118 KB

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