@payloadcms/plugin-form-builder 3.0.0-canary.92e4997 → 3.0.0-canary.95fcd13

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.
Files changed (79) hide show
  1. package/dist/collections/FormSubmissions/hooks/createCharge.d.ts +3 -0
  2. package/dist/collections/FormSubmissions/hooks/createCharge.d.ts.map +1 -0
  3. package/dist/collections/FormSubmissions/hooks/createCharge.js.map +1 -1
  4. package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts +3 -0
  5. package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts.map +1 -0
  6. package/dist/collections/FormSubmissions/hooks/sendEmail.js.map +1 -1
  7. package/dist/collections/FormSubmissions/index.d.ts +4 -0
  8. package/dist/collections/FormSubmissions/index.d.ts.map +1 -0
  9. package/dist/collections/FormSubmissions/index.js +62 -60
  10. package/dist/collections/FormSubmissions/index.js.map +1 -1
  11. package/dist/collections/Forms/DynamicFieldSelector.d.ts +4 -0
  12. package/dist/collections/Forms/DynamicFieldSelector.d.ts.map +1 -0
  13. package/dist/collections/Forms/DynamicFieldSelector.js +3 -5
  14. package/dist/collections/Forms/DynamicFieldSelector.js.map +1 -1
  15. package/dist/collections/Forms/DynamicPriceSelector.d.ts +4 -0
  16. package/dist/collections/Forms/DynamicPriceSelector.d.ts.map +1 -0
  17. package/dist/collections/Forms/DynamicPriceSelector.js +18 -9
  18. package/dist/collections/Forms/DynamicPriceSelector.js.map +1 -1
  19. package/dist/collections/Forms/fields.d.ts +6 -0
  20. package/dist/collections/Forms/fields.d.ts.map +1 -0
  21. package/dist/collections/Forms/fields.js +0 -1
  22. package/dist/collections/Forms/fields.js.map +1 -1
  23. package/dist/collections/Forms/index.d.ts +4 -0
  24. package/dist/collections/Forms/index.d.ts.map +1 -0
  25. package/dist/collections/Forms/index.js +149 -145
  26. package/dist/collections/Forms/index.js.map +1 -1
  27. package/dist/exports/types.d.ts +2 -0
  28. package/dist/exports/types.d.ts.map +1 -0
  29. package/dist/exports/types.js.map +1 -1
  30. package/dist/index.d.ts +6 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +0 -14
  33. package/dist/index.js.map +1 -1
  34. package/dist/types.d.ts +182 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/types.js.map +1 -1
  37. package/dist/utilities/getPaymentTotal.d.ts +5 -0
  38. package/dist/utilities/getPaymentTotal.d.ts.map +1 -0
  39. package/dist/utilities/getPaymentTotal.js.map +1 -1
  40. package/dist/utilities/lexical/converters/heading.d.ts +3 -0
  41. package/dist/utilities/lexical/converters/heading.d.ts.map +1 -0
  42. package/dist/utilities/lexical/converters/heading.js.map +1 -1
  43. package/dist/utilities/lexical/converters/linebreak.d.ts +3 -0
  44. package/dist/utilities/lexical/converters/linebreak.d.ts.map +1 -0
  45. package/dist/utilities/lexical/converters/linebreak.js.map +1 -1
  46. package/dist/utilities/lexical/converters/link.d.ts +3 -0
  47. package/dist/utilities/lexical/converters/link.d.ts.map +1 -0
  48. package/dist/utilities/lexical/converters/link.js.map +1 -1
  49. package/dist/utilities/lexical/converters/list.d.ts +4 -0
  50. package/dist/utilities/lexical/converters/list.d.ts.map +1 -0
  51. package/dist/utilities/lexical/converters/list.js.map +1 -1
  52. package/dist/utilities/lexical/converters/paragraph.d.ts +3 -0
  53. package/dist/utilities/lexical/converters/paragraph.d.ts.map +1 -0
  54. package/dist/utilities/lexical/converters/paragraph.js.map +1 -1
  55. package/dist/utilities/lexical/converters/quote.d.ts +3 -0
  56. package/dist/utilities/lexical/converters/quote.d.ts.map +1 -0
  57. package/dist/utilities/lexical/converters/quote.js.map +1 -1
  58. package/dist/utilities/lexical/converters/text.d.ts +3 -0
  59. package/dist/utilities/lexical/converters/text.d.ts.map +1 -0
  60. package/dist/utilities/lexical/converters/text.js.map +1 -1
  61. package/dist/utilities/lexical/defaultConverters.d.ts +3 -0
  62. package/dist/utilities/lexical/defaultConverters.d.ts.map +1 -0
  63. package/dist/utilities/lexical/defaultConverters.js.map +1 -1
  64. package/dist/utilities/lexical/nodeFormat.d.ts +39 -0
  65. package/dist/utilities/lexical/nodeFormat.d.ts.map +1 -0
  66. package/dist/utilities/lexical/nodeFormat.js.map +1 -1
  67. package/dist/utilities/lexical/serializeLexical.d.ts +9 -0
  68. package/dist/utilities/lexical/serializeLexical.d.ts.map +1 -0
  69. package/dist/utilities/lexical/serializeLexical.js.map +1 -1
  70. package/dist/utilities/lexical/types.d.ts +14 -0
  71. package/dist/utilities/lexical/types.d.ts.map +1 -0
  72. package/dist/utilities/lexical/types.js.map +1 -1
  73. package/dist/utilities/replaceDoubleCurlys.d.ts +8 -0
  74. package/dist/utilities/replaceDoubleCurlys.d.ts.map +1 -0
  75. package/dist/utilities/replaceDoubleCurlys.js.map +1 -1
  76. package/dist/utilities/slate/serializeSlate.d.ts +12 -0
  77. package/dist/utilities/slate/serializeSlate.d.ts.map +1 -0
  78. package/dist/utilities/slate/serializeSlate.js.map +1 -1
  79. package/package.json +21 -18
@@ -0,0 +1,3 @@
1
+ import type { FormBuilderPluginConfig } from '../../../types.js';
2
+ export declare const createCharge: (beforeChangeData: any, formConfig: FormBuilderPluginConfig) => Promise<any>;
3
+ //# sourceMappingURL=createCharge.d.ts.map
@@ -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,OAAO,CAAC,GAAG,CAeb,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/createCharge.ts"],"sourcesContent":["import type { FormBuilderPluginConfig } from '../../../types.js'\n\nexport const createCharge = async (\n beforeChangeData: any,\n formConfig: FormBuilderPluginConfig,\n): Promise<any> => {\n const { data, operation } = beforeChangeData\n\n let dataWithPaymentDetails = data\n\n if (operation === 'create') {\n const { handlePayment } = formConfig || {}\n\n if (typeof handlePayment === 'function') {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n dataWithPaymentDetails = await handlePayment(beforeChangeData)\n }\n }\n\n return dataWithPaymentDetails\n}\n"],"names":["createCharge","beforeChangeData","formConfig","data","operation","dataWithPaymentDetails","handlePayment"],"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"}
1
+ {"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/createCharge.ts"],"sourcesContent":["import type { FormBuilderPluginConfig } from '../../../types.js'\n\nexport const createCharge = async (\n beforeChangeData: any,\n formConfig: FormBuilderPluginConfig,\n): Promise<any> => {\n const { data, operation } = beforeChangeData\n\n let dataWithPaymentDetails = data\n\n if (operation === 'create') {\n const { handlePayment } = formConfig || {}\n\n if (typeof handlePayment === 'function') {\n // eslint-disable-next-line @typescript-eslint/await-thenable\n dataWithPaymentDetails = await handlePayment(beforeChangeData)\n }\n }\n\n return dataWithPaymentDetails\n}\n"],"names":["createCharge","beforeChangeData","formConfig","data","operation","dataWithPaymentDetails","handlePayment"],"mappings":"AAEA,OAAO,MAAMA,eAAe,OAC1BC,kBACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAE,GAAGH;IAE5B,IAAII,yBAAyBF;IAE7B,IAAIC,cAAc,UAAU;QAC1B,MAAM,EAAEE,aAAa,EAAE,GAAGJ,cAAc,CAAC;QAEzC,IAAI,OAAOI,kBAAkB,YAAY;YACvC,6DAA6D;YAC7DD,yBAAyB,MAAMC,cAAcL;QAC/C;IACF;IAEA,OAAOI;AACT,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FormBuilderPluginConfig } from '../../../types.js';
2
+ export declare const sendEmail: (beforeChangeData: any, formConfig: FormBuilderPluginConfig) => Promise<any>;
3
+ //# sourceMappingURL=sendEmail.d.ts.map
@@ -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,OAAO,CAAC,GAAG,CA6Fb,CAAA"}
@@ -1 +1 @@
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","m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AUA;oBAElE,MAAMS,oBAAoBH,YACtB,MAAMxC,iBAAiBkC,SAASnB,kBAChCb,eAAegC,SAASnB;oBAE5B,OAAO;wBACLa;wBACAE;wBACAS;wBACAK,MAAM,CAAC,KAAK,EAAED,kBAAkB,MAAM,CAAC;wBACvCR;wBACAE,SAASpC,oBAAoBoC,SAAStB;wBACtCuB;oBACF;gBACF;gBAGF,IAAIO,eAAetB;gBAEnB,IAAI,OAAOP,gBAAgB,YAAY;oBACrC6B,eAAe,MAAM7B,YAAYO;gBACnC;gBAEA,qEAAqE;gBAErE,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"}
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"],"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,GAAGR;QAEJ,MAAM,EAAES,MAAMC,MAAM,EAAEC,cAAc,EAAE,GAAGT,QAAQ,CAAC;QAElD,MAAM,EAAEU,WAAW,EAAEC,aAAa,EAAE,GAAGZ,cAAc,CAAC;QAEtD,IAAI;YACF,MAAMQ,OAAO,MAAMD,QAAQM,QAAQ,CAAC;gBAClCT,IAAIK;gBACJK,YAAYF,eAAeG,QAAQ;gBACnCT;gBACAH;YACF;YAEA,MAAM,EAAEa,MAAM,EAAE,GAAGR;YAEnB,IAAIQ,UAAUA,OAAOC,MAAM,EAAE;gBAC3B,MAAMC,kBAAoC,MAAMC,QAAQC,GAAG,CACzDJ,OAAOK,GAAG,CAAC,OAAOC;oBAChB,MAAM,EACJC,KAAKC,QAAQ,EACbC,IAAIC,OAAO,EACXC,SAAS,EACTC,OAAO,EACPC,OAAO,EACPC,SA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QoC,MAAM,CAACC,KAAK,CAAC;gBAAEF,KAAKM;YAAI;QAClC;IACF;IAEA,OAAO/C;AACT,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CollectionConfig } from 'payload';
2
+ import type { FormBuilderPluginConfig } from '../../types.js';
3
+ export declare const generateSubmissionCollection: (formConfig: FormBuilderPluginConfig) => CollectionConfig;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/FormSubmissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAM7D,eAAO,MAAM,4BAA4B,eAC3B,uBAAuB,KAClC,gBA6JF,CAAA"}
@@ -3,6 +3,65 @@ import { sendEmail } from './hooks/sendEmail.js';
3
3
  // all settings can be overridden by the config
4
4
  export const generateSubmissionCollection = (formConfig)=>{
5
5
  const formSlug = formConfig?.formOverrides?.slug || 'forms';
6
+ const defaultFields = [
7
+ {
8
+ name: 'form',
9
+ type: 'relationship',
10
+ admin: {
11
+ readOnly: true
12
+ },
13
+ relationTo: formSlug,
14
+ required: true,
15
+ validate: async (value, { req: { payload }, req })=>{
16
+ /* Don't run in the client side */ if (!payload) return true;
17
+ if (payload) {
18
+ let _existingForm;
19
+ try {
20
+ _existingForm = await payload.findByID({
21
+ id: value,
22
+ collection: formSlug,
23
+ req
24
+ });
25
+ return true;
26
+ } catch (error) {
27
+ return 'Cannot create this submission because this form does not exist.';
28
+ }
29
+ }
30
+ }
31
+ },
32
+ {
33
+ name: 'submissionData',
34
+ type: 'array',
35
+ admin: {
36
+ readOnly: true
37
+ },
38
+ fields: [
39
+ {
40
+ name: 'field',
41
+ type: 'text',
42
+ required: true
43
+ },
44
+ {
45
+ name: 'value',
46
+ type: 'text',
47
+ required: true,
48
+ validate: (value)=>{
49
+ // TODO:
50
+ // create a validation function that dynamically
51
+ // relies on the field type and its options as configured.
52
+ // How to access sibling data from this field?
53
+ // Need the `name` of the field in order to validate it.
54
+ // Might not be possible to use this validation function.
55
+ // Instead, might need to do all validation in a `beforeValidate` collection hook.
56
+ if (typeof value !== 'undefined') {
57
+ return true;
58
+ }
59
+ return 'This field is required.';
60
+ }
61
+ }
62
+ ]
63
+ }
64
+ ];
6
65
  const newConfig = {
7
66
  ...formConfig?.formSubmissionOverrides || {},
8
67
  slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',
@@ -16,66 +75,9 @@ export const generateSubmissionCollection = (formConfig)=>{
16
75
  ...formConfig?.formSubmissionOverrides?.admin || {},
17
76
  enableRichTextRelationship: false
18
77
  },
19
- fields: [
20
- {
21
- name: 'form',
22
- type: 'relationship',
23
- admin: {
24
- readOnly: true
25
- },
26
- relationTo: formSlug,
27
- required: true,
28
- validate: async (value, { req: { payload }, req })=>{
29
- /* Don't run in the client side */ if (!payload) return true;
30
- if (payload) {
31
- let _existingForm;
32
- try {
33
- _existingForm = await payload.findByID({
34
- id: value,
35
- collection: formSlug,
36
- req
37
- });
38
- return true;
39
- } catch (error) {
40
- return 'Cannot create this submission because this form does not exist.';
41
- }
42
- }
43
- }
44
- },
45
- {
46
- name: 'submissionData',
47
- type: 'array',
48
- admin: {
49
- readOnly: true
50
- },
51
- fields: [
52
- {
53
- name: 'field',
54
- type: 'text',
55
- required: true
56
- },
57
- {
58
- name: 'value',
59
- type: 'text',
60
- required: true,
61
- validate: (value)=>{
62
- // TODO:
63
- // create a validation function that dynamically
64
- // relies on the field type and its options as configured.
65
- // How to access sibling data from this field?
66
- // Need the `name` of the field in order to validate it.
67
- // Might not be possible to use this validation function.
68
- // Instead, might need to do all validation in a `beforeValidate` collection hook.
69
- if (typeof value !== 'undefined') {
70
- return true;
71
- }
72
- return 'This field is required.';
73
- }
74
- }
75
- ]
76
- },
77
- ...formConfig?.formSubmissionOverrides?.fields || []
78
- ],
78
+ fields: formConfig?.formSubmissionOverrides?.fields && typeof formConfig?.formSubmissionOverrides?.fields === 'function' ? formConfig.formSubmissionOverrides.fields({
79
+ defaultFields
80
+ }) : defaultFields,
79
81
  hooks: {
80
82
  ...formConfig?.formSubmissionOverrides?.hooks || {},
81
83
  beforeChange: [
@@ -1 +1 @@
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,SAASA,YAAY,QAAQ,0BAAyB;AACtD,SAASC,SAAS,QAAQ,uBAAsB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AAI,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"}
1
+ {"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { createCharge } from './hooks/createCharge.js'\nimport { sendEmail } from './hooks/sendEmail.js'\n\n// all settings can be overridden by the config\nexport const generateSubmissionCollection = (\n formConfig: FormBuilderPluginConfig,\n): CollectionConfig => {\n const formSlug = formConfig?.formOverrides?.slug || 'forms'\n\n const defaultFields: Field[] = [\n {\n name: 'form',\n type: 'relationship',\n admin: {\n readOnly: true,\n },\n relationTo: formSlug,\n required: true,\n validate: async (value, { req: { payload }, req }) => {\n /* Don't run in the client side */\n if (!payload) return true\n\n if (payload) {\n let _existingForm\n\n try {\n _existingForm = await payload.findByID({\n id: value,\n collection: formSlug,\n req,\n })\n\n return true\n } catch (error) {\n return 'Cannot create this submission because this form does not exist.'\n }\n }\n },\n },\n {\n name: 'submissionData',\n type: 'array',\n admin: {\n readOnly: true,\n },\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n required: true,\n validate: (value: unknown) => {\n // TODO:\n // create a validation function that dynamically\n // relies on the field type and its options as configured.\n\n // How to access sibling data from this field?\n // Need the `name` of the field in order to validate it.\n\n // Might not be possible to use this validation function.\n // Instead, might need to do all validation in a `beforeValidate` collection hook.\n\n if (typeof value !== 'undefined') {\n return true\n }\n\n return 'This field is required.'\n },\n },\n ],\n },\n ]\n\n const newConfig: CollectionConfig = {\n ...(formConfig?.formSubmissionOverrides || {}),\n slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',\n access: {\n create: () => true,\n read: ({ req: { user } }) => !!user, // logged-in users,\n update: () => false,\n ...(formConfig?.formSubmissionOverrides?.access || {}),\n },\n admin: {\n ...(formConfig?.formSubmissionOverrides?.admin || {}),\n enableRichTextRelationship: false,\n },\n fields:\n formConfig?.formSubmissionOverrides?.fields &&\n typeof formConfig?.formSubmissionOverrides?.fields === 'function'\n ? formConfig.formSubmissionOverrides.fields({ defaultFields })\n : defaultFields,\n hooks: {\n ...(formConfig?.formSubmissionOverrides?.hooks || {}),\n beforeChange: [\n (data) => createCharge(data, formConfig),\n (data) => sendEmail(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []),\n ],\n },\n }\n\n const paymentFieldConfig = formConfig?.fields?.payment\n\n if (paymentFieldConfig) {\n newConfig.fields.push({\n name: 'payment',\n type: 'group',\n admin: {\n readOnly: true,\n },\n fields: [\n {\n name: 'field',\n type: 'text',\n label: 'Field',\n },\n {\n name: 'status',\n type: 'text',\n label: 'Status',\n },\n {\n name: 'amount',\n type: 'number',\n admin: {\n description: 'Amount in cents',\n },\n },\n {\n name: 'paymentProcessor',\n type: 'text',\n },\n {\n name: 'creditCard',\n type: 'group',\n fields: [\n {\n name: 'token',\n type: 'text',\n label: 'token',\n },\n {\n name: 'brand',\n type: 'text',\n label: 'Brand',\n },\n {\n name: 'number',\n type: 'text',\n label: 'Number',\n },\n ],\n label: 'Credit Card',\n },\n ],\n })\n }\n\n return newConfig\n}\n"],"names":["createCharge","sendEmail","generateSubmissionCollection","formConfig","formSlug","formOverrides","slug","defaultFields","name","type","admin","readOnly","relationTo","required","validate","value","req","payload","_existingForm","findByID","id","collection","error","fields","newConfig","formSubmissionOverrides","access","create","read","user","update","enableRichTextRelationship","hooks","beforeChange","data","paymentFieldConfig","payment","push","label","description"],"mappings":"AAIA,SAASA,YAAY,QAAQ,0BAAyB;AACtD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,+CAA+C;AAC/C,OAAO,MAAMC,+BAA+B,CAC1CC;IAEA,MAAMC,WAAWD,YAAYE,eAAeC,QAAQ;IAEpD,MAAMC,gBAAyB;QAC7B;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAC,YAAYR;YACZS,UAAU;YACVC,UAAU,OAAOC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAE,EAAED,GAAG,EAAE;gBAC/C,gCAAgC,GAChC,IAAI,CAACC,SAAS,OAAO;gBAErB,IAAIA,SAAS;oBACX,IAAIC;oBAEJ,IAAI;wBACFA,gBAAgB,MAAMD,QAAQE,QAAQ,CAAC;4BACrCC,IAAIL;4BACJM,YAAYjB;4BACZY;wBACF;wBAEA,OAAO;oBACT,EAAE,OAAOM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AAUD,MAAM,CAACc,IAAI,CAAC;YACpB7B,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,UAAU;YACZ;YACAY,QAAQ;gBACN;oBACEf,MAAM;oBACNC,MAAM;oBACN6B,OAAO;gBACT;gBACA;oBACE9B,MAAM;oBACNC,MAAM;oBACN6B,OAAO;gBACT;gBACA;oBACE9B,MAAM;oBACNC,MAAM;oBACNC,OAAO;wBACL6B,aAAa;oBACf;gBACF;gBACA;oBACE/B,MAAM;oBACNC,MAAM;gBACR;gBACA;oBACED,MAAM;oBACNC,MAAM;oBACNc,QAAQ;wBACN;4BACEf,MAAM;4BACNC,MAAM;4BACN6B,OAAO;wBACT;wBACA;4BACE9B,MAAM;4BACNC,MAAM;4BACN6B,OAAO;wBACT;wBACA;4BACE9B,MAAM;4BACNC,MAAM;4BACN6B,OAAO;wBACT;qBACD;oBACDA,OAAO;gBACT;aACD;QACH;IACF;IAEA,OAAOd;AACT,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TextFieldProps } from 'payload';
2
+ import React from 'react';
3
+ export declare const DynamicFieldSelector: React.FC<TextFieldProps>;
4
+ //# sourceMappingURL=DynamicFieldSelector.d.ts.map
@@ -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,SAAS,CAAA;AAG7C,OAAO,KAA8B,MAAM,OAAO,CAAA;AAIlD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA4BzD,CAAA"}
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import { Select } from '@payloadcms/ui/fields/Select';
3
- import { useForm } from '@payloadcms/ui/forms/Form';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { SelectField, useForm } from '@payloadcms/ui';
4
4
  import React, { useEffect, useState } from 'react';
5
5
  export const DynamicFieldSelector = (props)=>{
6
6
  const { fields, getDataByPath } = useForm();
@@ -24,9 +24,7 @@ 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
- return /*#__PURE__*/ React.createElement(Select, {
27
+ return /*#__PURE__*/ _jsx(SelectField, {
30
28
  ...props,
31
29
  options: options
32
30
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { TextField } from 'payload/types'\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<TextField> = (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,uBAA4C,CAACC;IACxD,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"}
1
+ {"version":3,"sources":["../../../src/collections/Forms/DynamicFieldSelector.tsx"],"sourcesContent":["'use client'\n\nimport type { 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<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 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,qBAAO,KAACR;QAAa,GAAGM,KAAK;QAAEG,SAASA;;AAC1C,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { TextFieldProps } from 'payload';
2
+ import React from 'react';
3
+ export declare const DynamicPriceSelector: React.FC<TextFieldProps>;
4
+ //# sourceMappingURL=DynamicPriceSelector.d.ts.map
@@ -0,0 +1 @@
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,7 +1,6 @@
1
1
  'use client';
2
- import { Text } from '@payloadcms/ui/fields/Text';
3
- import { useWatchForm } from '@payloadcms/ui/forms/Form';
4
- import { useLocale } from '@payloadcms/ui/providers/Locale';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { TextField, useLocale, useWatchForm } from '@payloadcms/ui';
5
4
  import React, { useEffect, useState } from 'react';
6
5
  export const DynamicPriceSelector = (props)=>{
7
6
  const { label, path } = props;
@@ -33,7 +32,9 @@ export const DynamicPriceSelector = (props)=>{
33
32
  ]);
34
33
  // TODO: make this a number field, block by Payload
35
34
  if (valueType === 'static') {
36
- return /*#__PURE__*/ React.createElement(Text, props);
35
+ return /*#__PURE__*/ _jsx(TextField, {
36
+ ...props
37
+ });
37
38
  }
38
39
  const localeCode = typeof locale === 'object' && 'code' in locale ? locale.code : locale;
39
40
  const localLabels = typeof label === 'object' ? label : {
@@ -41,11 +42,19 @@ export const DynamicPriceSelector = (props)=>{
41
42
  };
42
43
  const labelValue = localLabels[localeCode] || localLabels['en'] || '';
43
44
  if (valueType === 'valueOfField' && !isNumberField) {
44
- return /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("div", null, labelValue), /*#__PURE__*/ React.createElement("div", {
45
- style: {
46
- color: '#9A9A9A'
47
- }
48
- }, "The selected field must be a number field."));
45
+ return /*#__PURE__*/ _jsxs("div", {
46
+ children: [
47
+ /*#__PURE__*/ _jsx("div", {
48
+ children: String(labelValue)
49
+ }),
50
+ /*#__PURE__*/ _jsx("div", {
51
+ style: {
52
+ color: '#9A9A9A'
53
+ },
54
+ children: "The selected field must be a number field."
55
+ })
56
+ ]
57
+ });
49
58
  }
50
59
  return null;
51
60
  };
@@ -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;IA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../src/collections/Forms/DynamicPriceSelector.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,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;8BACC,KAACA;8BAAKC,OAAOF;;8BACb,KAACC;oBACCE,OAAO;wBACLC,OAAO;oBACT;8BACD;;;;IAKP;IAEA,OAAO;AACT,EAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Block } from 'payload';
2
+ import type { FieldConfig } from '../../types.js';
3
+ export declare const fields: {
4
+ [key: string]: ((fieldConfig?: FieldConfig | boolean) => Block) | Block;
5
+ };
6
+ //# sourceMappingURL=fields.d.ts.map
@@ -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,SAAS,CAAA;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,gBAAgB,CAAA;AA6jBrE,eAAO,MAAM,MAAM,EAWd;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAA;CACxE,CAAA"}
@@ -550,7 +550,6 @@ const Message = {
550
550
  singular: 'Message'
551
551
  }
552
552
  };
553
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
554
553
  export const fields = {
555
554
  checkbox: Checkbox,
556
555
  country: Country,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/Forms/fields.ts"],"sourcesContent":["import type { Block, Field } from 'payload/types'\n\nimport type { FieldConfig, PaymentFieldConfig } from '../../types.js'\n\nimport { DynamicFieldSelector } from './DynamicFieldSelector.js'\nimport { DynamicPriceSelector } from './DynamicPriceSelector.js'\n\nconst name: Field = {\n name: 'name',\n type: 'text',\n label: 'Name (lowercase, no special characters)',\n required: true,\n}\n\nconst label: Field = {\n name: 'label',\n type: 'text',\n label: 'Label',\n localized: true,\n}\n\nconst required: Field = {\n name: 'required',\n type: 'checkbox',\n label: 'Required',\n}\n\nconst width: Field = {\n name: 'width',\n type: 'number',\n label: 'Field Width (percentage)',\n}\n\nconst Select: Block = {\n slug: 'select',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Select Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Select Fields',\n singular: 'Select',\n },\n}\n\nconst Text: Block = {\n slug: 'text',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Fields',\n singular: 'Text',\n },\n}\n\nconst TextArea: Block = {\n slug: 'textarea',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Area Fields',\n singular: 'Text Area',\n },\n}\n\nconst Number: Block = {\n slug: 'number',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Number Fields',\n singular: 'Number',\n },\n}\n\nconst Email: Block = {\n slug: 'email',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Email Fields',\n singular: 'Email',\n },\n}\n\nconst State: Block = {\n slug: 'state',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'State Fields',\n singular: 'State',\n },\n}\n\nconst Country: Block = {\n slug: 'country',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Country Fields',\n singular: 'Country',\n },\n}\n\nconst Checkbox: Block = {\n slug: 'checkbox',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'checkbox',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Checkbox Fields',\n singular: 'Checkbox',\n },\n}\n\nconst Payment = (fieldConfig: PaymentFieldConfig): Block => {\n let paymentProcessorField = null\n if (fieldConfig?.paymentProcessor) {\n paymentProcessorField = {\n name: 'paymentProcessor',\n type: 'select',\n label: 'Payment Processor',\n options: [],\n ...fieldConfig.paymentProcessor,\n }\n }\n\n const fields = {\n slug: 'payment',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'basePrice',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Base Price',\n },\n ],\n },\n paymentProcessorField,\n {\n name: 'priceConditions',\n type: 'array',\n fields: [\n {\n name: 'fieldToUse',\n type: 'text',\n admin: {\n components: {\n Field: DynamicFieldSelector,\n },\n },\n },\n {\n name: 'condition',\n type: 'select',\n defaultValue: 'hasValue',\n label: 'Condition',\n options: [\n {\n label: 'Has Any Value',\n value: 'hasValue',\n },\n {\n label: 'Equals',\n value: 'equals',\n },\n {\n label: 'Does Not Equal',\n value: 'notEquals',\n },\n ],\n },\n {\n name: 'valueForCondition',\n type: 'text',\n admin: {\n condition: (_: any, { condition }: any) =>\n condition === 'equals' || condition === 'notEquals',\n },\n label: 'Value',\n },\n {\n name: 'operator',\n type: 'select',\n defaultValue: 'add',\n options: [\n {\n label: 'Add',\n value: 'add',\n },\n {\n label: 'Subtract',\n value: 'subtract',\n },\n {\n label: 'Multiply',\n value: 'multiply',\n },\n {\n label: 'Divide',\n value: 'divide',\n },\n ],\n },\n {\n name: 'valueType',\n type: 'radio',\n admin: {\n width: '100%',\n },\n defaultValue: 'static',\n label: 'Value Type',\n options: [\n {\n label: 'Static Value',\n value: 'static',\n },\n {\n label: 'Value Of Field',\n value: 'valueOfField',\n },\n ],\n },\n {\n name: 'valueForOperator',\n type: 'text',\n admin: {\n components: {\n Field: DynamicPriceSelector,\n },\n },\n label: 'Value',\n },\n ],\n label: 'Price Conditions',\n labels: {\n plural: 'Price Conditions',\n singular: 'Price Condition',\n },\n },\n required,\n ].filter(Boolean) as Field[],\n labels: {\n plural: 'Payment Fields',\n singular: 'Payment',\n },\n }\n\n return fields\n}\n\nconst Message: Block = {\n slug: 'message',\n fields: [\n {\n name: 'message',\n type: 'richText',\n localized: true,\n },\n ],\n labels: {\n plural: 'Message Blocks',\n singular: 'Message',\n },\n}\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\nexport const fields = {\n checkbox: Checkbox,\n country: Country,\n email: Email,\n message: Message,\n number: Number,\n payment: Payment,\n select: Select,\n state: State,\n text: Text,\n textarea: TextArea,\n} as {\n [key: string]: ((fieldConfig?: FieldConfig | boolean) => Block) | Block\n}\n"],"names":["DynamicFieldSelector","DynamicPriceSelector","name","type","label","required","localized","width","Select","slug","fields","admin","labels","plural","singular","Text","TextArea","Number","Email","State","Country","Checkbox","Payment","fieldConfig","paymentProcessorField","paymentProcessor","options","components","Field","defaultValue","value","condition","_","filter","Boolean","Message","checkbox","country","email","message","number","payment","select","state","text","textarea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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gB,SAASjB;IACTkB,OAAOpB;IACPqB,SAASJ;IACTK,QAAQvB;IACRwB,SAASnB;IACToB,QAAQlC;IACRmC,OAAOxB;IACPyB,MAAM7B;IACN8B,UAAU7B;AACZ,EAEC"}
1
+ {"version":3,"sources":["../../../src/collections/Forms/fields.ts"],"sourcesContent":["import type { Block, Field } from 'payload'\n\nimport type { FieldConfig, PaymentFieldConfig } from '../../types.js'\n\nimport { DynamicFieldSelector } from './DynamicFieldSelector.js'\nimport { DynamicPriceSelector } from './DynamicPriceSelector.js'\n\nconst name: Field = {\n name: 'name',\n type: 'text',\n label: 'Name (lowercase, no special characters)',\n required: true,\n}\n\nconst label: Field = {\n name: 'label',\n type: 'text',\n label: 'Label',\n localized: true,\n}\n\nconst required: Field = {\n name: 'required',\n type: 'checkbox',\n label: 'Required',\n}\n\nconst width: Field = {\n name: 'width',\n type: 'number',\n label: 'Field Width (percentage)',\n}\n\nconst Select: Block = {\n slug: 'select',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Select Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Select Fields',\n singular: 'Select',\n },\n}\n\nconst Text: Block = {\n slug: 'text',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Fields',\n singular: 'Text',\n },\n}\n\nconst TextArea: Block = {\n slug: 'textarea',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Area Fields',\n singular: 'Text Area',\n },\n}\n\nconst Number: Block = {\n slug: 'number',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Number Fields',\n singular: 'Number',\n },\n}\n\nconst Email: Block = {\n slug: 'email',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Email Fields',\n singular: 'Email',\n },\n}\n\nconst State: Block = {\n slug: 'state',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'State Fields',\n singular: 'State',\n },\n}\n\nconst Country: Block = {\n slug: 'country',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Country Fields',\n singular: 'Country',\n },\n}\n\nconst Checkbox: Block = {\n slug: 'checkbox',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'checkbox',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Checkbox Fields',\n singular: 'Checkbox',\n },\n}\n\nconst Payment = (fieldConfig: PaymentFieldConfig): Block => {\n let paymentProcessorField = null\n if (fieldConfig?.paymentProcessor) {\n paymentProcessorField = {\n name: 'paymentProcessor',\n type: 'select',\n label: 'Payment Processor',\n options: [],\n ...fieldConfig.paymentProcessor,\n }\n }\n\n const fields = {\n slug: 'payment',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'basePrice',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Base Price',\n },\n ],\n },\n paymentProcessorField,\n {\n name: 'priceConditions',\n type: 'array',\n fields: [\n {\n name: 'fieldToUse',\n type: 'text',\n admin: {\n components: {\n Field: DynamicFieldSelector,\n },\n },\n },\n {\n name: 'condition',\n type: 'select',\n defaultValue: 'hasValue',\n label: 'Condition',\n options: [\n {\n label: 'Has Any Value',\n value: 'hasValue',\n },\n {\n label: 'Equals',\n value: 'equals',\n },\n {\n label: 'Does Not Equal',\n value: 'notEquals',\n },\n ],\n },\n {\n name: 'valueForCondition',\n type: 'text',\n admin: {\n condition: (_: any, { condition }: any) =>\n condition === 'equals' || condition === 'notEquals',\n },\n label: 'Value',\n },\n {\n name: 'operator',\n type: 'select',\n defaultValue: 'add',\n options: [\n {\n label: 'Add',\n value: 'add',\n },\n {\n label: 'Subtract',\n value: 'subtract',\n },\n {\n label: 'Multiply',\n value: 'multiply',\n },\n {\n label: 'Divide',\n value: 'divide',\n },\n ],\n },\n {\n name: 'valueType',\n type: 'radio',\n admin: {\n width: '100%',\n },\n defaultValue: 'static',\n label: 'Value Type',\n options: [\n {\n label: 'Static Value',\n value: 'static',\n },\n {\n label: 'Value Of Field',\n value: 'valueOfField',\n },\n ],\n },\n {\n name: 'valueForOperator',\n type: 'text',\n admin: {\n components: {\n Field: DynamicPriceSelector,\n },\n },\n label: 'Value',\n },\n ],\n label: 'Price Conditions',\n labels: {\n plural: 'Price Conditions',\n singular: 'Price Condition',\n },\n },\n required,\n ].filter(Boolean) as Field[],\n labels: {\n plural: 'Payment Fields',\n singular: 'Payment',\n },\n }\n\n return fields\n}\n\nconst Message: Block = {\n slug: 'message',\n fields: [\n {\n name: 'message',\n type: 'richText',\n localized: true,\n },\n ],\n labels: {\n plural: 'Message Blocks',\n singular: 'Message',\n },\n}\n\n \nexport const fields = {\n checkbox: Checkbox,\n country: Country,\n email: Email,\n message: Message,\n number: Number,\n payment: Payment,\n select: Select,\n state: State,\n text: Text,\n textarea: TextArea,\n} as {\n [key: string]: ((fieldConfig?: FieldConfig | boolean) => Block) | Block\n}\n"],"names":["DynamicFieldSelector","DynamicPriceSelector","name","type","label","required","localized","width","Select","slug","fields","admin","labels","plural","singular","Text","TextArea","Number","Email","State","Country","Checkbox","Payment","fieldConfig","paymentProcessorField","paymentProcessor","options","components","Field","defaultValue","value","condition","_","filter","Boolean","Message","checkbox","country","email","message","number","payment","select","state","text","textarea"],"mappings":"AAIA,SAASA,oBAAoB,Q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wBACNC,MAAM;wBACNQ,OAAO;4BACLoB,WAAW,CAACC,GAAQ,EAAED,SAAS,EAAO,GACpCA,cAAc,YAAYA,cAAc;wBAC5C;wBACA3B,OAAO;oBACT;oBACA;wBACEF,MAAM;wBACNC,MAAM;wBACN0B,cAAc;wBACdH,SAAS;4BACP;gCACEtB,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;yBACD;oBACH;oBACA;wBACE5B,MAAM;wBACNC,MAAM;wBACNQ,OAAO;4BACLJ,OAAO;wBACT;wBACAsB,cAAc;wBACdzB,OAAO;wBACPsB,SAAS;4BACP;gCACEtB,OAAO;gCACP0B,OAAO;4BACT;4BACA;gCACE1B,OAAO;gCACP0B,OAAO;4BACT;yBACD;oBACH;oBACA;wBACE5B,MAAM;wBACNC,MAAM;wBACNQ,OAAO;4BACLgB,YAAY;gCACVC,OAAO3B;4BACT;wBACF;wBACAG,OAAO;oBACT;iBACD;gBACDA,OAAO;gBACPQ,QAAQ;oBACNC,QAAQ;oBACRC,UAAU;gBACZ;YACF;YACAT;SACD,CAAC4B,MAAM,CAACC;QACTtB,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF;IAEA,OAAOJ;AACT;AAEA,MAAMyB,UAAiB;IACrB1B,MAAM;IACNC,QAAQ;QACN;YACER,MAAM;YACNC,MAAM;YACNG,WAAW;QACb;KACD;IACDM,QAAQ;QACNC,QAAQ;QACRC,UAAU;IACZ;AACF;AAGA,OAAO,MAAMJ,SAAS;IACpB0B,UAAUf;IACVgB,SAASjB;IACTkB,OAAOpB;IACPqB,SAASJ;IACTK,QAAQvB;IACRwB,SAASnB;IACToB,QAAQlC;IACRmC,OAAOxB;IACPyB,MAAM7B;IACN8B,UAAU7B;AACZ,EAEC"}
@@ -0,0 +1,4 @@
1
+ import type { CollectionConfig } from 'payload';
2
+ import type { FormBuilderPluginConfig } from '../../types.js';
3
+ export declare const generateFormCollection: (formConfig: FormBuilderPluginConfig) => CollectionConfig;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAK7D,eAAO,MAAM,sBAAsB,eAAgB,uBAAuB,KAAG,gBAuO5E,CAAA"}