chore(plugin-form-builder): format
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export default buildConfig({
|
||||
},
|
||||
admin: {
|
||||
user: Users.slug,
|
||||
webpack: config => {
|
||||
webpack: (config) => {
|
||||
const newConfig = {
|
||||
...config,
|
||||
resolve: {
|
||||
|
||||
@@ -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
|
||||
|
||||
2
packages/plugin-form-builder/types.d.ts
vendored
2
packages/plugin-form-builder/types.d.ts
vendored
@@ -1 +1 @@
|
||||
export * from './dist/types';
|
||||
export * from './dist/types'
|
||||
|
||||
@@ -1 +1 @@
|
||||
module.exports = require('./dist/types');
|
||||
module.exports = require('./dist/types')
|
||||
|
||||
Reference in New Issue
Block a user