import type { Block, Field } from 'payload' /** * Extra form-builder field types — what the built-in set can't express: * * - `step` — a divider: fields below it (until the next Step) are one * screen of a step-by-step form, with Next / Back buttons. * Carries no value. * - `checkboxGroup` — a list of options where the visitor ticks several * ("Services you're interested in"). Value: string[]. * * Plain English labels (the panel is EN). Rendered by BuilderForm / * useBuilderForm, validated by submitForm like every other field. */ const name: Field = { name: 'name', type: 'text', admin: { description: 'Technical name, e.g. "services" — no spaces.', width: '50%' }, label: 'Name (lowercase, no special characters)', required: true, } const label: Field = { name: 'label', type: 'text', admin: { width: '50%' }, label: 'Label', localized: true } const width: Field = { name: 'width', type: 'number', admin: { width: '50%' }, label: 'Field width (percentage)' } const required: Field = { name: 'required', type: 'checkbox', admin: { width: '50%' }, label: 'Required' } export const stepBlock: Block = { slug: 'step', fields: [ { name: 'title', type: 'text', admin: { description: 'Starts a new step: the fields below it (until the next Step) are shown together, with Next / Back buttons. Leave the form without Steps for a single-screen form.', }, label: 'Step title', localized: true, }, { name: 'description', type: 'textarea', admin: { rows: 2 }, label: 'Step description', localized: true }, ], labels: { plural: 'Steps', singular: 'Step' }, } export const checkboxGroupBlock: Block = { slug: 'checkboxGroup', fields: [ { type: 'row', fields: [name, label] }, { type: 'row', fields: [width, required] }, { name: 'options', type: 'array', fields: [ { type: 'row', fields: [ { name: 'label', type: 'text', admin: { width: '50%' }, label: 'Label', localized: true, required: true }, { name: 'value', type: 'text', admin: { width: '50%' }, label: 'Value', required: true }, ], }, ], labels: { plural: 'Options', singular: 'Option' }, minRows: 1, }, { type: 'row', fields: [ { name: 'minSelected', type: 'number', admin: { description: 'Empty = no minimum (Required = at least one).', width: '50%' }, label: 'Minimum selected', min: 0 }, { name: 'maxSelected', type: 'number', admin: { description: 'Empty = no limit.', width: '50%' }, label: 'Maximum selected', min: 1 }, ], }, ], labels: { plural: 'Checkbox groups', singular: 'Checkbox group' }, }