index.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. autocomplete: FormKitBaseSlots<Props>
  18. }
  19. }
  20. export const autoCompleteProps = [
  21. 'actions',
  22. 'alternativeBackground',
  23. 'additionalQueryParams',
  24. 'clearable',
  25. 'debounceInterval',
  26. 'defaultFilter',
  27. 'stripFilter',
  28. 'limit',
  29. 'multiple',
  30. 'noOptionsLabelTranslation',
  31. 'belongsToObjectField',
  32. 'optionIconComponent',
  33. 'dialogNotFoundMessage',
  34. 'dialogEmptyMessage',
  35. 'options',
  36. 'initialOptionBuilder',
  37. 'autocompleteOptionsPreprocessor',
  38. 'sorting',
  39. 'complexValue',
  40. 'clearValue',
  41. 'emptyInitialLabelText',
  42. 'alwaysApplyDefaultFilter',
  43. ]
  44. const fieldDefinition = createInput(
  45. FieldAutoCompleteInput,
  46. [...autoCompleteProps, 'gqlQuery'],
  47. { features: [addLink, formUpdaterTrigger()] },
  48. )
  49. export default {
  50. fieldType: 'autocomplete',
  51. definition: fieldDefinition,
  52. }