@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
|
@@ -13,6 +13,8 @@ var ref_js = require('lit-html/directives/ref.js');
|
|
|
13
13
|
var portal_constants = require('../portal/portal_constants.js');
|
|
14
14
|
var backdrop_constants = require('../backdrop/backdrop_constants.js');
|
|
15
15
|
var backdrop_controller = require('../backdrop/controller/backdrop_controller.js');
|
|
16
|
+
var focus_trap_strategy_constants = require('../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js');
|
|
17
|
+
var focus_trap_controller = require('../../controllers/focus_trap_controller/focus_trap_controller.js');
|
|
16
18
|
var modal_constants = require('./modal_constants.js');
|
|
17
19
|
var modal_close = require('./modal_close.js');
|
|
18
20
|
|
|
@@ -25,6 +27,7 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
25
27
|
this.transition = 'scale';
|
|
26
28
|
this.modalLabel = '';
|
|
27
29
|
this.noAutofocus = false;
|
|
30
|
+
this.isSearchFocusTrapFixEnabled = false;
|
|
28
31
|
this._firstFocusableElement = undefined;
|
|
29
32
|
this._focusableElements = null;
|
|
30
33
|
this._lastFocusableElement = undefined;
|
|
@@ -40,22 +43,35 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
40
43
|
document.addEventListener('keydown', this._bindCloseOnEsc);
|
|
41
44
|
document.addEventListener(backdrop_constants.BACKDROP_EVENTS.clicked, this.close);
|
|
42
45
|
this._dispatchModalOpenedEvent();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
this._focusTrapController.activate();
|
|
47
|
+
if (this.isSearchFocusTrapFixEnabled) {
|
|
48
|
+
this._focusTrapController.activate();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (!this.noAutofocus) {
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
var _a;
|
|
54
|
+
(_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
55
|
+
window.scrollTo(0, scrollY);
|
|
56
|
+
}, 0);
|
|
57
|
+
}
|
|
49
58
|
}
|
|
50
59
|
},
|
|
51
60
|
false: () => {
|
|
52
61
|
HModal_1.openModals = HModal_1.openModals.filter((modal) => modal !== this);
|
|
53
62
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
54
63
|
document.removeEventListener(backdrop_constants.BACKDROP_EVENTS.clicked, this.close);
|
|
64
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
65
|
+
this._focusTrapController.deactivate();
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
68
|
};
|
|
58
69
|
this._backdropController = new backdrop_controller.BackdropController();
|
|
70
|
+
this._focusTrapController = new focus_trap_controller.FocusTrapController(this, {
|
|
71
|
+
mode: focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.sentinel,
|
|
72
|
+
getContainer: () => this._contentRef.value,
|
|
73
|
+
noAutofocus: this.noAutofocus
|
|
74
|
+
});
|
|
59
75
|
this._keepFocusWithinModal = (ev) => {
|
|
60
76
|
var _a;
|
|
61
77
|
const isTabPressed = ev.code === 'Tab';
|
|
@@ -149,7 +165,8 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
149
165
|
connectedCallback() {
|
|
150
166
|
super.connectedCallback();
|
|
151
167
|
HModal_1._appendModalsPortal();
|
|
152
|
-
|
|
168
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
169
|
+
document.addEventListener('keyup', this._keepFocusWithinModal);
|
|
153
170
|
document.addEventListener(modal_constants.MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
154
171
|
}
|
|
155
172
|
disconnectedCallback() {
|
|
@@ -158,17 +175,23 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
158
175
|
this.close();
|
|
159
176
|
document.removeEventListener(modal_constants.MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
160
177
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
161
|
-
|
|
178
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
179
|
+
document.removeEventListener('keyup', this._keepFocusWithinModal);
|
|
162
180
|
}
|
|
163
181
|
firstUpdated(props) {
|
|
164
182
|
super.firstUpdated(props);
|
|
165
|
-
this.
|
|
166
|
-
|
|
183
|
+
if (!this.isSearchFocusTrapFixEnabled) {
|
|
184
|
+
this._firstFocusableElement = this._focusSentinelStart.value;
|
|
185
|
+
this._lastFocusableElement = this._focusSentinelEnd.value;
|
|
186
|
+
}
|
|
167
187
|
}
|
|
168
188
|
updated(changedProps) {
|
|
169
189
|
if (changedProps.has(modal_constants.MODAL_OPENED_PROP)) {
|
|
170
190
|
this._propsChangeStrategies[modal_constants.MODAL_OPENED_PROP][String(this[modal_constants.MODAL_OPENED_PROP])]();
|
|
171
191
|
}
|
|
192
|
+
if (this.isSearchFocusTrapFixEnabled && changedProps.has('noAutofocus')) {
|
|
193
|
+
this._focusTrapController.strategy.noAutofocus = this.noAutofocus;
|
|
194
|
+
}
|
|
172
195
|
}
|
|
173
196
|
_setFocusToFirstFocusableElementInModalOrCloseBtn() {
|
|
174
197
|
if (this.noAutofocus)
|
|
@@ -197,7 +220,8 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
197
220
|
setTimeout(() => {
|
|
198
221
|
var _a;
|
|
199
222
|
(_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
|
|
200
|
-
this.
|
|
223
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
224
|
+
this._setFocusToFirstFocusableElementInModalOrCloseBtn();
|
|
201
225
|
resolve();
|
|
202
226
|
}, transitionDuration);
|
|
203
227
|
});
|
|
@@ -256,6 +280,10 @@ tslib_es6.__decorate([
|
|
|
256
280
|
decorators_js.property({ type: Boolean, attribute: 'no-autofocus' }),
|
|
257
281
|
tslib_es6.__metadata("design:type", Object)
|
|
258
282
|
], exports.HModal.prototype, "noAutofocus", void 0);
|
|
283
|
+
tslib_es6.__decorate([
|
|
284
|
+
decorators_js.property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
|
|
285
|
+
tslib_es6.__metadata("design:type", Boolean)
|
|
286
|
+
], exports.HModal.prototype, "isSearchFocusTrapFixEnabled", void 0);
|
|
259
287
|
tslib_es6.__decorate([
|
|
260
288
|
decorators_js.state(),
|
|
261
289
|
tslib_es6.__metadata("design:type", Object)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -13,6 +13,8 @@ var ref_js = require('lit-html/directives/ref.js');
|
|
|
13
13
|
var portal_constants = require('../portal/portal_constants.js');
|
|
14
14
|
var backdrop_constants = require('../backdrop/backdrop_constants.js');
|
|
15
15
|
var backdrop_controller = require('../backdrop/controller/backdrop_controller.js');
|
|
16
|
+
var focus_trap_strategy_constants = require('../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js');
|
|
17
|
+
var focus_trap_controller = require('../../controllers/focus_trap_controller/focus_trap_controller.js');
|
|
16
18
|
var sheet_constants = require('./sheet_constants.js');
|
|
17
19
|
var sheet_close = require('./sheet_close.js');
|
|
18
20
|
|
|
@@ -24,6 +26,7 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
|
|
|
24
26
|
this.class = '';
|
|
25
27
|
this.transition = 'scale';
|
|
26
28
|
this.sheetLabel = '';
|
|
29
|
+
this.isSearchFocusTrapFixEnabled = false;
|
|
27
30
|
this._firstFocusableElement = undefined;
|
|
28
31
|
this._focusableElements = null;
|
|
29
32
|
this._lastFocusableElement = undefined;
|
|
@@ -39,20 +42,31 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
|
|
|
39
42
|
document.addEventListener('keydown', this._bindCloseOnEsc);
|
|
40
43
|
document.addEventListener(backdrop_constants.BACKDROP_EVENTS.clicked, this.close);
|
|
41
44
|
this._dispatchSheetOpenedEvent();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (this.isSearchFocusTrapFixEnabled) {
|
|
46
|
+
this._focusTrapController.activate();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
var _a;
|
|
51
|
+
(_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
52
|
+
window.scrollTo(0, scrollY);
|
|
53
|
+
}, 0);
|
|
54
|
+
}
|
|
47
55
|
},
|
|
48
56
|
false: () => {
|
|
49
57
|
HSheet_1.openSheets = HSheet_1.openSheets.filter((sheet) => sheet !== this);
|
|
50
58
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
51
59
|
document.removeEventListener(backdrop_constants.BACKDROP_EVENTS.clicked, this.close);
|
|
60
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
61
|
+
this._focusTrapController.deactivate();
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
64
|
};
|
|
55
65
|
this._backdropController = new backdrop_controller.BackdropController();
|
|
66
|
+
this._focusTrapController = new focus_trap_controller.FocusTrapController(this, {
|
|
67
|
+
mode: focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.sentinel,
|
|
68
|
+
getContainer: () => this._contentRef.value
|
|
69
|
+
});
|
|
56
70
|
this._keepFocusWithinSheet = (ev) => {
|
|
57
71
|
var _a;
|
|
58
72
|
const isTabPressed = ev.code === 'Tab';
|
|
@@ -146,7 +160,8 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
|
|
|
146
160
|
connectedCallback() {
|
|
147
161
|
super.connectedCallback();
|
|
148
162
|
HSheet_1._appendSheetPortal();
|
|
149
|
-
|
|
163
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
164
|
+
document.addEventListener('keyup', this._keepFocusWithinSheet);
|
|
150
165
|
document.addEventListener(sheet_constants.SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
151
166
|
}
|
|
152
167
|
disconnectedCallback() {
|
|
@@ -155,12 +170,15 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
|
|
|
155
170
|
this.close();
|
|
156
171
|
document.removeEventListener(sheet_constants.SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
157
172
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
158
|
-
|
|
173
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
174
|
+
document.removeEventListener('keyup', this._keepFocusWithinSheet);
|
|
159
175
|
}
|
|
160
176
|
firstUpdated(props) {
|
|
161
177
|
super.firstUpdated(props);
|
|
162
|
-
this.
|
|
163
|
-
|
|
178
|
+
if (!this.isSearchFocusTrapFixEnabled) {
|
|
179
|
+
this._firstFocusableElement = this._focusSentinelStart.value;
|
|
180
|
+
this._lastFocusableElement = this._focusSentinelEnd.value;
|
|
181
|
+
}
|
|
164
182
|
}
|
|
165
183
|
updated(changedProps) {
|
|
166
184
|
if (changedProps.has(sheet_constants.SHEET_OPENED_PROP)) {
|
|
@@ -192,7 +210,8 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
|
|
|
192
210
|
setTimeout(() => {
|
|
193
211
|
var _a;
|
|
194
212
|
(_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`sheet_show-${this.transition}-start`, `sheet_show-${this.transition}-end`);
|
|
195
|
-
this.
|
|
213
|
+
if (!this.isSearchFocusTrapFixEnabled)
|
|
214
|
+
this._setFocusToFirstFocusableElementInSheetOrCloseBtn();
|
|
196
215
|
resolve();
|
|
197
216
|
}, transitionDuration);
|
|
198
217
|
});
|
|
@@ -245,6 +264,10 @@ tslib_es6.__decorate([
|
|
|
245
264
|
decorators_js.property({ type: String, attribute: 'sheet-label' }),
|
|
246
265
|
tslib_es6.__metadata("design:type", Object)
|
|
247
266
|
], exports.HSheet.prototype, "sheetLabel", void 0);
|
|
267
|
+
tslib_es6.__decorate([
|
|
268
|
+
decorators_js.property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
|
|
269
|
+
tslib_es6.__metadata("design:type", Boolean)
|
|
270
|
+
], exports.HSheet.prototype, "isSearchFocusTrapFixEnabled", void 0);
|
|
248
271
|
tslib_es6.__decorate([
|
|
249
272
|
decorators_js.state(),
|
|
250
273
|
tslib_es6.__metadata("design:type", Object)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
|
|
6
|
+
require('lit');
|
|
7
|
+
var sentinel_focus_trap_strategy = require('./strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js');
|
|
8
|
+
var cyclic_focus_trap_strategy = require('./strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js');
|
|
9
|
+
var toggler_focus_trap_strategy = require('./strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js');
|
|
10
|
+
var focus_trap_strategy_constants = require('./strategies/focus_trap_strategy_constants.js');
|
|
11
|
+
|
|
12
|
+
var _a, _FocusTrapController_strategy, _FocusTrapController_createStrategy;
|
|
13
|
+
class FocusTrapController {
|
|
14
|
+
constructor(host, props) {
|
|
15
|
+
_FocusTrapController_strategy.set(this, void 0);
|
|
16
|
+
tslib_es6.__classPrivateFieldSet(this, _FocusTrapController_strategy, tslib_es6.__classPrivateFieldGet(FocusTrapController, _a, "m", _FocusTrapController_createStrategy).call(FocusTrapController, props), "f");
|
|
17
|
+
host.addController(this);
|
|
18
|
+
}
|
|
19
|
+
get strategy() {
|
|
20
|
+
return tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
|
|
21
|
+
}
|
|
22
|
+
hostConnected() {
|
|
23
|
+
tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").attach();
|
|
24
|
+
}
|
|
25
|
+
hostDisconnected() {
|
|
26
|
+
tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").detach();
|
|
27
|
+
}
|
|
28
|
+
activate() {
|
|
29
|
+
tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").activate();
|
|
30
|
+
}
|
|
31
|
+
deactivate() {
|
|
32
|
+
tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").deactivate();
|
|
33
|
+
}
|
|
34
|
+
getFocusableElements(container) {
|
|
35
|
+
return tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").getFocusableElements(container);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
_a = FocusTrapController, _FocusTrapController_strategy = new WeakMap(), _FocusTrapController_createStrategy = function _FocusTrapController_createStrategy(props) {
|
|
39
|
+
switch (props.mode) {
|
|
40
|
+
case focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.sentinel: return new sentinel_focus_trap_strategy.SentinelFocusTrapStrategy(props);
|
|
41
|
+
case focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.cyclic: return new cyclic_focus_trap_strategy.CyclicFocusTrapStrategy(props);
|
|
42
|
+
case focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.toggler: return new toggler_focus_trap_strategy.TogglerFocusTrapStrategy(props);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.FocusTrapController = FocusTrapController;
|
|
47
|
+
//# sourceMappingURL=focus_trap_controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utilities = require('@dreamcommerce/utilities');
|
|
6
|
+
|
|
7
|
+
class BaseFocusTrapStrategy {
|
|
8
|
+
constructor(getContainer) {
|
|
9
|
+
this.getContainer = getContainer;
|
|
10
|
+
this.active = false;
|
|
11
|
+
this.noAutofocus = false;
|
|
12
|
+
this._handleKeyDown = (ev) => {
|
|
13
|
+
if (!this.active || ev.code !== 'Tab')
|
|
14
|
+
return;
|
|
15
|
+
const container = this.getContainer();
|
|
16
|
+
if (!container)
|
|
17
|
+
return;
|
|
18
|
+
const focusableElements = this.getFocusableElements(container);
|
|
19
|
+
if (focusableElements.length === 0)
|
|
20
|
+
return;
|
|
21
|
+
const $target = ev.target;
|
|
22
|
+
if (ev.shiftKey) {
|
|
23
|
+
if ($target === focusableElements[0]) {
|
|
24
|
+
ev.preventDefault();
|
|
25
|
+
focusableElements[focusableElements.length - 1].focus();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if ($target === focusableElements[focusableElements.length - 1]) {
|
|
30
|
+
ev.preventDefault();
|
|
31
|
+
focusableElements[0].focus();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
attach() {
|
|
37
|
+
document.addEventListener('keydown', this._handleKeyDown);
|
|
38
|
+
}
|
|
39
|
+
detach() {
|
|
40
|
+
document.removeEventListener('keydown', this._handleKeyDown);
|
|
41
|
+
}
|
|
42
|
+
activate() {
|
|
43
|
+
this.active = true;
|
|
44
|
+
}
|
|
45
|
+
deactivate() {
|
|
46
|
+
this.active = false;
|
|
47
|
+
}
|
|
48
|
+
getFocusableElements(container) {
|
|
49
|
+
return utilities.UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
|
|
50
|
+
}
|
|
51
|
+
_isElementTrulyFocusable($el) {
|
|
52
|
+
const style = window.getComputedStyle($el);
|
|
53
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if ($el.nodeName === 'H-PORTAL')
|
|
57
|
+
return true;
|
|
58
|
+
const $parent = $el.parentElement;
|
|
59
|
+
if (!$parent)
|
|
60
|
+
return true;
|
|
61
|
+
return this._isElementTrulyFocusable($parent);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.BaseFocusTrapStrategy = BaseFocusTrapStrategy;
|
|
66
|
+
//# 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;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var base_focus_trap_strategy = require('../base_focus_trap_strategy.js');
|
|
6
|
+
|
|
7
|
+
class CyclicFocusTrapStrategy extends base_focus_trap_strategy.BaseFocusTrapStrategy {
|
|
8
|
+
constructor({ getContainer }) {
|
|
9
|
+
super(getContainer);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.CyclicFocusTrapStrategy = CyclicFocusTrapStrategy;
|
|
14
|
+
//# 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;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const FOCUS_TRAP_STRATEGY_TYPES = {
|
|
6
|
+
cyclic: 'cyclic',
|
|
7
|
+
toggler: 'toggler',
|
|
8
|
+
sentinel: 'sentinel',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.FOCUS_TRAP_STRATEGY_TYPES = FOCUS_TRAP_STRATEGY_TYPES;
|
|
12
|
+
//# sourceMappingURL=focus_trap_strategy_constants.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;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var base_focus_trap_strategy = require('../base_focus_trap_strategy.js');
|
|
6
|
+
|
|
7
|
+
class SentinelFocusTrapStrategy extends base_focus_trap_strategy.BaseFocusTrapStrategy {
|
|
8
|
+
constructor({ getContainer, noAutofocus = false }) {
|
|
9
|
+
super(getContainer);
|
|
10
|
+
this.noAutofocus = noAutofocus;
|
|
11
|
+
}
|
|
12
|
+
activate() {
|
|
13
|
+
this.active = true;
|
|
14
|
+
if (!this.noAutofocus) {
|
|
15
|
+
requestAnimationFrame(() => {
|
|
16
|
+
const container = this.getContainer();
|
|
17
|
+
if (!container)
|
|
18
|
+
return;
|
|
19
|
+
const focusableElements = this.getFocusableElements(container);
|
|
20
|
+
const shouldSkipStartSentinel = focusableElements.length > 1;
|
|
21
|
+
const $firstFocusableContentElement = shouldSkipStartSentinel ? focusableElements[1] : focusableElements[0];
|
|
22
|
+
$firstFocusableContentElement === null || $firstFocusableContentElement === void 0 ? void 0 : $firstFocusableContentElement.focus();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.SentinelFocusTrapStrategy = SentinelFocusTrapStrategy;
|
|
29
|
+
//# 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;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../../../../../../../external/tslib/tslib.es6.js');
|
|
6
|
+
var base_focus_trap_strategy = require('../base_focus_trap_strategy.js');
|
|
7
|
+
|
|
8
|
+
var _TogglerFocusTrapStrategy_getToggler;
|
|
9
|
+
class TogglerFocusTrapStrategy extends base_focus_trap_strategy.BaseFocusTrapStrategy {
|
|
10
|
+
constructor({ getContainer, getToggler }) {
|
|
11
|
+
super(getContainer);
|
|
12
|
+
_TogglerFocusTrapStrategy_getToggler.set(this, void 0);
|
|
13
|
+
this._handleKeyDown = (ev) => {
|
|
14
|
+
var _a;
|
|
15
|
+
if (!this.active || ev.code !== 'Tab')
|
|
16
|
+
return;
|
|
17
|
+
const container = this.getContainer();
|
|
18
|
+
const toggler = (_a = tslib_es6.__classPrivateFieldGet(this, _TogglerFocusTrapStrategy_getToggler, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
19
|
+
if (!container || !toggler)
|
|
20
|
+
return;
|
|
21
|
+
const $target = ev.target;
|
|
22
|
+
const focusableElements = this.getFocusableElements(container);
|
|
23
|
+
if (ev.shiftKey) {
|
|
24
|
+
if (toggler.contains($target))
|
|
25
|
+
return this._focusLastContentElement(ev, focusableElements);
|
|
26
|
+
if ($target === focusableElements[0])
|
|
27
|
+
return this._returnToToggler(ev, toggler);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (toggler.contains($target))
|
|
31
|
+
return this._focusFirstContentElement(ev, focusableElements);
|
|
32
|
+
if ($target === focusableElements[focusableElements.length - 1])
|
|
33
|
+
return this._returnToToggler(ev, toggler);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
tslib_es6.__classPrivateFieldSet(this, _TogglerFocusTrapStrategy_getToggler, getToggler, "f");
|
|
37
|
+
}
|
|
38
|
+
_focusLastContentElement(ev, focusableElements) {
|
|
39
|
+
const last = focusableElements[focusableElements.length - 1];
|
|
40
|
+
if (!last)
|
|
41
|
+
return;
|
|
42
|
+
ev.preventDefault();
|
|
43
|
+
last.focus();
|
|
44
|
+
}
|
|
45
|
+
_focusFirstContentElement(ev, focusableElements) {
|
|
46
|
+
const first = focusableElements[0];
|
|
47
|
+
if (!first)
|
|
48
|
+
return;
|
|
49
|
+
ev.preventDefault();
|
|
50
|
+
first.focus();
|
|
51
|
+
}
|
|
52
|
+
_returnToToggler(ev, toggler) {
|
|
53
|
+
ev.preventDefault();
|
|
54
|
+
toggler.focus();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
_TogglerFocusTrapStrategy_getToggler = new WeakMap();
|
|
58
|
+
|
|
59
|
+
exports.TogglerFocusTrapStrategy = TogglerFocusTrapStrategy;
|
|
60
|
+
//# sourceMappingURL=toggler_focus_trap_strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,kDAAsD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -26,6 +26,7 @@ export declare class HDropdown extends PhoenixLightLitElement implements IDropdo
|
|
|
26
26
|
private _dropdownContentChildrenHeight;
|
|
27
27
|
private _hasScrollableClassInitially;
|
|
28
28
|
private _backdropController;
|
|
29
|
+
private _focusTrapController;
|
|
29
30
|
constructor();
|
|
30
31
|
connectedCallback(): Promise<void>;
|
|
31
32
|
private static _appendDropdownPortal;
|
|
@@ -43,16 +44,8 @@ export declare class HDropdown extends PhoenixLightLitElement implements IDropdo
|
|
|
43
44
|
private _observeScrollToggling;
|
|
44
45
|
private _toggleScroll;
|
|
45
46
|
private _closeDropdownOnEscape;
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
private _handleFocusFromTogglerForwards;
|
|
49
|
-
private _handleFocusFromSentinelEndForwards;
|
|
50
|
-
private _keepFocusWithinDropdownBackwards;
|
|
51
|
-
private _handleDefaultFocusFromDropdownBackwards;
|
|
52
|
-
private _handleFocusFromTogglerBackwards;
|
|
53
|
-
private _handleFocusFromSentinelStartBackwards;
|
|
54
|
-
private _getTrulyFocusableElements;
|
|
55
|
-
private _isElementTrulyFocusable;
|
|
47
|
+
private _handleTabExitForward;
|
|
48
|
+
private _handleTabExitBackward;
|
|
56
49
|
private _hoverToggle;
|
|
57
50
|
private _isHoveredWithinDropdown;
|
|
58
51
|
private _focusOnFirstContentElement;
|