Files
payload/test/fields/collections/Text/index.ts
Alessio Gravili 9467074fb9 chore: update 2.0 branch from master (#3207)
Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
Co-authored-by: Alessio Gravili <alessio@gravili.de>
Co-authored-by: PatrikKozak <patrik@trbl.design>
Co-authored-by: Lucas Blancas <lablancas@gmail.com>
Co-authored-by: Stef Gootzen <37367280+stefgootzen@users.noreply.github.com>
Co-authored-by: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com>
Co-authored-by: Jessica Chowdhury <67977755+JessChowdhury@users.noreply.github.com>
Co-authored-by: PatrikKozak <35232443+PatrikKozak@users.noreply.github.com>
Co-authored-by: Greg Willard <Wickett06@gmail.com>
Co-authored-by: James Mikrut <james@payloadcms.com>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
fix: WhereBuilder component does not accept all valid Where queries (#3087)
fix: passes in height to resizeOptions upload option to allow height resize (#3171)
2023-08-22 16:04:50 -04:00

89 lines
1.8 KiB
TypeScript

import type { CollectionConfig } from '../../../../src/collections/config/types';
export const defaultText = 'default-text';
export const textFieldsSlug = 'text-fields';
const TextFields: CollectionConfig = {
slug: textFieldsSlug,
admin: {
useAsTitle: 'text',
},
fields: [
{
name: 'text',
type: 'text',
required: true,
},
{
name: 'localizedText',
type: 'text',
localized: true,
},
{
name: 'i18nText',
type: 'text',
label: {
en: 'Text en',
es: 'Text es',
},
admin: {
placeholder: {
en: 'en placeholder',
es: 'es placeholder',
},
description: {
en: 'en description',
es: 'es description',
},
},
},
{
name: 'defaultFunction',
type: 'text',
defaultValue: () => (defaultText),
},
{
name: 'defaultAsync',
type: 'text',
defaultValue: async (): Promise<string> => {
return new Promise((resolve) => setTimeout(() => {
resolve(defaultText);
}, 1));
},
},
{
label: 'Override the 40k text length default',
name: 'overrideLength',
type: 'text',
maxLength: 50000,
},
{
name: 'fieldWithDefaultValue',
type: 'text',
defaultValue: async () => {
const defaultValue = new Promise((resolve) => setTimeout(() => resolve('some-value'), 1000));
return defaultValue;
},
},
{
name: 'dependentOnFieldWithDefaultValue',
type: 'text',
hooks: {
beforeChange: [
({ data }) => {
return data?.fieldWithDefaultValue || '';
},
],
},
},
],
};
export const textDoc = {
text: 'Seeded text document',
localizedText: 'Localized text',
};
export default TextFields;