@shoper/phoenix_design_system 1.18.23-4 → 1.18.23-6
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 +2 -2
- package/build/cjs/packages/phoenix/src/components/form/search/search.js +3 -5
- package/build/cjs/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/modal/modal.js +5 -5
- package/build/cjs/packages/phoenix/src/components/sheet/sheet.js +4 -4
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +14 -176
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js +53 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js +36 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +22 -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.js +93 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js +77 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +2 -2
- package/build/esm/packages/phoenix/src/components/form/search/search.js +3 -5
- package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/modal/modal.js +5 -5
- package/build/esm/packages/phoenix/src/components/sheet/sheet.js +4 -4
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +10 -17
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +15 -177
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +12 -11
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +1 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.d.ts +21 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js +49 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.d.ts +12 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js +32 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +13 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +17 -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/focus_trap_strategy_types.d.ts +15 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.js +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.d.ts +32 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js +89 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.d.ts +22 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js +73 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js.map +1 -0
- package/package.json +1 -1
|
@@ -30,11 +30,9 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
30
30
|
this._id = v4();
|
|
31
31
|
this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
|
|
32
32
|
this._searchContentContainerId = v4();
|
|
33
|
-
this._mobileFocusTrapController = new FocusTrapController({
|
|
34
|
-
|
|
35
|
-
getContainer: () => this
|
|
36
|
-
noAutofocus: true,
|
|
37
|
-
cyclicKeydown: true
|
|
33
|
+
this._mobileFocusTrapController = new FocusTrapController(this, {
|
|
34
|
+
mode: 'cyclic',
|
|
35
|
+
getContainer: () => this
|
|
38
36
|
});
|
|
39
37
|
this._searchResultsRef = createRef();
|
|
40
38
|
this._searchHistoryRef = createRef();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wDAA4D;AAC3E;AACA;AACA;AACA,0BAA0B,wDAA4D;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wDAA4D;AAC3E;AACA;AACA;AACA,0BAA0B,wDAA4D;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -43,8 +43,8 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
this._backdropController = new BackdropController();
|
|
46
|
-
this._focusTrapController = new FocusTrapController({
|
|
47
|
-
|
|
46
|
+
this._focusTrapController = new FocusTrapController(this, {
|
|
47
|
+
mode: 'sentinel',
|
|
48
48
|
getContainer: () => this._contentRef.value,
|
|
49
49
|
noAutofocus: this.noAutofocus
|
|
50
50
|
});
|
|
@@ -134,14 +134,14 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
134
134
|
}
|
|
135
135
|
firstUpdated(props) {
|
|
136
136
|
super.firstUpdated(props);
|
|
137
|
-
this._focusTrapController.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
|
|
137
|
+
this._focusTrapController.strategy.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
|
|
138
138
|
}
|
|
139
139
|
updated(changedProps) {
|
|
140
140
|
if (changedProps.has(MODAL_OPENED_PROP)) {
|
|
141
141
|
this._propsChangeStrategies[MODAL_OPENED_PROP][String(this[MODAL_OPENED_PROP])]();
|
|
142
142
|
}
|
|
143
143
|
if (changedProps.has('noAutofocus')) {
|
|
144
|
-
this._focusTrapController.noAutofocus = this.noAutofocus;
|
|
144
|
+
this._focusTrapController.strategy.noAutofocus = this.noAutofocus;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
async open() {
|
|
@@ -159,7 +159,7 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
|
|
|
159
159
|
setTimeout(() => {
|
|
160
160
|
var _a;
|
|
161
161
|
(_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
|
|
162
|
-
this._focusTrapController.focusFirst();
|
|
162
|
+
this._focusTrapController.strategy.focusFirst();
|
|
163
163
|
resolve();
|
|
164
164
|
}, transitionDuration);
|
|
165
165
|
});
|
|
@@ -42,8 +42,8 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
this._backdropController = new BackdropController();
|
|
45
|
-
this._focusTrapController = new FocusTrapController({
|
|
46
|
-
|
|
45
|
+
this._focusTrapController = new FocusTrapController(this, {
|
|
46
|
+
mode: 'sentinel',
|
|
47
47
|
getContainer: () => this._contentRef.value
|
|
48
48
|
});
|
|
49
49
|
this._handleCloseFromCloseComponent = async (ev) => {
|
|
@@ -132,7 +132,7 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
132
132
|
}
|
|
133
133
|
firstUpdated(props) {
|
|
134
134
|
super.firstUpdated(props);
|
|
135
|
-
this._focusTrapController.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
|
|
135
|
+
this._focusTrapController.strategy.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
|
|
136
136
|
}
|
|
137
137
|
updated(changedProps) {
|
|
138
138
|
if (changedProps.has(SHEET_OPENED_PROP)) {
|
|
@@ -154,7 +154,7 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
|
|
|
154
154
|
setTimeout(() => {
|
|
155
155
|
var _a;
|
|
156
156
|
(_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`sheet_show-${this.transition}-start`, `sheet_show-${this.transition}-end`);
|
|
157
|
-
this._focusTrapController.focusFirst();
|
|
157
|
+
this._focusTrapController.strategy.focusFirst();
|
|
158
158
|
resolve();
|
|
159
159
|
}, transitionDuration);
|
|
160
160
|
});
|
package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import { ReactiveController } from 'lit';
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import type { SentinelFocusTrapStrategy } from './strategies/sentinel_focus_trap_strategy';
|
|
3
|
+
import type { CyclicFocusTrapStrategy } from './strategies/cyclic_focus_trap_strategy';
|
|
4
|
+
import type { TogglerFocusTrapStrategy } from './strategies/toggler_focus_trap_strategy';
|
|
5
|
+
import type { TFocusTrapProps, TSentinelFocusTrapProps, TCyclicFocusTrapProps } from './focus_trap_controller_types';
|
|
6
|
+
declare type StrategyFor<T extends TFocusTrapProps> = T extends TSentinelFocusTrapProps ? SentinelFocusTrapStrategy : T extends TCyclicFocusTrapProps ? CyclicFocusTrapStrategy : TogglerFocusTrapStrategy;
|
|
7
|
+
export declare class FocusTrapController<TProps extends TFocusTrapProps = TFocusTrapProps> implements ReactiveController {
|
|
4
8
|
#private;
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
constructor(host: ReactiveControllerHost, { mode, ...strategyProps }: TProps);
|
|
10
|
+
get strategy(): StrategyFor<TProps>;
|
|
7
11
|
hostConnected(): void;
|
|
8
12
|
hostDisconnected(): void;
|
|
9
|
-
/** Sentinel mode only: call once in firstUpdated with the two bookend elements. */
|
|
10
|
-
setSentinels(start: HTMLElement, end: HTMLElement): void;
|
|
11
13
|
activate(): void;
|
|
12
14
|
deactivate(): void;
|
|
13
|
-
/**
|
|
14
|
-
* Sentinel mode: move focus to the first real interactive element after the
|
|
15
|
-
* open transition completes (skips sentinelStart at index 0).
|
|
16
|
-
*/
|
|
17
|
-
focusFirst(): void;
|
|
18
|
-
private _getFocusableElements;
|
|
19
15
|
getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
20
|
-
private _isElementTrulyFocusable;
|
|
21
|
-
private _handleSentinelModeKeyUp;
|
|
22
|
-
private _handleCyclicKeyDown;
|
|
23
|
-
private _handleTogglerModeKeyDown;
|
|
24
16
|
}
|
|
17
|
+
export {};
|
package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js
CHANGED
|
@@ -1,196 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __classPrivateFieldSet, __classPrivateFieldGet } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import 'lit';
|
|
3
|
-
import {
|
|
3
|
+
import { FOCUS_TRAP_STRATEGY_STRATEGIES } from './strategies/focus_trap_strategy_constants.js';
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _FocusTrapController_strategy;
|
|
6
6
|
class FocusTrapController {
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
_FocusTrapController_cyclicKeydown.set(this, void 0);
|
|
11
|
-
_FocusTrapController_active.set(this, false);
|
|
12
|
-
_FocusTrapController_sentinelStart.set(this, void 0);
|
|
13
|
-
_FocusTrapController_sentinelEnd.set(this, void 0);
|
|
14
|
-
// ─── Sentinel mode ───────────────────────────────────────────────────────
|
|
15
|
-
this._handleSentinelModeKeyUp = (ev) => {
|
|
16
|
-
var _a;
|
|
17
|
-
if (!__classPrivateFieldGet(this, _FocusTrapController_active, "f") || ev.code !== 'Tab')
|
|
18
|
-
return;
|
|
19
|
-
const container = __classPrivateFieldGet(this, _FocusTrapController_getContainer, "f").call(this);
|
|
20
|
-
if (!container)
|
|
21
|
-
return;
|
|
22
|
-
if (ev.shiftKey) {
|
|
23
|
-
if (document.activeElement === __classPrivateFieldGet(this, _FocusTrapController_sentinelStart, "f")) {
|
|
24
|
-
const focusableElements = this._getFocusableElements(container);
|
|
25
|
-
(_a = focusableElements[focusableElements.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
26
|
-
ev.preventDefault();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else if (document.activeElement === __classPrivateFieldGet(this, _FocusTrapController_sentinelEnd, "f")) {
|
|
30
|
-
UiDomUtils.setFocusToFirstFocusableElementInContainer(container);
|
|
31
|
-
ev.preventDefault();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
// ─── Cyclic keydown mode ─────────────────────────────────────────────────
|
|
35
|
-
//
|
|
36
|
-
// No sentinel elements. Tab past the last focusable element wraps to the
|
|
37
|
-
// first; Shift+Tab past the first wraps to the last. Uses keydown +
|
|
38
|
-
// preventDefault so the browser never moves focus outside the container.
|
|
39
|
-
this._handleCyclicKeyDown = (ev) => {
|
|
40
|
-
if (!__classPrivateFieldGet(this, _FocusTrapController_active, "f") || ev.code !== 'Tab')
|
|
41
|
-
return;
|
|
42
|
-
const container = __classPrivateFieldGet(this, _FocusTrapController_getContainer, "f").call(this);
|
|
43
|
-
if (!container)
|
|
44
|
-
return;
|
|
45
|
-
const focusableElements = this._getFocusableElements(container);
|
|
46
|
-
if (focusableElements.length === 0)
|
|
47
|
-
return;
|
|
48
|
-
const $target = ev.target;
|
|
49
|
-
if (ev.shiftKey) {
|
|
50
|
-
if ($target === focusableElements[0]) {
|
|
51
|
-
ev.preventDefault();
|
|
52
|
-
focusableElements[focusableElements.length - 1].focus();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
if ($target === focusableElements[focusableElements.length - 1]) {
|
|
57
|
-
ev.preventDefault();
|
|
58
|
-
focusableElements[0].focus();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
// ─── Toggler mode ────────────────────────────────────────────────────────
|
|
63
|
-
//
|
|
64
|
-
// Cycle: toggler → content[0] → … → content[last] → toggler (and reverse).
|
|
65
|
-
// Uses keydown + preventDefault so the browser never moves focus on its own.
|
|
66
|
-
this._handleTogglerModeKeyDown = (ev) => {
|
|
67
|
-
var _a;
|
|
68
|
-
if (!__classPrivateFieldGet(this, _FocusTrapController_active, "f") || ev.code !== 'Tab')
|
|
69
|
-
return;
|
|
70
|
-
const container = __classPrivateFieldGet(this, _FocusTrapController_getContainer, "f").call(this);
|
|
71
|
-
const toggler = (_a = __classPrivateFieldGet(this, _FocusTrapController_getToggler, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
72
|
-
if (!container || !toggler)
|
|
73
|
-
return;
|
|
74
|
-
const $target = ev.target;
|
|
75
|
-
const focusableElements = this._getFocusableElements(container);
|
|
76
|
-
if (ev.shiftKey) {
|
|
77
|
-
// Shift+Tab on toggler → last content element
|
|
78
|
-
if (toggler.contains($target)) {
|
|
79
|
-
const last = focusableElements[focusableElements.length - 1];
|
|
80
|
-
if (!last)
|
|
81
|
-
return;
|
|
82
|
-
ev.preventDefault();
|
|
83
|
-
last.focus();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
// Shift+Tab on first content element → toggler
|
|
87
|
-
if ($target === focusableElements[0]) {
|
|
88
|
-
ev.preventDefault();
|
|
89
|
-
toggler.focus();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
// Tab on toggler → first content element
|
|
94
|
-
if (toggler.contains($target)) {
|
|
95
|
-
const first = focusableElements[0];
|
|
96
|
-
if (!first)
|
|
97
|
-
return;
|
|
98
|
-
ev.preventDefault();
|
|
99
|
-
first.focus();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
// Tab on last content element → toggler
|
|
103
|
-
if ($target === focusableElements[focusableElements.length - 1]) {
|
|
104
|
-
ev.preventDefault();
|
|
105
|
-
toggler.focus();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
__classPrivateFieldSet(this, _FocusTrapController_getContainer, getContainer, "f");
|
|
110
|
-
__classPrivateFieldSet(this, _FocusTrapController_getToggler, getToggler, "f");
|
|
111
|
-
__classPrivateFieldSet(this, _FocusTrapController_cyclicKeydown, cyclicKeydown, "f");
|
|
112
|
-
this.noAutofocus = noAutofocus;
|
|
7
|
+
constructor(host, { mode, ...strategyProps }) {
|
|
8
|
+
_FocusTrapController_strategy.set(this, void 0);
|
|
9
|
+
__classPrivateFieldSet(this, _FocusTrapController_strategy, new FOCUS_TRAP_STRATEGY_STRATEGIES[mode](strategyProps), "f");
|
|
113
10
|
host.addController(this);
|
|
114
11
|
}
|
|
12
|
+
get strategy() {
|
|
13
|
+
return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
|
|
14
|
+
}
|
|
115
15
|
hostConnected() {
|
|
116
|
-
|
|
117
|
-
document.addEventListener('keydown', this._handleCyclicKeyDown);
|
|
118
|
-
}
|
|
119
|
-
else if (__classPrivateFieldGet(this, _FocusTrapController_getToggler, "f")) {
|
|
120
|
-
document.addEventListener('keydown', this._handleTogglerModeKeyDown);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
document.addEventListener('keyup', this._handleSentinelModeKeyUp);
|
|
124
|
-
}
|
|
16
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").attach();
|
|
125
17
|
}
|
|
126
18
|
hostDisconnected() {
|
|
127
|
-
|
|
128
|
-
document.removeEventListener('keydown', this._handleCyclicKeyDown);
|
|
129
|
-
}
|
|
130
|
-
else if (__classPrivateFieldGet(this, _FocusTrapController_getToggler, "f")) {
|
|
131
|
-
document.removeEventListener('keydown', this._handleTogglerModeKeyDown);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
document.removeEventListener('keyup', this._handleSentinelModeKeyUp);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/** Sentinel mode only: call once in firstUpdated with the two bookend elements. */
|
|
138
|
-
setSentinels(start, end) {
|
|
139
|
-
__classPrivateFieldSet(this, _FocusTrapController_sentinelStart, start, "f");
|
|
140
|
-
__classPrivateFieldSet(this, _FocusTrapController_sentinelEnd, end, "f");
|
|
19
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").detach();
|
|
141
20
|
}
|
|
142
21
|
activate() {
|
|
143
|
-
|
|
144
|
-
// Sentinel mode: move focus to sentinelStart to prime the trap.
|
|
145
|
-
if (!__classPrivateFieldGet(this, _FocusTrapController_getToggler, "f") && !this.noAutofocus) {
|
|
146
|
-
const scrollY = window.scrollY;
|
|
147
|
-
setTimeout(() => {
|
|
148
|
-
var _a;
|
|
149
|
-
(_a = __classPrivateFieldGet(this, _FocusTrapController_sentinelStart, "f")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
150
|
-
window.scrollTo(0, scrollY);
|
|
151
|
-
}, 0);
|
|
152
|
-
}
|
|
22
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").activate();
|
|
153
23
|
}
|
|
154
24
|
deactivate() {
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Sentinel mode: move focus to the first real interactive element after the
|
|
159
|
-
* open transition completes (skips sentinelStart at index 0).
|
|
160
|
-
*/
|
|
161
|
-
focusFirst() {
|
|
162
|
-
if (this.noAutofocus)
|
|
163
|
-
return;
|
|
164
|
-
requestAnimationFrame(() => {
|
|
165
|
-
const container = __classPrivateFieldGet(this, _FocusTrapController_getContainer, "f").call(this);
|
|
166
|
-
if (!container)
|
|
167
|
-
return;
|
|
168
|
-
const focusableElements = this._getFocusableElements(container);
|
|
169
|
-
if (focusableElements.length > 0) {
|
|
170
|
-
focusableElements.length > 1 ? focusableElements[1].focus() : focusableElements[0].focus();
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
_getFocusableElements(container) {
|
|
175
|
-
return UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
|
|
25
|
+
__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").deactivate();
|
|
176
26
|
}
|
|
177
27
|
getFocusableElements(container) {
|
|
178
|
-
return this.
|
|
179
|
-
}
|
|
180
|
-
_isElementTrulyFocusable($el) {
|
|
181
|
-
const style = window.getComputedStyle($el);
|
|
182
|
-
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
if ($el.nodeName === 'H-PORTAL')
|
|
186
|
-
return true;
|
|
187
|
-
const $parent = $el.parentElement;
|
|
188
|
-
if (!$parent)
|
|
189
|
-
return true;
|
|
190
|
-
return this._isElementTrulyFocusable($parent);
|
|
28
|
+
return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").getFocusableElements(container);
|
|
191
29
|
}
|
|
192
30
|
}
|
|
193
|
-
|
|
31
|
+
_FocusTrapController_strategy = new WeakMap();
|
|
194
32
|
|
|
195
33
|
export { FocusTrapController };
|
|
196
34
|
//# sourceMappingURL=focus_trap_controller.js.map
|
|
@@ -1 +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;
|
|
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;"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
host: ReactiveControllerHost & HTMLElement;
|
|
1
|
+
export declare type TSentinelFocusTrapProps = {
|
|
2
|
+
mode: 'sentinel';
|
|
4
3
|
getContainer: () => HTMLElement | undefined;
|
|
5
4
|
noAutofocus?: boolean;
|
|
6
|
-
/** When provided, enables toggler mode: focus cycles between the toggler and the container's focusable elements. */
|
|
7
|
-
getToggler?: () => HTMLElement | null | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* When true, enables cyclic keydown mode: Tab past the last focusable element wraps to the
|
|
10
|
-
* first, and Shift+Tab past the first wraps to the last. No sentinel DOM elements required.
|
|
11
|
-
* Use this when the host element is not portaled and `inert` is not applied to background content.
|
|
12
|
-
*/
|
|
13
|
-
cyclicKeydown?: boolean;
|
|
14
5
|
};
|
|
6
|
+
export declare type TCyclicFocusTrapProps = {
|
|
7
|
+
mode: 'cyclic';
|
|
8
|
+
getContainer: () => HTMLElement | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare type TTogglerFocusTrapProps = {
|
|
11
|
+
mode: 'toggler';
|
|
12
|
+
getContainer: () => HTMLElement | undefined;
|
|
13
|
+
getToggler: () => HTMLElement | null | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare type TFocusTrapProps = TSentinelFocusTrapProps | TCyclicFocusTrapProps | TTogglerFocusTrapProps;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=focus_trap_controller_types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus_trap_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/focus_trap_controller/focus_trap_controller_types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"focus_trap_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/focus_trap_controller/focus_trap_controller_types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FocusTrapStrategy } from './focus_trap_strategy';
|
|
2
|
+
import { ICyclicFocusTrapStrategy } from './focus_trap_strategy_types';
|
|
3
|
+
export declare type TCyclicFocusTrapStrategyProps = {
|
|
4
|
+
getContainer: () => HTMLElement | undefined;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Cyclic keydown focus trap.
|
|
8
|
+
*
|
|
9
|
+
* No sentinel DOM elements. Tab past the last focusable element wraps to the first;
|
|
10
|
+
* Shift+Tab past the first wraps to the last. Uses `keydown` + `preventDefault` so the
|
|
11
|
+
* browser never moves focus outside the container.
|
|
12
|
+
*
|
|
13
|
+
* Suitable when the host is not portaled and `inert` is not applied to background content
|
|
14
|
+
* (e.g. a full-screen search overlay on mobile).
|
|
15
|
+
*/
|
|
16
|
+
export declare class CyclicFocusTrapStrategy extends FocusTrapStrategy implements ICyclicFocusTrapStrategy {
|
|
17
|
+
constructor({ getContainer }: TCyclicFocusTrapStrategyProps);
|
|
18
|
+
attach(): void;
|
|
19
|
+
detach(): void;
|
|
20
|
+
private _handleKeyDown;
|
|
21
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { FocusTrapStrategy } from './focus_trap_strategy.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cyclic keydown focus trap.
|
|
5
|
+
*
|
|
6
|
+
* No sentinel DOM elements. Tab past the last focusable element wraps to the first;
|
|
7
|
+
* Shift+Tab past the first wraps to the last. Uses `keydown` + `preventDefault` so the
|
|
8
|
+
* browser never moves focus outside the container.
|
|
9
|
+
*
|
|
10
|
+
* Suitable when the host is not portaled and `inert` is not applied to background content
|
|
11
|
+
* (e.g. a full-screen search overlay on mobile).
|
|
12
|
+
*/
|
|
13
|
+
class CyclicFocusTrapStrategy extends FocusTrapStrategy {
|
|
14
|
+
constructor({ getContainer }) {
|
|
15
|
+
super(getContainer);
|
|
16
|
+
this._handleKeyDown = (ev) => {
|
|
17
|
+
if (!this.active || ev.code !== 'Tab')
|
|
18
|
+
return;
|
|
19
|
+
const container = this.getContainer();
|
|
20
|
+
if (!container)
|
|
21
|
+
return;
|
|
22
|
+
const focusableElements = this.getFocusableElements(container);
|
|
23
|
+
if (focusableElements.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
const $target = ev.target;
|
|
26
|
+
if (ev.shiftKey) {
|
|
27
|
+
if ($target === focusableElements[0]) {
|
|
28
|
+
ev.preventDefault();
|
|
29
|
+
focusableElements[focusableElements.length - 1].focus();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if ($target === focusableElements[focusableElements.length - 1]) {
|
|
34
|
+
ev.preventDefault();
|
|
35
|
+
focusableElements[0].focus();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
attach() {
|
|
41
|
+
document.addEventListener('keydown', this._handleKeyDown);
|
|
42
|
+
}
|
|
43
|
+
detach() {
|
|
44
|
+
document.removeEventListener('keydown', this._handleKeyDown);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { CyclicFocusTrapStrategy };
|
|
49
|
+
//# 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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,12 @@
|
|
|
1
|
+
import { IFocusTrapStrategy } from './focus_trap_strategy_types';
|
|
2
|
+
export declare abstract class FocusTrapStrategy implements IFocusTrapStrategy {
|
|
3
|
+
protected readonly getContainer: () => HTMLElement | undefined;
|
|
4
|
+
protected active: boolean;
|
|
5
|
+
constructor(getContainer: () => HTMLElement | undefined);
|
|
6
|
+
abstract attach(): void;
|
|
7
|
+
abstract detach(): void;
|
|
8
|
+
activate(): void;
|
|
9
|
+
deactivate(): void;
|
|
10
|
+
getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
11
|
+
private _isElementTrulyFocusable;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
2
|
+
|
|
3
|
+
class FocusTrapStrategy {
|
|
4
|
+
constructor(getContainer) {
|
|
5
|
+
this.getContainer = getContainer;
|
|
6
|
+
this.active = false;
|
|
7
|
+
}
|
|
8
|
+
activate() {
|
|
9
|
+
this.active = true;
|
|
10
|
+
}
|
|
11
|
+
deactivate() {
|
|
12
|
+
this.active = false;
|
|
13
|
+
}
|
|
14
|
+
getFocusableElements(container) {
|
|
15
|
+
return UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
|
|
16
|
+
}
|
|
17
|
+
_isElementTrulyFocusable($el) {
|
|
18
|
+
const style = window.getComputedStyle($el);
|
|
19
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if ($el.nodeName === 'H-PORTAL')
|
|
23
|
+
return true;
|
|
24
|
+
const $parent = $el.parentElement;
|
|
25
|
+
if (!$parent)
|
|
26
|
+
return true;
|
|
27
|
+
return this._isElementTrulyFocusable($parent);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { FocusTrapStrategy };
|
|
32
|
+
//# sourceMappingURL=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;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CyclicFocusTrapStrategy } from './cyclic_focus_trap_strategy';
|
|
2
|
+
import { TogglerFocusTrapStrategy } from './toggler_focus_trap_strategy';
|
|
3
|
+
import { SentinelFocusTrapStrategy } from './sentinel_focus_trap_strategy';
|
|
4
|
+
export declare const FOCUS_TRAP_STRATEGY_TYPES: {
|
|
5
|
+
readonly cyclic: "cyclic";
|
|
6
|
+
readonly toggler: "toggler";
|
|
7
|
+
readonly sentinel: "sentinel";
|
|
8
|
+
};
|
|
9
|
+
export declare const FOCUS_TRAP_STRATEGY_STRATEGIES: {
|
|
10
|
+
readonly cyclic: typeof CyclicFocusTrapStrategy;
|
|
11
|
+
readonly toggler: typeof TogglerFocusTrapStrategy;
|
|
12
|
+
readonly sentinel: typeof SentinelFocusTrapStrategy;
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CyclicFocusTrapStrategy } from './cyclic_focus_trap_strategy.js';
|
|
2
|
+
import { TogglerFocusTrapStrategy } from './toggler_focus_trap_strategy.js';
|
|
3
|
+
import { SentinelFocusTrapStrategy } from './sentinel_focus_trap_strategy.js';
|
|
4
|
+
|
|
5
|
+
const FOCUS_TRAP_STRATEGY_TYPES = {
|
|
6
|
+
cyclic: 'cyclic',
|
|
7
|
+
toggler: 'toggler',
|
|
8
|
+
sentinel: 'sentinel',
|
|
9
|
+
};
|
|
10
|
+
const FOCUS_TRAP_STRATEGY_STRATEGIES = {
|
|
11
|
+
[FOCUS_TRAP_STRATEGY_TYPES.cyclic]: CyclicFocusTrapStrategy,
|
|
12
|
+
[FOCUS_TRAP_STRATEGY_TYPES.toggler]: TogglerFocusTrapStrategy,
|
|
13
|
+
[FOCUS_TRAP_STRATEGY_TYPES.sentinel]: SentinelFocusTrapStrategy,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { FOCUS_TRAP_STRATEGY_STRATEGIES, FOCUS_TRAP_STRATEGY_TYPES };
|
|
17
|
+
//# 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;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IFocusTrapStrategy {
|
|
2
|
+
attach(): void;
|
|
3
|
+
detach(): void;
|
|
4
|
+
activate(): void;
|
|
5
|
+
deactivate(): void;
|
|
6
|
+
getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
7
|
+
}
|
|
8
|
+
export interface ICyclicFocusTrapStrategy extends IFocusTrapStrategy {
|
|
9
|
+
}
|
|
10
|
+
export interface ITogglerFocusTrapStrategy extends IFocusTrapStrategy {
|
|
11
|
+
}
|
|
12
|
+
export interface ISentinelFocusTrapStrategy extends IFocusTrapStrategy {
|
|
13
|
+
setSentinels(start: HTMLElement, end: HTMLElement): void;
|
|
14
|
+
focusFirst(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus_trap_strategy_types.js","sourceRoot":"","sources":["../../../../../../../../src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FocusTrapStrategy } from './focus_trap_strategy';
|
|
2
|
+
import { ISentinelFocusTrapStrategy } from './focus_trap_strategy_types';
|
|
3
|
+
export declare type TSentinelFocusTrapStrategyProps = {
|
|
4
|
+
getContainer: () => HTMLElement | undefined;
|
|
5
|
+
noAutofocus?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Sentinel mode focus trap.
|
|
9
|
+
*
|
|
10
|
+
* Uses two inert bookend elements (sentinelStart / sentinelEnd) to detect when focus
|
|
11
|
+
* escapes the container and cycle it back. Appropriate for modal dialogs and sheets where
|
|
12
|
+
* background content is marked `inert`, giving the browser an extra safety net.
|
|
13
|
+
*
|
|
14
|
+
* Reacts on `keyup` so that the browser's native focus movement has already completed
|
|
15
|
+
* before we redirect it.
|
|
16
|
+
*/
|
|
17
|
+
export declare class SentinelFocusTrapStrategy extends FocusTrapStrategy implements ISentinelFocusTrapStrategy {
|
|
18
|
+
#private;
|
|
19
|
+
noAutofocus: boolean;
|
|
20
|
+
constructor({ getContainer, noAutofocus }: TSentinelFocusTrapStrategyProps);
|
|
21
|
+
/** Call once in firstUpdated with the two bookend sentinel elements. */
|
|
22
|
+
setSentinels(start: HTMLElement, end: HTMLElement): void;
|
|
23
|
+
/**
|
|
24
|
+
* Move focus to the first real interactive element after the open transition
|
|
25
|
+
* completes (skips sentinelStart at index 0).
|
|
26
|
+
*/
|
|
27
|
+
focusFirst(): void;
|
|
28
|
+
attach(): void;
|
|
29
|
+
detach(): void;
|
|
30
|
+
activate(): void;
|
|
31
|
+
private _handleKeyUp;
|
|
32
|
+
}
|