noph-ui 0.18.15 → 0.19.0
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.
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
clampMenuWidth = false,
|
|
17
17
|
children,
|
|
18
18
|
optionsFilter,
|
|
19
|
-
|
|
19
|
+
showPopover = $bindable(),
|
|
20
|
+
hidePopover = $bindable(),
|
|
21
|
+
onoptionselect = (option) => {
|
|
20
22
|
value = option.label
|
|
21
23
|
finalPopulated = populated
|
|
22
24
|
menuElement?.hidePopover()
|
|
@@ -28,6 +30,13 @@
|
|
|
28
30
|
...attributes
|
|
29
31
|
}: AutoCompleteProps = $props()
|
|
30
32
|
|
|
33
|
+
showPopover = () => {
|
|
34
|
+
menuElement?.showPopover()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
hidePopover = () => {
|
|
38
|
+
menuElement?.hidePopover()
|
|
39
|
+
}
|
|
31
40
|
const uid = $props.id()
|
|
32
41
|
let defaultOptionsFilter = (option: AutoCompleteOption) => {
|
|
33
42
|
return !value || option.label.toLocaleLowerCase().includes(value.toLocaleLowerCase())
|
|
@@ -43,7 +52,7 @@
|
|
|
43
52
|
<Item
|
|
44
53
|
onclick={(event) => {
|
|
45
54
|
event.preventDefault()
|
|
46
|
-
|
|
55
|
+
onoptionselect(option)
|
|
47
56
|
element?.focus()
|
|
48
57
|
}}
|
|
49
58
|
disabled={option.disabled}
|
|
@@ -57,7 +66,7 @@
|
|
|
57
66
|
event.preventDefault()
|
|
58
67
|
}
|
|
59
68
|
if (event.key === 'Enter') {
|
|
60
|
-
|
|
69
|
+
onoptionselect(option)
|
|
61
70
|
}
|
|
62
71
|
if (event.key === 'Tab') {
|
|
63
72
|
finalPopulated = populated
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AutoCompleteProps } from './types.ts';
|
|
2
|
-
declare const AutoComplete: import("svelte").Component<AutoCompleteProps, {}, "element" | "value" | "reportValidity" | "checkValidity" | "focused">;
|
|
2
|
+
declare const AutoComplete: import("svelte").Component<AutoCompleteProps, {}, "element" | "value" | "showPopover" | "hidePopover" | "reportValidity" | "checkValidity" | "focused">;
|
|
3
3
|
type AutoComplete = ReturnType<typeof AutoComplete>;
|
|
4
4
|
export default AutoComplete;
|
|
@@ -8,6 +8,8 @@ export interface AutoCompleteOption {
|
|
|
8
8
|
export interface AutoCompleteProps extends Omit<InputFieldProps, 'clientWidth' | 'clientHeight'> {
|
|
9
9
|
options: AutoCompleteOption[];
|
|
10
10
|
optionsFilter?: (option: AutoCompleteOption) => boolean;
|
|
11
|
-
|
|
11
|
+
onoptionselect?: (option: AutoCompleteOption) => void;
|
|
12
12
|
clampMenuWidth?: boolean;
|
|
13
|
+
showPopover?: () => void;
|
|
14
|
+
hidePopover?: () => void;
|
|
13
15
|
}
|