@scouterna/ui-webc 3.2.0 → 4.0.1

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 (147) hide show
  1. package/dist/cjs/{index-BPpKjjvS.js → index-Vd3hlPvW.js} +35 -4
  2. package/dist/cjs/{inputMixin-D0IzcaXz.js → inputMixin-BsRV69ob.js} +1 -1
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/scout-app-bar.cjs.entry.js +2 -2
  5. package/dist/cjs/scout-avatar.cjs.entry.js +39 -0
  6. package/dist/cjs/scout-bottom-bar-item.cjs.entry.js +2 -2
  7. package/dist/cjs/scout-bottom-bar.cjs.entry.js +2 -2
  8. package/dist/cjs/scout-button.cjs.entry.js +1 -1
  9. package/dist/cjs/scout-card.cjs.entry.js +1 -1
  10. package/dist/cjs/scout-checkbox_2.cjs.entry.js +2 -2
  11. package/dist/cjs/scout-divider.cjs.entry.js +1 -1
  12. package/dist/cjs/scout-drawer.cjs.entry.js +841 -0
  13. package/dist/cjs/scout-field.cjs.entry.js +1 -1
  14. package/dist/cjs/scout-input.cjs.entry.js +2 -2
  15. package/dist/cjs/scout-link.cjs.entry.js +1 -1
  16. package/dist/cjs/scout-list-view-item.cjs.entry.js +2 -2
  17. package/dist/cjs/scout-list-view-subheader.cjs.entry.js +1 -1
  18. package/dist/cjs/scout-list-view.cjs.entry.js +7 -5
  19. package/dist/cjs/scout-loader.cjs.entry.js +1 -1
  20. package/dist/cjs/scout-segmented-control.cjs.entry.js +88 -0
  21. package/dist/cjs/scout-select.cjs.entry.js +3 -3
  22. package/dist/cjs/scout-stack.cjs.entry.js +3 -3
  23. package/dist/cjs/scout-switch.cjs.entry.js +3 -3
  24. package/dist/cjs/scout-tabs-tab.cjs.entry.js +2 -2
  25. package/dist/cjs/scout-tabs.cjs.entry.js +3 -3
  26. package/dist/cjs/ui-webc.cjs.js +2 -2
  27. package/dist/collection/collection-manifest.json +3 -0
  28. package/dist/collection/components/app-bar/app-bar.css +5 -1
  29. package/dist/collection/components/avatar/assets/fallbackImage.png +0 -0
  30. package/dist/collection/components/avatar/avatar.css +7 -0
  31. package/dist/collection/components/avatar/avatar.js +88 -0
  32. package/dist/collection/components/bottom-bar/bottom-bar.css +7 -2
  33. package/dist/collection/components/bottom-bar-item/bottom-bar-item.css +16 -2
  34. package/dist/collection/components/drawer/drawer.css +157 -0
  35. package/dist/collection/components/drawer/drawer.js +323 -0
  36. package/dist/collection/components/list-view/list-view.css +7 -2
  37. package/dist/collection/components/list-view/list-view.js +6 -4
  38. package/dist/collection/components/list-view-item/list-view-item.css +16 -4
  39. package/dist/collection/components/segmented-control/segmented-control.css +68 -0
  40. package/dist/collection/components/segmented-control/segmented-control.js +185 -0
  41. package/dist/collection/components/select/select.js +1 -1
  42. package/dist/collection/components/stack/stack.js +2 -2
  43. package/dist/collection/components/switch/switch.js +1 -1
  44. package/dist/collection/components/tabs/tabs.js +2 -2
  45. package/dist/collection/components/tabs-tab/tabs-tab.js +1 -1
  46. package/dist/components/index.js +1 -1
  47. package/dist/components/p-7UFtpiQE.js +1 -0
  48. package/dist/components/p-CWxftSWo.js +1 -0
  49. package/dist/components/p-DLiFilsh.js +1 -0
  50. package/dist/components/{p-CYcNS38J.js → p-DYpc8Wxz.js} +1 -1
  51. package/dist/components/scout-app-bar.js +1 -1
  52. package/dist/components/scout-avatar.d.ts +11 -0
  53. package/dist/components/scout-avatar.js +1 -0
  54. package/dist/components/scout-bottom-bar-item.js +1 -1
  55. package/dist/components/scout-bottom-bar.js +1 -1
  56. package/dist/components/scout-button.js +1 -1
  57. package/dist/components/scout-card.js +1 -1
  58. package/dist/components/scout-checkbox.js +1 -1
  59. package/dist/components/scout-divider.js +1 -1
  60. package/dist/components/scout-drawer.d.ts +11 -0
  61. package/dist/components/scout-drawer.js +1 -0
  62. package/dist/components/scout-field.js +1 -1
  63. package/dist/components/scout-input.js +1 -1
  64. package/dist/components/scout-link.js +1 -1
  65. package/dist/components/scout-list-view-item.js +1 -1
  66. package/dist/components/scout-list-view-subheader.js +1 -1
  67. package/dist/components/scout-list-view.js +1 -1
  68. package/dist/components/scout-loader.js +1 -1
  69. package/dist/components/scout-radio-button.js +1 -1
  70. package/dist/components/scout-segmented-control.d.ts +11 -0
  71. package/dist/components/scout-segmented-control.js +1 -0
  72. package/dist/components/scout-select.js +1 -1
  73. package/dist/components/scout-stack.js +1 -1
  74. package/dist/components/scout-switch.js +1 -1
  75. package/dist/components/scout-tabs-tab.js +1 -1
  76. package/dist/components/scout-tabs.js +1 -1
  77. package/dist/custom-elements.json +475 -1
  78. package/dist/esm/{index-CBq_WkdR.js → index-BtN0bCWb.js} +35 -5
  79. package/dist/esm/{inputMixin-CArDsEiI.js → inputMixin-DC4hF1Lp.js} +1 -1
  80. package/dist/esm/loader.js +3 -3
  81. package/dist/esm/scout-app-bar.entry.js +2 -2
  82. package/dist/esm/scout-avatar.entry.js +37 -0
  83. package/dist/esm/scout-bottom-bar-item.entry.js +2 -2
  84. package/dist/esm/scout-bottom-bar.entry.js +2 -2
  85. package/dist/esm/scout-button.entry.js +1 -1
  86. package/dist/esm/scout-card.entry.js +1 -1
  87. package/dist/esm/scout-checkbox_2.entry.js +2 -2
  88. package/dist/esm/scout-divider.entry.js +1 -1
  89. package/dist/esm/scout-drawer.entry.js +839 -0
  90. package/dist/esm/scout-field.entry.js +1 -1
  91. package/dist/esm/scout-input.entry.js +2 -2
  92. package/dist/esm/scout-link.entry.js +1 -1
  93. package/dist/esm/scout-list-view-item.entry.js +2 -2
  94. package/dist/esm/scout-list-view-subheader.entry.js +1 -1
  95. package/dist/esm/scout-list-view.entry.js +7 -5
  96. package/dist/esm/scout-loader.entry.js +1 -1
  97. package/dist/esm/scout-segmented-control.entry.js +86 -0
  98. package/dist/esm/scout-select.entry.js +3 -3
  99. package/dist/esm/scout-stack.entry.js +3 -3
  100. package/dist/esm/scout-switch.entry.js +3 -3
  101. package/dist/esm/scout-tabs-tab.entry.js +2 -2
  102. package/dist/esm/scout-tabs.entry.js +3 -3
  103. package/dist/esm/ui-webc.js +3 -3
  104. package/dist/types/components/avatar/avatar.d.ts +16 -0
  105. package/dist/types/components/drawer/drawer.d.ts +53 -0
  106. package/dist/types/components/segmented-control/segmented-control.d.ts +40 -0
  107. package/dist/types/components/tabs/tabs.d.ts +1 -1
  108. package/dist/types/components.d.ts +252 -0
  109. package/dist/ui-webc/assets/fallbackImage.png +0 -0
  110. package/dist/ui-webc/p-0b313ae9.entry.js +1 -0
  111. package/dist/ui-webc/p-1c5b40f5.entry.js +1 -0
  112. package/dist/ui-webc/p-214dc4e4.entry.js +1 -0
  113. package/dist/ui-webc/{p-a153023c.entry.js → p-2d773911.entry.js} +1 -1
  114. package/dist/ui-webc/{p-c0696c1f.entry.js → p-4d676928.entry.js} +1 -1
  115. package/dist/ui-webc/p-4d905b20.entry.js +1 -0
  116. package/dist/ui-webc/{p-f8a4ef3d.entry.js → p-5b0e6de5.entry.js} +1 -1
  117. package/dist/ui-webc/p-6bd3258b.entry.js +1 -0
  118. package/dist/ui-webc/p-6fea31a0.entry.js +1 -0
  119. package/dist/ui-webc/{p-6287efe7.entry.js → p-70c0acea.entry.js} +1 -1
  120. package/dist/ui-webc/p-74bd1d24.entry.js +1 -0
  121. package/dist/ui-webc/{p-0e444b1f.entry.js → p-8c81f27f.entry.js} +1 -1
  122. package/dist/ui-webc/{p-ff537388.entry.js → p-9c8d24b2.entry.js} +1 -1
  123. package/dist/ui-webc/p-9e3739c6.entry.js +1 -0
  124. package/dist/ui-webc/p-BtN0bCWb.js +2 -0
  125. package/dist/ui-webc/{p-6xDaXBJm.js → p-DMdnqqlQ.js} +1 -1
  126. package/dist/ui-webc/{p-b699617e.entry.js → p-a26bd0db.entry.js} +1 -1
  127. package/dist/ui-webc/{p-a2c09e05.entry.js → p-cec7a021.entry.js} +1 -1
  128. package/dist/ui-webc/p-d0fc1cd6.entry.js +1 -0
  129. package/dist/ui-webc/p-d76c67a5.entry.js +1 -0
  130. package/dist/ui-webc/{p-8f5965aa.entry.js → p-d88cbd78.entry.js} +1 -1
  131. package/dist/ui-webc/{p-f8099e5b.entry.js → p-db109100.entry.js} +1 -1
  132. package/dist/ui-webc/{p-6825e415.entry.js → p-ee796725.entry.js} +1 -1
  133. package/dist/ui-webc/{p-189879c2.entry.js → p-f1fb33e9.entry.js} +1 -1
  134. package/dist/ui-webc/ui-webc.css +2 -2
  135. package/dist/ui-webc/ui-webc.esm.js +1 -1
  136. package/package.json +3 -2
  137. package/dist/components/p-CXXyN7aY.js +0 -1
  138. package/dist/components/p-CpD1flSg.js +0 -1
  139. package/dist/components/p-a16hBieR.js +0 -1
  140. package/dist/ui-webc/p-60cd6c7e.entry.js +0 -1
  141. package/dist/ui-webc/p-78126f74.entry.js +0 -1
  142. package/dist/ui-webc/p-CBq_WkdR.js +0 -2
  143. package/dist/ui-webc/p-c4f7cfa2.entry.js +0 -1
  144. package/dist/ui-webc/p-cdc127de.entry.js +0 -1
  145. package/dist/ui-webc/p-db40c987.entry.js +0 -1
  146. package/dist/ui-webc/p-f799b2d8.entry.js +0 -1
  147. package/dist/ui-webc/p-fe2020a1.entry.js +0 -1
@@ -0,0 +1,841 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-Vd3hlPvW.js');
4
+
5
+ /**
6
+ * defines a focus group
7
+ */
8
+ var FOCUS_GROUP = 'data-focus-lock';
9
+ /**
10
+ * disables element discovery inside a group marked by key
11
+ */
12
+ var FOCUS_DISABLED = 'data-focus-lock-disabled';
13
+ /**
14
+ * allows uncontrolled focus within the marked area, effectively disabling focus lock for it's content
15
+ */
16
+ var FOCUS_ALLOW = 'data-no-focus-lock';
17
+ /**
18
+ * instructs autofocus engine to pick default autofocus inside a given node
19
+ * can be set on the element or container
20
+ */
21
+ var FOCUS_AUTO = 'data-autofocus-inside';
22
+ /**
23
+ * instructs autofocus to ignore elements within a given node
24
+ * can be set on the element or container
25
+ */
26
+ var FOCUS_NO_AUTOFOCUS = 'data-no-autofocus';
27
+
28
+ /*
29
+ IE11 support
30
+ */
31
+ var toArray = function (a) {
32
+ var ret = Array(a.length);
33
+ for (var i = 0; i < a.length; ++i) {
34
+ ret[i] = a[i];
35
+ }
36
+ return ret;
37
+ };
38
+ var asArray = function (a) { return (Array.isArray(a) ? a : [a]); };
39
+ var getFirst = function (a) { return (Array.isArray(a) ? a[0] : a); };
40
+
41
+ var isElementHidden = function (node) {
42
+ // we can measure only "elements"
43
+ // consider others as "visible"
44
+ if (node.nodeType !== Node.ELEMENT_NODE) {
45
+ return false;
46
+ }
47
+ var computedStyle = window.getComputedStyle(node, null);
48
+ if (!computedStyle || !computedStyle.getPropertyValue) {
49
+ return false;
50
+ }
51
+ return (computedStyle.getPropertyValue('display') === 'none' || computedStyle.getPropertyValue('visibility') === 'hidden');
52
+ };
53
+ var getParentNode = function (node) {
54
+ // DOCUMENT_FRAGMENT_NODE can also point on ShadowRoot. In this case .host will point on the next node
55
+ return node.parentNode && node.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE
56
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
+ node.parentNode.host
58
+ : node.parentNode;
59
+ };
60
+ var isTopNode = function (node) {
61
+ // @ts-ignore
62
+ return node === document || (node && node.nodeType === Node.DOCUMENT_NODE);
63
+ };
64
+ var isVisibleUncached = function (node, checkParent) {
65
+ return !node || isTopNode(node) || (!isElementHidden(node) && checkParent(getParentNode(node)));
66
+ };
67
+ var isVisibleCached = function (visibilityCache, node) {
68
+ var cached = visibilityCache.get(node);
69
+ if (cached !== undefined) {
70
+ return cached;
71
+ }
72
+ var result = isVisibleUncached(node, isVisibleCached.bind(undefined, visibilityCache));
73
+ visibilityCache.set(node, result);
74
+ return result;
75
+ };
76
+ var isAutoFocusAllowedUncached = function (node, checkParent) {
77
+ return node && !isTopNode(node) ? (isAutoFocusAllowed(node) ? checkParent(getParentNode(node)) : false) : true;
78
+ };
79
+ var isAutoFocusAllowedCached = function (cache, node) {
80
+ var cached = cache.get(node);
81
+ if (cached !== undefined) {
82
+ return cached;
83
+ }
84
+ var result = isAutoFocusAllowedUncached(node, isAutoFocusAllowedCached.bind(undefined, cache));
85
+ cache.set(node, result);
86
+ return result;
87
+ };
88
+ var getDataset = function (node) {
89
+ // @ts-ignore
90
+ return node.dataset;
91
+ };
92
+ var isHTMLButtonElement = function (node) { return node.tagName === 'BUTTON'; };
93
+ var isHTMLInputElement = function (node) { return node.tagName === 'INPUT'; };
94
+ var isRadioElement = function (node) {
95
+ return isHTMLInputElement(node) && node.type === 'radio';
96
+ };
97
+ var notHiddenInput = function (node) {
98
+ return !((isHTMLInputElement(node) || isHTMLButtonElement(node)) && (node.type === 'hidden' || node.disabled));
99
+ };
100
+ var isAutoFocusAllowed = function (node) {
101
+ var attribute = node.getAttribute(FOCUS_NO_AUTOFOCUS);
102
+ return ![true, 'true', ''].includes(attribute);
103
+ };
104
+ var isGuard = function (node) { var _a; return Boolean(node && ((_a = getDataset(node)) === null || _a === void 0 ? void 0 : _a.focusGuard)); };
105
+ var isNotAGuard = function (node) { return !isGuard(node); };
106
+ var isDefined = function (x) { return Boolean(x); };
107
+
108
+ var tabSort = function (a, b) {
109
+ var tabDiff = a.tabIndex - b.tabIndex;
110
+ var indexDiff = a.index - b.index;
111
+ if (tabDiff) {
112
+ if (!a.tabIndex) {
113
+ return 1;
114
+ }
115
+ if (!b.tabIndex) {
116
+ return -1;
117
+ }
118
+ }
119
+ return tabDiff || indexDiff;
120
+ };
121
+ var orderByTabIndex = function (nodes, filterNegative, keepGuards) {
122
+ return toArray(nodes)
123
+ .map(function (node, index) { return ({
124
+ node: node,
125
+ index: index,
126
+ tabIndex: node.tabIndex,
127
+ }); })
128
+ .filter(function (data) { return !filterNegative || data.tabIndex >= 0; })
129
+ .sort(tabSort);
130
+ };
131
+
132
+ /**
133
+ * list of the object to be considered as focusable
134
+ */
135
+ var tabbables = [
136
+ 'button:enabled',
137
+ 'select:enabled',
138
+ 'textarea:enabled',
139
+ 'input:enabled',
140
+ // elements with explicit roles will also use explicit tabindex
141
+ // '[role="button"]',
142
+ 'a[href]',
143
+ 'area[href]',
144
+ 'summary',
145
+ 'iframe',
146
+ 'object',
147
+ 'embed',
148
+ 'audio[controls]',
149
+ 'video[controls]',
150
+ '[tabindex]',
151
+ '[contenteditable]',
152
+ '[autofocus]',
153
+ ];
154
+
155
+ var queryTabbables = tabbables.join(',');
156
+ var getFocusablesWithShadowDom = function (parent, withGuards) {
157
+ return toArray((parent.shadowRoot || parent).children).reduce(function (acc, child) {
158
+ return acc.concat(child.matches(queryTabbables) ? [child] : [], getFocusablesWithShadowDom(child));
159
+ }, []);
160
+ };
161
+ var getFocusablesWithIFrame = function (parent, withGuards) {
162
+ var _a;
163
+ // contentDocument of iframe will be null if current origin cannot access it
164
+ if (parent instanceof HTMLIFrameElement && ((_a = parent.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) {
165
+ return getFocusables([parent.contentDocument.body]);
166
+ }
167
+ return [parent];
168
+ };
169
+ var getFocusables = function (parents, withGuards) {
170
+ return parents.reduce(function (acc, parent) {
171
+ var _a;
172
+ var focusableWithShadowDom = getFocusablesWithShadowDom(parent);
173
+ var focusableWithIframes = (_a = []).concat.apply(_a, focusableWithShadowDom.map(function (node) { return getFocusablesWithIFrame(node); }));
174
+ return acc.concat(
175
+ // add all tabbables inside and within shadow DOMs in DOM order
176
+ focusableWithIframes,
177
+ // add if node is tabbable itself
178
+ parent.parentNode
179
+ ? toArray(parent.parentNode.querySelectorAll(queryTabbables)).filter(function (node) { return node === parent; })
180
+ : []);
181
+ }, []);
182
+ };
183
+ /**
184
+ * return a list of focusable nodes within an area marked as "auto-focusable"
185
+ * @param parent
186
+ */
187
+ var getParentAutofocusables = function (parent) {
188
+ var parentFocus = parent.querySelectorAll("[".concat(FOCUS_AUTO, "]"));
189
+ return toArray(parentFocus)
190
+ .map(function (node) { return getFocusables([node]); })
191
+ .reduce(function (acc, nodes) { return acc.concat(nodes); }, []);
192
+ };
193
+
194
+ /**
195
+ * given list of focusable elements keeps the ones user can interact with
196
+ * @param nodes
197
+ * @param visibilityCache
198
+ */
199
+ var filterFocusable = function (nodes, visibilityCache) {
200
+ return toArray(nodes)
201
+ .filter(function (node) { return isVisibleCached(visibilityCache, node); })
202
+ .filter(function (node) { return notHiddenInput(node); });
203
+ };
204
+ var filterAutoFocusable = function (nodes, cache) {
205
+ if (cache === void 0) { cache = new Map(); }
206
+ return toArray(nodes).filter(function (node) { return isAutoFocusAllowedCached(cache, node); });
207
+ };
208
+ /**
209
+ * only tabbable ones
210
+ * (but with guards which would be ignored)
211
+ */
212
+ var getTabbableNodes = function (topNodes, visibilityCache, withGuards) {
213
+ return orderByTabIndex(filterFocusable(getFocusables(topNodes), visibilityCache), true);
214
+ };
215
+ /**
216
+ * actually anything "focusable", not only tabbable
217
+ * (without guards, as long as they are not expected to be focused)
218
+ */
219
+ var getAllTabbableNodes = function (topNodes, visibilityCache) {
220
+ return orderByTabIndex(filterFocusable(getFocusables(topNodes), visibilityCache), false);
221
+ };
222
+ /**
223
+ * return list of nodes which are expected to be auto-focused
224
+ * @param topNode
225
+ * @param visibilityCache
226
+ */
227
+ var parentAutofocusables = function (topNode, visibilityCache) {
228
+ return filterFocusable(getParentAutofocusables(topNode), visibilityCache);
229
+ };
230
+ /*
231
+ * Determines if element is contained in scope, including nested shadow DOMs
232
+ */
233
+ var contains = function (scope, element) {
234
+ if (scope.shadowRoot) {
235
+ return contains(scope.shadowRoot, element);
236
+ }
237
+ else {
238
+ if (Object.getPrototypeOf(scope).contains !== undefined &&
239
+ Object.getPrototypeOf(scope).contains.call(scope, element)) {
240
+ return true;
241
+ }
242
+ return toArray(scope.children).some(function (child) {
243
+ var _a;
244
+ if (child instanceof HTMLIFrameElement) {
245
+ var iframeBody = (_a = child.contentDocument) === null || _a === void 0 ? void 0 : _a.body;
246
+ if (iframeBody) {
247
+ return contains(iframeBody, element);
248
+ }
249
+ return false;
250
+ }
251
+ return contains(child, element);
252
+ });
253
+ }
254
+ };
255
+
256
+ /**
257
+ * in case of multiple nodes nested inside each other
258
+ * keeps only top ones
259
+ * this is O(nlogn)
260
+ * @param nodes
261
+ * @returns {*}
262
+ */
263
+ var filterNested = function (nodes) {
264
+ var contained = new Set();
265
+ var l = nodes.length;
266
+ for (var i = 0; i < l; i += 1) {
267
+ for (var j = i + 1; j < l; j += 1) {
268
+ var position = nodes[i].compareDocumentPosition(nodes[j]);
269
+ /* eslint-disable no-bitwise */
270
+ if ((position & Node.DOCUMENT_POSITION_CONTAINED_BY) > 0) {
271
+ contained.add(j);
272
+ }
273
+ if ((position & Node.DOCUMENT_POSITION_CONTAINS) > 0) {
274
+ contained.add(i);
275
+ }
276
+ /* eslint-enable */
277
+ }
278
+ }
279
+ return nodes.filter(function (_, index) { return !contained.has(index); });
280
+ };
281
+ /**
282
+ * finds top most parent for a node
283
+ * @param node
284
+ * @returns {*}
285
+ */
286
+ var getTopParent = function (node) {
287
+ return node.parentNode ? getTopParent(node.parentNode) : node;
288
+ };
289
+ /**
290
+ * returns all "focus containers" inside a given node
291
+ * @param node
292
+ * @returns {T}
293
+ */
294
+ var getAllAffectedNodes = function (node) {
295
+ var nodes = asArray(node);
296
+ return nodes.filter(Boolean).reduce(function (acc, currentNode) {
297
+ var group = currentNode.getAttribute(FOCUS_GROUP);
298
+ acc.push.apply(acc, (group
299
+ ? filterNested(toArray(getTopParent(currentNode).querySelectorAll("[".concat(FOCUS_GROUP, "=\"").concat(group, "\"]:not([").concat(FOCUS_DISABLED, "=\"disabled\"])"))))
300
+ : [currentNode]));
301
+ return acc;
302
+ }, []);
303
+ };
304
+
305
+ var safeProbe = function (cb) {
306
+ try {
307
+ return cb();
308
+ }
309
+ catch (e) {
310
+ return undefined;
311
+ }
312
+ };
313
+
314
+ /**
315
+ * returns active element from document or from nested shadowdoms
316
+ */
317
+ var getActiveElement = function (inDocument) {
318
+ if (inDocument === void 0) { inDocument = document; }
319
+ if (!inDocument || !inDocument.activeElement) {
320
+ return undefined;
321
+ }
322
+ var activeElement = inDocument.activeElement;
323
+ return (activeElement.shadowRoot
324
+ ? getActiveElement(activeElement.shadowRoot)
325
+ : activeElement instanceof HTMLIFrameElement && safeProbe(function () { return activeElement.contentWindow.document; })
326
+ ? getActiveElement(activeElement.contentWindow.document)
327
+ : activeElement);
328
+ };
329
+
330
+ var focusInFrame = function (frame, activeElement) { return frame === activeElement; };
331
+ var focusInsideIframe = function (topNode, activeElement) {
332
+ return Boolean(toArray(topNode.querySelectorAll('iframe')).some(function (node) { return focusInFrame(node, activeElement); }));
333
+ };
334
+ /**
335
+ * @returns {Boolean} true, if the current focus is inside given node or nodes
336
+ */
337
+ var focusInside = function (topNode, activeElement) {
338
+ // const activeElement = document && getActiveElement();
339
+ if (activeElement === void 0) { activeElement = getActiveElement(getFirst(topNode).ownerDocument); }
340
+ if (!activeElement || (activeElement.dataset && activeElement.dataset.focusGuard)) {
341
+ return false;
342
+ }
343
+ return getAllAffectedNodes(topNode).some(function (node) {
344
+ return contains(node, activeElement) || focusInsideIframe(node, activeElement);
345
+ });
346
+ };
347
+
348
+ /**
349
+ * focus is hidden FROM the focus-lock
350
+ * ie contained inside a node focus-lock shall ignore
351
+ * @returns {boolean} focus is currently is in "allow" area
352
+ */
353
+ var focusIsHidden = function (inDocument) {
354
+ if (inDocument === void 0) { inDocument = document; }
355
+ var activeElement = getActiveElement(inDocument);
356
+ if (!activeElement) {
357
+ return false;
358
+ }
359
+ // this does not support setting FOCUS_ALLOW within shadow dom
360
+ return toArray(inDocument.querySelectorAll("[".concat(FOCUS_ALLOW, "]"))).some(function (node) { return contains(node, activeElement); });
361
+ };
362
+
363
+ var findSelectedRadio = function (node, nodes) {
364
+ return nodes
365
+ .filter(isRadioElement)
366
+ .filter(function (el) { return el.name === node.name; })
367
+ .filter(function (el) { return el.checked; })[0] || node;
368
+ };
369
+ var correctNode = function (node, nodes) {
370
+ if (isRadioElement(node) && node.name) {
371
+ return findSelectedRadio(node, nodes);
372
+ }
373
+ return node;
374
+ };
375
+ /**
376
+ * giving a set of radio inputs keeps only selected (tabbable) ones
377
+ * @param nodes
378
+ */
379
+ var correctNodes = function (nodes) {
380
+ // IE11 has no Set(array) constructor
381
+ var resultSet = new Set();
382
+ nodes.forEach(function (node) { return resultSet.add(correctNode(node, nodes)); });
383
+ // using filter to support IE11
384
+ return nodes.filter(function (node) { return resultSet.has(node); });
385
+ };
386
+
387
+ var pickFirstFocus = function (nodes) {
388
+ if (nodes[0] && nodes.length > 1) {
389
+ return correctNode(nodes[0], nodes);
390
+ }
391
+ return nodes[0];
392
+ };
393
+ var pickFocusable = function (nodes, index) {
394
+ if (nodes.length > 1) {
395
+ return nodes.indexOf(correctNode(nodes[index], nodes));
396
+ }
397
+ return index;
398
+ };
399
+
400
+ var NEW_FOCUS = 'NEW_FOCUS';
401
+ /**
402
+ * Main solver for the "find next focus" question
403
+ * @param innerNodes
404
+ * @param outerNodes
405
+ * @param activeElement
406
+ * @param lastNode
407
+ * @returns {number|string|undefined|*}
408
+ */
409
+ var newFocus = function (innerNodes, outerNodes, activeElement, lastNode) {
410
+ var cnt = innerNodes.length;
411
+ var firstFocus = innerNodes[0];
412
+ var lastFocus = innerNodes[cnt - 1];
413
+ var isOnGuard = isGuard(activeElement);
414
+ // focus is inside
415
+ if (activeElement && innerNodes.indexOf(activeElement) >= 0) {
416
+ return undefined;
417
+ }
418
+ var activeIndex = activeElement !== undefined ? outerNodes.indexOf(activeElement) : -1;
419
+ var lastIndex = lastNode ? outerNodes.indexOf(lastNode) : activeIndex;
420
+ var lastNodeInside = lastNode ? innerNodes.indexOf(lastNode) : -1;
421
+ var indexDiff = activeIndex - lastIndex;
422
+ var firstNodeIndex = outerNodes.indexOf(firstFocus);
423
+ var lastNodeIndex = outerNodes.indexOf(lastFocus);
424
+ var correctedNodes = correctNodes(outerNodes);
425
+ var correctedIndex = activeElement !== undefined ? correctedNodes.indexOf(activeElement) : -1;
426
+ var correctedIndexDiff = correctedIndex - (lastNode ? correctedNodes.indexOf(lastNode) : activeIndex);
427
+ var returnFirstNode = pickFocusable(innerNodes, 0);
428
+ var returnLastNode = pickFocusable(innerNodes, cnt - 1);
429
+ // new focus
430
+ if (activeIndex === -1 || lastNodeInside === -1) {
431
+ return NEW_FOCUS;
432
+ }
433
+ // old focus
434
+ if (!indexDiff && lastNodeInside >= 0) {
435
+ return lastNodeInside;
436
+ }
437
+ // first element
438
+ if (activeIndex <= firstNodeIndex && isOnGuard && Math.abs(indexDiff) > 1) {
439
+ return returnLastNode;
440
+ }
441
+ // last element
442
+ if (activeIndex >= lastNodeIndex && isOnGuard && Math.abs(indexDiff) > 1) {
443
+ return returnFirstNode;
444
+ }
445
+ // jump out, but not on the guard
446
+ if (indexDiff && Math.abs(correctedIndexDiff) > 1) {
447
+ return lastNodeInside;
448
+ }
449
+ // focus above lock
450
+ if (activeIndex <= firstNodeIndex) {
451
+ return returnLastNode;
452
+ }
453
+ // focus below lock
454
+ if (activeIndex > lastNodeIndex) {
455
+ return returnFirstNode;
456
+ }
457
+ // index is inside tab order, but outside Lock
458
+ if (indexDiff) {
459
+ if (Math.abs(indexDiff) > 1) {
460
+ return lastNodeInside;
461
+ }
462
+ return (cnt + lastNodeInside + indexDiff) % cnt;
463
+ }
464
+ // do nothing
465
+ return undefined;
466
+ };
467
+
468
+ var findAutoFocused = function (autoFocusables) {
469
+ return function (node) {
470
+ var _a;
471
+ var autofocus = (_a = getDataset(node)) === null || _a === void 0 ? void 0 : _a.autofocus;
472
+ return (
473
+ // @ts-expect-error
474
+ node.autofocus ||
475
+ //
476
+ (autofocus !== undefined && autofocus !== 'false') ||
477
+ //
478
+ autoFocusables.indexOf(node) >= 0);
479
+ };
480
+ };
481
+ var pickAutofocus = function (nodesIndexes, orderedNodes, groups) {
482
+ var nodes = nodesIndexes.map(function (_a) {
483
+ var node = _a.node;
484
+ return node;
485
+ });
486
+ var autoFocusable = filterAutoFocusable(nodes.filter(findAutoFocused(groups)));
487
+ if (autoFocusable && autoFocusable.length) {
488
+ return pickFirstFocus(autoFocusable);
489
+ }
490
+ return pickFirstFocus(filterAutoFocusable(orderedNodes));
491
+ };
492
+
493
+ var getParents = function (node, parents) {
494
+ if (parents === void 0) { parents = []; }
495
+ parents.push(node);
496
+ if (node.parentNode) {
497
+ getParents(node.parentNode.host || node.parentNode, parents);
498
+ }
499
+ return parents;
500
+ };
501
+ /**
502
+ * finds a parent for both nodeA and nodeB
503
+ * @param nodeA
504
+ * @param nodeB
505
+ * @returns {boolean|*}
506
+ */
507
+ var getCommonParent = function (nodeA, nodeB) {
508
+ var parentsA = getParents(nodeA);
509
+ var parentsB = getParents(nodeB);
510
+ // tslint:disable-next-line:prefer-for-of
511
+ for (var i = 0; i < parentsA.length; i += 1) {
512
+ var currentParent = parentsA[i];
513
+ if (parentsB.indexOf(currentParent) >= 0) {
514
+ return currentParent;
515
+ }
516
+ }
517
+ return false;
518
+ };
519
+ var getTopCommonParent = function (baseActiveElement, leftEntry, rightEntries) {
520
+ var activeElements = asArray(baseActiveElement);
521
+ var leftEntries = asArray(leftEntry);
522
+ var activeElement = activeElements[0];
523
+ var topCommon = false;
524
+ leftEntries.filter(Boolean).forEach(function (entry) {
525
+ topCommon = getCommonParent(topCommon || entry, entry) || topCommon;
526
+ rightEntries.filter(Boolean).forEach(function (subEntry) {
527
+ var common = getCommonParent(activeElement, subEntry);
528
+ if (common) {
529
+ if (!topCommon || contains(common, topCommon)) {
530
+ topCommon = common;
531
+ }
532
+ else {
533
+ topCommon = getCommonParent(common, topCommon);
534
+ }
535
+ }
536
+ });
537
+ });
538
+ // TODO: add assert here?
539
+ return topCommon;
540
+ };
541
+ /**
542
+ * return list of nodes which are expected to be autofocused inside a given top nodes
543
+ * @param entries
544
+ * @param visibilityCache
545
+ */
546
+ var allParentAutofocusables = function (entries, visibilityCache) {
547
+ return entries.reduce(function (acc, node) { return acc.concat(parentAutofocusables(node, visibilityCache)); }, []);
548
+ };
549
+
550
+ var reorderNodes = function (srcNodes, dstNodes) {
551
+ var remap = new Map();
552
+ // no Set(dstNodes) for IE11 :(
553
+ dstNodes.forEach(function (entity) { return remap.set(entity.node, entity); });
554
+ // remap to dstNodes
555
+ return srcNodes.map(function (node) { return remap.get(node); }).filter(isDefined);
556
+ };
557
+ /**
558
+ * given top node(s) and the last active element return the element to be focused next
559
+ * @param topNode
560
+ * @param lastNode
561
+ */
562
+ var getFocusMerge = function (topNode, lastNode) {
563
+ var activeElement = getActiveElement(asArray(topNode).length > 0 ? document : getFirst(topNode).ownerDocument);
564
+ var entries = getAllAffectedNodes(topNode).filter(isNotAGuard);
565
+ var commonParent = getTopCommonParent(activeElement || topNode, topNode, entries);
566
+ var visibilityCache = new Map();
567
+ var anyFocusable = getAllTabbableNodes(entries, visibilityCache);
568
+ var innerElements = getTabbableNodes(entries, visibilityCache).filter(function (_a) {
569
+ var node = _a.node;
570
+ return isNotAGuard(node);
571
+ });
572
+ if (!innerElements[0]) {
573
+ innerElements = anyFocusable;
574
+ if (!innerElements[0]) {
575
+ return undefined;
576
+ }
577
+ }
578
+ var outerNodes = getAllTabbableNodes([commonParent], visibilityCache).map(function (_a) {
579
+ var node = _a.node;
580
+ return node;
581
+ });
582
+ var orderedInnerElements = reorderNodes(outerNodes, innerElements);
583
+ var innerNodes = orderedInnerElements.map(function (_a) {
584
+ var node = _a.node;
585
+ return node;
586
+ });
587
+ var newId = newFocus(innerNodes, outerNodes, activeElement, lastNode);
588
+ if (newId === NEW_FOCUS) {
589
+ var focusNode = pickAutofocus(anyFocusable, innerNodes, allParentAutofocusables(entries, visibilityCache));
590
+ if (focusNode) {
591
+ return { node: focusNode };
592
+ }
593
+ else {
594
+ console.warn('focus-lock: cannot find any node to move focus into');
595
+ return undefined;
596
+ }
597
+ }
598
+ if (newId === undefined) {
599
+ return newId;
600
+ }
601
+ return orderedInnerElements[newId];
602
+ };
603
+
604
+ var focusOn = function (target, focusOptions) {
605
+ if ('focus' in target) {
606
+ target.focus(focusOptions);
607
+ }
608
+ if ('contentWindow' in target && target.contentWindow) {
609
+ target.contentWindow.focus();
610
+ }
611
+ };
612
+ var guardCount = 0;
613
+ var lockDisabled = false;
614
+ /**
615
+ * Sets focus at a given node. The last focused element will help to determine which element(first or last) should be focused.
616
+ * HTML markers (see {@link import('./constants').FOCUS_AUTO} constants) can control autofocus
617
+ * @param topNode
618
+ * @param lastNode
619
+ * @param options
620
+ */
621
+ var setFocus = function (topNode, lastNode, options) {
622
+ if (options === void 0) { options = {}; }
623
+ var focusable = getFocusMerge(topNode, lastNode);
624
+ if (lockDisabled) {
625
+ return;
626
+ }
627
+ if (focusable) {
628
+ if (guardCount > 2) {
629
+ // tslint:disable-next-line:no-console
630
+ console.error('FocusLock: focus-fighting detected. Only one focus management system could be active. ' +
631
+ 'See https://github.com/theKashey/focus-lock/#focus-fighting');
632
+ lockDisabled = true;
633
+ setTimeout(function () {
634
+ lockDisabled = false;
635
+ }, 1);
636
+ return;
637
+ }
638
+ guardCount++;
639
+ focusOn(focusable.node, options.focusOptions);
640
+ guardCount--;
641
+ }
642
+ };
643
+
644
+ var lastActiveTrap = 0;
645
+ var lastActiveFocus = null;
646
+
647
+ var focusOnBody = function focusOnBody() {
648
+ return document && document.activeElement === document.body;
649
+ };
650
+
651
+ var isFreeFocus = function isFreeFocus() {
652
+ return focusOnBody() || focusIsHidden();
653
+ };
654
+
655
+ var activateTrap = function activateTrap() {
656
+ var result = false;
657
+
658
+ if (lastActiveTrap) {
659
+ var observed = lastActiveTrap;
660
+
661
+ if (!isFreeFocus()) {
662
+ if (observed && !focusInside(observed)) {
663
+ result = setFocus(observed, lastActiveFocus);
664
+ }
665
+
666
+ lastActiveFocus = document.activeElement;
667
+ }
668
+ }
669
+
670
+ return result;
671
+ };
672
+
673
+ var reducePropsToState = function reducePropsToState(propsList) {
674
+ return propsList.filter(function (node) {
675
+ return node;
676
+ }).slice(-1)[0];
677
+ };
678
+
679
+ var handleStateChangeOnClient = function handleStateChangeOnClient(trap) {
680
+ lastActiveTrap = trap;
681
+
682
+ if (trap) {
683
+ activateTrap();
684
+ }
685
+ };
686
+
687
+ var instances = [];
688
+
689
+ var emitChange = function emitChange(event) {
690
+ if (handleStateChangeOnClient(reducePropsToState(instances))) {
691
+ event && event.preventDefault();
692
+ return true;
693
+ }
694
+
695
+ return false;
696
+ };
697
+
698
+ var attachHandler = function attachHandler() {
699
+ document.addEventListener('focusin', emitChange);
700
+ };
701
+
702
+ var detachHandler = function detachHandler() {
703
+ document.removeEventListener('focusin', emitChange);
704
+ };
705
+
706
+ var focusLock = {
707
+ on: function on(domNode) {
708
+ if (instances.length === 0) {
709
+ attachHandler();
710
+ }
711
+
712
+ if (instances.indexOf(domNode) < 0) {
713
+ instances.push(domNode);
714
+ emitChange();
715
+ }
716
+ },
717
+ off: function off(domNode) {
718
+ instances = instances.filter(function (node) {
719
+ return node !== domNode;
720
+ });
721
+ emitChange();
722
+
723
+ if (instances.length === 0) {
724
+ detachHandler();
725
+ }
726
+ }
727
+ };
728
+
729
+ const drawerCss = () => `.drawer{width:100%}.drawer--container{position:fixed;bottom:0;right:0;left:0;height:90%;width:100%;transform:translateY(100%);background-color:#fefefe;box-shadow:0 0 20px 3px var(--color-gray-200);border-top-left-radius:var(--spacing-5);border-top-right-radius:var(--spacing-5);overflow:hidden;margin:0;z-index:101}@keyframes drawerOpen{from{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes drawerClose{from{transform:translateY(0)}to{transform:translateY(100%)}}.open{animation:drawerOpen 0.3s ease-in-out forwards}.close{animation:drawerClose 0.3s ease-in-out forwards}@media screen and (min-width: 901px){@keyframes drawerOpen{from{transform:translateX(100%)}to{transform:translateX(0)}}@keyframes drawerClose{from{transform:translateX(0)}to{transform:translateX(100%)}}.drawer--container{top:0;bottom:0;right:0;left:auto;left:initial;height:100%;max-height:100%;max-width:90%;min-height:600px;width:430px;transform:translateX(100%);border-top-left-radius:var(--spacing-5);border-bottom-left-radius:var(--spacing-5);border-top-right-radius:0}.open{animation:drawerOpen 0.3s ease-in-out forwards}.close{animation:drawerClose 0.3s ease-in-out forwards}}.backdrop{position:fixed;top:0;bottom:0;left:0;right:0;transition:opacity 0.2s;z-index:100}.backdrop-hidden{opacity:0}.backdrop-visible{opacity:0.6;pointer-events:all;background-color:var(--color-gray-200)}.header--wrapper{display:flex;position:relative;width:100%;height:var(--spacing-20);flex-direction:row;justify-content:center;align-items:center}.heading{font:var(--type-body-lg);font-weight:600;color:var(--color-text-base)}.content--wrapper{padding:0 var(--spacing-7)}button{z-index:2;pointer-events:all;cursor:pointer;background:none;box-shadow:none;position:absolute;border:none;width:24px;height:24px;padding:24px;display:flex;align-items:center;justify-content:center}.exit-button{right:var(--spacing-3)}.back-button{left:var(--spacing-3)}.visually-hidden{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}`;
730
+
731
+ const backIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-arrow-left"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l14 0" /><path d="M5 12l6 6" /><path d="M5 12l6 -6" /></svg>';
732
+ const exitIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-x"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M18 6l-12 12" /><path d="M6 6l12 12" /></svg>';
733
+ const ScoutDrawer = class {
734
+ constructor(hostRef) {
735
+ index.registerInstance(this, hostRef);
736
+ this.backButtonClicked = index.createEvent(this, "backButtonClicked");
737
+ this.exitButtonClicked = index.createEvent(this, "exitButtonClicked");
738
+ }
739
+ get rootElement() { return index.getElement(this); }
740
+ /**
741
+ * Open/close state of the drawer.
742
+ */
743
+ open = false;
744
+ /**
745
+ * Heading within the sheet.
746
+ */
747
+ heading = "";
748
+ /**
749
+ * Render back button.
750
+ */
751
+ showBackButton = false;
752
+ /**
753
+ * Back button label.
754
+ */
755
+ backButtonLabel = "";
756
+ /**
757
+ * Render exit button.
758
+ */
759
+ showExitButton = false;
760
+ /**
761
+ * Exit button label.
762
+ */
763
+ exitButtonLabel = "";
764
+ /**
765
+ * Disable backdrop for the drawer.
766
+ */
767
+ disableBackdrop = false;
768
+ /**
769
+ * Disable drawer content padding. Use only if you have specific use case and you need to use full width.
770
+ */
771
+ disableContentPadding = false;
772
+ drawerState = "closed";
773
+ focusedNode = null;
774
+ componentWillLoad() {
775
+ this.focusedNode = document.activeElement;
776
+ }
777
+ componentDidLoad() {
778
+ if (this.open) {
779
+ this.setDrawerOpenState(true);
780
+ }
781
+ }
782
+ disconnectedCallback() {
783
+ }
784
+ /**
785
+ * Fired when clicking backButton (<-)
786
+ */
787
+ backButtonClicked;
788
+ /**
789
+ * Fired when clicking backButton (X). Also sent when clicking the backdrop.
790
+ */
791
+ exitButtonClicked;
792
+ onBackButtonClick() {
793
+ this.backButtonClicked.emit();
794
+ }
795
+ onExitButtonClick() {
796
+ this.exitButtonClicked.emit();
797
+ }
798
+ setDrawerOpenState(open) {
799
+ const drawer = this.rootElement.shadowRoot.querySelector(".drawer--container");
800
+ if (!drawer) {
801
+ this.drawerState = open ? "opening" : "closing";
802
+ }
803
+ if (open) {
804
+ this.drawerState = "opening";
805
+ focusLock.on(drawer);
806
+ }
807
+ else {
808
+ focusLock.off(drawer);
809
+ this.drawerState = "closing";
810
+ }
811
+ }
812
+ render() {
813
+ const shouldRenderHeader = this.heading || this.showBackButton || this.showExitButton;
814
+ const getDrawerStateClass = (state) => {
815
+ switch (state) {
816
+ case "opening":
817
+ case "open":
818
+ return "open";
819
+ case "closing":
820
+ return "close";
821
+ }
822
+ };
823
+ return (index.h("div", { class: "drawer" }, !this.disableBackdrop && (
824
+ // biome-ignore lint/a11y/noStaticElementInteractions: <closable backdrop>
825
+ // biome-ignore lint/a11y/useKeyWithClickEvents: <closable backdrop>
826
+ index.h("div", { onClick: () => {
827
+ this.onExitButtonClick();
828
+ }, class: `backdrop ${this.drawerState !== "closed" ? "backdrop-visible" : "backdrop-hidden"}` })), index.h("div", { class: `drawer--container ${getDrawerStateClass(this.drawerState)}`, onAnimationEnd: () => {
829
+ this.drawerState = this.open ? "open" : "closed";
830
+ } }, shouldRenderHeader && (index.h("div", { class: "header--wrapper" }, this.showBackButton && (index.h("button", { type: "button", class: "back-button", onClick: () => this.onBackButtonClick() }, index.h("span", { class: "icon", innerHTML: backIcon }), index.h("span", { class: "visually-hidden" }, this.backButtonLabel))), this.showExitButton && (index.h("button", { type: "button", class: "exit-button", onClick: () => this.onExitButtonClick() }, index.h("span", { class: "icon", innerHTML: exitIcon }), index.h("span", { class: "visually-hidden" }, this.exitButtonLabel))), this.heading && index.h("h3", { class: "heading" }, this.heading))), index.h("div", { class: !this.disableContentPadding && `content--wrapper` }, index.h("slot", null)))));
831
+ }
832
+ static get delegatesFocus() { return true; }
833
+ static get watchers() { return {
834
+ "open": [{
835
+ "setDrawerOpenState": 0
836
+ }]
837
+ }; }
838
+ };
839
+ ScoutDrawer.style = drawerCss();
840
+
841
+ exports.scout_drawer = ScoutDrawer;