@shoper/phoenix_design_system 1.15.11 → 1.15.13

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 +23 -5
  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 +31 -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 +98 -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 +78 -19
  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 +3 -1
  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 +76 -30
  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 +3 -0
  23. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +23 -5
  24. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  25. package/build/esm/packages/phoenix/src/components/form/radio/radio_control.d.ts +1 -0
  26. package/build/esm/packages/phoenix/src/components/form/radio/radio_control.js +5 -0
  27. package/build/esm/packages/phoenix/src/components/form/radio/radio_control.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 +31 -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 +15 -0
  34. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +94 -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 +14 -5
  40. package/build/esm/packages/phoenix/src/components/form/select/select.js +78 -19
  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 +3 -1
  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 +8 -3
  48. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +76 -30
  49. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  50. package/package.json +2 -2
@@ -5,37 +5,64 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  require('lit');
7
7
  var utilities = require('@dreamcommerce/utilities');
8
- var keystrokes_controller = require('../keystrokes_controller/keystrokes_controller.js');
9
8
  var list_box_controller_constants = require('./list_box_controller_constants.js');
10
9
 
11
- var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController_currentOptionIndex, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
10
+ var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
12
11
  class ListBoxKeyboardController {
13
12
  constructor({ host, $list, listItemSelector = '[role="option"]', orientation = list_box_controller_constants.LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS.vertical }) {
14
13
  _ListBoxKeyboardController_host.set(this, void 0);
15
14
  _ListBoxKeyboardController__$list.set(this, void 0);
16
- _ListBoxKeyboardController_currentOptionIndex.set(this, void 0);
17
15
  _ListBoxKeyboardController__$options.set(this, void 0);
18
16
  _ListBoxKeyboardController_listItemSelector.set(this, void 0);
19
17
  _ListBoxKeyboardController_keys.set(this, void 0);
18
+ this._handleKeyboardNavigation = (ev) => {
19
+ if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f").find((key) => key === ev.key)) {
20
+ this._handleArrowNavigation(ev);
21
+ return;
22
+ }
23
+ this._handleWriteableCharacter(ev);
24
+ };
20
25
  this._handleArrowNavigation = (event) => {
21
26
  event.preventDefault();
22
27
  const { key } = event;
23
- const prevOptionIndex = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
28
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
29
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
30
+ });
31
+ const prevOptionIndex = this._findCurrentIndex();
24
32
  let newOptionIndex = key === 'ArrowDown' || key === 'ArrowRight' ? this._getNextOptionIndex() : this._getPrevOptionIndex();
25
33
  if (newOptionIndex === undefined) {
26
- const selectedOptionIndex = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
27
- newOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
34
+ newOptionIndex = this._findCurrentIndex();
28
35
  }
29
- if (newOptionIndex === tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f"))
36
+ if (newOptionIndex === this.currentOptionIndex)
30
37
  return;
31
38
  if (prevOptionIndex !== undefined) {
32
39
  const $prevOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
33
- utilities.UiDomUtils.makeUnnavigable($prevOption);
40
+ $prevOption && utilities.UiDomUtils.makeUnnavigable($prevOption);
34
41
  }
35
- tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, newOptionIndex, "f");
36
- const $focusedOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[newOptionIndex];
37
- utilities.UiDomUtils.makeNavigable($focusedOption);
38
- $focusedOption.focus();
42
+ this.currentOptionIndex = newOptionIndex;
43
+ const $focusedOption = $availableOptions[newOptionIndex];
44
+ if ($focusedOption) {
45
+ utilities.UiDomUtils.makeNavigable($focusedOption);
46
+ $focusedOption.focus();
47
+ }
48
+ };
49
+ this._findCurrentIndex = () => {
50
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
51
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
52
+ });
53
+ const selectedOptionIndex = $availableOptions.findIndex(($option) => $option.selected);
54
+ return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
55
+ };
56
+ this._handleWriteableCharacter = (ev) => {
57
+ var _a;
58
+ const $searchInput = (_a = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
59
+ if (!$searchInput)
60
+ return;
61
+ $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
62
+ };
63
+ this.calculateSelectedOptionIndex = () => {
64
+ const selectedOptionIndex = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
65
+ this.currentOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
39
66
  };
40
67
  tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
41
68
  tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
@@ -45,40 +72,59 @@ class ListBoxKeyboardController {
45
72
  tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").addController(this);
46
73
  }
47
74
  hostConnected() {
48
- new keystrokes_controller.KeystrokesController({
49
- host: tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f"),
50
- keys: tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f"),
51
- callback: this._handleArrowNavigation,
52
- target: tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f")
53
- });
75
+ tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('keydown', this._handleKeyboardNavigation);
54
76
  utilities.UiDomUtils.makeNavigable(tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"));
55
77
  tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
56
78
  if (event.target !== tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
57
79
  return;
58
- if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
80
+ if (this.currentOptionIndex === undefined)
59
81
  return;
60
- const $prevOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f")];
82
+ const $prevOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[this.currentOptionIndex];
61
83
  utilities.UiDomUtils.makeUnnavigable($prevOption);
62
- tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, undefined, "f");
84
+ this.currentOptionIndex = undefined;
63
85
  });
64
86
  tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").forEach(($option) => utilities.UiDomUtils.makeUnnavigable($option));
65
87
  }
66
88
  _getPrevOptionIndex() {
67
- if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
89
+ if (this.currentOptionIndex === undefined)
68
90
  return undefined;
69
- if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
70
- return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
71
- return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
91
+ if (this.currentOptionIndex <= 0)
92
+ return this.currentOptionIndex;
93
+ if (this.currentOptionIndex <= 0)
94
+ return this.currentOptionIndex;
95
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
96
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
97
+ });
98
+ if (!!$availableOptions[this.currentOptionIndex - 1])
99
+ return this.currentOptionIndex - 1;
100
+ // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
101
+ const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
102
+ if (newIndexOfCurrentlySelectedOption)
103
+ return newIndexOfCurrentlySelectedOption - 1;
104
+ return this.currentOptionIndex - 1;
72
105
  }
73
106
  _getNextOptionIndex() {
74
- if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
107
+ if (this.currentOptionIndex === undefined)
75
108
  return undefined;
76
- if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") >= tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").length - 1)
77
- return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
78
- return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") + 1;
109
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
110
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
111
+ });
112
+ if (this.currentOptionIndex === $availableOptions.length - 1)
113
+ return this.currentOptionIndex;
114
+ if (this.currentOptionIndex > $availableOptions.length - 1) {
115
+ // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
116
+ const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
117
+ if (newIndexOfCurrentlySelectedOption)
118
+ return newIndexOfCurrentlySelectedOption + 1;
119
+ return 0;
120
+ }
121
+ return this.currentOptionIndex + 1;
122
+ }
123
+ hostDisconnected() {
124
+ tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
79
125
  }
80
126
  }
81
- _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController_currentOptionIndex = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
127
+ _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
82
128
 
83
129
  exports.ListBoxKeyboardController = ListBoxKeyboardController;
84
130
  //# sourceMappingURL=list_box_keyboard_controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -17,6 +17,7 @@ export declare class HDropdown extends PhoenixLightLitElement implements IDropdo
17
17
  mobilePosition: TMobileElementPosition;
18
18
  id: string;
19
19
  preventFocusTrap: boolean;
20
+ noAutoFocus: boolean;
20
21
  $dropdownToggler: HDropdownToggler | null;
21
22
  $dropdownContent: HDropdownContent | null;
22
23
  $nestedDropdownContentElements?: HDropdownContent[];
@@ -28,6 +28,7 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
28
28
  this.portalTarget = DEFAULT_DROPDOWN_PORTAL_NAME;
29
29
  this.id = v4();
30
30
  this.preventFocusTrap = false;
31
+ this.noAutoFocus = false;
31
32
  this._backdropController = new BackdropController();
32
33
  this._handleClickOutside = async (target) => {
33
34
  var _a, _b;
@@ -44,7 +45,8 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
44
45
  return;
45
46
  }
46
47
  await this.show();
47
- this._focusOnFirstContentElement();
48
+ if (!this.noAutoFocus)
49
+ this._focusOnFirstContentElement();
48
50
  };
49
51
  this.show = async () => {
50
52
  if (this.opened)
@@ -172,7 +174,8 @@ let HDropdown = HDropdown_1 = class HDropdown extends PhoenixLightLitElement {
172
174
  const isHoveredWithinDropdown = this._isHoveredWithinDropdown(ev.target);
173
175
  if (isHoveredWithinDropdown && !this.opened) {
174
176
  await this.show();
175
- this._focusOnFirstContentElement();
177
+ if (!this.noAutoFocus)
178
+ this._focusOnFirstContentElement();
176
179
  return;
177
180
  }
178
181
  if (!isHoveredWithinDropdown && this.opened)
@@ -462,6 +465,10 @@ __decorate([
462
465
  property({ type: Boolean, attribute: 'prevent-focus-trap' }),
463
466
  __metadata("design:type", Object)
464
467
  ], HDropdown.prototype, "preventFocusTrap", void 0);
468
+ __decorate([
469
+ property({ type: Boolean, attribute: 'no-autofocus' }),
470
+ __metadata("design:type", Object)
471
+ ], HDropdown.prototype, "noAutoFocus", void 0);
465
472
  HDropdown = HDropdown_1 = __decorate([
466
473
  phoenixCustomElement('h-dropdown'),
467
474
  __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,eAAe,qDAAyD;AACxE;AACA;AACA;AACA,uBAAuB,4CAAgD;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,eAAe,qDAAyD;AACxE;AACA;AACA;AACA,uBAAuB,4CAAgD;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,6 +1,9 @@
1
1
  import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
2
2
  export declare class HDropdownToggler extends PhoenixLightLitElement {
3
3
  name: string;
4
+ ariaHasPopup: string;
5
+ ariaControls: string;
6
+ role: string;
4
7
  private _btnController;
5
8
  private _toggleElementAriaController;
6
9
  private _$dropdown;
@@ -3,7 +3,6 @@ import { property } from 'lit/decorators';
3
3
  import '@dreamcommerce/utilities';
4
4
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
5
5
  import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
6
- import { BtnController } from '../../controllers/btn_controller/btn_controller.js';
7
6
  import { BREAKPOINTS } from '../../global_constants.js';
8
7
  import { DROPDOWN_CONTAINER_NAME, DROPDOWN_EVENTS, DROPDOWN_CSS_CLASSES, DROPDOWN_TOGGLE_ON_HOVER_ATTRIBUTE_NAME } from './dropdown_constants.js';
9
8
  import { ToggleElementAriaController } from '../../controllers/toggle_element_aria_controller/toggle_element_aria_controller.js';
@@ -12,6 +11,9 @@ let HDropdownToggler = class HDropdownToggler extends PhoenixLightLitElement {
12
11
  constructor() {
13
12
  super();
14
13
  this.name = '';
14
+ this.ariaHasPopup = 'menu';
15
+ this.ariaControls = '';
16
+ this.role = 'button';
15
17
  this._setupTogglerAria = () => {
16
18
  this._$dropdown = this.closest(DROPDOWN_CONTAINER_NAME);
17
19
  if (this._$dropdown.isOpened)
@@ -19,11 +21,14 @@ let HDropdownToggler = class HDropdownToggler extends PhoenixLightLitElement {
19
21
  host: this,
20
22
  initialAriaExpandedValue: this._$dropdown.isOpened()
21
23
  });
22
- this.setAttribute('aria-haspopup', 'true');
23
- if (this._$dropdown.id)
24
- this.setAttribute('aria-controls', this._$dropdown.id);
24
+ this.setAttribute('role', this.role);
25
+ this.setAttribute('aria-haspopup', this.ariaHasPopup);
26
+ if (this.ariaControls || this._$dropdown.id)
27
+ this.setAttribute('aria-controls', this.ariaControls || this._$dropdown.id);
25
28
  };
26
29
  this._dispatchToggleDropdownEventWithKeyboard = (ev) => {
30
+ if (ev.key !== 'Enter' && ev.key !== ' ')
31
+ return;
27
32
  ev.stopImmediatePropagation();
28
33
  this._dispatchToggleDropdownEvent(ev);
29
34
  };
@@ -42,7 +47,8 @@ let HDropdownToggler = class HDropdownToggler extends PhoenixLightLitElement {
42
47
  connectedCallback() {
43
48
  var _a;
44
49
  super.connectedCallback();
45
- this._btnController = new BtnController(this, this._dispatchToggleDropdownEventWithKeyboard);
50
+ this.setAttribute('tabindex', '0');
51
+ this.addEventListener('keydown', this._dispatchToggleDropdownEventWithKeyboard);
46
52
  this._setupTogglerAria();
47
53
  const hasToggleOnHover = (_a = this._$dropdown) === null || _a === void 0 ? void 0 : _a.hasAttribute(DROPDOWN_TOGGLE_ON_HOVER_ATTRIBUTE_NAME);
48
54
  if (hasToggleOnHover) {
@@ -56,6 +62,18 @@ __decorate([
56
62
  property({ type: String, reflect: true }),
57
63
  __metadata("design:type", Object)
58
64
  ], HDropdownToggler.prototype, "name", void 0);
65
+ __decorate([
66
+ property({ type: String, attribute: 'aria-haspopup' }),
67
+ __metadata("design:type", Object)
68
+ ], HDropdownToggler.prototype, "ariaHasPopup", void 0);
69
+ __decorate([
70
+ property({ type: String, attribute: 'aria-controls' }),
71
+ __metadata("design:type", Object)
72
+ ], HDropdownToggler.prototype, "ariaControls", void 0);
73
+ __decorate([
74
+ property({ type: String }),
75
+ __metadata("design:type", Object)
76
+ ], HDropdownToggler.prototype, "role", void 0);
59
77
  HDropdownToggler = __decorate([
60
78
  phoenixCustomElement('h-dropdown-toggler'),
61
79
  __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;"}
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;"}
@@ -9,6 +9,7 @@ export declare class HRadioControl extends PhoenixLightLitElement {
9
9
  readonly: boolean;
10
10
  checked: boolean;
11
11
  value: string;
12
+ ariaDescribedby: string;
12
13
  constructor();
13
14
  connectedCallback(): void;
14
15
  protected render(): TemplateResult;
@@ -37,6 +37,7 @@ let HRadioControl = class HRadioControl extends PhoenixLightLitElement {
37
37
  ?readonly="${this.readonly}"
38
38
  ?hidden="${this.hidden}"
39
39
  .checked="${this.checked}"
40
+ aria-describedby="${ifDefined(this.ariaDescribedby)}"
40
41
  @change="${this._handleChangeEvent}"
41
42
  />
42
43
 
@@ -76,6 +77,10 @@ __decorate([
76
77
  property({ type: String }),
77
78
  __metadata("design:type", String)
78
79
  ], HRadioControl.prototype, "value", void 0);
80
+ __decorate([
81
+ property({ type: String, attribute: 'aria-describedby' }),
82
+ __metadata("design:type", String)
83
+ ], HRadioControl.prototype, "ariaDescribedby", void 0);
79
84
  HRadioControl = __decorate([
80
85
  phoenixCustomElement('h-radio-control'),
81
86
  __metadata("design:paramtypes", [])
@@ -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;"}
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;"}
@@ -2,7 +2,11 @@ import { PhoenixLightLitElement } from "../../../../../core/phoenix_light_lit_el
2
2
  import { TemplateResult } from 'lit';
3
3
  export declare class HSelectSearch extends PhoenixLightLitElement {
4
4
  value: string;
5
+ private _$selectOptions;
5
6
  connectedCallback(): void;
7
+ private _handleSearchKeydown;
8
+ private _handleDispatchEventOnOptionsList;
9
+ private _handleFocusOptionOnArrowNavigation;
6
10
  private _handleInputChange;
7
11
  protected render(): TemplateResult;
8
12
  }
@@ -1,9 +1,11 @@
1
1
  import { __decorate, __metadata } from '../../../../../../../../external/tslib/tslib.es6.js';
2
2
  import { html } from 'lit';
3
3
  import { property } from 'lit/decorators';
4
+ import '@dreamcommerce/utilities';
4
5
  import { PhoenixLightLitElement } from '../../../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
5
6
  import { phoenixCustomElement } from '../../../../../core/decorators/phoenix_custom_element.js';
6
7
  import { SELECT_SEARCH_EVENT_NAMES, SELECT_RELATED_COMPONENTS_NAMES } from '../select_components_constatns.js';
8
+ import { DROPDOWN_CONTENT_NAME } from '../../../../dropdown/dropdown_constants.js';
7
9
  import debounce_1 from '../../../../../../../../external/lodash/debounce.js';
8
10
  import { SELECT_SEARCH_CSS_CLASSES } from './select_search_constants.js';
9
11
 
@@ -11,6 +13,32 @@ let HSelectSearch = class HSelectSearch extends PhoenixLightLitElement {
11
13
  constructor() {
12
14
  super(...arguments);
13
15
  this.value = '';
16
+ this._$selectOptions = null;
17
+ this._handleSearchKeydown = (ev) => {
18
+ if (ev.key !== 'ArrowDown' && ev.key !== 'ArrowUp')
19
+ return;
20
+ this._handleFocusOptionOnArrowNavigation();
21
+ this._handleDispatchEventOnOptionsList(ev);
22
+ };
23
+ this._handleDispatchEventOnOptionsList = (ev) => {
24
+ var _a;
25
+ const arrowNavigationEvent = new KeyboardEvent('keydown', {
26
+ key: ev.key
27
+ });
28
+ (_a = this._$selectOptions) === null || _a === void 0 ? void 0 : _a.dispatchEvent(arrowNavigationEvent);
29
+ };
30
+ this._handleFocusOptionOnArrowNavigation = () => {
31
+ const $options = this._$selectOptions ? [...this._$selectOptions.querySelectorAll('h-option')] : [];
32
+ const $availableOptions = $options.filter(($option) => {
33
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
34
+ });
35
+ const $firstOption = $availableOptions.find(($option) => {
36
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.getAttribute('hidden');
37
+ });
38
+ const $selectedOption = $availableOptions.find(($option) => $option.getAttribute('aria-selected'));
39
+ const $optionToFocus = $selectedOption || $firstOption;
40
+ $optionToFocus === null || $optionToFocus === void 0 ? void 0 : $optionToFocus.focus();
41
+ };
14
42
  this._handleInputChange = debounce_1(({ target }) => {
15
43
  this.value = target.value;
16
44
  this.emitCustomEvent(SELECT_SEARCH_EVENT_NAMES.search, {
@@ -21,6 +49,9 @@ let HSelectSearch = class HSelectSearch extends PhoenixLightLitElement {
21
49
  connectedCallback() {
22
50
  super.connectedCallback();
23
51
  this.classList.add(SELECT_SEARCH_CSS_CLASSES.selectSearch);
52
+ const $selectOptionsContainer = this.closest(DROPDOWN_CONTENT_NAME);
53
+ this._$selectOptions = $selectOptionsContainer === null || $selectOptionsContainer === void 0 ? void 0 : $selectOptionsContainer.querySelector('h-options');
54
+ this.addEventListener('keydown', this._handleSearchKeydown);
24
55
  }
25
56
  render() {
26
57
  return html `
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;AACA;AACA;AACA;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __metadata } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { UiDomUtils } from '@dreamcommerce/utilities';
2
+ import '@dreamcommerce/utilities';
3
3
  import { PhoenixLightLitElement } from '../../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
4
4
  import { phoenixCustomElement } from '../../../../core/decorators/phoenix_custom_element.js';
5
5
  import { SELECT_OPTIONS_EVENT_NAMES, SELECT_OPTION_EVENT_NAMES, SELECT_RELATED_COMPONENTS_NAMES } from './select_components_constatns.js';
@@ -22,7 +22,6 @@ let HOptions = class HOptions extends PhoenixLightLitElement {
22
22
  });
23
23
  };
24
24
  this.setAttribute('role', 'listbox');
25
- UiDomUtils.makeNavigable(this);
26
25
  this.addEventListener(SELECT_OPTION_EVENT_NAMES.clicked, this._dispatchClickedEvent);
27
26
  this.addEventListener(SELECT_OPTION_EVENT_NAMES.updated, this._dispatchUpdatedEvent);
28
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,kDAAsD;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,kDAAsD;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,15 @@
1
+ import { TSelectTogglerKeyboardControllerConstructorOptions } from './select_toggler_keyboard_controller_types';
2
+ export declare class SelectTogglerKeyboardController {
3
+ #private;
4
+ constructor({ host, $toggler, $list, listItemSelector, }: TSelectTogglerKeyboardControllerConstructorOptions);
5
+ hostConnected(): void;
6
+ private _handleKeyboardNavigation;
7
+ private _openSelect;
8
+ private _openSelectAndGoToFirstElement;
9
+ private _openSelectAndGoToLastElement;
10
+ private _openSelectAndGoToMatchedElement;
11
+ private _getAvailableOptions;
12
+ private _findSelectedIndex;
13
+ private _navigate;
14
+ hostDisconnected(): void;
15
+ }
@@ -0,0 +1,94 @@
1
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import 'lit';
3
+ import { UiDomUtils } from '@dreamcommerce/utilities';
4
+
5
+ var _SelectTogglerKeyboardController_host, _SelectTogglerKeyboardController__$toggler, _SelectTogglerKeyboardController_currentOptionIndex, _SelectTogglerKeyboardController__$options;
6
+ class SelectTogglerKeyboardController {
7
+ constructor({ host, $toggler, $list, listItemSelector = '[role="option"]', }) {
8
+ _SelectTogglerKeyboardController_host.set(this, void 0);
9
+ _SelectTogglerKeyboardController__$toggler.set(this, void 0);
10
+ _SelectTogglerKeyboardController_currentOptionIndex.set(this, void 0);
11
+ _SelectTogglerKeyboardController__$options.set(this, void 0);
12
+ this._handleKeyboardNavigation = (ev) => {
13
+ const arrowKeys = ['ArrowUp', 'ArrowDown'];
14
+ if (arrowKeys.includes(ev.key)) {
15
+ this._openSelect(ev);
16
+ return;
17
+ }
18
+ if (ev.key === 'Home') {
19
+ this._openSelectAndGoToFirstElement(ev);
20
+ return;
21
+ }
22
+ if (ev.key === 'End') {
23
+ this._openSelectAndGoToLastElement(ev);
24
+ return;
25
+ }
26
+ if (ev.altKey || ev.shiftKey)
27
+ return;
28
+ const isAWriteableCharacter = ev.key.length === 1;
29
+ if (isAWriteableCharacter)
30
+ this._openSelectAndGoToMatchedElement(ev);
31
+ };
32
+ this._openSelect = (event) => {
33
+ var _a;
34
+ event.preventDefault();
35
+ (_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show();
36
+ };
37
+ this._openSelectAndGoToFirstElement = async (event) => {
38
+ var _a;
39
+ event.preventDefault();
40
+ await ((_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
41
+ const $firstOption = this._getAvailableOptions()[0];
42
+ if ($firstOption)
43
+ this._navigate($firstOption);
44
+ };
45
+ this._openSelectAndGoToLastElement = async (event) => {
46
+ var _a;
47
+ event.preventDefault();
48
+ await ((_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
49
+ const $availableOptions = this._getAvailableOptions();
50
+ const $lastOption = $availableOptions[$availableOptions.length - 1];
51
+ if ($lastOption)
52
+ this._navigate($lastOption);
53
+ };
54
+ this._openSelectAndGoToMatchedElement = async (event) => {
55
+ var _a;
56
+ event.preventDefault();
57
+ await ((_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
58
+ const $matchedOption = this._getAvailableOptions().find(($option) => { var _a; return (_a = $option.innerText) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith(event.key.toLowerCase()); });
59
+ if ($matchedOption)
60
+ this._navigate($matchedOption);
61
+ };
62
+ this._getAvailableOptions = () => {
63
+ return __classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f").filter(($option) => {
64
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
65
+ });
66
+ };
67
+ this._findSelectedIndex = () => {
68
+ const selectedOptionIndex = this._getAvailableOptions().findIndex(($option) => $option.selected);
69
+ return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
70
+ };
71
+ this._navigate = ($newOption) => {
72
+ const $selectedOption = __classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f")[this._findSelectedIndex()];
73
+ UiDomUtils.makeUnnavigable($selectedOption);
74
+ const newOptionIndex = this._getAvailableOptions().findIndex(($option) => $newOption.value === $option.value);
75
+ __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").listBoxController.currentOptionIndex = newOptionIndex;
76
+ UiDomUtils.makeNavigable($newOption);
77
+ $newOption.focus();
78
+ };
79
+ __classPrivateFieldSet(this, _SelectTogglerKeyboardController_host, host, "f");
80
+ __classPrivateFieldSet(this, _SelectTogglerKeyboardController__$toggler, $toggler, "f");
81
+ __classPrivateFieldSet(this, _SelectTogglerKeyboardController__$options, Array.from($list.querySelectorAll(listItemSelector)), "f");
82
+ __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").addController(this);
83
+ }
84
+ hostConnected() {
85
+ __classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").addEventListener('keydown', this._handleKeyboardNavigation);
86
+ }
87
+ hostDisconnected() {
88
+ __classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
89
+ }
90
+ }
91
+ _SelectTogglerKeyboardController_host = new WeakMap(), _SelectTogglerKeyboardController__$toggler = new WeakMap(), _SelectTogglerKeyboardController_currentOptionIndex = new WeakMap(), _SelectTogglerKeyboardController__$options = new WeakMap();
92
+
93
+ export { SelectTogglerKeyboardController };
94
+ //# sourceMappingURL=select_toggler_keyboard_controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,qDAAyD;AACxH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,8 @@
1
+ import { ReactiveControllerHost } from 'lit';
2
+ import { HSelect } from "../../select";
3
+ export declare type TSelectTogglerKeyboardControllerConstructorOptions = {
4
+ host: ReactiveControllerHost & HSelect;
5
+ $toggler: HTMLElement;
6
+ $list: HTMLElement;
7
+ listItemSelector?: string;
8
+ };
@@ -0,0 +1,3 @@
1
+ import 'lit';
2
+ import '@phoenixRoot/components/form/select/select';
3
+ //# sourceMappingURL=select_toggler_keyboard_controller_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select_toggler_keyboard_controller_types.js","sourceRoot":"","sources":["../../../../../../../../../../src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.ts"],"names":[],"mappings":"AAAA,OAAuC,KAAK,CAAC;AAC7C,OAAwB,4CAA4C,CAAC"}
@@ -1,5 +1,9 @@
1
1
  import { PropertyValues, TemplateResult } from 'lit';
2
+ import { HDropdown } from "../../dropdown/dropdown";
3
+ import { HDropdownToggler } from "../../dropdown/dropdown_toggler";
2
4
  import { HOption } from "./components/option/select_option";
5
+ import { HSelectSearch } from "./components/search/select_search";
6
+ import { ListBoxKeyboardController } from "../../../controllers/list_box_controller/list_box_keyboard_controller";
3
7
  import { PhoenixLightLitElement } from "../../../core/phoenix_light_lit_element/phoenix_light_lit_element";
4
8
  import { SelectOption } from "./model/select_option";
5
9
  import type { TSelectType } from "./select_types";
@@ -18,7 +22,8 @@ export declare class HSelect extends PhoenixLightLitElement {
18
22
  required: boolean;
19
23
  optionsList?: TSelectOption[];
20
24
  noDeselect: boolean;
21
- ariaLabelledby: string;
25
+ assistiveTitleId: string;
26
+ private _selectOptionsId;
22
27
  get selectedIndex(): number;
23
28
  set selectedIndex(index: number);
24
29
  get selectedOptions(): (HOption | undefined)[];
@@ -28,15 +33,18 @@ export declare class HSelect extends PhoenixLightLitElement {
28
33
  private _searchValue;
29
34
  private _selectController;
30
35
  private _$options;
31
- private _$dropdown;
32
- private _$search;
36
+ $dropdown: import("lit-html/directives/ref.js").Ref<HDropdown>;
37
+ $search: import("lit-html/directives/ref.js").Ref<HSelectSearch>;
33
38
  private _$optionsList;
34
39
  private _$dropdownContent;
35
- private _$dropdownToggler;
40
+ $dropdownToggler: import("lit-html/directives/ref.js").Ref<HDropdownToggler>;
36
41
  private _selectContext;
37
- private _listBoxController;
42
+ listBoxController: ListBoxKeyboardController;
43
+ private _selectTogglerKeyboardController;
38
44
  private _optionsObserver;
45
+ private _selectedOptionsAriaObserver;
39
46
  private $placeholder;
47
+ private $searchLabel;
40
48
  constructor();
41
49
  updated(changedProperties: PropertyValues): void;
42
50
  private _focusElementAfterSelectOpened;
@@ -47,6 +55,7 @@ export declare class HSelect extends PhoenixLightLitElement {
47
55
  private _setupEvents;
48
56
  private _handleOptionDeselect;
49
57
  private _updateOptionsView;
58
+ private _updateLabelAria;
50
59
  private _appendNewHTMLOption;
51
60
  updateOptionAriaAttribute($option: HOption): void;
52
61
  private _removeHTMLOptions;