@@ -16,6 +16,9 @@ export interface FormKitPrimeAutoCompleteProps {
1616 optionLabel? : AutoCompleteProps [' optionLabel' ]
1717 options? : any [] | undefined
1818 size? : AutoCompleteProps [' size' ]
19+ minLength? : AutoCompleteProps [' minLength' ]
20+ placeholder? : AutoCompleteProps [' placeholder' ]
21+ fluid? : AutoCompleteProps [' fluid' ]
1922}
2023
2124const props = defineProps ({
@@ -29,15 +32,27 @@ const { validSlotNames, unstyled, isInvalid, handleInput, handleBlur } = useForm
2932
3033const suggestions = ref ([' ' , {}])
3134suggestions .value = []
35+ const loading = ref (false )
3236
33- function search(event : AutoCompleteCompleteEvent ) {
37+ async function search(event : AutoCompleteCompleteEvent ) {
3438 if (props .context ?.options && props .context ?.optionLabel ) {
3539 suggestions .value = props .context .options .filter ((option ) => {
3640 return option [` ${props .context .optionLabel } ` ].toString ().toLowerCase ().includes (event .query .toLowerCase ())
3741 })
3842 }
3943 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 )
4156 }
4257}
4358 </script >
@@ -60,9 +75,13 @@ function search(event: AutoCompleteCompleteEvent) {
6075 :dropdown =" context?.dropdown ?? false"
6176 :multiple =" context?.multiple ?? false"
6277 :typeahead =" context?.typeahead ?? true"
78+ :min-length =" context?.minLength ?? undefined"
79+ :placeholder =" context?.placeholder ?? undefined"
80+ :fluid =" context?.fluid ?? undefined"
6381 :pt =" context?.pt"
6482 :pt-options =" context?.ptOptions"
6583 :unstyled =" unstyled"
84+ :loading =" loading"
6685 @keydown.enter.prevent
6786 @complete =" search"
6887 @change =" handleInput"
0 commit comments