mdc.checkbox.js 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define([], factory);
  13. else if(typeof exports === 'object')
  14. exports["checkbox"] = factory();
  15. else
  16. root["mdc"] = root["mdc"] || {}, root["mdc"]["checkbox"] = factory();
  17. })(this, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // define __esModule on exports
  61. /******/ __webpack_require__.r = function(exports) {
  62. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  63. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  64. /******/ }
  65. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  66. /******/ };
  67. /******/
  68. /******/ // create a fake namespace object
  69. /******/ // mode & 1: value is a module id, require it
  70. /******/ // mode & 2: merge all properties of value into the ns
  71. /******/ // mode & 4: return value when already ns object
  72. /******/ // mode & 8|1: behave like require
  73. /******/ __webpack_require__.t = function(value, mode) {
  74. /******/ if(mode & 1) value = __webpack_require__(value);
  75. /******/ if(mode & 8) return value;
  76. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  77. /******/ var ns = Object.create(null);
  78. /******/ __webpack_require__.r(ns);
  79. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  80. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  81. /******/ return ns;
  82. /******/ };
  83. /******/
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function getDefault() { return module['default']; } :
  88. /******/ function getModuleExports() { return module; };
  89. /******/ __webpack_require__.d(getter, 'a', getter);
  90. /******/ return getter;
  91. /******/ };
  92. /******/
  93. /******/ // Object.prototype.hasOwnProperty.call
  94. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  95. /******/
  96. /******/ // __webpack_public_path__
  97. /******/ __webpack_require__.p = "";
  98. /******/
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-checkbox/index.ts");
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ({
  105. /***/ "./packages/mdc-animation/util.ts":
  106. /*!****************************************!*\
  107. !*** ./packages/mdc-animation/util.ts ***!
  108. \****************************************/
  109. /*! no static exports found */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. /**
  113. * @license
  114. * Copyright 2016 Google Inc.
  115. *
  116. * Permission is hereby granted, free of charge, to any person obtaining a copy
  117. * of this software and associated documentation files (the "Software"), to deal
  118. * in the Software without restriction, including without limitation the rights
  119. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  120. * copies of the Software, and to permit persons to whom the Software is
  121. * furnished to do so, subject to the following conditions:
  122. *
  123. * The above copyright notice and this permission notice shall be included in
  124. * all copies or substantial portions of the Software.
  125. *
  126. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  127. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  128. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  129. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  130. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  131. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  132. * THE SOFTWARE.
  133. */
  134. Object.defineProperty(exports, "__esModule", { value: true });
  135. var cssPropertyNameMap = {
  136. animation: {
  137. prefixed: '-webkit-animation',
  138. standard: 'animation'
  139. },
  140. transform: {
  141. prefixed: '-webkit-transform',
  142. standard: 'transform'
  143. },
  144. transition: {
  145. prefixed: '-webkit-transition',
  146. standard: 'transition'
  147. }
  148. };
  149. var jsEventTypeMap = {
  150. animationend: {
  151. cssProperty: 'animation',
  152. prefixed: 'webkitAnimationEnd',
  153. standard: 'animationend'
  154. },
  155. animationiteration: {
  156. cssProperty: 'animation',
  157. prefixed: 'webkitAnimationIteration',
  158. standard: 'animationiteration'
  159. },
  160. animationstart: {
  161. cssProperty: 'animation',
  162. prefixed: 'webkitAnimationStart',
  163. standard: 'animationstart'
  164. },
  165. transitionend: {
  166. cssProperty: 'transition',
  167. prefixed: 'webkitTransitionEnd',
  168. standard: 'transitionend'
  169. }
  170. };
  171. function isWindow(windowObj) {
  172. return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
  173. }
  174. function getCorrectPropertyName(windowObj, cssProperty) {
  175. if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
  176. var el = windowObj.document.createElement('div');
  177. var _a = cssPropertyNameMap[cssProperty],
  178. standard = _a.standard,
  179. prefixed = _a.prefixed;
  180. var isStandard = standard in el.style;
  181. return isStandard ? standard : prefixed;
  182. }
  183. return cssProperty;
  184. }
  185. exports.getCorrectPropertyName = getCorrectPropertyName;
  186. function getCorrectEventName(windowObj, eventType) {
  187. if (isWindow(windowObj) && eventType in jsEventTypeMap) {
  188. var el = windowObj.document.createElement('div');
  189. var _a = jsEventTypeMap[eventType],
  190. standard = _a.standard,
  191. prefixed = _a.prefixed,
  192. cssProperty = _a.cssProperty;
  193. var isStandard = cssProperty in el.style;
  194. return isStandard ? standard : prefixed;
  195. }
  196. return eventType;
  197. }
  198. exports.getCorrectEventName = getCorrectEventName;
  199. /***/ }),
  200. /***/ "./packages/mdc-base/component.ts":
  201. /*!****************************************!*\
  202. !*** ./packages/mdc-base/component.ts ***!
  203. \****************************************/
  204. /*! no static exports found */
  205. /***/ (function(module, exports, __webpack_require__) {
  206. "use strict";
  207. /**
  208. * @license
  209. * Copyright 2016 Google Inc.
  210. *
  211. * Permission is hereby granted, free of charge, to any person obtaining a copy
  212. * of this software and associated documentation files (the "Software"), to deal
  213. * in the Software without restriction, including without limitation the rights
  214. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  215. * copies of the Software, and to permit persons to whom the Software is
  216. * furnished to do so, subject to the following conditions:
  217. *
  218. * The above copyright notice and this permission notice shall be included in
  219. * all copies or substantial portions of the Software.
  220. *
  221. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  222. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  223. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  224. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  225. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  226. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  227. * THE SOFTWARE.
  228. */
  229. var __read = this && this.__read || function (o, n) {
  230. var m = typeof Symbol === "function" && o[Symbol.iterator];
  231. if (!m) return o;
  232. var i = m.call(o),
  233. r,
  234. ar = [],
  235. e;
  236. try {
  237. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  238. ar.push(r.value);
  239. }
  240. } catch (error) {
  241. e = { error: error };
  242. } finally {
  243. try {
  244. if (r && !r.done && (m = i["return"])) m.call(i);
  245. } finally {
  246. if (e) throw e.error;
  247. }
  248. }
  249. return ar;
  250. };
  251. var __spread = this && this.__spread || function () {
  252. for (var ar = [], i = 0; i < arguments.length; i++) {
  253. ar = ar.concat(__read(arguments[i]));
  254. }return ar;
  255. };
  256. Object.defineProperty(exports, "__esModule", { value: true });
  257. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
  258. var MDCComponent = /** @class */function () {
  259. function MDCComponent(root, foundation) {
  260. var args = [];
  261. for (var _i = 2; _i < arguments.length; _i++) {
  262. args[_i - 2] = arguments[_i];
  263. }
  264. this.root_ = root;
  265. this.initialize.apply(this, __spread(args));
  266. // Note that we initialize foundation here and not within the constructor's default param so that
  267. // this.root_ is defined and can be used within the foundation class.
  268. this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
  269. this.foundation_.init();
  270. this.initialSyncWithDOM();
  271. }
  272. MDCComponent.attachTo = function (root) {
  273. // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
  274. // returns an instantiated component with its root set to that element. Also note that in the cases of
  275. // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
  276. // from getDefaultFoundation().
  277. return new MDCComponent(root, new foundation_1.MDCFoundation({}));
  278. };
  279. /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
  280. MDCComponent.prototype.initialize = function () {
  281. var _args = [];
  282. for (var _i = 0; _i < arguments.length; _i++) {
  283. _args[_i] = arguments[_i];
  284. }
  285. // Subclasses can override this to do any additional setup work that would be considered part of a
  286. // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
  287. // initialized. Any additional arguments besides root and foundation will be passed in here.
  288. };
  289. MDCComponent.prototype.getDefaultFoundation = function () {
  290. // Subclasses must override this method to return a properly configured foundation class for the
  291. // component.
  292. throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
  293. };
  294. MDCComponent.prototype.initialSyncWithDOM = function () {
  295. // Subclasses should override this method if they need to perform work to synchronize with a host DOM
  296. // object. An example of this would be a form control wrapper that needs to synchronize its internal state
  297. // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
  298. // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
  299. };
  300. MDCComponent.prototype.destroy = function () {
  301. // Subclasses may implement this method to release any resources / deregister any listeners they have
  302. // attached. An example of this might be deregistering a resize event from the window object.
  303. this.foundation_.destroy();
  304. };
  305. MDCComponent.prototype.listen = function (evtType, handler, options) {
  306. this.root_.addEventListener(evtType, handler, options);
  307. };
  308. MDCComponent.prototype.unlisten = function (evtType, handler, options) {
  309. this.root_.removeEventListener(evtType, handler, options);
  310. };
  311. /**
  312. * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
  313. */
  314. MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
  315. if (shouldBubble === void 0) {
  316. shouldBubble = false;
  317. }
  318. var evt;
  319. if (typeof CustomEvent === 'function') {
  320. evt = new CustomEvent(evtType, {
  321. bubbles: shouldBubble,
  322. detail: evtData
  323. });
  324. } else {
  325. evt = document.createEvent('CustomEvent');
  326. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  327. }
  328. this.root_.dispatchEvent(evt);
  329. };
  330. return MDCComponent;
  331. }();
  332. exports.MDCComponent = MDCComponent;
  333. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  334. exports.default = MDCComponent;
  335. /***/ }),
  336. /***/ "./packages/mdc-base/foundation.ts":
  337. /*!*****************************************!*\
  338. !*** ./packages/mdc-base/foundation.ts ***!
  339. \*****************************************/
  340. /*! no static exports found */
  341. /***/ (function(module, exports, __webpack_require__) {
  342. "use strict";
  343. /**
  344. * @license
  345. * Copyright 2016 Google Inc.
  346. *
  347. * Permission is hereby granted, free of charge, to any person obtaining a copy
  348. * of this software and associated documentation files (the "Software"), to deal
  349. * in the Software without restriction, including without limitation the rights
  350. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  351. * copies of the Software, and to permit persons to whom the Software is
  352. * furnished to do so, subject to the following conditions:
  353. *
  354. * The above copyright notice and this permission notice shall be included in
  355. * all copies or substantial portions of the Software.
  356. *
  357. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  358. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  359. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  360. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  361. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  362. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  363. * THE SOFTWARE.
  364. */
  365. Object.defineProperty(exports, "__esModule", { value: true });
  366. var MDCFoundation = /** @class */function () {
  367. function MDCFoundation(adapter) {
  368. if (adapter === void 0) {
  369. adapter = {};
  370. }
  371. this.adapter_ = adapter;
  372. }
  373. Object.defineProperty(MDCFoundation, "cssClasses", {
  374. get: function get() {
  375. // Classes extending MDCFoundation should implement this method to return an object which exports every
  376. // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
  377. return {};
  378. },
  379. enumerable: true,
  380. configurable: true
  381. });
  382. Object.defineProperty(MDCFoundation, "strings", {
  383. get: function get() {
  384. // Classes extending MDCFoundation should implement this method to return an object which exports all
  385. // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
  386. return {};
  387. },
  388. enumerable: true,
  389. configurable: true
  390. });
  391. Object.defineProperty(MDCFoundation, "numbers", {
  392. get: function get() {
  393. // Classes extending MDCFoundation should implement this method to return an object which exports all
  394. // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
  395. return {};
  396. },
  397. enumerable: true,
  398. configurable: true
  399. });
  400. Object.defineProperty(MDCFoundation, "defaultAdapter", {
  401. get: function get() {
  402. // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
  403. // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
  404. // validation.
  405. return {};
  406. },
  407. enumerable: true,
  408. configurable: true
  409. });
  410. MDCFoundation.prototype.init = function () {
  411. // Subclasses should override this method to perform initialization routines (registering events, etc.)
  412. };
  413. MDCFoundation.prototype.destroy = function () {
  414. // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
  415. };
  416. return MDCFoundation;
  417. }();
  418. exports.MDCFoundation = MDCFoundation;
  419. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  420. exports.default = MDCFoundation;
  421. /***/ }),
  422. /***/ "./packages/mdc-checkbox/component.ts":
  423. /*!********************************************!*\
  424. !*** ./packages/mdc-checkbox/component.ts ***!
  425. \********************************************/
  426. /*! no static exports found */
  427. /***/ (function(module, exports, __webpack_require__) {
  428. "use strict";
  429. /**
  430. * @license
  431. * Copyright 2016 Google Inc.
  432. *
  433. * Permission is hereby granted, free of charge, to any person obtaining a copy
  434. * of this software and associated documentation files (the "Software"), to deal
  435. * in the Software without restriction, including without limitation the rights
  436. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  437. * copies of the Software, and to permit persons to whom the Software is
  438. * furnished to do so, subject to the following conditions:
  439. *
  440. * The above copyright notice and this permission notice shall be included in
  441. * all copies or substantial portions of the Software.
  442. *
  443. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  444. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  445. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  446. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  447. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  448. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  449. * THE SOFTWARE.
  450. */
  451. var __extends = this && this.__extends || function () {
  452. var _extendStatics = function extendStatics(d, b) {
  453. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  454. d.__proto__ = b;
  455. } || function (d, b) {
  456. for (var p in b) {
  457. if (b.hasOwnProperty(p)) d[p] = b[p];
  458. }
  459. };
  460. return _extendStatics(d, b);
  461. };
  462. return function (d, b) {
  463. _extendStatics(d, b);
  464. function __() {
  465. this.constructor = d;
  466. }
  467. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  468. };
  469. }();
  470. var __assign = this && this.__assign || function () {
  471. __assign = Object.assign || function (t) {
  472. for (var s, i = 1, n = arguments.length; i < n; i++) {
  473. s = arguments[i];
  474. for (var p in s) {
  475. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  476. }
  477. }
  478. return t;
  479. };
  480. return __assign.apply(this, arguments);
  481. };
  482. Object.defineProperty(exports, "__esModule", { value: true });
  483. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  484. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  485. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  486. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  487. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  488. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  489. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts");
  490. var CB_PROTO_PROPS = ['checked', 'indeterminate'];
  491. var MDCCheckbox = /** @class */function (_super) {
  492. __extends(MDCCheckbox, _super);
  493. function MDCCheckbox() {
  494. var _this = _super !== null && _super.apply(this, arguments) || this;
  495. _this.ripple_ = _this.createRipple_();
  496. return _this;
  497. }
  498. MDCCheckbox.attachTo = function (root) {
  499. return new MDCCheckbox(root);
  500. };
  501. Object.defineProperty(MDCCheckbox.prototype, "ripple", {
  502. get: function get() {
  503. return this.ripple_;
  504. },
  505. enumerable: true,
  506. configurable: true
  507. });
  508. Object.defineProperty(MDCCheckbox.prototype, "checked", {
  509. get: function get() {
  510. return this.nativeControl_.checked;
  511. },
  512. set: function set(checked) {
  513. this.nativeControl_.checked = checked;
  514. },
  515. enumerable: true,
  516. configurable: true
  517. });
  518. Object.defineProperty(MDCCheckbox.prototype, "indeterminate", {
  519. get: function get() {
  520. return this.nativeControl_.indeterminate;
  521. },
  522. set: function set(indeterminate) {
  523. this.nativeControl_.indeterminate = indeterminate;
  524. },
  525. enumerable: true,
  526. configurable: true
  527. });
  528. Object.defineProperty(MDCCheckbox.prototype, "disabled", {
  529. get: function get() {
  530. return this.nativeControl_.disabled;
  531. },
  532. set: function set(disabled) {
  533. this.foundation_.setDisabled(disabled);
  534. },
  535. enumerable: true,
  536. configurable: true
  537. });
  538. Object.defineProperty(MDCCheckbox.prototype, "value", {
  539. get: function get() {
  540. return this.nativeControl_.value;
  541. },
  542. set: function set(value) {
  543. this.nativeControl_.value = value;
  544. },
  545. enumerable: true,
  546. configurable: true
  547. });
  548. MDCCheckbox.prototype.initialSyncWithDOM = function () {
  549. var _this = this;
  550. this.handleChange_ = function () {
  551. return _this.foundation_.handleChange();
  552. };
  553. this.handleAnimationEnd_ = function () {
  554. return _this.foundation_.handleAnimationEnd();
  555. };
  556. this.nativeControl_.addEventListener('change', this.handleChange_);
  557. this.listen(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_);
  558. this.installPropertyChangeHooks_();
  559. };
  560. MDCCheckbox.prototype.destroy = function () {
  561. this.ripple_.destroy();
  562. this.nativeControl_.removeEventListener('change', this.handleChange_);
  563. this.unlisten(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_);
  564. this.uninstallPropertyChangeHooks_();
  565. _super.prototype.destroy.call(this);
  566. };
  567. MDCCheckbox.prototype.getDefaultFoundation = function () {
  568. var _this = this;
  569. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  570. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  571. var adapter = {
  572. addClass: function addClass(className) {
  573. return _this.root_.classList.add(className);
  574. },
  575. forceLayout: function forceLayout() {
  576. return _this.root_.offsetWidth;
  577. },
  578. hasNativeControl: function hasNativeControl() {
  579. return !!_this.nativeControl_;
  580. },
  581. isAttachedToDOM: function isAttachedToDOM() {
  582. return Boolean(_this.root_.parentNode);
  583. },
  584. isChecked: function isChecked() {
  585. return _this.checked;
  586. },
  587. isIndeterminate: function isIndeterminate() {
  588. return _this.indeterminate;
  589. },
  590. removeClass: function removeClass(className) {
  591. return _this.root_.classList.remove(className);
  592. },
  593. removeNativeControlAttr: function removeNativeControlAttr(attr) {
  594. return _this.nativeControl_.removeAttribute(attr);
  595. },
  596. setNativeControlAttr: function setNativeControlAttr(attr, value) {
  597. return _this.nativeControl_.setAttribute(attr, value);
  598. },
  599. setNativeControlDisabled: function setNativeControlDisabled(disabled) {
  600. return _this.nativeControl_.disabled = disabled;
  601. }
  602. };
  603. return new foundation_2.MDCCheckboxFoundation(adapter);
  604. };
  605. MDCCheckbox.prototype.createRipple_ = function () {
  606. var _this = this;
  607. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  608. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  609. var adapter = __assign({}, component_2.MDCRipple.createAdapter(this), { deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  610. return _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
  611. }, isSurfaceActive: function isSurfaceActive() {
  612. return ponyfill_1.matches(_this.nativeControl_, ':active');
  613. }, isUnbounded: function isUnbounded() {
  614. return true;
  615. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  616. return _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
  617. } });
  618. return new component_2.MDCRipple(this.root_, new foundation_1.MDCRippleFoundation(adapter));
  619. };
  620. MDCCheckbox.prototype.installPropertyChangeHooks_ = function () {
  621. var _this = this;
  622. var nativeCb = this.nativeControl_;
  623. var cbProto = Object.getPrototypeOf(nativeCb);
  624. CB_PROTO_PROPS.forEach(function (controlState) {
  625. var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
  626. // We have to check for this descriptor, since some browsers (Safari) don't support its return.
  627. // See: https://bugs.webkit.org/show_bug.cgi?id=49739
  628. if (!validDescriptor(desc)) {
  629. return;
  630. }
  631. // Type cast is needed for compatibility with Closure Compiler.
  632. var nativeGetter = desc.get;
  633. var nativeCbDesc = {
  634. configurable: desc.configurable,
  635. enumerable: desc.enumerable,
  636. get: nativeGetter,
  637. set: function set(state) {
  638. desc.set.call(nativeCb, state);
  639. _this.foundation_.handleChange();
  640. }
  641. };
  642. Object.defineProperty(nativeCb, controlState, nativeCbDesc);
  643. });
  644. };
  645. MDCCheckbox.prototype.uninstallPropertyChangeHooks_ = function () {
  646. var nativeCb = this.nativeControl_;
  647. var cbProto = Object.getPrototypeOf(nativeCb);
  648. CB_PROTO_PROPS.forEach(function (controlState) {
  649. var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
  650. if (!validDescriptor(desc)) {
  651. return;
  652. }
  653. Object.defineProperty(nativeCb, controlState, desc);
  654. });
  655. };
  656. Object.defineProperty(MDCCheckbox.prototype, "nativeControl_", {
  657. get: function get() {
  658. var NATIVE_CONTROL_SELECTOR = foundation_2.MDCCheckboxFoundation.strings.NATIVE_CONTROL_SELECTOR;
  659. var el = this.root_.querySelector(NATIVE_CONTROL_SELECTOR);
  660. if (!el) {
  661. throw new Error("Checkbox component requires a " + NATIVE_CONTROL_SELECTOR + " element");
  662. }
  663. return el;
  664. },
  665. enumerable: true,
  666. configurable: true
  667. });
  668. return MDCCheckbox;
  669. }(component_1.MDCComponent);
  670. exports.MDCCheckbox = MDCCheckbox;
  671. function validDescriptor(inputPropDesc) {
  672. return !!inputPropDesc && typeof inputPropDesc.set === 'function';
  673. }
  674. /***/ }),
  675. /***/ "./packages/mdc-checkbox/constants.ts":
  676. /*!********************************************!*\
  677. !*** ./packages/mdc-checkbox/constants.ts ***!
  678. \********************************************/
  679. /*! no static exports found */
  680. /***/ (function(module, exports, __webpack_require__) {
  681. "use strict";
  682. /**
  683. * @license
  684. * Copyright 2016 Google Inc.
  685. *
  686. * Permission is hereby granted, free of charge, to any person obtaining a copy
  687. * of this software and associated documentation files (the "Software"), to deal
  688. * in the Software without restriction, including without limitation the rights
  689. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  690. * copies of the Software, and to permit persons to whom the Software is
  691. * furnished to do so, subject to the following conditions:
  692. *
  693. * The above copyright notice and this permission notice shall be included in
  694. * all copies or substantial portions of the Software.
  695. *
  696. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  697. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  698. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  699. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  700. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  701. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  702. * THE SOFTWARE.
  703. */
  704. Object.defineProperty(exports, "__esModule", { value: true });
  705. exports.cssClasses = {
  706. ANIM_CHECKED_INDETERMINATE: 'mdc-checkbox--anim-checked-indeterminate',
  707. ANIM_CHECKED_UNCHECKED: 'mdc-checkbox--anim-checked-unchecked',
  708. ANIM_INDETERMINATE_CHECKED: 'mdc-checkbox--anim-indeterminate-checked',
  709. ANIM_INDETERMINATE_UNCHECKED: 'mdc-checkbox--anim-indeterminate-unchecked',
  710. ANIM_UNCHECKED_CHECKED: 'mdc-checkbox--anim-unchecked-checked',
  711. ANIM_UNCHECKED_INDETERMINATE: 'mdc-checkbox--anim-unchecked-indeterminate',
  712. BACKGROUND: 'mdc-checkbox__background',
  713. CHECKED: 'mdc-checkbox--checked',
  714. CHECKMARK: 'mdc-checkbox__checkmark',
  715. CHECKMARK_PATH: 'mdc-checkbox__checkmark-path',
  716. DISABLED: 'mdc-checkbox--disabled',
  717. INDETERMINATE: 'mdc-checkbox--indeterminate',
  718. MIXEDMARK: 'mdc-checkbox__mixedmark',
  719. NATIVE_CONTROL: 'mdc-checkbox__native-control',
  720. ROOT: 'mdc-checkbox',
  721. SELECTED: 'mdc-checkbox--selected',
  722. UPGRADED: 'mdc-checkbox--upgraded'
  723. };
  724. exports.strings = {
  725. ARIA_CHECKED_ATTR: 'aria-checked',
  726. ARIA_CHECKED_INDETERMINATE_VALUE: 'mixed',
  727. NATIVE_CONTROL_SELECTOR: '.mdc-checkbox__native-control',
  728. TRANSITION_STATE_CHECKED: 'checked',
  729. TRANSITION_STATE_INDETERMINATE: 'indeterminate',
  730. TRANSITION_STATE_INIT: 'init',
  731. TRANSITION_STATE_UNCHECKED: 'unchecked'
  732. };
  733. exports.numbers = {
  734. ANIM_END_LATCH_MS: 250
  735. };
  736. /***/ }),
  737. /***/ "./packages/mdc-checkbox/foundation.ts":
  738. /*!*********************************************!*\
  739. !*** ./packages/mdc-checkbox/foundation.ts ***!
  740. \*********************************************/
  741. /*! no static exports found */
  742. /***/ (function(module, exports, __webpack_require__) {
  743. "use strict";
  744. /**
  745. * @license
  746. * Copyright 2016 Google Inc.
  747. *
  748. * Permission is hereby granted, free of charge, to any person obtaining a copy
  749. * of this software and associated documentation files (the "Software"), to deal
  750. * in the Software without restriction, including without limitation the rights
  751. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  752. * copies of the Software, and to permit persons to whom the Software is
  753. * furnished to do so, subject to the following conditions:
  754. *
  755. * The above copyright notice and this permission notice shall be included in
  756. * all copies or substantial portions of the Software.
  757. *
  758. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  759. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  760. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  761. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  762. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  763. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  764. * THE SOFTWARE.
  765. */
  766. var __extends = this && this.__extends || function () {
  767. var _extendStatics = function extendStatics(d, b) {
  768. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  769. d.__proto__ = b;
  770. } || function (d, b) {
  771. for (var p in b) {
  772. if (b.hasOwnProperty(p)) d[p] = b[p];
  773. }
  774. };
  775. return _extendStatics(d, b);
  776. };
  777. return function (d, b) {
  778. _extendStatics(d, b);
  779. function __() {
  780. this.constructor = d;
  781. }
  782. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  783. };
  784. }();
  785. var __assign = this && this.__assign || function () {
  786. __assign = Object.assign || function (t) {
  787. for (var s, i = 1, n = arguments.length; i < n; i++) {
  788. s = arguments[i];
  789. for (var p in s) {
  790. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  791. }
  792. }
  793. return t;
  794. };
  795. return __assign.apply(this, arguments);
  796. };
  797. Object.defineProperty(exports, "__esModule", { value: true });
  798. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  799. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts");
  800. var MDCCheckboxFoundation = /** @class */function (_super) {
  801. __extends(MDCCheckboxFoundation, _super);
  802. function MDCCheckboxFoundation(adapter) {
  803. var _this = _super.call(this, __assign({}, MDCCheckboxFoundation.defaultAdapter, adapter)) || this;
  804. _this.currentCheckState_ = constants_1.strings.TRANSITION_STATE_INIT;
  805. _this.currentAnimationClass_ = '';
  806. _this.animEndLatchTimer_ = 0;
  807. _this.enableAnimationEndHandler_ = false;
  808. return _this;
  809. }
  810. Object.defineProperty(MDCCheckboxFoundation, "cssClasses", {
  811. get: function get() {
  812. return constants_1.cssClasses;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(MDCCheckboxFoundation, "strings", {
  818. get: function get() {
  819. return constants_1.strings;
  820. },
  821. enumerable: true,
  822. configurable: true
  823. });
  824. Object.defineProperty(MDCCheckboxFoundation, "numbers", {
  825. get: function get() {
  826. return constants_1.numbers;
  827. },
  828. enumerable: true,
  829. configurable: true
  830. });
  831. Object.defineProperty(MDCCheckboxFoundation, "defaultAdapter", {
  832. get: function get() {
  833. return {
  834. addClass: function addClass() {
  835. return undefined;
  836. },
  837. forceLayout: function forceLayout() {
  838. return undefined;
  839. },
  840. hasNativeControl: function hasNativeControl() {
  841. return false;
  842. },
  843. isAttachedToDOM: function isAttachedToDOM() {
  844. return false;
  845. },
  846. isChecked: function isChecked() {
  847. return false;
  848. },
  849. isIndeterminate: function isIndeterminate() {
  850. return false;
  851. },
  852. removeClass: function removeClass() {
  853. return undefined;
  854. },
  855. removeNativeControlAttr: function removeNativeControlAttr() {
  856. return undefined;
  857. },
  858. setNativeControlAttr: function setNativeControlAttr() {
  859. return undefined;
  860. },
  861. setNativeControlDisabled: function setNativeControlDisabled() {
  862. return undefined;
  863. }
  864. };
  865. },
  866. enumerable: true,
  867. configurable: true
  868. });
  869. MDCCheckboxFoundation.prototype.init = function () {
  870. this.currentCheckState_ = this.determineCheckState_();
  871. this.updateAriaChecked_();
  872. this.adapter_.addClass(constants_1.cssClasses.UPGRADED);
  873. };
  874. MDCCheckboxFoundation.prototype.destroy = function () {
  875. clearTimeout(this.animEndLatchTimer_);
  876. };
  877. MDCCheckboxFoundation.prototype.setDisabled = function (disabled) {
  878. this.adapter_.setNativeControlDisabled(disabled);
  879. if (disabled) {
  880. this.adapter_.addClass(constants_1.cssClasses.DISABLED);
  881. } else {
  882. this.adapter_.removeClass(constants_1.cssClasses.DISABLED);
  883. }
  884. };
  885. /**
  886. * Handles the animationend event for the checkbox
  887. */
  888. MDCCheckboxFoundation.prototype.handleAnimationEnd = function () {
  889. var _this = this;
  890. if (!this.enableAnimationEndHandler_) {
  891. return;
  892. }
  893. clearTimeout(this.animEndLatchTimer_);
  894. this.animEndLatchTimer_ = setTimeout(function () {
  895. _this.adapter_.removeClass(_this.currentAnimationClass_);
  896. _this.enableAnimationEndHandler_ = false;
  897. }, constants_1.numbers.ANIM_END_LATCH_MS);
  898. };
  899. /**
  900. * Handles the change event for the checkbox
  901. */
  902. MDCCheckboxFoundation.prototype.handleChange = function () {
  903. this.transitionCheckState_();
  904. };
  905. MDCCheckboxFoundation.prototype.transitionCheckState_ = function () {
  906. if (!this.adapter_.hasNativeControl()) {
  907. return;
  908. }
  909. var oldState = this.currentCheckState_;
  910. var newState = this.determineCheckState_();
  911. if (oldState === newState) {
  912. return;
  913. }
  914. this.updateAriaChecked_();
  915. var TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
  916. var SELECTED = constants_1.cssClasses.SELECTED;
  917. if (newState === TRANSITION_STATE_UNCHECKED) {
  918. this.adapter_.removeClass(SELECTED);
  919. } else {
  920. this.adapter_.addClass(SELECTED);
  921. }
  922. // Check to ensure that there isn't a previously existing animation class, in case for example
  923. // the user interacted with the checkbox before the animation was finished.
  924. if (this.currentAnimationClass_.length > 0) {
  925. clearTimeout(this.animEndLatchTimer_);
  926. this.adapter_.forceLayout();
  927. this.adapter_.removeClass(this.currentAnimationClass_);
  928. }
  929. this.currentAnimationClass_ = this.getTransitionAnimationClass_(oldState, newState);
  930. this.currentCheckState_ = newState;
  931. // Check for parentNode so that animations are only run when the element is attached
  932. // to the DOM.
  933. if (this.adapter_.isAttachedToDOM() && this.currentAnimationClass_.length > 0) {
  934. this.adapter_.addClass(this.currentAnimationClass_);
  935. this.enableAnimationEndHandler_ = true;
  936. }
  937. };
  938. MDCCheckboxFoundation.prototype.determineCheckState_ = function () {
  939. var TRANSITION_STATE_INDETERMINATE = constants_1.strings.TRANSITION_STATE_INDETERMINATE,
  940. TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
  941. TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
  942. if (this.adapter_.isIndeterminate()) {
  943. return TRANSITION_STATE_INDETERMINATE;
  944. }
  945. return this.adapter_.isChecked() ? TRANSITION_STATE_CHECKED : TRANSITION_STATE_UNCHECKED;
  946. };
  947. MDCCheckboxFoundation.prototype.getTransitionAnimationClass_ = function (oldState, newState) {
  948. var TRANSITION_STATE_INIT = constants_1.strings.TRANSITION_STATE_INIT,
  949. TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
  950. TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
  951. var _a = MDCCheckboxFoundation.cssClasses,
  952. ANIM_UNCHECKED_CHECKED = _a.ANIM_UNCHECKED_CHECKED,
  953. ANIM_UNCHECKED_INDETERMINATE = _a.ANIM_UNCHECKED_INDETERMINATE,
  954. ANIM_CHECKED_UNCHECKED = _a.ANIM_CHECKED_UNCHECKED,
  955. ANIM_CHECKED_INDETERMINATE = _a.ANIM_CHECKED_INDETERMINATE,
  956. ANIM_INDETERMINATE_CHECKED = _a.ANIM_INDETERMINATE_CHECKED,
  957. ANIM_INDETERMINATE_UNCHECKED = _a.ANIM_INDETERMINATE_UNCHECKED;
  958. switch (oldState) {
  959. case TRANSITION_STATE_INIT:
  960. if (newState === TRANSITION_STATE_UNCHECKED) {
  961. return '';
  962. }
  963. return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
  964. case TRANSITION_STATE_UNCHECKED:
  965. return newState === TRANSITION_STATE_CHECKED ? ANIM_UNCHECKED_CHECKED : ANIM_UNCHECKED_INDETERMINATE;
  966. case TRANSITION_STATE_CHECKED:
  967. return newState === TRANSITION_STATE_UNCHECKED ? ANIM_CHECKED_UNCHECKED : ANIM_CHECKED_INDETERMINATE;
  968. default:
  969. // TRANSITION_STATE_INDETERMINATE
  970. return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
  971. }
  972. };
  973. MDCCheckboxFoundation.prototype.updateAriaChecked_ = function () {
  974. // Ensure aria-checked is set to mixed if checkbox is in indeterminate state.
  975. if (this.adapter_.isIndeterminate()) {
  976. this.adapter_.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, constants_1.strings.ARIA_CHECKED_INDETERMINATE_VALUE);
  977. } else {
  978. // The on/off state does not need to keep track of aria-checked, since
  979. // the screenreader uses the checked property on the checkbox element.
  980. this.adapter_.removeNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR);
  981. }
  982. };
  983. return MDCCheckboxFoundation;
  984. }(foundation_1.MDCFoundation);
  985. exports.MDCCheckboxFoundation = MDCCheckboxFoundation;
  986. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  987. exports.default = MDCCheckboxFoundation;
  988. /***/ }),
  989. /***/ "./packages/mdc-checkbox/index.ts":
  990. /*!****************************************!*\
  991. !*** ./packages/mdc-checkbox/index.ts ***!
  992. \****************************************/
  993. /*! no static exports found */
  994. /***/ (function(module, exports, __webpack_require__) {
  995. "use strict";
  996. /**
  997. * @license
  998. * Copyright 2019 Google Inc.
  999. *
  1000. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1001. * of this software and associated documentation files (the "Software"), to deal
  1002. * in the Software without restriction, including without limitation the rights
  1003. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1004. * copies of the Software, and to permit persons to whom the Software is
  1005. * furnished to do so, subject to the following conditions:
  1006. *
  1007. * The above copyright notice and this permission notice shall be included in
  1008. * all copies or substantial portions of the Software.
  1009. *
  1010. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1011. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1012. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1013. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1014. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1015. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1016. * THE SOFTWARE.
  1017. */
  1018. function __export(m) {
  1019. for (var p in m) {
  1020. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1021. }
  1022. }
  1023. Object.defineProperty(exports, "__esModule", { value: true });
  1024. __export(__webpack_require__(/*! ./component */ "./packages/mdc-checkbox/component.ts"));
  1025. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts"));
  1026. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts"));
  1027. /***/ }),
  1028. /***/ "./packages/mdc-dom/events.ts":
  1029. /*!************************************!*\
  1030. !*** ./packages/mdc-dom/events.ts ***!
  1031. \************************************/
  1032. /*! no static exports found */
  1033. /***/ (function(module, exports, __webpack_require__) {
  1034. "use strict";
  1035. /**
  1036. * @license
  1037. * Copyright 2019 Google Inc.
  1038. *
  1039. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1040. * of this software and associated documentation files (the "Software"), to deal
  1041. * in the Software without restriction, including without limitation the rights
  1042. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1043. * copies of the Software, and to permit persons to whom the Software is
  1044. * furnished to do so, subject to the following conditions:
  1045. *
  1046. * The above copyright notice and this permission notice shall be included in
  1047. * all copies or substantial portions of the Software.
  1048. *
  1049. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1050. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1051. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1052. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1053. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1054. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1055. * THE SOFTWARE.
  1056. */
  1057. Object.defineProperty(exports, "__esModule", { value: true });
  1058. /**
  1059. * Determine whether the current browser supports passive event listeners, and
  1060. * if so, use them.
  1061. */
  1062. function applyPassive(globalObj) {
  1063. if (globalObj === void 0) {
  1064. globalObj = window;
  1065. }
  1066. return supportsPassiveOption(globalObj) ? { passive: true } : false;
  1067. }
  1068. exports.applyPassive = applyPassive;
  1069. function supportsPassiveOption(globalObj) {
  1070. if (globalObj === void 0) {
  1071. globalObj = window;
  1072. }
  1073. // See
  1074. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
  1075. var passiveSupported = false;
  1076. try {
  1077. var options = {
  1078. // This function will be called when the browser
  1079. // attempts to access the passive property.
  1080. get passive() {
  1081. passiveSupported = true;
  1082. return false;
  1083. }
  1084. };
  1085. var handler = function handler() {};
  1086. globalObj.document.addEventListener('test', handler, options);
  1087. globalObj.document.removeEventListener('test', handler, options);
  1088. } catch (err) {
  1089. passiveSupported = false;
  1090. }
  1091. return passiveSupported;
  1092. }
  1093. /***/ }),
  1094. /***/ "./packages/mdc-dom/ponyfill.ts":
  1095. /*!**************************************!*\
  1096. !*** ./packages/mdc-dom/ponyfill.ts ***!
  1097. \**************************************/
  1098. /*! no static exports found */
  1099. /***/ (function(module, exports, __webpack_require__) {
  1100. "use strict";
  1101. /**
  1102. * @license
  1103. * Copyright 2018 Google Inc.
  1104. *
  1105. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1106. * of this software and associated documentation files (the "Software"), to deal
  1107. * in the Software without restriction, including without limitation the rights
  1108. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1109. * copies of the Software, and to permit persons to whom the Software is
  1110. * furnished to do so, subject to the following conditions:
  1111. *
  1112. * The above copyright notice and this permission notice shall be included in
  1113. * all copies or substantial portions of the Software.
  1114. *
  1115. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1116. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1117. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1118. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1119. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1120. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1121. * THE SOFTWARE.
  1122. */
  1123. Object.defineProperty(exports, "__esModule", { value: true });
  1124. /**
  1125. * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
  1126. * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
  1127. */
  1128. function closest(element, selector) {
  1129. if (element.closest) {
  1130. return element.closest(selector);
  1131. }
  1132. var el = element;
  1133. while (el) {
  1134. if (matches(el, selector)) {
  1135. return el;
  1136. }
  1137. el = el.parentElement;
  1138. }
  1139. return null;
  1140. }
  1141. exports.closest = closest;
  1142. function matches(element, selector) {
  1143. var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
  1144. return nativeMatches.call(element, selector);
  1145. }
  1146. exports.matches = matches;
  1147. /**
  1148. * Used to compute the estimated scroll width of elements. When an element is
  1149. * hidden due to display: none; being applied to a parent element, the width is
  1150. * returned as 0. However, the element will have a true width once no longer
  1151. * inside a display: none context. This method computes an estimated width when
  1152. * the element is hidden or returns the true width when the element is visble.
  1153. * @param {Element} element the element whose width to estimate
  1154. */
  1155. function estimateScrollWidth(element) {
  1156. // Check the offsetParent. If the element inherits display: none from any
  1157. // parent, the offsetParent property will be null (see
  1158. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
  1159. // This check ensures we only clone the node when necessary.
  1160. var htmlEl = element;
  1161. if (htmlEl.offsetParent !== null) {
  1162. return htmlEl.scrollWidth;
  1163. }
  1164. var clone = htmlEl.cloneNode(true);
  1165. clone.style.setProperty('position', 'absolute');
  1166. clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
  1167. document.documentElement.appendChild(clone);
  1168. var scrollWidth = clone.scrollWidth;
  1169. document.documentElement.removeChild(clone);
  1170. return scrollWidth;
  1171. }
  1172. exports.estimateScrollWidth = estimateScrollWidth;
  1173. /***/ }),
  1174. /***/ "./packages/mdc-ripple/component.ts":
  1175. /*!******************************************!*\
  1176. !*** ./packages/mdc-ripple/component.ts ***!
  1177. \******************************************/
  1178. /*! no static exports found */
  1179. /***/ (function(module, exports, __webpack_require__) {
  1180. "use strict";
  1181. /**
  1182. * @license
  1183. * Copyright 2016 Google Inc.
  1184. *
  1185. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1186. * of this software and associated documentation files (the "Software"), to deal
  1187. * in the Software without restriction, including without limitation the rights
  1188. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1189. * copies of the Software, and to permit persons to whom the Software is
  1190. * furnished to do so, subject to the following conditions:
  1191. *
  1192. * The above copyright notice and this permission notice shall be included in
  1193. * all copies or substantial portions of the Software.
  1194. *
  1195. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1196. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1197. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1198. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1199. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1200. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1201. * THE SOFTWARE.
  1202. */
  1203. var __extends = this && this.__extends || function () {
  1204. var _extendStatics = function extendStatics(d, b) {
  1205. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  1206. d.__proto__ = b;
  1207. } || function (d, b) {
  1208. for (var p in b) {
  1209. if (b.hasOwnProperty(p)) d[p] = b[p];
  1210. }
  1211. };
  1212. return _extendStatics(d, b);
  1213. };
  1214. return function (d, b) {
  1215. _extendStatics(d, b);
  1216. function __() {
  1217. this.constructor = d;
  1218. }
  1219. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1220. };
  1221. }();
  1222. var __importStar = this && this.__importStar || function (mod) {
  1223. if (mod && mod.__esModule) return mod;
  1224. var result = {};
  1225. if (mod != null) for (var k in mod) {
  1226. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  1227. }result["default"] = mod;
  1228. return result;
  1229. };
  1230. Object.defineProperty(exports, "__esModule", { value: true });
  1231. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  1232. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  1233. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  1234. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
  1235. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
  1236. var MDCRipple = /** @class */function (_super) {
  1237. __extends(MDCRipple, _super);
  1238. function MDCRipple() {
  1239. var _this = _super !== null && _super.apply(this, arguments) || this;
  1240. _this.disabled = false;
  1241. return _this;
  1242. }
  1243. MDCRipple.attachTo = function (root, opts) {
  1244. if (opts === void 0) {
  1245. opts = { isUnbounded: undefined };
  1246. }
  1247. var ripple = new MDCRipple(root);
  1248. // Only override unbounded behavior if option is explicitly specified
  1249. if (opts.isUnbounded !== undefined) {
  1250. ripple.unbounded = opts.isUnbounded;
  1251. }
  1252. return ripple;
  1253. };
  1254. MDCRipple.createAdapter = function (instance) {
  1255. return {
  1256. addClass: function addClass(className) {
  1257. return instance.root_.classList.add(className);
  1258. },
  1259. browserSupportsCssVars: function browserSupportsCssVars() {
  1260. return util.supportsCssVariables(window);
  1261. },
  1262. computeBoundingRect: function computeBoundingRect() {
  1263. return instance.root_.getBoundingClientRect();
  1264. },
  1265. containsEventTarget: function containsEventTarget(target) {
  1266. return instance.root_.contains(target);
  1267. },
  1268. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
  1269. return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
  1270. },
  1271. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  1272. return instance.root_.removeEventListener(evtType, handler, events_1.applyPassive());
  1273. },
  1274. deregisterResizeHandler: function deregisterResizeHandler(handler) {
  1275. return window.removeEventListener('resize', handler);
  1276. },
  1277. getWindowPageOffset: function getWindowPageOffset() {
  1278. return { x: window.pageXOffset, y: window.pageYOffset };
  1279. },
  1280. isSurfaceActive: function isSurfaceActive() {
  1281. return ponyfill_1.matches(instance.root_, ':active');
  1282. },
  1283. isSurfaceDisabled: function isSurfaceDisabled() {
  1284. return Boolean(instance.disabled);
  1285. },
  1286. isUnbounded: function isUnbounded() {
  1287. return Boolean(instance.unbounded);
  1288. },
  1289. registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
  1290. return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
  1291. },
  1292. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  1293. return instance.root_.addEventListener(evtType, handler, events_1.applyPassive());
  1294. },
  1295. registerResizeHandler: function registerResizeHandler(handler) {
  1296. return window.addEventListener('resize', handler);
  1297. },
  1298. removeClass: function removeClass(className) {
  1299. return instance.root_.classList.remove(className);
  1300. },
  1301. updateCssVariable: function updateCssVariable(varName, value) {
  1302. return instance.root_.style.setProperty(varName, value);
  1303. }
  1304. };
  1305. };
  1306. Object.defineProperty(MDCRipple.prototype, "unbounded", {
  1307. get: function get() {
  1308. return Boolean(this.unbounded_);
  1309. },
  1310. set: function set(unbounded) {
  1311. this.unbounded_ = Boolean(unbounded);
  1312. this.setUnbounded_();
  1313. },
  1314. enumerable: true,
  1315. configurable: true
  1316. });
  1317. MDCRipple.prototype.activate = function () {
  1318. this.foundation_.activate();
  1319. };
  1320. MDCRipple.prototype.deactivate = function () {
  1321. this.foundation_.deactivate();
  1322. };
  1323. MDCRipple.prototype.layout = function () {
  1324. this.foundation_.layout();
  1325. };
  1326. MDCRipple.prototype.getDefaultFoundation = function () {
  1327. return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
  1328. };
  1329. MDCRipple.prototype.initialSyncWithDOM = function () {
  1330. var root = this.root_;
  1331. this.unbounded = 'mdcRippleIsUnbounded' in root.dataset;
  1332. };
  1333. /**
  1334. * Closure Compiler throws an access control error when directly accessing a
  1335. * protected or private property inside a getter/setter, like unbounded above.
  1336. * By accessing the protected property inside a method, we solve that problem.
  1337. * That's why this function exists.
  1338. */
  1339. MDCRipple.prototype.setUnbounded_ = function () {
  1340. this.foundation_.setUnbounded(Boolean(this.unbounded_));
  1341. };
  1342. return MDCRipple;
  1343. }(component_1.MDCComponent);
  1344. exports.MDCRipple = MDCRipple;
  1345. /***/ }),
  1346. /***/ "./packages/mdc-ripple/constants.ts":
  1347. /*!******************************************!*\
  1348. !*** ./packages/mdc-ripple/constants.ts ***!
  1349. \******************************************/
  1350. /*! no static exports found */
  1351. /***/ (function(module, exports, __webpack_require__) {
  1352. "use strict";
  1353. /**
  1354. * @license
  1355. * Copyright 2016 Google Inc.
  1356. *
  1357. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1358. * of this software and associated documentation files (the "Software"), to deal
  1359. * in the Software without restriction, including without limitation the rights
  1360. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1361. * copies of the Software, and to permit persons to whom the Software is
  1362. * furnished to do so, subject to the following conditions:
  1363. *
  1364. * The above copyright notice and this permission notice shall be included in
  1365. * all copies or substantial portions of the Software.
  1366. *
  1367. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1368. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1369. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1370. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1371. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1372. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1373. * THE SOFTWARE.
  1374. */
  1375. Object.defineProperty(exports, "__esModule", { value: true });
  1376. exports.cssClasses = {
  1377. // Ripple is a special case where the "root" component is really a "mixin" of sorts,
  1378. // given that it's an 'upgrade' to an existing component. That being said it is the root
  1379. // CSS class that all other CSS classes derive from.
  1380. BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
  1381. FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
  1382. FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
  1383. ROOT: 'mdc-ripple-upgraded',
  1384. UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
  1385. };
  1386. exports.strings = {
  1387. VAR_FG_SCALE: '--mdc-ripple-fg-scale',
  1388. VAR_FG_SIZE: '--mdc-ripple-fg-size',
  1389. VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
  1390. VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
  1391. VAR_LEFT: '--mdc-ripple-left',
  1392. VAR_TOP: '--mdc-ripple-top'
  1393. };
  1394. exports.numbers = {
  1395. DEACTIVATION_TIMEOUT_MS: 225,
  1396. FG_DEACTIVATION_MS: 150,
  1397. INITIAL_ORIGIN_SCALE: 0.6,
  1398. PADDING: 10,
  1399. TAP_DELAY_MS: 300
  1400. };
  1401. /***/ }),
  1402. /***/ "./packages/mdc-ripple/foundation.ts":
  1403. /*!*******************************************!*\
  1404. !*** ./packages/mdc-ripple/foundation.ts ***!
  1405. \*******************************************/
  1406. /*! no static exports found */
  1407. /***/ (function(module, exports, __webpack_require__) {
  1408. "use strict";
  1409. /**
  1410. * @license
  1411. * Copyright 2016 Google Inc.
  1412. *
  1413. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1414. * of this software and associated documentation files (the "Software"), to deal
  1415. * in the Software without restriction, including without limitation the rights
  1416. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1417. * copies of the Software, and to permit persons to whom the Software is
  1418. * furnished to do so, subject to the following conditions:
  1419. *
  1420. * The above copyright notice and this permission notice shall be included in
  1421. * all copies or substantial portions of the Software.
  1422. *
  1423. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1424. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1425. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1426. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1427. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1428. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1429. * THE SOFTWARE.
  1430. */
  1431. var __extends = this && this.__extends || function () {
  1432. var _extendStatics = function extendStatics(d, b) {
  1433. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  1434. d.__proto__ = b;
  1435. } || function (d, b) {
  1436. for (var p in b) {
  1437. if (b.hasOwnProperty(p)) d[p] = b[p];
  1438. }
  1439. };
  1440. return _extendStatics(d, b);
  1441. };
  1442. return function (d, b) {
  1443. _extendStatics(d, b);
  1444. function __() {
  1445. this.constructor = d;
  1446. }
  1447. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1448. };
  1449. }();
  1450. var __assign = this && this.__assign || function () {
  1451. __assign = Object.assign || function (t) {
  1452. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1453. s = arguments[i];
  1454. for (var p in s) {
  1455. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1456. }
  1457. }
  1458. return t;
  1459. };
  1460. return __assign.apply(this, arguments);
  1461. };
  1462. Object.defineProperty(exports, "__esModule", { value: true });
  1463. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  1464. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
  1465. var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
  1466. // Activation events registered on the root element of each instance for activation
  1467. var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
  1468. // Deactivation events registered on documentElement when a pointer-related down event occurs
  1469. var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
  1470. // simultaneous nested activations
  1471. var activatedTargets = [];
  1472. var MDCRippleFoundation = /** @class */function (_super) {
  1473. __extends(MDCRippleFoundation, _super);
  1474. function MDCRippleFoundation(adapter) {
  1475. var _this = _super.call(this, __assign({}, MDCRippleFoundation.defaultAdapter, adapter)) || this;
  1476. _this.activationAnimationHasEnded_ = false;
  1477. _this.activationTimer_ = 0;
  1478. _this.fgDeactivationRemovalTimer_ = 0;
  1479. _this.fgScale_ = '0';
  1480. _this.frame_ = { width: 0, height: 0 };
  1481. _this.initialSize_ = 0;
  1482. _this.layoutFrame_ = 0;
  1483. _this.maxRadius_ = 0;
  1484. _this.unboundedCoords_ = { left: 0, top: 0 };
  1485. _this.activationState_ = _this.defaultActivationState_();
  1486. _this.activationTimerCallback_ = function () {
  1487. _this.activationAnimationHasEnded_ = true;
  1488. _this.runDeactivationUXLogicIfReady_();
  1489. };
  1490. _this.activateHandler_ = function (e) {
  1491. return _this.activate_(e);
  1492. };
  1493. _this.deactivateHandler_ = function () {
  1494. return _this.deactivate_();
  1495. };
  1496. _this.focusHandler_ = function () {
  1497. return _this.handleFocus();
  1498. };
  1499. _this.blurHandler_ = function () {
  1500. return _this.handleBlur();
  1501. };
  1502. _this.resizeHandler_ = function () {
  1503. return _this.layout();
  1504. };
  1505. return _this;
  1506. }
  1507. Object.defineProperty(MDCRippleFoundation, "cssClasses", {
  1508. get: function get() {
  1509. return constants_1.cssClasses;
  1510. },
  1511. enumerable: true,
  1512. configurable: true
  1513. });
  1514. Object.defineProperty(MDCRippleFoundation, "strings", {
  1515. get: function get() {
  1516. return constants_1.strings;
  1517. },
  1518. enumerable: true,
  1519. configurable: true
  1520. });
  1521. Object.defineProperty(MDCRippleFoundation, "numbers", {
  1522. get: function get() {
  1523. return constants_1.numbers;
  1524. },
  1525. enumerable: true,
  1526. configurable: true
  1527. });
  1528. Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
  1529. get: function get() {
  1530. return {
  1531. addClass: function addClass() {
  1532. return undefined;
  1533. },
  1534. browserSupportsCssVars: function browserSupportsCssVars() {
  1535. return true;
  1536. },
  1537. computeBoundingRect: function computeBoundingRect() {
  1538. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  1539. },
  1540. containsEventTarget: function containsEventTarget() {
  1541. return true;
  1542. },
  1543. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
  1544. return undefined;
  1545. },
  1546. deregisterInteractionHandler: function deregisterInteractionHandler() {
  1547. return undefined;
  1548. },
  1549. deregisterResizeHandler: function deregisterResizeHandler() {
  1550. return undefined;
  1551. },
  1552. getWindowPageOffset: function getWindowPageOffset() {
  1553. return { x: 0, y: 0 };
  1554. },
  1555. isSurfaceActive: function isSurfaceActive() {
  1556. return true;
  1557. },
  1558. isSurfaceDisabled: function isSurfaceDisabled() {
  1559. return true;
  1560. },
  1561. isUnbounded: function isUnbounded() {
  1562. return true;
  1563. },
  1564. registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
  1565. return undefined;
  1566. },
  1567. registerInteractionHandler: function registerInteractionHandler() {
  1568. return undefined;
  1569. },
  1570. registerResizeHandler: function registerResizeHandler() {
  1571. return undefined;
  1572. },
  1573. removeClass: function removeClass() {
  1574. return undefined;
  1575. },
  1576. updateCssVariable: function updateCssVariable() {
  1577. return undefined;
  1578. }
  1579. };
  1580. },
  1581. enumerable: true,
  1582. configurable: true
  1583. });
  1584. MDCRippleFoundation.prototype.init = function () {
  1585. var _this = this;
  1586. var supportsPressRipple = this.supportsPressRipple_();
  1587. this.registerRootHandlers_(supportsPressRipple);
  1588. if (supportsPressRipple) {
  1589. var _a = MDCRippleFoundation.cssClasses,
  1590. ROOT_1 = _a.ROOT,
  1591. UNBOUNDED_1 = _a.UNBOUNDED;
  1592. requestAnimationFrame(function () {
  1593. _this.adapter_.addClass(ROOT_1);
  1594. if (_this.adapter_.isUnbounded()) {
  1595. _this.adapter_.addClass(UNBOUNDED_1);
  1596. // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
  1597. _this.layoutInternal_();
  1598. }
  1599. });
  1600. }
  1601. };
  1602. MDCRippleFoundation.prototype.destroy = function () {
  1603. var _this = this;
  1604. if (this.supportsPressRipple_()) {
  1605. if (this.activationTimer_) {
  1606. clearTimeout(this.activationTimer_);
  1607. this.activationTimer_ = 0;
  1608. this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
  1609. }
  1610. if (this.fgDeactivationRemovalTimer_) {
  1611. clearTimeout(this.fgDeactivationRemovalTimer_);
  1612. this.fgDeactivationRemovalTimer_ = 0;
  1613. this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
  1614. }
  1615. var _a = MDCRippleFoundation.cssClasses,
  1616. ROOT_2 = _a.ROOT,
  1617. UNBOUNDED_2 = _a.UNBOUNDED;
  1618. requestAnimationFrame(function () {
  1619. _this.adapter_.removeClass(ROOT_2);
  1620. _this.adapter_.removeClass(UNBOUNDED_2);
  1621. _this.removeCssVars_();
  1622. });
  1623. }
  1624. this.deregisterRootHandlers_();
  1625. this.deregisterDeactivationHandlers_();
  1626. };
  1627. /**
  1628. * @param evt Optional event containing position information.
  1629. */
  1630. MDCRippleFoundation.prototype.activate = function (evt) {
  1631. this.activate_(evt);
  1632. };
  1633. MDCRippleFoundation.prototype.deactivate = function () {
  1634. this.deactivate_();
  1635. };
  1636. MDCRippleFoundation.prototype.layout = function () {
  1637. var _this = this;
  1638. if (this.layoutFrame_) {
  1639. cancelAnimationFrame(this.layoutFrame_);
  1640. }
  1641. this.layoutFrame_ = requestAnimationFrame(function () {
  1642. _this.layoutInternal_();
  1643. _this.layoutFrame_ = 0;
  1644. });
  1645. };
  1646. MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
  1647. var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
  1648. if (unbounded) {
  1649. this.adapter_.addClass(UNBOUNDED);
  1650. } else {
  1651. this.adapter_.removeClass(UNBOUNDED);
  1652. }
  1653. };
  1654. MDCRippleFoundation.prototype.handleFocus = function () {
  1655. var _this = this;
  1656. requestAnimationFrame(function () {
  1657. return _this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  1658. });
  1659. };
  1660. MDCRippleFoundation.prototype.handleBlur = function () {
  1661. var _this = this;
  1662. requestAnimationFrame(function () {
  1663. return _this.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  1664. });
  1665. };
  1666. /**
  1667. * We compute this property so that we are not querying information about the client
  1668. * until the point in time where the foundation requests it. This prevents scenarios where
  1669. * client-side feature-detection may happen too early, such as when components are rendered on the server
  1670. * and then initialized at mount time on the client.
  1671. */
  1672. MDCRippleFoundation.prototype.supportsPressRipple_ = function () {
  1673. return this.adapter_.browserSupportsCssVars();
  1674. };
  1675. MDCRippleFoundation.prototype.defaultActivationState_ = function () {
  1676. return {
  1677. activationEvent: undefined,
  1678. hasDeactivationUXRun: false,
  1679. isActivated: false,
  1680. isProgrammatic: false,
  1681. wasActivatedByPointer: false,
  1682. wasElementMadeActive: false
  1683. };
  1684. };
  1685. /**
  1686. * supportsPressRipple Passed from init to save a redundant function call
  1687. */
  1688. MDCRippleFoundation.prototype.registerRootHandlers_ = function (supportsPressRipple) {
  1689. var _this = this;
  1690. if (supportsPressRipple) {
  1691. ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  1692. _this.adapter_.registerInteractionHandler(evtType, _this.activateHandler_);
  1693. });
  1694. if (this.adapter_.isUnbounded()) {
  1695. this.adapter_.registerResizeHandler(this.resizeHandler_);
  1696. }
  1697. }
  1698. this.adapter_.registerInteractionHandler('focus', this.focusHandler_);
  1699. this.adapter_.registerInteractionHandler('blur', this.blurHandler_);
  1700. };
  1701. MDCRippleFoundation.prototype.registerDeactivationHandlers_ = function (evt) {
  1702. var _this = this;
  1703. if (evt.type === 'keydown') {
  1704. this.adapter_.registerInteractionHandler('keyup', this.deactivateHandler_);
  1705. } else {
  1706. POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  1707. _this.adapter_.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_);
  1708. });
  1709. }
  1710. };
  1711. MDCRippleFoundation.prototype.deregisterRootHandlers_ = function () {
  1712. var _this = this;
  1713. ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  1714. _this.adapter_.deregisterInteractionHandler(evtType, _this.activateHandler_);
  1715. });
  1716. this.adapter_.deregisterInteractionHandler('focus', this.focusHandler_);
  1717. this.adapter_.deregisterInteractionHandler('blur', this.blurHandler_);
  1718. if (this.adapter_.isUnbounded()) {
  1719. this.adapter_.deregisterResizeHandler(this.resizeHandler_);
  1720. }
  1721. };
  1722. MDCRippleFoundation.prototype.deregisterDeactivationHandlers_ = function () {
  1723. var _this = this;
  1724. this.adapter_.deregisterInteractionHandler('keyup', this.deactivateHandler_);
  1725. POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  1726. _this.adapter_.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_);
  1727. });
  1728. };
  1729. MDCRippleFoundation.prototype.removeCssVars_ = function () {
  1730. var _this = this;
  1731. var rippleStrings = MDCRippleFoundation.strings;
  1732. var keys = Object.keys(rippleStrings);
  1733. keys.forEach(function (key) {
  1734. if (key.indexOf('VAR_') === 0) {
  1735. _this.adapter_.updateCssVariable(rippleStrings[key], null);
  1736. }
  1737. });
  1738. };
  1739. MDCRippleFoundation.prototype.activate_ = function (evt) {
  1740. var _this = this;
  1741. if (this.adapter_.isSurfaceDisabled()) {
  1742. return;
  1743. }
  1744. var activationState = this.activationState_;
  1745. if (activationState.isActivated) {
  1746. return;
  1747. }
  1748. // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
  1749. var previousActivationEvent = this.previousActivationEvent_;
  1750. var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
  1751. if (isSameInteraction) {
  1752. return;
  1753. }
  1754. activationState.isActivated = true;
  1755. activationState.isProgrammatic = evt === undefined;
  1756. activationState.activationEvent = evt;
  1757. activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
  1758. var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
  1759. return _this.adapter_.containsEventTarget(target);
  1760. });
  1761. if (hasActivatedChild) {
  1762. // Immediately reset activation state, while preserving logic that prevents touch follow-on events
  1763. this.resetActivationState_();
  1764. return;
  1765. }
  1766. if (evt !== undefined) {
  1767. activatedTargets.push(evt.target);
  1768. this.registerDeactivationHandlers_(evt);
  1769. }
  1770. activationState.wasElementMadeActive = this.checkElementMadeActive_(evt);
  1771. if (activationState.wasElementMadeActive) {
  1772. this.animateActivation_();
  1773. }
  1774. requestAnimationFrame(function () {
  1775. // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
  1776. activatedTargets = [];
  1777. if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
  1778. // If space was pressed, try again within an rAF call to detect :active, because different UAs report
  1779. // active states inconsistently when they're called within event handling code:
  1780. // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
  1781. // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
  1782. // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
  1783. // variable is set within a rAF callback for a submit button interaction (#2241).
  1784. activationState.wasElementMadeActive = _this.checkElementMadeActive_(evt);
  1785. if (activationState.wasElementMadeActive) {
  1786. _this.animateActivation_();
  1787. }
  1788. }
  1789. if (!activationState.wasElementMadeActive) {
  1790. // Reset activation state immediately if element was not made active.
  1791. _this.activationState_ = _this.defaultActivationState_();
  1792. }
  1793. });
  1794. };
  1795. MDCRippleFoundation.prototype.checkElementMadeActive_ = function (evt) {
  1796. return evt !== undefined && evt.type === 'keydown' ? this.adapter_.isSurfaceActive() : true;
  1797. };
  1798. MDCRippleFoundation.prototype.animateActivation_ = function () {
  1799. var _this = this;
  1800. var _a = MDCRippleFoundation.strings,
  1801. VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
  1802. VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
  1803. var _b = MDCRippleFoundation.cssClasses,
  1804. FG_DEACTIVATION = _b.FG_DEACTIVATION,
  1805. FG_ACTIVATION = _b.FG_ACTIVATION;
  1806. var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
  1807. this.layoutInternal_();
  1808. var translateStart = '';
  1809. var translateEnd = '';
  1810. if (!this.adapter_.isUnbounded()) {
  1811. var _c = this.getFgTranslationCoordinates_(),
  1812. startPoint = _c.startPoint,
  1813. endPoint = _c.endPoint;
  1814. translateStart = startPoint.x + "px, " + startPoint.y + "px";
  1815. translateEnd = endPoint.x + "px, " + endPoint.y + "px";
  1816. }
  1817. this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
  1818. this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
  1819. // Cancel any ongoing activation/deactivation animations
  1820. clearTimeout(this.activationTimer_);
  1821. clearTimeout(this.fgDeactivationRemovalTimer_);
  1822. this.rmBoundedActivationClasses_();
  1823. this.adapter_.removeClass(FG_DEACTIVATION);
  1824. // Force layout in order to re-trigger the animation.
  1825. this.adapter_.computeBoundingRect();
  1826. this.adapter_.addClass(FG_ACTIVATION);
  1827. this.activationTimer_ = setTimeout(function () {
  1828. return _this.activationTimerCallback_();
  1829. }, DEACTIVATION_TIMEOUT_MS);
  1830. };
  1831. MDCRippleFoundation.prototype.getFgTranslationCoordinates_ = function () {
  1832. var _a = this.activationState_,
  1833. activationEvent = _a.activationEvent,
  1834. wasActivatedByPointer = _a.wasActivatedByPointer;
  1835. var startPoint;
  1836. if (wasActivatedByPointer) {
  1837. startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter_.getWindowPageOffset(), this.adapter_.computeBoundingRect());
  1838. } else {
  1839. startPoint = {
  1840. x: this.frame_.width / 2,
  1841. y: this.frame_.height / 2
  1842. };
  1843. }
  1844. // Center the element around the start point.
  1845. startPoint = {
  1846. x: startPoint.x - this.initialSize_ / 2,
  1847. y: startPoint.y - this.initialSize_ / 2
  1848. };
  1849. var endPoint = {
  1850. x: this.frame_.width / 2 - this.initialSize_ / 2,
  1851. y: this.frame_.height / 2 - this.initialSize_ / 2
  1852. };
  1853. return { startPoint: startPoint, endPoint: endPoint };
  1854. };
  1855. MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady_ = function () {
  1856. var _this = this;
  1857. // This method is called both when a pointing device is released, and when the activation animation ends.
  1858. // The deactivation animation should only run after both of those occur.
  1859. var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
  1860. var _a = this.activationState_,
  1861. hasDeactivationUXRun = _a.hasDeactivationUXRun,
  1862. isActivated = _a.isActivated;
  1863. var activationHasEnded = hasDeactivationUXRun || !isActivated;
  1864. if (activationHasEnded && this.activationAnimationHasEnded_) {
  1865. this.rmBoundedActivationClasses_();
  1866. this.adapter_.addClass(FG_DEACTIVATION);
  1867. this.fgDeactivationRemovalTimer_ = setTimeout(function () {
  1868. _this.adapter_.removeClass(FG_DEACTIVATION);
  1869. }, constants_1.numbers.FG_DEACTIVATION_MS);
  1870. }
  1871. };
  1872. MDCRippleFoundation.prototype.rmBoundedActivationClasses_ = function () {
  1873. var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
  1874. this.adapter_.removeClass(FG_ACTIVATION);
  1875. this.activationAnimationHasEnded_ = false;
  1876. this.adapter_.computeBoundingRect();
  1877. };
  1878. MDCRippleFoundation.prototype.resetActivationState_ = function () {
  1879. var _this = this;
  1880. this.previousActivationEvent_ = this.activationState_.activationEvent;
  1881. this.activationState_ = this.defaultActivationState_();
  1882. // Touch devices may fire additional events for the same interaction within a short time.
  1883. // Store the previous event until it's safe to assume that subsequent events are for new interactions.
  1884. setTimeout(function () {
  1885. return _this.previousActivationEvent_ = undefined;
  1886. }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
  1887. };
  1888. MDCRippleFoundation.prototype.deactivate_ = function () {
  1889. var _this = this;
  1890. var activationState = this.activationState_;
  1891. // This can happen in scenarios such as when you have a keyup event that blurs the element.
  1892. if (!activationState.isActivated) {
  1893. return;
  1894. }
  1895. var state = __assign({}, activationState);
  1896. if (activationState.isProgrammatic) {
  1897. requestAnimationFrame(function () {
  1898. return _this.animateDeactivation_(state);
  1899. });
  1900. this.resetActivationState_();
  1901. } else {
  1902. this.deregisterDeactivationHandlers_();
  1903. requestAnimationFrame(function () {
  1904. _this.activationState_.hasDeactivationUXRun = true;
  1905. _this.animateDeactivation_(state);
  1906. _this.resetActivationState_();
  1907. });
  1908. }
  1909. };
  1910. MDCRippleFoundation.prototype.animateDeactivation_ = function (_a) {
  1911. var wasActivatedByPointer = _a.wasActivatedByPointer,
  1912. wasElementMadeActive = _a.wasElementMadeActive;
  1913. if (wasActivatedByPointer || wasElementMadeActive) {
  1914. this.runDeactivationUXLogicIfReady_();
  1915. }
  1916. };
  1917. MDCRippleFoundation.prototype.layoutInternal_ = function () {
  1918. var _this = this;
  1919. this.frame_ = this.adapter_.computeBoundingRect();
  1920. var maxDim = Math.max(this.frame_.height, this.frame_.width);
  1921. // Surface diameter is treated differently for unbounded vs. bounded ripples.
  1922. // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
  1923. // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
  1924. // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
  1925. // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
  1926. // `overflow: hidden`.
  1927. var getBoundedRadius = function getBoundedRadius() {
  1928. var hypotenuse = Math.sqrt(Math.pow(_this.frame_.width, 2) + Math.pow(_this.frame_.height, 2));
  1929. return hypotenuse + MDCRippleFoundation.numbers.PADDING;
  1930. };
  1931. this.maxRadius_ = this.adapter_.isUnbounded() ? maxDim : getBoundedRadius();
  1932. // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
  1933. var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
  1934. // Unbounded ripple size should always be even number to equally center align.
  1935. if (this.adapter_.isUnbounded() && initialSize % 2 !== 0) {
  1936. this.initialSize_ = initialSize - 1;
  1937. } else {
  1938. this.initialSize_ = initialSize;
  1939. }
  1940. this.fgScale_ = "" + this.maxRadius_ / this.initialSize_;
  1941. this.updateLayoutCssVars_();
  1942. };
  1943. MDCRippleFoundation.prototype.updateLayoutCssVars_ = function () {
  1944. var _a = MDCRippleFoundation.strings,
  1945. VAR_FG_SIZE = _a.VAR_FG_SIZE,
  1946. VAR_LEFT = _a.VAR_LEFT,
  1947. VAR_TOP = _a.VAR_TOP,
  1948. VAR_FG_SCALE = _a.VAR_FG_SCALE;
  1949. this.adapter_.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + "px");
  1950. this.adapter_.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
  1951. if (this.adapter_.isUnbounded()) {
  1952. this.unboundedCoords_ = {
  1953. left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
  1954. top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
  1955. };
  1956. this.adapter_.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + "px");
  1957. this.adapter_.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + "px");
  1958. }
  1959. };
  1960. return MDCRippleFoundation;
  1961. }(foundation_1.MDCFoundation);
  1962. exports.MDCRippleFoundation = MDCRippleFoundation;
  1963. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  1964. exports.default = MDCRippleFoundation;
  1965. /***/ }),
  1966. /***/ "./packages/mdc-ripple/util.ts":
  1967. /*!*************************************!*\
  1968. !*** ./packages/mdc-ripple/util.ts ***!
  1969. \*************************************/
  1970. /*! no static exports found */
  1971. /***/ (function(module, exports, __webpack_require__) {
  1972. "use strict";
  1973. Object.defineProperty(exports, "__esModule", { value: true });
  1974. /**
  1975. * Stores result from supportsCssVariables to avoid redundant processing to
  1976. * detect CSS custom variable support.
  1977. */
  1978. var supportsCssVariables_;
  1979. function supportsCssVariables(windowObj, forceRefresh) {
  1980. if (forceRefresh === void 0) {
  1981. forceRefresh = false;
  1982. }
  1983. var CSS = windowObj.CSS;
  1984. var supportsCssVars = supportsCssVariables_;
  1985. if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
  1986. return supportsCssVariables_;
  1987. }
  1988. var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
  1989. if (!supportsFunctionPresent) {
  1990. return false;
  1991. }
  1992. var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
  1993. // See: https://bugs.webkit.org/show_bug.cgi?id=154669
  1994. // See: README section on Safari
  1995. var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
  1996. supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
  1997. if (!forceRefresh) {
  1998. supportsCssVariables_ = supportsCssVars;
  1999. }
  2000. return supportsCssVars;
  2001. }
  2002. exports.supportsCssVariables = supportsCssVariables;
  2003. function getNormalizedEventCoords(evt, pageOffset, clientRect) {
  2004. if (!evt) {
  2005. return { x: 0, y: 0 };
  2006. }
  2007. var x = pageOffset.x,
  2008. y = pageOffset.y;
  2009. var documentX = x + clientRect.left;
  2010. var documentY = y + clientRect.top;
  2011. var normalizedX;
  2012. var normalizedY;
  2013. // Determine touch point relative to the ripple container.
  2014. if (evt.type === 'touchstart') {
  2015. var touchEvent = evt;
  2016. normalizedX = touchEvent.changedTouches[0].pageX - documentX;
  2017. normalizedY = touchEvent.changedTouches[0].pageY - documentY;
  2018. } else {
  2019. var mouseEvent = evt;
  2020. normalizedX = mouseEvent.pageX - documentX;
  2021. normalizedY = mouseEvent.pageY - documentY;
  2022. }
  2023. return { x: normalizedX, y: normalizedY };
  2024. }
  2025. exports.getNormalizedEventCoords = getNormalizedEventCoords;
  2026. /***/ })
  2027. /******/ });
  2028. });
  2029. //# sourceMappingURL=mdc.checkbox.js.map