<template>
  <el-autocomplete :style="{width}" v-model="proxyValue" :fetch-suggestions="querySearchAsync"></el-autocomplete>
</template>
<script>
import { ElAutocomplete } from 'element-plus'
import { formInputProps, fromInputEmits } from '../../form-input-props'
import { useFormInput } from '@cip/components/hooks/form-input'
export default {
  components: { ElAutocomplete },
  props: formInputProps,
  emits: [...fromInputEmits],
  setup (props, content) {
    const formInput = useFormInput(props, content)
    const querySearchAsync = async (query, cb) => {
      const options = await props.config.asyncOptions(query)
      cb(options)
    }
    return {
      ...formInput,
      querySearchAsync
    }
  }
}
</script>
