@getflip/swirl-components 0.116.0 → 0.117.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 (107) hide show
  1. package/components.json +371 -69
  2. package/dist/cjs/focus-trap.esm-21561e09.js +1145 -0
  3. package/dist/cjs/index-506fe4ea.js +14 -26
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/swirl-app-bar.cjs.entry.js +2 -1
  6. package/dist/cjs/swirl-app-icon.cjs.entry.js +1 -3
  7. package/dist/cjs/swirl-app-layout_6.cjs.entry.js +1 -1
  8. package/dist/cjs/swirl-badge.cjs.entry.js +1 -1
  9. package/dist/cjs/swirl-components.cjs.js +1 -1
  10. package/dist/cjs/swirl-icon-arrow-back_5.cjs.entry.js +87 -0
  11. package/dist/cjs/swirl-icon-dock-left.cjs.entry.js +23 -0
  12. package/dist/cjs/swirl-modal.cjs.entry.js +2 -1143
  13. package/dist/cjs/swirl-shell-layout.cjs.entry.js +87 -75
  14. package/dist/cjs/swirl-shell-navigation-item.cjs.entry.js +1 -1
  15. package/dist/cjs/swirl-visually-hidden.cjs.entry.js +1 -1
  16. package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
  17. package/dist/collection/collection-manifest.json +1 -0
  18. package/dist/collection/components/swirl-app-bar/swirl-app-bar.js +20 -1
  19. package/dist/collection/components/swirl-app-icon/swirl-app-icon.css +3 -22
  20. package/dist/collection/components/swirl-app-icon/swirl-app-icon.js +0 -20
  21. package/dist/collection/components/swirl-app-layout/swirl-app-layout.css +38 -4
  22. package/dist/collection/components/swirl-badge/swirl-badge.css +18 -1
  23. package/dist/collection/components/swirl-badge/swirl-badge.js +1 -1
  24. package/dist/collection/components/swirl-icon/icons/swirl-icon-dock-left.js +52 -0
  25. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.css +353 -132
  26. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.js +322 -95
  27. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.spec.js +8 -58
  28. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.stories.js +81 -102
  29. package/dist/collection/components/swirl-shell-navigation-item/swirl-shell-navigation-item.css +46 -35
  30. package/dist/collection/components/swirl-visually-hidden/swirl-visually-hidden.js +1 -1
  31. package/dist/collection/components/swirl-visually-hidden/swirl-visually-hidden.spec.js +0 -3
  32. package/dist/components/assets/images/flip-logo.png +0 -0
  33. package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
  34. package/dist/components/focus-trap.esm.js +1143 -0
  35. package/dist/components/swirl-app-bar.js +3 -1
  36. package/dist/components/swirl-app-icon.js +1 -4
  37. package/dist/components/swirl-app-layout2.js +1 -1
  38. package/dist/components/swirl-badge2.js +1 -1
  39. package/dist/components/swirl-icon-arrow-back.js +1 -35
  40. package/dist/{esm/swirl-icon-arrow-back.entry.js → components/swirl-icon-arrow-back2.js} +26 -8
  41. package/dist/components/swirl-icon-arrow-forward.js +1 -35
  42. package/dist/{esm/swirl-icon-arrow-forward.entry.js → components/swirl-icon-arrow-forward2.js} +26 -8
  43. package/dist/components/swirl-icon-dock-left.d.ts +11 -0
  44. package/dist/components/swirl-icon-dock-left.js +40 -0
  45. package/dist/components/swirl-icon-double-arrow-left.js +1 -35
  46. package/dist/{esm/swirl-icon-double-arrow-left.entry.js → components/swirl-icon-double-arrow-left2.js} +26 -8
  47. package/dist/components/swirl-icon-double-arrow-right.js +1 -35
  48. package/dist/{esm/swirl-icon-double-arrow-right.entry.js → components/swirl-icon-double-arrow-right2.js} +26 -8
  49. package/dist/components/swirl-icon-menu.js +1 -35
  50. package/dist/{esm/swirl-icon-menu.entry.js → components/swirl-icon-menu2.js} +26 -8
  51. package/dist/components/swirl-modal.js +1 -1142
  52. package/dist/components/swirl-shell-layout.js +150 -89
  53. package/dist/components/swirl-shell-navigation-item.js +1 -1
  54. package/dist/components/swirl-visually-hidden2.js +2 -3
  55. package/dist/esm/focus-trap.esm-37cd2d2b.js +1143 -0
  56. package/dist/esm/index-99d0060d.js +14 -26
  57. package/dist/esm/loader.js +1 -1
  58. package/dist/esm/swirl-app-bar.entry.js +2 -1
  59. package/dist/esm/swirl-app-icon.entry.js +1 -3
  60. package/dist/esm/swirl-app-layout_6.entry.js +1 -1
  61. package/dist/esm/swirl-badge.entry.js +1 -1
  62. package/dist/esm/swirl-components.js +1 -1
  63. package/dist/esm/swirl-icon-arrow-back_5.entry.js +79 -0
  64. package/dist/esm/swirl-icon-dock-left.entry.js +19 -0
  65. package/dist/esm/swirl-modal.entry.js +1 -1142
  66. package/dist/esm/swirl-shell-layout.entry.js +88 -76
  67. package/dist/esm/swirl-shell-navigation-item.entry.js +1 -1
  68. package/dist/esm/swirl-visually-hidden.entry.js +1 -1
  69. package/dist/swirl-components/p-08fd60a5.entry.js +1 -0
  70. package/dist/swirl-components/p-0ac2eb84.entry.js +1 -0
  71. package/dist/swirl-components/p-11c6c9ba.entry.js +1 -0
  72. package/dist/swirl-components/p-25b4973d.entry.js +1 -0
  73. package/dist/swirl-components/p-262771e5.entry.js +1 -0
  74. package/dist/swirl-components/p-3795fbb4.entry.js +1 -0
  75. package/dist/swirl-components/p-40ee5f22.entry.js +1 -0
  76. package/dist/swirl-components/p-4a69e7f3.entry.js +1 -0
  77. package/dist/swirl-components/p-76c36ee9.entry.js +1 -0
  78. package/dist/swirl-components/p-7c4a4b66.entry.js +1 -0
  79. package/dist/swirl-components/p-c2e1dfdb.js +10 -0
  80. package/dist/swirl-components/swirl-components.esm.js +1 -1
  81. package/dist/types/components/swirl-app-bar/swirl-app-bar.d.ts +1 -0
  82. package/dist/types/components/swirl-app-icon/swirl-app-icon.d.ts +0 -1
  83. package/dist/types/components/swirl-badge/swirl-badge.d.ts +1 -1
  84. package/dist/types/components/swirl-icon/icons/swirl-icon-dock-left.d.ts +5 -0
  85. package/dist/types/components/swirl-shell-layout/swirl-shell-layout.d.ts +42 -25
  86. package/dist/types/components.d.ts +50 -11
  87. package/icons.json +1 -1
  88. package/package.json +2 -2
  89. package/vscode-data.json +58 -6
  90. package/dist/cjs/swirl-icon-arrow-back.cjs.entry.js +0 -23
  91. package/dist/cjs/swirl-icon-arrow-forward.cjs.entry.js +0 -23
  92. package/dist/cjs/swirl-icon-double-arrow-left.cjs.entry.js +0 -23
  93. package/dist/cjs/swirl-icon-double-arrow-right.cjs.entry.js +0 -23
  94. package/dist/cjs/swirl-icon-menu.cjs.entry.js +0 -23
  95. package/dist/swirl-components/p-3a2abee9.entry.js +0 -1
  96. package/dist/swirl-components/p-441c8210.entry.js +0 -1
  97. package/dist/swirl-components/p-4a84e63d.entry.js +0 -1
  98. package/dist/swirl-components/p-54e4ff0b.entry.js +0 -1
  99. package/dist/swirl-components/p-5da3a9a8.entry.js +0 -1
  100. package/dist/swirl-components/p-645a878c.entry.js +0 -1
  101. package/dist/swirl-components/p-79be22ea.entry.js +0 -10
  102. package/dist/swirl-components/p-97668c59.entry.js +0 -1
  103. package/dist/swirl-components/p-be2cf7ee.entry.js +0 -1
  104. package/dist/swirl-components/p-c4d4a99d.entry.js +0 -1
  105. package/dist/swirl-components/p-ca78767e.entry.js +0 -1
  106. package/dist/swirl-components/p-d2fc7935.entry.js +0 -1
  107. package/dist/swirl-components/p-f83a0b0f.entry.js +0 -1
@@ -1,1149 +1,8 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-99d0060d.js';
2
2
  import { d as disableBodyScroll, e as enableBodyScroll } from './bodyScrollLock.esm-ce6356d8.js';
3
+ import { c as createFocusTrap } from './focus-trap.esm-37cd2d2b.js';
3
4
  import { c as classnames } from './index-d280dafb.js';
4
5
 
5
- /*!
6
- * tabbable 6.0.1
7
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
8
- */
9
- var candidateSelectors = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]:not(slot)', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])', 'details>summary:first-of-type', 'details'];
10
- var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
11
- var NoElement = typeof Element === 'undefined';
12
- var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
13
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
14
- return element.getRootNode();
15
- } : function (element) {
16
- return element.ownerDocument;
17
- };
18
-
19
- /**
20
- * @param {Element} el container to check in
21
- * @param {boolean} includeContainer add container to check
22
- * @param {(node: Element) => boolean} filter filter candidates
23
- * @returns {Element[]}
24
- */
25
- var getCandidates = function getCandidates(el, includeContainer, filter) {
26
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
27
- if (includeContainer && matches.call(el, candidateSelector)) {
28
- candidates.unshift(el);
29
- }
30
- candidates = candidates.filter(filter);
31
- return candidates;
32
- };
33
-
34
- /**
35
- * @callback GetShadowRoot
36
- * @param {Element} element to check for shadow root
37
- * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
38
- */
39
-
40
- /**
41
- * @callback ShadowRootFilter
42
- * @param {Element} shadowHostNode the element which contains shadow content
43
- * @returns {boolean} true if a shadow root could potentially contain valid candidates.
44
- */
45
-
46
- /**
47
- * @typedef {Object} CandidateScope
48
- * @property {Element} scopeParent contains inner candidates
49
- * @property {Element[]} candidates list of candidates found in the scope parent
50
- */
51
-
52
- /**
53
- * @typedef {Object} IterativeOptions
54
- * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
55
- * if a function, implies shadow support is enabled and either returns the shadow root of an element
56
- * or a boolean stating if it has an undisclosed shadow root
57
- * @property {(node: Element) => boolean} filter filter candidates
58
- * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
59
- * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
60
- */
61
-
62
- /**
63
- * @param {Element[]} elements list of element containers to match candidates from
64
- * @param {boolean} includeContainer add container list to check
65
- * @param {IterativeOptions} options
66
- * @returns {Array.<Element|CandidateScope>}
67
- */
68
- var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
69
- var candidates = [];
70
- var elementsToCheck = Array.from(elements);
71
- while (elementsToCheck.length) {
72
- var element = elementsToCheck.shift();
73
- if (element.tagName === 'SLOT') {
74
- // add shadow dom slot scope (slot itself cannot be focusable)
75
- var assigned = element.assignedElements();
76
- var content = assigned.length ? assigned : element.children;
77
- var nestedCandidates = getCandidatesIteratively(content, true, options);
78
- if (options.flatten) {
79
- candidates.push.apply(candidates, nestedCandidates);
80
- } else {
81
- candidates.push({
82
- scopeParent: element,
83
- candidates: nestedCandidates
84
- });
85
- }
86
- } else {
87
- // check candidate element
88
- var validCandidate = matches.call(element, candidateSelector);
89
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
90
- candidates.push(element);
91
- }
92
-
93
- // iterate over shadow content if possible
94
- var shadowRoot = element.shadowRoot ||
95
- // check for an undisclosed shadow
96
- typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
97
- var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element);
98
- if (shadowRoot && validShadowRoot) {
99
- // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
100
- // shadow exists, so look at light dom children as fallback BUT create a scope for any
101
- // child candidates found because they're likely slotted elements (elements that are
102
- // children of the web component element (which has the shadow), in the light dom, but
103
- // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
104
- // _after_ we return from this recursive call
105
- var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
106
- if (options.flatten) {
107
- candidates.push.apply(candidates, _nestedCandidates);
108
- } else {
109
- candidates.push({
110
- scopeParent: element,
111
- candidates: _nestedCandidates
112
- });
113
- }
114
- } else {
115
- // there's not shadow so just dig into the element's (light dom) children
116
- // __without__ giving the element special scope treatment
117
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
118
- }
119
- }
120
- }
121
- return candidates;
122
- };
123
- var getTabindex = function getTabindex(node, isScope) {
124
- if (node.tabIndex < 0) {
125
- // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
126
- // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
127
- // yet they are still part of the regular tab order; in FF, they get a default
128
- // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
129
- // order, consider their tab index to be 0.
130
- // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
131
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
132
- //
133
- // isScope is positive for custom element with shadow root or slot that by default
134
- // have tabIndex -1, but need to be sorted by document order in order for their
135
- // content to be inserted in the correct position
136
- if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) {
137
- return 0;
138
- }
139
- }
140
- return node.tabIndex;
141
- };
142
- var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
143
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
144
- };
145
- var isInput = function isInput(node) {
146
- return node.tagName === 'INPUT';
147
- };
148
- var isHiddenInput = function isHiddenInput(node) {
149
- return isInput(node) && node.type === 'hidden';
150
- };
151
- var isDetailsWithSummary = function isDetailsWithSummary(node) {
152
- var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
153
- return child.tagName === 'SUMMARY';
154
- });
155
- return r;
156
- };
157
- var getCheckedRadio = function getCheckedRadio(nodes, form) {
158
- for (var i = 0; i < nodes.length; i++) {
159
- if (nodes[i].checked && nodes[i].form === form) {
160
- return nodes[i];
161
- }
162
- }
163
- };
164
- var isTabbableRadio = function isTabbableRadio(node) {
165
- if (!node.name) {
166
- return true;
167
- }
168
- var radioScope = node.form || getRootNode(node);
169
- var queryRadios = function queryRadios(name) {
170
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
171
- };
172
- var radioSet;
173
- if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
174
- radioSet = queryRadios(window.CSS.escape(node.name));
175
- } else {
176
- try {
177
- radioSet = queryRadios(node.name);
178
- } catch (err) {
179
- // eslint-disable-next-line no-console
180
- console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
181
- return false;
182
- }
183
- }
184
- var checked = getCheckedRadio(radioSet, node.form);
185
- return !checked || checked === node;
186
- };
187
- var isRadio = function isRadio(node) {
188
- return isInput(node) && node.type === 'radio';
189
- };
190
- var isNonTabbableRadio = function isNonTabbableRadio(node) {
191
- return isRadio(node) && !isTabbableRadio(node);
192
- };
193
-
194
- // determines if a node is ultimately attached to the window's document
195
- var isNodeAttached = function isNodeAttached(node) {
196
- var _nodeRootHost;
197
- // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
198
- // (but NOT _the_ document; see second 'If' comment below for more).
199
- // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
200
- // is attached, and the one we need to check if it's in the document or not (because the
201
- // shadow, and all nodes it contains, is never considered in the document since shadows
202
- // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
203
- // is hidden, or is not in the document itself but is detached, it will affect the shadow's
204
- // visibility, including all the nodes it contains). The host could be any normal node,
205
- // or a custom element (i.e. web component). Either way, that's the one that is considered
206
- // part of the document, not the shadow root, nor any of its children (i.e. the node being
207
- // tested).
208
- // To further complicate things, we have to look all the way up until we find a shadow HOST
209
- // that is attached (or find none) because the node might be in nested shadows...
210
- // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
211
- // document (per the docs) and while it's a Document-type object, that document does not
212
- // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
213
- // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
214
- // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
215
- // node is actually detached.
216
- var nodeRootHost = getRootNode(node).host;
217
- var attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && _nodeRootHost.ownerDocument.contains(nodeRootHost) || node.ownerDocument.contains(node));
218
- while (!attached && nodeRootHost) {
219
- var _nodeRootHost2;
220
- // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
221
- // which means we need to get the host's host and check if that parent host is contained
222
- // in (i.e. attached to) the document
223
- nodeRootHost = getRootNode(nodeRootHost).host;
224
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && _nodeRootHost2.ownerDocument.contains(nodeRootHost));
225
- }
226
- return attached;
227
- };
228
- var isZeroArea = function isZeroArea(node) {
229
- var _node$getBoundingClie = node.getBoundingClientRect(),
230
- width = _node$getBoundingClie.width,
231
- height = _node$getBoundingClie.height;
232
- return width === 0 && height === 0;
233
- };
234
- var isHidden = function isHidden(node, _ref) {
235
- var displayCheck = _ref.displayCheck,
236
- getShadowRoot = _ref.getShadowRoot;
237
- // NOTE: visibility will be `undefined` if node is detached from the document
238
- // (see notes about this further down), which means we will consider it visible
239
- // (this is legacy behavior from a very long way back)
240
- // NOTE: we check this regardless of `displayCheck="none"` because this is a
241
- // _visibility_ check, not a _display_ check
242
- if (getComputedStyle(node).visibility === 'hidden') {
243
- return true;
244
- }
245
- var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
246
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
247
- if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
248
- return true;
249
- }
250
- if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
251
- if (typeof getShadowRoot === 'function') {
252
- // figure out if we should consider the node to be in an undisclosed shadow and use the
253
- // 'non-zero-area' fallback
254
- var originalNode = node;
255
- while (node) {
256
- var parentElement = node.parentElement;
257
- var rootNode = getRootNode(node);
258
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
259
- ) {
260
- // node has an undisclosed shadow which means we can only treat it as a black box, so we
261
- // fall back to a non-zero-area test
262
- return isZeroArea(node);
263
- } else if (node.assignedSlot) {
264
- // iterate up slot
265
- node = node.assignedSlot;
266
- } else if (!parentElement && rootNode !== node.ownerDocument) {
267
- // cross shadow boundary
268
- node = rootNode.host;
269
- } else {
270
- // iterate up normal dom
271
- node = parentElement;
272
- }
273
- }
274
- node = originalNode;
275
- }
276
- // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
277
- // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
278
- // it might be a falsy value, which means shadow DOM support is disabled
279
-
280
- // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
281
- // now we can just test to see if it would normally be visible or not, provided it's
282
- // attached to the main document.
283
- // NOTE: We must consider case where node is inside a shadow DOM and given directly to
284
- // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
285
-
286
- if (isNodeAttached(node)) {
287
- // this works wherever the node is: if there's at least one client rect, it's
288
- // somehow displayed; it also covers the CSS 'display: contents' case where the
289
- // node itself is hidden in place of its contents; and there's no need to search
290
- // up the hierarchy either
291
- return !node.getClientRects().length;
292
- }
293
-
294
- // Else, the node isn't attached to the document, which means the `getClientRects()`
295
- // API will __always__ return zero rects (this can happen, for example, if React
296
- // is used to render nodes onto a detached tree, as confirmed in this thread:
297
- // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
298
- //
299
- // It also means that even window.getComputedStyle(node).display will return `undefined`
300
- // because styles are only computed for nodes that are in the document.
301
- //
302
- // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
303
- // somehow. Though it was never stated officially, anyone who has ever used tabbable
304
- // APIs on nodes in detached containers has actually implicitly used tabbable in what
305
- // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
306
- // considering __everything__ to be visible because of the innability to determine styles.
307
- //
308
- // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
309
- // nodes as visible with the 'none' fallback.__
310
- if (displayCheck !== 'legacy-full') {
311
- return true; // hidden
312
- }
313
- // else, fallback to 'none' mode and consider the node visible
314
- } else if (displayCheck === 'non-zero-area') {
315
- // NOTE: Even though this tests that the node's client rect is non-zero to determine
316
- // whether it's displayed, and that a detached node will __always__ have a zero-area
317
- // client rect, we don't special-case for whether the node is attached or not. In
318
- // this mode, we do want to consider nodes that have a zero area to be hidden at all
319
- // times, and that includes attached or not.
320
- return isZeroArea(node);
321
- }
322
-
323
- // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
324
- // it's visible
325
- return false;
326
- };
327
-
328
- // form fields (nested) inside a disabled fieldset are not focusable/tabbable
329
- // unless they are in the _first_ <legend> element of the top-most disabled
330
- // fieldset
331
- var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
332
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
333
- var parentNode = node.parentElement;
334
- // check if `node` is contained in a disabled <fieldset>
335
- while (parentNode) {
336
- if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
337
- // look for the first <legend> among the children of the disabled <fieldset>
338
- for (var i = 0; i < parentNode.children.length; i++) {
339
- var child = parentNode.children.item(i);
340
- // when the first <legend> (in document order) is found
341
- if (child.tagName === 'LEGEND') {
342
- // if its parent <fieldset> is not nested in another disabled <fieldset>,
343
- // return whether `node` is a descendant of its first <legend>
344
- return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
345
- }
346
- }
347
- // the disabled <fieldset> containing `node` has no <legend>
348
- return true;
349
- }
350
- parentNode = parentNode.parentElement;
351
- }
352
- }
353
-
354
- // else, node's tabbable/focusable state should not be affected by a fieldset's
355
- // enabled/disabled state
356
- return false;
357
- };
358
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
359
- if (node.disabled || isHiddenInput(node) || isHidden(node, options) ||
360
- // For a details element with a summary, the summary element gets the focus
361
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
362
- return false;
363
- }
364
- return true;
365
- };
366
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
367
- if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
368
- return false;
369
- }
370
- return true;
371
- };
372
- var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
373
- var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
374
- if (isNaN(tabIndex) || tabIndex >= 0) {
375
- return true;
376
- }
377
- // If a custom element has an explicit negative tabindex,
378
- // browsers will not allow tab targeting said element's children.
379
- return false;
380
- };
381
-
382
- /**
383
- * @param {Array.<Element|CandidateScope>} candidates
384
- * @returns Element[]
385
- */
386
- var sortByOrder = function sortByOrder(candidates) {
387
- var regularTabbables = [];
388
- var orderedTabbables = [];
389
- candidates.forEach(function (item, i) {
390
- var isScope = !!item.scopeParent;
391
- var element = isScope ? item.scopeParent : item;
392
- var candidateTabindex = getTabindex(element, isScope);
393
- var elements = isScope ? sortByOrder(item.candidates) : element;
394
- if (candidateTabindex === 0) {
395
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
396
- } else {
397
- orderedTabbables.push({
398
- documentOrder: i,
399
- tabIndex: candidateTabindex,
400
- item: item,
401
- isScope: isScope,
402
- content: elements
403
- });
404
- }
405
- });
406
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
407
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
408
- return acc;
409
- }, []).concat(regularTabbables);
410
- };
411
- var tabbable = function tabbable(el, options) {
412
- options = options || {};
413
- var candidates;
414
- if (options.getShadowRoot) {
415
- candidates = getCandidatesIteratively([el], options.includeContainer, {
416
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
417
- flatten: false,
418
- getShadowRoot: options.getShadowRoot,
419
- shadowRootFilter: isValidShadowRootTabbable
420
- });
421
- } else {
422
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
423
- }
424
- return sortByOrder(candidates);
425
- };
426
- var focusable = function focusable(el, options) {
427
- options = options || {};
428
- var candidates;
429
- if (options.getShadowRoot) {
430
- candidates = getCandidatesIteratively([el], options.includeContainer, {
431
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
432
- flatten: true,
433
- getShadowRoot: options.getShadowRoot
434
- });
435
- } else {
436
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
437
- }
438
- return candidates;
439
- };
440
- var isTabbable = function isTabbable(node, options) {
441
- options = options || {};
442
- if (!node) {
443
- throw new Error('No node provided');
444
- }
445
- if (matches.call(node, candidateSelector) === false) {
446
- return false;
447
- }
448
- return isNodeMatchingSelectorTabbable(options, node);
449
- };
450
- var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
451
- var isFocusable = function isFocusable(node, options) {
452
- options = options || {};
453
- if (!node) {
454
- throw new Error('No node provided');
455
- }
456
- if (matches.call(node, focusableCandidateSelector) === false) {
457
- return false;
458
- }
459
- return isNodeMatchingSelectorFocusable(options, node);
460
- };
461
-
462
- /*!
463
- * focus-trap 7.1.0
464
- * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
465
- */
466
-
467
- function ownKeys(object, enumerableOnly) {
468
- var keys = Object.keys(object);
469
- if (Object.getOwnPropertySymbols) {
470
- var symbols = Object.getOwnPropertySymbols(object);
471
- enumerableOnly && (symbols = symbols.filter(function (sym) {
472
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
473
- })), keys.push.apply(keys, symbols);
474
- }
475
- return keys;
476
- }
477
- function _objectSpread2(target) {
478
- for (var i = 1; i < arguments.length; i++) {
479
- var source = null != arguments[i] ? arguments[i] : {};
480
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
481
- _defineProperty(target, key, source[key]);
482
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
483
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
484
- });
485
- }
486
- return target;
487
- }
488
- function _defineProperty(obj, key, value) {
489
- if (key in obj) {
490
- Object.defineProperty(obj, key, {
491
- value: value,
492
- enumerable: true,
493
- configurable: true,
494
- writable: true
495
- });
496
- } else {
497
- obj[key] = value;
498
- }
499
- return obj;
500
- }
501
-
502
- var rooTrapStack = [];
503
- var activeFocusTraps = {
504
- activateTrap: function activateTrap(trapStack, trap) {
505
- if (trapStack.length > 0) {
506
- var activeTrap = trapStack[trapStack.length - 1];
507
- if (activeTrap !== trap) {
508
- activeTrap.pause();
509
- }
510
- }
511
- var trapIndex = trapStack.indexOf(trap);
512
- if (trapIndex === -1) {
513
- trapStack.push(trap);
514
- } else {
515
- // move this existing trap to the front of the queue
516
- trapStack.splice(trapIndex, 1);
517
- trapStack.push(trap);
518
- }
519
- },
520
- deactivateTrap: function deactivateTrap(trapStack, trap) {
521
- var trapIndex = trapStack.indexOf(trap);
522
- if (trapIndex !== -1) {
523
- trapStack.splice(trapIndex, 1);
524
- }
525
- if (trapStack.length > 0) {
526
- trapStack[trapStack.length - 1].unpause();
527
- }
528
- }
529
- };
530
- var isSelectableInput = function isSelectableInput(node) {
531
- return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
532
- };
533
- var isEscapeEvent = function isEscapeEvent(e) {
534
- return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
535
- };
536
- var isTabEvent = function isTabEvent(e) {
537
- return e.key === 'Tab' || e.keyCode === 9;
538
- };
539
- var delay = function delay(fn) {
540
- return setTimeout(fn, 0);
541
- };
542
-
543
- // Array.find/findIndex() are not supported on IE; this replicates enough
544
- // of Array.findIndex() for our needs
545
- var findIndex = function findIndex(arr, fn) {
546
- var idx = -1;
547
- arr.every(function (value, i) {
548
- if (fn(value)) {
549
- idx = i;
550
- return false; // break
551
- }
552
-
553
- return true; // next
554
- });
555
-
556
- return idx;
557
- };
558
-
559
- /**
560
- * Get an option's value when it could be a plain value, or a handler that provides
561
- * the value.
562
- * @param {*} value Option's value to check.
563
- * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
564
- * @returns {*} The `value`, or the handler's returned value.
565
- */
566
- var valueOrHandler = function valueOrHandler(value) {
567
- for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
568
- params[_key - 1] = arguments[_key];
569
- }
570
- return typeof value === 'function' ? value.apply(void 0, params) : value;
571
- };
572
- var getActualTarget = function getActualTarget(event) {
573
- // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
574
- // shadow host. However, event.target.composedPath() will be an array of
575
- // nodes "clicked" from inner-most (the actual element inside the shadow) to
576
- // outer-most (the host HTML document). If we have access to composedPath(),
577
- // then use its first element; otherwise, fall back to event.target (and
578
- // this only works for an _open_ shadow DOM; otherwise,
579
- // composedPath()[0] === event.target always).
580
- return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
581
- };
582
- var createFocusTrap = function createFocusTrap(elements, userOptions) {
583
- // SSR: a live trap shouldn't be created in this type of environment so this
584
- // should be safe code to execute if the `document` option isn't specified
585
- var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
586
- var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || rooTrapStack;
587
- var config = _objectSpread2({
588
- returnFocusOnDeactivate: true,
589
- escapeDeactivates: true,
590
- delayInitialFocus: true
591
- }, userOptions);
592
- var state = {
593
- // containers given to createFocusTrap()
594
- // @type {Array<HTMLElement>}
595
- containers: [],
596
- // list of objects identifying tabbable nodes in `containers` in the trap
597
- // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
598
- // is active, but the trap should never get to a state where there isn't at least one group
599
- // with at least one tabbable node in it (that would lead to an error condition that would
600
- // result in an error being thrown)
601
- // @type {Array<{
602
- // container: HTMLElement,
603
- // tabbableNodes: Array<HTMLElement>, // empty if none
604
- // focusableNodes: Array<HTMLElement>, // empty if none
605
- // firstTabbableNode: HTMLElement|null,
606
- // lastTabbableNode: HTMLElement|null,
607
- // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
608
- // }>}
609
- containerGroups: [],
610
- // same order/length as `containers` list
611
-
612
- // references to objects in `containerGroups`, but only those that actually have
613
- // tabbable nodes in them
614
- // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
615
- // the same length
616
- tabbableGroups: [],
617
- nodeFocusedBeforeActivation: null,
618
- mostRecentlyFocusedNode: null,
619
- active: false,
620
- paused: false,
621
- // timer ID for when delayInitialFocus is true and initial focus in this trap
622
- // has been delayed during activation
623
- delayInitialFocusTimer: undefined
624
- };
625
- 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
626
-
627
- /**
628
- * Gets a configuration option value.
629
- * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
630
- * value will be taken from this object. Otherwise, value will be taken from base configuration.
631
- * @param {string} optionName Name of the option whose value is sought.
632
- * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
633
- * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
634
- */
635
- var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
636
- return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
637
- };
638
-
639
- /**
640
- * Finds the index of the container that contains the element.
641
- * @param {HTMLElement} element
642
- * @returns {number} Index of the container in either `state.containers` or
643
- * `state.containerGroups` (the order/length of these lists are the same); -1
644
- * if the element isn't found.
645
- */
646
- var findContainerIndex = function findContainerIndex(element) {
647
- // NOTE: search `containerGroups` because it's possible a group contains no tabbable
648
- // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
649
- // and we still need to find the element in there
650
- return state.containerGroups.findIndex(function (_ref) {
651
- var container = _ref.container,
652
- tabbableNodes = _ref.tabbableNodes;
653
- return container.contains(element) ||
654
- // fall back to explicit tabbable search which will take into consideration any
655
- // web components if the `tabbableOptions.getShadowRoot` option was used for
656
- // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
657
- // look inside web components even if open)
658
- tabbableNodes.find(function (node) {
659
- return node === element;
660
- });
661
- });
662
- };
663
-
664
- /**
665
- * Gets the node for the given option, which is expected to be an option that
666
- * can be either a DOM node, a string that is a selector to get a node, `false`
667
- * (if a node is explicitly NOT given), or a function that returns any of these
668
- * values.
669
- * @param {string} optionName
670
- * @returns {undefined | false | HTMLElement | SVGElement} Returns
671
- * `undefined` if the option is not specified; `false` if the option
672
- * resolved to `false` (node explicitly not given); otherwise, the resolved
673
- * DOM node.
674
- * @throws {Error} If the option is set, not `false`, and is not, or does not
675
- * resolve to a node.
676
- */
677
- var getNodeForOption = function getNodeForOption(optionName) {
678
- var optionValue = config[optionName];
679
- if (typeof optionValue === 'function') {
680
- for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
681
- params[_key2 - 1] = arguments[_key2];
682
- }
683
- optionValue = optionValue.apply(void 0, params);
684
- }
685
- if (optionValue === true) {
686
- optionValue = undefined; // use default value
687
- }
688
-
689
- if (!optionValue) {
690
- if (optionValue === undefined || optionValue === false) {
691
- return optionValue;
692
- }
693
- // else, empty string (invalid), null (invalid), 0 (invalid)
694
-
695
- throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
696
- }
697
- var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
698
-
699
- if (typeof optionValue === 'string') {
700
- node = doc.querySelector(optionValue); // resolve to node, or null if fails
701
- if (!node) {
702
- throw new Error("`".concat(optionName, "` as selector refers to no known node"));
703
- }
704
- }
705
- return node;
706
- };
707
- var getInitialFocusNode = function getInitialFocusNode() {
708
- var node = getNodeForOption('initialFocus');
709
-
710
- // false explicitly indicates we want no initialFocus at all
711
- if (node === false) {
712
- return false;
713
- }
714
- if (node === undefined) {
715
- // option not specified: use fallback options
716
- if (findContainerIndex(doc.activeElement) >= 0) {
717
- node = doc.activeElement;
718
- } else {
719
- var firstTabbableGroup = state.tabbableGroups[0];
720
- var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
721
-
722
- // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
723
- node = firstTabbableNode || getNodeForOption('fallbackFocus');
724
- }
725
- }
726
- if (!node) {
727
- throw new Error('Your focus-trap needs to have at least one focusable element');
728
- }
729
- return node;
730
- };
731
- var updateTabbableNodes = function updateTabbableNodes() {
732
- state.containerGroups = state.containers.map(function (container) {
733
- var tabbableNodes = tabbable(container, config.tabbableOptions);
734
-
735
- // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
736
- // are a superset of tabbable nodes
737
- var focusableNodes = focusable(container, config.tabbableOptions);
738
- return {
739
- container: container,
740
- tabbableNodes: tabbableNodes,
741
- focusableNodes: focusableNodes,
742
- firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
743
- lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
744
- /**
745
- * Finds the __tabbable__ node that follows the given node in the specified direction,
746
- * in this container, if any.
747
- * @param {HTMLElement} node
748
- * @param {boolean} [forward] True if going in forward tab order; false if going
749
- * in reverse.
750
- * @returns {HTMLElement|undefined} The next tabbable node, if any.
751
- */
752
- nextTabbableNode: function nextTabbableNode(node) {
753
- var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
754
- // NOTE: If tabindex is positive (in order to manipulate the tab order separate
755
- // from the DOM order), this __will not work__ because the list of focusableNodes,
756
- // while it contains tabbable nodes, does not sort its nodes in any order other
757
- // than DOM order, because it can't: Where would you place focusable (but not
758
- // tabbable) nodes in that order? They have no order, because they aren't tabbale...
759
- // Support for positive tabindex is already broken and hard to manage (possibly
760
- // not supportable, TBD), so this isn't going to make things worse than they
761
- // already are, and at least makes things better for the majority of cases where
762
- // tabindex is either 0/unset or negative.
763
- // FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
764
- var nodeIdx = focusableNodes.findIndex(function (n) {
765
- return n === node;
766
- });
767
- if (nodeIdx < 0) {
768
- return undefined;
769
- }
770
- if (forward) {
771
- return focusableNodes.slice(nodeIdx + 1).find(function (n) {
772
- return isTabbable(n, config.tabbableOptions);
773
- });
774
- }
775
- return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
776
- return isTabbable(n, config.tabbableOptions);
777
- });
778
- }
779
- };
780
- });
781
- state.tabbableGroups = state.containerGroups.filter(function (group) {
782
- return group.tabbableNodes.length > 0;
783
- });
784
-
785
- // throw if no groups have tabbable nodes and we don't have a fallback focus node either
786
- if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
787
- ) {
788
- throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
789
- }
790
- };
791
- var tryFocus = function tryFocus(node) {
792
- if (node === false) {
793
- return;
794
- }
795
- if (node === doc.activeElement) {
796
- return;
797
- }
798
- if (!node || !node.focus) {
799
- tryFocus(getInitialFocusNode());
800
- return;
801
- }
802
- node.focus({
803
- preventScroll: !!config.preventScroll
804
- });
805
- state.mostRecentlyFocusedNode = node;
806
- if (isSelectableInput(node)) {
807
- node.select();
808
- }
809
- };
810
- var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
811
- var node = getNodeForOption('setReturnFocus', previousActiveElement);
812
- return node ? node : node === false ? false : previousActiveElement;
813
- };
814
-
815
- // This needs to be done on mousedown and touchstart instead of click
816
- // so that it precedes the focus event.
817
- var checkPointerDown = function checkPointerDown(e) {
818
- var target = getActualTarget(e);
819
- if (findContainerIndex(target) >= 0) {
820
- // allow the click since it ocurred inside the trap
821
- return;
822
- }
823
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
824
- // immediately deactivate the trap
825
- trap.deactivate({
826
- // if, on deactivation, we should return focus to the node originally-focused
827
- // when the trap was activated (or the configured `setReturnFocus` node),
828
- // then assume it's also OK to return focus to the outside node that was
829
- // just clicked, causing deactivation, as long as that node is focusable;
830
- // if it isn't focusable, then return focus to the original node focused
831
- // on activation (or the configured `setReturnFocus` node)
832
- // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
833
- // which will result in the outside click setting focus to the node
834
- // that was clicked, whether it's focusable or not; by setting
835
- // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
836
- // on activation (or the configured `setReturnFocus` node)
837
- returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
838
- });
839
- return;
840
- }
841
-
842
- // This is needed for mobile devices.
843
- // (If we'll only let `click` events through,
844
- // then on mobile they will be blocked anyways if `touchstart` is blocked.)
845
- if (valueOrHandler(config.allowOutsideClick, e)) {
846
- // allow the click outside the trap to take place
847
- return;
848
- }
849
-
850
- // otherwise, prevent the click
851
- e.preventDefault();
852
- };
853
-
854
- // In case focus escapes the trap for some strange reason, pull it back in.
855
- var checkFocusIn = function checkFocusIn(e) {
856
- var target = getActualTarget(e);
857
- var targetContained = findContainerIndex(target) >= 0;
858
-
859
- // In Firefox when you Tab out of an iframe the Document is briefly focused.
860
- if (targetContained || target instanceof Document) {
861
- if (targetContained) {
862
- state.mostRecentlyFocusedNode = target;
863
- }
864
- } else {
865
- // escaped! pull it back in to where it just left
866
- e.stopImmediatePropagation();
867
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
868
- }
869
- };
870
-
871
- // Hijack Tab events on the first and last focusable nodes of the trap,
872
- // in order to prevent focus from escaping. If it escapes for even a
873
- // moment it can end up scrolling the page and causing confusion so we
874
- // kind of need to capture the action at the keydown phase.
875
- var checkTab = function checkTab(e) {
876
- var target = getActualTarget(e);
877
- updateTabbableNodes();
878
- var destinationNode = null;
879
- if (state.tabbableGroups.length > 0) {
880
- // make sure the target is actually contained in a group
881
- // NOTE: the target may also be the container itself if it's focusable
882
- // with tabIndex='-1' and was given initial focus
883
- var containerIndex = findContainerIndex(target);
884
- var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
885
- if (containerIndex < 0) {
886
- // target not found in any group: quite possible focus has escaped the trap,
887
- // so bring it back in to...
888
- if (e.shiftKey) {
889
- // ...the last node in the last group
890
- destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
891
- } else {
892
- // ...the first node in the first group
893
- destinationNode = state.tabbableGroups[0].firstTabbableNode;
894
- }
895
- } else if (e.shiftKey) {
896
- // REVERSE
897
-
898
- // is the target the first tabbable node in a group?
899
- var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
900
- var firstTabbableNode = _ref2.firstTabbableNode;
901
- return target === firstTabbableNode;
902
- });
903
- if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
904
- // an exception case where the target is either the container itself, or
905
- // a non-tabbable node that was given focus (i.e. tabindex is negative
906
- // and user clicked on it or node was programmatically given focus)
907
- // and is not followed by any other tabbable node, in which
908
- // case, we should handle shift+tab as if focus were on the container's
909
- // first tabbable node, and go to the last tabbable node of the LAST group
910
- startOfGroupIndex = containerIndex;
911
- }
912
- if (startOfGroupIndex >= 0) {
913
- // YES: then shift+tab should go to the last tabbable node in the
914
- // previous group (and wrap around to the last tabbable node of
915
- // the LAST group if it's the first tabbable node of the FIRST group)
916
- var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
917
- var destinationGroup = state.tabbableGroups[destinationGroupIndex];
918
- destinationNode = destinationGroup.lastTabbableNode;
919
- }
920
- } else {
921
- // FORWARD
922
-
923
- // is the target the last tabbable node in a group?
924
- var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
925
- var lastTabbableNode = _ref3.lastTabbableNode;
926
- return target === lastTabbableNode;
927
- });
928
- if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
929
- // an exception case where the target is the container itself, or
930
- // a non-tabbable node that was given focus (i.e. tabindex is negative
931
- // and user clicked on it or node was programmatically given focus)
932
- // and is not followed by any other tabbable node, in which
933
- // case, we should handle tab as if focus were on the container's
934
- // last tabbable node, and go to the first tabbable node of the FIRST group
935
- lastOfGroupIndex = containerIndex;
936
- }
937
- if (lastOfGroupIndex >= 0) {
938
- // YES: then tab should go to the first tabbable node in the next
939
- // group (and wrap around to the first tabbable node of the FIRST
940
- // group if it's the last tabbable node of the LAST group)
941
- var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
942
- var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
943
- destinationNode = _destinationGroup.firstTabbableNode;
944
- }
945
- }
946
- } else {
947
- // NOTE: the fallbackFocus option does not support returning false to opt-out
948
- destinationNode = getNodeForOption('fallbackFocus');
949
- }
950
- if (destinationNode) {
951
- e.preventDefault();
952
- tryFocus(destinationNode);
953
- }
954
- // else, let the browser take care of [shift+]tab and move the focus
955
- };
956
-
957
- var checkKey = function checkKey(e) {
958
- if (isEscapeEvent(e) && valueOrHandler(config.escapeDeactivates, e) !== false) {
959
- e.preventDefault();
960
- trap.deactivate();
961
- return;
962
- }
963
- if (isTabEvent(e)) {
964
- checkTab(e);
965
- return;
966
- }
967
- };
968
- var checkClick = function checkClick(e) {
969
- var target = getActualTarget(e);
970
- if (findContainerIndex(target) >= 0) {
971
- return;
972
- }
973
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
974
- return;
975
- }
976
- if (valueOrHandler(config.allowOutsideClick, e)) {
977
- return;
978
- }
979
- e.preventDefault();
980
- e.stopImmediatePropagation();
981
- };
982
-
983
- //
984
- // EVENT LISTENERS
985
- //
986
-
987
- var addListeners = function addListeners() {
988
- if (!state.active) {
989
- return;
990
- }
991
-
992
- // There can be only one listening focus trap at a time
993
- activeFocusTraps.activateTrap(trapStack, trap);
994
-
995
- // Delay ensures that the focused element doesn't capture the event
996
- // that caused the focus trap activation.
997
- state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
998
- tryFocus(getInitialFocusNode());
999
- }) : tryFocus(getInitialFocusNode());
1000
- doc.addEventListener('focusin', checkFocusIn, true);
1001
- doc.addEventListener('mousedown', checkPointerDown, {
1002
- capture: true,
1003
- passive: false
1004
- });
1005
- doc.addEventListener('touchstart', checkPointerDown, {
1006
- capture: true,
1007
- passive: false
1008
- });
1009
- doc.addEventListener('click', checkClick, {
1010
- capture: true,
1011
- passive: false
1012
- });
1013
- doc.addEventListener('keydown', checkKey, {
1014
- capture: true,
1015
- passive: false
1016
- });
1017
- return trap;
1018
- };
1019
- var removeListeners = function removeListeners() {
1020
- if (!state.active) {
1021
- return;
1022
- }
1023
- doc.removeEventListener('focusin', checkFocusIn, true);
1024
- doc.removeEventListener('mousedown', checkPointerDown, true);
1025
- doc.removeEventListener('touchstart', checkPointerDown, true);
1026
- doc.removeEventListener('click', checkClick, true);
1027
- doc.removeEventListener('keydown', checkKey, true);
1028
- return trap;
1029
- };
1030
-
1031
- //
1032
- // TRAP DEFINITION
1033
- //
1034
-
1035
- trap = {
1036
- get active() {
1037
- return state.active;
1038
- },
1039
- get paused() {
1040
- return state.paused;
1041
- },
1042
- activate: function activate(activateOptions) {
1043
- if (state.active) {
1044
- return this;
1045
- }
1046
- var onActivate = getOption(activateOptions, 'onActivate');
1047
- var onPostActivate = getOption(activateOptions, 'onPostActivate');
1048
- var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
1049
- if (!checkCanFocusTrap) {
1050
- updateTabbableNodes();
1051
- }
1052
- state.active = true;
1053
- state.paused = false;
1054
- state.nodeFocusedBeforeActivation = doc.activeElement;
1055
- if (onActivate) {
1056
- onActivate();
1057
- }
1058
- var finishActivation = function finishActivation() {
1059
- if (checkCanFocusTrap) {
1060
- updateTabbableNodes();
1061
- }
1062
- addListeners();
1063
- if (onPostActivate) {
1064
- onPostActivate();
1065
- }
1066
- };
1067
- if (checkCanFocusTrap) {
1068
- checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
1069
- return this;
1070
- }
1071
- finishActivation();
1072
- return this;
1073
- },
1074
- deactivate: function deactivate(deactivateOptions) {
1075
- if (!state.active) {
1076
- return this;
1077
- }
1078
- var options = _objectSpread2({
1079
- onDeactivate: config.onDeactivate,
1080
- onPostDeactivate: config.onPostDeactivate,
1081
- checkCanReturnFocus: config.checkCanReturnFocus
1082
- }, deactivateOptions);
1083
- clearTimeout(state.delayInitialFocusTimer); // noop if undefined
1084
- state.delayInitialFocusTimer = undefined;
1085
- removeListeners();
1086
- state.active = false;
1087
- state.paused = false;
1088
- activeFocusTraps.deactivateTrap(trapStack, trap);
1089
- var onDeactivate = getOption(options, 'onDeactivate');
1090
- var onPostDeactivate = getOption(options, 'onPostDeactivate');
1091
- var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
1092
- var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
1093
- if (onDeactivate) {
1094
- onDeactivate();
1095
- }
1096
- var finishDeactivation = function finishDeactivation() {
1097
- delay(function () {
1098
- if (returnFocus) {
1099
- tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
1100
- }
1101
- if (onPostDeactivate) {
1102
- onPostDeactivate();
1103
- }
1104
- });
1105
- };
1106
- if (returnFocus && checkCanReturnFocus) {
1107
- checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
1108
- return this;
1109
- }
1110
- finishDeactivation();
1111
- return this;
1112
- },
1113
- pause: function pause() {
1114
- if (state.paused || !state.active) {
1115
- return this;
1116
- }
1117
- state.paused = true;
1118
- removeListeners();
1119
- return this;
1120
- },
1121
- unpause: function unpause() {
1122
- if (!state.paused || !state.active) {
1123
- return this;
1124
- }
1125
- state.paused = false;
1126
- updateTabbableNodes();
1127
- addListeners();
1128
- return this;
1129
- },
1130
- updateContainerElements: function updateContainerElements(containerElements) {
1131
- var elementsAsArray = [].concat(containerElements).filter(Boolean);
1132
- state.containers = elementsAsArray.map(function (element) {
1133
- return typeof element === 'string' ? doc.querySelector(element) : element;
1134
- });
1135
- if (state.active) {
1136
- updateTabbableNodes();
1137
- }
1138
- return this;
1139
- }
1140
- };
1141
-
1142
- // initialize container elements
1143
- trap.updateContainerElements(elements);
1144
- return trap;
1145
- };
1146
-
1147
6
  const swirlModalCss = ":host{display:block}:host *{box-sizing:border-box}.modal{--swirl-ghost-button-background-default:var(--s-surface-overlay-default);--swirl-ghost-button-background-hovered:var(--s-surface-overlay-hovered);--swirl-ghost-button-background-pressed:var(--s-surface-overlay-pressed);--swirl-resource-list-item-background-default:var(\n --s-surface-overlay-default\n );--swirl-resource-list-item-background-hovered:var(\n --s-surface-overlay-hovered\n );--swirl-resource-list-item-background-pressed:var(\n --s-surface-overlay-pressed\n );--swirl-modal-height:auto;--swirl-modal-max-height:90vh;position:fixed;z-index:var(--s-z-40);display:flex;justify-content:center;align-items:center;inset:0}.modal[aria-hidden=\"true\"]{display:none}.modal--variant-default.modal--closing{animation:0.15s modal-fade-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-default.modal--closing{animation:none}}.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:0.15s modal-backdrop-fade-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__backdrop{animation:none}}.modal--variant-default:not(.modal--closing) .modal__body{animation:0.15s modal-scale-in}@media (prefers-reduced-motion){.modal--variant-default:not(.modal--closing) .modal__body{animation:none}}.modal--variant-drawer{justify-content:end;align-items:stretch}.modal--variant-drawer.modal--closing{animation:0.15s modal-drawer-slide-out;animation-fill-mode:forwards}@media (prefers-reduced-motion){.modal--variant-drawer.modal--closing{animation:none}}@media (min-width: 768px){.modal--variant-drawer.modal--hide-label .modal__header-bar{height:auto;padding-top:var(--s-space-4);padding-bottom:var(--s-space-4)}}.modal--variant-drawer .modal__backdrop{background-color:transparent;animation:none}.modal--variant-drawer .modal__body{height:100%;max-height:none;border-radius:0;animation:0.15s modal-drawer-slide-in;box-shadow:var(--s-shadow-level-3)}@media (prefers-reduced-motion){.modal--variant-drawer .modal__body{animation:none}}.modal--variant-drawer .modal__header-bar{background-color:var(--s-surface-overlay-default)}.modal--variant-drawer .modal__header-bar .modal__close-button{margin-left:calc(-1 * var(--s-space-8))}@media (min-width: 768px){.modal--variant-drawer .modal__header-bar{flex-direction:row}}.modal--variant-drawer .modal__content{min-height:100%}@media (min-width: 768px){.modal--variant-drawer.modal--padded .modal__content{padding-top:var(--s-space-8)}}.modal--padded .modal__content{padding-top:var(--s-space-24);padding-right:var(--s-space-16);padding-bottom:var(--s-space-24);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal--padded .modal__content{padding-top:0;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}}@media (min-width: 768px){.modal--scrollable .modal__content{padding-bottom:0}}.modal--scrollable:not(.modal--scrolled-down).modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--scrollable:not(.modal--scrolled-down):not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-custom-header .modal__custom-header{display:block}.modal--has-custom-header .modal__content{padding-top:var(--s-space-16)}.modal--has-custom-footer .modal__custom-footer{padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24)}.modal--has-header-tools .modal__header{border-bottom-color:transparent}.modal--has-header-tools .modal__header-tools{display:block}.modal--has-secondary-content .modal__body{max-width:64rem}.modal--has-secondary-content:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}.modal--has-secondary-content.modal--has-custom-footer .modal__custom-footer{border-top:var(--s-border-width-default) solid var(--s-border-default)}.modal--has-secondary-content:not(.modal--has-custom-footer) .modal__controls{border-top:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 992px){.modal--has-secondary-content .modal__header-tools,.modal--has-secondary-content .modal__content{padding-right:0}}.modal--has-secondary-content .modal__primary-content{overflow:visible;max-height:60%;flex-basis:auto}@media (min-width: 992px){.modal--has-secondary-content .modal__primary-content{max-width:calc(100% - 24rem);max-height:none;flex-basis:calc(100% - 24rem)}}.modal--has-secondary-content .modal__secondary-content{display:block}@media (min-width: 768px){.modal--scrolled:not(.modal--has-header-tools) .modal__header{border-bottom-color:var(--s-border-default)}.modal--scrolled.modal--has-header-tools .modal__header-tools{border-bottom-color:var(--s-border-default)}}.modal__backdrop{position:fixed;background-color:rgba(0, 0, 0, 0.2);inset:0}.modal__body{--swirl-card-background-default:var(--s-surface-overlay-default);--swirl-card-background-hovered:var(--s-surface-overlay-hovered);--swirl-card-background-pressed:var(--s-surface-overlay-pressed);--swirl-accordion-item-toggle-default:var(--s-surface-overlay-default);--swirl-accordion-item-toggle-hovered:var(--s-surface-overlay-hovered);--swirl-accordion-item-toggle-pressed:var(--s-surface-overlay-pressed);position:relative;z-index:var(--s-z-40);display:flex;overflow:hidden;width:100vw;max-width:40rem;height:100vh;background-color:var(--s-surface-overlay-default);flex-direction:column}@media (min-width: 768px){.modal__body{width:90vw;max-height:var(--swirl-modal-max-height);border-radius:var(--s-border-radius-base);box-shadow:var(--s-shadow-level-3)}}@media (min-width: 992px){.modal__body{height:var(--swirl-modal-height)}}.modal__header{border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header{border-bottom:var(--s-border-width-default) solid transparent}}.modal__header-bar{display:flex;height:3.5rem;padding-top:var(--s-space-8);padding-right:var(--s-space-16);padding-bottom:var(--s-space-8);padding-left:var(--s-space-16);flex-shrink:0;align-items:center;gap:var(--s-space-8)}@media (min-width: 768px){.modal__header-bar{height:3.75rem;padding-top:var(--s-space-12);padding-right:var(--s-space-24);padding-bottom:var(--s-space-12);padding-left:var(--s-space-24);flex-direction:row-reverse;gap:var(--s-space-16)}}.modal__header-tools{display:none;padding-right:var(--s-space-16);padding-left:var(--s-space-16);border-bottom:var(--s-border-width-default) solid var(--s-border-default)}@media (min-width: 768px){.modal__header-tools{padding-right:var(--s-space-24);padding-left:var(--s-space-24);border-bottom-color:transparent}}.modal__custom-header{display:none;flex-shrink:0;border-bottom:var(--s-border-width-default) solid var(--s-border-default)}.modal__heading{overflow:hidden}.modal__heading .heading{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.modal__content-container{display:flex;overflow:hidden;flex-grow:1;flex-direction:column;gap:var(--s-space-24)}@media (min-width: 992px){.modal__content-container{flex-direction:row}}.modal__primary-content{display:flex;overflow:hidden;flex-basis:100%;flex-direction:column}.modal__content{overflow-x:hidden;overflow-y:auto;min-height:100%}.modal__content ::slotted(*){margin:0}.modal__secondary-content{display:none;overflow:visible;overflow-x:hidden;overflow-y:auto;max-width:none;max-height:40%;padding-right:var(--s-space-16);padding-left:var(--s-space-16)}@media (min-width: 768px){.modal__secondary-content{padding-left:var(--s-space-24)}}@media (min-width: 992px){.modal__secondary-content{overflow-x:hidden;overflow-y:auto;max-width:24rem;max-height:none;padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:0;flex-basis:50%}}.modal__custom-footer{flex-shrink:0}.modal__controls{display:flex;padding-top:var(--s-space-16);padding-right:var(--s-space-24);padding-bottom:var(--s-space-16);padding-left:var(--s-space-24);flex-shrink:0;justify-content:flex-end}@keyframes modal-scale-in{from{transform:scale(0)}to{transform:scale(1)}}@keyframes modal-backdrop-fade-in{from{opacity:0}to{opacity:1}}@keyframes modal-fade-out{from{opacity:1}to{opacity:0}}@keyframes modal-drawer-slide-in{from{transform:translate3d(100%, 0, 0)}to{transform:translate3d(0, 0, 0)}}@keyframes modal-drawer-slide-out{from{transform:translate3d(0, 0, 0)}to{transform:translate3d(100%, 0, 0)}}";
1148
7
 
1149
8
  const SwirlModal = class {