formLocaleDir.ts 577 B

123456789101112131415161718
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { useLocaleStore } from '#shared/stores/locale.ts'
  3. import type { FormKitNode } from '@formkit/core'
  4. import { toRef } from 'vue'
  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