index.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { AutocompleteSelectValue } from '#shared/components/Form/fields/FieldAutocomplete/types.ts'
  3. import createInput from '#shared/form/core/createInput.ts'
  4. import addLink from '#shared/form/features/addLink.ts'
  5. import formUpdaterTrigger from '#shared/form/features/formUpdaterTrigger.ts'
  6. import FieldAutoCompleteInput from './FieldAutoCompleteInput.vue'
  7. import type { AutoCompleteProps } from './types.ts'
  8. import type { FormKitBaseSlots, FormKitInputs } from '@formkit/inputs'
  9. declare module '@formkit/inputs' {
  10. interface FormKitInputProps<Props extends FormKitInputs<Props>> {
  11. autocomplete: AutoCompleteProps & {
  12. type: 'autocomplete'
  13. value: AutocompleteSelectValue | null
  14. }
  15. }
  16. interface FormKitInputSlots<Props extends FormKitInputs<Props>> {
  17. treeselect: FormKitBaseSlots<Props>
  18. }
  19. }
  20. export const autoCompleteProps = [
  21. 'actions',
  22. 'alternativeBackground',
  23. 'additionalQueryParams',
  24. 'clearable',
  25. 'debounceInterval',
  26. 'defaultFilter',
  27. 'limit',
  28. 'multiple',
  29. 'noOptionsLabelTranslation',
  30. 'belongsToObjectField',
  31. 'optionIconComponent',
  32. 'dialogNotFoundMessage',
  33. 'dialogEmptyMessage',
  34. 'options',
  35. 'initialOptionBuilder',
  36. 'autocompleteOptionsPreprocessor',
  37. 'sorting',
  38. 'complexValue',
  39. 'clearValue',
  40. 'emptyInitialLabelText',
  41. ]
  42. const fieldDefinition = createInput(
  43. FieldAutoCompleteInput,
  44. [...autoCompleteProps, 'gqlQuery'],
  45. { features: [addLink, formUpdaterTrigger()] },
  46. )
  47. export default {
  48. fieldType: 'autocomplete',
  49. definition: fieldDefinition,
  50. }