formLocaleDir.ts 579 B

1234567891011121314151617181920
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { toRef } from 'vue'
  3. import { useLocaleStore } from '#shared/stores/locale.ts'
  4. import type { FormKitNode } from '@formkit/core'
  5. const formLocaleDir = (node: FormKitNode) => {
  6. const locale = useLocaleStore()
  7. const { props } = node
  8. node.addProps(['localeDir', 'arrowIconName'])
  9. props.localeDir = toRef(() => locale.localeData?.dir ?? 'ltr')
  10. props.arrowIconName = toRef(
  11. () => `chevron-${locale.localeData?.dir === 'rtl' ? 'left' : 'right'}`,
  12. )
  13. }
  14. export default formLocaleDir