@payloadcms/plugin-form-builder 4.0.0-internal.cea8867 → 4.0.0-internal.d21c039

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.
@@ -91,7 +91,7 @@ export const generateSubmissionCollection = (formConfig)=>{
91
91
  slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',
92
92
  access: {
93
93
  create: ()=>true,
94
- read: ({ req: { user } })=>!!user,
94
+ read: ({ req })=>req.user?.collection === req.payload.config.admin.user,
95
95
  update: ()=>false,
96
96
  ...formConfig?.formSubmissionOverrides?.access || {}
97
97
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook, CollectionConfig, Field } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { defaultPaymentFields } from './fields/defaultPaymentFields.js'\nimport { createCharge } from './hooks/createCharge.js'\nimport { handleUploads } from './hooks/handleUploads.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 enablePaymentFields = Boolean(formConfig?.fields?.payment)\n\n const uploadCollections = formConfig?.uploadCollections\n\n const defaultFields: Field[] = [\n {\n name: 'form',\n type: 'relationship',\n relationTo: formSlug,\n required: true,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\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 fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'textarea',\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 ...(uploadCollections && uploadCollections.length > 0\n ? ([\n {\n name: 'submissionUploads',\n type: 'array',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'upload',\n hasMany: true,\n relationTo: uploadCollections,\n required: true,\n },\n ],\n },\n ] as Field[])\n : []),\n ...(enablePaymentFields ? [defaultPaymentFields] : []),\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 afterChange: [\n (data) => sendEmail(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.afterChange || []),\n ],\n beforeChange: [\n ...(uploadCollections && uploadCollections.length > 0\n ? [(data: Parameters<CollectionBeforeChangeHook>[0]) => handleUploads(data, formConfig)]\n : []),\n (data) => createCharge(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []),\n ],\n },\n }\n return newConfig\n}\n"],"names":["defaultPaymentFields","createCharge","handleUploads","sendEmail","generateSubmissionCollection","formConfig","formSlug","formOverrides","slug","enablePaymentFields","Boolean","fields","payment","uploadCollections","defaultFields","name","type","relationTo","required","validate","value","req","payload","_existingForm","findByID","id","collection","_error","length","hasMany","newConfig","formSubmissionOverrides","access","create","read","user","update","admin","enableRichTextRelationship","hooks","afterChange","data","beforeChange"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,+CAA+C;AAC/C,OAAO,MAAMC,+BAA+B,CAC1CC;IAEA,MAAMC,WAAWD,YAAYE,eAAeC,QAAQ;IAEpD,MAAMC,sBAAsBC,QAAQL,YAAYM,QAAQC;IAExD,MAAMC,oBAAoBR,YAAYQ;IAEtC,MAAMC,gBAAyB;QAC7B;YACEC,MAAM;YACNC,MAAM;YACNC,YAAYX;YACZY,UAAU;YACV,oFAAoF;YACpFC,UAAU,OAAOC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAE,EAAED,GAAG,EAAE;gBAC/C,gCAAgC,GAChC,IAAI,CAACC,SAAS;oBACZ,OAAO;gBACT;gBAEA,IAAIA,SAAS;oBACX,IAAIC;oBAEJ,IAAI;wBACFA,gBAAgB,MAAMD,QAAQE,QAAQ,CAAC;4BACrCC,IAAIL;4BACJM,YAAYpB;4BACZe;wBACF;wBAEA,OAAO;oBACT,EAAE,OAAOM,QAAQ;wBACf,OAAO;oBACT;gBACF;YACF;QACF;QACA;YACEZ,MAAM;YACNC,MAAM;YACNL,QAAQ;gBACN;oBACEI,MAAM;oBACNC,MAAM;oBACNE,UAAU;gBACZ;gBACA;oBACEH,MAAM;oBACNC,MAAM;oBACNE,UAAU;oBACVC,UAAU,CAACC;wBACT,QAAQ;wBACR,gDAAgD;wBAChD,0DAA0D;wBAE1D,8CAA8C;wBAC9C,wDAAwD;wBAExD,yDAAyD;wBACzD,kFAAkF;wBAElF,IAAI,OAAOA,UAAU,aAAa;4BAChC,OAAO;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ACF;IACA,OAAOZ;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook, CollectionConfig, Field } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { defaultPaymentFields } from './fields/defaultPaymentFields.js'\nimport { createCharge } from './hooks/createCharge.js'\nimport { handleUploads } from './hooks/handleUploads.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 enablePaymentFields = Boolean(formConfig?.fields?.payment)\n\n const uploadCollections = formConfig?.uploadCollections\n\n const defaultFields: Field[] = [\n {\n name: 'form',\n type: 'relationship',\n relationTo: formSlug,\n required: true,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\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 fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'textarea',\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 ...(uploadCollections && uploadCollections.length > 0\n ? ([\n {\n name: 'submissionUploads',\n type: 'array',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'upload',\n hasMany: true,\n relationTo: uploadCollections,\n required: true,\n },\n ],\n },\n ] as Field[])\n : []),\n ...(enablePaymentFields ? [defaultPaymentFields] : []),\n ]\n\n const newConfig: CollectionConfig = {\n ...(formConfig?.formSubmissionOverrides || {}),\n slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',\n access: {\n create: () => true,\n read: ({ req }) => req.user?.collection === req.payload.config.admin.user,\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 afterChange: [\n (data) => sendEmail(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.afterChange || []),\n ],\n beforeChange: [\n ...(uploadCollections && uploadCollections.length > 0\n ? [(data: Parameters<CollectionBeforeChangeHook>[0]) => handleUploads(data, formConfig)]\n : []),\n (data) => createCharge(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []),\n ],\n },\n }\n return newConfig\n}\n"],"names":["defaultPaymentFields","createCharge","handleUploads","sendEmail","generateSubmissionCollection","formConfig","formSlug","formOverrides","slug","enablePaymentFields","Boolean","fields","payment","uploadCollections","defaultFields","name","type","relationTo","required","validate","value","req","payload","_existingForm","findByID","id","collection","_error","length","hasMany","newConfig","formSubmissionOverrides","access","create","read","user","config","admin","update","enableRichTextRelationship","hooks","afterChange","data","beforeChange"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,+CAA+C;AAC/C,OAAO,MAAMC,+BAA+B,CAC1CC;IA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AClC,GAAIzB,YAAY0B,2BAA2B,CAAC,CAAC;QAC7CvB,MAAMH,YAAY0B,yBAAyBvB,QAAQ;QACnDwB,QAAQ;YACNC,QAAQ,IAAM;YACdC,MAAM,CAAC,EAAEb,GAAG,EAAE,GAAKA,IAAIc,IAAI,EAAET,eAAeL,IAAIC,OAAO,CAACc,MAAM,CAACC,KAAK,CAACF,IAAI;YACzEG,QAAQ,IAAM;YACd,GAAIjC,YAAY0B,yBAAyBC,UAAU,CAAC,CAAC;QACvD;QACAK,OAAO;YACL,GAAIhC,YAAY0B,yBAAyBM,SAAS,CAAC,CAAC;YACpDE,4BAA4B;QAC9B;QACA5B,QACEN,YAAY0B,yBAAyBpB,UACrC,OAAON,YAAY0B,yBAAyBpB,WAAW,aACnDN,WAAW0B,uBAAuB,CAACpB,MAAM,CAAC;YAAEG;QAAc,KAC1DA;QACN0B,OAAO;YACL,GAAInC,YAAY0B,yBAAyBS,SAAS,CAAC,CAAC;YACpDC,aAAa;gBACX,CAACC,OAASvC,UAAUuC,MAAMrC;mBACtBA,YAAY0B,yBAAyBS,OAAOC,eAAe,EAAE;aAClE;YACDE,cAAc;mBACR9B,qBAAqBA,kBAAkBe,MAAM,GAAG,IAChD;oBAAC,CAACc,OAAoDxC,cAAcwC,MAAMrC;iBAAY,GACtF,EAAE;gBACN,CAACqC,OAASzC,aAAayC,MAAMrC;mBACzBA,YAAY0B,yBAAyBS,OAAOG,gBAAgB,EAAE;aACnE;QACH;IACF;IACA,OAAOb;AACT,EAAC"}
@@ -36,7 +36,7 @@ export const DynamicPriceSelector = (props)=>{
36
36
  ...props
37
37
  });
38
38
  }
39
- const localeCode = typeof locale === 'object' && 'code' in locale ? locale.code : locale;
39
+ const localeCode = locale?.code ?? 'en';
40
40
  const localLabels = typeof field.label === 'object' ? field.label : {
41
41
  [localeCode]: field.label
42
42
  };
@@ -1 +1 @@
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, 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, getDataByPath, getData, path])\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","path","fields","getData","getDataByPath","locale","isNumberField","setIsNumberField","valueType","setValueType","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,EA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;8BACC,KAACA;8BAAKC,OAAOF;;8BACb,KAACC;oBACCE,OAAO;wBACLC,OAAO;oBACT;8BACD;;;;IAKP;IAEA,OAAO;AACT,EAAC"}
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, 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, getDataByPath, getData, path])\n\n // TODO: make this a number field, block by Payload\n if (valueType === 'static') {\n return <TextField {...props} />\n }\n\n const localeCode = locale?.code ?? 'en'\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","path","fields","getData","getDataByPath","locale","isNumberField","setIsNumberField","valueType","setValueType","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,EAAEC,IAAI,EAAE,GAAGF;IAExB,MAAM,EAAEG,MAAM,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAGV;IAE3C,MAAMW,SAASZ;IAEf,MAAM,CAACa,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,MAAMH,QAAQgB,UAAUC,IAAI,CAAC,CAACjB,QAAuBA,MAAMkB,IAAI,KAAKH;gBAEpE,IAAIf,OAAO;oBACT,MAAM,EAAEmB,SAAS,EAAE,GAAGnB;oBACtBO,iBAAiBY,cAAc;gBACjC;YACF;QACF;IACF,GAAG;QAACjB;QAAQE;QAAeD;QAASF;KAAK;IAEzC,mDAAmD;IACnD,IAAIO,cAAc,UAAU;QAC1B,qBAAO,KAAChB;YAAW,GAAGO,KAAK;;IAC7B;IAEA,MAAMqB,aAAaf,QAAQgB,QAAQ;IAEnC,MAAMC,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,IAAId,cAAc,kBAAkB,CAACF,eAAe;QAClD,qBACE,MAACmB;;8BACC,KAACA;8BAAKC,OAAOF;;8BACb,KAACC;oBACCE,OAAO;wBACLC,OAAO;oBACT;8BACD;;;;IAKP;IAEA,OAAO;AACT,EAAC"}
@@ -178,7 +178,7 @@ export const generateFormCollection = (formConfig, collections)=>{
178
178
  name: 'emails',
179
179
  type: 'array',
180
180
  access: {
181
- read: ({ req: { user } })=>!!user
181
+ read: ({ req })=>req.user?.collection === req.payload.config.admin.user
182
182
  },
183
183
  admin: {
184
184
  description: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Config, Field } from 'payload'\n\nimport { deepMergeWithSourceArrays } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\nconst applyUploadCollectionLabels = (args: {\n block: Block\n collections: Config['collections']\n uploadCollections: FormBuilderPluginConfig['uploadCollections']\n}): Block => {\n const { block, collections, uploadCollections } = args\n const collectionsBySlug = new Map(\n (collections || []).map((collection) => [collection.slug, collection]),\n )\n\n for (const field of block.fields) {\n if ('name' in field && field.name === 'uploadCollection' && field.type === 'select') {\n // Replace the default slug labels with the source collection's labels.singular.\n // Select option labels accept strings, locale records and label functions —\n // Payload's admin resolves them at render time via getTranslation.\n field.options = (uploadCollections || []).map((slug) => {\n const singular = collectionsBySlug.get(slug)?.labels?.singular\n return { label: singular ?? slug, value: slug }\n })\n break\n }\n }\n\n return block\n}\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (\n formConfig: FormBuilderPluginConfig,\n collections?: Config['collections'],\n): 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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:urlToRedirectTo'),\n required: true,\n },\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:redirect'),\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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:documentToLinkTo'),\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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:internalLink'),\n value: 'reference',\n },\n {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:customURL'),\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2]!.type !== 'row') {\n redirect.fields[2]!.label = ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:customURL')\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 label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:title'),\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 // Special handling for upload field - factory takes slug list; after it runs,\n // inject resolved collection labels into the uploadCollection select.\n if (fieldKey === 'upload') {\n return applyUploadCollectionLabels({\n block: block(formConfig.uploadCollections || []),\n collections,\n uploadCollections: formConfig.uploadCollections,\n })\n }\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:fields'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:fields'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:field'),\n },\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:submitButton'),\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:chooseConfirmationType'),\n layout: 'horizontal',\n },\n defaultValue: 'message',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:confirmationType'),\n options: [\n {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:message'),\n value: 'message',\n },\n {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:redirect'),\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:confirmationMessage'),\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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:emailsDescription'),\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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:emailTo'),\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:cc'),\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder: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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:replyTo'),\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:emailFrom'),\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:subject'),\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:messageDescription'),\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder: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","applyUploadCollectionLabels","args","block","collections","uploadCollections","collectionsBySlug","Map","map","collection","slug","field","name","type","options","singular","get","labels","label","value","generateFormCollection","formConfig","redirect","admin","condition","_","siblingData","confirmationType","hideGutter","t","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","defaultFields","blocks","Object","entries","fieldKey","fieldConfig","undefined","filter","Boolean","plural","localized","description","access","read","req","user","placeholder","width","style","maxWidth","config","formOverrides","enableRichTextRelationship","useAsTitle"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAInD,SAASC,MAAM,QAAQ,cAAa;AAEpC,MAAMC,8BAA8B,CAACC;IAKnC,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,iBAAiB,EAAE,GAAGH;IAClD,MAAMI,oBAAoB,IAAIC,IAC5B,AAACH,CAAAA,eAAe,EAAE,AAAD,EAAGI,GAAG,CAAC,CAACC,aAAe;YAACA,WAAWC,IAAI;YAAED;SAAW;IAGvE,KAAK,MAAME,SAASR,MAAMH,MAAM,CAAE;QAChC,IAAI,UAAUW,SAASA,MAAMC,IAAI,KAAK,sBAAsBD,MAAME,IAAI,KAAK,UAAU;YACnF,gFAAgF;YAChF,4EAA4E;YAC5E,mEAAmE;YACnEF,MAAMG,OAAO,GAAG,AAACT,CAAAA,qBAAqB,EAAE,AAAD,EAAGG,GAAG,CAAC,CAACE;gBAC7C,MAAMK,WAAWT,kBAAkBU,GAAG,CAACN,OAAOO,QAAQF;gBACtD,OAAO;oBAAEG,OAAOH,YAAYL;oBAAMS,OAAOT;gBAAK;YAChD;YACA;QACF;IACF;IAEA,OAAOP;AACT;AAEA,+CAA+C;A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AW,aAC9EqB,WAAWqC,aAAa,CAAC1D,MAAM,CAAC;YAAEqC;QAAc,KAChDA;IACR;IAEA,OAAOoB;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Config, Field } from 'payload'\n\nimport { deepMergeWithSourceArrays } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\nconst applyUploadCollectionLabels = (args: {\n block: Block\n collections: Config['collections']\n uploadCollections: FormBuilderPluginConfig['uploadCollections']\n}): Block => {\n const { block, collections, uploadCollections } = args\n const collectionsBySlug = new Map(\n (collections || []).map((collection) => [collection.slug, collection]),\n )\n\n for (const field of block.fields) {\n if ('name' in field && field.name === 'uploadCollection' && field.type === 'select') {\n // Replace the default slug labels with the source collection's labels.singular.\n // Select option labels accept strings, locale records and label functions —\n // Payload's admin resolves them at render time via getTranslation.\n field.options = (uploadCollections || []).map((slug) => {\n const singular = collectionsBySlug.get(slug)?.labels?.singular\n return { label: singular ?? slug, value: slug }\n })\n break\n }\n }\n\n return block\n}\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (\n formConfig: FormBuilderPluginConfig,\n collections?: Config['collections'],\n): 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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:urlToRedirectTo'),\n required: true,\n },\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:redirect'),\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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:documentToLinkTo'),\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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:internalLink'),\n value: 'reference',\n },\n {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:customURL'),\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2]!.type !== 'row') {\n redirect.fields[2]!.label = ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:customURL')\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 label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:title'),\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 // Special handling for upload field - factory takes slug list; after it runs,\n // inject resolved collection labels into the uploadCollection select.\n if (fieldKey === 'upload') {\n return applyUploadCollectionLabels({\n block: block(formConfig.uploadCollections || []),\n collections,\n uploadCollections: formConfig.uploadCollections,\n })\n }\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:fields'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:fields'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:field'),\n },\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:submitButton'),\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:chooseConfirmationType'),\n layout: 'horizontal',\n },\n defaultValue: 'message',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:confirmationType'),\n options: [\n {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:message'),\n value: 'message',\n },\n {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:redirect'),\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:confirmationMessage'),\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n access: {\n read: ({ req }) => req.user?.collection === req.payload.config.admin.user,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:emailsDescription'),\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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:emailTo'),\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:cc'),\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder: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: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:replyTo'),\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:emailFrom'),\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:subject'),\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder:messageDescription'),\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-form-builder: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","applyUploadCollectionLabels","args","block","collections","uploadCollections","collectionsBySlug","Map","map","collection","slug","field","name","type","options","singular","get","labels","label","value","generateFormCollection","formConfig","redirect","admin","condition","_","siblingData","confirmationType","hideGutter","t","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","defaultFields","blocks","Object","entries","fieldKey","fieldConfig","undefined","filter","Boolean","plural","localized","description","access","read","req","user","payload","config","placeholder","width","style","maxWidth","formOverrides","enableRichTextRelationship","useAsTitle"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAInD,SAASC,MAAM,QAAQ,cAAa;AAEpC,MAAMC,8BAA8B,CAACC;IAKnC,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,iBAAiB,EAAE,GAAGH;IAClD,MAAMI,oBAAoB,IAAIC,IAC5B,AAACH,CAAAA,eAAe,EAAE,AAAD,EAAGI,GAAG,CAAC,CAACC,aAAe;YAACA,WAAWC,IAAI;YAAED;SAAW;IAGvE,KAAK,MAAME,SAASR,MAAMH,MAAM,CAAE;QAChC,IAAI,UAAUW,SAASA,MAAMC,IAAI,KAAK,sBAAsBD,MAAME,IAAI,KAAK,UAAU;YACnF,gFAAgF;YAChF,4EAA4E;YAC5E,mEAAmE;YACnEF,MAAMG,OAAO,GAAG,AAACT,CAAAA,qBAAqB,EAAE,AAAD,EAAGG,GAAG,CAAC,CAACE;gBAC7C,MAAMK,WAAWT,kBAAkBU,GAAG,CAACN,OAAOO,QAAQF;gBACtD,OAAO;oBAAEG,OAAOH,YAAYL;oBAAMS,OAAOT;gBAAK;YAChD;YACA;QACF;IACF;IAEA,OAAOP;AACT;AAEA,+CAA+C;AAC/C,OAAO,MAAMiB,yBAAyB,CACpCC,YACAjB;IAEA,MAAMkB,WAAkB;QACtBV,MAAM;QACNC,MAAM;QACNU,OAAO;YACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACjEC,YAAY;QACd;QACA5B,QAAQ;YACN;gBACEY,MAAM;gBACNC,MAAM;gBACNK,OAAO,CAAC,EAAEW,CAAC,EAAE,GACX,+DAA+D;oBAC/DA,EAAE;gBACJC,UAAU;YACZ;SACD;QACDZ,OAAO,CAAC,EAAEW,CAAC,EAAE,GACX,+DAA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E,GACX,+DAA+D;gCAC/DA,EAAE;wBACN;wBACA;4BACEjB,MAAM;4BACNC,MAAM;4BACNU,OAAO;gCACLgC,aAAa;gCACbC,OAAO;4BACT;4BACAtC,OAAO,CAAC,EAAEW,CAAC,EAAE,GACX,+DAA+D;gCAC/DA,EAAE;wBACN;qBACD;gBACH;gBACA;oBACEjB,MAAM;oBACNC,MAAM;oBACNuB,cAAc;oBACdlB,OAAO,CAAC,EAAEW,CAAC,EAAE,GACX,+DAA+D;wBAC/DA,EAAE;oBACJkB,WAAW;oBACXjB,UAAU;gBACZ;gBACA;oBACElB,MAAM;oBACNC,MAAM;oBACNU,OAAO;wBACLyB,aAAa,CAAC,EAAEnB,CAAC,EAAE,GACjB,+DAA+D;4BAC/DA,EAAE;oBACN;oBACAX,OAAO,CAAC,EAAEW,CAAC,EAAE,GACX,+DAA+D;wBAC/DA,EAAE;oBACJkB,WAAW;gBACb;aACD;QACH;KACD;IAED,MAAMO,SAA2B;QAC/B,GAAIjC,YAAYsC,iBAAiB,CAAC,CAAC;QACnCjD,MAAMW,YAAYsC,eAAejD,QAAQ;QACzCuC,QAAQ;YACNC,MAAM,IAAM;YACZ,GAAI7B,YAAYsC,eAAeV,UAAU,CAAC,CAAC;QAC7C;QACA1B,OAAO;YACLqC,4BAA4B;YAC5BC,YAAY;YACZ,GAAIxC,YAAYsC,eAAepC,SAAS,CAAC,CAAC;QAC5C;QACAvB,QACEqB,YAAYsC,eAAe3D,UAAU,OAAOqB,YAAYsC,eAAe3D,WAAW,aAC9EqB,WAAWsC,aAAa,CAAC3D,MAAM,CAAC;YAAEqC;QAAc,KAChDA;IACR;IAEA,OAAOiB;AACT,EAAC"}
@@ -21,6 +21,7 @@ export const LinkHTMLConverter = {
21
21
  return `<a href="${safeHref}"${node.fields.newTab ? ' rel="noopener noreferrer" target="_blank"' : ''}>${childrenText}</a>`;
22
22
  },
23
23
  nodeTypes: [
24
+ 'autolink',
24
25
  'link'
25
26
  ]
26
27
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utilities/lexical/converters/link.ts"],"sourcesContent":["import escapeHTML from 'escape-html'\nimport { sanitizeUrl } from 'payload/shared'\n\nimport type { HTMLConverter } from '../types.js'\n\nimport { replaceDoubleCurlys } from '../../replaceDoubleCurlys.js'\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const LinkHTMLConverter: HTMLConverter<any> = {\n async converter({ converters, node, parent, submissionData }) {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n submissionData,\n })\n\n let href: string =\n node.fields.linkType === 'custom'\n ? (node.fields.url ?? '')\n : (node.fields.doc?.value?.id ?? '')\n\n if (submissionData) {\n href = replaceDoubleCurlys(href, submissionData)\n }\n\n const safeHref = escapeHTML(sanitizeUrl(href))\n\n return `<a href=\"${safeHref}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${childrenText}</a>`\n },\n nodeTypes: ['link'],\n}\n"],"names":["escapeHTML","sanitizeUrl","replaceDoubleCurlys","convertLexicalNodesToHTML","LinkHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","href","fields","linkType","url","doc","value","id","safeHref","newTab","nodeTypes"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,WAAW,QAAQ,iBAAgB;AAI5C,SAASC,mBAAmB,QAAQ,+BAA8B;AAClE,SAASC,yBAAyB,QAAQ,yBAAwB;AAElE,OAAO,MAAMC,oBAAwC;IACnD,MAAMC,WAAU,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,cAAc,EAAE;QAC1D,MAAMC,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;YACAC;QACF;QAEA,IAAII,OACFN,KAAKO,MAAM,CAACC,QAAQ,KAAK,WACpBR,KAAKO,MAAM,CAACE,GAAG,IAAI,KACnBT,KAAKO,MAAM,CAACG,GAAG,EAAEC,OAAOC,MAAM;QAErC,IAAIV,gBAAgB;YAClBI,OAAOX,oBAAoBW,MAAMJ;QACnC;QAEA,MAAMW,WAAWpB,WAAWC,YAAYY;QAExC,OAAO,CAAC,SAAS,EAAEO,SAAS,CAAC,EAAEb,KAAKO,MAAM,CAACO,MAAM,GAAG,+CAA+C,GAAG,CAAC,EAAEX,aAAa,IAAI,CAAC;IAC7H;IACAY,WAAW;QAAC;KAAO;AACrB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/utilities/lexical/converters/link.ts"],"sourcesContent":["import escapeHTML from 'escape-html'\nimport { sanitizeUrl } from 'payload/shared'\n\nimport type { HTMLConverter } from '../types.js'\n\nimport { replaceDoubleCurlys } from '../../replaceDoubleCurlys.js'\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const LinkHTMLConverter: HTMLConverter<any> = {\n async converter({ converters, node, parent, submissionData }) {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n submissionData,\n })\n\n let href: string =\n node.fields.linkType === 'custom'\n ? (node.fields.url ?? '')\n : (node.fields.doc?.value?.id ?? '')\n\n if (submissionData) {\n href = replaceDoubleCurlys(href, submissionData)\n }\n\n const safeHref = escapeHTML(sanitizeUrl(href))\n\n return `<a href=\"${safeHref}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${childrenText}</a>`\n },\n nodeTypes: ['autolink', 'link'],\n}\n"],"names":["escapeHTML","sanitizeUrl","replaceDoubleCurlys","convertLexicalNodesToHTML","LinkHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","href","fields","linkType","url","doc","value","id","safeHref","newTab","nodeTypes"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,WAAW,QAAQ,iBAAgB;AAI5C,SAASC,mBAAmB,QAAQ,+BAA8B;AAClE,SAASC,yBAAyB,QAAQ,yBAAwB;AAElE,OAAO,MAAMC,oBAAwC;IACnD,MAAMC,WAAU,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,cAAc,EAAE;QAC1D,MAAMC,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;YACAC;QACF;QAEA,IAAII,OACFN,KAAKO,MAAM,CAACC,QAAQ,KAAK,WACpBR,KAAKO,MAAM,CAACE,GAAG,IAAI,KACnBT,KAAKO,MAAM,CAACG,GAAG,EAAEC,OAAOC,MAAM;QAErC,IAAIV,gBAAgB;YAClBI,OAAOX,oBAAoBW,MAAMJ;QACnC;QAEA,MAAMW,WAAWpB,WAAWC,YAAYY;QAExC,OAAO,CAAC,SAAS,EAAEO,SAAS,CAAC,EAAEb,KAAKO,MAAM,CAACO,MAAM,GAAG,+CAA+C,GAAG,CAAC,EAAEX,aAAa,IAAI,CAAC;IAC7H;IACAY,WAAW;QAAC;QAAY;KAAO;AACjC,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-form-builder",
3
- "version": "4.0.0-internal.cea8867",
3
+ "version": "4.0.0-internal.d21c039",
4
4
  "description": "Form builder plugin for Payload CMS",
5
5
  "keywords": [
6
6
  "payload",
@@ -63,22 +63,22 @@
63
63
  ],
64
64
  "dependencies": {
65
65
  "escape-html": "^1.0.3",
66
- "@payloadcms/translations": "4.0.0-internal.cea8867",
67
- "@payloadcms/ui": "4.0.0-internal.cea8867"
66
+ "@payloadcms/ui": "4.0.0-internal.d21c039",
67
+ "@payloadcms/translations": "4.0.0-internal.d21c039"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/escape-html": "^1.0.4",
71
71
  "@types/react": "19.2.14",
72
72
  "@types/react-dom": "19.2.3",
73
- "copyfiles": "^2.4.1",
73
+ "copyfiles": "2.4.1",
74
74
  "cross-env": "10.1.0",
75
- "payload": "4.0.0-internal.cea8867",
76
- "@payloadcms/eslint-config": "3.28.0"
75
+ "@payloadcms/eslint-config": "3.28.0",
76
+ "payload": "4.0.0-internal.d21c039"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
80
80
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
81
- "payload": "4.0.0-internal.cea8867"
81
+ "payload": "4.0.0-internal.d21c039"
82
82
  },
83
83
  "publishConfig": {
84
84
  "registry": "https://registry.npmjs.org/"