@momentum-design/components 0.49.1 → 0.49.3
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/dist/browser/index.js +802 -606
- package/dist/browser/index.js.map +4 -4
- package/dist/components/formfieldwrapper/formfieldwrapper.component.js +1 -1
- package/dist/components/list/list.component.js +2 -1
- package/dist/components/list/list.constants.d.ts +1 -7
- package/dist/components/list/list.constants.js +1 -7
- package/dist/components/listitem/listitem.component.d.ts +2 -1
- package/dist/components/listitem/listitem.component.js +2 -1
- package/dist/components/listitem/listitem.styles.js +4 -3
- package/dist/components/option/index.d.ts +2 -0
- package/dist/components/option/index.js +2 -0
- package/dist/components/option/option.component.d.ts +17 -0
- package/dist/components/option/option.component.js +64 -9
- package/dist/components/option/option.constants.d.ts +2 -1
- package/dist/components/option/option.constants.js +2 -1
- package/dist/components/option/option.styles.js +22 -0
- package/dist/components/option/option.types.d.ts +7 -0
- package/dist/components/option/option.types.js +1 -0
- package/dist/components/popover/popover.component.d.ts +2 -0
- package/dist/components/popover/popover.component.js +2 -0
- package/dist/components/popover/popover.styles.js +4 -0
- package/dist/components/select/index.d.ts +10 -0
- package/dist/components/select/index.js +7 -0
- package/dist/components/select/select.component.d.ts +191 -0
- package/dist/components/select/select.component.js +544 -0
- package/dist/components/select/select.constants.d.ts +6 -0
- package/dist/components/select/select.constants.js +7 -0
- package/dist/components/select/select.styles.d.ts +2 -0
- package/dist/components/select/select.styles.js +103 -0
- package/dist/components/select/select.types.d.ts +7 -0
- package/dist/components/select/select.types.js +1 -0
- package/dist/custom-elements.json +7279 -6307
- package/dist/index.d.ts +14 -13
- package/dist/index.js +11 -10
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +3 -2
- package/dist/react/listitem/index.d.ts +2 -1
- package/dist/react/listitem/index.js +2 -1
- package/dist/react/option/index.d.ts +4 -0
- package/dist/react/option/index.js +4 -0
- package/dist/react/popover/index.d.ts +2 -0
- package/dist/react/popover/index.js +2 -0
- package/dist/react/select/index.d.ts +28 -0
- package/dist/react/select/index.js +36 -0
- package/dist/utils/keys.d.ts +12 -0
- package/dist/utils/keys.js +12 -0
- package/dist/utils/styles/index.js +3 -5
- package/package.json +1 -1
@@ -49,7 +49,7 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
49
49
|
return nothing;
|
50
50
|
}
|
51
51
|
return this.shouldRenderLabel
|
52
|
-
? html `<label for="${this.id}" class="mdc-label" part="label">${this.label}</label>`
|
52
|
+
? html `<label for="${this.id}" id="${DEFAULTS.HEADING_ID}" class="mdc-label" part="label">${this.label}</label>`
|
53
53
|
: html ` <mdc-text
|
54
54
|
id="${DEFAULTS.HEADING_ID}"
|
55
55
|
tagname="${MDC_TEXT_OPTIONS.TAGNAME}"
|
@@ -13,8 +13,9 @@ import { Component } from '../../models';
|
|
13
13
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
14
14
|
import { TAG_NAME as LISTITEM_TAGNAME } from '../listitem/listitem.constants';
|
15
15
|
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
16
|
-
import { HEADER_ID
|
16
|
+
import { HEADER_ID } from './list.constants';
|
17
17
|
import styles from './list.styles';
|
18
|
+
import { KEYS } from '../../utils/keys';
|
18
19
|
/**
|
19
20
|
* mdc-list component is used to display a group of list items. It is used as a container to wrap other list items.
|
20
21
|
*
|
@@ -1,9 +1,3 @@
|
|
1
1
|
declare const TAG_NAME: "mdc-list";
|
2
|
-
declare const KEYS: {
|
3
|
-
readonly ARROW_DOWN: "ArrowDown";
|
4
|
-
readonly ARROW_UP: "ArrowUp";
|
5
|
-
readonly HOME: "Home";
|
6
|
-
readonly END: "End";
|
7
|
-
};
|
8
2
|
declare const HEADER_ID = "header-id";
|
9
|
-
export { TAG_NAME,
|
3
|
+
export { TAG_NAME, HEADER_ID };
|
@@ -1,10 +1,4 @@
|
|
1
1
|
import utils from '../../utils/tag-name';
|
2
2
|
const TAG_NAME = utils.constructTagName('list');
|
3
|
-
const KEYS = {
|
4
|
-
ARROW_DOWN: 'ArrowDown',
|
5
|
-
ARROW_UP: 'ArrowUp',
|
6
|
-
HOME: 'Home',
|
7
|
-
END: 'End',
|
8
|
-
};
|
9
3
|
const HEADER_ID = 'header-id';
|
10
|
-
export { TAG_NAME,
|
4
|
+
export { TAG_NAME, HEADER_ID };
|
@@ -33,8 +33,9 @@ declare const ListItem_base: import("../../utils/mixins/index.types").Constructo
|
|
33
33
|
* @cssproperty --mdc-listitem-primary-label-color
|
34
34
|
* - Allows customization of the primary label, side header and subline text slot color.
|
35
35
|
* @cssproperty --mdc-listitem-secondary-label-color
|
36
|
-
* - Allows customization of the secondary and
|
36
|
+
* - Allows customization of the secondary and tertiary label text slot color.
|
37
37
|
* @cssproperty --mdc-listitem-disabled-color - Allows customization of the disabled color.
|
38
|
+
* @cssproperty --mdc-listitem-column-gap - Allows customization of column gap.
|
38
39
|
*
|
39
40
|
* @event click - (React: onClick) This event is dispatched when the listitem is clicked.
|
40
41
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the listitem.
|
@@ -45,8 +45,9 @@ import styles from './listitem.styles';
|
|
45
45
|
* @cssproperty --mdc-listitem-primary-label-color
|
46
46
|
* - Allows customization of the primary label, side header and subline text slot color.
|
47
47
|
* @cssproperty --mdc-listitem-secondary-label-color
|
48
|
-
* - Allows customization of the secondary and
|
48
|
+
* - Allows customization of the secondary and tertiary label text slot color.
|
49
49
|
* @cssproperty --mdc-listitem-disabled-color - Allows customization of the disabled color.
|
50
|
+
* @cssproperty --mdc-listitem-column-gap - Allows customization of column gap.
|
50
51
|
*
|
51
52
|
* @event click - (React: onClick) This event is dispatched when the listitem is clicked.
|
52
53
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the listitem.
|
@@ -8,10 +8,11 @@ const styles = css `
|
|
8
8
|
--mdc-listitem-primary-label-color: var(--mds-color-theme-text-primary-normal);
|
9
9
|
--mdc-listitem-secondary-label-color: var(--mds-color-theme-text-secondary-normal);
|
10
10
|
--mdc-listitem-disabled-color: var(--mds-color-theme-text-primary-disabled);
|
11
|
+
--mdc-listitem-column-gap: 0.75rem;
|
11
12
|
}
|
12
13
|
:host {
|
13
14
|
background-color: var(--mdc-listitem-default-background-color);
|
14
|
-
column-gap:
|
15
|
+
column-gap: var(--mdc-listitem-column-gap);
|
15
16
|
cursor: pointer;
|
16
17
|
display: flex;
|
17
18
|
flex-direction: row;
|
@@ -51,7 +52,7 @@ const styles = css `
|
|
51
52
|
}
|
52
53
|
:host::part(leading), :host::part(trailing) {
|
53
54
|
align-items: center;
|
54
|
-
column-gap:
|
55
|
+
column-gap: var(--mdc-listitem-column-gap);
|
55
56
|
display: flex;
|
56
57
|
}
|
57
58
|
:host::part(leading-text-secondary-label), :host::part(leading-text-tertiary-label) {
|
@@ -65,7 +66,7 @@ const styles = css `
|
|
65
66
|
}
|
66
67
|
::slotted([slot="leading-controls"]), ::slotted([slot="trailing-controls"]) {
|
67
68
|
align-items: center;
|
68
|
-
column-gap:
|
69
|
+
column-gap: var(--mdc-listitem-column-gap);
|
69
70
|
display: flex;
|
70
71
|
flex-direction: row;
|
71
72
|
}
|
@@ -6,6 +6,10 @@ declare const Option_base: import("../../utils/mixins/index.types").Constructor<
|
|
6
6
|
* option component, which is used as a list item in a select component.<br/>
|
7
7
|
* We can pass an icon which will be displayed in leading position of the option label text.
|
8
8
|
*
|
9
|
+
* @dependency mdc-icon
|
10
|
+
* @dependency mdc-text
|
11
|
+
* @dependency mdc-tooltip
|
12
|
+
*
|
9
13
|
* @tagname mdc-option
|
10
14
|
*
|
11
15
|
* @slot default - This is a default/unnamed slot
|
@@ -29,6 +33,19 @@ declare class Option extends Option_base {
|
|
29
33
|
*/
|
30
34
|
ariaLabel: string | null;
|
31
35
|
connectedCallback(): void;
|
36
|
+
disconnectedCallback(): void;
|
37
|
+
private handleClick;
|
38
|
+
/**
|
39
|
+
* Display a tooltip for long text label with an ellipse at the end.
|
40
|
+
* Create the tooltip programmatically after the nearest select component or the parent element.
|
41
|
+
* @param event - A focus or a mouse event.
|
42
|
+
*/
|
43
|
+
private displayTooltipForLongText;
|
44
|
+
/**
|
45
|
+
* Removes the dynamically created tooltip for long text label on focus or mouse leave.
|
46
|
+
* This is triggered on focusout and mouseout events.
|
47
|
+
*/
|
48
|
+
private hideTooltipOnLeave;
|
32
49
|
/**
|
33
50
|
* Listens to changes in the default slot and updates the label of the option accordingly.
|
34
51
|
* This is used to set the label of the option when it is not explicitly set.
|
@@ -11,15 +11,20 @@ import { html, nothing } from 'lit';
|
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
13
|
import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
14
|
+
import { TAG_NAME as TOOLTIP_TAG_NAME } from '../tooltip/tooltip.constants';
|
14
15
|
import ListItem from '../listitem/listitem.component';
|
15
16
|
import { LISTITEM_VARIANTS } from '../listitem/listitem.constants';
|
16
17
|
import { TYPE } from '../text/text.constants';
|
17
|
-
import { SELECTED_ICON_NAME } from './option.constants';
|
18
|
+
import { SELECTED_ICON_NAME, TOOLTIP_ID } from './option.constants';
|
18
19
|
import styles from './option.styles';
|
19
20
|
/**
|
20
21
|
* option component, which is used as a list item in a select component.<br/>
|
21
22
|
* We can pass an icon which will be displayed in leading position of the option label text.
|
22
23
|
*
|
24
|
+
* @dependency mdc-icon
|
25
|
+
* @dependency mdc-text
|
26
|
+
* @dependency mdc-tooltip
|
27
|
+
*
|
23
28
|
* @tagname mdc-option
|
24
29
|
*
|
25
30
|
* @slot default - This is a default/unnamed slot
|
@@ -53,6 +58,56 @@ class Option extends FormInternalsMixin(ListItem) {
|
|
53
58
|
this.sideHeaderText = undefined;
|
54
59
|
this.sublineText = undefined;
|
55
60
|
this.dataAriaLabel = undefined;
|
61
|
+
this.addEventListener('focusin', this.displayTooltipForLongText);
|
62
|
+
this.addEventListener('mouseover', this.displayTooltipForLongText);
|
63
|
+
this.addEventListener('focusout', this.hideTooltipOnLeave);
|
64
|
+
this.addEventListener('mouseout', this.hideTooltipOnLeave);
|
65
|
+
this.addEventListener('click', this.handleClick);
|
66
|
+
}
|
67
|
+
disconnectedCallback() {
|
68
|
+
super.disconnectedCallback();
|
69
|
+
this.removeEventListener('focusin', this.displayTooltipForLongText);
|
70
|
+
this.removeEventListener('mouseover', this.displayTooltipForLongText);
|
71
|
+
this.removeEventListener('focusout', this.hideTooltipOnLeave);
|
72
|
+
this.removeEventListener('mouseout', this.hideTooltipOnLeave);
|
73
|
+
this.removeEventListener('click', this.handleClick);
|
74
|
+
}
|
75
|
+
handleClick() {
|
76
|
+
// When the select dropdown (popover) is open,
|
77
|
+
// then if the tooltip is open, it has to be closed first.
|
78
|
+
// only then we can close the dropdown on option click/select.
|
79
|
+
this.hideTooltipOnLeave();
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* Display a tooltip for long text label with an ellipse at the end.
|
83
|
+
* Create the tooltip programmatically after the nearest select component or the parent element.
|
84
|
+
* @param event - A focus or a mouse event.
|
85
|
+
*/
|
86
|
+
displayTooltipForLongText(event) {
|
87
|
+
var _a, _b;
|
88
|
+
const dimensions = (_a = event.target.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('[part="leading-text-primary-label"]');
|
89
|
+
if (dimensions && dimensions.scrollWidth && dimensions.clientWidth
|
90
|
+
&& dimensions.scrollWidth <= (dimensions === null || dimensions === void 0 ? void 0 : dimensions.clientWidth)) {
|
91
|
+
// it means that the option label text is fully visible and we do not need to show the tooltip.
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
// Create tooltip for long text label which has an ellipse at the end.
|
95
|
+
const tooltip = document.createElement(TOOLTIP_TAG_NAME);
|
96
|
+
tooltip.id = TOOLTIP_ID;
|
97
|
+
tooltip.textContent = (_b = this.label) !== null && _b !== void 0 ? _b : '';
|
98
|
+
tooltip.setAttribute('triggerid', this.id);
|
99
|
+
tooltip.setAttribute('visible', '');
|
100
|
+
// Add tooltip programmatically after the nearest select component or the parent element.
|
101
|
+
const parent = this.closest('mdc-select') || this.parentElement;
|
102
|
+
parent === null || parent === void 0 ? void 0 : parent.after(tooltip);
|
103
|
+
}
|
104
|
+
/**
|
105
|
+
* Removes the dynamically created tooltip for long text label on focus or mouse leave.
|
106
|
+
* This is triggered on focusout and mouseout events.
|
107
|
+
*/
|
108
|
+
hideTooltipOnLeave() {
|
109
|
+
const existingTooltip = document.querySelector(`#${TOOLTIP_ID}`);
|
110
|
+
existingTooltip === null || existingTooltip === void 0 ? void 0 : existingTooltip.remove();
|
56
111
|
}
|
57
112
|
/**
|
58
113
|
* Listens to changes in the default slot and updates the label of the option accordingly.
|
@@ -82,18 +137,18 @@ class Option extends FormInternalsMixin(ListItem) {
|
|
82
137
|
}
|
83
138
|
}
|
84
139
|
render() {
|
140
|
+
const prefixIconContent = this.prefixIcon ? html `
|
141
|
+
<div part="leading-icon">
|
142
|
+
<mdc-icon slot="leading-controls" name="${ifDefined(this.prefixIcon)}"></mdc-icon>
|
143
|
+
</div>
|
144
|
+
` : nothing;
|
85
145
|
const selectedIcon = this.selected ? html `
|
86
146
|
<mdc-icon slot="trailing-controls" name="${SELECTED_ICON_NAME}"></mdc-icon>
|
87
|
-
` : nothing;
|
88
|
-
const prefixIcon = this.prefixIcon ? html `
|
89
|
-
<mdc-icon slot="leading-controls" name="${ifDefined(this.prefixIcon)}"></mdc-icon>
|
90
147
|
` : nothing;
|
91
148
|
return html `
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
${this.getText('leading-text-primary-label', TYPE.BODY_MIDSIZE_REGULAR, this.label)}
|
96
|
-
</div>
|
149
|
+
${prefixIconContent}
|
150
|
+
<div part="leading-text">
|
151
|
+
${this.getText('leading-text-primary-label', TYPE.BODY_MIDSIZE_REGULAR, this.label)}
|
97
152
|
</div>
|
98
153
|
<div part="trailing">
|
99
154
|
${selectedIcon}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { IconNames } from '../icon/icon.types';
|
2
2
|
declare const SELECTED_ICON_NAME: Extract<IconNames, 'check-bold'>;
|
3
|
+
declare const TOOLTIP_ID = "dynamic-option-tooltip-popover";
|
3
4
|
declare const TAG_NAME: "mdc-option";
|
4
|
-
export { SELECTED_ICON_NAME, TAG_NAME };
|
5
|
+
export { SELECTED_ICON_NAME, TAG_NAME, TOOLTIP_ID };
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import utils from '../../utils/tag-name';
|
2
2
|
const SELECTED_ICON_NAME = 'check-bold';
|
3
|
+
const TOOLTIP_ID = 'dynamic-option-tooltip-popover';
|
3
4
|
const TAG_NAME = utils.constructTagName('option');
|
4
|
-
export { SELECTED_ICON_NAME, TAG_NAME };
|
5
|
+
export { SELECTED_ICON_NAME, TAG_NAME, TOOLTIP_ID };
|
@@ -1,10 +1,32 @@
|
|
1
1
|
import { css } from 'lit';
|
2
2
|
const styles = css `
|
3
|
+
:host {
|
4
|
+
--mdc-option-icon-width: 1rem;
|
5
|
+
|
6
|
+
display: flex;
|
7
|
+
flex-direction: row;
|
8
|
+
align-items: center;
|
9
|
+
}
|
3
10
|
:host::part(list-item) {
|
4
11
|
height: 2.25rem;
|
5
12
|
}
|
6
13
|
:host::part(default-slot) {
|
7
14
|
display: none;
|
8
15
|
}
|
16
|
+
:host::part(leading-icon),
|
17
|
+
:host::part(trailing) {
|
18
|
+
flex: 1;
|
19
|
+
max-width: var(--mdc-option-icon-width);
|
20
|
+
}
|
21
|
+
:host::part(leading-text) {
|
22
|
+
flex: 1;
|
23
|
+
/** 2x of leading and trailing icon width + 2x of column gap on both sides of the label text */
|
24
|
+
width: calc(100% - (2 * var(--mdc-option-icon-width)) - (2 * var(--mdc-listitem-column-gap)));
|
25
|
+
}
|
26
|
+
:host::part(leading-text-primary-label) {
|
27
|
+
overflow: hidden;
|
28
|
+
text-overflow: ellipsis;
|
29
|
+
white-space: nowrap;
|
30
|
+
}
|
9
31
|
`;
|
10
32
|
export default [styles];
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -26,6 +26,8 @@ declare const Popover_base: import("../../utils/mixins/index.types").Constructor
|
|
26
26
|
* @cssproperty --mdc-popover-inverted-border-color - inverted border color of the popover
|
27
27
|
* @cssproperty --mdc-popover-inverted-text-color - inverted text color of the popover
|
28
28
|
* @cssproperty --mdc-popover-elevation-3 - elevation of the popover
|
29
|
+
* @cssproperty --mdc-popover-max-width - max width of the popover
|
30
|
+
* @cssproperty --mdc-popover-max-height - max height of the popover
|
29
31
|
*
|
30
32
|
* @slot - Default slot for the popover content
|
31
33
|
*
|
@@ -42,6 +42,8 @@ import { PopoverUtils } from './popover.utils';
|
|
42
42
|
* @cssproperty --mdc-popover-inverted-border-color - inverted border color of the popover
|
43
43
|
* @cssproperty --mdc-popover-inverted-text-color - inverted text color of the popover
|
44
44
|
* @cssproperty --mdc-popover-elevation-3 - elevation of the popover
|
45
|
+
* @cssproperty --mdc-popover-max-width - max width of the popover
|
46
|
+
* @cssproperty --mdc-popover-max-height - max height of the popover
|
45
47
|
*
|
46
48
|
* @slot - Default slot for the popover content
|
47
49
|
*
|
@@ -10,6 +10,8 @@ const styles = css `
|
|
10
10
|
--mdc-popover-inverted-border-color: var(--mds-color-theme-inverted-outline-primary-normal);
|
11
11
|
--mdc-popover-inverted-text-color: var(--mds-color-theme-inverted-text-primary-normal);
|
12
12
|
--mdc-popover-elevation-3: var(--mds-elevation-3);
|
13
|
+
--mdc-popover-max-width: unset;
|
14
|
+
--mdc-popover-max-height: auto;
|
13
15
|
|
14
16
|
display: none;
|
15
17
|
position: absolute;
|
@@ -18,6 +20,7 @@ const styles = css `
|
|
18
20
|
border-radius: 0.5rem;
|
19
21
|
border: 0.0625rem solid var(--mdc-popover-border-color);
|
20
22
|
filter: var(--mdc-popover-elevation-3);
|
23
|
+
width: var(--mdc-popover-max-width);
|
21
24
|
}
|
22
25
|
|
23
26
|
:host([visible]) {
|
@@ -48,6 +51,7 @@ const styles = css `
|
|
48
51
|
overflow-y: auto;
|
49
52
|
min-width: max-content;
|
50
53
|
z-index: 9998;
|
54
|
+
max-height: var(--mdc-popover-max-height);
|
51
55
|
}
|
52
56
|
|
53
57
|
.popover-hover-bridge {
|
@@ -0,0 +1,191 @@
|
|
1
|
+
import type { PropertyValues, TemplateResult } from 'lit';
|
2
|
+
import { CSSResult } from 'lit';
|
3
|
+
import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
|
4
|
+
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
5
|
+
declare const Select_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
6
|
+
/**
|
7
|
+
* The mdc-select component is a dropdown selection control that allows users to pick an option from a predefined list.
|
8
|
+
* It is designed to work with `mdc-option` for individual options and `mdc-optgroup` for grouping related options.
|
9
|
+
* The component ensures accessibility and usability while handling various use cases,
|
10
|
+
* including long text truncation with tooltip support.
|
11
|
+
*
|
12
|
+
* @dependency mdc-icon
|
13
|
+
* @dependency mdc-popover
|
14
|
+
* @dependency mdc-text
|
15
|
+
*
|
16
|
+
* @tagname mdc-select
|
17
|
+
*
|
18
|
+
* @slot default - This is a default/unnamed slot for options and/or option group.
|
19
|
+
*
|
20
|
+
* @event click - (React: onClick) This event is dispatched when the select is clicked.
|
21
|
+
* @event change - (React: onChange) This event is dispatched when the select is changed.
|
22
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the select.
|
23
|
+
* @event focus - (React: onFocus) This event is dispatched when the select receives focus.
|
24
|
+
*/
|
25
|
+
declare class Select extends Select_base implements AssociatedFormControl {
|
26
|
+
/**
|
27
|
+
* The placeholder text which will be shown on the text if provided.
|
28
|
+
*/
|
29
|
+
placeholder?: string;
|
30
|
+
/**
|
31
|
+
* readonly attribute of the select field. If true, the select is read-only.
|
32
|
+
* @default false
|
33
|
+
*/
|
34
|
+
readonly: boolean;
|
35
|
+
/**
|
36
|
+
* height attribute of the select field. If set,
|
37
|
+
* then a scroll bar will be visible when there more options than the adjusted height.
|
38
|
+
* @default 'auto'
|
39
|
+
*/
|
40
|
+
height: string;
|
41
|
+
/** @internal */
|
42
|
+
optionsList: Array<HTMLElement>;
|
43
|
+
/** @internal */
|
44
|
+
private baseIconName;
|
45
|
+
/** @internal */
|
46
|
+
selectedValueText?: string;
|
47
|
+
/** @internal */
|
48
|
+
selectedValue: string;
|
49
|
+
/** @internal */
|
50
|
+
showPopover: boolean;
|
51
|
+
/** @internal */
|
52
|
+
activeDescendant: string;
|
53
|
+
/**
|
54
|
+
* @internal
|
55
|
+
* The native select element
|
56
|
+
*/
|
57
|
+
inputElement: HTMLInputElement;
|
58
|
+
connectedCallback(): void;
|
59
|
+
disconnectedCallback(): void;
|
60
|
+
/**
|
61
|
+
* A helper function which returns a flattened array of all valid options from the assigned slot.
|
62
|
+
* It takes care of the edge cases where the option is either a direct child or a
|
63
|
+
* child of an option group.
|
64
|
+
*/
|
65
|
+
private getAllValidOptions;
|
66
|
+
private handlePopoverOpen;
|
67
|
+
private handlePopoverClose;
|
68
|
+
/**
|
69
|
+
* Updates the tabindex and selected attribute of the options.
|
70
|
+
* If selectedOption is provided, it will be set as the selected option.
|
71
|
+
* Otherwise, it will set the first option as the selected option.
|
72
|
+
* @param selectedOption - The option which should be selected.
|
73
|
+
*/
|
74
|
+
private updateTabIndexForAllOptions;
|
75
|
+
/**
|
76
|
+
* A private method which is called when an option is clicked.
|
77
|
+
* It is used to update the tabindex and selected attribute of the options.
|
78
|
+
* @param event - The event which triggered this function.
|
79
|
+
*/
|
80
|
+
private handleOptionsClick;
|
81
|
+
/**
|
82
|
+
* Sets the selected value based on the provided option element.
|
83
|
+
* It retrieves the 'label' attribute of the option, if present,
|
84
|
+
* otherwise it falls back to the option's text content.
|
85
|
+
* @param option - The option element from which to set the selected value.
|
86
|
+
*/
|
87
|
+
private setSelectedValue;
|
88
|
+
/**
|
89
|
+
* Manages the required state of the select.
|
90
|
+
* If the value is not set and the requiredLabel property is set,
|
91
|
+
* then the select is invalid.
|
92
|
+
*/
|
93
|
+
private manageRequired;
|
94
|
+
/**
|
95
|
+
* @internal
|
96
|
+
* Resets the select to its initial state.
|
97
|
+
*/
|
98
|
+
formResetCallback(): void;
|
99
|
+
/** @internal */
|
100
|
+
formStateRestoreCallback(state: string): void;
|
101
|
+
private dispatchChange;
|
102
|
+
/**
|
103
|
+
* Handles the keydown event on the select element.
|
104
|
+
* If the popover is open, then it calls `handlePopoverOnOpen` with the event.
|
105
|
+
* If the popover is closed, then it calls `handlePopoverOnClose` with the event.
|
106
|
+
* @param event - The keyboard event.
|
107
|
+
*/
|
108
|
+
private handleKeydown;
|
109
|
+
/**
|
110
|
+
* Handles the keydown event on the select element when the popover is open.
|
111
|
+
* The options are as follows:
|
112
|
+
* - SPACE or ENTER: Selects the currently active option and closes the popover.
|
113
|
+
* - ESCAPE: Closes the popover.
|
114
|
+
* - HOME: Sets focus and tabindex on the first option.
|
115
|
+
* - END: Sets focus and tabindex on the last option.
|
116
|
+
* - ARROW_DOWN, ARROW_UP, PAGE_DOWN, PAGE_UP: Handles navigation between options.
|
117
|
+
* @param event - The keyboard event.
|
118
|
+
*/
|
119
|
+
private handlePopoverOnOpen;
|
120
|
+
/**
|
121
|
+
* Handles the keydown event on the select element when the popover is closed.
|
122
|
+
* The options are as follows:
|
123
|
+
* - ARROW_DOWN, ARROW_UP, SPACE: Opens the popover and prevents the default scrolling behavior.
|
124
|
+
* - ENTER: Opens the popover, prevents default scrolling, and submits the form if the popover is closed.
|
125
|
+
* - HOME: Opens the popover and sets focus and tabindex on the first option.
|
126
|
+
* - END: Opens the popover and sets focus and tabindex on the last option.
|
127
|
+
* @param event - The keyboard event.
|
128
|
+
*/
|
129
|
+
private handlePopoverOnClose;
|
130
|
+
/**
|
131
|
+
* Handles the navigation of options when the user presses
|
132
|
+
* ArrowUp, ArrowDown, PageUp, or PageDown keys.
|
133
|
+
* @param event - The keyboard event that triggered the navigation.
|
134
|
+
*/
|
135
|
+
private handleOptionsNavigation;
|
136
|
+
/**
|
137
|
+
* Calculates the new index based on the pressed navigation key.
|
138
|
+
* Supports ArrowUp, ArrowDown, PageUp, and PageDown keys for navigating options.
|
139
|
+
* - ArrowDown: Moves focus to the next option, if available.
|
140
|
+
* - ArrowUp: Moves focus to the previous option, if available.
|
141
|
+
* - PageDown: Moves focus 10 options down or to the last option.
|
142
|
+
* - PageUp: Moves focus 10 options up or to the first option.
|
143
|
+
*
|
144
|
+
* @param key - The navigation key that was pressed.
|
145
|
+
* @param currentIndex - The current index of the focused option.
|
146
|
+
* @param optionsLength - The total number of options.
|
147
|
+
* @returns The new index to focus on, or -1 if no movement is possible.
|
148
|
+
*/
|
149
|
+
private getNewIndexBasedOnKey;
|
150
|
+
private updateActivedescendant;
|
151
|
+
private resetActivedescendant;
|
152
|
+
private setFocusAndTabIndex;
|
153
|
+
private openPopover;
|
154
|
+
private closePopover;
|
155
|
+
/**
|
156
|
+
* Handles the first updated lifecycle event.
|
157
|
+
* If an option is selected, use that as the value.
|
158
|
+
* If not, use the placeholder if it exists, otherwise use the first option.
|
159
|
+
*/
|
160
|
+
firstUpdated(): void;
|
161
|
+
/**
|
162
|
+
* Generates the native select element.
|
163
|
+
* The native select element is not rendered directly and is not visible on the UI.
|
164
|
+
* It's rendered only on the DOM for accessibility purposes.
|
165
|
+
* Instead, the overlay uses the native select element to generate the list of options.
|
166
|
+
* @returns A TemplateResult representing the native select element.
|
167
|
+
*/
|
168
|
+
private getNativeSelect;
|
169
|
+
/**
|
170
|
+
* This method maps over all valid options and constructs their corresponding
|
171
|
+
* HTML `<option>` elements. The attributes such as `value`, `label`, `disabled`,
|
172
|
+
* and `selected` are extracted from the respective option elements.
|
173
|
+
* If the attribute is not present, a default value or fallback is used.
|
174
|
+
* The content of each `<option>` is set to the text content of the option element.
|
175
|
+
* @returns An array of `TemplateResult` representing the option elements.
|
176
|
+
*/
|
177
|
+
private getOptionsContentFromSlot;
|
178
|
+
/**
|
179
|
+
* Generates the content for the popover associated with the select component.
|
180
|
+
* If the component is disabled or readonly, returns `nothing`.
|
181
|
+
* Otherwise, returns a `TemplateResult` that renders a popover with various configurations
|
182
|
+
* such as visibility, interaction, and event handlers.
|
183
|
+
* The popover acts as a dropdown list with options, allowing user interaction.
|
184
|
+
*/
|
185
|
+
private getPopoverContent;
|
186
|
+
private shouldFocusSelect;
|
187
|
+
updated(changedProperties: PropertyValues): void;
|
188
|
+
render(): TemplateResult<1>;
|
189
|
+
static styles: Array<CSSResult>;
|
190
|
+
}
|
191
|
+
export default Select;
|