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. 'clearable',
  25. 'historicalOptions',
  26. 'multiple',
  27. 'noFiltering',
  28. 'noOptionsLabelTranslation',
  29. 'options',
  30. 'rejectNonExistentValues',
  31. 'sorting',
  32. ],
  33. {
  34. features: [
  35. addLink,
  36. formUpdaterTrigger(),
  37. removeValuesForNonExistingOrDisabledOptions,
  38. ],
  39. },
  40. { addArrow: true },
  41. )
  42. export default {
  43. fieldType: 'treeselect',
  44. definition: fieldDefinition,
  45. }