@shoper/phoenix_design_system 1.15.11-2 → 1.15.11-21
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 +2 -9
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js +1 -6
- 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 +0 -30
- 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 +2 -1
- 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/select.js +11 -61
- 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 +35 -4
- 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 +6 -1
- package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/base_message_content.js +7 -2
- package/build/cjs/packages/phoenix/src/components/messages/base_message_content.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js +2 -0
- 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 +15 -62
- 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 +0 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +2 -9
- 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 +0 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +1 -6
- 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 +0 -4
- package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js +0 -30
- 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 +2 -1
- 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/select.d.ts +3 -10
- package/build/esm/packages/phoenix/src/components/form/select/select.js +11 -61
- 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 +4 -0
- package/build/esm/packages/phoenix/src/components/messages/base_message.js +36 -5
- 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 +2 -0
- package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js +5 -2
- package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message_content.d.ts +1 -0
- package/build/esm/packages/phoenix/src/components/messages/base_message_content.js +7 -2
- package/build/esm/packages/phoenix/src/components/messages/base_message_content.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/portal/portal_constants.js +2 -1
- 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 +2 -6
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js +0 -1
- 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 +3 -7
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +15 -62
- package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
- package/package.json +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +0 -90
- package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +0 -1
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.d.ts +0 -13
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +0 -86
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +0 -1
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.d.ts +0 -8
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js +0 -3
- package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js.map +0 -1
|
@@ -5,7 +5,7 @@ import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/pho
|
|
|
5
5
|
import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP, PORTAL_TARGET_ATTRIBUTE_NAME } from '../portal/portal_constants.js';
|
|
6
6
|
import { ClickOutsideController } from '../../controllers/click_outside_controller/click_outside_controller.js';
|
|
7
7
|
import { RelativePositionController } from '../../controllers/relative_position_controller/relative_position_controller.js';
|
|
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';
|
|
8
|
+
import { DEFAULT_MESSAGE_PORTAL_NAME, DEFAULT_MESSAGE_OFFSET, LIST_OF_MESSAGE_CHILDREN, MESSAGE_SHOW_DELAY_IN_MS, MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS, MESSAGE_REMOVED_CLASS_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS, LIST_OF_MESSAGE_CONTENT_ELEMENTS } from './base_message_constants.js';
|
|
9
9
|
|
|
10
10
|
class BaseMessage extends PhoenixLightLitElement {
|
|
11
11
|
constructor() {
|
|
@@ -16,12 +16,20 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
16
16
|
this.offset = DEFAULT_MESSAGE_OFFSET;
|
|
17
17
|
this.mouseonly = false;
|
|
18
18
|
this.tabindex = '-1';
|
|
19
|
+
this._handleChildrenAriaAttributes = () => {
|
|
20
|
+
if (!this._$baseMessageContent)
|
|
21
|
+
return;
|
|
22
|
+
[...this.children].forEach((child) => {
|
|
23
|
+
if (LIST_OF_MESSAGE_CHILDREN.includes(child.tagName.toLowerCase()))
|
|
24
|
+
return;
|
|
25
|
+
child.setAttribute('aria-describedby', this._$baseMessageContent.id);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
19
28
|
this._setupEventListeners = () => {
|
|
20
|
-
|
|
21
|
-
this.addEventListener('mouseleave', this.close);
|
|
29
|
+
document.addEventListener('mouseover', this._toggleTooltipFromEvent);
|
|
22
30
|
if (!this.mouseonly) {
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
document.addEventListener('focusin', this.open);
|
|
32
|
+
document.addEventListener('focusout', this.close);
|
|
25
33
|
}
|
|
26
34
|
};
|
|
27
35
|
this._positionMessage = () => {
|
|
@@ -30,6 +38,19 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
30
38
|
(_a = this._$messageContent) === null || _a === void 0 ? void 0 : _a.setAttribute('direction', this._positionController.position(true));
|
|
31
39
|
});
|
|
32
40
|
};
|
|
41
|
+
this._toggleTooltipFromEvent = (ev) => {
|
|
42
|
+
var _a;
|
|
43
|
+
if (!ev.target)
|
|
44
|
+
return;
|
|
45
|
+
const $target = ev.target;
|
|
46
|
+
const isInsideMessageContent = $target.closest && $target.closest(`[id="${(_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.id}"]`);
|
|
47
|
+
const isInsideMessageContainer = !!this.contains($target);
|
|
48
|
+
if (!isInsideMessageContent && !isInsideMessageContainer) {
|
|
49
|
+
this.close();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.open();
|
|
53
|
+
};
|
|
33
54
|
this.open = () => {
|
|
34
55
|
this._tooltipOpenTime = Date.now();
|
|
35
56
|
clearTimeout(this._closeTimeout);
|
|
@@ -80,6 +101,8 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
80
101
|
});
|
|
81
102
|
this.setAttribute('tabindex', this.tabindex);
|
|
82
103
|
this._setupEventListeners();
|
|
104
|
+
this._$baseMessageContent = [...this.children].find((child) => LIST_OF_MESSAGE_CONTENT_ELEMENTS.includes(child.tagName.toLowerCase()));
|
|
105
|
+
this._handleChildrenAriaAttributes();
|
|
83
106
|
}
|
|
84
107
|
static _appendMessagePortal() {
|
|
85
108
|
const $messagePortalTarget = document.querySelector(`[name="${DEFAULT_MESSAGE_PORTAL_NAME}"]`);
|
|
@@ -89,6 +112,14 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
89
112
|
$portalTarget.setAttribute(PORTAL_TARGET_NAME_PROP, DEFAULT_MESSAGE_PORTAL_NAME);
|
|
90
113
|
document.body.appendChild($portalTarget);
|
|
91
114
|
}
|
|
115
|
+
disconnectedCallback() {
|
|
116
|
+
super.disconnectedCallback();
|
|
117
|
+
document.removeEventListener('mouseover', this._toggleTooltipFromEvent);
|
|
118
|
+
if (!this.mouseonly) {
|
|
119
|
+
document.removeEventListener('focusin', this.open);
|
|
120
|
+
document.removeEventListener('focusout', this.close);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
92
123
|
}
|
|
93
124
|
__decorate([
|
|
94
125
|
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -7,3 +7,5 @@ export declare const MESSAGE_CONTENT_ELEMENTS: string[];
|
|
|
7
7
|
export declare const MESSAGE_SHOW_DELAY_IN_MS = 100;
|
|
8
8
|
export declare const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
|
|
9
9
|
export declare const MESSAGE_CLOSE_DELAY_IN_MS = 500;
|
|
10
|
+
export declare const LIST_OF_MESSAGE_CONTENT_ELEMENTS: string[];
|
|
11
|
+
export declare const LIST_OF_MESSAGE_CHILDREN: string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PORTAL_COMPONENT_NAME } from '../portal/portal_constants.js';
|
|
1
2
|
import { HINT_CONTENT_ELEMENT_NAME } from './hints/hint_constants.js';
|
|
2
3
|
import { TOOLTIP_CONTENT_ELEMENT_NAME } from './tooltips/tooltip_constants.js';
|
|
3
4
|
|
|
@@ -8,7 +9,9 @@ const DEFAULT_MESSAGE_OFFSET = 10;
|
|
|
8
9
|
const MESSAGE_CONTENT_ELEMENTS = [TOOLTIP_CONTENT_ELEMENT_NAME, HINT_CONTENT_ELEMENT_NAME];
|
|
9
10
|
const MESSAGE_SHOW_DELAY_IN_MS = 100;
|
|
10
11
|
const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
|
|
11
|
-
const MESSAGE_CLOSE_DELAY_IN_MS = 500;
|
|
12
|
+
const MESSAGE_CLOSE_DELAY_IN_MS = 500;
|
|
13
|
+
const LIST_OF_MESSAGE_CONTENT_ELEMENTS = [TOOLTIP_CONTENT_ELEMENT_NAME, HINT_CONTENT_ELEMENT_NAME];
|
|
14
|
+
const LIST_OF_MESSAGE_CHILDREN = [...LIST_OF_MESSAGE_CONTENT_ELEMENTS, PORTAL_COMPONENT_NAME];
|
|
12
15
|
|
|
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
|
+
export { DEFAULT_MESSAGE_OFFSET, DEFAULT_MESSAGE_PORTAL_NAME, LIST_OF_MESSAGE_CHILDREN, LIST_OF_MESSAGE_CONTENT_ELEMENTS, 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 };
|
|
14
17
|
//# 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;AACA;AACA;AACA;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
|
|
2
2
|
export declare class BaseMessageContent extends PhoenixLightLitElement {
|
|
3
3
|
portalTarget: string;
|
|
4
|
+
id: string;
|
|
4
5
|
constructor();
|
|
5
6
|
connectedCallback(): void;
|
|
6
7
|
private _setupAriaAttributes;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import { property } from 'lit/decorators';
|
|
3
3
|
import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
4
|
+
import v4 from '../../../../../external/uuid/dist/esm-browser/v4.js';
|
|
4
5
|
import { PORTAL_TARGET_ATTRIBUTE_NAME } from '../portal/portal_constants.js';
|
|
5
6
|
import { DEFAULT_MESSAGE_PORTAL_NAME, MESSAGE_CONTENT_SLOT_NAME } from './base_message_constants.js';
|
|
6
7
|
|
|
@@ -8,6 +9,7 @@ class BaseMessageContent extends PhoenixLightLitElement {
|
|
|
8
9
|
constructor() {
|
|
9
10
|
super();
|
|
10
11
|
this.portalTarget = DEFAULT_MESSAGE_PORTAL_NAME;
|
|
12
|
+
this.id = v4();
|
|
11
13
|
this.slot = MESSAGE_CONTENT_SLOT_NAME;
|
|
12
14
|
}
|
|
13
15
|
connectedCallback() {
|
|
@@ -16,13 +18,16 @@ class BaseMessageContent extends PhoenixLightLitElement {
|
|
|
16
18
|
}
|
|
17
19
|
_setupAriaAttributes() {
|
|
18
20
|
this.setAttribute('role', 'tooltip');
|
|
19
|
-
this.setAttribute('inert', '');
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
__decorate([
|
|
23
24
|
property({ type: String, attribute: PORTAL_TARGET_ATTRIBUTE_NAME }),
|
|
24
25
|
__metadata("design:type", Object)
|
|
25
|
-
], BaseMessageContent.prototype, "portalTarget", void 0);
|
|
26
|
+
], BaseMessageContent.prototype, "portalTarget", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
property({ type: String, reflect: true }),
|
|
29
|
+
__metadata("design:type", Object)
|
|
30
|
+
], BaseMessageContent.prototype, "id", void 0);
|
|
26
31
|
|
|
27
32
|
export { BaseMessageContent };
|
|
28
33
|
//# sourceMappingURL=base_message_content.js.map
|
|
@@ -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;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA,eAAe,qDAAyD;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;"}
|
|
@@ -3,8 +3,9 @@ const PORTAL_EVENTS = {
|
|
|
3
3
|
close: 'close'
|
|
4
4
|
};
|
|
5
5
|
const PORTAL_TARGET_NAME_PROP = 'name';
|
|
6
|
+
const PORTAL_COMPONENT_NAME = 'h-portal';
|
|
6
7
|
const PORTAL_TARGET_COMPONENT_NAME = 'h-portal-target';
|
|
7
8
|
const PORTAL_TARGET_ATTRIBUTE_NAME = 'portal-target';
|
|
8
9
|
|
|
9
|
-
export { PORTAL_EVENTS, PORTAL_TARGET_ATTRIBUTE_NAME, PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP };
|
|
10
|
+
export { PORTAL_COMPONENT_NAME, PORTAL_EVENTS, PORTAL_TARGET_ATTRIBUTE_NAME, PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP };
|
|
10
11
|
//# sourceMappingURL=portal_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;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { Any } from 'ts-toolbelt';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactiveControllerHost } from 'lit';
|
|
3
3
|
import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from "./list_box_controller_constants";
|
|
4
|
-
import { HSelect } from "../../components/form/select/select";
|
|
5
4
|
export declare type TListBoxKeyboardNavigationDirection = Any.Keys<typeof LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS>;
|
|
6
5
|
export declare type TListBoxKeyboardControllerConstructorOptions = {
|
|
7
|
-
host: ReactiveControllerHost &
|
|
6
|
+
host: ReactiveControllerHost & HTMLElement;
|
|
8
7
|
$list: HTMLElement;
|
|
9
8
|
listItemSelector?: string;
|
|
10
9
|
orientation?: TListBoxKeyboardNavigationDirection;
|
|
11
10
|
};
|
|
12
|
-
export interface IListboxController extends ReactiveController {
|
|
13
|
-
calculateSelectedOptionIndex(): void;
|
|
14
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list_box_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/list_box_controller/list_box_controller_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,
|
|
1
|
+
{"version":3,"file":"list_box_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/list_box_controller/list_box_controller_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,OAAuC,KAAK,CAAC;AAC7C,OAAwD,4EAA4E,CAAC"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ReactiveController } from 'lit';
|
|
2
|
+
import { TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
|
|
3
|
+
export declare class ListBoxKeyboardController implements ReactiveController {
|
|
3
4
|
#private;
|
|
4
5
|
constructor({ host, $list, listItemSelector, orientation }: TListBoxKeyboardControllerConstructorOptions);
|
|
5
6
|
hostConnected(): void;
|
|
6
|
-
private _handleKeyboardNavigation;
|
|
7
7
|
private _handleArrowNavigation;
|
|
8
|
-
private _findCurrentIndex;
|
|
9
|
-
private _handleWriteableCharacter;
|
|
10
|
-
calculateSelectedOptionIndex: () => void;
|
|
11
8
|
private _getPrevOptionIndex;
|
|
12
9
|
private _getNextOptionIndex;
|
|
13
|
-
hostDisconnected(): void;
|
|
14
10
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import 'lit';
|
|
3
3
|
import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
4
|
+
import { KeystrokesController } from '../keystrokes_controller/keystrokes_controller.js';
|
|
4
5
|
import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from './list_box_controller_constants.js';
|
|
5
6
|
|
|
6
7
|
var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController_currentOptionIndex, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
|
|
@@ -12,54 +13,25 @@ class ListBoxKeyboardController {
|
|
|
12
13
|
_ListBoxKeyboardController__$options.set(this, void 0);
|
|
13
14
|
_ListBoxKeyboardController_listItemSelector.set(this, void 0);
|
|
14
15
|
_ListBoxKeyboardController_keys.set(this, void 0);
|
|
15
|
-
this._handleKeyboardNavigation = (ev) => {
|
|
16
|
-
if (__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f").find((key) => key === ev.key)) {
|
|
17
|
-
this._handleArrowNavigation(ev);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
this._handleWriteableCharacter(ev);
|
|
21
|
-
};
|
|
22
16
|
this._handleArrowNavigation = (event) => {
|
|
23
17
|
event.preventDefault();
|
|
24
18
|
const { key } = event;
|
|
25
|
-
const
|
|
26
|
-
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
27
|
-
});
|
|
28
|
-
const prevOptionIndex = this._findCurrentIndex();
|
|
19
|
+
const prevOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
|
|
29
20
|
let newOptionIndex = key === 'ArrowDown' || key === 'ArrowRight' ? this._getNextOptionIndex() : this._getPrevOptionIndex();
|
|
30
21
|
if (newOptionIndex === undefined) {
|
|
31
|
-
|
|
22
|
+
const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
|
|
23
|
+
newOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
|
|
32
24
|
}
|
|
33
25
|
if (newOptionIndex === __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f"))
|
|
34
26
|
return;
|
|
35
27
|
if (prevOptionIndex !== undefined) {
|
|
36
28
|
const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
|
|
37
|
-
|
|
29
|
+
UiDomUtils.makeUnnavigable($prevOption);
|
|
38
30
|
}
|
|
39
31
|
__classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, newOptionIndex, "f");
|
|
40
|
-
const $focusedOption = $
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
$focusedOption.focus();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
this._findCurrentIndex = () => {
|
|
47
|
-
const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
|
|
48
|
-
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
49
|
-
});
|
|
50
|
-
const selectedOptionIndex = $availableOptions.findIndex(($option) => $option.selected);
|
|
51
|
-
return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
|
|
52
|
-
};
|
|
53
|
-
this._handleWriteableCharacter = (ev) => {
|
|
54
|
-
var _a;
|
|
55
|
-
const $searchInput = (_a = __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
|
|
56
|
-
if (!$searchInput)
|
|
57
|
-
return;
|
|
58
|
-
$searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
|
|
59
|
-
};
|
|
60
|
-
this.calculateSelectedOptionIndex = () => {
|
|
61
|
-
const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
|
|
62
|
-
__classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, selectedOptionIndex !== -1 ? selectedOptionIndex : 0, "f");
|
|
32
|
+
const $focusedOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[newOptionIndex];
|
|
33
|
+
UiDomUtils.makeNavigable($focusedOption);
|
|
34
|
+
$focusedOption.focus();
|
|
63
35
|
};
|
|
64
36
|
__classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
|
|
65
37
|
__classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
|
|
@@ -69,7 +41,12 @@ class ListBoxKeyboardController {
|
|
|
69
41
|
__classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").addController(this);
|
|
70
42
|
}
|
|
71
43
|
hostConnected() {
|
|
72
|
-
|
|
44
|
+
new KeystrokesController({
|
|
45
|
+
host: __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f"),
|
|
46
|
+
keys: __classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f"),
|
|
47
|
+
callback: this._handleArrowNavigation,
|
|
48
|
+
target: __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f")
|
|
49
|
+
});
|
|
73
50
|
UiDomUtils.makeNavigable(__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"));
|
|
74
51
|
__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
|
|
75
52
|
if (event.target !== __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
|
|
@@ -87,39 +64,15 @@ class ListBoxKeyboardController {
|
|
|
87
64
|
return undefined;
|
|
88
65
|
if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
|
|
89
66
|
return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
|
|
90
|
-
if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
|
|
91
|
-
return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
|
|
92
|
-
const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
|
|
93
|
-
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
94
|
-
});
|
|
95
|
-
if (!!$availableOptions[__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1])
|
|
96
|
-
return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
|
|
97
|
-
// bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
|
|
98
|
-
const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
|
|
99
|
-
if (newIndexOfCurrentlySelectedOption)
|
|
100
|
-
return newIndexOfCurrentlySelectedOption - 1;
|
|
101
67
|
return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
|
|
102
68
|
}
|
|
103
69
|
_getNextOptionIndex() {
|
|
104
70
|
if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
|
|
105
71
|
return undefined;
|
|
106
|
-
|
|
107
|
-
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
108
|
-
});
|
|
109
|
-
if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === $availableOptions.length - 1)
|
|
72
|
+
if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") >= __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").length - 1)
|
|
110
73
|
return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
|
|
111
|
-
if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") > $availableOptions.length - 1) {
|
|
112
|
-
// bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
|
|
113
|
-
const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
|
|
114
|
-
if (newIndexOfCurrentlySelectedOption)
|
|
115
|
-
return newIndexOfCurrentlySelectedOption + 1;
|
|
116
|
-
return 0;
|
|
117
|
-
}
|
|
118
74
|
return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") + 1;
|
|
119
75
|
}
|
|
120
|
-
hostDisconnected() {
|
|
121
|
-
__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
|
|
122
|
-
}
|
|
123
76
|
}
|
|
124
77
|
_ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController_currentOptionIndex = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
|
|
125
78
|
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib_es6 = require('../../../../../../../../external/tslib/tslib.es6.js');
|
|
6
|
-
require('lit');
|
|
7
|
-
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
|
-
}
|
|
25
|
-
if (ev.key === 'End') {
|
|
26
|
-
this._openSelectAndGoToLastElement(ev);
|
|
27
|
-
}
|
|
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 = tslib_es6.__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 = tslib_es6.__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
|
-
utilities.UiDomUtils.makeNavigable($firstOption);
|
|
44
|
-
$firstOption.focus();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
this._openSelectAndGoToLastElement = async (event) => {
|
|
48
|
-
var _a;
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
51
|
-
const $lastOption = this._getAvailableOptions()[-1];
|
|
52
|
-
if ($lastOption) {
|
|
53
|
-
utilities.UiDomUtils.makeNavigable($lastOption);
|
|
54
|
-
$lastOption.focus();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this._openSelectAndGoToMatchedElement = async (event) => {
|
|
58
|
-
var _a;
|
|
59
|
-
event.preventDefault();
|
|
60
|
-
await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
61
|
-
const $matchedOption = this._getAvailableOptions().find(($option) => {
|
|
62
|
-
var _a;
|
|
63
|
-
(_a = $option.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith(event.key.toLowerCase());
|
|
64
|
-
});
|
|
65
|
-
if ($matchedOption) {
|
|
66
|
-
utilities.UiDomUtils.makeNavigable($matchedOption);
|
|
67
|
-
$matchedOption.focus();
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
this._getAvailableOptions = () => {
|
|
71
|
-
return tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f").filter(($option) => {
|
|
72
|
-
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController_host, host, "f");
|
|
76
|
-
tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$toggler, $toggler, "f");
|
|
77
|
-
tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$options, Array.from($list.querySelectorAll(listItemSelector)), "f");
|
|
78
|
-
tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").addController(this);
|
|
79
|
-
}
|
|
80
|
-
hostConnected() {
|
|
81
|
-
tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").addEventListener('keydown', this._handleKeyboardNavigation);
|
|
82
|
-
}
|
|
83
|
-
hostDisconnected() {
|
|
84
|
-
tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
_SelectTogglerKeyboardController_host = new WeakMap(), _SelectTogglerKeyboardController__$toggler = new WeakMap(), _SelectTogglerKeyboardController_currentOptionIndex = new WeakMap(), _SelectTogglerKeyboardController__$options = new WeakMap();
|
|
88
|
-
|
|
89
|
-
exports.SelectTogglerKeyboardController = SelectTogglerKeyboardController;
|
|
90
|
-
//# sourceMappingURL=select_toggler_keyboard_controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
hostDisconnected(): void;
|
|
13
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
}
|
|
21
|
-
if (ev.key === 'End') {
|
|
22
|
-
this._openSelectAndGoToLastElement(ev);
|
|
23
|
-
}
|
|
24
|
-
const isAWriteableCharacter = ev.key.length === 1;
|
|
25
|
-
if (isAWriteableCharacter)
|
|
26
|
-
this._openSelectAndGoToMatchedElement(ev);
|
|
27
|
-
};
|
|
28
|
-
this._openSelect = (event) => {
|
|
29
|
-
var _a;
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
(_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show();
|
|
32
|
-
};
|
|
33
|
-
this._openSelectAndGoToFirstElement = async (event) => {
|
|
34
|
-
var _a;
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
await ((_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
37
|
-
const $firstOption = this._getAvailableOptions()[0];
|
|
38
|
-
if ($firstOption) {
|
|
39
|
-
UiDomUtils.makeNavigable($firstOption);
|
|
40
|
-
$firstOption.focus();
|
|
41
|
-
}
|
|
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 $lastOption = this._getAvailableOptions()[-1];
|
|
48
|
-
if ($lastOption) {
|
|
49
|
-
UiDomUtils.makeNavigable($lastOption);
|
|
50
|
-
$lastOption.focus();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this._openSelectAndGoToMatchedElement = async (event) => {
|
|
54
|
-
var _a;
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
await ((_a = __classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
|
|
57
|
-
const $matchedOption = this._getAvailableOptions().find(($option) => {
|
|
58
|
-
var _a;
|
|
59
|
-
(_a = $option.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith(event.key.toLowerCase());
|
|
60
|
-
});
|
|
61
|
-
if ($matchedOption) {
|
|
62
|
-
UiDomUtils.makeNavigable($matchedOption);
|
|
63
|
-
$matchedOption.focus();
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
this._getAvailableOptions = () => {
|
|
67
|
-
return __classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f").filter(($option) => {
|
|
68
|
-
return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
|
|
69
|
-
});
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|