@shoper/phoenix_design_system 1.15.11-39 → 1.15.11-40

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 +2 -9
  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 +5 -23
  4. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/form/radio/radio_control.js +5 -0
  6. package/build/cjs/packages/phoenix/src/components/form/radio/radio_control.js.map +1 -1
  7. package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js +1 -48
  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 +2 -1
  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/select.js +29 -97
  12. package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
  13. package/build/cjs/packages/phoenix/src/components/modal/modal.js +3 -1
  14. package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
  15. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +38 -83
  16. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  17. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +0 -1
  18. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +2 -9
  19. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  20. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.d.ts +0 -3
  21. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +5 -23
  22. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  23. package/build/esm/packages/phoenix/src/components/form/radio/radio_control.d.ts +1 -0
  24. package/build/esm/packages/phoenix/src/components/form/radio/radio_control.js +5 -0
  25. package/build/esm/packages/phoenix/src/components/form/radio/radio_control.js.map +1 -1
  26. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.d.ts +0 -7
  27. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js +1 -48
  28. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
  29. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js +2 -1
  30. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +6 -16
  32. package/build/esm/packages/phoenix/src/components/form/select/select.js +29 -97
  33. package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
  34. package/build/esm/packages/phoenix/src/components/modal/modal.js +3 -1
  35. package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
  36. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.d.ts +2 -6
  37. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js +0 -1
  38. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js.map +1 -1
  39. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.d.ts +3 -8
  40. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +38 -83
  41. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  42. package/package.json +2 -2
  43. package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +0 -88
  44. package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +0 -1
  45. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.d.ts +0 -14
  46. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +0 -84
  47. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +0 -1
  48. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.d.ts +0 -8
  49. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js +0 -3
  50. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js.map +0 -1
@@ -14,7 +14,6 @@ import { observe } from '../../../directives/observable_directive.js';
14
14
  import { HSelectToggler } from './components/toggler/select_toggler.js';
15
15
  import { createRef, ref } from 'lit-html/directives/ref.js';
16
16
  import { ContextProviderController } from '../../../core/context/context_provider_controller.js';
17
- import v4 from '../../../../../../external/uuid/dist/esm-browser/v4.js';
18
17
  import { HDropdownContent } from '../../dropdown/dropdown_content.js';
19
18
  import { HDropdownToggler } from '../../dropdown/dropdown_toggler.js';
20
19
  import { HDropdown } from '../../dropdown/dropdown.js';
@@ -26,7 +25,6 @@ import { SelectControlUtils } from './select_utils.js';
26
25
  import { SelectController } from './controllers/select_controller.js';
27
26
  import { SelectOptionMapper } from './model/select_option_mapper.js';
28
27
  import { repeat } from 'lit/directives/repeat';
29
- import { SelectTogglerKeyboardController } from './controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js';
30
28
 
31
29
  let HSelect = class HSelect extends PhoenixLightLitElement {
32
30
  constructor() {
@@ -38,15 +36,14 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
38
36
  this.searchDisabled = false;
39
37
  this.type = SELECT_TYPES.select;
40
38
  this.noDeselect = false;
41
- this.assistiveTitleId = '';
42
- this._selectOptionsId = v4();
39
+ this.ariaLabelledby = '';
43
40
  this._searchValue = '';
44
41
  this._$options = new Map();
45
- this.$dropdown = createRef();
46
- this.$search = createRef();
42
+ this._$dropdown = createRef();
43
+ this._$search = createRef();
47
44
  this._$optionsList = createRef();
48
45
  this._$dropdownContent = createRef();
49
- this.$dropdownToggler = createRef();
46
+ this._$dropdownToggler = createRef();
50
47
  this._selectContext = new ContextProviderController(this);
51
48
  this._updateOptions = () => {
52
49
  const $options = this._getOptions();
@@ -104,18 +101,6 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
104
101
  this.updateOptionAriaAttribute($option);
105
102
  });
106
103
  };
107
- this._updateLabelAria = (options) => {
108
- var _a, _b;
109
- if (!this.$searchLabel)
110
- return;
111
- (_a = this.$searchLabel.querySelector(`[id="value-label"]`)) === null || _a === void 0 ? void 0 : _a.remove();
112
- this.$searchLabel.innerHTML = `
113
- ${(_b = this.$searchLabel) === null || _b === void 0 ? void 0 : _b.innerHTML}
114
- <span id="value-label" class="sr-only">
115
- ${options.reduce((totalSelectedContent, currentOption) => (totalSelectedContent += currentOption.content), '')}
116
- </span>
117
- `;
118
- };
119
104
  this._handleOptionClicked = ({ detail }) => {
120
105
  if (!(detail === null || detail === void 0 ? void 0 : detail.$option))
121
106
  return;
@@ -131,37 +116,26 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
131
116
  });
132
117
  };
133
118
  this._handleDropdownHidden = () => {
134
- var _a, _b, _c;
119
+ var _a;
135
120
  this._searchValue = '';
136
121
  this.opened = false;
137
- (_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.removeAttribute('aria-activedescendant');
138
- const isBodyActive = document.activeElement === document.body;
139
- const isInnerElementActive = (_b = this._$dropdownContent.value) === null || _b === void 0 ? void 0 : _b.contains(document.activeElement);
140
- if (isInnerElementActive || isBodyActive) {
141
- (_c = this.$dropdownToggler.value) === null || _c === void 0 ? void 0 : _c.focus();
142
- }
122
+ (_a = this._$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', '');
143
123
  };
144
- this._handleDropdownShowed = () => {
145
- this.opened = true;
146
- const $activeDescendant = this.options.find((option) => option.selected);
147
- if ($activeDescendant) {
148
- this.manageSelectVirtualFocus($activeDescendant);
124
+ this._manageSelectFocusAria = (ev) => {
125
+ var _a;
126
+ const $target = ev.target;
127
+ if (!$target)
128
+ return;
129
+ const optionId = $target.id;
130
+ if (optionId) {
131
+ (_a = this._$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', optionId);
149
132
  }
150
133
  };
151
- this.manageSelectVirtualFocus = ($newOption) => {
152
- var _a, _b, _c;
153
- (_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', $newOption.id);
154
- (_c = (_b = this.$search.value) === null || _b === void 0 ? void 0 : _b.querySelector('input')) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-activedescendant', $newOption.id);
155
- this.options.forEach((option) => {
156
- option.classList.remove('select-option_virtually-focused');
157
- });
158
- $newOption.classList.add('select-option_virtually-focused');
159
- };
160
134
  this._closeSelect = () => {
161
135
  var _a;
162
136
  if (!this.opened)
163
137
  return;
164
- (_a = this.$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
138
+ (_a = this._$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
165
139
  };
166
140
  this._clearOptions = () => {
167
141
  this._selectController.deselectAll();
@@ -205,7 +179,6 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
205
179
  return Array.from(this._$options.values());
206
180
  }
207
181
  updated(changedProperties) {
208
- var _a, _b;
209
182
  super.updated(changedProperties);
210
183
  if (changedProperties.has('opened')) {
211
184
  if (this.opened) {
@@ -219,55 +192,28 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
219
192
  if (changedProperties.has('optionsList')) {
220
193
  this._updateOptions();
221
194
  }
222
- if (this._$optionsList.value) {
223
- (_a = this.listBoxController) === null || _a === void 0 ? void 0 : _a.hostDisconnected();
224
- this.listBoxController = new ListBoxKeyboardController({
195
+ if (this._$optionsList.value && !this._listBoxController)
196
+ this._listBoxController = new ListBoxKeyboardController({
225
197
  host: this,
226
198
  $list: this._$optionsList.value
227
199
  });
228
- }
229
- if (this.listBoxController) {
230
- this.listBoxController.calculateSelectedOptionIndex();
231
- }
232
- if (this._$optionsList.value && this.$dropdownToggler.value) {
233
- (_b = this._selectTogglerKeyboardController) === null || _b === void 0 ? void 0 : _b.hostDisconnected();
234
- this._selectTogglerKeyboardController = new SelectTogglerKeyboardController({
235
- host: this,
236
- $toggler: this.$dropdownToggler.value,
237
- $list: this._$optionsList.value
238
- });
239
- }
240
200
  }
241
201
  _focusElementAfterSelectOpened() {
242
- var _a;
243
- const $searchInput = (_a = this.$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
244
- if ($searchInput)
245
- $searchInput.focus();
246
- const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
247
- const $firstOption = $options.find(($option) => {
248
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.getAttribute('hidden');
249
- });
250
- const $selectedOption = this.selectedOptions[0];
251
- const $optionToFocus = $selectedOption || $firstOption;
252
- if ($optionToFocus)
253
- this.manageSelectVirtualFocus($optionToFocus);
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();
254
205
  }
255
206
  connectedCallback() {
256
- var _a;
257
207
  super.connectedCallback();
258
208
  this.classList.add(SELECT_CSS_CLASSES.select);
259
209
  if (!this.searchDisabled) {
260
210
  this.classList.add(SELECT_CSS_CLASSES.selectWithSearch);
261
211
  }
262
- this.$searchLabel = document.querySelector(`[id="${this.assistiveTitleId}"]`);
263
- (_a = this.$searchLabel) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-hidden', 'true');
264
212
  this._selectController = this.multiple ? new MultiSelectController({ host: this }) : new SelectController({ host: this });
265
213
  this._selectContext.provide(SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
266
214
  this._selectContext.provide(SELECT_CONTEXTS.isMultiselect, this.multiple);
267
215
  this._optionsObserver = new Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
268
216
  this._selectController.options$.subscribe(this._optionsObserver);
269
- this._selectedOptionsAriaObserver = new Observer((selectedOptions) => this._updateLabelAria(selectedOptions));
270
- this._selectController.selectedOptions$.subscribe(this._selectedOptionsAriaObserver);
271
217
  this._updateOptions();
272
218
  this._setupEvents();
273
219
  }
@@ -297,10 +243,6 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
297
243
  SelectControlUtils.appendHTMLOption($option, $list, position);
298
244
  }
299
245
  updateOptionAriaAttribute($option) {
300
- if (!this.multiple) {
301
- const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
302
- $options.forEach(($option) => ($option.removeAttribute('aria-selected')));
303
- }
304
246
  $option.setAttribute(this.multiple ? 'aria-checked' : 'aria-selected', String($option.selected));
305
247
  }
306
248
  _removeHTMLOptions(optionsValues) {
@@ -310,12 +252,6 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
310
252
  const option = this._selectController.getOption(value);
311
253
  if (!option)
312
254
  return;
313
- const $selectedOption = this._$options.get(option.value);
314
- const $selectedOptionLink = $selectedOption === null || $selectedOption === void 0 ? void 0 : $selectedOption.querySelector('a');
315
- if ($selectedOptionLink) {
316
- $selectedOptionLink.click();
317
- return;
318
- }
319
255
  this.noDeselect ? this._selectController.select(option) : this._selectController.toggle(option);
320
256
  if (!this.multiple)
321
257
  this._closeSelect();
@@ -366,24 +302,23 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
366
302
  const isSearchEnabled = !this.searchDisabled && options.length > MIN_NUMBER_OF_OPTIONS_TO_SHOW_SEARCH;
367
303
  return html `
368
304
  <h-dropdown
369
- ${ref(this.$dropdown)}
370
- @showed=${this._handleDropdownShowed}
305
+ ${ref(this._$dropdown)}
306
+ @showed=${() => (this.opened = true)}
371
307
  @hidden=${this._handleDropdownHidden}
372
308
  name="${this.controlName}"
373
309
  offset=${this.offset}
374
310
  content-width="full"
375
311
  prevent-focus-trap
376
- no-autofocus
377
312
  >
378
313
  <h-dropdown-toggler
379
- ${ref(this.$dropdownToggler)}
314
+ ${ref(this._$dropdownToggler)}
380
315
  name="${this.controlName}"
381
316
  validation-container
382
317
  aria-haspopup="listbox"
383
318
  role="combobox"
384
319
  aria-required="${this.required ? 'true' : 'false'}"
385
- role="combobox"
386
- aria-controls="${this._selectOptionsId}"
320
+ aria-activedescendant
321
+ aria-labelledby="${this.ariaLabelledby}"
387
322
  >
388
323
  ${this.getSlot(SELECT_SLOT_NAMES.toggler)}
389
324
  </h-dropdown-toggler>
@@ -392,6 +327,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
392
327
  class="${SELECT_CSS_CLASSES.selectContent} ${this.error ? SELECT_CSS_CLASSES.selectContentError : ''}"
393
328
  ${ref(this._$dropdownContent)}
394
329
  name="${this.controlName}"
330
+ @focusin="${this._manageSelectFocusAria}"
395
331
  >
396
332
  <h-select-close-btn class="${SELECT_CSS_CLASSES.selectCloseMobileButton}" @close=${this._closeSelect}></h-select-close-btn>
397
333
 
@@ -400,18 +336,14 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
400
336
  ${isSearchEnabled
401
337
  ? html ` <h-select-search
402
338
  class=${SELECT_CSS_CLASSES.selectSearch}
403
- ${ref(this.$search)}
339
+ ${ref(this._$search)}
404
340
  .value=${this._searchValue}
405
341
  @search=${this._handleSearch}
406
- .selectControlId="${this.controlId}"
407
- .selectOptionsId="${this._selectOptionsId}"
408
342
  ></h-select-search>`
409
343
  : nothing}
410
344
 
411
345
  <h-options
412
346
  class="${SELECT_CSS_CLASSES.selectOptions} ${this._searchNoResult() ? SELECT_CSS_CLASSES.selectOptionsEmpty : ''}"
413
- aria-labelledby="${this.assistiveTitleId}"
414
- id="${this._selectOptionsId}"
415
347
  ${ref(this._$optionsList)}
416
348
  @optionClicked=${this._handleOptionClicked}
417
349
  @optionUpdated=${this._handleOptionUpdated}
@@ -503,9 +435,9 @@ __decorate([
503
435
  __metadata("design:type", Boolean)
504
436
  ], HSelect.prototype, "noDeselect", void 0);
505
437
  __decorate([
506
- property({ type: String, attribute: 'assistive-title-id' }),
438
+ property({ type: String, attribute: 'aria-labelledby' }),
507
439
  __metadata("design:type", String)
508
- ], HSelect.prototype, "assistiveTitleId", void 0);
440
+ ], HSelect.prototype, "ariaLabelledby", void 0);
509
441
  __decorate([
510
442
  state(),
511
443
  __metadata("design:type", String)
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,wDAA4D;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}
@@ -112,7 +112,9 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
112
112
  };
113
113
  this._addInertToBodyChildrenElements = () => {
114
114
  [...document.body.children].forEach((child) => {
115
- if (child.tagName !== PORTAL_TARGET_COMPONENT_NAME.toUpperCase()) {
115
+ const isPortalTarget = child.tagName === PORTAL_TARGET_COMPONENT_NAME.toUpperCase();
116
+ const isAriaLiveContainer = child.hasAttribute('aria-live');
117
+ if (!isPortalTarget && !isAriaLiveContainer) {
116
118
  child.setAttribute('inert', '');
117
119
  }
118
120
  });
@@ -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;"}
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,14 +1,10 @@
1
1
  import { Any } from 'ts-toolbelt';
2
- import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ import { ReactiveControllerHost } from 'lit';
3
3
  import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from "./list_box_controller_constants";
4
- import { HSelect } from "../../components/form/select/select";
5
4
  export declare type TListBoxKeyboardNavigationDirection = Any.Keys<typeof LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS>;
6
5
  export declare type TListBoxKeyboardControllerConstructorOptions = {
7
- host: ReactiveControllerHost & HSelect;
6
+ host: ReactiveControllerHost & HTMLElement;
8
7
  $list: HTMLElement;
9
8
  listItemSelector?: string;
10
9
  orientation?: TListBoxKeyboardNavigationDirection;
11
10
  };
12
- export interface IListboxController extends ReactiveController {
13
- calculateSelectedOptionIndex(): void;
14
- }
@@ -1,5 +1,4 @@
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';
5
4
  //# 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,OAA2D,KAAK,CAAC;AACjE,OAAwD,4EAA4E,CAAC;AACrI,OAAwB,4CAA4C,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,OAAuC,KAAK,CAAC;AAC7C,OAAwD,4EAA4E,CAAC"}
@@ -1,15 +1,10 @@
1
- import { IListboxController, TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
2
- export declare class ListBoxKeyboardController implements IListboxController {
1
+ import { ReactiveController } from 'lit';
2
+ import { TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
3
+ export declare class ListBoxKeyboardController implements ReactiveController {
3
4
  #private;
4
- currentOptionIndex: number | undefined;
5
5
  constructor({ host, $list, listItemSelector, orientation }: TListBoxKeyboardControllerConstructorOptions);
6
6
  hostConnected(): void;
7
- private _handleKeyboardNavigation;
8
7
  private _handleArrowNavigation;
9
- private _setVirtualFocusToFirstElement;
10
- private _handleWriteableCharacter;
11
- calculateSelectedOptionIndex: () => void;
12
8
  private _getPrevOptionIndex;
13
9
  private _getNextOptionIndex;
14
- hostDisconnected(): void;
15
10
  }
@@ -1,64 +1,37 @@
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';
4
5
  import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from './list_box_controller_constants.js';
5
6
 
6
- var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
7
+ var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController_currentOptionIndex, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
7
8
  class ListBoxKeyboardController {
8
9
  constructor({ host, $list, listItemSelector = '[role="option"]', orientation = LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS.vertical }) {
9
10
  _ListBoxKeyboardController_host.set(this, void 0);
10
11
  _ListBoxKeyboardController__$list.set(this, void 0);
12
+ _ListBoxKeyboardController_currentOptionIndex.set(this, void 0);
11
13
  _ListBoxKeyboardController__$options.set(this, void 0);
12
14
  _ListBoxKeyboardController_listItemSelector.set(this, void 0);
13
15
  _ListBoxKeyboardController_keys.set(this, void 0);
14
- this._handleKeyboardNavigation = (ev) => {
15
- if (__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f").find((key) => key === ev.key)) {
16
- this._handleArrowNavigation(ev);
17
- return;
18
- }
19
- this._handleWriteableCharacter(ev);
20
- };
21
16
  this._handleArrowNavigation = (event) => {
22
- var _a;
23
17
  event.preventDefault();
24
18
  const { key } = event;
25
- const activeElementId = (_a = __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.getAttribute('aria-activedescendant');
26
- if (!activeElementId) {
27
- this._setVirtualFocusToFirstElement();
28
- return;
29
- }
30
- const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
31
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
32
- });
33
- const $activeElement = document.querySelector(`#${activeElementId}`);
34
- const activeElementIndex = $availableOptions.findIndex(($element) => $element.id === $activeElement.id);
35
- let $newActiveElement;
36
- if (key === 'ArrowDown' || key === 'ArrowRight') {
37
- $newActiveElement = $availableOptions[activeElementIndex + 1];
19
+ const prevOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
20
+ let newOptionIndex = key === 'ArrowDown' || key === 'ArrowRight' ? this._getNextOptionIndex() : this._getPrevOptionIndex();
21
+ if (newOptionIndex === undefined) {
22
+ const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
23
+ newOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
38
24
  }
39
- if (key === 'ArrowUp' || key === 'ArrowLeft') {
40
- $newActiveElement = $availableOptions[activeElementIndex - 1];
41
- }
42
- if (!$newActiveElement)
43
- return;
44
- __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").manageSelectVirtualFocus($newActiveElement);
45
- };
46
- this._setVirtualFocusToFirstElement = () => {
47
- const $firstOption = __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").options[0];
48
- if (!$firstOption)
25
+ if (newOptionIndex === __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f"))
49
26
  return;
50
- __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").manageSelectVirtualFocus($firstOption);
51
- };
52
- this._handleWriteableCharacter = (ev) => {
53
- var _a;
54
- const $searchInput = (_a = __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
55
- if (!$searchInput)
56
- return;
57
- $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
58
- };
59
- this.calculateSelectedOptionIndex = () => {
60
- const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
61
- this.currentOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
27
+ if (prevOptionIndex !== undefined) {
28
+ const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
29
+ UiDomUtils.makeUnnavigable($prevOption);
30
+ }
31
+ __classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, newOptionIndex, "f");
32
+ const $focusedOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[newOptionIndex];
33
+ UiDomUtils.makeNavigable($focusedOption);
34
+ $focusedOption.focus();
62
35
  };
63
36
  __classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
64
37
  __classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
@@ -68,58 +41,40 @@ class ListBoxKeyboardController {
68
41
  __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").addController(this);
69
42
  }
70
43
  hostConnected() {
71
- __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('keydown', this._handleKeyboardNavigation);
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
50
  UiDomUtils.makeNavigable(__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"));
73
51
  __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
74
52
  if (event.target !== __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
75
53
  return;
76
- // if (this.currentOptionIndex === undefined) return;
77
- // const $prevOption = this.#_$options[this.currentOptionIndex];
78
- // UiDomUtils.makeUnnavigable($prevOption);
79
- // this.currentOptionIndex = undefined;
54
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
55
+ return;
56
+ const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f")];
57
+ UiDomUtils.makeUnnavigable($prevOption);
58
+ __classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, undefined, "f");
80
59
  });
81
- // this.#_$options.forEach(($option: HTMLElement) => UiDomUtils.makeUnnavigable($option));
60
+ __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").forEach(($option) => UiDomUtils.makeUnnavigable($option));
82
61
  }
83
62
  _getPrevOptionIndex() {
84
- if (this.currentOptionIndex === undefined)
63
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
85
64
  return undefined;
86
- if (this.currentOptionIndex <= 0)
87
- return this.currentOptionIndex;
88
- if (this.currentOptionIndex <= 0)
89
- return this.currentOptionIndex;
90
- const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
91
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
92
- });
93
- if (!!$availableOptions[this.currentOptionIndex - 1])
94
- return this.currentOptionIndex - 1;
95
- // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
96
- const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
97
- if (newIndexOfCurrentlySelectedOption)
98
- return newIndexOfCurrentlySelectedOption - 1;
99
- return this.currentOptionIndex - 1;
65
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
66
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
67
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
100
68
  }
101
69
  _getNextOptionIndex() {
102
- if (this.currentOptionIndex === undefined)
70
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
103
71
  return undefined;
104
- const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
105
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
106
- });
107
- if (this.currentOptionIndex === $availableOptions.length - 1)
108
- return this.currentOptionIndex;
109
- if (this.currentOptionIndex > $availableOptions.length - 1) {
110
- // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
111
- const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
112
- if (newIndexOfCurrentlySelectedOption)
113
- return newIndexOfCurrentlySelectedOption + 1;
114
- return 0;
115
- }
116
- return this.currentOptionIndex + 1;
117
- }
118
- hostDisconnected() {
119
- __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
72
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") >= __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").length - 1)
73
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
74
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") + 1;
120
75
  }
121
76
  }
122
- _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
77
+ _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController_currentOptionIndex = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
123
78
 
124
79
  export { ListBoxKeyboardController };
125
80
  //# sourceMappingURL=list_box_keyboard_controller.js.map
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}
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-39",
5
+ "version": "1.15.11-40",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "@splidejs/splide": "^4.0.7"
31
31
  },
32
32
  "devDependencies": {
33
- "@dreamcommerce/utilities": "^1.20.1-0",
33
+ "@dreamcommerce/utilities": "^1.20.1",
34
34
  "@shoper/jest_config": "^0.0.0",
35
35
  "@shoper/tsconfig": "^0.0.0",
36
36
  "@splidejs/splide": "4.0.7",
@@ -1,88 +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
- require('@dreamcommerce/utilities');
8
-
9
- var _SelectTogglerKeyboardController_host, _SelectTogglerKeyboardController__$toggler, _SelectTogglerKeyboardController_currentOptionIndex, _SelectTogglerKeyboardController__$options;
10
- class SelectTogglerKeyboardController {
11
- constructor({ host, $toggler, $list, listItemSelector = '[role="option"]', }) {
12
- _SelectTogglerKeyboardController_host.set(this, void 0);
13
- _SelectTogglerKeyboardController__$toggler.set(this, void 0);
14
- _SelectTogglerKeyboardController_currentOptionIndex.set(this, void 0);
15
- _SelectTogglerKeyboardController__$options.set(this, void 0);
16
- this._handleKeyboardNavigation = (ev) => {
17
- const arrowKeys = ['ArrowUp', 'ArrowDown'];
18
- if (arrowKeys.includes(ev.key)) {
19
- this._openSelect(ev);
20
- return;
21
- }
22
- if (ev.key === 'Home') {
23
- this._openSelectAndGoToFirstElement(ev);
24
- return;
25
- }
26
- if (ev.key === 'End') {
27
- this._openSelectAndGoToLastElement(ev);
28
- return;
29
- }
30
- if (ev.altKey || ev.shiftKey)
31
- return;
32
- const isAWriteableCharacter = ev.key.length === 1;
33
- if (isAWriteableCharacter)
34
- this._openSelectAndGoToMatchedElement(ev);
35
- };
36
- this._openSelect = (event) => {
37
- var _a;
38
- event.preventDefault();
39
- (_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show();
40
- };
41
- this._openSelectAndGoToFirstElement = async (event) => {
42
- var _a;
43
- event.preventDefault();
44
- await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
45
- this._navigate(0);
46
- };
47
- this._openSelectAndGoToLastElement = async (event) => {
48
- var _a;
49
- event.preventDefault();
50
- await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
51
- const $availableOptions = this._getAvailableOptions();
52
- this._navigate($availableOptions.length - 1);
53
- };
54
- this._openSelectAndGoToMatchedElement = async (event) => {
55
- var _a;
56
- event.preventDefault();
57
- await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
58
- const matchedOptionIndex = this._getAvailableOptions().findIndex(($option) => { var _a; return (_a = $option.innerText) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith(event.key.toLowerCase()); });
59
- if (matchedOptionIndex)
60
- this._navigate(matchedOptionIndex);
61
- };
62
- this._getAvailableOptions = () => {
63
- return tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f").filter(($option) => {
64
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
65
- });
66
- };
67
- this._navigate = (newOptionIndex) => {
68
- const $newOption = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").options[newOptionIndex];
69
- if (!$newOption)
70
- return;
71
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").manageSelectVirtualFocus($newOption);
72
- };
73
- tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController_host, host, "f");
74
- tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$toggler, $toggler, "f");
75
- tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$options, Array.from($list.querySelectorAll(listItemSelector)), "f");
76
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").addController(this);
77
- }
78
- hostConnected() {
79
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").addEventListener('keydown', this._handleKeyboardNavigation);
80
- }
81
- hostDisconnected() {
82
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
83
- }
84
- }
85
- _SelectTogglerKeyboardController_host = new WeakMap(), _SelectTogglerKeyboardController__$toggler = new WeakMap(), _SelectTogglerKeyboardController_currentOptionIndex = new WeakMap(), _SelectTogglerKeyboardController__$options = new WeakMap();
86
-
87
- exports.SelectTogglerKeyboardController = SelectTogglerKeyboardController;
88
- //# sourceMappingURL=select_toggler_keyboard_controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}