1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
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/dialog", [], factory);
|
13 | else if(typeof exports === 'object')
|
14 | exports["dialog"] = factory();
|
15 | else
|
16 | root["mdc"] = root["mdc"] || {}, root["mdc"]["dialog"] = factory();
|
17 | })(this, function() {
|
18 | return (function(modules) {
|
19 |
|
20 | var installedModules = {};
|
21 |
|
22 |
|
23 | function __webpack_require__(moduleId) {
|
24 |
|
25 |
|
26 | if(installedModules[moduleId]) {
|
27 | return installedModules[moduleId].exports;
|
28 | }
|
29 |
|
30 | var module = installedModules[moduleId] = {
|
31 | i: moduleId,
|
32 | l: false,
|
33 | exports: {}
|
34 | };
|
35 |
|
36 |
|
37 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
38 |
|
39 |
|
40 | module.l = true;
|
41 |
|
42 |
|
43 | return module.exports;
|
44 | }
|
45 |
|
46 |
|
47 |
|
48 | __webpack_require__.m = modules;
|
49 |
|
50 |
|
51 | __webpack_require__.c = installedModules;
|
52 |
|
53 |
|
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 |
|
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 |
|
69 |
|
70 |
|
71 |
|
72 |
|
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 |
|
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 |
|
94 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
95 |
|
96 |
|
97 | __webpack_require__.p = "";
|
98 |
|
99 |
|
100 |
|
101 | return __webpack_require__(__webpack_require__.s = "./packages/mdc-dialog/index.ts");
|
102 | })
|
103 |
|
104 | ({
|
105 |
|
106 | "./packages/mdc-animation/animationframe.ts":
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | (function(module, exports, __webpack_require__) {
|
112 |
|
113 | "use strict";
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | Object.defineProperty(exports, "__esModule", { value: true });
|
139 | exports.AnimationFrame = void 0;
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | var AnimationFrame = function () {
|
145 | function AnimationFrame() {
|
146 | this.rafIDs = new Map();
|
147 | }
|
148 | |
149 |
|
150 |
|
151 |
|
152 |
|
153 | AnimationFrame.prototype.request = function (key, callback) {
|
154 | var _this = this;
|
155 | this.cancel(key);
|
156 | var frameID = requestAnimationFrame(function (frame) {
|
157 | _this.rafIDs.delete(key);
|
158 |
|
159 |
|
160 | callback(frame);
|
161 | });
|
162 | this.rafIDs.set(key, frameID);
|
163 | };
|
164 | |
165 |
|
166 |
|
167 |
|
168 | AnimationFrame.prototype.cancel = function (key) {
|
169 | var rafID = this.rafIDs.get(key);
|
170 | if (rafID) {
|
171 | cancelAnimationFrame(rafID);
|
172 | this.rafIDs.delete(key);
|
173 | }
|
174 | };
|
175 | |
176 |
|
177 |
|
178 | AnimationFrame.prototype.cancelAll = function () {
|
179 | var _this = this;
|
180 |
|
181 |
|
182 |
|
183 | this.rafIDs.forEach(function (_, key) {
|
184 | _this.cancel(key);
|
185 | });
|
186 | };
|
187 | |
188 |
|
189 |
|
190 | AnimationFrame.prototype.getQueue = function () {
|
191 | var queue = [];
|
192 |
|
193 |
|
194 |
|
195 | this.rafIDs.forEach(function (_, key) {
|
196 | queue.push(key);
|
197 | });
|
198 | return queue;
|
199 | };
|
200 | return AnimationFrame;
|
201 | }();
|
202 | exports.AnimationFrame = AnimationFrame;
|
203 |
|
204 | }),
|
205 |
|
206 | "./packages/mdc-base/component.ts":
|
207 |
|
208 |
|
209 |
|
210 |
|
211 | (function(module, exports, __webpack_require__) {
|
212 |
|
213 | "use strict";
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 | var __read = this && this.__read || function (o, n) {
|
239 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
240 | if (!m) return o;
|
241 | var i = m.call(o),
|
242 | r,
|
243 | ar = [],
|
244 | e;
|
245 | try {
|
246 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
247 | ar.push(r.value);
|
248 | }
|
249 | } catch (error) {
|
250 | e = { error: error };
|
251 | } finally {
|
252 | try {
|
253 | if (r && !r.done && (m = i["return"])) m.call(i);
|
254 | } finally {
|
255 | if (e) throw e.error;
|
256 | }
|
257 | }
|
258 | return ar;
|
259 | };
|
260 | var __spreadArray = this && this.__spreadArray || function (to, from) {
|
261 | for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
|
262 | to[j] = from[i];
|
263 | }return to;
|
264 | };
|
265 | Object.defineProperty(exports, "__esModule", { value: true });
|
266 | exports.MDCComponent = void 0;
|
267 | var foundation_1 = __webpack_require__( "./packages/mdc-base/foundation.ts");
|
268 | var MDCComponent = function () {
|
269 | function MDCComponent(root, foundation) {
|
270 | var args = [];
|
271 | for (var _i = 2; _i < arguments.length; _i++) {
|
272 | args[_i - 2] = arguments[_i];
|
273 | }
|
274 | this.root = root;
|
275 | this.initialize.apply(this, __spreadArray([], __read(args)));
|
276 |
|
277 |
|
278 |
|
279 | this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
|
280 | this.foundation.init();
|
281 | this.initialSyncWithDOM();
|
282 | }
|
283 | MDCComponent.attachTo = function (root) {
|
284 |
|
285 |
|
286 |
|
287 |
|
288 | return new MDCComponent(root, new foundation_1.MDCFoundation({}));
|
289 | };
|
290 |
|
291 | MDCComponent.prototype.initialize = function () {
|
292 | var _args = [];
|
293 | for (var _i = 0; _i < arguments.length; _i++) {
|
294 | _args[_i] = arguments[_i];
|
295 | }
|
296 |
|
297 |
|
298 |
|
299 | };
|
300 | MDCComponent.prototype.getDefaultFoundation = function () {
|
301 |
|
302 |
|
303 | throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
|
304 | };
|
305 | MDCComponent.prototype.initialSyncWithDOM = function () {
|
306 |
|
307 |
|
308 |
|
309 |
|
310 | };
|
311 | MDCComponent.prototype.destroy = function () {
|
312 |
|
313 |
|
314 | this.foundation.destroy();
|
315 | };
|
316 | MDCComponent.prototype.listen = function (evtType, handler, options) {
|
317 | this.root.addEventListener(evtType, handler, options);
|
318 | };
|
319 | MDCComponent.prototype.unlisten = function (evtType, handler, options) {
|
320 | this.root.removeEventListener(evtType, handler, options);
|
321 | };
|
322 | |
323 |
|
324 |
|
325 | MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
|
326 | if (shouldBubble === void 0) {
|
327 | shouldBubble = false;
|
328 | }
|
329 | var evt;
|
330 | if (typeof CustomEvent === 'function') {
|
331 | evt = new CustomEvent(evtType, {
|
332 | bubbles: shouldBubble,
|
333 | detail: evtData
|
334 | });
|
335 | } else {
|
336 | evt = document.createEvent('CustomEvent');
|
337 | evt.initCustomEvent(evtType, shouldBubble, false, evtData);
|
338 | }
|
339 | this.root.dispatchEvent(evt);
|
340 | };
|
341 | return MDCComponent;
|
342 | }();
|
343 | exports.MDCComponent = MDCComponent;
|
344 |
|
345 | exports.default = MDCComponent;
|
346 |
|
347 | }),
|
348 |
|
349 | "./packages/mdc-base/foundation.ts":
|
350 |
|
351 |
|
352 |
|
353 |
|
354 | (function(module, exports, __webpack_require__) {
|
355 |
|
356 | "use strict";
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 | Object.defineProperty(exports, "__esModule", { value: true });
|
382 | exports.MDCFoundation = void 0;
|
383 | var MDCFoundation = function () {
|
384 | function MDCFoundation(adapter) {
|
385 | if (adapter === void 0) {
|
386 | adapter = {};
|
387 | }
|
388 | this.adapter = adapter;
|
389 | }
|
390 | Object.defineProperty(MDCFoundation, "cssClasses", {
|
391 | get: function get() {
|
392 |
|
393 |
|
394 | return {};
|
395 | },
|
396 | enumerable: false,
|
397 | configurable: true
|
398 | });
|
399 | Object.defineProperty(MDCFoundation, "strings", {
|
400 | get: function get() {
|
401 |
|
402 |
|
403 | return {};
|
404 | },
|
405 | enumerable: false,
|
406 | configurable: true
|
407 | });
|
408 | Object.defineProperty(MDCFoundation, "numbers", {
|
409 | get: function get() {
|
410 |
|
411 |
|
412 | return {};
|
413 | },
|
414 | enumerable: false,
|
415 | configurable: true
|
416 | });
|
417 | Object.defineProperty(MDCFoundation, "defaultAdapter", {
|
418 | get: function get() {
|
419 |
|
420 |
|
421 |
|
422 | return {};
|
423 | },
|
424 | enumerable: false,
|
425 | configurable: true
|
426 | });
|
427 | MDCFoundation.prototype.init = function () {
|
428 |
|
429 | };
|
430 | MDCFoundation.prototype.destroy = function () {
|
431 |
|
432 | };
|
433 | return MDCFoundation;
|
434 | }();
|
435 | exports.MDCFoundation = MDCFoundation;
|
436 |
|
437 | exports.default = MDCFoundation;
|
438 |
|
439 | }),
|
440 |
|
441 | "./packages/mdc-dialog/adapter.ts":
|
442 |
|
443 |
|
444 |
|
445 |
|
446 | (function(module, exports, __webpack_require__) {
|
447 |
|
448 | "use strict";
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 | Object.defineProperty(exports, "__esModule", { value: true });
|
474 |
|
475 | }),
|
476 |
|
477 | "./packages/mdc-dialog/component.ts":
|
478 |
|
479 |
|
480 |
|
481 |
|
482 | (function(module, exports, __webpack_require__) {
|
483 |
|
484 | "use strict";
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 | var __extends = this && this.__extends || function () {
|
510 | var _extendStatics = function extendStatics(d, b) {
|
511 | _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
|
512 | d.__proto__ = b;
|
513 | } || function (d, b) {
|
514 | for (var p in b) {
|
515 | if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
516 | }
|
517 | };
|
518 | return _extendStatics(d, b);
|
519 | };
|
520 | return function (d, b) {
|
521 | if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
522 | _extendStatics(d, b);
|
523 | function __() {
|
524 | this.constructor = d;
|
525 | }
|
526 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
527 | };
|
528 | }();
|
529 | var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
530 | if (k2 === undefined) k2 = k;
|
531 | Object.defineProperty(o, k2, { enumerable: true, get: function get() {
|
532 | return m[k];
|
533 | } });
|
534 | } : function (o, m, k, k2) {
|
535 | if (k2 === undefined) k2 = k;
|
536 | o[k2] = m[k];
|
537 | });
|
538 | var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
539 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
540 | } : function (o, v) {
|
541 | o["default"] = v;
|
542 | });
|
543 | var __importStar = this && this.__importStar || function (mod) {
|
544 | if (mod && mod.__esModule) return mod;
|
545 | var result = {};
|
546 | if (mod != null) for (var k in mod) {
|
547 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
548 | }__setModuleDefault(result, mod);
|
549 | return result;
|
550 | };
|
551 | var __values = this && this.__values || function (o) {
|
552 | var s = typeof Symbol === "function" && Symbol.iterator,
|
553 | m = s && o[s],
|
554 | i = 0;
|
555 | if (m) return m.call(o);
|
556 | if (o && typeof o.length === "number") return {
|
557 | next: function next() {
|
558 | if (o && i >= o.length) o = void 0;
|
559 | return { value: o && o[i++], done: !o };
|
560 | }
|
561 | };
|
562 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
563 | };
|
564 | Object.defineProperty(exports, "__esModule", { value: true });
|
565 | exports.MDCDialog = void 0;
|
566 | var component_1 = __webpack_require__( "./packages/mdc-base/component.ts");
|
567 | var focus_trap_1 = __webpack_require__( "./packages/mdc-dom/focus-trap.ts");
|
568 | var ponyfill_1 = __webpack_require__( "./packages/mdc-dom/ponyfill.ts");
|
569 | var component_2 = __webpack_require__( "./packages/mdc-ripple/component.ts");
|
570 | var foundation_1 = __webpack_require__( "./packages/mdc-dialog/foundation.ts");
|
571 | var util = __importStar(__webpack_require__( "./packages/mdc-dialog/util.ts"));
|
572 | var strings = foundation_1.MDCDialogFoundation.strings;
|
573 | var MDCDialog = function (_super) {
|
574 | __extends(MDCDialog, _super);
|
575 | function MDCDialog() {
|
576 | return _super !== null && _super.apply(this, arguments) || this;
|
577 | }
|
578 | Object.defineProperty(MDCDialog.prototype, "isOpen", {
|
579 | get: function get() {
|
580 | return this.foundation.isOpen();
|
581 | },
|
582 | enumerable: false,
|
583 | configurable: true
|
584 | });
|
585 | Object.defineProperty(MDCDialog.prototype, "escapeKeyAction", {
|
586 | get: function get() {
|
587 | return this.foundation.getEscapeKeyAction();
|
588 | },
|
589 | set: function set(action) {
|
590 | this.foundation.setEscapeKeyAction(action);
|
591 | },
|
592 | enumerable: false,
|
593 | configurable: true
|
594 | });
|
595 | Object.defineProperty(MDCDialog.prototype, "scrimClickAction", {
|
596 | get: function get() {
|
597 | return this.foundation.getScrimClickAction();
|
598 | },
|
599 | set: function set(action) {
|
600 | this.foundation.setScrimClickAction(action);
|
601 | },
|
602 | enumerable: false,
|
603 | configurable: true
|
604 | });
|
605 | Object.defineProperty(MDCDialog.prototype, "autoStackButtons", {
|
606 | get: function get() {
|
607 | return this.foundation.getAutoStackButtons();
|
608 | },
|
609 | set: function set(autoStack) {
|
610 | this.foundation.setAutoStackButtons(autoStack);
|
611 | },
|
612 | enumerable: false,
|
613 | configurable: true
|
614 | });
|
615 | MDCDialog.attachTo = function (root) {
|
616 | return new MDCDialog(root);
|
617 | };
|
618 | MDCDialog.prototype.initialize = function (focusTrapFactory) {
|
619 | var e_1, _a;
|
620 | if (focusTrapFactory === void 0) {
|
621 | focusTrapFactory = function focusTrapFactory(el, focusOptions) {
|
622 | return new focus_trap_1.FocusTrap(el, focusOptions);
|
623 | };
|
624 | }
|
625 | var container = this.root.querySelector(strings.CONTAINER_SELECTOR);
|
626 | if (!container) {
|
627 | throw new Error("Dialog component requires a " + strings.CONTAINER_SELECTOR + " container element");
|
628 | }
|
629 | this.container = container;
|
630 | this.content = this.root.querySelector(strings.CONTENT_SELECTOR);
|
631 | this.buttons = [].slice.call(this.root.querySelectorAll(strings.BUTTON_SELECTOR));
|
632 | this.defaultButton = this.root.querySelector("[" + strings.BUTTON_DEFAULT_ATTRIBUTE + "]");
|
633 | this.focusTrapFactory = focusTrapFactory;
|
634 | this.buttonRipples = [];
|
635 | try {
|
636 | for (var _b = __values(this.buttons), _c = _b.next(); !_c.done; _c = _b.next()) {
|
637 | var buttonEl = _c.value;
|
638 | this.buttonRipples.push(new component_2.MDCRipple(buttonEl));
|
639 | }
|
640 | } catch (e_1_1) {
|
641 | e_1 = { error: e_1_1 };
|
642 | } finally {
|
643 | try {
|
644 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
645 | } finally {
|
646 | if (e_1) throw e_1.error;
|
647 | }
|
648 | }
|
649 | };
|
650 | MDCDialog.prototype.initialSyncWithDOM = function () {
|
651 | var _this = this;
|
652 | this.focusTrap = util.createFocusTrapInstance(this.container, this.focusTrapFactory, this.getInitialFocusEl() || undefined);
|
653 | this.handleClick = this.foundation.handleClick.bind(this.foundation);
|
654 | this.handleKeydown = this.foundation.handleKeydown.bind(this.foundation);
|
655 | this.handleDocumentKeydown = this.foundation.handleDocumentKeydown.bind(this.foundation);
|
656 |
|
657 | this.handleOpening = function () {
|
658 | document.addEventListener('keydown', _this.handleDocumentKeydown);
|
659 | };
|
660 | this.handleClosing = function () {
|
661 | document.removeEventListener('keydown', _this.handleDocumentKeydown);
|
662 | };
|
663 | this.listen('click', this.handleClick);
|
664 | this.listen('keydown', this.handleKeydown);
|
665 | this.listen(strings.OPENING_EVENT, this.handleOpening);
|
666 | this.listen(strings.CLOSING_EVENT, this.handleClosing);
|
667 | };
|
668 | MDCDialog.prototype.destroy = function () {
|
669 | this.unlisten('click', this.handleClick);
|
670 | this.unlisten('keydown', this.handleKeydown);
|
671 | this.unlisten(strings.OPENING_EVENT, this.handleOpening);
|
672 | this.unlisten(strings.CLOSING_EVENT, this.handleClosing);
|
673 | this.handleClosing();
|
674 | this.buttonRipples.forEach(function (ripple) {
|
675 | ripple.destroy();
|
676 | });
|
677 | _super.prototype.destroy.call(this);
|
678 | };
|
679 | MDCDialog.prototype.layout = function () {
|
680 | this.foundation.layout();
|
681 | };
|
682 | MDCDialog.prototype.open = function () {
|
683 | this.foundation.open();
|
684 | };
|
685 | MDCDialog.prototype.close = function (action) {
|
686 | if (action === void 0) {
|
687 | action = '';
|
688 | }
|
689 | this.foundation.close(action);
|
690 | };
|
691 | MDCDialog.prototype.getDefaultFoundation = function () {
|
692 | var _this = this;
|
693 |
|
694 |
|
695 | var adapter = {
|
696 | addBodyClass: function addBodyClass(className) {
|
697 | return document.body.classList.add(className);
|
698 | },
|
699 | addClass: function addClass(className) {
|
700 | return _this.root.classList.add(className);
|
701 | },
|
702 | areButtonsStacked: function areButtonsStacked() {
|
703 | return util.areTopsMisaligned(_this.buttons);
|
704 | },
|
705 | clickDefaultButton: function clickDefaultButton() {
|
706 | if (_this.defaultButton && !_this.defaultButton.disabled) {
|
707 | _this.defaultButton.click();
|
708 | }
|
709 | },
|
710 | eventTargetMatches: function eventTargetMatches(target, selector) {
|
711 | return target ? ponyfill_1.matches(target, selector) : false;
|
712 | },
|
713 | getActionFromEvent: function getActionFromEvent(evt) {
|
714 | if (!evt.target) {
|
715 | return '';
|
716 | }
|
717 | var element = ponyfill_1.closest(evt.target, "[" + strings.ACTION_ATTRIBUTE + "]");
|
718 | return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
|
719 | },
|
720 | getInitialFocusEl: function getInitialFocusEl() {
|
721 | return _this.getInitialFocusEl();
|
722 | },
|
723 | hasClass: function hasClass(className) {
|
724 | return _this.root.classList.contains(className);
|
725 | },
|
726 | isContentScrollable: function isContentScrollable() {
|
727 | return util.isScrollable(_this.content);
|
728 | },
|
729 | notifyClosed: function notifyClosed(action) {
|
730 | return _this.emit(strings.CLOSED_EVENT, action ? { action: action } : {});
|
731 | },
|
732 | notifyClosing: function notifyClosing(action) {
|
733 | return _this.emit(strings.CLOSING_EVENT, action ? { action: action } : {});
|
734 | },
|
735 | notifyOpened: function notifyOpened() {
|
736 | return _this.emit(strings.OPENED_EVENT, {});
|
737 | },
|
738 | notifyOpening: function notifyOpening() {
|
739 | return _this.emit(strings.OPENING_EVENT, {});
|
740 | },
|
741 | releaseFocus: function releaseFocus() {
|
742 | _this.focusTrap.releaseFocus();
|
743 | },
|
744 | removeBodyClass: function removeBodyClass(className) {
|
745 | return document.body.classList.remove(className);
|
746 | },
|
747 | removeClass: function removeClass(className) {
|
748 | return _this.root.classList.remove(className);
|
749 | },
|
750 | reverseButtons: function reverseButtons() {
|
751 | _this.buttons.reverse();
|
752 | _this.buttons.forEach(function (button) {
|
753 | button.parentElement.appendChild(button);
|
754 | });
|
755 | },
|
756 | trapFocus: function trapFocus() {
|
757 | _this.focusTrap.trapFocus();
|
758 | },
|
759 | registerContentEventHandler: function registerContentEventHandler(evt, handler) {
|
760 | if (_this.content instanceof HTMLElement) {
|
761 | _this.content.addEventListener(evt, handler);
|
762 | }
|
763 | },
|
764 | deregisterContentEventHandler: function deregisterContentEventHandler(evt, handler) {
|
765 | if (_this.content instanceof HTMLElement) {
|
766 | _this.content.removeEventListener(evt, handler);
|
767 | }
|
768 | },
|
769 | isScrollableContentAtTop: function isScrollableContentAtTop() {
|
770 | return util.isScrollAtTop(_this.content);
|
771 | },
|
772 | isScrollableContentAtBottom: function isScrollableContentAtBottom() {
|
773 | return util.isScrollAtBottom(_this.content);
|
774 | },
|
775 | registerWindowEventHandler: function registerWindowEventHandler(evt, handler) {
|
776 | window.addEventListener(evt, handler);
|
777 | },
|
778 | deregisterWindowEventHandler: function deregisterWindowEventHandler(evt, handler) {
|
779 | window.removeEventListener(evt, handler);
|
780 | }
|
781 | };
|
782 | return new foundation_1.MDCDialogFoundation(adapter);
|
783 | };
|
784 | MDCDialog.prototype.getInitialFocusEl = function () {
|
785 | return this.root.querySelector("[" + strings.INITIAL_FOCUS_ATTRIBUTE + "]");
|
786 | };
|
787 | return MDCDialog;
|
788 | }(component_1.MDCComponent);
|
789 | exports.MDCDialog = MDCDialog;
|
790 |
|
791 | }),
|
792 |
|
793 | "./packages/mdc-dialog/constants.ts":
|
794 |
|
795 |
|
796 |
|
797 |
|
798 | (function(module, exports, __webpack_require__) {
|
799 |
|
800 | "use strict";
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 | Object.defineProperty(exports, "__esModule", { value: true });
|
826 | exports.numbers = exports.strings = exports.cssClasses = void 0;
|
827 | exports.cssClasses = {
|
828 | CLOSING: 'mdc-dialog--closing',
|
829 | OPEN: 'mdc-dialog--open',
|
830 | OPENING: 'mdc-dialog--opening',
|
831 | SCROLLABLE: 'mdc-dialog--scrollable',
|
832 | SCROLL_LOCK: 'mdc-dialog-scroll-lock',
|
833 | STACKED: 'mdc-dialog--stacked',
|
834 | FULLSCREEN: 'mdc-dialog--fullscreen',
|
835 |
|
836 |
|
837 |
|
838 | SCROLL_DIVIDER_HEADER: 'mdc-dialog-scroll-divider-header',
|
839 |
|
840 |
|
841 |
|
842 | SCROLL_DIVIDER_FOOTER: 'mdc-dialog-scroll-divider-footer',
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 | SURFACE_SCRIM_SHOWN: 'mdc-dialog__surface-scrim--shown',
|
851 |
|
852 | SURFACE_SCRIM_SHOWING: 'mdc-dialog__surface-scrim--showing',
|
853 |
|
854 | SURFACE_SCRIM_HIDING: 'mdc-dialog__surface-scrim--hiding',
|
855 |
|
856 |
|
857 |
|
858 |
|
859 | SCRIM_HIDDEN: 'mdc-dialog__scrim--hidden'
|
860 | };
|
861 | exports.strings = {
|
862 | ACTION_ATTRIBUTE: 'data-mdc-dialog-action',
|
863 | BUTTON_DEFAULT_ATTRIBUTE: 'data-mdc-dialog-button-default',
|
864 | BUTTON_SELECTOR: '.mdc-dialog__button',
|
865 | CLOSED_EVENT: 'MDCDialog:closed',
|
866 | CLOSE_ACTION: 'close',
|
867 | CLOSING_EVENT: 'MDCDialog:closing',
|
868 | CONTAINER_SELECTOR: '.mdc-dialog__container',
|
869 | CONTENT_SELECTOR: '.mdc-dialog__content',
|
870 | DESTROY_ACTION: 'destroy',
|
871 | INITIAL_FOCUS_ATTRIBUTE: 'data-mdc-dialog-initial-focus',
|
872 | OPENED_EVENT: 'MDCDialog:opened',
|
873 | OPENING_EVENT: 'MDCDialog:opening',
|
874 | SCRIM_SELECTOR: '.mdc-dialog__scrim',
|
875 | SUPPRESS_DEFAULT_PRESS_SELECTOR: ['textarea', '.mdc-menu .mdc-list-item', '.mdc-menu .mdc-deprecated-list-item'].join(', '),
|
876 | SURFACE_SELECTOR: '.mdc-dialog__surface'
|
877 | };
|
878 | exports.numbers = {
|
879 | DIALOG_ANIMATION_CLOSE_TIME_MS: 75,
|
880 | DIALOG_ANIMATION_OPEN_TIME_MS: 150
|
881 | };
|
882 |
|
883 | }),
|
884 |
|
885 | "./packages/mdc-dialog/foundation.ts":
|
886 |
|
887 |
|
888 |
|
889 |
|
890 | (function(module, exports, __webpack_require__) {
|
891 |
|
892 | "use strict";
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 | var __extends = this && this.__extends || function () {
|
918 | var _extendStatics = function extendStatics(d, b) {
|
919 | _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
|
920 | d.__proto__ = b;
|
921 | } || function (d, b) {
|
922 | for (var p in b) {
|
923 | if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
924 | }
|
925 | };
|
926 | return _extendStatics(d, b);
|
927 | };
|
928 | return function (d, b) {
|
929 | if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
930 | _extendStatics(d, b);
|
931 | function __() {
|
932 | this.constructor = d;
|
933 | }
|
934 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
935 | };
|
936 | }();
|
937 | var __assign = this && this.__assign || function () {
|
938 | __assign = Object.assign || function (t) {
|
939 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
940 | s = arguments[i];
|
941 | for (var p in s) {
|
942 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
943 | }
|
944 | }
|
945 | return t;
|
946 | };
|
947 | return __assign.apply(this, arguments);
|
948 | };
|
949 | Object.defineProperty(exports, "__esModule", { value: true });
|
950 | exports.MDCDialogFoundation = void 0;
|
951 | var animationframe_1 = __webpack_require__( "./packages/mdc-animation/animationframe.ts");
|
952 | var foundation_1 = __webpack_require__( "./packages/mdc-base/foundation.ts");
|
953 | var constants_1 = __webpack_require__( "./packages/mdc-dialog/constants.ts");
|
954 | var AnimationKeys;
|
955 | (function (AnimationKeys) {
|
956 | AnimationKeys["POLL_SCROLL_POS"] = "poll_scroll_position";
|
957 | AnimationKeys["POLL_LAYOUT_CHANGE"] = "poll_layout_change";
|
958 | })(AnimationKeys || (AnimationKeys = {}));
|
959 | var MDCDialogFoundation = function (_super) {
|
960 | __extends(MDCDialogFoundation, _super);
|
961 | function MDCDialogFoundation(adapter) {
|
962 | var _this = _super.call(this, __assign(__assign({}, MDCDialogFoundation.defaultAdapter), adapter)) || this;
|
963 | _this.dialogOpen = false;
|
964 | _this.isFullscreen = false;
|
965 | _this.animationFrame = 0;
|
966 | _this.animationTimer = 0;
|
967 | _this.escapeKeyAction = constants_1.strings.CLOSE_ACTION;
|
968 | _this.scrimClickAction = constants_1.strings.CLOSE_ACTION;
|
969 | _this.autoStackButtons = true;
|
970 | _this.areButtonsStacked = false;
|
971 | _this.suppressDefaultPressSelector = constants_1.strings.SUPPRESS_DEFAULT_PRESS_SELECTOR;
|
972 | _this.animFrame = new animationframe_1.AnimationFrame();
|
973 | _this.contentScrollHandler = function () {
|
974 | _this.handleScrollEvent();
|
975 | };
|
976 | _this.windowResizeHandler = function () {
|
977 | _this.layout();
|
978 | };
|
979 | _this.windowOrientationChangeHandler = function () {
|
980 | _this.layout();
|
981 | };
|
982 | return _this;
|
983 | }
|
984 | Object.defineProperty(MDCDialogFoundation, "cssClasses", {
|
985 | get: function get() {
|
986 | return constants_1.cssClasses;
|
987 | },
|
988 | enumerable: false,
|
989 | configurable: true
|
990 | });
|
991 | Object.defineProperty(MDCDialogFoundation, "strings", {
|
992 | get: function get() {
|
993 | return constants_1.strings;
|
994 | },
|
995 | enumerable: false,
|
996 | configurable: true
|
997 | });
|
998 | Object.defineProperty(MDCDialogFoundation, "numbers", {
|
999 | get: function get() {
|
1000 | return constants_1.numbers;
|
1001 | },
|
1002 | enumerable: false,
|
1003 | configurable: true
|
1004 | });
|
1005 | Object.defineProperty(MDCDialogFoundation, "defaultAdapter", {
|
1006 | get: function get() {
|
1007 | return {
|
1008 | addBodyClass: function addBodyClass() {
|
1009 | return undefined;
|
1010 | },
|
1011 | addClass: function addClass() {
|
1012 | return undefined;
|
1013 | },
|
1014 | areButtonsStacked: function areButtonsStacked() {
|
1015 | return false;
|
1016 | },
|
1017 | clickDefaultButton: function clickDefaultButton() {
|
1018 | return undefined;
|
1019 | },
|
1020 | eventTargetMatches: function eventTargetMatches() {
|
1021 | return false;
|
1022 | },
|
1023 | getActionFromEvent: function getActionFromEvent() {
|
1024 | return '';
|
1025 | },
|
1026 | getInitialFocusEl: function getInitialFocusEl() {
|
1027 | return null;
|
1028 | },
|
1029 | hasClass: function hasClass() {
|
1030 | return false;
|
1031 | },
|
1032 | isContentScrollable: function isContentScrollable() {
|
1033 | return false;
|
1034 | },
|
1035 | notifyClosed: function notifyClosed() {
|
1036 | return undefined;
|
1037 | },
|
1038 | notifyClosing: function notifyClosing() {
|
1039 | return undefined;
|
1040 | },
|
1041 | notifyOpened: function notifyOpened() {
|
1042 | return undefined;
|
1043 | },
|
1044 | notifyOpening: function notifyOpening() {
|
1045 | return undefined;
|
1046 | },
|
1047 | releaseFocus: function releaseFocus() {
|
1048 | return undefined;
|
1049 | },
|
1050 | removeBodyClass: function removeBodyClass() {
|
1051 | return undefined;
|
1052 | },
|
1053 | removeClass: function removeClass() {
|
1054 | return undefined;
|
1055 | },
|
1056 | reverseButtons: function reverseButtons() {
|
1057 | return undefined;
|
1058 | },
|
1059 | trapFocus: function trapFocus() {
|
1060 | return undefined;
|
1061 | },
|
1062 | registerContentEventHandler: function registerContentEventHandler() {
|
1063 | return undefined;
|
1064 | },
|
1065 | deregisterContentEventHandler: function deregisterContentEventHandler() {
|
1066 | return undefined;
|
1067 | },
|
1068 | isScrollableContentAtTop: function isScrollableContentAtTop() {
|
1069 | return false;
|
1070 | },
|
1071 | isScrollableContentAtBottom: function isScrollableContentAtBottom() {
|
1072 | return false;
|
1073 | },
|
1074 | registerWindowEventHandler: function registerWindowEventHandler() {
|
1075 | return undefined;
|
1076 | },
|
1077 | deregisterWindowEventHandler: function deregisterWindowEventHandler() {
|
1078 | return undefined;
|
1079 | }
|
1080 | };
|
1081 | },
|
1082 | enumerable: false,
|
1083 | configurable: true
|
1084 | });
|
1085 | MDCDialogFoundation.prototype.init = function () {
|
1086 | if (this.adapter.hasClass(constants_1.cssClasses.STACKED)) {
|
1087 | this.setAutoStackButtons(false);
|
1088 | }
|
1089 | this.isFullscreen = this.adapter.hasClass(constants_1.cssClasses.FULLSCREEN);
|
1090 | };
|
1091 | MDCDialogFoundation.prototype.destroy = function () {
|
1092 | if (this.animationTimer) {
|
1093 | clearTimeout(this.animationTimer);
|
1094 | this.handleAnimationTimerEnd();
|
1095 | }
|
1096 | if (this.isFullscreen) {
|
1097 | this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
|
1098 | }
|
1099 | this.animFrame.cancelAll();
|
1100 | this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
|
1101 | this.adapter.deregisterWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
|
1102 | };
|
1103 | MDCDialogFoundation.prototype.open = function (dialogOptions) {
|
1104 | var _this = this;
|
1105 | this.dialogOpen = true;
|
1106 | this.adapter.notifyOpening();
|
1107 | this.adapter.addClass(constants_1.cssClasses.OPENING);
|
1108 | if (this.isFullscreen) {
|
1109 |
|
1110 |
|
1111 |
|
1112 | this.adapter.registerContentEventHandler('scroll', this.contentScrollHandler);
|
1113 | }
|
1114 | if (dialogOptions && dialogOptions.isAboveFullscreenDialog) {
|
1115 | this.adapter.addClass(constants_1.cssClasses.SCRIM_HIDDEN);
|
1116 | }
|
1117 | this.adapter.registerWindowEventHandler('resize', this.windowResizeHandler);
|
1118 | this.adapter.registerWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
|
1119 |
|
1120 |
|
1121 | this.runNextAnimationFrame(function () {
|
1122 | _this.adapter.addClass(constants_1.cssClasses.OPEN);
|
1123 | _this.adapter.addBodyClass(constants_1.cssClasses.SCROLL_LOCK);
|
1124 | _this.layout();
|
1125 | _this.animationTimer = setTimeout(function () {
|
1126 | _this.handleAnimationTimerEnd();
|
1127 | _this.adapter.trapFocus(_this.adapter.getInitialFocusEl());
|
1128 | _this.adapter.notifyOpened();
|
1129 | }, constants_1.numbers.DIALOG_ANIMATION_OPEN_TIME_MS);
|
1130 | });
|
1131 | };
|
1132 | MDCDialogFoundation.prototype.close = function (action) {
|
1133 | var _this = this;
|
1134 | if (action === void 0) {
|
1135 | action = '';
|
1136 | }
|
1137 | if (!this.dialogOpen) {
|
1138 |
|
1139 |
|
1140 | return;
|
1141 | }
|
1142 | this.dialogOpen = false;
|
1143 | this.adapter.notifyClosing(action);
|
1144 | this.adapter.addClass(constants_1.cssClasses.CLOSING);
|
1145 | this.adapter.removeClass(constants_1.cssClasses.OPEN);
|
1146 | this.adapter.removeBodyClass(constants_1.cssClasses.SCROLL_LOCK);
|
1147 | if (this.isFullscreen) {
|
1148 | this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
|
1149 | }
|
1150 | this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
|
1151 | this.adapter.deregisterWindowEventHandler('orientationchange', this.windowOrientationChangeHandler);
|
1152 | cancelAnimationFrame(this.animationFrame);
|
1153 | this.animationFrame = 0;
|
1154 | clearTimeout(this.animationTimer);
|
1155 | this.animationTimer = setTimeout(function () {
|
1156 | _this.adapter.releaseFocus();
|
1157 | _this.handleAnimationTimerEnd();
|
1158 | _this.adapter.notifyClosed(action);
|
1159 | }, constants_1.numbers.DIALOG_ANIMATION_CLOSE_TIME_MS);
|
1160 | };
|
1161 | |
1162 |
|
1163 |
|
1164 |
|
1165 | MDCDialogFoundation.prototype.showSurfaceScrim = function () {
|
1166 | var _this = this;
|
1167 | this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWING);
|
1168 | this.runNextAnimationFrame(function () {
|
1169 | _this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWN);
|
1170 | });
|
1171 | };
|
1172 | |
1173 |
|
1174 |
|
1175 |
|
1176 | MDCDialogFoundation.prototype.hideSurfaceScrim = function () {
|
1177 | this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWN);
|
1178 | this.adapter.addClass(constants_1.cssClasses.SURFACE_SCRIM_HIDING);
|
1179 | };
|
1180 | |
1181 |
|
1182 |
|
1183 |
|
1184 | MDCDialogFoundation.prototype.handleSurfaceScrimTransitionEnd = function () {
|
1185 | this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_HIDING);
|
1186 | this.adapter.removeClass(constants_1.cssClasses.SURFACE_SCRIM_SHOWING);
|
1187 | };
|
1188 | MDCDialogFoundation.prototype.isOpen = function () {
|
1189 | return this.dialogOpen;
|
1190 | };
|
1191 | MDCDialogFoundation.prototype.getEscapeKeyAction = function () {
|
1192 | return this.escapeKeyAction;
|
1193 | };
|
1194 | MDCDialogFoundation.prototype.setEscapeKeyAction = function (action) {
|
1195 | this.escapeKeyAction = action;
|
1196 | };
|
1197 | MDCDialogFoundation.prototype.getScrimClickAction = function () {
|
1198 | return this.scrimClickAction;
|
1199 | };
|
1200 | MDCDialogFoundation.prototype.setScrimClickAction = function (action) {
|
1201 | this.scrimClickAction = action;
|
1202 | };
|
1203 | MDCDialogFoundation.prototype.getAutoStackButtons = function () {
|
1204 | return this.autoStackButtons;
|
1205 | };
|
1206 | MDCDialogFoundation.prototype.setAutoStackButtons = function (autoStack) {
|
1207 | this.autoStackButtons = autoStack;
|
1208 | };
|
1209 | MDCDialogFoundation.prototype.getSuppressDefaultPressSelector = function () {
|
1210 | return this.suppressDefaultPressSelector;
|
1211 | };
|
1212 | MDCDialogFoundation.prototype.setSuppressDefaultPressSelector = function (selector) {
|
1213 | this.suppressDefaultPressSelector = selector;
|
1214 | };
|
1215 | MDCDialogFoundation.prototype.layout = function () {
|
1216 | var _this = this;
|
1217 | this.animFrame.request(AnimationKeys.POLL_LAYOUT_CHANGE, function () {
|
1218 | _this.layoutInternal();
|
1219 | });
|
1220 | };
|
1221 |
|
1222 | MDCDialogFoundation.prototype.handleClick = function (evt) {
|
1223 | var isScrim = this.adapter.eventTargetMatches(evt.target, constants_1.strings.SCRIM_SELECTOR);
|
1224 |
|
1225 | if (isScrim && this.scrimClickAction !== '') {
|
1226 | this.close(this.scrimClickAction);
|
1227 | } else {
|
1228 | var action = this.adapter.getActionFromEvent(evt);
|
1229 | if (action) {
|
1230 | this.close(action);
|
1231 | }
|
1232 | }
|
1233 | };
|
1234 |
|
1235 | MDCDialogFoundation.prototype.handleKeydown = function (evt) {
|
1236 | var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
|
1237 | if (!isEnter) {
|
1238 | return;
|
1239 | }
|
1240 | var action = this.adapter.getActionFromEvent(evt);
|
1241 | if (action) {
|
1242 |
|
1243 |
|
1244 | return;
|
1245 | }
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 | var target = evt.composedPath ? evt.composedPath()[0] : evt.target;
|
1260 | var isDefault = this.suppressDefaultPressSelector ? !this.adapter.eventTargetMatches(target, this.suppressDefaultPressSelector) : true;
|
1261 | if (isEnter && isDefault) {
|
1262 | this.adapter.clickDefaultButton();
|
1263 | }
|
1264 | };
|
1265 |
|
1266 | MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) {
|
1267 | var isEscape = evt.key === 'Escape' || evt.keyCode === 27;
|
1268 | if (isEscape && this.escapeKeyAction !== '') {
|
1269 | this.close(this.escapeKeyAction);
|
1270 | }
|
1271 | };
|
1272 | |
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 | MDCDialogFoundation.prototype.handleScrollEvent = function () {
|
1278 | var _this = this;
|
1279 |
|
1280 |
|
1281 | this.animFrame.request(AnimationKeys.POLL_SCROLL_POS, function () {
|
1282 | _this.toggleScrollDividerHeader();
|
1283 | _this.toggleScrollDividerFooter();
|
1284 | });
|
1285 | };
|
1286 | MDCDialogFoundation.prototype.layoutInternal = function () {
|
1287 | if (this.autoStackButtons) {
|
1288 | this.detectStackedButtons();
|
1289 | }
|
1290 | this.toggleScrollableClasses();
|
1291 | };
|
1292 | MDCDialogFoundation.prototype.handleAnimationTimerEnd = function () {
|
1293 | this.animationTimer = 0;
|
1294 | this.adapter.removeClass(constants_1.cssClasses.OPENING);
|
1295 | this.adapter.removeClass(constants_1.cssClasses.CLOSING);
|
1296 | };
|
1297 | |
1298 |
|
1299 |
|
1300 |
|
1301 | MDCDialogFoundation.prototype.runNextAnimationFrame = function (callback) {
|
1302 | var _this = this;
|
1303 | cancelAnimationFrame(this.animationFrame);
|
1304 | this.animationFrame = requestAnimationFrame(function () {
|
1305 | _this.animationFrame = 0;
|
1306 | clearTimeout(_this.animationTimer);
|
1307 | _this.animationTimer = setTimeout(callback, 0);
|
1308 | });
|
1309 | };
|
1310 | MDCDialogFoundation.prototype.detectStackedButtons = function () {
|
1311 |
|
1312 | this.adapter.removeClass(constants_1.cssClasses.STACKED);
|
1313 | var areButtonsStacked = this.adapter.areButtonsStacked();
|
1314 | if (areButtonsStacked) {
|
1315 | this.adapter.addClass(constants_1.cssClasses.STACKED);
|
1316 | }
|
1317 | if (areButtonsStacked !== this.areButtonsStacked) {
|
1318 | this.adapter.reverseButtons();
|
1319 | this.areButtonsStacked = areButtonsStacked;
|
1320 | }
|
1321 | };
|
1322 | MDCDialogFoundation.prototype.toggleScrollableClasses = function () {
|
1323 |
|
1324 |
|
1325 | this.adapter.removeClass(constants_1.cssClasses.SCROLLABLE);
|
1326 | if (this.adapter.isContentScrollable()) {
|
1327 | this.adapter.addClass(constants_1.cssClasses.SCROLLABLE);
|
1328 | if (this.isFullscreen) {
|
1329 |
|
1330 |
|
1331 | this.toggleScrollDividerHeader();
|
1332 | this.toggleScrollDividerFooter();
|
1333 | }
|
1334 | }
|
1335 | };
|
1336 | MDCDialogFoundation.prototype.toggleScrollDividerHeader = function () {
|
1337 | if (!this.adapter.isScrollableContentAtTop()) {
|
1338 | this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
|
1339 | } else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER)) {
|
1340 | this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
|
1341 | }
|
1342 | };
|
1343 | MDCDialogFoundation.prototype.toggleScrollDividerFooter = function () {
|
1344 | if (!this.adapter.isScrollableContentAtBottom()) {
|
1345 | this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
|
1346 | } else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER)) {
|
1347 | this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
|
1348 | }
|
1349 | };
|
1350 | return MDCDialogFoundation;
|
1351 | }(foundation_1.MDCFoundation);
|
1352 | exports.MDCDialogFoundation = MDCDialogFoundation;
|
1353 |
|
1354 | exports.default = MDCDialogFoundation;
|
1355 |
|
1356 | }),
|
1357 |
|
1358 | "./packages/mdc-dialog/index.ts":
|
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 | (function(module, exports, __webpack_require__) {
|
1364 |
|
1365 | "use strict";
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 | var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
1391 | if (k2 === undefined) k2 = k;
|
1392 | Object.defineProperty(o, k2, { enumerable: true, get: function get() {
|
1393 | return m[k];
|
1394 | } });
|
1395 | } : function (o, m, k, k2) {
|
1396 | if (k2 === undefined) k2 = k;
|
1397 | o[k2] = m[k];
|
1398 | });
|
1399 | var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
1400 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
1401 | } : function (o, v) {
|
1402 | o["default"] = v;
|
1403 | });
|
1404 | var __importStar = this && this.__importStar || function (mod) {
|
1405 | if (mod && mod.__esModule) return mod;
|
1406 | var result = {};
|
1407 | if (mod != null) for (var k in mod) {
|
1408 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
1409 | }__setModuleDefault(result, mod);
|
1410 | return result;
|
1411 | };
|
1412 | var __exportStar = this && this.__exportStar || function (m, exports) {
|
1413 | for (var p in m) {
|
1414 | if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
1415 | }
|
1416 | };
|
1417 | Object.defineProperty(exports, "__esModule", { value: true });
|
1418 | exports.util = void 0;
|
1419 | var util = __importStar(__webpack_require__( "./packages/mdc-dialog/util.ts"));
|
1420 | exports.util = util;
|
1421 | __exportStar(__webpack_require__( "./packages/mdc-dialog/adapter.ts"), exports);
|
1422 | __exportStar(__webpack_require__( "./packages/mdc-dialog/component.ts"), exports);
|
1423 | __exportStar(__webpack_require__( "./packages/mdc-dialog/constants.ts"), exports);
|
1424 | __exportStar(__webpack_require__( "./packages/mdc-dialog/foundation.ts"), exports);
|
1425 | __exportStar(__webpack_require__( "./packages/mdc-dialog/types.ts"), exports);
|
1426 |
|
1427 | }),
|
1428 |
|
1429 | "./packages/mdc-dialog/types.ts":
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 | (function(module, exports, __webpack_require__) {
|
1435 |
|
1436 | "use strict";
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 | Object.defineProperty(exports, "__esModule", { value: true });
|
1462 |
|
1463 | }),
|
1464 |
|
1465 | "./packages/mdc-dialog/util.ts":
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 | (function(module, exports, __webpack_require__) {
|
1471 |
|
1472 | "use strict";
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 | Object.defineProperty(exports, "__esModule", { value: true });
|
1498 | exports.areTopsMisaligned = exports.isScrollAtBottom = exports.isScrollAtTop = exports.isScrollable = exports.createFocusTrapInstance = void 0;
|
1499 | function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
|
1500 | return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl });
|
1501 | }
|
1502 | exports.createFocusTrapInstance = createFocusTrapInstance;
|
1503 | function isScrollable(el) {
|
1504 | return el ? el.scrollHeight > el.offsetHeight : false;
|
1505 | }
|
1506 | exports.isScrollable = isScrollable;
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 | function isScrollAtTop(el) {
|
1514 | return el ? el.scrollTop === 0 : false;
|
1515 | }
|
1516 | exports.isScrollAtTop = isScrollAtTop;
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 |
|
1523 | function isScrollAtBottom(el) {
|
1524 | return el ? Math.ceil(el.scrollHeight - el.scrollTop) === el.clientHeight : false;
|
1525 | }
|
1526 | exports.isScrollAtBottom = isScrollAtBottom;
|
1527 | function areTopsMisaligned(els) {
|
1528 | var tops = new Set();
|
1529 | [].forEach.call(els, function (el) {
|
1530 | return tops.add(el.offsetTop);
|
1531 | });
|
1532 | return tops.size > 1;
|
1533 | }
|
1534 | exports.areTopsMisaligned = areTopsMisaligned;
|
1535 |
|
1536 | }),
|
1537 |
|
1538 | "./packages/mdc-dom/events.ts":
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 | (function(module, exports, __webpack_require__) {
|
1544 |
|
1545 | "use strict";
|
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 |
|
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 | Object.defineProperty(exports, "__esModule", { value: true });
|
1571 | exports.applyPassive = void 0;
|
1572 |
|
1573 |
|
1574 |
|
1575 |
|
1576 | function applyPassive(globalObj) {
|
1577 | if (globalObj === void 0) {
|
1578 | globalObj = window;
|
1579 | }
|
1580 | return supportsPassiveOption(globalObj) ? { passive: true } : false;
|
1581 | }
|
1582 | exports.applyPassive = applyPassive;
|
1583 | function supportsPassiveOption(globalObj) {
|
1584 | if (globalObj === void 0) {
|
1585 | globalObj = window;
|
1586 | }
|
1587 |
|
1588 |
|
1589 | var passiveSupported = false;
|
1590 | try {
|
1591 | var options = {
|
1592 |
|
1593 |
|
1594 | get passive() {
|
1595 | passiveSupported = true;
|
1596 | return false;
|
1597 | }
|
1598 | };
|
1599 | var handler = function handler() {};
|
1600 | globalObj.document.addEventListener('test', handler, options);
|
1601 | globalObj.document.removeEventListener('test', handler, options);
|
1602 | } catch (err) {
|
1603 | passiveSupported = false;
|
1604 | }
|
1605 | return passiveSupported;
|
1606 | }
|
1607 |
|
1608 | }),
|
1609 |
|
1610 | "./packages/mdc-dom/focus-trap.ts":
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 | (function(module, exports, __webpack_require__) {
|
1616 |
|
1617 | "use strict";
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 | Object.defineProperty(exports, "__esModule", { value: true });
|
1643 | exports.FocusTrap = void 0;
|
1644 | var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
|
1645 |
|
1646 |
|
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 | var FocusTrap = function () {
|
1653 | function FocusTrap(root, options) {
|
1654 | if (options === void 0) {
|
1655 | options = {};
|
1656 | }
|
1657 | this.root = root;
|
1658 | this.options = options;
|
1659 |
|
1660 | this.elFocusedBeforeTrapFocus = null;
|
1661 | }
|
1662 | |
1663 |
|
1664 |
|
1665 |
|
1666 | FocusTrap.prototype.trapFocus = function () {
|
1667 | var focusableEls = this.getFocusableElements(this.root);
|
1668 | if (focusableEls.length === 0) {
|
1669 | throw new Error('FocusTrap: Element must have at least one focusable child.');
|
1670 | }
|
1671 | this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
1672 | this.wrapTabFocus(this.root);
|
1673 | if (!this.options.skipInitialFocus) {
|
1674 | this.focusInitialElement(focusableEls, this.options.initialFocusEl);
|
1675 | }
|
1676 | };
|
1677 | |
1678 |
|
1679 |
|
1680 |
|
1681 | FocusTrap.prototype.releaseFocus = function () {
|
1682 | [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
|
1683 | sentinelEl.parentElement.removeChild(sentinelEl);
|
1684 | });
|
1685 | if (!this.options.skipRestoreFocus && this.elFocusedBeforeTrapFocus) {
|
1686 | this.elFocusedBeforeTrapFocus.focus();
|
1687 | }
|
1688 | };
|
1689 | |
1690 |
|
1691 |
|
1692 |
|
1693 |
|
1694 |
|
1695 |
|
1696 | FocusTrap.prototype.wrapTabFocus = function (el) {
|
1697 | var _this = this;
|
1698 | var sentinelStart = this.createSentinel();
|
1699 | var sentinelEnd = this.createSentinel();
|
1700 | sentinelStart.addEventListener('focus', function () {
|
1701 | var focusableEls = _this.getFocusableElements(el);
|
1702 | if (focusableEls.length > 0) {
|
1703 | focusableEls[focusableEls.length - 1].focus();
|
1704 | }
|
1705 | });
|
1706 | sentinelEnd.addEventListener('focus', function () {
|
1707 | var focusableEls = _this.getFocusableElements(el);
|
1708 | if (focusableEls.length > 0) {
|
1709 | focusableEls[0].focus();
|
1710 | }
|
1711 | });
|
1712 | el.insertBefore(sentinelStart, el.children[0]);
|
1713 | el.appendChild(sentinelEnd);
|
1714 | };
|
1715 | |
1716 |
|
1717 |
|
1718 |
|
1719 | FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
|
1720 | var focusIndex = 0;
|
1721 | if (initialFocusEl) {
|
1722 | focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
|
1723 | }
|
1724 | focusableEls[focusIndex].focus();
|
1725 | };
|
1726 | FocusTrap.prototype.getFocusableElements = function (root) {
|
1727 | var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
|
1728 | return focusableEls.filter(function (el) {
|
1729 | var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
|
1730 | var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
|
1731 | var isProgrammaticallyHidden = false;
|
1732 | if (isTabbableAndVisible) {
|
1733 | var style = getComputedStyle(el);
|
1734 | isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
|
1735 | }
|
1736 | return isTabbableAndVisible && !isProgrammaticallyHidden;
|
1737 | });
|
1738 | };
|
1739 | FocusTrap.prototype.createSentinel = function () {
|
1740 | var sentinel = document.createElement('div');
|
1741 | sentinel.setAttribute('tabindex', '0');
|
1742 |
|
1743 | sentinel.setAttribute('aria-hidden', 'true');
|
1744 | sentinel.classList.add(FOCUS_SENTINEL_CLASS);
|
1745 | return sentinel;
|
1746 | };
|
1747 | return FocusTrap;
|
1748 | }();
|
1749 | exports.FocusTrap = FocusTrap;
|
1750 |
|
1751 | }),
|
1752 |
|
1753 | "./packages/mdc-dom/ponyfill.ts":
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 | (function(module, exports, __webpack_require__) {
|
1759 |
|
1760 | "use strict";
|
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 |
|
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 | Object.defineProperty(exports, "__esModule", { value: true });
|
1786 | exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 | function closest(element, selector) {
|
1792 | if (element.closest) {
|
1793 | return element.closest(selector);
|
1794 | }
|
1795 | var el = element;
|
1796 | while (el) {
|
1797 | if (matches(el, selector)) {
|
1798 | return el;
|
1799 | }
|
1800 | el = el.parentElement;
|
1801 | }
|
1802 | return null;
|
1803 | }
|
1804 | exports.closest = closest;
|
1805 | function matches(element, selector) {
|
1806 | var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
|
1807 | return nativeMatches.call(element, selector);
|
1808 | }
|
1809 | exports.matches = matches;
|
1810 |
|
1811 |
|
1812 |
|
1813 |
|
1814 |
|
1815 |
|
1816 |
|
1817 |
|
1818 | function estimateScrollWidth(element) {
|
1819 |
|
1820 |
|
1821 |
|
1822 |
|
1823 | var htmlEl = element;
|
1824 | if (htmlEl.offsetParent !== null) {
|
1825 | return htmlEl.scrollWidth;
|
1826 | }
|
1827 | var clone = htmlEl.cloneNode(true);
|
1828 | clone.style.setProperty('position', 'absolute');
|
1829 | clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
|
1830 | document.documentElement.appendChild(clone);
|
1831 | var scrollWidth = clone.scrollWidth;
|
1832 | document.documentElement.removeChild(clone);
|
1833 | return scrollWidth;
|
1834 | }
|
1835 | exports.estimateScrollWidth = estimateScrollWidth;
|
1836 |
|
1837 | }),
|
1838 |
|
1839 | "./packages/mdc-ripple/component.ts":
|
1840 |
|
1841 |
|
1842 |
|
1843 |
|
1844 | (function(module, exports, __webpack_require__) {
|
1845 |
|
1846 | "use strict";
|
1847 |
|
1848 |
|
1849 |
|
1850 |
|
1851 |
|
1852 |
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 |
|
1864 |
|
1865 |
|
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 | var __extends = this && this.__extends || function () {
|
1872 | var _extendStatics = function extendStatics(d, b) {
|
1873 | _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
|
1874 | d.__proto__ = b;
|
1875 | } || function (d, b) {
|
1876 | for (var p in b) {
|
1877 | if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
1878 | }
|
1879 | };
|
1880 | return _extendStatics(d, b);
|
1881 | };
|
1882 | return function (d, b) {
|
1883 | if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
1884 | _extendStatics(d, b);
|
1885 | function __() {
|
1886 | this.constructor = d;
|
1887 | }
|
1888 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1889 | };
|
1890 | }();
|
1891 | var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
1892 | if (k2 === undefined) k2 = k;
|
1893 | Object.defineProperty(o, k2, { enumerable: true, get: function get() {
|
1894 | return m[k];
|
1895 | } });
|
1896 | } : function (o, m, k, k2) {
|
1897 | if (k2 === undefined) k2 = k;
|
1898 | o[k2] = m[k];
|
1899 | });
|
1900 | var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
1901 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
1902 | } : function (o, v) {
|
1903 | o["default"] = v;
|
1904 | });
|
1905 | var __importStar = this && this.__importStar || function (mod) {
|
1906 | if (mod && mod.__esModule) return mod;
|
1907 | var result = {};
|
1908 | if (mod != null) for (var k in mod) {
|
1909 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
1910 | }__setModuleDefault(result, mod);
|
1911 | return result;
|
1912 | };
|
1913 | Object.defineProperty(exports, "__esModule", { value: true });
|
1914 | exports.MDCRipple = void 0;
|
1915 | var component_1 = __webpack_require__( "./packages/mdc-base/component.ts");
|
1916 | var events_1 = __webpack_require__( "./packages/mdc-dom/events.ts");
|
1917 | var ponyfill_1 = __webpack_require__( "./packages/mdc-dom/ponyfill.ts");
|
1918 | var foundation_1 = __webpack_require__( "./packages/mdc-ripple/foundation.ts");
|
1919 | var util = __importStar(__webpack_require__( "./packages/mdc-ripple/util.ts"));
|
1920 | var MDCRipple = function (_super) {
|
1921 | __extends(MDCRipple, _super);
|
1922 | function MDCRipple() {
|
1923 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
1924 | _this.disabled = false;
|
1925 | return _this;
|
1926 | }
|
1927 | MDCRipple.attachTo = function (root, opts) {
|
1928 | if (opts === void 0) {
|
1929 | opts = {
|
1930 | isUnbounded: undefined
|
1931 | };
|
1932 | }
|
1933 | var ripple = new MDCRipple(root);
|
1934 |
|
1935 | if (opts.isUnbounded !== undefined) {
|
1936 | ripple.unbounded = opts.isUnbounded;
|
1937 | }
|
1938 | return ripple;
|
1939 | };
|
1940 | MDCRipple.createAdapter = function (instance) {
|
1941 | return {
|
1942 | addClass: function addClass(className) {
|
1943 | return instance.root.classList.add(className);
|
1944 | },
|
1945 | browserSupportsCssVars: function browserSupportsCssVars() {
|
1946 | return util.supportsCssVariables(window);
|
1947 | },
|
1948 | computeBoundingRect: function computeBoundingRect() {
|
1949 | return instance.root.getBoundingClientRect();
|
1950 | },
|
1951 | containsEventTarget: function containsEventTarget(target) {
|
1952 | return instance.root.contains(target);
|
1953 | },
|
1954 | deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
|
1955 | return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
|
1956 | },
|
1957 | deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
|
1958 | return instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
|
1959 | },
|
1960 | deregisterResizeHandler: function deregisterResizeHandler(handler) {
|
1961 | return window.removeEventListener('resize', handler);
|
1962 | },
|
1963 | getWindowPageOffset: function getWindowPageOffset() {
|
1964 | return { x: window.pageXOffset, y: window.pageYOffset };
|
1965 | },
|
1966 | isSurfaceActive: function isSurfaceActive() {
|
1967 | return ponyfill_1.matches(instance.root, ':active');
|
1968 | },
|
1969 | isSurfaceDisabled: function isSurfaceDisabled() {
|
1970 | return Boolean(instance.disabled);
|
1971 | },
|
1972 | isUnbounded: function isUnbounded() {
|
1973 | return Boolean(instance.unbounded);
|
1974 | },
|
1975 | registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
|
1976 | return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
|
1977 | },
|
1978 | registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
|
1979 | return instance.root.addEventListener(evtType, handler, events_1.applyPassive());
|
1980 | },
|
1981 | registerResizeHandler: function registerResizeHandler(handler) {
|
1982 | return window.addEventListener('resize', handler);
|
1983 | },
|
1984 | removeClass: function removeClass(className) {
|
1985 | return instance.root.classList.remove(className);
|
1986 | },
|
1987 | updateCssVariable: function updateCssVariable(varName, value) {
|
1988 | return instance.root.style.setProperty(varName, value);
|
1989 | }
|
1990 | };
|
1991 | };
|
1992 | Object.defineProperty(MDCRipple.prototype, "unbounded", {
|
1993 | get: function get() {
|
1994 | return Boolean(this.isUnbounded);
|
1995 | },
|
1996 | set: function set(unbounded) {
|
1997 | this.isUnbounded = Boolean(unbounded);
|
1998 | this.setUnbounded();
|
1999 | },
|
2000 | enumerable: false,
|
2001 | configurable: true
|
2002 | });
|
2003 | MDCRipple.prototype.activate = function () {
|
2004 | this.foundation.activate();
|
2005 | };
|
2006 | MDCRipple.prototype.deactivate = function () {
|
2007 | this.foundation.deactivate();
|
2008 | };
|
2009 | MDCRipple.prototype.layout = function () {
|
2010 | this.foundation.layout();
|
2011 | };
|
2012 | MDCRipple.prototype.getDefaultFoundation = function () {
|
2013 | return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
|
2014 | };
|
2015 | MDCRipple.prototype.initialSyncWithDOM = function () {
|
2016 | var root = this.root;
|
2017 | this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
|
2018 | };
|
2019 | |
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 | MDCRipple.prototype.setUnbounded = function () {
|
2026 | this.foundation.setUnbounded(Boolean(this.isUnbounded));
|
2027 | };
|
2028 | return MDCRipple;
|
2029 | }(component_1.MDCComponent);
|
2030 | exports.MDCRipple = MDCRipple;
|
2031 |
|
2032 | }),
|
2033 |
|
2034 | "./packages/mdc-ripple/constants.ts":
|
2035 |
|
2036 |
|
2037 |
|
2038 |
|
2039 | (function(module, exports, __webpack_require__) {
|
2040 |
|
2041 | "use strict";
|
2042 |
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 |
|
2066 | Object.defineProperty(exports, "__esModule", { value: true });
|
2067 | exports.numbers = exports.strings = exports.cssClasses = void 0;
|
2068 | exports.cssClasses = {
|
2069 |
|
2070 |
|
2071 |
|
2072 | BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
|
2073 | FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
|
2074 | FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
|
2075 | ROOT: 'mdc-ripple-upgraded',
|
2076 | UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
|
2077 | };
|
2078 | exports.strings = {
|
2079 | VAR_FG_SCALE: '--mdc-ripple-fg-scale',
|
2080 | VAR_FG_SIZE: '--mdc-ripple-fg-size',
|
2081 | VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
|
2082 | VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
|
2083 | VAR_LEFT: '--mdc-ripple-left',
|
2084 | VAR_TOP: '--mdc-ripple-top'
|
2085 | };
|
2086 | exports.numbers = {
|
2087 | DEACTIVATION_TIMEOUT_MS: 225,
|
2088 | FG_DEACTIVATION_MS: 150,
|
2089 | INITIAL_ORIGIN_SCALE: 0.6,
|
2090 | PADDING: 10,
|
2091 | TAP_DELAY_MS: 300 };
|
2092 |
|
2093 | }),
|
2094 |
|
2095 | "./packages/mdc-ripple/foundation.ts":
|
2096 |
|
2097 |
|
2098 |
|
2099 |
|
2100 | (function(module, exports, __webpack_require__) {
|
2101 |
|
2102 | "use strict";
|
2103 |
|
2104 |
|
2105 |
|
2106 |
|
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 |
|
2117 |
|
2118 |
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 | var __extends = this && this.__extends || function () {
|
2128 | var _extendStatics = function extendStatics(d, b) {
|
2129 | _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
|
2130 | d.__proto__ = b;
|
2131 | } || function (d, b) {
|
2132 | for (var p in b) {
|
2133 | if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
2134 | }
|
2135 | };
|
2136 | return _extendStatics(d, b);
|
2137 | };
|
2138 | return function (d, b) {
|
2139 | if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
2140 | _extendStatics(d, b);
|
2141 | function __() {
|
2142 | this.constructor = d;
|
2143 | }
|
2144 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2145 | };
|
2146 | }();
|
2147 | var __assign = this && this.__assign || function () {
|
2148 | __assign = Object.assign || function (t) {
|
2149 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
2150 | s = arguments[i];
|
2151 | for (var p in s) {
|
2152 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
2153 | }
|
2154 | }
|
2155 | return t;
|
2156 | };
|
2157 | return __assign.apply(this, arguments);
|
2158 | };
|
2159 | var __values = this && this.__values || function (o) {
|
2160 | var s = typeof Symbol === "function" && Symbol.iterator,
|
2161 | m = s && o[s],
|
2162 | i = 0;
|
2163 | if (m) return m.call(o);
|
2164 | if (o && typeof o.length === "number") return {
|
2165 | next: function next() {
|
2166 | if (o && i >= o.length) o = void 0;
|
2167 | return { value: o && o[i++], done: !o };
|
2168 | }
|
2169 | };
|
2170 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
2171 | };
|
2172 | Object.defineProperty(exports, "__esModule", { value: true });
|
2173 | exports.MDCRippleFoundation = void 0;
|
2174 | var foundation_1 = __webpack_require__( "./packages/mdc-base/foundation.ts");
|
2175 | var constants_1 = __webpack_require__( "./packages/mdc-ripple/constants.ts");
|
2176 | var util_1 = __webpack_require__( "./packages/mdc-ripple/util.ts");
|
2177 |
|
2178 | var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
|
2179 |
|
2180 | var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
|
2181 |
|
2182 | var activatedTargets = [];
|
2183 | var MDCRippleFoundation = function (_super) {
|
2184 | __extends(MDCRippleFoundation, _super);
|
2185 | function MDCRippleFoundation(adapter) {
|
2186 | var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
|
2187 | _this.activationAnimationHasEnded = false;
|
2188 | _this.activationTimer = 0;
|
2189 | _this.fgDeactivationRemovalTimer = 0;
|
2190 | _this.fgScale = '0';
|
2191 | _this.frame = { width: 0, height: 0 };
|
2192 | _this.initialSize = 0;
|
2193 | _this.layoutFrame = 0;
|
2194 | _this.maxRadius = 0;
|
2195 | _this.unboundedCoords = { left: 0, top: 0 };
|
2196 | _this.activationState = _this.defaultActivationState();
|
2197 | _this.activationTimerCallback = function () {
|
2198 | _this.activationAnimationHasEnded = true;
|
2199 | _this.runDeactivationUXLogicIfReady();
|
2200 | };
|
2201 | _this.activateHandler = function (e) {
|
2202 | _this.activateImpl(e);
|
2203 | };
|
2204 | _this.deactivateHandler = function () {
|
2205 | _this.deactivateImpl();
|
2206 | };
|
2207 | _this.focusHandler = function () {
|
2208 | _this.handleFocus();
|
2209 | };
|
2210 | _this.blurHandler = function () {
|
2211 | _this.handleBlur();
|
2212 | };
|
2213 | _this.resizeHandler = function () {
|
2214 | _this.layout();
|
2215 | };
|
2216 | return _this;
|
2217 | }
|
2218 | Object.defineProperty(MDCRippleFoundation, "cssClasses", {
|
2219 | get: function get() {
|
2220 | return constants_1.cssClasses;
|
2221 | },
|
2222 | enumerable: false,
|
2223 | configurable: true
|
2224 | });
|
2225 | Object.defineProperty(MDCRippleFoundation, "strings", {
|
2226 | get: function get() {
|
2227 | return constants_1.strings;
|
2228 | },
|
2229 | enumerable: false,
|
2230 | configurable: true
|
2231 | });
|
2232 | Object.defineProperty(MDCRippleFoundation, "numbers", {
|
2233 | get: function get() {
|
2234 | return constants_1.numbers;
|
2235 | },
|
2236 | enumerable: false,
|
2237 | configurable: true
|
2238 | });
|
2239 | Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
|
2240 | get: function get() {
|
2241 | return {
|
2242 | addClass: function addClass() {
|
2243 | return undefined;
|
2244 | },
|
2245 | browserSupportsCssVars: function browserSupportsCssVars() {
|
2246 | return true;
|
2247 | },
|
2248 | computeBoundingRect: function computeBoundingRect() {
|
2249 | return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
|
2250 | },
|
2251 | containsEventTarget: function containsEventTarget() {
|
2252 | return true;
|
2253 | },
|
2254 | deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
|
2255 | return undefined;
|
2256 | },
|
2257 | deregisterInteractionHandler: function deregisterInteractionHandler() {
|
2258 | return undefined;
|
2259 | },
|
2260 | deregisterResizeHandler: function deregisterResizeHandler() {
|
2261 | return undefined;
|
2262 | },
|
2263 | getWindowPageOffset: function getWindowPageOffset() {
|
2264 | return { x: 0, y: 0 };
|
2265 | },
|
2266 | isSurfaceActive: function isSurfaceActive() {
|
2267 | return true;
|
2268 | },
|
2269 | isSurfaceDisabled: function isSurfaceDisabled() {
|
2270 | return true;
|
2271 | },
|
2272 | isUnbounded: function isUnbounded() {
|
2273 | return true;
|
2274 | },
|
2275 | registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
|
2276 | return undefined;
|
2277 | },
|
2278 | registerInteractionHandler: function registerInteractionHandler() {
|
2279 | return undefined;
|
2280 | },
|
2281 | registerResizeHandler: function registerResizeHandler() {
|
2282 | return undefined;
|
2283 | },
|
2284 | removeClass: function removeClass() {
|
2285 | return undefined;
|
2286 | },
|
2287 | updateCssVariable: function updateCssVariable() {
|
2288 | return undefined;
|
2289 | }
|
2290 | };
|
2291 | },
|
2292 | enumerable: false,
|
2293 | configurable: true
|
2294 | });
|
2295 | MDCRippleFoundation.prototype.init = function () {
|
2296 | var _this = this;
|
2297 | var supportsPressRipple = this.supportsPressRipple();
|
2298 | this.registerRootHandlers(supportsPressRipple);
|
2299 | if (supportsPressRipple) {
|
2300 | var _a = MDCRippleFoundation.cssClasses,
|
2301 | ROOT_1 = _a.ROOT,
|
2302 | UNBOUNDED_1 = _a.UNBOUNDED;
|
2303 | requestAnimationFrame(function () {
|
2304 | _this.adapter.addClass(ROOT_1);
|
2305 | if (_this.adapter.isUnbounded()) {
|
2306 | _this.adapter.addClass(UNBOUNDED_1);
|
2307 |
|
2308 | _this.layoutInternal();
|
2309 | }
|
2310 | });
|
2311 | }
|
2312 | };
|
2313 | MDCRippleFoundation.prototype.destroy = function () {
|
2314 | var _this = this;
|
2315 | if (this.supportsPressRipple()) {
|
2316 | if (this.activationTimer) {
|
2317 | clearTimeout(this.activationTimer);
|
2318 | this.activationTimer = 0;
|
2319 | this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
|
2320 | }
|
2321 | if (this.fgDeactivationRemovalTimer) {
|
2322 | clearTimeout(this.fgDeactivationRemovalTimer);
|
2323 | this.fgDeactivationRemovalTimer = 0;
|
2324 | this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
|
2325 | }
|
2326 | var _a = MDCRippleFoundation.cssClasses,
|
2327 | ROOT_2 = _a.ROOT,
|
2328 | UNBOUNDED_2 = _a.UNBOUNDED;
|
2329 | requestAnimationFrame(function () {
|
2330 | _this.adapter.removeClass(ROOT_2);
|
2331 | _this.adapter.removeClass(UNBOUNDED_2);
|
2332 | _this.removeCssVars();
|
2333 | });
|
2334 | }
|
2335 | this.deregisterRootHandlers();
|
2336 | this.deregisterDeactivationHandlers();
|
2337 | };
|
2338 | |
2339 |
|
2340 |
|
2341 | MDCRippleFoundation.prototype.activate = function (evt) {
|
2342 | this.activateImpl(evt);
|
2343 | };
|
2344 | MDCRippleFoundation.prototype.deactivate = function () {
|
2345 | this.deactivateImpl();
|
2346 | };
|
2347 | MDCRippleFoundation.prototype.layout = function () {
|
2348 | var _this = this;
|
2349 | if (this.layoutFrame) {
|
2350 | cancelAnimationFrame(this.layoutFrame);
|
2351 | }
|
2352 | this.layoutFrame = requestAnimationFrame(function () {
|
2353 | _this.layoutInternal();
|
2354 | _this.layoutFrame = 0;
|
2355 | });
|
2356 | };
|
2357 | MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
|
2358 | var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
|
2359 | if (unbounded) {
|
2360 | this.adapter.addClass(UNBOUNDED);
|
2361 | } else {
|
2362 | this.adapter.removeClass(UNBOUNDED);
|
2363 | }
|
2364 | };
|
2365 | MDCRippleFoundation.prototype.handleFocus = function () {
|
2366 | var _this = this;
|
2367 | requestAnimationFrame(function () {
|
2368 | return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
|
2369 | });
|
2370 | };
|
2371 | MDCRippleFoundation.prototype.handleBlur = function () {
|
2372 | var _this = this;
|
2373 | requestAnimationFrame(function () {
|
2374 | return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
|
2375 | });
|
2376 | };
|
2377 | |
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 | MDCRippleFoundation.prototype.supportsPressRipple = function () {
|
2384 | return this.adapter.browserSupportsCssVars();
|
2385 | };
|
2386 | MDCRippleFoundation.prototype.defaultActivationState = function () {
|
2387 | return {
|
2388 | activationEvent: undefined,
|
2389 | hasDeactivationUXRun: false,
|
2390 | isActivated: false,
|
2391 | isProgrammatic: false,
|
2392 | wasActivatedByPointer: false,
|
2393 | wasElementMadeActive: false
|
2394 | };
|
2395 | };
|
2396 | |
2397 |
|
2398 |
|
2399 | MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
|
2400 | var e_1, _a;
|
2401 | if (supportsPressRipple) {
|
2402 | try {
|
2403 | 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()) {
|
2404 | var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
|
2405 | this.adapter.registerInteractionHandler(evtType, this.activateHandler);
|
2406 | }
|
2407 | } catch (e_1_1) {
|
2408 | e_1 = { error: e_1_1 };
|
2409 | } finally {
|
2410 | try {
|
2411 | if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
|
2412 | } finally {
|
2413 | if (e_1) throw e_1.error;
|
2414 | }
|
2415 | }
|
2416 | if (this.adapter.isUnbounded()) {
|
2417 | this.adapter.registerResizeHandler(this.resizeHandler);
|
2418 | }
|
2419 | }
|
2420 | this.adapter.registerInteractionHandler('focus', this.focusHandler);
|
2421 | this.adapter.registerInteractionHandler('blur', this.blurHandler);
|
2422 | };
|
2423 | MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
|
2424 | var e_2, _a;
|
2425 | if (evt.type === 'keydown') {
|
2426 | this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
|
2427 | } else {
|
2428 | try {
|
2429 | 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()) {
|
2430 | var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
|
2431 | this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
|
2432 | }
|
2433 | } catch (e_2_1) {
|
2434 | e_2 = { error: e_2_1 };
|
2435 | } finally {
|
2436 | try {
|
2437 | 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);
|
2438 | } finally {
|
2439 | if (e_2) throw e_2.error;
|
2440 | }
|
2441 | }
|
2442 | }
|
2443 | };
|
2444 | MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
|
2445 | var e_3, _a;
|
2446 | try {
|
2447 | 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()) {
|
2448 | var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
|
2449 | this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
|
2450 | }
|
2451 | } catch (e_3_1) {
|
2452 | e_3 = { error: e_3_1 };
|
2453 | } finally {
|
2454 | try {
|
2455 | if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
|
2456 | } finally {
|
2457 | if (e_3) throw e_3.error;
|
2458 | }
|
2459 | }
|
2460 | this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
|
2461 | this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
|
2462 | if (this.adapter.isUnbounded()) {
|
2463 | this.adapter.deregisterResizeHandler(this.resizeHandler);
|
2464 | }
|
2465 | };
|
2466 | MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
|
2467 | var e_4, _a;
|
2468 | this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
|
2469 | try {
|
2470 | 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()) {
|
2471 | var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
|
2472 | this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
|
2473 | }
|
2474 | } catch (e_4_1) {
|
2475 | e_4 = { error: e_4_1 };
|
2476 | } finally {
|
2477 | try {
|
2478 | 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);
|
2479 | } finally {
|
2480 | if (e_4) throw e_4.error;
|
2481 | }
|
2482 | }
|
2483 | };
|
2484 | MDCRippleFoundation.prototype.removeCssVars = function () {
|
2485 | var _this = this;
|
2486 | var rippleStrings = MDCRippleFoundation.strings;
|
2487 | var keys = Object.keys(rippleStrings);
|
2488 | keys.forEach(function (key) {
|
2489 | if (key.indexOf('VAR_') === 0) {
|
2490 | _this.adapter.updateCssVariable(rippleStrings[key], null);
|
2491 | }
|
2492 | });
|
2493 | };
|
2494 | MDCRippleFoundation.prototype.activateImpl = function (evt) {
|
2495 | var _this = this;
|
2496 | if (this.adapter.isSurfaceDisabled()) {
|
2497 | return;
|
2498 | }
|
2499 | var activationState = this.activationState;
|
2500 | if (activationState.isActivated) {
|
2501 | return;
|
2502 | }
|
2503 |
|
2504 | var previousActivationEvent = this.previousActivationEvent;
|
2505 | var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
|
2506 | if (isSameInteraction) {
|
2507 | return;
|
2508 | }
|
2509 | activationState.isActivated = true;
|
2510 | activationState.isProgrammatic = evt === undefined;
|
2511 | activationState.activationEvent = evt;
|
2512 | activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
|
2513 | var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
|
2514 | return _this.adapter.containsEventTarget(target);
|
2515 | });
|
2516 | if (hasActivatedChild) {
|
2517 |
|
2518 | this.resetActivationState();
|
2519 | return;
|
2520 | }
|
2521 | if (evt !== undefined) {
|
2522 | activatedTargets.push(evt.target);
|
2523 | this.registerDeactivationHandlers(evt);
|
2524 | }
|
2525 | activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
|
2526 | if (activationState.wasElementMadeActive) {
|
2527 | this.animateActivation();
|
2528 | }
|
2529 | requestAnimationFrame(function () {
|
2530 |
|
2531 | activatedTargets = [];
|
2532 | if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 |
|
2538 |
|
2539 | activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
|
2540 | if (activationState.wasElementMadeActive) {
|
2541 | _this.animateActivation();
|
2542 | }
|
2543 | }
|
2544 | if (!activationState.wasElementMadeActive) {
|
2545 |
|
2546 | _this.activationState = _this.defaultActivationState();
|
2547 | }
|
2548 | });
|
2549 | };
|
2550 | MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
|
2551 | return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
|
2552 | };
|
2553 | MDCRippleFoundation.prototype.animateActivation = function () {
|
2554 | var _this = this;
|
2555 | var _a = MDCRippleFoundation.strings,
|
2556 | VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
|
2557 | VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
|
2558 | var _b = MDCRippleFoundation.cssClasses,
|
2559 | FG_DEACTIVATION = _b.FG_DEACTIVATION,
|
2560 | FG_ACTIVATION = _b.FG_ACTIVATION;
|
2561 | var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
|
2562 | this.layoutInternal();
|
2563 | var translateStart = '';
|
2564 | var translateEnd = '';
|
2565 | if (!this.adapter.isUnbounded()) {
|
2566 | var _c = this.getFgTranslationCoordinates(),
|
2567 | startPoint = _c.startPoint,
|
2568 | endPoint = _c.endPoint;
|
2569 | translateStart = startPoint.x + "px, " + startPoint.y + "px";
|
2570 | translateEnd = endPoint.x + "px, " + endPoint.y + "px";
|
2571 | }
|
2572 | this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
|
2573 | this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
|
2574 |
|
2575 | clearTimeout(this.activationTimer);
|
2576 | clearTimeout(this.fgDeactivationRemovalTimer);
|
2577 | this.rmBoundedActivationClasses();
|
2578 | this.adapter.removeClass(FG_DEACTIVATION);
|
2579 |
|
2580 | this.adapter.computeBoundingRect();
|
2581 | this.adapter.addClass(FG_ACTIVATION);
|
2582 | this.activationTimer = setTimeout(function () {
|
2583 | _this.activationTimerCallback();
|
2584 | }, DEACTIVATION_TIMEOUT_MS);
|
2585 | };
|
2586 | MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
|
2587 | var _a = this.activationState,
|
2588 | activationEvent = _a.activationEvent,
|
2589 | wasActivatedByPointer = _a.wasActivatedByPointer;
|
2590 | var startPoint;
|
2591 | if (wasActivatedByPointer) {
|
2592 | startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
|
2593 | } else {
|
2594 | startPoint = {
|
2595 | x: this.frame.width / 2,
|
2596 | y: this.frame.height / 2
|
2597 | };
|
2598 | }
|
2599 |
|
2600 | startPoint = {
|
2601 | x: startPoint.x - this.initialSize / 2,
|
2602 | y: startPoint.y - this.initialSize / 2
|
2603 | };
|
2604 | var endPoint = {
|
2605 | x: this.frame.width / 2 - this.initialSize / 2,
|
2606 | y: this.frame.height / 2 - this.initialSize / 2
|
2607 | };
|
2608 | return { startPoint: startPoint, endPoint: endPoint };
|
2609 | };
|
2610 | MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
|
2611 | var _this = this;
|
2612 |
|
2613 |
|
2614 | var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
|
2615 | var _a = this.activationState,
|
2616 | hasDeactivationUXRun = _a.hasDeactivationUXRun,
|
2617 | isActivated = _a.isActivated;
|
2618 | var activationHasEnded = hasDeactivationUXRun || !isActivated;
|
2619 | if (activationHasEnded && this.activationAnimationHasEnded) {
|
2620 | this.rmBoundedActivationClasses();
|
2621 | this.adapter.addClass(FG_DEACTIVATION);
|
2622 | this.fgDeactivationRemovalTimer = setTimeout(function () {
|
2623 | _this.adapter.removeClass(FG_DEACTIVATION);
|
2624 | }, constants_1.numbers.FG_DEACTIVATION_MS);
|
2625 | }
|
2626 | };
|
2627 | MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
|
2628 | var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
|
2629 | this.adapter.removeClass(FG_ACTIVATION);
|
2630 | this.activationAnimationHasEnded = false;
|
2631 | this.adapter.computeBoundingRect();
|
2632 | };
|
2633 | MDCRippleFoundation.prototype.resetActivationState = function () {
|
2634 | var _this = this;
|
2635 | this.previousActivationEvent = this.activationState.activationEvent;
|
2636 | this.activationState = this.defaultActivationState();
|
2637 |
|
2638 |
|
2639 | setTimeout(function () {
|
2640 | return _this.previousActivationEvent = undefined;
|
2641 | }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
|
2642 | };
|
2643 | MDCRippleFoundation.prototype.deactivateImpl = function () {
|
2644 | var _this = this;
|
2645 | var activationState = this.activationState;
|
2646 |
|
2647 | if (!activationState.isActivated) {
|
2648 | return;
|
2649 | }
|
2650 | var state = __assign({}, activationState);
|
2651 | if (activationState.isProgrammatic) {
|
2652 | requestAnimationFrame(function () {
|
2653 | _this.animateDeactivation(state);
|
2654 | });
|
2655 | this.resetActivationState();
|
2656 | } else {
|
2657 | this.deregisterDeactivationHandlers();
|
2658 | requestAnimationFrame(function () {
|
2659 | _this.activationState.hasDeactivationUXRun = true;
|
2660 | _this.animateDeactivation(state);
|
2661 | _this.resetActivationState();
|
2662 | });
|
2663 | }
|
2664 | };
|
2665 | MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
|
2666 | var wasActivatedByPointer = _a.wasActivatedByPointer,
|
2667 | wasElementMadeActive = _a.wasElementMadeActive;
|
2668 | if (wasActivatedByPointer || wasElementMadeActive) {
|
2669 | this.runDeactivationUXLogicIfReady();
|
2670 | }
|
2671 | };
|
2672 | MDCRippleFoundation.prototype.layoutInternal = function () {
|
2673 | var _this = this;
|
2674 | this.frame = this.adapter.computeBoundingRect();
|
2675 | var maxDim = Math.max(this.frame.height, this.frame.width);
|
2676 |
|
2677 |
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 | var getBoundedRadius = function getBoundedRadius() {
|
2683 | var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
|
2684 | return hypotenuse + MDCRippleFoundation.numbers.PADDING;
|
2685 | };
|
2686 | this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
|
2687 |
|
2688 | var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
|
2689 |
|
2690 | if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
|
2691 | this.initialSize = initialSize - 1;
|
2692 | } else {
|
2693 | this.initialSize = initialSize;
|
2694 | }
|
2695 | this.fgScale = "" + this.maxRadius / this.initialSize;
|
2696 | this.updateLayoutCssVars();
|
2697 | };
|
2698 | MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
|
2699 | var _a = MDCRippleFoundation.strings,
|
2700 | VAR_FG_SIZE = _a.VAR_FG_SIZE,
|
2701 | VAR_LEFT = _a.VAR_LEFT,
|
2702 | VAR_TOP = _a.VAR_TOP,
|
2703 | VAR_FG_SCALE = _a.VAR_FG_SCALE;
|
2704 | this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
|
2705 | this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
|
2706 | if (this.adapter.isUnbounded()) {
|
2707 | this.unboundedCoords = {
|
2708 | left: Math.round(this.frame.width / 2 - this.initialSize / 2),
|
2709 | top: Math.round(this.frame.height / 2 - this.initialSize / 2)
|
2710 | };
|
2711 | this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
|
2712 | this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
|
2713 | }
|
2714 | };
|
2715 | return MDCRippleFoundation;
|
2716 | }(foundation_1.MDCFoundation);
|
2717 | exports.MDCRippleFoundation = MDCRippleFoundation;
|
2718 |
|
2719 | exports.default = MDCRippleFoundation;
|
2720 |
|
2721 | }),
|
2722 |
|
2723 | "./packages/mdc-ripple/util.ts":
|
2724 |
|
2725 |
|
2726 |
|
2727 |
|
2728 | (function(module, exports, __webpack_require__) {
|
2729 |
|
2730 | "use strict";
|
2731 |
|
2732 |
|
2733 | Object.defineProperty(exports, "__esModule", { value: true });
|
2734 | exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
|
2735 |
|
2736 |
|
2737 |
|
2738 |
|
2739 | var supportsCssVariables_;
|
2740 | function supportsCssVariables(windowObj, forceRefresh) {
|
2741 | if (forceRefresh === void 0) {
|
2742 | forceRefresh = false;
|
2743 | }
|
2744 | var CSS = windowObj.CSS;
|
2745 | var supportsCssVars = supportsCssVariables_;
|
2746 | if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
|
2747 | return supportsCssVariables_;
|
2748 | }
|
2749 | var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
|
2750 | if (!supportsFunctionPresent) {
|
2751 | return false;
|
2752 | }
|
2753 | var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
|
2754 |
|
2755 |
|
2756 | var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
|
2757 | supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
|
2758 | if (!forceRefresh) {
|
2759 | supportsCssVariables_ = supportsCssVars;
|
2760 | }
|
2761 | return supportsCssVars;
|
2762 | }
|
2763 | exports.supportsCssVariables = supportsCssVariables;
|
2764 | function getNormalizedEventCoords(evt, pageOffset, clientRect) {
|
2765 | if (!evt) {
|
2766 | return { x: 0, y: 0 };
|
2767 | }
|
2768 | var x = pageOffset.x,
|
2769 | y = pageOffset.y;
|
2770 | var documentX = x + clientRect.left;
|
2771 | var documentY = y + clientRect.top;
|
2772 | var normalizedX;
|
2773 | var normalizedY;
|
2774 |
|
2775 | if (evt.type === 'touchstart') {
|
2776 | var touchEvent = evt;
|
2777 | normalizedX = touchEvent.changedTouches[0].pageX - documentX;
|
2778 | normalizedY = touchEvent.changedTouches[0].pageY - documentY;
|
2779 | } else {
|
2780 | var mouseEvent = evt;
|
2781 | normalizedX = mouseEvent.pageX - documentX;
|
2782 | normalizedY = mouseEvent.pageY - documentY;
|
2783 | }
|
2784 | return { x: normalizedX, y: normalizedY };
|
2785 | }
|
2786 | exports.getNormalizedEventCoords = getNormalizedEventCoords;
|
2787 |
|
2788 | })
|
2789 |
|
2790 | });
|
2791 | });
|
2792 |
|
\ | No newline at end of file |