@fluid-topics/ft-combobox 1.3.26

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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ A
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ft-combobox
7
+ yarn add @fluid-topics/ft-combobox
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ import { html } from "lit"
14
+ import "@fluid-topics/ft-combobox"
15
+
16
+ function render() {
17
+ return html` <ft-combobox foo="bar"></ft-combobox> `
18
+ }
19
+ ```
@@ -0,0 +1,6 @@
1
+ import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
2
+ export interface FtComboboxMessages extends I18nMessages {
3
+ ariaLiveOptions(count: number): string;
4
+ }
5
+ export declare const comboboxContext: I18nMessageContext<FtComboboxMessages>;
6
+ export declare const defaultComboboxMessages: DefaultI18nMessages<FtComboboxMessages>;
@@ -0,0 +1,6 @@
1
+ import { I18nMessageContext } from "@fluid-topics/ft-i18n";
2
+ export const comboboxContext = I18nMessageContext.build("ftCombobox");
3
+ export const defaultComboboxMessages = {
4
+ "ariaLiveOptions": "{0} options",
5
+ "ariaLiveOptions[\\=1]": "1 option",
6
+ };
@@ -0,0 +1,2 @@
1
+ import { FtComboboxSuggestionDefinition } from "./models";
2
+ export declare function basicSuggestionsProvider(values: Array<string | FtComboboxSuggestionDefinition>): (query: string) => FtComboboxSuggestionDefinition[];
@@ -0,0 +1,25 @@
1
+ export function basicSuggestionsProvider(values) {
2
+ return (query) => {
3
+ const q = (query || "").toLowerCase();
4
+ const list = values
5
+ .map((value) => (typeof value === "string" ? { value, label: value } : value))
6
+ .filter((v) => v.label.toLowerCase().includes(q))
7
+ .sort((a, b) => alphabeticalSortWithPriorToStartWithQuery(a.label, b.label, q));
8
+ if (q.length === 0) {
9
+ return list;
10
+ }
11
+ return list;
12
+ };
13
+ }
14
+ function alphabeticalSortWithPriorToStartWithQuery(a, b, query) {
15
+ const lowerA = a.toLowerCase();
16
+ const lowerB = b.toLowerCase();
17
+ const lowerQuery = query.toLowerCase();
18
+ if (lowerA.startsWith(lowerQuery) && !lowerB.startsWith(lowerQuery)) {
19
+ return -1;
20
+ }
21
+ if (lowerB.startsWith(lowerQuery) && !lowerA.startsWith(lowerQuery)) {
22
+ return 1;
23
+ }
24
+ return lowerA.localeCompare(lowerB);
25
+ }
@@ -0,0 +1,80 @@
1
+ import { PropertyValues, TemplateResult } from "lit";
2
+ import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
3
+ import { FtComboboxProperties } from "./ft-combobox.properties";
4
+ import { FtComboboxSuggestionDefinition } from "./models";
5
+ declare const FtCombobox_base: typeof FtLitElement & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
6
+ export declare class FtCombobox extends FtCombobox_base implements FtComboboxProperties {
7
+ static styles: import("lit").CSSResult[];
8
+ static elementDefinitions: ElementDefinitionsMap;
9
+ label?: string;
10
+ icon?: string;
11
+ iconVariant?: string;
12
+ name?: string;
13
+ error: boolean;
14
+ filterSuggestions: boolean;
15
+ helper?: string;
16
+ disabled: boolean;
17
+ outlined: boolean;
18
+ placeholder?: string;
19
+ suggestionsHelper?: string;
20
+ suggestionsProvider: (query: string) => FtComboboxSuggestionDefinition[] | Promise<FtComboboxSuggestionDefinition[]>;
21
+ suggestionsProviderDebouncerTimeout?: number;
22
+ private _value;
23
+ get value(): string;
24
+ set value(value: string);
25
+ private filter;
26
+ private isOpen;
27
+ private comboboxHasVisualFocus;
28
+ private listboxHasVisualFocus;
29
+ private providedSuggestions;
30
+ private visibleSuggestions;
31
+ private activeIndex;
32
+ private input;
33
+ private listbox;
34
+ constructor();
35
+ private _suggestionsProviderDebouncer?;
36
+ protected willUpdate(props: PropertyValues): void;
37
+ protected render(): TemplateResult<1>;
38
+ private renderIcon;
39
+ private renderSuggestion;
40
+ private get activeSuggestion();
41
+ private shouldOfferNew;
42
+ private getTotalSuggestionsCount;
43
+ private isNewValueSuggestionSelected;
44
+ connectedCallback(): void;
45
+ disconnectedCallback(): void;
46
+ private renderLiveText;
47
+ private getActiveDescendantId;
48
+ private updateSuggestions;
49
+ private updateSuggestionsWithoutDebounce;
50
+ private onComboboxInput;
51
+ private setActiveSuggestion;
52
+ private scrollSuggestionIntoView;
53
+ private openListbox;
54
+ private closeListbox;
55
+ private setVisualFocusCombobox;
56
+ private setVisualFocusListbox;
57
+ private removeVisualFocusAll;
58
+ private setValue;
59
+ private dispatchChangeEvent;
60
+ private isPrintableCharacter;
61
+ private commitSelectionFromEnter;
62
+ private moveFocusToNextSuggestion;
63
+ private moveFocusToPreviousSuggestion;
64
+ private handleEscapeKey;
65
+ private handleTabKey;
66
+ private moveCaretToHome;
67
+ private moveCaretToEnd;
68
+ private onComboboxKeyDown;
69
+ private onComboboxKeyUp;
70
+ private onComboboxClick;
71
+ private onComboboxFocus;
72
+ private onComboboxBlur;
73
+ private onBackgroundPointerUp;
74
+ private onListboxPointerout;
75
+ private onSuggestionClick;
76
+ private onSuggestionPointerout;
77
+ focus(): void;
78
+ blur(): void;
79
+ }
80
+ export {};