Files
payloadcms/test/fields/collections/Array/index.ts
Patrik 224cddd045 feat: relationship sortOptions property (#4301)
* feat: adds sortOptions property to relationship field

* chore: fix lexical int tests

* feat: simplifies logic & updates joi schema definition

* feat: revert to default when searching in relationship select

* fix types and joi schema

* type adjustments

---------

Co-authored-by: Alessio Gravili <alessio@bonfireleads.com>
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-11-29 16:22:47 -05:00

159 lines
2.9 KiB
TypeScript

import type { CollectionConfig } from '../../../../packages/payload/src/collections/config/types'
import { arrayFieldsSlug } from '../../slugs'
import { ArrayRowLabel } from './LabelComponent'
export const arrayDefaultValue = [{ text: 'row one' }, { text: 'row two' }]
const ArrayFields: CollectionConfig = {
admin: {
enableRichTextLink: false,
},
fields: [
{
name: 'title',
type: 'text',
required: false,
},
{
name: 'items',
defaultValue: arrayDefaultValue,
fields: [
{
name: 'text',
required: true,
type: 'text',
},
{
name: 'subArray',
fields: [
{
name: 'text',
type: 'text',
},
],
type: 'array',
},
],
required: true,
type: 'array',
},
{
name: 'collapsedArray',
admin: {
initCollapsed: true,
},
fields: [
{
name: 'text',
required: true,
type: 'text',
},
],
type: 'array',
},
{
name: 'localized',
defaultValue: arrayDefaultValue,
fields: [
{
name: 'text',
required: true,
type: 'text',
},
],
localized: true,
required: true,
type: 'array',
},
{
name: 'readOnly',
admin: {
readOnly: true,
},
defaultValue: [
{
text: 'defaultValue',
},
{
text: 'defaultValue2',
},
],
fields: [
{
name: 'text',
type: 'text',
},
],
type: 'array',
},
{
name: 'potentiallyEmptyArray',
fields: [
{
name: 'text',
type: 'text',
},
{
name: 'groupInRow',
fields: [
{
name: 'textInGroupInRow',
type: 'text',
},
],
type: 'group',
},
],
type: 'array',
},
{
name: 'rowLabelAsFunction',
admin: {
components: {
RowLabel: ({ data }) => data.title,
},
description: 'Row labels rendered from a function.',
},
fields: [
{
name: 'title',
type: 'text',
},
],
type: 'array',
},
{
name: 'rowLabelAsComponent',
admin: {
components: {
RowLabel: ArrayRowLabel,
},
description: 'Row labels rendered as react components.',
},
fields: [
{
name: 'title',
type: 'text',
},
],
type: 'array',
},
{
name: 'arrayWithMinRows',
fields: [
{
name: 'text',
type: 'text',
},
],
minRows: 2,
type: 'array',
},
],
slug: arrayFieldsSlug,
versions: true,
}
export default ArrayFields