@shoper/phoenix_design_system 1.18.27-15 → 1.18.27-16

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 (40) hide show
  1. package/build/cjs/packages/phoenix/src/components/form/search/search.js +98 -10
  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/input/search_input.js +51 -22
  4. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +44 -0
  6. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  7. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +66 -0
  8. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  9. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +14 -0
  10. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  11. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +10 -0
  12. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  13. package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +8 -0
  14. package/build/esm/packages/phoenix/src/components/form/search/search.js +98 -10
  15. package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
  16. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.d.ts +1 -0
  17. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +51 -22
  18. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  19. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +13 -0
  20. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +40 -0
  21. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
  22. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +6 -0
  23. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +3 -0
  24. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +1 -0
  25. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +14 -0
  26. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +62 -0
  27. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
  28. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +8 -0
  29. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +2 -0
  30. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +1 -0
  31. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +6 -0
  32. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +10 -0
  33. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
  34. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +3 -0
  35. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +2 -0
  36. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +1 -0
  37. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +3 -0
  38. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +6 -0
  39. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
  40. package/package.json +1 -1
@@ -8,6 +8,7 @@ var decorators = require('lit/decorators');
8
8
  var utilities = require('@dreamcommerce/utilities');
9
9
  var phoenix_light_lit_element = require('../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
10
10
  var phoenix_custom_element = require('../../../core/decorators/phoenix_custom_element.js');
11
+ var icon_constants = require('../../icon/icon_constants.js');
11
12
  var observer = require('../../../core/classes/observer/observer.js');
12
13
  var context_consumer_controller = require('../../../core/context/context_consumer_controller.js');
13
14
  var behavior_subject = require('../../../core/classes/behavior_subject/behavior_subject.js');
@@ -19,17 +20,26 @@ var modal_constants = require('../../modal/modal_constants.js');
19
20
  var sheet_constants = require('../../sheet/sheet_constants.js');
20
21
  var when = require('../../../../../../external/lit-html/directives/when.js');
21
22
  var search_constants = require('./search_constants.js');
23
+ var focus_trap_strategy_constants = require('../../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js');
24
+ var focus_trap_controller = require('../../../controllers/focus_trap_controller/focus_trap_controller.js');
22
25
 
23
26
  exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLitElement {
24
27
  constructor() {
25
28
  super(...arguments);
26
29
  this.view = search_constants.DEFAULT_VIEW;
30
+ this.isSearchIconFixEnabled = false;
27
31
  this.isSearchUxFixesFlagEnabled = false;
32
+ this.isSearchFocusTrapFixEnabled = false;
28
33
  this.displayMode = 'dropdown';
29
34
  this._togglerElement = null;
35
+ this._mobileDialogOpener = null;
30
36
  this._id = v4['default']();
31
37
  this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
32
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
+ });
33
43
  this._searchResultsRef = ref_js.createRef();
34
44
  this._searchHistoryRef = ref_js.createRef();
35
45
  this._searchMessageRef = ref_js.createRef();
@@ -325,6 +335,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
325
335
  if (window.innerWidth > global_constants.BREAKPOINTS.sm) {
326
336
  const hasBeenOpened = this.classList.contains(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
327
337
  this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
338
+ if (this.isSearchFocusTrapFixEnabled)
339
+ this._deactivateMobileDialog();
328
340
  if (hasBeenOpened && this.displayMode !== 'dropdown') {
329
341
  const $storefrontSearch = document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`);
330
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');
@@ -340,6 +352,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
340
352
  };
341
353
  this._openMobileView = () => {
342
354
  this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
355
+ if (this.isSearchFocusTrapFixEnabled)
356
+ this._activateMobileDialog();
343
357
  };
344
358
  this._isSuggesterLayerVisible = () => {
345
359
  var _a;
@@ -360,8 +374,27 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
360
374
  document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
361
375
  }
362
376
  };
377
+ this._activateMobileDialog = () => {
378
+ this._mobileDialogOpener = document.activeElement;
379
+ this.setAttribute('role', 'dialog');
380
+ this.setAttribute('aria-modal', 'true');
381
+ this.mobileFocusTrapController.activate();
382
+ };
383
+ this._deactivateMobileDialog = () => {
384
+ this.removeAttribute('role');
385
+ this.removeAttribute('aria-modal');
386
+ this.mobileFocusTrapController.deactivate();
387
+ };
388
+ this._setupAriaAttributes = () => {
389
+ var _a;
390
+ if (this._translations.openSearchButtonAriaLabel) {
391
+ (_a = this._openSearchButtonLabelRef.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-labelledby', this._openSearchButtonAriaLabelId);
392
+ }
393
+ };
363
394
  this._handleOpenSearch = () => {
364
395
  this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
396
+ if (this.isSearchFocusTrapFixEnabled)
397
+ this._activateMobileDialog();
365
398
  const shouldShowMessage = this._searchPhrase !== '';
366
399
  this._updateSearchView(this._searchPhrase, shouldShowMessage, false);
367
400
  const $searchInput = this.querySelector(`
@@ -370,7 +403,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
370
403
  $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
371
404
  };
372
405
  this._handleOpenSearchWithKeyboard = (ev) => {
373
- if (ev.code !== 'Enter')
406
+ const isRepeated = this.isSearchFocusTrapFixEnabled ? ev.repeat : false;
407
+ if (ev.code !== 'Enter' || isRepeated)
374
408
  return;
375
409
  ev.preventDefault();
376
410
  this._handleOpenSearch();
@@ -379,6 +413,12 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
379
413
  async connectedCallback() {
380
414
  super.connectedCallback();
381
415
  this._setupContext();
416
+ this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
417
+ if (this.isSearchFocusTrapFixEnabled) {
418
+ this._setupInitialSearchPhrase();
419
+ this._setupListeners();
420
+ this.isSearchIconFixEnabled ? this._setupToggler() : this._setupAriaAttributes();
421
+ }
382
422
  try {
383
423
  this._searchContextConsumer = new context_consumer_controller.ContextConsumerController(this);
384
424
  this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
@@ -407,10 +447,12 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
407
447
  catch (_a) {
408
448
  console.error('Search context is not provided');
409
449
  }
410
- this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
411
- this._setupInitialSearchPhrase();
412
- this._setupListeners();
413
- this._setupToggler();
450
+ if (!this.isSearchFocusTrapFixEnabled) {
451
+ this._searchInput = this.querySelector(search_constants.SEARCH_COMPONENT_NAMES.searchInput);
452
+ this._setupInitialSearchPhrase();
453
+ this._setupListeners();
454
+ this.isSearchIconFixEnabled ? this._setupToggler() : this._setupAriaAttributes();
455
+ }
414
456
  }
415
457
  disconnectedCallback() {
416
458
  var _a;
@@ -420,7 +462,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
420
462
  document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
421
463
  window.removeEventListener('resize', this._switchTypeOfSearchView);
422
464
  (_a = this._searchForm) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', this._preventSubmitOnSearchClear);
423
- this._teardownToggler();
465
+ if (this.isSearchIconFixEnabled)
466
+ this._teardownToggler();
424
467
  }
425
468
  _setupContext() {
426
469
  this._historyContextProvider = new context_provider_controller.ContextProviderController(this);
@@ -481,8 +524,12 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
481
524
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, this._handleSubmitForm);
482
525
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.close, () => {
483
526
  this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
527
+ if (this.isSearchFocusTrapFixEnabled)
528
+ this._deactivateMobileDialog();
484
529
  this._resetSearchView();
485
530
  this.isSearchUxFixesFlagEnabled && this._removeSearchKeyboardNavigation();
531
+ if (this.isSearchFocusTrapFixEnabled)
532
+ requestAnimationFrame(() => { var _a; return (_a = this._mobileDialogOpener) === null || _a === void 0 ? void 0 : _a.focus(); });
486
533
  });
487
534
  this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.loadMoreHistoryItems, () => {
488
535
  const contentLength = this._searchHistory.length;
@@ -589,8 +636,15 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
589
636
  this._setActiveItemId(`${this._id}-1`);
590
637
  const searchBar = this.querySelector(`.${search_constants.SEARCH_CLASS_NAMES.searchBar}`);
591
638
  searchBar === null || searchBar === void 0 ? void 0 : searchBar.classList.remove(search_constants.SEARCH_CLASS_NAMES.outline);
592
- if (this.displayMode === 'dropdown')
593
- this._hideHistorySuggestionsAndResults();
639
+ if (this.displayMode === 'dropdown') {
640
+ const isMobileViewOpen = this.classList.contains(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
641
+ if (isMobileViewOpen) {
642
+ this._displaySuggester(this._searchPhrase);
643
+ }
644
+ else {
645
+ this._hideHistorySuggestionsAndResults();
646
+ }
647
+ }
594
648
  !this.isSearchUxFixesFlagEnabled && this._removeSearchKeyboardNavigation();
595
649
  }
596
650
  _submitSearchPhrase(searchPhrase) {
@@ -601,17 +655,43 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
601
655
  if (!this._togglerElement)
602
656
  return;
603
657
  this._togglerElement.addEventListener('click', this._handleOpenSearch);
604
- this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
658
+ if (this.isSearchFocusTrapFixEnabled) {
659
+ this._togglerElement.addEventListener('keydown', this._handleOpenSearchWithKeyboard);
660
+ }
661
+ else {
662
+ this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
663
+ }
605
664
  }
606
665
  _teardownToggler() {
607
666
  if (!this._togglerElement)
608
667
  return;
609
668
  this._togglerElement.removeEventListener('click', this._handleOpenSearch);
610
- this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
669
+ if (this.isSearchFocusTrapFixEnabled) {
670
+ this._togglerElement.removeEventListener('keydown', this._handleOpenSearchWithKeyboard);
671
+ }
672
+ else {
673
+ this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
674
+ }
611
675
  }
612
676
  render() {
613
677
  super.render();
614
678
  return lit.html `
679
+ ${when.when(!this.isSearchIconFixEnabled, () => lit.html ` <div
680
+ class="${search_constants.SEARCH_CLASS_NAMES.icon} labeled-icon hidden-md-only hidden-lg-only hidden-xl-only hidden-xxl-only hidden-xxxl-only"
681
+ tabindex="0"
682
+ aria-haspopup="dialog"
683
+ @click=${this._handleOpenSearch}
684
+ @keyup=${this.isSearchFocusTrapFixEnabled ? undefined : this._handleOpenSearchWithKeyboard}
685
+ @keydown=${this.isSearchFocusTrapFixEnabled ? this._handleOpenSearchWithKeyboard : undefined}
686
+ >
687
+ ${when.when(this._translations.openSearchButtonAriaLabel, () => lit.html `
688
+ <span id="${this._openSearchButtonAriaLabelId}" class="sr-only">
689
+ ${this._translations.openSearchButtonAriaLabel}
690
+ </span>
691
+ `)}
692
+ <h-icon icon-name="icon-search" size=${icon_constants.ICONS_SIZES.l}></h-icon>
693
+ <div ${ref_js.ref(this._openSearchButtonLabelRef)} class="labeled-icon__signature">${this._translations.search}</div>
694
+ </div>`)}
615
695
  ${when.when(this._isSuggesterLayerVisible(), () => lit.html `
616
696
  <div class="${search_constants.SEARCH_CLASS_NAMES.container}" id="${this._searchContentContainerId}" role="${this._containerRole}">
617
697
  ${when.when(this._shouldShowMessage, () => lit.html `<h-search-message
@@ -664,10 +744,18 @@ tslib_es6.__decorate([
664
744
  decorators.property({ type: String }),
665
745
  tslib_es6.__metadata("design:type", String)
666
746
  ], exports.HSearch.prototype, "locale", void 0);
747
+ tslib_es6.__decorate([
748
+ decorators.property({ type: Boolean, attribute: 'is-search-icon-fix-enabled' }),
749
+ tslib_es6.__metadata("design:type", Boolean)
750
+ ], exports.HSearch.prototype, "isSearchIconFixEnabled", void 0);
667
751
  tslib_es6.__decorate([
668
752
  decorators.property({ type: Boolean, attribute: 'is-search-ux-fixes-flag-enabled' }),
669
753
  tslib_es6.__metadata("design:type", Boolean)
670
754
  ], exports.HSearch.prototype, "isSearchUxFixesFlagEnabled", void 0);
755
+ tslib_es6.__decorate([
756
+ decorators.property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
757
+ tslib_es6.__metadata("design:type", Boolean)
758
+ ], exports.HSearch.prototype, "isSearchFocusTrapFixEnabled", void 0);
671
759
  tslib_es6.__decorate([
672
760
  decorators.property({ type: String, attribute: 'display-mode' }),
673
761
  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;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,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -13,6 +13,7 @@ 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.isSearchFocusTrapFixEnabled = false;
16
17
  this._isSearchPhraseCleared = false;
17
18
  this._setupAttributes = () => {
18
19
  var _a, _b, _c, _d;
@@ -72,36 +73,60 @@ exports.HSearchInput = class HSearchInput extends phoenix_light_lit_element.Phoe
72
73
  }
73
74
  });
74
75
  });
75
- this.input.addEventListener('keyup', (ev) => {
76
- if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape')
77
- return;
78
- if (ev.key !== 'Enter') {
76
+ if (this.isSearchFocusTrapFixEnabled) {
77
+ this.input.addEventListener('keydown', (ev) => {
78
+ if (ev.key !== 'Enter' || ev.repeat)
79
+ return;
80
+ if (this._isSearchPhraseCleared) {
81
+ this._isSearchPhraseCleared = false;
82
+ return;
83
+ }
84
+ this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, {
85
+ detail: { searchPhrase: ev.target.value }
86
+ });
87
+ });
88
+ this.input.addEventListener('keyup', debounce['default']((ev) => {
89
+ if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape' || ev.key === 'Enter')
90
+ return;
79
91
  this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.keyup, {
80
92
  detail: {
81
93
  searchPhrase: ev.target.value
82
94
  }
83
95
  });
84
- return;
85
- }
86
- if (this._isSearchPhraseCleared) {
87
- this._isSearchPhraseCleared = false;
88
- return;
89
- }
90
- this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, {
91
- detail: {
92
- searchPhrase: ev.target.value
96
+ }, 200));
97
+ }
98
+ else {
99
+ this.input.addEventListener('keyup', (ev) => {
100
+ if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape')
101
+ return;
102
+ if (ev.key !== 'Enter') {
103
+ this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.keyup, {
104
+ detail: {
105
+ searchPhrase: ev.target.value
106
+ }
107
+ });
108
+ return;
93
109
  }
94
- });
95
- });
96
- this.input.addEventListener('keyup', debounce['default']((ev) => {
97
- if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape' || ev.key === 'Enter')
98
- return;
99
- this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.keyup, {
100
- detail: {
101
- searchPhrase: ev.target.value
110
+ if (this._isSearchPhraseCleared) {
111
+ this._isSearchPhraseCleared = false;
112
+ return;
102
113
  }
114
+ this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, {
115
+ detail: {
116
+ searchPhrase: ev.target.value
117
+ }
118
+ });
103
119
  });
104
- }, 200));
120
+ this.input.addEventListener('keyup', debounce['default']((ev) => {
121
+ if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape' || ev.key === 'Enter')
122
+ return;
123
+ this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.keyup, {
124
+ detail: {
125
+ searchPhrase: ev.target.value
126
+ }
127
+ });
128
+ }, 200));
129
+ }
105
130
  this.input.addEventListener('search', (ev) => {
106
131
  if (this.input.value !== '') {
107
132
  return;
@@ -135,6 +160,10 @@ tslib_es6.__decorate([
135
160
  decorators.property({ type: String, attribute: 'module-instance-id' }),
136
161
  tslib_es6.__metadata("design:type", String)
137
162
  ], exports.HSearchInput.prototype, "moduleInstanceId", void 0);
163
+ tslib_es6.__decorate([
164
+ decorators.property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
165
+ tslib_es6.__metadata("design:type", Boolean)
166
+ ], exports.HSearchInput.prototype, "isSearchFocusTrapFixEnabled", void 0);
138
167
  tslib_es6.__decorate([
139
168
  decorators.state(),
140
169
  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;"}
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;"}
@@ -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,11 +1,14 @@
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
+ isSearchIconFixEnabled: boolean;
8
10
  isSearchUxFixesFlagEnabled: boolean;
11
+ isSearchFocusTrapFixEnabled: boolean;
9
12
  displayMode: TSearchDisplayMode;
10
13
  moduleInstanceId: string;
11
14
  private _historyContextProvider;
@@ -16,9 +19,11 @@ export declare class HSearch extends PhoenixLightLitElement {
16
19
  private _inputField;
17
20
  private _searchForm;
18
21
  private _togglerElement;
22
+ private _mobileDialogOpener;
19
23
  private _id;
20
24
  private _openSearchButtonAriaLabelId;
21
25
  private _searchContentContainerId;
26
+ mobileFocusTrapController: FocusTrapController;
22
27
  private _searchResultsRef;
23
28
  private _searchHistoryRef;
24
29
  private _searchMessageRef;
@@ -80,6 +85,9 @@ export declare class HSearch extends PhoenixLightLitElement {
80
85
  private _isSuggesterLayerVisible;
81
86
  private _preventSubmitOnSearchClear;
82
87
  private _resetSearchOnFocusOutside;
88
+ private _activateMobileDialog;
89
+ private _deactivateMobileDialog;
90
+ private _setupAriaAttributes;
83
91
  private _handleOpenSearch;
84
92
  private _handleOpenSearchWithKeyboard;
85
93
  private _setupToggler;
@@ -4,6 +4,7 @@ import { property, state } from 'lit/decorators';
4
4
  import { UiDomUtils } from '@dreamcommerce/utilities';
5
5
  import { PhoenixLightLitElement } from '../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
6
6
  import { phoenixCustomElement } from '../../../core/decorators/phoenix_custom_element.js';
7
+ import { ICONS_SIZES } from '../../icon/icon_constants.js';
7
8
  import { Observer } from '../../../core/classes/observer/observer.js';
8
9
  import { ContextConsumerController } from '../../../core/context/context_consumer_controller.js';
9
10
  import { BehaviorSubject } from '../../../core/classes/behavior_subject/behavior_subject.js';
@@ -15,17 +16,26 @@ import { MODAL_EVENTS } from '../../modal/modal_constants.js';
15
16
  import { SHEET_EVENTS } from '../../sheet/sheet_constants.js';
16
17
  import { when as n } from '../../../../../../external/lit-html/directives/when.js';
17
18
  import { DEFAULT_VIEW, SEARCH_CLASS_NAMES, SEARCH_COMPONENT_NAMES, SEARCH_CONFIGURATION, SEARCH_CONTEXT_NAMES, SEARCH_CUSTOM_EVENT_NAMES } from './search_constants.js';
19
+ import { FOCUS_TRAP_STRATEGY_TYPES } from '../../../controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js';
20
+ import { FocusTrapController } from '../../../controllers/focus_trap_controller/focus_trap_controller.js';
18
21
 
19
22
  let HSearch = class HSearch extends PhoenixLightLitElement {
20
23
  constructor() {
21
24
  super(...arguments);
22
25
  this.view = DEFAULT_VIEW;
26
+ this.isSearchIconFixEnabled = false;
23
27
  this.isSearchUxFixesFlagEnabled = false;
28
+ this.isSearchFocusTrapFixEnabled = false;
24
29
  this.displayMode = 'dropdown';
25
30
  this._togglerElement = null;
31
+ this._mobileDialogOpener = null;
26
32
  this._id = v4();
27
33
  this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
28
34
  this._searchContentContainerId = v4();
35
+ this.mobileFocusTrapController = new FocusTrapController(this, {
36
+ mode: FOCUS_TRAP_STRATEGY_TYPES.cyclic,
37
+ getContainer: () => this
38
+ });
29
39
  this._searchResultsRef = createRef();
30
40
  this._searchHistoryRef = createRef();
31
41
  this._searchMessageRef = createRef();
@@ -321,6 +331,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
321
331
  if (window.innerWidth > BREAKPOINTS.sm) {
322
332
  const hasBeenOpened = this.classList.contains(SEARCH_CLASS_NAMES.mobileOpened);
323
333
  this.classList.remove(SEARCH_CLASS_NAMES.mobileOpened);
334
+ if (this.isSearchFocusTrapFixEnabled)
335
+ this._deactivateMobileDialog();
324
336
  if (hasBeenOpened && this.displayMode !== 'dropdown') {
325
337
  const $storefrontSearch = document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`);
326
338
  const searchOverlayTriggerName = (_a = $storefrontSearch === null || $storefrontSearch === void 0 ? void 0 : $storefrontSearch.querySelector('[aria-haspopup="dialog"]')) === null || _a === void 0 ? void 0 : _a.getAttribute('name');
@@ -336,6 +348,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
336
348
  };
337
349
  this._openMobileView = () => {
338
350
  this.classList.add(SEARCH_CLASS_NAMES.mobileOpened);
351
+ if (this.isSearchFocusTrapFixEnabled)
352
+ this._activateMobileDialog();
339
353
  };
340
354
  this._isSuggesterLayerVisible = () => {
341
355
  var _a;
@@ -356,8 +370,27 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
356
370
  document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
357
371
  }
358
372
  };
373
+ this._activateMobileDialog = () => {
374
+ this._mobileDialogOpener = document.activeElement;
375
+ this.setAttribute('role', 'dialog');
376
+ this.setAttribute('aria-modal', 'true');
377
+ this.mobileFocusTrapController.activate();
378
+ };
379
+ this._deactivateMobileDialog = () => {
380
+ this.removeAttribute('role');
381
+ this.removeAttribute('aria-modal');
382
+ this.mobileFocusTrapController.deactivate();
383
+ };
384
+ this._setupAriaAttributes = () => {
385
+ var _a;
386
+ if (this._translations.openSearchButtonAriaLabel) {
387
+ (_a = this._openSearchButtonLabelRef.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-labelledby', this._openSearchButtonAriaLabelId);
388
+ }
389
+ };
359
390
  this._handleOpenSearch = () => {
360
391
  this.classList.add(SEARCH_CLASS_NAMES.mobileOpened);
392
+ if (this.isSearchFocusTrapFixEnabled)
393
+ this._activateMobileDialog();
361
394
  const shouldShowMessage = this._searchPhrase !== '';
362
395
  this._updateSearchView(this._searchPhrase, shouldShowMessage, false);
363
396
  const $searchInput = this.querySelector(`
@@ -366,7 +399,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
366
399
  $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
367
400
  };
368
401
  this._handleOpenSearchWithKeyboard = (ev) => {
369
- if (ev.code !== 'Enter')
402
+ const isRepeated = this.isSearchFocusTrapFixEnabled ? ev.repeat : false;
403
+ if (ev.code !== 'Enter' || isRepeated)
370
404
  return;
371
405
  ev.preventDefault();
372
406
  this._handleOpenSearch();
@@ -375,6 +409,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
375
409
  async connectedCallback() {
376
410
  super.connectedCallback();
377
411
  this._setupContext();
412
+ this._searchInput = this.querySelector(SEARCH_COMPONENT_NAMES.searchInput);
413
+ if (this.isSearchFocusTrapFixEnabled) {
414
+ this._setupInitialSearchPhrase();
415
+ this._setupListeners();
416
+ this.isSearchIconFixEnabled ? this._setupToggler() : this._setupAriaAttributes();
417
+ }
378
418
  try {
379
419
  this._searchContextConsumer = new ContextConsumerController(this);
380
420
  this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
@@ -403,10 +443,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
403
443
  catch (_a) {
404
444
  console.error('Search context is not provided');
405
445
  }
406
- this._searchInput = this.querySelector(SEARCH_COMPONENT_NAMES.searchInput);
407
- this._setupInitialSearchPhrase();
408
- this._setupListeners();
409
- this._setupToggler();
446
+ if (!this.isSearchFocusTrapFixEnabled) {
447
+ this._searchInput = this.querySelector(SEARCH_COMPONENT_NAMES.searchInput);
448
+ this._setupInitialSearchPhrase();
449
+ this._setupListeners();
450
+ this.isSearchIconFixEnabled ? this._setupToggler() : this._setupAriaAttributes();
451
+ }
410
452
  }
411
453
  disconnectedCallback() {
412
454
  var _a;
@@ -416,7 +458,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
416
458
  document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
417
459
  window.removeEventListener('resize', this._switchTypeOfSearchView);
418
460
  (_a = this._searchForm) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', this._preventSubmitOnSearchClear);
419
- this._teardownToggler();
461
+ if (this.isSearchIconFixEnabled)
462
+ this._teardownToggler();
420
463
  }
421
464
  _setupContext() {
422
465
  this._historyContextProvider = new ContextProviderController(this);
@@ -477,8 +520,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
477
520
  this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.submit, this._handleSubmitForm);
478
521
  this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.close, () => {
479
522
  this.classList.remove(SEARCH_CLASS_NAMES.mobileOpened);
523
+ if (this.isSearchFocusTrapFixEnabled)
524
+ this._deactivateMobileDialog();
480
525
  this._resetSearchView();
481
526
  this.isSearchUxFixesFlagEnabled && this._removeSearchKeyboardNavigation();
527
+ if (this.isSearchFocusTrapFixEnabled)
528
+ requestAnimationFrame(() => { var _a; return (_a = this._mobileDialogOpener) === null || _a === void 0 ? void 0 : _a.focus(); });
482
529
  });
483
530
  this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.loadMoreHistoryItems, () => {
484
531
  const contentLength = this._searchHistory.length;
@@ -585,8 +632,15 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
585
632
  this._setActiveItemId(`${this._id}-1`);
586
633
  const searchBar = this.querySelector(`.${SEARCH_CLASS_NAMES.searchBar}`);
587
634
  searchBar === null || searchBar === void 0 ? void 0 : searchBar.classList.remove(SEARCH_CLASS_NAMES.outline);
588
- if (this.displayMode === 'dropdown')
589
- this._hideHistorySuggestionsAndResults();
635
+ if (this.displayMode === 'dropdown') {
636
+ const isMobileViewOpen = this.classList.contains(SEARCH_CLASS_NAMES.mobileOpened);
637
+ if (isMobileViewOpen) {
638
+ this._displaySuggester(this._searchPhrase);
639
+ }
640
+ else {
641
+ this._hideHistorySuggestionsAndResults();
642
+ }
643
+ }
590
644
  !this.isSearchUxFixesFlagEnabled && this._removeSearchKeyboardNavigation();
591
645
  }
592
646
  _submitSearchPhrase(searchPhrase) {
@@ -597,17 +651,43 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
597
651
  if (!this._togglerElement)
598
652
  return;
599
653
  this._togglerElement.addEventListener('click', this._handleOpenSearch);
600
- this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
654
+ if (this.isSearchFocusTrapFixEnabled) {
655
+ this._togglerElement.addEventListener('keydown', this._handleOpenSearchWithKeyboard);
656
+ }
657
+ else {
658
+ this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
659
+ }
601
660
  }
602
661
  _teardownToggler() {
603
662
  if (!this._togglerElement)
604
663
  return;
605
664
  this._togglerElement.removeEventListener('click', this._handleOpenSearch);
606
- this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
665
+ if (this.isSearchFocusTrapFixEnabled) {
666
+ this._togglerElement.removeEventListener('keydown', this._handleOpenSearchWithKeyboard);
667
+ }
668
+ else {
669
+ this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
670
+ }
607
671
  }
608
672
  render() {
609
673
  super.render();
610
674
  return html `
675
+ ${n(!this.isSearchIconFixEnabled, () => html ` <div
676
+ class="${SEARCH_CLASS_NAMES.icon} labeled-icon hidden-md-only hidden-lg-only hidden-xl-only hidden-xxl-only hidden-xxxl-only"
677
+ tabindex="0"
678
+ aria-haspopup="dialog"
679
+ @click=${this._handleOpenSearch}
680
+ @keyup=${this.isSearchFocusTrapFixEnabled ? undefined : this._handleOpenSearchWithKeyboard}
681
+ @keydown=${this.isSearchFocusTrapFixEnabled ? this._handleOpenSearchWithKeyboard : undefined}
682
+ >
683
+ ${n(this._translations.openSearchButtonAriaLabel, () => html `
684
+ <span id="${this._openSearchButtonAriaLabelId}" class="sr-only">
685
+ ${this._translations.openSearchButtonAriaLabel}
686
+ </span>
687
+ `)}
688
+ <h-icon icon-name="icon-search" size=${ICONS_SIZES.l}></h-icon>
689
+ <div ${ref(this._openSearchButtonLabelRef)} class="labeled-icon__signature">${this._translations.search}</div>
690
+ </div>`)}
611
691
  ${n(this._isSuggesterLayerVisible(), () => html `
612
692
  <div class="${SEARCH_CLASS_NAMES.container}" id="${this._searchContentContainerId}" role="${this._containerRole}">
613
693
  ${n(this._shouldShowMessage, () => html `<h-search-message
@@ -660,10 +740,18 @@ __decorate([
660
740
  property({ type: String }),
661
741
  __metadata("design:type", String)
662
742
  ], HSearch.prototype, "locale", void 0);
743
+ __decorate([
744
+ property({ type: Boolean, attribute: 'is-search-icon-fix-enabled' }),
745
+ __metadata("design:type", Boolean)
746
+ ], HSearch.prototype, "isSearchIconFixEnabled", void 0);
663
747
  __decorate([
664
748
  property({ type: Boolean, attribute: 'is-search-ux-fixes-flag-enabled' }),
665
749
  __metadata("design:type", Boolean)
666
750
  ], HSearch.prototype, "isSearchUxFixesFlagEnabled", void 0);
751
+ __decorate([
752
+ property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
753
+ __metadata("design:type", Boolean)
754
+ ], HSearch.prototype, "isSearchFocusTrapFixEnabled", void 0);
667
755
  __decorate([
668
756
  property({ type: String, attribute: 'display-mode' }),
669
757
  __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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wDAA4D;AAC3E;AACA;AACA,0BAA0B,wDAA4D;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,6 +3,7 @@ import { PropertyValues } from 'lit';
3
3
  export declare class HSearchInput extends PhoenixLightLitElement {
4
4
  input: HTMLInputElement | null;
5
5
  moduleInstanceId: string;
6
+ isSearchFocusTrapFixEnabled: boolean;
6
7
  private _isSearchPhraseCleared;
7
8
  connectedCallback(): void;
8
9
  firstUpdated(props: PropertyValues): void;
@@ -9,6 +9,7 @@ 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.isSearchFocusTrapFixEnabled = false;
12
13
  this._isSearchPhraseCleared = false;
13
14
  this._setupAttributes = () => {
14
15
  var _a, _b, _c, _d;
@@ -68,36 +69,60 @@ let HSearchInput = class HSearchInput extends PhoenixLightLitElement {
68
69
  }
69
70
  });
70
71
  });
71
- this.input.addEventListener('keyup', (ev) => {
72
- if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape')
73
- return;
74
- if (ev.key !== 'Enter') {
72
+ if (this.isSearchFocusTrapFixEnabled) {
73
+ this.input.addEventListener('keydown', (ev) => {
74
+ if (ev.key !== 'Enter' || ev.repeat)
75
+ return;
76
+ if (this._isSearchPhraseCleared) {
77
+ this._isSearchPhraseCleared = false;
78
+ return;
79
+ }
80
+ this.emitCustomEvent(SEARCH_CUSTOM_EVENT_NAMES.submit, {
81
+ detail: { searchPhrase: ev.target.value }
82
+ });
83
+ });
84
+ this.input.addEventListener('keyup', debounce_1((ev) => {
85
+ if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape' || ev.key === 'Enter')
86
+ return;
75
87
  this.emitCustomEvent(SEARCH_CUSTOM_EVENT_NAMES.keyup, {
76
88
  detail: {
77
89
  searchPhrase: ev.target.value
78
90
  }
79
91
  });
80
- return;
81
- }
82
- if (this._isSearchPhraseCleared) {
83
- this._isSearchPhraseCleared = false;
84
- return;
85
- }
86
- this.emitCustomEvent(SEARCH_CUSTOM_EVENT_NAMES.submit, {
87
- detail: {
88
- searchPhrase: ev.target.value
92
+ }, 200));
93
+ }
94
+ else {
95
+ this.input.addEventListener('keyup', (ev) => {
96
+ if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape')
97
+ return;
98
+ if (ev.key !== 'Enter') {
99
+ this.emitCustomEvent(SEARCH_CUSTOM_EVENT_NAMES.keyup, {
100
+ detail: {
101
+ searchPhrase: ev.target.value
102
+ }
103
+ });
104
+ return;
89
105
  }
90
- });
91
- });
92
- this.input.addEventListener('keyup', debounce_1((ev) => {
93
- if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape' || ev.key === 'Enter')
94
- return;
95
- this.emitCustomEvent(SEARCH_CUSTOM_EVENT_NAMES.keyup, {
96
- detail: {
97
- searchPhrase: ev.target.value
106
+ if (this._isSearchPhraseCleared) {
107
+ this._isSearchPhraseCleared = false;
108
+ return;
98
109
  }
110
+ this.emitCustomEvent(SEARCH_CUSTOM_EVENT_NAMES.submit, {
111
+ detail: {
112
+ searchPhrase: ev.target.value
113
+ }
114
+ });
99
115
  });
100
- }, 200));
116
+ this.input.addEventListener('keyup', debounce_1((ev) => {
117
+ if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape' || ev.key === 'Enter')
118
+ return;
119
+ this.emitCustomEvent(SEARCH_CUSTOM_EVENT_NAMES.keyup, {
120
+ detail: {
121
+ searchPhrase: ev.target.value
122
+ }
123
+ });
124
+ }, 200));
125
+ }
101
126
  this.input.addEventListener('search', (ev) => {
102
127
  if (this.input.value !== '') {
103
128
  return;
@@ -131,6 +156,10 @@ __decorate([
131
156
  property({ type: String, attribute: 'module-instance-id' }),
132
157
  __metadata("design:type", String)
133
158
  ], HSearchInput.prototype, "moduleInstanceId", void 0);
159
+ __decorate([
160
+ property({ type: Boolean, attribute: 'is-search-focus-trap-fix-enabled' }),
161
+ __metadata("design:type", Boolean)
162
+ ], HSearchInput.prototype, "isSearchFocusTrapFixEnabled", void 0);
134
163
  __decorate([
135
164
  state(),
136
165
  __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;"}
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;"}
@@ -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.27-15",
5
+ "version": "1.18.27-16",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",