@haiilo/catalyst 4.1.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/assets/fonts/Lato-Black.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Black.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Bold.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Bold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Hairline.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Hairline.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Heavy.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Heavy.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Italic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Italic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Light.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Light.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-LightItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-LightItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Medium.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Medium.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Regular.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Regular.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Semibold.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Semibold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Thin.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Thin.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff2 +0 -0
- package/dist/catalyst/catalyst.css +6 -27
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-50855511.entry.js +10 -0
- package/dist/catalyst/p-50855511.entry.js.map +1 -0
- package/dist/catalyst/p-ccfebe33.js.map +1 -1
- package/dist/catalyst/p-d1fb9d96.js +3 -0
- package/dist/catalyst/p-d1fb9d96.js.map +1 -0
- package/dist/catalyst/scss/fonts/_fonts-mixins.scss +0 -10
- package/dist/cjs/cat-alert_24.cjs.entry.js +932 -1132
- package/dist/cjs/cat-alert_24.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +10 -3
- package/dist/cjs/catalyst.cjs.js.map +1 -1
- package/dist/cjs/{index-c4542095.js → index-01312a2e.js} +527 -245
- package/dist/cjs/index-01312a2e.js.map +1 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/collection/assets/fonts/Lato-Black.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Black.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-BlackItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-BlackItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Bold.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Bold.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Hairline.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Hairline.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-HairlineItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Heavy.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Heavy.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-HeavyItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Italic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Italic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Light.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Light.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-LightItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-LightItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Medium.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Medium.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-MediumItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-MediumItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Regular.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Regular.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Semibold.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Semibold.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Thin.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Thin.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-ThinItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-ThinItalic.woff2 +0 -0
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/cat-alert/cat-alert.js +69 -71
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
- package/dist/collection/components/cat-avatar/cat-avatar.js +172 -165
- package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
- package/dist/collection/components/cat-badge/cat-badge.js +102 -111
- package/dist/collection/components/cat-badge/cat-badge.js.map +1 -1
- package/dist/collection/components/cat-button/cat-button.js +526 -537
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-card/cat-card.js +12 -8
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +336 -350
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +137 -137
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
- package/dist/collection/components/cat-form-group/cat-form-group.js +58 -40
- package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint.js +14 -7
- package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -1
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +1 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js +1 -1
- package/dist/collection/components/cat-icon/cat-icon.js +85 -79
- package/dist/collection/components/cat-icon/cat-icon.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +32 -3
- package/dist/collection/components/cat-input/cat-input.js +662 -660
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-input/input-type.js +1 -1
- package/dist/collection/components/cat-label/cat-label.js +69 -78
- package/dist/collection/components/cat-label/cat-label.js.map +1 -1
- package/dist/collection/components/cat-notification/cat-notification.js +1 -1
- package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.js +192 -226
- package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.js +319 -327
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +173 -165
- package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +200 -208
- package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.js +555 -590
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +3 -28
- package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
- package/dist/collection/components/cat-skeleton/cat-skeleton.js +85 -88
- package/dist/collection/components/cat-skeleton/cat-skeleton.js.map +1 -1
- package/dist/collection/components/cat-spinner/cat-spinner.js +52 -50
- package/dist/collection/components/cat-spinner/cat-spinner.js.map +1 -1
- package/dist/collection/components/cat-tab/cat-tab.js +169 -168
- package/dist/collection/components/cat-tab/cat-tab.js.map +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.js +73 -66
- package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +32 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +479 -468
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js +319 -326
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +7 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +187 -198
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/collection/scss/fonts/_fonts-mixins.scss +0 -10
- package/dist/collection/utils/breakpoints.js +1 -1
- package/dist/collection/utils/breakpoints.js.map +1 -1
- package/dist/collection/utils/coerce.js +11 -0
- package/dist/collection/utils/coerce.js.map +1 -0
- package/dist/collection/utils/first-tabbable.js +1 -1
- package/dist/collection/utils/is-touch-screen.js +1 -1
- package/dist/collection/utils/load-img.js +1 -1
- package/dist/collection/utils/media-matcher.js +1 -1
- package/dist/collection/utils/platform.js +4 -4
- package/dist/collection/utils/setDefault.js +1 -1
- package/dist/components/cat-alert.js +1 -6
- package/dist/components/cat-alert.js.map +1 -1
- package/dist/components/cat-avatar2.js +6 -9
- package/dist/components/cat-avatar2.js.map +1 -1
- package/dist/components/cat-badge.js +0 -15
- package/dist/components/cat-badge.js.map +1 -1
- package/dist/components/cat-button2.js +10 -36
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox2.js +9 -26
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-dropdown2.js +139 -176
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-form-group.js +4 -9
- package/dist/components/cat-form-group.js.map +1 -1
- package/dist/components/cat-form-hint.js +13 -6
- package/dist/components/cat-form-hint.js.map +1 -1
- package/dist/components/cat-icon-registry.js +71 -0
- package/dist/components/cat-icon-registry.js.map +1 -0
- package/dist/components/cat-icon.js +1 -1
- package/dist/components/cat-icon2.js +5 -71
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.js +33 -41
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-label.js +1 -6
- package/dist/components/cat-label.js.map +1 -1
- package/dist/components/cat-pagination.js +0 -30
- package/dist/components/cat-pagination.js.map +1 -1
- package/dist/components/cat-radio-group.js +3 -6
- package/dist/components/cat-radio-group.js.map +1 -1
- package/dist/components/cat-radio.js +9 -23
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable2.js +1 -12
- package/dist/components/cat-scrollable2.js.map +1 -1
- package/dist/components/cat-select-demo.js +2 -12
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +40 -47
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-skeleton2.js +1 -10
- package/dist/components/cat-skeleton2.js.map +1 -1
- package/dist/components/cat-spinner2.js +1 -3
- package/dist/components/cat-spinner2.js.map +1 -1
- package/dist/components/cat-tab.js +3 -12
- package/dist/components/cat-tab.js.map +1 -1
- package/dist/components/cat-tabs.js +1 -6
- package/dist/components/cat-tabs.js.map +1 -1
- package/dist/components/cat-textarea.js +28 -33
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-toggle.js +9 -23
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +14 -34
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/first-tabbable.js +51 -113
- package/dist/components/first-tabbable.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +577 -441
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/components/index.d.ts +9 -27
- package/dist/components/index.js +2 -26
- package/dist/components/index.js.map +1 -1
- package/dist/esm/cat-alert_24.entry.js +933 -1133
- package/dist/esm/cat-alert_24.entry.js.map +1 -1
- package/dist/esm/catalyst.js +7 -3
- package/dist/esm/catalyst.js.map +1 -1
- package/dist/esm/{index-524906f7.js → index-fc2f91a4.js} +527 -246
- package/dist/esm/index-fc2f91a4.js.map +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +4 -3
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +1 -1
- package/dist/types/components/cat-form-group/cat-form-group.d.ts +4 -0
- package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +5 -0
- package/dist/types/components/cat-input/cat-input.d.ts +6 -1
- package/dist/types/components/cat-input/input-type.d.ts +1 -1
- package/dist/types/components/cat-radio/cat-radio.d.ts +1 -1
- package/dist/types/components/cat-select/cat-select.d.ts +3 -1
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +6 -1
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +1 -1
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +3 -0
- package/dist/types/components.d.ts +353 -7
- package/dist/types/stencil-public-runtime.d.ts +91 -19
- package/dist/types/utils/breakpoints.d.ts +1 -1
- package/dist/types/utils/coerce.d.ts +3 -0
- package/dist/types/utils/first-tabbable.d.ts +2 -2
- package/loader/index.d.ts +9 -0
- package/loader/package.json +1 -0
- package/package.json +19 -19
- package/dist/catalyst/assets/fonts/AzeretMono-Regular.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Bold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Italic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Medium.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/DMSans-Regular.woff2 +0 -0
- package/dist/catalyst/p-919eea27.js +0 -3
- package/dist/catalyst/p-919eea27.js.map +0 -1
- package/dist/catalyst/p-cd8f8639.entry.js +0 -10
- package/dist/catalyst/p-cd8f8639.entry.js.map +0 -1
- package/dist/catalyst/scss/fonts/_fonts.mixins.azeret.scss +0 -14
- package/dist/catalyst/scss/fonts/_fonts.mixins.dm.scss +0 -53
- package/dist/cjs/index-c4542095.js.map +0 -1
- package/dist/collection/assets/fonts/AzeretMono-Regular.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Bold.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Italic.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Medium.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/DMSans-Regular.woff2 +0 -0
- package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js +0 -13
- package/dist/collection/components/cat-form-hint/cat-form-hint-utils.js.map +0 -1
- package/dist/collection/scss/fonts/_fonts.mixins.azeret.scss +0 -14
- package/dist/collection/scss/fonts/_fonts.mixins.dm.scss +0 -53
- package/dist/components/cat-form-hint-utils.js +0 -17
- package/dist/components/cat-form-hint-utils.js.map +0 -1
- package/dist/esm/index-524906f7.js.map +0 -1
- package/dist/types/components/cat-form-hint/cat-form-hint-utils.d.ts +0 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { a as autoUpdate, c as computePosition, o as offset, f as flip } from './floating-ui.dom.esm.js';
|
|
3
|
-
import { t as tabbable,
|
|
3
|
+
import { t as tabbable, f as focusable, i as isTabbable, a as isFocusable, b as firstTabbable } from './first-tabbable.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Auto-generated file. Do not edit directly.
|
|
@@ -8,23 +8,20 @@ import { t as tabbable, a as focusable, i as isTabbable, b as isFocusable, f as
|
|
|
8
8
|
const timeTransitionS = 125;
|
|
9
9
|
|
|
10
10
|
/*!
|
|
11
|
-
* focus-trap 7.
|
|
11
|
+
* focus-trap 7.2.0
|
|
12
12
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
function ownKeys(object, enumerableOnly) {
|
|
16
16
|
var keys = Object.keys(object);
|
|
17
|
-
|
|
18
17
|
if (Object.getOwnPropertySymbols) {
|
|
19
18
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
20
19
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
21
20
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
22
21
|
})), keys.push.apply(keys, symbols);
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
return keys;
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
function _objectSpread2(target) {
|
|
29
26
|
for (var i = 1; i < arguments.length; i++) {
|
|
30
27
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -34,11 +31,10 @@ function _objectSpread2(target) {
|
|
|
34
31
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
35
32
|
});
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
return target;
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
function _defineProperty(obj, key, value) {
|
|
37
|
+
key = _toPropertyKey(key);
|
|
42
38
|
if (key in obj) {
|
|
43
39
|
Object.defineProperty(obj, key, {
|
|
44
40
|
value: value,
|
|
@@ -49,64 +45,75 @@ function _defineProperty(obj, key, value) {
|
|
|
49
45
|
} else {
|
|
50
46
|
obj[key] = value;
|
|
51
47
|
}
|
|
52
|
-
|
|
53
48
|
return obj;
|
|
54
49
|
}
|
|
50
|
+
function _toPrimitive(input, hint) {
|
|
51
|
+
if (typeof input !== "object" || input === null) return input;
|
|
52
|
+
var prim = input[Symbol.toPrimitive];
|
|
53
|
+
if (prim !== undefined) {
|
|
54
|
+
var res = prim.call(input, hint || "default");
|
|
55
|
+
if (typeof res !== "object") return res;
|
|
56
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
57
|
+
}
|
|
58
|
+
return (hint === "string" ? String : Number)(input);
|
|
59
|
+
}
|
|
60
|
+
function _toPropertyKey(arg) {
|
|
61
|
+
var key = _toPrimitive(arg, "string");
|
|
62
|
+
return typeof key === "symbol" ? key : String(key);
|
|
63
|
+
}
|
|
55
64
|
|
|
56
|
-
var activeFocusTraps =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (activeTrap !== trap) {
|
|
64
|
-
activeTrap.pause();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
var trapIndex = trapQueue.indexOf(trap);
|
|
69
|
-
|
|
70
|
-
if (trapIndex === -1) {
|
|
71
|
-
trapQueue.push(trap);
|
|
72
|
-
} else {
|
|
73
|
-
// move this existing trap to the front of the queue
|
|
74
|
-
trapQueue.splice(trapIndex, 1);
|
|
75
|
-
trapQueue.push(trap);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
deactivateTrap: function deactivateTrap(trap) {
|
|
79
|
-
var trapIndex = trapQueue.indexOf(trap);
|
|
80
|
-
|
|
81
|
-
if (trapIndex !== -1) {
|
|
82
|
-
trapQueue.splice(trapIndex, 1);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (trapQueue.length > 0) {
|
|
86
|
-
trapQueue[trapQueue.length - 1].unpause();
|
|
65
|
+
var activeFocusTraps = {
|
|
66
|
+
activateTrap: function activateTrap(trapStack, trap) {
|
|
67
|
+
if (trapStack.length > 0) {
|
|
68
|
+
var activeTrap = trapStack[trapStack.length - 1];
|
|
69
|
+
if (activeTrap !== trap) {
|
|
70
|
+
activeTrap.pause();
|
|
87
71
|
}
|
|
88
72
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
var trapIndex = trapStack.indexOf(trap);
|
|
74
|
+
if (trapIndex === -1) {
|
|
75
|
+
trapStack.push(trap);
|
|
76
|
+
} else {
|
|
77
|
+
// move this existing trap to the front of the queue
|
|
78
|
+
trapStack.splice(trapIndex, 1);
|
|
79
|
+
trapStack.push(trap);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
deactivateTrap: function deactivateTrap(trapStack, trap) {
|
|
83
|
+
var trapIndex = trapStack.indexOf(trap);
|
|
84
|
+
if (trapIndex !== -1) {
|
|
85
|
+
trapStack.splice(trapIndex, 1);
|
|
86
|
+
}
|
|
87
|
+
if (trapStack.length > 0) {
|
|
88
|
+
trapStack[trapStack.length - 1].unpause();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
92
|
var isSelectableInput = function isSelectableInput(node) {
|
|
93
93
|
return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
|
|
94
94
|
};
|
|
95
|
-
|
|
96
95
|
var isEscapeEvent = function isEscapeEvent(e) {
|
|
97
96
|
return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
|
|
98
97
|
};
|
|
99
|
-
|
|
100
98
|
var isTabEvent = function isTabEvent(e) {
|
|
101
99
|
return e.key === 'Tab' || e.keyCode === 9;
|
|
102
100
|
};
|
|
103
101
|
|
|
102
|
+
// checks for TAB by default
|
|
103
|
+
var isKeyForward = function isKeyForward(e) {
|
|
104
|
+
return isTabEvent(e) && !e.shiftKey;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// checks for SHIFT+TAB by default
|
|
108
|
+
var isKeyBackward = function isKeyBackward(e) {
|
|
109
|
+
return isTabEvent(e) && e.shiftKey;
|
|
110
|
+
};
|
|
104
111
|
var delay = function delay(fn) {
|
|
105
112
|
return setTimeout(fn, 0);
|
|
106
|
-
};
|
|
107
|
-
// of Array.findIndex() for our needs
|
|
108
|
-
|
|
113
|
+
};
|
|
109
114
|
|
|
115
|
+
// Array.find/findIndex() are not supported on IE; this replicates enough
|
|
116
|
+
// of Array.findIndex() for our needs
|
|
110
117
|
var findIndex = function findIndex(arr, fn) {
|
|
111
118
|
var idx = -1;
|
|
112
119
|
arr.every(function (value, i) {
|
|
@@ -117,8 +124,10 @@ var findIndex = function findIndex(arr, fn) {
|
|
|
117
124
|
|
|
118
125
|
return true; // next
|
|
119
126
|
});
|
|
127
|
+
|
|
120
128
|
return idx;
|
|
121
129
|
};
|
|
130
|
+
|
|
122
131
|
/**
|
|
123
132
|
* Get an option's value when it could be a plain value, or a handler that provides
|
|
124
133
|
* the value.
|
|
@@ -126,16 +135,12 @@ var findIndex = function findIndex(arr, fn) {
|
|
|
126
135
|
* @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
|
|
127
136
|
* @returns {*} The `value`, or the handler's returned value.
|
|
128
137
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
138
|
var valueOrHandler = function valueOrHandler(value) {
|
|
132
139
|
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
133
140
|
params[_key - 1] = arguments[_key];
|
|
134
141
|
}
|
|
135
|
-
|
|
136
142
|
return typeof value === 'function' ? value.apply(void 0, params) : value;
|
|
137
143
|
};
|
|
138
|
-
|
|
139
144
|
var getActualTarget = function getActualTarget(event) {
|
|
140
145
|
// NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
|
|
141
146
|
// shadow host. However, event.target.composedPath() will be an array of
|
|
@@ -147,17 +152,21 @@ var getActualTarget = function getActualTarget(event) {
|
|
|
147
152
|
return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
|
|
148
153
|
};
|
|
149
154
|
|
|
155
|
+
// NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this
|
|
156
|
+
// current instance use the same stack if `userOptions.trapStack` isn't specified
|
|
157
|
+
var internalTrapStack = [];
|
|
150
158
|
var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
151
159
|
// SSR: a live trap shouldn't be created in this type of environment so this
|
|
152
160
|
// should be safe code to execute if the `document` option isn't specified
|
|
153
161
|
var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
|
|
154
|
-
|
|
162
|
+
var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
|
|
155
163
|
var config = _objectSpread2({
|
|
156
164
|
returnFocusOnDeactivate: true,
|
|
157
165
|
escapeDeactivates: true,
|
|
158
|
-
delayInitialFocus: true
|
|
166
|
+
delayInitialFocus: true,
|
|
167
|
+
isKeyForward: isKeyForward,
|
|
168
|
+
isKeyBackward: isKeyBackward
|
|
159
169
|
}, userOptions);
|
|
160
|
-
|
|
161
170
|
var state = {
|
|
162
171
|
// containers given to createFocusTrap()
|
|
163
172
|
// @type {Array<HTMLElement>}
|
|
@@ -177,6 +186,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
177
186
|
// }>}
|
|
178
187
|
containerGroups: [],
|
|
179
188
|
// same order/length as `containers` list
|
|
189
|
+
|
|
180
190
|
// references to objects in `containerGroups`, but only those that actually have
|
|
181
191
|
// tabbable nodes in them
|
|
182
192
|
// NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
|
|
@@ -200,10 +210,10 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
200
210
|
* @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
|
|
201
211
|
* IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
|
|
202
212
|
*/
|
|
203
|
-
|
|
204
213
|
var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
|
|
205
214
|
return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
|
|
206
215
|
};
|
|
216
|
+
|
|
207
217
|
/**
|
|
208
218
|
* Finds the index of the container that contains the element.
|
|
209
219
|
* @param {HTMLElement} element
|
|
@@ -211,16 +221,15 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
211
221
|
* `state.containerGroups` (the order/length of these lists are the same); -1
|
|
212
222
|
* if the element isn't found.
|
|
213
223
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
216
224
|
var findContainerIndex = function findContainerIndex(element) {
|
|
217
225
|
// NOTE: search `containerGroups` because it's possible a group contains no tabbable
|
|
218
226
|
// nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
|
|
219
227
|
// and we still need to find the element in there
|
|
220
228
|
return state.containerGroups.findIndex(function (_ref) {
|
|
221
229
|
var container = _ref.container,
|
|
222
|
-
|
|
223
|
-
return container.contains(element) ||
|
|
230
|
+
tabbableNodes = _ref.tabbableNodes;
|
|
231
|
+
return container.contains(element) ||
|
|
232
|
+
// fall back to explicit tabbable search which will take into consideration any
|
|
224
233
|
// web components if the `tabbableOptions.getShadowRoot` option was used for
|
|
225
234
|
// the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
|
|
226
235
|
// look inside web components even if open)
|
|
@@ -229,6 +238,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
229
238
|
});
|
|
230
239
|
});
|
|
231
240
|
};
|
|
241
|
+
|
|
232
242
|
/**
|
|
233
243
|
* Gets the node for the given option, which is expected to be an option that
|
|
234
244
|
* can be either a DOM node, a string that is a selector to get a node, `false`
|
|
@@ -242,19 +252,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
242
252
|
* @throws {Error} If the option is set, not `false`, and is not, or does not
|
|
243
253
|
* resolve to a node.
|
|
244
254
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
255
|
var getNodeForOption = function getNodeForOption(optionName) {
|
|
248
256
|
var optionValue = config[optionName];
|
|
249
|
-
|
|
250
257
|
if (typeof optionValue === 'function') {
|
|
251
258
|
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
252
259
|
params[_key2 - 1] = arguments[_key2];
|
|
253
260
|
}
|
|
254
|
-
|
|
255
261
|
optionValue = optionValue.apply(void 0, params);
|
|
256
262
|
}
|
|
257
|
-
|
|
258
263
|
if (optionValue === true) {
|
|
259
264
|
optionValue = undefined; // use default value
|
|
260
265
|
}
|
|
@@ -262,56 +267,51 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
262
267
|
if (!optionValue) {
|
|
263
268
|
if (optionValue === undefined || optionValue === false) {
|
|
264
269
|
return optionValue;
|
|
265
|
-
}
|
|
266
|
-
|
|
270
|
+
}
|
|
271
|
+
// else, empty string (invalid), null (invalid), 0 (invalid)
|
|
267
272
|
|
|
268
273
|
throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
|
|
269
274
|
}
|
|
270
|
-
|
|
271
275
|
var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
|
|
272
276
|
|
|
273
277
|
if (typeof optionValue === 'string') {
|
|
274
278
|
node = doc.querySelector(optionValue); // resolve to node, or null if fails
|
|
275
|
-
|
|
276
279
|
if (!node) {
|
|
277
280
|
throw new Error("`".concat(optionName, "` as selector refers to no known node"));
|
|
278
281
|
}
|
|
279
282
|
}
|
|
280
|
-
|
|
281
283
|
return node;
|
|
282
284
|
};
|
|
283
|
-
|
|
284
285
|
var getInitialFocusNode = function getInitialFocusNode() {
|
|
285
|
-
var node = getNodeForOption('initialFocus');
|
|
286
|
+
var node = getNodeForOption('initialFocus');
|
|
286
287
|
|
|
288
|
+
// false explicitly indicates we want no initialFocus at all
|
|
287
289
|
if (node === false) {
|
|
288
290
|
return false;
|
|
289
291
|
}
|
|
290
|
-
|
|
291
292
|
if (node === undefined) {
|
|
292
293
|
// option not specified: use fallback options
|
|
293
294
|
if (findContainerIndex(doc.activeElement) >= 0) {
|
|
294
295
|
node = doc.activeElement;
|
|
295
296
|
} else {
|
|
296
297
|
var firstTabbableGroup = state.tabbableGroups[0];
|
|
297
|
-
var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
|
|
298
|
+
var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
|
|
298
299
|
|
|
300
|
+
// NOTE: `fallbackFocus` option function cannot return `false` (not supported)
|
|
299
301
|
node = firstTabbableNode || getNodeForOption('fallbackFocus');
|
|
300
302
|
}
|
|
301
303
|
}
|
|
302
|
-
|
|
303
304
|
if (!node) {
|
|
304
305
|
throw new Error('Your focus-trap needs to have at least one focusable element');
|
|
305
306
|
}
|
|
306
|
-
|
|
307
307
|
return node;
|
|
308
308
|
};
|
|
309
|
-
|
|
310
309
|
var updateTabbableNodes = function updateTabbableNodes() {
|
|
311
310
|
state.containerGroups = state.containers.map(function (container) {
|
|
312
|
-
var tabbableNodes = tabbable(container, config.tabbableOptions);
|
|
313
|
-
// are a superset of tabbable nodes
|
|
311
|
+
var tabbableNodes = tabbable(container, config.tabbableOptions);
|
|
314
312
|
|
|
313
|
+
// NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
|
|
314
|
+
// are a superset of tabbable nodes
|
|
315
315
|
var focusableNodes = focusable(container, config.tabbableOptions);
|
|
316
316
|
return {
|
|
317
317
|
container: container,
|
|
@@ -319,7 +319,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
319
319
|
focusableNodes: focusableNodes,
|
|
320
320
|
firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
|
|
321
321
|
lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
|
|
322
|
-
|
|
323
322
|
/**
|
|
324
323
|
* Finds the __tabbable__ node that follows the given node in the specified direction,
|
|
325
324
|
* in this container, if any.
|
|
@@ -343,17 +342,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
343
342
|
var nodeIdx = focusableNodes.findIndex(function (n) {
|
|
344
343
|
return n === node;
|
|
345
344
|
});
|
|
346
|
-
|
|
347
345
|
if (nodeIdx < 0) {
|
|
348
346
|
return undefined;
|
|
349
347
|
}
|
|
350
|
-
|
|
351
348
|
if (forward) {
|
|
352
349
|
return focusableNodes.slice(nodeIdx + 1).find(function (n) {
|
|
353
350
|
return isTabbable(n, config.tabbableOptions);
|
|
354
351
|
});
|
|
355
352
|
}
|
|
356
|
-
|
|
357
353
|
return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
|
|
358
354
|
return isTabbable(n, config.tabbableOptions);
|
|
359
355
|
});
|
|
@@ -362,53 +358,46 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
362
358
|
});
|
|
363
359
|
state.tabbableGroups = state.containerGroups.filter(function (group) {
|
|
364
360
|
return group.tabbableNodes.length > 0;
|
|
365
|
-
});
|
|
361
|
+
});
|
|
366
362
|
|
|
363
|
+
// throw if no groups have tabbable nodes and we don't have a fallback focus node either
|
|
367
364
|
if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
|
|
368
365
|
) {
|
|
369
366
|
throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
|
|
370
367
|
}
|
|
371
368
|
};
|
|
372
|
-
|
|
373
369
|
var tryFocus = function tryFocus(node) {
|
|
374
370
|
if (node === false) {
|
|
375
371
|
return;
|
|
376
372
|
}
|
|
377
|
-
|
|
378
373
|
if (node === doc.activeElement) {
|
|
379
374
|
return;
|
|
380
375
|
}
|
|
381
|
-
|
|
382
376
|
if (!node || !node.focus) {
|
|
383
377
|
tryFocus(getInitialFocusNode());
|
|
384
378
|
return;
|
|
385
379
|
}
|
|
386
|
-
|
|
387
380
|
node.focus({
|
|
388
381
|
preventScroll: !!config.preventScroll
|
|
389
382
|
});
|
|
390
383
|
state.mostRecentlyFocusedNode = node;
|
|
391
|
-
|
|
392
384
|
if (isSelectableInput(node)) {
|
|
393
385
|
node.select();
|
|
394
386
|
}
|
|
395
387
|
};
|
|
396
|
-
|
|
397
388
|
var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
|
|
398
389
|
var node = getNodeForOption('setReturnFocus', previousActiveElement);
|
|
399
390
|
return node ? node : node === false ? false : previousActiveElement;
|
|
400
|
-
};
|
|
401
|
-
// so that it precedes the focus event.
|
|
402
|
-
|
|
391
|
+
};
|
|
403
392
|
|
|
393
|
+
// This needs to be done on mousedown and touchstart instead of click
|
|
394
|
+
// so that it precedes the focus event.
|
|
404
395
|
var checkPointerDown = function checkPointerDown(e) {
|
|
405
396
|
var target = getActualTarget(e);
|
|
406
|
-
|
|
407
397
|
if (findContainerIndex(target) >= 0) {
|
|
408
398
|
// allow the click since it ocurred inside the trap
|
|
409
399
|
return;
|
|
410
400
|
}
|
|
411
|
-
|
|
412
401
|
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
413
402
|
// immediately deactivate the trap
|
|
414
403
|
trap.deactivate({
|
|
@@ -426,25 +415,26 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
426
415
|
returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
|
|
427
416
|
});
|
|
428
417
|
return;
|
|
429
|
-
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// This is needed for mobile devices.
|
|
430
421
|
// (If we'll only let `click` events through,
|
|
431
422
|
// then on mobile they will be blocked anyways if `touchstart` is blocked.)
|
|
432
|
-
|
|
433
|
-
|
|
434
423
|
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
435
424
|
// allow the click outside the trap to take place
|
|
436
425
|
return;
|
|
437
|
-
}
|
|
438
|
-
|
|
426
|
+
}
|
|
439
427
|
|
|
428
|
+
// otherwise, prevent the click
|
|
440
429
|
e.preventDefault();
|
|
441
|
-
};
|
|
442
|
-
|
|
430
|
+
};
|
|
443
431
|
|
|
432
|
+
// In case focus escapes the trap for some strange reason, pull it back in.
|
|
444
433
|
var checkFocusIn = function checkFocusIn(e) {
|
|
445
434
|
var target = getActualTarget(e);
|
|
446
|
-
var targetContained = findContainerIndex(target) >= 0;
|
|
435
|
+
var targetContained = findContainerIndex(target) >= 0;
|
|
447
436
|
|
|
437
|
+
// In Firefox when you Tab out of an iframe the Document is briefly focused.
|
|
448
438
|
if (targetContained || target instanceof Document) {
|
|
449
439
|
if (targetContained) {
|
|
450
440
|
state.mostRecentlyFocusedNode = target;
|
|
@@ -454,42 +444,41 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
454
444
|
e.stopImmediatePropagation();
|
|
455
445
|
tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
|
|
456
446
|
}
|
|
457
|
-
};
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
// Hijack key nav events on the first and last focusable nodes of the trap,
|
|
458
450
|
// in order to prevent focus from escaping. If it escapes for even a
|
|
459
451
|
// moment it can end up scrolling the page and causing confusion so we
|
|
460
452
|
// kind of need to capture the action at the keydown phase.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
var target = getActualTarget(e);
|
|
453
|
+
var checkKeyNav = function checkKeyNav(event) {
|
|
454
|
+
var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
455
|
+
var target = getActualTarget(event);
|
|
465
456
|
updateTabbableNodes();
|
|
466
457
|
var destinationNode = null;
|
|
467
|
-
|
|
468
458
|
if (state.tabbableGroups.length > 0) {
|
|
469
459
|
// make sure the target is actually contained in a group
|
|
470
460
|
// NOTE: the target may also be the container itself if it's focusable
|
|
471
461
|
// with tabIndex='-1' and was given initial focus
|
|
472
462
|
var containerIndex = findContainerIndex(target);
|
|
473
463
|
var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
|
|
474
|
-
|
|
475
464
|
if (containerIndex < 0) {
|
|
476
465
|
// target not found in any group: quite possible focus has escaped the trap,
|
|
477
|
-
// so bring it back
|
|
478
|
-
if (
|
|
466
|
+
// so bring it back into...
|
|
467
|
+
if (isBackward) {
|
|
479
468
|
// ...the last node in the last group
|
|
480
469
|
destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
|
|
481
470
|
} else {
|
|
482
471
|
// ...the first node in the first group
|
|
483
472
|
destinationNode = state.tabbableGroups[0].firstTabbableNode;
|
|
484
473
|
}
|
|
485
|
-
} else if (
|
|
474
|
+
} else if (isBackward) {
|
|
486
475
|
// REVERSE
|
|
476
|
+
|
|
487
477
|
// is the target the first tabbable node in a group?
|
|
488
478
|
var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
|
|
489
479
|
var firstTabbableNode = _ref2.firstTabbableNode;
|
|
490
480
|
return target === firstTabbableNode;
|
|
491
481
|
});
|
|
492
|
-
|
|
493
482
|
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
|
|
494
483
|
// an exception case where the target is either the container itself, or
|
|
495
484
|
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
@@ -499,7 +488,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
499
488
|
// first tabbable node, and go to the last tabbable node of the LAST group
|
|
500
489
|
startOfGroupIndex = containerIndex;
|
|
501
490
|
}
|
|
502
|
-
|
|
503
491
|
if (startOfGroupIndex >= 0) {
|
|
504
492
|
// YES: then shift+tab should go to the last tabbable node in the
|
|
505
493
|
// previous group (and wrap around to the last tabbable node of
|
|
@@ -507,15 +495,19 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
507
495
|
var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
|
|
508
496
|
var destinationGroup = state.tabbableGroups[destinationGroupIndex];
|
|
509
497
|
destinationNode = destinationGroup.lastTabbableNode;
|
|
498
|
+
} else if (!isTabEvent(event)) {
|
|
499
|
+
// user must have customized the nav keys so we have to move focus manually _within_
|
|
500
|
+
// the active group: do this based on the order determined by tabbable()
|
|
501
|
+
destinationNode = containerGroup.nextTabbableNode(target, false);
|
|
510
502
|
}
|
|
511
503
|
} else {
|
|
512
504
|
// FORWARD
|
|
505
|
+
|
|
513
506
|
// is the target the last tabbable node in a group?
|
|
514
507
|
var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
|
|
515
508
|
var lastTabbableNode = _ref3.lastTabbableNode;
|
|
516
509
|
return target === lastTabbableNode;
|
|
517
510
|
});
|
|
518
|
-
|
|
519
511
|
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
|
|
520
512
|
// an exception case where the target is the container itself, or
|
|
521
513
|
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
@@ -525,73 +517,76 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
525
517
|
// last tabbable node, and go to the first tabbable node of the FIRST group
|
|
526
518
|
lastOfGroupIndex = containerIndex;
|
|
527
519
|
}
|
|
528
|
-
|
|
529
520
|
if (lastOfGroupIndex >= 0) {
|
|
530
521
|
// YES: then tab should go to the first tabbable node in the next
|
|
531
522
|
// group (and wrap around to the first tabbable node of the FIRST
|
|
532
523
|
// group if it's the last tabbable node of the LAST group)
|
|
533
524
|
var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
|
|
534
|
-
|
|
535
525
|
var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
|
|
536
526
|
destinationNode = _destinationGroup.firstTabbableNode;
|
|
527
|
+
} else if (!isTabEvent(event)) {
|
|
528
|
+
// user must have customized the nav keys so we have to move focus manually _within_
|
|
529
|
+
// the active group: do this based on the order determined by tabbable()
|
|
530
|
+
destinationNode = containerGroup.nextTabbableNode(target);
|
|
537
531
|
}
|
|
538
532
|
}
|
|
539
533
|
} else {
|
|
534
|
+
// no groups available
|
|
540
535
|
// NOTE: the fallbackFocus option does not support returning false to opt-out
|
|
541
536
|
destinationNode = getNodeForOption('fallbackFocus');
|
|
542
537
|
}
|
|
543
|
-
|
|
544
538
|
if (destinationNode) {
|
|
545
|
-
|
|
539
|
+
if (isTabEvent(event)) {
|
|
540
|
+
// since tab natively moves focus, we wouldn't have a destination node unless we
|
|
541
|
+
// were on the edge of a container and had to move to the next/previous edge, in
|
|
542
|
+
// which case we want to prevent default to keep the browser from moving focus
|
|
543
|
+
// to where it normally would
|
|
544
|
+
event.preventDefault();
|
|
545
|
+
}
|
|
546
546
|
tryFocus(destinationNode);
|
|
547
|
-
}
|
|
548
|
-
|
|
547
|
+
}
|
|
548
|
+
// else, let the browser take care of [shift+]tab and move the focus
|
|
549
549
|
};
|
|
550
550
|
|
|
551
|
-
var checkKey = function checkKey(
|
|
552
|
-
if (isEscapeEvent(
|
|
553
|
-
|
|
551
|
+
var checkKey = function checkKey(event) {
|
|
552
|
+
if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
|
|
553
|
+
event.preventDefault();
|
|
554
554
|
trap.deactivate();
|
|
555
555
|
return;
|
|
556
556
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
checkTab(e);
|
|
560
|
-
return;
|
|
557
|
+
if (config.isKeyForward(event) || config.isKeyBackward(event)) {
|
|
558
|
+
checkKeyNav(event, config.isKeyBackward(event));
|
|
561
559
|
}
|
|
562
560
|
};
|
|
563
|
-
|
|
564
561
|
var checkClick = function checkClick(e) {
|
|
565
562
|
var target = getActualTarget(e);
|
|
566
|
-
|
|
567
563
|
if (findContainerIndex(target) >= 0) {
|
|
568
564
|
return;
|
|
569
565
|
}
|
|
570
|
-
|
|
571
566
|
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
572
567
|
return;
|
|
573
568
|
}
|
|
574
|
-
|
|
575
569
|
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
576
570
|
return;
|
|
577
571
|
}
|
|
578
|
-
|
|
579
572
|
e.preventDefault();
|
|
580
573
|
e.stopImmediatePropagation();
|
|
581
|
-
};
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
//
|
|
582
577
|
// EVENT LISTENERS
|
|
583
578
|
//
|
|
584
579
|
|
|
585
|
-
|
|
586
580
|
var addListeners = function addListeners() {
|
|
587
581
|
if (!state.active) {
|
|
588
582
|
return;
|
|
589
|
-
}
|
|
583
|
+
}
|
|
590
584
|
|
|
585
|
+
// There can be only one listening focus trap at a time
|
|
586
|
+
activeFocusTraps.activateTrap(trapStack, trap);
|
|
591
587
|
|
|
592
|
-
|
|
588
|
+
// Delay ensures that the focused element doesn't capture the event
|
|
593
589
|
// that caused the focus trap activation.
|
|
594
|
-
|
|
595
590
|
state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
|
|
596
591
|
tryFocus(getInitialFocusNode());
|
|
597
592
|
}) : tryFocus(getInitialFocusNode());
|
|
@@ -614,70 +609,58 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
614
609
|
});
|
|
615
610
|
return trap;
|
|
616
611
|
};
|
|
617
|
-
|
|
618
612
|
var removeListeners = function removeListeners() {
|
|
619
613
|
if (!state.active) {
|
|
620
614
|
return;
|
|
621
615
|
}
|
|
622
|
-
|
|
623
616
|
doc.removeEventListener('focusin', checkFocusIn, true);
|
|
624
617
|
doc.removeEventListener('mousedown', checkPointerDown, true);
|
|
625
618
|
doc.removeEventListener('touchstart', checkPointerDown, true);
|
|
626
619
|
doc.removeEventListener('click', checkClick, true);
|
|
627
620
|
doc.removeEventListener('keydown', checkKey, true);
|
|
628
621
|
return trap;
|
|
629
|
-
};
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
//
|
|
630
625
|
// TRAP DEFINITION
|
|
631
626
|
//
|
|
632
627
|
|
|
633
|
-
|
|
634
628
|
trap = {
|
|
635
629
|
get active() {
|
|
636
630
|
return state.active;
|
|
637
631
|
},
|
|
638
|
-
|
|
639
632
|
get paused() {
|
|
640
633
|
return state.paused;
|
|
641
634
|
},
|
|
642
|
-
|
|
643
635
|
activate: function activate(activateOptions) {
|
|
644
636
|
if (state.active) {
|
|
645
637
|
return this;
|
|
646
638
|
}
|
|
647
|
-
|
|
648
639
|
var onActivate = getOption(activateOptions, 'onActivate');
|
|
649
640
|
var onPostActivate = getOption(activateOptions, 'onPostActivate');
|
|
650
641
|
var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
|
|
651
|
-
|
|
652
642
|
if (!checkCanFocusTrap) {
|
|
653
643
|
updateTabbableNodes();
|
|
654
644
|
}
|
|
655
|
-
|
|
656
645
|
state.active = true;
|
|
657
646
|
state.paused = false;
|
|
658
647
|
state.nodeFocusedBeforeActivation = doc.activeElement;
|
|
659
|
-
|
|
660
648
|
if (onActivate) {
|
|
661
649
|
onActivate();
|
|
662
650
|
}
|
|
663
|
-
|
|
664
651
|
var finishActivation = function finishActivation() {
|
|
665
652
|
if (checkCanFocusTrap) {
|
|
666
653
|
updateTabbableNodes();
|
|
667
654
|
}
|
|
668
|
-
|
|
669
655
|
addListeners();
|
|
670
|
-
|
|
671
656
|
if (onPostActivate) {
|
|
672
657
|
onPostActivate();
|
|
673
658
|
}
|
|
674
659
|
};
|
|
675
|
-
|
|
676
660
|
if (checkCanFocusTrap) {
|
|
677
661
|
checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
|
|
678
662
|
return this;
|
|
679
663
|
}
|
|
680
|
-
|
|
681
664
|
finishActivation();
|
|
682
665
|
return this;
|
|
683
666
|
},
|
|
@@ -685,46 +668,38 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
685
668
|
if (!state.active) {
|
|
686
669
|
return this;
|
|
687
670
|
}
|
|
688
|
-
|
|
689
671
|
var options = _objectSpread2({
|
|
690
672
|
onDeactivate: config.onDeactivate,
|
|
691
673
|
onPostDeactivate: config.onPostDeactivate,
|
|
692
674
|
checkCanReturnFocus: config.checkCanReturnFocus
|
|
693
675
|
}, deactivateOptions);
|
|
694
|
-
|
|
695
676
|
clearTimeout(state.delayInitialFocusTimer); // noop if undefined
|
|
696
|
-
|
|
697
677
|
state.delayInitialFocusTimer = undefined;
|
|
698
678
|
removeListeners();
|
|
699
679
|
state.active = false;
|
|
700
680
|
state.paused = false;
|
|
701
|
-
activeFocusTraps.deactivateTrap(trap);
|
|
681
|
+
activeFocusTraps.deactivateTrap(trapStack, trap);
|
|
702
682
|
var onDeactivate = getOption(options, 'onDeactivate');
|
|
703
683
|
var onPostDeactivate = getOption(options, 'onPostDeactivate');
|
|
704
684
|
var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
|
|
705
685
|
var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
|
|
706
|
-
|
|
707
686
|
if (onDeactivate) {
|
|
708
687
|
onDeactivate();
|
|
709
688
|
}
|
|
710
|
-
|
|
711
689
|
var finishDeactivation = function finishDeactivation() {
|
|
712
690
|
delay(function () {
|
|
713
691
|
if (returnFocus) {
|
|
714
692
|
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
|
|
715
693
|
}
|
|
716
|
-
|
|
717
694
|
if (onPostDeactivate) {
|
|
718
695
|
onPostDeactivate();
|
|
719
696
|
}
|
|
720
697
|
});
|
|
721
698
|
};
|
|
722
|
-
|
|
723
699
|
if (returnFocus && checkCanReturnFocus) {
|
|
724
700
|
checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
|
|
725
701
|
return this;
|
|
726
702
|
}
|
|
727
|
-
|
|
728
703
|
finishDeactivation();
|
|
729
704
|
return this;
|
|
730
705
|
},
|
|
@@ -732,7 +707,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
732
707
|
if (state.paused || !state.active) {
|
|
733
708
|
return this;
|
|
734
709
|
}
|
|
735
|
-
|
|
736
710
|
state.paused = true;
|
|
737
711
|
removeListeners();
|
|
738
712
|
return this;
|
|
@@ -741,7 +715,6 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
741
715
|
if (!state.paused || !state.active) {
|
|
742
716
|
return this;
|
|
743
717
|
}
|
|
744
|
-
|
|
745
718
|
state.paused = false;
|
|
746
719
|
updateTabbableNodes();
|
|
747
720
|
addListeners();
|
|
@@ -752,15 +725,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
|
752
725
|
state.containers = elementsAsArray.map(function (element) {
|
|
753
726
|
return typeof element === 'string' ? doc.querySelector(element) : element;
|
|
754
727
|
});
|
|
755
|
-
|
|
756
728
|
if (state.active) {
|
|
757
729
|
updateTabbableNodes();
|
|
758
730
|
}
|
|
759
|
-
|
|
760
731
|
return this;
|
|
761
732
|
}
|
|
762
|
-
};
|
|
733
|
+
};
|
|
763
734
|
|
|
735
|
+
// initialize container elements
|
|
764
736
|
trap.updateContainerElements(elements);
|
|
765
737
|
return trap;
|
|
766
738
|
};
|
|
@@ -777,17 +749,8 @@ const CatDropdown = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
777
749
|
this.catClose = createEvent(this, "catClose", 7);
|
|
778
750
|
this.id = nextUniqueId++;
|
|
779
751
|
this.isOpen = false;
|
|
780
|
-
/**
|
|
781
|
-
* The placement of the dropdown.
|
|
782
|
-
*/
|
|
783
752
|
this.placement = 'bottom-start';
|
|
784
|
-
/**
|
|
785
|
-
* Do not close the dropdown on outside clicks.
|
|
786
|
-
*/
|
|
787
753
|
this.noAutoClose = false;
|
|
788
|
-
/**
|
|
789
|
-
* Allow overflow when dropdown is open.
|
|
790
|
-
*/
|
|
791
754
|
this.overflow = false;
|
|
792
755
|
}
|
|
793
756
|
clickHandler(event) {
|