vrembem 3.0.10 → 4.0.0-alpha.1

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