@payloadcms/plugin-form-builder 3.0.0-canary.a78fca3 → 3.0.0-canary.ab70b75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collections/FormSubmissions/hooks/createCharge.d.ts.map +1 -1
- package/dist/collections/FormSubmissions/hooks/createCharge.js.map +1 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts +4 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts.map +1 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.js +8 -8
- package/dist/collections/FormSubmissions/hooks/sendEmail.js.map +1 -1
- package/dist/collections/FormSubmissions/index.d.ts.map +1 -1
- package/dist/collections/FormSubmissions/index.js +3 -1
- package/dist/collections/FormSubmissions/index.js.map +1 -1
- package/dist/collections/Forms/DynamicFieldSelector.d.ts +4 -2
- package/dist/collections/Forms/DynamicFieldSelector.d.ts.map +1 -1
- package/dist/collections/Forms/DynamicFieldSelector.js +7 -6
- package/dist/collections/Forms/DynamicFieldSelector.js.map +1 -1
- package/dist/collections/Forms/DynamicPriceSelector.d.ts +2 -3
- package/dist/collections/Forms/DynamicPriceSelector.d.ts.map +1 -1
- package/dist/collections/Forms/DynamicPriceSelector.js +8 -10
- package/dist/collections/Forms/DynamicPriceSelector.js.map +1 -1
- package/dist/collections/Forms/fields.d.ts +1 -1
- package/dist/collections/Forms/fields.d.ts.map +1 -1
- package/dist/collections/Forms/fields.js +2 -5
- package/dist/collections/Forms/fields.js.map +1 -1
- package/dist/collections/Forms/index.d.ts.map +1 -1
- package/dist/collections/Forms/index.js +15 -8
- package/dist/collections/Forms/index.js.map +1 -1
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +4 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +29 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/getPaymentTotal.d.ts +2 -2
- package/dist/utilities/getPaymentTotal.d.ts.map +1 -1
- package/dist/utilities/getPaymentTotal.js.map +1 -1
- package/dist/utilities/keyValuePairToHtmlTable.d.ts +4 -0
- package/dist/utilities/keyValuePairToHtmlTable.d.ts.map +1 -0
- package/dist/utilities/keyValuePairToHtmlTable.js +10 -0
- package/dist/utilities/keyValuePairToHtmlTable.js.map +1 -0
- package/dist/utilities/lexical/converters/heading.js.map +1 -1
- package/dist/utilities/lexical/converters/linebreak.js.map +1 -1
- package/dist/utilities/lexical/converters/link.js.map +1 -1
- package/dist/utilities/lexical/converters/list.js.map +1 -1
- package/dist/utilities/lexical/converters/paragraph.js.map +1 -1
- package/dist/utilities/lexical/converters/quote.js.map +1 -1
- package/dist/utilities/lexical/converters/text.js.map +1 -1
- package/dist/utilities/lexical/defaultConverters.js.map +1 -1
- package/dist/utilities/lexical/nodeFormat.js.map +1 -1
- package/dist/utilities/lexical/serializeLexical.js.map +1 -1
- package/dist/utilities/lexical/types.d.ts +2 -2
- package/dist/utilities/lexical/types.d.ts.map +1 -1
- package/dist/utilities/lexical/types.js.map +1 -1
- package/dist/utilities/replaceDoubleCurlys.d.ts.map +1 -1
- package/dist/utilities/replaceDoubleCurlys.js +18 -2
- package/dist/utilities/replaceDoubleCurlys.js.map +1 -1
- package/dist/utilities/slate/serializeSlate.d.ts.map +1 -1
- package/dist/utilities/slate/serializeSlate.js +1 -1
- package/dist/utilities/slate/serializeSlate.js.map +1 -1
- package/package.json +24 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCharge.d.ts","sourceRoot":"","sources":["../../../../src/collections/FormSubmissions/hooks/createCharge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAEhE,eAAO,MAAM,YAAY,qBACL,GAAG,cACT,uBAAuB,KAClC,
|
|
1
|
+
{"version":3,"file":"createCharge.d.ts","sourceRoot":"","sources":["../../../../src/collections/FormSubmissions/hooks/createCharge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAEhE,eAAO,MAAM,YAAY,qBACL,GAAG,cACT,uBAAuB,KAClC,OAAO,CAAC,GAAG,CAeb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/createCharge.ts"],"sourcesContent":["import type { FormBuilderPluginConfig } from '../../../types.js'\n\nexport const createCharge = async (\n beforeChangeData: any,\n formConfig: FormBuilderPluginConfig,\n): Promise<any> => {\n const { data, operation } = beforeChangeData\n\n let dataWithPaymentDetails = data\n\n if (operation === 'create') {\n const { handlePayment } = formConfig || {}\n\n if (typeof handlePayment === 'function') {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n dataWithPaymentDetails = await handlePayment(beforeChangeData)\n }\n }\n\n return dataWithPaymentDetails\n}\n"],"names":["createCharge","beforeChangeData","formConfig","data","operation","dataWithPaymentDetails","handlePayment"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/createCharge.ts"],"sourcesContent":["import type { FormBuilderPluginConfig } from '../../../types.js'\n\nexport const createCharge = async (\n beforeChangeData: any,\n formConfig: FormBuilderPluginConfig,\n): Promise<any> => {\n const { data, operation } = beforeChangeData\n\n let dataWithPaymentDetails = data\n\n if (operation === 'create') {\n const { handlePayment } = formConfig || {}\n\n if (typeof handlePayment === 'function') {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n dataWithPaymentDetails = await handlePayment(beforeChangeData)\n }\n }\n\n return dataWithPaymentDetails\n}\n"],"names":["createCharge","beforeChangeData","formConfig","data","operation","dataWithPaymentDetails","handlePayment"],"mappings":"AAEA,OAAO,MAAMA,eAAe,OAC1BC,kBACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAE,GAAGH;IAE5B,IAAII,yBAAyBF;IAE7B,IAAIC,cAAc,UAAU;QAC1B,MAAM,EAAEE,aAAa,EAAE,GAAGJ,cAAc,CAAC;QAEzC,IAAI,OAAOI,kBAAkB,YAAY;YACvC,6DAA6D;YAC7DD,yBAAyB,MAAMC,cAAcL;QAC/C;IACF;IAEA,OAAOI;AACT,EAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { CollectionBeforeChangeHook } from 'payload';
|
|
1
2
|
import type { FormBuilderPluginConfig } from '../../../types.js';
|
|
2
|
-
|
|
3
|
+
type BeforeChangeParams = Parameters<CollectionBeforeChangeHook>[0];
|
|
4
|
+
export declare const sendEmail: (beforeChangeParameters: BeforeChangeParams, formConfig: FormBuilderPluginConfig) => Promise<BeforeChangeParams["data"]>;
|
|
5
|
+
export {};
|
|
3
6
|
//# sourceMappingURL=sendEmail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendEmail.d.ts","sourceRoot":"","sources":["../../../../src/collections/FormSubmissions/hooks/sendEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sendEmail.d.ts","sourceRoot":"","sources":["../../../../src/collections/FormSubmissions/hooks/sendEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAEzD,OAAO,KAAK,EAAyB,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAMvF,KAAK,kBAAkB,GAAG,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAA;AAEnE,eAAO,MAAM,SAAS,2BACI,kBAAkB,cAC9B,uBAAuB,KAClC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CA6FpC,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { serializeLexical } from '../../../utilities/lexical/serializeLexical.js';
|
|
2
2
|
import { replaceDoubleCurlys } from '../../../utilities/replaceDoubleCurlys.js';
|
|
3
3
|
import { serializeSlate } from '../../../utilities/slate/serializeSlate.js';
|
|
4
|
-
export const sendEmail = async (
|
|
5
|
-
const { data, operation, req } =
|
|
4
|
+
export const sendEmail = async (beforeChangeParameters, formConfig)=>{
|
|
5
|
+
const { data, operation, req } = beforeChangeParameters;
|
|
6
6
|
if (operation === 'create') {
|
|
7
|
-
const { data: { id: formSubmissionID }, req: { locale, payload } } =
|
|
7
|
+
const { data: { id: formSubmissionID }, req: { locale, payload } } = beforeChangeParameters;
|
|
8
8
|
const { form: formID, submissionData } = data || {};
|
|
9
|
-
const { beforeEmail, formOverrides } = formConfig || {};
|
|
9
|
+
const { beforeEmail, defaultToEmail, formOverrides } = formConfig || {};
|
|
10
10
|
try {
|
|
11
11
|
const form = await payload.findByID({
|
|
12
12
|
id: formID,
|
|
@@ -14,10 +14,11 @@ export const sendEmail = async (beforeChangeData, formConfig)=>{
|
|
|
14
14
|
locale,
|
|
15
15
|
req
|
|
16
16
|
});
|
|
17
|
-
const
|
|
17
|
+
const emails = form.emails;
|
|
18
18
|
if (emails && emails.length) {
|
|
19
19
|
const formattedEmails = await Promise.all(emails.map(async (email)=>{
|
|
20
|
-
const { bcc: emailBCC, cc: emailCC, emailFrom, emailTo, message, replyTo: emailReplyTo, subject } = email;
|
|
20
|
+
const { bcc: emailBCC, cc: emailCC, emailFrom, emailTo: emailToFromConfig, message, replyTo: emailReplyTo, subject } = email;
|
|
21
|
+
const emailTo = emailToFromConfig || defaultToEmail || payload.email.defaultFromAddress;
|
|
21
22
|
const to = replaceDoubleCurlys(emailTo, submissionData);
|
|
22
23
|
const cc = emailCC ? replaceDoubleCurlys(emailCC, submissionData) : '';
|
|
23
24
|
const bcc = emailBCC ? replaceDoubleCurlys(emailBCC, submissionData) : '';
|
|
@@ -37,9 +38,8 @@ export const sendEmail = async (beforeChangeData, formConfig)=>{
|
|
|
37
38
|
}));
|
|
38
39
|
let emailsToSend = formattedEmails;
|
|
39
40
|
if (typeof beforeEmail === 'function') {
|
|
40
|
-
emailsToSend = await beforeEmail(formattedEmails);
|
|
41
|
+
emailsToSend = await beforeEmail(formattedEmails, beforeChangeParameters);
|
|
41
42
|
}
|
|
42
|
-
// const log = emailsToSend.map(({ html, ...rest }) => ({ ...rest }))
|
|
43
43
|
await Promise.all(emailsToSend.map(async (email)=>{
|
|
44
44
|
const { to } = email;
|
|
45
45
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/sendEmail.ts"],"sourcesContent":["import type { Email,
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/sendEmail.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook } from 'payload'\n\nimport type { Email, FormattedEmail, FormBuilderPluginConfig } from '../../../types.js'\n\nimport { serializeLexical } from '../../../utilities/lexical/serializeLexical.js'\nimport { replaceDoubleCurlys } from '../../../utilities/replaceDoubleCurlys.js'\nimport { serializeSlate } from '../../../utilities/slate/serializeSlate.js'\n\ntype BeforeChangeParams = Parameters<CollectionBeforeChangeHook>[0]\n\nexport const sendEmail = async (\n beforeChangeParameters: BeforeChangeParams,\n formConfig: FormBuilderPluginConfig,\n): Promise<BeforeChangeParams['data']> => {\n const { data, operation, req } = beforeChangeParameters\n\n if (operation === 'create') {\n const {\n data: { id: formSubmissionID },\n req: { locale, payload },\n } = beforeChangeParameters\n\n const { form: formID, submissionData } = data || {}\n\n const { beforeEmail, defaultToEmail, formOverrides } = formConfig || {}\n\n try {\n const form = await payload.findByID({\n id: formID,\n collection: formOverrides?.slug || 'forms',\n locale,\n req,\n })\n\n const emails = form.emails as Email[]\n\n if (emails && emails.length) {\n const formattedEmails: FormattedEmail[] = await Promise.all(\n emails.map(async (email: Email): Promise<FormattedEmail | null> => {\n const {\n bcc: emailBCC,\n cc: emailCC,\n emailFrom,\n emailTo: emailToFromConfig,\n message,\n replyTo: emailReplyTo,\n subject,\n } = email\n\n const emailTo = emailToFromConfig || defaultToEmail || payload.email.defaultFromAddress\n\n const to = replaceDoubleCurlys(emailTo, submissionData)\n const cc = emailCC ? replaceDoubleCurlys(emailCC, submissionData) : ''\n const bcc = emailBCC ? replaceDoubleCurlys(emailBCC, submissionData) : ''\n const from = replaceDoubleCurlys(emailFrom, submissionData)\n const replyTo = replaceDoubleCurlys(emailReplyTo || emailFrom, submissionData)\n\n const isLexical = message && !Array.isArray(message) && 'root' in message\n\n const serializedMessage = isLexical\n ? await serializeLexical(message, submissionData)\n : serializeSlate(message, submissionData)\n\n return {\n bcc,\n cc,\n from,\n html: `<div>${serializedMessage}</div>`,\n replyTo,\n subject: replaceDoubleCurlys(subject, submissionData),\n to,\n }\n }),\n )\n\n let emailsToSend = formattedEmails\n\n if (typeof beforeEmail === 'function') {\n emailsToSend = await beforeEmail(formattedEmails, beforeChangeParameters)\n }\n\n await Promise.all(\n emailsToSend.map(async (email) => {\n const { to } = email\n try {\n const emailPromise = await payload.sendEmail(email)\n return emailPromise\n } catch (err: unknown) {\n payload.logger.error({\n err: `Error while sending email to address: ${to}. Email not sent: ${JSON.stringify(\n err,\n )}`,\n })\n }\n }),\n )\n } else {\n payload.logger.info({ msg: 'No emails to send.' })\n }\n } catch (err: unknown) {\n const msg = `Error while sending one or more emails in form submission id: ${formSubmissionID}.`\n payload.logger.error({ err: msg })\n }\n }\n\n return data\n}\n"],"names":["serializeLexical","replaceDoubleCurlys","serializeSlate","sendEmail","beforeChangeParameters","formConfig","data","operation","req","id","formSubmissionID","locale","payload","form","formID","submissionData","beforeEmail","defaultToEmail","formOverrides","findByID","collection","slug","emails","length","formattedEmails","Promise","all","map","email","bcc","emailBCC","cc","emailCC","emailFrom","emailTo","emailToFromConfig","message","replyTo","emailReplyTo","subject","defaultFromAddress","to","from","isLexical","Array","isArray","serializedMessage","html","emailsToSend","emailPromise","err","logger","error","JSON","stringify","info","msg"],"mappings":"AAIA,SAASA,g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AWlB;oBAE/D,MAAM4B,YAAYP,WAAW,CAACQ,MAAMC,OAAO,CAACT,YAAY,UAAUA;oBAElE,MAAMU,oBAAoBH,YACtB,MAAM3C,iBAAiBoC,SAASrB,kBAChCb,eAAekC,SAASrB;oBAE5B,OAAO;wBACLc;wBACAE;wBACAW;wBACAK,MAAM,CAAC,KAAK,EAAED,kBAAkB,MAAM,CAAC;wBACvCT;wBACAE,SAAStC,oBAAoBsC,SAASxB;wBACtC0B;oBACF;gBACF;gBAGF,IAAIO,eAAexB;gBAEnB,IAAI,OAAOR,gBAAgB,YAAY;oBACrCgC,eAAe,MAAMhC,YAAYQ,iBAAiBpB;gBACpD;gBAEA,MAAMqB,QAAQC,GAAG,CACfsB,aAAarB,GAAG,CAAC,OAAOC;oBACtB,MAAM,EAAEa,EAAE,EAAE,GAAGb;oBACf,IAAI;wBACF,MAAMqB,eAAe,MAAMrC,QAAQT,SAAS,CAACyB;wBAC7C,OAAOqB;oBACT,EAAE,OAAOC,KAAc;wBACrBtC,QAAQuC,MAAM,CAACC,KAAK,CAAC;4BACnBF,KAAK,CAAC,sCAAsC,EAAET,GAAG,kBAAkB,EAAEY,KAAKC,SAAS,CACjFJ,KACA,CAAC;wBACL;oBACF;gBACF;YAEJ,OAAO;gBACLtC,QAAQuC,MAAM,CAACI,IAAI,CAAC;oBAAEC,KAAK;gBAAqB;YAClD;QACF,EAAE,OAAON,KAAc;YACrB,MAAMM,MAAM,CAAC,8DAA8D,EAAE9C,iBAAiB,CAAC,CAAC;YAChGE,QAAQuC,MAAM,CAACC,KAAK,CAAC;gBAAEF,KAAKM;YAAI;QAClC;IACF;IAEA,OAAOlD;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/FormSubmissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAM7D,eAAO,MAAM,4BAA4B,eAC3B,uBAAuB,KAClC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/FormSubmissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAM7D,eAAO,MAAM,4BAA4B,eAC3B,uBAAuB,KAClC,gBA+JF,CAAA"}
|
|
@@ -13,7 +13,9 @@ export const generateSubmissionCollection = (formConfig)=>{
|
|
|
13
13
|
relationTo: formSlug,
|
|
14
14
|
required: true,
|
|
15
15
|
validate: async (value, { req: { payload }, req })=>{
|
|
16
|
-
/* Don't run in the client side */ if (!payload)
|
|
16
|
+
/* Don't run in the client side */ if (!payload) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
17
19
|
if (payload) {
|
|
18
20
|
let _existingForm;
|
|
19
21
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { createCharge } from './hooks/createCharge.js'\nimport { sendEmail } from './hooks/sendEmail.js'\n\n// all settings can be overridden by the config\nexport const generateSubmissionCollection = (\n formConfig: FormBuilderPluginConfig,\n): CollectionConfig => {\n const formSlug = formConfig?.formOverrides?.slug || 'forms'\n\n const defaultFields: Field[] = [\n {\n name: 'form',\n type: 'relationship',\n admin: {\n readOnly: true,\n },\n relationTo: formSlug,\n required: true,\n validate: async (value, { req: { payload }, req }) => {\n /* Don't run in the client side */\n if (!payload) return true\n\n if (payload) {\n let _existingForm\n\n try {\n _existingForm = await payload.findByID({\n id: value,\n collection: formSlug,\n req,\n })\n\n return true\n } catch (error) {\n return 'Cannot create this submission because this form does not exist.'\n }\n }\n },\n },\n {\n name: 'submissionData',\n type: 'array',\n admin: {\n readOnly: true,\n },\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n required: true,\n validate: (value: unknown) => {\n // TODO:\n // create a validation function that dynamically\n // relies on the field type and its options as configured.\n\n // How to access sibling data from this field?\n // Need the `name` of the field in order to validate it.\n\n // Might not be possible to use this validation function.\n // Instead, might need to do all validation in a `beforeValidate` collection hook.\n\n if (typeof value !== 'undefined') {\n return true\n }\n\n return 'This field is required.'\n },\n },\n ],\n },\n ]\n\n const newConfig: CollectionConfig = {\n ...(formConfig?.formSubmissionOverrides || {}),\n slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',\n access: {\n create: () => true,\n read: ({ req: { user } }) => !!user, // logged-in users,\n update: () => false,\n ...(formConfig?.formSubmissionOverrides?.access || {}),\n },\n admin: {\n ...(formConfig?.formSubmissionOverrides?.admin || {}),\n enableRichTextRelationship: false,\n },\n fields:\n formConfig?.formSubmissionOverrides?.fields &&\n typeof formConfig?.formSubmissionOverrides?.fields === 'function'\n ? formConfig.formSubmissionOverrides.fields({ defaultFields })\n : defaultFields,\n hooks: {\n ...(formConfig?.formSubmissionOverrides?.hooks || {}),\n beforeChange: [\n (data) => createCharge(data, formConfig),\n (data) => sendEmail(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []),\n ],\n },\n }\n\n const paymentFieldConfig = formConfig?.fields?.payment\n\n if (paymentFieldConfig) {\n newConfig.fields.push({\n name: 'payment',\n type: 'group',\n admin: {\n readOnly: true,\n },\n fields: [\n {\n name: 'field',\n type: 'text',\n label: 'Field',\n },\n {\n name: 'status',\n type: 'text',\n label: 'Status',\n },\n {\n name: 'amount',\n type: 'number',\n admin: {\n description: 'Amount in cents',\n },\n },\n {\n name: 'paymentProcessor',\n type: 'text',\n },\n {\n name: 'creditCard',\n type: 'group',\n fields: [\n {\n name: 'token',\n type: 'text',\n label: 'token',\n },\n {\n name: 'brand',\n type: 'text',\n label: 'Brand',\n },\n {\n name: 'number',\n type: 'text',\n label: 'Number',\n },\n ],\n label: 'Credit Card',\n },\n ],\n })\n }\n\n return newConfig\n}\n"],"names":["createCharge","sendEmail","generateSubmissionCollection","formConfig","formSlug","formOverrides","slug","defaultFields","name","type","admin","readOnly","relationTo","required","validate","value","req","payload","_existingForm","findByID","id","collection","error","fields","newConfig","formSubmissionOverrides","access","create","read","user","update","enableRichTextRelationship","hooks","beforeChange","data","paymentFieldConfig","payment","push","label","description"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { createCharge } from './hooks/createCharge.js'\nimport { sendEmail } from './hooks/sendEmail.js'\n\n// all settings can be overridden by the config\nexport const generateSubmissionCollection = (\n formConfig: FormBuilderPluginConfig,\n): CollectionConfig => {\n const formSlug = formConfig?.formOverrides?.slug || 'forms'\n\n const defaultFields: Field[] = [\n {\n name: 'form',\n type: 'relationship',\n admin: {\n readOnly: true,\n },\n relationTo: formSlug,\n required: true,\n validate: async (value, { req: { payload }, req }) => {\n /* Don't run in the client side */\n if (!payload) {\n return true\n }\n\n if (payload) {\n let _existingForm\n\n try {\n _existingForm = await payload.findByID({\n id: value,\n collection: formSlug,\n req,\n })\n\n return true\n } catch (error) {\n return 'Cannot create this submission because this form does not exist.'\n }\n }\n },\n },\n {\n name: 'submissionData',\n type: 'array',\n admin: {\n readOnly: true,\n },\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n required: true,\n validate: (value: unknown) => {\n // TODO:\n // create a validation function that dynamically\n // relies on the field type and its options as configured.\n\n // How to access sibling data from this field?\n // Need the `name` of the field in order to validate it.\n\n // Might not be possible to use this validation function.\n // Instead, might need to do all validation in a `beforeValidate` collection hook.\n\n if (typeof value !== 'undefined') {\n return true\n }\n\n return 'This field is required.'\n },\n },\n ],\n },\n ]\n\n const newConfig: CollectionConfig = {\n ...(formConfig?.formSubmissionOverrides || {}),\n slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',\n access: {\n create: () => true,\n read: ({ req: { user } }) => !!user, // logged-in users,\n update: () => false,\n ...(formConfig?.formSubmissionOverrides?.access || {}),\n },\n admin: {\n ...(formConfig?.formSubmissionOverrides?.admin || {}),\n enableRichTextRelationship: false,\n },\n fields:\n formConfig?.formSubmissionOverrides?.fields &&\n typeof formConfig?.formSubmissionOverrides?.fields === 'function'\n ? formConfig.formSubmissionOverrides.fields({ defaultFields })\n : defaultFields,\n hooks: {\n ...(formConfig?.formSubmissionOverrides?.hooks || {}),\n beforeChange: [\n (data) => createCharge(data, formConfig),\n (data) => sendEmail(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []),\n ],\n },\n }\n\n const paymentFieldConfig = formConfig?.fields?.payment\n\n if (paymentFieldConfig) {\n newConfig.fields.push({\n name: 'payment',\n type: 'group',\n admin: {\n readOnly: true,\n },\n fields: [\n {\n name: 'field',\n type: 'text',\n label: 'Field',\n },\n {\n name: 'status',\n type: 'text',\n label: 'Status',\n },\n {\n name: 'amount',\n type: 'number',\n admin: {\n description: 'Amount in cents',\n },\n },\n {\n name: 'paymentProcessor',\n type: 'text',\n },\n {\n name: 'creditCard',\n type: 'group',\n fields: [\n {\n name: 'token',\n type: 'text',\n label: 'token',\n },\n {\n name: 'brand',\n type: 'text',\n label: 'Brand',\n },\n {\n name: 'number',\n type: 'text',\n label: 'Number',\n },\n ],\n label: 'Credit Card',\n },\n ],\n })\n }\n\n return newConfig\n}\n"],"names":["createCharge","sendEmail","generateSubmissionCollection","formConfig","formSlug","formOverrides","slug","defaultFields","name","type","admin","readOnly","relationTo","required","validate","value","req","payload","_existingForm","findByID","id","collection","error","fields","newConfig","formSubmissionOverrides","access","create","read","user","update","enableRichTextRelationship","hooks","beforeChange","data","paymentFieldConfig","payment","push","label","description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
+
import type { SelectFieldClientProps, SelectFieldValidation } from 'payload';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare const DynamicFieldSelector: React.FC<
|
|
3
|
+
export declare const DynamicFieldSelector: React.FC<{
|
|
4
|
+
validate: SelectFieldValidation;
|
|
5
|
+
} & SelectFieldClientProps>;
|
|
4
6
|
//# sourceMappingURL=DynamicFieldSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicFieldSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"DynamicFieldSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAG5E,OAAO,KAA8B,MAAM,OAAO,CAAA;AAIlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC;IAAE,QAAQ,EAAE,qBAAqB,CAAA;CAAE,GAAG,sBAAsB,CAsC7D,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { useForm } from '@payloadcms/ui/forms/Form';
|
|
3
|
+
import { SelectField, useForm } from '@payloadcms/ui';
|
|
5
4
|
import React, { useEffect, useState } from 'react';
|
|
6
5
|
export const DynamicFieldSelector = (props)=>{
|
|
7
6
|
const { fields, getDataByPath } = useForm();
|
|
@@ -25,11 +24,13 @@ export const DynamicFieldSelector = (props)=>{
|
|
|
25
24
|
fields,
|
|
26
25
|
getDataByPath
|
|
27
26
|
]);
|
|
28
|
-
|
|
29
|
-
// but the FormFieldBase type has only label?: string, changing FormFieldBase breaks other ui components
|
|
30
|
-
return /*#__PURE__*/ _jsx(Select, {
|
|
27
|
+
return /*#__PURE__*/ _jsx(SelectField, {
|
|
31
28
|
...props,
|
|
32
|
-
|
|
29
|
+
field: {
|
|
30
|
+
name: props?.field?.name,
|
|
31
|
+
options,
|
|
32
|
+
...props.field || {}
|
|
33
|
+
}
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"sourcesContent":["'use client'\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { SelectFieldClientProps, SelectFieldValidation } from 'payload'\n\nimport { SelectField, useForm } from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { SelectFieldOption } from '../../types.js'\n\nexport const DynamicFieldSelector: React.FC<\n { validate: SelectFieldValidation } & SelectFieldClientProps\n> = (props) => {\n const { fields, getDataByPath } = useForm()\n\n const [options, setOptions] = useState<SelectFieldOption[]>([])\n\n useEffect(() => {\n const fields: any[] = getDataByPath('fields')\n\n if (fields) {\n const allNonPaymentFields = fields\n .map((block): null | SelectFieldOption => {\n const { name, blockType, label } = block\n\n if (blockType !== 'payment') {\n return {\n label,\n value: name,\n }\n }\n\n return null\n })\n .filter(Boolean)\n setOptions(allNonPaymentFields)\n }\n }, [fields, getDataByPath])\n\n return (\n <SelectField\n {...props}\n field={{\n name: props?.field?.name,\n options,\n ...(props.field || {}),\n }}\n />\n )\n}\n"],"names":["SelectField","useForm","React","useEffect","useState","DynamicFieldSelector","props","fields","getDataByPath","options","setOptions","allNonPaymentFields","map","block","name","blockType","label","value","filter","Boolean","field"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,OAAO,QAAQ,iBAAgB;AACrD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAIlD,OAAO,MAAMC,uBAET,CAACC;IACH,MAAM,EAAEC,MAAM,EAAEC,aAAa,EAAE,GAAGP;IAElC,MAAM,CAACQ,SAASC,WAAW,GAAGN,SAA8B,EAAE;IAE9DD,UAAU;QACR,MAAMI,SAAgBC,cAAc;QAEpC,IAAID,QAAQ;YACV,MAAMI,sBAAsBJ,OACzBK,GAAG,CAAC,CAACC;gBACJ,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGH;gBAEnC,IAAIE,cAAc,WAAW;oBAC3B,OAAO;wBACLC;wBACAC,OAAOH;oBACT;gBACF;gBAEA,OAAO;YACT,GACCI,MAAM,CAACC;YACVT,WAAWC;QACb;IACF,GAAG;QAACJ;QAAQC;KAAc;IAE1B,qBACE,KAACR;QACE,GAAGM,KAAK;QACTc,OAAO;YACLN,MAAMR,OAAOc,OAAON;YACpBL;YACA,GAAIH,MAAMc,KAAK,IAAI,CAAC,CAAC;QACvB;;AAGN,EAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare const DynamicPriceSelector: React.FC<TextFieldProps>;
|
|
1
|
+
import type { TextFieldClientComponent } from 'payload';
|
|
2
|
+
export declare const DynamicPriceSelector: TextFieldClientComponent;
|
|
4
3
|
//# sourceMappingURL=DynamicPriceSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicPriceSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"DynamicPriceSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAQ,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAU7D,eAAO,MAAM,oBAAoB,EAAE,wBA2DlC,CAAA"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { useWatchForm } from '@payloadcms/ui/forms/Form';
|
|
5
|
-
import { useLocale } from '@payloadcms/ui/providers/Locale';
|
|
3
|
+
import { TextField, useLocale, useWatchForm } from '@payloadcms/ui';
|
|
6
4
|
import React, { useEffect, useState } from 'react';
|
|
7
5
|
export const DynamicPriceSelector = (props)=>{
|
|
8
|
-
const {
|
|
6
|
+
const { field } = props;
|
|
9
7
|
const { fields, getData, getDataByPath } = useWatchForm();
|
|
10
8
|
const locale = useLocale();
|
|
11
9
|
const [isNumberField, setIsNumberField] = useState();
|
|
12
10
|
const [valueType, setValueType] = useState();
|
|
13
11
|
// only number fields can use 'valueOfField`
|
|
14
12
|
useEffect(()=>{
|
|
15
|
-
if (
|
|
16
|
-
const parentPath =
|
|
13
|
+
if (field?._path) {
|
|
14
|
+
const parentPath = field._path.split('.').slice(0, -1).join('.');
|
|
17
15
|
const paymentFieldData = getDataByPath(parentPath);
|
|
18
16
|
if (paymentFieldData) {
|
|
19
17
|
const { fieldToUse, valueType } = paymentFieldData;
|
|
@@ -28,19 +26,19 @@ export const DynamicPriceSelector = (props)=>{
|
|
|
28
26
|
}
|
|
29
27
|
}, [
|
|
30
28
|
fields,
|
|
31
|
-
|
|
29
|
+
field._path,
|
|
32
30
|
getDataByPath,
|
|
33
31
|
getData
|
|
34
32
|
]);
|
|
35
33
|
// TODO: make this a number field, block by Payload
|
|
36
34
|
if (valueType === 'static') {
|
|
37
|
-
return /*#__PURE__*/ _jsx(
|
|
35
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
38
36
|
...props
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
39
|
const localeCode = typeof locale === 'object' && 'code' in locale ? locale.code : locale;
|
|
42
|
-
const localLabels = typeof label === 'object' ? label : {
|
|
43
|
-
[localeCode]: label
|
|
40
|
+
const localLabels = typeof field.label === 'object' ? field.label : {
|
|
41
|
+
[localeCode]: field.label
|
|
44
42
|
};
|
|
45
43
|
const labelValue = localLabels[localeCode] || localLabels['en'] || '';
|
|
46
44
|
if (valueType === 'valueOfField' && !isNumberField) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { Data, TextFieldClientComponent } from 'payload'\n\nimport { TextField, useLocale, useWatchForm } from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\ntype FieldWithID = {\n id: string\n name: string\n}\n\nexport const DynamicPriceSelector: TextFieldClientComponent = (props) => {\n const { field } = props\n\n const { fields, getData, getDataByPath } = useWatchForm()\n\n const locale = useLocale()\n\n const [isNumberField, setIsNumberField] = useState<boolean>()\n const [valueType, setValueType] = useState<'static' | 'valueOfField'>()\n\n // only number fields can use 'valueOfField`\n useEffect(() => {\n if (field?._path) {\n const parentPath = field._path.split('.').slice(0, -1).join('.')\n const paymentFieldData: any = getDataByPath(parentPath)\n\n if (paymentFieldData) {\n const { fieldToUse, valueType } = paymentFieldData\n\n setValueType(valueType)\n\n const { fields: allFields }: Data = getData()\n const field = allFields.find((field: FieldWithID) => field.name === fieldToUse)\n\n if (field) {\n const { blockType } = field\n setIsNumberField(blockType === 'number')\n }\n }\n }\n }, [fields, field._path, getDataByPath, getData])\n\n // TODO: make this a number field, block by Payload\n if (valueType === 'static') {\n return <TextField {...props} />\n }\n\n const localeCode = typeof locale === 'object' && 'code' in locale ? locale.code : locale\n\n const localLabels = typeof field.label === 'object' ? field.label : { [localeCode]: field.label }\n\n const labelValue = localLabels[localeCode] || localLabels['en'] || ''\n\n if (valueType === 'valueOfField' && !isNumberField) {\n return (\n <div>\n <div>{String(labelValue)}</div>\n <div\n style={{\n color: '#9A9A9A',\n }}\n >\n The selected field must be a number field.\n </div>\n </div>\n )\n }\n\n return null\n}\n"],"names":["TextField","useLocale","useWatchForm","React","useEffect","useState","DynamicPriceSelector","props","field","fields","getData","getDataByPath","locale","isNumberField","setIsNumberField","valueType","setValueType","_path","parentPath","split","slice","join","paymentFieldData","fieldToUse","allFields","find","name","blockType","localeCode","code","localLabels","label","labelValue","div","String","style","color"],"mappings":"AAAA;;AAIA,SAASA,SAAS,EAAEC,SAAS,EAAEC,YAAY,QAAQ,iBAAgB;AACnE,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAOlD,OAAO,MAAMC,uBAAiD,CAACC;IAC7D,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAElB,MAAM,EAAEE,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGT;IAE3C,MAAMU,SAASX;IAEf,MAAM,CAACY,eAAeC,iBAAiB,GAAGT;IAC1C,MAAM,CAACU,WAAWC,aAAa,GAAGX;IAElC,4CAA4C;IAC5CD,UAAU;QACR,IAAII,OAAOS,OAAO;YAChB,MAAMC,aAAaV,MAAMS,KAAK,CAACE,KAAK,CAAC,KAAKC,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;YAC5D,MAAMC,mBAAwBX,cAAcO;YAE5C,IAAII,kBAAkB;gBACpB,MAAM,EAAEC,UAAU,EAAER,SAAS,EAAE,GAAGO;gBAElCN,aAAaD;gBAEb,MAAM,EAAEN,QAAQe,SAAS,EAAE,GAASd;gBACpC,MAAMF,QAAQgB,UAAUC,IAAI,CAAC,CAACjB,QAAuBA,MAAMkB,IAAI,KAAKH;gBAEpE,IAAIf,OAAO;oBACT,MAAM,EAAEmB,SAAS,EAAE,GAAGnB;oBACtBM,iBAAiBa,cAAc;gBACjC;YACF;QACF;IACF,GAAG;QAAClB;QAAQD,MAAMS,KAAK;QAAEN;QAAeD;KAAQ;IAEhD,mDAAmD;IACnD,IAAIK,cAAc,UAAU;QAC1B,qBAAO,KAACf;YAAW,GAAGO,KAAK;;IAC7B;IAEA,MAAMqB,aAAa,OAAOhB,WAAW,YAAY,UAAUA,SAASA,OAAOiB,IAAI,GAAGjB;IAElF,MAAMkB,cAAc,OAAOtB,MAAMuB,KAAK,KAAK,WAAWvB,MAAMuB,KAAK,GAAG;QAAE,CAACH,WAAW,EAAEpB,MAAMuB,KAAK;IAAC;IAEhG,MAAMC,aAAaF,WAAW,CAACF,WAAW,IAAIE,WAAW,CAAC,KAAK,IAAI;IAEnE,IAAIf,cAAc,kBAAkB,CAACF,eAAe;QAClD,qBACE,MAACoB;;8BACC,KAACA;8BAAKC,OAAOF;;8BACb,KAACC;oBACCE,OAAO;wBACLC,OAAO;oBACT;8BACD;;;;IAKP;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Block } from 'payload';
|
|
2
2
|
import type { FieldConfig } from '../../types.js';
|
|
3
3
|
export declare const fields: {
|
|
4
|
-
[key: string]:
|
|
4
|
+
[key: string]: ((fieldConfig?: boolean | FieldConfig) => Block) | Block;
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,SAAS,CAAA;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,SAAS,CAAA;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,gBAAgB,CAAA;AAyjBrE,eAAO,MAAM,MAAM,EAWd;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,WAAW,KAAK,KAAK,CAAC,GAAG,KAAK,CAAA;CACxE,CAAA"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { DynamicFieldSelector } from './DynamicFieldSelector.js';
|
|
2
|
-
import { DynamicPriceSelector } from './DynamicPriceSelector.js';
|
|
3
1
|
const name = {
|
|
4
2
|
name: 'name',
|
|
5
3
|
type: 'text',
|
|
@@ -436,7 +434,7 @@ const Payment = (fieldConfig)=>{
|
|
|
436
434
|
type: 'text',
|
|
437
435
|
admin: {
|
|
438
436
|
components: {
|
|
439
|
-
Field: DynamicFieldSelector
|
|
437
|
+
Field: '@payloadcms/plugin-form-builder/client#DynamicFieldSelector'
|
|
440
438
|
}
|
|
441
439
|
}
|
|
442
440
|
},
|
|
@@ -515,7 +513,7 @@ const Payment = (fieldConfig)=>{
|
|
|
515
513
|
type: 'text',
|
|
516
514
|
admin: {
|
|
517
515
|
components: {
|
|
518
|
-
Field: DynamicPriceSelector
|
|
516
|
+
Field: '@payloadcms/plugin-form-builder/client#DynamicPriceSelector'
|
|
519
517
|
}
|
|
520
518
|
},
|
|
521
519
|
label: 'Value'
|
|
@@ -550,7 +548,6 @@ const Message = {
|
|
|
550
548
|
singular: 'Message'
|
|
551
549
|
}
|
|
552
550
|
};
|
|
553
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
554
551
|
export const fields = {
|
|
555
552
|
checkbox: Checkbox,
|
|
556
553
|
country: Country,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/fields.ts"],"sourcesContent":["import type { Block, Field } from 'payload'\n\nimport type { FieldConfig, PaymentFieldConfig } from '../../types.js'\n\nimport { DynamicFieldSelector } from './DynamicFieldSelector.js'\nimport { DynamicPriceSelector } from './DynamicPriceSelector.js'\n\nconst name: Field = {\n name: 'name',\n type: 'text',\n label: 'Name (lowercase, no special characters)',\n required: true,\n}\n\nconst label: Field = {\n name: 'label',\n type: 'text',\n label: 'Label',\n localized: true,\n}\n\nconst required: Field = {\n name: 'required',\n type: 'checkbox',\n label: 'Required',\n}\n\nconst width: Field = {\n name: 'width',\n type: 'number',\n label: 'Field Width (percentage)',\n}\n\nconst Select: Block = {\n slug: 'select',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Select Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Select Fields',\n singular: 'Select',\n },\n}\n\nconst Text: Block = {\n slug: 'text',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Fields',\n singular: 'Text',\n },\n}\n\nconst TextArea: Block = {\n slug: 'textarea',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Area Fields',\n singular: 'Text Area',\n },\n}\n\nconst Number: Block = {\n slug: 'number',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Number Fields',\n singular: 'Number',\n },\n}\n\nconst Email: Block = {\n slug: 'email',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Email Fields',\n singular: 'Email',\n },\n}\n\nconst State: Block = {\n slug: 'state',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'State Fields',\n singular: 'State',\n },\n}\n\nconst Country: Block = {\n slug: 'country',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Country Fields',\n singular: 'Country',\n },\n}\n\nconst Checkbox: Block = {\n slug: 'checkbox',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'checkbox',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Checkbox Fields',\n singular: 'Checkbox',\n },\n}\n\nconst Payment = (fieldConfig: PaymentFieldConfig): Block => {\n let paymentProcessorField = null\n if (fieldConfig?.paymentProcessor) {\n paymentProcessorField = {\n name: 'paymentProcessor',\n type: 'select',\n label: 'Payment Processor',\n options: [],\n ...fieldConfig.paymentProcessor,\n }\n }\n\n const fields = {\n slug: 'payment',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'basePrice',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Base Price',\n },\n ],\n },\n paymentProcessorField,\n {\n name: 'priceConditions',\n type: 'array',\n fields: [\n {\n name: 'fieldToUse',\n type: 'text',\n admin: {\n components: {\n Field: DynamicFieldSelector,\n },\n },\n },\n {\n name: 'condition',\n type: 'select',\n defaultValue: 'hasValue',\n label: 'Condition',\n options: [\n {\n label: 'Has Any Value',\n value: 'hasValue',\n },\n {\n label: 'Equals',\n value: 'equals',\n },\n {\n label: 'Does Not Equal',\n value: 'notEquals',\n },\n ],\n },\n {\n name: 'valueForCondition',\n type: 'text',\n admin: {\n condition: (_: any, { condition }: any) =>\n condition === 'equals' || condition === 'notEquals',\n },\n label: 'Value',\n },\n {\n name: 'operator',\n type: 'select',\n defaultValue: 'add',\n options: [\n {\n label: 'Add',\n value: 'add',\n },\n {\n label: 'Subtract',\n value: 'subtract',\n },\n {\n label: 'Multiply',\n value: 'multiply',\n },\n {\n label: 'Divide',\n value: 'divide',\n },\n ],\n },\n {\n name: 'valueType',\n type: 'radio',\n admin: {\n width: '100%',\n },\n defaultValue: 'static',\n label: 'Value Type',\n options: [\n {\n label: 'Static Value',\n value: 'static',\n },\n {\n label: 'Value Of Field',\n value: 'valueOfField',\n },\n ],\n },\n {\n name: 'valueForOperator',\n type: 'text',\n admin: {\n components: {\n Field: DynamicPriceSelector,\n },\n },\n label: 'Value',\n },\n ],\n label: 'Price Conditions',\n labels: {\n plural: 'Price Conditions',\n singular: 'Price Condition',\n },\n },\n required,\n ].filter(Boolean) as Field[],\n labels: {\n plural: 'Payment Fields',\n singular: 'Payment',\n },\n }\n\n return fields\n}\n\nconst Message: Block = {\n slug: 'message',\n fields: [\n {\n name: 'message',\n type: 'richText',\n localized: true,\n },\n ],\n labels: {\n plural: 'Message Blocks',\n singular: 'Message',\n },\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\nexport const fields = {\n checkbox: Checkbox,\n country: Country,\n email: Email,\n message: Message,\n number: Number,\n payment: Payment,\n select: Select,\n state: State,\n text: Text,\n textarea: TextArea,\n} as {\n [key: string]: ((fieldConfig?: FieldConfig | boolean) => Block) | Block\n}\n"],"names":["DynamicFieldSelector","DynamicPriceSelector","name","type","label","required","localized","width","Select","slug","fields","admin","labels","plural","singular","Text","TextArea","Number","Email","State","Country","Checkbox","Payment","fieldConfig","paymentProcessorField","paymentProcessor","options","components","Field","defaultValue","value","condition","_","filter","Boolean","Message","checkbox","country","email","message","number","payment","select","state","text","textarea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAEA,yEAAyE;AACzE,OAAO,MAAMJ,SAAS;IACpB0B,UAAUf;IACVgB,SAASjB;IACTkB,OAAOpB;IACPqB,SAASJ;IACTK,QAAQvB;IACRwB,SAASnB;IACToB,QAAQlC;IACRmC,OAAOxB;IACPyB,MAAM7B;IACN8B,UAAU7B;AACZ,EAEC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/fields.ts"],"sourcesContent":["import type { Block, Field } from 'payload'\n\nimport type { FieldConfig, PaymentFieldConfig } from '../../types.js'\n\nconst name: Field = {\n name: 'name',\n type: 'text',\n label: 'Name (lowercase, no special characters)',\n required: true,\n}\n\nconst label: Field = {\n name: 'label',\n type: 'text',\n label: 'Label',\n localized: true,\n}\n\nconst required: Field = {\n name: 'required',\n type: 'checkbox',\n label: 'Required',\n}\n\nconst width: Field = {\n name: 'width',\n type: 'number',\n label: 'Field Width (percentage)',\n}\n\nconst Select: Block = {\n slug: 'select',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Select Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Select Fields',\n singular: 'Select',\n },\n}\n\nconst Text: Block = {\n slug: 'text',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Fields',\n singular: 'Text',\n },\n}\n\nconst TextArea: Block = {\n slug: 'textarea',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Area Fields',\n singular: 'Text Area',\n },\n}\n\nconst Number: Block = {\n slug: 'number',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Number Fields',\n singular: 'Number',\n },\n}\n\nconst Email: Block = {\n slug: 'email',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Email Fields',\n singular: 'Email',\n },\n}\n\nconst State: Block = {\n slug: 'state',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'State Fields',\n singular: 'State',\n },\n}\n\nconst Country: Block = {\n slug: 'country',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Country Fields',\n singular: 'Country',\n },\n}\n\nconst Checkbox: Block = {\n slug: 'checkbox',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'checkbox',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Checkbox Fields',\n singular: 'Checkbox',\n },\n}\n\nconst Payment = (fieldConfig: PaymentFieldConfig): Block => {\n let paymentProcessorField = null\n if (fieldConfig?.paymentProcessor) {\n paymentProcessorField = {\n name: 'paymentProcessor',\n type: 'select',\n label: 'Payment Processor',\n options: [],\n ...fieldConfig.paymentProcessor,\n }\n }\n\n const fields = {\n slug: 'payment',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'basePrice',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Base Price',\n },\n ],\n },\n paymentProcessorField,\n {\n name: 'priceConditions',\n type: 'array',\n fields: [\n {\n name: 'fieldToUse',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-form-builder/client#DynamicFieldSelector',\n },\n },\n },\n {\n name: 'condition',\n type: 'select',\n defaultValue: 'hasValue',\n label: 'Condition',\n options: [\n {\n label: 'Has Any Value',\n value: 'hasValue',\n },\n {\n label: 'Equals',\n value: 'equals',\n },\n {\n label: 'Does Not Equal',\n value: 'notEquals',\n },\n ],\n },\n {\n name: 'valueForCondition',\n type: 'text',\n admin: {\n condition: (_: any, { condition }: any) =>\n condition === 'equals' || condition === 'notEquals',\n },\n label: 'Value',\n },\n {\n name: 'operator',\n type: 'select',\n defaultValue: 'add',\n options: [\n {\n label: 'Add',\n value: 'add',\n },\n {\n label: 'Subtract',\n value: 'subtract',\n },\n {\n label: 'Multiply',\n value: 'multiply',\n },\n {\n label: 'Divide',\n value: 'divide',\n },\n ],\n },\n {\n name: 'valueType',\n type: 'radio',\n admin: {\n width: '100%',\n },\n defaultValue: 'static',\n label: 'Value Type',\n options: [\n {\n label: 'Static Value',\n value: 'static',\n },\n {\n label: 'Value Of Field',\n value: 'valueOfField',\n },\n ],\n },\n {\n name: 'valueForOperator',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-form-builder/client#DynamicPriceSelector',\n },\n },\n label: 'Value',\n },\n ],\n label: 'Price Conditions',\n labels: {\n plural: 'Price Conditions',\n singular: 'Price Condition',\n },\n },\n required,\n ].filter(Boolean) as Field[],\n labels: {\n plural: 'Payment Fields',\n singular: 'Payment',\n },\n }\n\n return fields\n}\n\nconst Message: Block = {\n slug: 'message',\n fields: [\n {\n name: 'message',\n type: 'richText',\n localized: true,\n },\n ],\n labels: {\n plural: 'Message Blocks',\n singular: 'Message',\n },\n}\n\nexport const fields = {\n checkbox: Checkbox,\n country: Country,\n email: Email,\n message: Message,\n number: Number,\n payment: Payment,\n select: Select,\n state: State,\n text: Text,\n textarea: TextArea,\n} as {\n [key: string]: ((fieldConfig?: boolean | FieldConfig) => Block) | Block\n}\n"],"names":["name","type","label","required","localized","width","Select","slug","fields","admin","labels","plural","singular","Text","TextArea","Number","Email","State","Country","Checkbox","Payment","fieldConfig","paymentProcessorField","paymentProcessor","options","components","Field","defaultValue","value","condition","_","filter","Boolean","Message","checkbox","country","email","message","number","payment","select","state","text","textarea"],"mappings":"AAIA,MAAMA,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,EAAO,GACpCA,cAAc,YAAYA,cAAc;wBAC5C;wBACA3B,OAAO;oBACT;oBACA;wBACEF,MAAM;wBACNC,MAAM;wBACN0B,cAAc;wBACdH,SAAS;4BACP;gCACEtB,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;yBACD;oBACH;oBACA;wBACE5B,MAAM;wBACNC,MAAM;wBACNQ,OAAO;4BACLJ,OAAO;wBACT;wBACAsB,cAAc;wBACdzB,OAAO;wBACPsB,SAAS;4BACP;gCACEtB,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;yBACD;oBACH;oBACA;wBACE5B,MAAM;wBACNC,MAAM;wBACNQ,OAAO;4BACLgB,YAAY;gCACVC,OAAO;4BACT;wBACF;wBACAxB,OAAO;oBACT;iBACD;gBACDA,OAAO;gBACPQ,QAAQ;oBACNC,QAAQ;oBACRC,UAAU;gBACZ;YACF;YACAT;SACD,CAAC4B,MAAM,CAACC;QACTtB,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF;IAEA,OAAOJ;AACT;AAEA,MAAMyB,UAAiB;IACrB1B,MAAM;IACNC,QAAQ;QACN;YACER,MAAM;YACNC,MAAM;YACNG,WAAW;QACb;KACD;IACDM,QAAQ;QACNC,QAAQ;QACRC,UAAU;IACZ;AACF;AAEA,OAAO,MAAMJ,SAAS;IACpB0B,UAAUf;IACVgB,SAASjB;IACTkB,OAAOpB;IACPqB,SAASJ;IACTK,QAAQvB;IACRwB,SAASnB;IACToB,QAAQlC;IACRmC,OAAOxB;IACPyB,MAAM7B;IACN8B,UAAU7B;AACZ,EAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAK7D,eAAO,MAAM,sBAAsB,eAAgB,uBAAuB,KAAG,gBA4O5E,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { deepMergeWithSourceArrays } from 'payload';
|
|
2
2
|
import { fields } from './fields.js';
|
|
3
3
|
// all settings can be overridden by the config
|
|
4
4
|
export const generateFormCollection = (formConfig)=>{
|
|
@@ -48,7 +48,9 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
48
48
|
}
|
|
49
49
|
]
|
|
50
50
|
});
|
|
51
|
-
if (redirect.fields[2].type !== 'row')
|
|
51
|
+
if (redirect.fields[2].type !== 'row') {
|
|
52
|
+
redirect.fields[2].label = 'Custom URL';
|
|
53
|
+
}
|
|
52
54
|
redirect.fields[2].admin = {
|
|
53
55
|
condition: (_, siblingData)=>siblingData?.type === 'custom'
|
|
54
56
|
};
|
|
@@ -70,9 +72,7 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
70
72
|
return fieldConfig;
|
|
71
73
|
}
|
|
72
74
|
if (typeof block === 'object' && typeof fieldConfig === 'object') {
|
|
73
|
-
return
|
|
74
|
-
arrayMerge: (_, sourceArray)=>sourceArray
|
|
75
|
-
});
|
|
75
|
+
return deepMergeWithSourceArrays(block, fieldConfig);
|
|
76
76
|
}
|
|
77
77
|
if (typeof block === 'function') {
|
|
78
78
|
return block(fieldConfig);
|
|
@@ -119,8 +119,11 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
119
119
|
{
|
|
120
120
|
name: 'emails',
|
|
121
121
|
type: 'array',
|
|
122
|
+
access: {
|
|
123
|
+
read: ({ req: { user } })=>!!user
|
|
124
|
+
},
|
|
122
125
|
admin: {
|
|
123
|
-
description: "Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}."
|
|
126
|
+
description: "Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}. You can use a wildcard {{*}} to output all data and {{*:table}} to format it as an HTML table in the email."
|
|
124
127
|
},
|
|
125
128
|
fields: [
|
|
126
129
|
{
|
|
@@ -139,7 +142,9 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
139
142
|
name: 'cc',
|
|
140
143
|
type: 'text',
|
|
141
144
|
admin: {
|
|
142
|
-
|
|
145
|
+
style: {
|
|
146
|
+
maxWidth: '50%'
|
|
147
|
+
}
|
|
143
148
|
},
|
|
144
149
|
label: 'CC'
|
|
145
150
|
},
|
|
@@ -147,7 +152,9 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
147
152
|
name: 'bcc',
|
|
148
153
|
type: 'text',
|
|
149
154
|
admin: {
|
|
150
|
-
|
|
155
|
+
style: {
|
|
156
|
+
maxWidth: '50%'
|
|
157
|
+
}
|
|
151
158
|
},
|
|
152
159
|
label: 'BCC'
|
|
153
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload'\n\nimport merge from 'deepmerge'\n\nimport type { FieldConfig, FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: FormBuilderPluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') redirect.fields[2].label = 'Custom URL'\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'fields',\n type: 'blocks',\n blocks: Object.entries(formConfig?.fields || {})\n .map(([fieldKey, fieldConfig]) => {\n // let the config enable/disable fields with either boolean values or objects\n if (fieldConfig !== false) {\n const block = fields[fieldKey]\n\n if (block === undefined && typeof fieldConfig === 'object') {\n return fieldConfig\n }\n\n if (typeof block === 'object' && typeof fieldConfig === 'object') {\n return merge<FieldConfig>(block, fieldConfig, {\n arrayMerge: (_, sourceArray) => sourceArray,\n })\n }\n\n if (typeof block === 'function') {\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description:\n 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',\n layout: 'horizontal',\n },\n defaultValue: 'message',\n options: [\n {\n label: 'Message',\n value: 'message',\n },\n {\n label: 'Redirect',\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n admin: {\n description:\n \"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}.\",\n },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'emailTo',\n type: 'text',\n admin: {\n placeholder: '\"Email Sender\" <sender@email.com>',\n width: '100%',\n },\n label: 'Email To',\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ]\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields:\n formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function'\n ? formConfig.formOverrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return config\n}\n"],"names":["merge","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","defaultFields","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","arrayMerge","sourceArray","filter","Boolean","localized","description","placeholder","width","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,WAAW,YAAW;AAI7B,SAASC,MAAM,QAAQ,cAAa;AAEpC,+CAA+C;AAC/C,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAMC,WAAkB;QACtBC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACjEC,YAAY;QACd;QACAX,QAAQ;YACN;gBACEI,MAAM;gBACNC,MAAM;gBACNO,OAAO;gBACPC,UAAU;YACZ;SACD;IACH;IAEA,IAAIX,WAAWY,qBAAqB,EAAE;QACpCX,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaJ,SAAS;YACvD;YACAO,OAAO;YACPI,UAAU;YACVC,YAAYf,WAAWY,qBAAqB;YAC5CD,UAAU;QACZ;QAEAV,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLY,QAAQ;YACV;YACAC,cAAc;YACdC,SAAS;gBACP;oBACER,OAAO;oBACPS,OAAO;gBACT;gBACA;oBACET,OAAO;oBACPS,OAAO;gBACT;aACD;QACH;QAEA,IAAIlB,SAASH,MAAM,CAAC,EAAE,CAACK,IAAI,KAAK,OAAOF,SAASH,MAAM,CAAC,EAAE,CAACY,KAAK,GAA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EI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACL+B,aAAa;gCACbC,OAAO;4BACT;4BACA1B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLgC,OAAO;4BACT;4BACA1B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLgC,OAAO;4BACT;4BACA1B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACEP,MAAM;oBACNL,QAAQ;wBACN;4BACEI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACL+B,aAAa;gCACbC,OAAO;4BACT;4BACA1B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACL+B,aAAa;gCACbC,OAAO;4BACT;4BACA1B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACER,MAAM;oBACNC,MAAM;oBACNc,cAAc;oBACdP,OAAO;oBACPuB,WAAW;oBACXtB,UAAU;gBACZ;gBACA;oBACET,MAAM;oBACNC,MAAM;oBACNC,OAAO;wBACL8B,aAAa;oBACf;oBACAxB,OAAO;oBACPuB,WAAW;gBACb;aACD;QACH;KACD;IAED,MAAMI,SAA2B;QAC/B,GAAIrC,YAAYsC,iBAAiB,CAAC,CAAC;QACnCC,MAAMvC,YAAYsC,eAAeC,QAAQ;QACzCC,QAAQ;YACNC,MAAM,IAAM;YACZ,GAAIzC,YAAYsC,eAAeE,UAAU,CAAC,CAAC;QAC7C;QACApC,OAAO;YACLsC,4BAA4B;YAC5BC,YAAY;YACZ,GAAI3C,YAAYsC,eAAelC,SAAS,CAAC,CAAC;QAC5C;QACAN,QACEE,YAAYsC,eAAexC,UAAU,OAAOE,YAAYsC,eAAexC,WAAW,aAC9EE,WAAWsC,aAAa,CAACxC,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOiB;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload'\n\nimport { deepMergeWithSourceArrays } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: FormBuilderPluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') {\n redirect.fields[2].label = 'Custom URL'\n }\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'fields',\n type: 'blocks',\n blocks: Object.entries(formConfig?.fields || {})\n .map(([fieldKey, fieldConfig]) => {\n // let the config enable/disable fields with either boolean values or objects\n if (fieldConfig !== false) {\n const block = fields[fieldKey]\n\n if (block === undefined && typeof fieldConfig === 'object') {\n return fieldConfig\n }\n\n if (typeof block === 'object' && typeof fieldConfig === 'object') {\n return deepMergeWithSourceArrays(block, fieldConfig)\n }\n\n if (typeof block === 'function') {\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description:\n 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',\n layout: 'horizontal',\n },\n defaultValue: 'message',\n options: [\n {\n label: 'Message',\n value: 'message',\n },\n {\n label: 'Redirect',\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n access: {\n read: ({ req: { user } }) => !!user,\n },\n admin: {\n description:\n \"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}. You can use a wildcard {{*}} to output all data and {{*:table}} to format it as an HTML table in the email.\",\n },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'emailTo',\n type: 'text',\n admin: {\n placeholder: '\"Email Sender\" <sender@email.com>',\n width: '100%',\n },\n label: 'Email To',\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ]\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields:\n formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function'\n ? formConfig.formOverrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return config\n}\n"],"names":["deepMergeWithSourceArrays","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","defaultFields","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","filter","Boolean","localized","description","access","read","req","user","placeholder","width","style","maxWidth","config","formOverrides","slug","enableRichTextRelationship","useAsTitle"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAInD,SAASC,MAAM,QAAQ,cAAa;AAEpC,+CAA+C;AAC/C,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAMC,WAAkB;QACtBC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACjEC,YAAY;QACd;QACAX,QAAQ;YACN;gBACEI,MAAM;gBACNC,MAAM;gBACNO,OAAO;gBACPC,UAAU;YACZ;SACD;IACH;IAEA,IAAIX,WAAWY,qBAAqB,EAAE;QACpCX,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaJ,SAAS;YACvD;YACAO,OAAO;YACPI,UAAU;YACVC,YAAYf,WAAWY,qBAAqB;YAC5CD,UAAU;QACZ;QAEAV,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLY,QAAQ;YACV;YACAC,cAAc;YACdC,SAAS;gBACP;oBACER,OAAO;oBACPS,OAAO;gBACT;gBACA;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AAetC,SAAS,CAAC,CAAC;QAC5C;QACAN,QACEE,YAAY0C,eAAe5C,UAAU,OAAOE,YAAY0C,eAAe5C,WAAW,aAC9EE,WAAW0C,aAAa,CAAC5C,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOqB;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA"}
|