defineFormSchema.ts 604 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import type { FormSchemaNode } from '@shared/components/Form'
  3. type FormSchemaOptions = {
  4. showDirtyMark: boolean
  5. }
  6. // TODO: do we need this?
  7. export const defineFormSchema = (
  8. schema: FormSchemaNode[],
  9. options?: FormSchemaOptions,
  10. ): FormSchemaNode[] => {
  11. const needGroup = schema.every(
  12. (node) => !(typeof node !== 'string' && 'isLayout' in node),
  13. )
  14. if (!needGroup) return schema
  15. return [
  16. {
  17. isLayout: true,
  18. component: 'FormGroup',
  19. props: options,
  20. children: schema,
  21. },
  22. ]
  23. }