@fluid-topics/ftds-combobox 2.0.37
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/BaseComboboxSuggestionProvider.d.ts +2 -0
- package/build/BaseComboboxSuggestionProvider.js +22 -0
- package/build/FtdsBaseComboboxMessages.d.ts +10 -0
- package/build/FtdsBaseComboboxMessages.js +9 -0
- package/build/FtdsComboboxMultiValueMessages.d.ts +10 -0
- package/build/FtdsComboboxMultiValueMessages.js +11 -0
- package/build/define.d.ts +1 -0
- package/build/define.js +3 -0
- package/build/definitions.d.ts +7 -0
- package/build/definitions.js +6 -0
- package/build/ftds-base-combobox.d.ts +71 -0
- package/build/ftds-base-combobox.js +540 -0
- package/build/ftds-base-combobox.properties.d.ts +39 -0
- package/build/ftds-base-combobox.properties.js +14 -0
- package/build/ftds-base-combobox.styles.d.ts +1 -0
- package/build/ftds-base-combobox.styles.js +111 -0
- package/build/ftds-combobox-multi-value.d.ts +30 -0
- package/build/ftds-combobox-multi-value.js +218 -0
- package/build/ftds-combobox-multi-value.properties.d.ts +14 -0
- package/build/ftds-combobox-multi-value.properties.js +5 -0
- package/build/ftds-combobox-multi-value.styles.d.ts +1 -0
- package/build/ftds-combobox-multi-value.styles.js +58 -0
- package/build/ftds-combobox.d.ts +21 -0
- package/build/ftds-combobox.js +96 -0
- package/build/ftds-combobox.light.js +3486 -0
- package/build/ftds-combobox.min.js +3607 -0
- package/build/ftds-combobox.properties.d.ts +8 -0
- package/build/ftds-combobox.properties.js +5 -0
- package/build/ftds-combobox.styles.d.ts +1 -0
- package/build/ftds-combobox.styles.js +36 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +11 -0
- package/package.json +36 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function basicSuggestionsProvider(values, maxSuggest = 20) {
|
|
2
|
+
return (query) => {
|
|
3
|
+
const q = (query || "").toLowerCase();
|
|
4
|
+
return 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
|
+
.slice(0, maxSuggest);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function alphabeticalSortWithPriorToStartWithQuery(a, b, query) {
|
|
12
|
+
const lowerA = a.toLowerCase();
|
|
13
|
+
const lowerB = b.toLowerCase();
|
|
14
|
+
const lowerQuery = query.toLowerCase();
|
|
15
|
+
if (lowerA.startsWith(lowerQuery) && !lowerB.startsWith(lowerQuery)) {
|
|
16
|
+
return -1;
|
|
17
|
+
}
|
|
18
|
+
if (lowerB.startsWith(lowerQuery) && !lowerA.startsWith(lowerQuery)) {
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
return lowerA.localeCompare(lowerB);
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export interface FtdsBaseComboboxMessages extends I18nMessages {
|
|
3
|
+
maxSuggestionsLabel(value: number): string;
|
|
4
|
+
maxSuggestionsAriaLabel(value: number): string;
|
|
5
|
+
refineYourSearchLabel(): string;
|
|
6
|
+
noResultLabel(): string;
|
|
7
|
+
newValueLabel(): string;
|
|
8
|
+
}
|
|
9
|
+
export declare const baseComboboxContext: I18nMessageContext<FtdsBaseComboboxMessages>;
|
|
10
|
+
export declare const defaultBaseComboboxMessages: DefaultI18nMessages<FtdsBaseComboboxMessages>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { I18nMessageContext, } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export const baseComboboxContext = I18nMessageContext.build("ftdsBaseCombobox");
|
|
3
|
+
export const defaultBaseComboboxMessages = {
|
|
4
|
+
"maxSuggestionsLabel": "{0} first results.",
|
|
5
|
+
"maxSuggestionsAriaLabel": "Only showing the {0} first results, please refine your search.",
|
|
6
|
+
"refineYourSearchLabel": "Refine your search.",
|
|
7
|
+
"noResultLabel": "No option",
|
|
8
|
+
"newValueLabel": "New value",
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export interface FtdsComboboxMultiValueMessages extends I18nMessages {
|
|
3
|
+
selectAll(): string;
|
|
4
|
+
valueAdded(value: string): string;
|
|
5
|
+
valueRemoved(value: string): string;
|
|
6
|
+
removeValueLabel(value: string): string;
|
|
7
|
+
numberOfSelectedValuesAriaLabel(count: number): string;
|
|
8
|
+
}
|
|
9
|
+
export declare const comboboxMultiValueContext: I18nMessageContext<FtdsComboboxMultiValueMessages>;
|
|
10
|
+
export declare const defaultComboboxMultiValueMessages: DefaultI18nMessages<FtdsComboboxMultiValueMessages>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { I18nMessageContext, } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export const comboboxMultiValueContext = I18nMessageContext.build("ftdsComboboxMultiValue");
|
|
3
|
+
export const defaultComboboxMultiValueMessages = {
|
|
4
|
+
"selectAll": "Select All",
|
|
5
|
+
"valueAdded": "{0} added",
|
|
6
|
+
"valueRemoved": "{0} removed",
|
|
7
|
+
"removeValueLabel": "Remove {0}",
|
|
8
|
+
"numberOfSelectedValuesAriaLabel": "{0} selected values",
|
|
9
|
+
"numberOfSelectedValuesAriaLabel[\\=1]": "1 selected value",
|
|
10
|
+
"numberOfSelectedValuesAriaLabel[\\=0]": "No selected value",
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/define.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FtdsComboboxMultiValue } from "./ftds-combobox-multi-value";
|
|
2
|
+
import { FtdsCombobox } from "./ftds-combobox";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
"ftds-combobox": typeof FtdsCombobox;
|
|
5
|
+
"ftds-combobox-multi-value": typeof FtdsComboboxMultiValue;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { nothing, PropertyValues, TemplateResult } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap, FtdsBase, ValidationRule } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtIcons } from "@fluid-topics/ft-icon";
|
|
4
|
+
import { ActionableListboxItem, FtdsBaseComboboxProperties, ListboxItem, SuggestionListboxItem, SuggestionsProvider } from "./ftds-base-combobox.properties";
|
|
5
|
+
declare const FtdsBaseComboboxBase: typeof FtdsBase & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").FtInputInterface<any>> & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
6
|
+
export declare abstract class FtdsBaseCombobox<T> extends FtdsBaseComboboxBase implements FtdsBaseComboboxProperties {
|
|
7
|
+
value: T;
|
|
8
|
+
static baseComboboxElementDefinitions: ElementDefinitionsMap;
|
|
9
|
+
suggestionsProvider: SuggestionsProvider;
|
|
10
|
+
debouncerTimeout?: number;
|
|
11
|
+
filterSuggestions: boolean;
|
|
12
|
+
canOfferNewValue: boolean;
|
|
13
|
+
required: boolean;
|
|
14
|
+
maxDisplayedSuggestions: number;
|
|
15
|
+
newValueValidationRules: Array<ValidationRule<string>>;
|
|
16
|
+
isOpen: boolean;
|
|
17
|
+
inputValue: string;
|
|
18
|
+
activeIndex: number;
|
|
19
|
+
providedSuggestions: SuggestionListboxItem[];
|
|
20
|
+
ariaLiveMessage: string;
|
|
21
|
+
ariaDescribedBy: string;
|
|
22
|
+
listboxItems: ListboxItem[];
|
|
23
|
+
input?: HTMLInputElement;
|
|
24
|
+
listbox?: HTMLUListElement;
|
|
25
|
+
private listboxId;
|
|
26
|
+
private debounceTimer?;
|
|
27
|
+
abstract handleBlurStrategy(): void;
|
|
28
|
+
abstract commitTypedText(typedText: string): void;
|
|
29
|
+
abstract commitSelection(suggestion: ActionableListboxItem): void;
|
|
30
|
+
abstract resetCombobox(): void;
|
|
31
|
+
abstract isSuggestionSelected(value: string): boolean;
|
|
32
|
+
abstract renderSuggestionItem(suggestion: SuggestionListboxItem, isSelected: boolean): TemplateResult;
|
|
33
|
+
protected constructor();
|
|
34
|
+
protected willUpdate(props: PropertyValues): void;
|
|
35
|
+
connectedCallback(): void;
|
|
36
|
+
disconnectedCallback(): void;
|
|
37
|
+
get shouldRaiseLabel(): boolean;
|
|
38
|
+
get filteredSuggestions(): SuggestionListboxItem[];
|
|
39
|
+
get filteredSuggestionsWithLimit(): SuggestionListboxItem[];
|
|
40
|
+
get appendIcon(): FtIcons;
|
|
41
|
+
get activeItemId(): string | undefined;
|
|
42
|
+
protected renderField(): TemplateResult;
|
|
43
|
+
protected renderListboxContainer(isMultiSelectable: boolean): TemplateResult;
|
|
44
|
+
protected renderListboxItem(listboxItem: ListboxItem, index: number): TemplateResult | typeof nothing;
|
|
45
|
+
protected renderSuggestion(suggestion: SuggestionListboxItem, index: number): TemplateResult;
|
|
46
|
+
protected renderNewValueSuggestion(suggestion: SuggestionListboxItem, index: number): TemplateResult;
|
|
47
|
+
protected renderNewValueTag(): TemplateResult;
|
|
48
|
+
protected renderNewValueLabel(suggestion: SuggestionListboxItem, isSelected: boolean): TemplateResult;
|
|
49
|
+
protected renderNewValueValidationErrors(validationErrors: string[]): TemplateResult;
|
|
50
|
+
protected renderMaxSuggestionsItem(index: number): TemplateResult;
|
|
51
|
+
protected renderNoResult(index: number): TemplateResult;
|
|
52
|
+
protected computeListboxItems(): Promise<void>;
|
|
53
|
+
private getListboxItems;
|
|
54
|
+
private setAriaDescribeBy;
|
|
55
|
+
private computeSuggestions;
|
|
56
|
+
private runSuggestionsProvider;
|
|
57
|
+
protected suggestionId(index: number): string;
|
|
58
|
+
protected onType(e: Event): Promise<void>;
|
|
59
|
+
protected onInputClick(): Promise<void>;
|
|
60
|
+
onBlur(): void;
|
|
61
|
+
private onBackgroundPointerUp;
|
|
62
|
+
protected openMenu(): Promise<void>;
|
|
63
|
+
protected closeMenu(): void;
|
|
64
|
+
private onItemSelected;
|
|
65
|
+
private onKeyDown;
|
|
66
|
+
private getSelectableIndexes;
|
|
67
|
+
private moveActiveIndex;
|
|
68
|
+
private scrollSuggestionIntoView;
|
|
69
|
+
private getElementToScrollTo;
|
|
70
|
+
}
|
|
71
|
+
export {};
|