index.ts 983 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import createInput from '#shared/form/core/createInput.ts'
  3. import addLink from '#shared/form/features/addLink.ts'
  4. import formUpdaterTrigger from '#shared/form/features/formUpdaterTrigger.ts'
  5. import FieldToggleInput from './FieldToggleInput.vue'
  6. import type { FormKitBaseSlots, FormKitInputs } from '@formkit/inputs'
  7. declare module '@formkit/inputs' {
  8. interface FormKitInputProps<Props extends FormKitInputs<Props>> {
  9. toggle: {
  10. type: 'toggle'
  11. value?: boolean
  12. variants?: {
  13. true?: string
  14. false?: string
  15. }
  16. size?: 'medium' | 'small'
  17. }
  18. }
  19. interface FormKitInputSlots<Props extends FormKitInputs<Props>> {
  20. toggle: FormKitBaseSlots<Props>
  21. }
  22. }
  23. const fieldDefinition = createInput(FieldToggleInput, ['variants', 'size'], {
  24. features: [addLink, formUpdaterTrigger()],
  25. })
  26. export default {
  27. fieldType: 'toggle',
  28. definition: fieldDefinition,
  29. }