@shoper/phoenix_design_system 1.18.34-2 → 1.18.34-3
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/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +21 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +21 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var utilities = require('@dreamcommerce/utilities');
|
|
6
|
+
var portal_constants = require('../../../components/portal/portal_constants.js');
|
|
7
|
+
var backdrop_constants = require('../../../components/backdrop/backdrop_constants.js');
|
|
6
8
|
|
|
7
9
|
class BaseFocusTrapStrategy {
|
|
8
10
|
constructor(getContainer, getOpener) {
|
|
@@ -33,6 +35,23 @@ class BaseFocusTrapStrategy {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
};
|
|
38
|
+
this._addInertToBodyChildrenElements = () => {
|
|
39
|
+
const container = this.getContainer();
|
|
40
|
+
[...document.body.children].forEach((child) => {
|
|
41
|
+
const isPortalTarget = child.tagName === portal_constants.PORTAL_TARGET_COMPONENT_NAME.toUpperCase();
|
|
42
|
+
const isAriaLiveContainer = child.hasAttribute('aria-live');
|
|
43
|
+
const isBackdrop = child.tagName === backdrop_constants.BACKDROP_NAME.toUpperCase();
|
|
44
|
+
const containsContainer = container ? child.contains(container) : false;
|
|
45
|
+
if (!isPortalTarget && !isAriaLiveContainer && !isBackdrop && !containsContainer) {
|
|
46
|
+
child.setAttribute('inert', '');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
this._removeInertFromBodyChildrenElements = () => {
|
|
51
|
+
[...document.body.children].forEach((child) => {
|
|
52
|
+
child.removeAttribute('inert');
|
|
53
|
+
});
|
|
54
|
+
};
|
|
36
55
|
}
|
|
37
56
|
attach() {
|
|
38
57
|
var _a, _b;
|
|
@@ -47,11 +66,13 @@ class BaseFocusTrapStrategy {
|
|
|
47
66
|
this.active = true;
|
|
48
67
|
(_b = (_a = this.getOpener) === null || _a === void 0 ? void 0 : _a.call(this)) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-haspopup', 'dialog');
|
|
49
68
|
(_c = this.getContainer()) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-modal', 'true');
|
|
69
|
+
this._addInertToBodyChildrenElements();
|
|
50
70
|
}
|
|
51
71
|
deactivate() {
|
|
52
72
|
var _a;
|
|
53
73
|
this.active = false;
|
|
54
74
|
(_a = this.getContainer()) === null || _a === void 0 ? void 0 : _a.removeAttribute('aria-modal');
|
|
75
|
+
this._removeInertFromBodyChildrenElements();
|
|
55
76
|
}
|
|
56
77
|
getFocusableElements(container) {
|
|
57
78
|
return utilities.UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -11,5 +11,7 @@ export declare abstract class BaseFocusTrapStrategy implements IBaseFocusTrapStr
|
|
|
11
11
|
deactivate(): void;
|
|
12
12
|
getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
13
13
|
protected _handleKeyDown: (ev: KeyboardEvent) => void;
|
|
14
|
+
private _addInertToBodyChildrenElements;
|
|
15
|
+
private _removeInertFromBodyChildrenElements;
|
|
14
16
|
private _isElementTrulyFocusable;
|
|
15
17
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
2
|
+
import { PORTAL_TARGET_COMPONENT_NAME } from '../../../components/portal/portal_constants.js';
|
|
3
|
+
import { BACKDROP_NAME } from '../../../components/backdrop/backdrop_constants.js';
|
|
2
4
|
|
|
3
5
|
class BaseFocusTrapStrategy {
|
|
4
6
|
constructor(getContainer, getOpener) {
|
|
@@ -29,6 +31,23 @@ class BaseFocusTrapStrategy {
|
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
};
|
|
34
|
+
this._addInertToBodyChildrenElements = () => {
|
|
35
|
+
const container = this.getContainer();
|
|
36
|
+
[...document.body.children].forEach((child) => {
|
|
37
|
+
const isPortalTarget = child.tagName === PORTAL_TARGET_COMPONENT_NAME.toUpperCase();
|
|
38
|
+
const isAriaLiveContainer = child.hasAttribute('aria-live');
|
|
39
|
+
const isBackdrop = child.tagName === BACKDROP_NAME.toUpperCase();
|
|
40
|
+
const containsContainer = container ? child.contains(container) : false;
|
|
41
|
+
if (!isPortalTarget && !isAriaLiveContainer && !isBackdrop && !containsContainer) {
|
|
42
|
+
child.setAttribute('inert', '');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
this._removeInertFromBodyChildrenElements = () => {
|
|
47
|
+
[...document.body.children].forEach((child) => {
|
|
48
|
+
child.removeAttribute('inert');
|
|
49
|
+
});
|
|
50
|
+
};
|
|
32
51
|
}
|
|
33
52
|
attach() {
|
|
34
53
|
var _a, _b;
|
|
@@ -43,11 +62,13 @@ class BaseFocusTrapStrategy {
|
|
|
43
62
|
this.active = true;
|
|
44
63
|
(_b = (_a = this.getOpener) === null || _a === void 0 ? void 0 : _a.call(this)) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-haspopup', 'dialog');
|
|
45
64
|
(_c = this.getContainer()) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-modal', 'true');
|
|
65
|
+
this._addInertToBodyChildrenElements();
|
|
46
66
|
}
|
|
47
67
|
deactivate() {
|
|
48
68
|
var _a;
|
|
49
69
|
this.active = false;
|
|
50
70
|
(_a = this.getContainer()) === null || _a === void 0 ? void 0 : _a.removeAttribute('aria-modal');
|
|
71
|
+
this._removeInertFromBodyChildrenElements();
|
|
51
72
|
}
|
|
52
73
|
getFocusableElements(container) {
|
|
53
74
|
return UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|