vrembem 3.0.10 → 3.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,10 +9,9 @@
9
9
  descriptor.enumerable = descriptor.enumerable || false;
10
10
  descriptor.configurable = true;
11
11
  if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
12
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
13
13
  }
14
14
  }
15
-
16
15
  function _createClass(Constructor, protoProps, staticProps) {
17
16
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
18
17
  if (staticProps) _defineProperties(Constructor, staticProps);
@@ -21,31 +20,25 @@
21
20
  });
22
21
  return Constructor;
23
22
  }
24
-
25
23
  function _extends() {
26
24
  _extends = Object.assign ? Object.assign.bind() : function (target) {
27
25
  for (var i = 1; i < arguments.length; i++) {
28
26
  var source = arguments[i];
29
-
30
27
  for (var key in source) {
31
28
  if (Object.prototype.hasOwnProperty.call(source, key)) {
32
29
  target[key] = source[key];
33
30
  }
34
31
  }
35
32
  }
36
-
37
33
  return target;
38
34
  };
39
35
  return _extends.apply(this, arguments);
40
36
  }
41
-
42
37
  function _inheritsLoose(subClass, superClass) {
43
38
  subClass.prototype = Object.create(superClass.prototype);
44
39
  subClass.prototype.constructor = subClass;
45
-
46
40
  _setPrototypeOf(subClass, superClass);
47
41
  }
48
-
49
42
  function _setPrototypeOf(o, p) {
50
43
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
51
44
  o.__proto__ = p;
@@ -53,31 +46,38 @@
53
46
  };
54
47
  return _setPrototypeOf(o, p);
55
48
  }
56
-
57
49
  function _assertThisInitialized(self) {
58
50
  if (self === void 0) {
59
51
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
60
52
  }
61
-
62
53
  return self;
63
54
  }
64
-
55
+ function _toPrimitive(input, hint) {
56
+ if (typeof input !== "object" || input === null) return input;
57
+ var prim = input[Symbol.toPrimitive];
58
+ if (prim !== undefined) {
59
+ var res = prim.call(input, hint || "default");
60
+ if (typeof res !== "object") return res;
61
+ throw new TypeError("@@toPrimitive must return a primitive value.");
62
+ }
63
+ return (hint === "string" ? String : Number)(input);
64
+ }
65
+ function _toPropertyKey(arg) {
66
+ var key = _toPrimitive(arg, "string");
67
+ return typeof key === "symbol" ? key : String(key);
68
+ }
65
69
  var id = 0;
66
-
67
70
  function _classPrivateFieldLooseKey(name) {
68
71
  return "__private_" + id++ + "_" + name;
69
72
  }
70
-
71
73
  function _classPrivateFieldLooseBase(receiver, privateKey) {
72
74
  if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
73
75
  throw new TypeError("attempted to use private field on non-instance");
74
76
  }
75
-
76
77
  return receiver;
77
78
  }
78
79
 
79
80
  var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler");
80
-
81
81
  var Breakpoint = /*#__PURE__*/function () {
82
82
  function Breakpoint(value, handler) {
83
83
  Object.defineProperty(this, _handler, {
@@ -88,52 +88,53 @@
88
88
  _classPrivateFieldLooseBase(this, _handler)[_handler] = handler;
89
89
  this.mql = null;
90
90
  }
91
-
92
91
  var _proto = Breakpoint.prototype;
93
-
94
92
  _proto.mount = function mount(value, handler) {
95
93
  // Update passed params.
96
94
  if (value) this.value = value;
97
- if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler; // Guard if no breakpoint was set.
95
+ if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler;
98
96
 
99
- if (!this.value) return this; // Setup and store the MediaQueryList instance.
97
+ // Guard if no breakpoint was set.
98
+ if (!this.value) return this;
100
99
 
101
- this.mql = window.matchMedia("(min-width: " + this.value + ")"); // Conditionally use addListener() for IE11 support.
100
+ // Setup and store the MediaQueryList instance.
101
+ this.mql = window.matchMedia("(min-width: " + this.value + ")");
102
102
 
103
+ // Conditionally use addListener() for IE11 support.
103
104
  if (typeof this.mql.addEventListener === 'function') {
104
105
  this.mql.addEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);
105
106
  } else {
106
107
  this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
107
- } // Run the handler.
108
-
108
+ }
109
109
 
110
+ // Run the handler.
110
111
  _classPrivateFieldLooseBase(this, _handler)[_handler](this.mql);
111
-
112
112
  return this;
113
113
  };
114
-
115
114
  _proto.unmount = function unmount() {
116
115
  // Guard if no MediaQueryList instance exists.
117
- if (!this.mql) return this; // Conditionally use removeListener() for IE11 support.
116
+ if (!this.mql) return this;
118
117
 
118
+ // Conditionally use removeListener() for IE11 support.
119
119
  if (typeof this.mql.removeEventListener === 'function') {
120
120
  this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);
121
121
  } else {
122
122
  this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
123
- } // Set value, handler and MediaQueryList to null.
124
-
123
+ }
125
124
 
125
+ // Set value, handler and MediaQueryList to null.
126
126
  this.value = null;
127
127
  _classPrivateFieldLooseBase(this, _handler)[_handler] = null;
128
128
  this.mql = null;
129
129
  return this;
130
130
  };
131
-
132
131
  _createClass(Breakpoint, [{
133
132
  key: "handler",
134
133
  get: function get() {
135
134
  return _classPrivateFieldLooseBase(this, _handler)[_handler];
136
- } // Unmount existing handler before setting a new one.
135
+ }
136
+
137
+ // Unmount existing handler before setting a new one.
137
138
  ,
138
139
  set: function set(func) {
139
140
  if (this.mql) {
@@ -144,11 +145,9 @@
144
145
  this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
145
146
  }
146
147
  }
147
-
148
148
  _classPrivateFieldLooseBase(this, _handler)[_handler] = func;
149
149
  }
150
150
  }]);
151
-
152
151
  return Breakpoint;
153
152
  }();
154
153
 
@@ -159,56 +158,45 @@
159
158
  if (state & 1) {
160
159
  state = value.s;
161
160
  }
162
-
163
161
  value = value.v;
164
162
  } else {
165
163
  value.o = _settle.bind(null, pact, state);
166
164
  return;
167
165
  }
168
166
  }
169
-
170
167
  if (value && value.then) {
171
168
  value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
172
169
  return;
173
170
  }
174
-
175
171
  pact.s = state;
176
172
  pact.v = value;
177
- var observer = pact.o;
178
-
173
+ const observer = pact.o;
179
174
  if (observer) {
180
175
  observer(pact);
181
176
  }
182
177
  }
183
178
  }
184
-
185
179
  var _Pact = /*#__PURE__*/function () {
186
180
  function _Pact() {}
187
-
188
181
  _Pact.prototype.then = function (onFulfilled, onRejected) {
189
182
  var result = new _Pact();
190
183
  var state = this.s;
191
-
192
184
  if (state) {
193
185
  var callback = state & 1 ? onFulfilled : onRejected;
194
-
195
186
  if (callback) {
196
187
  try {
197
188
  _settle(result, 1, callback(this.v));
198
189
  } catch (e) {
199
190
  _settle(result, 2, e);
200
191
  }
201
-
202
192
  return result;
203
193
  } else {
204
194
  return this;
205
195
  }
206
196
  }
207
-
208
197
  this.o = function (_this) {
209
198
  try {
210
199
  var value = _this.v;
211
-
212
200
  if (_this.s & 1) {
213
201
  _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
214
202
  } else if (onRejected) {
@@ -220,38 +208,28 @@
220
208
  _settle(result, 2, e);
221
209
  }
222
210
  };
223
-
224
211
  return result;
225
212
  };
226
-
227
213
  return _Pact;
228
214
  }();
229
-
230
215
  function _isSettledPact(thenable) {
231
216
  return thenable instanceof _Pact && thenable.s & 1;
232
217
  }
233
-
234
218
  function _for(test, update, body) {
235
219
  var stage;
236
-
237
220
  for (;;) {
238
221
  var shouldContinue = test();
239
-
240
222
  if (_isSettledPact(shouldContinue)) {
241
223
  shouldContinue = shouldContinue.v;
242
224
  }
243
-
244
225
  if (!shouldContinue) {
245
226
  return result;
246
227
  }
247
-
248
228
  if (shouldContinue.then) {
249
229
  stage = 0;
250
230
  break;
251
231
  }
252
-
253
232
  var result = body();
254
-
255
233
  if (result && result.then) {
256
234
  if (_isSettledPact(result)) {
257
235
  result = result.s;
@@ -260,64 +238,47 @@
260
238
  break;
261
239
  }
262
240
  }
263
-
264
241
  if (update) {
265
242
  var updateValue = update();
266
-
267
243
  if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
268
244
  stage = 2;
269
245
  break;
270
246
  }
271
247
  }
272
248
  }
273
-
274
249
  var pact = new _Pact();
275
-
276
250
  var reject = _settle.bind(null, pact, 2);
277
-
278
251
  (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
279
252
  return pact;
280
-
281
253
  function _resumeAfterBody(value) {
282
254
  result = value;
283
-
284
255
  do {
285
256
  if (update) {
286
257
  updateValue = update();
287
-
288
258
  if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
289
259
  updateValue.then(_resumeAfterUpdate).then(void 0, reject);
290
260
  return;
291
261
  }
292
262
  }
293
-
294
263
  shouldContinue = test();
295
-
296
264
  if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
297
265
  _settle(pact, 1, result);
298
-
299
266
  return;
300
267
  }
301
-
302
268
  if (shouldContinue.then) {
303
269
  shouldContinue.then(_resumeAfterTest).then(void 0, reject);
304
270
  return;
305
271
  }
306
-
307
272
  result = body();
308
-
309
273
  if (_isSettledPact(result)) {
310
274
  result = result.v;
311
275
  }
312
276
  } while (!result || !result.then);
313
-
314
277
  result.then(_resumeAfterBody).then(void 0, reject);
315
278
  }
316
-
317
279
  function _resumeAfterTest(shouldContinue) {
318
280
  if (shouldContinue) {
319
281
  result = body();
320
-
321
282
  if (result && result.then) {
322
283
  result.then(_resumeAfterBody).then(void 0, reject);
323
284
  } else {
@@ -327,7 +288,6 @@
327
288
  _settle(pact, 1, result);
328
289
  }
329
290
  }
330
-
331
291
  function _resumeAfterUpdate() {
332
292
  if (shouldContinue = test()) {
333
293
  if (shouldContinue.then) {
@@ -340,55 +300,43 @@
340
300
  }
341
301
  }
342
302
  }
343
-
344
303
  var Collection = /*#__PURE__*/function () {
345
304
  function Collection() {
346
305
  this.collection = [];
347
306
  }
348
-
349
307
  var _proto = Collection.prototype;
350
-
351
308
  _proto.register = function register(item) {
352
309
  try {
353
310
  var _this2 = this;
354
-
355
311
  return Promise.resolve(_this2.deregister(item)).then(function () {
356
312
  _this2.collection.push(item);
357
-
358
313
  return _this2.collection;
359
314
  });
360
315
  } catch (e) {
361
316
  return Promise.reject(e);
362
317
  }
363
318
  };
364
-
365
319
  _proto.deregister = function deregister(ref) {
366
320
  try {
367
321
  var _this4 = this;
368
-
369
322
  var index = _this4.collection.findIndex(function (entry) {
370
323
  return entry === ref;
371
324
  });
372
-
373
325
  if (index >= 0) {
374
326
  var entry = _this4.collection[index];
375
327
  Object.getOwnPropertyNames(entry).forEach(function (prop) {
376
328
  delete entry[prop];
377
329
  });
378
-
379
330
  _this4.collection.splice(index, 1);
380
331
  }
381
-
382
332
  return Promise.resolve(_this4.collection);
383
333
  } catch (e) {
384
334
  return Promise.reject(e);
385
335
  }
386
336
  };
387
-
388
337
  _proto.registerCollection = function registerCollection(items) {
389
338
  try {
390
339
  var _this6 = this;
391
-
392
340
  return Promise.resolve(Promise.all(Array.from(items, function (item) {
393
341
  _this6.register(item);
394
342
  }))).then(function () {
@@ -398,41 +346,34 @@
398
346
  return Promise.reject(e);
399
347
  }
400
348
  };
401
-
402
349
  _proto.deregisterCollection = function deregisterCollection() {
403
350
  try {
404
351
  var _temp3 = function _temp3() {
405
352
  return _this8.collection;
406
353
  };
407
-
408
354
  var _this8 = this;
409
-
410
355
  var _temp4 = _for(function () {
411
356
  return _this8.collection.length > 0;
412
357
  }, void 0, function () {
413
358
  return Promise.resolve(_this8.deregister(_this8.collection[0])).then(function () {});
414
359
  });
415
-
416
360
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
417
361
  } catch (e) {
418
362
  return Promise.reject(e);
419
363
  }
420
364
  };
421
-
422
365
  _proto.get = function get(value, key) {
423
366
  if (key === void 0) {
424
367
  key = 'id';
425
368
  }
426
-
427
369
  return this.collection.find(function (item) {
428
370
  return item[key] === value;
429
371
  });
430
372
  };
431
-
432
373
  return Collection;
433
374
  }();
434
375
 
435
- var focusableSelectors = [
376
+ var e = [
436
377
  'a[href]:not([tabindex^="-"])',
437
378
  'area[href]:not([tabindex^="-"])',
438
379
  'input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])',
@@ -448,21 +389,16 @@
448
389
  ];
449
390
 
450
391
  var _focusable = /*#__PURE__*/_classPrivateFieldLooseKey("focusable");
451
-
452
392
  var _handleFocusTrap = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusTrap");
453
-
454
393
  var _handleFocusLock = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusLock");
455
-
456
394
  var FocusTrap = /*#__PURE__*/function () {
457
395
  function FocusTrap(el, selectorFocus) {
458
396
  if (el === void 0) {
459
397
  el = null;
460
398
  }
461
-
462
399
  if (selectorFocus === void 0) {
463
400
  selectorFocus = '[data-focus]';
464
401
  }
465
-
466
402
  Object.defineProperty(this, _focusable, {
467
403
  writable: true,
468
404
  value: void 0
@@ -480,73 +416,73 @@
480
416
  _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap] = handleFocusTrap.bind(this);
481
417
  _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock] = handleFocusLock.bind(this);
482
418
  }
483
-
484
419
  var _proto = FocusTrap.prototype;
485
-
486
420
  _proto.mount = function mount(el, selectorFocus) {
487
421
  // Update passed params.
488
422
  if (el) this.el = el;
489
- if (selectorFocus) this.selectorFocus = selectorFocus; // Get the focusable elements.
423
+ if (selectorFocus) this.selectorFocus = selectorFocus;
490
424
 
491
- this.focusable = this.getFocusable(); // Set the focus on the element.
425
+ // Get the focusable elements.
426
+ this.focusable = this.getFocusable();
492
427
 
428
+ // Set the focus on the element.
493
429
  this.focus();
494
430
  };
495
-
496
431
  _proto.unmount = function unmount() {
497
432
  // Set element to null.
498
- this.el = null; // Apply empty array to focusable.
433
+ this.el = null;
499
434
 
500
- this.focusable = []; // Remove event listeners
435
+ // Apply empty array to focusable.
436
+ this.focusable = [];
501
437
 
438
+ // Remove event listeners
502
439
  document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
503
440
  document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
504
441
  };
505
-
506
442
  _proto.focus = function focus(el, selectorFocus) {
507
443
  if (el === void 0) {
508
444
  el = this.el;
509
445
  }
510
-
511
446
  if (selectorFocus === void 0) {
512
447
  selectorFocus = this.selectorFocus;
513
448
  }
514
-
515
449
  // Query for the focus selector, otherwise return this element.
516
- var result = el.querySelector(selectorFocus) || el; // Give the returned element focus.
517
-
450
+ var result = el.querySelector(selectorFocus) || el;
451
+ // Give the returned element focus.
518
452
  result.focus();
519
453
  };
520
-
521
454
  _proto.getFocusable = function getFocusable(el) {
522
455
  if (el === void 0) {
523
456
  el = this.el;
524
457
  }
525
-
526
458
  // Initialize the focusable array.
527
- var focusable = []; // Store the initial focus and scroll position.
459
+ var focusable = [];
528
460
 
461
+ // Store the initial focus and scroll position.
529
462
  var initFocus = document.activeElement;
530
- var initScrollTop = el.scrollTop; // Query for all the focusable elements.
463
+ var initScrollTop = el.scrollTop;
531
464
 
532
- var els = el.querySelectorAll(focusableSelectors.join(',')); // Loop through all focusable elements.
465
+ // Query for all the focusable elements.
466
+ var els = el.querySelectorAll(e.join(','));
533
467
 
468
+ // Loop through all focusable elements.
534
469
  els.forEach(function (el) {
535
470
  // Set them to focus and check
536
- el.focus(); // Test that the element took focus.
537
-
471
+ el.focus();
472
+ // Test that the element took focus.
538
473
  if (document.activeElement === el) {
539
474
  // Add element to the focusable array.
540
475
  focusable.push(el);
541
476
  }
542
- }); // Restore the initial scroll position and focus.
477
+ });
543
478
 
479
+ // Restore the initial scroll position and focus.
544
480
  el.scrollTop = initScrollTop;
545
- initFocus.focus(); // Return the focusable array.
481
+ initFocus.focus();
546
482
 
483
+ // Return the focusable array.
547
484
  return focusable;
548
485
  };
549
-
550
486
  _createClass(FocusTrap, [{
551
487
  key: "focusable",
552
488
  get: function get() {
@@ -554,8 +490,9 @@
554
490
  },
555
491
  set: function set(value) {
556
492
  // Update the focusable value.
557
- _classPrivateFieldLooseBase(this, _focusable)[_focusable] = value; // Apply event listeners based on new focusable array length.
493
+ _classPrivateFieldLooseBase(this, _focusable)[_focusable] = value;
558
494
 
495
+ // Apply event listeners based on new focusable array length.
559
496
  if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) {
560
497
  document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
561
498
  document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
@@ -575,15 +512,14 @@
575
512
  return this.focusable[this.focusable.length - 1];
576
513
  }
577
514
  }]);
578
-
579
515
  return FocusTrap;
580
516
  }();
581
-
582
517
  function handleFocusTrap(event) {
583
518
  // Check if the click was a tab and return if not.
584
519
  var isTab = event.key === 'Tab' || event.keyCode === 9;
585
- if (!isTab) return; // If the shift key is pressed.
520
+ if (!isTab) return;
586
521
 
522
+ // If the shift key is pressed.
587
523
  if (event.shiftKey) {
588
524
  // If the active element is either the root el or first focusable.
589
525
  if (document.activeElement === this.focusableFirst || document.activeElement === this.el) {
@@ -600,7 +536,6 @@
600
536
  }
601
537
  }
602
538
  }
603
-
604
539
  function handleFocusLock(event) {
605
540
  // Ignore the tab key by preventing default.
606
541
  var isTab = event.key === 'Tab' || event.keyCode === 9;
@@ -621,7 +556,6 @@
621
556
  if (enable === void 0) {
622
557
  enable = true;
623
558
  }
624
-
625
559
  var local = localStorage.getItem(key);
626
560
  var store = local ? JSON.parse(local) : {};
627
561
  return {
@@ -634,7 +568,6 @@
634
568
  } else {
635
569
  delete store[prop];
636
570
  }
637
-
638
571
  if (enable) localStorage.setItem(key, JSON.stringify(store));
639
572
  return store;
640
573
  }
@@ -655,31 +588,37 @@
655
588
  function teleport(what, where, how) {
656
589
  // Check if ref is either a comment or element node.
657
590
  var isComment = where.nodeType === Node.COMMENT_NODE;
658
- var isElement = where.nodeType === Node.ELEMENT_NODE; // Get the reference element.
591
+ var isElement = where.nodeType === Node.ELEMENT_NODE;
659
592
 
660
- where = isComment || isElement ? where : document.querySelector(where); // If ref is a comment, set teleport type to 'after'.
593
+ // Get the reference element.
594
+ where = isComment || isElement ? where : document.querySelector(where);
661
595
 
662
- if (isComment) how = 'after'; // Must be a valid reference element and method.
596
+ // If ref is a comment, set teleport type to 'after'.
597
+ if (isComment) how = 'after';
663
598
 
599
+ // Must be a valid reference element and method.
664
600
  if (!where) throw new Error("Not a valid teleport reference: '" + where + "'");
665
- if (typeof where[how] != 'function') throw new Error("Not a valid teleport method: '" + how + "'"); // Initial return ref is null.
601
+ if (typeof where[how] != 'function') throw new Error("Not a valid teleport method: '" + how + "'");
666
602
 
667
- var returnRef = null; // If ref is not a comment, set a return reference comment.
603
+ // Initial return ref is null.
604
+ var returnRef = null;
668
605
 
606
+ // If ref is not a comment, set a return reference comment.
669
607
  if (!isComment) {
670
608
  returnRef = document.createComment('teleported #' + what.id);
671
609
  what.before(returnRef);
672
- } // Teleport the target node.
673
-
610
+ }
674
611
 
675
- where[how](what); // Delete the comment node if element was returned to a comment reference.
612
+ // Teleport the target node.
613
+ where[how](what);
676
614
 
615
+ // Delete the comment node if element was returned to a comment reference.
677
616
  if (isComment) {
678
617
  where.remove();
679
- } // Return the return reference if it was teleported else return null if it was
680
- // returned to a comment reference.
681
-
618
+ }
682
619
 
620
+ // Return the return reference if it was teleported else return null if it was
621
+ // returned to a comment reference.
683
622
  return returnRef;
684
623
  }
685
624
 
@@ -732,7 +671,6 @@
732
671
  });
733
672
  }
734
673
  }
735
-
736
674
  function setInert(state, selector) {
737
675
  if (selector) {
738
676
  var els = document.querySelectorAll(selector);
@@ -747,11 +685,11 @@
747
685
  });
748
686
  }
749
687
  }
750
-
751
688
  function updateGlobalState(param, config) {
752
689
  // Set inert state based on if a modal is active.
753
- setInert(!!param, config.selectorInert); // Set overflow state based on if a modal is active.
690
+ setInert(!!param, config.selectorInert);
754
691
 
692
+ // Set overflow state based on if a modal is active.
755
693
  setOverflowHidden(!!param, config.selectorOverflow);
756
694
  }
757
695
 
@@ -782,25 +720,20 @@
782
720
  this.__handlerClick = this.handlerClick.bind(this);
783
721
  if (this.settings.autoInit) this.init();
784
722
  }
785
-
786
723
  var _proto = Checkbox.prototype;
787
-
788
724
  _proto.init = function init(options) {
789
725
  if (options === void 0) {
790
726
  options = null;
791
727
  }
792
-
793
728
  if (options) this.settings = _extends({}, this.settings, options);
794
729
  var selector = "[" + this.settings.stateAttr + "=\"" + this.settings.stateValue + "\"]";
795
730
  var mixed = document.querySelectorAll(selector);
796
731
  this.setIndeterminate(mixed);
797
732
  document.addEventListener('click', this.__handlerClick, false);
798
733
  };
799
-
800
734
  _proto.destroy = function destroy() {
801
735
  document.removeEventListener('click', this.__handlerClick, false);
802
736
  };
803
-
804
737
  _proto.handlerClick = function handlerClick(event) {
805
738
  var selector = "[" + this.settings.stateAttr + "=\"" + this.settings.stateValue + "\"]";
806
739
  var el = event.target.closest(selector);
@@ -808,32 +741,25 @@
808
741
  this.removeAriaState(el);
809
742
  this.setIndeterminate(el);
810
743
  };
811
-
812
744
  _proto.setAriaState = function setAriaState(el, value) {
813
745
  var _this = this;
814
-
815
746
  if (value === void 0) {
816
747
  value = this.settings.stateValue;
817
748
  }
818
-
819
749
  el = el.forEach ? el : [el];
820
750
  el.forEach(function (el) {
821
751
  el.setAttribute(_this.settings.stateAttr, value);
822
752
  });
823
753
  };
824
-
825
754
  _proto.removeAriaState = function removeAriaState(el) {
826
755
  var _this2 = this;
827
-
828
756
  el = el.forEach ? el : [el];
829
757
  el.forEach(function (el) {
830
758
  el.removeAttribute(_this2.settings.stateAttr);
831
759
  });
832
760
  };
833
-
834
761
  _proto.setIndeterminate = function setIndeterminate(el) {
835
762
  var _this3 = this;
836
-
837
763
  el = el.forEach ? el : [el];
838
764
  el.forEach(function (el) {
839
765
  if (el.hasAttribute(_this3.settings.stateAttr)) {
@@ -843,7 +769,6 @@
843
769
  }
844
770
  });
845
771
  };
846
-
847
772
  return Checkbox;
848
773
  }();
849
774
 
@@ -880,68 +805,61 @@
880
805
 
881
806
  function handleClick$2(event) {
882
807
  var _this = this;
883
-
884
808
  // If an open, close or toggle button was clicked, handle the click event.
885
809
  var trigger = event.target.closest("\n [data-" + this.settings.dataOpen + "],\n [data-" + this.settings.dataToggle + "],\n [data-" + this.settings.dataClose + "]\n ");
886
-
887
810
  if (trigger) {
888
811
  // Prevent the default behavior of the trigger.
889
- event.preventDefault(); // If it's a toggle trigger...
812
+ event.preventDefault();
890
813
 
814
+ // If it's a toggle trigger...
891
815
  if (trigger.matches("[data-" + this.settings.dataToggle + "]")) {
892
816
  var selectors = trigger.getAttribute("data-" + this.settings.dataToggle).trim().split(' ');
893
817
  selectors.forEach(function (selector) {
894
818
  // Get the entry from collection using the attribute value.
895
- var entry = _this.get(selector); // Store the trigger on the entry.
896
-
897
-
898
- entry.trigger = trigger; // Toggle the drawer
899
-
819
+ var entry = _this.get(selector);
820
+ // Store the trigger on the entry.
821
+ entry.trigger = trigger;
822
+ // Toggle the drawer
900
823
  entry.toggle();
901
824
  });
902
- } // If it's a open trigger...
903
-
825
+ }
904
826
 
827
+ // If it's a open trigger...
905
828
  if (trigger.matches("[data-" + this.settings.dataOpen + "]")) {
906
829
  var _selectors = trigger.getAttribute("data-" + this.settings.dataOpen).trim().split(' ');
907
-
908
830
  _selectors.forEach(function (selector) {
909
831
  // Get the entry from collection using the attribute value.
910
- var entry = _this.get(selector); // Store the trigger on the entry.
911
-
912
-
913
- entry.trigger = trigger; // Open the drawer.
914
-
832
+ var entry = _this.get(selector);
833
+ // Store the trigger on the entry.
834
+ entry.trigger = trigger;
835
+ // Open the drawer.
915
836
  entry.open();
916
837
  });
917
- } // If it's a close trigger...
918
-
838
+ }
919
839
 
840
+ // If it's a close trigger...
920
841
  if (trigger.matches("[data-" + this.settings.dataClose + "]")) {
921
842
  var _selectors2 = trigger.getAttribute("data-" + this.settings.dataClose).trim().split(' ');
922
-
923
843
  _selectors2.forEach(function (selector) {
924
844
  if (selector) {
925
845
  // Get the entry from collection using the attribute value.
926
- var entry = _this.get(selector); // Store the trigger on the entry.
927
-
928
-
929
- entry.trigger = trigger; // Close the drawer.
930
-
846
+ var entry = _this.get(selector);
847
+ // Store the trigger on the entry.
848
+ entry.trigger = trigger;
849
+ // Close the drawer.
931
850
  entry.close();
932
851
  } else {
933
852
  // If no value is set on close trigger, get the parent drawer.
934
- var parent = event.target.closest(_this.settings.selectorDrawer); // If a parent drawer was found, close it.
935
-
853
+ var parent = event.target.closest(_this.settings.selectorDrawer);
854
+ // If a parent drawer was found, close it.
936
855
  if (parent) _this.close(parent);
937
856
  }
938
857
  });
939
858
  }
940
-
941
859
  return;
942
- } // If the modal drawer screen was clicked...
943
-
860
+ }
944
861
 
862
+ // If the modal drawer screen was clicked...
945
863
  if (event.target.matches(this.settings.selectorDrawer)) {
946
864
  // Close the modal drawer.
947
865
  this.close(event.target.id);
@@ -958,53 +876,49 @@
958
876
  if (close === void 0) {
959
877
  close = true;
960
878
  }
961
-
962
879
  try {
963
880
  var _temp5 = function _temp5() {
964
881
  // Return the modified collection.
965
882
  return _this2.collection;
966
883
  };
967
-
968
884
  var _this2 = this;
969
-
970
885
  // Return collection if nothing was passed.
971
- if (!obj) return Promise.resolve(_this2.collection); // Check if entry has been registered in the collection.
886
+ if (!obj) return Promise.resolve(_this2.collection);
972
887
 
888
+ // Check if entry has been registered in the collection.
973
889
  var index = _this2.collection.findIndex(function (entry) {
974
890
  return entry.id === obj.id;
975
891
  });
976
-
977
892
  var _temp6 = function () {
978
893
  if (index >= 0) {
979
894
  var _temp7 = function _temp7() {
980
895
  // Remove entry from local store.
981
- _this2.store.set(_entry.id); // Unmount the MatchMedia functionality.
982
-
983
-
984
- _entry.unmountBreakpoint(); // Delete properties from collection entry.
896
+ _this2.store.set(_entry.id);
985
897
 
898
+ // Unmount the MatchMedia functionality.
899
+ _entry.unmountBreakpoint();
986
900
 
901
+ // Delete properties from collection entry.
987
902
  Object.getOwnPropertyNames(_entry).forEach(function (prop) {
988
903
  delete _entry[prop];
989
- }); // Remove entry from collection.
904
+ });
990
905
 
906
+ // Remove entry from collection.
991
907
  _this2.collection.splice(index, 1);
992
908
  };
993
-
994
909
  // Get the collection entry.
995
- var _entry = _this2.collection[index]; // If entry is in the opened state.
910
+ var _entry = _this2.collection[index];
996
911
 
912
+ // If entry is in the opened state.
997
913
  var _temp8 = function () {
998
914
  if (close && _entry.state === 'opened') {
999
915
  // Close the drawer.
1000
916
  return Promise.resolve(_entry.close(false)).then(function () {});
1001
917
  }
1002
918
  }();
1003
-
1004
919
  return _temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8);
1005
920
  }
1006
921
  }();
1007
-
1008
922
  return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));
1009
923
  } catch (e) {
1010
924
  return Promise.reject(e);
@@ -1018,7 +932,6 @@
1018
932
  function getBreakpoint(drawer) {
1019
933
  var prefix = g();
1020
934
  var bp = drawer.getAttribute("data-" + this.settings.dataBreakpoint);
1021
-
1022
935
  if (this.settings.breakpoints && this.settings.breakpoints[bp]) {
1023
936
  return this.settings.breakpoints[bp];
1024
937
  } else if (getComputedStyle(document.body).getPropertyValue("--" + prefix + "breakpoint-" + bp).trim()) {
@@ -1030,8 +943,9 @@
1030
943
 
1031
944
  function getDrawer(query) {
1032
945
  // Get the entry from collection.
1033
- var entry = typeof query === 'string' ? this.get(query) : this.get(query.id); // Return entry if it was resolved, otherwise throw error.
946
+ var entry = typeof query === 'string' ? this.get(query) : this.get(query.id);
1034
947
 
948
+ // Return entry if it was resolved, otherwise throw error.
1035
949
  if (entry) {
1036
950
  return entry;
1037
951
  } else {
@@ -1043,37 +957,49 @@
1043
957
  // If it's a string, return the string.
1044
958
  if (typeof obj === 'string') {
1045
959
  return obj;
1046
- } // If it's an HTML element.
960
+ }
961
+
962
+ // If it's an HTML element.
1047
963
  else if (typeof obj.hasAttribute === 'function') {
1048
964
  // If it's a drawer open trigger, return data value.
1049
965
  if (obj.hasAttribute("data-" + this.settings.dataOpen)) {
1050
966
  return obj.getAttribute("data-" + this.settings.dataOpen);
1051
- } // If it's a drawer close trigger, return data value or false.
967
+ }
968
+
969
+ // If it's a drawer close trigger, return data value or false.
1052
970
  else if (obj.hasAttribute("data-" + this.settings.dataClose)) {
1053
971
  return obj.getAttribute("data-" + this.settings.dataClose) || false;
1054
- } // If it's a drawer toggle trigger, return data value.
972
+ }
973
+
974
+ // If it's a drawer toggle trigger, return data value.
1055
975
  else if (obj.hasAttribute("data-" + this.settings.dataToggle)) {
1056
976
  return obj.getAttribute("data-" + this.settings.dataToggle);
1057
- } // If it's a drawer element, return the id.
977
+ }
978
+
979
+ // If it's a drawer element, return the id.
1058
980
  else if (obj.closest(this.settings.selectorDrawer)) {
1059
981
  obj = obj.closest(this.settings.selectorDrawer);
1060
982
  return obj.id || false;
1061
- } // Return false if no id was found.
983
+ }
984
+
985
+ // Return false if no id was found.
1062
986
  else return false;
1063
- } // If it has an id property, return its value.
987
+ }
988
+
989
+ // If it has an id property, return its value.
1064
990
  else if (obj.id) {
1065
991
  return obj.id;
1066
- } // Return false if no id was found.
992
+ }
993
+
994
+ // Return false if no id was found.
1067
995
  else return false;
1068
996
  }
1069
997
 
1070
998
  function getDrawerElements(query) {
1071
999
  var id = getDrawerID.call(this, query);
1072
-
1073
1000
  if (id) {
1074
1001
  var drawer = document.querySelector("#" + id);
1075
1002
  var dialog = drawer ? drawer.querySelector(this.settings.selectorDialog) : null;
1076
-
1077
1003
  if (!drawer && !dialog) {
1078
1004
  return {
1079
1005
  error: new Error("No drawer elements found using the ID: \"" + id + "\".")
@@ -1098,7 +1024,6 @@
1098
1024
  var initialState = function initialState(entry) {
1099
1025
  try {
1100
1026
  var _this2 = this;
1101
-
1102
1027
  var _temp3 = function () {
1103
1028
  if (_this2.store.get(entry.id)) {
1104
1029
  var _temp4 = function () {
@@ -1108,7 +1033,6 @@
1108
1033
  return Promise.resolve(entry.close(false, false)).then(function () {});
1109
1034
  }
1110
1035
  }();
1111
-
1112
1036
  if (_temp4 && _temp4.then) return _temp4.then(function () {});
1113
1037
  } else if (entry.el.classList.contains(_this2.settings.stateOpened)) {
1114
1038
  // Update drawer state.
@@ -1116,12 +1040,11 @@
1116
1040
  } else {
1117
1041
  // Remove transition state classes.
1118
1042
  entry.el.classList.remove(_this2.settings.stateOpening);
1119
- entry.el.classList.remove(_this2.settings.stateClosing); // Add closed state class.
1120
-
1043
+ entry.el.classList.remove(_this2.settings.stateClosing);
1044
+ // Add closed state class.
1121
1045
  entry.el.classList.add(_this2.settings.stateClosed);
1122
1046
  }
1123
1047
  }();
1124
-
1125
1048
  // Setup initial state using the following priority:
1126
1049
  // 1. If a store state is available, restore from local store.
1127
1050
  // 2. If opened state class is set, set state to opened.
@@ -1147,7 +1070,6 @@
1147
1070
  entry.trigger.focus();
1148
1071
  entry.trigger = null;
1149
1072
  }
1150
-
1151
1073
  this.focusTrap.unmount();
1152
1074
  }
1153
1075
  }
@@ -1156,47 +1078,48 @@
1156
1078
  if (focus === void 0) {
1157
1079
  focus = true;
1158
1080
  }
1159
-
1160
1081
  try {
1161
1082
  var _temp3 = function _temp3() {
1162
1083
  // Set focus to the drawer element if the focus param is true.
1163
1084
  if (focus) {
1164
1085
  updateFocusState$1.call(_this2, drawer);
1165
- } // Dispatch custom opened event.
1166
-
1086
+ }
1167
1087
 
1088
+ // Dispatch custom opened event.
1168
1089
  drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'opened', {
1169
1090
  detail: _this2,
1170
1091
  bubbles: true
1171
- })); // Return the drawer.
1092
+ }));
1172
1093
 
1094
+ // Return the drawer.
1173
1095
  return drawer;
1174
1096
  };
1175
-
1176
1097
  var _this2 = this;
1177
-
1178
1098
  // Get the drawer from collection.
1179
- var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
1099
+ var drawer = getDrawer.call(_this2, query);
1180
1100
 
1181
- var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
1101
+ // Get the modal configuration.
1102
+ var config = _extends({}, _this2.settings, drawer.settings);
1182
1103
 
1104
+ // Add transition parameter to configuration.
1105
+ if (transition !== undefined) config.transition = transition;
1183
1106
 
1184
- if (transition !== undefined) config.transition = transition; // If drawer is closed.
1185
-
1107
+ // If drawer is closed.
1186
1108
  var _temp4 = function () {
1187
1109
  if (drawer.state === 'closed') {
1188
1110
  // Update drawer state.
1189
- drawer.state = 'opening'; // Run the open transition.
1111
+ drawer.state = 'opening';
1190
1112
 
1113
+ // Run the open transition.
1191
1114
  return Promise.resolve(openTransition(drawer.el, config)).then(function () {
1192
1115
  // Update the global state if mode is modal.
1193
- if (drawer.mode === 'modal') updateGlobalState(true, config); // Update drawer state.
1116
+ if (drawer.mode === 'modal') updateGlobalState(true, config);
1194
1117
 
1118
+ // Update drawer state.
1195
1119
  drawer.state = 'opened';
1196
1120
  });
1197
1121
  }
1198
1122
  }();
1199
-
1200
1123
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
1201
1124
  } catch (e) {
1202
1125
  return Promise.reject(e);
@@ -1207,36 +1130,40 @@
1207
1130
  if (focus === void 0) {
1208
1131
  focus = true;
1209
1132
  }
1210
-
1211
1133
  try {
1212
1134
  var _this2 = this;
1213
-
1214
1135
  // Get the drawer from collection.
1215
- var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
1216
-
1217
- var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
1136
+ var drawer = getDrawer.call(_this2, query);
1218
1137
 
1138
+ // Get the modal configuration.
1139
+ var config = _extends({}, _this2.settings, drawer.settings);
1219
1140
 
1220
- if (transition !== undefined) config.transition = transition; // If drawer is opened.
1141
+ // Add transition parameter to configuration.
1142
+ if (transition !== undefined) config.transition = transition;
1221
1143
 
1144
+ // If drawer is opened.
1222
1145
  var _temp2 = function () {
1223
1146
  if (drawer.state === 'opened') {
1224
1147
  // Update drawer state.
1225
- drawer.state = 'closing'; // Remove focus from active element.
1148
+ drawer.state = 'closing';
1226
1149
 
1227
- document.activeElement.blur(); // Run the close transition.
1150
+ // Remove focus from active element.
1151
+ document.activeElement.blur();
1228
1152
 
1153
+ // Run the close transition.
1229
1154
  return Promise.resolve(closeTransition(drawer.el, config)).then(function () {
1230
1155
  // Update the global state if mode is modal.
1231
- if (drawer.mode === 'modal') updateGlobalState(false, config); // Set focus to the trigger element if the focus param is true.
1156
+ if (drawer.mode === 'modal') updateGlobalState(false, config);
1232
1157
 
1158
+ // Set focus to the trigger element if the focus param is true.
1233
1159
  if (focus) {
1234
1160
  updateFocusState$1.call(_this2, drawer);
1235
- } // Update drawer state.
1236
-
1161
+ }
1237
1162
 
1238
- drawer.state = 'closed'; // Dispatch custom closed event.
1163
+ // Update drawer state.
1164
+ drawer.state = 'closed';
1239
1165
 
1166
+ // Dispatch custom closed event.
1240
1167
  drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'closed', {
1241
1168
  detail: _this2,
1242
1169
  bubbles: true
@@ -1244,7 +1171,6 @@
1244
1171
  });
1245
1172
  }
1246
1173
  }();
1247
-
1248
1174
  return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {
1249
1175
  // Return the drawer.
1250
1176
  return drawer;
@@ -1257,10 +1183,10 @@
1257
1183
  var toggle = function toggle(query, transition, focus) {
1258
1184
  try {
1259
1185
  var _this2 = this;
1260
-
1261
1186
  // Get the drawer from collection.
1262
- var drawer = getDrawer.call(_this2, query); // Open or close the drawer based on its current state.
1187
+ var drawer = getDrawer.call(_this2, query);
1263
1188
 
1189
+ // Open or close the drawer based on its current state.
1264
1190
  if (drawer.state === 'closed') {
1265
1191
  return Promise.resolve(open$2.call(_this2, drawer, transition, focus));
1266
1192
  } else {
@@ -1274,69 +1200,71 @@
1274
1200
  var toModal = function toModal(entry) {
1275
1201
  try {
1276
1202
  var _this4 = this;
1277
-
1278
1203
  // Get the drawer configuration.
1204
+
1279
1205
  // Add the modal class.
1280
- entry.el.classList.add(entry.getSetting('classModal')); // Set aria-modal attribute to true.
1206
+ entry.el.classList.add(entry.getSetting('classModal'));
1281
1207
 
1282
- entry.dialog.setAttribute('aria-modal', 'true'); // If there isn't a stored state but also has the opened state class...
1208
+ // Set aria-modal attribute to true.
1209
+ entry.dialog.setAttribute('aria-modal', 'true');
1283
1210
 
1211
+ // If there isn't a stored state but also has the opened state class...
1284
1212
  if (!_this4.store.get(entry.id) && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
1285
1213
  // Save the opened state in local store.
1286
1214
  _this4.store.set(entry.id, 'opened');
1287
- } // Modal drawer defaults to closed state.
1288
-
1215
+ }
1289
1216
 
1217
+ // Modal drawer defaults to closed state.
1290
1218
  return Promise.resolve(close$2.call(_this4, entry, false, false)).then(function () {
1291
1219
  // Dispatch custom switch event.
1292
1220
  entry.el.dispatchEvent(new CustomEvent(entry.getSetting('customEventPrefix') + 'switchMode', {
1293
1221
  detail: _this4,
1294
1222
  bubbles: true
1295
- })); // Return the entry.
1223
+ }));
1296
1224
 
1225
+ // Return the entry.
1297
1226
  return entry;
1298
1227
  });
1299
1228
  } catch (e) {
1300
1229
  return Promise.reject(e);
1301
1230
  }
1302
1231
  };
1303
-
1304
1232
  var toInline = function toInline(entry) {
1305
1233
  try {
1306
1234
  var _this2 = this;
1307
-
1308
1235
  // Remove the modal class.
1309
- entry.el.classList.remove(entry.getSetting('classModal')); // Remove the aria-modal attribute.
1236
+ entry.el.classList.remove(entry.getSetting('classModal'));
1310
1237
 
1311
- entry.dialog.removeAttribute('aria-modal'); // Update the global state.
1238
+ // Remove the aria-modal attribute.
1239
+ entry.dialog.removeAttribute('aria-modal');
1312
1240
 
1313
- updateGlobalState(false, _extends({}, _this2.settings, entry.settings)); // Remove any focus traps.
1314
-
1315
- _this2.focusTrap.unmount(); // Setup initial state.
1241
+ // Update the global state.
1242
+ updateGlobalState(false, _extends({}, _this2.settings, entry.settings));
1316
1243
 
1244
+ // Remove any focus traps.
1245
+ _this2.focusTrap.unmount();
1317
1246
 
1247
+ // Setup initial state.
1318
1248
  return Promise.resolve(initialState.call(_this2, entry)).then(function () {
1319
1249
  // Dispatch custom switch event.
1320
1250
  entry.el.dispatchEvent(new CustomEvent(entry.getSetting('customEventPrefix') + 'switchMode', {
1321
1251
  detail: _this2,
1322
1252
  bubbles: true
1323
- })); // Return the entry.
1253
+ }));
1324
1254
 
1255
+ // Return the entry.
1325
1256
  return entry;
1326
1257
  });
1327
1258
  } catch (e) {
1328
1259
  return Promise.reject(e);
1329
1260
  }
1330
1261
  };
1331
-
1332
1262
  function switchMode(entry) {
1333
1263
  switch (entry.mode) {
1334
1264
  case 'inline':
1335
1265
  return toInline.call(this, entry);
1336
-
1337
1266
  case 'modal':
1338
1267
  return toModal.call(this, entry);
1339
-
1340
1268
  default:
1341
1269
  throw new Error("\"" + entry.mode + "\" is not a valid drawer mode.");
1342
1270
  }
@@ -1345,14 +1273,15 @@
1345
1273
  var register$2 = function register(el, dialog) {
1346
1274
  try {
1347
1275
  var _this2 = this;
1348
-
1349
1276
  // Deregister entry incase it has already been registered.
1350
1277
  return Promise.resolve(deregister$2.call(_this2, el, false)).then(function () {
1351
1278
  // Save root this for use inside methods API.
1352
- var root = _this2; // Create an instance of the Breakpoint class.
1279
+ var root = _this2;
1353
1280
 
1354
- var breakpoint = new Breakpoint(); // Setup methods API.
1281
+ // Create an instance of the Breakpoint class.
1282
+ var breakpoint = new Breakpoint();
1355
1283
 
1284
+ // Setup methods API.
1356
1285
  var methods = {
1357
1286
  open: function open(transition, focus) {
1358
1287
  return open$2.call(root, this, transition, focus);
@@ -1383,66 +1312,61 @@
1383
1312
  getSetting: function getSetting(key) {
1384
1313
  return key in this.settings ? this.settings[key] : root.settings[key];
1385
1314
  }
1386
- }; // Setup the drawer object.
1315
+ };
1387
1316
 
1317
+ // Setup the drawer object.
1388
1318
  var entry = _extends({
1389
1319
  id: el.id,
1390
1320
  el: el,
1391
1321
  dialog: dialog,
1392
1322
  trigger: null,
1393
1323
  settings: getConfig$1(el, _this2.settings.dataConfig),
1394
-
1395
1324
  get breakpoint() {
1396
1325
  return getBreakpoint.call(root, el);
1397
1326
  },
1398
-
1399
1327
  get state() {
1400
1328
  return __state;
1401
1329
  },
1402
-
1403
1330
  set state(value) {
1404
- __state = value; // Save 'opened' and 'closed' states to store if mode is inline.
1405
-
1331
+ __state = value;
1332
+ // Save 'opened' and 'closed' states to store if mode is inline.
1406
1333
  if (value === 'opened' || value === 'closed') {
1407
1334
  if (this.mode === 'inline') root.store.set(this.id, this.state);
1408
1335
  }
1409
1336
  },
1410
-
1411
1337
  get mode() {
1412
1338
  return __mode;
1413
1339
  },
1414
-
1415
1340
  set mode(value) {
1416
1341
  __mode = value;
1417
1342
  switchMode.call(root, this);
1418
1343
  }
1344
+ }, methods);
1419
1345
 
1420
- }, methods); // Create the state var with the initial state.
1421
-
1422
-
1423
- var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed'; // Create the mode var with the initial mode.
1424
-
1425
-
1426
- var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline'; // Setup mode specific attributes.
1346
+ // Create the state var with the initial state.
1347
+ var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed';
1427
1348
 
1349
+ // Create the mode var with the initial mode.
1350
+ var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline';
1428
1351
 
1352
+ // Setup mode specific attributes.
1429
1353
  if (entry.mode === 'modal') {
1430
1354
  // Set aria-modal attribute to true.
1431
1355
  entry.dialog.setAttribute('aria-modal', 'true');
1432
1356
  } else {
1433
1357
  // Remove the aria-modal attribute.
1434
1358
  entry.dialog.removeAttribute('aria-modal');
1435
- } // Set tabindex="-1" so dialog is focusable via JS or click.
1436
-
1359
+ }
1437
1360
 
1361
+ // Set tabindex="-1" so dialog is focusable via JS or click.
1438
1362
  if (entry.getSetting('setTabindex')) {
1439
1363
  entry.dialog.setAttribute('tabindex', '-1');
1440
- } // Add entry to collection.
1441
-
1442
-
1443
- _this2.collection.push(entry); // If the entry has a breakpoint...
1364
+ }
1444
1365
 
1366
+ // Add entry to collection.
1367
+ _this2.collection.push(entry);
1445
1368
 
1369
+ // If the entry has a breakpoint...
1446
1370
  var _temp = function () {
1447
1371
  if (entry.breakpoint) {
1448
1372
  // Mount media query breakpoint functionality.
@@ -1452,7 +1376,6 @@
1452
1376
  return Promise.resolve(initialState.call(_this2, entry)).then(function () {});
1453
1377
  }
1454
1378
  }();
1455
-
1456
1379
  return _temp && _temp.then ? _temp.then(function () {
1457
1380
  // Return the registered entry.
1458
1381
  return entry;
@@ -1464,15 +1387,11 @@
1464
1387
  };
1465
1388
 
1466
1389
  var _handleClick$1 = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
1467
-
1468
1390
  var _handleKeydown$2 = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
1469
-
1470
1391
  var Drawer = /*#__PURE__*/function (_Collection) {
1471
1392
  _inheritsLoose(Drawer, _Collection);
1472
-
1473
1393
  function Drawer(options) {
1474
1394
  var _this;
1475
-
1476
1395
  _this = _Collection.call(this) || this;
1477
1396
  Object.defineProperty(_assertThisInitialized(_this), _handleClick$1, {
1478
1397
  writable: true,
@@ -1484,96 +1403,81 @@
1484
1403
  });
1485
1404
  _this.defaults = defaults$2;
1486
1405
  _this.settings = _extends({}, _this.defaults, options);
1487
- _this.focusTrap = new FocusTrap(); // Setup local store for inline drawer state management.
1406
+ _this.focusTrap = new FocusTrap();
1488
1407
 
1408
+ // Setup local store for inline drawer state management.
1489
1409
  _this.store = localStore(_this.settings.storeKey, _this.settings.store);
1490
1410
  _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleClick$1)[_handleClick$1] = handleClick$2.bind(_assertThisInitialized(_this));
1491
1411
  _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleKeydown$2)[_handleKeydown$2] = handleKeydown$2.bind(_assertThisInitialized(_this));
1492
1412
  if (_this.settings.autoInit) _this.init();
1493
1413
  return _this;
1494
1414
  }
1495
-
1496
1415
  var _proto = Drawer.prototype;
1497
-
1498
1416
  _proto.init = function init(options) {
1499
1417
  if (options === void 0) {
1500
1418
  options = null;
1501
1419
  }
1502
-
1503
1420
  try {
1504
1421
  var _this3 = this;
1505
-
1506
1422
  // Update settings with passed options.
1507
- if (options) _this3.settings = _extends({}, _this3.settings, options); // Get all the modals.
1423
+ if (options) _this3.settings = _extends({}, _this3.settings, options);
1508
1424
 
1509
- var drawers = document.querySelectorAll(_this3.settings.selectorDrawer); // Register the collections array with modal instances.
1425
+ // Get all the modals.
1426
+ var drawers = document.querySelectorAll(_this3.settings.selectorDrawer);
1510
1427
 
1428
+ // Register the collections array with modal instances.
1511
1429
  return Promise.resolve(_this3.registerCollection(drawers)).then(function () {
1512
1430
  // If eventListeners are enabled, init event listeners.
1513
1431
  if (_this3.settings.eventListeners) {
1514
1432
  _this3.initEventListeners();
1515
1433
  }
1516
-
1517
1434
  return _this3;
1518
1435
  });
1519
1436
  } catch (e) {
1520
1437
  return Promise.reject(e);
1521
1438
  }
1522
1439
  };
1523
-
1524
1440
  _proto.destroy = function destroy() {
1525
1441
  try {
1526
1442
  var _this5 = this;
1527
-
1528
1443
  // Remove all entries from the collection.
1529
1444
  return Promise.resolve(_this5.deregisterCollection()).then(function () {
1530
1445
  // If eventListeners are enabled, init event listeners.
1531
1446
  if (_this5.settings.eventListeners) {
1532
1447
  _this5.destroyEventListeners();
1533
1448
  }
1534
-
1535
1449
  return _this5;
1536
1450
  });
1537
1451
  } catch (e) {
1538
1452
  return Promise.reject(e);
1539
1453
  }
1540
1454
  };
1541
-
1542
1455
  _proto.initEventListeners = function initEventListeners() {
1543
1456
  document.addEventListener('click', _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
1544
- document.addEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
1545
1457
  document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown$2)[_handleKeydown$2], false);
1546
1458
  };
1547
-
1548
1459
  _proto.destroyEventListeners = function destroyEventListeners() {
1549
1460
  document.removeEventListener('click', _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
1550
- document.removeEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
1551
1461
  document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown$2)[_handleKeydown$2], false);
1552
1462
  };
1553
-
1554
1463
  _proto.register = function register(query) {
1555
1464
  var els = getDrawerElements.call(this, query);
1556
1465
  if (els.error) return Promise.reject(els.error);
1557
1466
  return register$2.call(this, els.drawer, els.dialog);
1558
1467
  };
1559
-
1560
1468
  _proto.deregister = function deregister(query) {
1561
1469
  var entry = this.get(getDrawerID.call(this, query));
1562
1470
  return deregister$2.call(this, entry);
1563
1471
  };
1564
-
1565
1472
  _proto.open = function open(id, transition, focus) {
1566
1473
  return open$2.call(this, id, transition, focus);
1567
1474
  };
1568
-
1569
1475
  _proto.close = function close(id, transition, focus) {
1570
1476
  return close$2.call(this, id, transition, focus);
1571
1477
  };
1572
-
1573
1478
  _proto.toggle = function toggle$1(id, transition, focus) {
1574
1479
  return toggle.call(this, id, transition, focus);
1575
1480
  };
1576
-
1577
1481
  _createClass(Drawer, [{
1578
1482
  key: "activeModal",
1579
1483
  get: function get() {
@@ -1582,7 +1486,6 @@
1582
1486
  });
1583
1487
  }
1584
1488
  }]);
1585
-
1586
1489
  return Drawer;
1587
1490
  }(Collection);
1588
1491
 
@@ -1616,8 +1519,9 @@
1616
1519
 
1617
1520
  function getModal(query) {
1618
1521
  // Get the entry from collection.
1619
- var entry = typeof query === 'string' ? this.get(query) : this.get(query.id); // Return entry if it was resolved, otherwise throw error.
1522
+ var entry = typeof query === 'string' ? this.get(query) : this.get(query.id);
1620
1523
 
1524
+ // Return entry if it was resolved, otherwise throw error.
1621
1525
  if (entry) {
1622
1526
  return entry;
1623
1527
  } else {
@@ -1629,37 +1533,49 @@
1629
1533
  // If it's a string, return the string.
1630
1534
  if (typeof obj === 'string') {
1631
1535
  return obj;
1632
- } // If it's an HTML element.
1536
+ }
1537
+
1538
+ // If it's an HTML element.
1633
1539
  else if (typeof obj.hasAttribute === 'function') {
1634
1540
  // If it's a modal open trigger, return data value.
1635
1541
  if (obj.hasAttribute("data-" + this.settings.dataOpen)) {
1636
1542
  return obj.getAttribute("data-" + this.settings.dataOpen);
1637
- } // If it's a modal close trigger, return data value or false.
1543
+ }
1544
+
1545
+ // If it's a modal close trigger, return data value or false.
1638
1546
  else if (obj.hasAttribute("data-" + this.settings.dataClose)) {
1639
1547
  return obj.getAttribute("data-" + this.settings.dataClose) || false;
1640
- } // If it's a modal replace trigger, return data value.
1548
+ }
1549
+
1550
+ // If it's a modal replace trigger, return data value.
1641
1551
  else if (obj.hasAttribute("data-" + this.settings.dataReplace)) {
1642
1552
  return obj.getAttribute("data-" + this.settings.dataReplace);
1643
- } // If it's a modal element, return the id.
1553
+ }
1554
+
1555
+ // If it's a modal element, return the id.
1644
1556
  else if (obj.closest(this.settings.selectorModal)) {
1645
1557
  obj = obj.closest(this.settings.selectorModal);
1646
1558
  return obj.id || false;
1647
- } // Return false if no id was found.
1559
+ }
1560
+
1561
+ // Return false if no id was found.
1648
1562
  else return false;
1649
- } // If it has an id property, return its value.
1563
+ }
1564
+
1565
+ // If it has an id property, return its value.
1650
1566
  else if (obj.id) {
1651
1567
  return obj.id;
1652
- } // Return false if no id was found.
1568
+ }
1569
+
1570
+ // Return false if no id was found.
1653
1571
  else return false;
1654
1572
  }
1655
1573
 
1656
1574
  function getModalElements(query) {
1657
1575
  var id = getModalID.call(this, query);
1658
-
1659
1576
  if (id) {
1660
1577
  var modal = document.querySelector("#" + id);
1661
1578
  var dialog = modal ? modal.querySelector(this.settings.selectorDialog) : null;
1662
-
1663
1579
  if (!modal && !dialog) {
1664
1580
  return {
1665
1581
  error: new Error("No modal elements found using the ID: \"" + id + "\".")
@@ -1692,7 +1608,6 @@
1692
1608
  this.trigger.focus();
1693
1609
  this.trigger = null;
1694
1610
  }
1695
-
1696
1611
  this.focusTrap.unmount();
1697
1612
  }
1698
1613
  }
@@ -1700,38 +1615,33 @@
1700
1615
  var handleClick$1 = function handleClick(event) {
1701
1616
  try {
1702
1617
  var _this2 = this;
1703
-
1704
1618
  // If an open or replace button was clicked, open or replace the modal.
1705
1619
  var trigger = event.target.closest("[data-" + _this2.settings.dataOpen + "], [data-" + _this2.settings.dataReplace + "]");
1706
-
1707
1620
  if (trigger) {
1708
- event.preventDefault(); // Save the trigger if it's not coming from inside a modal.
1709
-
1621
+ event.preventDefault();
1622
+ // Save the trigger if it's not coming from inside a modal.
1710
1623
  var fromModal = event.target.closest(_this2.settings.selectorModal);
1711
- if (!fromModal) _this2.trigger = trigger; // Get the modal.
1712
-
1713
- var modal = _this2.get(getModalID.call(_this2, trigger)); // Depending on the button type, either open or replace the modal.
1714
-
1715
-
1624
+ if (!fromModal) _this2.trigger = trigger;
1625
+ // Get the modal.
1626
+ var modal = _this2.get(getModalID.call(_this2, trigger));
1627
+ // Depending on the button type, either open or replace the modal.
1716
1628
  return Promise.resolve(trigger.matches("[data-" + _this2.settings.dataOpen + "]") ? modal.open() : modal.replace());
1717
- } // If a close button was clicked, close the modal.
1718
-
1629
+ }
1719
1630
 
1631
+ // If a close button was clicked, close the modal.
1720
1632
  trigger = event.target.closest("[data-" + _this2.settings.dataClose + "]");
1721
-
1722
1633
  if (trigger) {
1723
- event.preventDefault(); // Get the value of the data attribute.
1724
-
1725
- var value = trigger.getAttribute("data-" + _this2.settings.dataClose); // Close all if * wildcard is passed, otherwise close a single modal.
1726
-
1634
+ event.preventDefault();
1635
+ // Get the value of the data attribute.
1636
+ var value = trigger.getAttribute("data-" + _this2.settings.dataClose);
1637
+ // Close all if * wildcard is passed, otherwise close a single modal.
1727
1638
  return Promise.resolve(value === '*' ? _this2.closeAll() : _this2.close(value));
1728
- } // If the modal screen was clicked, close the modal.
1729
-
1639
+ }
1730
1640
 
1641
+ // If the modal screen was clicked, close the modal.
1731
1642
  if (event.target.matches(_this2.settings.selectorModal) && !event.target.querySelector(_this2.settings.selectorRequired)) {
1732
1643
  return Promise.resolve(_this2.close(getModalID.call(_this2, event.target)));
1733
1644
  }
1734
-
1735
1645
  return Promise.resolve();
1736
1646
  } catch (e) {
1737
1647
  return Promise.reject(e);
@@ -1751,41 +1661,39 @@
1751
1661
  if (close === void 0) {
1752
1662
  close = true;
1753
1663
  }
1754
-
1755
1664
  try {
1756
1665
  var _temp5 = function _temp5() {
1757
1666
  // Return the modified collection.
1758
1667
  return _this2.collection;
1759
1668
  };
1760
-
1761
1669
  var _this2 = this;
1762
-
1763
1670
  // Return collection if nothing was passed.
1764
- if (!obj) return Promise.resolve(_this2.collection); // Check if entry has been registered in the collection.
1671
+ if (!obj) return Promise.resolve(_this2.collection);
1765
1672
 
1673
+ // Check if entry has been registered in the collection.
1766
1674
  var index = _this2.collection.findIndex(function (entry) {
1767
1675
  return entry.id === obj.id;
1768
1676
  });
1769
-
1770
1677
  var _temp6 = function () {
1771
1678
  if (index >= 0) {
1772
1679
  var _temp7 = function _temp7() {
1773
1680
  // Return teleported modal if a reference has been set.
1774
1681
  if (_entry.getSetting('teleport')) {
1775
1682
  _entry.teleportReturn();
1776
- } // Delete properties from collection entry.
1777
-
1683
+ }
1778
1684
 
1685
+ // Delete properties from collection entry.
1779
1686
  Object.getOwnPropertyNames(_entry).forEach(function (prop) {
1780
1687
  delete _entry[prop];
1781
- }); // Remove entry from collection.
1688
+ });
1782
1689
 
1690
+ // Remove entry from collection.
1783
1691
  _this2.collection.splice(index, 1);
1784
1692
  };
1785
-
1786
1693
  // Get the collection entry.
1787
- var _entry = _this2.collection[index]; // If entry is in the opened state, close it.
1694
+ var _entry = _this2.collection[index];
1788
1695
 
1696
+ // If entry is in the opened state, close it.
1789
1697
  var _temp8 = function () {
1790
1698
  if (close && _entry.state === 'opened') {
1791
1699
  return Promise.resolve(_entry.close(false)).then(function () {});
@@ -1794,11 +1702,9 @@
1794
1702
  _this2.stack.remove(_entry);
1795
1703
  }
1796
1704
  }();
1797
-
1798
1705
  return _temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8);
1799
1706
  }
1800
1707
  }();
1801
-
1802
1708
  return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));
1803
1709
  } catch (e) {
1804
1710
  return Promise.reject(e);
@@ -1809,51 +1715,51 @@
1809
1715
  if (focus === void 0) {
1810
1716
  focus = true;
1811
1717
  }
1812
-
1813
1718
  try {
1814
1719
  var _temp3 = function _temp3() {
1815
1720
  // Update focus if the focus param is true.
1816
1721
  if (focus) {
1817
1722
  updateFocusState.call(_this2);
1818
- } // Dispatch custom opened event.
1819
-
1723
+ }
1820
1724
 
1725
+ // Dispatch custom opened event.
1821
1726
  modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'opened', {
1822
1727
  detail: _this2,
1823
1728
  bubbles: true
1824
- })); // Return the modal.
1729
+ }));
1825
1730
 
1731
+ // Return the modal.
1826
1732
  return modal;
1827
1733
  };
1828
-
1829
1734
  var _this2 = this;
1830
-
1831
1735
  // Get the modal from collection.
1832
- var modal = getModal.call(_this2, query); // Get the modal configuration.
1833
-
1834
- var config = _extends({}, _this2.settings, modal.settings); // Add transition parameter to configuration.
1835
-
1736
+ var modal = getModal.call(_this2, query);
1836
1737
 
1837
- if (transition !== undefined) config.transition = transition; // Maybe add modal to top of stack.
1738
+ // Get the modal configuration.
1739
+ var config = _extends({}, _this2.settings, modal.settings);
1838
1740
 
1839
- _this2.stack.moveToTop(modal); // If modal is closed.
1741
+ // Add transition parameter to configuration.
1742
+ if (transition !== undefined) config.transition = transition;
1840
1743
 
1744
+ // Maybe add modal to top of stack.
1745
+ _this2.stack.moveToTop(modal);
1841
1746
 
1747
+ // If modal is closed.
1842
1748
  var _temp4 = function () {
1843
1749
  if (modal.state === 'closed') {
1844
1750
  // Update modal state.
1845
- modal.state = 'opening'; // Add modal to stack.
1846
-
1847
- _this2.stack.add(modal); // Run the open transition.
1751
+ modal.state = 'opening';
1848
1752
 
1753
+ // Add modal to stack.
1754
+ _this2.stack.add(modal);
1849
1755
 
1756
+ // Run the open transition.
1850
1757
  return Promise.resolve(openTransition(modal.el, config)).then(function () {
1851
1758
  // Update modal state.
1852
1759
  modal.state = 'opened';
1853
1760
  });
1854
1761
  }
1855
1762
  }();
1856
-
1857
1763
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
1858
1764
  } catch (e) {
1859
1765
  return Promise.reject(e);
@@ -1864,37 +1770,40 @@
1864
1770
  if (focus === void 0) {
1865
1771
  focus = true;
1866
1772
  }
1867
-
1868
1773
  try {
1869
1774
  var _this2 = this;
1870
-
1871
1775
  // Get the modal from collection, or top modal in stack if no query is provided.
1872
- var modal = query ? getModal.call(_this2, query) : _this2.active; // If a modal exists and its state is opened.
1776
+ var modal = query ? getModal.call(_this2, query) : _this2.active;
1873
1777
 
1778
+ // If a modal exists and its state is opened.
1874
1779
  var _temp2 = function () {
1875
1780
  if (modal && modal.state === 'opened') {
1876
1781
  // Update modal state.
1877
- modal.state = 'closing'; // Get the modal configuration.
1782
+ modal.state = 'closing';
1878
1783
 
1879
- var config = _extends({}, _this2.settings, modal.settings); // Add transition parameter to configuration.
1784
+ // Get the modal configuration.
1785
+ var config = _extends({}, _this2.settings, modal.settings);
1880
1786
 
1787
+ // Add transition parameter to configuration.
1788
+ if (transition !== undefined) config.transition = transition;
1881
1789
 
1882
- if (transition !== undefined) config.transition = transition; // Remove focus from active element.
1883
-
1884
- document.activeElement.blur(); // Run the close transition.
1790
+ // Remove focus from active element.
1791
+ document.activeElement.blur();
1885
1792
 
1793
+ // Run the close transition.
1886
1794
  return Promise.resolve(closeTransition(modal.el, config)).then(function () {
1887
1795
  // Remove modal from stack.
1888
- _this2.stack.remove(modal); // Update focus if the focus param is true.
1889
-
1796
+ _this2.stack.remove(modal);
1890
1797
 
1798
+ // Update focus if the focus param is true.
1891
1799
  if (focus) {
1892
1800
  updateFocusState.call(_this2);
1893
- } // Update modal state.
1894
-
1801
+ }
1895
1802
 
1896
- modal.state = 'closed'; // Dispatch custom closed event.
1803
+ // Update modal state.
1804
+ modal.state = 'closed';
1897
1805
 
1806
+ // Dispatch custom closed event.
1898
1807
  modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'closed', {
1899
1808
  detail: _this2,
1900
1809
  bubbles: true
@@ -1902,7 +1811,6 @@
1902
1811
  });
1903
1812
  }
1904
1813
  }();
1905
-
1906
1814
  return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {
1907
1815
  // Return the modal.
1908
1816
  return modal;
@@ -1915,14 +1823,12 @@
1915
1823
  var closeAll$1 = function closeAll(exclude, transition) {
1916
1824
  try {
1917
1825
  var _this2 = this;
1918
-
1919
1826
  var result = [];
1920
1827
  return Promise.resolve(Promise.all(_this2.stack.value.map(function (modal) {
1921
1828
  try {
1922
1829
  var _temp3 = function _temp3() {
1923
1830
  modal.trigger = null;
1924
1831
  };
1925
-
1926
1832
  var _temp4 = function () {
1927
1833
  if (exclude && exclude === modal.id) {
1928
1834
  Promise.resolve();
@@ -1933,7 +1839,6 @@
1933
1839
  });
1934
1840
  }
1935
1841
  }();
1936
-
1937
1842
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
1938
1843
  } catch (e) {
1939
1844
  return Promise.reject(e);
@@ -1950,28 +1855,25 @@
1950
1855
  if (focus === void 0) {
1951
1856
  focus = true;
1952
1857
  }
1953
-
1954
1858
  try {
1955
1859
  var _temp3 = function _temp3() {
1956
1860
  // Update focus if the focus param is true.
1957
1861
  if (focus) {
1958
1862
  updateFocusState.call(_this2);
1959
- } // Return the modals there were opened and closed.
1960
-
1863
+ }
1961
1864
 
1865
+ // Return the modals there were opened and closed.
1962
1866
  return {
1963
1867
  opened: resultOpened,
1964
1868
  closed: resultClosed
1965
1869
  };
1966
1870
  };
1967
-
1968
1871
  var _this2 = this;
1969
-
1970
1872
  // Get the modal from collection.
1971
- var modal = getModal.call(_this2, query); // Setup results for return.
1873
+ var modal = getModal.call(_this2, query);
1972
1874
 
1875
+ // Setup results for return.
1973
1876
  var resultOpened, resultClosed;
1974
-
1975
1877
  var _temp4 = function () {
1976
1878
  if (modal.state === 'opened') {
1977
1879
  // If modal is open, close all modals except for replacement.
@@ -1986,7 +1888,6 @@
1986
1888
  return Promise.resolve(Promise.all([resultOpened, resultClosed])).then(function () {});
1987
1889
  }
1988
1890
  }();
1989
-
1990
1891
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
1991
1892
  } catch (e) {
1992
1893
  return Promise.reject(e);
@@ -1996,12 +1897,12 @@
1996
1897
  var register$1 = function register(el, dialog) {
1997
1898
  try {
1998
1899
  var _this2 = this;
1999
-
2000
1900
  // Deregister entry incase it has already been registered.
2001
1901
  return Promise.resolve(deregister$1.call(_this2, el, false)).then(function () {
2002
1902
  // Save root this for use inside methods API.
2003
- var root = _this2; // Setup methods API.
1903
+ var root = _this2;
2004
1904
 
1905
+ // Setup methods API.
2005
1906
  var methods = {
2006
1907
  open: function open(transition, focus) {
2007
1908
  return open$1.call(root, this, transition, focus);
@@ -2019,11 +1920,9 @@
2019
1920
  if (ref === void 0) {
2020
1921
  ref = this.getSetting('teleport');
2021
1922
  }
2022
-
2023
1923
  if (method === void 0) {
2024
1924
  method = this.getSetting('teleportMethod');
2025
1925
  }
2026
-
2027
1926
  if (!this.returnRef) {
2028
1927
  this.returnRef = teleport(this.el, ref, method);
2029
1928
  return this.el;
@@ -2044,8 +1943,9 @@
2044
1943
  getSetting: function getSetting(key) {
2045
1944
  return key in this.settings ? this.settings[key] : root.settings[key];
2046
1945
  }
2047
- }; // Setup the modal object.
1946
+ };
2048
1947
 
1948
+ // Setup the modal object.
2049
1949
  var entry = _extends({
2050
1950
  id: el.id,
2051
1951
  state: 'closed',
@@ -2053,29 +1953,30 @@
2053
1953
  dialog: dialog,
2054
1954
  returnRef: null,
2055
1955
  settings: getConfig$1(el, _this2.settings.dataConfig)
2056
- }, methods); // Set aria-modal attribute to true.
2057
-
1956
+ }, methods);
2058
1957
 
2059
- entry.dialog.setAttribute('aria-modal', 'true'); // If a role attribute is not set, set it to "dialog" as the default.
1958
+ // Set aria-modal attribute to true.
1959
+ entry.dialog.setAttribute('aria-modal', 'true');
2060
1960
 
1961
+ // If a role attribute is not set, set it to "dialog" as the default.
2061
1962
  if (!entry.dialog.hasAttribute('role')) {
2062
1963
  entry.dialog.setAttribute('role', 'dialog');
2063
- } // Set tabindex="-1" so dialog is focusable via JS or click.
2064
-
1964
+ }
2065
1965
 
1966
+ // Set tabindex="-1" so dialog is focusable via JS or click.
2066
1967
  if (entry.getSetting('setTabindex')) {
2067
1968
  entry.dialog.setAttribute('tabindex', '-1');
2068
- } // Teleport modal if a reference has been set.
2069
-
1969
+ }
2070
1970
 
1971
+ // Teleport modal if a reference has been set.
2071
1972
  if (entry.getSetting('teleport')) {
2072
1973
  entry.teleport();
2073
- } // Add entry to collection.
2074
-
2075
-
2076
- _this2.collection.push(entry); // Setup initial state.
1974
+ }
2077
1975
 
1976
+ // Add entry to collection.
1977
+ _this2.collection.push(entry);
2078
1978
 
1979
+ // Setup initial state.
2079
1980
  var _temp = function () {
2080
1981
  if (entry.el.classList.contains(_this2.settings.stateOpened)) {
2081
1982
  // Open entry with transitions disabled.
@@ -2083,12 +1984,11 @@
2083
1984
  } else {
2084
1985
  // Remove transition state classes.
2085
1986
  entry.el.classList.remove(_this2.settings.stateOpening);
2086
- entry.el.classList.remove(_this2.settings.stateClosing); // Add closed state class.
2087
-
1987
+ entry.el.classList.remove(_this2.settings.stateClosing);
1988
+ // Add closed state class.
2088
1989
  entry.el.classList.add(_this2.settings.stateClosed);
2089
1990
  }
2090
1991
  }();
2091
-
2092
1992
  return _temp && _temp.then ? _temp.then(function () {
2093
1993
  // Return the registered entry.
2094
1994
  return entry;
@@ -2105,11 +2005,9 @@
2105
2005
  get value() {
2106
2006
  return [].concat(stackArray);
2107
2007
  },
2108
-
2109
2008
  get top() {
2110
2009
  return stackArray[stackArray.length - 1];
2111
2010
  },
2112
-
2113
2011
  updateIndex: function updateIndex() {
2114
2012
  stackArray.forEach(function (entry, index) {
2115
2013
  entry.el.style.zIndex = null;
@@ -2119,31 +2017,35 @@
2119
2017
  },
2120
2018
  updateGlobalState: function updateGlobalState$1() {
2121
2019
  updateGlobalState(this.top, settings);
2122
-
2123
2020
  this.updateIndex();
2124
2021
  },
2125
2022
  add: function add(entry) {
2126
2023
  // Apply z-index styles based on stack length.
2127
2024
  entry.el.style.zIndex = null;
2128
2025
  var value = getComputedStyle(entry.el)['z-index'];
2129
- entry.el.style.zIndex = parseInt(value) + stackArray.length + 1; // Move back to end of stack.
2026
+ entry.el.style.zIndex = parseInt(value) + stackArray.length + 1;
2130
2027
 
2131
- stackArray.push(entry); // Update the global state.
2028
+ // Move back to end of stack.
2029
+ stackArray.push(entry);
2132
2030
 
2031
+ // Update the global state.
2133
2032
  this.updateGlobalState();
2134
2033
  },
2135
2034
  remove: function remove(entry) {
2136
2035
  // Get the index of the entry.
2137
2036
  var index = stackArray.findIndex(function (item) {
2138
2037
  return item.id === entry.id;
2139
- }); // If entry is in stack...
2038
+ });
2140
2039
 
2040
+ // If entry is in stack...
2141
2041
  if (index >= 0) {
2142
2042
  // Remove z-index styles.
2143
- entry.el.style.zIndex = null; // Remove entry from stack array.
2043
+ entry.el.style.zIndex = null;
2144
2044
 
2145
- stackArray.splice(index, 1); // Update the global state.
2045
+ // Remove entry from stack array.
2046
+ stackArray.splice(index, 1);
2146
2047
 
2048
+ // Update the global state.
2147
2049
  this.updateGlobalState();
2148
2050
  }
2149
2051
  },
@@ -2151,12 +2053,14 @@
2151
2053
  // Get the index of the entry.
2152
2054
  var index = stackArray.findIndex(function (item) {
2153
2055
  return item.id === entry.id;
2154
- }); // If entry is in stack...
2056
+ });
2155
2057
 
2058
+ // If entry is in stack...
2156
2059
  if (index >= 0) {
2157
2060
  // Remove entry from stack array.
2158
- stackArray.splice(index, 1); // Add entry back to top of stack.
2061
+ stackArray.splice(index, 1);
2159
2062
 
2063
+ // Add entry back to top of stack.
2160
2064
  this.add(entry);
2161
2065
  }
2162
2066
  }
@@ -2164,15 +2068,11 @@
2164
2068
  }
2165
2069
 
2166
2070
  var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
2167
-
2168
2071
  var _handleKeydown$1 = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
2169
-
2170
2072
  var Modal = /*#__PURE__*/function (_Collection) {
2171
2073
  _inheritsLoose(Modal, _Collection);
2172
-
2173
2074
  function Modal(options) {
2174
2075
  var _this;
2175
-
2176
2076
  _this = _Collection.call(this) || this;
2177
2077
  Object.defineProperty(_assertThisInitialized(_this), _handleClick, {
2178
2078
  writable: true,
@@ -2185,126 +2085,107 @@
2185
2085
  _this.defaults = defaults$1;
2186
2086
  _this.settings = _extends({}, _this.defaults, options);
2187
2087
  _this.trigger = null;
2188
- _this.focusTrap = new FocusTrap(); // Setup stack module.
2088
+ _this.focusTrap = new FocusTrap();
2189
2089
 
2090
+ // Setup stack module.
2190
2091
  _this.stack = stack(_this.settings);
2191
2092
  _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleClick)[_handleClick] = handleClick$1.bind(_assertThisInitialized(_this));
2192
2093
  _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleKeydown$1)[_handleKeydown$1] = handleKeydown$1.bind(_assertThisInitialized(_this));
2193
2094
  if (_this.settings.autoInit) _this.init();
2194
2095
  return _this;
2195
2096
  }
2196
-
2197
2097
  var _proto = Modal.prototype;
2198
-
2199
2098
  _proto.init = function init(options) {
2200
2099
  try {
2201
2100
  var _this3 = this;
2202
-
2203
2101
  // Update settings with passed options.
2204
- if (options) _this3.settings = _extends({}, _this3.settings, options); // Get all the modals.
2102
+ if (options) _this3.settings = _extends({}, _this3.settings, options);
2205
2103
 
2206
- var modals = document.querySelectorAll(_this3.settings.selectorModal); // Register the collections array with modal instances.
2104
+ // Get all the modals.
2105
+ var modals = document.querySelectorAll(_this3.settings.selectorModal);
2207
2106
 
2107
+ // Register the collections array with modal instances.
2208
2108
  return Promise.resolve(_this3.registerCollection(modals)).then(function () {
2209
2109
  // If eventListeners are enabled, init event listeners.
2210
2110
  if (_this3.settings.eventListeners) {
2211
2111
  _this3.initEventListeners();
2212
2112
  }
2213
-
2214
2113
  return _this3;
2215
2114
  });
2216
2115
  } catch (e) {
2217
2116
  return Promise.reject(e);
2218
2117
  }
2219
2118
  };
2220
-
2221
2119
  _proto.destroy = function destroy() {
2222
2120
  try {
2223
2121
  var _this5 = this;
2224
-
2225
2122
  // Clear stored trigger.
2226
- _this5.trigger = null; // Remove all entries from the collection.
2123
+ _this5.trigger = null;
2227
2124
 
2125
+ // Remove all entries from the collection.
2228
2126
  return Promise.resolve(_this5.deregisterCollection()).then(function () {
2229
2127
  // If eventListeners are enabled, destroy event listeners.
2230
2128
  if (_this5.settings.eventListeners) {
2231
2129
  _this5.destroyEventListeners();
2232
2130
  }
2233
-
2234
2131
  return _this5;
2235
2132
  });
2236
2133
  } catch (e) {
2237
2134
  return Promise.reject(e);
2238
2135
  }
2239
2136
  };
2240
-
2241
2137
  _proto.initEventListeners = function initEventListeners() {
2242
2138
  document.addEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
2243
- document.addEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
2244
2139
  document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown$1)[_handleKeydown$1], false);
2245
2140
  };
2246
-
2247
2141
  _proto.destroyEventListeners = function destroyEventListeners() {
2248
2142
  document.removeEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
2249
- document.removeEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
2250
2143
  document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown$1)[_handleKeydown$1], false);
2251
2144
  };
2252
-
2253
2145
  _proto.register = function register(query) {
2254
2146
  var els = getModalElements.call(this, query);
2255
2147
  if (els.error) return Promise.reject(els.error);
2256
2148
  return register$1.call(this, els.modal, els.dialog);
2257
2149
  };
2258
-
2259
2150
  _proto.deregister = function deregister(query) {
2260
2151
  var modal = this.get(getModalID.call(this, query));
2261
2152
  return deregister$1.call(this, modal);
2262
2153
  };
2263
-
2264
2154
  _proto.open = function open(id, transition, focus) {
2265
2155
  return open$1.call(this, id, transition, focus);
2266
2156
  };
2267
-
2268
2157
  _proto.close = function close(id, transition, focus) {
2269
2158
  return close$1.call(this, id, transition, focus);
2270
2159
  };
2271
-
2272
2160
  _proto.replace = function replace$1(id, transition, focus) {
2273
2161
  return replace.call(this, id, transition, focus);
2274
2162
  };
2275
-
2276
2163
  _proto.closeAll = function closeAll(exclude, transition, focus) {
2277
2164
  if (exclude === void 0) {
2278
2165
  exclude = false;
2279
2166
  }
2280
-
2281
2167
  if (focus === void 0) {
2282
2168
  focus = true;
2283
2169
  }
2284
-
2285
2170
  try {
2286
2171
  var _this7 = this;
2287
-
2288
2172
  return Promise.resolve(closeAll$1.call(_this7, exclude, transition)).then(function (result) {
2289
2173
  // Update focus if the focus param is true.
2290
2174
  if (focus) {
2291
2175
  updateFocusState.call(_this7);
2292
2176
  }
2293
-
2294
2177
  return result;
2295
2178
  });
2296
2179
  } catch (e) {
2297
2180
  return Promise.reject(e);
2298
2181
  }
2299
2182
  };
2300
-
2301
2183
  _createClass(Modal, [{
2302
2184
  key: "active",
2303
2185
  get: function get() {
2304
2186
  return this.stack.top;
2305
2187
  }
2306
2188
  }]);
2307
-
2308
2189
  return Modal;
2309
2190
  }(Collection);
2310
2191
 
@@ -2323,8 +2204,9 @@
2323
2204
 
2324
2205
  function getConfig(el, settings) {
2325
2206
  // Get the computed styles of the element.
2326
- var styles = getComputedStyle(el); // Setup the config obj with default values.
2207
+ var styles = getComputedStyle(el);
2327
2208
 
2209
+ // Setup the config obj with default values.
2328
2210
  var config = {
2329
2211
  'placement': settings.placement,
2330
2212
  'event': settings.eventType,
@@ -2333,36 +2215,40 @@
2333
2215
  'flip-padding': 0,
2334
2216
  'arrow-element': settings.selectorArrow,
2335
2217
  'arrow-padding': 0
2336
- }; // Loop through config obj.
2218
+ };
2337
2219
 
2220
+ // Loop through config obj.
2338
2221
  for (var prop in config) {
2339
2222
  // Get the CSS variable property values.
2340
2223
  var prefix = g();
2341
- var value = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim(); // If a value was found, replace the default in config obj.
2224
+ var value = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim();
2342
2225
 
2226
+ // If a value was found, replace the default in config obj.
2343
2227
  if (value) {
2344
2228
  config[prop] = value;
2345
2229
  }
2346
- } // Return the config obj.
2347
-
2230
+ }
2348
2231
 
2232
+ // Return the config obj.
2349
2233
  return config;
2350
2234
  }
2351
2235
 
2352
2236
  function getPadding(value) {
2353
- var padding; // Split the value by spaces if it's a string.
2237
+ var padding;
2354
2238
 
2355
- var array = typeof value === 'string' ? value.trim().split(' ') : [value]; // Convert individual values to integers.
2239
+ // Split the value by spaces if it's a string.
2240
+ var array = typeof value === 'string' ? value.trim().split(' ') : [value];
2356
2241
 
2242
+ // Convert individual values to integers.
2357
2243
  array.forEach(function (item, index) {
2358
2244
  array[index] = parseInt(item, 10);
2359
- }); // Build the padding object based on the number of values passed.
2245
+ });
2360
2246
 
2247
+ // Build the padding object based on the number of values passed.
2361
2248
  switch (array.length) {
2362
2249
  case 1:
2363
2250
  padding = array[0];
2364
2251
  break;
2365
-
2366
2252
  case 2:
2367
2253
  padding = {
2368
2254
  top: array[0],
@@ -2371,7 +2257,6 @@
2371
2257
  left: array[1]
2372
2258
  };
2373
2259
  break;
2374
-
2375
2260
  case 3:
2376
2261
  padding = {
2377
2262
  top: array[0],
@@ -2380,7 +2265,6 @@
2380
2265
  left: array[1]
2381
2266
  };
2382
2267
  break;
2383
-
2384
2268
  case 4:
2385
2269
  padding = {
2386
2270
  top: array[0],
@@ -2389,13 +2273,12 @@
2389
2273
  left: array[3]
2390
2274
  };
2391
2275
  break;
2392
-
2393
2276
  default:
2394
2277
  padding = false;
2395
2278
  break;
2396
- } // Return the padding object.
2397
-
2279
+ }
2398
2280
 
2281
+ // Return the padding object.
2399
2282
  return padding;
2400
2283
  }
2401
2284
 
@@ -2426,8 +2309,9 @@
2426
2309
 
2427
2310
  function getPopover(query) {
2428
2311
  // Get the entry from collection.
2429
- var entry = typeof query === 'string' ? this.get(query) : this.get(query.id); // Return entry if it was resolved, otherwise throw error.
2312
+ var entry = typeof query === 'string' ? this.get(query) : this.get(query.id);
2430
2313
 
2314
+ // Return entry if it was resolved, otherwise throw error.
2431
2315
  if (entry) {
2432
2316
  return entry;
2433
2317
  } else {
@@ -2439,34 +2323,44 @@
2439
2323
  // If it's a string, return the string.
2440
2324
  if (typeof obj === 'string') {
2441
2325
  return obj;
2442
- } // If it's an HTML element.
2326
+ }
2327
+
2328
+ // If it's an HTML element.
2443
2329
  else if (typeof obj.hasAttribute === 'function') {
2444
2330
  // If it's a popover element, return the id.
2445
2331
  if (obj.closest(this.settings.selectorPopover)) {
2446
2332
  obj = obj.closest(this.settings.selectorPopover);
2447
2333
  return obj.id;
2448
- } // If it's a popover trigger, return value of aria-controls.
2334
+ }
2335
+
2336
+ // If it's a popover trigger, return value of aria-controls.
2449
2337
  else if (obj.hasAttribute('aria-controls')) {
2450
2338
  return obj.getAttribute('aria-controls');
2451
- } // If it's a popover tooltip trigger, return the value of aria-describedby.
2339
+ }
2340
+
2341
+ // If it's a popover tooltip trigger, return the value of aria-describedby.
2452
2342
  else if (obj.hasAttribute('aria-describedby')) {
2453
2343
  return obj.getAttribute('aria-describedby');
2454
- } // Return false if no id was found.
2344
+ }
2345
+
2346
+ // Return false if no id was found.
2455
2347
  else return false;
2456
- } // If it has an id property, return its value.
2348
+ }
2349
+
2350
+ // If it has an id property, return its value.
2457
2351
  else if (obj.id) {
2458
2352
  return obj.id;
2459
- } // Return false if no id was found.
2353
+ }
2354
+
2355
+ // Return false if no id was found.
2460
2356
  else return false;
2461
2357
  }
2462
2358
 
2463
2359
  function getPopoverElements(query) {
2464
2360
  var id = getPopoverID.call(this, query);
2465
-
2466
2361
  if (id) {
2467
2362
  var popover = document.querySelector("#" + id);
2468
2363
  var trigger = document.querySelector("[aria-controls=\"" + id + "\"]") || document.querySelector("[aria-describedby=\"" + id + "\"]");
2469
-
2470
2364
  if (!trigger && !popover) {
2471
2365
  return {
2472
2366
  error: new Error("No popover elements found using the ID: \"" + id + "\".")
@@ -2495,7 +2389,6 @@
2495
2389
  var closeAll = function closeAll() {
2496
2390
  try {
2497
2391
  var _this4 = this;
2498
-
2499
2392
  var result = [];
2500
2393
  return Promise.resolve(Promise.all(_this4.collection.map(function (popover) {
2501
2394
  try {
@@ -2507,7 +2400,6 @@
2507
2400
  });
2508
2401
  }
2509
2402
  }();
2510
-
2511
2403
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
2512
2404
  } catch (e) {
2513
2405
  return Promise.reject(e);
@@ -2525,33 +2417,34 @@
2525
2417
  // If a modal exists and its state is opened.
2526
2418
  if (popover && popover.state === 'opened') {
2527
2419
  // Update state class.
2528
- popover.el.classList.remove(_this2.settings.stateActive); // Update accessibility attribute(s).
2420
+ popover.el.classList.remove(_this2.settings.stateActive);
2529
2421
 
2422
+ // Update accessibility attribute(s).
2530
2423
  if (popover.trigger.hasAttribute('aria-controls')) {
2531
2424
  popover.trigger.setAttribute('aria-expanded', 'false');
2532
- } // Disable popper event listeners.
2533
-
2425
+ }
2534
2426
 
2427
+ // Disable popper event listeners.
2535
2428
  popover.popper.setOptions({
2536
2429
  modifiers: [{
2537
2430
  name: 'eventListeners',
2538
2431
  enabled: false
2539
2432
  }]
2540
- }); // Update popover state.
2433
+ });
2541
2434
 
2542
- popover.state = 'closed'; // Clear root trigger if popover trigger matches.
2435
+ // Update popover state.
2436
+ popover.state = 'closed';
2543
2437
 
2438
+ // Clear root trigger if popover trigger matches.
2544
2439
  if (popover.trigger === _this2.trigger) {
2545
2440
  _this2.trigger = null;
2546
2441
  }
2547
- } // Return the popover.
2548
-
2442
+ }
2549
2443
 
2444
+ // Return the popover.
2550
2445
  return popover;
2551
2446
  };
2552
-
2553
2447
  var _this2 = this;
2554
-
2555
2448
  // Get the popover from collection.
2556
2449
  return Promise.resolve(query ? _temp2(getPopover.call(_this2, query)) : Promise.resolve(closeAll.call(_this2)).then(_temp2));
2557
2450
  } catch (e) {
@@ -2560,19 +2453,22 @@
2560
2453
  };
2561
2454
  function closeCheck(popover) {
2562
2455
  // Only run closeCheck if provided popover is currently open.
2563
- if (popover.state != 'opened') return; // Needed to correctly check which element is currently being focused.
2456
+ if (popover.state != 'opened') return;
2564
2457
 
2458
+ // Needed to correctly check which element is currently being focused.
2565
2459
  setTimeout(function () {
2566
2460
  // Check if trigger or element are being hovered.
2567
- var isHovered = popover.el.closest(':hover') === popover.el || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or element are being focused.
2461
+ var isHovered = popover.el.closest(':hover') === popover.el || popover.trigger.closest(':hover') === popover.trigger;
2568
2462
 
2569
- var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]"); // Close if the trigger and element are not currently hovered or focused.
2463
+ // Check if trigger or element are being focused.
2464
+ var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]");
2570
2465
 
2466
+ // Close if the trigger and element are not currently hovered or focused.
2571
2467
  if (!isHovered && !isFocused) {
2572
2468
  popover.close();
2573
- } // Return the popover.
2574
-
2469
+ }
2575
2470
 
2471
+ // Return the popover.
2576
2472
  return popover;
2577
2473
  }, 1);
2578
2474
  }
@@ -2588,22 +2484,18 @@
2588
2484
  }
2589
2485
  function handleKeydown(event) {
2590
2486
  var _this = this;
2591
-
2592
2487
  switch (event.key) {
2593
2488
  case 'Escape':
2594
2489
  if (this.trigger) {
2595
2490
  this.trigger.focus();
2596
2491
  }
2597
-
2598
2492
  closeAll.call(this);
2599
2493
  return;
2600
-
2601
2494
  case 'Tab':
2602
2495
  this.collection.forEach(function (popover) {
2603
2496
  closeCheck.call(_this, popover);
2604
2497
  });
2605
2498
  return;
2606
-
2607
2499
  default:
2608
2500
  return;
2609
2501
  }
@@ -2612,8 +2504,9 @@
2612
2504
  var root = this;
2613
2505
  document.addEventListener('click', function _f(event) {
2614
2506
  // Check if a popover or its trigger was clicked.
2615
- var wasClicked = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]"); // If popover or popover trigger was clicked...
2507
+ var wasClicked = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]");
2616
2508
 
2509
+ // If popover or popover trigger was clicked...
2617
2510
  if (wasClicked) {
2618
2511
  // If popover element exists and is not active...
2619
2512
  if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
@@ -2624,7 +2517,6 @@
2624
2517
  if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
2625
2518
  popover.close();
2626
2519
  }
2627
-
2628
2520
  this.removeEventListener('click', _f);
2629
2521
  }
2630
2522
  });
@@ -2790,38 +2682,57 @@
2790
2682
  var min = Math.min;
2791
2683
  var round = Math.round;
2792
2684
 
2793
- function getBoundingClientRect(element, includeScale) {
2685
+ function getUAString() {
2686
+ var uaData = navigator.userAgentData;
2687
+
2688
+ if (uaData != null && uaData.brands) {
2689
+ return uaData.brands.map(function (item) {
2690
+ return item.brand + "/" + item.version;
2691
+ }).join(' ');
2692
+ }
2693
+
2694
+ return navigator.userAgent;
2695
+ }
2696
+
2697
+ function isLayoutViewport() {
2698
+ return !/^((?!chrome|android).)*safari/i.test(getUAString());
2699
+ }
2700
+
2701
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
2794
2702
  if (includeScale === void 0) {
2795
2703
  includeScale = false;
2796
2704
  }
2797
2705
 
2798
- var rect = element.getBoundingClientRect();
2706
+ if (isFixedStrategy === void 0) {
2707
+ isFixedStrategy = false;
2708
+ }
2709
+
2710
+ var clientRect = element.getBoundingClientRect();
2799
2711
  var scaleX = 1;
2800
2712
  var scaleY = 1;
2801
2713
 
2802
- if (isHTMLElement(element) && includeScale) {
2803
- var offsetHeight = element.offsetHeight;
2804
- var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
2805
- // Fallback to 1 in case both values are `0`
2806
-
2807
- if (offsetWidth > 0) {
2808
- scaleX = round(rect.width) / offsetWidth || 1;
2809
- }
2810
-
2811
- if (offsetHeight > 0) {
2812
- scaleY = round(rect.height) / offsetHeight || 1;
2813
- }
2714
+ if (includeScale && isHTMLElement(element)) {
2715
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
2716
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
2814
2717
  }
2815
2718
 
2719
+ var _ref = isElement(element) ? getWindow(element) : window,
2720
+ visualViewport = _ref.visualViewport;
2721
+
2722
+ var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
2723
+ var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
2724
+ var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
2725
+ var width = clientRect.width / scaleX;
2726
+ var height = clientRect.height / scaleY;
2816
2727
  return {
2817
- width: rect.width / scaleX,
2818
- height: rect.height / scaleY,
2819
- top: rect.top / scaleY,
2820
- right: rect.right / scaleX,
2821
- bottom: rect.bottom / scaleY,
2822
- left: rect.left / scaleX,
2823
- x: rect.left / scaleX,
2824
- y: rect.top / scaleY
2728
+ width: width,
2729
+ height: height,
2730
+ top: y,
2731
+ right: x + width,
2732
+ bottom: y + height,
2733
+ left: x,
2734
+ x: x,
2735
+ y: y
2825
2736
  };
2826
2737
  }
2827
2738
 
@@ -2916,8 +2827,8 @@
2916
2827
 
2917
2828
 
2918
2829
  function getContainingBlock(element) {
2919
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
2920
- var isIE = navigator.userAgent.indexOf('Trident') !== -1;
2830
+ var isFirefox = /firefox/i.test(getUAString());
2831
+ var isIE = /Trident/i.test(getUAString());
2921
2832
 
2922
2833
  if (isIE && isHTMLElement(element)) {
2923
2834
  // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
@@ -3338,31 +3249,21 @@
3338
3249
  return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
3339
3250
  }
3340
3251
 
3341
- function getViewportRect(element) {
3252
+ function getViewportRect(element, strategy) {
3342
3253
  var win = getWindow(element);
3343
3254
  var html = getDocumentElement(element);
3344
3255
  var visualViewport = win.visualViewport;
3345
3256
  var width = html.clientWidth;
3346
3257
  var height = html.clientHeight;
3347
3258
  var x = 0;
3348
- var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
3349
- // can be obscured underneath it.
3350
- // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
3351
- // if it isn't open, so if this isn't available, the popper will be detected
3352
- // to overflow the bottom of the screen too early.
3259
+ var y = 0;
3353
3260
 
3354
3261
  if (visualViewport) {
3355
3262
  width = visualViewport.width;
3356
- height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
3357
- // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
3358
- // errors due to floating point numbers, so we need to check precision.
3359
- // Safari returns a number <= 0, usually < -1 when pinch-zoomed
3360
- // Feature detection fails in mobile emulation mode in Chrome.
3361
- // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
3362
- // 0.001
3363
- // Fallback here: "Not Safari" userAgent
3364
-
3365
- if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
3263
+ height = visualViewport.height;
3264
+ var layoutViewport = isLayoutViewport();
3265
+
3266
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
3366
3267
  x = visualViewport.offsetLeft;
3367
3268
  y = visualViewport.offsetTop;
3368
3269
  }
@@ -3456,8 +3357,8 @@
3456
3357
  });
3457
3358
  }
3458
3359
 
3459
- function getInnerBoundingClientRect(element) {
3460
- var rect = getBoundingClientRect(element);
3360
+ function getInnerBoundingClientRect(element, strategy) {
3361
+ var rect = getBoundingClientRect(element, false, strategy === 'fixed');
3461
3362
  rect.top = rect.top + element.clientTop;
3462
3363
  rect.left = rect.left + element.clientLeft;
3463
3364
  rect.bottom = rect.top + element.clientHeight;
@@ -3469,8 +3370,8 @@
3469
3370
  return rect;
3470
3371
  }
3471
3372
 
3472
- function getClientRectFromMixedType(element, clippingParent) {
3473
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
3373
+ function getClientRectFromMixedType(element, clippingParent, strategy) {
3374
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
3474
3375
  } // A "clipping parent" is an overflowable container with the characteristic of
3475
3376
  // clipping (or hiding) overflowing elements with a position different from
3476
3377
  // `initial`
@@ -3493,18 +3394,18 @@
3493
3394
  // clipping parents
3494
3395
 
3495
3396
 
3496
- function getClippingRect(element, boundary, rootBoundary) {
3397
+ function getClippingRect(element, boundary, rootBoundary, strategy) {
3497
3398
  var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
3498
3399
  var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
3499
3400
  var firstClippingParent = clippingParents[0];
3500
3401
  var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
3501
- var rect = getClientRectFromMixedType(element, clippingParent);
3402
+ var rect = getClientRectFromMixedType(element, clippingParent, strategy);
3502
3403
  accRect.top = max(rect.top, accRect.top);
3503
3404
  accRect.right = min(rect.right, accRect.right);
3504
3405
  accRect.bottom = min(rect.bottom, accRect.bottom);
3505
3406
  accRect.left = max(rect.left, accRect.left);
3506
3407
  return accRect;
3507
- }, getClientRectFromMixedType(element, firstClippingParent));
3408
+ }, getClientRectFromMixedType(element, firstClippingParent, strategy));
3508
3409
  clippingRect.width = clippingRect.right - clippingRect.left;
3509
3410
  clippingRect.height = clippingRect.bottom - clippingRect.top;
3510
3411
  clippingRect.x = clippingRect.left;
@@ -3585,6 +3486,8 @@
3585
3486
  var _options = options,
3586
3487
  _options$placement = _options.placement,
3587
3488
  placement = _options$placement === void 0 ? state.placement : _options$placement,
3489
+ _options$strategy = _options.strategy,
3490
+ strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
3588
3491
  _options$boundary = _options.boundary,
3589
3492
  boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
3590
3493
  _options$rootBoundary = _options.rootBoundary,
@@ -3599,7 +3502,7 @@
3599
3502
  var altContext = elementContext === popper ? reference : popper;
3600
3503
  var popperRect = state.rects.popper;
3601
3504
  var element = state.elements[altBoundary ? altContext : elementContext];
3602
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
3505
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
3603
3506
  var referenceClientRect = getBoundingClientRect(state.elements.reference);
3604
3507
  var popperOffsets = computeOffsets({
3605
3508
  reference: referenceClientRect,
@@ -4113,7 +4016,7 @@
4113
4016
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
4114
4017
  var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
4115
4018
  var documentElement = getDocumentElement(offsetParent);
4116
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
4019
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
4117
4020
  var scroll = {
4118
4021
  scrollLeft: 0,
4119
4022
  scrollTop: 0
@@ -4420,35 +4323,38 @@
4420
4323
  var deregister = function deregister(obj) {
4421
4324
  try {
4422
4325
  var _this2 = this;
4423
-
4424
4326
  // Return collection if nothing was passed.
4425
- if (!obj) return Promise.resolve(_this2.collection); // Check if entry has been registered in the collection.
4327
+ if (!obj) return Promise.resolve(_this2.collection);
4426
4328
 
4329
+ // Check if entry has been registered in the collection.
4427
4330
  var index = _this2.collection.findIndex(function (entry) {
4428
4331
  return entry.id === obj.id;
4429
4332
  });
4430
-
4431
4333
  if (index >= 0) {
4432
4334
  // Get the collection entry.
4433
- var entry = _this2.collection[index]; // If entry is in the opened state, close it.
4335
+ var entry = _this2.collection[index];
4434
4336
 
4337
+ // If entry is in the opened state, close it.
4435
4338
  if (entry.state === 'opened') {
4436
4339
  entry.close();
4437
- } // Clean up the popper instance.
4438
-
4340
+ }
4439
4341
 
4440
- entry.popper.destroy(); // Remove event listeners.
4342
+ // Clean up the popper instance.
4343
+ entry.popper.destroy();
4441
4344
 
4442
- deregisterEventListeners(entry); // Delete properties from collection entry.
4345
+ // Remove event listeners.
4346
+ deregisterEventListeners(entry);
4443
4347
 
4348
+ // Delete properties from collection entry.
4444
4349
  Object.getOwnPropertyNames(entry).forEach(function (prop) {
4445
4350
  delete entry[prop];
4446
- }); // Remove entry from collection.
4351
+ });
4447
4352
 
4353
+ // Remove entry from collection.
4448
4354
  _this2.collection.splice(index, 1);
4449
- } // Return the modified collection.
4450
-
4355
+ }
4451
4356
 
4357
+ // Return the modified collection.
4452
4358
  return Promise.resolve(_this2.collection);
4453
4359
  } catch (e) {
4454
4360
  return Promise.reject(e);
@@ -4464,44 +4370,49 @@
4464
4370
  entry[el].removeEventListener(type, evObj.listener, false);
4465
4371
  });
4466
4372
  });
4467
- }); // Remove eventListeners object from collection.
4468
-
4373
+ });
4469
4374
 
4375
+ // Remove eventListeners object from collection.
4470
4376
  delete entry.__eventListeners;
4471
- } // Return the entry object.
4472
-
4377
+ }
4473
4378
 
4379
+ // Return the entry object.
4474
4380
  return entry;
4475
4381
  }
4476
4382
 
4477
4383
  var open = function open(query) {
4478
4384
  try {
4479
4385
  var _this2 = this;
4480
-
4481
4386
  // Get the popover from collection.
4482
- var popover = getPopover.call(_this2, query); // Update state class.
4387
+ var popover = getPopover.call(_this2, query);
4483
4388
 
4484
- popover.el.classList.add(_this2.settings.stateActive); // Update accessibility attribute(s).
4389
+ // Update state class.
4390
+ popover.el.classList.add(_this2.settings.stateActive);
4485
4391
 
4392
+ // Update accessibility attribute(s).
4486
4393
  if (popover.trigger.hasAttribute('aria-controls')) {
4487
4394
  popover.trigger.setAttribute('aria-expanded', 'true');
4488
- } // Update popover config.
4489
-
4395
+ }
4490
4396
 
4491
- popover.config = getConfig(popover.el, _this2.settings); // Enable popper event listeners and set placement/modifiers.
4397
+ // Update popover config.
4398
+ popover.config = getConfig(popover.el, _this2.settings);
4492
4399
 
4400
+ // Enable popper event listeners and set placement/modifiers.
4493
4401
  popover.popper.setOptions({
4494
4402
  placement: popover.config['placement'],
4495
4403
  modifiers: [{
4496
4404
  name: 'eventListeners',
4497
4405
  enabled: true
4498
4406
  }].concat(getModifiers(popover.config))
4499
- }); // Update popover position.
4407
+ });
4500
4408
 
4501
- popover.popper.update(); // Update popover state.
4409
+ // Update popover position.
4410
+ popover.popper.update();
4502
4411
 
4503
- popover.state = 'opened'; // Return the popover.
4412
+ // Update popover state.
4413
+ popover.state = 'opened';
4504
4414
 
4415
+ // Return the popover.
4505
4416
  return Promise.resolve(popover);
4506
4417
  } catch (e) {
4507
4418
  return Promise.reject(e);
@@ -4511,13 +4422,13 @@
4511
4422
  var register = function register(el, trigger) {
4512
4423
  try {
4513
4424
  var _this2 = this;
4514
-
4515
4425
  // Deregister entry incase it has already been registered.
4516
- deregister.call(_this2, el); // Save root this for use inside methods API.
4426
+ deregister.call(_this2, el);
4517
4427
 
4428
+ // Save root this for use inside methods API.
4429
+ var root = _this2;
4518
4430
 
4519
- var root = _this2; // Setup methods API.
4520
-
4431
+ // Setup methods API.
4521
4432
  var methods = {
4522
4433
  open: function open$1() {
4523
4434
  return open.call(root, this);
@@ -4528,8 +4439,9 @@
4528
4439
  deregister: function deregister$1() {
4529
4440
  return deregister.call(root, this);
4530
4441
  }
4531
- }; // Setup the popover object.
4442
+ };
4532
4443
 
4444
+ // Setup the popover object.
4533
4445
  var entry = _extends({
4534
4446
  id: el.id,
4535
4447
  state: 'closed',
@@ -4537,19 +4449,20 @@
4537
4449
  trigger: trigger,
4538
4450
  popper: createPopper(trigger, el),
4539
4451
  config: getConfig(el, _this2.settings)
4540
- }, methods); // Set aria-expanded to false if trigger has aria-controls attribute.
4541
-
4452
+ }, methods);
4542
4453
 
4454
+ // Set aria-expanded to false if trigger has aria-controls attribute.
4543
4455
  if (entry.trigger.hasAttribute('aria-controls')) {
4544
4456
  entry.trigger.setAttribute('aria-expanded', 'false');
4545
- } // Setup event listeners.
4546
-
4547
-
4548
- registerEventListeners.call(_this2, entry); // Add entry to collection.
4457
+ }
4549
4458
 
4550
- _this2.collection.push(entry); // Set initial state.
4459
+ // Setup event listeners.
4460
+ registerEventListeners.call(_this2, entry);
4551
4461
 
4462
+ // Add entry to collection.
4463
+ _this2.collection.push(entry);
4552
4464
 
4465
+ // Set initial state.
4553
4466
  var _temp2 = function () {
4554
4467
  if (entry.el.classList.contains(_this2.settings.stateActive)) {
4555
4468
  return Promise.resolve(entry.open()).then(function () {
@@ -4557,7 +4470,6 @@
4557
4470
  });
4558
4471
  }
4559
4472
  }();
4560
-
4561
4473
  return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {
4562
4474
  // Return the registered entry.
4563
4475
  return entry;
@@ -4570,8 +4482,9 @@
4570
4482
  // If event listeners aren't already setup.
4571
4483
  if (!entry.__eventListeners) {
4572
4484
  // Add event listeners based on event type.
4573
- var eventType = entry.config['event']; // If the event type is hover.
4485
+ var eventType = entry.config['event'];
4574
4486
 
4487
+ // If the event type is hover.
4575
4488
  if (eventType === 'hover') {
4576
4489
  // Setup event listeners object for hover.
4577
4490
  entry.__eventListeners = [{
@@ -4582,8 +4495,9 @@
4582
4495
  el: ['el', 'trigger'],
4583
4496
  type: ['mouseleave', 'focusout'],
4584
4497
  listener: closeCheck.bind(this, entry)
4585
- }]; // Loop through listeners and apply to the appropriate elements.
4498
+ }];
4586
4499
 
4500
+ // Loop through listeners and apply to the appropriate elements.
4587
4501
  entry.__eventListeners.forEach(function (evObj) {
4588
4502
  evObj.el.forEach(function (el) {
4589
4503
  evObj.type.forEach(function (type) {
@@ -4591,15 +4505,18 @@
4591
4505
  });
4592
4506
  });
4593
4507
  });
4594
- } // Else the event type is click.
4508
+ }
4509
+
4510
+ // Else the event type is click.
4595
4511
  else {
4596
4512
  // Setup event listeners object for click.
4597
4513
  entry.__eventListeners = [{
4598
4514
  el: ['trigger'],
4599
4515
  type: ['click'],
4600
4516
  listener: handleClick.bind(this, entry)
4601
- }]; // Loop through listeners and apply to the appropriate elements.
4517
+ }];
4602
4518
 
4519
+ // Loop through listeners and apply to the appropriate elements.
4603
4520
  entry.__eventListeners.forEach(function (evObj) {
4604
4521
  evObj.el.forEach(function (el) {
4605
4522
  evObj.type.forEach(function (type) {
@@ -4608,20 +4525,17 @@
4608
4525
  });
4609
4526
  });
4610
4527
  }
4611
- } // Return the entry object.
4612
-
4528
+ }
4613
4529
 
4530
+ // Return the entry object.
4614
4531
  return entry;
4615
4532
  }
4616
4533
 
4617
4534
  var _handleKeydown = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
4618
-
4619
4535
  var Popover = /*#__PURE__*/function (_Collection) {
4620
4536
  _inheritsLoose(Popover, _Collection);
4621
-
4622
4537
  function Popover(options) {
4623
4538
  var _this;
4624
-
4625
4539
  _this = _Collection.call(this) || this;
4626
4540
  Object.defineProperty(_assertThisInitialized(_this), _handleKeydown, {
4627
4541
  writable: true,
@@ -4634,18 +4548,17 @@
4634
4548
  if (_this.settings.autoInit) _this.init();
4635
4549
  return _this;
4636
4550
  }
4637
-
4638
4551
  var _proto = Popover.prototype;
4639
-
4640
4552
  _proto.init = function init(options) {
4641
4553
  try {
4642
4554
  var _this3 = this;
4643
-
4644
4555
  // Update settings with passed options.
4645
- if (options) _this3.settings = _extends({}, _this3.settings, options); // Get all the popovers.
4556
+ if (options) _this3.settings = _extends({}, _this3.settings, options);
4646
4557
 
4647
- var popovers = document.querySelectorAll(_this3.settings.selectorPopover); // Register the collections array with popover instances.
4558
+ // Get all the popovers.
4559
+ var popovers = document.querySelectorAll(_this3.settings.selectorPopover);
4648
4560
 
4561
+ // Register the collections array with popover instances.
4649
4562
  return Promise.resolve(_this3.registerCollection(popovers)).then(function () {
4650
4563
  // If eventListeners are enabled, init event listeners.
4651
4564
  if (_this3.settings.eventListeners) {
@@ -4653,21 +4566,19 @@
4653
4566
  // already adds event listeners to popovers.
4654
4567
  _this3.initEventListeners(false);
4655
4568
  }
4656
-
4657
4569
  return _this3;
4658
4570
  });
4659
4571
  } catch (e) {
4660
4572
  return Promise.reject(e);
4661
4573
  }
4662
4574
  };
4663
-
4664
4575
  _proto.destroy = function destroy() {
4665
4576
  try {
4666
4577
  var _this5 = this;
4667
-
4668
4578
  // Clear stored trigger.
4669
- _this5.trigger = null; // Remove all entries from the collection.
4579
+ _this5.trigger = null;
4670
4580
 
4581
+ // Remove all entries from the collection.
4671
4582
  return Promise.resolve(_this5.deregisterCollection()).then(function () {
4672
4583
  // If eventListeners are enabled, destroy event listeners.
4673
4584
  if (_this5.settings.eventListeners) {
@@ -4675,67 +4586,56 @@
4675
4586
  // already removes event listeners from popovers.
4676
4587
  _this5.destroyEventListeners(false);
4677
4588
  }
4678
-
4679
4589
  return _this5;
4680
4590
  });
4681
4591
  } catch (e) {
4682
4592
  return Promise.reject(e);
4683
4593
  }
4684
4594
  };
4685
-
4686
4595
  _proto.initEventListeners = function initEventListeners(processCollection) {
4687
4596
  var _this6 = this;
4688
-
4689
4597
  if (processCollection === void 0) {
4690
4598
  processCollection = true;
4691
4599
  }
4692
-
4693
4600
  if (processCollection) {
4694
4601
  // Loop through collection and setup event listeners.
4695
4602
  this.collection.forEach(function (popover) {
4696
4603
  registerEventListeners.call(_this6, popover);
4697
4604
  });
4698
- } // Add keydown global event listener.
4699
-
4605
+ }
4700
4606
 
4607
+ // Add keydown global event listener.
4701
4608
  document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
4702
4609
  };
4703
-
4704
4610
  _proto.destroyEventListeners = function destroyEventListeners(processCollection) {
4705
4611
  if (processCollection === void 0) {
4706
4612
  processCollection = true;
4707
4613
  }
4708
-
4709
4614
  if (processCollection) {
4710
4615
  // Loop through collection and remove event listeners.
4711
4616
  this.collection.forEach(function (popover) {
4712
4617
  deregisterEventListeners(popover);
4713
4618
  });
4714
- } // Remove keydown global event listener.
4715
-
4619
+ }
4716
4620
 
4621
+ // Remove keydown global event listener.
4717
4622
  document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
4718
4623
  };
4719
-
4720
4624
  _proto.register = function register$1(query) {
4721
4625
  var els = getPopoverElements.call(this, query);
4722
4626
  if (els.error) return Promise.reject(els.error);
4723
4627
  return register.call(this, els.popover, els.trigger);
4724
4628
  };
4725
-
4726
4629
  _proto.deregister = function deregister$1(query) {
4727
4630
  var popover = this.get(getPopoverID.call(this, query));
4728
4631
  return deregister.call(this, popover);
4729
4632
  };
4730
-
4731
4633
  _proto.open = function open$1(id) {
4732
4634
  return open.call(this, id);
4733
4635
  };
4734
-
4735
4636
  _proto.close = function close$1(id) {
4736
4637
  return close.call(this, id);
4737
4638
  };
4738
-
4739
4639
  return Popover;
4740
4640
  }(Collection);
4741
4641