@shoper/phoenix_design_system 1.18.23-0 → 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.
Files changed (70) hide show
  1. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +24 -93
  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 +3 -13
  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/modal/modal.js +39 -11
  8. package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
  9. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js +33 -10
  10. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +47 -0
  12. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  13. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +66 -0
  14. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  15. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +14 -0
  16. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  17. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +12 -0
  18. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  19. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +29 -0
  20. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +1 -0
  21. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +60 -0
  22. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +1 -0
  23. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +3 -10
  24. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +24 -93
  25. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  26. package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +6 -0
  27. package/build/esm/packages/phoenix/src/components/form/search/search.js +55 -8
  28. package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
  29. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +3 -13
  30. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/modal/modal.d.ts +2 -0
  32. package/build/esm/packages/phoenix/src/components/modal/modal.js +39 -11
  33. package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
  34. package/build/esm/packages/phoenix/src/components/sheet/sheet.d.ts +2 -0
  35. package/build/esm/packages/phoenix/src/components/sheet/sheet.js +33 -10
  36. package/build/esm/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  37. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +13 -0
  38. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +43 -0
  39. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  40. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +14 -0
  41. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +5 -0
  42. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +1 -0
  43. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +14 -0
  44. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +62 -0
  45. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  46. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +8 -0
  47. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +2 -0
  48. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +1 -0
  49. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +6 -0
  50. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +10 -0
  51. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  52. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +3 -0
  53. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +2 -0
  54. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +1 -0
  55. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +5 -0
  56. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +8 -0
  57. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  58. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.d.ts +7 -0
  59. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +25 -0
  60. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +1 -0
  61. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.d.ts +4 -0
  62. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js +2 -0
  63. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js.map +1 -0
  64. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.d.ts +11 -0
  65. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +56 -0
  66. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +1 -0
  67. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.d.ts +4 -0
  68. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js +2 -0
  69. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js.map +1 -0
  70. package/package.json +1 -1
@@ -16,6 +16,8 @@ var v4 = require('../../../../../external/uuid/dist/esm-browser/v4.js');
16
16
  var portal_constants = require('../portal/portal_constants.js');
17
17
  var backdrop_controller = require('../backdrop/controller/backdrop_controller.js');
18
18
  var click_outside_controller = require('../../controllers/click_outside_controller/click_outside_controller.js');
19
+ var focus_trap_strategy_constants = require('../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js');
20
+ var focus_trap_controller = require('../../controllers/focus_trap_controller/focus_trap_controller.js');
19
21
  var throttle = require('../../../../../external/lodash/throttle.js');
20
22
  var relative_position_controller = require('../../controllers/relative_position_controller/relative_position_controller.js');
21
23
 
@@ -34,6 +36,11 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
34
36
  this.preventFocusTrap = false;
35
37
  this.noAutoFocus = false;
36
38
  this._backdropController = new backdrop_controller.BackdropController();
39
+ this._focusTrapController = new focus_trap_controller.FocusTrapController(this, {
40
+ mode: focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.toggler,
41
+ getContainer: () => { var _a; return (_a = this.$dropdownContent) !== null && _a !== void 0 ? _a : undefined; },
42
+ getToggler: () => { var _a; return (_a = this.$dropdownToggler) !== null && _a !== void 0 ? _a : undefined; }
43
+ });
37
44
  this._handleClickOutside = async (target) => {
38
45
  var _a, _b;
39
46
  if (!this.opened)
@@ -71,6 +78,8 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
71
78
  this._dispatchShowDropdownEvent();
72
79
  (_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.classList.remove(`${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.show}-${this.transition}-start`, `${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.show}-${this.transition}-end`);
73
80
  this._toggleScroll();
81
+ if (!this.preventFocusTrap)
82
+ this._focusTrapController.activate();
74
83
  resolve();
75
84
  }, transitionDuration);
76
85
  });
@@ -111,6 +120,7 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
111
120
  var _a;
112
121
  (_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.classList.remove(`${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.hide}-${this.transition}-start`, `${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.hide}-${this.transition}-end`);
113
122
  this.opened = false;
123
+ this._focusTrapController.deactivate();
114
124
  this._dispatchHideDropdownEvent();
115
125
  resolve();
116
126
  }, transitionDuration);
@@ -141,32 +151,21 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
141
151
  return;
142
152
  await this.hide();
143
153
  };
144
- this._keepFocusWithinDropdownForwards = (ev) => {
145
- var _a, _b;
146
- if (ev.shiftKey === true || !this.$dropdownContent || !this.opened)
147
- return;
148
- const $target = ev.target;
149
- if (((_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.contains($target)) && this.preventFocusTrap) {
150
- this._handleFocusOnNextElementAfterDropdown(ev);
151
- return;
152
- }
153
- if ((_b = this.$dropdownToggler) === null || _b === void 0 ? void 0 : _b.contains($target)) {
154
- this._handleFocusFromTogglerForwards(ev);
154
+ this._handleTabExitForward = (ev) => {
155
+ if (ev.shiftKey || !this.$dropdownContent || !this.opened || !this.preventFocusTrap)
155
156
  return;
157
+ if (this.$dropdownContent.contains(ev.target)) {
158
+ ev.preventDefault();
159
+ this.hide();
160
+ utilities.UiDomUtils.getNextFocusableElement(this.$dropdownToggler || this).focus();
156
161
  }
157
- this._handleFocusFromSentinelEndForwards(ev, $target);
158
162
  };
159
- this._keepFocusWithinDropdownBackwards = (ev) => {
160
- if (!this.opened || !this.$dropdownContent)
163
+ this._handleTabExitBackward = (ev) => {
164
+ if (!this.opened || !this.$dropdownContent || !this.preventFocusTrap)
161
165
  return;
162
- const $target = ev.target;
163
- if (this.preventFocusTrap) {
164
- this._handleDefaultFocusFromDropdownBackwards(ev);
165
- }
166
- else {
167
- this._handleFocusFromTogglerBackwards(ev, $target);
168
- this._handleFocusFromSentinelStartBackwards(ev, $target);
169
- }
166
+ ev.preventDefault();
167
+ this.hide();
168
+ utilities.UiDomUtils.getPreviousFocusableElement(this.$dropdownToggler || this).focus();
170
169
  };
171
170
  this._hoverToggle = async (ev) => {
172
171
  if (window.innerWidth < global_constants.BREAKPOINTS.xs)
@@ -188,7 +187,7 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
188
187
  this._focusOnFirstContentElement = () => {
189
188
  if (!this.$dropdownContent)
190
189
  return;
191
- const $firstFocusableElement = this._getTrulyFocusableElements(this.$dropdownContent)[0];
190
+ const $firstFocusableElement = this._focusTrapController.getFocusableElements(this.$dropdownContent)[0];
192
191
  if ($firstFocusableElement)
193
192
  $firstFocusableElement.focus();
194
193
  };
@@ -217,13 +216,13 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
217
216
  host: this,
218
217
  target: document.body,
219
218
  keys: ['tab'],
220
- callback: this._keepFocusWithinDropdownForwards
219
+ callback: this._handleTabExitForward
221
220
  });
222
221
  new keystrokes_controller.KeystrokesController({
223
222
  host: this,
224
223
  target: document.body,
225
224
  keys: [['shift', 'tab']],
226
- callback: this._keepFocusWithinDropdownBackwards,
225
+ callback: this._handleTabExitBackward,
227
226
  containerSelectors: ['h-dropdown', 'h-dropdown-content']
228
227
  });
229
228
  }
@@ -300,74 +299,6 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
300
299
  (_b = this.$dropdownContent) === null || _b === void 0 ? void 0 : _b.classList.add(global_constants.SCROLLABLE_CLASS_NAME);
301
300
  }
302
301
  }
303
- _handleFocusOnNextElementAfterDropdown(ev) {
304
- ev.preventDefault();
305
- this.hide();
306
- utilities.UiDomUtils.getNextFocusableElement(this.$dropdownToggler || this).focus();
307
- return;
308
- }
309
- _handleFocusFromTogglerForwards(ev) {
310
- if (!this.$dropdownContent)
311
- return;
312
- const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
313
- if (trulyFocusableElements.length === 0)
314
- return;
315
- ev.preventDefault();
316
- trulyFocusableElements[0].focus();
317
- }
318
- _handleFocusFromSentinelEndForwards(ev, $target) {
319
- var _a;
320
- if (!this.$dropdownContent)
321
- return;
322
- const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
323
- const $lastFocusableElement = trulyFocusableElements.slice(-1)[0];
324
- if ($target !== $lastFocusableElement)
325
- return;
326
- ev.preventDefault();
327
- (_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.focus();
328
- }
329
- _handleDefaultFocusFromDropdownBackwards(ev) {
330
- ev.preventDefault();
331
- this.hide();
332
- utilities.UiDomUtils.getPreviousFocusableElement(this.$dropdownToggler || this).focus();
333
- }
334
- _handleFocusFromTogglerBackwards(ev, $target) {
335
- var _a;
336
- if ($target !== this.$dropdownToggler && !((_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.contains($target)) || !this.$dropdownContent)
337
- return;
338
- ev.preventDefault();
339
- const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
340
- if (trulyFocusableElements.length === 0)
341
- return;
342
- const $lastFocusableElement = trulyFocusableElements.slice(-1)[0];
343
- $lastFocusableElement.focus();
344
- }
345
- _handleFocusFromSentinelStartBackwards(ev, $target) {
346
- var _a;
347
- if (!this.$dropdownContent)
348
- return;
349
- const $firstFocusableElement = this._getTrulyFocusableElements(this.$dropdownContent)[0];
350
- if ($target !== $firstFocusableElement)
351
- return;
352
- ev.preventDefault();
353
- (_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.focus();
354
- }
355
- _getTrulyFocusableElements($container) {
356
- const focusableElements = utilities.UiDomUtils.getFocusableElements($container);
357
- return focusableElements.filter(($el) => this._isElementTrulyFocusable($el));
358
- }
359
- _isElementTrulyFocusable($el) {
360
- const style = window.getComputedStyle($el);
361
- if (style.display === 'none' || style.visibility === 'hidden') {
362
- return false;
363
- }
364
- if ($el.nodeName === 'H-PORTAL')
365
- return true;
366
- const $parent = $el.parentElement;
367
- if (!$parent)
368
- return true;
369
- return this._isElementTrulyFocusable($parent);
370
- }
371
302
  _isHoveredWithinDropdown(element) {
372
303
  var _a;
373
304
  if (element === this)
@@ -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,iBAAiB,qDAAyD;AAC1E;AACA;AACA;AACA,uBAAuB,4CAAgD;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,iBAAiB,qDAAyD;AAC1E;AACA;AACA;AACA;AACA;AACA,uBAAuB,4CAAgD;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -16,6 +16,8 @@ var ref_js = require('lit-html/directives/ref.js');
16
16
  var context_provider_controller = require('../../../core/context/context_provider_controller.js');
17
17
  var global_constants = require('../../../global_constants.js');
18
18
  var v4 = require('../../../../../../external/uuid/dist/esm-browser/v4.js');
19
+ var focus_trap_strategy_constants = require('../../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js');
20
+ var focus_trap_controller = require('../../../controllers/focus_trap_controller/focus_trap_controller.js');
19
21
  var modal_constants = require('../../modal/modal_constants.js');
20
22
  var sheet_constants = require('../../sheet/sheet_constants.js');
21
23
  var when = require('../../../../../../external/lit-html/directives/when.js');
@@ -27,11 +29,17 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
27
29
  this.view = search_constants.DEFAULT_VIEW;
28
30
  this.isSearchIconFixEnabled = false;
29
31
  this.isSearchUxFixesFlagEnabled = false;
32
+ this.isSearchFocusTrapFixEnabled = false;
30
33
  this.displayMode = 'dropdown';
31
34
  this._togglerElement = null;
35
+ this._mobileDialogOpener = null;
32
36
  this._id = v4['default']();
33
37
  this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
34
38
  this._searchContentContainerId = v4['default']();
39
+ this.mobileFocusTrapController = new focus_trap_controller.FocusTrapController(this, {
40
+ mode: focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.cyclic,
41
+ getContainer: () => this
42
+ });
35
43
  this._searchResultsRef = ref_js.createRef();
36
44
  this._searchHistoryRef = ref_js.createRef();
37
45
  this._searchMessageRef = ref_js.createRef();
@@ -327,6 +335,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
327
335
  if (window.innerWidth > global_constants.BREAKPOINTS.sm) {
328
336
  const hasBeenOpened = this.classList.contains(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
329
337
  this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
338
+ if (this.isSearchFocusTrapFixEnabled)
339
+ this._deactivateMobileDialog();
330
340
  if (hasBeenOpened && this.displayMode !== 'dropdown') {
331
341
  const $storefrontSearch = document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`);
332
342
  const searchOverlayTriggerName = (_a = $storefrontSearch === null || $storefrontSearch === void 0 ? void 0 : $storefrontSearch.querySelector('[aria-haspopup="dialog"]')) === null || _a === void 0 ? void 0 : _a.getAttribute('name');
@@ -342,6 +352,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
342
352
  };
343
353
  this._openMobileView = () => {
344
354
  this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
355
+ if (this.isSearchFocusTrapFixEnabled)
356
+ this._activateMobileDialog();
345
357
  };
346
358
  this._isSuggesterLayerVisible = () => {
347
359
  var _a;
@@ -362,6 +374,19 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
362
374
  document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
363
375
  }
364
376
  };
377
+ this._activateMobileDialog = () => {
378
+ if (this.displayMode !== 'dropdown')
379
+ return;
380
+ this._mobileDialogOpener = document.activeElement;
381
+ this.setAttribute('role', 'dialog');
382
+ this.setAttribute('aria-modal', 'true');
383
+ this.mobileFocusTrapController.activate();
384
+ };
385
+ this._deactivateMobileDialog = () => {
386
+ this.removeAttribute('role');
387
+ this.removeAttribute('aria-modal');
388
+ this.mobileFocusTrapController.deactivate();
389
+ };
365
390
  this._setupAriaAttributes = () => {
366
391
  var _a;
367
392
  if (this._translations.openSearchButtonAriaLabel) {
@@ -370,6 +395,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
370
395
  };
371
396
  this._handleOpenSearch = () => {
372
397
  this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
398
+ if (this.isSearchFocusTrapFixEnabled)
399
+ this._activateMobileDialog();
373
400
  const shouldShowMessage = this._searchPhrase !== '';
374
401
  this._updateSearchView(this._searchPhrase, shouldShowMessage, false);
375
402
  const $searchInput = this.querySelector(`
@@ -378,7 +405,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
378
405
  $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
379
406
  };
380
407
  this._handleOpenSearchWithKeyboard = (ev) => {
381
- if (ev.code !== 'Enter')
408
+ const isRepeated = this.isSearchFocusTrapFixEnabled ? ev.repeat : false;
409
+ if (ev.code !== 'Enter' || isRepeated)
382
410
  return;
383
411
  ev.preventDefault();
384
412
  this._handleOpenSearch();
@@ -387,6 +415,10 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
387
415
  async connectedCallback() {
388
416
  super.connectedCallback();
389
417
  this._setupContext();
418
+ this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
419
+ this._setupInitialSearchPhrase();
420
+ this._setupListeners();
421
+ this.isSearchIconFixEnabled ? this._setupToggler() : this._setupAriaAttributes();
390
422
  try {
391
423
  this._searchContextConsumer = new context_consumer_controller.ContextConsumerController(this);
392
424
  this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
@@ -415,10 +447,6 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
415
447
  catch (_a) {
416
448
  console.error('Search context is not provided');
417
449
  }
418
- this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
419
- this._setupInitialSearchPhrase();
420
- this._setupListeners();
421
- this.isSearchIconFixEnabled ? this._setupToggler() : this._setupAriaAttributes();
422
450
  }
423
451
  disconnectedCallback() {
424
452
  var _a;
@@ -490,8 +518,12 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
490
518
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, this._handleSubmitForm);
491
519
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.close, () => {
492
520
  this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
521
+ if (this.isSearchFocusTrapFixEnabled)
522
+ this._deactivateMobileDialog();
493
523
  this._resetSearchView();
494
524
  this.isSearchUxFixesFlagEnabled && this._removeSearchKeyboardNavigation();
525
+ if (this.isSearchFocusTrapFixEnabled)
526
+ requestAnimationFrame(() => { var _a; return (_a = this._mobileDialogOpener) === null || _a === void 0 ? void 0 : _a.focus(); });
495
527
  });
496
528
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.loadMoreHistoryItems, () => {
497
529
  const contentLength = this._searchHistory.length;
@@ -610,13 +642,23 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
610
642
  if (!this._togglerElement)
611
643
  return;
612
644
  this._togglerElement.addEventListener('click', this._handleOpenSearch);
613
- this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
645
+ if (this.isSearchFocusTrapFixEnabled) {
646
+ this._togglerElement.addEventListener('keydown', this._handleOpenSearchWithKeyboard);
647
+ }
648
+ else {
649
+ this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
650
+ }
614
651
  }
615
652
  _teardownToggler() {
616
653
  if (!this._togglerElement)
617
654
  return;
618
655
  this._togglerElement.removeEventListener('click', this._handleOpenSearch);
619
- this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
656
+ if (this.isSearchFocusTrapFixEnabled) {
657
+ this._togglerElement.removeEventListener('keydown', this._handleOpenSearchWithKeyboard);
658
+ }
659
+ else {
660
+ this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
661
+ }
620
662
  }
621
663
  render() {
622
664
  super.render();
@@ -626,7 +668,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
626
668
  tabindex="0"
627
669
  aria-haspopup="dialog"
628
670
  @click=${this._handleOpenSearch}
629
- @keyup=${this._handleOpenSearchWithKeyboard}
671
+ @keyup=${this.isSearchFocusTrapFixEnabled ? undefined : this._handleOpenSearchWithKeyboard}
672
+ @keydown=${this.isSearchFocusTrapFixEnabled ? this._handleOpenSearchWithKeyboard : undefined}
630
673
  >
631
674
  ${when.when(this._translations.openSearchButtonAriaLabel, () => lit.html `
632
675
  <span id="${this._openSearchButtonAriaLabelId}" class="sr-only">
@@ -696,6 +739,10 @@ tslib_es6.__decorate([
696
739
  decorators.property({ type: Boolean, attribute: 'is-search-ux-fixes-flag-enabled' }),
697
740
  tslib_es6.__metadata("design:type", Boolean)
698
741
  ], exports.HSearch.prototype, "isSearchUxFixesFlagEnabled", void 0);
742
+ tslib_es6.__decorate([
743
+ decorators.property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
744
+ tslib_es6.__metadata("design:type", Boolean)
745
+ ], exports.HSearch.prototype, "isSearchFocusTrapFixEnabled", void 0);
699
746
  tslib_es6.__decorate([
700
747
  decorators.property({ type: String, attribute: 'display-mode' }),
701
748
  tslib_es6.__metadata("design:type", String)
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,wDAA4D;AAC7E;AACA;AACA,mBAAmB,wDAA4D;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,wDAA4D;AAC7E;AACA;AACA;AACA;AACA,mBAAmB,wDAA4D;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -72,25 +72,15 @@ exports.HSearchInput = class HSearchInput extends phoenix_light_lit_element.Phoe
72
72
  }
73
73
  });
74
74
  });
75
- this.input.addEventListener('keyup', (ev) => {
76
- if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape')
75
+ this.input.addEventListener('keydown', (ev) => {
76
+ if (ev.key !== 'Enter' || ev.repeat)
77
77
  return;
78
- if (ev.key !== 'Enter') {
79
- this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.keyup, {
80
- detail: {
81
- searchPhrase: ev.target.value
82
- }
83
- });
84
- return;
85
- }
86
78
  if (this._isSearchPhraseCleared) {
87
79
  this._isSearchPhraseCleared = false;
88
80
  return;
89
81
  }
90
82
  this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, {
91
- detail: {
92
- searchPhrase: ev.target.value
93
- }
83
+ detail: { searchPhrase: ev.target.value }
94
84
  });
95
85
  });
96
86
  this.input.addEventListener('keyup', debounce['default']((ev) => {
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,qDAAyD;AACjF;AACA;AACA;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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 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)