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