@shoper/phoenix_design_system 1.18.27-14 → 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.
- package/build/cjs/packages/phoenix/src/components/form/search/search.js +70 -10
- package/build/cjs/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +51 -22
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/slider/slider.js +16 -52
- package/build/cjs/packages/phoenix/src/components/slider/slider.js.map +1 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +44 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +66 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +14 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +10 -0
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
- package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +6 -0
- package/build/esm/packages/phoenix/src/components/form/search/search.js +70 -10
- package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.d.ts +1 -0
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +51 -22
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/slider/slider.d.ts +0 -2
- package/build/esm/packages/phoenix/src/components/slider/slider.js +16 -52
- package/build/esm/packages/phoenix/src/components/slider/slider.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +13 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +40 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +6 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +3 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +14 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +62 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +8 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +6 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +10 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +3 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +2 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +3 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +6 -0
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +1 -0
- package/package.json +2 -2
|
@@ -16,6 +16,8 @@ import { MODAL_EVENTS } from '../../modal/modal_constants.js';
|
|
|
16
16
|
import { SHEET_EVENTS } from '../../sheet/sheet_constants.js';
|
|
17
17
|
import { when as n } from '../../../../../../external/lit-html/directives/when.js';
|
|
18
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';
|
|
19
21
|
|
|
20
22
|
let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
21
23
|
constructor() {
|
|
@@ -23,11 +25,17 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
23
25
|
this.view = DEFAULT_VIEW;
|
|
24
26
|
this.isSearchIconFixEnabled = false;
|
|
25
27
|
this.isSearchUxFixesFlagEnabled = false;
|
|
28
|
+
this.isSearchFocusTrapFixEnabled = false;
|
|
26
29
|
this.displayMode = 'dropdown';
|
|
27
30
|
this._togglerElement = null;
|
|
31
|
+
this._mobileDialogOpener = null;
|
|
28
32
|
this._id = v4();
|
|
29
33
|
this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
|
|
30
34
|
this._searchContentContainerId = v4();
|
|
35
|
+
this.mobileFocusTrapController = new FocusTrapController(this, {
|
|
36
|
+
mode: FOCUS_TRAP_STRATEGY_TYPES.cyclic,
|
|
37
|
+
getContainer: () => this
|
|
38
|
+
});
|
|
31
39
|
this._searchResultsRef = createRef();
|
|
32
40
|
this._searchHistoryRef = createRef();
|
|
33
41
|
this._searchMessageRef = createRef();
|
|
@@ -323,6 +331,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
323
331
|
if (window.innerWidth > BREAKPOINTS.sm) {
|
|
324
332
|
const hasBeenOpened = this.classList.contains(SEARCH_CLASS_NAMES.mobileOpened);
|
|
325
333
|
this.classList.remove(SEARCH_CLASS_NAMES.mobileOpened);
|
|
334
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
335
|
+
this._deactivateMobileDialog();
|
|
326
336
|
if (hasBeenOpened && this.displayMode !== 'dropdown') {
|
|
327
337
|
const $storefrontSearch = document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`);
|
|
328
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');
|
|
@@ -338,6 +348,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
338
348
|
};
|
|
339
349
|
this._openMobileView = () => {
|
|
340
350
|
this.classList.add(SEARCH_CLASS_NAMES.mobileOpened);
|
|
351
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
352
|
+
this._activateMobileDialog();
|
|
341
353
|
};
|
|
342
354
|
this._isSuggesterLayerVisible = () => {
|
|
343
355
|
var _a;
|
|
@@ -358,6 +370,17 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
358
370
|
document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
|
|
359
371
|
}
|
|
360
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
|
+
};
|
|
361
384
|
this._setupAriaAttributes = () => {
|
|
362
385
|
var _a;
|
|
363
386
|
if (this._translations.openSearchButtonAriaLabel) {
|
|
@@ -366,6 +389,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
366
389
|
};
|
|
367
390
|
this._handleOpenSearch = () => {
|
|
368
391
|
this.classList.add(SEARCH_CLASS_NAMES.mobileOpened);
|
|
392
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
393
|
+
this._activateMobileDialog();
|
|
369
394
|
const shouldShowMessage = this._searchPhrase !== '';
|
|
370
395
|
this._updateSearchView(this._searchPhrase, shouldShowMessage, false);
|
|
371
396
|
const $searchInput = this.querySelector(`
|
|
@@ -374,7 +399,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
374
399
|
$searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
|
|
375
400
|
};
|
|
376
401
|
this._handleOpenSearchWithKeyboard = (ev) => {
|
|
377
|
-
|
|
402
|
+
const isRepeated = this.isSearchFocusTrapFixEnabled ? ev.repeat : false;
|
|
403
|
+
if (ev.code !== 'Enter' || isRepeated)
|
|
378
404
|
return;
|
|
379
405
|
ev.preventDefault();
|
|
380
406
|
this._handleOpenSearch();
|
|
@@ -383,6 +409,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
383
409
|
async connectedCallback() {
|
|
384
410
|
super.connectedCallback();
|
|
385
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
|
+
}
|
|
386
418
|
try {
|
|
387
419
|
this._searchContextConsumer = new ContextConsumerController(this);
|
|
388
420
|
this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
|
|
@@ -411,10 +443,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
411
443
|
catch (_a) {
|
|
412
444
|
console.error('Search context is not provided');
|
|
413
445
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
+
}
|
|
418
452
|
}
|
|
419
453
|
disconnectedCallback() {
|
|
420
454
|
var _a;
|
|
@@ -486,8 +520,12 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
486
520
|
this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.submit, this._handleSubmitForm);
|
|
487
521
|
this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.close, () => {
|
|
488
522
|
this.classList.remove(SEARCH_CLASS_NAMES.mobileOpened);
|
|
523
|
+
if (this.isSearchFocusTrapFixEnabled)
|
|
524
|
+
this._deactivateMobileDialog();
|
|
489
525
|
this._resetSearchView();
|
|
490
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(); });
|
|
491
529
|
});
|
|
492
530
|
this.addEventListener(SEARCH_CUSTOM_EVENT_NAMES.loadMoreHistoryItems, () => {
|
|
493
531
|
const contentLength = this._searchHistory.length;
|
|
@@ -594,8 +632,15 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
594
632
|
this._setActiveItemId(`${this._id}-1`);
|
|
595
633
|
const searchBar = this.querySelector(`.${SEARCH_CLASS_NAMES.searchBar}`);
|
|
596
634
|
searchBar === null || searchBar === void 0 ? void 0 : searchBar.classList.remove(SEARCH_CLASS_NAMES.outline);
|
|
597
|
-
if (this.displayMode === 'dropdown')
|
|
598
|
-
this.
|
|
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
|
+
}
|
|
599
644
|
!this.isSearchUxFixesFlagEnabled && this._removeSearchKeyboardNavigation();
|
|
600
645
|
}
|
|
601
646
|
_submitSearchPhrase(searchPhrase) {
|
|
@@ -606,13 +651,23 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
606
651
|
if (!this._togglerElement)
|
|
607
652
|
return;
|
|
608
653
|
this._togglerElement.addEventListener('click', this._handleOpenSearch);
|
|
609
|
-
|
|
654
|
+
if (this.isSearchFocusTrapFixEnabled) {
|
|
655
|
+
this._togglerElement.addEventListener('keydown', this._handleOpenSearchWithKeyboard);
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
|
|
659
|
+
}
|
|
610
660
|
}
|
|
611
661
|
_teardownToggler() {
|
|
612
662
|
if (!this._togglerElement)
|
|
613
663
|
return;
|
|
614
664
|
this._togglerElement.removeEventListener('click', this._handleOpenSearch);
|
|
615
|
-
|
|
665
|
+
if (this.isSearchFocusTrapFixEnabled) {
|
|
666
|
+
this._togglerElement.removeEventListener('keydown', this._handleOpenSearchWithKeyboard);
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
|
|
670
|
+
}
|
|
616
671
|
}
|
|
617
672
|
render() {
|
|
618
673
|
super.render();
|
|
@@ -622,7 +677,8 @@ let HSearch = class HSearch extends PhoenixLightLitElement {
|
|
|
622
677
|
tabindex="0"
|
|
623
678
|
aria-haspopup="dialog"
|
|
624
679
|
@click=${this._handleOpenSearch}
|
|
625
|
-
@keyup=${this._handleOpenSearchWithKeyboard}
|
|
680
|
+
@keyup=${this.isSearchFocusTrapFixEnabled ? undefined : this._handleOpenSearchWithKeyboard}
|
|
681
|
+
@keydown=${this.isSearchFocusTrapFixEnabled ? this._handleOpenSearchWithKeyboard : undefined}
|
|
626
682
|
>
|
|
627
683
|
${n(this._translations.openSearchButtonAriaLabel, () => html `
|
|
628
684
|
<span id="${this._openSearchButtonAriaLabelId}" class="sr-only">
|
|
@@ -692,6 +748,10 @@ __decorate([
|
|
|
692
748
|
property({ type: Boolean, attribute: 'is-search-ux-fixes-flag-enabled' }),
|
|
693
749
|
__metadata("design:type", Boolean)
|
|
694
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);
|
|
695
755
|
__decorate([
|
|
696
756
|
property({ type: String, attribute: 'display-mode' }),
|
|
697
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;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;"}
|
|
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;"}
|
package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.d.ts
CHANGED
|
@@ -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;
|
package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js
CHANGED
|
@@ -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.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;"}
|
|
@@ -3,12 +3,10 @@ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/pho
|
|
|
3
3
|
export declare class HSlider extends PhoenixLightLitElement {
|
|
4
4
|
settings: string;
|
|
5
5
|
id: string;
|
|
6
|
-
isSliderOptimizationFlagEnabled: boolean;
|
|
7
6
|
get sliderSettings(): ISliderOptions;
|
|
8
7
|
set sliderSettings(newSettingsObject: ISliderOptions);
|
|
9
8
|
private _settings;
|
|
10
9
|
private _slider;
|
|
11
|
-
private _mutationObserver;
|
|
12
10
|
private _$focusableElements;
|
|
13
11
|
connectedCallback(): void;
|
|
14
12
|
private _showFocusableNodes;
|
|
@@ -11,7 +11,6 @@ let HSlider = class HSlider extends PhoenixLightLitElement {
|
|
|
11
11
|
super(...arguments);
|
|
12
12
|
this.settings = '';
|
|
13
13
|
this.id = '';
|
|
14
|
-
this.isSliderOptimizationFlagEnabled = false;
|
|
15
14
|
this._settings = {
|
|
16
15
|
mountOnConnectedCallback: true,
|
|
17
16
|
type: 'loop',
|
|
@@ -19,8 +18,7 @@ let HSlider = class HSlider extends PhoenixLightLitElement {
|
|
|
19
18
|
focus: 'center'
|
|
20
19
|
};
|
|
21
20
|
this._slider = null;
|
|
22
|
-
this.
|
|
23
|
-
this._$focusableElements = new Set();
|
|
21
|
+
this._$focusableElements = [];
|
|
24
22
|
this._showFocusableNodes = (slideComponent) => {
|
|
25
23
|
this._handleFocusableNodes(slideComponent, SLIDER_HANDLE_FOCUSABLE_NODES_OPTIONS.show);
|
|
26
24
|
};
|
|
@@ -28,47 +26,27 @@ let HSlider = class HSlider extends PhoenixLightLitElement {
|
|
|
28
26
|
this._handleFocusableNodes(slideComponent, SLIDER_HANDLE_FOCUSABLE_NODES_OPTIONS.hide);
|
|
29
27
|
};
|
|
30
28
|
this._handleFocusableNodes = ({ slide }, action) => {
|
|
31
|
-
const $focusableSlideChildren =
|
|
29
|
+
const $focusableSlideChildren = this._$focusableElements.filter(($focusableElement) => slide.contains($focusableElement));
|
|
32
30
|
if ($focusableSlideChildren.length === 0)
|
|
33
31
|
return;
|
|
34
|
-
|
|
35
|
-
if (this.isSliderOptimizationFlagEnabled) {
|
|
36
|
-
updateFocusability = action === SLIDER_HANDLE_FOCUSABLE_NODES_OPTIONS.show ? UiDomUtils.showFocusableElement : UiDomUtils.hideFocusableElement;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
updateFocusability = action === SLIDER_HANDLE_FOCUSABLE_NODES_OPTIONS.show ? this._showFocusableElement : this._hideFocusableElement;
|
|
40
|
-
}
|
|
32
|
+
const updateFocusability = action === SLIDER_HANDLE_FOCUSABLE_NODES_OPTIONS.show ? this._showFocusableElement : this._hideFocusableElement;
|
|
41
33
|
$focusableSlideChildren.forEach(($element) => updateFocusability($element));
|
|
42
34
|
};
|
|
43
35
|
this._scanMutationsForNewFocusableElements = (mutationList) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
$focusableChildren.forEach(($child) => this._initializeFocusableElement($child));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
for (const mutation of mutationList) {
|
|
58
|
-
if (mutation.type !== 'childList')
|
|
59
|
-
continue;
|
|
60
|
-
const $target = mutation.target;
|
|
61
|
-
const isFocusable = UiDomUtils.isFocusable($target);
|
|
62
|
-
const $focusableChildren = [...$target.querySelectorAll(UiDomUtils.getFocusableSelector())];
|
|
63
|
-
isFocusable && this._initializeFocusableElement($target);
|
|
64
|
-
$focusableChildren.forEach(($child) => this._initializeFocusableElement($child));
|
|
65
|
-
}
|
|
36
|
+
for (const mutation of mutationList) {
|
|
37
|
+
if (mutation.type !== 'childList')
|
|
38
|
+
continue;
|
|
39
|
+
const $target = mutation.target;
|
|
40
|
+
const isFocusable = UiDomUtils.isFocusable($target);
|
|
41
|
+
const $focusableChildren = [...$target.querySelectorAll(UiDomUtils.getFocusableSelector())];
|
|
42
|
+
isFocusable && this._initializeFocusableElement($target);
|
|
43
|
+
$focusableChildren.forEach(($child) => this._initializeFocusableElement($child));
|
|
66
44
|
}
|
|
67
45
|
};
|
|
68
46
|
this._initializeFocusableElement = ($element) => {
|
|
69
|
-
!this._$focusableElements.
|
|
47
|
+
!this._$focusableElements.includes($element) && this._$focusableElements.push($element);
|
|
70
48
|
if ($element.closest('[aria-hidden="true"]')) {
|
|
71
|
-
|
|
49
|
+
this._hideFocusableElement($element);
|
|
72
50
|
}
|
|
73
51
|
};
|
|
74
52
|
}
|
|
@@ -92,14 +70,8 @@ let HSlider = class HSlider extends PhoenixLightLitElement {
|
|
|
92
70
|
}
|
|
93
71
|
this._slider.on('visible', this._showFocusableNodes);
|
|
94
72
|
this._slider.on('hidden', this._hideFocusableNodes);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this._mutationObserver.observe(this, { childList: true, subtree: true });
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const mutationObserver = new MutationObserver(this._scanMutationsForNewFocusableElements);
|
|
101
|
-
mutationObserver.observe(this, { childList: true, subtree: true, attributes: true });
|
|
102
|
-
}
|
|
73
|
+
const mutationObserver = new MutationObserver(this._scanMutationsForNewFocusableElements);
|
|
74
|
+
mutationObserver.observe(this, { childList: true, subtree: true, attributes: true });
|
|
103
75
|
}
|
|
104
76
|
_showFocusableElement($element) {
|
|
105
77
|
$element.setAttribute('tabindex', '0');
|
|
@@ -113,14 +85,10 @@ let HSlider = class HSlider extends PhoenixLightLitElement {
|
|
|
113
85
|
return this._slider;
|
|
114
86
|
}
|
|
115
87
|
disconnectedCallback() {
|
|
116
|
-
var _a, _b
|
|
88
|
+
var _a, _b;
|
|
117
89
|
super.disconnectedCallback();
|
|
118
90
|
(_a = this._slider) === null || _a === void 0 ? void 0 : _a.off('visible');
|
|
119
91
|
(_b = this._slider) === null || _b === void 0 ? void 0 : _b.off('hidden');
|
|
120
|
-
if (this.isSliderOptimizationFlagEnabled) {
|
|
121
|
-
(_c = this._mutationObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
122
|
-
this._mutationObserver = null;
|
|
123
|
-
}
|
|
124
92
|
}
|
|
125
93
|
};
|
|
126
94
|
__decorate([
|
|
@@ -131,10 +99,6 @@ __decorate([
|
|
|
131
99
|
property(),
|
|
132
100
|
__metadata("design:type", String)
|
|
133
101
|
], HSlider.prototype, "id", void 0);
|
|
134
|
-
__decorate([
|
|
135
|
-
property({ attribute: 'is-slider-optimization-flag-enabled' }),
|
|
136
|
-
__metadata("design:type", Boolean)
|
|
137
|
-
], HSlider.prototype, "isSliderOptimizationFlagEnabled", void 0);
|
|
138
102
|
HSlider = __decorate([
|
|
139
103
|
phoenixCustomElement('h-slider')
|
|
140
104
|
], HSlider);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA,uBAAuB,gEAAoE;AAC3F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,4CAAgD;AACvF;AACA;AACA;AACA;AACA,uBAAuB,gEAAoE;AAC3F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts
ADDED
|
@@ -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
|
+
}
|
package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js
ADDED
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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":""}
|