@fluid-topics/ft-combobox 2.2.34 → 2.2.36
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/ComboboxMessages.d.ts +2 -0
- package/build/ComboboxMessages.js +2 -0
- package/build/ft-combobox.d.ts +4 -0
- package/build/ft-combobox.js +32 -1
- package/build/ft-combobox.light.js +348 -281
- package/build/ft-combobox.min.js +294 -227
- package/build/ft-combobox.properties.d.ts +1 -0
- package/build/ft-combobox.styles.js +20 -0
- package/package.json +11 -11
|
@@ -5,6 +5,8 @@ export interface FtComboboxMessages extends I18nMessages {
|
|
|
5
5
|
valueRemoved(value: string): string;
|
|
6
6
|
maxValuesReached(max: number): string;
|
|
7
7
|
removeValueLabel(value: string): string;
|
|
8
|
+
clear(): string;
|
|
9
|
+
cleared(): string;
|
|
8
10
|
}
|
|
9
11
|
export declare const comboboxContext: I18nMessageContext<FtComboboxMessages>;
|
|
10
12
|
export declare const defaultComboboxMessages: DefaultI18nMessages<FtComboboxMessages>;
|
package/build/ft-combobox.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare class FtCombobox extends FtCombobox_base implements FtComboboxPro
|
|
|
29
29
|
canOfferNewValue: boolean;
|
|
30
30
|
set value(value: string);
|
|
31
31
|
multiValued: boolean;
|
|
32
|
+
clearable: boolean;
|
|
32
33
|
maxValues?: number;
|
|
33
34
|
maxLength?: number;
|
|
34
35
|
labels: string[];
|
|
@@ -47,6 +48,9 @@ export declare class FtCombobox extends FtCombobox_base implements FtComboboxPro
|
|
|
47
48
|
private _suggestionsProviderDebouncer?;
|
|
48
49
|
protected willUpdate(props: PropertyValues): void;
|
|
49
50
|
protected render(): TemplateResult<1>;
|
|
51
|
+
private get canClear();
|
|
52
|
+
private renderClearButton;
|
|
53
|
+
private onClearClick;
|
|
50
54
|
private renderIcon;
|
|
51
55
|
private renderSuggestion;
|
|
52
56
|
private get activeSuggestion();
|
package/build/ft-combobox.js
CHANGED
|
@@ -15,7 +15,7 @@ import { styles } from "./ft-combobox.styles";
|
|
|
15
15
|
import { FtInputLabel } from "@fluid-topics/ft-input-label";
|
|
16
16
|
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
17
17
|
import { FtTypography, FtTypographyBody1, FtTypographyVariants, } from "@fluid-topics/ft-typography";
|
|
18
|
-
import { FtIcon } from "@fluid-topics/ft-icon";
|
|
18
|
+
import { FtIcon, FtIcons, FtIconVariants, } from "@fluid-topics/ft-icon";
|
|
19
19
|
import { FtChip } from "@fluid-topics/ft-chip";
|
|
20
20
|
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
21
21
|
import { comboboxContext, defaultComboboxMessages, } from "./ComboboxMessages";
|
|
@@ -39,6 +39,7 @@ export class FtCombobox extends withI18n(FtLitElement) {
|
|
|
39
39
|
this._value = "";
|
|
40
40
|
this.canOfferNewValue = true;
|
|
41
41
|
this.multiValued = false;
|
|
42
|
+
this.clearable = false;
|
|
42
43
|
this.labels = [];
|
|
43
44
|
this.labelsToValues = new Map();
|
|
44
45
|
this.filter = "";
|
|
@@ -49,6 +50,13 @@ export class FtCombobox extends withI18n(FtLitElement) {
|
|
|
49
50
|
this.visibleSuggestions = [];
|
|
50
51
|
this.activeIndex = -1;
|
|
51
52
|
this.ariaLiveMessage = "";
|
|
53
|
+
this.onClearClick = () => {
|
|
54
|
+
var _a;
|
|
55
|
+
this.setValue("");
|
|
56
|
+
this.closeListbox(true);
|
|
57
|
+
this.ariaLiveMessage = comboboxContext.messages.cleared();
|
|
58
|
+
(_a = this.input) === null || _a === void 0 ? void 0 : _a.focus();
|
|
59
|
+
};
|
|
52
60
|
this.onComboboxInput = async () => {
|
|
53
61
|
const newValue = this.input.value;
|
|
54
62
|
const hadValue = this._value !== "" || (this.multiValued && this.labels.length > 0);
|
|
@@ -175,6 +183,7 @@ export class FtCombobox extends withI18n(FtLitElement) {
|
|
|
175
183
|
@click=${this.onComboboxClick}
|
|
176
184
|
@focus=${this.onComboboxFocus}
|
|
177
185
|
/>
|
|
186
|
+
${this.canClear ? this.renderClearButton() : nothing}
|
|
178
187
|
${(this.renderIcon())}
|
|
179
188
|
</div>
|
|
180
189
|
<div class="sr-only" aria-live="polite" aria-atomic="true">
|
|
@@ -215,6 +224,25 @@ export class FtCombobox extends withI18n(FtLitElement) {
|
|
|
215
224
|
</div>
|
|
216
225
|
`;
|
|
217
226
|
}
|
|
227
|
+
get canClear() {
|
|
228
|
+
return this.clearable && !this.multiValued && !this.disabled && !!(this.filter || this.value);
|
|
229
|
+
}
|
|
230
|
+
renderClearButton() {
|
|
231
|
+
return html `
|
|
232
|
+
<button type="button"
|
|
233
|
+
class="ft-combobox--clear-button"
|
|
234
|
+
part="clear-button"
|
|
235
|
+
aria-label="${comboboxContext.messages.clear()}"
|
|
236
|
+
aria-controls="combobox-input"
|
|
237
|
+
@pointerdown=${(e) => e.preventDefault() /* To keep focus inside the input */}
|
|
238
|
+
@click=${this.onClearClick}>
|
|
239
|
+
<ft-icon
|
|
240
|
+
.variant=${FtIconVariants.fluid_topics}
|
|
241
|
+
.value=${FtIcons.X_MARK}>
|
|
242
|
+
</ft-icon>
|
|
243
|
+
</button>
|
|
244
|
+
`;
|
|
245
|
+
}
|
|
218
246
|
renderIcon() {
|
|
219
247
|
return this.icon ? html `
|
|
220
248
|
<ft-icon class="ft-combobox--icon"
|
|
@@ -721,6 +749,9 @@ __decorate([
|
|
|
721
749
|
__decorate([
|
|
722
750
|
property({ type: Boolean })
|
|
723
751
|
], FtCombobox.prototype, "multiValued", void 0);
|
|
752
|
+
__decorate([
|
|
753
|
+
property({ type: Boolean })
|
|
754
|
+
], FtCombobox.prototype, "clearable", void 0);
|
|
724
755
|
__decorate([
|
|
725
756
|
numberProperty()
|
|
726
757
|
], FtCombobox.prototype, "maxValues", void 0);
|