@payloadcms/plugin-form-builder 3.0.0-beta.9 → 3.0.0-canary.f6e77b8
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 +3 -0
- package/dist/collections/FormSubmissions/hooks/createCharge.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/hooks/createCharge.js.map +1 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts +3 -0
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/hooks/sendEmail.js.map +1 -1
- package/dist/collections/FormSubmissions/index.d.ts +4 -0
- package/dist/collections/FormSubmissions/index.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/index.js +2 -2
- package/dist/collections/FormSubmissions/index.js.map +1 -1
- package/dist/collections/Forms/DynamicFieldSelector.d.ts +4 -0
- package/dist/collections/Forms/DynamicFieldSelector.d.ts.map +1 -0
- package/dist/collections/Forms/DynamicFieldSelector.js.map +1 -1
- package/dist/collections/Forms/DynamicPriceSelector.d.ts +4 -0
- package/dist/collections/Forms/DynamicPriceSelector.d.ts.map +1 -0
- package/dist/collections/Forms/DynamicPriceSelector.js +1 -1
- package/dist/collections/Forms/DynamicPriceSelector.js.map +1 -1
- package/dist/collections/Forms/fields.d.ts +6 -0
- package/dist/collections/Forms/fields.d.ts.map +1 -0
- package/dist/collections/Forms/index.d.ts +4 -0
- package/dist/collections/Forms/index.d.ts.map +1 -0
- package/dist/collections/Forms/index.js.map +1 -1
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +175 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js.map +1 -1
- package/dist/utilities/getPaymentTotal.d.ts +5 -0
- package/dist/utilities/getPaymentTotal.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/heading.d.ts +3 -0
- package/dist/utilities/lexical/converters/heading.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/linebreak.d.ts +3 -0
- package/dist/utilities/lexical/converters/linebreak.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/link.d.ts +3 -0
- package/dist/utilities/lexical/converters/link.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/list.d.ts +4 -0
- package/dist/utilities/lexical/converters/list.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/paragraph.d.ts +3 -0
- package/dist/utilities/lexical/converters/paragraph.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/quote.d.ts +3 -0
- package/dist/utilities/lexical/converters/quote.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/text.d.ts +3 -0
- package/dist/utilities/lexical/converters/text.d.ts.map +1 -0
- package/dist/utilities/lexical/defaultConverters.d.ts +3 -0
- package/dist/utilities/lexical/defaultConverters.d.ts.map +1 -0
- package/dist/utilities/lexical/nodeFormat.d.ts +39 -0
- package/dist/utilities/lexical/nodeFormat.d.ts.map +1 -0
- package/dist/utilities/lexical/serializeLexical.d.ts +9 -0
- package/dist/utilities/lexical/serializeLexical.d.ts.map +1 -0
- package/dist/utilities/lexical/types.d.ts +14 -0
- package/dist/utilities/lexical/types.d.ts.map +1 -0
- package/dist/utilities/replaceDoubleCurlys.d.ts +8 -0
- package/dist/utilities/replaceDoubleCurlys.d.ts.map +1 -0
- package/dist/utilities/slate/serializeSlate.d.ts +12 -0
- package/dist/utilities/slate/serializeSlate.d.ts.map +1 -0
- package/package.json +39 -34
- package/src/index.ts +0 -55
- package/types.d.ts +0 -1
- package/types.js +0 -1
|
@@ -0,0 +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,QAAQ,GAAG,CAeb,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/createCharge.ts"],"sourcesContent":["import type {
|
|
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"],"rangeMappings":";;;;;;;;;;;","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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendEmail.d.ts","sourceRoot":"","sources":["../../../../src/collections/FormSubmissions/hooks/sendEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,uBAAuB,EAAkB,MAAM,mBAAmB,CAAA;AAMvF,eAAO,MAAM,SAAS,qBACF,GAAG,cACT,uBAAuB,KAClC,QAAQ,GAAG,CA6Fb,CAAA"}
|
|
@@ -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 { Email, FormBuilderPluginConfig, FormattedEmail } 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\nexport const sendEmail = async (\n beforeChangeData: any,\n formConfig: FormBuilderPluginConfig,\n): Promise<any> => {\n const { data, operation, req } = beforeChangeData\n\n if (operation === 'create') {\n const {\n data: { id: formSubmissionID },\n req: { locale, payload },\n } = beforeChangeData\n\n const { form: formID, submissionData } = data || {}\n\n const { beforeEmail, 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\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,\n message,\n replyTo: emailReplyTo,\n subject,\n } = email\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)\n }\n\n // const log = emailsToSend.map(({ html, ...rest }) => ({ ...rest }))\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","beforeChangeData","formConfig","data","operation","req","id","formSubmissionID","locale","payload","form","formID","submissionData","beforeEmail","formOverrides","findByID","collection","slug","emails","length","formattedEmails","Promise","all","map","email","bcc","emailBCC","cc","emailCC","emailFrom","emailTo","message","replyTo","emailReplyTo","subject","to","from","isLexical","Array","isArray","serializedMessage","html","emailsToSend","emailPromise","err","logger","error","JSON","stringify","info","msg"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,gBAAgB,QAAQ,iDAAgD;AACjF,SAASC,mBAAmB,QAAQ,4CAA2C;AAC/E,SAASC,cAAc,QAAQ,6CAA4C;AAE3E,OAAO,MAAMC,YAAY,OACvBC,kBACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,GAAG,EAAE,GAAGJ;IAEjC,IAAIG,cAAc,UAAU;QAC1B,MAAM,EACJD,MAAM,EAAEG,IAAIC,gBAAgB,EAAE,EAC9BF,KAAK,EAAEG,MAAM,EAAEC,OAAO,EAAE,EACzB,G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MAAMC,QAAQC,GAAG,CACfoB,aAAanB,GAAG,CAAC,OAAOC;oBACtB,MAAM,EAAEW,EAAE,EAAE,GAAGX;oBACf,IAAI;wBACF,MAAMmB,eAAe,MAAMlC,QAAQT,SAAS,CAACwB;wBAC7C,OAAOmB;oBACT,EAAE,OAAOC,KAAc;wBACrBnC,QAAQoC,MAAM,CAACC,KAAK,CAAC;4BACnBF,KAAK,CAAC,sCAAsC,EAAET,GAAG,kBAAkB,EAAEY,KAAKC,SAAS,CACjFJ,KACA,CAAC;wBACL;oBACF;gBACF;YAEJ,OAAO;gBACLnC,QAAQoC,MAAM,CAACI,IAAI,CAAC;oBAAEC,KAAK;gBAAqB;YAClD;QACF,EAAE,OAAON,KAAc;YACrB,MAAMM,MAAM,CAAC,8DAA8D,EAAE3C,iBAAiB,CAAC,CAAC;YAChGE,QAAQoC,MAAM,CAACC,KAAK,CAAC;gBAAEF,KAAKM;YAAI;QAClC;IACF;IAEA,OAAO/C;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/FormSubmissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAM7D,eAAO,MAAM,4BAA4B,eAC3B,uBAAuB,KAClC,gBAwJF,CAAA"}
|
|
@@ -77,12 +77,12 @@ export const generateSubmissionCollection = (formConfig)=>{
|
|
|
77
77
|
...formConfig?.formSubmissionOverrides?.fields || []
|
|
78
78
|
],
|
|
79
79
|
hooks: {
|
|
80
|
+
...formConfig?.formSubmissionOverrides?.hooks || {},
|
|
80
81
|
beforeChange: [
|
|
81
82
|
(data)=>createCharge(data, formConfig),
|
|
82
83
|
(data)=>sendEmail(data, formConfig),
|
|
83
84
|
...formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []
|
|
84
|
-
]
|
|
85
|
-
...formConfig?.formSubmissionOverrides?.hooks || {}
|
|
85
|
+
]
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
const paymentFieldConfig = formConfig?.fields?.payment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload/types'\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload/types'\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 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 {\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 ...(formConfig?.formSubmissionOverrides?.fields || []),\n ],\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","newConfig","formSubmissionOverrides","access","create","read","req","user","update","admin","enableRichTextRelationship","fields","name","type","readOnly","relationTo","required","validate","value","payload","_existingForm","findByID","id","collection","error","hooks","beforeChange","data","paymentFieldConfig","payment","push","label","description"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA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A8C;4BAC9C,wDAAwD;4BAExD,yDAAyD;4BACzD,kFAAkF;4BAElF,IAAI,OAAOA,UAAU,aAAa;gCAChC,OAAO;4BACT;4BAEA,OAAO;wBACT;oBACF;iBACD;YACH;eACIrB,YAAYK,yBAAyBS,UAAU,EAAE;SACtD;QACDc,OAAO;YACL,GAAI5B,YAAYK,yBAAyBuB,SAAS,CAAC,CAAC;YACpDC,cAAc;gBACZ,CAACC,OAASjC,aAAaiC,MAAM9B;gBAC7B,CAAC8B,OAAShC,UAAUgC,MAAM9B;mBACtBA,YAAYK,yBAAyBuB,OAAOC,gBAAgB,EAAE;aACnE;QACH;IACF;IAEA,MAAME,qBAAqB/B,YAAYc,QAAQkB;IAE/C,IAAID,oBAAoB;QACtB3B,UAAUU,MAAM,CAACmB,IAAI,CAAC;YACpBlB,MAAM;YACNC,MAAM;YACNJ,OAAO;gBACLK,UAAU;YACZ;YACAH,QAAQ;gBACN;oBACEC,MAAM;oBACNC,MAAM;oBACNkB,OAAO;gBACT;gBACA;oBACEnB,MAAM;oBACNC,MAAM;oBACNkB,OAAO;gBACT;gBACA;oBACEnB,MAAM;oBACNC,MAAM;oBACNJ,OAAO;wBACLuB,aAAa;oBACf;gBACF;gBACA;oBACEpB,MAAM;oBACNC,MAAM;gBACR;gBACA;oBACED,MAAM;oBACNC,MAAM;oBACNF,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNkB,OAAO;wBACT;wBACA;4BACEnB,MAAM;4BACNC,MAAM;4BACNkB,OAAO;wBACT;wBACA;4BACEnB,MAAM;4BACNC,MAAM;4BACNkB,OAAO;wBACT;qBACD;oBACDA,OAAO;gBACT;aACD;QACH;IACF;IAEA,OAAO9B;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicFieldSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAIhE,OAAO,KAA8B,MAAM,OAAO,CAAA;AAIlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA8BzD,CAAA"}
|
|
@@ -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 { TextFieldProps } from '@payloadcms/ui/fields/Text'\n\nimport { Select } from '@payloadcms/ui/fields/Select'\nimport { useForm } from '@payloadcms/ui/forms/Form'\nimport React, { useEffect, useState } from 'react'\n\nimport type { SelectFieldOption } from '../../types.js'\n\nexport const DynamicFieldSelector: React.FC<TextFieldProps> = (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): SelectFieldOption | null => {\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 // TODO: label from config is Record<string, string> | false | string\n // but the FormFieldBase type has only label?: string, changing FormFieldBase breaks other ui components\n return <Select {...props} options={options} />\n}\n"],"names":["Select","useForm","React","useEffect","useState","DynamicFieldSelector","props","fields","getDataByPath","options","setOptions","allNonPaymentFields","map","block","name","blockType","label","value","filter","Boolean"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,MAAM,QAAQ,+BAA8B;AACrD,SAASC,OAAO,QAAQ,4BAA2B;AACnD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAIlD,OAAO,MAAMC,uBAAiD,CAACC;IAC7D,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,qEAAqE;IACrE,yGAAyG;IACzG,qBAAO,oBAACR;QAAQ,GAAGM,KAAK;QAAEG,SAASA;;AACrC,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicPriceSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAMhE,OAAO,KAA8B,MAAM,OAAO,CAAA;AAOlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA2DzD,CAAA"}
|
|
@@ -41,7 +41,7 @@ export const DynamicPriceSelector = (props)=>{
|
|
|
41
41
|
};
|
|
42
42
|
const labelValue = localLabels[localeCode] || localLabels['en'] || '';
|
|
43
43
|
if (valueType === 'valueOfField' && !isNumberField) {
|
|
44
|
-
return /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("div", null, labelValue), /*#__PURE__*/ React.createElement("div", {
|
|
44
|
+
return /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("div", null, String(labelValue)), /*#__PURE__*/ React.createElement("div", {
|
|
45
45
|
style: {
|
|
46
46
|
color: '#9A9A9A'
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { TextFieldProps } from '@payloadcms/ui/fields/Text'\nimport type { Data } from 'payload/types'\n\nimport { Text } from '@payloadcms/ui/fields/Text'\nimport { useWatchForm } from '@payloadcms/ui/forms/Form'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport React, { useEffect, useState } from 'react'\n\ntype FieldWithID = {\n id: string\n name: string\n}\n\nexport const DynamicPriceSelector: React.FC<TextFieldProps> = (props) => {\n const { label, path } = 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 (path) {\n const parentPath = 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, path, getDataByPath, getData])\n\n // TODO: make this a number field, block by Payload\n if (valueType === 'static') {\n return <Text {...props} />\n }\n\n const localeCode = typeof locale === 'object' && 'code' in locale ? locale.code : locale\n\n const localLabels = typeof label === 'object' ? label : { [localeCode]: label }\n const labelValue = localLabels[localeCode] || localLabels['en'] || ''\n\n if (valueType === 'valueOfField' && !isNumberField) {\n return (\n <div>\n <div>{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":["Text","useWatchForm","useLocale","React","useEffect","useState","DynamicPriceSelector","props","label","path","fields","getData","getDataByPath","locale","isNumberField","setIsNumberField","valueType","setValueType","parentPath","split","slice","join","paymentFieldData","fieldToUse","allFields","field","find","name","blockType","localeCode","code","localLabels","labelValue","div","style","color"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,SAASA,IAAI,QAAQ,6BAA4B;AACjD,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAOlD,OAAO,MAAMC,uBAAiD,CAACC;IAC7D,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGF;IAExB,MAAM,EAAEG,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGX;IAE3C,MAAMY,SAASX;IAEf,MAAM,CAACY,eAAeC,iBAAiB,GAAGV;IAC1C,MAAM,CAACW,WAAWC,aAAa,GAAGZ;IAElC,4CAA4C;IAC5CD,UAAU;QACR,IAAIK,MAAM;YACR,MAAMS,aAAaT,KAAKU,KAAK,CAAC,KAAKC,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;YACrD,MAAMC,mBAAwBV,cAAcM;YAE5C,IAAII,kBAAkB;gBACpB,MAAM,EAAEC,UAAU,EAAEP,SAAS,EAAE,GAAGM;gBAElCL,aAAaD;gBAEb,MAAM,EAAEN,QAAQc,SAAS,EAAE,GAASb;gBACpC,MAAMc,QAAQD,UAAUE,IAAI,CAAC,CAACD,QAAuBA,MAAME,IAAI,KAAKJ;gBAEpE,IAAIE,OAAO;oBACT,MAAM,EAAEG,SAAS,EAAE,GAAGH;oBACtBV,iBAAiBa,cAAc;gBACjC;YACF;QACF;IACF,GAAG;QAAClB;QAAQD;QAAMG;QAAeD;KAAQ;IAEzC,mDAAmD;IACnD,IAAIK,cAAc,UAAU;QAC1B,qBAAO,oBAAChB,MAASO;IACnB;IAEA,MAAMsB,aAAa,OAAOhB,WAAW,YAAY,UAAUA,SAASA,OAAOiB,IAAI,GAAGjB;IAElF,MAAMkB,cAAc,OAAOvB,UAAU,WAAWA,QAAQ;QAAE,CAACqB,WAAW,EAAErB;IAAM;
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { TextFieldProps } from '@payloadcms/ui/fields/Text'\nimport type { Data } from 'payload/types'\n\nimport { Text } from '@payloadcms/ui/fields/Text'\nimport { useWatchForm } from '@payloadcms/ui/forms/Form'\nimport { useLocale } from '@payloadcms/ui/providers/Locale'\nimport React, { useEffect, useState } from 'react'\n\ntype FieldWithID = {\n id: string\n name: string\n}\n\nexport const DynamicPriceSelector: React.FC<TextFieldProps> = (props) => {\n const { label, path } = 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 (path) {\n const parentPath = 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, path, getDataByPath, getData])\n\n // TODO: make this a number field, block by Payload\n if (valueType === 'static') {\n return <Text {...props} />\n }\n\n const localeCode = typeof locale === 'object' && 'code' in locale ? locale.code : locale\n\n const localLabels = typeof label === 'object' ? label : { [localeCode]: 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":["Text","useWatchForm","useLocale","React","useEffect","useState","DynamicPriceSelector","props","label","path","fields","getData","getDataByPath","locale","isNumberField","setIsNumberField","valueType","setValueType","parentPath","split","slice","join","paymentFieldData","fieldToUse","allFields","field","find","name","blockType","localeCode","code","localLabels","labelValue","div","String","style","color"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,SAASA,IAAI,QAAQ,6BAA4B;AACjD,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAOlD,OAAO,MAAMC,uBAAiD,CAACC;IAC7D,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGF;IAExB,MAAM,EAAEG,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGX;IAE3C,MAAMY,SAASX;IAEf,MAAM,CAACY,eAAeC,iBAAiB,GAAGV;IAC1C,MAAM,CAACW,WAAWC,aAAa,GAAGZ;IAElC,4CAA4C;IAC5CD,UAAU;QACR,IAAIK,MAAM;YACR,MAAMS,aAAaT,KAAKU,KAAK,CAAC,KAAKC,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;YACrD,MAAMC,mBAAwBV,cAAcM;YAE5C,IAAII,kBAAkB;gBACpB,MAAM,EAAEC,UAAU,EAAEP,SAAS,EAAE,GAAGM;gBAElCL,aAAaD;gBAEb,MAAM,EAAEN,QAAQc,SAAS,EAAE,GAASb;gBACpC,MAAMc,QAAQD,UAAUE,IAAI,CAAC,CAACD,QAAuBA,MAAME,IAAI,KAAKJ;gBAEpE,IAAIE,OAAO;oBACT,MAAM,EAAEG,SAAS,EAAE,GAAGH;oBACtBV,iBAAiBa,cAAc;gBACjC;YACF;QACF;IACF,GAAG;QAAClB;QAAQD;QAAMG;QAAeD;KAAQ;IAEzC,mDAAmD;IACnD,IAAIK,cAAc,UAAU;QAC1B,qBAAO,oBAAChB,MAASO;IACnB;IAEA,MAAMsB,aAAa,OAAOhB,WAAW,YAAY,UAAUA,SAASA,OAAOiB,IAAI,GAAGjB;IAElF,MAAMkB,cAAc,OAAOvB,UAAU,WAAWA,QAAQ;QAAE,CAACqB,WAAW,EAAErB;IAAM;IAE9E,MAAMwB,aAAaD,WAAW,CAACF,WAAW,IAAIE,WAAW,CAAC,KAAK,IAAI;IAEnE,IAAIf,cAAc,kBAAkB,CAACF,eAAe;QAClD,qBACE,oBAACmB,2BACC,oBAACA,aAAKC,OAAOF,4BACb,oBAACC;YACCE,OAAO;gBACLC,OAAO;YACT;WACD;IAKP;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,gBAAgB,CAAA;AA6jBrE,eAAO,MAAM,MAAM;2CAYc,WAAW,GAAG,OAAO,KAAK,KAAK;CAC/D,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAS,MAAM,eAAe,CAAA;AAInE,OAAO,KAAK,EAAe,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAK1E,eAAO,MAAM,sBAAsB,eAAgB,uBAAuB,KAAG,gBAiO5E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\n\nimport merge from 'deepmerge'\n\nimport type { FieldConfig, PluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: PluginConfig): 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 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 {\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 ...(formConfig?.formOverrides?.fields || []),\n ],\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","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","arrayMerge","sourceArray","filter","Boolean","localized","description","placeholder","width"],"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,C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;gBACV;gBACAC,cAAc;gBACdC,SAAS;oBACP;wBACER,OAAO;wBACPS,OAAO;oBACT;oBACA;wBACET,OAAO;wBACPS,OAAO;oBACT;iBACD;YACH;YACA;gBACEjB,MAAM;gBACNC,MAAM;gBACNC,OAAO;oBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;gBACnE;gBACA+B,WAAW;gBACX5B,UAAU;YACZ;YACAV;YACA;gBACEC,MAAM;gBACNC,MAAM;gBACNC,OAAO;oBACLoC,aACE;gBACJ;gBACA1C,QAAQ;oBACN;wBACEK,MAAM;wBACNL,QAAQ;4BACN;gCACEI,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLsC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLsC,OAAO;gCACT;gCACAhC,OAAO;4BACT;yBACD;oBACH;oBACA;wBACEP,MAAM;wBACNL,QAAQ;4BACN;gCACEI,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;yBACD;oBACH;oBACA;wBACER,MAAM;wBACNC,MAAM;wBACNc,cAAc;wBACdP,OAAO;wBACP6B,WAAW;wBACX5B,UAAU;oBACZ;oBACA;wBACET,MAAM;wBACNC,MAAM;wBACNC,OAAO;4BACLoC,aAAa;wBACf;wBACA9B,OAAO;wBACP6B,WAAW;oBACb;iBACD;YACH;eACIvC,YAAYqB,eAAevB,UAAU,EAAE;SAC5C;IACH;IAEA,OAAOsB;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\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 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 {\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 ...(formConfig?.formOverrides?.fields || []),\n ],\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","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","arrayMerge","sourceArray","filter","Boolean","localized","description","placeholder","width"],"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;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O;gBACT,GACCI,MAAM,CAACC;YACZ;YACA;gBACEpC,MAAM;gBACNC,MAAM;gBACNoC,WAAW;YACb;YACA;gBACErC,MAAM;gBACNC,MAAM;gBACNC,OAAO;oBACLoC,aACE;oBACFxB,QAAQ;gBACV;gBACAC,cAAc;gBACdC,SAAS;oBACP;wBACER,OAAO;wBACPS,OAAO;oBACT;oBACA;wBACET,OAAO;wBACPS,OAAO;oBACT;iBACD;YACH;YACA;gBACEjB,MAAM;gBACNC,MAAM;gBACNC,OAAO;oBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;gBACnE;gBACA+B,WAAW;gBACX5B,UAAU;YACZ;YACAV;YACA;gBACEC,MAAM;gBACNC,MAAM;gBACNC,OAAO;oBACLoC,aACE;gBACJ;gBACA1C,QAAQ;oBACN;wBACEK,MAAM;wBACNL,QAAQ;4BACN;gCACEI,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLsC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLsC,OAAO;gCACT;gCACAhC,OAAO;4BACT;yBACD;oBACH;oBACA;wBACEP,MAAM;wBACNL,QAAQ;4BACN;gCACEI,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;yBACD;oBACH;oBACA;wBACER,MAAM;wBACNC,MAAM;wBACNc,cAAc;wBACdP,OAAO;wBACP6B,WAAW;wBACX5B,UAAU;oBACZ;oBACA;wBACET,MAAM;wBACNC,MAAM;wBACNC,OAAO;4BACLoC,aAAa;wBACf;wBACA9B,OAAO;wBACP6B,WAAW;oBACb;iBACD;YACH;eACIvC,YAAYqB,eAAevB,UAAU,EAAE;SAC5C;IACH;IAEA,OAAOsB;AACT,EAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { BeforeEmail, BlockConfig, CheckboxField, CountryField, Email, EmailField, FieldConfig, FieldValues, FieldsConfig, Form, FormBuilderPluginConfig as PluginConfig, FormFieldBlock, FormSubmission, FormattedEmail, HandlePayment, MessageField, PaymentField, PaymentFieldConfig, PriceCondition, Redirect, SelectField, SelectFieldOption, StateField, SubmissionValue, TextAreaField, TextField, isValidBlockConfig, } from '../types.js';
|
|
2
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,KAAK,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,uBAAuB,IAAI,YAAY,EACvC,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,aAAa,EACb,SAAS,EACT,kBAAkB,GACnB,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n BeforeEmail,\n BlockConfig,\n CheckboxField,\n CountryField,\n Email,\n EmailField,\n FieldConfig,\n FieldValues,\n FieldsConfig,\n Form,\n FormBuilderPluginConfig as PluginConfig,\n FormFieldBlock,\n FormSubmission,\n FormattedEmail,\n HandlePayment,\n MessageField,\n PaymentField,\n PaymentFieldConfig,\n PriceCondition,\n Redirect,\n SelectField,\n SelectFieldOption,\n StateField,\n SubmissionValue,\n TextAreaField,\n TextField,\n isValidBlockConfig,\n} from '../types.js'\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WA4BoB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Config } from 'payload/config';
|
|
2
|
+
import type { FormBuilderPluginConfig } from './types.js';
|
|
3
|
+
export { fields } from './collections/Forms/fields.js';
|
|
4
|
+
export { getPaymentTotal } from './utilities/getPaymentTotal.js';
|
|
5
|
+
export declare const formBuilderPlugin: (incomingFormConfig: FormBuilderPluginConfig) => (config: Config) => Config;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAKzD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAEhE,eAAO,MAAM,iBAAiB,uBACP,uBAAuB,cACnC,MAAM,KAAG,MAwCjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { generateSubmissionCollection } from './collections/FormSubmissions/inde
|
|
|
2
2
|
import { generateFormCollection } from './collections/Forms/index.js';
|
|
3
3
|
export { fields } from './collections/Forms/fields.js';
|
|
4
4
|
export { getPaymentTotal } from './utilities/getPaymentTotal.js';
|
|
5
|
-
const
|
|
5
|
+
export const formBuilderPlugin = (incomingFormConfig)=>(config)=>{
|
|
6
6
|
const formConfig = {
|
|
7
7
|
...incomingFormConfig,
|
|
8
8
|
fields: {
|
|
@@ -42,6 +42,5 @@ const FormBuilder = (incomingFormConfig)=>(config)=>{
|
|
|
42
42
|
]
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
-
export default FormBuilder;
|
|
46
45
|
|
|
47
46
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type { FormBuilderPluginConfig } from './types.js'\n\nimport { generateSubmissionCollection } from './collections/FormSubmissions/index.js'\nimport { generateFormCollection } from './collections/Forms/index.js'\n\nexport { fields } from './collections/Forms/fields.js'\nexport { getPaymentTotal } from './utilities/getPaymentTotal.js'\n\nexport const formBuilderPlugin =\n (incomingFormConfig: FormBuilderPluginConfig) =>\n (config: Config): Config => {\n const formConfig: FormBuilderPluginConfig = {\n ...incomingFormConfig,\n fields: {\n checkbox: true,\n country: true,\n email: true,\n message: true,\n number: true,\n payment: false,\n select: true,\n state: true,\n text: true,\n textarea: true,\n ...incomingFormConfig.fields,\n },\n }\n\n return {\n ...config,\n // admin: {\n // ...config.admin,\n // webpack: (webpackConfig) => ({\n // ...webpackConfig,\n // resolve: {\n // ...webpackConfig.resolve,\n // alias: {\n // ...webpackConfig.resolve.alias,\n // [path.resolve(__dirname, 'collections/FormSubmissions/hooks/sendEmail.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),\n // [path.resolve(__dirname, 'collections/FormSubmissions/hooks/createCharge.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),\n // },\n // },\n // })\n // },\n collections: [\n ...(config?.collections || []),\n generateFormCollection(formConfig),\n generateSubmissionCollection(formConfig),\n ],\n }\n }\n"],"names":["generateSubmissionCollection","generateFormCollection","fields","getPaymentTotal","formBuilderPlugin","incomingFormConfig","config","formConfig","checkbox","country","email","message","number","payment","select","state","text","textarea","collections"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,4BAA4B,QAAQ,yCAAwC;AACrF,SAASC,sBAAsB,QAAQ,+BAA8B;AAErE,SAASC,MAAM,QAAQ,gCAA+B;AACtD,SAASC,eAAe,QAAQ,iCAAgC;AAEhE,OAAO,MAAMC,oBACX,CAACC,qBACD,CAACC;QACC,MAAMC,aAAsC;YAC1C,GAAGF,kBAAkB;YACrBH,QAAQ;gBACNM,UAAU;gBACVC,SAAS;gBACTC,OAAO;gBACPC,SAAS;gBACTC,QAAQ;gBACRC,SAAS;gBACTC,QAAQ;gBACRC,OAAO;gBACPC,MAAM;gBACNC,UAAU;gBACV,GAAGZ,mBAAmBH,MAAM;YAC9B;QACF;QAEA,OAAO;YACL,GAAGI,MAAM;YACT,WAAW;YACX,qBAAqB;YACrB,mCAAmC;YACnC,wBAAwB;YACxB,iBAAiB;YACjB,kCAAkC;YAClC,iBAAiB;YACjB,0CAA0C;YAC1C,yIAAyI;YACzI,4IAA4I;YAC5I,WAAW;YACX,SAAS;YACT,OAAO;YACP,KAAK;YACLY,aAAa;mBACPZ,QAAQY,eAAe,EAAE;gBAC7BjB,uBAAuBM;gBACvBP,6BAA6BO;aAC9B;QACH;IACF,EAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { Block, CollectionConfig, Field } from 'payload/types';
|
|
2
|
+
export interface BlockConfig {
|
|
3
|
+
block: Block;
|
|
4
|
+
validate?: (value: unknown) => boolean | string;
|
|
5
|
+
}
|
|
6
|
+
export declare function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig;
|
|
7
|
+
export interface FieldValues {
|
|
8
|
+
[key: string]: boolean | null | number | string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type PaymentFieldConfig = Partial<Field> & {
|
|
11
|
+
paymentProcessor: Partial<SelectField>;
|
|
12
|
+
};
|
|
13
|
+
export type FieldConfig = Partial<Field> | PaymentFieldConfig;
|
|
14
|
+
export interface FieldsConfig {
|
|
15
|
+
[key: string]: FieldConfig | boolean | undefined;
|
|
16
|
+
checkbox?: FieldConfig | boolean;
|
|
17
|
+
country?: FieldConfig | boolean;
|
|
18
|
+
email?: FieldConfig | boolean;
|
|
19
|
+
message?: FieldConfig | boolean;
|
|
20
|
+
number?: FieldConfig | boolean;
|
|
21
|
+
payment?: FieldConfig | boolean;
|
|
22
|
+
select?: FieldConfig | boolean;
|
|
23
|
+
state?: FieldConfig | boolean;
|
|
24
|
+
text?: FieldConfig | boolean;
|
|
25
|
+
textarea?: FieldConfig | boolean;
|
|
26
|
+
}
|
|
27
|
+
export type BeforeEmail = (emails: FormattedEmail[]) => FormattedEmail[] | Promise<FormattedEmail[]>;
|
|
28
|
+
export type HandlePayment = (data: any) => void;
|
|
29
|
+
export type FormBuilderPluginConfig = {
|
|
30
|
+
beforeEmail?: BeforeEmail;
|
|
31
|
+
fields?: FieldsConfig;
|
|
32
|
+
formOverrides?: Partial<CollectionConfig>;
|
|
33
|
+
formSubmissionOverrides?: Partial<CollectionConfig>;
|
|
34
|
+
handlePayment?: HandlePayment;
|
|
35
|
+
redirectRelationships?: string[];
|
|
36
|
+
};
|
|
37
|
+
export interface TextField {
|
|
38
|
+
blockName?: string;
|
|
39
|
+
blockType: 'text';
|
|
40
|
+
defaultValue?: string;
|
|
41
|
+
label?: string;
|
|
42
|
+
name: string;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
width?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface TextAreaField {
|
|
47
|
+
blockName?: string;
|
|
48
|
+
blockType: 'textarea';
|
|
49
|
+
defaultValue?: string;
|
|
50
|
+
label?: string;
|
|
51
|
+
name: string;
|
|
52
|
+
required?: boolean;
|
|
53
|
+
width?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface SelectFieldOption {
|
|
56
|
+
label: string;
|
|
57
|
+
value: string;
|
|
58
|
+
}
|
|
59
|
+
export interface SelectField {
|
|
60
|
+
blockName?: string;
|
|
61
|
+
blockType: 'select';
|
|
62
|
+
defaultValue?: string;
|
|
63
|
+
label?: string;
|
|
64
|
+
name: string;
|
|
65
|
+
options: SelectFieldOption[];
|
|
66
|
+
required?: boolean;
|
|
67
|
+
width?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface PriceCondition {
|
|
70
|
+
condition: 'equals' | 'hasValue' | 'notEquals';
|
|
71
|
+
fieldToUse: string;
|
|
72
|
+
operator: 'add' | 'divide' | 'multiply' | 'subtract';
|
|
73
|
+
valueForCondition: string;
|
|
74
|
+
valueForOperator: number | string;
|
|
75
|
+
valueType: 'static' | 'valueOfField';
|
|
76
|
+
}
|
|
77
|
+
export interface PaymentField {
|
|
78
|
+
basePrice: number;
|
|
79
|
+
blockName?: string;
|
|
80
|
+
blockType: 'payment';
|
|
81
|
+
defaultValue?: string;
|
|
82
|
+
label?: string;
|
|
83
|
+
name: string;
|
|
84
|
+
paymentProcessor: string;
|
|
85
|
+
priceConditions: PriceCondition[];
|
|
86
|
+
required?: boolean;
|
|
87
|
+
width?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface EmailField {
|
|
90
|
+
blockName?: string;
|
|
91
|
+
blockType: 'email';
|
|
92
|
+
defaultValue?: string;
|
|
93
|
+
label?: string;
|
|
94
|
+
name: string;
|
|
95
|
+
required?: boolean;
|
|
96
|
+
width?: number;
|
|
97
|
+
}
|
|
98
|
+
export interface StateField {
|
|
99
|
+
blockName?: string;
|
|
100
|
+
blockType: 'state';
|
|
101
|
+
defaultValue?: string;
|
|
102
|
+
label?: string;
|
|
103
|
+
name: string;
|
|
104
|
+
required?: boolean;
|
|
105
|
+
width?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface CountryField {
|
|
108
|
+
blockName?: string;
|
|
109
|
+
blockType: 'country';
|
|
110
|
+
defaultValue?: string;
|
|
111
|
+
label?: string;
|
|
112
|
+
name: string;
|
|
113
|
+
required?: boolean;
|
|
114
|
+
width?: number;
|
|
115
|
+
}
|
|
116
|
+
export interface CheckboxField {
|
|
117
|
+
blockName?: string;
|
|
118
|
+
blockType: 'checkbox';
|
|
119
|
+
defaultValue?: boolean;
|
|
120
|
+
label?: string;
|
|
121
|
+
name: string;
|
|
122
|
+
required?: boolean;
|
|
123
|
+
width?: number;
|
|
124
|
+
}
|
|
125
|
+
export interface MessageField {
|
|
126
|
+
blockName?: string;
|
|
127
|
+
blockType: 'message';
|
|
128
|
+
message: unknown;
|
|
129
|
+
}
|
|
130
|
+
export type FormFieldBlock = CheckboxField | CountryField | EmailField | MessageField | PaymentField | SelectField | StateField | TextAreaField | TextField;
|
|
131
|
+
export interface Email {
|
|
132
|
+
bcc?: string;
|
|
133
|
+
cc?: string;
|
|
134
|
+
emailFrom: string;
|
|
135
|
+
emailTo: string;
|
|
136
|
+
message?: any;
|
|
137
|
+
replyTo?: string;
|
|
138
|
+
subject: string;
|
|
139
|
+
}
|
|
140
|
+
export interface FormattedEmail {
|
|
141
|
+
bcc?: string;
|
|
142
|
+
cc?: string;
|
|
143
|
+
from: string;
|
|
144
|
+
html: string;
|
|
145
|
+
replyTo: string;
|
|
146
|
+
subject: string;
|
|
147
|
+
to: string;
|
|
148
|
+
}
|
|
149
|
+
export interface Redirect {
|
|
150
|
+
reference?: {
|
|
151
|
+
relationTo: string;
|
|
152
|
+
value: string | unknown;
|
|
153
|
+
};
|
|
154
|
+
type: 'custom' | 'reference';
|
|
155
|
+
url: string;
|
|
156
|
+
}
|
|
157
|
+
export interface Form {
|
|
158
|
+
confirmationMessage?: any;
|
|
159
|
+
confirmationType: 'message' | 'redirect';
|
|
160
|
+
emails: Email[];
|
|
161
|
+
fields: FormFieldBlock[];
|
|
162
|
+
id: string;
|
|
163
|
+
redirect?: Redirect;
|
|
164
|
+
submitButtonLabel?: string;
|
|
165
|
+
title: string;
|
|
166
|
+
}
|
|
167
|
+
export interface SubmissionValue {
|
|
168
|
+
field: string;
|
|
169
|
+
value: unknown;
|
|
170
|
+
}
|
|
171
|
+
export interface FormSubmission {
|
|
172
|
+
form: Form | string;
|
|
173
|
+
submissionData: SubmissionValue[];
|
|
174
|
+
}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, Field } from 'payload/types'\n\nexport interface BlockConfig {\n block: Block\n validate?: (value: unknown) => boolean | string\n}\n\nexport function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig {\n return (\n typeof blockConfig !== 'string' &&\n typeof blockConfig?.block?.slug === 'string' &&\n Array.isArray(blockConfig?.block?.fields)\n )\n}\n\nexport interface FieldValues {\n [key: string]: boolean | null | number | string | undefined\n}\n\nexport type PaymentFieldConfig = Partial<Field> & {\n paymentProcessor: Partial<SelectField>\n}\n\nexport type FieldConfig = Partial<Field> | PaymentFieldConfig\n\nexport interface FieldsConfig {\n [key: string]: FieldConfig | boolean | undefined\n checkbox?: FieldConfig | boolean\n country?: FieldConfig | boolean\n email?: FieldConfig | boolean\n message?: FieldConfig | boolean\n number?: FieldConfig | boolean\n payment?: FieldConfig | boolean\n select?: FieldConfig | boolean\n state?: FieldConfig | boolean\n text?: FieldConfig | boolean\n textarea?: FieldConfig | boolean\n}\n\nexport type BeforeEmail = (emails: FormattedEmail[]) => FormattedEmail[] | Promise<FormattedEmail[]>\nexport type HandlePayment = (data: any) => void\n\nexport
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\n\nexport interface BlockConfig {\n block: Block\n validate?: (value: unknown) => boolean | string\n}\n\nexport function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig {\n return (\n typeof blockConfig !== 'string' &&\n typeof blockConfig?.block?.slug === 'string' &&\n Array.isArray(blockConfig?.block?.fields)\n )\n}\n\nexport interface FieldValues {\n [key: string]: boolean | null | number | string | undefined\n}\n\nexport type PaymentFieldConfig = Partial<Field> & {\n paymentProcessor: Partial<SelectField>\n}\n\nexport type FieldConfig = Partial<Field> | PaymentFieldConfig\n\nexport interface FieldsConfig {\n [key: string]: FieldConfig | boolean | undefined\n checkbox?: FieldConfig | boolean\n country?: FieldConfig | boolean\n email?: FieldConfig | boolean\n message?: FieldConfig | boolean\n number?: FieldConfig | boolean\n payment?: FieldConfig | boolean\n select?: FieldConfig | boolean\n state?: FieldConfig | boolean\n text?: FieldConfig | boolean\n textarea?: FieldConfig | boolean\n}\n\nexport type BeforeEmail = (emails: FormattedEmail[]) => FormattedEmail[] | Promise<FormattedEmail[]>\nexport type HandlePayment = (data: any) => void\n\nexport type FormBuilderPluginConfig = {\n beforeEmail?: BeforeEmail\n fields?: FieldsConfig\n formOverrides?: Partial<CollectionConfig>\n formSubmissionOverrides?: Partial<CollectionConfig>\n handlePayment?: HandlePayment\n redirectRelationships?: string[]\n}\n\nexport interface TextField {\n blockName?: string\n blockType: 'text'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface TextAreaField {\n blockName?: string\n blockType: 'textarea'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface SelectFieldOption {\n label: string\n value: string\n}\n\nexport interface SelectField {\n blockName?: string\n blockType: 'select'\n defaultValue?: string\n label?: string\n name: string\n options: SelectFieldOption[]\n required?: boolean\n width?: number\n}\n\nexport interface PriceCondition {\n condition: 'equals' | 'hasValue' | 'notEquals'\n fieldToUse: string\n operator: 'add' | 'divide' | 'multiply' | 'subtract'\n valueForCondition: string\n valueForOperator: number | string // TODO: make this a number, see ./collections/Forms/DynamicPriceSelector.tsx\n valueType: 'static' | 'valueOfField'\n}\n\nexport interface PaymentField {\n basePrice: number\n blockName?: string\n blockType: 'payment'\n defaultValue?: string\n label?: string\n name: string\n paymentProcessor: string\n priceConditions: PriceCondition[]\n required?: boolean\n width?: number\n}\n\nexport interface EmailField {\n blockName?: string\n blockType: 'email'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface StateField {\n blockName?: string\n blockType: 'state'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface CountryField {\n blockName?: string\n blockType: 'country'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface CheckboxField {\n blockName?: string\n blockType: 'checkbox'\n defaultValue?: boolean\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface MessageField {\n blockName?: string\n blockType: 'message'\n message: unknown\n}\n\nexport type FormFieldBlock =\n | CheckboxField\n | CountryField\n | EmailField\n | MessageField\n | PaymentField\n | SelectField\n | StateField\n | TextAreaField\n | TextField\n\nexport interface Email {\n bcc?: string\n cc?: string\n emailFrom: string\n emailTo: string\n message?: any // TODO: configure rich text type\n replyTo?: string\n subject: string\n}\n\nexport interface FormattedEmail {\n bcc?: string\n cc?: string\n from: string\n html: string\n replyTo: string\n subject: string\n to: string\n}\n\nexport interface Redirect {\n reference?: {\n relationTo: string\n value: string | unknown\n }\n type: 'custom' | 'reference'\n url: string\n}\n\nexport interface Form {\n confirmationMessage?: any // TODO: configure rich text type\n confirmationType: 'message' | 'redirect'\n emails: Email[]\n fields: FormFieldBlock[]\n id: string\n redirect?: Redirect\n submitButtonLabel?: string\n title: string\n}\n\nexport interface SubmissionValue {\n field: string\n value: unknown\n}\n\nexport interface FormSubmission {\n form: Form | string\n submissionData: SubmissionValue[]\n}\n"],"names":["isValidBlockConfig","blockConfig","block","slug","Array","isArray","fields"],"rangeMappings":";;","mappings":"AAOA,OAAO,SAASA,mBAAmBC,WAAiC;IAClE,OACE,OAAOA,gBAAgB,YACvB,OAAOA,aAAaC,OAAOC,SAAS,YACpCC,MAAMC,OAAO,CAACJ,aAAaC,OAAOI;AAEtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPaymentTotal.d.ts","sourceRoot":"","sources":["../../src/utilities/getPaymentTotal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAA;AAE5E,eAAO,MAAM,eAAe,SACpB,QAAQ,YAAY,CAAC,GAAG;IAC5B,WAAW,EAAE,WAAW,CAAA;CACzB,KACA,MA8CF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../../../src/utilities/lexical/converters/heading.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,GAAG,CAenD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linebreak.d.ts","sourceRoot":"","sources":["../../../../src/utilities/lexical/converters/linebreak.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,GAAG,CAKrD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../src/utilities/lexical/converters/link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAKhD,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,GAAG,CAyBhD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/utilities/lexical/converters/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,GAAG,CAehD,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,GAAG,CA4BpD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../src/utilities/lexical/converters/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,GAAG,CAcrD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../../../src/utilities/lexical/converters/quote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,GAAG,CAejD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/utilities/lexical/converters/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAKhD,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,GAAG,CAiChD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultConverters.d.ts","sourceRoot":"","sources":["../../../src/utilities/lexical/defaultConverters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAU/C,eAAO,MAAM,qBAAqB,EAAE,aAAa,EAShD,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const NodeFormat: {
|
|
2
|
+
readonly DOM_ELEMENT_TYPE: 1;
|
|
3
|
+
readonly DOM_TEXT_TYPE: 3;
|
|
4
|
+
readonly NO_DIRTY_NODES: 0;
|
|
5
|
+
readonly HAS_DIRTY_NODES: 1;
|
|
6
|
+
readonly FULL_RECONCILE: 2;
|
|
7
|
+
readonly IS_NORMAL: 0;
|
|
8
|
+
readonly IS_TOKEN: 1;
|
|
9
|
+
readonly IS_SEGMENTED: 2;
|
|
10
|
+
readonly IS_INERT: 3;
|
|
11
|
+
readonly IS_BOLD: 1;
|
|
12
|
+
readonly IS_ITALIC: number;
|
|
13
|
+
readonly IS_STRIKETHROUGH: number;
|
|
14
|
+
readonly IS_UNDERLINE: number;
|
|
15
|
+
readonly IS_CODE: number;
|
|
16
|
+
readonly IS_SUBSCRIPT: number;
|
|
17
|
+
readonly IS_SUPERSCRIPT: number;
|
|
18
|
+
readonly IS_HIGHLIGHT: number;
|
|
19
|
+
readonly IS_DIRECTIONLESS: 1;
|
|
20
|
+
readonly IS_UNMERGEABLE: number;
|
|
21
|
+
readonly IS_ALIGN_LEFT: 1;
|
|
22
|
+
readonly IS_ALIGN_CENTER: 2;
|
|
23
|
+
readonly IS_ALIGN_RIGHT: 3;
|
|
24
|
+
readonly IS_ALIGN_JUSTIFY: 4;
|
|
25
|
+
readonly IS_ALIGN_START: 5;
|
|
26
|
+
readonly IS_ALIGN_END: 6;
|
|
27
|
+
};
|
|
28
|
+
export declare const IS_ALL_FORMATTING: number;
|
|
29
|
+
export declare const NON_BREAKING_SPACE = "\u00A0";
|
|
30
|
+
export declare const DOUBLE_LINE_BREAK = "\n\n";
|
|
31
|
+
export declare const RTL_REGEX: RegExp;
|
|
32
|
+
export declare const LTR_REGEX: RegExp;
|
|
33
|
+
export declare const TEXT_TYPE_TO_FORMAT: Record<any | string, number>;
|
|
34
|
+
export declare const DETAIL_TYPE_TO_DETAIL: Record<any | string, number>;
|
|
35
|
+
export declare const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<any, ''>, number>;
|
|
36
|
+
export declare const ELEMENT_FORMAT_TO_TYPE: Record<number, any>;
|
|
37
|
+
export declare const TEXT_MODE_TO_TYPE: Record<any, 0 | 1 | 2>;
|
|
38
|
+
export declare const TEXT_TYPE_TO_MODE: Record<number, any>;
|
|
39
|
+
//# sourceMappingURL=nodeFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeFormat.d.ts","sourceRoot":"","sources":["../../../src/utilities/lexical/nodeFormat.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Bb,CAAA;AAEV,eAAO,MAAM,iBAAiB,QAQL,CAAA;AAGzB,eAAO,MAAM,kBAAkB,WAAW,CAAA;AAE1C,eAAO,MAAM,iBAAiB,SAAS,CAAA;AAYvC,eAAO,MAAM,SAAS,QAA8C,CAAA;AAEpE,eAAO,MAAM,SAAS,QAA8C,CAAA;AAEpE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,GAAG,GAAG,MAAM,EAAE,MAAM,CAS5D,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,GAAG,GAAG,MAAM,EAAE,MAAM,CAG9D,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,MAAM,CAOnE,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAOtD,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAIpD,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAIjD,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HTMLConverter, SerializedLexicalNodeWithParent } from './types.js';
|
|
2
|
+
export declare function serializeLexical(data?: any, submissionData?: any): Promise<string>;
|
|
3
|
+
export declare function convertLexicalNodesToHTML({ converters, lexicalNodes, parent, submissionData, }: {
|
|
4
|
+
converters: HTMLConverter[];
|
|
5
|
+
lexicalNodes: any[];
|
|
6
|
+
parent: SerializedLexicalNodeWithParent;
|
|
7
|
+
submissionData?: any;
|
|
8
|
+
}): Promise<string>;
|
|
9
|
+
//# sourceMappingURL=serializeLexical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeLexical.d.ts","sourceRoot":"","sources":["../../../src/utilities/lexical/serializeLexical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAIhF,wBAAsB,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAYxF;AAED,wBAAsB,yBAAyB,CAAC,EAC9C,UAAU,EACV,YAAY,EACZ,MAAM,EACN,cAAc,GACf,EAAE;IACD,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,YAAY,EAAE,GAAG,EAAE,CAAA;IACnB,MAAM,EAAE,+BAA+B,CAAA;IACvC,cAAc,CAAC,EAAE,GAAG,CAAA;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type HTMLConverter<T = any> = {
|
|
2
|
+
converter: ({ childIndex, converters, node, parent, submissionData, }: {
|
|
3
|
+
childIndex: number;
|
|
4
|
+
converters: HTMLConverter[];
|
|
5
|
+
node: T;
|
|
6
|
+
parent: SerializedLexicalNodeWithParent;
|
|
7
|
+
submissionData?: any;
|
|
8
|
+
}) => Promise<string> | string;
|
|
9
|
+
nodeTypes: string[];
|
|
10
|
+
};
|
|
11
|
+
export type SerializedLexicalNodeWithParent = any & {
|
|
12
|
+
parent?: any;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utilities/lexical/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,GAAG,IAAI;IACnC,SAAS,EAAE,CAAC,EACV,UAAU,EACV,UAAU,EACV,IAAI,EACJ,MAAM,EACN,cAAc,GACf,EAAE;QACD,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,aAAa,EAAE,CAAA;QAC3B,IAAI,EAAE,CAAC,CAAA;QACP,MAAM,EAAE,+BAA+B,CAAA;QACvC,cAAc,CAAC,EAAE,GAAG,CAAA;KACrB,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG,GAAG,GAAG;IAClD,MAAM,CAAC,EAAE,GAAG,CAAA;CACb,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface EmailVariable {
|
|
2
|
+
field: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
type EmailVariables = EmailVariable[];
|
|
6
|
+
export declare const replaceDoubleCurlys: (str: string, variables?: EmailVariables) => string;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=replaceDoubleCurlys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceDoubleCurlys.d.ts","sourceRoot":"","sources":["../../src/utilities/replaceDoubleCurlys.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,KAAK,cAAc,GAAG,aAAa,EAAE,CAAA;AAErC,eAAO,MAAM,mBAAmB,QAAS,MAAM,iCAA+B,MAU7E,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface Node {
|
|
2
|
+
bold?: boolean;
|
|
3
|
+
children?: Node[];
|
|
4
|
+
code?: boolean;
|
|
5
|
+
italic?: boolean;
|
|
6
|
+
text?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const serializeSlate: (children?: Node[], submissionData?: any) => string | undefined;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=serializeSlate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeSlate.d.ts","sourceRoot":"","sources":["../../../src/utilities/slate/serializeSlate.ts"],"names":[],"mappings":"AAIA,UAAU,IAAI;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA;IACjB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAMD,eAAO,MAAM,cAAc,cAAe,IAAI,EAAE,mBAAmB,GAAG,KAAG,MAAM,GAAG,SAwHrE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-form-builder",
|
|
3
|
+
"version": "3.0.0-canary.f6e77b8",
|
|
3
4
|
"description": "Form builder plugin for Payload CMS",
|
|
4
|
-
"
|
|
5
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"payload",
|
|
7
|
+
"cms",
|
|
8
|
+
"plugin",
|
|
9
|
+
"typescript",
|
|
10
|
+
"react",
|
|
11
|
+
"forms",
|
|
12
|
+
"fields",
|
|
13
|
+
"form builder",
|
|
14
|
+
"payments"
|
|
15
|
+
],
|
|
6
16
|
"repository": {
|
|
7
17
|
"type": "git",
|
|
8
18
|
"url": "https://github.com/payloadcms/payload.git",
|
|
9
19
|
"directory": "packages/plugin-form-builder"
|
|
10
20
|
},
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
21
|
"license": "MIT",
|
|
14
|
-
"author": "dev@payloadcms.com",
|
|
22
|
+
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
15
23
|
"type": "module",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./*": {
|
|
31
|
+
"import": "./dist/exports/*.js",
|
|
32
|
+
"require": "./dist/exports/*.js",
|
|
33
|
+
"types": "./dist/exports/*.d.ts"
|
|
34
|
+
}
|
|
19
35
|
},
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
20
41
|
"dependencies": {
|
|
21
42
|
"deepmerge": "^4.2.2",
|
|
22
43
|
"escape-html": "^1.0.3",
|
|
23
|
-
"@payloadcms/ui": "3.0.0-
|
|
44
|
+
"@payloadcms/ui": "3.0.0-canary.f6e77b8"
|
|
24
45
|
},
|
|
25
46
|
"devDependencies": {
|
|
26
47
|
"@types/escape-html": "^1.0.4",
|
|
@@ -29,38 +50,22 @@
|
|
|
29
50
|
"copyfiles": "^2.4.1",
|
|
30
51
|
"cross-env": "^7.0.3",
|
|
31
52
|
"nodemon": "3.0.3",
|
|
32
|
-
"react": "^18.0.0",
|
|
33
53
|
"ts-node": "10.9.1",
|
|
34
54
|
"@payloadcms/eslint-config": "1.1.1",
|
|
35
|
-
"payload": "3.0.0-
|
|
55
|
+
"payload": "3.0.0-canary.f6e77b8"
|
|
36
56
|
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
"require": "./dist/index.js",
|
|
41
|
-
"types": "./dist/index.d.ts"
|
|
42
|
-
}
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
59
|
+
"payload": "3.0.0-canary.f6e77b8"
|
|
43
60
|
},
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
],
|
|
49
|
-
"keywords": [
|
|
50
|
-
"payload",
|
|
51
|
-
"cms",
|
|
52
|
-
"plugin",
|
|
53
|
-
"typescript",
|
|
54
|
-
"react",
|
|
55
|
-
"forms",
|
|
56
|
-
"fields",
|
|
57
|
-
"form builder",
|
|
58
|
-
"payments"
|
|
59
|
-
],
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
},
|
|
64
|
+
"homepage:": "https://payloadcms.com",
|
|
60
65
|
"scripts": {
|
|
66
|
+
"build": "pnpm build:swc && pnpm build:types",
|
|
61
67
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
|
|
62
68
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
63
|
-
"build": "swc ./src -d ./dist --config-file .swcrc",
|
|
64
69
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
65
70
|
"test": "echo \"No tests available.\""
|
|
66
71
|
}
|
package/src/index.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'payload/config'
|
|
2
|
-
|
|
3
|
-
import type { PluginConfig } from './types.js'
|
|
4
|
-
|
|
5
|
-
import { generateSubmissionCollection } from './collections/FormSubmissions/index.js'
|
|
6
|
-
import { generateFormCollection } from './collections/Forms/index.js'
|
|
7
|
-
|
|
8
|
-
export { fields } from './collections/Forms/fields.js'
|
|
9
|
-
export { getPaymentTotal } from './utilities/getPaymentTotal.js'
|
|
10
|
-
|
|
11
|
-
const FormBuilder =
|
|
12
|
-
(incomingFormConfig: PluginConfig) =>
|
|
13
|
-
(config: Config): Config => {
|
|
14
|
-
const formConfig: PluginConfig = {
|
|
15
|
-
...incomingFormConfig,
|
|
16
|
-
fields: {
|
|
17
|
-
checkbox: true,
|
|
18
|
-
country: true,
|
|
19
|
-
email: true,
|
|
20
|
-
message: true,
|
|
21
|
-
number: true,
|
|
22
|
-
payment: false,
|
|
23
|
-
select: true,
|
|
24
|
-
state: true,
|
|
25
|
-
text: true,
|
|
26
|
-
textarea: true,
|
|
27
|
-
...incomingFormConfig.fields,
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
...config,
|
|
33
|
-
// admin: {
|
|
34
|
-
// ...config.admin,
|
|
35
|
-
// webpack: (webpackConfig) => ({
|
|
36
|
-
// ...webpackConfig,
|
|
37
|
-
// resolve: {
|
|
38
|
-
// ...webpackConfig.resolve,
|
|
39
|
-
// alias: {
|
|
40
|
-
// ...webpackConfig.resolve.alias,
|
|
41
|
-
// [path.resolve(__dirname, 'collections/FormSubmissions/hooks/sendEmail.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),
|
|
42
|
-
// [path.resolve(__dirname, 'collections/FormSubmissions/hooks/createCharge.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),
|
|
43
|
-
// },
|
|
44
|
-
// },
|
|
45
|
-
// })
|
|
46
|
-
// },
|
|
47
|
-
collections: [
|
|
48
|
-
...(config?.collections || []),
|
|
49
|
-
generateFormCollection(formConfig),
|
|
50
|
-
generateSubmissionCollection(formConfig),
|
|
51
|
-
],
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default FormBuilder
|
package/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/types'
|
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/types')
|