defineFormSchema.ts 587 B

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