@payloadcms/plugin-form-builder 3.0.0-canary.ef0a8d0 → 3.0.0-canary.f13d413

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.
@@ -1,4 +1,6 @@
1
- import type { TextFieldProps } from '@payloadcms/ui';
1
+ import type { SelectFieldValidation, TextFieldProps } from 'payload';
2
2
  import React from 'react';
3
- export declare const DynamicFieldSelector: React.FC<TextFieldProps>;
3
+ export declare const DynamicFieldSelector: React.FC<{
4
+ validate: SelectFieldValidation;
5
+ } & TextFieldProps>;
4
6
  //# sourceMappingURL=DynamicFieldSelector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicFieldSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGpD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAIlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA8BzD,CAAA"}
1
+ {"version":3,"file":"DynamicFieldSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGpE,OAAO,KAA8B,MAAM,OAAO,CAAA;AAIlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC;IAAE,QAAQ,EAAE,qBAAqB,CAAA;CAAE,GAAG,cAAc,CA6BrD,CAAA"}
@@ -24,8 +24,6 @@ export const DynamicFieldSelector = (props)=>{
24
24
  fields,
25
25
  getDataByPath
26
26
  ]);
27
- // TODO: label from config is Record<string, string> | false | string
28
- // but the FormFieldBase type has only label?: string, changing FormFieldBase breaks other ui components
29
27
  return /*#__PURE__*/ _jsx(SelectField, {
30
28
  ...props,
31
29
  options: options
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { TextFieldProps } from '@payloadcms/ui'\n\nimport { SelectField, useForm } from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { SelectFieldOption } from '../../types.js'\n\nexport const DynamicFieldSelector: React.FC<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 <SelectField {...props} options={options} />\n}\n"],"names":["SelectField","useForm","React","useEffect","useState","DynamicFieldSelector","props","fields","getDataByPath","options","setOptions","allNonPaymentFields","map","block","name","blockType","label","value","filter","Boolean"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,OAAO,QAAQ,iBAAgB;AACrD,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,KAACR;QAAa,GAAGM,KAAK;QAAEG,SAASA;;AAC1C,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { SelectFieldValidation, TextFieldProps } from 'payload'\n\nimport { SelectField, useForm } from '@payloadcms/ui'\nimport React, { useEffect, useState } from 'react'\n\nimport type { SelectFieldOption } from '../../types.js'\n\nexport const DynamicFieldSelector: React.FC<\n { validate: SelectFieldValidation } & TextFieldProps\n> = (props) => {\n const { fields, getDataByPath } = useForm()\n\n const [options, setOptions] = useState<SelectFieldOption[]>([])\n\n useEffect(() => {\n const fields: any[] = getDataByPath('fields')\n\n if (fields) {\n const allNonPaymentFields = fields\n .map((block): 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 return <SelectField {...props} options={options} />\n}\n"],"names":["SelectField","useForm","React","useEffect","useState","DynamicFieldSelector","props","fields","getDataByPath","options","setOptions","allNonPaymentFields","map","block","name","blockType","label","value","filter","Boolean"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,OAAO,QAAQ,iBAAgB;AACrD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAIlD,OAAO,MAAMC,uBAET,CAACC;IACH,MAAM,EAAEC,MAAM,EAAEC,aAAa,EAAE,GAAGP;IAElC,MAAM,CAACQ,SAASC,WAAW,GAAGN,SAA8B,EAAE;IAE9DD,UAAU;QACR,MAAMI,SAAgBC,cAAc;QAEpC,IAAID,QAAQ;YACV,MAAMI,sBAAsBJ,OACzBK,GAAG,CAAC,CAACC;gBACJ,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGH;gBAEnC,IAAIE,cAAc,WAAW;oBAC3B,OAAO;wBACLC;wBACAC,OAAOH;oBACT;gBACF;gBAEA,OAAO;YACT,GACCI,MAAM,CAACC;YACVT,WAAWC;QACb;IACF,GAAG;QAACJ;QAAQC;KAAc;IAE1B,qBAAO,KAACR;QAAa,GAAGM,KAAK;QAAEG,SAASA;;AAC1C,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { TextFieldProps } from '@payloadcms/ui';
1
+ import type { TextFieldProps } from 'payload';
2
2
  import React from 'react';
3
3
  export declare const DynamicPriceSelector: React.FC<TextFieldProps>;
4
4
  //# sourceMappingURL=DynamicPriceSelector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicPriceSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIpD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAOlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA2DzD,CAAA"}
1
+ {"version":3,"file":"DynamicPriceSelector.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAQ,cAAc,EAAE,MAAM,SAAS,CAAA;AAGnD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAOlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA2DzD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/Forms/DynamicPriceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { TextFieldProps } from '@payloadcms/ui'\nimport type { Data } 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: 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 <TextField {...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":["TextField","useLocale","useWatchForm","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"],"mappings":"AAAA;;AAKA,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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ceSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { Data, TextFieldProps } 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: 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 <TextField {...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":["TextField","useLocale","useWatchForm","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"],"mappings":"AAAA;;AAIA,SAASA,SAAS,EAAEC,SAAS,EAAEC,YAAY,QAAQ,iBAAgB;AACn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C,OAAOF;;8BACb,KAACC;oBACCE,OAAO;wBACLC,OAAO;oBACT;8BACD;;;;IAKP;IAEA,OAAO;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAe,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAK1E,eAAO,MAAM,sBAAsB,eAAgB,uBAAuB,KAAG,gBAqO5E,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAK7D,eAAO,MAAM,sBAAsB,eAAgB,uBAAuB,KAAG,gBAuO5E,CAAA"}
@@ -1,4 +1,4 @@
1
- import merge from 'deepmerge';
1
+ import { deepMergeWithSourceArrays } from 'payload';
2
2
  import { fields } from './fields.js';
3
3
  // all settings can be overridden by the config
4
4
  export const generateFormCollection = (formConfig)=>{
@@ -70,9 +70,7 @@ export const generateFormCollection = (formConfig)=>{
70
70
  return fieldConfig;
71
71
  }
72
72
  if (typeof block === 'object' && typeof fieldConfig === 'object') {
73
- return merge(block, fieldConfig, {
74
- arrayMerge: (_, sourceArray)=>sourceArray
75
- });
73
+ return deepMergeWithSourceArrays(block, fieldConfig);
76
74
  }
77
75
  if (typeof block === 'function') {
78
76
  return block(fieldConfig);
@@ -139,7 +137,9 @@ export const generateFormCollection = (formConfig)=>{
139
137
  name: 'cc',
140
138
  type: 'text',
141
139
  admin: {
142
- width: '50%'
140
+ style: {
141
+ maxWidth: '50%'
142
+ }
143
143
  },
144
144
  label: 'CC'
145
145
  },
@@ -147,7 +147,9 @@ export const generateFormCollection = (formConfig)=>{
147
147
  name: 'bcc',
148
148
  type: 'text',
149
149
  admin: {
150
- width: '50%'
150
+ style: {
151
+ maxWidth: '50%'
152
+ }
151
153
  },
152
154
  label: 'BCC'
153
155
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload'\n\nimport merge from 'deepmerge'\n\nimport type { FieldConfig, FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: FormBuilderPluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') redirect.fields[2].label = 'Custom URL'\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'fields',\n type: 'blocks',\n blocks: Object.entries(formConfig?.fields || {})\n .map(([fieldKey, fieldConfig]) => {\n // let the config enable/disable fields with either boolean values or objects\n if (fieldConfig !== false) {\n const block = fields[fieldKey]\n\n if (block === undefined && typeof fieldConfig === 'object') {\n return fieldConfig\n }\n\n if (typeof block === 'object' && typeof fieldConfig === 'object') {\n return merge<FieldConfig>(block, fieldConfig, {\n arrayMerge: (_, sourceArray) => sourceArray,\n })\n }\n\n if (typeof block === 'function') {\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description:\n 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',\n layout: 'horizontal',\n },\n defaultValue: 'message',\n options: [\n {\n label: 'Message',\n value: 'message',\n },\n {\n label: 'Redirect',\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n admin: {\n description:\n \"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}.\",\n },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'emailTo',\n type: 'text',\n admin: {\n placeholder: '\"Email Sender\" <sender@email.com>',\n width: '100%',\n },\n label: 'Email To',\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ]\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields:\n formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function'\n ? formConfig.formOverrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return config\n}\n"],"names":["merge","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","defaultFields","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","arrayMerge","sourceArray","filter","Boolean","localized","description","placeholder","width","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle"],"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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AAC;QAC5C;QACAN,QACEE,YAAYsC,eAAexC,UAAU,OAAOE,YAAYsC,eAAexC,WAAW,aAC9EE,WAAWsC,aAAa,CAACxC,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOiB;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload'\n\nimport { deepMergeWithSourceArrays } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: FormBuilderPluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') redirect.fields[2].label = 'Custom URL'\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'fields',\n type: 'blocks',\n blocks: Object.entries(formConfig?.fields || {})\n .map(([fieldKey, fieldConfig]) => {\n // let the config enable/disable fields with either boolean values or objects\n if (fieldConfig !== false) {\n const block = fields[fieldKey]\n\n if (block === undefined && typeof fieldConfig === 'object') {\n return fieldConfig\n }\n\n if (typeof block === 'object' && typeof fieldConfig === 'object') {\n return deepMergeWithSourceArrays(block, fieldConfig)\n }\n\n if (typeof block === 'function') {\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description:\n 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',\n layout: 'horizontal',\n },\n defaultValue: 'message',\n options: [\n {\n label: 'Message',\n value: 'message',\n },\n {\n label: 'Redirect',\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n 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 style: {\n maxWidth: '50%',\n },\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ]\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields:\n formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function'\n ? formConfig.formOverrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return config\n}\n"],"names":["deepMergeWithSourceArrays","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","defaultFields","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","filter","Boolean","localized","description","placeholder","width","style","maxWidth","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAInD,SAASC,MAAM,QAAQ,cAAa;AAEpC,+CAA+C;AAC/C,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAMC,WAAkB;QACtBC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACjEC,YAAY;QACd;QACAX,QAAQ;YACN;gBACEI,MAAM;gBACNC,MAAM;gBACNO,OAAO;gBACPC,UAAU;YACZ;SACD;IACH;IAEA,IAAIX,WAAWY,qBAAqB,EAAE;QACpCX,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaJ,SAAS;YACvD;YACAO,OAAO;YACPI,UAAU;YACVC,YAAYf,WAAWY,qBAAqB;YAC5CD,UAAU;QACZ;QAEAV,SAASH,MAAM,CAACe,OA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,GAAI3C,YAAYsC,eAAelC,SAAS,CAAC,CAAC;QAC5C;QACAN,QACEE,YAAYsC,eAAexC,UAAU,OAAOE,YAAYsC,eAAexC,WAAW,aAC9EE,WAAWsC,aAAa,CAACxC,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOiB;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-form-builder",
3
- "version": "3.0.0-canary.ef0a8d0",
3
+ "version": "3.0.0-canary.f13d413",
4
4
  "description": "Form builder plugin for Payload CMS",
5
5
  "keywords": [
6
6
  "payload",
@@ -39,9 +39,8 @@
39
39
  "dist"
40
40
  ],
41
41
  "dependencies": {
42
- "deepmerge": "^4.2.2",
43
42
  "escape-html": "^1.0.3",
44
- "@payloadcms/ui": "3.0.0-canary.ef0a8d0"
43
+ "@payloadcms/ui": "3.0.0-canary.f13d413"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@types/escape-html": "^1.0.4",
@@ -50,13 +49,13 @@
50
49
  "@types/react-dom": "npm:types-react-dom@19.0.0-rc.0",
51
50
  "copyfiles": "^2.4.1",
52
51
  "cross-env": "^7.0.3",
53
- "payload": "3.0.0-canary.ef0a8d0",
54
- "@payloadcms/eslint-config": "3.0.0-beta.59"
52
+ "@payloadcms/eslint-config": "3.0.0-beta.59",
53
+ "payload": "3.0.0-canary.f13d413"
55
54
  },
56
55
  "peerDependencies": {
57
- "react": "^19.0.0 || ^19.0.0-rc-6230622a1a-20240610",
58
- "react-dom": "^19.0.0 || ^19.0.0-rc-6230622a1a-20240610",
59
- "payload": "3.0.0-canary.ef0a8d0"
56
+ "react": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
57
+ "react-dom": "^19.0.0 || ^19.0.0-rc-06d0b89e-20240801",
58
+ "payload": "3.0.0-canary.f13d413"
60
59
  },
61
60
  "publishConfig": {
62
61
  "registry": "https://registry.npmjs.org/"