@fluid-topics/ft-select 0.2.2 → 0.2.6
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 +9 -1
- package/build/ft-select.inline-styles.js +206 -164
- package/build/ft-select.js +50 -3
- package/build/ft-select.light.js +180 -138
- package/build/ft-select.min.js +204 -162
- package/package.json +7 -7
package/build/ft-select.js
CHANGED
|
@@ -45,12 +45,13 @@ export const FtSelectCssVariables = {
|
|
|
45
45
|
selectedOptionColor: FtCssVariable.extend("--ft-select-selected-option-color", designSystemVariables.colorOnSurface),
|
|
46
46
|
helperColor: FtCssVariable.extend("--ft-select-helper-color", designSystemVariables.colorOnSurfaceMedium),
|
|
47
47
|
optionsColor: FtCssVariable.extend("--ft-select-options-color", designSystemVariables.colorOnSurface),
|
|
48
|
-
optionsZIndex: FtCssVariable.create("--ft-select-options-z-index", "NUMBER", "
|
|
48
|
+
optionsZIndex: FtCssVariable.create("--ft-select-options-z-index", "NUMBER", "3"),
|
|
49
49
|
colorSurface: FtCssVariable.external(designSystemVariables.colorSurface, "Design system"),
|
|
50
50
|
colorOnSurfaceDisabled: FtCssVariable.external(designSystemVariables.colorOnSurfaceDisabled, "Design system"),
|
|
51
51
|
colorPrimary: FtCssVariable.external(designSystemVariables.colorPrimary, "Design system"),
|
|
52
52
|
borderRadiusS: FtCssVariable.external(designSystemVariables.borderRadiusS, "Design system"),
|
|
53
53
|
elevation02: FtCssVariable.external(designSystemVariables.elevation02, "Design system"),
|
|
54
|
+
colorError: FtCssVariable.external(designSystemVariables.colorError, "Design system"),
|
|
54
55
|
};
|
|
55
56
|
export class FtSelect extends FtLitElement {
|
|
56
57
|
constructor() {
|
|
@@ -59,6 +60,8 @@ export class FtSelect extends FtLitElement {
|
|
|
59
60
|
this.helper = "";
|
|
60
61
|
this.outlined = false;
|
|
61
62
|
this.disabled = false;
|
|
63
|
+
this.error = false;
|
|
64
|
+
this.fixedMenuPosition = false;
|
|
62
65
|
this.options = [];
|
|
63
66
|
this.optionsDisplayed = false;
|
|
64
67
|
this.focusOptions = false;
|
|
@@ -66,7 +69,7 @@ export class FtSelect extends FtLitElement {
|
|
|
66
69
|
}
|
|
67
70
|
render() {
|
|
68
71
|
var _a, _b, _c, _d, _e;
|
|
69
|
-
let optionsDisplayed =
|
|
72
|
+
let optionsDisplayed = this.hasOptionsMenuOpen;
|
|
70
73
|
let disabled = this.disabled || !this.hasOptions;
|
|
71
74
|
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;
|
|
72
75
|
const classes = {
|
|
@@ -76,7 +79,9 @@ export class FtSelect extends FtLitElement {
|
|
|
76
79
|
"ft-select--disabled": disabled,
|
|
77
80
|
"ft-select--options-displayed": optionsDisplayed,
|
|
78
81
|
"ft-select--has-option-selected": hasOptionSelected,
|
|
79
|
-
"ft-select--no-label": !this.label
|
|
82
|
+
"ft-select--no-label": !this.label,
|
|
83
|
+
"ft-select--fixed": this.fixedMenuPosition,
|
|
84
|
+
"ft-select--in-error": this.error
|
|
80
85
|
};
|
|
81
86
|
return html `
|
|
82
87
|
<div class="${classMap(classes)}" part="container">
|
|
@@ -86,6 +91,7 @@ export class FtSelect extends FtLitElement {
|
|
|
86
91
|
?disabled=${disabled}
|
|
87
92
|
?outlined=${this.outlined}
|
|
88
93
|
?raised=${hasOptionSelected || optionsDisplayed}
|
|
94
|
+
?error=${this.error}
|
|
89
95
|
></ft-input-label>
|
|
90
96
|
<div class="ft-select--input-panel"
|
|
91
97
|
part="selected-value"
|
|
@@ -148,6 +154,16 @@ export class FtSelect extends FtLitElement {
|
|
|
148
154
|
this.optionsDisplayed = false;
|
|
149
155
|
this.dispatchEvent(new CustomEvent("change", { detail: (_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value }));
|
|
150
156
|
}
|
|
157
|
+
if (props.has("optionsDisplayed")) {
|
|
158
|
+
if (this.fixedMenuPosition && this.hasOptionsMenuOpen) {
|
|
159
|
+
this.positionOptionsMenu();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
positionOptionsMenu() {
|
|
164
|
+
this.optionsMenu.style.top = this.mainPanel.getBoundingClientRect().top + this.mainPanel.getBoundingClientRect().height + "px";
|
|
165
|
+
this.optionsMenu.style.left = this.mainPanel.getBoundingClientRect().left + "px";
|
|
166
|
+
this.optionsMenu.style.minWidth = this.mainPanel.getBoundingClientRect().width + "px";
|
|
151
167
|
}
|
|
152
168
|
contentAvailableCallback(props) {
|
|
153
169
|
var _a, _b;
|
|
@@ -156,6 +172,9 @@ export class FtSelect extends FtLitElement {
|
|
|
156
172
|
this.focusOptions = false;
|
|
157
173
|
}
|
|
158
174
|
}
|
|
175
|
+
get hasOptionsMenuOpen() {
|
|
176
|
+
return !this.disabled && this.optionsDisplayed && this.hasOptions;
|
|
177
|
+
}
|
|
159
178
|
get hasOptions() {
|
|
160
179
|
return this.options.length > 0;
|
|
161
180
|
}
|
|
@@ -282,6 +301,11 @@ FtSelect.styles = [
|
|
|
282
301
|
${setVariable(FtRippleCssVariables.opacityContentOnSurfacePressed, "0.04")};
|
|
283
302
|
}
|
|
284
303
|
|
|
304
|
+
.ft-select--input-panel > *:not(ft-ripple),
|
|
305
|
+
.ft-select--option > *:not(ft-ripple) {
|
|
306
|
+
position: relative;
|
|
307
|
+
}
|
|
308
|
+
|
|
285
309
|
.ft-select--disabled .ft-select--input-panel,
|
|
286
310
|
.ft-select--disabled .ft-select--option {
|
|
287
311
|
color: ${FtSelectCssVariables.colorOnSurfaceDisabled};
|
|
@@ -318,6 +342,10 @@ FtSelect.styles = [
|
|
|
318
342
|
${setVariable(FtTypographyBody1CssVariables.lineHeight, FtSelectCssVariables.selectedOptionSize)};
|
|
319
343
|
}
|
|
320
344
|
|
|
345
|
+
.ft-select--in-error .ft-select--selected-option {
|
|
346
|
+
color: ${FtSelectCssVariables.colorError};
|
|
347
|
+
}
|
|
348
|
+
|
|
321
349
|
ft-icon {
|
|
322
350
|
flex-shrink: 0;
|
|
323
351
|
}
|
|
@@ -351,6 +379,12 @@ FtSelect.styles = [
|
|
|
351
379
|
box-shadow: ${FtSelectCssVariables.elevation02};
|
|
352
380
|
}
|
|
353
381
|
|
|
382
|
+
.ft-select--fixed .ft-select--options {
|
|
383
|
+
position: fixed;
|
|
384
|
+
right: unset;
|
|
385
|
+
/* left and top are set dynamically */
|
|
386
|
+
}
|
|
387
|
+
|
|
354
388
|
.ft-select--options-displayed .ft-select--options {
|
|
355
389
|
display: block;
|
|
356
390
|
}
|
|
@@ -367,6 +401,10 @@ FtSelect.styles = [
|
|
|
367
401
|
padding: 0 12px 0 16px;
|
|
368
402
|
color: ${FtSelectCssVariables.helperColor};
|
|
369
403
|
}
|
|
404
|
+
|
|
405
|
+
.ft-select--in-error .ft-select--helper-text {
|
|
406
|
+
color: ${FtSelectCssVariables.colorError};
|
|
407
|
+
}
|
|
370
408
|
`
|
|
371
409
|
];
|
|
372
410
|
__decorate([
|
|
@@ -381,6 +419,12 @@ __decorate([
|
|
|
381
419
|
__decorate([
|
|
382
420
|
property({ type: Boolean })
|
|
383
421
|
], FtSelect.prototype, "disabled", void 0);
|
|
422
|
+
__decorate([
|
|
423
|
+
property({ type: Boolean })
|
|
424
|
+
], FtSelect.prototype, "error", void 0);
|
|
425
|
+
__decorate([
|
|
426
|
+
property({ type: Boolean })
|
|
427
|
+
], FtSelect.prototype, "fixedMenuPosition", void 0);
|
|
384
428
|
__decorate([
|
|
385
429
|
property({ type: Array })
|
|
386
430
|
], FtSelect.prototype, "options", void 0);
|
|
@@ -396,6 +440,9 @@ __decorate([
|
|
|
396
440
|
__decorate([
|
|
397
441
|
query(".ft-select")
|
|
398
442
|
], FtSelect.prototype, "container", void 0);
|
|
443
|
+
__decorate([
|
|
444
|
+
query(".ft-select--options")
|
|
445
|
+
], FtSelect.prototype, "optionsMenu", void 0);
|
|
399
446
|
__decorate([
|
|
400
447
|
query(".ft-select--input-panel")
|
|
401
448
|
], FtSelect.prototype, "mainPanel", void 0);
|