Breaking Changes: - Globals config: `admin.description` no longer accepts a custom component. You will have to move it to `admin.components.elements.Description` - Collections config: `admin.description` no longer accepts a custom component. You will have to move it to `admin.components.edit.Description` - All Fields: `field.admin.description` no longer accepts a custom component. You will have to move it to `field.admin.components.Description` - Collapsible Field: `field.label` no longer accepts a custom component. You will have to move it to `field.admin.components.RowLabel` - Array Field: `field.admin.components.RowLabel` no longer accepts strings or records - If you are using our exported field components in your own app, their `labelProps` property has been stripped down and no longer contains the `label` and `required` prop. Those can now only be configured at the top-level
155 lines
3.4 KiB
TypeScript
155 lines
3.4 KiB
TypeScript
import type { CollectionConfig } from 'payload/types'
|
|
|
|
import { collapsibleFieldsSlug } from '../../slugs.js'
|
|
import { getCustomLabel } from './CustomLabel/getCustomLabel.js'
|
|
import { NestedCustomLabel } from './NestedCustomLabel/index.js'
|
|
|
|
const CollapsibleFields: CollectionConfig = {
|
|
slug: collapsibleFieldsSlug,
|
|
versions: true,
|
|
fields: [
|
|
{
|
|
label: 'Collapsible Field',
|
|
type: 'collapsible',
|
|
admin: {
|
|
description: 'This is a collapsible field.',
|
|
initCollapsed: false,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'group',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'textWithinGroup',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'subGroup',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'textWithinSubGroup',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: 'Collapsible Field - Collapsed by Default',
|
|
type: 'collapsible',
|
|
admin: {
|
|
description: 'This is a collapsible field.',
|
|
initCollapsed: true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'someText',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'group2',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'textWithinGroup',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'subGroup',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'textWithinSubGroup',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'collapsible',
|
|
admin: {
|
|
description: 'Collapsible label rendered from a function.',
|
|
initCollapsed: true,
|
|
components: {
|
|
RowLabel: () =>
|
|
getCustomLabel({
|
|
path: 'functionTitleField',
|
|
fallback: 'Custom Collapsible Label',
|
|
style: {},
|
|
}),
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'functionTitleField',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'collapsible',
|
|
admin: {
|
|
description: 'Collapsible label rendered as a react component.',
|
|
components: {
|
|
RowLabel: () => getCustomLabel({ path: 'componentTitleField', style: {} }),
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'componentTitleField',
|
|
type: 'text',
|
|
},
|
|
{
|
|
type: 'collapsible',
|
|
admin: {
|
|
components: {
|
|
RowLabel: () =>
|
|
getCustomLabel({ path: 'nestedTitle', fallback: 'Nested Collapsible', style: {} }),
|
|
},
|
|
},
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'nestedTitle',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'arrayWithCollapsibles',
|
|
type: 'array',
|
|
fields: [
|
|
{
|
|
admin: {
|
|
components: {
|
|
RowLabel: NestedCustomLabel,
|
|
},
|
|
},
|
|
type: 'collapsible',
|
|
fields: [
|
|
{
|
|
name: 'innerCollapsible',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|
|
|
|
export default CollapsibleFields
|