@dso-toolkit/core 34.2.1 → 36.1.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 (194) hide show
  1. package/dist/cjs/dso-alert.cjs.entry.js +1 -1
  2. package/dist/cjs/dso-attachments-counter.cjs.entry.js +1 -1
  3. package/dist/cjs/dso-autosuggest.cjs.entry.js +7 -3
  4. package/dist/cjs/dso-badge.cjs.entry.js +1 -1
  5. package/dist/cjs/dso-banner.cjs.entry.js +1 -1
  6. package/dist/cjs/dso-date-picker.cjs.entry.js +2 -2
  7. package/dist/cjs/dso-dropdown-menu.cjs.entry.js +2 -2
  8. package/dist/cjs/dso-header.cjs.entry.js +16 -7
  9. package/dist/cjs/dso-helpcenter-panel.cjs.entry.js +1 -1
  10. package/dist/cjs/dso-highlight-box.cjs.entry.js +1 -1
  11. package/dist/cjs/dso-icon.cjs.entry.js +1 -1
  12. package/dist/cjs/dso-image-overlay.cjs.entry.js +62 -0
  13. package/dist/cjs/dso-info-button.cjs.entry.js +1 -1
  14. package/dist/cjs/dso-info_2.cjs.entry.js +2 -2
  15. package/dist/cjs/dso-label.cjs.entry.js +1 -1
  16. package/dist/cjs/dso-map-base-layers.cjs.entry.js +1 -1
  17. package/dist/cjs/dso-map-controls.cjs.entry.js +22 -19
  18. package/dist/cjs/dso-map-overlays.cjs.entry.js +1 -1
  19. package/dist/cjs/dso-ozon-content.cjs.entry.js +289 -419
  20. package/dist/cjs/dso-progress-bar.cjs.entry.js +1 -1
  21. package/dist/cjs/dso-progress-indicator.cjs.entry.js +1 -1
  22. package/dist/cjs/dso-toggletip.cjs.entry.js +1 -1
  23. package/dist/cjs/dso-toolkit.cjs.js +3 -3
  24. package/dist/cjs/dso-tooltip.cjs.entry.js +8 -4
  25. package/dist/cjs/dso-tree-view.cjs.entry.js +9 -9
  26. package/dist/cjs/dso-viewer-grid.cjs.entry.js +6 -712
  27. package/dist/cjs/focus-trap.esm-a85643b0.js +746 -0
  28. package/dist/cjs/{index-5ea63531.js → index-dfb4ea62.js} +73 -64
  29. package/dist/cjs/index.esm-3520a2a6.js +427 -0
  30. package/dist/cjs/loader.cjs.js +3 -3
  31. package/dist/collection/collection-manifest.json +3 -2
  32. package/dist/collection/components/alert/alert.template.js +1 -1
  33. package/dist/collection/components/anchor/anchor.template.js +1 -1
  34. package/dist/collection/components/autosuggest/autosuggest.css +1 -1
  35. package/dist/collection/components/autosuggest/autosuggest.js +6 -2
  36. package/dist/collection/components/badge/badge.template.js +1 -1
  37. package/dist/collection/components/button/button.template.js +1 -1
  38. package/dist/collection/components/date-picker/date-picker.css +6 -6
  39. package/dist/collection/components/date-picker/date-picker.template.js +1 -1
  40. package/dist/collection/components/definition-list/definition-list.template.js +2 -2
  41. package/dist/collection/components/dropdown-menu/dropdown-menu.template.js +1 -1
  42. package/dist/collection/components/header/header.css +1 -1
  43. package/dist/collection/components/header/header.js +38 -9
  44. package/dist/collection/components/header/header.template.js +4 -2
  45. package/dist/collection/components/helpcenter-panel/helpcenter-panel.template.js +2 -2
  46. package/dist/collection/components/highlight-box/highlight-box.template.js +5 -2
  47. package/dist/collection/components/icon/icon.template.js +1 -1
  48. package/dist/collection/components/image-overlay/image-overlay.css +263 -0
  49. package/dist/collection/components/image-overlay/image-overlay.js +72 -0
  50. package/dist/collection/components/image-overlay/image-overlay.template.js +7 -0
  51. package/dist/collection/components/label/label.template.js +2 -2
  52. package/dist/collection/components/list/list.template.js +1 -1
  53. package/dist/collection/components/map-controls/map-controls.js +17 -19
  54. package/dist/collection/components/ozon-content/get-node-name.function.js +9 -0
  55. package/dist/collection/components/ozon-content/nodes/al.node.js +14 -0
  56. package/dist/collection/components/ozon-content/nodes/document.node.js +9 -0
  57. package/dist/collection/components/ozon-content/nodes/ext-ref.node.js +15 -0
  58. package/dist/collection/components/ozon-content/nodes/fallback.node.js +11 -0
  59. package/dist/collection/components/ozon-content/nodes/illustratie.node.js +13 -0
  60. package/dist/collection/components/ozon-content/nodes/inhoud.node.js +14 -0
  61. package/dist/collection/components/ozon-content/nodes/inline.nodes.js +21 -0
  62. package/dist/collection/components/ozon-content/nodes/int-ref.node.js +26 -0
  63. package/dist/collection/components/ozon-content/nodes/noot.node.js +27 -0
  64. package/dist/collection/components/ozon-content/nodes/table.node/colspec/colspec-mapper.js +39 -0
  65. package/dist/collection/components/ozon-content/nodes/table.node/colspec/colspec.interface.js +2 -0
  66. package/dist/collection/components/ozon-content/nodes/table.node/index.js +1 -0
  67. package/dist/collection/components/ozon-content/nodes/table.node/table-cell.js +25 -0
  68. package/dist/collection/components/ozon-content/nodes/table.node/table-colgroup.js +4 -0
  69. package/dist/collection/components/ozon-content/nodes/table.node/table-rows.js +5 -0
  70. package/dist/collection/components/ozon-content/nodes/table.node/table.node.js +32 -0
  71. package/dist/collection/components/ozon-content/nodes/text.node.js +9 -0
  72. package/dist/collection/components/ozon-content/ozon-content-context.interface.js +1 -0
  73. package/dist/collection/components/ozon-content/ozon-content-mapper.js +80 -0
  74. package/dist/collection/components/ozon-content/ozon-content-node-context.interface.js +1 -0
  75. package/dist/collection/components/ozon-content/ozon-content-node-state.interface.js +1 -0
  76. package/dist/collection/components/ozon-content/ozon-content-node.interface.js +1 -0
  77. package/dist/collection/components/ozon-content/ozon-content.css +84 -23
  78. package/dist/collection/components/ozon-content/ozon-content.js +21 -33
  79. package/dist/collection/components/progress-bar/progress-bar.template.js +1 -1
  80. package/dist/collection/components/progress-indicator/progress-indicator.template.js +1 -1
  81. package/dist/collection/components/selectable/selectable.css +7 -1
  82. package/dist/collection/components/selectable/selectable.template.js +1 -1
  83. package/dist/collection/components/toggletip/toggletip.template.js +2 -2
  84. package/dist/collection/components/tooltip/tooltip.css +1 -1
  85. package/dist/collection/components/tooltip/tooltip.template.js +1 -1
  86. package/dist/collection/components/tree-view/tree-item.js +7 -7
  87. package/dist/collection/components/tree-view/tree-view.css +86 -15
  88. package/dist/collection/components/viewer-grid/viewer-grid.css +32 -4
  89. package/dist/custom-elements/index.d.ts +6 -0
  90. package/dist/custom-elements/index.js +1541 -1400
  91. package/dist/dso-toolkit/dso-toolkit.css +1 -1
  92. package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
  93. package/dist/dso-toolkit/p-016ed5a8.entry.js +1 -0
  94. package/dist/dso-toolkit/p-0216f283.entry.js +1 -0
  95. package/dist/dso-toolkit/{p-348414bf.entry.js → p-09bcacd0.entry.js} +1 -1
  96. package/dist/dso-toolkit/{p-2b6a3dfa.entry.js → p-117a31fe.entry.js} +1 -1
  97. package/dist/dso-toolkit/p-131d54e3.js +5 -0
  98. package/dist/dso-toolkit/{p-50b63cf4.entry.js → p-1eeadd3e.entry.js} +1 -1
  99. package/dist/dso-toolkit/{p-ad540748.entry.js → p-2279329b.entry.js} +1 -1
  100. package/dist/dso-toolkit/p-258e8371.entry.js +1 -0
  101. package/dist/dso-toolkit/{p-bc14cafd.entry.js → p-3ced438e.entry.js} +1 -1
  102. package/dist/dso-toolkit/{p-c54ecae1.entry.js → p-406b179d.entry.js} +1 -1
  103. package/dist/dso-toolkit/p-4b5f6b4c.entry.js +1 -0
  104. package/dist/dso-toolkit/{p-3b493a2c.entry.js → p-527a85b6.entry.js} +1 -1
  105. package/dist/dso-toolkit/{p-94dffa65.entry.js → p-52f159e7.entry.js} +1 -1
  106. package/dist/dso-toolkit/{p-dc86d830.entry.js → p-58f5e092.entry.js} +1 -1
  107. package/dist/dso-toolkit/p-5e5fbd41.js +5 -0
  108. package/dist/dso-toolkit/{p-f0b67246.entry.js → p-639228f6.entry.js} +1 -1
  109. package/dist/dso-toolkit/{p-951f5872.entry.js → p-6a8452bd.entry.js} +1 -1
  110. package/dist/dso-toolkit/{p-4e573fc5.entry.js → p-98ef5f8c.entry.js} +1 -1
  111. package/dist/dso-toolkit/{p-94b79e43.entry.js → p-a1c9bb35.entry.js} +1 -1
  112. package/dist/dso-toolkit/{p-3c4dbd89.entry.js → p-a5008a4e.entry.js} +1 -1
  113. package/dist/dso-toolkit/{p-c95108fe.entry.js → p-a59dcbb0.entry.js} +1 -1
  114. package/dist/dso-toolkit/p-b06c275a.entry.js +1 -0
  115. package/dist/dso-toolkit/p-b4222d6e.entry.js +1 -0
  116. package/dist/dso-toolkit/{p-dad72605.js → p-b9eb3491.js} +1 -1
  117. package/dist/dso-toolkit/p-bec38cf5.entry.js +1 -0
  118. package/dist/dso-toolkit/{p-ad2210ad.entry.js → p-d0d3ca99.entry.js} +1 -1
  119. package/dist/dso-toolkit/{p-5037944e.entry.js → p-d72edd80.entry.js} +1 -1
  120. package/dist/dso-toolkit/{p-1fefbf8c.entry.js → p-e1934ab6.entry.js} +1 -1
  121. package/dist/esm/dso-alert.entry.js +1 -1
  122. package/dist/esm/dso-attachments-counter.entry.js +1 -1
  123. package/dist/esm/dso-autosuggest.entry.js +7 -3
  124. package/dist/esm/dso-badge.entry.js +1 -1
  125. package/dist/esm/dso-banner.entry.js +1 -1
  126. package/dist/esm/dso-date-picker.entry.js +2 -2
  127. package/dist/esm/dso-dropdown-menu.entry.js +2 -2
  128. package/dist/esm/dso-header.entry.js +16 -7
  129. package/dist/esm/dso-helpcenter-panel.entry.js +1 -1
  130. package/dist/esm/dso-highlight-box.entry.js +1 -1
  131. package/dist/esm/dso-icon.entry.js +1 -1
  132. package/dist/esm/dso-image-overlay.entry.js +58 -0
  133. package/dist/esm/dso-info-button.entry.js +1 -1
  134. package/dist/esm/dso-info_2.entry.js +2 -2
  135. package/dist/esm/dso-label.entry.js +1 -1
  136. package/dist/esm/dso-map-base-layers.entry.js +1 -1
  137. package/dist/esm/dso-map-controls.entry.js +22 -19
  138. package/dist/esm/dso-map-overlays.entry.js +1 -1
  139. package/dist/esm/dso-ozon-content.entry.js +289 -419
  140. package/dist/esm/dso-progress-bar.entry.js +1 -1
  141. package/dist/esm/dso-progress-indicator.entry.js +1 -1
  142. package/dist/esm/dso-toggletip.entry.js +1 -1
  143. package/dist/esm/dso-toolkit.js +3 -3
  144. package/dist/esm/dso-tooltip.entry.js +8 -4
  145. package/dist/esm/dso-tree-view.entry.js +9 -9
  146. package/dist/esm/dso-viewer-grid.entry.js +4 -710
  147. package/dist/esm/focus-trap.esm-a01ad6c9.js +744 -0
  148. package/dist/esm/{index-d54cae76.js → index-9ec8c07f.js} +73 -64
  149. package/dist/esm/index.esm-45465af7.js +422 -0
  150. package/dist/esm/loader.js +3 -3
  151. package/dist/types/components/autosuggest/autosuggest.d.ts +15 -1
  152. package/dist/types/components/header/header.d.ts +7 -1
  153. package/dist/types/components/header/header.template.d.ts +1 -1
  154. package/dist/types/components/image-overlay/image-overlay.d.ts +15 -0
  155. package/dist/types/components/image-overlay/image-overlay.template.d.ts +2 -0
  156. package/dist/types/components/ozon-content/get-node-name.function.d.ts +1 -0
  157. package/dist/types/components/ozon-content/nodes/al.node.d.ts +6 -0
  158. package/dist/types/components/ozon-content/nodes/document.node.d.ts +6 -0
  159. package/dist/types/components/ozon-content/nodes/ext-ref.node.d.ts +6 -0
  160. package/dist/types/components/ozon-content/nodes/fallback.node.d.ts +6 -0
  161. package/dist/types/components/ozon-content/nodes/illustratie.node.d.ts +5 -0
  162. package/dist/types/components/ozon-content/nodes/inhoud.node.d.ts +6 -0
  163. package/dist/types/components/ozon-content/nodes/inline.nodes.d.ts +6 -0
  164. package/dist/types/components/ozon-content/nodes/int-ref.node.d.ts +6 -0
  165. package/dist/types/components/ozon-content/nodes/noot.node.d.ts +8 -0
  166. package/dist/types/components/ozon-content/nodes/table.node/colspec/colspec-mapper.d.ts +2 -0
  167. package/dist/types/components/ozon-content/nodes/table.node/colspec/colspec.interface.d.ts +10 -0
  168. package/dist/types/components/ozon-content/nodes/table.node/index.d.ts +1 -0
  169. package/dist/types/components/ozon-content/nodes/table.node/table-cell.d.ts +8 -0
  170. package/dist/types/components/ozon-content/nodes/table.node/table-colgroup.d.ts +5 -0
  171. package/dist/types/components/ozon-content/nodes/table.node/table-rows.d.ts +8 -0
  172. package/dist/types/components/ozon-content/nodes/table.node/table.node.d.ts +7 -0
  173. package/dist/types/components/ozon-content/nodes/text.node.d.ts +5 -0
  174. package/dist/types/components/ozon-content/ozon-content-context.interface.d.ts +8 -0
  175. package/dist/types/components/ozon-content/ozon-content-mapper.d.ts +11 -0
  176. package/dist/types/components/ozon-content/ozon-content-node-context.interface.d.ts +7 -0
  177. package/dist/types/components/ozon-content/ozon-content-node-state.interface.d.ts +3 -0
  178. package/dist/types/components/ozon-content/ozon-content-node.interface.d.ts +7 -0
  179. package/dist/types/components/ozon-content/ozon-content.d.ts +7 -10
  180. package/dist/types/components/ozon-content/ozon-content.interfaces.d.ts +2 -2
  181. package/dist/types/components.d.ts +22 -8
  182. package/dist/types/icon/dso-icon-sass-function.d.ts +1 -1
  183. package/package.json +31 -27
  184. package/dist/cjs/index.esm-2ac7081c.js +0 -267
  185. package/dist/collection/components/ozon-content/ozon-content.transformer.js +0 -105
  186. package/dist/dso-toolkit/p-20856f91.entry.js +0 -1
  187. package/dist/dso-toolkit/p-88bc5873.entry.js +0 -1
  188. package/dist/dso-toolkit/p-8b6e3abc.entry.js +0 -1
  189. package/dist/dso-toolkit/p-8bf3a60e.js +0 -5
  190. package/dist/dso-toolkit/p-a7306b7b.entry.js +0 -1
  191. package/dist/dso-toolkit/p-daa1e29d.entry.js +0 -1
  192. package/dist/dso-toolkit/p-de3ab027.entry.js +0 -5
  193. package/dist/esm/index.esm-a1362957.js +0 -262
  194. package/dist/types/components/ozon-content/ozon-content.transformer.d.ts +0 -15
@@ -0,0 +1,746 @@
1
+ 'use strict';
2
+
3
+ const index_esm = require('./index.esm-3520a2a6.js');
4
+
5
+ /*!
6
+ * focus-trap 6.8.1
7
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
8
+ */
9
+
10
+ function ownKeys(object, enumerableOnly) {
11
+ var keys = Object.keys(object);
12
+
13
+ if (Object.getOwnPropertySymbols) {
14
+ var symbols = Object.getOwnPropertySymbols(object);
15
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
16
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
17
+ })), keys.push.apply(keys, symbols);
18
+ }
19
+
20
+ return keys;
21
+ }
22
+
23
+ function _objectSpread2(target) {
24
+ for (var i = 1; i < arguments.length; i++) {
25
+ var source = null != arguments[i] ? arguments[i] : {};
26
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
27
+ _defineProperty(target, key, source[key]);
28
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
29
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
30
+ });
31
+ }
32
+
33
+ return target;
34
+ }
35
+
36
+ function _defineProperty(obj, key, value) {
37
+ if (key in obj) {
38
+ Object.defineProperty(obj, key, {
39
+ value: value,
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true
43
+ });
44
+ } else {
45
+ obj[key] = value;
46
+ }
47
+
48
+ return obj;
49
+ }
50
+
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();
82
+ }
83
+ }
84
+ };
85
+ }();
86
+
87
+ var isSelectableInput = function isSelectableInput(node) {
88
+ return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
89
+ };
90
+
91
+ var isEscapeEvent = function isEscapeEvent(e) {
92
+ return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
93
+ };
94
+
95
+ var isTabEvent = function isTabEvent(e) {
96
+ return e.key === 'Tab' || e.keyCode === 9;
97
+ };
98
+
99
+ var delay = function delay(fn) {
100
+ return setTimeout(fn, 0);
101
+ }; // Array.find/findIndex() are not supported on IE; this replicates enough
102
+ // of Array.findIndex() for our needs
103
+
104
+
105
+ var findIndex = function findIndex(arr, fn) {
106
+ var idx = -1;
107
+ arr.every(function (value, i) {
108
+ if (fn(value)) {
109
+ idx = i;
110
+ return false; // break
111
+ }
112
+
113
+ return true; // next
114
+ });
115
+ return idx;
116
+ };
117
+ /**
118
+ * Get an option's value when it could be a plain value, or a handler that provides
119
+ * the value.
120
+ * @param {*} value Option's value to check.
121
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
122
+ * @returns {*} The `value`, or the handler's returned value.
123
+ */
124
+
125
+
126
+ var valueOrHandler = function valueOrHandler(value) {
127
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
128
+ params[_key - 1] = arguments[_key];
129
+ }
130
+
131
+ return typeof value === 'function' ? value.apply(void 0, params) : value;
132
+ };
133
+
134
+ var getActualTarget = function getActualTarget(event) {
135
+ // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
136
+ // shadow host. However, event.target.composedPath() will be an array of
137
+ // nodes "clicked" from inner-most (the actual element inside the shadow) to
138
+ // outer-most (the host HTML document). If we have access to composedPath(),
139
+ // then use its first element; otherwise, fall back to event.target (and
140
+ // this only works for an _open_ shadow DOM; otherwise,
141
+ // composedPath()[0] === event.target always).
142
+ return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
143
+ };
144
+
145
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
146
+ // SSR: a live trap shouldn't be created in this type of environment so this
147
+ // should be safe code to execute if the `document` option isn't specified
148
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
149
+
150
+ var config = _objectSpread2({
151
+ returnFocusOnDeactivate: true,
152
+ escapeDeactivates: true,
153
+ delayInitialFocus: true
154
+ }, userOptions);
155
+
156
+ var state = {
157
+ // containers given to createFocusTrap()
158
+ // @type {Array<HTMLElement>}
159
+ containers: [],
160
+ // list of objects identifying tabbable nodes in `containers` in the trap
161
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
162
+ // is active, but the trap should never get to a state where there isn't at least one group
163
+ // with at least one tabbable node in it (that would lead to an error condition that would
164
+ // result in an error being thrown)
165
+ // @type {Array<{
166
+ // container: HTMLElement,
167
+ // tabbableNodes: Array<HTMLElement>, // empty if none
168
+ // focusableNodes: Array<HTMLElement>, // empty if none
169
+ // firstTabbableNode: HTMLElement|null,
170
+ // lastTabbableNode: HTMLElement|null,
171
+ // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
172
+ // }>}
173
+ containerGroups: [],
174
+ // same order/length as `containers` list
175
+ // references to objects in `containerGroups`, but only those that actually have
176
+ // tabbable nodes in them
177
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
178
+ // the same length
179
+ tabbableGroups: [],
180
+ nodeFocusedBeforeActivation: null,
181
+ mostRecentlyFocusedNode: null,
182
+ active: false,
183
+ paused: false,
184
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
185
+ // has been delayed during activation
186
+ delayInitialFocusTimer: undefined
187
+ };
188
+ var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
189
+
190
+ /**
191
+ * Gets a configuration option value.
192
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
193
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
194
+ * @param {string} optionName Name of the option whose value is sought.
195
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
196
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
197
+ */
198
+
199
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
200
+ return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
201
+ };
202
+ /**
203
+ * Finds the index of the container that contains the element.
204
+ * @param {HTMLElement} element
205
+ * @returns {number} Index of the container in either `state.containers` or
206
+ * `state.containerGroups` (the order/length of these lists are the same); -1
207
+ * if the element isn't found.
208
+ */
209
+
210
+
211
+ var findContainerIndex = function findContainerIndex(element) {
212
+ // NOTE: search `containerGroups` because it's possible a group contains no tabbable
213
+ // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
214
+ // and we still need to find the element in there
215
+ return state.containerGroups.findIndex(function (_ref) {
216
+ 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
219
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
220
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
221
+ // look inside web components even if open)
222
+ tabbableNodes.find(function (node) {
223
+ return node === element;
224
+ });
225
+ });
226
+ };
227
+ /**
228
+ * Gets the node for the given option, which is expected to be an option that
229
+ * can be either a DOM node, a string that is a selector to get a node, `false`
230
+ * (if a node is explicitly NOT given), or a function that returns any of these
231
+ * values.
232
+ * @param {string} optionName
233
+ * @returns {undefined | false | HTMLElement | SVGElement} Returns
234
+ * `undefined` if the option is not specified; `false` if the option
235
+ * resolved to `false` (node explicitly not given); otherwise, the resolved
236
+ * DOM node.
237
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
238
+ * resolve to a node.
239
+ */
240
+
241
+
242
+ var getNodeForOption = function getNodeForOption(optionName) {
243
+ var optionValue = config[optionName];
244
+
245
+ if (typeof optionValue === 'function') {
246
+ for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
247
+ params[_key2 - 1] = arguments[_key2];
248
+ }
249
+
250
+ optionValue = optionValue.apply(void 0, params);
251
+ }
252
+
253
+ if (!optionValue) {
254
+ if (optionValue === undefined || optionValue === false) {
255
+ return optionValue;
256
+ } // else, empty string (invalid), null (invalid), 0 (invalid)
257
+
258
+
259
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
260
+ }
261
+
262
+ var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
263
+
264
+ if (typeof optionValue === 'string') {
265
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
266
+
267
+ if (!node) {
268
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
269
+ }
270
+ }
271
+
272
+ return node;
273
+ };
274
+
275
+ var getInitialFocusNode = function getInitialFocusNode() {
276
+ var node = getNodeForOption('initialFocus'); // false explicitly indicates we want no initialFocus at all
277
+
278
+ if (node === false) {
279
+ return false;
280
+ }
281
+
282
+ if (node === undefined) {
283
+ // option not specified: use fallback options
284
+ if (findContainerIndex(doc.activeElement) >= 0) {
285
+ node = doc.activeElement;
286
+ } else {
287
+ var firstTabbableGroup = state.tabbableGroups[0];
288
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
289
+
290
+ node = firstTabbableNode || getNodeForOption('fallbackFocus');
291
+ }
292
+ }
293
+
294
+ if (!node) {
295
+ throw new Error('Your focus-trap needs to have at least one focusable element');
296
+ }
297
+
298
+ return node;
299
+ };
300
+
301
+ var updateTabbableNodes = function updateTabbableNodes() {
302
+ state.containerGroups = state.containers.map(function (container) {
303
+ var tabbableNodes = index_esm.tabbable(container, config.tabbableOptions); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
304
+ // are a superset of tabbable nodes
305
+
306
+ var focusableNodes = index_esm.focusable(container, config.tabbableOptions);
307
+ return {
308
+ container: container,
309
+ tabbableNodes: tabbableNodes,
310
+ focusableNodes: focusableNodes,
311
+ firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
312
+ lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
313
+
314
+ /**
315
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
316
+ * in this container, if any.
317
+ * @param {HTMLElement} node
318
+ * @param {boolean} [forward] True if going in forward tab order; false if going
319
+ * in reverse.
320
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
321
+ */
322
+ nextTabbableNode: function nextTabbableNode(node) {
323
+ var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
324
+ // NOTE: If tabindex is positive (in order to manipulate the tab order separate
325
+ // from the DOM order), this __will not work__ because the list of focusableNodes,
326
+ // while it contains tabbable nodes, does not sort its nodes in any order other
327
+ // than DOM order, because it can't: Where would you place focusable (but not
328
+ // tabbable) nodes in that order? They have no order, because they aren't tabbale...
329
+ // Support for positive tabindex is already broken and hard to manage (possibly
330
+ // not supportable, TBD), so this isn't going to make things worse than they
331
+ // already are, and at least makes things better for the majority of cases where
332
+ // tabindex is either 0/unset or negative.
333
+ // FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
334
+ var nodeIdx = focusableNodes.findIndex(function (n) {
335
+ return n === node;
336
+ });
337
+
338
+ if (nodeIdx < 0) {
339
+ return undefined;
340
+ }
341
+
342
+ if (forward) {
343
+ return focusableNodes.slice(nodeIdx + 1).find(function (n) {
344
+ return index_esm.isTabbable(n, config.tabbableOptions);
345
+ });
346
+ }
347
+
348
+ return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
349
+ return index_esm.isTabbable(n, config.tabbableOptions);
350
+ });
351
+ }
352
+ };
353
+ });
354
+ state.tabbableGroups = state.containerGroups.filter(function (group) {
355
+ return group.tabbableNodes.length > 0;
356
+ }); // throw if no groups have tabbable nodes and we don't have a fallback focus node either
357
+
358
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
359
+ ) {
360
+ throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
361
+ }
362
+ };
363
+
364
+ var tryFocus = function tryFocus(node) {
365
+ if (node === false) {
366
+ return;
367
+ }
368
+
369
+ if (node === doc.activeElement) {
370
+ return;
371
+ }
372
+
373
+ if (!node || !node.focus) {
374
+ tryFocus(getInitialFocusNode());
375
+ return;
376
+ }
377
+
378
+ node.focus({
379
+ preventScroll: !!config.preventScroll
380
+ });
381
+ state.mostRecentlyFocusedNode = node;
382
+
383
+ if (isSelectableInput(node)) {
384
+ node.select();
385
+ }
386
+ };
387
+
388
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
389
+ var node = getNodeForOption('setReturnFocus', previousActiveElement);
390
+ return node ? node : node === false ? false : previousActiveElement;
391
+ }; // This needs to be done on mousedown and touchstart instead of click
392
+ // so that it precedes the focus event.
393
+
394
+
395
+ var checkPointerDown = function checkPointerDown(e) {
396
+ var target = getActualTarget(e);
397
+
398
+ if (findContainerIndex(target) >= 0) {
399
+ // allow the click since it ocurred inside the trap
400
+ return;
401
+ }
402
+
403
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
404
+ // immediately deactivate the trap
405
+ trap.deactivate({
406
+ // if, on deactivation, we should return focus to the node originally-focused
407
+ // when the trap was activated (or the configured `setReturnFocus` node),
408
+ // then assume it's also OK to return focus to the outside node that was
409
+ // just clicked, causing deactivation, as long as that node is focusable;
410
+ // if it isn't focusable, then return focus to the original node focused
411
+ // on activation (or the configured `setReturnFocus` node)
412
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
413
+ // which will result in the outside click setting focus to the node
414
+ // that was clicked, whether it's focusable or not; by setting
415
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
416
+ // on activation (or the configured `setReturnFocus` node)
417
+ returnFocus: config.returnFocusOnDeactivate && !index_esm.isFocusable(target, config.tabbableOptions)
418
+ });
419
+ return;
420
+ } // This is needed for mobile devices.
421
+ // (If we'll only let `click` events through,
422
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
423
+
424
+
425
+ if (valueOrHandler(config.allowOutsideClick, e)) {
426
+ // allow the click outside the trap to take place
427
+ return;
428
+ } // otherwise, prevent the click
429
+
430
+
431
+ e.preventDefault();
432
+ }; // In case focus escapes the trap for some strange reason, pull it back in.
433
+
434
+
435
+ var checkFocusIn = function checkFocusIn(e) {
436
+ var target = getActualTarget(e);
437
+ var targetContained = findContainerIndex(target) >= 0; // In Firefox when you Tab out of an iframe the Document is briefly focused.
438
+
439
+ if (targetContained || target instanceof Document) {
440
+ if (targetContained) {
441
+ state.mostRecentlyFocusedNode = target;
442
+ }
443
+ } else {
444
+ // escaped! pull it back in to where it just left
445
+ e.stopImmediatePropagation();
446
+ tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
447
+ }
448
+ }; // Hijack Tab events on the first and last focusable nodes of the trap,
449
+ // in order to prevent focus from escaping. If it escapes for even a
450
+ // moment it can end up scrolling the page and causing confusion so we
451
+ // kind of need to capture the action at the keydown phase.
452
+
453
+
454
+ var checkTab = function checkTab(e) {
455
+ var target = getActualTarget(e);
456
+ updateTabbableNodes();
457
+ var destinationNode = null;
458
+
459
+ if (state.tabbableGroups.length > 0) {
460
+ // make sure the target is actually contained in a group
461
+ // NOTE: the target may also be the container itself if it's focusable
462
+ // with tabIndex='-1' and was given initial focus
463
+ var containerIndex = findContainerIndex(target);
464
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
465
+
466
+ if (containerIndex < 0) {
467
+ // target not found in any group: quite possible focus has escaped the trap,
468
+ // so bring it back in to...
469
+ if (e.shiftKey) {
470
+ // ...the last node in the last group
471
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
472
+ } else {
473
+ // ...the first node in the first group
474
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
475
+ }
476
+ } else if (e.shiftKey) {
477
+ // REVERSE
478
+ // is the target the first tabbable node in a group?
479
+ var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
480
+ var firstTabbableNode = _ref2.firstTabbableNode;
481
+ return target === firstTabbableNode;
482
+ });
483
+
484
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || index_esm.isFocusable(target, config.tabbableOptions) && !index_esm.isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
485
+ // an exception case where the target is either the container itself, or
486
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
487
+ // and user clicked on it or node was programmatically given focus)
488
+ // and is not followed by any other tabbable node, in which
489
+ // case, we should handle shift+tab as if focus were on the container's
490
+ // first tabbable node, and go to the last tabbable node of the LAST group
491
+ startOfGroupIndex = containerIndex;
492
+ }
493
+
494
+ if (startOfGroupIndex >= 0) {
495
+ // YES: then shift+tab should go to the last tabbable node in the
496
+ // previous group (and wrap around to the last tabbable node of
497
+ // the LAST group if it's the first tabbable node of the FIRST group)
498
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
499
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
500
+ destinationNode = destinationGroup.lastTabbableNode;
501
+ }
502
+ } else {
503
+ // FORWARD
504
+ // is the target the last tabbable node in a group?
505
+ var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
506
+ var lastTabbableNode = _ref3.lastTabbableNode;
507
+ return target === lastTabbableNode;
508
+ });
509
+
510
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || index_esm.isFocusable(target, config.tabbableOptions) && !index_esm.isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
511
+ // an exception case where the target is the container itself, or
512
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
513
+ // and user clicked on it or node was programmatically given focus)
514
+ // and is not followed by any other tabbable node, in which
515
+ // case, we should handle tab as if focus were on the container's
516
+ // last tabbable node, and go to the first tabbable node of the FIRST group
517
+ lastOfGroupIndex = containerIndex;
518
+ }
519
+
520
+ if (lastOfGroupIndex >= 0) {
521
+ // YES: then tab should go to the first tabbable node in the next
522
+ // group (and wrap around to the first tabbable node of the FIRST
523
+ // group if it's the last tabbable node of the LAST group)
524
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
525
+
526
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
527
+ destinationNode = _destinationGroup.firstTabbableNode;
528
+ }
529
+ }
530
+ } else {
531
+ // NOTE: the fallbackFocus option does not support returning false to opt-out
532
+ destinationNode = getNodeForOption('fallbackFocus');
533
+ }
534
+
535
+ if (destinationNode) {
536
+ e.preventDefault();
537
+ tryFocus(destinationNode);
538
+ } // else, let the browser take care of [shift+]tab and move the focus
539
+
540
+ };
541
+
542
+ var checkKey = function checkKey(e) {
543
+ if (isEscapeEvent(e) && valueOrHandler(config.escapeDeactivates, e) !== false) {
544
+ e.preventDefault();
545
+ trap.deactivate();
546
+ return;
547
+ }
548
+
549
+ if (isTabEvent(e)) {
550
+ checkTab(e);
551
+ return;
552
+ }
553
+ };
554
+
555
+ var checkClick = function checkClick(e) {
556
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
557
+ return;
558
+ }
559
+
560
+ var target = getActualTarget(e);
561
+
562
+ if (findContainerIndex(target) >= 0) {
563
+ return;
564
+ }
565
+
566
+ if (valueOrHandler(config.allowOutsideClick, e)) {
567
+ return;
568
+ }
569
+
570
+ e.preventDefault();
571
+ e.stopImmediatePropagation();
572
+ }; //
573
+ // EVENT LISTENERS
574
+ //
575
+
576
+
577
+ var addListeners = function addListeners() {
578
+ if (!state.active) {
579
+ return;
580
+ } // There can be only one listening focus trap at a time
581
+
582
+
583
+ activeFocusTraps.activateTrap(trap); // Delay ensures that the focused element doesn't capture the event
584
+ // that caused the focus trap activation.
585
+
586
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
587
+ tryFocus(getInitialFocusNode());
588
+ }) : tryFocus(getInitialFocusNode());
589
+ doc.addEventListener('focusin', checkFocusIn, true);
590
+ doc.addEventListener('mousedown', checkPointerDown, {
591
+ capture: true,
592
+ passive: false
593
+ });
594
+ doc.addEventListener('touchstart', checkPointerDown, {
595
+ capture: true,
596
+ passive: false
597
+ });
598
+ doc.addEventListener('click', checkClick, {
599
+ capture: true,
600
+ passive: false
601
+ });
602
+ doc.addEventListener('keydown', checkKey, {
603
+ capture: true,
604
+ passive: false
605
+ });
606
+ return trap;
607
+ };
608
+
609
+ var removeListeners = function removeListeners() {
610
+ if (!state.active) {
611
+ return;
612
+ }
613
+
614
+ doc.removeEventListener('focusin', checkFocusIn, true);
615
+ doc.removeEventListener('mousedown', checkPointerDown, true);
616
+ doc.removeEventListener('touchstart', checkPointerDown, true);
617
+ doc.removeEventListener('click', checkClick, true);
618
+ doc.removeEventListener('keydown', checkKey, true);
619
+ return trap;
620
+ }; //
621
+ // TRAP DEFINITION
622
+ //
623
+
624
+
625
+ trap = {
626
+ activate: function activate(activateOptions) {
627
+ if (state.active) {
628
+ return this;
629
+ }
630
+
631
+ var onActivate = getOption(activateOptions, 'onActivate');
632
+ var onPostActivate = getOption(activateOptions, 'onPostActivate');
633
+ var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
634
+
635
+ if (!checkCanFocusTrap) {
636
+ updateTabbableNodes();
637
+ }
638
+
639
+ state.active = true;
640
+ state.paused = false;
641
+ state.nodeFocusedBeforeActivation = doc.activeElement;
642
+
643
+ if (onActivate) {
644
+ onActivate();
645
+ }
646
+
647
+ var finishActivation = function finishActivation() {
648
+ if (checkCanFocusTrap) {
649
+ updateTabbableNodes();
650
+ }
651
+
652
+ addListeners();
653
+
654
+ if (onPostActivate) {
655
+ onPostActivate();
656
+ }
657
+ };
658
+
659
+ if (checkCanFocusTrap) {
660
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
661
+ return this;
662
+ }
663
+
664
+ finishActivation();
665
+ return this;
666
+ },
667
+ deactivate: function deactivate(deactivateOptions) {
668
+ if (!state.active) {
669
+ return this;
670
+ }
671
+
672
+ clearTimeout(state.delayInitialFocusTimer); // noop if undefined
673
+
674
+ state.delayInitialFocusTimer = undefined;
675
+ removeListeners();
676
+ state.active = false;
677
+ state.paused = false;
678
+ activeFocusTraps.deactivateTrap(trap);
679
+ var onDeactivate = getOption(deactivateOptions, 'onDeactivate');
680
+ var onPostDeactivate = getOption(deactivateOptions, 'onPostDeactivate');
681
+ var checkCanReturnFocus = getOption(deactivateOptions, 'checkCanReturnFocus');
682
+
683
+ if (onDeactivate) {
684
+ onDeactivate();
685
+ }
686
+
687
+ var returnFocus = getOption(deactivateOptions, 'returnFocus', 'returnFocusOnDeactivate');
688
+
689
+ var finishDeactivation = function finishDeactivation() {
690
+ delay(function () {
691
+ if (returnFocus) {
692
+ tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
693
+ }
694
+
695
+ if (onPostDeactivate) {
696
+ onPostDeactivate();
697
+ }
698
+ });
699
+ };
700
+
701
+ if (returnFocus && checkCanReturnFocus) {
702
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
703
+ return this;
704
+ }
705
+
706
+ finishDeactivation();
707
+ return this;
708
+ },
709
+ pause: function pause() {
710
+ if (state.paused || !state.active) {
711
+ return this;
712
+ }
713
+
714
+ state.paused = true;
715
+ removeListeners();
716
+ return this;
717
+ },
718
+ unpause: function unpause() {
719
+ if (!state.paused || !state.active) {
720
+ return this;
721
+ }
722
+
723
+ state.paused = false;
724
+ updateTabbableNodes();
725
+ addListeners();
726
+ return this;
727
+ },
728
+ updateContainerElements: function updateContainerElements(containerElements) {
729
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
730
+ state.containers = elementsAsArray.map(function (element) {
731
+ return typeof element === 'string' ? doc.querySelector(element) : element;
732
+ });
733
+
734
+ if (state.active) {
735
+ updateTabbableNodes();
736
+ }
737
+
738
+ return this;
739
+ }
740
+ }; // initialize container elements
741
+
742
+ trap.updateContainerElements(elements);
743
+ return trap;
744
+ };
745
+
746
+ exports.createFocusTrap = createFocusTrap;