UNPKG

@nouance/payload-better-fields-plugin

Version:

A Payload plugin that aims to provide improved fields for the admin panel

48 lines (47 loc) 1.36 kB
import { formatSlugHook } from './formatSlug.js'; export const SlugField = (fieldToUse = 'title', overrides = {})=>{ const { checkboxOverrides, slugOverrides } = overrides; const checkBoxField = { name: 'slugLock', type: 'checkbox', admin: { hidden: true, position: 'sidebar' }, defaultValue: true, ...checkboxOverrides }; // @ts-expect-error - ts mismatch Partial<TextField> with TextField const slugField = { name: 'slug', type: 'text', index: true, label: 'Slug', unique: true, ...slugOverrides || {}, admin: { position: 'sidebar', ...slugOverrides?.admin || {}, components: { Field: { clientProps: { checkboxFieldPath: checkBoxField.name, fieldToUse }, path: '@nouance/payload-better-fields-plugin/Slug/client#SlugComponent' } } }, hooks: { // Kept this in for hook or API based updates beforeValidate: [ formatSlugHook(fieldToUse) ] } }; return [ slugField, checkBoxField ]; }; //# sourceMappingURL=index.js.map