index.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { SelectValue } from '#shared/components/CommonSelect/types.ts'
  3. import type { TreeSelectProps } from '#shared/components/Form/fields/FieldTreeSelect/types.ts'
  4. import createInput from '#shared/form/core/createInput.ts'
  5. import addLink from '#shared/form/features/addLink.ts'
  6. import formUpdaterTrigger from '#shared/form/features/formUpdaterTrigger.ts'
  7. import removeValuesForNonExistingOrDisabledOptions from '#shared/form/features/removeValuesForNonExistingOrDisabledOptions.ts'
  8. import FieldTreeSelectInput from './FieldTreeSelectInput.vue'
  9. import type { FormKitBaseSlots, FormKitInputs } from '@formkit/inputs'
  10. declare module '@formkit/inputs' {
  11. interface FormKitInputProps<Props extends FormKitInputs<Props>> {
  12. treeselect: TreeSelectProps & {
  13. type: 'treeselect'
  14. value?: SelectValue | null
  15. }
  16. }
  17. interface FormKitInputSlots<Props extends FormKitInputs<Props>> {
  18. treeselect: FormKitBaseSlots<Props>
  19. }
  20. }
  21. const fieldDefinition = createInput(
  22. FieldTreeSelectInput,
  23. [
  24. 'alternativeBackground',
  25. 'clearable',
  26. 'historicalOptions',
  27. 'multiple',
  28. 'noFiltering',
  29. 'noOptionsLabelTranslation',
  30. 'options',
  31. 'rejectNonExistentValues',
  32. 'sorting',
  33. ],
  34. {
  35. features: [
  36. addLink,
  37. formUpdaterTrigger(),
  38. removeValuesForNonExistingOrDisabledOptions,
  39. ],
  40. },
  41. )
  42. export default {
  43. fieldType: 'treeselect',
  44. definition: fieldDefinition,
  45. }