index.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import type { App } from 'vue'
  3. import type { FormKitPlugin } from '@formkit/core'
  4. import mainInitializeForm, { getFormPlugins } from '@shared/form'
  5. import type {
  6. FormFieldTypeImportModules,
  7. FormThemeExtension,
  8. InitializeAppForm,
  9. } from '@shared/types/form'
  10. import type { ImportGlobEagerOutput } from '@shared/types/utils'
  11. import getCoreClasses from './theme/global/getCoreClasses'
  12. const pluginModules: ImportGlobEagerOutput<FormKitPlugin> = import.meta.glob(
  13. './plugins/global/*.ts',
  14. { eager: true },
  15. )
  16. const fieldModules: ImportGlobEagerOutput<FormFieldTypeImportModules> =
  17. import.meta.glob('../components/Form/fields/**/index.ts', { eager: true })
  18. const themeExtensionModules: ImportGlobEagerOutput<FormThemeExtension> =
  19. import.meta.glob('./theme/global/extensions/*.ts', { eager: true })
  20. const initializeForm: InitializeAppForm = (app: App) => {
  21. const plugins = getFormPlugins(pluginModules)
  22. const theme = {
  23. coreClasses: getCoreClasses,
  24. extensions: themeExtensionModules,
  25. }
  26. mainInitializeForm(app, undefined, fieldModules, plugins, theme)
  27. }
  28. export default initializeForm