11<script setup lang='ts'>
2- import { type PropType , computed , ref } from ' vue'
2+ import { type PropType , ref } from ' vue'
33import type { FormKitFrameworkContext } from ' @formkit/core'
44
55import type { AutoCompleteCompleteEvent , AutoCompleteProps } from ' primevue/autocomplete'
6+ import { useFormKitInput } from ' ../composables'
67
78export interface FormKitPrimeAutoCompleteProps {
89 pt? : AutoCompleteProps [' pt' ]
@@ -11,6 +12,7 @@ export interface FormKitPrimeAutoCompleteProps {
1112 dropdown? : AutoCompleteProps [' dropdown' ]
1213 multiple? : AutoCompleteProps [' multiple' ]
1314 typeahead? : AutoCompleteProps [' typeahead' ]
15+ wrapperClass? : string
1416}
1517
1618const props = defineProps ({
@@ -20,25 +22,17 @@ const props = defineProps({
2022 },
2123})
2224
25+ const { styleClass, wrapperClass, handleInput, handleBlur } = useFormKitInput (props .context )
26+
2327const suggestions = ref ([])
2428
2529function search(event : AutoCompleteCompleteEvent ) {
2630 suggestions .value = props .context ?.attrs .complete (event .query )
2731}
28-
29- function handleInput(_ : any ) {
30- props .context ?.node .input (props .context ?._value )
31- }
32-
33- function handleBlur(event : Event ) {
34- props .context ?.handlers .blur (event )
35- }
36-
37- const styleClass = computed (() => (props .context ?.state .validationVisible && ! props .context ?.state .valid ) ? ` ${props .context ?.attrs ?.class } p-invalid ` : props .context ?.attrs ?.class )
3832 </script >
3933
4034<template >
41- <div class =" p-formkit " >
35+ <div : class =" wrapperClass " >
4236 <AutoComplete
4337 :id =" context.id"
4438 v-model =" context._value"
@@ -51,7 +45,7 @@ const styleClass = computed(() => (props.context?.state.validationVisible && !pr
5145 :suggestions =" suggestions"
5246 :dropdown =" context?.dropdown ?? false"
5347 :multiple =" context?.multiple ?? false"
54- :typeahead =" context?.attrs. typeahead ?? true"
48+ :typeahead =" context?.typeahead ?? true"
5549 :pt =" context?.pt"
5650 :pt-options =" context?.ptOptions"
5751 :unstyled =" context?.unstyled ?? false"
0 commit comments