@shoper/phoenix_design_system 1.18.23-9 → 1.18.24-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +77 -14
  2. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/form/search/search.js +4 -28
  4. package/build/cjs/packages/phoenix/src/components/form/search/search.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +13 -3
  6. package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  7. package/build/cjs/packages/phoenix/src/components/form/select/select.js +24 -42
  8. package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
  9. package/build/cjs/packages/phoenix/src/components/modal/modal.js +67 -13
  10. package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/components/modal/modal_constants.js +3 -1
  12. package/build/cjs/packages/phoenix/src/components/modal/modal_constants.js.map +1 -1
  13. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js +63 -9
  14. package/build/cjs/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  15. package/build/cjs/packages/phoenix/src/components/sheet/sheet_constants.js +3 -1
  16. package/build/cjs/packages/phoenix/src/components/sheet/sheet_constants.js.map +1 -1
  17. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +6 -1
  18. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +77 -14
  19. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  20. package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +0 -5
  21. package/build/esm/packages/phoenix/src/components/form/search/search.js +4 -28
  22. package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
  23. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +13 -3
  24. package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
  25. package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +0 -1
  26. package/build/esm/packages/phoenix/src/components/form/select/select.js +24 -42
  27. package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
  28. package/build/esm/packages/phoenix/src/components/modal/modal.d.ts +9 -1
  29. package/build/esm/packages/phoenix/src/components/modal/modal.js +69 -15
  30. package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/modal/modal_constants.js +3 -2
  32. package/build/esm/packages/phoenix/src/components/modal/modal_constants.js.map +1 -1
  33. package/build/esm/packages/phoenix/src/components/sheet/sheet.d.ts +9 -1
  34. package/build/esm/packages/phoenix/src/components/sheet/sheet.js +65 -11
  35. package/build/esm/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
  36. package/build/esm/packages/phoenix/src/components/sheet/sheet_constants.js +3 -2
  37. package/build/esm/packages/phoenix/src/components/sheet/sheet_constants.js.map +1 -1
  38. package/package.json +1 -1
  39. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +0 -38
  40. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +0 -1
  41. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +0 -66
  42. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +0 -1
  43. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +0 -14
  44. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +0 -1
  45. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +0 -22
  46. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +0 -1
  47. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +0 -29
  48. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +0 -1
  49. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +0 -62
  50. package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +0 -1
  51. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +0 -13
  52. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +0 -34
  53. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +0 -1
  54. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +0 -15
  55. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +0 -2
  56. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +0 -1
  57. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +0 -14
  58. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +0 -62
  59. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +0 -1
  60. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +0 -8
  61. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +0 -2
  62. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +0 -1
  63. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +0 -6
  64. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +0 -10
  65. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +0 -1
  66. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +0 -3
  67. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +0 -2
  68. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +0 -1
  69. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +0 -13
  70. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +0 -17
  71. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +0 -1
  72. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.d.ts +0 -7
  73. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +0 -25
  74. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +0 -1
  75. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.d.ts +0 -4
  76. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js +0 -2
  77. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js.map +0 -1
  78. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.d.ts +0 -8
  79. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +0 -58
  80. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +0 -1
  81. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.d.ts +0 -4
  82. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js +0 -2
  83. package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js.map +0 -1
@@ -1,14 +1,15 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
+ import { UiDomUtils } from '@dreamcommerce/utilities';
2
3
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
3
4
  import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
- import { property } from '@lit/reactive-element/decorators.js';
5
+ import { property, state } from '@lit/reactive-element/decorators.js';
6
+ import '@lit/reactive-element';
5
7
  import { html } from 'lit-html';
6
8
  import { createRef, ref } from 'lit-html/directives/ref.js';
7
9
  import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
8
10
  import { BACKDROP_EVENTS } from '../backdrop/backdrop_constants.js';
9
11
  import { BackdropController } from '../backdrop/controller/backdrop_controller.js';
10
- import { FocusTrapController } from '../../controllers/focus_trap_controller/focus_trap_controller.js';
11
- import { SHEET_OPENED_PROP, SHEETS_PORTAL_NAME, SHEET_EVENTS } from './sheet_constants.js';
12
+ import { SHEET_OPENED_PROP, FOCUSABLE_ELEMENTS_WITHIN_SHEET, SHEETS_PORTAL_NAME, SHEET_EVENTS } from './sheet_constants.js';
12
13
  import { HSheetClose } from './sheet_close.js';
13
14
 
14
15
  var HSheet_1;
@@ -19,30 +20,52 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
19
20
  this.class = '';
20
21
  this.transition = 'scale';
21
22
  this.sheetLabel = '';
23
+ this._firstFocusableElement = undefined;
24
+ this._focusableElements = null;
25
+ this._lastFocusableElement = undefined;
22
26
  this._focusedToggler = null;
23
27
  this._contentRef = createRef();
28
+ this._focusSentinelStart = createRef();
29
+ this._focusSentinelEnd = createRef();
24
30
  this._propsChangeStrategies = {
25
31
  [SHEET_OPENED_PROP]: {
26
32
  true: () => {
33
+ const scrollY = window.scrollY;
27
34
  HSheet_1.openSheets = [...HSheet_1.openSheets, this];
28
35
  document.addEventListener('keydown', this._bindCloseOnEsc);
29
36
  document.addEventListener(BACKDROP_EVENTS.clicked, this.close);
30
37
  this._dispatchSheetOpenedEvent();
31
- this._focusTrapController.activate();
38
+ setTimeout(() => {
39
+ var _a;
40
+ (_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
41
+ window.scrollTo(0, scrollY);
42
+ }, 0);
32
43
  },
33
44
  false: () => {
34
45
  HSheet_1.openSheets = HSheet_1.openSheets.filter((sheet) => sheet !== this);
35
46
  document.removeEventListener('keydown', this._bindCloseOnEsc);
36
47
  document.removeEventListener(BACKDROP_EVENTS.clicked, this.close);
37
- this._focusTrapController.deactivate();
38
48
  }
39
49
  }
40
50
  };
41
51
  this._backdropController = new BackdropController();
42
- this._focusTrapController = new FocusTrapController(this, {
43
- mode: 'sentinel',
44
- getContainer: () => this._contentRef.value
45
- });
52
+ this._keepFocusWithinSheet = (ev) => {
53
+ var _a;
54
+ const isTabPressed = ev.code === 'Tab';
55
+ if (isTabPressed && this._contentRef.value) {
56
+ if (ev.shiftKey) {
57
+ if (document.activeElement === this._firstFocusableElement) {
58
+ const focusableElements = UiDomUtils.getFocusableElements(this._contentRef.value);
59
+ (_a = focusableElements[focusableElements.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
60
+ ev.preventDefault();
61
+ }
62
+ }
63
+ else if (document.activeElement === this._lastFocusableElement) {
64
+ UiDomUtils.setFocusToFirstFocusableElementInContainer(this._contentRef.value);
65
+ ev.preventDefault();
66
+ }
67
+ }
68
+ };
46
69
  this._handleCloseFromCloseComponent = async (ev) => {
47
70
  var _a;
48
71
  ev.stopPropagation();
@@ -103,6 +126,7 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
103
126
  });
104
127
  };
105
128
  this.hidden = true;
129
+ this._focusableElements = [...this.querySelectorAll(FOCUSABLE_ELEMENTS_WITHIN_SHEET)];
106
130
  }
107
131
  static _appendSheetPortal() {
108
132
  const $modalsPortalTarget = document.querySelector(`h-portal-target[name="${SHEETS_PORTAL_NAME}"]`);
@@ -118,6 +142,7 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
118
142
  connectedCallback() {
119
143
  super.connectedCallback();
120
144
  HSheet_1._appendSheetPortal();
145
+ document.addEventListener('keyup', this._keepFocusWithinSheet);
121
146
  document.addEventListener(SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
122
147
  }
123
148
  disconnectedCallback() {
@@ -126,12 +151,28 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
126
151
  this.close();
127
152
  document.removeEventListener(SHEET_EVENTS.close, this._handleCloseFromCloseComponent);
128
153
  document.removeEventListener('keydown', this._bindCloseOnEsc);
154
+ document.removeEventListener('keyup', this._keepFocusWithinSheet);
155
+ }
156
+ firstUpdated(props) {
157
+ super.firstUpdated(props);
158
+ this._firstFocusableElement = this._focusSentinelStart.value;
159
+ this._lastFocusableElement = this._focusSentinelEnd.value;
129
160
  }
130
161
  updated(changedProps) {
131
162
  if (changedProps.has(SHEET_OPENED_PROP)) {
132
163
  this._propsChangeStrategies[SHEET_OPENED_PROP][String(this[SHEET_OPENED_PROP])]();
133
164
  }
134
165
  }
166
+ _setFocusToFirstFocusableElementInSheetOrCloseBtn() {
167
+ requestAnimationFrame(() => {
168
+ if (this._contentRef.value) {
169
+ const focusableElements = UiDomUtils.getFocusableElements(this._contentRef.value);
170
+ if (focusableElements.length > 0) {
171
+ focusableElements.length > 1 ? focusableElements[1].focus() : focusableElements[0].focus();
172
+ }
173
+ }
174
+ });
175
+ }
135
176
  async open() {
136
177
  this._focusedToggler = document.activeElement;
137
178
  return new Promise((resolve) => {
@@ -147,6 +188,7 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
147
188
  setTimeout(() => {
148
189
  var _a;
149
190
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`sheet_show-${this.transition}-start`, `sheet_show-${this.transition}-end`);
191
+ this._setFocusToFirstFocusableElementInSheetOrCloseBtn();
150
192
  resolve();
151
193
  }, transitionDuration);
152
194
  });
@@ -172,11 +214,11 @@ let HSheet = HSheet_1 = class HSheet extends PhoenixLightLitElement {
172
214
  return html `
173
215
  <h-portal ?disabled="${!this.opened}" to="${SHEETS_PORTAL_NAME}" hidden>
174
216
  <div class="sheet-wrapper ${this.class}">
175
- <div tabindex="0"></div>
217
+ <div tabindex="0" ${ref(this._focusSentinelStart)}></div>
176
218
  <div ${ref(this._contentRef)} class="sheet" role="dialog" aria-label="${this.sheetLabel}">
177
219
  <div class="sheet__container">${this.getSlot('header')} ${this.getSlot('body')} ${this.getSlot('footer')}</div>
178
220
  </div>
179
- <div tabindex="0"></div>
221
+ <div tabindex="0" ${ref(this._focusSentinelEnd)}></div>
180
222
  </div>
181
223
  </h-portal>
182
224
  `;
@@ -199,6 +241,18 @@ __decorate([
199
241
  property({ type: String, attribute: 'sheet-label' }),
200
242
  __metadata("design:type", Object)
201
243
  ], HSheet.prototype, "sheetLabel", void 0);
244
+ __decorate([
245
+ state(),
246
+ __metadata("design:type", Object)
247
+ ], HSheet.prototype, "_firstFocusableElement", void 0);
248
+ __decorate([
249
+ state(),
250
+ __metadata("design:type", Object)
251
+ ], HSheet.prototype, "_focusableElements", void 0);
252
+ __decorate([
253
+ state(),
254
+ __metadata("design:type", Object)
255
+ ], HSheet.prototype, "_lastFocusableElement", void 0);
202
256
  HSheet = HSheet_1 = __decorate([
203
257
  phoenixCustomElement('h-sheet'),
204
258
  __metadata("design:paramtypes", [])
@@ -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;"}
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -5,7 +5,8 @@ const SHEET_EVENTS = {
5
5
  opened: 'opened',
6
6
  closed: 'closed'
7
7
  };
8
- const SHEET_OPENED_PROP = 'opened';
8
+ const SHEET_OPENED_PROP = 'opened';
9
+ const FOCUSABLE_ELEMENTS_WITHIN_SHEET = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
9
10
 
10
- export { SHEETS_PORTAL_NAME, SHEET_EVENTS, SHEET_OPENED_PROP };
11
+ export { FOCUSABLE_ELEMENTS_WITHIN_SHEET, SHEETS_PORTAL_NAME, SHEET_EVENTS, SHEET_OPENED_PROP };
11
12
  //# sourceMappingURL=sheet_constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;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;"}
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-9",
5
+ "version": "1.18.24-0",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
- require('lit');
7
- var focus_trap_strategy_constants = require('./strategies/focus_trap_strategy_constants.js');
8
-
9
- var _FocusTrapController_strategy;
10
- class FocusTrapController {
11
- constructor(host, { mode, ...strategyProps }) {
12
- _FocusTrapController_strategy.set(this, void 0);
13
- tslib_es6.__classPrivateFieldSet(this, _FocusTrapController_strategy, new focus_trap_strategy_constants.FOCUS_TRAP_STRATEGY_STRATEGIES[mode](strategyProps), "f");
14
- host.addController(this);
15
- }
16
- get strategy() {
17
- return tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
18
- }
19
- hostConnected() {
20
- tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").attach();
21
- }
22
- hostDisconnected() {
23
- tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").detach();
24
- }
25
- activate() {
26
- tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").activate();
27
- }
28
- deactivate() {
29
- tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").deactivate();
30
- }
31
- getFocusableElements(container) {
32
- return tslib_es6.__classPrivateFieldGet(this, _FocusTrapController_strategy, "f").getFocusableElements(container);
33
- }
34
- }
35
- _FocusTrapController_strategy = new WeakMap();
36
-
37
- exports.FocusTrapController = FocusTrapController;
38
- //# sourceMappingURL=focus_trap_controller.js.map
@@ -1 +0,0 @@
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;"}
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var utilities = require('@dreamcommerce/utilities');
6
-
7
- class BaseFocusTrapStrategy {
8
- constructor(getContainer) {
9
- this.getContainer = getContainer;
10
- this.active = false;
11
- this.noAutofocus = false;
12
- this._handleKeyDown = (ev) => {
13
- if (!this.active || ev.code !== 'Tab')
14
- return;
15
- const container = this.getContainer();
16
- if (!container)
17
- return;
18
- const focusableElements = this.getFocusableElements(container);
19
- if (focusableElements.length === 0)
20
- return;
21
- const $target = ev.target;
22
- if (ev.shiftKey) {
23
- if ($target === focusableElements[0]) {
24
- ev.preventDefault();
25
- focusableElements[focusableElements.length - 1].focus();
26
- }
27
- }
28
- else {
29
- if ($target === focusableElements[focusableElements.length - 1]) {
30
- ev.preventDefault();
31
- focusableElements[0].focus();
32
- }
33
- }
34
- };
35
- }
36
- attach() {
37
- document.addEventListener('keydown', this._handleKeyDown);
38
- }
39
- detach() {
40
- document.removeEventListener('keydown', this._handleKeyDown);
41
- }
42
- activate() {
43
- this.active = true;
44
- }
45
- deactivate() {
46
- this.active = false;
47
- }
48
- getFocusableElements(container) {
49
- return utilities.UiDomUtils.getFocusableElements(container).filter(($el) => this._isElementTrulyFocusable($el));
50
- }
51
- _isElementTrulyFocusable($el) {
52
- const style = window.getComputedStyle($el);
53
- if (style.display === 'none' || style.visibility === 'hidden') {
54
- return false;
55
- }
56
- if ($el.nodeName === 'H-PORTAL')
57
- return true;
58
- const $parent = $el.parentElement;
59
- if (!$parent)
60
- return true;
61
- return this._isElementTrulyFocusable($parent);
62
- }
63
- }
64
-
65
- exports.BaseFocusTrapStrategy = BaseFocusTrapStrategy;
66
- //# sourceMappingURL=base_focus_trap_strategy.js.map
@@ -1 +0,0 @@
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;"}
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var base_focus_trap_strategy = require('../base_focus_trap_strategy.js');
6
-
7
- class CyclicFocusTrapStrategy extends base_focus_trap_strategy.BaseFocusTrapStrategy {
8
- constructor({ getContainer }) {
9
- super(getContainer);
10
- }
11
- }
12
-
13
- exports.CyclicFocusTrapStrategy = CyclicFocusTrapStrategy;
14
- //# sourceMappingURL=cyclic_focus_trap_strategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var cyclic_focus_trap_strategy = require('./cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js');
6
- var toggler_focus_trap_strategy = require('./toggler_focus_trap_strategy/toggler_focus_trap_strategy.js');
7
- var sentinel_focus_trap_strategy = require('./sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js');
8
-
9
- const FOCUS_TRAP_STRATEGY_TYPES = {
10
- cyclic: 'cyclic',
11
- toggler: 'toggler',
12
- sentinel: 'sentinel',
13
- };
14
- const FOCUS_TRAP_STRATEGY_STRATEGIES = {
15
- [FOCUS_TRAP_STRATEGY_TYPES.cyclic]: cyclic_focus_trap_strategy.CyclicFocusTrapStrategy,
16
- [FOCUS_TRAP_STRATEGY_TYPES.toggler]: toggler_focus_trap_strategy.TogglerFocusTrapStrategy,
17
- [FOCUS_TRAP_STRATEGY_TYPES.sentinel]: sentinel_focus_trap_strategy.SentinelFocusTrapStrategy,
18
- };
19
-
20
- exports.FOCUS_TRAP_STRATEGY_STRATEGIES = FOCUS_TRAP_STRATEGY_STRATEGIES;
21
- exports.FOCUS_TRAP_STRATEGY_TYPES = FOCUS_TRAP_STRATEGY_TYPES;
22
- //# sourceMappingURL=focus_trap_strategy_constants.js.map
@@ -1 +0,0 @@
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;"}
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var base_focus_trap_strategy = require('../base_focus_trap_strategy.js');
6
-
7
- class SentinelFocusTrapStrategy extends base_focus_trap_strategy.BaseFocusTrapStrategy {
8
- constructor({ getContainer, noAutofocus = false }) {
9
- super(getContainer);
10
- this.noAutofocus = noAutofocus;
11
- }
12
- activate() {
13
- this.active = true;
14
- if (!this.noAutofocus) {
15
- requestAnimationFrame(() => {
16
- const container = this.getContainer();
17
- if (!container)
18
- return;
19
- const focusableElements = this.getFocusableElements(container);
20
- const shouldSkipStartSentinel = focusableElements.length > 1;
21
- const $firstFocusableContentElement = shouldSkipStartSentinel ? focusableElements[1] : focusableElements[0];
22
- $firstFocusableContentElement === null || $firstFocusableContentElement === void 0 ? void 0 : $firstFocusableContentElement.focus();
23
- });
24
- }
25
- }
26
- }
27
-
28
- exports.SentinelFocusTrapStrategy = SentinelFocusTrapStrategy;
29
- //# sourceMappingURL=sentinel_focus_trap_strategy.js.map
@@ -1 +0,0 @@
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;"}
@@ -1,62 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib_es6 = require('../../../../../../../external/tslib/tslib.es6.js');
6
- var base_focus_trap_strategy = require('../base_focus_trap_strategy.js');
7
-
8
- var _TogglerFocusTrapStrategy_getToggler;
9
- class TogglerFocusTrapStrategy extends base_focus_trap_strategy.BaseFocusTrapStrategy {
10
- constructor({ getContainer, getToggler }) {
11
- super(getContainer);
12
- _TogglerFocusTrapStrategy_getToggler.set(this, void 0);
13
- this._handleKeyDown = (ev) => {
14
- var _a;
15
- if (!this.active || ev.code !== 'Tab')
16
- return;
17
- const container = this.getContainer();
18
- const toggler = (_a = tslib_es6.__classPrivateFieldGet(this, _TogglerFocusTrapStrategy_getToggler, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
19
- if (!container || !toggler)
20
- return;
21
- const $target = ev.target;
22
- const focusableElements = this.getFocusableElements(container);
23
- if (ev.shiftKey) {
24
- // Shift+Tab on toggler → last content element
25
- if (toggler.contains($target)) {
26
- const last = focusableElements[focusableElements.length - 1];
27
- if (!last)
28
- return;
29
- ev.preventDefault();
30
- last.focus();
31
- return;
32
- }
33
- // Shift+Tab on first content element → toggler
34
- if ($target === focusableElements[0]) {
35
- ev.preventDefault();
36
- toggler.focus();
37
- }
38
- }
39
- else {
40
- // Tab on toggler → first content element
41
- if (toggler.contains($target)) {
42
- const first = focusableElements[0];
43
- if (!first)
44
- return;
45
- ev.preventDefault();
46
- first.focus();
47
- return;
48
- }
49
- // Tab on last content element → toggler
50
- if ($target === focusableElements[focusableElements.length - 1]) {
51
- ev.preventDefault();
52
- toggler.focus();
53
- }
54
- }
55
- };
56
- tslib_es6.__classPrivateFieldSet(this, _TogglerFocusTrapStrategy_getToggler, getToggler, "f");
57
- }
58
- }
59
- _TogglerFocusTrapStrategy_getToggler = new WeakMap();
60
-
61
- exports.TogglerFocusTrapStrategy = TogglerFocusTrapStrategy;
62
- //# sourceMappingURL=toggler_focus_trap_strategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,kDAAsD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,13 +0,0 @@
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<TProps extends TFocusTrapProps = TFocusTrapProps> implements ReactiveController {
5
- #private;
6
- constructor(host: ReactiveControllerHost, { mode, ...strategyProps }: TProps);
7
- get strategy(): IBaseFocusTrapStrategy;
8
- hostConnected(): void;
9
- hostDisconnected(): void;
10
- activate(): void;
11
- deactivate(): void;
12
- getFocusableElements(container: HTMLElement): HTMLElement[];
13
- }
@@ -1,34 +0,0 @@
1
- import { __classPrivateFieldSet, __classPrivateFieldGet } from '../../../../../external/tslib/tslib.es6.js';
2
- import 'lit';
3
- import { FOCUS_TRAP_STRATEGY_STRATEGIES } from './strategies/focus_trap_strategy_constants.js';
4
-
5
- var _FocusTrapController_strategy;
6
- class FocusTrapController {
7
- constructor(host, { mode, ...strategyProps }) {
8
- _FocusTrapController_strategy.set(this, void 0);
9
- __classPrivateFieldSet(this, _FocusTrapController_strategy, new FOCUS_TRAP_STRATEGY_STRATEGIES[mode](strategyProps), "f");
10
- host.addController(this);
11
- }
12
- get strategy() {
13
- return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f");
14
- }
15
- hostConnected() {
16
- __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").attach();
17
- }
18
- hostDisconnected() {
19
- __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").detach();
20
- }
21
- activate() {
22
- __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").activate();
23
- }
24
- deactivate() {
25
- __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").deactivate();
26
- }
27
- getFocusableElements(container) {
28
- return __classPrivateFieldGet(this, _FocusTrapController_strategy, "f").getFocusableElements(container);
29
- }
30
- }
31
- _FocusTrapController_strategy = new WeakMap();
32
-
33
- export { FocusTrapController };
34
- //# sourceMappingURL=focus_trap_controller.js.map
@@ -1 +0,0 @@
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;"}
@@ -1,15 +0,0 @@
1
- export declare type TSentinelFocusTrapProps = {
2
- mode: 'sentinel';
3
- getContainer: () => HTMLElement | undefined;
4
- noAutofocus?: boolean;
5
- };
6
- export declare type TCyclicFocusTrapProps = {
7
- mode: 'cyclic';
8
- getContainer: () => HTMLElement | undefined;
9
- };
10
- export declare type TTogglerFocusTrapProps = {
11
- mode: 'toggler';
12
- getContainer: () => HTMLElement | undefined;
13
- getToggler: () => HTMLElement | null | undefined;
14
- };
15
- export declare type TFocusTrapProps = TSentinelFocusTrapProps | TCyclicFocusTrapProps | TTogglerFocusTrapProps;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=focus_trap_controller_types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"focus_trap_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/focus_trap_controller/focus_trap_controller_types.ts"],"names":[],"mappings":""}
@@ -1,14 +0,0 @@
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
- }
@@ -1,62 +0,0 @@
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
@@ -1 +0,0 @@
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,8 +0,0 @@
1
- export interface IBaseFocusTrapStrategy {
2
- noAutofocus: boolean;
3
- attach(): void;
4
- detach(): void;
5
- activate(): void;
6
- deactivate(): void;
7
- getFocusableElements(container: HTMLElement): HTMLElement[];
8
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=base_focus_trap_strategy_types.js.map
@@ -1 +0,0 @@
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":""}
@@ -1,6 +0,0 @@
1
- import { BaseFocusTrapStrategy } from '../base_focus_trap_strategy';
2
- import { IBaseFocusTrapStrategy } from '../base_focus_trap_strategy_types';
3
- import { TCyclicFocusTrapStrategyProps } from './cyclic_focus_trap_strategy_types';
4
- export declare class CyclicFocusTrapStrategy extends BaseFocusTrapStrategy implements IBaseFocusTrapStrategy {
5
- constructor({ getContainer }: TCyclicFocusTrapStrategyProps);
6
- }