import { defineAsyncComponent } from 'vue'
import { useFormInput, useInputProps } from '@cip/components/hooks/form-input'
import { formInputProps, fromInputEmits } from '../../form-input-props'
import { useMultiple } from './use-multiple'
export default {
  props: formInputProps,
  emits: fromInputEmits,
  setup (props, context) {
    const { proxyValue, securityConfig, width } = useFormInput(props, context, { maxOtherKey: 1 })
    // 做一次兼容设置
    // checkType
    const multiple = useMultiple(securityConfig)

    const inputProps = useInputProps(props, [
      'direction',
      'multiple',
      'entity',
      'curdFn',
      'tableColumns',
      'searchFieldList',
      'optionProps',
      'hideSearch',
      'defaultSearchModel',
      'withPagination',
      'selectable'
    ])
    const CipSelectTable = defineAsyncComponent(() => import('@cip/components/cip-select-table'))
    return () => <CipSelectTable
      {...inputProps.value}
      style={{ width: width.value }}
      multiple={multiple.value}
      v-model={proxyValue.value}
    />
  }
}
