@shoper/phoenix_design_system 1.15.11-36 → 1.15.11-37
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.js +9 -2
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js +23 -5
- 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 +31 -0
- 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 -2
- 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 +90 -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 +86 -21
- package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/base_message.js +0 -47
- package/build/cjs/packages/phoenix/src/components/messages/base_message.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js +0 -3
- package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/hints/hint.js +10 -0
- package/build/cjs/packages/phoenix/src/components/messages/hints/hint.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/tooltips/tooltip.js +10 -0
- package/build/cjs/packages/phoenix/src/components/messages/tooltips/tooltip.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js +0 -2
- package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js.map +1 -1
- package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +78 -38
- 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.d.ts +1 -0
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +9 -2
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.d.ts +3 -0
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +23 -5
- 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.d.ts +4 -0
- package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js +31 -0
- 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 -2
- 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 +14 -0
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +86 -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 +15 -5
- package/build/esm/packages/phoenix/src/components/form/select/select.js +86 -21
- package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message.d.ts +0 -9
- package/build/esm/packages/phoenix/src/components/messages/base_message.js +2 -49
- package/build/esm/packages/phoenix/src/components/messages/base_message.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message_constants.d.ts +0 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js +1 -3
- package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/hints/hint.d.ts +2 -0
- package/build/esm/packages/phoenix/src/components/messages/hints/hint.js +10 -0
- package/build/esm/packages/phoenix/src/components/messages/hints/hint.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.d.ts +2 -0
- package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.js +10 -0
- package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/portal/portal_constants.js +1 -2
- package/build/esm/packages/phoenix/src/components/portal/portal_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.d.ts +6 -2
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js +1 -0
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.d.ts +8 -3
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +78 -38
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,14 @@
|
|
|
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 _navigate;
|
|
13
|
+
hostDisconnected(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import 'lit';
|
|
3
|
+
import '@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
|
+
this._navigate(0);
|
|
42
|
+
};
|
|
43
|
+
this._openSelectAndGoToLastElement = async (event) => {
|
|
44
|
+
var _a;
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
await ((_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
47
|
+
const $availableOptions = this._getAvailableOptions();
|
|
48
|
+
this._navigate($availableOptions.length - 1);
|
|
49
|
+
};
|
|
50
|
+
this._openSelectAndGoToMatchedElement = async (event) => {
|
|
51
|
+
var _a;
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
await ((_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
54
|
+
const matchedOptionIndex = this._getAvailableOptions().findIndex(($option) => { var _a; return (_a = $option.innerText) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith(event.key.toLowerCase()); });
|
|
55
|
+
if (matchedOptionIndex)
|
|
56
|
+
this._navigate(matchedOptionIndex);
|
|
57
|
+
};
|
|
58
|
+
this._getAvailableOptions = () => {
|
|
59
|
+
return __classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f").filter(($option) => {
|
|
60
|
+
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
this._navigate = (newOptionIndex) => {
|
|
64
|
+
var _a;
|
|
65
|
+
const $newOption = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").options[newOptionIndex];
|
|
66
|
+
if (!$newOption)
|
|
67
|
+
return;
|
|
68
|
+
(_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', $newOption.id);
|
|
69
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").listBoxController.currentOptionIndex = newOptionIndex;
|
|
70
|
+
};
|
|
71
|
+
__classPrivateFieldSet(this, _SelectTogglerKeyboardController_host, host, "f");
|
|
72
|
+
__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$toggler, $toggler, "f");
|
|
73
|
+
__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$options, Array.from($list.querySelectorAll(listItemSelector)), "f");
|
|
74
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").addController(this);
|
|
75
|
+
}
|
|
76
|
+
hostConnected() {
|
|
77
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").addEventListener('keydown', this._handleKeyboardNavigation);
|
|
78
|
+
}
|
|
79
|
+
hostDisconnected() {
|
|
80
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
_SelectTogglerKeyboardController_host = new WeakMap(), _SelectTogglerKeyboardController__$toggler = new WeakMap(), _SelectTogglerKeyboardController_currentOptionIndex = new WeakMap(), _SelectTogglerKeyboardController__$options = new WeakMap();
|
|
84
|
+
|
|
85
|
+
export { SelectTogglerKeyboardController };
|
|
86
|
+
//# 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;"}
|
|
@@ -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,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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
40
|
+
$dropdownToggler: import("lit-html/directives/ref.js").Ref<HDropdownToggler>;
|
|
36
41
|
private _selectContext;
|
|
37
|
-
|
|
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;
|
|
@@ -55,6 +64,7 @@ export declare class HSelect extends PhoenixLightLitElement {
|
|
|
55
64
|
private _selectOption;
|
|
56
65
|
private _handleSearch;
|
|
57
66
|
private _handleDropdownHidden;
|
|
67
|
+
private _handleDropdownShowed;
|
|
58
68
|
private _manageSelectFocusAria;
|
|
59
69
|
private _closeSelect;
|
|
60
70
|
private _clearOptions;
|
|
@@ -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() {
|
|
@@ -36,14 +38,15 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
36
38
|
this.searchDisabled = false;
|
|
37
39
|
this.type = SELECT_TYPES.select;
|
|
38
40
|
this.noDeselect = false;
|
|
39
|
-
this.
|
|
41
|
+
this.assistiveTitleId = '';
|
|
42
|
+
this._selectOptionsId = v4();
|
|
40
43
|
this._searchValue = '';
|
|
41
44
|
this._$options = new Map();
|
|
42
|
-
this
|
|
43
|
-
this
|
|
45
|
+
this.$dropdown = createRef();
|
|
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();
|
|
@@ -101,6 +104,18 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
101
104
|
this.updateOptionAriaAttribute($option);
|
|
102
105
|
});
|
|
103
106
|
};
|
|
107
|
+
this._updateLabelAria = (options) => {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
if (!this.$searchLabel)
|
|
110
|
+
return;
|
|
111
|
+
(_a = this.$searchLabel.querySelector(`[id="value-label"]`)) === null || _a === void 0 ? void 0 : _a.remove();
|
|
112
|
+
this.$searchLabel.innerHTML = `
|
|
113
|
+
${(_b = this.$searchLabel) === null || _b === void 0 ? void 0 : _b.innerHTML}
|
|
114
|
+
<span id="value-label" class="sr-only">
|
|
115
|
+
${options.reduce((totalSelectedContent, currentOption) => (totalSelectedContent += currentOption.content), '')}
|
|
116
|
+
</span>
|
|
117
|
+
`;
|
|
118
|
+
};
|
|
104
119
|
this._handleOptionClicked = ({ detail }) => {
|
|
105
120
|
if (!(detail === null || detail === void 0 ? void 0 : detail.$option))
|
|
106
121
|
return;
|
|
@@ -116,10 +131,22 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
116
131
|
});
|
|
117
132
|
};
|
|
118
133
|
this._handleDropdownHidden = () => {
|
|
119
|
-
var _a;
|
|
134
|
+
var _a, _b, _c;
|
|
120
135
|
this._searchValue = '';
|
|
121
136
|
this.opened = false;
|
|
122
|
-
(_a = this
|
|
137
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.removeAttribute('aria-activedescendant');
|
|
138
|
+
const isBodyActive = document.activeElement === document.body;
|
|
139
|
+
const isInnerElementActive = (_b = this._$dropdownContent.value) === null || _b === void 0 ? void 0 : _b.contains(document.activeElement);
|
|
140
|
+
if (isInnerElementActive || isBodyActive) {
|
|
141
|
+
(_c = this.$dropdownToggler.value) === null || _c === void 0 ? void 0 : _c.focus();
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
this._handleDropdownShowed = () => {
|
|
145
|
+
var _a;
|
|
146
|
+
this.opened = true;
|
|
147
|
+
const $activeDescendant = this.options.find((option) => option.selected);
|
|
148
|
+
if ($activeDescendant)
|
|
149
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', $activeDescendant.id);
|
|
123
150
|
};
|
|
124
151
|
this._manageSelectFocusAria = (ev) => {
|
|
125
152
|
var _a;
|
|
@@ -128,14 +155,14 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
128
155
|
return;
|
|
129
156
|
const optionId = $target.id;
|
|
130
157
|
if (optionId) {
|
|
131
|
-
(_a = this
|
|
158
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', optionId);
|
|
132
159
|
}
|
|
133
160
|
};
|
|
134
161
|
this._closeSelect = () => {
|
|
135
162
|
var _a;
|
|
136
163
|
if (!this.opened)
|
|
137
164
|
return;
|
|
138
|
-
(_a = this
|
|
165
|
+
(_a = this.$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
|
|
139
166
|
};
|
|
140
167
|
this._clearOptions = () => {
|
|
141
168
|
this._selectController.deselectAll();
|
|
@@ -179,6 +206,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
179
206
|
return Array.from(this._$options.values());
|
|
180
207
|
}
|
|
181
208
|
updated(changedProperties) {
|
|
209
|
+
var _a, _b;
|
|
182
210
|
super.updated(changedProperties);
|
|
183
211
|
if (changedProperties.has('opened')) {
|
|
184
212
|
if (this.opened) {
|
|
@@ -192,28 +220,52 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
192
220
|
if (changedProperties.has('optionsList')) {
|
|
193
221
|
this._updateOptions();
|
|
194
222
|
}
|
|
195
|
-
if (this._$optionsList.value
|
|
196
|
-
this.
|
|
223
|
+
if (this._$optionsList.value) {
|
|
224
|
+
(_a = this.listBoxController) === null || _a === void 0 ? void 0 : _a.hostDisconnected();
|
|
225
|
+
this.listBoxController = new ListBoxKeyboardController({
|
|
197
226
|
host: this,
|
|
198
227
|
$list: this._$optionsList.value
|
|
199
228
|
});
|
|
229
|
+
}
|
|
230
|
+
if (this.listBoxController) {
|
|
231
|
+
this.listBoxController.calculateSelectedOptionIndex();
|
|
232
|
+
}
|
|
233
|
+
if (this._$optionsList.value && this.$dropdownToggler.value) {
|
|
234
|
+
(_b = this._selectTogglerKeyboardController) === null || _b === void 0 ? void 0 : _b.hostDisconnected();
|
|
235
|
+
this._selectTogglerKeyboardController = new SelectTogglerKeyboardController({
|
|
236
|
+
host: this,
|
|
237
|
+
$toggler: this.$dropdownToggler.value,
|
|
238
|
+
$list: this._$optionsList.value
|
|
239
|
+
});
|
|
240
|
+
}
|
|
200
241
|
}
|
|
201
242
|
_focusElementAfterSelectOpened() {
|
|
202
|
-
var _a
|
|
203
|
-
const $searchInput = (_a = this
|
|
204
|
-
$
|
|
243
|
+
var _a;
|
|
244
|
+
const $searchInput = (_a = this.$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
|
|
245
|
+
const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
|
|
246
|
+
const $firstOption = $options.find(($option) => {
|
|
247
|
+
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.getAttribute('hidden');
|
|
248
|
+
});
|
|
249
|
+
const $selectedOption = this.selectedOptions[0];
|
|
250
|
+
const $optionToFocus = $selectedOption || $firstOption;
|
|
251
|
+
$searchInput ? $searchInput.focus() : $optionToFocus === null || $optionToFocus === void 0 ? void 0 : $optionToFocus.focus();
|
|
205
252
|
}
|
|
206
253
|
connectedCallback() {
|
|
254
|
+
var _a;
|
|
207
255
|
super.connectedCallback();
|
|
208
256
|
this.classList.add(SELECT_CSS_CLASSES.select);
|
|
209
257
|
if (!this.searchDisabled) {
|
|
210
258
|
this.classList.add(SELECT_CSS_CLASSES.selectWithSearch);
|
|
211
259
|
}
|
|
260
|
+
this.$searchLabel = document.querySelector(`[id="${this.assistiveTitleId}"]`);
|
|
261
|
+
(_a = this.$searchLabel) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-hidden', 'true');
|
|
212
262
|
this._selectController = this.multiple ? new MultiSelectController({ host: this }) : new SelectController({ host: this });
|
|
213
263
|
this._selectContext.provide(SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
|
|
214
264
|
this._selectContext.provide(SELECT_CONTEXTS.isMultiselect, this.multiple);
|
|
215
265
|
this._optionsObserver = new Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
|
|
216
266
|
this._selectController.options$.subscribe(this._optionsObserver);
|
|
267
|
+
this._selectedOptionsAriaObserver = new Observer((selectedOptions) => this._updateLabelAria(selectedOptions));
|
|
268
|
+
this._selectController.selectedOptions$.subscribe(this._selectedOptionsAriaObserver);
|
|
217
269
|
this._updateOptions();
|
|
218
270
|
this._setupEvents();
|
|
219
271
|
}
|
|
@@ -243,6 +295,10 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
243
295
|
SelectControlUtils.appendHTMLOption($option, $list, position);
|
|
244
296
|
}
|
|
245
297
|
updateOptionAriaAttribute($option) {
|
|
298
|
+
if (!this.multiple) {
|
|
299
|
+
const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
|
|
300
|
+
$options.forEach(($option) => ($option.removeAttribute('aria-selected')));
|
|
301
|
+
}
|
|
246
302
|
$option.setAttribute(this.multiple ? 'aria-checked' : 'aria-selected', String($option.selected));
|
|
247
303
|
}
|
|
248
304
|
_removeHTMLOptions(optionsValues) {
|
|
@@ -252,6 +308,12 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
252
308
|
const option = this._selectController.getOption(value);
|
|
253
309
|
if (!option)
|
|
254
310
|
return;
|
|
311
|
+
const $selectedOption = this._$options.get(option.value);
|
|
312
|
+
const $selectedOptionLink = $selectedOption === null || $selectedOption === void 0 ? void 0 : $selectedOption.querySelector('a');
|
|
313
|
+
if ($selectedOptionLink) {
|
|
314
|
+
$selectedOptionLink.click();
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
255
317
|
this.noDeselect ? this._selectController.select(option) : this._selectController.toggle(option);
|
|
256
318
|
if (!this.multiple)
|
|
257
319
|
this._closeSelect();
|
|
@@ -302,23 +364,24 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
302
364
|
const isSearchEnabled = !this.searchDisabled && options.length > MIN_NUMBER_OF_OPTIONS_TO_SHOW_SEARCH;
|
|
303
365
|
return html `
|
|
304
366
|
<h-dropdown
|
|
305
|
-
${ref(this
|
|
306
|
-
@showed=${
|
|
367
|
+
${ref(this.$dropdown)}
|
|
368
|
+
@showed=${this._handleDropdownShowed}
|
|
307
369
|
@hidden=${this._handleDropdownHidden}
|
|
308
370
|
name="${this.controlName}"
|
|
309
371
|
offset=${this.offset}
|
|
310
372
|
content-width="full"
|
|
311
373
|
prevent-focus-trap
|
|
374
|
+
no-autofocus
|
|
312
375
|
>
|
|
313
376
|
<h-dropdown-toggler
|
|
314
|
-
${ref(this
|
|
377
|
+
${ref(this.$dropdownToggler)}
|
|
315
378
|
name="${this.controlName}"
|
|
316
379
|
validation-container
|
|
317
380
|
aria-haspopup="listbox"
|
|
318
381
|
role="combobox"
|
|
319
382
|
aria-required="${this.required ? 'true' : 'false'}"
|
|
320
|
-
|
|
321
|
-
aria-
|
|
383
|
+
role="combobox"
|
|
384
|
+
aria-controls="${this._selectOptionsId}"
|
|
322
385
|
>
|
|
323
386
|
${this.getSlot(SELECT_SLOT_NAMES.toggler)}
|
|
324
387
|
</h-dropdown-toggler>
|
|
@@ -336,7 +399,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
336
399
|
${isSearchEnabled
|
|
337
400
|
? html ` <h-select-search
|
|
338
401
|
class=${SELECT_CSS_CLASSES.selectSearch}
|
|
339
|
-
${ref(this
|
|
402
|
+
${ref(this.$search)}
|
|
340
403
|
.value=${this._searchValue}
|
|
341
404
|
@search=${this._handleSearch}
|
|
342
405
|
></h-select-search>`
|
|
@@ -344,6 +407,8 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
344
407
|
|
|
345
408
|
<h-options
|
|
346
409
|
class="${SELECT_CSS_CLASSES.selectOptions} ${this._searchNoResult() ? SELECT_CSS_CLASSES.selectOptionsEmpty : ''}"
|
|
410
|
+
aria-labelledby="${this.assistiveTitleId}"
|
|
411
|
+
id="${this._selectOptionsId}"
|
|
347
412
|
${ref(this._$optionsList)}
|
|
348
413
|
@optionClicked=${this._handleOptionClicked}
|
|
349
414
|
@optionUpdated=${this._handleOptionUpdated}
|
|
@@ -435,9 +500,9 @@ __decorate([
|
|
|
435
500
|
__metadata("design:type", Boolean)
|
|
436
501
|
], HSelect.prototype, "noDeselect", void 0);
|
|
437
502
|
__decorate([
|
|
438
|
-
property({ type: String, attribute: '
|
|
503
|
+
property({ type: String, attribute: 'assistive-title-id' }),
|
|
439
504
|
__metadata("design:type", String)
|
|
440
|
-
], HSelect.prototype, "
|
|
505
|
+
], HSelect.prototype, "assistiveTitleId", void 0);
|
|
441
506
|
__decorate([
|
|
442
507
|
state(),
|
|
443
508
|
__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IBaseMessage } from './base_message_types';
|
|
2
2
|
import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
|
|
3
3
|
import type { TDirection } from '@dreamcommerce/utilities';
|
|
4
|
-
import { PropertyValues, TemplateResult } from 'lit';
|
|
5
4
|
export declare class BaseMessage extends PhoenixLightLitElement implements IBaseMessage {
|
|
6
5
|
opened: boolean;
|
|
7
6
|
portalTarget: string;
|
|
@@ -9,7 +8,6 @@ export declare class BaseMessage extends PhoenixLightLitElement implements IBase
|
|
|
9
8
|
offset: number;
|
|
10
9
|
mouseonly: boolean;
|
|
11
10
|
tabindex: string;
|
|
12
|
-
private _messageId;
|
|
13
11
|
private _positionController;
|
|
14
12
|
private _clickOutsideController;
|
|
15
13
|
private _$messageContent;
|
|
@@ -18,18 +16,11 @@ export declare class BaseMessage extends PhoenixLightLitElement implements IBase
|
|
|
18
16
|
private _shouldDelayClosing;
|
|
19
17
|
private _closeTimeout;
|
|
20
18
|
private _messageComponentName;
|
|
21
|
-
private _$baseMessageContent?;
|
|
22
|
-
private _tooltipRef;
|
|
23
19
|
constructor();
|
|
24
20
|
connectedCallback(messageComponentName?: string): void;
|
|
25
|
-
firstUpdated(props: PropertyValues): void;
|
|
26
|
-
private _handleChildrenAriaAttributes;
|
|
27
21
|
private static _appendMessagePortal;
|
|
28
22
|
private _setupEventListeners;
|
|
29
23
|
protected _positionMessage: () => void;
|
|
30
24
|
open: () => void;
|
|
31
|
-
private _closeFromKeyboard;
|
|
32
25
|
close: () => void;
|
|
33
|
-
disconnectedCallback(): void;
|
|
34
|
-
protected render(): TemplateResult;
|
|
35
26
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { html } from 'lit';
|
|
3
2
|
import { property } from 'lit/decorators';
|
|
4
|
-
import { DIRECTIONS
|
|
3
|
+
import { DIRECTIONS } from '@dreamcommerce/utilities';
|
|
5
4
|
import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
6
|
-
import v4 from '../../../../../external/uuid/dist/esm-browser/v4.js';
|
|
7
5
|
import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP, PORTAL_TARGET_ATTRIBUTE_NAME } from '../portal/portal_constants.js';
|
|
8
6
|
import { ClickOutsideController } from '../../controllers/click_outside_controller/click_outside_controller.js';
|
|
9
7
|
import { RelativePositionController } from '../../controllers/relative_position_controller/relative_position_controller.js';
|
|
10
|
-
import { DEFAULT_MESSAGE_PORTAL_NAME, DEFAULT_MESSAGE_OFFSET,
|
|
11
|
-
import { createRef, ref } from 'lit/directives/ref';
|
|
8
|
+
import { DEFAULT_MESSAGE_PORTAL_NAME, DEFAULT_MESSAGE_OFFSET, MESSAGE_SHOW_DELAY_IN_MS, MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS, MESSAGE_REMOVED_CLASS_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS } from './base_message_constants.js';
|
|
12
9
|
|
|
13
10
|
class BaseMessage extends PhoenixLightLitElement {
|
|
14
11
|
constructor() {
|
|
@@ -19,22 +16,9 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
19
16
|
this.offset = DEFAULT_MESSAGE_OFFSET;
|
|
20
17
|
this.mouseonly = false;
|
|
21
18
|
this.tabindex = '-1';
|
|
22
|
-
this._messageId = v4();
|
|
23
|
-
this._tooltipRef = createRef();
|
|
24
|
-
this._handleChildrenAriaAttributes = () => {
|
|
25
|
-
[...this.children].forEach((child) => {
|
|
26
|
-
if (LIST_OF_MESSAGE_CHILDREN.includes(child.tagName.toLowerCase()) || this._tooltipRef.value === child)
|
|
27
|
-
return;
|
|
28
|
-
child.setAttribute('aria-describedby', `${child.getAttribute('aria-describedby') || ''} ${this._messageId}`);
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
19
|
this._setupEventListeners = () => {
|
|
32
|
-
var _a, _b;
|
|
33
20
|
this.addEventListener('mouseenter', this.open);
|
|
34
21
|
this.addEventListener('mouseleave', this.close);
|
|
35
|
-
this.addEventListener('keydown', this._closeFromKeyboard);
|
|
36
|
-
(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.open);
|
|
37
|
-
(_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this.close);
|
|
38
22
|
if (!this.mouseonly) {
|
|
39
23
|
this.addEventListener('focusin', this.open);
|
|
40
24
|
this.addEventListener('focusout', this.close);
|
|
@@ -55,13 +39,6 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
55
39
|
this.opened = true;
|
|
56
40
|
}, MESSAGE_SHOW_DELAY_IN_MS);
|
|
57
41
|
};
|
|
58
|
-
this._closeFromKeyboard = (ev) => {
|
|
59
|
-
if (ev.key !== 'Escape' || !this.opened)
|
|
60
|
-
return;
|
|
61
|
-
ev.preventDefault();
|
|
62
|
-
ev.stopPropagation();
|
|
63
|
-
this.close();
|
|
64
|
-
};
|
|
65
42
|
this.close = () => {
|
|
66
43
|
this._shouldDelayClosing = Date.now() - this._tooltipOpenTime > MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
|
|
67
44
|
clearTimeout(this._openTimeout);
|
|
@@ -102,14 +79,8 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
102
79
|
offset: this.offset
|
|
103
80
|
});
|
|
104
81
|
this.setAttribute('tabindex', this.tabindex);
|
|
105
|
-
if (!this._$baseMessageContent)
|
|
106
|
-
this._$baseMessageContent = [...this.children].find((child) => MESSAGE_CONTENT_ELEMENTS.includes(child.tagName.toLowerCase()));
|
|
107
82
|
this._setupEventListeners();
|
|
108
83
|
}
|
|
109
|
-
firstUpdated(props) {
|
|
110
|
-
super.firstUpdated(props);
|
|
111
|
-
this._handleChildrenAriaAttributes();
|
|
112
|
-
}
|
|
113
84
|
static _appendMessagePortal() {
|
|
114
85
|
const $messagePortalTarget = document.querySelector(`[name="${DEFAULT_MESSAGE_PORTAL_NAME}"]`);
|
|
115
86
|
if ($messagePortalTarget)
|
|
@@ -118,24 +89,6 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
118
89
|
$portalTarget.setAttribute(PORTAL_TARGET_NAME_PROP, DEFAULT_MESSAGE_PORTAL_NAME);
|
|
119
90
|
document.body.appendChild($portalTarget);
|
|
120
91
|
}
|
|
121
|
-
disconnectedCallback() {
|
|
122
|
-
var _a, _b;
|
|
123
|
-
super.disconnectedCallback();
|
|
124
|
-
(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.open);
|
|
125
|
-
(_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this.close);
|
|
126
|
-
}
|
|
127
|
-
render() {
|
|
128
|
-
var _a;
|
|
129
|
-
super.render();
|
|
130
|
-
return html `
|
|
131
|
-
<span ${ref(this._tooltipRef)} id="${this._messageId}" class="sr-only" role="tooltip">
|
|
132
|
-
${DomUtils.stripHTMLTags(((_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.innerHTML) || '')}
|
|
133
|
-
</span>
|
|
134
|
-
<h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
|
|
135
|
-
${this.getSlot(MESSAGE_CONTENT_SLOT_NAME)}
|
|
136
|
-
</h-portal>
|
|
137
|
-
`;
|
|
138
|
-
}
|
|
139
92
|
}
|
|
140
93
|
__decorate([
|
|
141
94
|
property({ type: Boolean, reflect: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -4,7 +4,6 @@ export declare const MESSAGE_REMOVED_CLASS_NAME = "removed";
|
|
|
4
4
|
export declare const DEFAULT_MESSAGE_OFFSET = 10;
|
|
5
5
|
export declare const MESSAGE_ELEMENTS: string[];
|
|
6
6
|
export declare const MESSAGE_CONTENT_ELEMENTS: string[];
|
|
7
|
-
export declare const LIST_OF_MESSAGE_CHILDREN: string[];
|
|
8
7
|
export declare const MESSAGE_SHOW_DELAY_IN_MS = 100;
|
|
9
8
|
export declare const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
|
|
10
9
|
export declare const MESSAGE_CLOSE_DELAY_IN_MS = 500;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PORTAL_COMPONENT_NAME } from '../portal/portal_constants.js';
|
|
2
1
|
import { HINT_CONTENT_ELEMENT_NAME } from './hints/hint_constants.js';
|
|
3
2
|
import { TOOLTIP_CONTENT_ELEMENT_NAME } from './tooltips/tooltip_constants.js';
|
|
4
3
|
|
|
@@ -7,10 +6,9 @@ const MESSAGE_CONTENT_SLOT_NAME = 'message-content';
|
|
|
7
6
|
const MESSAGE_REMOVED_CLASS_NAME = `removed`;
|
|
8
7
|
const DEFAULT_MESSAGE_OFFSET = 10;
|
|
9
8
|
const MESSAGE_CONTENT_ELEMENTS = [TOOLTIP_CONTENT_ELEMENT_NAME, HINT_CONTENT_ELEMENT_NAME];
|
|
10
|
-
const LIST_OF_MESSAGE_CHILDREN = [...MESSAGE_CONTENT_ELEMENTS, PORTAL_COMPONENT_NAME];
|
|
11
9
|
const MESSAGE_SHOW_DELAY_IN_MS = 100;
|
|
12
10
|
const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
|
|
13
11
|
const MESSAGE_CLOSE_DELAY_IN_MS = 500;
|
|
14
12
|
|
|
15
|
-
export { DEFAULT_MESSAGE_OFFSET, DEFAULT_MESSAGE_PORTAL_NAME,
|
|
13
|
+
export { DEFAULT_MESSAGE_OFFSET, DEFAULT_MESSAGE_PORTAL_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS, MESSAGE_CONTENT_SLOT_NAME, MESSAGE_REMOVED_CLASS_NAME, MESSAGE_SHOW_DELAY_IN_MS, MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS };
|
|
16
14
|
//# sourceMappingURL=base_message_constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import { phoenixCustomElement } from '../../../core/decorators/phoenix_custom_element.js';
|
|
3
|
+
import { html } from 'lit-html';
|
|
3
4
|
import { HINT_DEFAULT_OFFSET, HINT_CLASS_NAME, HINT_ELEMENT_NAME } from './hint_constants.js';
|
|
5
|
+
import { MESSAGE_CONTENT_SLOT_NAME } from '../base_message_constants.js';
|
|
4
6
|
import { BaseMessage } from '../base_message.js';
|
|
5
7
|
|
|
6
8
|
let HHint = class HHint extends BaseMessage {
|
|
@@ -12,6 +14,14 @@ let HHint = class HHint extends BaseMessage {
|
|
|
12
14
|
super.connectedCallback(HINT_CLASS_NAME);
|
|
13
15
|
this.classList.add(HINT_CLASS_NAME);
|
|
14
16
|
}
|
|
17
|
+
render() {
|
|
18
|
+
super.render();
|
|
19
|
+
return html `
|
|
20
|
+
<h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
|
|
21
|
+
${this.getSlot(MESSAGE_CONTENT_SLOT_NAME)}
|
|
22
|
+
</h-portal>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
15
25
|
};
|
|
16
26
|
HHint = __decorate([
|
|
17
27
|
phoenixCustomElement(HINT_ELEMENT_NAME),
|