@shoper/phoenix_design_system 1.18.32 → 1.18.34-0

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 (43) hide show
  1. package/build/cjs/packages/phoenix/src/components/form/search/search.js +68 -9
  2. package/build/cjs/packages/phoenix/src/components/form/search/search.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/buttons/search_clear.js +5 -5
  4. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +12 -5
  5. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  6. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +44 -0
  7. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  8. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +66 -0
  9. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  10. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +14 -0
  11. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  12. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +10 -0
  13. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  14. package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +6 -0
  15. package/build/esm/packages/phoenix/src/components/form/search/search.js +68 -9
  16. package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
  17. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/buttons/search_clear.d.ts +1 -1
  18. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/buttons/search_clear.js +5 -5
  19. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.d.ts +2 -1
  20. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +12 -5
  21. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  22. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +13 -0
  23. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +40 -0
  24. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  25. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +6 -0
  26. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +3 -0
  27. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +1 -0
  28. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +14 -0
  29. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +62 -0
  30. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  31. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +8 -0
  32. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +2 -0
  33. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +1 -0
  34. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +6 -0
  35. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +10 -0
  36. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  37. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +3 -0
  38. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +2 -0
  39. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +1 -0
  40. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +3 -0
  41. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +6 -0
  42. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  43. package/package.json +2 -2
@@ -19,16 +19,24 @@ var modal_constants = require('../../modal/modal_constants.js');
19
19
  var sheet_constants = require('../../sheet/sheet_constants.js');
20
20
  var when = require('../../../../../../external/lit-html/directives/when.js');
21
21
  var search_constants = require('./search_constants.js');
22
+ var focus_trap_strategy_constants = require('../../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js');
23
+ var focus_trap_controller = require('../../../controllers/focus_trap_controller/focus_trap_controller.js');
22
24
 
23
25
  exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLitElement {
24
26
  constructor() {
25
27
  super(...arguments);
26
28
  this.view = search_constants.DEFAULT_VIEW;
29
+ this.isSearchFocusTrapFixEnabled = false;
27
30
  this.displayMode = 'dropdown';
28
31
  this._togglerElement = null;
32
+ this._mobileDialogOpener = null;
29
33
  this._id = v4['default']();
30
34
  this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
31
35
  this._searchContentContainerId = v4['default']();
36
+ this.mobileFocusTrapController = new focus_trap_controller.FocusTrapController(this, {
37
+ mode: focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.cyclic,
38
+ getContainer: () => this
39
+ });
32
40
  this._searchResultsRef = ref_js.createRef();
33
41
  this._searchHistoryRef = ref_js.createRef();
34
42
  this._searchMessageRef = ref_js.createRef();
@@ -314,6 +322,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
314
322
  if (window.innerWidth > global_constants.BREAKPOINTS.sm) {
315
323
  const hasBeenOpened = this.classList.contains(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
316
324
  this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
325
+ if (this.isSearchFocusTrapFixEnabled)
326
+ this._deactivateMobileDialog();
317
327
  if (hasBeenOpened && this.displayMode !== 'dropdown') {
318
328
  const $storefrontSearch = document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`);
319
329
  const searchOverlayTriggerName = (_a = $storefrontSearch === null || $storefrontSearch === void 0 ? void 0 : $storefrontSearch.querySelector('[aria-haspopup="dialog"]')) === null || _a === void 0 ? void 0 : _a.getAttribute('name');
@@ -329,6 +339,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
329
339
  };
330
340
  this._openMobileView = () => {
331
341
  this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
342
+ if (this.isSearchFocusTrapFixEnabled)
343
+ this._activateMobileDialog();
332
344
  };
333
345
  this._isSuggesterLayerVisible = () => {
334
346
  var _a;
@@ -349,8 +361,21 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
349
361
  document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
350
362
  }
351
363
  };
364
+ this._activateMobileDialog = () => {
365
+ this._mobileDialogOpener = document.activeElement;
366
+ this.setAttribute('role', 'dialog');
367
+ this.setAttribute('aria-modal', 'true');
368
+ this.mobileFocusTrapController.activate();
369
+ };
370
+ this._deactivateMobileDialog = () => {
371
+ this.removeAttribute('role');
372
+ this.removeAttribute('aria-modal');
373
+ this.mobileFocusTrapController.deactivate();
374
+ };
352
375
  this._handleOpenSearch = () => {
353
376
  this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
377
+ if (this.isSearchFocusTrapFixEnabled)
378
+ this._activateMobileDialog();
354
379
  const shouldShowMessage = this._searchPhrase !== '';
355
380
  this._updateSearchView(this._searchPhrase, shouldShowMessage, false);
356
381
  const $searchInput = this.querySelector(`
@@ -359,7 +384,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
359
384
  $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
360
385
  };
361
386
  this._handleOpenSearchWithKeyboard = (ev) => {
362
- if (ev.code !== 'Enter')
387
+ const isRepeated = this.isSearchFocusTrapFixEnabled ? ev.repeat : false;
388
+ if (ev.code !== 'Enter' || isRepeated)
363
389
  return;
364
390
  ev.preventDefault();
365
391
  this._handleOpenSearch();
@@ -368,6 +394,12 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
368
394
  async connectedCallback() {
369
395
  super.connectedCallback();
370
396
  this._setupContext();
397
+ this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
398
+ if (this.isSearchFocusTrapFixEnabled) {
399
+ this._setupInitialSearchPhrase();
400
+ this._setupListeners();
401
+ this._setupToggler();
402
+ }
371
403
  try {
372
404
  this._searchContextConsumer = new context_consumer_controller.ContextConsumerController(this);
373
405
  this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
@@ -396,10 +428,12 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
396
428
  catch (_a) {
397
429
  console.error('Search context is not provided');
398
430
  }
399
- this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
400
- this._setupInitialSearchPhrase();
401
- this._setupListeners();
402
- this._setupToggler();
431
+ if (!this.isSearchFocusTrapFixEnabled) {
432
+ this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
433
+ this._setupInitialSearchPhrase();
434
+ this._setupListeners();
435
+ this._setupToggler();
436
+ }
403
437
  }
404
438
  disconnectedCallback() {
405
439
  var _a;
@@ -470,8 +504,12 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
470
504
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, this._handleSubmitForm);
471
505
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.close, () => {
472
506
  this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
507
+ if (this.isSearchFocusTrapFixEnabled)
508
+ this._deactivateMobileDialog();
473
509
  this._resetSearchView();
474
510
  this._removeSearchKeyboardNavigation();
511
+ if (this.isSearchFocusTrapFixEnabled)
512
+ requestAnimationFrame(() => { var _a; return (_a = this._mobileDialogOpener) === null || _a === void 0 ? void 0 : _a.focus(); });
475
513
  });
476
514
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.loadMoreHistoryItems, () => {
477
515
  const contentLength = this._searchHistory.length;
@@ -578,8 +616,15 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
578
616
  this._setActiveItemId(`${this._id}-1`);
579
617
  const searchBar = this.querySelector(`.${search_constants.SEARCH_CLASS_NAMES.searchBar}`);
580
618
  searchBar === null || searchBar === void 0 ? void 0 : searchBar.classList.remove(search_constants.SEARCH_CLASS_NAMES.outline);
581
- if (this.displayMode === 'dropdown')
582
- this._hideHistorySuggestionsAndResults();
619
+ if (this.displayMode === 'dropdown') {
620
+ const isMobileViewOpen = this.classList.contains(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
621
+ if (isMobileViewOpen) {
622
+ this._displaySuggester(this._searchPhrase);
623
+ }
624
+ else {
625
+ this._hideHistorySuggestionsAndResults();
626
+ }
627
+ }
583
628
  }
584
629
  _submitSearchPhrase(searchPhrase) {
585
630
  this._dispatchEventWithSearchPhrase(search_constants.SEARCH_CUSTOM_EVENT_NAMES.searchPhraseSubmitted, searchPhrase);
@@ -589,13 +634,23 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
589
634
  if (!this._togglerElement)
590
635
  return;
591
636
  this._togglerElement.addEventListener('click', this._handleOpenSearch);
592
- this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
637
+ if (this.isSearchFocusTrapFixEnabled) {
638
+ this._togglerElement.addEventListener('keydown', this._handleOpenSearchWithKeyboard);
639
+ }
640
+ else {
641
+ this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
642
+ }
593
643
  }
594
644
  _teardownToggler() {
595
645
  if (!this._togglerElement)
596
646
  return;
597
647
  this._togglerElement.removeEventListener('click', this._handleOpenSearch);
598
- this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
648
+ if (this.isSearchFocusTrapFixEnabled) {
649
+ this._togglerElement.removeEventListener('keydown', this._handleOpenSearchWithKeyboard);
650
+ }
651
+ else {
652
+ this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
653
+ }
599
654
  }
600
655
  render() {
601
656
  super.render();
@@ -652,6 +707,10 @@ tslib_es6.__decorate([
652
707
  decorators.property({ type: String }),
653
708
  tslib_es6.__metadata("design:type", String)
654
709
  ], exports.HSearch.prototype, "locale", void 0);
710
+ tslib_es6.__decorate([
711
+ decorators.property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
712
+ tslib_es6.__metadata("design:type", Boolean)
713
+ ], exports.HSearch.prototype, "isSearchFocusTrapFixEnabled", void 0);
655
714
  tslib_es6.__decorate([
656
715
  decorators.property({ type: String, attribute: 'display-mode' }),
657
716
  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,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;"}
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,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -16,7 +16,7 @@ var search_constants = require('../../search_constants.js');
16
16
  exports.HSearchClear = class HSearchClear extends phoenix_light_lit_element.PhoenixLightLitElement {
17
17
  constructor() {
18
18
  super();
19
- this.isSearchClearFixFlagEnabled = false;
19
+ this.isSearchFixesFlagEnabled = false;
20
20
  this._shouldShow = false;
21
21
  this._isRequestPending = false;
22
22
  this._$searchInput = null;
@@ -29,7 +29,7 @@ exports.HSearchClear = class HSearchClear extends phoenix_light_lit_element.Phoe
29
29
  this._handleSearchClear = () => {
30
30
  var _a;
31
31
  this._dispatchClearEvent();
32
- if (this.isSearchClearFixFlagEnabled) {
32
+ if (this.isSearchFixesFlagEnabled) {
33
33
  this._updateClearButtonVisibility('');
34
34
  (_a = this._$searchInput) === null || _a === void 0 ? void 0 : _a.focus();
35
35
  }
@@ -49,7 +49,7 @@ exports.HSearchClear = class HSearchClear extends phoenix_light_lit_element.Phoe
49
49
  this._searchContextSetup();
50
50
  const $search = this.closest(search_constants.SEARCH_COMPONENT_NAMES.search);
51
51
  this._$searchInput = (_a = $search === null || $search === void 0 ? void 0 : $search.querySelector('input[type="search"]')) !== null && _a !== void 0 ? _a : null;
52
- if (this.isSearchClearFixFlagEnabled) {
52
+ if (this.isSearchFixesFlagEnabled) {
53
53
  this._updateClearButtonVisibility((_c = (_b = this._$searchInput) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : '');
54
54
  }
55
55
  this.addEventListener('click', this._handleSearchClear);
@@ -100,9 +100,9 @@ tslib_es6.__decorate([
100
100
  tslib_es6.__metadata("design:type", String)
101
101
  ], exports.HSearchClear.prototype, "moduleInstanceId", void 0);
102
102
  tslib_es6.__decorate([
103
- decorators.property({ type: Boolean, attribute: 'is-search-clear-fix-flag-enabled' }),
103
+ decorators.property({ type: Boolean, attribute: 'is-search-fixes-flag-enabled' }),
104
104
  tslib_es6.__metadata("design:type", Boolean)
105
- ], exports.HSearchClear.prototype, "isSearchClearFixFlagEnabled", void 0);
105
+ ], exports.HSearchClear.prototype, "isSearchFixesFlagEnabled", void 0);
106
106
  tslib_es6.__decorate([
107
107
  decorators.state(),
108
108
  tslib_es6.__metadata("design:type", Boolean)
@@ -13,7 +13,8 @@ var search_constants = require('../../search_constants.js');
13
13
  exports.HSearchInput = class HSearchInput extends phoenix_light_lit_element.PhoenixLightLitElement {
14
14
  constructor() {
15
15
  super(...arguments);
16
- this.isSearchClearFixFlagEnabled = false;
16
+ this.isSearchFocusTrapFixEnabled = false;
17
+ this.isSearchFixesFlagEnabled = false;
17
18
  this._isSearchPhraseCleared = false;
18
19
  this._setupAttributes = () => {
19
20
  var _a, _b, _c, _d;
@@ -39,7 +40,9 @@ exports.HSearchInput = class HSearchInput extends phoenix_light_lit_element.Phoe
39
40
  }
40
41
  firstUpdated(props) {
41
42
  super.firstUpdated(props);
42
- this._setupInitialValue();
43
+ if (!this.isSearchFixesFlagEnabled) {
44
+ this._setupInitialValue();
45
+ }
43
46
  }
44
47
  _setupInitialValue() {
45
48
  const searchQueryRegExp = /\/searchquery\/([^/]{1,})/;
@@ -73,7 +76,7 @@ exports.HSearchInput = class HSearchInput extends phoenix_light_lit_element.Phoe
73
76
  }
74
77
  });
75
78
  });
76
- if (this.isSearchClearFixFlagEnabled) {
79
+ if (this.isSearchFocusTrapFixEnabled || this.isSearchFixesFlagEnabled) {
77
80
  this.input.addEventListener('keydown', (ev) => {
78
81
  if (ev.key !== 'Enter' || ev.repeat)
79
82
  return;
@@ -161,9 +164,13 @@ tslib_es6.__decorate([
161
164
  tslib_es6.__metadata("design:type", String)
162
165
  ], exports.HSearchInput.prototype, "moduleInstanceId", void 0);
163
166
  tslib_es6.__decorate([
164
- decorators.property({ type: Boolean, attribute: 'is-search-clear-fix-flag-enabled' }),
167
+ decorators.property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
168
+ tslib_es6.__metadata("design:type", Boolean)
169
+ ], exports.HSearchInput.prototype, "isSearchFocusTrapFixEnabled", void 0);
170
+ tslib_es6.__decorate([
171
+ decorators.property({ type: Boolean, attribute: 'is-search-fixes-flag-enabled' }),
165
172
  tslib_es6.__metadata("design:type", Boolean)
166
- ], exports.HSearchInput.prototype, "isSearchClearFixFlagEnabled", void 0);
173
+ ], exports.HSearchInput.prototype, "isSearchFixesFlagEnabled", void 0);
167
174
  tslib_es6.__decorate([
168
175
  decorators.state(),
169
176
  tslib_es6.__metadata("design:type", Boolean)
@@ -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;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,44 @@
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 cyclic_focus_trap_strategy = require('./strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js');
8
+ var focus_trap_strategy_constants = require('./strategies/focus_trap_strategy_constants.js');
9
+
10
+ var _a, _FocusTrapController_strategy, _FocusTrapController_createStrategy;
11
+ class FocusTrapController {
12
+ constructor(host, props) {
13
+ _FocusTrapController_strategy.set(this, void 0);
14
+ tslib_es6.__classPrivateFieldSet(this, _FocusTrapController_strategy, tslib_es6.__classPrivateFieldGet(FocusTrapController, _a, "m", _FocusTrapController_createStrategy).call(FocusTrapController, props), "f");
15
+ host.addController(this);
16
+ }
17
+ get strategy() {
18
+ return tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
19
+ }
20
+ hostConnected() {
21
+ tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").attach();
22
+ }
23
+ hostDisconnected() {
24
+ tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").detach();
25
+ }
26
+ activate() {
27
+ tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").activate();
28
+ }
29
+ deactivate() {
30
+ tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").deactivate();
31
+ }
32
+ getFocusableElements(container) {
33
+ return tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").getFocusableElements(container);
34
+ }
35
+ }
36
+ _a = FocusTrapController, _FocusTrapController_strategy = new WeakMap(), _FocusTrapController_createStrategy = function _FocusTrapController_createStrategy(props) {
37
+ switch (props.mode) {
38
+ case focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_TYPES.cyclic: return new cyclic_focus_trap_strategy.CyclicFocusTrapStrategy(props);
39
+ default: return new cyclic_focus_trap_strategy.CyclicFocusTrapStrategy(props);
40
+ }
41
+ };
42
+
43
+ exports.FocusTrapController = FocusTrapController;
44
+ //# 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;"}
@@ -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,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const FOCUS_TRAP_STRATEGY_TYPES = {
6
+ cyclic: 'cyclic'
7
+ };
8
+
9
+ exports.FOCUS_TRAP_STRATEGY_TYPES = FOCUS_TRAP_STRATEGY_TYPES;
10
+ //# 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;"}
@@ -1,10 +1,12 @@
1
1
  import { TemplateResult } from 'lit';
2
2
  import { PhoenixLightLitElement } from "../../../core/phoenix_light_lit_element/phoenix_light_lit_element";
3
3
  import type { TSearchDisplayMode, TSearchSettings } from "./search_types";
4
+ import { FocusTrapController } from "../../../controllers/focus_trap_controller/focus_trap_controller";
4
5
  export declare class HSearch extends PhoenixLightLitElement {
5
6
  settings: TSearchSettings;
6
7
  view: string;
7
8
  locale: string;
9
+ isSearchFocusTrapFixEnabled: boolean;
8
10
  displayMode: TSearchDisplayMode;
9
11
  moduleInstanceId: string;
10
12
  private _historyContextProvider;
@@ -15,9 +17,11 @@ export declare class HSearch extends PhoenixLightLitElement {
15
17
  private _inputField;
16
18
  private _searchForm;
17
19
  private _togglerElement;
20
+ private _mobileDialogOpener;
18
21
  private _id;
19
22
  private _openSearchButtonAriaLabelId;
20
23
  private _searchContentContainerId;
24
+ mobileFocusTrapController: FocusTrapController;
21
25
  private _searchResultsRef;
22
26
  private _searchHistoryRef;
23
27
  private _searchMessageRef;
@@ -79,6 +83,8 @@ export declare class HSearch extends PhoenixLightLitElement {
79
83
  private _isSuggesterLayerVisible;
80
84
  private _preventSubmitOnSearchClear;
81
85
  private _resetSearchOnFocusOutside;
86
+ private _activateMobileDialog;
87
+ private _deactivateMobileDialog;
82
88
  private _handleOpenSearch;
83
89
  private _handleOpenSearchWithKeyboard;
84
90
  private _setupToggler;
@@ -15,16 +15,24 @@ import { MODAL_EVENTS } from '../../modal/modal_constants.js';
15
15
  import { SHEET_EVENTS } from '../../sheet/sheet_constants.js';
16
16
  import { when as n } from '../../../../../../external/lit-html/directives/when.js';
17
17
  import { DEFAULT_VIEW, SEARCH_CLASS_NAMES, SEARCH_COMPONENT_NAMES, SEARCH_CONFIGURATION, SEARCH_CONTEXT_NAMES, SEARCH_CUSTOM_EVENT_NAMES } from './search_constants.js';
18
+ import { FOCUS_TRAP_STRATEGY_TYPES } from '../../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js';
19
+ import { FocusTrapController } from '../../../controllers/focus_trap_controller/focus_trap_controller.js';
18
20
 
19
21
  let HSearch = class HSearch extends PhoenixLightLitElement {
20
22
  constructor() {
21
23
  super(...arguments);
22
24
  this.view = DEFAULT_VIEW;
25
+ this.isSearchFocusTrapFixEnabled = false;
23
26
  this.displayMode = 'dropdown';
24
27
  this._togglerElement = null;
28
+ this._mobileDialogOpener = null;
25
29
  this._id = v4();
26
30
  this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
27
31
  this._searchContentContainerId = v4();
32
+ this.mobileFocusTrapController = new FocusTrapController(this, {
33
+ mode: FOCUS_TRAP_STRATEGY_TYPES.cyclic,
34
+ getContainer: () => this
35
+ });
28
36
  this._searchResultsRef = createRef();
29
37
  this._searchHistoryRef = createRef();
30
38
  this._searchMessageRef = createRef();
@@ -310,6 +318,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
310
318
  if (window.innerWidth > BREAKPOINTS.sm) {
311
319
  const hasBeenOpened = this.classList.contains(SEARCH_CLASS_NAMES.mobileOpened);
312
320
  this.classList.remove(SEARCH_CLASS_NAMES.mobileOpened);
321
+ if (this.isSearchFocusTrapFixEnabled)
322
+ this._deactivateMobileDialog();
313
323
  if (hasBeenOpened && this.displayMode !== 'dropdown') {
314
324
  const $storefrontSearch = document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`);
315
325
  const searchOverlayTriggerName = (_a = $storefrontSearch === null || $storefrontSearch === void 0 ? void 0 : $storefrontSearch.querySelector('[aria-haspopup="dialog"]')) === null || _a === void 0 ? void 0 : _a.getAttribute('name');
@@ -325,6 +335,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
325
335
  };
326
336
  this._openMobileView = () => {
327
337
  this.classList.add(SEARCH_CLASS_NAMES.mobileOpened);
338
+ if (this.isSearchFocusTrapFixEnabled)
339
+ this._activateMobileDialog();
328
340
  };
329
341
  this._isSuggesterLayerVisible = () => {
330
342
  var _a;
@@ -345,8 +357,21 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
345
357
  document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
346
358
  }
347
359
  };
360
+ this._activateMobileDialog = () => {
361
+ this._mobileDialogOpener = document.activeElement;
362
+ this.setAttribute('role', 'dialog');
363
+ this.setAttribute('aria-modal', 'true');
364
+ this.mobileFocusTrapController.activate();
365
+ };
366
+ this._deactivateMobileDialog = () => {
367
+ this.removeAttribute('role');
368
+ this.removeAttribute('aria-modal');
369
+ this.mobileFocusTrapController.deactivate();
370
+ };
348
371
  this._handleOpenSearch = () => {
349
372
  this.classList.add(SEARCH_CLASS_NAMES.mobileOpened);
373
+ if (this.isSearchFocusTrapFixEnabled)
374
+ this._activateMobileDialog();
350
375
  const shouldShowMessage = this._searchPhrase !== '';
351
376
  this._updateSearchView(this._searchPhrase, shouldShowMessage, false);
352
377
  const $searchInput = this.querySelector(`
@@ -355,7 +380,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
355
380
  $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
356
381
  };
357
382
  this._handleOpenSearchWithKeyboard = (ev) => {
358
- if (ev.code !== 'Enter')
383
+ const isRepeated = this.isSearchFocusTrapFixEnabled ? ev.repeat : false;
384
+ if (ev.code !== 'Enter' || isRepeated)
359
385
  return;
360
386
  ev.preventDefault();
361
387
  this._handleOpenSearch();
@@ -364,6 +390,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
364
390
  async connectedCallback() {
365
391
  super.connectedCallback();
366
392
  this._setupContext();
393
+ this._searchInput = this.querySelector(SEARCH_COMPONENT_NAMES.searchInput);
394
+ if (this.isSearchFocusTrapFixEnabled) {
395
+ this._setupInitialSearchPhrase();
396
+ this._setupListeners();
397
+ this._setupToggler();
398
+ }
367
399
  try {
368
400
  this._searchContextConsumer = new ContextConsumerController(this);
369
401
  this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
@@ -392,10 +424,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
392
424
  catch (_a) {
393
425
  console.error('Search context is not provided');
394
426
  }
395
- this._searchInput = this.querySelector(SEARCH_COMPONENT_NAMES.searchInput);
396
- this._setupInitialSearchPhrase();
397
- this._setupListeners();
398
- this._setupToggler();
427
+ if (!this.isSearchFocusTrapFixEnabled) {
428
+ this._searchInput = this.querySelector(SEARCH_COMPONENT_NAMES.searchInput);
429
+ this._setupInitialSearchPhrase();
430
+ this._setupListeners();
431
+ this._setupToggler();
432
+ }
399
433
  }
400
434
  disconnectedCallback() {
401
435
  var _a;
@@ -466,8 +500,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
466
500
  this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.submit, this._handleSubmitForm);
467
501
  this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.close, () => {
468
502
  this.classList.remove(SEARCH_CLASS_NAMES.mobileOpened);
503
+ if (this.isSearchFocusTrapFixEnabled)
504
+ this._deactivateMobileDialog();
469
505
  this._resetSearchView();
470
506
  this._removeSearchKeyboardNavigation();
507
+ if (this.isSearchFocusTrapFixEnabled)
508
+ requestAnimationFrame(() => { var _a; return (_a = this._mobileDialogOpener) === null || _a === void 0 ? void 0 : _a.focus(); });
471
509
  });
472
510
  this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.loadMoreHistoryItems, () => {
473
511
  const contentLength = this._searchHistory.length;
@@ -574,8 +612,15 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
574
612
  this._setActiveItemId(`${this._id}-1`);
575
613
  const searchBar = this.querySelector(`.${SEARCH_CLASS_NAMES.searchBar}`);
576
614
  searchBar === null || searchBar === void 0 ? void 0 : searchBar.classList.remove(SEARCH_CLASS_NAMES.outline);
577
- if (this.displayMode === 'dropdown')
578
- this._hideHistorySuggestionsAndResults();
615
+ if (this.displayMode === 'dropdown') {
616
+ const isMobileViewOpen = this.classList.contains(SEARCH_CLASS_NAMES.mobileOpened);
617
+ if (isMobileViewOpen) {
618
+ this._displaySuggester(this._searchPhrase);
619
+ }
620
+ else {
621
+ this._hideHistorySuggestionsAndResults();
622
+ }
623
+ }
579
624
  }
580
625
  _submitSearchPhrase(searchPhrase) {
581
626
  this._dispatchEventWithSearchPhrase(SEARCH_CUSTOM_EVENT_NAMES.searchPhraseSubmitted, searchPhrase);
@@ -585,13 +630,23 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
585
630
  if (!this._togglerElement)
586
631
  return;
587
632
  this._togglerElement.addEventListener('click', this._handleOpenSearch);
588
- this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
633
+ if (this.isSearchFocusTrapFixEnabled) {
634
+ this._togglerElement.addEventListener('keydown', this._handleOpenSearchWithKeyboard);
635
+ }
636
+ else {
637
+ this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
638
+ }
589
639
  }
590
640
  _teardownToggler() {
591
641
  if (!this._togglerElement)
592
642
  return;
593
643
  this._togglerElement.removeEventListener('click', this._handleOpenSearch);
594
- this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
644
+ if (this.isSearchFocusTrapFixEnabled) {
645
+ this._togglerElement.removeEventListener('keydown', this._handleOpenSearchWithKeyboard);
646
+ }
647
+ else {
648
+ this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
649
+ }
595
650
  }
596
651
  render() {
597
652
  super.render();
@@ -648,6 +703,10 @@ __decorate([
648
703
  property({ type: String }),
649
704
  __metadata("design:type", String)
650
705
  ], HSearch.prototype, "locale", void 0);
706
+ __decorate([
707
+ property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
708
+ __metadata("design:type", Boolean)
709
+ ], HSearch.prototype, "isSearchFocusTrapFixEnabled", void 0);
651
710
  __decorate([
652
711
  property({ type: String, attribute: 'display-mode' }),
653
712
  __metadata("design:type", String)
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wDAA4D;AAC3E;AACA;AACA,0BAA0B,wDAA4D;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wDAA4D;AAC3E;AACA;AACA,0BAA0B,wDAA4D;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -3,7 +3,7 @@ import { PhoenixLightLitElement } from "../../../../../core/phoenix_light_lit_el
3
3
  export declare class HSearchClear extends PhoenixLightLitElement {
4
4
  private _btnController;
5
5
  moduleInstanceId: string;
6
- isSearchClearFixFlagEnabled: boolean;
6
+ isSearchFixesFlagEnabled: boolean;
7
7
  private _shouldShow;
8
8
  private _isRequestPending;
9
9
  private _searchContextConsumer;
@@ -12,7 +12,7 @@ import { SEARCH_CUSTOM_EVENT_NAMES, SEARCH_COMPONENT_NAMES, SEARCH_CLASS_NAMES,
12
12
  let HSearchClear = class HSearchClear extends PhoenixLightLitElement {
13
13
  constructor() {
14
14
  super();
15
- this.isSearchClearFixFlagEnabled = false;
15
+ this.isSearchFixesFlagEnabled = false;
16
16
  this._shouldShow = false;
17
17
  this._isRequestPending = false;
18
18
  this._$searchInput = null;
@@ -25,7 +25,7 @@ let HSearchClear = class HSearchClear extends PhoenixLightLitElement {
25
25
  this._handleSearchClear = () => {
26
26
  var _a;
27
27
  this._dispatchClearEvent();
28
- if (this.isSearchClearFixFlagEnabled) {
28
+ if (this.isSearchFixesFlagEnabled) {
29
29
  this._updateClearButtonVisibility('');
30
30
  (_a = this._$searchInput) === null || _a === void 0 ? void 0 : _a.focus();
31
31
  }
@@ -45,7 +45,7 @@ let HSearchClear = class HSearchClear extends PhoenixLightLitElement {
45
45
  this._searchContextSetup();
46
46
  const $search = this.closest(SEARCH_COMPONENT_NAMES.search);
47
47
  this._$searchInput = (_a = $search === null || $search === void 0 ? void 0 : $search.querySelector('input[type="search"]')) !== null && _a !== void 0 ? _a : null;
48
- if (this.isSearchClearFixFlagEnabled) {
48
+ if (this.isSearchFixesFlagEnabled) {
49
49
  this._updateClearButtonVisibility((_c = (_b = this._$searchInput) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : '');
50
50
  }
51
51
  this.addEventListener('click', this._handleSearchClear);
@@ -96,9 +96,9 @@ __decorate([
96
96
  __metadata("design:type", String)
97
97
  ], HSearchClear.prototype, "moduleInstanceId", void 0);
98
98
  __decorate([
99
- property({ type: Boolean, attribute: 'is-search-clear-fix-flag-enabled' }),
99
+ property({ type: Boolean, attribute: 'is-search-fixes-flag-enabled' }),
100
100
  __metadata("design:type", Boolean)
101
- ], HSearchClear.prototype, "isSearchClearFixFlagEnabled", void 0);
101
+ ], HSearchClear.prototype, "isSearchFixesFlagEnabled", void 0);
102
102
  __decorate([
103
103
  state(),
104
104
  __metadata("design:type", Boolean)
@@ -3,7 +3,8 @@ import { PropertyValues } from 'lit';
3
3
  export declare class HSearchInput extends PhoenixLightLitElement {
4
4
  input: HTMLInputElement | null;
5
5
  moduleInstanceId: string;
6
- isSearchClearFixFlagEnabled: boolean;
6
+ isSearchFocusTrapFixEnabled: boolean;
7
+ isSearchFixesFlagEnabled: boolean;
7
8
  private _isSearchPhraseCleared;
8
9
  connectedCallback(): void;
9
10
  firstUpdated(props: PropertyValues): void;
@@ -9,7 +9,8 @@ import { SEARCH_CLASS_NAMES, SEARCH_CUSTOM_EVENT_NAMES, SEARCH_COMPONENT_NAMES }
9
9
  let HSearchInput = class HSearchInput extends PhoenixLightLitElement {
10
10
  constructor() {
11
11
  super(...arguments);
12
- this.isSearchClearFixFlagEnabled = false;
12
+ this.isSearchFocusTrapFixEnabled = false;
13
+ this.isSearchFixesFlagEnabled = false;
13
14
  this._isSearchPhraseCleared = false;
14
15
  this._setupAttributes = () => {
15
16
  var _a, _b, _c, _d;
@@ -35,7 +36,9 @@ let HSearchInput = class HSearchInput extends PhoenixLightLitElement {
35
36
  }
36
37
  firstUpdated(props) {
37
38
  super.firstUpdated(props);
38
- this._setupInitialValue();
39
+ if (!this.isSearchFixesFlagEnabled) {
40
+ this._setupInitialValue();
41
+ }
39
42
  }
40
43
  _setupInitialValue() {
41
44
  const searchQueryRegExp = /\/searchquery\/([^/]{1,})/;
@@ -69,7 +72,7 @@ let HSearchInput = class HSearchInput extends PhoenixLightLitElement {
69
72
  }
70
73
  });
71
74
  });
72
- if (this.isSearchClearFixFlagEnabled) {
75
+ if (this.isSearchFocusTrapFixEnabled || this.isSearchFixesFlagEnabled) {
73
76
  this.input.addEventListener('keydown', (ev) => {
74
77
  if (ev.key !== 'Enter' || ev.repeat)
75
78
  return;
@@ -157,9 +160,13 @@ __decorate([
157
160
  __metadata("design:type", String)
158
161
  ], HSearchInput.prototype, "moduleInstanceId", void 0);
159
162
  __decorate([
160
- property({ type: Boolean, attribute: 'is-search-clear-fix-flag-enabled' }),
163
+ property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
164
+ __metadata("design:type", Boolean)
165
+ ], HSearchInput.prototype, "isSearchFocusTrapFixEnabled", void 0);
166
+ __decorate([
167
+ property({ type: Boolean, attribute: 'is-search-fixes-flag-enabled' }),
161
168
  __metadata("design:type", Boolean)
162
- ], HSearchInput.prototype, "isSearchClearFixFlagEnabled", void 0);
169
+ ], HSearchInput.prototype, "isSearchFixesFlagEnabled", void 0);
163
170
  __decorate([
164
171
  state(),
165
172
  __metadata("design:type", Boolean)
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,13 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ import type { TFocusTrapProps } from './focus_trap_controller_types';
3
+ import { IBaseFocusTrapStrategy } from './strategies/base_focus_trap_strategy_types';
4
+ export declare class FocusTrapController implements ReactiveController {
5
+ #private;
6
+ constructor(host: ReactiveControllerHost, props: TFocusTrapProps);
7
+ get strategy(): IBaseFocusTrapStrategy;
8
+ hostConnected(): void;
9
+ hostDisconnected(): void;
10
+ activate(): void;
11
+ deactivate(): void;
12
+ getFocusableElements(container: HTMLElement): HTMLElement[];
13
+ }
@@ -0,0 +1,40 @@
1
+ import { __classPrivateFieldSet, __classPrivateFieldGet } from '../../../../../external/tslib/tslib.es6.js';
2
+ import 'lit';
3
+ import { CyclicFocusTrapStrategy } from './strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js';
4
+ import { FOCUS_TRAP_STRATEGY_TYPES } from './strategies/focus_trap_strategy_constants.js';
5
+
6
+ var _a, _FocusTrapController_strategy, _FocusTrapController_createStrategy;
7
+ class FocusTrapController {
8
+ constructor(host, props) {
9
+ _FocusTrapController_strategy.set(this, void 0);
10
+ __classPrivateFieldSet(this, _FocusTrapController_strategy, __classPrivateFieldGet(FocusTrapController, _a, "m", _FocusTrapController_createStrategy).call(FocusTrapController, props), "f");
11
+ host.addController(this);
12
+ }
13
+ get strategy() {
14
+ return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
15
+ }
16
+ hostConnected() {
17
+ __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").attach();
18
+ }
19
+ hostDisconnected() {
20
+ __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").detach();
21
+ }
22
+ activate() {
23
+ __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").activate();
24
+ }
25
+ deactivate() {
26
+ __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").deactivate();
27
+ }
28
+ getFocusableElements(container) {
29
+ return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").getFocusableElements(container);
30
+ }
31
+ }
32
+ _a = FocusTrapController, _FocusTrapController_strategy = new WeakMap(), _FocusTrapController_createStrategy = function _FocusTrapController_createStrategy(props) {
33
+ switch (props.mode) {
34
+ case FOCUS_TRAP_STRATEGY_TYPES.cyclic: return new CyclicFocusTrapStrategy(props);
35
+ default: return new CyclicFocusTrapStrategy(props);
36
+ }
37
+ };
38
+
39
+ export { FocusTrapController };
40
+ //# sourceMappingURL=focus_trap_controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,6 @@
1
+ import { TCyclicFocusTrapStrategyProps } from './strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types';
2
+ import { FOCUS_TRAP_STRATEGY_TYPES } from './strategies/focus_trap_strategy_constants';
3
+ export declare type TCyclicFocusTrapProps = TCyclicFocusTrapStrategyProps & {
4
+ mode: typeof FOCUS_TRAP_STRATEGY_TYPES.cyclic;
5
+ };
6
+ export declare type TFocusTrapProps = TCyclicFocusTrapProps;
@@ -0,0 +1,3 @@
1
+ import './strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types';
2
+ import './strategies/focus_trap_strategy_constants';
3
+ //# sourceMappingURL=focus_trap_controller_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus_trap_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/focus_trap_controller/focus_trap_controller_types.ts"],"names":[],"mappings":"AAAA,OAA8C,0EAA0E,CAAC;AACzH,OAA0C,4CAA4C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { IBaseFocusTrapStrategy } from './base_focus_trap_strategy_types';
2
+ export declare abstract class BaseFocusTrapStrategy implements IBaseFocusTrapStrategy {
3
+ protected readonly getContainer: () => HTMLElement | undefined;
4
+ protected active: boolean;
5
+ noAutofocus: boolean;
6
+ constructor(getContainer: () => HTMLElement | undefined);
7
+ attach(): void;
8
+ detach(): void;
9
+ activate(): void;
10
+ deactivate(): void;
11
+ getFocusableElements(container: HTMLElement): HTMLElement[];
12
+ protected _handleKeyDown: (ev: KeyboardEvent) => void;
13
+ private _isElementTrulyFocusable;
14
+ }
@@ -0,0 +1,62 @@
1
+ import { UiDomUtils } from '@dreamcommerce/utilities';
2
+
3
+ class BaseFocusTrapStrategy {
4
+ constructor(getContainer) {
5
+ this.getContainer = getContainer;
6
+ this.active = false;
7
+ this.noAutofocus = false;
8
+ this._handleKeyDown = (ev) => {
9
+ if (!this.active || ev.code !== 'Tab')
10
+ return;
11
+ const container = this.getContainer();
12
+ if (!container)
13
+ return;
14
+ const focusableElements = this.getFocusableElements(container);
15
+ if (focusableElements.length === 0)
16
+ return;
17
+ const $target = ev.target;
18
+ if (ev.shiftKey) {
19
+ if ($target === focusableElements[0]) {
20
+ ev.preventDefault();
21
+ focusableElements[focusableElements.length - 1].focus();
22
+ }
23
+ }
24
+ else {
25
+ if ($target === focusableElements[focusableElements.length - 1]) {
26
+ ev.preventDefault();
27
+ focusableElements[0].focus();
28
+ }
29
+ }
30
+ };
31
+ }
32
+ attach() {
33
+ document.addEventListener('keydown', this._handleKeyDown);
34
+ }
35
+ detach() {
36
+ document.removeEventListener('keydown', this._handleKeyDown);
37
+ }
38
+ activate() {
39
+ this.active = true;
40
+ }
41
+ deactivate() {
42
+ this.active = false;
43
+ }
44
+ getFocusableElements(container) {
45
+ return UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
46
+ }
47
+ _isElementTrulyFocusable($el) {
48
+ const style = window.getComputedStyle($el);
49
+ if (style.display === 'none' || style.visibility === 'hidden') {
50
+ return false;
51
+ }
52
+ if ($el.nodeName === 'H-PORTAL')
53
+ return true;
54
+ const $parent = $el.parentElement;
55
+ if (!$parent)
56
+ return true;
57
+ return this._isElementTrulyFocusable($parent);
58
+ }
59
+ }
60
+
61
+ export { BaseFocusTrapStrategy };
62
+ //# sourceMappingURL=base_focus_trap_strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,8 @@
1
+ export interface IBaseFocusTrapStrategy {
2
+ noAutofocus: boolean;
3
+ attach(): void;
4
+ detach(): void;
5
+ activate(): void;
6
+ deactivate(): void;
7
+ getFocusableElements(container: HTMLElement): HTMLElement[];
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=base_focus_trap_strategy_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base_focus_trap_strategy_types.js","sourceRoot":"","sources":["../../../../../../../../src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy';
2
+ import { IBaseFocusTrapStrategy } from '../base_focus_trap_strategy_types';
3
+ import { TCyclicFocusTrapStrategyProps } from './cyclic_focus_trap_strategy_types';
4
+ export declare class CyclicFocusTrapStrategy extends BaseFocusTrapStrategy implements IBaseFocusTrapStrategy {
5
+ constructor({ getContainer }: TCyclicFocusTrapStrategyProps);
6
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy.js';
2
+
3
+ class CyclicFocusTrapStrategy extends BaseFocusTrapStrategy {
4
+ constructor({ getContainer }) {
5
+ super(getContainer);
6
+ }
7
+ }
8
+
9
+ export { CyclicFocusTrapStrategy };
10
+ //# sourceMappingURL=cyclic_focus_trap_strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,3 @@
1
+ export declare type TCyclicFocusTrapStrategyProps = {
2
+ getContainer: () => HTMLElement | undefined;
3
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cyclic_focus_trap_strategy_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cyclic_focus_trap_strategy_types.js","sourceRoot":"","sources":["../../../../../../../../../src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare const FOCUS_TRAP_STRATEGY_TYPES: {
2
+ readonly cyclic: "cyclic";
3
+ };
@@ -0,0 +1,6 @@
1
+ const FOCUS_TRAP_STRATEGY_TYPES = {
2
+ cyclic: 'cyclic'
3
+ };
4
+
5
+ export { FOCUS_TRAP_STRATEGY_TYPES };
6
+ //# 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;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shoper/phoenix_design_system",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "1.18.32",
5
+ "version": "1.18.34-0",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "@splidejs/splide-extension-auto-scroll": "0.5.3"
32
32
  },
33
33
  "devDependencies": {
34
- "@dreamcommerce/utilities": "^1.23.4-1",
34
+ "@dreamcommerce/utilities": "^1.23.5",
35
35
  "@shoper/jest_config": "^0.0.0",
36
36
  "@shoper/tsconfig": "^0.0.0",
37
37
  "@splidejs/splide": "4.0.7",