@shoper/phoenix_design_system 1.18.23-1 → 1.18.23-11

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.
Files changed (76) hide show
  1. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +51 -3
  2. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/form/search/search.js +55 -8
  4. package/build/cjs/packages/phoenix/src/components/form/search/search.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +51 -22
  6. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  7. package/build/cjs/packages/phoenix/src/components/form/select/select.js +37 -18
  8. package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
  9. package/build/cjs/packages/phoenix/src/components/modal/modal.js +39 -11
  10. package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js +33 -10
  12. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  13. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +47 -0
  14. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  15. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +66 -0
  16. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  17. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +14 -0
  18. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  19. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +12 -0
  20. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  21. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +29 -0
  22. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +1 -0
  23. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +60 -0
  24. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +1 -0
  25. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +6 -0
  26. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +51 -3
  27. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  28. package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +6 -0
  29. package/build/esm/packages/phoenix/src/components/form/search/search.js +55 -8
  30. package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.d.ts +1 -0
  32. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +51 -22
  33. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  34. package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +1 -0
  35. package/build/esm/packages/phoenix/src/components/form/select/select.js +37 -18
  36. package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
  37. package/build/esm/packages/phoenix/src/components/modal/modal.d.ts +2 -0
  38. package/build/esm/packages/phoenix/src/components/modal/modal.js +39 -11
  39. package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
  40. package/build/esm/packages/phoenix/src/components/sheet/sheet.d.ts +2 -0
  41. package/build/esm/packages/phoenix/src/components/sheet/sheet.js +33 -10
  42. package/build/esm/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  43. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +13 -0
  44. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +43 -0
  45. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  46. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +14 -0
  47. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +5 -0
  48. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +1 -0
  49. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +14 -0
  50. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +62 -0
  51. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  52. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +8 -0
  53. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +2 -0
  54. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +1 -0
  55. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +6 -0
  56. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +10 -0
  57. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  58. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +3 -0
  59. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +2 -0
  60. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +1 -0
  61. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +5 -0
  62. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +8 -0
  63. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  64. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.d.ts +7 -0
  65. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +25 -0
  66. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +1 -0
  67. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.d.ts +4 -0
  68. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js +2 -0
  69. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js.map +1 -0
  70. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.d.ts +11 -0
  71. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +56 -0
  72. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +1 -0
  73. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.d.ts +4 -0
  74. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js +2 -0
  75. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js.map +1 -0
  76. 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
- if (!this.noAutofocus) {
44
- setTimeout(() => {
45
- var _a;
46
- (_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
47
- window.scrollTo(0, scrollY);
48
- }, 0);
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
- document.addEventListener('keyup', this._keepFocusWithinModal);
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
- document.removeEventListener('keyup', this._keepFocusWithinModal);
178
+ if (!this.isSearchFocusTrapFixEnabled)
179
+ document.removeEventListener('keyup', this._keepFocusWithinModal);
162
180
  }
163
181
  firstUpdated(props) {
164
182
  super.firstUpdated(props);
165
- this._firstFocusableElement = this._focusSentinelStart.value;
166
- this._lastFocusableElement = this._focusSentinelEnd.value;
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._setFocusToFirstFocusableElementInModalOrCloseBtn();
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
- setTimeout(() => {
43
- var _a;
44
- (_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
45
- window.scrollTo(0, scrollY);
46
- }, 0);
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
- document.addEventListener('keyup', this._keepFocusWithinSheet);
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
- document.removeEventListener('keyup', this._keepFocusWithinSheet);
173
+ if (!this.isSearchFocusTrapFixEnabled)
174
+ document.removeEventListener('keyup', this._keepFocusWithinSheet);
159
175
  }
160
176
  firstUpdated(props) {
161
177
  super.firstUpdated(props);
162
- this._firstFocusableElement = this._focusSentinelStart.value;
163
- this._lastFocusableElement = this._focusSentinelEnd.value;
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._setFocusToFirstFocusableElementInSheetOrCloseBtn();
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;"}
@@ -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;"}
@@ -18,6 +18,7 @@ export declare class HDropdown extends PhoenixLightLitElement implements IDropdo
18
18
  id: string;
19
19
  preventFocusTrap: boolean;
20
20
  noAutoFocus: boolean;
21
+ isSearchFocusTrapFixEnabled: boolean;
21
22
  $dropdownToggler: HDropdownToggler | null;
22
23
  $dropdownContent: HDropdownContent | null;
23
24
  $nestedDropdownContentElements?: HDropdownContent[];
@@ -26,6 +27,7 @@ export declare class HDropdown extends PhoenixLightLitElement implements IDropdo
26
27
  private _dropdownContentChildrenHeight;
27
28
  private _hasScrollableClassInitially;
28
29
  private _backdropController;
30
+ private _focusTrapController;
29
31
  constructor();
30
32
  connectedCallback(): Promise<void>;
31
33
  private static _appendDropdownPortal;
@@ -43,10 +45,14 @@ export declare class HDropdown extends PhoenixLightLitElement implements IDropdo
43
45
  private _observeScrollToggling;
44
46
  private _toggleScroll;
45
47
  private _closeDropdownOnEscape;
48
+ private _handleTabForward;
49
+ private _handleTabExitForward;
46
50
  private _keepFocusWithinDropdownForwards;
47
51
  private _handleFocusOnNextElementAfterDropdown;
48
52
  private _handleFocusFromTogglerForwards;
49
53
  private _handleFocusFromSentinelEndForwards;
54
+ private _handleTabBackward;
55
+ private _handleTabExitBackward;
50
56
  private _keepFocusWithinDropdownBackwards;
51
57
  private _handleDefaultFocusFromDropdownBackwards;
52
58
  private _handleFocusFromTogglerBackwards;
@@ -12,6 +12,8 @@ import v4 from '../../../../../external/uuid/dist/esm-browser/v4.js';
12
12
  import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
13
13
  import { BackdropController } from '../backdrop/controller/backdrop_controller.js';
14
14
  import { ClickOutsideController } from '../../controllers/click_outside_controller/click_outside_controller.js';
15
+ import { FOCUS_TRAP_STRATEGY_TYPES } from '../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js';
16
+ import { FocusTrapController } from '../../controllers/focus_trap_controller/focus_trap_controller.js';
15
17
  import throttle_1 from '../../../../../external/lodash/throttle.js';
16
18
  import { RelativePositionController } from '../../controllers/relative_position_controller/relative_position_controller.js';
17
19
 
@@ -29,7 +31,13 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
29
31
  this.id = v4();
30
32
  this.preventFocusTrap = false;
31
33
  this.noAutoFocus = false;
34
+ this.isSearchFocusTrapFixEnabled = false;
32
35
  this._backdropController = new BackdropController();
36
+ this._focusTrapController = new FocusTrapController(this, {
37
+ mode: FOCUS_TRAP_STRATEGY_TYPES.toggler,
38
+ getContainer: () => { var _a; return (_a = this.$dropdownContent) !== null && _a !== void 0 ? _a : undefined; },
39
+ getToggler: () => { var _a; return (_a = this.$dropdownToggler) !== null && _a !== void 0 ? _a : undefined; }
40
+ });
33
41
  this._handleClickOutside = async (target) => {
34
42
  var _a, _b;
35
43
  if (!this.opened)
@@ -67,6 +75,8 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
67
75
  this._dispatchShowDropdownEvent();
68
76
  (_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.classList.remove(`${DROPDOWN_CONTENT_CSS_CLASSES.show}-${this.transition}-start`, `${DROPDOWN_CONTENT_CSS_CLASSES.show}-${this.transition}-end`);
69
77
  this._toggleScroll();
78
+ if (this.isSearchFocusTrapFixEnabled && !this.preventFocusTrap)
79
+ this._focusTrapController.activate();
70
80
  resolve();
71
81
  }, transitionDuration);
72
82
  });
@@ -107,6 +117,8 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
107
117
  var _a;
108
118
  (_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.classList.remove(`${DROPDOWN_CONTENT_CSS_CLASSES.hide}-${this.transition}-start`, `${DROPDOWN_CONTENT_CSS_CLASSES.hide}-${this.transition}-end`);
109
119
  this.opened = false;
120
+ if (this.isSearchFocusTrapFixEnabled)
121
+ this._focusTrapController.deactivate();
110
122
  this._dispatchHideDropdownEvent();
111
123
  resolve();
112
124
  }, transitionDuration);
@@ -137,6 +149,23 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
137
149
  return;
138
150
  await this.hide();
139
151
  };
152
+ this._handleTabForward = (ev) => {
153
+ if (this.isSearchFocusTrapFixEnabled) {
154
+ this._handleTabExitForward(ev);
155
+ }
156
+ else {
157
+ this._keepFocusWithinDropdownForwards(ev);
158
+ }
159
+ };
160
+ this._handleTabExitForward = (ev) => {
161
+ if (ev.shiftKey || !this.$dropdownContent || !this.opened || !this.preventFocusTrap)
162
+ return;
163
+ if (this.$dropdownContent.contains(ev.target)) {
164
+ ev.preventDefault();
165
+ this.hide();
166
+ UiDomUtils.getNextFocusableElement(this.$dropdownToggler || this).focus();
167
+ }
168
+ };
140
169
  this._keepFocusWithinDropdownForwards = (ev) => {
141
170
  var _a, _b;
142
171
  if (ev.shiftKey === true || !this.$dropdownContent || !this.opened)
@@ -152,6 +181,21 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
152
181
  }
153
182
  this._handleFocusFromSentinelEndForwards(ev, $target);
154
183
  };
184
+ this._handleTabBackward = (ev) => {
185
+ if (this.isSearchFocusTrapFixEnabled) {
186
+ this._handleTabExitBackward(ev);
187
+ }
188
+ else {
189
+ this._keepFocusWithinDropdownBackwards(ev);
190
+ }
191
+ };
192
+ this._handleTabExitBackward = (ev) => {
193
+ if (!this.opened || !this.$dropdownContent || !this.preventFocusTrap)
194
+ return;
195
+ ev.preventDefault();
196
+ this.hide();
197
+ UiDomUtils.getPreviousFocusableElement(this.$dropdownToggler || this).focus();
198
+ };
155
199
  this._keepFocusWithinDropdownBackwards = (ev) => {
156
200
  if (!this.opened || !this.$dropdownContent)
157
201
  return;
@@ -184,7 +228,7 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
184
228
  this._focusOnFirstContentElement = () => {
185
229
  if (!this.$dropdownContent)
186
230
  return;
187
- const $firstFocusableElement = this._getTrulyFocusableElements(this.$dropdownContent)[0];
231
+ const $firstFocusableElement = this.isSearchFocusTrapFixEnabled ? this._focusTrapController.getFocusableElements(this.$dropdownContent)[0] : this._getTrulyFocusableElements(this.$dropdownContent)[0];
188
232
  if ($firstFocusableElement)
189
233
  $firstFocusableElement.focus();
190
234
  };
@@ -213,13 +257,13 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
213
257
  host: this,
214
258
  target: document.body,
215
259
  keys: ['tab'],
216
- callback: this._keepFocusWithinDropdownForwards
260
+ callback: this._handleTabForward
217
261
  });
218
262
  new KeystrokesController({
219
263
  host: this,
220
264
  target: document.body,
221
265
  keys: [['shift', 'tab']],
222
- callback: this._keepFocusWithinDropdownBackwards,
266
+ callback: this._handleTabBackward,
223
267
  containerSelectors: ['h-dropdown', 'h-dropdown-content']
224
268
  });
225
269
  }
@@ -469,6 +513,10 @@ __decorate([
469
513
  property({ type: Boolean, attribute: 'no-autofocus' }),
470
514
  __metadata("design:type", Object)
471
515
  ], HDropdown.prototype, "noAutoFocus", void 0);
516
+ __decorate([
517
+ property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
518
+ __metadata("design:type", Boolean)
519
+ ], HDropdown.prototype, "isSearchFocusTrapFixEnabled", void 0);
472
520
  HDropdown = HDropdown_1 = __decorate([
473
521
  phoenixCustomElement('h-dropdown'),
474
522
  __metadata("design:paramtypes", [])