import {string} from '../types/string' import {blockContent} from './blockContent' import {link as linkField} from './link' import {mergeConfig} from '../../configStore' import type {ContentGroupField, FieldReturn} from '../../types' const defaultProps: Partial = { label: {name: 'label'}, heading: {name: 'heading'}, content: {name: 'content'}, link: {name: 'link'}, } export const contentGroup = ( props?: ContentGroupField, mergeProps?: Partial, ): FieldReturn[] => { const {label, heading, content, link} = mergeConfig( 'contentGroup', props, mergeProps, defaultProps, ) const fields = [ label && string(label), heading && string(heading), content && blockContent(content), link && linkField(link), ].filter((field): field is FieldReturn => Boolean(field)) return fields }