This commit is contained in:
James
2022-08-06 13:12:25 -04:00
parent a5918059a8
commit 209b02b069
4 changed files with 30 additions and 6 deletions

View File

@@ -178,18 +178,21 @@ function buildMutationInputType(payload: Payload, name: string, fields: Field[],
}),
row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) => field.fields.reduce((acc, subField: Field) => {
const addSubField = fieldToSchemaMap[subField.type];
return addSubField(acc, subField);
if (addSubField) return addSubField(acc, subField);
return acc;
}, inputObjectTypeConfig),
collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) => field.fields.reduce((acc, subField: CollapsibleField) => {
const addSubField = fieldToSchemaMap[subField.type];
return addSubField(acc, subField);
if (addSubField) return addSubField(acc, subField);
return acc;
}, inputObjectTypeConfig),
tabs: (inputObjectTypeConfig: InputObjectTypeConfig, field: TabsField) => field.tabs.reduce((acc, tab) => {
return {
...acc,
...tab.fields.reduce((subFieldSchema, subField) => {
const addSubField = fieldToSchemaMap[subField.type];
return addSubField(subFieldSchema, subField);
if (addSubField) return addSubField(subFieldSchema, subField);
return subFieldSchema;
}, acc),
};
}, inputObjectTypeConfig),

View File

@@ -444,18 +444,21 @@ function buildObjectType({
},
row: (objectTypeConfig: ObjectTypeConfig, field: RowField) => field.fields.reduce((objectTypeConfigWithRowFields, subField) => {
const addSubField = fieldToSchemaMap[subField.type];
return addSubField(objectTypeConfigWithRowFields, subField);
if (addSubField) return addSubField(objectTypeConfigWithRowFields, subField);
return objectTypeConfigWithRowFields;
}, objectTypeConfig),
collapsible: (objectTypeConfig: ObjectTypeConfig, field: CollapsibleField) => field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {
const addSubField = fieldToSchemaMap[subField.type];
return addSubField(objectTypeConfigWithCollapsibleFields, subField);
if (addSubField) return addSubField(objectTypeConfigWithCollapsibleFields, subField);
return objectTypeConfigWithCollapsibleFields;
}, objectTypeConfig),
tabs: (objectTypeConfig: ObjectTypeConfig, field: TabsField) => field.tabs.reduce((tabSchema, tab) => {
return {
...tabSchema,
...tab.fields.reduce((subFieldSchema, subField) => {
const addSubField = fieldToSchemaMap[subField.type];
return addSubField(subFieldSchema, subField);
if (addSubField) return addSubField(subFieldSchema, subField);
return subFieldSchema;
}, tabSchema),
};
}, objectTypeConfig),

View File

@@ -0,0 +1,7 @@
import React from 'react';
export const UIField: React.FC = () => {
return (
<p>This is a UI field within a tab component.</p>
);
};

View File

@@ -1,5 +1,6 @@
import type { CollectionConfig } from '../../../../src/collections/config/types';
import { blocksField, blocksFieldSeedData } from '../Blocks';
import { UIField } from './UIField';
const TabsFields: CollectionConfig = {
slug: 'tabs-fields',
@@ -12,6 +13,16 @@ const TabsFields: CollectionConfig = {
label: 'Tab with Array',
description: 'This tab has an array.',
fields: [
{
type: 'ui',
name: 'demoUIField',
label: 'Demo UI Field',
admin: {
components: {
Field: UIField,
},
},
},
{
name: 'array',
labels: {