Files
payload/test/fields/collections/Array/index.ts
Dan Ribbens bab34d82f5 feat: add i18n to admin panel (#1326)
Co-authored-by: shikhantmaungs <shinkhantmaungs@gmail.com>
Co-authored-by: Thomas Ghysels <info@thomasg.be>
Co-authored-by: Kokutse Djoguenou <kokutse@Kokutses-MacBook-Pro.local>
Co-authored-by: Christian Gil <47041342+ChrisGV04@users.noreply.github.com>
Co-authored-by: Łukasz Rabiec <lukaszrabiec@gmail.com>
Co-authored-by: Jenny <jennifer.eberlei@gmail.com>
Co-authored-by: Hung Vu <hunghvu2017@gmail.com>
Co-authored-by: Shin Khant Maung <101539335+shinkhantmaungs@users.noreply.github.com>
Co-authored-by: Carlo Brualdi <carlo.brualdi@gmail.com>
Co-authored-by: Ariel Tonglet <ariel.tonglet@gmail.com>
Co-authored-by: Roman Ryzhikov <general+github@ya.ru>
Co-authored-by: maekoya <maekoya@stromatolite.jp>
Co-authored-by: Emilia Trollros <3m1l1a@emiliatrollros.se>
Co-authored-by: Kokutse J Djoguenou <90865585+Julesdj@users.noreply.github.com>
Co-authored-by: Mitch Dries <mitch.dries@gmail.com>

BREAKING CHANGE: If you assigned labels to collections, globals or block names, you need to update your config! Your GraphQL schema and generated Typescript interfaces may have changed. Payload no longer uses labels for code based naming. To prevent breaking changes to your GraphQL API and typescript types in your project, you can assign the below properties to match what Payload previously generated for you from labels.

On Collections
Use `graphQL.singularName`, `graphQL.pluralName` for GraphQL schema names.
Use `typescript.interface` for typescript generation name.

On Globals
Use `graphQL.name` for GraphQL Schema name.
Use `typescript.interface` for typescript generation name.

On Blocks (within Block fields)
Use `graphQL.singularName` for graphQL schema names.
2022-11-18 07:36:30 -05:00

150 lines
2.6 KiB
TypeScript

import type { CollectionConfig } from '../../../../src/collections/config/types';
import { ArrayRowLabel } from './LabelComponent';
export const arrayDefaultValue = [
{ text: 'row one' },
{ text: 'row two' },
];
export const arrayFieldsSlug = 'array-fields';
const ArrayFields: CollectionConfig = {
slug: arrayFieldsSlug,
fields: [
{
name: 'items',
type: 'array',
required: true,
defaultValue: arrayDefaultValue,
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
{
name: 'collapsedArray',
type: 'array',
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
admin: {
initCollapsed: true,
},
},
{
name: 'localized',
type: 'array',
required: true,
localized: true,
defaultValue: arrayDefaultValue,
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
},
{
type: 'array',
name: 'readOnly',
admin: {
readOnly: true,
},
defaultValue: [
{
text: 'defaultValue',
},
{
text: 'defaultValue2',
},
],
fields: [
{
type: 'text',
name: 'text',
},
],
},
{
type: 'array',
name: 'potentiallyEmptyArray',
fields: [
{
type: 'text',
name: 'text',
},
],
},
{
type: 'array',
name: 'rowLabelAsFunction',
fields: [
{
name: 'title',
type: 'text',
},
],
admin: {
description: 'Row labels rendered from a function.',
components: {
RowLabel: ({ data }) => data.title,
},
},
},
{
type: 'array',
name: 'rowLabelAsComponent',
fields: [
{
name: 'title',
type: 'text',
},
],
admin: {
description: 'Row labels rendered as react components.',
components: {
RowLabel: ArrayRowLabel,
},
},
},
],
};
export const arrayDoc = {
items: [
{
text: 'first row',
},
{
text: 'second row',
},
{
text: 'third row',
},
{
text: 'fourth row',
},
{
text: 'fifth row',
},
{
text: 'sixth row',
},
],
collapsedArray: [
{
text: 'initialize collapsed',
},
],
};
export default ArrayFields;