@fluid-topics/ft-select 1.3.21 → 1.3.22
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/ft-select.d.ts +3 -2
- package/build/ft-select.js +28 -12
- package/build/ft-select.light.js +126 -111
- package/build/ft-select.min.js +146 -131
- package/build/ft-select.styles.js +5 -1
- package/package.json +7 -7
package/build/ft-select.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class FtSelect extends FtLitElement implements FtSelectProperties
|
|
|
14
14
|
static searchTimeoutMilliseconds: number;
|
|
15
15
|
static styles: import("lit").CSSResult[];
|
|
16
16
|
label: string;
|
|
17
|
-
ariaLabel: string;
|
|
17
|
+
ariaLabel: string | null;
|
|
18
18
|
helper: string;
|
|
19
19
|
outlined: boolean;
|
|
20
20
|
disabled: boolean;
|
|
@@ -36,7 +36,7 @@ export declare class FtSelect extends FtLitElement implements FtSelectProperties
|
|
|
36
36
|
private optionsSlot?;
|
|
37
37
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
38
38
|
private renderOption;
|
|
39
|
-
protected
|
|
39
|
+
protected willUpdate(props: PropertyValues): void;
|
|
40
40
|
protected contentAvailableCallback(props: PropertyValues): void;
|
|
41
41
|
private get hasOptionsMenuOpen();
|
|
42
42
|
private get hasOptions();
|
|
@@ -46,6 +46,7 @@ export declare class FtSelect extends FtLitElement implements FtSelectProperties
|
|
|
46
46
|
private isKeyAlphanumeric;
|
|
47
47
|
private handleAlphanumericPress;
|
|
48
48
|
private onOptionKeyDown;
|
|
49
|
+
private getOptionId;
|
|
49
50
|
private selectOption;
|
|
50
51
|
private hideOptions;
|
|
51
52
|
connectedCallback(): void;
|
package/build/ft-select.js
CHANGED
|
@@ -8,11 +8,13 @@ import { html, nothing } from "lit";
|
|
|
8
8
|
import { property, query, state } from "lit/decorators.js";
|
|
9
9
|
import { classMap } from "lit/directives/class-map.js";
|
|
10
10
|
import { repeat } from "lit/directives/repeat.js";
|
|
11
|
+
import { when } from "lit/directives/when.js";
|
|
12
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
11
13
|
import { computeOffsetAutoPosition, deepEqual, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
12
|
-
import { FtTypography, FtTypographyBody2, FtTypographyCaption } from "@fluid-topics/ft-typography";
|
|
14
|
+
import { FtTypography, FtTypographyBody2, FtTypographyCaption, FtTypographyVariants } from "@fluid-topics/ft-typography";
|
|
13
15
|
import { FtInputLabel } from "@fluid-topics/ft-input-label";
|
|
14
16
|
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
15
|
-
import { FtIcon } from "@fluid-topics/ft-icon";
|
|
17
|
+
import { FtIcon, FtIcons } from "@fluid-topics/ft-icon";
|
|
16
18
|
import { FtSelectCssVariables, styles } from "./ft-select.styles";
|
|
17
19
|
class FtSelectOption extends FtLitElement {
|
|
18
20
|
constructor() {
|
|
@@ -44,7 +46,7 @@ class FtSelect extends FtLitElement {
|
|
|
44
46
|
constructor() {
|
|
45
47
|
super(...arguments);
|
|
46
48
|
this.label = "";
|
|
47
|
-
this.ariaLabel =
|
|
49
|
+
this.ariaLabel = null;
|
|
48
50
|
this.helper = "";
|
|
49
51
|
this.outlined = false;
|
|
50
52
|
this.disabled = false;
|
|
@@ -78,6 +80,7 @@ class FtSelect extends FtLitElement {
|
|
|
78
80
|
<div class="ft-select--main-panel" part="main-panel">
|
|
79
81
|
<ft-input-label text="${this.label}"
|
|
80
82
|
part="label"
|
|
83
|
+
id="label"
|
|
81
84
|
?disabled=${disabled}
|
|
82
85
|
?outlined=${this.outlined}
|
|
83
86
|
?raised=${hasOptionSelected || optionsDisplayed}
|
|
@@ -91,26 +94,28 @@ class FtSelect extends FtLitElement {
|
|
|
91
94
|
this.focusOptions = this.optionsDisplayed;
|
|
92
95
|
}}
|
|
93
96
|
@keydown=${this.onMainPanelKeyDown}
|
|
94
|
-
aria-label="${this.ariaLabel}"
|
|
97
|
+
aria-label="${ifDefined(this.ariaLabel)}"
|
|
98
|
+
aria-labelledby="${when(!this.ariaLabel, () => "label")}"
|
|
95
99
|
aria-haspopup="listbox"
|
|
96
100
|
aria-expanded="${optionsDisplayed}"
|
|
101
|
+
aria-activedescendant="${ifDefined(this.getOptionId(this.selectedOption))}"
|
|
97
102
|
role="combobox">
|
|
98
103
|
<ft-ripple ?disabled=${disabled} ?activated=${!this.outlined}></ft-ripple>
|
|
99
|
-
<ft-typography variant="body1" class="ft-select--selected-option">
|
|
104
|
+
<ft-typography variant="${FtTypographyVariants.body1}" class="ft-select--selected-option">
|
|
100
105
|
${(_e = (_d = this.selectedOption) === null || _d === void 0 ? void 0 : _d.label) !== null && _e !== void 0 ? _e : ""}
|
|
101
106
|
</ft-typography>
|
|
102
|
-
<ft-icon
|
|
107
|
+
<ft-icon aria-hidden="true" .value=${optionsDisplayed ? FtIcons.THIN_ARROW_UP : FtIcons.THIN_ARROW}></ft-icon>
|
|
103
108
|
</div>
|
|
104
109
|
<div class="ft-select--options"
|
|
105
110
|
part="options"
|
|
106
111
|
@keydown=${this.onOptionsKeyDown}
|
|
107
|
-
|
|
108
|
-
${repeat(this.options, (option) => option.value, (option) => this.renderOption(option))}
|
|
112
|
+
role="listbox">
|
|
113
|
+
${repeat(this.options, (option) => option.value, (option, index) => this.renderOption(option, index))}
|
|
109
114
|
</div>
|
|
110
115
|
</div>
|
|
111
116
|
<slot name="helper" part="helper">
|
|
112
117
|
${this.helper ? html `
|
|
113
|
-
<ft-typography class="ft-select--helper-text" variant="caption">${this.helper}
|
|
118
|
+
<ft-typography class="ft-select--helper-text" variant="${FtTypographyVariants.caption}">${this.helper}
|
|
114
119
|
</ft-typography>` : nothing}
|
|
115
120
|
</slot>
|
|
116
121
|
</div>
|
|
@@ -119,7 +124,7 @@ class FtSelect extends FtLitElement {
|
|
|
119
124
|
></slot>
|
|
120
125
|
`;
|
|
121
126
|
}
|
|
122
|
-
renderOption(option) {
|
|
127
|
+
renderOption(option, index) {
|
|
123
128
|
const selected = this.selectedOption === option;
|
|
124
129
|
const classes = {
|
|
125
130
|
"ft-select--option": true,
|
|
@@ -132,6 +137,7 @@ class FtSelect extends FtLitElement {
|
|
|
132
137
|
tabindex="0"
|
|
133
138
|
aria-label="${option.label}"
|
|
134
139
|
data-value="${option.value}"
|
|
140
|
+
id="${"option-" + index}"
|
|
135
141
|
@keydown=${(e) => this.onOptionKeyDown(e, option)}
|
|
136
142
|
@click=${() => this.selectOption(option)}>
|
|
137
143
|
<ft-ripple ?primary=${selected} ?activated=${selected}></ft-ripple>
|
|
@@ -139,8 +145,8 @@ class FtSelect extends FtLitElement {
|
|
|
139
145
|
</div>
|
|
140
146
|
`;
|
|
141
147
|
}
|
|
142
|
-
|
|
143
|
-
super.
|
|
148
|
+
willUpdate(props) {
|
|
149
|
+
super.willUpdate(props);
|
|
144
150
|
if (props.has("options")) {
|
|
145
151
|
this.selectedOption = this.options.filter((o) => o.selected)[0];
|
|
146
152
|
}
|
|
@@ -265,6 +271,16 @@ class FtSelect extends FtLitElement {
|
|
|
265
271
|
(_a = this.mainPanel) === null || _a === void 0 ? void 0 : _a.focus();
|
|
266
272
|
}
|
|
267
273
|
}
|
|
274
|
+
getOptionId(selectedOption) {
|
|
275
|
+
if (!selectedOption) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
const index = this.options.findIndex((o) => deepEqual(o.value, selectedOption.value));
|
|
279
|
+
if (index === -1) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
return `option-${index}`;
|
|
283
|
+
}
|
|
268
284
|
selectOption(option) {
|
|
269
285
|
var _a, _b;
|
|
270
286
|
if (!deepEqual((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value, option.value)) {
|