Socket
Socket
Sign inDemoInstall

@nouance/payload-better-fields-plugin

Package Overview
Dependencies
1
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nouance/payload-better-fields-plugin

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


Version published
Maintainers
1
Created

Readme

Source

Better fields plugin (beta)

This plugin aims to provide you with very specific and improved fields for the admin panel.
We've tried to keep styling as consistent as possible with the existing admin UI, however if there are any issues please report them!

Every field will come with its own usage instructions and structure. These are subject to change!

Installation

  yarn add @nouance/payload-better-fields-plugin
  # OR
  npm i @nouance/payload-better-fields-plugin

Fields

  • Slug field

  • Combo field

Slug field

slugField

Usage

import { CollectionConfig } from 'payload/types'
import { SlugField } from '@nouance/payload-better-fields-plugin'

const Examples: CollectionConfig = {
  slug: 'examples',
  admin: {
    useAsTitle: 'title',
  },
  fields: [
    {
      name: 'title',
      type: 'text',
    },
    ...SlugField(['title'], undefined, {
      admin: {
        position: 'sidebar',
      },
    }),
  ],
}

Options

The SlugField accepts the following parameters, all are optional

  • fieldToUse - string[] @default ['title']

  • slugifyOptions - Options to be passed to the slugify function

@default
{ lower: true, remove: /[*+~.()'"!?#\.,:@]/g }
  • slugOverrides - TextField Slug field overrides, use this to rename the machine name or label of the field

  • enableEditSlug - boolean @default true Enable or disable the checkbox field

  • editSlugOverrides - CheckboxField @default ['title'] Checkbox field overrides

Combo field

comboField

Usage

import { CollectionConfig } from 'payload/types'
import { ComboField } from '@nouance/payload-better-fields-plugin'

const Examples: CollectionConfig = {
  slug: 'examples',
  admin: {
    useAsTitle: 'fullName',
  },
  fields: [
    {
      type: 'row',
      fields: [
        {
          name: 'firstName',
          type: 'text',
        },
        {
          name: 'lastName',
          type: 'text',
        },
      ],
    },
    ...ComboField(['firstName', 'lastName'], { name: 'fullName' }),
  ],
}

Options

The ComboField accepts the following parameters, all are optional

  • fieldToUse - string[] required

  • overrides - TextField required for name attribute

  • options

    • separator - string @default ' '

    • initial - string The starting string value before all fields are concatenated

    • callback - (value: string) => string You can apply a callback to modify each field value if you want to preprocess them

Contributing

For development purposes, there is a full working example of how this plugin might be used in the dev directory of this repo.

git clone git@github.com:NouanceLabs/payload-better-fields-plugin.git \
  cd payload-better-fields-plugin && yarn \
  cd demo && yarn \
  cp .env.example .env \
  vim .env \ # add your payload details
  yarn dev

Keywords

FAQs

Last updated on 03 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc