@dso-toolkit/core 47.0.0 → 48.0.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 (215) hide show
  1. package/dist/cjs/dso-accordion-section.cjs.entry.js +1447 -58
  2. package/dist/cjs/dso-autosuggest.cjs.entry.js +57 -47
  3. package/dist/cjs/dso-date-picker.cjs.entry.js +3 -2
  4. package/dist/cjs/dso-dropdown-menu.cjs.entry.js +2 -2
  5. package/dist/cjs/dso-helpcenter-panel.cjs.entry.js +1 -1
  6. package/dist/cjs/dso-image-overlay.cjs.entry.js +1 -1
  7. package/dist/cjs/dso-info_2.cjs.entry.js +2 -2
  8. package/dist/cjs/dso-label.cjs.entry.js +2 -2
  9. package/dist/cjs/dso-modal.cjs.entry.js +4 -7
  10. package/dist/cjs/dso-ozon-content.cjs.entry.js +3 -3
  11. package/dist/cjs/dso-table.cjs.entry.js +3 -5
  12. package/dist/cjs/dso-toggletip.cjs.entry.js +1 -1
  13. package/dist/cjs/dso-toolkit.cjs.js +2 -2
  14. package/dist/cjs/dso-tooltip.cjs.entry.js +13 -21
  15. package/dist/cjs/dso-viewer-grid.cjs.entry.js +8 -3
  16. package/dist/cjs/{focus-trap.esm-d83fd673.js → focus-trap.esm-c501d382.js} +82 -155
  17. package/dist/cjs/loader.cjs.js +2 -2
  18. package/dist/collection/collection-manifest.json +8 -8
  19. package/dist/collection/components/accordion/components/accordion-section.css +27 -4
  20. package/dist/collection/components/accordion/components/accordion-section.interfaces.js +6 -0
  21. package/dist/collection/components/accordion/components/accordion-section.js +91 -59
  22. package/dist/collection/components/accordion/components/handles/element.handle.js +7 -0
  23. package/dist/collection/components/accordion/components/handles/heading.handle.js +14 -0
  24. package/dist/collection/components/accordion/components/handles/icon.handle.js +13 -0
  25. package/dist/collection/components/accordion/components/handles/index.js +4 -0
  26. package/dist/collection/components/accordion/components/handles/state-icon.handle.js +15 -0
  27. package/dist/collection/components/autosuggest/autosuggest.interfaces.js +1 -0
  28. package/dist/collection/components/autosuggest/autosuggest.js +61 -49
  29. package/dist/collection/components/banner/banner.js +1 -1
  30. package/dist/collection/components/card-container/card-container.js +1 -1
  31. package/dist/collection/components/date-picker/date-picker.interfaces.js +1 -0
  32. package/dist/collection/components/date-picker/date-picker.js +19 -11
  33. package/dist/collection/components/dropdown-menu/dropdown-menu.js +2 -2
  34. package/dist/collection/components/header/header.js +2 -6
  35. package/dist/collection/components/info-button/info-button.interfaces.js +1 -0
  36. package/dist/collection/components/info-button/info-button.js +2 -1
  37. package/dist/collection/components/label/label.js +2 -2
  38. package/dist/collection/components/modal/modal.css +103 -75
  39. package/dist/collection/components/modal/modal.interfaces.js +1 -0
  40. package/dist/collection/components/modal/modal.js +6 -9
  41. package/dist/collection/components/ozon-content/nodes/noot.node.js +1 -1
  42. package/dist/collection/components/ozon-content/nodes/table.node/table.node.js +1 -1
  43. package/dist/collection/components/progress-indicator/progress-indicator.js +1 -1
  44. package/dist/collection/components/selectable/selectable.css +18 -1
  45. package/dist/collection/components/selectable/selectable.interfaces.js +1 -0
  46. package/dist/collection/components/selectable/selectable.js +3 -2
  47. package/dist/collection/components/table/table.css +49 -16
  48. package/dist/collection/components/table/table.js +2 -4
  49. package/dist/collection/components/toggletip/toggletip.js +1 -1
  50. package/dist/collection/components/tooltip/tooltip.js +13 -42
  51. package/dist/collection/components/tree-view/tree-view.js +8 -2
  52. package/dist/collection/components/viewer-grid/viewer-grid.interfaces.js +1 -0
  53. package/dist/collection/components/viewer-grid/viewer-grid.js +19 -11
  54. package/dist/collection/index.js +13 -0
  55. package/dist/components/clsx.m.js +3 -0
  56. package/dist/components/create-identifier.js +15 -0
  57. package/dist/components/dropdown-menu.js +151 -0
  58. package/dist/components/dso-accordion-section.d.ts +11 -0
  59. package/dist/components/dso-accordion-section.js +1535 -0
  60. package/dist/components/dso-accordion.d.ts +11 -0
  61. package/dist/components/dso-accordion.js +316 -0
  62. package/dist/components/dso-alert.d.ts +11 -0
  63. package/dist/components/dso-alert.js +55 -0
  64. package/dist/components/dso-attachments-counter.d.ts +11 -0
  65. package/dist/components/dso-attachments-counter.js +42 -0
  66. package/dist/components/dso-autosuggest.d.ts +11 -0
  67. package/dist/components/dso-autosuggest.js +309 -0
  68. package/dist/components/dso-badge.d.ts +11 -0
  69. package/dist/components/dso-badge.js +37 -0
  70. package/dist/components/dso-banner.d.ts +11 -0
  71. package/dist/components/dso-banner.js +37 -0
  72. package/dist/components/dso-card-container.d.ts +11 -0
  73. package/dist/components/dso-card-container.js +36 -0
  74. package/dist/components/dso-card.d.ts +11 -0
  75. package/dist/components/dso-card.js +66 -0
  76. package/dist/components/dso-date-picker.d.ts +11 -0
  77. package/dist/components/dso-date-picker.js +682 -0
  78. package/dist/components/dso-dropdown-menu.d.ts +11 -0
  79. package/dist/components/dso-dropdown-menu.js +6 -0
  80. package/dist/components/dso-header.d.ts +11 -0
  81. package/dist/components/dso-header.js +159 -0
  82. package/dist/components/dso-helpcenter-panel.d.ts +11 -0
  83. package/dist/components/dso-helpcenter-panel.js +127 -0
  84. package/dist/components/dso-highlight-box.d.ts +11 -0
  85. package/dist/components/dso-highlight-box.js +55 -0
  86. package/dist/components/dso-icon.d.ts +11 -0
  87. package/dist/components/dso-icon.js +6 -0
  88. package/dist/components/dso-image-overlay.d.ts +11 -0
  89. package/dist/components/dso-image-overlay.js +129 -0
  90. package/dist/components/dso-info-button.d.ts +11 -0
  91. package/dist/components/dso-info-button.js +6 -0
  92. package/dist/components/dso-info.d.ts +11 -0
  93. package/dist/components/dso-info.js +6 -0
  94. package/dist/components/dso-label.d.ts +11 -0
  95. package/dist/components/dso-label.js +156 -0
  96. package/dist/components/dso-map-base-layers.d.ts +11 -0
  97. package/dist/components/dso-map-base-layers.js +80 -0
  98. package/dist/components/dso-map-controls.d.ts +11 -0
  99. package/dist/components/dso-map-controls.js +86 -0
  100. package/dist/components/dso-map-overlays.d.ts +11 -0
  101. package/dist/components/dso-map-overlays.js +81 -0
  102. package/dist/components/dso-modal.d.ts +11 -0
  103. package/dist/components/dso-modal.js +85 -0
  104. package/dist/components/dso-ozon-content.d.ts +11 -0
  105. package/dist/components/dso-ozon-content.js +507 -0
  106. package/dist/components/dso-pagination.d.ts +11 -0
  107. package/dist/components/dso-pagination.js +159 -0
  108. package/dist/components/dso-progress-bar.d.ts +11 -0
  109. package/dist/components/dso-progress-bar.js +42 -0
  110. package/dist/components/dso-progress-indicator.d.ts +11 -0
  111. package/dist/components/dso-progress-indicator.js +6 -0
  112. package/dist/components/dso-responsive-element.d.ts +11 -0
  113. package/dist/components/dso-responsive-element.js +6 -0
  114. package/dist/components/dso-selectable.d.ts +11 -0
  115. package/dist/components/dso-selectable.js +6 -0
  116. package/dist/components/dso-table.d.ts +11 -0
  117. package/dist/components/dso-table.js +111 -0
  118. package/dist/components/dso-toggletip.d.ts +11 -0
  119. package/dist/components/dso-toggletip.js +90 -0
  120. package/dist/components/dso-tooltip.d.ts +11 -0
  121. package/dist/components/dso-tooltip.js +6 -0
  122. package/dist/components/dso-tree-view.d.ts +11 -0
  123. package/dist/components/dso-tree-view.js +227 -0
  124. package/dist/components/dso-viewer-grid.d.ts +11 -0
  125. package/dist/components/dso-viewer-grid.js +171 -0
  126. package/dist/components/focus-trap.esm.js +688 -0
  127. package/dist/components/icon.js +663 -0
  128. package/dist/components/index.d.ts +55 -0
  129. package/dist/components/index.esm.js +458 -0
  130. package/dist/components/index.js +35 -0
  131. package/dist/components/index2.js +70 -0
  132. package/dist/components/info-button.js +56 -0
  133. package/dist/components/info.js +42 -0
  134. package/dist/components/is-modified-event.js +4 -0
  135. package/dist/components/progress-indicator.js +44 -0
  136. package/dist/components/responsive-element.js +67 -0
  137. package/dist/components/selectable.js +108 -0
  138. package/dist/components/tooltip.js +2047 -0
  139. package/dist/components/v4.js +66 -0
  140. package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
  141. package/dist/dso-toolkit/p-04ffcc93.entry.js +1 -0
  142. package/dist/dso-toolkit/{p-e0a37d82.entry.js → p-06b4f78d.entry.js} +1 -1
  143. package/dist/dso-toolkit/{p-2b83a825.entry.js → p-35687d62.entry.js} +1 -1
  144. package/dist/dso-toolkit/p-52bc72d0.entry.js +1 -0
  145. package/dist/dso-toolkit/p-57ceabab.js +5 -0
  146. package/dist/dso-toolkit/p-655eff47.entry.js +1 -0
  147. package/dist/dso-toolkit/p-672c8323.entry.js +1 -0
  148. package/dist/dso-toolkit/p-7f8be9bc.entry.js +1 -0
  149. package/dist/dso-toolkit/p-80575700.entry.js +1 -0
  150. package/dist/dso-toolkit/p-8e9f6355.entry.js +1 -0
  151. package/dist/dso-toolkit/p-a8cb2eae.entry.js +1 -0
  152. package/dist/dso-toolkit/p-d31805a9.entry.js +1 -0
  153. package/dist/dso-toolkit/{p-dcc74039.entry.js → p-d7b2adc3.entry.js} +1 -1
  154. package/dist/dso-toolkit/{p-800e1267.entry.js → p-daee3252.entry.js} +1 -1
  155. package/dist/dso-toolkit/p-ec5412aa.entry.js +1 -0
  156. package/dist/esm/dso-accordion-section.entry.js +1448 -59
  157. package/dist/esm/dso-autosuggest.entry.js +57 -47
  158. package/dist/esm/dso-date-picker.entry.js +3 -2
  159. package/dist/esm/dso-dropdown-menu.entry.js +2 -2
  160. package/dist/esm/dso-helpcenter-panel.entry.js +1 -1
  161. package/dist/esm/dso-image-overlay.entry.js +1 -1
  162. package/dist/esm/dso-info_2.entry.js +2 -2
  163. package/dist/esm/dso-label.entry.js +2 -2
  164. package/dist/esm/dso-modal.entry.js +5 -8
  165. package/dist/esm/dso-ozon-content.entry.js +3 -3
  166. package/dist/esm/dso-table.entry.js +3 -5
  167. package/dist/esm/dso-toggletip.entry.js +1 -1
  168. package/dist/esm/dso-toolkit.js +2 -2
  169. package/dist/esm/dso-tooltip.entry.js +13 -21
  170. package/dist/esm/dso-viewer-grid.entry.js +8 -3
  171. package/dist/esm/{focus-trap.esm-33203b60.js → focus-trap.esm-94794d92.js} +82 -155
  172. package/dist/esm/loader.js +2 -2
  173. package/dist/types/components/accordion/accordion.interfaces.d.ts +0 -2
  174. package/dist/types/components/accordion/components/accordion-section.d.ts +10 -1
  175. package/dist/types/components/accordion/components/accordion-section.interfaces.d.ts +3 -0
  176. package/dist/types/components/accordion/components/handles/element.handle.d.ts +6 -0
  177. package/dist/types/components/accordion/components/handles/heading.handle.d.ts +5 -0
  178. package/dist/types/components/accordion/components/handles/icon.handle.d.ts +7 -0
  179. package/dist/types/components/accordion/components/handles/index.d.ts +4 -0
  180. package/dist/types/components/accordion/components/handles/state-icon.handle.d.ts +5 -0
  181. package/dist/types/components/autosuggest/autosuggest.d.ts +2 -15
  182. package/dist/types/components/autosuggest/autosuggest.interfaces.d.ts +14 -0
  183. package/dist/types/components/date-picker/date-picker.d.ts +2 -15
  184. package/dist/types/components/date-picker/date-picker.interfaces.d.ts +14 -0
  185. package/dist/types/components/dropdown-menu/dropdown-menu.d.ts +1 -1
  186. package/dist/types/components/header/header.d.ts +2 -2
  187. package/dist/types/components/header/header.interfaces.d.ts +1 -0
  188. package/dist/types/components/info-button/info-button.d.ts +1 -4
  189. package/dist/types/components/info-button/info-button.interfaces.d.ts +4 -0
  190. package/dist/types/components/map-overlays/map-overlays.d.ts +1 -1
  191. package/dist/types/components/modal/modal.d.ts +3 -5
  192. package/dist/types/components/modal/modal.interfaces.d.ts +3 -0
  193. package/dist/types/components/selectable/selectable.d.ts +1 -2
  194. package/dist/types/components/selectable/selectable.interfaces.d.ts +2 -0
  195. package/dist/types/components/table/table.d.ts +1 -1
  196. package/dist/types/components/tooltip/tooltip.d.ts +0 -8
  197. package/dist/types/components/tree-view/tree-view.d.ts +2 -2
  198. package/dist/types/components/viewer-grid/viewer-grid.d.ts +5 -16
  199. package/dist/types/components/viewer-grid/viewer-grid.interfaces.d.ts +15 -0
  200. package/dist/types/components.d.ts +20 -27
  201. package/dist/types/index.d.ts +13 -0
  202. package/package.json +8 -8
  203. package/dist/custom-elements/index.d.ts +0 -243
  204. package/dist/custom-elements/index.js +0 -7555
  205. package/dist/dso-toolkit/p-0917f18a.entry.js +0 -1
  206. package/dist/dso-toolkit/p-0c8cd0d8.entry.js +0 -1
  207. package/dist/dso-toolkit/p-203fc66c.entry.js +0 -1
  208. package/dist/dso-toolkit/p-3ab4441a.entry.js +0 -1
  209. package/dist/dso-toolkit/p-44c0bb3e.entry.js +0 -1
  210. package/dist/dso-toolkit/p-89d262b7.js +0 -5
  211. package/dist/dso-toolkit/p-9aa3fa9d.entry.js +0 -1
  212. package/dist/dso-toolkit/p-ba253bcd.entry.js +0 -1
  213. package/dist/dso-toolkit/p-e43e39cf.entry.js +0 -1
  214. package/dist/dso-toolkit/p-e8b22546.entry.js +0 -1
  215. package/dist/dso-toolkit/p-f93b7c7a.entry.js +0 -1
@@ -3,23 +3,20 @@
3
3
  const index_esm = require('./index.esm-03a9e0b4.js');
4
4
 
5
5
  /*!
6
- * focus-trap 7.0.0
6
+ * focus-trap 7.1.0
7
7
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
8
8
  */
9
9
 
10
10
  function ownKeys(object, enumerableOnly) {
11
11
  var keys = Object.keys(object);
12
-
13
12
  if (Object.getOwnPropertySymbols) {
14
13
  var symbols = Object.getOwnPropertySymbols(object);
15
14
  enumerableOnly && (symbols = symbols.filter(function (sym) {
16
15
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
17
16
  })), keys.push.apply(keys, symbols);
18
17
  }
19
-
20
18
  return keys;
21
19
  }
22
-
23
20
  function _objectSpread2(target) {
24
21
  for (var i = 1; i < arguments.length; i++) {
25
22
  var source = null != arguments[i] ? arguments[i] : {};
@@ -29,10 +26,8 @@ function _objectSpread2(target) {
29
26
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
30
27
  });
31
28
  }
32
-
33
29
  return target;
34
30
  }
35
-
36
31
  function _defineProperty(obj, key, value) {
37
32
  if (key in obj) {
38
33
  Object.defineProperty(obj, key, {
@@ -44,64 +39,52 @@ function _defineProperty(obj, key, value) {
44
39
  } else {
45
40
  obj[key] = value;
46
41
  }
47
-
48
42
  return obj;
49
43
  }
50
44
 
51
- var activeFocusTraps = function () {
52
- var trapQueue = [];
53
- return {
54
- activateTrap: function activateTrap(trap) {
55
- if (trapQueue.length > 0) {
56
- var activeTrap = trapQueue[trapQueue.length - 1];
57
-
58
- if (activeTrap !== trap) {
59
- activeTrap.pause();
60
- }
61
- }
62
-
63
- var trapIndex = trapQueue.indexOf(trap);
64
-
65
- if (trapIndex === -1) {
66
- trapQueue.push(trap);
67
- } else {
68
- // move this existing trap to the front of the queue
69
- trapQueue.splice(trapIndex, 1);
70
- trapQueue.push(trap);
71
- }
72
- },
73
- deactivateTrap: function deactivateTrap(trap) {
74
- var trapIndex = trapQueue.indexOf(trap);
75
-
76
- if (trapIndex !== -1) {
77
- trapQueue.splice(trapIndex, 1);
78
- }
79
-
80
- if (trapQueue.length > 0) {
81
- trapQueue[trapQueue.length - 1].unpause();
45
+ var rooTrapStack = [];
46
+ var activeFocusTraps = {
47
+ activateTrap: function activateTrap(trapStack, trap) {
48
+ if (trapStack.length > 0) {
49
+ var activeTrap = trapStack[trapStack.length - 1];
50
+ if (activeTrap !== trap) {
51
+ activeTrap.pause();
82
52
  }
83
53
  }
84
- };
85
- }();
86
-
54
+ var trapIndex = trapStack.indexOf(trap);
55
+ if (trapIndex === -1) {
56
+ trapStack.push(trap);
57
+ } else {
58
+ // move this existing trap to the front of the queue
59
+ trapStack.splice(trapIndex, 1);
60
+ trapStack.push(trap);
61
+ }
62
+ },
63
+ deactivateTrap: function deactivateTrap(trapStack, trap) {
64
+ var trapIndex = trapStack.indexOf(trap);
65
+ if (trapIndex !== -1) {
66
+ trapStack.splice(trapIndex, 1);
67
+ }
68
+ if (trapStack.length > 0) {
69
+ trapStack[trapStack.length - 1].unpause();
70
+ }
71
+ }
72
+ };
87
73
  var isSelectableInput = function isSelectableInput(node) {
88
74
  return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
89
75
  };
90
-
91
76
  var isEscapeEvent = function isEscapeEvent(e) {
92
77
  return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
93
78
  };
94
-
95
79
  var isTabEvent = function isTabEvent(e) {
96
80
  return e.key === 'Tab' || e.keyCode === 9;
97
81
  };
98
-
99
82
  var delay = function delay(fn) {
100
83
  return setTimeout(fn, 0);
101
- }; // Array.find/findIndex() are not supported on IE; this replicates enough
102
- // of Array.findIndex() for our needs
103
-
84
+ };
104
85
 
86
+ // Array.find/findIndex() are not supported on IE; this replicates enough
87
+ // of Array.findIndex() for our needs
105
88
  var findIndex = function findIndex(arr, fn) {
106
89
  var idx = -1;
107
90
  arr.every(function (value, i) {
@@ -112,8 +95,10 @@ var findIndex = function findIndex(arr, fn) {
112
95
 
113
96
  return true; // next
114
97
  });
98
+
115
99
  return idx;
116
100
  };
101
+
117
102
  /**
118
103
  * Get an option's value when it could be a plain value, or a handler that provides
119
104
  * the value.
@@ -121,16 +106,12 @@ var findIndex = function findIndex(arr, fn) {
121
106
  * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
122
107
  * @returns {*} The `value`, or the handler's returned value.
123
108
  */
124
-
125
-
126
109
  var valueOrHandler = function valueOrHandler(value) {
127
110
  for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
128
111
  params[_key - 1] = arguments[_key];
129
112
  }
130
-
131
113
  return typeof value === 'function' ? value.apply(void 0, params) : value;
132
114
  };
133
-
134
115
  var getActualTarget = function getActualTarget(event) {
135
116
  // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
136
117
  // shadow host. However, event.target.composedPath() will be an array of
@@ -141,18 +122,16 @@ var getActualTarget = function getActualTarget(event) {
141
122
  // composedPath()[0] === event.target always).
142
123
  return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
143
124
  };
144
-
145
125
  var createFocusTrap = function createFocusTrap(elements, userOptions) {
146
126
  // SSR: a live trap shouldn't be created in this type of environment so this
147
127
  // should be safe code to execute if the `document` option isn't specified
148
128
  var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
149
-
129
+ var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || rooTrapStack;
150
130
  var config = _objectSpread2({
151
131
  returnFocusOnDeactivate: true,
152
132
  escapeDeactivates: true,
153
133
  delayInitialFocus: true
154
134
  }, userOptions);
155
-
156
135
  var state = {
157
136
  // containers given to createFocusTrap()
158
137
  // @type {Array<HTMLElement>}
@@ -172,6 +151,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
172
151
  // }>}
173
152
  containerGroups: [],
174
153
  // same order/length as `containers` list
154
+
175
155
  // references to objects in `containerGroups`, but only those that actually have
176
156
  // tabbable nodes in them
177
157
  // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
@@ -195,10 +175,10 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
195
175
  * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
196
176
  * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
197
177
  */
198
-
199
178
  var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
200
179
  return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
201
180
  };
181
+
202
182
  /**
203
183
  * Finds the index of the container that contains the element.
204
184
  * @param {HTMLElement} element
@@ -206,16 +186,15 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
206
186
  * `state.containerGroups` (the order/length of these lists are the same); -1
207
187
  * if the element isn't found.
208
188
  */
209
-
210
-
211
189
  var findContainerIndex = function findContainerIndex(element) {
212
190
  // NOTE: search `containerGroups` because it's possible a group contains no tabbable
213
191
  // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
214
192
  // and we still need to find the element in there
215
193
  return state.containerGroups.findIndex(function (_ref) {
216
194
  var container = _ref.container,
217
- tabbableNodes = _ref.tabbableNodes;
218
- return container.contains(element) || // fall back to explicit tabbable search which will take into consideration any
195
+ tabbableNodes = _ref.tabbableNodes;
196
+ return container.contains(element) ||
197
+ // fall back to explicit tabbable search which will take into consideration any
219
198
  // web components if the `tabbableOptions.getShadowRoot` option was used for
220
199
  // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
221
200
  // look inside web components even if open)
@@ -224,6 +203,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
224
203
  });
225
204
  });
226
205
  };
206
+
227
207
  /**
228
208
  * Gets the node for the given option, which is expected to be an option that
229
209
  * can be either a DOM node, a string that is a selector to get a node, `false`
@@ -237,19 +217,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
237
217
  * @throws {Error} If the option is set, not `false`, and is not, or does not
238
218
  * resolve to a node.
239
219
  */
240
-
241
-
242
220
  var getNodeForOption = function getNodeForOption(optionName) {
243
221
  var optionValue = config[optionName];
244
-
245
222
  if (typeof optionValue === 'function') {
246
223
  for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
247
224
  params[_key2 - 1] = arguments[_key2];
248
225
  }
249
-
250
226
  optionValue = optionValue.apply(void 0, params);
251
227
  }
252
-
253
228
  if (optionValue === true) {
254
229
  optionValue = undefined; // use default value
255
230
  }
@@ -257,56 +232,51 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
257
232
  if (!optionValue) {
258
233
  if (optionValue === undefined || optionValue === false) {
259
234
  return optionValue;
260
- } // else, empty string (invalid), null (invalid), 0 (invalid)
261
-
235
+ }
236
+ // else, empty string (invalid), null (invalid), 0 (invalid)
262
237
 
263
238
  throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
264
239
  }
265
-
266
240
  var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
267
241
 
268
242
  if (typeof optionValue === 'string') {
269
243
  node = doc.querySelector(optionValue); // resolve to node, or null if fails
270
-
271
244
  if (!node) {
272
245
  throw new Error("`".concat(optionName, "` as selector refers to no known node"));
273
246
  }
274
247
  }
275
-
276
248
  return node;
277
249
  };
278
-
279
250
  var getInitialFocusNode = function getInitialFocusNode() {
280
- var node = getNodeForOption('initialFocus'); // false explicitly indicates we want no initialFocus at all
251
+ var node = getNodeForOption('initialFocus');
281
252
 
253
+ // false explicitly indicates we want no initialFocus at all
282
254
  if (node === false) {
283
255
  return false;
284
256
  }
285
-
286
257
  if (node === undefined) {
287
258
  // option not specified: use fallback options
288
259
  if (findContainerIndex(doc.activeElement) >= 0) {
289
260
  node = doc.activeElement;
290
261
  } else {
291
262
  var firstTabbableGroup = state.tabbableGroups[0];
292
- var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
263
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
293
264
 
265
+ // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
294
266
  node = firstTabbableNode || getNodeForOption('fallbackFocus');
295
267
  }
296
268
  }
297
-
298
269
  if (!node) {
299
270
  throw new Error('Your focus-trap needs to have at least one focusable element');
300
271
  }
301
-
302
272
  return node;
303
273
  };
304
-
305
274
  var updateTabbableNodes = function updateTabbableNodes() {
306
275
  state.containerGroups = state.containers.map(function (container) {
307
- var tabbableNodes = index_esm.tabbable(container, config.tabbableOptions); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
308
- // are a superset of tabbable nodes
276
+ var tabbableNodes = index_esm.tabbable(container, config.tabbableOptions);
309
277
 
278
+ // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
279
+ // are a superset of tabbable nodes
310
280
  var focusableNodes = index_esm.focusable(container, config.tabbableOptions);
311
281
  return {
312
282
  container: container,
@@ -314,7 +284,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
314
284
  focusableNodes: focusableNodes,
315
285
  firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
316
286
  lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
317
-
318
287
  /**
319
288
  * Finds the __tabbable__ node that follows the given node in the specified direction,
320
289
  * in this container, if any.
@@ -338,17 +307,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
338
307
  var nodeIdx = focusableNodes.findIndex(function (n) {
339
308
  return n === node;
340
309
  });
341
-
342
310
  if (nodeIdx < 0) {
343
311
  return undefined;
344
312
  }
345
-
346
313
  if (forward) {
347
314
  return focusableNodes.slice(nodeIdx + 1).find(function (n) {
348
315
  return index_esm.isTabbable(n, config.tabbableOptions);
349
316
  });
350
317
  }
351
-
352
318
  return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
353
319
  return index_esm.isTabbable(n, config.tabbableOptions);
354
320
  });
@@ -357,53 +323,46 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
357
323
  });
358
324
  state.tabbableGroups = state.containerGroups.filter(function (group) {
359
325
  return group.tabbableNodes.length > 0;
360
- }); // throw if no groups have tabbable nodes and we don't have a fallback focus node either
326
+ });
361
327
 
328
+ // throw if no groups have tabbable nodes and we don't have a fallback focus node either
362
329
  if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
363
330
  ) {
364
331
  throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
365
332
  }
366
333
  };
367
-
368
334
  var tryFocus = function tryFocus(node) {
369
335
  if (node === false) {
370
336
  return;
371
337
  }
372
-
373
338
  if (node === doc.activeElement) {
374
339
  return;
375
340
  }
376
-
377
341
  if (!node || !node.focus) {
378
342
  tryFocus(getInitialFocusNode());
379
343
  return;
380
344
  }
381
-
382
345
  node.focus({
383
346
  preventScroll: !!config.preventScroll
384
347
  });
385
348
  state.mostRecentlyFocusedNode = node;
386
-
387
349
  if (isSelectableInput(node)) {
388
350
  node.select();
389
351
  }
390
352
  };
391
-
392
353
  var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
393
354
  var node = getNodeForOption('setReturnFocus', previousActiveElement);
394
355
  return node ? node : node === false ? false : previousActiveElement;
395
- }; // This needs to be done on mousedown and touchstart instead of click
396
- // so that it precedes the focus event.
397
-
356
+ };
398
357
 
358
+ // This needs to be done on mousedown and touchstart instead of click
359
+ // so that it precedes the focus event.
399
360
  var checkPointerDown = function checkPointerDown(e) {
400
361
  var target = getActualTarget(e);
401
-
402
362
  if (findContainerIndex(target) >= 0) {
403
363
  // allow the click since it ocurred inside the trap
404
364
  return;
405
365
  }
406
-
407
366
  if (valueOrHandler(config.clickOutsideDeactivates, e)) {
408
367
  // immediately deactivate the trap
409
368
  trap.deactivate({
@@ -421,25 +380,26 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
421
380
  returnFocus: config.returnFocusOnDeactivate && !index_esm.isFocusable(target, config.tabbableOptions)
422
381
  });
423
382
  return;
424
- } // This is needed for mobile devices.
383
+ }
384
+
385
+ // This is needed for mobile devices.
425
386
  // (If we'll only let `click` events through,
426
387
  // then on mobile they will be blocked anyways if `touchstart` is blocked.)
427
-
428
-
429
388
  if (valueOrHandler(config.allowOutsideClick, e)) {
430
389
  // allow the click outside the trap to take place
431
390
  return;
432
- } // otherwise, prevent the click
433
-
391
+ }
434
392
 
393
+ // otherwise, prevent the click
435
394
  e.preventDefault();
436
- }; // In case focus escapes the trap for some strange reason, pull it back in.
437
-
395
+ };
438
396
 
397
+ // In case focus escapes the trap for some strange reason, pull it back in.
439
398
  var checkFocusIn = function checkFocusIn(e) {
440
399
  var target = getActualTarget(e);
441
- var targetContained = findContainerIndex(target) >= 0; // In Firefox when you Tab out of an iframe the Document is briefly focused.
400
+ var targetContained = findContainerIndex(target) >= 0;
442
401
 
402
+ // In Firefox when you Tab out of an iframe the Document is briefly focused.
443
403
  if (targetContained || target instanceof Document) {
444
404
  if (targetContained) {
445
405
  state.mostRecentlyFocusedNode = target;
@@ -449,24 +409,22 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
449
409
  e.stopImmediatePropagation();
450
410
  tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
451
411
  }
452
- }; // Hijack Tab events on the first and last focusable nodes of the trap,
412
+ };
413
+
414
+ // Hijack Tab events on the first and last focusable nodes of the trap,
453
415
  // in order to prevent focus from escaping. If it escapes for even a
454
416
  // moment it can end up scrolling the page and causing confusion so we
455
417
  // kind of need to capture the action at the keydown phase.
456
-
457
-
458
418
  var checkTab = function checkTab(e) {
459
419
  var target = getActualTarget(e);
460
420
  updateTabbableNodes();
461
421
  var destinationNode = null;
462
-
463
422
  if (state.tabbableGroups.length > 0) {
464
423
  // make sure the target is actually contained in a group
465
424
  // NOTE: the target may also be the container itself if it's focusable
466
425
  // with tabIndex='-1' and was given initial focus
467
426
  var containerIndex = findContainerIndex(target);
468
427
  var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
469
-
470
428
  if (containerIndex < 0) {
471
429
  // target not found in any group: quite possible focus has escaped the trap,
472
430
  // so bring it back in to...
@@ -479,12 +437,12 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
479
437
  }
480
438
  } else if (e.shiftKey) {
481
439
  // REVERSE
440
+
482
441
  // is the target the first tabbable node in a group?
483
442
  var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
484
443
  var firstTabbableNode = _ref2.firstTabbableNode;
485
444
  return target === firstTabbableNode;
486
445
  });
487
-
488
446
  if (startOfGroupIndex < 0 && (containerGroup.container === target || index_esm.isFocusable(target, config.tabbableOptions) && !index_esm.isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
489
447
  // an exception case where the target is either the container itself, or
490
448
  // a non-tabbable node that was given focus (i.e. tabindex is negative
@@ -494,7 +452,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
494
452
  // first tabbable node, and go to the last tabbable node of the LAST group
495
453
  startOfGroupIndex = containerIndex;
496
454
  }
497
-
498
455
  if (startOfGroupIndex >= 0) {
499
456
  // YES: then shift+tab should go to the last tabbable node in the
500
457
  // previous group (and wrap around to the last tabbable node of
@@ -505,12 +462,12 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
505
462
  }
506
463
  } else {
507
464
  // FORWARD
465
+
508
466
  // is the target the last tabbable node in a group?
509
467
  var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
510
468
  var lastTabbableNode = _ref3.lastTabbableNode;
511
469
  return target === lastTabbableNode;
512
470
  });
513
-
514
471
  if (lastOfGroupIndex < 0 && (containerGroup.container === target || index_esm.isFocusable(target, config.tabbableOptions) && !index_esm.isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
515
472
  // an exception case where the target is the container itself, or
516
473
  // a non-tabbable node that was given focus (i.e. tabindex is negative
@@ -520,13 +477,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
520
477
  // last tabbable node, and go to the first tabbable node of the FIRST group
521
478
  lastOfGroupIndex = containerIndex;
522
479
  }
523
-
524
480
  if (lastOfGroupIndex >= 0) {
525
481
  // YES: then tab should go to the first tabbable node in the next
526
482
  // group (and wrap around to the first tabbable node of the FIRST
527
483
  // group if it's the last tabbable node of the LAST group)
528
484
  var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
529
-
530
485
  var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
531
486
  destinationNode = _destinationGroup.firstTabbableNode;
532
487
  }
@@ -535,12 +490,11 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
535
490
  // NOTE: the fallbackFocus option does not support returning false to opt-out
536
491
  destinationNode = getNodeForOption('fallbackFocus');
537
492
  }
538
-
539
493
  if (destinationNode) {
540
494
  e.preventDefault();
541
495
  tryFocus(destinationNode);
542
- } // else, let the browser take care of [shift+]tab and move the focus
543
-
496
+ }
497
+ // else, let the browser take care of [shift+]tab and move the focus
544
498
  };
545
499
 
546
500
  var checkKey = function checkKey(e) {
@@ -549,44 +503,40 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
549
503
  trap.deactivate();
550
504
  return;
551
505
  }
552
-
553
506
  if (isTabEvent(e)) {
554
507
  checkTab(e);
555
508
  return;
556
509
  }
557
510
  };
558
-
559
511
  var checkClick = function checkClick(e) {
560
512
  var target = getActualTarget(e);
561
-
562
513
  if (findContainerIndex(target) >= 0) {
563
514
  return;
564
515
  }
565
-
566
516
  if (valueOrHandler(config.clickOutsideDeactivates, e)) {
567
517
  return;
568
518
  }
569
-
570
519
  if (valueOrHandler(config.allowOutsideClick, e)) {
571
520
  return;
572
521
  }
573
-
574
522
  e.preventDefault();
575
523
  e.stopImmediatePropagation();
576
- }; //
524
+ };
525
+
526
+ //
577
527
  // EVENT LISTENERS
578
528
  //
579
529
 
580
-
581
530
  var addListeners = function addListeners() {
582
531
  if (!state.active) {
583
532
  return;
584
- } // There can be only one listening focus trap at a time
533
+ }
585
534
 
535
+ // There can be only one listening focus trap at a time
536
+ activeFocusTraps.activateTrap(trapStack, trap);
586
537
 
587
- activeFocusTraps.activateTrap(trap); // Delay ensures that the focused element doesn't capture the event
538
+ // Delay ensures that the focused element doesn't capture the event
588
539
  // that caused the focus trap activation.
589
-
590
540
  state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
591
541
  tryFocus(getInitialFocusNode());
592
542
  }) : tryFocus(getInitialFocusNode());
@@ -609,70 +559,58 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
609
559
  });
610
560
  return trap;
611
561
  };
612
-
613
562
  var removeListeners = function removeListeners() {
614
563
  if (!state.active) {
615
564
  return;
616
565
  }
617
-
618
566
  doc.removeEventListener('focusin', checkFocusIn, true);
619
567
  doc.removeEventListener('mousedown', checkPointerDown, true);
620
568
  doc.removeEventListener('touchstart', checkPointerDown, true);
621
569
  doc.removeEventListener('click', checkClick, true);
622
570
  doc.removeEventListener('keydown', checkKey, true);
623
571
  return trap;
624
- }; //
572
+ };
573
+
574
+ //
625
575
  // TRAP DEFINITION
626
576
  //
627
577
 
628
-
629
578
  trap = {
630
579
  get active() {
631
580
  return state.active;
632
581
  },
633
-
634
582
  get paused() {
635
583
  return state.paused;
636
584
  },
637
-
638
585
  activate: function activate(activateOptions) {
639
586
  if (state.active) {
640
587
  return this;
641
588
  }
642
-
643
589
  var onActivate = getOption(activateOptions, 'onActivate');
644
590
  var onPostActivate = getOption(activateOptions, 'onPostActivate');
645
591
  var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
646
-
647
592
  if (!checkCanFocusTrap) {
648
593
  updateTabbableNodes();
649
594
  }
650
-
651
595
  state.active = true;
652
596
  state.paused = false;
653
597
  state.nodeFocusedBeforeActivation = doc.activeElement;
654
-
655
598
  if (onActivate) {
656
599
  onActivate();
657
600
  }
658
-
659
601
  var finishActivation = function finishActivation() {
660
602
  if (checkCanFocusTrap) {
661
603
  updateTabbableNodes();
662
604
  }
663
-
664
605
  addListeners();
665
-
666
606
  if (onPostActivate) {
667
607
  onPostActivate();
668
608
  }
669
609
  };
670
-
671
610
  if (checkCanFocusTrap) {
672
611
  checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
673
612
  return this;
674
613
  }
675
-
676
614
  finishActivation();
677
615
  return this;
678
616
  },
@@ -680,46 +618,38 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
680
618
  if (!state.active) {
681
619
  return this;
682
620
  }
683
-
684
621
  var options = _objectSpread2({
685
622
  onDeactivate: config.onDeactivate,
686
623
  onPostDeactivate: config.onPostDeactivate,
687
624
  checkCanReturnFocus: config.checkCanReturnFocus
688
625
  }, deactivateOptions);
689
-
690
626
  clearTimeout(state.delayInitialFocusTimer); // noop if undefined
691
-
692
627
  state.delayInitialFocusTimer = undefined;
693
628
  removeListeners();
694
629
  state.active = false;
695
630
  state.paused = false;
696
- activeFocusTraps.deactivateTrap(trap);
631
+ activeFocusTraps.deactivateTrap(trapStack, trap);
697
632
  var onDeactivate = getOption(options, 'onDeactivate');
698
633
  var onPostDeactivate = getOption(options, 'onPostDeactivate');
699
634
  var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
700
635
  var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
701
-
702
636
  if (onDeactivate) {
703
637
  onDeactivate();
704
638
  }
705
-
706
639
  var finishDeactivation = function finishDeactivation() {
707
640
  delay(function () {
708
641
  if (returnFocus) {
709
642
  tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
710
643
  }
711
-
712
644
  if (onPostDeactivate) {
713
645
  onPostDeactivate();
714
646
  }
715
647
  });
716
648
  };
717
-
718
649
  if (returnFocus && checkCanReturnFocus) {
719
650
  checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
720
651
  return this;
721
652
  }
722
-
723
653
  finishDeactivation();
724
654
  return this;
725
655
  },
@@ -727,7 +657,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
727
657
  if (state.paused || !state.active) {
728
658
  return this;
729
659
  }
730
-
731
660
  state.paused = true;
732
661
  removeListeners();
733
662
  return this;
@@ -736,7 +665,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
736
665
  if (!state.paused || !state.active) {
737
666
  return this;
738
667
  }
739
-
740
668
  state.paused = false;
741
669
  updateTabbableNodes();
742
670
  addListeners();
@@ -747,15 +675,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
747
675
  state.containers = elementsAsArray.map(function (element) {
748
676
  return typeof element === 'string' ? doc.querySelector(element) : element;
749
677
  });
750
-
751
678
  if (state.active) {
752
679
  updateTabbableNodes();
753
680
  }
754
-
755
681
  return this;
756
682
  }
757
- }; // initialize container elements
683
+ };
758
684
 
685
+ // initialize container elements
759
686
  trap.updateContainerElements(elements);
760
687
  return trap;
761
688
  };