fluent-svelte-extra 1.2.7 → 1.2.8
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.
|
@@ -6,10 +6,12 @@ import ListItem from "../ListItem/ListItem.svelte";
|
|
|
6
6
|
/** The input's current value. */
|
|
7
7
|
export let value = "";
|
|
8
8
|
export let maxSuggestions = 99999;
|
|
9
|
-
/** Array of strings
|
|
9
|
+
/** Array of strings will be suggested to the user as options. */
|
|
10
10
|
export let items = [];
|
|
11
11
|
/** The current visibility state of the suggestion flyout. */
|
|
12
12
|
export let open = false;
|
|
13
|
+
/** Disables or enables AutoSuggest mode */
|
|
14
|
+
export let autoSuggest = true;
|
|
13
15
|
/** Bindable index of the currently selected item. */
|
|
14
16
|
export let selection = 0;
|
|
15
17
|
/** Bindable array of currently suggested items. */
|
|
@@ -32,12 +34,46 @@ let focused = false;
|
|
|
32
34
|
let typedValue = "";
|
|
33
35
|
const dispatch = createEventDispatcher();
|
|
34
36
|
const flyoutId = uid("fds-auto-suggest-flyout-");
|
|
37
|
+
/** Pushes the specified item to the items array */
|
|
38
|
+
export function addItem(item) {
|
|
39
|
+
items.push(item);
|
|
40
|
+
}
|
|
41
|
+
/** Removes the specified item from the items array */
|
|
42
|
+
export function removeItem(item) {
|
|
43
|
+
items.splice(items.indexOf(item), 1);
|
|
44
|
+
}
|
|
45
|
+
/** Removes all of the items from the items array */
|
|
46
|
+
export function removeAllItems() {
|
|
47
|
+
items = [];
|
|
48
|
+
}
|
|
49
|
+
/* Sets the items array to the specified array */
|
|
50
|
+
export function setItems(argItems) {
|
|
51
|
+
items = argItems;
|
|
52
|
+
}
|
|
53
|
+
/** Pushes the specified item to the matches array */
|
|
54
|
+
export function addMatch(match) {
|
|
55
|
+
matches.push(match);
|
|
56
|
+
}
|
|
57
|
+
/** Removes the specified item from the matches array */
|
|
58
|
+
export function removeMatch(match) {
|
|
59
|
+
matches.splice(matches.indexOf(match), 1);
|
|
60
|
+
}
|
|
61
|
+
/** Removes all of the items from the matches array */
|
|
62
|
+
export function removeAllMatches() {
|
|
63
|
+
matches = [];
|
|
64
|
+
}
|
|
65
|
+
/* Sets the matches array to the specified array */
|
|
66
|
+
export function setMatches(argMatches) {
|
|
67
|
+
matches = argMatches;
|
|
68
|
+
}
|
|
35
69
|
$: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
filter.length
|
|
70
|
+
if (autoSuggest) {
|
|
71
|
+
const filter = items.filter(item => item.toLowerCase().includes(typedValue.toLowerCase()));
|
|
72
|
+
if (filter.length > maxSuggestions) {
|
|
73
|
+
filter.length = maxSuggestions; //slice it
|
|
74
|
+
}
|
|
75
|
+
matches = filter;
|
|
39
76
|
}
|
|
40
|
-
matches = filter;
|
|
41
77
|
}
|
|
42
78
|
$: selection, dispatchSelect();
|
|
43
79
|
function dispatchSelect() {
|
|
@@ -6,6 +6,7 @@ declare const __propDef: {
|
|
|
6
6
|
maxSuggestions?: number;
|
|
7
7
|
items?: string[];
|
|
8
8
|
open?: boolean;
|
|
9
|
+
autoSuggest?: boolean;
|
|
9
10
|
selection?: number;
|
|
10
11
|
matches?: string[];
|
|
11
12
|
class?: string;
|
|
@@ -15,6 +16,14 @@ declare const __propDef: {
|
|
|
15
16
|
clearButtonElement?: HTMLButtonElement;
|
|
16
17
|
searchButtonElement?: HTMLButtonElement;
|
|
17
18
|
flyoutElement?: HTMLUListElement;
|
|
19
|
+
addItem?: (item: string) => void;
|
|
20
|
+
removeItem?: (item: string) => void;
|
|
21
|
+
removeAllItems?: () => void;
|
|
22
|
+
setItems?: (argItems: string[]) => void;
|
|
23
|
+
addMatch?: (match: string) => void;
|
|
24
|
+
removeMatch?: (match: string) => void;
|
|
25
|
+
removeAllMatches?: () => void;
|
|
26
|
+
setMatches?: (argMatches: string[]) => void;
|
|
18
27
|
};
|
|
19
28
|
events: {
|
|
20
29
|
search: CustomEvent<any>;
|
|
@@ -59,5 +68,13 @@ export declare type AutoSuggestBoxProps = typeof __propDef.props;
|
|
|
59
68
|
export declare type AutoSuggestBoxEvents = typeof __propDef.events;
|
|
60
69
|
export declare type AutoSuggestBoxSlots = typeof __propDef.slots;
|
|
61
70
|
export default class AutoSuggestBox extends SvelteComponentTyped<AutoSuggestBoxProps, AutoSuggestBoxEvents, AutoSuggestBoxSlots> {
|
|
71
|
+
get addItem(): (item: string) => void;
|
|
72
|
+
get removeItem(): (item: string) => void;
|
|
73
|
+
get removeAllItems(): () => void;
|
|
74
|
+
get setItems(): (argItems: string[]) => void;
|
|
75
|
+
get addMatch(): (match: string) => void;
|
|
76
|
+
get removeMatch(): (match: string) => void;
|
|
77
|
+
get removeAllMatches(): () => void;
|
|
78
|
+
get setMatches(): (argMatches: string[]) => void;
|
|
62
79
|
}
|
|
63
80
|
export {};
|
|
@@ -43,9 +43,9 @@ onMount(() => {
|
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
45
|
<div class="glob">
|
|
46
|
-
<div class="expand-menu" bind:this={root} use:forwardEvents>
|
|
46
|
+
<div role="list" class="expand-menu" bind:this={root} use:forwardEvents>
|
|
47
47
|
<slot></slot>
|
|
48
48
|
</div>
|
|
49
49
|
</div>
|
|
50
50
|
|
|
51
|
-
<style>.expand-menu{background-color:var(--fds-solid-background-quarternary);display:flex;flex-direction:column;overflow:hidden;transition:width var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing)}.glob :global(.expand-menu-closed){width:48px!important}.glob :global(.expand-menu-closed>li[role=listitem]){padding-inline:unset!important}.glob :global(.expand-menu-icon){-webkit-margin-end:unset!important;left:11px;margin-inline-end:unset!important;min-height:16px;min-width:16px;position:absolute}.glob :global(.expand-menu-text){left:45px;position:absolute;white-space:nowrap!important}:global(.fds-copy-calculation){display:block;left:-1000000000px;opacity:0;position:absolute}</style>
|
|
51
|
+
<style>.expand-menu{background-color:var(--fds-solid-background-quarternary);display:flex;flex-direction:column;overflow:hidden;transition:width var(--fds-control-normal-duration) var(--fds-control-fast-out-slow-in-easing)}.glob :global(.expand-menu-closed){width:48px!important}.glob :global(.expand-menu-closed>li[role=listitem]){padding-inline:unset!important}.glob :global(.expand-menu-icon){-webkit-margin-end:unset!important;left:11px;margin-inline-end:unset!important;min-height:16px;min-width:16px;position:absolute}.glob :global(.expand-menu-text){left:45px;position:absolute;white-space:nowrap!important}:global(.fds-copy-calculation){display:block;left:-1000000000px;opacity:0;position:absolute}</style>
|
package/package.json
CHANGED