From ed68583392d1f5651464bee24e02767d6e57ebcc Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Thu, 26 Oct 2023 23:07:33 -0400 Subject: [PATCH] chore(plugin-form-builder): format --- packages/plugin-form-builder/README.md | 33 +- .../demo/src/payload-types.ts | 306 +++++++++--------- .../demo/src/payload.config.ts | 2 +- .../plugin-form-builder/demo/tsconfig.json | 8 +- packages/plugin-form-builder/types.d.ts | 2 +- packages/plugin-form-builder/types.js | 2 +- 6 files changed, 175 insertions(+), 178 deletions(-) diff --git a/packages/plugin-form-builder/README.md b/packages/plugin-form-builder/README.md index d52047b6e..80c66df99 100644 --- a/packages/plugin-form-builder/README.md +++ b/packages/plugin-form-builder/README.md @@ -28,20 +28,20 @@ Core features: In the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview), call the plugin with [options](#options): ```js -import { buildConfig } from "payload/config"; -import formBuilder from "@payloadcms/plugin-form-builder"; +import { buildConfig } from 'payload/config' +import formBuilder from '@payloadcms/plugin-form-builder' const config = buildConfig({ collections: [ { - slug: "pages", + slug: 'pages', fields: [], }, ], plugins: [formBuilder()], -}); +}) -export default config; +export default config ``` ### Options @@ -70,7 +70,7 @@ export default config; An array of collection slugs that, when enabled, are populated as options in form redirect fields. ```js - redirectRelationships: ["pages"]; + redirectRelationships: ['pages'] ``` - `handlePayment` @@ -102,8 +102,8 @@ export default config; return emails.map((email) => ({ ...email, html: email.html, // transform the html in any way you'd like (maybe wrap it in an html template?) - })); - }; + })) + } ``` - `formOverrides` @@ -196,6 +196,7 @@ Each field represents a form input. To override default settings pass either a b - `message` - `message`: richText - `payment` + - `name`: string - `label`: string - `defaultValue`: number @@ -214,7 +215,7 @@ Each field represents a form input. To override default settings pass either a b You can also provide your own custom field definitions by passing a new [Payload Block](https://payloadcms.com/docs/fields/blocks#block-configs) object into `fields`. You can override or extend any existing fields by first importing the `fields` from the plugin: ```ts - import { fields } from "@payloadcms/plugin-form-builder"; + import { fields } from '@payloadcms/plugin-form-builder' ``` Then merging it into your own custom field: @@ -283,7 +284,7 @@ To actively develop or debug this plugin you can either work directly within the You might also need to alias these modules in your Webpack config. To do this, open your project's Payload config and add the following: ```ts - import { buildConfig } from "payload/config"; + import { buildConfig } from 'payload/config' export default buildConfig({ admin: { @@ -293,18 +294,18 @@ To actively develop or debug this plugin you can either work directly within the ...config.resolve, alias: { ...config.resolve.alias, - react: path.join(__dirname, "../node_modules/react"), - "react-dom": path.join(__dirname, "../node_modules/react-dom"), - payload: path.join(__dirname, "../node_modules/payload"), - "@payloadcms/plugin-form-builder": path.join( + react: path.join(__dirname, '../node_modules/react'), + 'react-dom': path.join(__dirname, '../node_modules/react-dom'), + payload: path.join(__dirname, '../node_modules/payload'), + '@payloadcms/plugin-form-builder': path.join( __dirname, - "../../payload/plugin-form-builder/src" + '../../payload/plugin-form-builder/src', ), }, }, }), }, - }); + }) ``` ## Troubleshooting diff --git a/packages/plugin-form-builder/demo/src/payload-types.ts b/packages/plugin-form-builder/demo/src/payload-types.ts index 43c698fad..b3c3cb55d 100644 --- a/packages/plugin-form-builder/demo/src/payload-types.ts +++ b/packages/plugin-form-builder/demo/src/payload-types.ts @@ -7,199 +7,199 @@ export interface Config { collections: { - users: User; - pages: Page; - forms: Form; - 'form-submissions': FormSubmission; - }; - globals: {}; + users: User + pages: Page + forms: Form + 'form-submissions': FormSubmission + } + globals: {} } export interface User { - id: string; - updatedAt: string; - createdAt: string; - email?: string; - resetPasswordToken?: string; - resetPasswordExpiration?: string; - loginAttempts?: number; - lockUntil?: string; - password?: string; + id: string + updatedAt: string + createdAt: string + email?: string + resetPasswordToken?: string + resetPasswordExpiration?: string + loginAttempts?: number + lockUntil?: string + password?: string } export interface Page { - id: string; - title: string; - form?: string | Form; - updatedAt: string; - createdAt: string; + id: string + title: string + form?: string | Form + updatedAt: string + createdAt: string } export interface Form { - id: string; - title: string; + id: string + title: string fields?: ( | { - name: string; - label?: string; - width?: number; - defaultValue?: string; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'text'; + name: string + label?: string + width?: number + defaultValue?: string + required?: boolean + id?: string + blockName?: string + blockType: 'text' } | { - name: string; - label?: string; - width?: number; - defaultValue?: string; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'textarea'; + name: string + label?: string + width?: number + defaultValue?: string + required?: boolean + id?: string + blockName?: string + blockType: 'textarea' } | { - name: string; - label?: string; - width?: number; - defaultValue?: string; + name: string + label?: string + width?: number + defaultValue?: string options: { - label: string; - value: string; - id?: string; - }[]; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'select'; + label: string + value: string + id?: string + }[] + required?: boolean + id?: string + blockName?: string + blockType: 'select' } | { - name: string; - label?: string; - width?: number; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'email'; + name: string + label?: string + width?: number + required?: boolean + id?: string + blockName?: string + blockType: 'email' } | { - name: string; - label?: string; - width?: number; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'state'; + name: string + label?: string + width?: number + required?: boolean + id?: string + blockName?: string + blockType: 'state' } | { - name: string; - label?: string; - width?: number; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'country'; + name: string + label?: string + width?: number + required?: boolean + id?: string + blockName?: string + blockType: 'country' } | { - name: string; - label?: string; - width?: number; - defaultValue?: number; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'number'; + name: string + label?: string + width?: number + defaultValue?: number + required?: boolean + id?: string + blockName?: string + blockType: 'number' } | { - name: string; - label?: string; - width?: number; - required?: boolean; - defaultValue?: boolean; - id?: string; - blockName?: string; - blockType: 'checkbox'; + name: string + label?: string + width?: number + required?: boolean + defaultValue?: boolean + id?: string + blockName?: string + blockType: 'checkbox' } | { message?: { - [k: string]: unknown; - }[]; - id?: string; - blockName?: string; - blockType: 'message'; + [k: string]: unknown + }[] + id?: string + blockName?: string + blockType: 'message' } | { - name: string; - label?: string; - width?: number; - basePrice?: number; + name: string + label?: string + width?: number + basePrice?: number priceConditions?: { - fieldToUse?: string; - condition?: 'hasValue' | 'equals' | 'notEquals'; - valueForCondition?: string; - operator?: 'add' | 'subtract' | 'multiply' | 'divide'; - valueType?: 'static' | 'valueOfField'; - valueForOperator?: string; - id?: string; - }[]; - required?: boolean; - id?: string; - blockName?: string; - blockType: 'payment'; + fieldToUse?: string + condition?: 'hasValue' | 'equals' | 'notEquals' + valueForCondition?: string + operator?: 'add' | 'subtract' | 'multiply' | 'divide' + valueType?: 'static' | 'valueOfField' + valueForOperator?: string + id?: string + }[] + required?: boolean + id?: string + blockName?: string + blockType: 'payment' } | { - value?: string; - id?: string; - blockName?: string; - blockType: 'color'; + value?: string + id?: string + blockName?: string + blockType: 'color' } - )[]; - submitButtonLabel?: string; - confirmationType?: 'message' | 'redirect'; + )[] + submitButtonLabel?: string + confirmationType?: 'message' | 'redirect' confirmationMessage: { - [k: string]: unknown; - }[]; + [k: string]: unknown + }[] redirect?: { - type?: 'reference' | 'custom'; + type?: 'reference' | 'custom' reference: { - value: string | Page; - relationTo: 'pages'; - }; - url: string; - }; + value: string | Page + relationTo: 'pages' + } + url: string + } emails: { - emailTo?: string; - cc?: string; - bcc?: string; - replyTo?: string; - emailFrom?: string; - subject: string; + emailTo?: string + cc?: string + bcc?: string + replyTo?: string + emailFrom?: string + subject: string message?: { - [k: string]: unknown; - }[]; - id?: string; - }[]; - name?: string; - updatedAt: string; - createdAt: string; + [k: string]: unknown + }[] + id?: string + }[] + name?: string + updatedAt: string + createdAt: string } export interface FormSubmission { - id: string; - form: string | Form; + id: string + form: string | Form submissionData: { - field: string; - value: string; - id?: string; - }[]; + field: string + value: string + id?: string + }[] payment?: { - field?: string; - status?: string; - amount?: number; - paymentProcessor?: string; + field?: string + status?: string + amount?: number + paymentProcessor?: string creditCard?: { - token?: string; - brand?: string; - number?: string; - }; - }; - updatedAt: string; - createdAt: string; + token?: string + brand?: string + number?: string + } + } + updatedAt: string + createdAt: string } diff --git a/packages/plugin-form-builder/demo/src/payload.config.ts b/packages/plugin-form-builder/demo/src/payload.config.ts index 4e168646a..300f752be 100644 --- a/packages/plugin-form-builder/demo/src/payload.config.ts +++ b/packages/plugin-form-builder/demo/src/payload.config.ts @@ -30,7 +30,7 @@ export default buildConfig({ }, admin: { user: Users.slug, - webpack: config => { + webpack: (config) => { const newConfig = { ...config, resolve: { diff --git a/packages/plugin-form-builder/demo/tsconfig.json b/packages/plugin-form-builder/demo/tsconfig.json index 7b58db48b..6fc62185a 100644 --- a/packages/plugin-form-builder/demo/tsconfig.json +++ b/packages/plugin-form-builder/demo/tsconfig.json @@ -1,17 +1,13 @@ { "compilerOptions": { "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "strict": false, "esModuleInterop": true, "skipLibCheck": true, "outDir": "./dist", "rootDir": "../", - "jsx": "react", + "jsx": "react" }, "ts-node": { "transpileOnly": true diff --git a/packages/plugin-form-builder/types.d.ts b/packages/plugin-form-builder/types.d.ts index 7236c51a0..64a93ddff 100644 --- a/packages/plugin-form-builder/types.d.ts +++ b/packages/plugin-form-builder/types.d.ts @@ -1 +1 @@ -export * from './dist/types'; +export * from './dist/types' diff --git a/packages/plugin-form-builder/types.js b/packages/plugin-form-builder/types.js index d94f7183d..b1e46c47a 100644 --- a/packages/plugin-form-builder/types.js +++ b/packages/plugin-form-builder/types.js @@ -1 +1 @@ -module.exports = require('./dist/types'); +module.exports = require('./dist/types')