@fluid-topics/ft-select 1.3.16 → 1.3.18
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.js +19 -18
- package/build/ft-select.light.js +1 -0
- package/build/ft-select.min.js +38 -37
- package/package.json +7 -7
package/build/ft-select.js
CHANGED
|
@@ -34,7 +34,7 @@ __decorate([
|
|
|
34
34
|
property({ type: String })
|
|
35
35
|
], FtSelectOption.prototype, "label", void 0);
|
|
36
36
|
__decorate([
|
|
37
|
-
property({ type: Object, converter: value => value })
|
|
37
|
+
property({ type: Object, converter: (value) => value })
|
|
38
38
|
], FtSelectOption.prototype, "value", void 0);
|
|
39
39
|
__decorate([
|
|
40
40
|
property({ type: Boolean, reflect: true })
|
|
@@ -59,8 +59,8 @@ class FtSelect extends FtLitElement {
|
|
|
59
59
|
}
|
|
60
60
|
render() {
|
|
61
61
|
var _a, _b, _c, _d, _e;
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
const optionsDisplayed = this.hasOptionsMenuOpen;
|
|
63
|
+
const disabled = this.disabled || !this.hasOptions;
|
|
64
64
|
const hasOptionSelected = ((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) != null || ((_c = (_b = this.selectedOption) === null || _b === void 0 ? void 0 : _b.label) !== null && _c !== void 0 ? _c : "").length > 0;
|
|
65
65
|
const classes = {
|
|
66
66
|
"ft-select": true,
|
|
@@ -71,7 +71,7 @@ class FtSelect extends FtLitElement {
|
|
|
71
71
|
"ft-select--has-option-selected": hasOptionSelected,
|
|
72
72
|
"ft-select--no-label": !this.label,
|
|
73
73
|
"ft-select--fixed": this.fixedMenuPosition,
|
|
74
|
-
"ft-select--in-error": this.error
|
|
74
|
+
"ft-select--in-error": this.error,
|
|
75
75
|
};
|
|
76
76
|
return html `
|
|
77
77
|
<div class="${classMap(classes)}" part="container">
|
|
@@ -105,7 +105,7 @@ class FtSelect extends FtLitElement {
|
|
|
105
105
|
part="options"
|
|
106
106
|
@keydown=${this.onOptionsKeyDown}
|
|
107
107
|
innerrole="listbox">
|
|
108
|
-
${repeat(this.options, option => option.value, option => this.renderOption(option))}
|
|
108
|
+
${repeat(this.options, (option) => option.value, (option) => this.renderOption(option))}
|
|
109
109
|
</div>
|
|
110
110
|
</div>
|
|
111
111
|
<slot name="helper" part="helper">
|
|
@@ -120,16 +120,17 @@ class FtSelect extends FtLitElement {
|
|
|
120
120
|
`;
|
|
121
121
|
}
|
|
122
122
|
renderOption(option) {
|
|
123
|
-
|
|
123
|
+
const selected = this.selectedOption === option;
|
|
124
124
|
const classes = {
|
|
125
125
|
"ft-select--option": true,
|
|
126
126
|
"ft-select--option-selected": selected,
|
|
127
|
-
"ft-typography--body2": true
|
|
127
|
+
"ft-typography--body2": true,
|
|
128
128
|
};
|
|
129
129
|
return html `
|
|
130
130
|
<div class="${classMap(classes)}"
|
|
131
131
|
part="option"
|
|
132
132
|
tabindex="0"
|
|
133
|
+
aria-label="${option.label}"
|
|
133
134
|
data-value="${option.value}"
|
|
134
135
|
@keydown=${(e) => this.onOptionKeyDown(e, option)}
|
|
135
136
|
@click=${() => this.selectOption(option)}>
|
|
@@ -141,7 +142,7 @@ class FtSelect extends FtLitElement {
|
|
|
141
142
|
update(props) {
|
|
142
143
|
super.update(props);
|
|
143
144
|
if (props.has("options")) {
|
|
144
|
-
this.selectedOption = this.options.filter(o => o.selected)[0];
|
|
145
|
+
this.selectedOption = this.options.filter((o) => o.selected)[0];
|
|
145
146
|
}
|
|
146
147
|
if (props.has("selectedOption")) {
|
|
147
148
|
this.optionsDisplayed = false;
|
|
@@ -173,7 +174,7 @@ class FtSelect extends FtLitElement {
|
|
|
173
174
|
updateOptionsFromSlot(e) {
|
|
174
175
|
var _a;
|
|
175
176
|
e.stopPropagation();
|
|
176
|
-
|
|
177
|
+
const optionsFromSlot = (_a = this.optionsSlot) === null || _a === void 0 ? void 0 : _a.assignedElements().map((n) => n);
|
|
177
178
|
if (optionsFromSlot && optionsFromSlot.length > 0) {
|
|
178
179
|
this.options = optionsFromSlot;
|
|
179
180
|
}
|
|
@@ -231,26 +232,26 @@ class FtSelect extends FtLitElement {
|
|
|
231
232
|
optionToFocus === null || optionToFocus === void 0 ? void 0 : optionToFocus.focus();
|
|
232
233
|
}
|
|
233
234
|
isKeyAlphanumeric(key) {
|
|
234
|
-
|
|
235
|
-
return (charCode > 47 && charCode < 58)
|
|
236
|
-
(charCode > 64 && charCode < 91)
|
|
237
|
-
(charCode > 96 && charCode < 123); // lower alpha (a-z)
|
|
235
|
+
const charCode = key.charCodeAt(0);
|
|
236
|
+
return (charCode > 47 && charCode < 58) // numeric (0-9)
|
|
237
|
+
|| (charCode > 64 && charCode < 91) // upper alpha (A-Z)
|
|
238
|
+
|| (charCode > 96 && charCode < 123); // lower alpha (a-z)
|
|
238
239
|
}
|
|
239
240
|
handleAlphanumericPress(c) {
|
|
240
241
|
var _a, _b;
|
|
241
|
-
|
|
242
|
+
const currentDate = new Date();
|
|
242
243
|
// Resetting current search if timeout elapsed
|
|
243
244
|
if (currentDate.getTime() - this.lastSearchInputDate.getTime() > FtSelect.searchTimeoutMilliseconds) {
|
|
244
245
|
this.currentSearch = "";
|
|
245
246
|
}
|
|
246
247
|
this.currentSearch += c.toLowerCase();
|
|
247
248
|
// Searching for option
|
|
248
|
-
|
|
249
|
+
const foundOption = this.options.find((opt) => { var _a; return ((_a = opt.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().substring(0, this.currentSearch.length)) === this.currentSearch; });
|
|
249
250
|
if (foundOption === undefined) {
|
|
250
251
|
this.lastSearchInputDate = currentDate;
|
|
251
252
|
return undefined;
|
|
252
253
|
}
|
|
253
|
-
|
|
254
|
+
const optionElement = (_b = (_a = this.optionsMenu) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-value="${foundOption.value}"]`)) !== null && _b !== void 0 ? _b : undefined;
|
|
254
255
|
this.lastSearchInputDate = currentDate;
|
|
255
256
|
return optionElement;
|
|
256
257
|
}
|
|
@@ -268,7 +269,7 @@ class FtSelect extends FtLitElement {
|
|
|
268
269
|
var _a, _b;
|
|
269
270
|
if (!deepEqual((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value, option.value)) {
|
|
270
271
|
this.selectedOption = option;
|
|
271
|
-
for (
|
|
272
|
+
for (const otherOption of this.options) {
|
|
272
273
|
otherOption.selected = otherOption === option;
|
|
273
274
|
}
|
|
274
275
|
this.dispatchEvent(new CustomEvent("change", { detail: (_b = this.selectedOption) === null || _b === void 0 ? void 0 : _b.value }));
|
|
@@ -294,7 +295,7 @@ FtSelect.searchTimeoutMilliseconds = 2000;
|
|
|
294
295
|
FtSelect.styles = [
|
|
295
296
|
FtTypographyBody2,
|
|
296
297
|
FtTypographyCaption,
|
|
297
|
-
styles
|
|
298
|
+
styles,
|
|
298
299
|
];
|
|
299
300
|
__decorate([
|
|
300
301
|
property({ type: String })
|
package/build/ft-select.light.js
CHANGED
|
@@ -694,6 +694,7 @@ Also for action icons.`,t.colorGray200),contentGlobalSubtle:e.extend("--ft-conte
|
|
|
694
694
|
<div class="${(0,ot.classMap)({"ft-select--option":!0,"ft-select--option-selected":n,"ft-typography--body2":!0})}"
|
|
695
695
|
part="option"
|
|
696
696
|
tabindex="0"
|
|
697
|
+
aria-label="${r.label}"
|
|
697
698
|
data-value="${r.value}"
|
|
698
699
|
@keydown=${l=>this.onOptionKeyDown(l,r)}
|
|
699
700
|
@click=${()=>this.selectOption(r)}>
|