@shoper/phoenix_design_system 1.15.11-0 → 1.15.11-2

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 (50) hide show
  1. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +9 -2
  2. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js +6 -1
  4. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/form/input/input_copy_button.js +4 -3
  6. package/build/cjs/packages/phoenix/src/components/form/input/input_copy_button.js.map +1 -1
  7. package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js +30 -0
  8. package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
  9. package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js +1 -2
  10. package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +90 -0
  12. package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +1 -0
  13. package/build/cjs/packages/phoenix/src/components/form/select/select.js +61 -11
  14. package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
  15. package/build/cjs/packages/phoenix/src/components/modal/modal.js +1 -3
  16. package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
  17. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +62 -15
  18. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  19. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +1 -0
  20. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +9 -2
  21. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  22. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.d.ts +1 -0
  23. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +6 -1
  24. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  25. package/build/esm/packages/phoenix/src/components/form/input/input_copy_button.d.ts +1 -0
  26. package/build/esm/packages/phoenix/src/components/form/input/input_copy_button.js +4 -3
  27. package/build/esm/packages/phoenix/src/components/form/input/input_copy_button.js.map +1 -1
  28. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.d.ts +4 -0
  29. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js +30 -0
  30. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js +1 -2
  32. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
  33. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.d.ts +13 -0
  34. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +86 -0
  35. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +1 -0
  36. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.d.ts +8 -0
  37. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js +3 -0
  38. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js.map +1 -0
  39. package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +10 -3
  40. package/build/esm/packages/phoenix/src/components/form/select/select.js +61 -11
  41. package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
  42. package/build/esm/packages/phoenix/src/components/modal/modal.js +1 -3
  43. package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
  44. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.d.ts +6 -2
  45. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js +1 -0
  46. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js.map +1 -1
  47. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.d.ts +7 -3
  48. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +62 -15
  49. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  50. package/package.json +1 -1
@@ -25,6 +25,7 @@ import { SelectControlUtils } from './select_utils.js';
25
25
  import { SelectController } from './controllers/select_controller.js';
26
26
  import { SelectOptionMapper } from './model/select_option_mapper.js';
27
27
  import { repeat } from 'lit/directives/repeat';
28
+ import { SelectTogglerKeyboardController } from './controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js';
28
29
 
29
30
  let HSelect = class HSelect extends PhoenixLightLitElement {
30
31
  constructor() {
@@ -39,8 +40,8 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
39
40
  this.ariaLabelledby = '';
40
41
  this._searchValue = '';
41
42
  this._$options = new Map();
42
- this._$dropdown = createRef();
43
- this._$search = createRef();
43
+ this.$dropdown = createRef();
44
+ this.$search = createRef();
44
45
  this._$optionsList = createRef();
45
46
  this._$dropdownContent = createRef();
46
47
  this._$dropdownToggler = createRef();
@@ -101,6 +102,18 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
101
102
  this.updateOptionAriaAttribute($option);
102
103
  });
103
104
  };
105
+ this._updateLabelAria = (options) => {
106
+ var _a, _b;
107
+ if (!this.$searchLabel)
108
+ return;
109
+ (_a = this.$searchLabel.querySelector(`[id="value-label"]`)) === null || _a === void 0 ? void 0 : _a.remove();
110
+ this.$searchLabel.innerHTML = `
111
+ ${(_b = this.$searchLabel) === null || _b === void 0 ? void 0 : _b.innerHTML}
112
+ <span id="value-label" class="sr-only">
113
+ ${options.reduce((totalSelectedContent, currentOption) => (totalSelectedContent += currentOption.content), '')}
114
+ </span>
115
+ `;
116
+ };
104
117
  this._handleOptionClicked = ({ detail }) => {
105
118
  if (!(detail === null || detail === void 0 ? void 0 : detail.$option))
106
119
  return;
@@ -116,10 +129,11 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
116
129
  });
117
130
  };
118
131
  this._handleDropdownHidden = () => {
119
- var _a;
132
+ var _a, _b;
120
133
  this._searchValue = '';
121
134
  this.opened = false;
122
135
  (_a = this._$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', '');
136
+ (_b = this._$dropdownToggler.value) === null || _b === void 0 ? void 0 : _b.focus();
123
137
  };
124
138
  this._manageSelectFocusAria = (ev) => {
125
139
  var _a;
@@ -135,7 +149,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
135
149
  var _a;
136
150
  if (!this.opened)
137
151
  return;
138
- (_a = this._$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
152
+ (_a = this.$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
139
153
  };
140
154
  this._clearOptions = () => {
141
155
  this._selectController.deselectAll();
@@ -179,6 +193,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
179
193
  return Array.from(this._$options.values());
180
194
  }
181
195
  updated(changedProperties) {
196
+ var _a;
182
197
  super.updated(changedProperties);
183
198
  if (changedProperties.has('opened')) {
184
199
  if (this.opened) {
@@ -192,28 +207,52 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
192
207
  if (changedProperties.has('optionsList')) {
193
208
  this._updateOptions();
194
209
  }
195
- if (this._$optionsList.value && !this._listBoxController)
196
- this._listBoxController = new ListBoxKeyboardController({
210
+ if (this._$optionsList.value) {
211
+ (_a = this.listBoxController) === null || _a === void 0 ? void 0 : _a.hostDisconnected();
212
+ this.listBoxController = new ListBoxKeyboardController({
197
213
  host: this,
198
214
  $list: this._$optionsList.value
199
215
  });
216
+ }
217
+ if (this.listBoxController) {
218
+ this.listBoxController.calculateSelectedOptionIndex();
219
+ }
200
220
  }
201
221
  _focusElementAfterSelectOpened() {
202
- var _a, _b;
203
- const $searchInput = (_a = this._$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
204
- $searchInput ? $searchInput.focus() : (_b = this._$optionsList.value) === null || _b === void 0 ? void 0 : _b.focus();
222
+ var _a;
223
+ const $searchInput = (_a = this.$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
224
+ const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
225
+ const $firstOption = $options.find(($option) => {
226
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.getAttribute('hidden');
227
+ });
228
+ const $selectedOption = this.selectedOptions[0];
229
+ const $optionToFocus = $selectedOption || $firstOption;
230
+ $searchInput ? $searchInput.focus() : $optionToFocus === null || $optionToFocus === void 0 ? void 0 : $optionToFocus.focus();
205
231
  }
206
232
  connectedCallback() {
233
+ var _a, _b;
207
234
  super.connectedCallback();
208
235
  this.classList.add(SELECT_CSS_CLASSES.select);
209
236
  if (!this.searchDisabled) {
210
237
  this.classList.add(SELECT_CSS_CLASSES.selectWithSearch);
211
238
  }
239
+ this.$searchLabel = document.querySelector(`[id="${this.ariaLabelledby}"]`);
240
+ (_a = this.$searchLabel) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-hidden', 'true');
212
241
  this._selectController = this.multiple ? new MultiSelectController({ host: this }) : new SelectController({ host: this });
213
242
  this._selectContext.provide(SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
214
243
  this._selectContext.provide(SELECT_CONTEXTS.isMultiselect, this.multiple);
215
244
  this._optionsObserver = new Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
216
245
  this._selectController.options$.subscribe(this._optionsObserver);
246
+ this._selectedOptionsAriaObserver = new Observer((selectedOptions) => this._updateLabelAria(selectedOptions));
247
+ this._selectController.selectedOptions$.subscribe(this._selectedOptionsAriaObserver);
248
+ if (this._$optionsList.value && this._$dropdownToggler.value) {
249
+ (_b = this._selectTogglerKeyboardController) === null || _b === void 0 ? void 0 : _b.hostDisconnected();
250
+ this._selectTogglerKeyboardController = new SelectTogglerKeyboardController({
251
+ host: this,
252
+ $toggler: this._$dropdownToggler.value,
253
+ $list: this._$optionsList.value
254
+ });
255
+ }
217
256
  this._updateOptions();
218
257
  this._setupEvents();
219
258
  }
@@ -243,6 +282,10 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
243
282
  SelectControlUtils.appendHTMLOption($option, $list, position);
244
283
  }
245
284
  updateOptionAriaAttribute($option) {
285
+ if (!this.multiple) {
286
+ const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
287
+ $options.forEach(($option) => ($option.removeAttribute('aria-selected')));
288
+ }
246
289
  $option.setAttribute(this.multiple ? 'aria-checked' : 'aria-selected', String($option.selected));
247
290
  }
248
291
  _removeHTMLOptions(optionsValues) {
@@ -252,6 +295,12 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
252
295
  const option = this._selectController.getOption(value);
253
296
  if (!option)
254
297
  return;
298
+ const $selectedOption = this._$options.get(option.value);
299
+ const $selectedOptionLink = $selectedOption === null || $selectedOption === void 0 ? void 0 : $selectedOption.querySelector('a');
300
+ if ($selectedOptionLink) {
301
+ $selectedOptionLink.click();
302
+ return;
303
+ }
255
304
  this.noDeselect ? this._selectController.select(option) : this._selectController.toggle(option);
256
305
  if (!this.multiple)
257
306
  this._closeSelect();
@@ -302,13 +351,14 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
302
351
  const isSearchEnabled = !this.searchDisabled && options.length > MIN_NUMBER_OF_OPTIONS_TO_SHOW_SEARCH;
303
352
  return html `
304
353
  <h-dropdown
305
- ${ref(this._$dropdown)}
354
+ ${ref(this.$dropdown)}
306
355
  @showed=${() => (this.opened = true)}
307
356
  @hidden=${this._handleDropdownHidden}
308
357
  name="${this.controlName}"
309
358
  offset=${this.offset}
310
359
  content-width="full"
311
360
  prevent-focus-trap
361
+ no-autofocus
312
362
  >
313
363
  <h-dropdown-toggler
314
364
  ${ref(this._$dropdownToggler)}
@@ -336,7 +386,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
336
386
  ${isSearchEnabled
337
387
  ? html ` <h-select-search
338
388
  class=${SELECT_CSS_CLASSES.selectSearch}
339
- ${ref(this._$search)}
389
+ ${ref(this.$search)}
340
390
  .value=${this._searchValue}
341
391
  @search=${this._handleSearch}
342
392
  ></h-select-search>`
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -112,9 +112,7 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
112
112
  };
113
113
  this._addInertToBodyChildrenElements = () => {
114
114
  [...document.body.children].forEach((child) => {
115
- const isPortalTarget = child.tagName === PORTAL_TARGET_COMPONENT_NAME.toUpperCase();
116
- const isAriaLiveContainer = child.hasAttribute('aria-live');
117
- if (!isPortalTarget && !isAriaLiveContainer) {
115
+ if (child.tagName !== PORTAL_TARGET_COMPONENT_NAME.toUpperCase()) {
118
116
  child.setAttribute('inert', '');
119
117
  }
120
118
  });
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}
@@ -1,10 +1,14 @@
1
1
  import { Any } from 'ts-toolbelt';
2
- import { ReactiveControllerHost } from 'lit';
2
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
3
3
  import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from "./list_box_controller_constants";
4
+ import { HSelect } from "../../components/form/select/select";
4
5
  export declare type TListBoxKeyboardNavigationDirection = Any.Keys<typeof LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS>;
5
6
  export declare type TListBoxKeyboardControllerConstructorOptions = {
6
- host: ReactiveControllerHost & HTMLElement;
7
+ host: ReactiveControllerHost & HSelect;
7
8
  $list: HTMLElement;
8
9
  listItemSelector?: string;
9
10
  orientation?: TListBoxKeyboardNavigationDirection;
10
11
  };
12
+ export interface IListboxController extends ReactiveController {
13
+ calculateSelectedOptionIndex(): void;
14
+ }
@@ -1,4 +1,5 @@
1
1
  import 'ts-toolbelt';
2
2
  import 'lit';
3
3
  import '@phoenixRoot/controllers/list_box_controller/list_box_controller_constants';
4
+ import '@phoenixRoot/components/form/select/select';
4
5
  //# sourceMappingURL=list_box_controller_types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list_box_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/list_box_controller/list_box_controller_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,OAAuC,KAAK,CAAC;AAC7C,OAAwD,4EAA4E,CAAC"}
1
+ {"version":3,"file":"list_box_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/list_box_controller/list_box_controller_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,OAA2D,KAAK,CAAC;AACjE,OAAwD,4EAA4E,CAAC;AACrI,OAAwB,4CAA4C,CAAC"}
@@ -1,10 +1,14 @@
1
- import { ReactiveController } from 'lit';
2
- import { TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
3
- export declare class ListBoxKeyboardController implements ReactiveController {
1
+ import { IListboxController, TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
2
+ export declare class ListBoxKeyboardController implements IListboxController {
4
3
  #private;
5
4
  constructor({ host, $list, listItemSelector, orientation }: TListBoxKeyboardControllerConstructorOptions);
6
5
  hostConnected(): void;
6
+ private _handleKeyboardNavigation;
7
7
  private _handleArrowNavigation;
8
+ private _findCurrentIndex;
9
+ private _handleWriteableCharacter;
10
+ calculateSelectedOptionIndex: () => void;
8
11
  private _getPrevOptionIndex;
9
12
  private _getNextOptionIndex;
13
+ hostDisconnected(): void;
10
14
  }
@@ -1,7 +1,6 @@
1
1
  import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../external/tslib/tslib.es6.js';
2
2
  import 'lit';
3
3
  import { UiDomUtils } from '@dreamcommerce/utilities';
4
- import { KeystrokesController } from '../keystrokes_controller/keystrokes_controller.js';
5
4
  import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from './list_box_controller_constants.js';
6
5
 
7
6
  var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController_currentOptionIndex, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
@@ -13,25 +12,54 @@ class ListBoxKeyboardController {
13
12
  _ListBoxKeyboardController__$options.set(this, void 0);
14
13
  _ListBoxKeyboardController_listItemSelector.set(this, void 0);
15
14
  _ListBoxKeyboardController_keys.set(this, void 0);
15
+ this._handleKeyboardNavigation = (ev) => {
16
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f").find((key) => key === ev.key)) {
17
+ this._handleArrowNavigation(ev);
18
+ return;
19
+ }
20
+ this._handleWriteableCharacter(ev);
21
+ };
16
22
  this._handleArrowNavigation = (event) => {
17
23
  event.preventDefault();
18
24
  const { key } = event;
19
- const prevOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
25
+ const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
26
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
27
+ });
28
+ const prevOptionIndex = this._findCurrentIndex();
20
29
  let newOptionIndex = key === 'ArrowDown' || key === 'ArrowRight' ? this._getNextOptionIndex() : this._getPrevOptionIndex();
21
30
  if (newOptionIndex === undefined) {
22
- const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
23
- newOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
31
+ newOptionIndex = this._findCurrentIndex();
24
32
  }
25
33
  if (newOptionIndex === __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f"))
26
34
  return;
27
35
  if (prevOptionIndex !== undefined) {
28
36
  const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
29
- UiDomUtils.makeUnnavigable($prevOption);
37
+ $prevOption && UiDomUtils.makeUnnavigable($prevOption);
30
38
  }
31
39
  __classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, newOptionIndex, "f");
32
- const $focusedOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[newOptionIndex];
33
- UiDomUtils.makeNavigable($focusedOption);
34
- $focusedOption.focus();
40
+ const $focusedOption = $availableOptions[newOptionIndex];
41
+ if ($focusedOption) {
42
+ UiDomUtils.makeNavigable($focusedOption);
43
+ $focusedOption.focus();
44
+ }
45
+ };
46
+ this._findCurrentIndex = () => {
47
+ const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
48
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
49
+ });
50
+ const selectedOptionIndex = $availableOptions.findIndex(($option) => $option.selected);
51
+ return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
52
+ };
53
+ this._handleWriteableCharacter = (ev) => {
54
+ var _a;
55
+ const $searchInput = (_a = __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
56
+ if (!$searchInput)
57
+ return;
58
+ $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
59
+ };
60
+ this.calculateSelectedOptionIndex = () => {
61
+ const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
62
+ __classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, selectedOptionIndex !== -1 ? selectedOptionIndex : 0, "f");
35
63
  };
36
64
  __classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
37
65
  __classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
@@ -41,12 +69,7 @@ class ListBoxKeyboardController {
41
69
  __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").addController(this);
42
70
  }
43
71
  hostConnected() {
44
- new KeystrokesController({
45
- host: __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f"),
46
- keys: __classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f"),
47
- callback: this._handleArrowNavigation,
48
- target: __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f")
49
- });
72
+ __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('keydown', this._handleKeyboardNavigation);
50
73
  UiDomUtils.makeNavigable(__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"));
51
74
  __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
52
75
  if (event.target !== __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
@@ -64,15 +87,39 @@ class ListBoxKeyboardController {
64
87
  return undefined;
65
88
  if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
66
89
  return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
90
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
91
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
92
+ const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
93
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
94
+ });
95
+ if (!!$availableOptions[__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1])
96
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
97
+ // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
98
+ const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
99
+ if (newIndexOfCurrentlySelectedOption)
100
+ return newIndexOfCurrentlySelectedOption - 1;
67
101
  return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
68
102
  }
69
103
  _getNextOptionIndex() {
70
104
  if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
71
105
  return undefined;
72
- if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") >= __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").length - 1)
106
+ const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
107
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
108
+ });
109
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === $availableOptions.length - 1)
73
110
  return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
111
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") > $availableOptions.length - 1) {
112
+ // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
113
+ const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
114
+ if (newIndexOfCurrentlySelectedOption)
115
+ return newIndexOfCurrentlySelectedOption + 1;
116
+ return 0;
117
+ }
74
118
  return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") + 1;
75
119
  }
120
+ hostDisconnected() {
121
+ __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
122
+ }
76
123
  }
77
124
  _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController_currentOptionIndex = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
78
125
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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.15.11-0",
5
+ "version": "1.15.11-2",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",