@shoper/phoenix_design_system 1.18.23-6 → 1.18.23-8

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 (33) hide show
  1. package/build/cjs/packages/phoenix/src/components/modal/modal.js +2 -10
  2. package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js +2 -10
  4. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js +0 -29
  6. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js.map +1 -1
  7. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js +30 -0
  8. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js.map +1 -1
  9. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js +13 -70
  10. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js +0 -6
  12. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js.map +1 -1
  13. package/build/esm/packages/phoenix/src/components/modal/modal.d.ts +0 -4
  14. package/build/esm/packages/phoenix/src/components/modal/modal.js +2 -10
  15. package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
  16. package/build/esm/packages/phoenix/src/components/sheet/sheet.d.ts +0 -4
  17. package/build/esm/packages/phoenix/src/components/sheet/sheet.js +2 -10
  18. package/build/esm/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  19. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +3 -7
  20. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.d.ts +2 -5
  21. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js +0 -29
  22. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy.js.map +1 -1
  23. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.d.ts +4 -2
  24. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js +30 -0
  25. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy.js.map +1 -1
  26. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_types.d.ts +1 -8
  27. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.d.ts +5 -20
  28. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js +13 -70
  29. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy.js.map +1 -1
  30. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.d.ts +3 -5
  31. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js +0 -6
  32. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy.js.map +1 -1
  33. package/package.json +1 -1
@@ -6,7 +6,6 @@ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
7
7
  var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
8
  var decorators_js = require('@lit/reactive-element/decorators.js');
9
- require('@lit/reactive-element');
10
9
  var litHtml = require('lit-html');
11
10
  var ref_js = require('lit-html/directives/ref.js');
12
11
  var portal_constants = require('../portal/portal_constants.js');
@@ -27,8 +26,6 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
27
26
  this.noAutofocus = false;
28
27
  this._focusedToggler = null;
29
28
  this._contentRef = ref_js.createRef();
30
- this._focusSentinelStart = ref_js.createRef();
31
- this._focusSentinelEnd = ref_js.createRef();
32
29
  this._propsChangeStrategies = {
33
30
  [modal_constants.MODAL_OPENED_PROP]: {
34
31
  true: () => {
@@ -136,10 +133,6 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
136
133
  document.removeEventListener(modal_constants.MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
137
134
  document.removeEventListener('keydown', this._bindCloseOnEsc);
138
135
  }
139
- firstUpdated(props) {
140
- super.firstUpdated(props);
141
- this._focusTrapController.strategy.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
142
- }
143
136
  updated(changedProps) {
144
137
  if (changedProps.has(modal_constants.MODAL_OPENED_PROP)) {
145
138
  this._propsChangeStrategies[modal_constants.MODAL_OPENED_PROP][String(this[modal_constants.MODAL_OPENED_PROP])]();
@@ -163,7 +156,6 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
163
156
  setTimeout(() => {
164
157
  var _a;
165
158
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
166
- this._focusTrapController.strategy.focusFirst();
167
159
  resolve();
168
160
  }, transitionDuration);
169
161
  });
@@ -191,11 +183,11 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
191
183
  return litHtml.html `
192
184
  <h-portal ?disabled="${!this.opened}" to="${modal_constants.MODALS_PORTAL_NAME}" hidden>
193
185
  <div class="modal-wrapper ${this.class}">
194
- <div tabindex="0" ${ref_js.ref(this._focusSentinelStart)}></div>
186
+ <div tabindex="0"></div>
195
187
  <div ${ref_js.ref(this._contentRef)} class="modal" role="dialog" aria-label="${this.modalLabel}">
196
188
  <div class="modal__container">${this.getSlot('header')} ${this.getSlot('body')} ${this.getSlot('footer')}</div>
197
189
  </div>
198
- <div tabindex="0" ${ref_js.ref(this._focusSentinelEnd)}></div>
190
+ <div tabindex="0"></div>
199
191
  </div>
200
192
  </h-portal>
201
193
  `;
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -6,7 +6,6 @@ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
7
7
  var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
8
  var decorators_js = require('@lit/reactive-element/decorators.js');
9
- require('@lit/reactive-element');
10
9
  var litHtml = require('lit-html');
11
10
  var ref_js = require('lit-html/directives/ref.js');
12
11
  var portal_constants = require('../portal/portal_constants.js');
@@ -26,8 +25,6 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
26
25
  this.sheetLabel = '';
27
26
  this._focusedToggler = null;
28
27
  this._contentRef = ref_js.createRef();
29
- this._focusSentinelStart = ref_js.createRef();
30
- this._focusSentinelEnd = ref_js.createRef();
31
28
  this._propsChangeStrategies = {
32
29
  [sheet_constants.SHEET_OPENED_PROP]: {
33
30
  true: () => {
@@ -134,10 +131,6 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
134
131
  document.removeEventListener(sheet_constants.SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
135
132
  document.removeEventListener('keydown', this._bindCloseOnEsc);
136
133
  }
137
- firstUpdated(props) {
138
- super.firstUpdated(props);
139
- this._focusTrapController.strategy.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
140
- }
141
134
  updated(changedProps) {
142
135
  if (changedProps.has(sheet_constants.SHEET_OPENED_PROP)) {
143
136
  this._propsChangeStrategies[sheet_constants.SHEET_OPENED_PROP][String(this[sheet_constants.SHEET_OPENED_PROP])]();
@@ -158,7 +151,6 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
158
151
  setTimeout(() => {
159
152
  var _a;
160
153
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`sheet_show-${this.transition}-start`, `sheet_show-${this.transition}-end`);
161
- this._focusTrapController.strategy.focusFirst();
162
154
  resolve();
163
155
  }, transitionDuration);
164
156
  });
@@ -184,11 +176,11 @@ exports.HSheet = HSheet_1 = class HSheet extends phoenix_light_lit_element.Phoen
184
176
  return litHtml.html `
185
177
  <h-portal ?disabled="${!this.opened}" to="${sheet_constants.SHEETS_PORTAL_NAME}" hidden>
186
178
  <div class="sheet-wrapper ${this.class}">
187
- <div tabindex="0" ${ref_js.ref(this._focusSentinelStart)}></div>
179
+ <div tabindex="0"></div>
188
180
  <div ${ref_js.ref(this._contentRef)} class="sheet" role="dialog" aria-label="${this.sheetLabel}">
189
181
  <div class="sheet__container">${this.getSlot('header')} ${this.getSlot('body')} ${this.getSlot('footer')}</div>
190
182
  </div>
191
- <div tabindex="0" ${ref_js.ref(this._focusSentinelEnd)}></div>
183
+ <div tabindex="0"></div>
192
184
  </div>
193
185
  </h-portal>
194
186
  `;
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -17,35 +17,6 @@ var focus_trap_strategy = require('./focus_trap_strategy.js');
17
17
  class CyclicFocusTrapStrategy extends focus_trap_strategy.FocusTrapStrategy {
18
18
  constructor({ getContainer }) {
19
19
  super(getContainer);
20
- this._handleKeyDown = (ev) => {
21
- if (!this.active || ev.code !== 'Tab')
22
- return;
23
- const container = this.getContainer();
24
- if (!container)
25
- return;
26
- const focusableElements = this.getFocusableElements(container);
27
- if (focusableElements.length === 0)
28
- return;
29
- const $target = ev.target;
30
- if (ev.shiftKey) {
31
- if ($target === focusableElements[0]) {
32
- ev.preventDefault();
33
- focusableElements[focusableElements.length - 1].focus();
34
- }
35
- }
36
- else {
37
- if ($target === focusableElements[focusableElements.length - 1]) {
38
- ev.preventDefault();
39
- focusableElements[0].focus();
40
- }
41
- }
42
- };
43
- }
44
- attach() {
45
- document.addEventListener('keydown', this._handleKeyDown);
46
- }
47
- detach() {
48
- document.removeEventListener('keydown', this._handleKeyDown);
49
20
  }
50
21
  }
51
22
 
@@ -1 +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;"}
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;"}
@@ -8,6 +8,36 @@ class FocusTrapStrategy {
8
8
  constructor(getContainer) {
9
9
  this.getContainer = getContainer;
10
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);
11
41
  }
12
42
  activate() {
13
43
  this.active = true;
@@ -1 +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;"}
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;"}
@@ -2,92 +2,35 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../../../../../external/tslib/tslib.es6.js');
6
- require('@dreamcommerce/utilities');
7
5
  var focus_trap_strategy = require('./focus_trap_strategy.js');
8
6
 
9
- var _SentinelFocusTrapStrategy_sentinelStart, _SentinelFocusTrapStrategy_sentinelEnd;
10
7
  /**
11
8
  * Sentinel mode focus trap.
12
9
  *
13
- * Uses two inert bookend elements (sentinelStart / sentinelEnd) to detect when focus
14
- * escapes the container and cycle it back. Appropriate for modal dialogs and sheets where
15
- * background content is marked `inert`, giving the browser an extra safety net.
16
- *
17
- * Reacts on `keyup` so that the browser's native focus movement has already completed
18
- * before we redirect it.
10
+ * Traps focus within the container using `keydown` interception. On `activate()`,
11
+ * automatically moves focus to the first focusable element inside the container.
12
+ * Appropriate for modal dialogs and sheets where background content is marked `inert`.
19
13
  */
20
14
  class SentinelFocusTrapStrategy extends focus_trap_strategy.FocusTrapStrategy {
21
15
  constructor({ getContainer, noAutofocus = false }) {
22
16
  super(getContainer);
23
- _SentinelFocusTrapStrategy_sentinelStart.set(this, void 0);
24
- _SentinelFocusTrapStrategy_sentinelEnd.set(this, void 0);
25
- this._handleKeyUp = (ev) => {
26
- if (!this.active || ev.code !== 'Tab')
27
- return;
28
- const container = this.getContainer();
29
- if (!container)
30
- return;
31
- const focusableElements = this.getFocusableElements(container);
32
- if (focusableElements.length === 0)
33
- return;
34
- const $target = ev.target;
35
- if (ev.shiftKey) {
36
- if ($target === focusableElements[0]) {
37
- ev.preventDefault();
38
- focusableElements[focusableElements.length - 1].focus();
39
- }
40
- }
41
- else {
42
- if ($target === focusableElements[focusableElements.length - 1]) {
43
- ev.preventDefault();
44
- focusableElements[0].focus();
45
- }
46
- }
47
- };
48
17
  this.noAutofocus = noAutofocus;
49
18
  }
50
- /** Call once in firstUpdated with the two bookend sentinel elements. */
51
- setSentinels(start, end) {
52
- tslib_es6.__classPrivateFieldSet(this, _SentinelFocusTrapStrategy_sentinelStart, start, "f");
53
- tslib_es6.__classPrivateFieldSet(this, _SentinelFocusTrapStrategy_sentinelEnd, end, "f");
54
- }
55
- /**
56
- * Move focus to the first real interactive element after the open transition
57
- * completes (skips sentinelStart at index 0).
58
- */
59
- focusFirst() {
60
- if (this.noAutofocus)
61
- return;
62
- requestAnimationFrame(() => {
63
- const container = this.getContainer();
64
- if (!container)
65
- return;
66
- const focusableElements = this.getFocusableElements(container);
67
- if (focusableElements.length > 0) {
68
- focusableElements.length > 1 ? focusableElements[1].focus() : focusableElements[0].focus();
69
- }
70
- });
71
- }
72
- attach() {
73
- document.addEventListener('keydown', this._handleKeyUp);
74
- }
75
- detach() {
76
- document.removeEventListener('keydown', this._handleKeyUp);
77
- }
78
19
  activate() {
79
20
  this.active = true;
80
21
  if (!this.noAutofocus) {
81
- const scrollY = window.scrollY;
82
- setTimeout(() => {
83
- var _a;
84
- (_a = tslib_es6.__classPrivateFieldGet(this, _SentinelFocusTrapStrategy_sentinelStart, "f")) === null || _a === void 0 ? void 0 : _a.focus();
85
- window.scrollTo(0, scrollY);
86
- }, 0);
22
+ requestAnimationFrame(() => {
23
+ const container = this.getContainer();
24
+ if (!container)
25
+ return;
26
+ const focusableElements = this.getFocusableElements(container);
27
+ if (focusableElements.length > 0) {
28
+ focusableElements.length > 1 ? focusableElements[1].focus() : focusableElements[0].focus();
29
+ }
30
+ });
87
31
  }
88
32
  }
89
- }
90
- _SentinelFocusTrapStrategy_sentinelStart = new WeakMap(), _SentinelFocusTrapStrategy_sentinelEnd = new WeakMap();
33
+ }
91
34
 
92
35
  exports.SentinelFocusTrapStrategy = SentinelFocusTrapStrategy;
93
36
  //# sourceMappingURL=sentinel_focus_trap_strategy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -64,12 +64,6 @@ class TogglerFocusTrapStrategy extends focus_trap_strategy.FocusTrapStrategy {
64
64
  };
65
65
  tslib_es6.__classPrivateFieldSet(this, _TogglerFocusTrapStrategy_getToggler, getToggler, "f");
66
66
  }
67
- attach() {
68
- document.addEventListener('keydown', this._handleKeyDown);
69
- }
70
- detach() {
71
- document.removeEventListener('keydown', this._handleKeyDown);
72
- }
73
67
  }
74
68
  _TogglerFocusTrapStrategy_getToggler = new WeakMap();
75
69
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,6 +1,5 @@
1
1
  import { TemplateResult } from 'lit-html';
2
2
  import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
3
- import { PropertyValues } from '@lit/reactive-element';
4
3
  export declare class HModal extends PhoenixLightLitElement {
5
4
  opened: boolean;
6
5
  class: string;
@@ -9,8 +8,6 @@ export declare class HModal extends PhoenixLightLitElement {
9
8
  noAutofocus: boolean;
10
9
  private _focusedToggler;
11
10
  private _contentRef;
12
- private _focusSentinelStart;
13
- private _focusSentinelEnd;
14
11
  private _propsChangeStrategies;
15
12
  private static openModals;
16
13
  private _backdropController;
@@ -20,7 +17,6 @@ export declare class HModal extends PhoenixLightLitElement {
20
17
  constructor();
21
18
  connectedCallback(): void;
22
19
  disconnectedCallback(): void;
23
- firstUpdated(props: PropertyValues): void;
24
20
  updated(changedProps: Map<string, any>): void;
25
21
  private _handleCloseFromCloseComponent;
26
22
  private _bindCloseOnEsc;
@@ -2,7 +2,6 @@ import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.
2
2
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
3
3
  import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
4
  import { property } from '@lit/reactive-element/decorators.js';
5
- import '@lit/reactive-element';
6
5
  import { html } from 'lit-html';
7
6
  import { createRef, ref } from 'lit-html/directives/ref.js';
8
7
  import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
@@ -23,8 +22,6 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
23
22
  this.noAutofocus = false;
24
23
  this._focusedToggler = null;
25
24
  this._contentRef = createRef();
26
- this._focusSentinelStart = createRef();
27
- this._focusSentinelEnd = createRef();
28
25
  this._propsChangeStrategies = {
29
26
  [MODAL_OPENED_PROP]: {
30
27
  true: () => {
@@ -132,10 +129,6 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
132
129
  document.removeEventListener(MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
133
130
  document.removeEventListener('keydown', this._bindCloseOnEsc);
134
131
  }
135
- firstUpdated(props) {
136
- super.firstUpdated(props);
137
- this._focusTrapController.strategy.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
138
- }
139
132
  updated(changedProps) {
140
133
  if (changedProps.has(MODAL_OPENED_PROP)) {
141
134
  this._propsChangeStrategies[MODAL_OPENED_PROP][String(this[MODAL_OPENED_PROP])]();
@@ -159,7 +152,6 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
159
152
  setTimeout(() => {
160
153
  var _a;
161
154
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
162
- this._focusTrapController.strategy.focusFirst();
163
155
  resolve();
164
156
  }, transitionDuration);
165
157
  });
@@ -187,11 +179,11 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
187
179
  return html `
188
180
  <h-portal ?disabled="${!this.opened}" to="${MODALS_PORTAL_NAME}" hidden>
189
181
  <div class="modal-wrapper ${this.class}">
190
- <div tabindex="0" ${ref(this._focusSentinelStart)}></div>
182
+ <div tabindex="0"></div>
191
183
  <div ${ref(this._contentRef)} class="modal" role="dialog" aria-label="${this.modalLabel}">
192
184
  <div class="modal__container">${this.getSlot('header')} ${this.getSlot('body')} ${this.getSlot('footer')}</div>
193
185
  </div>
194
- <div tabindex="0" ${ref(this._focusSentinelEnd)}></div>
186
+ <div tabindex="0"></div>
195
187
  </div>
196
188
  </h-portal>
197
189
  `;
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,6 +1,5 @@
1
1
  import { TemplateResult } from 'lit-html';
2
2
  import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
3
- import { PropertyValues } from '@lit/reactive-element';
4
3
  export declare class HSheet extends PhoenixLightLitElement {
5
4
  opened: boolean;
6
5
  class: string;
@@ -8,8 +7,6 @@ export declare class HSheet extends PhoenixLightLitElement {
8
7
  sheetLabel: string;
9
8
  private _focusedToggler;
10
9
  private _contentRef;
11
- private _focusSentinelStart;
12
- private _focusSentinelEnd;
13
10
  private _propsChangeStrategies;
14
11
  private static openSheets;
15
12
  private _backdropController;
@@ -19,7 +16,6 @@ export declare class HSheet extends PhoenixLightLitElement {
19
16
  constructor();
20
17
  connectedCallback(): void;
21
18
  disconnectedCallback(): void;
22
- firstUpdated(props: PropertyValues): void;
23
19
  updated(changedProps: Map<string, any>): void;
24
20
  private _handleCloseFromCloseComponent;
25
21
  private _bindCloseOnEsc;
@@ -2,7 +2,6 @@ import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.
2
2
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
3
3
  import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
4
  import { property } from '@lit/reactive-element/decorators.js';
5
- import '@lit/reactive-element';
6
5
  import { html } from 'lit-html';
7
6
  import { createRef, ref } from 'lit-html/directives/ref.js';
8
7
  import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
@@ -22,8 +21,6 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
22
21
  this.sheetLabel = '';
23
22
  this._focusedToggler = null;
24
23
  this._contentRef = createRef();
25
- this._focusSentinelStart = createRef();
26
- this._focusSentinelEnd = createRef();
27
24
  this._propsChangeStrategies = {
28
25
  [SHEET_OPENED_PROP]: {
29
26
  true: () => {
@@ -130,10 +127,6 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
130
127
  document.removeEventListener(SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
131
128
  document.removeEventListener('keydown', this._bindCloseOnEsc);
132
129
  }
133
- firstUpdated(props) {
134
- super.firstUpdated(props);
135
- this._focusTrapController.strategy.setSentinels(this._focusSentinelStart.value, this._focusSentinelEnd.value);
136
- }
137
130
  updated(changedProps) {
138
131
  if (changedProps.has(SHEET_OPENED_PROP)) {
139
132
  this._propsChangeStrategies[SHEET_OPENED_PROP][String(this[SHEET_OPENED_PROP])]();
@@ -154,7 +147,6 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
154
147
  setTimeout(() => {
155
148
  var _a;
156
149
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`sheet_show-${this.transition}-start`, `sheet_show-${this.transition}-end`);
157
- this._focusTrapController.strategy.focusFirst();
158
150
  resolve();
159
151
  }, transitionDuration);
160
152
  });
@@ -180,11 +172,11 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
180
172
  return html `
181
173
  <h-portal ?disabled="${!this.opened}" to="${SHEETS_PORTAL_NAME}" hidden>
182
174
  <div class="sheet-wrapper ${this.class}">
183
- <div tabindex="0" ${ref(this._focusSentinelStart)}></div>
175
+ <div tabindex="0"></div>
184
176
  <div ${ref(this._contentRef)} class="sheet" role="dialog" aria-label="${this.sheetLabel}">
185
177
  <div class="sheet__container">${this.getSlot('header')} ${this.getSlot('body')} ${this.getSlot('footer')}</div>
186
178
  </div>
187
- <div tabindex="0" ${ref(this._focusSentinelEnd)}></div>
179
+ <div tabindex="0"></div>
188
180
  </div>
189
181
  </h-portal>
190
182
  `;
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,17 +1,13 @@
1
1
  import { ReactiveController, ReactiveControllerHost } from 'lit';
2
- import type { SentinelFocusTrapStrategy } from './strategies/sentinel_focus_trap_strategy';
3
- import type { CyclicFocusTrapStrategy } from './strategies/cyclic_focus_trap_strategy';
4
- import type { TogglerFocusTrapStrategy } from './strategies/toggler_focus_trap_strategy';
5
- import type { TFocusTrapProps, TSentinelFocusTrapProps, TCyclicFocusTrapProps } from './focus_trap_controller_types';
6
- declare type StrategyFor<T extends TFocusTrapProps> = T extends TSentinelFocusTrapProps ? SentinelFocusTrapStrategy : T extends TCyclicFocusTrapProps ? CyclicFocusTrapStrategy : TogglerFocusTrapStrategy;
2
+ import type { TFocusTrapProps } from './focus_trap_controller_types';
3
+ import { IFocusTrapStrategy } from './strategies/focus_trap_strategy_types';
7
4
  export declare class FocusTrapController<TProps extends TFocusTrapProps = TFocusTrapProps> implements ReactiveController {
8
5
  #private;
9
6
  constructor(host: ReactiveControllerHost, { mode, ...strategyProps }: TProps);
10
- get strategy(): StrategyFor<TProps>;
7
+ get strategy(): IFocusTrapStrategy;
11
8
  hostConnected(): void;
12
9
  hostDisconnected(): void;
13
10
  activate(): void;
14
11
  deactivate(): void;
15
12
  getFocusableElements(container: HTMLElement): HTMLElement[];
16
13
  }
17
- export {};
@@ -1,5 +1,5 @@
1
1
  import { FocusTrapStrategy } from './focus_trap_strategy';
2
- import { ICyclicFocusTrapStrategy } from './focus_trap_strategy_types';
2
+ import { IFocusTrapStrategy } from './focus_trap_strategy_types';
3
3
  export declare type TCyclicFocusTrapStrategyProps = {
4
4
  getContainer: () => HTMLElement | undefined;
5
5
  };
@@ -13,9 +13,6 @@ export declare type TCyclicFocusTrapStrategyProps = {
13
13
  * Suitable when the host is not portaled and `inert` is not applied to background content
14
14
  * (e.g. a full-screen search overlay on mobile).
15
15
  */
16
- export declare class CyclicFocusTrapStrategy extends FocusTrapStrategy implements ICyclicFocusTrapStrategy {
16
+ export declare class CyclicFocusTrapStrategy extends FocusTrapStrategy implements IFocusTrapStrategy {
17
17
  constructor({ getContainer }: TCyclicFocusTrapStrategyProps);
18
- attach(): void;
19
- detach(): void;
20
- private _handleKeyDown;
21
18
  }
@@ -13,35 +13,6 @@ import { FocusTrapStrategy } from './focus_trap_strategy.js';
13
13
  class CyclicFocusTrapStrategy extends FocusTrapStrategy {
14
14
  constructor({ getContainer }) {
15
15
  super(getContainer);
16
- this._handleKeyDown = (ev) => {
17
- if (!this.active || ev.code !== 'Tab')
18
- return;
19
- const container = this.getContainer();
20
- if (!container)
21
- return;
22
- const focusableElements = this.getFocusableElements(container);
23
- if (focusableElements.length === 0)
24
- return;
25
- const $target = ev.target;
26
- if (ev.shiftKey) {
27
- if ($target === focusableElements[0]) {
28
- ev.preventDefault();
29
- focusableElements[focusableElements.length - 1].focus();
30
- }
31
- }
32
- else {
33
- if ($target === focusableElements[focusableElements.length - 1]) {
34
- ev.preventDefault();
35
- focusableElements[0].focus();
36
- }
37
- }
38
- };
39
- }
40
- attach() {
41
- document.addEventListener('keydown', this._handleKeyDown);
42
- }
43
- detach() {
44
- document.removeEventListener('keydown', this._handleKeyDown);
45
16
  }
46
17
  }
47
18
 
@@ -1 +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;"}
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;"}
@@ -2,11 +2,13 @@ import { IFocusTrapStrategy } from './focus_trap_strategy_types';
2
2
  export declare abstract class FocusTrapStrategy implements IFocusTrapStrategy {
3
3
  protected readonly getContainer: () => HTMLElement | undefined;
4
4
  protected active: boolean;
5
+ noAutofocus: boolean;
5
6
  constructor(getContainer: () => HTMLElement | undefined);
6
- abstract attach(): void;
7
- abstract detach(): void;
7
+ attach(): void;
8
+ detach(): void;
8
9
  activate(): void;
9
10
  deactivate(): void;
10
11
  getFocusableElements(container: HTMLElement): HTMLElement[];
12
+ protected _handleKeyDown: (ev: KeyboardEvent) => void;
11
13
  private _isElementTrulyFocusable;
12
14
  }
@@ -4,6 +4,36 @@ class FocusTrapStrategy {
4
4
  constructor(getContainer) {
5
5
  this.getContainer = getContainer;
6
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);
7
37
  }
8
38
  activate() {
9
39
  this.active = true;
@@ -1 +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;"}
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;"}
@@ -1,15 +1,8 @@
1
1
  export interface IFocusTrapStrategy {
2
+ noAutofocus: boolean;
2
3
  attach(): void;
3
4
  detach(): void;
4
5
  activate(): void;
5
6
  deactivate(): void;
6
7
  getFocusableElements(container: HTMLElement): HTMLElement[];
7
8
  }
8
- export interface ICyclicFocusTrapStrategy extends IFocusTrapStrategy {
9
- }
10
- export interface ITogglerFocusTrapStrategy extends IFocusTrapStrategy {
11
- }
12
- export interface ISentinelFocusTrapStrategy extends IFocusTrapStrategy {
13
- setSentinels(start: HTMLElement, end: HTMLElement): void;
14
- focusFirst(): void;
15
- }
@@ -1,5 +1,5 @@
1
1
  import { FocusTrapStrategy } from './focus_trap_strategy';
2
- import { ISentinelFocusTrapStrategy } from './focus_trap_strategy_types';
2
+ import { IFocusTrapStrategy } from './focus_trap_strategy_types';
3
3
  export declare type TSentinelFocusTrapStrategyProps = {
4
4
  getContainer: () => HTMLElement | undefined;
5
5
  noAutofocus?: boolean;
@@ -7,26 +7,11 @@ export declare type TSentinelFocusTrapStrategyProps = {
7
7
  /**
8
8
  * Sentinel mode focus trap.
9
9
  *
10
- * Uses two inert bookend elements (sentinelStart / sentinelEnd) to detect when focus
11
- * escapes the container and cycle it back. Appropriate for modal dialogs and sheets where
12
- * background content is marked `inert`, giving the browser an extra safety net.
13
- *
14
- * Reacts on `keyup` so that the browser's native focus movement has already completed
15
- * before we redirect it.
10
+ * Traps focus within the container using `keydown` interception. On `activate()`,
11
+ * automatically moves focus to the first focusable element inside the container.
12
+ * Appropriate for modal dialogs and sheets where background content is marked `inert`.
16
13
  */
17
- export declare class SentinelFocusTrapStrategy extends FocusTrapStrategy implements ISentinelFocusTrapStrategy {
18
- #private;
19
- noAutofocus: boolean;
14
+ export declare class SentinelFocusTrapStrategy extends FocusTrapStrategy implements IFocusTrapStrategy {
20
15
  constructor({ getContainer, noAutofocus }: TSentinelFocusTrapStrategyProps);
21
- /** Call once in firstUpdated with the two bookend sentinel elements. */
22
- setSentinels(start: HTMLElement, end: HTMLElement): void;
23
- /**
24
- * Move focus to the first real interactive element after the open transition
25
- * completes (skips sentinelStart at index 0).
26
- */
27
- focusFirst(): void;
28
- attach(): void;
29
- detach(): void;
30
16
  activate(): void;
31
- private _handleKeyUp;
32
17
  }
@@ -1,89 +1,32 @@
1
- import { __classPrivateFieldSet, __classPrivateFieldGet } from '../../../../../../external/tslib/tslib.es6.js';
2
- import '@dreamcommerce/utilities';
3
1
  import { FocusTrapStrategy } from './focus_trap_strategy.js';
4
2
 
5
- var _SentinelFocusTrapStrategy_sentinelStart, _SentinelFocusTrapStrategy_sentinelEnd;
6
3
  /**
7
4
  * Sentinel mode focus trap.
8
5
  *
9
- * Uses two inert bookend elements (sentinelStart / sentinelEnd) to detect when focus
10
- * escapes the container and cycle it back. Appropriate for modal dialogs and sheets where
11
- * background content is marked `inert`, giving the browser an extra safety net.
12
- *
13
- * Reacts on `keyup` so that the browser's native focus movement has already completed
14
- * before we redirect it.
6
+ * Traps focus within the container using `keydown` interception. On `activate()`,
7
+ * automatically moves focus to the first focusable element inside the container.
8
+ * Appropriate for modal dialogs and sheets where background content is marked `inert`.
15
9
  */
16
10
  class SentinelFocusTrapStrategy extends FocusTrapStrategy {
17
11
  constructor({ getContainer, noAutofocus = false }) {
18
12
  super(getContainer);
19
- _SentinelFocusTrapStrategy_sentinelStart.set(this, void 0);
20
- _SentinelFocusTrapStrategy_sentinelEnd.set(this, void 0);
21
- this._handleKeyUp = (ev) => {
22
- if (!this.active || ev.code !== 'Tab')
23
- return;
24
- const container = this.getContainer();
25
- if (!container)
26
- return;
27
- const focusableElements = this.getFocusableElements(container);
28
- if (focusableElements.length === 0)
29
- return;
30
- const $target = ev.target;
31
- if (ev.shiftKey) {
32
- if ($target === focusableElements[0]) {
33
- ev.preventDefault();
34
- focusableElements[focusableElements.length - 1].focus();
35
- }
36
- }
37
- else {
38
- if ($target === focusableElements[focusableElements.length - 1]) {
39
- ev.preventDefault();
40
- focusableElements[0].focus();
41
- }
42
- }
43
- };
44
13
  this.noAutofocus = noAutofocus;
45
14
  }
46
- /** Call once in firstUpdated with the two bookend sentinel elements. */
47
- setSentinels(start, end) {
48
- __classPrivateFieldSet(this, _SentinelFocusTrapStrategy_sentinelStart, start, "f");
49
- __classPrivateFieldSet(this, _SentinelFocusTrapStrategy_sentinelEnd, end, "f");
50
- }
51
- /**
52
- * Move focus to the first real interactive element after the open transition
53
- * completes (skips sentinelStart at index 0).
54
- */
55
- focusFirst() {
56
- if (this.noAutofocus)
57
- return;
58
- requestAnimationFrame(() => {
59
- const container = this.getContainer();
60
- if (!container)
61
- return;
62
- const focusableElements = this.getFocusableElements(container);
63
- if (focusableElements.length > 0) {
64
- focusableElements.length > 1 ? focusableElements[1].focus() : focusableElements[0].focus();
65
- }
66
- });
67
- }
68
- attach() {
69
- document.addEventListener('keydown', this._handleKeyUp);
70
- }
71
- detach() {
72
- document.removeEventListener('keydown', this._handleKeyUp);
73
- }
74
15
  activate() {
75
16
  this.active = true;
76
17
  if (!this.noAutofocus) {
77
- const scrollY = window.scrollY;
78
- setTimeout(() => {
79
- var _a;
80
- (_a = __classPrivateFieldGet(this, _SentinelFocusTrapStrategy_sentinelStart, "f")) === null || _a === void 0 ? void 0 : _a.focus();
81
- window.scrollTo(0, scrollY);
82
- }, 0);
18
+ requestAnimationFrame(() => {
19
+ const container = this.getContainer();
20
+ if (!container)
21
+ return;
22
+ const focusableElements = this.getFocusableElements(container);
23
+ if (focusableElements.length > 0) {
24
+ focusableElements.length > 1 ? focusableElements[1].focus() : focusableElements[0].focus();
25
+ }
26
+ });
83
27
  }
84
28
  }
85
- }
86
- _SentinelFocusTrapStrategy_sentinelStart = new WeakMap(), _SentinelFocusTrapStrategy_sentinelEnd = new WeakMap();
29
+ }
87
30
 
88
31
  export { SentinelFocusTrapStrategy };
89
32
  //# sourceMappingURL=sentinel_focus_trap_strategy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,+CAAmD;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;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,5 +1,5 @@
1
1
  import { FocusTrapStrategy } from './focus_trap_strategy';
2
- import { ITogglerFocusTrapStrategy } from './focus_trap_strategy_types';
2
+ import { IFocusTrapStrategy } from './focus_trap_strategy_types';
3
3
  export declare type TTogglerFocusTrapStrategyProps = {
4
4
  getContainer: () => HTMLElement | undefined;
5
5
  getToggler: () => HTMLElement | null | undefined;
@@ -13,10 +13,8 @@ export declare type TTogglerFocusTrapStrategyProps = {
13
13
  * Suitable for dropdowns where the toggler button should stay in the Tab cycle
14
14
  * alongside the dropdown content.
15
15
  */
16
- export declare class TogglerFocusTrapStrategy extends FocusTrapStrategy implements ITogglerFocusTrapStrategy {
16
+ export declare class TogglerFocusTrapStrategy extends FocusTrapStrategy implements IFocusTrapStrategy {
17
17
  #private;
18
18
  constructor({ getContainer, getToggler }: TTogglerFocusTrapStrategyProps);
19
- attach(): void;
20
- detach(): void;
21
- private _handleKeyDown;
19
+ protected _handleKeyDown: (ev: KeyboardEvent) => void;
22
20
  }
@@ -60,12 +60,6 @@ class TogglerFocusTrapStrategy extends FocusTrapStrategy {
60
60
  };
61
61
  __classPrivateFieldSet(this, _TogglerFocusTrapStrategy_getToggler, getToggler, "f");
62
62
  }
63
- attach() {
64
- document.addEventListener('keydown', this._handleKeyDown);
65
- }
66
- detach() {
67
- document.removeEventListener('keydown', this._handleKeyDown);
68
- }
69
63
  }
70
64
  _TogglerFocusTrapStrategy_getToggler = new WeakMap();
71
65
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,+CAAmD;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,+DAA+D,+CAAmD;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/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.23-6",
5
+ "version": "1.18.23-8",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",