@haiilo/catalyst 10.28.2 → 10.30.0

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.
Files changed (74) hide show
  1. package/dist/catalyst/catalyst.css +3 -1
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.esm.js +1 -1
  5. package/dist/catalyst/p-41a50f19.entry.js +10 -0
  6. package/dist/catalyst/p-41a50f19.entry.js.map +1 -0
  7. package/dist/catalyst/{p-e5aee21d.js → p-9500d6fb.js} +1 -1
  8. package/dist/catalyst/{p-e5aee21d.js.map → p-9500d6fb.js.map} +1 -1
  9. package/dist/catalyst/scss/core/_notification.scss +4 -1
  10. package/dist/catalyst/scss/utils/_elevation.mixins.scss +8 -2
  11. package/dist/cjs/cat-alert_30.cjs.entry.js +274 -180
  12. package/dist/cjs/cat-alert_30.cjs.entry.js.map +1 -1
  13. package/dist/cjs/catalyst.cjs.js +1 -1
  14. package/dist/cjs/index.cjs.js +1 -1
  15. package/dist/cjs/loader.cjs.js +1 -1
  16. package/dist/cjs/{of-aaee31a6.js → of-958251e4.js} +1 -1
  17. package/dist/cjs/{of-aaee31a6.js.map → of-958251e4.js.map} +1 -1
  18. package/dist/collection/components/cat-button/cat-button.css +1 -1
  19. package/dist/collection/components/cat-date/cat-date.js +8 -7
  20. package/dist/collection/components/cat-date/cat-date.js.map +1 -1
  21. package/dist/collection/components/cat-date-inline/cat-date-inline.js +10 -8
  22. package/dist/collection/components/cat-date-inline/cat-date-inline.js.map +1 -1
  23. package/dist/collection/components/cat-date-inline/cat-date-locale.js +2 -4
  24. package/dist/collection/components/cat-date-inline/cat-date-locale.js.map +1 -1
  25. package/dist/collection/components/cat-datepicker/cat-datepicker.js +9 -8
  26. package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
  27. package/dist/collection/components/cat-dropdown/cat-dropdown.js +1 -1
  28. package/dist/collection/components/cat-input/cat-input.js +8 -4
  29. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  30. package/dist/collection/components/cat-select/cat-select.js +1 -1
  31. package/dist/collection/components/cat-textarea/cat-textarea.js +25 -3
  32. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  33. package/dist/collection/components/cat-time/cat-time.js +8 -7
  34. package/dist/collection/components/cat-time/cat-time.js.map +1 -1
  35. package/dist/collection/components/cat-tooltip/cat-tooltip.css +18 -9
  36. package/dist/collection/scss/core/_notification.scss +4 -1
  37. package/dist/collection/scss/utils/_elevation.mixins.scss +8 -2
  38. package/dist/components/cat-button2.js +1 -1
  39. package/dist/components/cat-button2.js.map +1 -1
  40. package/dist/components/cat-date-inline2.js +12 -12
  41. package/dist/components/cat-date-inline2.js.map +1 -1
  42. package/dist/components/cat-date.js +3 -3
  43. package/dist/components/cat-date.js.map +1 -1
  44. package/dist/components/cat-datepicker.js +4 -4
  45. package/dist/components/cat-datepicker.js.map +1 -1
  46. package/dist/components/cat-dropdown2.js +169 -118
  47. package/dist/components/cat-dropdown2.js.map +1 -1
  48. package/dist/components/cat-input2.js +7 -4
  49. package/dist/components/cat-input2.js.map +1 -1
  50. package/dist/components/cat-textarea.js +8 -3
  51. package/dist/components/cat-textarea.js.map +1 -1
  52. package/dist/components/cat-time.js +3 -3
  53. package/dist/components/cat-time.js.map +1 -1
  54. package/dist/components/cat-tooltip.js +1 -1
  55. package/dist/components/cat-tooltip.js.map +1 -1
  56. package/dist/components/floating-ui.dom.esm.js +67 -29
  57. package/dist/components/floating-ui.dom.esm.js.map +1 -1
  58. package/dist/components/loglevel.js.map +1 -1
  59. package/dist/esm/cat-alert_30.entry.js +274 -180
  60. package/dist/esm/cat-alert_30.entry.js.map +1 -1
  61. package/dist/esm/catalyst.js +1 -1
  62. package/dist/esm/index.js +2 -2
  63. package/dist/esm/loader.js +1 -1
  64. package/dist/esm/{of-acb1f3a9.js → of-e4ec2eb4.js} +1 -1
  65. package/dist/esm/{of-acb1f3a9.js.map → of-e4ec2eb4.js.map} +1 -1
  66. package/dist/types/components/cat-date/cat-date.d.ts +1 -1
  67. package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +1 -1
  68. package/dist/types/components/cat-input/cat-input.d.ts +2 -0
  69. package/dist/types/components/cat-textarea/cat-textarea.d.ts +6 -0
  70. package/dist/types/components/cat-time/cat-time.d.ts +1 -1
  71. package/dist/types/components.d.ts +11 -3
  72. package/package.json +8 -8
  73. package/dist/catalyst/p-ee89e395.entry.js +0 -10
  74. package/dist/catalyst/p-ee89e395.entry.js.map +0 -1
@@ -8,10 +8,32 @@ import { t as tabbable, a as focusable, i as isTabbable, g as getTabIndex, b as
8
8
  const timeTransitionS = 125;
9
9
 
10
10
  /*!
11
- * focus-trap 7.5.4
11
+ * focus-trap 7.6.4
12
12
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
13
13
  */
14
14
 
15
+ function _arrayLikeToArray(r, a) {
16
+ (null == a || a > r.length) && (a = r.length);
17
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
18
+ return n;
19
+ }
20
+ function _arrayWithoutHoles(r) {
21
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
22
+ }
23
+ function _defineProperty(e, r, t) {
24
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
25
+ value: t,
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true
29
+ }) : e[r] = t, e;
30
+ }
31
+ function _iterableToArray(r) {
32
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
33
+ }
34
+ function _nonIterableSpread() {
35
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
+ }
15
37
  function ownKeys(e, r) {
16
38
  var t = Object.keys(e);
17
39
  if (Object.getOwnPropertySymbols) {
@@ -25,7 +47,7 @@ function ownKeys(e, r) {
25
47
  function _objectSpread2(e) {
26
48
  for (var r = 1; r < arguments.length; r++) {
27
49
  var t = null != arguments[r] ? arguments[r] : {};
28
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
50
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
29
51
  _defineProperty(e, r, t[r]);
30
52
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
31
53
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
@@ -33,33 +55,29 @@ function _objectSpread2(e) {
33
55
  }
34
56
  return e;
35
57
  }
36
- function _defineProperty(obj, key, value) {
37
- key = _toPropertyKey(key);
38
- if (key in obj) {
39
- Object.defineProperty(obj, key, {
40
- value: value,
41
- enumerable: true,
42
- configurable: true,
43
- writable: true
44
- });
45
- } else {
46
- obj[key] = value;
47
- }
48
- return obj;
58
+ function _toConsumableArray(r) {
59
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
49
60
  }
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;
61
+ function _toPrimitive(t, r) {
62
+ if ("object" != typeof t || !t) return t;
63
+ var e = t[Symbol.toPrimitive];
64
+ if (undefined !== e) {
65
+ var i = e.call(t, r || "default");
66
+ if ("object" != typeof i) return i;
56
67
  throw new TypeError("@@toPrimitive must return a primitive value.");
57
68
  }
58
- return (hint === "string" ? String : Number)(input);
69
+ return ("string" === r ? String : Number)(t);
59
70
  }
60
- function _toPropertyKey(arg) {
61
- var key = _toPrimitive(arg, "string");
62
- return typeof key === "symbol" ? key : String(key);
71
+ function _toPropertyKey(t) {
72
+ var i = _toPrimitive(t, "string");
73
+ return "symbol" == typeof i ? i : i + "";
74
+ }
75
+ function _unsupportedIterableToArray(r, a) {
76
+ if (r) {
77
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
78
+ var t = {}.toString.call(r).slice(8, -1);
79
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
80
+ }
63
81
  }
64
82
 
65
83
  var activeFocusTraps = {
@@ -67,7 +85,7 @@ var activeFocusTraps = {
67
85
  if (trapStack.length > 0) {
68
86
  var activeTrap = trapStack[trapStack.length - 1];
69
87
  if (activeTrap !== trap) {
70
- activeTrap.pause();
88
+ activeTrap._setPausedState(true);
71
89
  }
72
90
  }
73
91
  var trapIndex = trapStack.indexOf(trap);
@@ -84,8 +102,8 @@ var activeFocusTraps = {
84
102
  if (trapIndex !== -1) {
85
103
  trapStack.splice(trapIndex, 1);
86
104
  }
87
- if (trapStack.length > 0) {
88
- trapStack[trapStack.length - 1].unpause();
105
+ if (trapStack.length > 0 && !trapStack[trapStack.length - 1]._isManuallyPaused()) {
106
+ trapStack[trapStack.length - 1]._setPausedState(false);
89
107
  }
90
108
  }
91
109
  };
@@ -93,10 +111,10 @@ var isSelectableInput = function isSelectableInput(node) {
93
111
  return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
94
112
  };
95
113
  var isEscapeEvent = function isEscapeEvent(e) {
96
- return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
114
+ return (e === null || e === undefined ? undefined : e.key) === 'Escape' || (e === null || e === undefined ? undefined : e.key) === 'Esc' || (e === null || e === undefined ? undefined : e.keyCode) === 27;
97
115
  };
98
116
  var isTabEvent = function isTabEvent(e) {
99
- return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
117
+ return (e === null || e === undefined ? undefined : e.key) === 'Tab' || (e === null || e === undefined ? undefined : e.keyCode) === 9;
100
118
  };
101
119
 
102
120
  // checks for TAB by default
@@ -112,22 +130,6 @@ var delay = function delay(fn) {
112
130
  return setTimeout(fn, 0);
113
131
  };
114
132
 
115
- // Array.find/findIndex() are not supported on IE; this replicates enough
116
- // of Array.findIndex() for our needs
117
- var findIndex = function findIndex(arr, fn) {
118
- var idx = -1;
119
- arr.every(function (value, i) {
120
- if (fn(value)) {
121
- idx = i;
122
- return false; // break
123
- }
124
-
125
- return true; // next
126
- });
127
-
128
- return idx;
129
- };
130
-
131
133
  /**
132
134
  * Get an option's value when it could be a plain value, or a handler that provides
133
135
  * the value.
@@ -139,7 +141,7 @@ var valueOrHandler = function valueOrHandler(value) {
139
141
  for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
140
142
  params[_key - 1] = arguments[_key];
141
143
  }
142
- return typeof value === 'function' ? value.apply(void 0, params) : value;
144
+ return typeof value === 'function' ? value.apply(undefined, params) : value;
143
145
  };
144
146
  var getActualTarget = function getActualTarget(event) {
145
147
  // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
@@ -158,8 +160,8 @@ var internalTrapStack = [];
158
160
  var createFocusTrap = function createFocusTrap(elements, userOptions) {
159
161
  // SSR: a live trap shouldn't be created in this type of environment so this
160
162
  // should be safe code to execute if the `document` option isn't specified
161
- var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
162
- var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
163
+ var doc = (userOptions === null || userOptions === undefined ? undefined : userOptions.document) || document;
164
+ var trapStack = (userOptions === null || userOptions === undefined ? undefined : userOptions.trapStack) || internalTrapStack;
163
165
  var config = _objectSpread2({
164
166
  returnFocusOnDeactivate: true,
165
167
  escapeDeactivates: true,
@@ -199,6 +201,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
199
201
  mostRecentlyFocusedNode: null,
200
202
  active: false,
201
203
  paused: false,
204
+ manuallyPaused: false,
202
205
  // timer ID for when delayInitialFocus is true and initial focus in this trap
203
206
  // has been delayed during activation
204
207
  delayInitialFocusTimer: undefined,
@@ -230,18 +233,18 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
230
233
  * if the element isn't found.
231
234
  */
232
235
  var findContainerIndex = function findContainerIndex(element, event) {
233
- var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined;
236
+ var composedPath = typeof (event === null || event === undefined ? undefined : event.composedPath) === 'function' ? event.composedPath() : undefined;
234
237
  // NOTE: search `containerGroups` because it's possible a group contains no tabbable
235
238
  // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
236
239
  // and we still need to find the element in there
237
240
  return state.containerGroups.findIndex(function (_ref) {
238
241
  var container = _ref.container,
239
242
  tabbableNodes = _ref.tabbableNodes;
240
- return container.contains(element) || ( // fall back to explicit tabbable search which will take into consideration any
243
+ return container.contains(element) || (// fall back to explicit tabbable search which will take into consideration any
241
244
  // web components if the `tabbableOptions.getShadowRoot` option was used for
242
245
  // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
243
246
  // look inside web components even if open)
244
- composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) {
247
+ composedPath === null || composedPath === undefined ? undefined : composedPath.includes(container)) || tabbableNodes.find(function (node) {
245
248
  return node === element;
246
249
  });
247
250
  });
@@ -253,25 +256,31 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
253
256
  * (if a node is explicitly NOT given), or a function that returns any of these
254
257
  * values.
255
258
  * @param {string} optionName
256
- * @returns {undefined | false | HTMLElement | SVGElement} Returns
257
- * `undefined` if the option is not specified; `false` if the option
258
- * resolved to `false` (node explicitly not given); otherwise, the resolved
259
- * DOM node.
259
+ * @param {Object} options
260
+ * @param {boolean} [options.hasFallback] True if the option could be a selector string
261
+ * and the option allows for a fallback scenario in the case where the selector is
262
+ * valid but does not match a node (i.e. the queried node doesn't exist in the DOM).
263
+ * @param {Array} [options.params] Params to pass to the option if it's a function.
264
+ * @returns {undefined | null | false | HTMLElement | SVGElement} Returns
265
+ * `undefined` if the option is not specified; `null` if the option didn't resolve
266
+ * to a node but `options.hasFallback=true`, `false` if the option resolved to `false`
267
+ * (node explicitly not given); otherwise, the resolved DOM node.
260
268
  * @throws {Error} If the option is set, not `false`, and is not, or does not
261
- * resolve to a node.
269
+ * resolve to a node, unless the option is a selector string and `options.hasFallback=true`.
262
270
  */
263
271
  var getNodeForOption = function getNodeForOption(optionName) {
272
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
273
+ _ref2$hasFallback = _ref2.hasFallback,
274
+ hasFallback = _ref2$hasFallback === undefined ? false : _ref2$hasFallback,
275
+ _ref2$params = _ref2.params,
276
+ params = _ref2$params === undefined ? [] : _ref2$params;
264
277
  var optionValue = config[optionName];
265
278
  if (typeof optionValue === 'function') {
266
- for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
267
- params[_key2 - 1] = arguments[_key2];
268
- }
269
- optionValue = optionValue.apply(void 0, params);
279
+ optionValue = optionValue.apply(undefined, _toConsumableArray(params));
270
280
  }
271
281
  if (optionValue === true) {
272
282
  optionValue = undefined; // use default value
273
283
  }
274
-
275
284
  if (!optionValue) {
276
285
  if (optionValue === undefined || optionValue === false) {
277
286
  return optionValue;
@@ -283,21 +292,31 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
283
292
  var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
284
293
 
285
294
  if (typeof optionValue === 'string') {
286
- node = doc.querySelector(optionValue); // resolve to node, or null if fails
295
+ try {
296
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
297
+ } catch (err) {
298
+ throw new Error("`".concat(optionName, "` appears to be an invalid selector; error=\"").concat(err.message, "\""));
299
+ }
287
300
  if (!node) {
288
- throw new Error("`".concat(optionName, "` as selector refers to no known node"));
301
+ if (!hasFallback) {
302
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
303
+ }
304
+ // else, `node` MUST be `null` because that's what `Document.querySelector()` returns
305
+ // if the selector is valid but doesn't match anything
289
306
  }
290
307
  }
291
308
  return node;
292
309
  };
293
310
  var getInitialFocusNode = function getInitialFocusNode() {
294
- var node = getNodeForOption('initialFocus');
311
+ var node = getNodeForOption('initialFocus', {
312
+ hasFallback: true
313
+ });
295
314
 
296
315
  // false explicitly indicates we want no initialFocus at all
297
316
  if (node === false) {
298
317
  return false;
299
318
  }
300
- if (node === undefined || !isFocusable(node, config.tabbableOptions)) {
319
+ if (node === undefined || node && !isFocusable(node, config.tabbableOptions)) {
301
320
  // option not specified nor focusable: use fallback options
302
321
  if (findContainerIndex(doc.activeElement) >= 0) {
303
322
  node = doc.activeElement;
@@ -308,6 +327,10 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
308
327
  // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
309
328
  node = firstTabbableNode || getNodeForOption('fallbackFocus');
310
329
  }
330
+ } else if (node === null) {
331
+ // option is a VALID selector string that doesn't yield a node: use the `fallbackFocus`
332
+ // option instead of the default behavior when the option isn't specified at all
333
+ node = getNodeForOption('fallbackFocus');
311
334
  }
312
335
  if (!node) {
313
336
  throw new Error('Your focus-trap needs to have at least one focusable element');
@@ -417,25 +440,25 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
417
440
  *
418
441
  * @returns {HTMLElement} The element that currently has the focus
419
442
  **/
420
- var getActiveElement = function getActiveElement(el) {
443
+ var _getActiveElement = function getActiveElement(el) {
421
444
  var activeElement = el.activeElement;
422
445
  if (!activeElement) {
423
446
  return;
424
447
  }
425
448
  if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
426
- return getActiveElement(activeElement.shadowRoot);
449
+ return _getActiveElement(activeElement.shadowRoot);
427
450
  }
428
451
  return activeElement;
429
452
  };
430
- var tryFocus = function tryFocus(node) {
453
+ var _tryFocus = function tryFocus(node) {
431
454
  if (node === false) {
432
455
  return;
433
456
  }
434
- if (node === getActiveElement(document)) {
457
+ if (node === _getActiveElement(document)) {
435
458
  return;
436
459
  }
437
460
  if (!node || !node.focus) {
438
- tryFocus(getInitialFocusNode());
461
+ _tryFocus(getInitialFocusNode());
439
462
  return;
440
463
  }
441
464
  node.focus({
@@ -448,7 +471,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
448
471
  }
449
472
  };
450
473
  var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
451
- var node = getNodeForOption('setReturnFocus', previousActiveElement);
474
+ var node = getNodeForOption('setReturnFocus', {
475
+ params: [previousActiveElement]
476
+ });
452
477
  return node ? node : node === false ? false : previousActiveElement;
453
478
  };
454
479
 
@@ -463,11 +488,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
463
488
  * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
464
489
  * determined given the current state of the trap.
465
490
  */
466
- var findNextNavNode = function findNextNavNode(_ref2) {
467
- var target = _ref2.target,
468
- event = _ref2.event,
469
- _ref2$isBackward = _ref2.isBackward,
470
- isBackward = _ref2$isBackward === void 0 ? false : _ref2$isBackward;
491
+ var findNextNavNode = function findNextNavNode(_ref3) {
492
+ var target = _ref3.target,
493
+ event = _ref3.event,
494
+ _ref3$isBackward = _ref3.isBackward,
495
+ isBackward = _ref3$isBackward === undefined ? false : _ref3$isBackward;
471
496
  target = target || getActualTarget(event);
472
497
  updateTabbableNodes();
473
498
  var destinationNode = null;
@@ -491,8 +516,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
491
516
  // REVERSE
492
517
 
493
518
  // is the target the first tabbable node in a group?
494
- var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
495
- var firstTabbableNode = _ref3.firstTabbableNode;
519
+ var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
520
+ var firstTabbableNode = _ref4.firstTabbableNode;
496
521
  return target === firstTabbableNode;
497
522
  });
498
523
  if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
@@ -520,8 +545,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
520
545
  // FORWARD
521
546
 
522
547
  // is the target the last tabbable node in a group?
523
- var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
524
- var lastTabbableNode = _ref4.lastTabbableNode;
548
+ var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
549
+ var lastTabbableNode = _ref5.lastTabbableNode;
525
550
  return target === lastTabbableNode;
526
551
  });
527
552
  if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
@@ -679,9 +704,9 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
679
704
  });
680
705
  }
681
706
  if (nextNode) {
682
- tryFocus(nextNode);
707
+ _tryFocus(nextNode);
683
708
  } else {
684
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
709
+ _tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
685
710
  }
686
711
  }
687
712
  state.recentNavEvent = undefined; // clear
@@ -706,19 +731,21 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
706
731
  // to where it normally would
707
732
  event.preventDefault();
708
733
  }
709
- tryFocus(destinationNode);
734
+ _tryFocus(destinationNode);
710
735
  }
711
736
  // else, let the browser take care of [shift+]tab and move the focus
712
737
  };
738
+ var checkTabKey = function checkTabKey(event) {
739
+ if (config.isKeyForward(event) || config.isKeyBackward(event)) {
740
+ checkKeyNav(event, config.isKeyBackward(event));
741
+ }
742
+ };
713
743
 
714
- var checkKey = function checkKey(event) {
744
+ // we use a different event phase for the Escape key to allow canceling the event and checking for this in escapeDeactivates
745
+ var checkEscapeKey = function checkEscapeKey(event) {
715
746
  if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
716
747
  event.preventDefault();
717
748
  trap.deactivate();
718
- return;
719
- }
720
- if (config.isKeyForward(event) || config.isKeyBackward(event)) {
721
- checkKeyNav(event, config.isKeyBackward(event));
722
749
  }
723
750
  };
724
751
  var checkClick = function checkClick(e) {
@@ -751,8 +778,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
751
778
  // Delay ensures that the focused element doesn't capture the event
752
779
  // that caused the focus trap activation.
753
780
  state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
754
- tryFocus(getInitialFocusNode());
755
- }) : tryFocus(getInitialFocusNode());
781
+ _tryFocus(getInitialFocusNode());
782
+ }) : _tryFocus(getInitialFocusNode());
756
783
  doc.addEventListener('focusin', checkFocusIn, true);
757
784
  doc.addEventListener('mousedown', checkPointerDown, {
758
785
  capture: true,
@@ -766,10 +793,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
766
793
  capture: true,
767
794
  passive: false
768
795
  });
769
- doc.addEventListener('keydown', checkKey, {
796
+ doc.addEventListener('keydown', checkTabKey, {
770
797
  capture: true,
771
798
  passive: false
772
799
  });
800
+ doc.addEventListener('keydown', checkEscapeKey);
773
801
  return trap;
774
802
  };
775
803
  var removeListeners = function removeListeners() {
@@ -780,7 +808,8 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
780
808
  doc.removeEventListener('mousedown', checkPointerDown, true);
781
809
  doc.removeEventListener('touchstart', checkPointerDown, true);
782
810
  doc.removeEventListener('click', checkClick, true);
783
- doc.removeEventListener('keydown', checkKey, true);
811
+ doc.removeEventListener('keydown', checkTabKey, true);
812
+ doc.removeEventListener('keydown', checkEscapeKey);
784
813
  return trap;
785
814
  };
786
815
 
@@ -799,7 +828,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
799
828
  // If the currently focused is removed then browsers will move focus to the
800
829
  // <body> element. If this happens, try to move focus back into the trap.
801
830
  if (isFocusedNodeRemoved) {
802
- tryFocus(getInitialFocusNode());
831
+ _tryFocus(getInitialFocusNode());
803
832
  }
804
833
  };
805
834
 
@@ -845,14 +874,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
845
874
  state.active = true;
846
875
  state.paused = false;
847
876
  state.nodeFocusedBeforeActivation = doc.activeElement;
848
- onActivate === null || onActivate === void 0 || onActivate();
877
+ onActivate === null || onActivate === undefined || onActivate();
849
878
  var finishActivation = function finishActivation() {
850
879
  if (checkCanFocusTrap) {
851
880
  updateTabbableNodes();
852
881
  }
853
882
  addListeners();
854
883
  updateObservedNodes();
855
- onPostActivate === null || onPostActivate === void 0 || onPostActivate();
884
+ onPostActivate === null || onPostActivate === undefined || onPostActivate();
856
885
  };
857
886
  if (checkCanFocusTrap) {
858
887
  checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
@@ -881,13 +910,13 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
881
910
  var onPostDeactivate = getOption(options, 'onPostDeactivate');
882
911
  var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
883
912
  var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
884
- onDeactivate === null || onDeactivate === void 0 || onDeactivate();
913
+ onDeactivate === null || onDeactivate === undefined || onDeactivate();
885
914
  var finishDeactivation = function finishDeactivation() {
886
915
  delay(function () {
887
916
  if (returnFocus) {
888
- tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
917
+ _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
889
918
  }
890
- onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
919
+ onPostDeactivate === null || onPostDeactivate === undefined || onPostDeactivate();
891
920
  });
892
921
  };
893
922
  if (returnFocus && checkCanReturnFocus) {
@@ -898,31 +927,21 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
898
927
  return this;
899
928
  },
900
929
  pause: function pause(pauseOptions) {
901
- if (state.paused || !state.active) {
930
+ if (!state.active) {
902
931
  return this;
903
932
  }
904
- var onPause = getOption(pauseOptions, 'onPause');
905
- var onPostPause = getOption(pauseOptions, 'onPostPause');
906
- state.paused = true;
907
- onPause === null || onPause === void 0 || onPause();
908
- removeListeners();
909
- updateObservedNodes();
910
- onPostPause === null || onPostPause === void 0 || onPostPause();
911
- return this;
933
+ state.manuallyPaused = true;
934
+ return this._setPausedState(true, pauseOptions);
912
935
  },
913
936
  unpause: function unpause(unpauseOptions) {
914
- if (!state.paused || !state.active) {
937
+ if (!state.active) {
915
938
  return this;
916
939
  }
917
- var onUnpause = getOption(unpauseOptions, 'onUnpause');
918
- var onPostUnpause = getOption(unpauseOptions, 'onPostUnpause');
919
- state.paused = false;
920
- onUnpause === null || onUnpause === void 0 || onUnpause();
921
- updateTabbableNodes();
922
- addListeners();
923
- updateObservedNodes();
924
- onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
925
- return this;
940
+ state.manuallyPaused = false;
941
+ if (trapStack[trapStack.length - 1] !== this) {
942
+ return this;
943
+ }
944
+ return this._setPausedState(false, unpauseOptions);
926
945
  },
927
946
  updateContainerElements: function updateContainerElements(containerElements) {
928
947
  var elementsAsArray = [].concat(containerElements).filter(Boolean);
@@ -936,6 +955,38 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
936
955
  return this;
937
956
  }
938
957
  };
958
+ Object.defineProperties(trap, {
959
+ _isManuallyPaused: {
960
+ value: function value() {
961
+ return state.manuallyPaused;
962
+ }
963
+ },
964
+ _setPausedState: {
965
+ value: function value(paused, options) {
966
+ if (state.paused === paused) {
967
+ return this;
968
+ }
969
+ state.paused = paused;
970
+ if (paused) {
971
+ var onPause = getOption(options, 'onPause');
972
+ var onPostPause = getOption(options, 'onPostPause');
973
+ onPause === null || onPause === undefined || onPause();
974
+ removeListeners();
975
+ updateObservedNodes();
976
+ onPostPause === null || onPostPause === undefined || onPostPause();
977
+ } else {
978
+ var onUnpause = getOption(options, 'onUnpause');
979
+ var onPostUnpause = getOption(options, 'onPostUnpause');
980
+ onUnpause === null || onUnpause === undefined || onUnpause();
981
+ updateTabbableNodes();
982
+ addListeners();
983
+ updateObservedNodes();
984
+ onPostUnpause === null || onPostUnpause === undefined || onPostUnpause();
985
+ }
986
+ return this;
987
+ }
988
+ }
989
+ });
939
990
 
940
991
  // initialize container elements
941
992
  trap.updateContainerElements(elements);