@haiilo/catalyst 0.7.4 → 0.8.2

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