@shoper/phoenix_design_system 1.18.23-1 → 1.18.23-10
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/components/dropdown/dropdown.js +24 -93
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/search/search.js +55 -8
- package/build/cjs/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +3 -13
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/select.js +37 -18
- package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/modal/modal.js +39 -11
- package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/sheet/sheet.js +33 -10
- package/build/cjs/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +47 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +66 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +14 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +12 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +29 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +60 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +3 -10
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +24 -93
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +6 -0
- package/build/esm/packages/phoenix/src/components/form/search/search.js +55 -8
- package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +3 -13
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +1 -0
- package/build/esm/packages/phoenix/src/components/form/select/select.js +37 -18
- package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/modal/modal.d.ts +2 -0
- package/build/esm/packages/phoenix/src/components/modal/modal.js +39 -11
- package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/sheet/sheet.d.ts +2 -0
- package/build/esm/packages/phoenix/src/components/sheet/sheet.js +33 -10
- package/build/esm/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +13 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +43 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +14 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +5 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +14 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +62 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +8 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +6 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +10 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +3 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +5 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +8 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.d.ts +7 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +25 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.d.ts +4 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.d.ts +11 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +56 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.d.ts +4 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js.map +1 -0
- package/package.json +1 -1
|
@@ -9,6 +9,8 @@ import { createRef, ref } from 'lit-html/directives/ref.js';
|
|
|
9
9
|
import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
|
|
10
10
|
import { BACKDROP_EVENTS } from '../backdrop/backdrop_constants.js';
|
|
11
11
|
import { BackdropController } from '../backdrop/controller/backdrop_controller.js';
|
|
12
|
+
import { FOCUS_TRAP_STRATEGY_TYPES } from '../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js';
|
|
13
|
+
import { FocusTrapController } from '../../controllers/focus_trap_controller/focus_trap_controller.js';
|
|
12
14
|
import { MODAL_OPENED_PROP, FOCUSABLE_ELEMENTS_WITHIN_MODAL, MODALS_PORTAL_NAME, MODAL_EVENTS } from './modal_constants.js';
|
|
13
15
|
import { HModalClose } from './modal_close.js';
|
|
14
16
|
|
|
@@ -21,6 +23,7 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
21
23
|
this.transition = 'scale';
|
|
22
24
|
this.modalLabel = '';
|
|
23
25
|
this.noAutofocus = false;
|
|
26
|
+
this.isSearchFocusTrapFixEnabled = false;
|
|
24
27
|
this._firstFocusableElement = undefined;
|
|
25
28
|
this._focusableElements = null;
|
|
26
29
|
this._lastFocusableElement = undefined;
|
|
@@ -36,22 +39,35 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
36
39
|
document.addEventListener('keydown', this._bindCloseOnEsc);
|
|
37
40
|
document.addEventListener(BACKDROP_EVENTS.clicked, this.close);
|
|
38
41
|
this._dispatchModalOpenedEvent();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
this._focusTrapController.activate();
|
|
43
|
+
if (this.isSearchFocusTrapFixEnabled) {
|
|
44
|
+
this._focusTrapController.activate();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (!this.noAutofocus) {
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
51
|
+
window.scrollTo(0, scrollY);
|
|
52
|
+
}, 0);
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
},
|
|
47
56
|
false: () => {
|
|
48
57
|
HModal_1.openModals = HModal_1.openModals.filter((modal) => modal !== this);
|
|
49
58
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
50
59
|
document.removeEventListener(BACKDROP_EVENTS.clicked, this.close);
|
|
60
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
61
|
+
this._focusTrapController.deactivate();
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
};
|
|
54
65
|
this._backdropController = new BackdropController();
|
|
66
|
+
this._focusTrapController = new FocusTrapController(this, {
|
|
67
|
+
mode: FOCUS_TRAP_STRATEGY_TYPES.sentinel,
|
|
68
|
+
getContainer: () => this._contentRef.value,
|
|
69
|
+
noAutofocus: this.noAutofocus
|
|
70
|
+
});
|
|
55
71
|
this._keepFocusWithinModal = (ev) => {
|
|
56
72
|
var _a;
|
|
57
73
|
const isTabPressed = ev.code === 'Tab';
|
|
@@ -145,7 +161,8 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
145
161
|
connectedCallback() {
|
|
146
162
|
super.connectedCallback();
|
|
147
163
|
HModal_1._appendModalsPortal();
|
|
148
|
-
|
|
164
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
165
|
+
document.addEventListener('keyup', this._keepFocusWithinModal);
|
|
149
166
|
document.addEventListener(MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
150
167
|
}
|
|
151
168
|
disconnectedCallback() {
|
|
@@ -154,17 +171,23 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
154
171
|
this.close();
|
|
155
172
|
document.removeEventListener(MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
156
173
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
157
|
-
|
|
174
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
175
|
+
document.removeEventListener('keyup', this._keepFocusWithinModal);
|
|
158
176
|
}
|
|
159
177
|
firstUpdated(props) {
|
|
160
178
|
super.firstUpdated(props);
|
|
161
|
-
this.
|
|
162
|
-
|
|
179
|
+
if (!this.isSearchFocusTrapFixEnabled) {
|
|
180
|
+
this._firstFocusableElement = this._focusSentinelStart.value;
|
|
181
|
+
this._lastFocusableElement = this._focusSentinelEnd.value;
|
|
182
|
+
}
|
|
163
183
|
}
|
|
164
184
|
updated(changedProps) {
|
|
165
185
|
if (changedProps.has(MODAL_OPENED_PROP)) {
|
|
166
186
|
this._propsChangeStrategies[MODAL_OPENED_PROP][String(this[MODAL_OPENED_PROP])]();
|
|
167
187
|
}
|
|
188
|
+
if (this.isSearchFocusTrapFixEnabled && changedProps.has('noAutofocus')) {
|
|
189
|
+
this._focusTrapController.strategy.noAutofocus = this.noAutofocus;
|
|
190
|
+
}
|
|
168
191
|
}
|
|
169
192
|
_setFocusToFirstFocusableElementInModalOrCloseBtn() {
|
|
170
193
|
if (this.noAutofocus)
|
|
@@ -193,7 +216,8 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
193
216
|
setTimeout(() => {
|
|
194
217
|
var _a;
|
|
195
218
|
(_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
|
|
196
|
-
this.
|
|
219
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
220
|
+
this._setFocusToFirstFocusableElementInModalOrCloseBtn();
|
|
197
221
|
resolve();
|
|
198
222
|
}, transitionDuration);
|
|
199
223
|
});
|
|
@@ -252,6 +276,10 @@ __decorate([
|
|
|
252
276
|
property({ type: Boolean, attribute: 'no-autofocus' }),
|
|
253
277
|
__metadata("design:type", Object)
|
|
254
278
|
], HModal.prototype, "noAutofocus", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
|
|
281
|
+
__metadata("design:type", Boolean)
|
|
282
|
+
], HModal.prototype, "isSearchFocusTrapFixEnabled", void 0);
|
|
255
283
|
__decorate([
|
|
256
284
|
state(),
|
|
257
285
|
__metadata("design:type", Object)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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;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;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;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -6,6 +6,7 @@ export declare class HSheet extends PhoenixLightLitElement {
|
|
|
6
6
|
class: string;
|
|
7
7
|
transition: string;
|
|
8
8
|
sheetLabel: string;
|
|
9
|
+
isSearchFocusTrapFixEnabled: boolean;
|
|
9
10
|
_firstFocusableElement: HTMLElement | undefined;
|
|
10
11
|
_focusableElements: HTMLElement[] | null;
|
|
11
12
|
_lastFocusableElement: HTMLElement | undefined;
|
|
@@ -16,6 +17,7 @@ export declare class HSheet extends PhoenixLightLitElement {
|
|
|
16
17
|
private _propsChangeStrategies;
|
|
17
18
|
private static openSheets;
|
|
18
19
|
private _backdropController;
|
|
20
|
+
private _focusTrapController;
|
|
19
21
|
private static _appendSheetPortal;
|
|
20
22
|
static isSomeSheetOpen(): boolean;
|
|
21
23
|
constructor();
|
|
@@ -9,6 +9,8 @@ import { createRef, ref } from 'lit-html/directives/ref.js';
|
|
|
9
9
|
import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
|
|
10
10
|
import { BACKDROP_EVENTS } from '../backdrop/backdrop_constants.js';
|
|
11
11
|
import { BackdropController } from '../backdrop/controller/backdrop_controller.js';
|
|
12
|
+
import { FOCUS_TRAP_STRATEGY_TYPES } from '../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js';
|
|
13
|
+
import { FocusTrapController } from '../../controllers/focus_trap_controller/focus_trap_controller.js';
|
|
12
14
|
import { SHEET_OPENED_PROP, FOCUSABLE_ELEMENTS_WITHIN_SHEET, SHEETS_PORTAL_NAME, SHEET_EVENTS } from './sheet_constants.js';
|
|
13
15
|
import { HSheetClose } from './sheet_close.js';
|
|
14
16
|
|
|
@@ -20,6 +22,7 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
20
22
|
this.class = '';
|
|
21
23
|
this.transition = 'scale';
|
|
22
24
|
this.sheetLabel = '';
|
|
25
|
+
this.isSearchFocusTrapFixEnabled = false;
|
|
23
26
|
this._firstFocusableElement = undefined;
|
|
24
27
|
this._focusableElements = null;
|
|
25
28
|
this._lastFocusableElement = undefined;
|
|
@@ -35,20 +38,31 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
35
38
|
document.addEventListener('keydown', this._bindCloseOnEsc);
|
|
36
39
|
document.addEventListener(BACKDROP_EVENTS.clicked, this.close);
|
|
37
40
|
this._dispatchSheetOpenedEvent();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
if (this.isSearchFocusTrapFixEnabled) {
|
|
42
|
+
this._focusTrapController.activate();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
(_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
48
|
+
window.scrollTo(0, scrollY);
|
|
49
|
+
}, 0);
|
|
50
|
+
}
|
|
43
51
|
},
|
|
44
52
|
false: () => {
|
|
45
53
|
HSheet_1.openSheets = HSheet_1.openSheets.filter((sheet) => sheet !== this);
|
|
46
54
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
47
55
|
document.removeEventListener(BACKDROP_EVENTS.clicked, this.close);
|
|
56
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
57
|
+
this._focusTrapController.deactivate();
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
};
|
|
51
61
|
this._backdropController = new BackdropController();
|
|
62
|
+
this._focusTrapController = new FocusTrapController(this, {
|
|
63
|
+
mode: FOCUS_TRAP_STRATEGY_TYPES.sentinel,
|
|
64
|
+
getContainer: () => this._contentRef.value
|
|
65
|
+
});
|
|
52
66
|
this._keepFocusWithinSheet = (ev) => {
|
|
53
67
|
var _a;
|
|
54
68
|
const isTabPressed = ev.code === 'Tab';
|
|
@@ -142,7 +156,8 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
142
156
|
connectedCallback() {
|
|
143
157
|
super.connectedCallback();
|
|
144
158
|
HSheet_1._appendSheetPortal();
|
|
145
|
-
|
|
159
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
160
|
+
document.addEventListener('keyup', this._keepFocusWithinSheet);
|
|
146
161
|
document.addEventListener(SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
147
162
|
}
|
|
148
163
|
disconnectedCallback() {
|
|
@@ -151,12 +166,15 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
151
166
|
this.close();
|
|
152
167
|
document.removeEventListener(SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
153
168
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
154
|
-
|
|
169
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
170
|
+
document.removeEventListener('keyup', this._keepFocusWithinSheet);
|
|
155
171
|
}
|
|
156
172
|
firstUpdated(props) {
|
|
157
173
|
super.firstUpdated(props);
|
|
158
|
-
this.
|
|
159
|
-
|
|
174
|
+
if (!this.isSearchFocusTrapFixEnabled) {
|
|
175
|
+
this._firstFocusableElement = this._focusSentinelStart.value;
|
|
176
|
+
this._lastFocusableElement = this._focusSentinelEnd.value;
|
|
177
|
+
}
|
|
160
178
|
}
|
|
161
179
|
updated(changedProps) {
|
|
162
180
|
if (changedProps.has(SHEET_OPENED_PROP)) {
|
|
@@ -188,7 +206,8 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
188
206
|
setTimeout(() => {
|
|
189
207
|
var _a;
|
|
190
208
|
(_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`sheet_show-${this.transition}-start`, `sheet_show-${this.transition}-end`);
|
|
191
|
-
this.
|
|
209
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
210
|
+
this._setFocusToFirstFocusableElementInSheetOrCloseBtn();
|
|
192
211
|
resolve();
|
|
193
212
|
}, transitionDuration);
|
|
194
213
|
});
|
|
@@ -241,6 +260,10 @@ __decorate([
|
|
|
241
260
|
property({ type: String, attribute: 'sheet-label' }),
|
|
242
261
|
__metadata("design:type", Object)
|
|
243
262
|
], HSheet.prototype, "sheetLabel", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
|
|
265
|
+
__metadata("design:type", Boolean)
|
|
266
|
+
], HSheet.prototype, "isSearchFocusTrapFixEnabled", void 0);
|
|
244
267
|
__decorate([
|
|
245
268
|
state(),
|
|
246
269
|
__metadata("design:type", Object)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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;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;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;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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;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;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;AACA;AACA;AACA;"}
|
package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import type { TFocusTrapProps } from './focus_trap_controller_types';
|
|
3
|
+
import { IBaseFocusTrapStrategy } from './strategies/base_focus_trap_strategy_types';
|
|
4
|
+
export declare class FocusTrapController implements ReactiveController {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(host: ReactiveControllerHost, props: TFocusTrapProps);
|
|
7
|
+
get strategy(): IBaseFocusTrapStrategy;
|
|
8
|
+
hostConnected(): void;
|
|
9
|
+
hostDisconnected(): void;
|
|
10
|
+
activate(): void;
|
|
11
|
+
deactivate(): void;
|
|
12
|
+
getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
13
|
+
}
|
package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { __classPrivateFieldSet, __classPrivateFieldGet } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import 'lit';
|
|
3
|
+
import { SentinelFocusTrapStrategy } from './strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js';
|
|
4
|
+
import { CyclicFocusTrapStrategy } from './strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js';
|
|
5
|
+
import { TogglerFocusTrapStrategy } from './strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js';
|
|
6
|
+
import { FOCUS_TRAP_STRATEGY_TYPES } from './strategies/focus_trap_strategy_constants.js';
|
|
7
|
+
|
|
8
|
+
var _a, _FocusTrapController_strategy, _FocusTrapController_createStrategy;
|
|
9
|
+
class FocusTrapController {
|
|
10
|
+
constructor(host, props) {
|
|
11
|
+
_FocusTrapController_strategy.set(this, void 0);
|
|
12
|
+
__classPrivateFieldSet(this, _FocusTrapController_strategy, __classPrivateFieldGet(FocusTrapController, _a, "m", _FocusTrapController_createStrategy).call(FocusTrapController, props), "f");
|
|
13
|
+
host.addController(this);
|
|
14
|
+
}
|
|
15
|
+
get strategy() {
|
|
16
|
+
return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
|
|
17
|
+
}
|
|
18
|
+
hostConnected() {
|
|
19
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").attach();
|
|
20
|
+
}
|
|
21
|
+
hostDisconnected() {
|
|
22
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").detach();
|
|
23
|
+
}
|
|
24
|
+
activate() {
|
|
25
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").activate();
|
|
26
|
+
}
|
|
27
|
+
deactivate() {
|
|
28
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").deactivate();
|
|
29
|
+
}
|
|
30
|
+
getFocusableElements(container) {
|
|
31
|
+
return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").getFocusableElements(container);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_a = FocusTrapController, _FocusTrapController_strategy = new WeakMap(), _FocusTrapController_createStrategy = function _FocusTrapController_createStrategy(props) {
|
|
35
|
+
switch (props.mode) {
|
|
36
|
+
case FOCUS_TRAP_STRATEGY_TYPES.sentinel: return new SentinelFocusTrapStrategy(props);
|
|
37
|
+
case FOCUS_TRAP_STRATEGY_TYPES.cyclic: return new CyclicFocusTrapStrategy(props);
|
|
38
|
+
case FOCUS_TRAP_STRATEGY_TYPES.toggler: return new TogglerFocusTrapStrategy(props);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { FocusTrapController };
|
|
43
|
+
//# sourceMappingURL=focus_trap_controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;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;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TCyclicFocusTrapStrategyProps } from "./strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types";
|
|
2
|
+
import { FOCUS_TRAP_STRATEGY_TYPES } from "./strategies/focus_trap_strategy_constants";
|
|
3
|
+
import { TSentinelFocusTrapStrategyProps } from "./strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types";
|
|
4
|
+
import { TTogglerFocusTrapStrategyProps } from "./strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types";
|
|
5
|
+
export declare type TSentinelFocusTrapProps = TSentinelFocusTrapStrategyProps & {
|
|
6
|
+
mode: typeof FOCUS_TRAP_STRATEGY_TYPES.sentinel;
|
|
7
|
+
};
|
|
8
|
+
export declare type TCyclicFocusTrapProps = TCyclicFocusTrapStrategyProps & {
|
|
9
|
+
mode: typeof FOCUS_TRAP_STRATEGY_TYPES.cyclic;
|
|
10
|
+
};
|
|
11
|
+
export declare type TTogglerFocusTrapProps = TTogglerFocusTrapStrategyProps & {
|
|
12
|
+
mode: typeof FOCUS_TRAP_STRATEGY_TYPES.toggler;
|
|
13
|
+
};
|
|
14
|
+
export declare type TFocusTrapProps = TSentinelFocusTrapProps | TCyclicFocusTrapProps | TTogglerFocusTrapProps;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types";
|
|
2
|
+
import "./strategies/focus_trap_strategy_constants";
|
|
3
|
+
import "./strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types";
|
|
4
|
+
import "./strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types";
|
|
5
|
+
//# sourceMappingURL=focus_trap_controller_types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus_trap_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/focus_trap_controller/focus_trap_controller_types.ts"],"names":[],"mappings":"AAAA,OAA8C,0EAA0E,CAAC;AACzH,OAA0C,4CAA4C,CAAC;AACvF,OAAgD,8EAA8E,CAAC;AAC/H,OAA+C,4EAA4E,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IBaseFocusTrapStrategy } from './base_focus_trap_strategy_types';
|
|
2
|
+
export declare abstract class BaseFocusTrapStrategy implements IBaseFocusTrapStrategy {
|
|
3
|
+
protected readonly getContainer: () => HTMLElement | undefined;
|
|
4
|
+
protected active: boolean;
|
|
5
|
+
noAutofocus: boolean;
|
|
6
|
+
constructor(getContainer: () => HTMLElement | undefined);
|
|
7
|
+
attach(): void;
|
|
8
|
+
detach(): void;
|
|
9
|
+
activate(): void;
|
|
10
|
+
deactivate(): void;
|
|
11
|
+
getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
12
|
+
protected _handleKeyDown: (ev: KeyboardEvent) => void;
|
|
13
|
+
private _isElementTrulyFocusable;
|
|
14
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
2
|
+
|
|
3
|
+
class BaseFocusTrapStrategy {
|
|
4
|
+
constructor(getContainer) {
|
|
5
|
+
this.getContainer = getContainer;
|
|
6
|
+
this.active = false;
|
|
7
|
+
this.noAutofocus = false;
|
|
8
|
+
this._handleKeyDown = (ev) => {
|
|
9
|
+
if (!this.active || ev.code !== 'Tab')
|
|
10
|
+
return;
|
|
11
|
+
const container = this.getContainer();
|
|
12
|
+
if (!container)
|
|
13
|
+
return;
|
|
14
|
+
const focusableElements = this.getFocusableElements(container);
|
|
15
|
+
if (focusableElements.length === 0)
|
|
16
|
+
return;
|
|
17
|
+
const $target = ev.target;
|
|
18
|
+
if (ev.shiftKey) {
|
|
19
|
+
if ($target === focusableElements[0]) {
|
|
20
|
+
ev.preventDefault();
|
|
21
|
+
focusableElements[focusableElements.length - 1].focus();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if ($target === focusableElements[focusableElements.length - 1]) {
|
|
26
|
+
ev.preventDefault();
|
|
27
|
+
focusableElements[0].focus();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
attach() {
|
|
33
|
+
document.addEventListener('keydown', this._handleKeyDown);
|
|
34
|
+
}
|
|
35
|
+
detach() {
|
|
36
|
+
document.removeEventListener('keydown', this._handleKeyDown);
|
|
37
|
+
}
|
|
38
|
+
activate() {
|
|
39
|
+
this.active = true;
|
|
40
|
+
}
|
|
41
|
+
deactivate() {
|
|
42
|
+
this.active = false;
|
|
43
|
+
}
|
|
44
|
+
getFocusableElements(container) {
|
|
45
|
+
return UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
|
|
46
|
+
}
|
|
47
|
+
_isElementTrulyFocusable($el) {
|
|
48
|
+
const style = window.getComputedStyle($el);
|
|
49
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if ($el.nodeName === 'H-PORTAL')
|
|
53
|
+
return true;
|
|
54
|
+
const $parent = $el.parentElement;
|
|
55
|
+
if (!$parent)
|
|
56
|
+
return true;
|
|
57
|
+
return this._isElementTrulyFocusable($parent);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { BaseFocusTrapStrategy };
|
|
62
|
+
//# sourceMappingURL=base_focus_trap_strategy.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_focus_trap_strategy_types.js","sourceRoot":"","sources":["../../../../../../../../src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy';
|
|
2
|
+
import { IBaseFocusTrapStrategy } from '../base_focus_trap_strategy_types';
|
|
3
|
+
import { TCyclicFocusTrapStrategyProps } from './cyclic_focus_trap_strategy_types';
|
|
4
|
+
export declare class CyclicFocusTrapStrategy extends BaseFocusTrapStrategy implements IBaseFocusTrapStrategy {
|
|
5
|
+
constructor({ getContainer }: TCyclicFocusTrapStrategyProps);
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy.js';
|
|
2
|
+
|
|
3
|
+
class CyclicFocusTrapStrategy extends BaseFocusTrapStrategy {
|
|
4
|
+
constructor({ getContainer }) {
|
|
5
|
+
super(getContainer);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { CyclicFocusTrapStrategy };
|
|
10
|
+
//# sourceMappingURL=cyclic_focus_trap_strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cyclic_focus_trap_strategy_types.js","sourceRoot":"","sources":["../../../../../../../../../src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy';
|
|
2
|
+
import { IBaseFocusTrapStrategy } from '../base_focus_trap_strategy_types';
|
|
3
|
+
import { TSentinelFocusTrapStrategyProps } from './sentinel_focus_trap_strategy_types';
|
|
4
|
+
export declare class SentinelFocusTrapStrategy extends BaseFocusTrapStrategy implements IBaseFocusTrapStrategy {
|
|
5
|
+
constructor({ getContainer, noAutofocus }: TSentinelFocusTrapStrategyProps);
|
|
6
|
+
activate(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy.js';
|
|
2
|
+
|
|
3
|
+
class SentinelFocusTrapStrategy extends BaseFocusTrapStrategy {
|
|
4
|
+
constructor({ getContainer, noAutofocus = false }) {
|
|
5
|
+
super(getContainer);
|
|
6
|
+
this.noAutofocus = noAutofocus;
|
|
7
|
+
}
|
|
8
|
+
activate() {
|
|
9
|
+
this.active = true;
|
|
10
|
+
if (!this.noAutofocus) {
|
|
11
|
+
requestAnimationFrame(() => {
|
|
12
|
+
const container = this.getContainer();
|
|
13
|
+
if (!container)
|
|
14
|
+
return;
|
|
15
|
+
const focusableElements = this.getFocusableElements(container);
|
|
16
|
+
const shouldSkipStartSentinel = focusableElements.length > 1;
|
|
17
|
+
const $firstFocusableContentElement = shouldSkipStartSentinel ? focusableElements[1] : focusableElements[0];
|
|
18
|
+
$firstFocusableContentElement === null || $firstFocusableContentElement === void 0 ? void 0 : $firstFocusableContentElement.focus();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { SentinelFocusTrapStrategy };
|
|
25
|
+
//# sourceMappingURL=sentinel_focus_trap_strategy.js.map
|
|
@@ -0,0 +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;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentinel_focus_trap_strategy_types.js","sourceRoot":"","sources":["../../../../../../../../../src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy';
|
|
2
|
+
import { IBaseFocusTrapStrategy } from '../base_focus_trap_strategy_types';
|
|
3
|
+
import { TTogglerFocusTrapStrategyProps } from './toggler_focus_trap_strategy_types';
|
|
4
|
+
export declare class TogglerFocusTrapStrategy extends BaseFocusTrapStrategy implements IBaseFocusTrapStrategy {
|
|
5
|
+
#private;
|
|
6
|
+
constructor({ getContainer, getToggler }: TTogglerFocusTrapStrategyProps);
|
|
7
|
+
protected _handleKeyDown: (ev: KeyboardEvent) => void;
|
|
8
|
+
private _focusLastContentElement;
|
|
9
|
+
private _focusFirstContentElement;
|
|
10
|
+
private _returnToToggler;
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy.js';
|
|
3
|
+
|
|
4
|
+
var _TogglerFocusTrapStrategy_getToggler;
|
|
5
|
+
class TogglerFocusTrapStrategy extends BaseFocusTrapStrategy {
|
|
6
|
+
constructor({ getContainer, getToggler }) {
|
|
7
|
+
super(getContainer);
|
|
8
|
+
_TogglerFocusTrapStrategy_getToggler.set(this, void 0);
|
|
9
|
+
this._handleKeyDown = (ev) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (!this.active || ev.code !== 'Tab')
|
|
12
|
+
return;
|
|
13
|
+
const container = this.getContainer();
|
|
14
|
+
const toggler = (_a = __classPrivateFieldGet(this, _TogglerFocusTrapStrategy_getToggler, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
15
|
+
if (!container || !toggler)
|
|
16
|
+
return;
|
|
17
|
+
const $target = ev.target;
|
|
18
|
+
const focusableElements = this.getFocusableElements(container);
|
|
19
|
+
if (ev.shiftKey) {
|
|
20
|
+
if (toggler.contains($target))
|
|
21
|
+
return this._focusLastContentElement(ev, focusableElements);
|
|
22
|
+
if ($target === focusableElements[0])
|
|
23
|
+
return this._returnToToggler(ev, toggler);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (toggler.contains($target))
|
|
27
|
+
return this._focusFirstContentElement(ev, focusableElements);
|
|
28
|
+
if ($target === focusableElements[focusableElements.length - 1])
|
|
29
|
+
return this._returnToToggler(ev, toggler);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
__classPrivateFieldSet(this, _TogglerFocusTrapStrategy_getToggler, getToggler, "f");
|
|
33
|
+
}
|
|
34
|
+
_focusLastContentElement(ev, focusableElements) {
|
|
35
|
+
const last = focusableElements[focusableElements.length - 1];
|
|
36
|
+
if (!last)
|
|
37
|
+
return;
|
|
38
|
+
ev.preventDefault();
|
|
39
|
+
last.focus();
|
|
40
|
+
}
|
|
41
|
+
_focusFirstContentElement(ev, focusableElements) {
|
|
42
|
+
const first = focusableElements[0];
|
|
43
|
+
if (!first)
|
|
44
|
+
return;
|
|
45
|
+
ev.preventDefault();
|
|
46
|
+
first.focus();
|
|
47
|
+
}
|
|
48
|
+
_returnToToggler(ev, toggler) {
|
|
49
|
+
ev.preventDefault();
|
|
50
|
+
toggler.focus();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
_TogglerFocusTrapStrategy_getToggler = new WeakMap();
|
|
54
|
+
|
|
55
|
+
export { TogglerFocusTrapStrategy };
|
|
56
|
+
//# sourceMappingURL=toggler_focus_trap_strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,kDAAsD;AACrH;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;"}
|