@shoper/phoenix_design_system 1.15.11-1 → 1.15.11-11
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.
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js +16 -4
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js +3 -2
- package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js +1 -0
- package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +98 -0
- package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +1 -0
- package/build/cjs/packages/phoenix/src/components/form/select/select.js +29 -10
- package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +21 -22
- package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.d.ts +2 -0
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +16 -4
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js +3 -2
- package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js +1 -0
- package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.d.ts +15 -0
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +94 -0
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +1 -0
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.d.ts +8 -0
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js +3 -0
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +6 -2
- package/build/esm/packages/phoenix/src/components/form/select/select.js +29 -10
- package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.d.ts +1 -0
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +21 -22
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,7 +7,6 @@ var decorators = require('lit/decorators');
|
|
|
7
7
|
require('@dreamcommerce/utilities');
|
|
8
8
|
var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
9
9
|
var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
|
|
10
|
-
var btn_controller = require('../../controllers/btn_controller/btn_controller.js');
|
|
11
10
|
var global_constants = require('../../global_constants.js');
|
|
12
11
|
var dropdown_constants = require('./dropdown_constants.js');
|
|
13
12
|
var toggle_element_aria_controller = require('../../controllers/toggle_element_aria_controller/toggle_element_aria_controller.js');
|
|
@@ -17,6 +16,8 @@ exports.HDropdownToggler = class HDropdownToggler extends phoenix_light_lit_elem
|
|
|
17
16
|
super();
|
|
18
17
|
this.name = '';
|
|
19
18
|
this.ariaHasPopup = 'menu';
|
|
19
|
+
this.ariaControls = '';
|
|
20
|
+
this.role = 'button';
|
|
20
21
|
this._setupTogglerAria = () => {
|
|
21
22
|
this._$dropdown = this.closest(dropdown_constants.DROPDOWN_CONTAINER_NAME);
|
|
22
23
|
if (this._$dropdown.isOpened)
|
|
@@ -24,11 +25,14 @@ exports.HDropdownToggler = class HDropdownToggler extends phoenix_light_lit_elem
|
|
|
24
25
|
host: this,
|
|
25
26
|
initialAriaExpandedValue: this._$dropdown.isOpened()
|
|
26
27
|
});
|
|
28
|
+
this.setAttribute('role', this.role);
|
|
27
29
|
this.setAttribute('aria-haspopup', this.ariaHasPopup);
|
|
28
|
-
if (this._$dropdown.id)
|
|
29
|
-
this.setAttribute('aria-controls', this._$dropdown.id);
|
|
30
|
+
if (this.ariaControls || this._$dropdown.id)
|
|
31
|
+
this.setAttribute('aria-controls', this.ariaControls || this._$dropdown.id);
|
|
30
32
|
};
|
|
31
33
|
this._dispatchToggleDropdownEventWithKeyboard = (ev) => {
|
|
34
|
+
if (ev.key !== 'Enter' && ev.key !== ' ')
|
|
35
|
+
return;
|
|
32
36
|
ev.stopImmediatePropagation();
|
|
33
37
|
this._dispatchToggleDropdownEvent(ev);
|
|
34
38
|
};
|
|
@@ -47,7 +51,7 @@ exports.HDropdownToggler = class HDropdownToggler extends phoenix_light_lit_elem
|
|
|
47
51
|
connectedCallback() {
|
|
48
52
|
var _a;
|
|
49
53
|
super.connectedCallback();
|
|
50
|
-
this.
|
|
54
|
+
this.addEventListener('keydown', this._dispatchToggleDropdownEventWithKeyboard);
|
|
51
55
|
this._setupTogglerAria();
|
|
52
56
|
const hasToggleOnHover = (_a = this._$dropdown) === null || _a === void 0 ? void 0 : _a.hasAttribute(dropdown_constants.DROPDOWN_TOGGLE_ON_HOVER_ATTRIBUTE_NAME);
|
|
53
57
|
if (hasToggleOnHover) {
|
|
@@ -65,6 +69,14 @@ tslib_es6.__decorate([
|
|
|
65
69
|
decorators.property({ type: String, attribute: 'aria-haspopup' }),
|
|
66
70
|
tslib_es6.__metadata("design:type", Object)
|
|
67
71
|
], exports.HDropdownToggler.prototype, "ariaHasPopup", void 0);
|
|
72
|
+
tslib_es6.__decorate([
|
|
73
|
+
decorators.property({ type: String, attribute: 'aria-controls' }),
|
|
74
|
+
tslib_es6.__metadata("design:type", Object)
|
|
75
|
+
], exports.HDropdownToggler.prototype, "ariaControls", void 0);
|
|
76
|
+
tslib_es6.__decorate([
|
|
77
|
+
decorators.property({ type: String }),
|
|
78
|
+
tslib_es6.__metadata("design:type", Object)
|
|
79
|
+
], exports.HDropdownToggler.prototype, "role", void 0);
|
|
68
80
|
exports.HDropdownToggler = tslib_es6.__decorate([
|
|
69
81
|
phoenix_custom_element.phoenixCustomElement('h-dropdown-toggler'),
|
|
70
82
|
tslib_es6.__metadata("design:paramtypes", [])
|
|
@@ -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;"}
|
|
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;"}
|
package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js
CHANGED
|
@@ -9,6 +9,7 @@ require('@dreamcommerce/utilities');
|
|
|
9
9
|
var phoenix_light_lit_element = require('../../../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
10
10
|
var phoenix_custom_element = require('../../../../../core/decorators/phoenix_custom_element.js');
|
|
11
11
|
var select_components_constatns = require('../select_components_constatns.js');
|
|
12
|
+
var dropdown_constants = require('../../../../dropdown/dropdown_constants.js');
|
|
12
13
|
var debounce = require('../../../../../../../../external/lodash/debounce.js');
|
|
13
14
|
var select_search_constants = require('./select_search_constants.js');
|
|
14
15
|
|
|
@@ -52,8 +53,8 @@ exports.HSelectSearch = class HSelectSearch extends phoenix_light_lit_element.Ph
|
|
|
52
53
|
connectedCallback() {
|
|
53
54
|
super.connectedCallback();
|
|
54
55
|
this.classList.add(select_search_constants.SELECT_SEARCH_CSS_CLASSES.selectSearch);
|
|
55
|
-
|
|
56
|
-
this._$selectOptions =
|
|
56
|
+
const $selectOptionsContainer = this.closest(dropdown_constants.DROPDOWN_CONTENT_NAME);
|
|
57
|
+
this._$selectOptions = $selectOptionsContainer === null || $selectOptionsContainer === void 0 ? void 0 : $selectOptionsContainer.querySelector('h-options');
|
|
57
58
|
this.addEventListener('keydown', this._handleSearchKeydown);
|
|
58
59
|
}
|
|
59
60
|
render() {
|
package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,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;"}
|
|
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,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;"}
|
|
@@ -26,6 +26,7 @@ exports.HOptions = class HOptions extends phoenix_light_lit_element.PhoenixLight
|
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
this.setAttribute('role', 'listbox');
|
|
29
|
+
this.setAttribute('aria-labelledby', 'dsf');
|
|
29
30
|
this.addEventListener(select_components_constatns.SELECT_OPTION_EVENT_NAMES.clicked, this._dispatchClickedEvent);
|
|
30
31
|
this.addEventListener(select_components_constatns.SELECT_OPTION_EVENT_NAMES.updated, this._dispatchUpdatedEvent);
|
|
31
32
|
}
|
package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,kDAAsD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,kDAAsD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../../../../../../../../external/tslib/tslib.es6.js');
|
|
6
|
+
require('lit');
|
|
7
|
+
var utilities = 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
|
+
const $firstOption = this._getAvailableOptions()[0];
|
|
46
|
+
if ($firstOption)
|
|
47
|
+
this._navigate($firstOption);
|
|
48
|
+
};
|
|
49
|
+
this._openSelectAndGoToLastElement = async (event) => {
|
|
50
|
+
var _a;
|
|
51
|
+
event.preventDefault();
|
|
52
|
+
await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
53
|
+
const $availableOptions = this._getAvailableOptions();
|
|
54
|
+
const $lastOption = $availableOptions[$availableOptions.length - 1];
|
|
55
|
+
if ($lastOption)
|
|
56
|
+
this._navigate($lastOption);
|
|
57
|
+
};
|
|
58
|
+
this._openSelectAndGoToMatchedElement = async (event) => {
|
|
59
|
+
var _a;
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
62
|
+
const $matchedOption = this._getAvailableOptions().find(($option) => { var _a; return (_a = $option.innerText) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith(event.key.toLowerCase()); });
|
|
63
|
+
if ($matchedOption)
|
|
64
|
+
this._navigate($matchedOption);
|
|
65
|
+
};
|
|
66
|
+
this._getAvailableOptions = () => {
|
|
67
|
+
return tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f").filter(($option) => {
|
|
68
|
+
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
this._findSelectedIndex = () => {
|
|
72
|
+
const selectedOptionIndex = this._getAvailableOptions().findIndex(($option) => $option.selected);
|
|
73
|
+
return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
|
|
74
|
+
};
|
|
75
|
+
this._navigate = ($newOption) => {
|
|
76
|
+
const $selectedOption = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f")[this._findSelectedIndex()];
|
|
77
|
+
utilities.UiDomUtils.makeUnnavigable($selectedOption);
|
|
78
|
+
const newOptionIndex = this._getAvailableOptions().findIndex(($option) => $newOption.value === $option.value);
|
|
79
|
+
tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").listBoxController.currentOptionIndex = newOptionIndex;
|
|
80
|
+
utilities.UiDomUtils.makeNavigable($newOption);
|
|
81
|
+
$newOption.focus();
|
|
82
|
+
};
|
|
83
|
+
tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController_host, host, "f");
|
|
84
|
+
tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$toggler, $toggler, "f");
|
|
85
|
+
tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$options, Array.from($list.querySelectorAll(listItemSelector)), "f");
|
|
86
|
+
tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").addController(this);
|
|
87
|
+
}
|
|
88
|
+
hostConnected() {
|
|
89
|
+
tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").addEventListener('keydown', this._handleKeyboardNavigation);
|
|
90
|
+
}
|
|
91
|
+
hostDisconnected() {
|
|
92
|
+
tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
_SelectTogglerKeyboardController_host = new WeakMap(), _SelectTogglerKeyboardController__$toggler = new WeakMap(), _SelectTogglerKeyboardController_currentOptionIndex = new WeakMap(), _SelectTogglerKeyboardController__$options = new WeakMap();
|
|
96
|
+
|
|
97
|
+
exports.SelectTogglerKeyboardController = SelectTogglerKeyboardController;
|
|
98
|
+
//# sourceMappingURL=select_toggler_keyboard_controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -18,6 +18,7 @@ var observable_directive = require('../../../directives/observable_directive.js'
|
|
|
18
18
|
var select_toggler = require('./components/toggler/select_toggler.js');
|
|
19
19
|
var ref_js = require('lit-html/directives/ref.js');
|
|
20
20
|
var context_provider_controller = require('../../../core/context/context_provider_controller.js');
|
|
21
|
+
var v4 = require('../../../../../../external/uuid/dist/esm-browser/v4.js');
|
|
21
22
|
var dropdown_content = require('../../dropdown/dropdown_content.js');
|
|
22
23
|
var dropdown_toggler = require('../../dropdown/dropdown_toggler.js');
|
|
23
24
|
var dropdown = require('../../dropdown/dropdown.js');
|
|
@@ -29,6 +30,7 @@ var select_utils = require('./select_utils.js');
|
|
|
29
30
|
var select_controller = require('./controllers/select_controller.js');
|
|
30
31
|
var select_option_mapper = require('./model/select_option_mapper.js');
|
|
31
32
|
var repeat = require('lit/directives/repeat');
|
|
33
|
+
var select_toggler_keyboard_controller = require('./controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js');
|
|
32
34
|
|
|
33
35
|
exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
34
36
|
constructor() {
|
|
@@ -41,13 +43,14 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
41
43
|
this.type = select_constants.SELECT_TYPES.select;
|
|
42
44
|
this.noDeselect = false;
|
|
43
45
|
this.ariaLabelledby = '';
|
|
46
|
+
this._selectOptionsId = v4['default']();
|
|
44
47
|
this._searchValue = '';
|
|
45
48
|
this._$options = new Map();
|
|
46
|
-
this
|
|
49
|
+
this.$dropdown = ref_js.createRef();
|
|
47
50
|
this.$search = ref_js.createRef();
|
|
48
51
|
this._$optionsList = ref_js.createRef();
|
|
49
52
|
this._$dropdownContent = ref_js.createRef();
|
|
50
|
-
this
|
|
53
|
+
this.$dropdownToggler = ref_js.createRef();
|
|
51
54
|
this._selectContext = new context_provider_controller.ContextProviderController(this);
|
|
52
55
|
this._updateOptions = () => {
|
|
53
56
|
const $options = this._getOptions();
|
|
@@ -132,11 +135,15 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
132
135
|
});
|
|
133
136
|
};
|
|
134
137
|
this._handleDropdownHidden = () => {
|
|
135
|
-
var _a, _b;
|
|
138
|
+
var _a, _b, _c;
|
|
136
139
|
this._searchValue = '';
|
|
137
140
|
this.opened = false;
|
|
138
|
-
(_a = this
|
|
139
|
-
|
|
141
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', '');
|
|
142
|
+
const isBodyActive = document.activeElement === document.body;
|
|
143
|
+
const isInnerElementActive = (_b = this._$dropdownContent.value) === null || _b === void 0 ? void 0 : _b.contains(document.activeElement);
|
|
144
|
+
if (isInnerElementActive || isBodyActive) {
|
|
145
|
+
(_c = this.$dropdownToggler.value) === null || _c === void 0 ? void 0 : _c.focus();
|
|
146
|
+
}
|
|
140
147
|
};
|
|
141
148
|
this._manageSelectFocusAria = (ev) => {
|
|
142
149
|
var _a;
|
|
@@ -145,14 +152,14 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
145
152
|
return;
|
|
146
153
|
const optionId = $target.id;
|
|
147
154
|
if (optionId) {
|
|
148
|
-
(_a = this
|
|
155
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', optionId);
|
|
149
156
|
}
|
|
150
157
|
};
|
|
151
158
|
this._closeSelect = () => {
|
|
152
159
|
var _a;
|
|
153
160
|
if (!this.opened)
|
|
154
161
|
return;
|
|
155
|
-
(_a = this
|
|
162
|
+
(_a = this.$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
|
|
156
163
|
};
|
|
157
164
|
this._clearOptions = () => {
|
|
158
165
|
this._selectController.deselectAll();
|
|
@@ -196,7 +203,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
196
203
|
return Array.from(this._$options.values());
|
|
197
204
|
}
|
|
198
205
|
updated(changedProperties) {
|
|
199
|
-
var _a;
|
|
206
|
+
var _a, _b;
|
|
200
207
|
super.updated(changedProperties);
|
|
201
208
|
if (changedProperties.has('opened')) {
|
|
202
209
|
if (this.opened) {
|
|
@@ -220,6 +227,14 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
220
227
|
if (this.listBoxController) {
|
|
221
228
|
this.listBoxController.calculateSelectedOptionIndex();
|
|
222
229
|
}
|
|
230
|
+
if (this._$optionsList.value && this.$dropdownToggler.value) {
|
|
231
|
+
(_b = this._selectTogglerKeyboardController) === null || _b === void 0 ? void 0 : _b.hostDisconnected();
|
|
232
|
+
this._selectTogglerKeyboardController = new select_toggler_keyboard_controller.SelectTogglerKeyboardController({
|
|
233
|
+
host: this,
|
|
234
|
+
$toggler: this.$dropdownToggler.value,
|
|
235
|
+
$list: this._$optionsList.value
|
|
236
|
+
});
|
|
237
|
+
}
|
|
223
238
|
}
|
|
224
239
|
_focusElementAfterSelectOpened() {
|
|
225
240
|
var _a;
|
|
@@ -346,7 +361,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
346
361
|
const isSearchEnabled = !this.searchDisabled && options.length > select_constants.MIN_NUMBER_OF_OPTIONS_TO_SHOW_SEARCH;
|
|
347
362
|
return lit.html `
|
|
348
363
|
<h-dropdown
|
|
349
|
-
${ref_js.ref(this
|
|
364
|
+
${ref_js.ref(this.$dropdown)}
|
|
350
365
|
@showed=${() => (this.opened = true)}
|
|
351
366
|
@hidden=${this._handleDropdownHidden}
|
|
352
367
|
name="${this.controlName}"
|
|
@@ -356,7 +371,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
356
371
|
no-autofocus
|
|
357
372
|
>
|
|
358
373
|
<h-dropdown-toggler
|
|
359
|
-
${ref_js.ref(this
|
|
374
|
+
${ref_js.ref(this.$dropdownToggler)}
|
|
360
375
|
name="${this.controlName}"
|
|
361
376
|
validation-container
|
|
362
377
|
aria-haspopup="listbox"
|
|
@@ -364,6 +379,8 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
364
379
|
aria-required="${this.required ? 'true' : 'false'}"
|
|
365
380
|
aria-activedescendant
|
|
366
381
|
aria-labelledby="${this.ariaLabelledby}"
|
|
382
|
+
role="combobox"
|
|
383
|
+
aria-controls="${this._selectOptionsId}"
|
|
367
384
|
>
|
|
368
385
|
${this.getSlot(select_constants.SELECT_SLOT_NAMES.toggler)}
|
|
369
386
|
</h-dropdown-toggler>
|
|
@@ -389,6 +406,8 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
389
406
|
|
|
390
407
|
<h-options
|
|
391
408
|
class="${select_constants.SELECT_CSS_CLASSES.selectOptions} ${this._searchNoResult() ? select_constants.SELECT_CSS_CLASSES.selectOptionsEmpty : ''}"
|
|
409
|
+
aria-labelledby="${this.ariaLabelledby}"
|
|
410
|
+
id="${this._selectOptionsId}"
|
|
392
411
|
${ref_js.ref(this._$optionsList)}
|
|
393
412
|
@optionClicked=${this._handleOptionClicked}
|
|
394
413
|
@optionUpdated=${this._handleOptionUpdated}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,wDAA4D;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -7,12 +7,11 @@ require('lit');
|
|
|
7
7
|
var utilities = require('@dreamcommerce/utilities');
|
|
8
8
|
var list_box_controller_constants = require('./list_box_controller_constants.js');
|
|
9
9
|
|
|
10
|
-
var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list,
|
|
10
|
+
var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
|
|
11
11
|
class ListBoxKeyboardController {
|
|
12
12
|
constructor({ host, $list, listItemSelector = '[role="option"]', orientation = list_box_controller_constants.LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS.vertical }) {
|
|
13
13
|
_ListBoxKeyboardController_host.set(this, void 0);
|
|
14
14
|
_ListBoxKeyboardController__$list.set(this, void 0);
|
|
15
|
-
_ListBoxKeyboardController_currentOptionIndex.set(this, void 0);
|
|
16
15
|
_ListBoxKeyboardController__$options.set(this, void 0);
|
|
17
16
|
_ListBoxKeyboardController_listItemSelector.set(this, void 0);
|
|
18
17
|
_ListBoxKeyboardController_keys.set(this, void 0);
|
|
@@ -34,13 +33,13 @@ class ListBoxKeyboardController {
|
|
|
34
33
|
if (newOptionIndex === undefined) {
|
|
35
34
|
newOptionIndex = this._findCurrentIndex();
|
|
36
35
|
}
|
|
37
|
-
if (newOptionIndex ===
|
|
36
|
+
if (newOptionIndex === this.currentOptionIndex)
|
|
38
37
|
return;
|
|
39
38
|
if (prevOptionIndex !== undefined) {
|
|
40
39
|
const $prevOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
|
|
41
40
|
$prevOption && utilities.UiDomUtils.makeUnnavigable($prevOption);
|
|
42
41
|
}
|
|
43
|
-
|
|
42
|
+
this.currentOptionIndex = newOptionIndex;
|
|
44
43
|
const $focusedOption = $availableOptions[newOptionIndex];
|
|
45
44
|
if ($focusedOption) {
|
|
46
45
|
utilities.UiDomUtils.makeNavigable($focusedOption);
|
|
@@ -63,7 +62,7 @@ class ListBoxKeyboardController {
|
|
|
63
62
|
};
|
|
64
63
|
this.calculateSelectedOptionIndex = () => {
|
|
65
64
|
const selectedOptionIndex = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
|
|
66
|
-
|
|
65
|
+
this.currentOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
|
|
67
66
|
};
|
|
68
67
|
tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
|
|
69
68
|
tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
|
|
@@ -78,54 +77,54 @@ class ListBoxKeyboardController {
|
|
|
78
77
|
tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
|
|
79
78
|
if (event.target !== tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
|
|
80
79
|
return;
|
|
81
|
-
if (
|
|
80
|
+
if (this.currentOptionIndex === undefined)
|
|
82
81
|
return;
|
|
83
|
-
const $prevOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[
|
|
82
|
+
const $prevOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[this.currentOptionIndex];
|
|
84
83
|
utilities.UiDomUtils.makeUnnavigable($prevOption);
|
|
85
|
-
|
|
84
|
+
this.currentOptionIndex = undefined;
|
|
86
85
|
});
|
|
87
86
|
tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").forEach(($option) => utilities.UiDomUtils.makeUnnavigable($option));
|
|
88
87
|
}
|
|
89
88
|
_getPrevOptionIndex() {
|
|
90
|
-
if (
|
|
89
|
+
if (this.currentOptionIndex === undefined)
|
|
91
90
|
return undefined;
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
94
|
-
if (
|
|
95
|
-
return
|
|
91
|
+
if (this.currentOptionIndex <= 0)
|
|
92
|
+
return this.currentOptionIndex;
|
|
93
|
+
if (this.currentOptionIndex <= 0)
|
|
94
|
+
return this.currentOptionIndex;
|
|
96
95
|
const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
|
|
97
96
|
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
98
97
|
});
|
|
99
|
-
if (!!$availableOptions[
|
|
100
|
-
return
|
|
98
|
+
if (!!$availableOptions[this.currentOptionIndex - 1])
|
|
99
|
+
return this.currentOptionIndex - 1;
|
|
101
100
|
// bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
|
|
102
101
|
const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
|
|
103
102
|
if (newIndexOfCurrentlySelectedOption)
|
|
104
103
|
return newIndexOfCurrentlySelectedOption - 1;
|
|
105
|
-
return
|
|
104
|
+
return this.currentOptionIndex - 1;
|
|
106
105
|
}
|
|
107
106
|
_getNextOptionIndex() {
|
|
108
|
-
if (
|
|
107
|
+
if (this.currentOptionIndex === undefined)
|
|
109
108
|
return undefined;
|
|
110
109
|
const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
|
|
111
110
|
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
112
111
|
});
|
|
113
|
-
if (
|
|
114
|
-
return
|
|
115
|
-
if (
|
|
112
|
+
if (this.currentOptionIndex === $availableOptions.length - 1)
|
|
113
|
+
return this.currentOptionIndex;
|
|
114
|
+
if (this.currentOptionIndex > $availableOptions.length - 1) {
|
|
116
115
|
// bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
|
|
117
116
|
const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
|
|
118
117
|
if (newIndexOfCurrentlySelectedOption)
|
|
119
118
|
return newIndexOfCurrentlySelectedOption + 1;
|
|
120
119
|
return 0;
|
|
121
120
|
}
|
|
122
|
-
return
|
|
121
|
+
return this.currentOptionIndex + 1;
|
|
123
122
|
}
|
|
124
123
|
hostDisconnected() {
|
|
125
124
|
tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
|
-
_ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(),
|
|
127
|
+
_ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
|
|
129
128
|
|
|
130
129
|
exports.ListBoxKeyboardController = ListBoxKeyboardController;
|
|
131
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}
|
|
@@ -2,6 +2,8 @@ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/pho
|
|
|
2
2
|
export declare class HDropdownToggler extends PhoenixLightLitElement {
|
|
3
3
|
name: string;
|
|
4
4
|
ariaHasPopup: string;
|
|
5
|
+
ariaControls: string;
|
|
6
|
+
role: string;
|
|
5
7
|
private _btnController;
|
|
6
8
|
private _toggleElementAriaController;
|
|
7
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';
|
|
@@ -13,6 +12,8 @@ let HDropdownToggler = class HDropdownToggler extends PhoenixLightLitElement {
|
|
|
13
12
|
super();
|
|
14
13
|
this.name = '';
|
|
15
14
|
this.ariaHasPopup = 'menu';
|
|
15
|
+
this.ariaControls = '';
|
|
16
|
+
this.role = 'button';
|
|
16
17
|
this._setupTogglerAria = () => {
|
|
17
18
|
this._$dropdown = this.closest(DROPDOWN_CONTAINER_NAME);
|
|
18
19
|
if (this._$dropdown.isOpened)
|
|
@@ -20,11 +21,14 @@ let HDropdownToggler = class HDropdownToggler extends PhoenixLightLitElement {
|
|
|
20
21
|
host: this,
|
|
21
22
|
initialAriaExpandedValue: this._$dropdown.isOpened()
|
|
22
23
|
});
|
|
24
|
+
this.setAttribute('role', this.role);
|
|
23
25
|
this.setAttribute('aria-haspopup', this.ariaHasPopup);
|
|
24
|
-
if (this._$dropdown.id)
|
|
25
|
-
this.setAttribute('aria-controls', this._$dropdown.id);
|
|
26
|
+
if (this.ariaControls || this._$dropdown.id)
|
|
27
|
+
this.setAttribute('aria-controls', this.ariaControls || this._$dropdown.id);
|
|
26
28
|
};
|
|
27
29
|
this._dispatchToggleDropdownEventWithKeyboard = (ev) => {
|
|
30
|
+
if (ev.key !== 'Enter' && ev.key !== ' ')
|
|
31
|
+
return;
|
|
28
32
|
ev.stopImmediatePropagation();
|
|
29
33
|
this._dispatchToggleDropdownEvent(ev);
|
|
30
34
|
};
|
|
@@ -43,7 +47,7 @@ let HDropdownToggler = class HDropdownToggler extends PhoenixLightLitElement {
|
|
|
43
47
|
connectedCallback() {
|
|
44
48
|
var _a;
|
|
45
49
|
super.connectedCallback();
|
|
46
|
-
this.
|
|
50
|
+
this.addEventListener('keydown', this._dispatchToggleDropdownEventWithKeyboard);
|
|
47
51
|
this._setupTogglerAria();
|
|
48
52
|
const hasToggleOnHover = (_a = this._$dropdown) === null || _a === void 0 ? void 0 : _a.hasAttribute(DROPDOWN_TOGGLE_ON_HOVER_ATTRIBUTE_NAME);
|
|
49
53
|
if (hasToggleOnHover) {
|
|
@@ -61,6 +65,14 @@ __decorate([
|
|
|
61
65
|
property({ type: String, attribute: 'aria-haspopup' }),
|
|
62
66
|
__metadata("design:type", Object)
|
|
63
67
|
], HDropdownToggler.prototype, "ariaHasPopup", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
property({ type: String, attribute: 'aria-controls' }),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], HDropdownToggler.prototype, "ariaControls", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
property({ type: String }),
|
|
74
|
+
__metadata("design:type", Object)
|
|
75
|
+
], HDropdownToggler.prototype, "role", void 0);
|
|
64
76
|
HDropdownToggler = __decorate([
|
|
65
77
|
phoenixCustomElement('h-dropdown-toggler'),
|
|
66
78
|
__metadata("design:paramtypes", [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
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;"}
|
package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js
CHANGED
|
@@ -5,6 +5,7 @@ import '@dreamcommerce/utilities';
|
|
|
5
5
|
import { PhoenixLightLitElement } from '../../../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
6
6
|
import { phoenixCustomElement } from '../../../../../core/decorators/phoenix_custom_element.js';
|
|
7
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';
|
|
8
9
|
import debounce_1 from '../../../../../../../../external/lodash/debounce.js';
|
|
9
10
|
import { SELECT_SEARCH_CSS_CLASSES } from './select_search_constants.js';
|
|
10
11
|
|
|
@@ -48,8 +49,8 @@ let HSelectSearch = class HSelectSearch extends PhoenixLightLitElement {
|
|
|
48
49
|
connectedCallback() {
|
|
49
50
|
super.connectedCallback();
|
|
50
51
|
this.classList.add(SELECT_SEARCH_CSS_CLASSES.selectSearch);
|
|
51
|
-
|
|
52
|
-
this._$selectOptions =
|
|
52
|
+
const $selectOptionsContainer = this.closest(DROPDOWN_CONTENT_NAME);
|
|
53
|
+
this._$selectOptions = $selectOptionsContainer === null || $selectOptionsContainer === void 0 ? void 0 : $selectOptionsContainer.querySelector('h-options');
|
|
53
54
|
this.addEventListener('keydown', this._handleSearchKeydown);
|
|
54
55
|
}
|
|
55
56
|
render() {
|
package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;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
|
+
{"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;"}
|
|
@@ -22,6 +22,7 @@ let HOptions = class HOptions extends PhoenixLightLitElement {
|
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
this.setAttribute('role', 'listbox');
|
|
25
|
+
this.setAttribute('aria-labelledby', 'dsf');
|
|
25
26
|
this.addEventListener(SELECT_OPTION_EVENT_NAMES.clicked, this._dispatchClickedEvent);
|
|
26
27
|
this.addEventListener(SELECT_OPTION_EVENT_NAMES.updated, this._dispatchUpdatedEvent);
|
|
27
28
|
}
|
package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js.map
CHANGED
|
@@ -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;"}
|
|
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;"}
|
|
@@ -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 @@
|
|
|
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,4 +1,6 @@
|
|
|
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";
|
|
3
5
|
import { HSelectSearch } from "./components/search/select_search";
|
|
4
6
|
import { ListBoxKeyboardController } from "../../../controllers/list_box_controller/list_box_keyboard_controller";
|
|
@@ -21,6 +23,7 @@ export declare class HSelect extends PhoenixLightLitElement {
|
|
|
21
23
|
optionsList?: TSelectOption[];
|
|
22
24
|
noDeselect: boolean;
|
|
23
25
|
ariaLabelledby: string;
|
|
26
|
+
private _selectOptionsId;
|
|
24
27
|
get selectedIndex(): number;
|
|
25
28
|
set selectedIndex(index: number);
|
|
26
29
|
get selectedOptions(): (HOption | undefined)[];
|
|
@@ -30,13 +33,14 @@ export declare class HSelect extends PhoenixLightLitElement {
|
|
|
30
33
|
private _searchValue;
|
|
31
34
|
private _selectController;
|
|
32
35
|
private _$options;
|
|
33
|
-
|
|
36
|
+
$dropdown: import("lit-html/directives/ref.js").Ref<HDropdown>;
|
|
34
37
|
$search: import("lit-html/directives/ref.js").Ref<HSelectSearch>;
|
|
35
38
|
private _$optionsList;
|
|
36
39
|
private _$dropdownContent;
|
|
37
|
-
|
|
40
|
+
$dropdownToggler: import("lit-html/directives/ref.js").Ref<HDropdownToggler>;
|
|
38
41
|
private _selectContext;
|
|
39
42
|
listBoxController: ListBoxKeyboardController;
|
|
43
|
+
private _selectTogglerKeyboardController;
|
|
40
44
|
private _optionsObserver;
|
|
41
45
|
private _selectedOptionsAriaObserver;
|
|
42
46
|
private $placeholder;
|
|
@@ -14,6 +14,7 @@ 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';
|
|
17
18
|
import { HDropdownContent } from '../../dropdown/dropdown_content.js';
|
|
18
19
|
import { HDropdownToggler } from '../../dropdown/dropdown_toggler.js';
|
|
19
20
|
import { HDropdown } from '../../dropdown/dropdown.js';
|
|
@@ -25,6 +26,7 @@ import { SelectControlUtils } from './select_utils.js';
|
|
|
25
26
|
import { SelectController } from './controllers/select_controller.js';
|
|
26
27
|
import { SelectOptionMapper } from './model/select_option_mapper.js';
|
|
27
28
|
import { repeat } from 'lit/directives/repeat';
|
|
29
|
+
import { SelectTogglerKeyboardController } from './controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js';
|
|
28
30
|
|
|
29
31
|
let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
30
32
|
constructor() {
|
|
@@ -37,13 +39,14 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
37
39
|
this.type = SELECT_TYPES.select;
|
|
38
40
|
this.noDeselect = false;
|
|
39
41
|
this.ariaLabelledby = '';
|
|
42
|
+
this._selectOptionsId = v4();
|
|
40
43
|
this._searchValue = '';
|
|
41
44
|
this._$options = new Map();
|
|
42
|
-
this
|
|
45
|
+
this.$dropdown = createRef();
|
|
43
46
|
this.$search = createRef();
|
|
44
47
|
this._$optionsList = createRef();
|
|
45
48
|
this._$dropdownContent = createRef();
|
|
46
|
-
this
|
|
49
|
+
this.$dropdownToggler = createRef();
|
|
47
50
|
this._selectContext = new ContextProviderController(this);
|
|
48
51
|
this._updateOptions = () => {
|
|
49
52
|
const $options = this._getOptions();
|
|
@@ -128,11 +131,15 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
128
131
|
});
|
|
129
132
|
};
|
|
130
133
|
this._handleDropdownHidden = () => {
|
|
131
|
-
var _a, _b;
|
|
134
|
+
var _a, _b, _c;
|
|
132
135
|
this._searchValue = '';
|
|
133
136
|
this.opened = false;
|
|
134
|
-
(_a = this
|
|
135
|
-
|
|
137
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('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
|
+
}
|
|
136
143
|
};
|
|
137
144
|
this._manageSelectFocusAria = (ev) => {
|
|
138
145
|
var _a;
|
|
@@ -141,14 +148,14 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
141
148
|
return;
|
|
142
149
|
const optionId = $target.id;
|
|
143
150
|
if (optionId) {
|
|
144
|
-
(_a = this
|
|
151
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', optionId);
|
|
145
152
|
}
|
|
146
153
|
};
|
|
147
154
|
this._closeSelect = () => {
|
|
148
155
|
var _a;
|
|
149
156
|
if (!this.opened)
|
|
150
157
|
return;
|
|
151
|
-
(_a = this
|
|
158
|
+
(_a = this.$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
|
|
152
159
|
};
|
|
153
160
|
this._clearOptions = () => {
|
|
154
161
|
this._selectController.deselectAll();
|
|
@@ -192,7 +199,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
192
199
|
return Array.from(this._$options.values());
|
|
193
200
|
}
|
|
194
201
|
updated(changedProperties) {
|
|
195
|
-
var _a;
|
|
202
|
+
var _a, _b;
|
|
196
203
|
super.updated(changedProperties);
|
|
197
204
|
if (changedProperties.has('opened')) {
|
|
198
205
|
if (this.opened) {
|
|
@@ -216,6 +223,14 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
216
223
|
if (this.listBoxController) {
|
|
217
224
|
this.listBoxController.calculateSelectedOptionIndex();
|
|
218
225
|
}
|
|
226
|
+
if (this._$optionsList.value && this.$dropdownToggler.value) {
|
|
227
|
+
(_b = this._selectTogglerKeyboardController) === null || _b === void 0 ? void 0 : _b.hostDisconnected();
|
|
228
|
+
this._selectTogglerKeyboardController = new SelectTogglerKeyboardController({
|
|
229
|
+
host: this,
|
|
230
|
+
$toggler: this.$dropdownToggler.value,
|
|
231
|
+
$list: this._$optionsList.value
|
|
232
|
+
});
|
|
233
|
+
}
|
|
219
234
|
}
|
|
220
235
|
_focusElementAfterSelectOpened() {
|
|
221
236
|
var _a;
|
|
@@ -342,7 +357,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
342
357
|
const isSearchEnabled = !this.searchDisabled && options.length > MIN_NUMBER_OF_OPTIONS_TO_SHOW_SEARCH;
|
|
343
358
|
return html `
|
|
344
359
|
<h-dropdown
|
|
345
|
-
${ref(this
|
|
360
|
+
${ref(this.$dropdown)}
|
|
346
361
|
@showed=${() => (this.opened = true)}
|
|
347
362
|
@hidden=${this._handleDropdownHidden}
|
|
348
363
|
name="${this.controlName}"
|
|
@@ -352,7 +367,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
352
367
|
no-autofocus
|
|
353
368
|
>
|
|
354
369
|
<h-dropdown-toggler
|
|
355
|
-
${ref(this
|
|
370
|
+
${ref(this.$dropdownToggler)}
|
|
356
371
|
name="${this.controlName}"
|
|
357
372
|
validation-container
|
|
358
373
|
aria-haspopup="listbox"
|
|
@@ -360,6 +375,8 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
360
375
|
aria-required="${this.required ? 'true' : 'false'}"
|
|
361
376
|
aria-activedescendant
|
|
362
377
|
aria-labelledby="${this.ariaLabelledby}"
|
|
378
|
+
role="combobox"
|
|
379
|
+
aria-controls="${this._selectOptionsId}"
|
|
363
380
|
>
|
|
364
381
|
${this.getSlot(SELECT_SLOT_NAMES.toggler)}
|
|
365
382
|
</h-dropdown-toggler>
|
|
@@ -385,6 +402,8 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
385
402
|
|
|
386
403
|
<h-options
|
|
387
404
|
class="${SELECT_CSS_CLASSES.selectOptions} ${this._searchNoResult() ? SELECT_CSS_CLASSES.selectOptionsEmpty : ''}"
|
|
405
|
+
aria-labelledby="${this.ariaLabelledby}"
|
|
406
|
+
id="${this._selectOptionsId}"
|
|
388
407
|
${ref(this._$optionsList)}
|
|
389
408
|
@optionClicked=${this._handleOptionClicked}
|
|
390
409
|
@optionUpdated=${this._handleOptionUpdated}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,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;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IListboxController, TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
|
|
2
2
|
export declare class ListBoxKeyboardController implements IListboxController {
|
|
3
3
|
#private;
|
|
4
|
+
currentOptionIndex: number | undefined;
|
|
4
5
|
constructor({ host, $list, listItemSelector, orientation }: TListBoxKeyboardControllerConstructorOptions);
|
|
5
6
|
hostConnected(): void;
|
|
6
7
|
private _handleKeyboardNavigation;
|
|
@@ -3,12 +3,11 @@ import 'lit';
|
|
|
3
3
|
import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
4
4
|
import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from './list_box_controller_constants.js';
|
|
5
5
|
|
|
6
|
-
var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list,
|
|
6
|
+
var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
|
|
7
7
|
class ListBoxKeyboardController {
|
|
8
8
|
constructor({ host, $list, listItemSelector = '[role="option"]', orientation = LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS.vertical }) {
|
|
9
9
|
_ListBoxKeyboardController_host.set(this, void 0);
|
|
10
10
|
_ListBoxKeyboardController__$list.set(this, void 0);
|
|
11
|
-
_ListBoxKeyboardController_currentOptionIndex.set(this, void 0);
|
|
12
11
|
_ListBoxKeyboardController__$options.set(this, void 0);
|
|
13
12
|
_ListBoxKeyboardController_listItemSelector.set(this, void 0);
|
|
14
13
|
_ListBoxKeyboardController_keys.set(this, void 0);
|
|
@@ -30,13 +29,13 @@ class ListBoxKeyboardController {
|
|
|
30
29
|
if (newOptionIndex === undefined) {
|
|
31
30
|
newOptionIndex = this._findCurrentIndex();
|
|
32
31
|
}
|
|
33
|
-
if (newOptionIndex ===
|
|
32
|
+
if (newOptionIndex === this.currentOptionIndex)
|
|
34
33
|
return;
|
|
35
34
|
if (prevOptionIndex !== undefined) {
|
|
36
35
|
const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
|
|
37
36
|
$prevOption && UiDomUtils.makeUnnavigable($prevOption);
|
|
38
37
|
}
|
|
39
|
-
|
|
38
|
+
this.currentOptionIndex = newOptionIndex;
|
|
40
39
|
const $focusedOption = $availableOptions[newOptionIndex];
|
|
41
40
|
if ($focusedOption) {
|
|
42
41
|
UiDomUtils.makeNavigable($focusedOption);
|
|
@@ -59,7 +58,7 @@ class ListBoxKeyboardController {
|
|
|
59
58
|
};
|
|
60
59
|
this.calculateSelectedOptionIndex = () => {
|
|
61
60
|
const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
|
|
62
|
-
|
|
61
|
+
this.currentOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
|
|
63
62
|
};
|
|
64
63
|
__classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
|
|
65
64
|
__classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
|
|
@@ -74,54 +73,54 @@ class ListBoxKeyboardController {
|
|
|
74
73
|
__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
|
|
75
74
|
if (event.target !== __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
|
|
76
75
|
return;
|
|
77
|
-
if (
|
|
76
|
+
if (this.currentOptionIndex === undefined)
|
|
78
77
|
return;
|
|
79
|
-
const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[
|
|
78
|
+
const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[this.currentOptionIndex];
|
|
80
79
|
UiDomUtils.makeUnnavigable($prevOption);
|
|
81
|
-
|
|
80
|
+
this.currentOptionIndex = undefined;
|
|
82
81
|
});
|
|
83
82
|
__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").forEach(($option) => UiDomUtils.makeUnnavigable($option));
|
|
84
83
|
}
|
|
85
84
|
_getPrevOptionIndex() {
|
|
86
|
-
if (
|
|
85
|
+
if (this.currentOptionIndex === undefined)
|
|
87
86
|
return undefined;
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
90
|
-
if (
|
|
91
|
-
return
|
|
87
|
+
if (this.currentOptionIndex <= 0)
|
|
88
|
+
return this.currentOptionIndex;
|
|
89
|
+
if (this.currentOptionIndex <= 0)
|
|
90
|
+
return this.currentOptionIndex;
|
|
92
91
|
const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
|
|
93
92
|
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
94
93
|
});
|
|
95
|
-
if (!!$availableOptions[
|
|
96
|
-
return
|
|
94
|
+
if (!!$availableOptions[this.currentOptionIndex - 1])
|
|
95
|
+
return this.currentOptionIndex - 1;
|
|
97
96
|
// bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
|
|
98
97
|
const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
|
|
99
98
|
if (newIndexOfCurrentlySelectedOption)
|
|
100
99
|
return newIndexOfCurrentlySelectedOption - 1;
|
|
101
|
-
return
|
|
100
|
+
return this.currentOptionIndex - 1;
|
|
102
101
|
}
|
|
103
102
|
_getNextOptionIndex() {
|
|
104
|
-
if (
|
|
103
|
+
if (this.currentOptionIndex === undefined)
|
|
105
104
|
return undefined;
|
|
106
105
|
const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
|
|
107
106
|
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
108
107
|
});
|
|
109
|
-
if (
|
|
110
|
-
return
|
|
111
|
-
if (
|
|
108
|
+
if (this.currentOptionIndex === $availableOptions.length - 1)
|
|
109
|
+
return this.currentOptionIndex;
|
|
110
|
+
if (this.currentOptionIndex > $availableOptions.length - 1) {
|
|
112
111
|
// bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
|
|
113
112
|
const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
|
|
114
113
|
if (newIndexOfCurrentlySelectedOption)
|
|
115
114
|
return newIndexOfCurrentlySelectedOption + 1;
|
|
116
115
|
return 0;
|
|
117
116
|
}
|
|
118
|
-
return
|
|
117
|
+
return this.currentOptionIndex + 1;
|
|
119
118
|
}
|
|
120
119
|
hostDisconnected() {
|
|
121
120
|
__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
|
-
_ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(),
|
|
123
|
+
_ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
|
|
125
124
|
|
|
126
125
|
export { ListBoxKeyboardController };
|
|
127
126
|
//# 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;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
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-
|
|
5
|
+
"version": "1.15.11-11",
|
|
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",
|
|
33
|
+
"@dreamcommerce/utilities": "^1.20.1-0",
|
|
34
34
|
"@shoper/jest_config": "^0.0.0",
|
|
35
35
|
"@shoper/tsconfig": "^0.0.0",
|
|
36
36
|
"@splidejs/splide": "4.0.7",
|