UNPKG

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