mdc.textfield.js 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167
  1. /*!
  2. Material Components for the web
  3. Copyright (c) 2017 Google Inc.
  4. License: Apache-2.0
  5. */
  6. (function webpackUniversalModuleDefinition(root, factory) {
  7. if(typeof exports === 'object' && typeof module === 'object')
  8. module.exports = factory();
  9. else if(typeof define === 'function' && define.amd)
  10. define([], factory);
  11. else if(typeof exports === 'object')
  12. exports["textfield"] = factory();
  13. else
  14. root["mdc"] = root["mdc"] || {}, root["mdc"]["textfield"] = factory();
  15. })(this, function() {
  16. return /******/ (function(modules) { // webpackBootstrap
  17. /******/ // The module cache
  18. /******/ var installedModules = {};
  19. /******/
  20. /******/ // The require function
  21. /******/ function __webpack_require__(moduleId) {
  22. /******/
  23. /******/ // Check if module is in cache
  24. /******/ if(installedModules[moduleId]) {
  25. /******/ return installedModules[moduleId].exports;
  26. /******/ }
  27. /******/ // Create a new module (and put it into the cache)
  28. /******/ var module = installedModules[moduleId] = {
  29. /******/ i: moduleId,
  30. /******/ l: false,
  31. /******/ exports: {}
  32. /******/ };
  33. /******/
  34. /******/ // Execute the module function
  35. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36. /******/
  37. /******/ // Flag the module as loaded
  38. /******/ module.l = true;
  39. /******/
  40. /******/ // Return the exports of the module
  41. /******/ return module.exports;
  42. /******/ }
  43. /******/
  44. /******/
  45. /******/ // expose the modules object (__webpack_modules__)
  46. /******/ __webpack_require__.m = modules;
  47. /******/
  48. /******/ // expose the module cache
  49. /******/ __webpack_require__.c = installedModules;
  50. /******/
  51. /******/ // identity function for calling harmony imports with the correct context
  52. /******/ __webpack_require__.i = function(value) { return value; };
  53. /******/
  54. /******/ // define getter function for harmony exports
  55. /******/ __webpack_require__.d = function(exports, name, getter) {
  56. /******/ if(!__webpack_require__.o(exports, name)) {
  57. /******/ Object.defineProperty(exports, name, {
  58. /******/ configurable: false,
  59. /******/ enumerable: true,
  60. /******/ get: getter
  61. /******/ });
  62. /******/ }
  63. /******/ };
  64. /******/
  65. /******/ // getDefaultExport function for compatibility with non-harmony modules
  66. /******/ __webpack_require__.n = function(module) {
  67. /******/ var getter = module && module.__esModule ?
  68. /******/ function getDefault() { return module['default']; } :
  69. /******/ function getModuleExports() { return module; };
  70. /******/ __webpack_require__.d(getter, 'a', getter);
  71. /******/ return getter;
  72. /******/ };
  73. /******/
  74. /******/ // Object.prototype.hasOwnProperty.call
  75. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  76. /******/
  77. /******/ // __webpack_public_path__
  78. /******/ __webpack_require__.p = "/assets/";
  79. /******/
  80. /******/ // Load entry module and return exports
  81. /******/ return __webpack_require__(__webpack_require__.s = 98);
  82. /******/ })
  83. /************************************************************************/
  84. /******/ ({
  85. /***/ 0:
  86. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87. "use strict";
  88. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  89. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  90. /**
  91. * Copyright 2016 Google Inc.
  92. *
  93. * Licensed under the Apache License, Version 2.0 (the "License");
  94. * you may not use this file except in compliance with the License.
  95. * You may obtain a copy of the License at
  96. *
  97. * http://www.apache.org/licenses/LICENSE-2.0
  98. *
  99. * Unless required by applicable law or agreed to in writing, software
  100. * distributed under the License is distributed on an "AS IS" BASIS,
  101. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  102. * See the License for the specific language governing permissions and
  103. * limitations under the License.
  104. */
  105. /**
  106. * @template A
  107. */
  108. var MDCFoundation = function () {
  109. _createClass(MDCFoundation, null, [{
  110. key: "cssClasses",
  111. /** @return enum{cssClasses} */
  112. get: function get() {
  113. // Classes extending MDCFoundation should implement this method to return an object which exports every
  114. // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
  115. return {};
  116. }
  117. /** @return enum{strings} */
  118. }, {
  119. key: "strings",
  120. get: function get() {
  121. // Classes extending MDCFoundation should implement this method to return an object which exports all
  122. // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
  123. return {};
  124. }
  125. /** @return enum{numbers} */
  126. }, {
  127. key: "numbers",
  128. get: function get() {
  129. // Classes extending MDCFoundation should implement this method to return an object which exports all
  130. // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
  131. return {};
  132. }
  133. /** @return {!Object} */
  134. }, {
  135. key: "defaultAdapter",
  136. get: function get() {
  137. // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
  138. // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
  139. // validation.
  140. return {};
  141. }
  142. /**
  143. * @param {A=} adapter
  144. */
  145. }]);
  146. function MDCFoundation() {
  147. var adapter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  148. _classCallCheck(this, MDCFoundation);
  149. /** @protected {!A} */
  150. this.adapter_ = adapter;
  151. }
  152. _createClass(MDCFoundation, [{
  153. key: "init",
  154. value: function init() {
  155. // Subclasses should override this method to perform initialization routines (registering events, etc.)
  156. }
  157. }, {
  158. key: "destroy",
  159. value: function destroy() {
  160. // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
  161. }
  162. }]);
  163. return MDCFoundation;
  164. }();
  165. /* harmony default export */ __webpack_exports__["a"] = (MDCFoundation);
  166. /***/ }),
  167. /***/ 1:
  168. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  169. "use strict";
  170. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation__ = __webpack_require__(0);
  171. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  172. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  173. /**
  174. * Copyright 2016 Google Inc.
  175. *
  176. * Licensed under the Apache License, Version 2.0 (the "License");
  177. * you may not use this file except in compliance with the License.
  178. * You may obtain a copy of the License at
  179. *
  180. * http://www.apache.org/licenses/LICENSE-2.0
  181. *
  182. * Unless required by applicable law or agreed to in writing, software
  183. * distributed under the License is distributed on an "AS IS" BASIS,
  184. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  185. * See the License for the specific language governing permissions and
  186. * limitations under the License.
  187. */
  188. /**
  189. * @template F
  190. */
  191. var MDCComponent = function () {
  192. _createClass(MDCComponent, null, [{
  193. key: 'attachTo',
  194. /**
  195. * @param {!Element} root
  196. * @return {!MDCComponent}
  197. */
  198. value: function attachTo(root) {
  199. // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
  200. // returns an instantiated component with its root set to that element. Also note that in the cases of
  201. // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
  202. // from getDefaultFoundation().
  203. return new MDCComponent(root, new __WEBPACK_IMPORTED_MODULE_0__foundation__["a" /* default */]());
  204. }
  205. /**
  206. * @param {!Element} root
  207. * @param {F=} foundation
  208. * @param {...?} args
  209. */
  210. }]);
  211. function MDCComponent(root) {
  212. var foundation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
  213. _classCallCheck(this, MDCComponent);
  214. /** @protected {!Element} */
  215. this.root_ = root;
  216. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  217. args[_key - 2] = arguments[_key];
  218. }
  219. this.initialize.apply(this, args);
  220. // Note that we initialize foundation here and not within the constructor's default param so that
  221. // this.root_ is defined and can be used within the foundation class.
  222. /** @protected {!F} */
  223. this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
  224. this.foundation_.init();
  225. this.initialSyncWithDOM();
  226. }
  227. _createClass(MDCComponent, [{
  228. key: 'initialize',
  229. value: function initialize() /* ...args */{}
  230. // Subclasses can override this to do any additional setup work that would be considered part of a
  231. // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
  232. // initialized. Any additional arguments besides root and foundation will be passed in here.
  233. /**
  234. * @return {!F} foundation
  235. */
  236. }, {
  237. key: 'getDefaultFoundation',
  238. value: function getDefaultFoundation() {
  239. // Subclasses must override this method to return a properly configured foundation class for the
  240. // component.
  241. throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
  242. }
  243. }, {
  244. key: 'initialSyncWithDOM',
  245. value: function initialSyncWithDOM() {
  246. // Subclasses should override this method if they need to perform work to synchronize with a host DOM
  247. // object. An example of this would be a form control wrapper that needs to synchronize its internal state
  248. // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
  249. // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
  250. }
  251. }, {
  252. key: 'destroy',
  253. value: function destroy() {
  254. // Subclasses may implement this method to release any resources / deregister any listeners they have
  255. // attached. An example of this might be deregistering a resize event from the window object.
  256. this.foundation_.destroy();
  257. }
  258. /**
  259. * Wrapper method to add an event listener to the component's root element. This is most useful when
  260. * listening for custom events.
  261. * @param {string} evtType
  262. * @param {!Function} handler
  263. */
  264. }, {
  265. key: 'listen',
  266. value: function listen(evtType, handler) {
  267. this.root_.addEventListener(evtType, handler);
  268. }
  269. /**
  270. * Wrapper method to remove an event listener to the component's root element. This is most useful when
  271. * unlistening for custom events.
  272. * @param {string} evtType
  273. * @param {!Function} handler
  274. */
  275. }, {
  276. key: 'unlisten',
  277. value: function unlisten(evtType, handler) {
  278. this.root_.removeEventListener(evtType, handler);
  279. }
  280. /**
  281. * Fires a cross-browser-compatible custom event from the component root of the given type,
  282. * with the given data.
  283. * @param {string} evtType
  284. * @param {!Object} evtData
  285. * @param {boolean=} shouldBubble
  286. */
  287. }, {
  288. key: 'emit',
  289. value: function emit(evtType, evtData) {
  290. var shouldBubble = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  291. var evt = void 0;
  292. if (typeof CustomEvent === 'function') {
  293. evt = new CustomEvent(evtType, {
  294. detail: evtData,
  295. bubbles: shouldBubble
  296. });
  297. } else {
  298. evt = document.createEvent('CustomEvent');
  299. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  300. }
  301. this.root_.dispatchEvent(evt);
  302. }
  303. }]);
  304. return MDCComponent;
  305. }();
  306. /* harmony default export */ __webpack_exports__["a"] = (MDCComponent);
  307. /***/ }),
  308. /***/ 2:
  309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  310. "use strict";
  311. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  312. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__foundation__ = __webpack_require__(0);
  313. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component__ = __webpack_require__(1);
  314. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__selection_control__ = __webpack_require__(3);
  315. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCFoundation", function() { return __WEBPACK_IMPORTED_MODULE_0__foundation__["a"]; });
  316. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCComponent", function() { return __WEBPACK_IMPORTED_MODULE_1__component__["a"]; });
  317. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionControlState", function() { return __WEBPACK_IMPORTED_MODULE_2__selection_control__["a"]; });
  318. /**
  319. * Copyright 2016 Google Inc.
  320. *
  321. * Licensed under the Apache License, Version 2.0 (the "License");
  322. * you may not use this file except in compliance with the License.
  323. * You may obtain a copy of the License at
  324. *
  325. * http://www.apache.org/licenses/LICENSE-2.0
  326. *
  327. * Unless required by applicable law or agreed to in writing, software
  328. * distributed under the License is distributed on an "AS IS" BASIS,
  329. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  330. * See the License for the specific language governing permissions and
  331. * limitations under the License.
  332. */
  333. /***/ }),
  334. /***/ 22:
  335. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  336. "use strict";
  337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return strings; });
  338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return cssClasses; });
  339. /**
  340. * Copyright 2016 Google Inc. All Rights Reserved.
  341. *
  342. * Licensed under the Apache License, Version 2.0 (the "License");
  343. * you may not use this file except in compliance with the License.
  344. * You may obtain a copy of the License at
  345. *
  346. * http://www.apache.org/licenses/LICENSE-2.0
  347. *
  348. * Unless required by applicable law or agreed to in writing, software
  349. * distributed under the License is distributed on an "AS IS" BASIS,
  350. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  351. * See the License for the specific language governing permissions and
  352. * limitations under the License.
  353. */
  354. var strings = {
  355. ARIA_HIDDEN: 'aria-hidden',
  356. ROLE: 'role',
  357. INPUT_SELECTOR: '.mdc-textfield__input',
  358. LABEL_SELECTOR: '.mdc-textfield__label'
  359. };
  360. var cssClasses = {
  361. ROOT: 'mdc-textfield',
  362. UPGRADED: 'mdc-textfield--upgraded',
  363. DISABLED: 'mdc-textfield--disabled',
  364. FOCUSED: 'mdc-textfield--focused',
  365. INVALID: 'mdc-textfield--invalid',
  366. HELPTEXT_PERSISTENT: 'mdc-textfield-helptext--persistent',
  367. HELPTEXT_VALIDATION_MSG: 'mdc-textfield-helptext--validation-msg',
  368. LABEL_FLOAT_ABOVE: 'mdc-textfield__label--float-above',
  369. BOX: 'mdc-textfield--box'
  370. };
  371. /***/ }),
  372. /***/ 3:
  373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  374. "use strict";
  375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SelectionControlState; });
  376. /**
  377. * Copyright 2017 Google Inc. All Rights Reserved.
  378. *
  379. * Licensed under the Apache License, Version 2.0 (the "License");
  380. * you may not use this file except in compliance with the License.
  381. * You may obtain a copy of the License at
  382. *
  383. * http://www.apache.org/licenses/LICENSE-2.0
  384. *
  385. * Unless required by applicable law or agreed to in writing, software
  386. * distributed under the License is distributed on an "AS IS" BASIS,
  387. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  388. * See the License for the specific language governing permissions and
  389. * limitations under the License.
  390. */
  391. /**
  392. * @typedef {!{
  393. * checked: boolean,
  394. * indeterminate: boolean,
  395. * disabled: boolean,
  396. * value: ?string
  397. * }}
  398. */
  399. var SelectionControlState = void 0;
  400. /***/ }),
  401. /***/ 36:
  402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  403. "use strict";
  404. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCTextfield", function() { return MDCTextfield; });
  406. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base__ = __webpack_require__(2);
  407. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__material_ripple__ = __webpack_require__(6);
  408. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constants__ = __webpack_require__(22);
  409. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__foundation__ = __webpack_require__(75);
  410. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCTextfieldFoundation", function() { return __WEBPACK_IMPORTED_MODULE_3__foundation__["a"]; });
  411. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  412. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  413. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  414. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  415. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  416. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  417. /**
  418. * Copyright 2016 Google Inc. All Rights Reserved.
  419. *
  420. * Licensed under the Apache License, Version 2.0 (the "License");
  421. * you may not use this file except in compliance with the License.
  422. * You may obtain a copy of the License at
  423. *
  424. * http://www.apache.org/licenses/LICENSE-2.0
  425. *
  426. * Unless required by applicable law or agreed to in writing, software
  427. * distributed under the License is distributed on an "AS IS" BASIS,
  428. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  429. * See the License for the specific language governing permissions and
  430. * limitations under the License.
  431. */
  432. var MDCTextfield = function (_MDCComponent) {
  433. _inherits(MDCTextfield, _MDCComponent);
  434. function MDCTextfield() {
  435. _classCallCheck(this, MDCTextfield);
  436. return _possibleConstructorReturn(this, (MDCTextfield.__proto__ || Object.getPrototypeOf(MDCTextfield)).apply(this, arguments));
  437. }
  438. _createClass(MDCTextfield, [{
  439. key: 'initialize',
  440. value: function initialize() {
  441. var rippleFactory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (el) {
  442. return new __WEBPACK_IMPORTED_MODULE_1__material_ripple__["MDCRipple"](el);
  443. };
  444. this.input_ = this.root_.querySelector(__WEBPACK_IMPORTED_MODULE_2__constants__["a" /* strings */].INPUT_SELECTOR);
  445. this.label_ = this.root_.querySelector(__WEBPACK_IMPORTED_MODULE_2__constants__["a" /* strings */].LABEL_SELECTOR);
  446. this.helptextElement = null;
  447. this.ripple = null;
  448. if (this.input_.hasAttribute('aria-controls')) {
  449. this.helptextElement = document.getElementById(this.input_.getAttribute('aria-controls'));
  450. }
  451. if (this.root_.classList.contains(__WEBPACK_IMPORTED_MODULE_2__constants__["b" /* cssClasses */].BOX)) {
  452. this.ripple = rippleFactory(this.root_);
  453. };
  454. }
  455. }, {
  456. key: 'destroy',
  457. value: function destroy() {
  458. if (this.ripple) {
  459. this.ripple.destroy();
  460. }
  461. _get(MDCTextfield.prototype.__proto__ || Object.getPrototypeOf(MDCTextfield.prototype), 'destroy', this).call(this);
  462. }
  463. }, {
  464. key: 'initialSyncWithDom',
  465. value: function initialSyncWithDom() {
  466. this.disabled = this.input_.disabled;
  467. }
  468. }, {
  469. key: 'getDefaultFoundation',
  470. value: function getDefaultFoundation() {
  471. var _this2 = this;
  472. return new __WEBPACK_IMPORTED_MODULE_3__foundation__["a" /* default */](_extends({
  473. addClass: function addClass(className) {
  474. return _this2.root_.classList.add(className);
  475. },
  476. removeClass: function removeClass(className) {
  477. return _this2.root_.classList.remove(className);
  478. },
  479. addClassToLabel: function addClassToLabel(className) {
  480. var label = _this2.label_;
  481. if (label) {
  482. label.classList.add(className);
  483. }
  484. },
  485. removeClassFromLabel: function removeClassFromLabel(className) {
  486. var label = _this2.label_;
  487. if (label) {
  488. label.classList.remove(className);
  489. }
  490. }
  491. }, this.getInputAdapterMethods_(), this.getHelptextAdapterMethods_()));
  492. }
  493. }, {
  494. key: 'getInputAdapterMethods_',
  495. value: function getInputAdapterMethods_() {
  496. var _this3 = this;
  497. return {
  498. registerInputFocusHandler: function registerInputFocusHandler(handler) {
  499. return _this3.input_.addEventListener('focus', handler);
  500. },
  501. registerInputBlurHandler: function registerInputBlurHandler(handler) {
  502. return _this3.input_.addEventListener('blur', handler);
  503. },
  504. registerInputInputHandler: function registerInputInputHandler(handler) {
  505. return _this3.input_.addEventListener('input', handler);
  506. },
  507. registerInputKeydownHandler: function registerInputKeydownHandler(handler) {
  508. return _this3.input_.addEventListener('keydown', handler);
  509. },
  510. deregisterInputFocusHandler: function deregisterInputFocusHandler(handler) {
  511. return _this3.input_.removeEventListener('focus', handler);
  512. },
  513. deregisterInputBlurHandler: function deregisterInputBlurHandler(handler) {
  514. return _this3.input_.removeEventListener('blur', handler);
  515. },
  516. deregisterInputInputHandler: function deregisterInputInputHandler(handler) {
  517. return _this3.input_.removeEventListener('input', handler);
  518. },
  519. deregisterInputKeydownHandler: function deregisterInputKeydownHandler(handler) {
  520. return _this3.input_.removeEventListener('keydown', handler);
  521. },
  522. getNativeInput: function getNativeInput() {
  523. return _this3.input_;
  524. }
  525. };
  526. }
  527. }, {
  528. key: 'getHelptextAdapterMethods_',
  529. value: function getHelptextAdapterMethods_() {
  530. var _this4 = this;
  531. return {
  532. addClassToHelptext: function addClassToHelptext(className) {
  533. if (_this4.helptextElement) {
  534. _this4.helptextElement.classList.add(className);
  535. }
  536. },
  537. removeClassFromHelptext: function removeClassFromHelptext(className) {
  538. if (_this4.helptextElement) {
  539. _this4.helptextElement.classList.remove(className);
  540. }
  541. },
  542. helptextHasClass: function helptextHasClass(className) {
  543. if (!_this4.helptextElement) {
  544. return false;
  545. }
  546. return _this4.helptextElement.classList.contains(className);
  547. },
  548. setHelptextAttr: function setHelptextAttr(name, value) {
  549. if (_this4.helptextElement) {
  550. _this4.helptextElement.setAttribute(name, value);
  551. }
  552. },
  553. removeHelptextAttr: function removeHelptextAttr(name) {
  554. if (_this4.helptextElement) {
  555. _this4.helptextElement.removeAttribute(name);
  556. }
  557. }
  558. };
  559. }
  560. }, {
  561. key: 'disabled',
  562. get: function get() {
  563. return this.foundation_.isDisabled();
  564. },
  565. set: function set(disabled) {
  566. this.foundation_.setDisabled(disabled);
  567. }
  568. }], [{
  569. key: 'attachTo',
  570. value: function attachTo(root) {
  571. return new MDCTextfield(root);
  572. }
  573. }]);
  574. return MDCTextfield;
  575. }(__WEBPACK_IMPORTED_MODULE_0__material_base__["MDCComponent"]);
  576. /***/ }),
  577. /***/ 4:
  578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  579. "use strict";
  580. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  581. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  582. /**
  583. * Copyright 2016 Google Inc. All Rights Reserved.
  584. *
  585. * Licensed under the Apache License, Version 2.0 (the "License");
  586. * you may not use this file except in compliance with the License.
  587. * You may obtain a copy of the License at
  588. *
  589. * http://www.apache.org/licenses/LICENSE-2.0
  590. *
  591. * Unless required by applicable law or agreed to in writing, software
  592. * distributed under the License is distributed on an "AS IS" BASIS,
  593. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  594. * See the License for the specific language governing permissions and
  595. * limitations under the License.
  596. */
  597. /* eslint no-unused-vars: [2, {"args": "none"}] */
  598. /**
  599. * Adapter for MDC Ripple. Provides an interface for managing
  600. * - classes
  601. * - dom
  602. * - CSS variables
  603. * - position
  604. * - dimensions
  605. * - scroll position
  606. * - event handlers
  607. * - unbounded, active and disabled states
  608. *
  609. * Additionally, provides type information for the adapter to the Closure
  610. * compiler.
  611. *
  612. * Implement this adapter for your framework of choice to delegate updates to
  613. * the component in your framework of choice. See architecture documentation
  614. * for more details.
  615. * https://github.com/material-components/material-components-web/blob/master/docs/architecture.md
  616. *
  617. * @record
  618. */
  619. var MDCRippleAdapter = function () {
  620. function MDCRippleAdapter() {
  621. _classCallCheck(this, MDCRippleAdapter);
  622. }
  623. _createClass(MDCRippleAdapter, [{
  624. key: "browserSupportsCssVars",
  625. /** @return {boolean} */
  626. value: function browserSupportsCssVars() {}
  627. /** @return {boolean} */
  628. }, {
  629. key: "isUnbounded",
  630. value: function isUnbounded() {}
  631. /** @return {boolean} */
  632. }, {
  633. key: "isSurfaceActive",
  634. value: function isSurfaceActive() {}
  635. /** @return {boolean} */
  636. }, {
  637. key: "isSurfaceDisabled",
  638. value: function isSurfaceDisabled() {}
  639. /** @param {string} className */
  640. }, {
  641. key: "addClass",
  642. value: function addClass(className) {}
  643. /** @param {string} className */
  644. }, {
  645. key: "removeClass",
  646. value: function removeClass(className) {}
  647. /**
  648. * @param {string} evtType
  649. * @param {!Function} handler
  650. */
  651. }, {
  652. key: "registerInteractionHandler",
  653. value: function registerInteractionHandler(evtType, handler) {}
  654. /**
  655. * @param {string} evtType
  656. * @param {!Function} handler
  657. */
  658. }, {
  659. key: "deregisterInteractionHandler",
  660. value: function deregisterInteractionHandler(evtType, handler) {}
  661. /**
  662. * @param {!Function} handler
  663. */
  664. }, {
  665. key: "registerResizeHandler",
  666. value: function registerResizeHandler(handler) {}
  667. /**
  668. * @param {!Function} handler
  669. */
  670. }, {
  671. key: "deregisterResizeHandler",
  672. value: function deregisterResizeHandler(handler) {}
  673. /**
  674. * @param {string} varName
  675. * @param {?number|string} value
  676. */
  677. }, {
  678. key: "updateCssVariable",
  679. value: function updateCssVariable(varName, value) {}
  680. /** @return {!ClientRect} */
  681. }, {
  682. key: "computeBoundingRect",
  683. value: function computeBoundingRect() {}
  684. /** @return {{x: number, y: number}} */
  685. }, {
  686. key: "getWindowPageOffset",
  687. value: function getWindowPageOffset() {}
  688. }]);
  689. return MDCRippleAdapter;
  690. }();
  691. /* unused harmony default export */ var _unused_webpack_default_export = (MDCRippleAdapter);
  692. /***/ }),
  693. /***/ 5:
  694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  695. "use strict";
  696. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  697. /* harmony export (immutable) */ __webpack_exports__["supportsCssVariables"] = supportsCssVariables;
  698. /* harmony export (immutable) */ __webpack_exports__["applyPassive"] = applyPassive;
  699. /* harmony export (immutable) */ __webpack_exports__["getMatchesProperty"] = getMatchesProperty;
  700. /* harmony export (immutable) */ __webpack_exports__["getNormalizedEventCoords"] = getNormalizedEventCoords;
  701. /**
  702. * Copyright 2016 Google Inc. All Rights Reserved.
  703. *
  704. * Licensed under the Apache License, Version 2.0 (the "License");
  705. * you may not use this file except in compliance with the License.
  706. * You may obtain a copy of the License at
  707. *
  708. * http://www.apache.org/licenses/LICENSE-2.0
  709. *
  710. * Unless required by applicable law or agreed to in writing, software
  711. * distributed under the License is distributed on an "AS IS" BASIS,
  712. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  713. * See the License for the specific language governing permissions and
  714. * limitations under the License.
  715. */
  716. /**
  717. * Stores result from supportsCssVariables to avoid redundant processing to detect CSS custom variable support.
  718. * @private {boolean|undefined}
  719. */
  720. var supportsCssVariables_ = void 0;
  721. /**
  722. * Stores result from applyPassive to avoid redundant processing to detect passive event listener support.
  723. * @private {boolean|undefined}
  724. */
  725. var supportsPassive_ = void 0;
  726. /**
  727. * @param {!Window} windowObj
  728. * @return {boolean}
  729. */
  730. function detectEdgePseudoVarBug(windowObj) {
  731. // Detect versions of Edge with buggy var() support
  732. // See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11495448/
  733. var document = windowObj.document;
  734. var className = 'test-edge-css-var';
  735. var styleNode = document.createElement('style');
  736. document.head.appendChild(styleNode);
  737. var sheet = styleNode.sheet;
  738. // Internet Explorer 11 requires indices to always be specified to insertRule
  739. sheet.insertRule(':root { --' + className + ': 1px solid #000; }', 0);
  740. sheet.insertRule('.' + className + ' { visibility: hidden; }', 1);
  741. sheet.insertRule('.' + className + '::before { border: var(--' + className + '); }', 2);
  742. var node = document.createElement('div');
  743. node.className = className;
  744. document.body.appendChild(node);
  745. // Bug exists if ::before style ends up propagating to the parent element
  746. var hasPseudoVarBug = windowObj.getComputedStyle(node).borderTopStyle === 'solid';
  747. node.remove();
  748. styleNode.remove();
  749. return hasPseudoVarBug;
  750. }
  751. /**
  752. * @param {!Window} windowObj
  753. * @param {boolean=} forceRefresh
  754. * @return {boolean|undefined}
  755. */
  756. function supportsCssVariables(windowObj) {
  757. var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  758. if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
  759. return supportsCssVariables_;
  760. }
  761. var supportsFunctionPresent = windowObj.CSS && typeof windowObj.CSS.supports === 'function';
  762. if (!supportsFunctionPresent) {
  763. return;
  764. }
  765. var explicitlySupportsCssVars = windowObj.CSS.supports('--css-vars', 'yes');
  766. // See: https://bugs.webkit.org/show_bug.cgi?id=154669
  767. // See: README section on Safari
  768. var weAreFeatureDetectingSafari10plus = windowObj.CSS.supports('(--css-vars: yes)') && windowObj.CSS.supports('color', '#00000000');
  769. if (explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus) {
  770. supportsCssVariables_ = !detectEdgePseudoVarBug(windowObj);
  771. } else {
  772. supportsCssVariables_ = false;
  773. }
  774. return supportsCssVariables_;
  775. }
  776. //
  777. /**
  778. * Determine whether the current browser supports passive event listeners, and if so, use them.
  779. * @param {!Window=} globalObj
  780. * @param {boolean=} forceRefresh
  781. * @return {boolean|{passive: boolean}}
  782. */
  783. function applyPassive() {
  784. var globalObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
  785. var forceRefresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  786. if (supportsPassive_ === undefined || forceRefresh) {
  787. var isSupported = false;
  788. try {
  789. globalObj.document.addEventListener('test', null, { get passive() {
  790. isSupported = true;
  791. } });
  792. } catch (e) {}
  793. supportsPassive_ = isSupported;
  794. }
  795. return supportsPassive_ ? { passive: true } : false;
  796. }
  797. /**
  798. * @param {!Object} HTMLElementPrototype
  799. * @return {!Array<string>}
  800. */
  801. function getMatchesProperty(HTMLElementPrototype) {
  802. return ['webkitMatchesSelector', 'msMatchesSelector', 'matches'].filter(function (p) {
  803. return p in HTMLElementPrototype;
  804. }).pop();
  805. }
  806. /**
  807. * @param {!Event} ev
  808. * @param {!{x: number, y: number}} pageOffset
  809. * @param {!ClientRect} clientRect
  810. * @return {!{x: number, y: number}}
  811. */
  812. function getNormalizedEventCoords(ev, pageOffset, clientRect) {
  813. var x = pageOffset.x,
  814. y = pageOffset.y;
  815. var documentX = x + clientRect.left;
  816. var documentY = y + clientRect.top;
  817. var normalizedX = void 0;
  818. var normalizedY = void 0;
  819. // Determine touch point relative to the ripple container.
  820. if (ev.type === 'touchstart') {
  821. normalizedX = ev.changedTouches[0].pageX - documentX;
  822. normalizedY = ev.changedTouches[0].pageY - documentY;
  823. } else {
  824. normalizedX = ev.pageX - documentX;
  825. normalizedY = ev.pageY - documentY;
  826. }
  827. return { x: normalizedX, y: normalizedY };
  828. }
  829. /***/ }),
  830. /***/ 6:
  831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  832. "use strict";
  833. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCRipple", function() { return MDCRipple; });
  835. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_component__ = __webpack_require__(1);
  836. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__adapter__ = __webpack_require__(4);
  837. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__foundation__ = __webpack_require__(8);
  838. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util__ = __webpack_require__(5);
  839. /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCRippleFoundation", function() { return __WEBPACK_IMPORTED_MODULE_2__foundation__["a"]; });
  840. /* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "util", function() { return __WEBPACK_IMPORTED_MODULE_3__util__; });
  841. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  842. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  843. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  844. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  845. /**
  846. * Copyright 2016 Google Inc. All Rights Reserved.
  847. *
  848. * Licensed under the Apache License, Version 2.0 (the "License");
  849. * you may not use this file except in compliance with the License.
  850. * You may obtain a copy of the License at
  851. *
  852. * http://www.apache.org/licenses/LICENSE-2.0
  853. *
  854. * Unless required by applicable law or agreed to in writing, software
  855. * distributed under the License is distributed on an "AS IS" BASIS,
  856. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  857. * See the License for the specific language governing permissions and
  858. * limitations under the License.
  859. */
  860. /**
  861. * @extends MDCComponent<!MDCRippleFoundation>
  862. */
  863. var MDCRipple = function (_MDCComponent) {
  864. _inherits(MDCRipple, _MDCComponent);
  865. /** @param {...?} args */
  866. function MDCRipple() {
  867. var _ref;
  868. _classCallCheck(this, MDCRipple);
  869. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  870. args[_key] = arguments[_key];
  871. }
  872. /** @type {boolean} */
  873. var _this = _possibleConstructorReturn(this, (_ref = MDCRipple.__proto__ || Object.getPrototypeOf(MDCRipple)).call.apply(_ref, [this].concat(args)));
  874. _this.disabled = false;
  875. /** @private {boolean} */
  876. _this.unbounded_;
  877. return _this;
  878. }
  879. /**
  880. * @param {!Element} root
  881. * @param {{isUnbounded: (boolean|undefined)}=} options
  882. * @return {!MDCRipple}
  883. */
  884. _createClass(MDCRipple, [{
  885. key: 'activate',
  886. value: function activate() {
  887. this.foundation_.activate();
  888. }
  889. }, {
  890. key: 'deactivate',
  891. value: function deactivate() {
  892. this.foundation_.deactivate();
  893. }
  894. }, {
  895. key: 'layout',
  896. value: function layout() {
  897. this.foundation_.layout();
  898. }
  899. /** @return {!MDCRippleFoundation} */
  900. }, {
  901. key: 'getDefaultFoundation',
  902. value: function getDefaultFoundation() {
  903. return new __WEBPACK_IMPORTED_MODULE_2__foundation__["a" /* default */](MDCRipple.createAdapter(this));
  904. }
  905. }, {
  906. key: 'initialSyncWithDOM',
  907. value: function initialSyncWithDOM() {
  908. this.unbounded = 'mdcRippleIsUnbounded' in this.root_.dataset;
  909. }
  910. }, {
  911. key: 'unbounded',
  912. /** @return {boolean} */
  913. get: function get() {
  914. return this.unbounded_;
  915. }
  916. /** @param {boolean} unbounded */
  917. ,
  918. set: function set(unbounded) {
  919. var UNBOUNDED = __WEBPACK_IMPORTED_MODULE_2__foundation__["a" /* default */].cssClasses.UNBOUNDED;
  920. this.unbounded_ = Boolean(unbounded);
  921. if (this.unbounded_) {
  922. this.root_.classList.add(UNBOUNDED);
  923. } else {
  924. this.root_.classList.remove(UNBOUNDED);
  925. }
  926. }
  927. }], [{
  928. key: 'attachTo',
  929. value: function attachTo(root) {
  930. var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  931. _ref2$isUnbounded = _ref2.isUnbounded,
  932. isUnbounded = _ref2$isUnbounded === undefined ? undefined : _ref2$isUnbounded;
  933. var ripple = new MDCRipple(root);
  934. // Only override unbounded behavior if option is explicitly specified
  935. if (isUnbounded !== undefined) {
  936. ripple.unbounded = /** @type {boolean} */isUnbounded;
  937. }
  938. return ripple;
  939. }
  940. /**
  941. * @param {!RippleCapableSurface} instance
  942. * @return {!MDCRippleAdapter}
  943. */
  944. }, {
  945. key: 'createAdapter',
  946. value: function createAdapter(instance) {
  947. var MATCHES = __WEBPACK_IMPORTED_MODULE_3__util__["getMatchesProperty"](HTMLElement.prototype);
  948. return {
  949. browserSupportsCssVars: function browserSupportsCssVars() {
  950. return __WEBPACK_IMPORTED_MODULE_3__util__["supportsCssVariables"](window);
  951. },
  952. isUnbounded: function isUnbounded() {
  953. return instance.unbounded;
  954. },
  955. isSurfaceActive: function isSurfaceActive() {
  956. return instance.root_[MATCHES](':active');
  957. },
  958. isSurfaceDisabled: function isSurfaceDisabled() {
  959. return instance.disabled;
  960. },
  961. addClass: function addClass(className) {
  962. return instance.root_.classList.add(className);
  963. },
  964. removeClass: function removeClass(className) {
  965. return instance.root_.classList.remove(className);
  966. },
  967. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  968. return instance.root_.addEventListener(evtType, handler, __WEBPACK_IMPORTED_MODULE_3__util__["applyPassive"]());
  969. },
  970. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  971. return instance.root_.removeEventListener(evtType, handler, __WEBPACK_IMPORTED_MODULE_3__util__["applyPassive"]());
  972. },
  973. registerResizeHandler: function registerResizeHandler(handler) {
  974. return window.addEventListener('resize', handler);
  975. },
  976. deregisterResizeHandler: function deregisterResizeHandler(handler) {
  977. return window.removeEventListener('resize', handler);
  978. },
  979. updateCssVariable: function updateCssVariable(varName, value) {
  980. return instance.root_.style.setProperty(varName, value);
  981. },
  982. computeBoundingRect: function computeBoundingRect() {
  983. return instance.root_.getBoundingClientRect();
  984. },
  985. getWindowPageOffset: function getWindowPageOffset() {
  986. return { x: window.pageXOffset, y: window.pageYOffset };
  987. }
  988. };
  989. }
  990. }]);
  991. return MDCRipple;
  992. }(__WEBPACK_IMPORTED_MODULE_0__material_base_component__["a" /* default */]);
  993. /**
  994. * See Material Design spec for more details on when to use ripples.
  995. * https://material.io/guidelines/motion/choreography.html#choreography-creation
  996. * @record
  997. */
  998. var RippleCapableSurface = function RippleCapableSurface() {
  999. _classCallCheck(this, RippleCapableSurface);
  1000. };
  1001. /** @protected {!Element} */
  1002. RippleCapableSurface.prototype.root_;
  1003. /**
  1004. * Whether or not the ripple bleeds out of the bounds of the element.
  1005. * @type {boolean|undefined}
  1006. */
  1007. RippleCapableSurface.prototype.unbounded;
  1008. /**
  1009. * Whether or not the ripple is attached to a disabled component.
  1010. * @type {boolean|undefined}
  1011. */
  1012. RippleCapableSurface.prototype.disabled;
  1013. /***/ }),
  1014. /***/ 7:
  1015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1016. "use strict";
  1017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cssClasses; });
  1018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return strings; });
  1019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return numbers; });
  1020. /**
  1021. * Copyright 2016 Google Inc. All Rights Reserved.
  1022. *
  1023. * Licensed under the Apache License, Version 2.0 (the "License");
  1024. * you may not use this file except in compliance with the License.
  1025. * You may obtain a copy of the License at
  1026. *
  1027. * http://www.apache.org/licenses/LICENSE-2.0
  1028. *
  1029. * Unless required by applicable law or agreed to in writing, software
  1030. * distributed under the License is distributed on an "AS IS" BASIS,
  1031. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1032. * See the License for the specific language governing permissions and
  1033. * limitations under the License.
  1034. */
  1035. var cssClasses = {
  1036. // Ripple is a special case where the "root" component is really a "mixin" of sorts,
  1037. // given that it's an 'upgrade' to an existing component. That being said it is the root
  1038. // CSS class that all other CSS classes derive from.
  1039. ROOT: 'mdc-ripple-upgraded',
  1040. UNBOUNDED: 'mdc-ripple-upgraded--unbounded',
  1041. BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
  1042. BG_ACTIVE_FILL: 'mdc-ripple-upgraded--background-active-fill',
  1043. FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
  1044. FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation'
  1045. };
  1046. var strings = {
  1047. VAR_SURFACE_WIDTH: '--mdc-ripple-surface-width',
  1048. VAR_SURFACE_HEIGHT: '--mdc-ripple-surface-height',
  1049. VAR_FG_SIZE: '--mdc-ripple-fg-size',
  1050. VAR_LEFT: '--mdc-ripple-left',
  1051. VAR_TOP: '--mdc-ripple-top',
  1052. VAR_FG_SCALE: '--mdc-ripple-fg-scale',
  1053. VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
  1054. VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end'
  1055. };
  1056. var numbers = {
  1057. PADDING: 10,
  1058. INITIAL_ORIGIN_SCALE: 0.6,
  1059. DEACTIVATION_TIMEOUT_MS: 300,
  1060. FG_DEACTIVATION_MS: 83
  1061. };
  1062. /***/ }),
  1063. /***/ 75:
  1064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1065. "use strict";
  1066. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base__ = __webpack_require__(2);
  1067. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__(22);
  1068. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  1069. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1070. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1071. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1072. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1073. /**
  1074. * Copyright 2016 Google Inc. All Rights Reserved.
  1075. *
  1076. * Licensed under the Apache License, Version 2.0 (the "License");
  1077. * you may not use this file except in compliance with the License.
  1078. * You may obtain a copy of the License at
  1079. *
  1080. * http://www.apache.org/licenses/LICENSE-2.0
  1081. *
  1082. * Unless required by applicable law or agreed to in writing, software
  1083. * distributed under the License is distributed on an "AS IS" BASIS,
  1084. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1085. * See the License for the specific language governing permissions and
  1086. * limitations under the License.
  1087. */
  1088. var MDCTextfieldFoundation = function (_MDCFoundation) {
  1089. _inherits(MDCTextfieldFoundation, _MDCFoundation);
  1090. _createClass(MDCTextfieldFoundation, null, [{
  1091. key: 'cssClasses',
  1092. get: function get() {
  1093. return __WEBPACK_IMPORTED_MODULE_1__constants__["b" /* cssClasses */];
  1094. }
  1095. }, {
  1096. key: 'strings',
  1097. get: function get() {
  1098. return __WEBPACK_IMPORTED_MODULE_1__constants__["a" /* strings */];
  1099. }
  1100. }, {
  1101. key: 'defaultAdapter',
  1102. get: function get() {
  1103. return {
  1104. addClass: function addClass() /* className: string */{},
  1105. removeClass: function removeClass() /* className: string */{},
  1106. addClassToLabel: function addClassToLabel() /* className: string */{},
  1107. removeClassFromLabel: function removeClassFromLabel() /* className: string */{},
  1108. addClassToHelptext: function addClassToHelptext() /* className: string */{},
  1109. removeClassFromHelptext: function removeClassFromHelptext() /* className: string */{},
  1110. helptextHasClass: function helptextHasClass() {
  1111. return (/* className: string */ /* boolean */false
  1112. );
  1113. },
  1114. registerInputFocusHandler: function registerInputFocusHandler() /* handler: EventListener */{},
  1115. deregisterInputFocusHandler: function deregisterInputFocusHandler() /* handler: EventListener */{},
  1116. registerInputBlurHandler: function registerInputBlurHandler() /* handler: EventListener */{},
  1117. deregisterInputBlurHandler: function deregisterInputBlurHandler() /* handler: EventListener */{},
  1118. registerInputInputHandler: function registerInputInputHandler() /* handler: EventListener */{},
  1119. deregisterInputInputHandler: function deregisterInputInputHandler() /* handler: EventListener */{},
  1120. registerInputKeydownHandler: function registerInputKeydownHandler() /* handler: EventListener */{},
  1121. deregisterInputKeydownHandler: function deregisterInputKeydownHandler() /* handler: EventListener */{},
  1122. setHelptextAttr: function setHelptextAttr() /* name: string, value: string */{},
  1123. removeHelptextAttr: function removeHelptextAttr() /* name: string */{},
  1124. getNativeInput: function getNativeInput() {
  1125. return (/* HTMLInputElement */{}
  1126. );
  1127. }
  1128. };
  1129. }
  1130. }]);
  1131. function MDCTextfieldFoundation() {
  1132. var adapter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1133. _classCallCheck(this, MDCTextfieldFoundation);
  1134. var _this = _possibleConstructorReturn(this, (MDCTextfieldFoundation.__proto__ || Object.getPrototypeOf(MDCTextfieldFoundation)).call(this, _extends(MDCTextfieldFoundation.defaultAdapter, adapter)));
  1135. _this.receivedUserInput_ = false;
  1136. _this.inputFocusHandler_ = function () {
  1137. return _this.activateFocus_();
  1138. };
  1139. _this.inputBlurHandler_ = function () {
  1140. return _this.deactivateFocus_();
  1141. };
  1142. _this.inputInputHandler_ = function () {
  1143. return _this.autoCompleteFocus_();
  1144. };
  1145. _this.inputKeydownHandler_ = function () {
  1146. return _this.receivedUserInput_ = true;
  1147. };
  1148. return _this;
  1149. }
  1150. _createClass(MDCTextfieldFoundation, [{
  1151. key: 'init',
  1152. value: function init() {
  1153. this.adapter_.addClass(MDCTextfieldFoundation.cssClasses.UPGRADED);
  1154. this.adapter_.registerInputFocusHandler(this.inputFocusHandler_);
  1155. this.adapter_.registerInputBlurHandler(this.inputBlurHandler_);
  1156. this.adapter_.registerInputInputHandler(this.inputInputHandler_);
  1157. this.adapter_.registerInputKeydownHandler(this.inputKeydownHandler_);
  1158. // Ensure label does not collide with any pre-filled value.
  1159. if (this.getNativeInput_().value) {
  1160. this.adapter_.addClassToLabel(MDCTextfieldFoundation.cssClasses.LABEL_FLOAT_ABOVE);
  1161. }
  1162. }
  1163. }, {
  1164. key: 'destroy',
  1165. value: function destroy() {
  1166. this.adapter_.removeClass(MDCTextfieldFoundation.cssClasses.UPGRADED);
  1167. this.adapter_.deregisterInputFocusHandler(this.inputFocusHandler_);
  1168. this.adapter_.deregisterInputBlurHandler(this.inputBlurHandler_);
  1169. this.adapter_.deregisterInputInputHandler(this.inputInputHandler_);
  1170. this.adapter_.deregisterInputKeydownHandler(this.inputKeydownHandler_);
  1171. }
  1172. }, {
  1173. key: 'activateFocus_',
  1174. value: function activateFocus_() {
  1175. var _MDCTextfieldFoundati = MDCTextfieldFoundation.cssClasses,
  1176. FOCUSED = _MDCTextfieldFoundati.FOCUSED,
  1177. LABEL_FLOAT_ABOVE = _MDCTextfieldFoundati.LABEL_FLOAT_ABOVE;
  1178. this.adapter_.addClass(FOCUSED);
  1179. this.adapter_.addClassToLabel(LABEL_FLOAT_ABOVE);
  1180. this.showHelptext_();
  1181. }
  1182. }, {
  1183. key: 'autoCompleteFocus_',
  1184. value: function autoCompleteFocus_() {
  1185. if (!this.receivedUserInput_) {
  1186. this.activateFocus_();
  1187. }
  1188. }
  1189. }, {
  1190. key: 'showHelptext_',
  1191. value: function showHelptext_() {
  1192. var ARIA_HIDDEN = MDCTextfieldFoundation.strings.ARIA_HIDDEN;
  1193. this.adapter_.removeHelptextAttr(ARIA_HIDDEN);
  1194. }
  1195. }, {
  1196. key: 'deactivateFocus_',
  1197. value: function deactivateFocus_() {
  1198. var _MDCTextfieldFoundati2 = MDCTextfieldFoundation.cssClasses,
  1199. FOCUSED = _MDCTextfieldFoundati2.FOCUSED,
  1200. INVALID = _MDCTextfieldFoundati2.INVALID,
  1201. LABEL_FLOAT_ABOVE = _MDCTextfieldFoundati2.LABEL_FLOAT_ABOVE;
  1202. var input = this.getNativeInput_();
  1203. var isValid = input.checkValidity();
  1204. this.adapter_.removeClass(FOCUSED);
  1205. if (!input.value && !this.isBadInput_()) {
  1206. this.adapter_.removeClassFromLabel(LABEL_FLOAT_ABOVE);
  1207. this.receivedUserInput_ = false;
  1208. }
  1209. if (isValid) {
  1210. this.adapter_.removeClass(INVALID);
  1211. } else {
  1212. this.adapter_.addClass(INVALID);
  1213. }
  1214. this.updateHelptextOnDeactivation_(isValid);
  1215. }
  1216. }, {
  1217. key: 'updateHelptextOnDeactivation_',
  1218. value: function updateHelptextOnDeactivation_(isValid) {
  1219. var _MDCTextfieldFoundati3 = MDCTextfieldFoundation.cssClasses,
  1220. HELPTEXT_PERSISTENT = _MDCTextfieldFoundati3.HELPTEXT_PERSISTENT,
  1221. HELPTEXT_VALIDATION_MSG = _MDCTextfieldFoundati3.HELPTEXT_VALIDATION_MSG;
  1222. var ROLE = MDCTextfieldFoundation.strings.ROLE;
  1223. var helptextIsPersistent = this.adapter_.helptextHasClass(HELPTEXT_PERSISTENT);
  1224. var helptextIsValidationMsg = this.adapter_.helptextHasClass(HELPTEXT_VALIDATION_MSG);
  1225. var validationMsgNeedsDisplay = helptextIsValidationMsg && !isValid;
  1226. if (validationMsgNeedsDisplay) {
  1227. this.adapter_.setHelptextAttr(ROLE, 'alert');
  1228. } else {
  1229. this.adapter_.removeHelptextAttr(ROLE);
  1230. }
  1231. if (helptextIsPersistent || validationMsgNeedsDisplay) {
  1232. return;
  1233. }
  1234. this.hideHelptext_();
  1235. }
  1236. }, {
  1237. key: 'hideHelptext_',
  1238. value: function hideHelptext_() {
  1239. var ARIA_HIDDEN = MDCTextfieldFoundation.strings.ARIA_HIDDEN;
  1240. this.adapter_.setHelptextAttr(ARIA_HIDDEN, 'true');
  1241. }
  1242. }, {
  1243. key: 'isBadInput_',
  1244. value: function isBadInput_() {
  1245. var input = this.getNativeInput_();
  1246. return input.validity ? input.validity.badInput : input.badInput;
  1247. }
  1248. }, {
  1249. key: 'isDisabled',
  1250. value: function isDisabled() {
  1251. return this.getNativeInput_().disabled;
  1252. }
  1253. }, {
  1254. key: 'setDisabled',
  1255. value: function setDisabled(disabled) {
  1256. var DISABLED = MDCTextfieldFoundation.cssClasses.DISABLED;
  1257. this.getNativeInput_().disabled = disabled;
  1258. if (disabled) {
  1259. this.adapter_.addClass(DISABLED);
  1260. } else {
  1261. this.adapter_.removeClass(DISABLED);
  1262. }
  1263. }
  1264. }, {
  1265. key: 'getNativeInput_',
  1266. value: function getNativeInput_() {
  1267. return this.adapter_.getNativeInput() || {
  1268. checkValidity: function checkValidity() {
  1269. return true;
  1270. },
  1271. value: '',
  1272. disabled: false,
  1273. badInput: false
  1274. };
  1275. }
  1276. }]);
  1277. return MDCTextfieldFoundation;
  1278. }(__WEBPACK_IMPORTED_MODULE_0__material_base__["MDCFoundation"]);
  1279. /* harmony default export */ __webpack_exports__["a"] = (MDCTextfieldFoundation);
  1280. /***/ }),
  1281. /***/ 8:
  1282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1283. "use strict";
  1284. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base_foundation__ = __webpack_require__(0);
  1285. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__adapter__ = __webpack_require__(4);
  1286. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__constants__ = __webpack_require__(7);
  1287. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util__ = __webpack_require__(5);
  1288. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  1289. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1290. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1291. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1292. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1293. /**
  1294. * Copyright 2016 Google Inc. All Rights Reserved.
  1295. *
  1296. * Licensed under the Apache License, Version 2.0 (the "License");
  1297. * you may not use this file except in compliance with the License.
  1298. * You may obtain a copy of the License at
  1299. *
  1300. * http://www.apache.org/licenses/LICENSE-2.0
  1301. *
  1302. * Unless required by applicable law or agreed to in writing, software
  1303. * distributed under the License is distributed on an "AS IS" BASIS,
  1304. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1305. * See the License for the specific language governing permissions and
  1306. * limitations under the License.
  1307. */
  1308. /**
  1309. * @typedef {!{
  1310. * isActivated: (boolean|undefined),
  1311. * hasDeactivationUXRun: (boolean|undefined),
  1312. * wasActivatedByPointer: (boolean|undefined),
  1313. * wasElementMadeActive: (boolean|undefined),
  1314. * activationStartTime: (number|undefined),
  1315. * activationEvent: Event,
  1316. * isProgrammatic: (boolean|undefined)
  1317. * }}
  1318. */
  1319. var ActivationStateType = void 0;
  1320. /**
  1321. * @typedef {!{
  1322. * activate: (string|undefined),
  1323. * deactivate: (string|undefined),
  1324. * focus: (string|undefined),
  1325. * blur: (string|undefined)
  1326. * }}
  1327. */
  1328. var ListenerInfoType = void 0;
  1329. /**
  1330. * @typedef {!{
  1331. * activate: function(!Event),
  1332. * deactivate: function(!Event),
  1333. * focus: function(),
  1334. * blur: function()
  1335. * }}
  1336. */
  1337. var ListenersType = void 0;
  1338. /**
  1339. * @typedef {!{
  1340. * x: number,
  1341. * y: number
  1342. * }}
  1343. */
  1344. var PointType = void 0;
  1345. /**
  1346. * @enum {string}
  1347. */
  1348. var DEACTIVATION_ACTIVATION_PAIRS = {
  1349. mouseup: 'mousedown',
  1350. pointerup: 'pointerdown',
  1351. touchend: 'touchstart',
  1352. keyup: 'keydown',
  1353. blur: 'focus'
  1354. };
  1355. /**
  1356. * @extends {MDCFoundation<!MDCRippleAdapter>}
  1357. */
  1358. var MDCRippleFoundation = function (_MDCFoundation) {
  1359. _inherits(MDCRippleFoundation, _MDCFoundation);
  1360. _createClass(MDCRippleFoundation, [{
  1361. key: 'isSupported_',
  1362. /**
  1363. * We compute this property so that we are not querying information about the client
  1364. * until the point in time where the foundation requests it. This prevents scenarios where
  1365. * client-side feature-detection may happen too early, such as when components are rendered on the server
  1366. * and then initialized at mount time on the client.
  1367. * @return {boolean}
  1368. */
  1369. get: function get() {
  1370. return this.adapter_.browserSupportsCssVars();
  1371. }
  1372. }], [{
  1373. key: 'cssClasses',
  1374. get: function get() {
  1375. return __WEBPACK_IMPORTED_MODULE_2__constants__["a" /* cssClasses */];
  1376. }
  1377. }, {
  1378. key: 'strings',
  1379. get: function get() {
  1380. return __WEBPACK_IMPORTED_MODULE_2__constants__["b" /* strings */];
  1381. }
  1382. }, {
  1383. key: 'numbers',
  1384. get: function get() {
  1385. return __WEBPACK_IMPORTED_MODULE_2__constants__["c" /* numbers */];
  1386. }
  1387. }, {
  1388. key: 'defaultAdapter',
  1389. get: function get() {
  1390. return {
  1391. browserSupportsCssVars: function browserSupportsCssVars() /* boolean - cached */{},
  1392. isUnbounded: function isUnbounded() /* boolean */{},
  1393. isSurfaceActive: function isSurfaceActive() /* boolean */{},
  1394. isSurfaceDisabled: function isSurfaceDisabled() /* boolean */{},
  1395. addClass: function addClass() /* className: string */{},
  1396. removeClass: function removeClass() /* className: string */{},
  1397. registerInteractionHandler: function registerInteractionHandler() /* evtType: string, handler: EventListener */{},
  1398. deregisterInteractionHandler: function deregisterInteractionHandler() /* evtType: string, handler: EventListener */{},
  1399. registerResizeHandler: function registerResizeHandler() /* handler: EventListener */{},
  1400. deregisterResizeHandler: function deregisterResizeHandler() /* handler: EventListener */{},
  1401. updateCssVariable: function updateCssVariable() /* varName: string, value: string */{},
  1402. computeBoundingRect: function computeBoundingRect() /* ClientRect */{},
  1403. getWindowPageOffset: function getWindowPageOffset() /* {x: number, y: number} */{}
  1404. };
  1405. }
  1406. }]);
  1407. function MDCRippleFoundation(adapter) {
  1408. _classCallCheck(this, MDCRippleFoundation);
  1409. /** @private {number} */
  1410. var _this = _possibleConstructorReturn(this, (MDCRippleFoundation.__proto__ || Object.getPrototypeOf(MDCRippleFoundation)).call(this, _extends(MDCRippleFoundation.defaultAdapter, adapter)));
  1411. _this.layoutFrame_ = 0;
  1412. /** @private {!ClientRect} */
  1413. _this.frame_ = /** @type {!ClientRect} */{ width: 0, height: 0 };
  1414. /** @private {!ActivationStateType} */
  1415. _this.activationState_ = _this.defaultActivationState_();
  1416. /** @private {number} */
  1417. _this.xfDuration_ = 0;
  1418. /** @private {number} */
  1419. _this.initialSize_ = 0;
  1420. /** @private {number} */
  1421. _this.maxRadius_ = 0;
  1422. /** @private {!Array<{ListenerInfoType}>} */
  1423. _this.listenerInfos_ = [{ activate: 'touchstart', deactivate: 'touchend' }, { activate: 'pointerdown', deactivate: 'pointerup' }, { activate: 'mousedown', deactivate: 'mouseup' }, { activate: 'keydown', deactivate: 'keyup' }, { focus: 'focus', blur: 'blur' }];
  1424. /** @private {!ListenersType} */
  1425. _this.listeners_ = {
  1426. activate: function activate(e) {
  1427. return _this.activate_(e);
  1428. },
  1429. deactivate: function deactivate(e) {
  1430. return _this.deactivate_(e);
  1431. },
  1432. focus: function focus() {
  1433. return requestAnimationFrame(function () {
  1434. return _this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  1435. });
  1436. },
  1437. blur: function blur() {
  1438. return requestAnimationFrame(function () {
  1439. return _this.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  1440. });
  1441. }
  1442. };
  1443. /** @private {!Function} */
  1444. _this.resizeHandler_ = function () {
  1445. return _this.layout();
  1446. };
  1447. /** @private {!{left: number, top:number}} */
  1448. _this.unboundedCoords_ = {
  1449. left: 0,
  1450. top: 0
  1451. };
  1452. /** @private {number} */
  1453. _this.fgScale_ = 0;
  1454. /** @private {number} */
  1455. _this.activationTimer_ = 0;
  1456. /** @private {number} */
  1457. _this.fgDeactivationRemovalTimer_ = 0;
  1458. /** @private {boolean} */
  1459. _this.activationAnimationHasEnded_ = false;
  1460. /** @private {!Function} */
  1461. _this.activationTimerCallback_ = function () {
  1462. _this.activationAnimationHasEnded_ = true;
  1463. _this.runDeactivationUXLogicIfReady_();
  1464. };
  1465. return _this;
  1466. }
  1467. /**
  1468. * @return {!ActivationStateType}
  1469. */
  1470. _createClass(MDCRippleFoundation, [{
  1471. key: 'defaultActivationState_',
  1472. value: function defaultActivationState_() {
  1473. return {
  1474. isActivated: false,
  1475. hasDeactivationUXRun: false,
  1476. wasActivatedByPointer: false,
  1477. wasElementMadeActive: false,
  1478. activationStartTime: 0,
  1479. activationEvent: null,
  1480. isProgrammatic: false
  1481. };
  1482. }
  1483. }, {
  1484. key: 'init',
  1485. value: function init() {
  1486. var _this2 = this;
  1487. if (!this.isSupported_) {
  1488. return;
  1489. }
  1490. this.addEventListeners_();
  1491. var _MDCRippleFoundation$ = MDCRippleFoundation.cssClasses,
  1492. ROOT = _MDCRippleFoundation$.ROOT,
  1493. UNBOUNDED = _MDCRippleFoundation$.UNBOUNDED;
  1494. requestAnimationFrame(function () {
  1495. _this2.adapter_.addClass(ROOT);
  1496. if (_this2.adapter_.isUnbounded()) {
  1497. _this2.adapter_.addClass(UNBOUNDED);
  1498. }
  1499. _this2.layoutInternal_();
  1500. });
  1501. }
  1502. /** @private */
  1503. }, {
  1504. key: 'addEventListeners_',
  1505. value: function addEventListeners_() {
  1506. var _this3 = this;
  1507. this.listenerInfos_.forEach(function (info) {
  1508. Object.keys(info).forEach(function (k) {
  1509. _this3.adapter_.registerInteractionHandler(info[k], _this3.listeners_[k]);
  1510. });
  1511. });
  1512. this.adapter_.registerResizeHandler(this.resizeHandler_);
  1513. }
  1514. /**
  1515. * @param {Event} e
  1516. * @private
  1517. */
  1518. }, {
  1519. key: 'activate_',
  1520. value: function activate_(e) {
  1521. var _this4 = this;
  1522. if (this.adapter_.isSurfaceDisabled()) {
  1523. return;
  1524. }
  1525. var activationState = this.activationState_;
  1526. if (activationState.isActivated) {
  1527. return;
  1528. }
  1529. activationState.isActivated = true;
  1530. activationState.isProgrammatic = e === null;
  1531. activationState.activationEvent = e;
  1532. activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : e.type === 'mousedown' || e.type === 'touchstart' || e.type === 'pointerdown';
  1533. activationState.activationStartTime = Date.now();
  1534. requestAnimationFrame(function () {
  1535. // This needs to be wrapped in an rAF call b/c web browsers
  1536. // report active states inconsistently when they're called within
  1537. // event handling code:
  1538. // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
  1539. // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
  1540. activationState.wasElementMadeActive = e && e.type === 'keydown' ? _this4.adapter_.isSurfaceActive() : true;
  1541. if (activationState.wasElementMadeActive) {
  1542. _this4.animateActivation_();
  1543. } else {
  1544. // Reset activation state immediately if element was not made active.
  1545. _this4.activationState_ = _this4.defaultActivationState_();
  1546. }
  1547. });
  1548. }
  1549. }, {
  1550. key: 'activate',
  1551. value: function activate() {
  1552. this.activate_(null);
  1553. }
  1554. /** @private */
  1555. }, {
  1556. key: 'animateActivation_',
  1557. value: function animateActivation_() {
  1558. var _this5 = this;
  1559. var _MDCRippleFoundation$2 = MDCRippleFoundation.strings,
  1560. VAR_FG_TRANSLATE_START = _MDCRippleFoundation$2.VAR_FG_TRANSLATE_START,
  1561. VAR_FG_TRANSLATE_END = _MDCRippleFoundation$2.VAR_FG_TRANSLATE_END;
  1562. var _MDCRippleFoundation$3 = MDCRippleFoundation.cssClasses,
  1563. BG_ACTIVE_FILL = _MDCRippleFoundation$3.BG_ACTIVE_FILL,
  1564. FG_DEACTIVATION = _MDCRippleFoundation$3.FG_DEACTIVATION,
  1565. FG_ACTIVATION = _MDCRippleFoundation$3.FG_ACTIVATION;
  1566. var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
  1567. var translateStart = '';
  1568. var translateEnd = '';
  1569. if (!this.adapter_.isUnbounded()) {
  1570. var _getFgTranslationCoor = this.getFgTranslationCoordinates_(),
  1571. startPoint = _getFgTranslationCoor.startPoint,
  1572. endPoint = _getFgTranslationCoor.endPoint;
  1573. translateStart = startPoint.x + 'px, ' + startPoint.y + 'px';
  1574. translateEnd = endPoint.x + 'px, ' + endPoint.y + 'px';
  1575. }
  1576. this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
  1577. this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
  1578. // Cancel any ongoing activation/deactivation animations
  1579. clearTimeout(this.activationTimer_);
  1580. clearTimeout(this.fgDeactivationRemovalTimer_);
  1581. this.rmBoundedActivationClasses_();
  1582. this.adapter_.removeClass(FG_DEACTIVATION);
  1583. // Force layout in order to re-trigger the animation.
  1584. this.adapter_.computeBoundingRect();
  1585. this.adapter_.addClass(BG_ACTIVE_FILL);
  1586. this.adapter_.addClass(FG_ACTIVATION);
  1587. this.activationTimer_ = setTimeout(function () {
  1588. return _this5.activationTimerCallback_();
  1589. }, DEACTIVATION_TIMEOUT_MS);
  1590. }
  1591. /**
  1592. * @private
  1593. * @return {{startPoint: PointType, endPoint: PointType}}
  1594. */
  1595. }, {
  1596. key: 'getFgTranslationCoordinates_',
  1597. value: function getFgTranslationCoordinates_() {
  1598. var activationState = this.activationState_;
  1599. var activationEvent = activationState.activationEvent,
  1600. wasActivatedByPointer = activationState.wasActivatedByPointer;
  1601. var startPoint = void 0;
  1602. if (wasActivatedByPointer) {
  1603. startPoint = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["getNormalizedEventCoords"])(
  1604. /** @type {!Event} */activationEvent, this.adapter_.getWindowPageOffset(), this.adapter_.computeBoundingRect());
  1605. } else {
  1606. startPoint = {
  1607. x: this.frame_.width / 2,
  1608. y: this.frame_.height / 2
  1609. };
  1610. }
  1611. // Center the element around the start point.
  1612. startPoint = {
  1613. x: startPoint.x - this.initialSize_ / 2,
  1614. y: startPoint.y - this.initialSize_ / 2
  1615. };
  1616. var endPoint = {
  1617. x: this.frame_.width / 2 - this.initialSize_ / 2,
  1618. y: this.frame_.height / 2 - this.initialSize_ / 2
  1619. };
  1620. return { startPoint: startPoint, endPoint: endPoint };
  1621. }
  1622. /** @private */
  1623. }, {
  1624. key: 'runDeactivationUXLogicIfReady_',
  1625. value: function runDeactivationUXLogicIfReady_() {
  1626. var _this6 = this;
  1627. var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
  1628. var _activationState_ = this.activationState_,
  1629. hasDeactivationUXRun = _activationState_.hasDeactivationUXRun,
  1630. isActivated = _activationState_.isActivated;
  1631. var activationHasEnded = hasDeactivationUXRun || !isActivated;
  1632. if (activationHasEnded && this.activationAnimationHasEnded_) {
  1633. this.rmBoundedActivationClasses_();
  1634. this.adapter_.addClass(FG_DEACTIVATION);
  1635. this.fgDeactivationRemovalTimer_ = setTimeout(function () {
  1636. _this6.adapter_.removeClass(FG_DEACTIVATION);
  1637. }, __WEBPACK_IMPORTED_MODULE_2__constants__["c" /* numbers */].FG_DEACTIVATION_MS);
  1638. }
  1639. }
  1640. /** @private */
  1641. }, {
  1642. key: 'rmBoundedActivationClasses_',
  1643. value: function rmBoundedActivationClasses_() {
  1644. var _MDCRippleFoundation$4 = MDCRippleFoundation.cssClasses,
  1645. BG_ACTIVE_FILL = _MDCRippleFoundation$4.BG_ACTIVE_FILL,
  1646. FG_ACTIVATION = _MDCRippleFoundation$4.FG_ACTIVATION;
  1647. this.adapter_.removeClass(BG_ACTIVE_FILL);
  1648. this.adapter_.removeClass(FG_ACTIVATION);
  1649. this.activationAnimationHasEnded_ = false;
  1650. this.adapter_.computeBoundingRect();
  1651. }
  1652. /**
  1653. * @param {Event} e
  1654. * @private
  1655. */
  1656. }, {
  1657. key: 'deactivate_',
  1658. value: function deactivate_(e) {
  1659. var _this7 = this;
  1660. var activationState = this.activationState_;
  1661. // This can happen in scenarios such as when you have a keyup event that blurs the element.
  1662. if (!activationState.isActivated) {
  1663. return;
  1664. }
  1665. // Programmatic deactivation.
  1666. if (activationState.isProgrammatic) {
  1667. var evtObject = null;
  1668. var _state = /** @type {!ActivationStateType} */_extends({}, activationState);
  1669. requestAnimationFrame(function () {
  1670. return _this7.animateDeactivation_(evtObject, _state);
  1671. });
  1672. this.activationState_ = this.defaultActivationState_();
  1673. return;
  1674. }
  1675. var actualActivationType = DEACTIVATION_ACTIVATION_PAIRS[e.type];
  1676. var expectedActivationType = activationState.activationEvent.type;
  1677. // NOTE: Pointer events are tricky - https://patrickhlauke.github.io/touch/tests/results/
  1678. // Essentially, what we need to do here is decouple the deactivation UX from the actual
  1679. // deactivation state itself. This way, touch/pointer events in sequence do not trample one
  1680. // another.
  1681. var needsDeactivationUX = actualActivationType === expectedActivationType;
  1682. var needsActualDeactivation = needsDeactivationUX;
  1683. if (activationState.wasActivatedByPointer) {
  1684. needsActualDeactivation = e.type === 'mouseup';
  1685. }
  1686. var state = /** @type {!ActivationStateType} */_extends({}, activationState);
  1687. requestAnimationFrame(function () {
  1688. if (needsDeactivationUX) {
  1689. _this7.activationState_.hasDeactivationUXRun = true;
  1690. _this7.animateDeactivation_(e, state);
  1691. }
  1692. if (needsActualDeactivation) {
  1693. _this7.activationState_ = _this7.defaultActivationState_();
  1694. }
  1695. });
  1696. }
  1697. }, {
  1698. key: 'deactivate',
  1699. value: function deactivate() {
  1700. this.deactivate_(null);
  1701. }
  1702. /**
  1703. * @param {Event} e
  1704. * @param {!ActivationStateType} options
  1705. * @private
  1706. */
  1707. }, {
  1708. key: 'animateDeactivation_',
  1709. value: function animateDeactivation_(e, _ref) {
  1710. var wasActivatedByPointer = _ref.wasActivatedByPointer,
  1711. wasElementMadeActive = _ref.wasElementMadeActive;
  1712. var BG_FOCUSED = MDCRippleFoundation.cssClasses.BG_FOCUSED;
  1713. if (wasActivatedByPointer || wasElementMadeActive) {
  1714. // Remove class left over by element being focused
  1715. this.adapter_.removeClass(BG_FOCUSED);
  1716. this.runDeactivationUXLogicIfReady_();
  1717. }
  1718. }
  1719. }, {
  1720. key: 'destroy',
  1721. value: function destroy() {
  1722. var _this8 = this;
  1723. if (!this.isSupported_) {
  1724. return;
  1725. }
  1726. this.removeEventListeners_();
  1727. var _MDCRippleFoundation$5 = MDCRippleFoundation.cssClasses,
  1728. ROOT = _MDCRippleFoundation$5.ROOT,
  1729. UNBOUNDED = _MDCRippleFoundation$5.UNBOUNDED;
  1730. requestAnimationFrame(function () {
  1731. _this8.adapter_.removeClass(ROOT);
  1732. _this8.adapter_.removeClass(UNBOUNDED);
  1733. _this8.removeCssVars_();
  1734. });
  1735. }
  1736. /** @private */
  1737. }, {
  1738. key: 'removeEventListeners_',
  1739. value: function removeEventListeners_() {
  1740. var _this9 = this;
  1741. this.listenerInfos_.forEach(function (info) {
  1742. Object.keys(info).forEach(function (k) {
  1743. _this9.adapter_.deregisterInteractionHandler(info[k], _this9.listeners_[k]);
  1744. });
  1745. });
  1746. this.adapter_.deregisterResizeHandler(this.resizeHandler_);
  1747. }
  1748. /** @private */
  1749. }, {
  1750. key: 'removeCssVars_',
  1751. value: function removeCssVars_() {
  1752. var _this10 = this;
  1753. var strings = MDCRippleFoundation.strings;
  1754. Object.keys(strings).forEach(function (k) {
  1755. if (k.indexOf('VAR_') === 0) {
  1756. _this10.adapter_.updateCssVariable(strings[k], null);
  1757. }
  1758. });
  1759. }
  1760. }, {
  1761. key: 'layout',
  1762. value: function layout() {
  1763. var _this11 = this;
  1764. if (this.layoutFrame_) {
  1765. cancelAnimationFrame(this.layoutFrame_);
  1766. }
  1767. this.layoutFrame_ = requestAnimationFrame(function () {
  1768. _this11.layoutInternal_();
  1769. _this11.layoutFrame_ = 0;
  1770. });
  1771. }
  1772. /** @private */
  1773. }, {
  1774. key: 'layoutInternal_',
  1775. value: function layoutInternal_() {
  1776. this.frame_ = this.adapter_.computeBoundingRect();
  1777. var maxDim = Math.max(this.frame_.height, this.frame_.width);
  1778. var surfaceDiameter = Math.sqrt(Math.pow(this.frame_.width, 2) + Math.pow(this.frame_.height, 2));
  1779. // 60% of the largest dimension of the surface
  1780. this.initialSize_ = maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE;
  1781. // Diameter of the surface + 10px
  1782. this.maxRadius_ = surfaceDiameter + MDCRippleFoundation.numbers.PADDING;
  1783. this.fgScale_ = this.maxRadius_ / this.initialSize_;
  1784. this.xfDuration_ = 1000 * Math.sqrt(this.maxRadius_ / 1024);
  1785. this.updateLayoutCssVars_();
  1786. }
  1787. /** @private */
  1788. }, {
  1789. key: 'updateLayoutCssVars_',
  1790. value: function updateLayoutCssVars_() {
  1791. var _MDCRippleFoundation$6 = MDCRippleFoundation.strings,
  1792. VAR_SURFACE_WIDTH = _MDCRippleFoundation$6.VAR_SURFACE_WIDTH,
  1793. VAR_SURFACE_HEIGHT = _MDCRippleFoundation$6.VAR_SURFACE_HEIGHT,
  1794. VAR_FG_SIZE = _MDCRippleFoundation$6.VAR_FG_SIZE,
  1795. VAR_LEFT = _MDCRippleFoundation$6.VAR_LEFT,
  1796. VAR_TOP = _MDCRippleFoundation$6.VAR_TOP,
  1797. VAR_FG_SCALE = _MDCRippleFoundation$6.VAR_FG_SCALE;
  1798. this.adapter_.updateCssVariable(VAR_SURFACE_WIDTH, this.frame_.width + 'px');
  1799. this.adapter_.updateCssVariable(VAR_SURFACE_HEIGHT, this.frame_.height + 'px');
  1800. this.adapter_.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + 'px');
  1801. this.adapter_.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
  1802. if (this.adapter_.isUnbounded()) {
  1803. this.unboundedCoords_ = {
  1804. left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
  1805. top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
  1806. };
  1807. this.adapter_.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + 'px');
  1808. this.adapter_.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + 'px');
  1809. }
  1810. }
  1811. }]);
  1812. return MDCRippleFoundation;
  1813. }(__WEBPACK_IMPORTED_MODULE_0__material_base_foundation__["a" /* default */]);
  1814. /* harmony default export */ __webpack_exports__["a"] = (MDCRippleFoundation);
  1815. /***/ }),
  1816. /***/ 98:
  1817. /***/ (function(module, exports, __webpack_require__) {
  1818. module.exports = __webpack_require__(36);
  1819. /***/ })
  1820. /******/ });
  1821. });