@shoper/phoenix_design_system 1.15.11-36 → 1.15.11-38
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 +88 -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 +91 -29
- 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 +83 -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 +84 -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 +16 -6
- package/build/esm/packages/phoenix/src/components/form/select/select.js +91 -29
- 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 +83 -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,84 @@
|
|
|
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
|
+
const $newOption = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").options[newOptionIndex];
|
|
65
|
+
if (!$newOption)
|
|
66
|
+
return;
|
|
67
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").manageSelectVirtualFocus($newOption);
|
|
68
|
+
};
|
|
69
|
+
__classPrivateFieldSet(this, _SelectTogglerKeyboardController_host, host, "f");
|
|
70
|
+
__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$toggler, $toggler, "f");
|
|
71
|
+
__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$options, Array.from($list.querySelectorAll(listItemSelector)), "f");
|
|
72
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").addController(this);
|
|
73
|
+
}
|
|
74
|
+
hostConnected() {
|
|
75
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").addEventListener('keydown', this._handleKeyboardNavigation);
|
|
76
|
+
}
|
|
77
|
+
hostDisconnected() {
|
|
78
|
+
__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_SelectTogglerKeyboardController_host = new WeakMap(), _SelectTogglerKeyboardController__$toggler = new WeakMap(), _SelectTogglerKeyboardController_currentOptionIndex = new WeakMap(), _SelectTogglerKeyboardController__$options = new WeakMap();
|
|
82
|
+
|
|
83
|
+
export { SelectTogglerKeyboardController };
|
|
84
|
+
//# 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;"}
|
|
@@ -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,7 +64,8 @@ export declare class HSelect extends PhoenixLightLitElement {
|
|
|
55
64
|
private _selectOption;
|
|
56
65
|
private _handleSearch;
|
|
57
66
|
private _handleDropdownHidden;
|
|
58
|
-
private
|
|
67
|
+
private _handleDropdownShowed;
|
|
68
|
+
manageSelectVirtualFocus: ($newOption: HTMLElement) => void;
|
|
59
69
|
private _closeSelect;
|
|
60
70
|
private _clearOptions;
|
|
61
71
|
private _dispatchChangeEvent;
|
|
@@ -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,26 +131,36 @@ 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
|
+
}
|
|
123
143
|
};
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
const $
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
const optionId = $target.id;
|
|
130
|
-
if (optionId) {
|
|
131
|
-
(_a = this._$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', optionId);
|
|
144
|
+
this._handleDropdownShowed = () => {
|
|
145
|
+
this.opened = true;
|
|
146
|
+
const $activeDescendant = this.options.find((option) => option.selected);
|
|
147
|
+
if ($activeDescendant) {
|
|
148
|
+
this.manageSelectVirtualFocus($activeDescendant);
|
|
132
149
|
}
|
|
133
150
|
};
|
|
151
|
+
this.manageSelectVirtualFocus = ($newOption) => {
|
|
152
|
+
var _a;
|
|
153
|
+
(_a = this.$dropdownToggler.value) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-activedescendant', $newOption.id);
|
|
154
|
+
this.options.forEach((option) => {
|
|
155
|
+
option.classList.remove('select-option_virtually-focused');
|
|
156
|
+
});
|
|
157
|
+
$newOption.classList.add('select-option_virtually-focused');
|
|
158
|
+
};
|
|
134
159
|
this._closeSelect = () => {
|
|
135
160
|
var _a;
|
|
136
161
|
if (!this.opened)
|
|
137
162
|
return;
|
|
138
|
-
(_a = this
|
|
163
|
+
(_a = this.$dropdown.value) === null || _a === void 0 ? void 0 : _a.hide();
|
|
139
164
|
};
|
|
140
165
|
this._clearOptions = () => {
|
|
141
166
|
this._selectController.deselectAll();
|
|
@@ -179,6 +204,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
179
204
|
return Array.from(this._$options.values());
|
|
180
205
|
}
|
|
181
206
|
updated(changedProperties) {
|
|
207
|
+
var _a, _b;
|
|
182
208
|
super.updated(changedProperties);
|
|
183
209
|
if (changedProperties.has('opened')) {
|
|
184
210
|
if (this.opened) {
|
|
@@ -192,28 +218,52 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
192
218
|
if (changedProperties.has('optionsList')) {
|
|
193
219
|
this._updateOptions();
|
|
194
220
|
}
|
|
195
|
-
if (this._$optionsList.value
|
|
196
|
-
this.
|
|
221
|
+
if (this._$optionsList.value) {
|
|
222
|
+
(_a = this.listBoxController) === null || _a === void 0 ? void 0 : _a.hostDisconnected();
|
|
223
|
+
this.listBoxController = new ListBoxKeyboardController({
|
|
224
|
+
host: this,
|
|
225
|
+
$list: this._$optionsList.value
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
if (this.listBoxController) {
|
|
229
|
+
this.listBoxController.calculateSelectedOptionIndex();
|
|
230
|
+
}
|
|
231
|
+
if (this._$optionsList.value && this.$dropdownToggler.value) {
|
|
232
|
+
(_b = this._selectTogglerKeyboardController) === null || _b === void 0 ? void 0 : _b.hostDisconnected();
|
|
233
|
+
this._selectTogglerKeyboardController = new SelectTogglerKeyboardController({
|
|
197
234
|
host: this,
|
|
235
|
+
$toggler: this.$dropdownToggler.value,
|
|
198
236
|
$list: this._$optionsList.value
|
|
199
237
|
});
|
|
238
|
+
}
|
|
200
239
|
}
|
|
201
240
|
_focusElementAfterSelectOpened() {
|
|
202
|
-
var _a
|
|
203
|
-
const $searchInput = (_a = this
|
|
204
|
-
$
|
|
241
|
+
var _a;
|
|
242
|
+
const $searchInput = (_a = this.$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
|
|
243
|
+
const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
|
|
244
|
+
const $firstOption = $options.find(($option) => {
|
|
245
|
+
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.getAttribute('hidden');
|
|
246
|
+
});
|
|
247
|
+
const $selectedOption = this.selectedOptions[0];
|
|
248
|
+
const $optionToFocus = $selectedOption || $firstOption;
|
|
249
|
+
$searchInput ? $searchInput.focus() : $optionToFocus === null || $optionToFocus === void 0 ? void 0 : $optionToFocus.focus();
|
|
205
250
|
}
|
|
206
251
|
connectedCallback() {
|
|
252
|
+
var _a;
|
|
207
253
|
super.connectedCallback();
|
|
208
254
|
this.classList.add(SELECT_CSS_CLASSES.select);
|
|
209
255
|
if (!this.searchDisabled) {
|
|
210
256
|
this.classList.add(SELECT_CSS_CLASSES.selectWithSearch);
|
|
211
257
|
}
|
|
258
|
+
this.$searchLabel = document.querySelector(`[id="${this.assistiveTitleId}"]`);
|
|
259
|
+
(_a = this.$searchLabel) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-hidden', 'true');
|
|
212
260
|
this._selectController = this.multiple ? new MultiSelectController({ host: this }) : new SelectController({ host: this });
|
|
213
261
|
this._selectContext.provide(SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
|
|
214
262
|
this._selectContext.provide(SELECT_CONTEXTS.isMultiselect, this.multiple);
|
|
215
263
|
this._optionsObserver = new Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
|
|
216
264
|
this._selectController.options$.subscribe(this._optionsObserver);
|
|
265
|
+
this._selectedOptionsAriaObserver = new Observer((selectedOptions) => this._updateLabelAria(selectedOptions));
|
|
266
|
+
this._selectController.selectedOptions$.subscribe(this._selectedOptionsAriaObserver);
|
|
217
267
|
this._updateOptions();
|
|
218
268
|
this._setupEvents();
|
|
219
269
|
}
|
|
@@ -243,6 +293,10 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
243
293
|
SelectControlUtils.appendHTMLOption($option, $list, position);
|
|
244
294
|
}
|
|
245
295
|
updateOptionAriaAttribute($option) {
|
|
296
|
+
if (!this.multiple) {
|
|
297
|
+
const $options = this._$optionsList.value ? [...this._$optionsList.value.querySelectorAll('h-option')] : [];
|
|
298
|
+
$options.forEach(($option) => ($option.removeAttribute('aria-selected')));
|
|
299
|
+
}
|
|
246
300
|
$option.setAttribute(this.multiple ? 'aria-checked' : 'aria-selected', String($option.selected));
|
|
247
301
|
}
|
|
248
302
|
_removeHTMLOptions(optionsValues) {
|
|
@@ -252,6 +306,12 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
252
306
|
const option = this._selectController.getOption(value);
|
|
253
307
|
if (!option)
|
|
254
308
|
return;
|
|
309
|
+
const $selectedOption = this._$options.get(option.value);
|
|
310
|
+
const $selectedOptionLink = $selectedOption === null || $selectedOption === void 0 ? void 0 : $selectedOption.querySelector('a');
|
|
311
|
+
if ($selectedOptionLink) {
|
|
312
|
+
$selectedOptionLink.click();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
255
315
|
this.noDeselect ? this._selectController.select(option) : this._selectController.toggle(option);
|
|
256
316
|
if (!this.multiple)
|
|
257
317
|
this._closeSelect();
|
|
@@ -302,23 +362,24 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
302
362
|
const isSearchEnabled = !this.searchDisabled && options.length > MIN_NUMBER_OF_OPTIONS_TO_SHOW_SEARCH;
|
|
303
363
|
return html `
|
|
304
364
|
<h-dropdown
|
|
305
|
-
${ref(this
|
|
306
|
-
@showed=${
|
|
365
|
+
${ref(this.$dropdown)}
|
|
366
|
+
@showed=${this._handleDropdownShowed}
|
|
307
367
|
@hidden=${this._handleDropdownHidden}
|
|
308
368
|
name="${this.controlName}"
|
|
309
369
|
offset=${this.offset}
|
|
310
370
|
content-width="full"
|
|
311
371
|
prevent-focus-trap
|
|
372
|
+
no-autofocus
|
|
312
373
|
>
|
|
313
374
|
<h-dropdown-toggler
|
|
314
|
-
${ref(this
|
|
375
|
+
${ref(this.$dropdownToggler)}
|
|
315
376
|
name="${this.controlName}"
|
|
316
377
|
validation-container
|
|
317
378
|
aria-haspopup="listbox"
|
|
318
379
|
role="combobox"
|
|
319
380
|
aria-required="${this.required ? 'true' : 'false'}"
|
|
320
|
-
|
|
321
|
-
aria-
|
|
381
|
+
role="combobox"
|
|
382
|
+
aria-controls="${this._selectOptionsId}"
|
|
322
383
|
>
|
|
323
384
|
${this.getSlot(SELECT_SLOT_NAMES.toggler)}
|
|
324
385
|
</h-dropdown-toggler>
|
|
@@ -327,7 +388,6 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
327
388
|
class="${SELECT_CSS_CLASSES.selectContent} ${this.error ? SELECT_CSS_CLASSES.selectContentError : ''}"
|
|
328
389
|
${ref(this._$dropdownContent)}
|
|
329
390
|
name="${this.controlName}"
|
|
330
|
-
@focusin="${this._manageSelectFocusAria}"
|
|
331
391
|
>
|
|
332
392
|
<h-select-close-btn class="${SELECT_CSS_CLASSES.selectCloseMobileButton}" @close=${this._closeSelect}></h-select-close-btn>
|
|
333
393
|
|
|
@@ -336,7 +396,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
336
396
|
${isSearchEnabled
|
|
337
397
|
? html ` <h-select-search
|
|
338
398
|
class=${SELECT_CSS_CLASSES.selectSearch}
|
|
339
|
-
${ref(this
|
|
399
|
+
${ref(this.$search)}
|
|
340
400
|
.value=${this._searchValue}
|
|
341
401
|
@search=${this._handleSearch}
|
|
342
402
|
></h-select-search>`
|
|
@@ -344,6 +404,8 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
344
404
|
|
|
345
405
|
<h-options
|
|
346
406
|
class="${SELECT_CSS_CLASSES.selectOptions} ${this._searchNoResult() ? SELECT_CSS_CLASSES.selectOptionsEmpty : ''}"
|
|
407
|
+
aria-labelledby="${this.assistiveTitleId}"
|
|
408
|
+
id="${this._selectOptionsId}"
|
|
347
409
|
${ref(this._$optionsList)}
|
|
348
410
|
@optionClicked=${this._handleOptionClicked}
|
|
349
411
|
@optionUpdated=${this._handleOptionUpdated}
|
|
@@ -435,9 +497,9 @@ __decorate([
|
|
|
435
497
|
__metadata("design:type", Boolean)
|
|
436
498
|
], HSelect.prototype, "noDeselect", void 0);
|
|
437
499
|
__decorate([
|
|
438
|
-
property({ type: String, attribute: '
|
|
500
|
+
property({ type: String, attribute: 'assistive-title-id' }),
|
|
439
501
|
__metadata("design:type", String)
|
|
440
|
-
], HSelect.prototype, "
|
|
502
|
+
], HSelect.prototype, "assistiveTitleId", void 0);
|
|
441
503
|
__decorate([
|
|
442
504
|
state(),
|
|
443
505
|
__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;"}
|
|
@@ -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;"}
|