@@ -16,6 +16,9 @@ export interface FormKitPrimeAutoCompleteProps {
16
16
optionLabel? : AutoCompleteProps [' optionLabel' ]
17
17
options? : any [] | undefined
18
18
size? : AutoCompleteProps [' size' ]
19
+ minLength? : AutoCompleteProps [' minLength' ]
20
+ placeholder? : AutoCompleteProps [' placeholder' ]
21
+ fluid? : AutoCompleteProps [' fluid' ]
19
22
}
20
23
21
24
const props = defineProps ({
@@ -29,15 +32,27 @@ const { validSlotNames, unstyled, isInvalid, handleInput, handleBlur } = useForm
29
32
30
33
const suggestions = ref ([' ' , {}])
31
34
suggestions .value = []
35
+ const loading = ref (false )
32
36
33
- function search(event : AutoCompleteCompleteEvent ) {
37
+ async function search(event : AutoCompleteCompleteEvent ) {
34
38
if (props .context ?.options && props .context ?.optionLabel ) {
35
39
suggestions .value = props .context .options .filter ((option ) => {
36
40
return option [` ${props .context .optionLabel } ` ].toString ().toLowerCase ().includes (event .query .toLowerCase ())
37
41
})
38
42
}
39
43
else {
40
- suggestions .value = props .context ?.attrs .complete (event .query )
44
+ loading .value = true
45
+ try {
46
+ suggestions .value = await props .context ?.attrs .complete (event .query )
47
+ }
48
+ catch (error ) {
49
+ console .error (' Error fetching suggestions:' , error )
50
+ suggestions .value = []
51
+ }
52
+ finally {
53
+ loading .value = false
54
+ }
55
+ suggestions .value = await props .context ?.attrs .complete (event .query )
41
56
}
42
57
}
43
58
</script >
@@ -60,9 +75,13 @@ function search(event: AutoCompleteCompleteEvent) {
60
75
:dropdown =" context?.dropdown ?? false"
61
76
:multiple =" context?.multiple ?? false"
62
77
:typeahead =" context?.typeahead ?? true"
78
+ :min-length =" context?.minLength ?? undefined"
79
+ :placeholder =" context?.placeholder ?? undefined"
80
+ :fluid =" context?.fluid ?? undefined"
63
81
:pt =" context?.pt"
64
82
:pt-options =" context?.ptOptions"
65
83
:unstyled =" unstyled"
84
+ :loading =" loading"
66
85
@keydown.enter.prevent
67
86
@complete =" search"
68
87
@change =" handleInput"
0 commit comments