@payloadcms/plugin-form-builder 3.0.0-canary.6d9b462 → 3.0.0-canary.6f0a417
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collections/FormSubmissions/hooks/createCharge.d.ts.map +1 -1
- package/dist/collections/FormSubmissions/hooks/createCharge.js.map +1 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts +4 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts.map +1 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.js +8 -8
- package/dist/collections/FormSubmissions/hooks/sendEmail.js.map +1 -1
- package/dist/collections/FormSubmissions/index.d.ts +1 -1
- package/dist/collections/FormSubmissions/index.d.ts.map +1 -1
- package/dist/collections/FormSubmissions/index.js +3 -1
- package/dist/collections/FormSubmissions/index.js.map +1 -1
- package/dist/collections/Forms/DynamicFieldSelector.d.ts +4 -2
- package/dist/collections/Forms/DynamicFieldSelector.d.ts.map +1 -1
- package/dist/collections/Forms/DynamicFieldSelector.js +7 -6
- package/dist/collections/Forms/DynamicFieldSelector.js.map +1 -1
- package/dist/collections/Forms/DynamicPriceSelector.d.ts +2 -3
- package/dist/collections/Forms/DynamicPriceSelector.d.ts.map +1 -1
- package/dist/collections/Forms/DynamicPriceSelector.js +8 -10
- package/dist/collections/Forms/DynamicPriceSelector.js.map +1 -1
- package/dist/collections/Forms/fields.d.ts +2 -2
- package/dist/collections/Forms/fields.d.ts.map +1 -1
- package/dist/collections/Forms/fields.js +2 -5
- package/dist/collections/Forms/fields.js.map +1 -1
- package/dist/collections/Forms/index.d.ts +1 -1
- package/dist/collections/Forms/index.d.ts.map +1 -1
- package/dist/collections/Forms/index.js +15 -8
- package/dist/collections/Forms/index.js.map +1 -1
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +4 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/types.d.ts +1 -1
- package/dist/exports/types.d.ts.map +1 -1
- package/dist/exports/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +29 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/getPaymentTotal.d.ts +2 -2
- package/dist/utilities/getPaymentTotal.d.ts.map +1 -1
- package/dist/utilities/getPaymentTotal.js.map +1 -1
- package/dist/utilities/keyValuePairToHtmlTable.d.ts +4 -0
- package/dist/utilities/keyValuePairToHtmlTable.d.ts.map +1 -0
- package/dist/utilities/keyValuePairToHtmlTable.js +10 -0
- package/dist/utilities/keyValuePairToHtmlTable.js.map +1 -0
- package/dist/utilities/lexical/converters/heading.js.map +1 -1
- package/dist/utilities/lexical/converters/linebreak.js.map +1 -1
- package/dist/utilities/lexical/converters/link.js.map +1 -1
- package/dist/utilities/lexical/converters/list.js.map +1 -1
- package/dist/utilities/lexical/converters/paragraph.js.map +1 -1
- package/dist/utilities/lexical/converters/quote.js.map +1 -1
- package/dist/utilities/lexical/converters/text.js.map +1 -1
- package/dist/utilities/lexical/defaultConverters.js.map +1 -1
- package/dist/utilities/lexical/nodeFormat.js.map +1 -1
- package/dist/utilities/lexical/serializeLexical.js.map +1 -1
- package/dist/utilities/lexical/types.d.ts +2 -2
- package/dist/utilities/lexical/types.d.ts.map +1 -1
- package/dist/utilities/lexical/types.js.map +1 -1
- package/dist/utilities/replaceDoubleCurlys.d.ts.map +1 -1
- package/dist/utilities/replaceDoubleCurlys.js +18 -2
- package/dist/utilities/replaceDoubleCurlys.js.map +1 -1
- package/dist/utilities/slate/serializeSlate.d.ts.map +1 -1
- package/dist/utilities/slate/serializeSlate.js +1 -1
- package/dist/utilities/slate/serializeSlate.js.map +1 -1
- package/package.json +26 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\n\nimport merge from 'deepmerge'\n\nimport type { FieldConfig, FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: FormBuilderPluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') redirect.fields[2].label = 'Custom URL'\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'fields',\n type: 'blocks',\n blocks: Object.entries(formConfig?.fields || {})\n .map(([fieldKey, fieldConfig]) => {\n // let the config enable/disable fields with either boolean values or objects\n if (fieldConfig !== false) {\n const block = fields[fieldKey]\n\n if (block === undefined && typeof fieldConfig === 'object') {\n return fieldConfig\n }\n\n if (typeof block === 'object' && typeof fieldConfig === 'object') {\n return merge<FieldConfig>(block, fieldConfig, {\n arrayMerge: (_, sourceArray) => sourceArray,\n })\n }\n\n if (typeof block === 'function') {\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description:\n 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',\n layout: 'horizontal',\n },\n defaultValue: 'message',\n options: [\n {\n label: 'Message',\n value: 'message',\n },\n {\n label: 'Redirect',\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n admin: {\n description:\n \"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}.\",\n },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'emailTo',\n type: 'text',\n admin: {\n placeholder: '\"Email Sender\" <sender@email.com>',\n width: '100%',\n },\n label: 'Email To',\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ]\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields:\n formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function'\n ? formConfig.formOverrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return config\n}\n"],"names":["merge","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","defaultFields","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","arrayMerge","sourceArray","filter","Boolean","localized","description","placeholder","width","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,WAAW,YAAW;AAI7B,SAASC,MAAM,QAAQ,cAAa;AAEpC,+CAA+C;AAC/C,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAMC,WAAkB;QACtBC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACjEC,YAAY;QACd;QACAX,QAAQ;YACN;gBACEI,MAAM;gBACNC,MAAM;gBACNO,OAAO;gBACPC,UAAU;YACZ;SACD;IACH;IAEA,IAAIX,WAAWY,qBAAqB,EAAE;QACpCX,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaJ,SAAS;YACvD;YACAO,OAAO;YACPI,UAAU;YACVC,YAAYf,WAAWY,qBAAqB;YAC5CD,UAAU;QACZ;Q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ACT;gBACA;oBACET,OAAO;oBACPS,OAAO;gBACT;aACD;QACH;QACA;YACEjB,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACnE;YACAyB,WAAW;YACXtB,UAAU;QACZ;QACAV;QACA;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACL8B,aACE;YACJ;YACApC,QAAQ;gBACN;oBACEK,MAAM;oBACNL,QAAQ;wBACN;4BACEI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACL+B,aAAa;gCACbC,OAAO;4BACT;4BACA1B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLgC,OAAO;4BACT;4BACA1B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLgC,OAAO;4BACT;4BACA1B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACEP,MAAM;oBACNL,QAAQ;wBACN;4BACEI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACL+B,aAAa;gCACbC,OAAO;4BACT;4BACA1B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACL+B,aAAa;gCACbC,OAAO;4BACT;4BACA1B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACER,MAAM;oBACNC,MAAM;oBACNc,cAAc;oBACdP,OAAO;oBACPuB,WAAW;oBACXtB,UAAU;gBACZ;gBACA;oBACET,MAAM;oBACNC,MAAM;oBACNC,OAAO;wBACL8B,aAAa;oBACf;oBACAxB,OAAO;oBACPuB,WAAW;gBACb;aACD;QACH;KACD;IAED,MAAMI,SAA2B;QAC/B,GAAIrC,YAAYsC,iBAAiB,CAAC,CAAC;QACnCC,MAAMvC,YAAYsC,eAAeC,QAAQ;QACzCC,QAAQ;YACNC,MAAM,IAAM;YACZ,GAAIzC,YAAYsC,eAAeE,UAAU,CAAC,CAAC;QAC7C;QACApC,OAAO;YACLsC,4BAA4B;YAC5BC,YAAY;YACZ,GAAI3C,YAAYsC,eAAelC,SAAS,CAAC,CAAC;QAC5C;QACAN,QACEE,YAAYsC,eAAexC,UAAU,OAAOE,YAAYsC,eAAexC,WAAW,aAC9EE,WAAWsC,aAAa,CAACxC,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOiB;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload'\n\nimport { deepMergeWithSourceArrays } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: FormBuilderPluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') {\n redirect.fields[2].label = 'Custom URL'\n }\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const defaultFields: Field[] = [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'fields',\n type: 'blocks',\n blocks: Object.entries(formConfig?.fields || {})\n .map(([fieldKey, fieldConfig]) => {\n // let the config enable/disable fields with either boolean values or objects\n if (fieldConfig !== false) {\n const block = fields[fieldKey]\n\n if (block === undefined && typeof fieldConfig === 'object') {\n return fieldConfig\n }\n\n if (typeof block === 'object' && typeof fieldConfig === 'object') {\n return deepMergeWithSourceArrays(block, fieldConfig)\n }\n\n if (typeof block === 'function') {\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description:\n 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',\n layout: 'horizontal',\n },\n defaultValue: 'message',\n options: [\n {\n label: 'Message',\n value: 'message',\n },\n {\n label: 'Redirect',\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n access: {\n read: ({ req: { user } }) => !!user,\n },\n admin: {\n description:\n \"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}. You can use a wildcard {{*}} to output all data and {{*:table}} to format it as an HTML table in the email.\",\n },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'emailTo',\n type: 'text',\n admin: {\n placeholder: '\"Email Sender\" <sender@email.com>',\n width: '100%',\n },\n label: 'Email To',\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ]\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields:\n formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function'\n ? formConfig.formOverrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return config\n}\n"],"names":["deepMergeWithSourceArrays","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","defaultFields","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","filter","Boolean","localized","description","access","read","req","user","placeholder","width","style","maxWidth","config","formOverrides","slug","enableRichTextRelationship","useAsTitle"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAInD,SAASC,MAAM,QAAQ,cAAa;AAEpC,+CAA+C;AAC/C,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAMC,WAAkB;QACtBC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACjEC,YAAY;QACd;QACAX,QAAQ;YACN;gBACEI,MAAM;gBACNC,MAAM;gBACNO,OAAO;gBACPC,UAAU;YACZ;SACD;IACH;IAEA,IAAIX,WAAWY,qBAAqB,EAAE;QACpCX,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAA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MAAM;YACNC,OAAO;gBACL4B,aACE;gBACFhB,QAAQ;YACV;YACAC,cAAc;YACdC,SAAS;gBACP;oBACER,OAAO;oBACPS,OAAO;gBACT;gBACA;oBACET,OAAO;oBACPS,OAAO;gBACT;aACD;QACH;QACA;YACEjB,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACnE;YACAuB,WAAW;YACXpB,UAAU;QACZ;QACAV;QACA;YACEC,MAAM;YACNC,MAAM;YACN8B,QAAQ;gBACNC,MAAM,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAK,CAAC,CAACA;YACjC;YACAhC,OAAO;gBACL4B,aACE;YACJ;YACAlC,QAAQ;gBACN;oBACEK,MAAM;oBACNL,QAAQ;wBACN;4BACEI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLiC,aAAa;gCACbC,OAAO;4BACT;4BACA5B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLmC,OAAO;oCACLC,UAAU;gCACZ;4BACF;4BACA9B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLmC,OAAO;oCACLC,UAAU;gCACZ;4BACF;4BACA9B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACEP,MAAM;oBACNL,QAAQ;wBACN;4BACEI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLiC,aAAa;gCACbC,OAAO;4BACT;4BACA5B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLiC,aAAa;gCACbC,OAAO;4BACT;4BACA5B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACER,MAAM;oBACNC,MAAM;oBACNc,cAAc;oBACdP,OAAO;oBACPqB,WAAW;oBACXpB,UAAU;gBACZ;gBACA;oBACET,MAAM;oBACNC,MAAM;oBACNC,OAAO;wBACL4B,aAAa;oBACf;oBACAtB,OAAO;oBACPqB,WAAW;gBACb;aACD;QACH;KACD;IAED,MAAMU,SAA2B;QAC/B,GAAIzC,YAAY0C,iBAAiB,CAAC,CAAC;QACnCC,MAAM3C,YAAY0C,eAAeC,QAAQ;QACzCV,QAAQ;YACNC,MAAM,IAAM;YACZ,GAAIlC,YAAY0C,eAAeT,UAAU,CAAC,CAAC;QAC7C;QACA7B,OAAO;YACLwC,4BAA4B;YAC5BC,YAAY;YACZ,GAAI7C,YAAY0C,eAAetC,SAAS,CAAC,CAAC;QAC5C;QACAN,QACEE,YAAY0C,eAAe5C,UAAU,OAAOE,YAAY0C,eAAe5C,WAAW,aAC9EE,WAAW0C,aAAa,CAAC5C,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOqB;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DynamicFieldSelector } from '../collections/Forms/DynamicFieldSelector.js'\nexport { DynamicPriceSelector } from '../collections/Forms/DynamicPriceSelector.js'\n"],"names":["DynamicFieldSelector","DynamicPriceSelector"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,+CAA8C;AACnF,SAASC,oBAAoB,QAAQ,+CAA8C"}
|
package/dist/exports/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { BeforeEmail, BlockConfig, CheckboxField, CountryField, Email, EmailField, FieldConfig,
|
|
1
|
+
export type { BeforeEmail, BlockConfig, CheckboxField, CountryField, Email, EmailField, FieldConfig, FieldsConfig, FieldValues, Form, FormattedEmail, FormBuilderPluginConfig as PluginConfig, FormFieldBlock, FormSubmission, HandlePayment, isValidBlockConfig, MessageField, PaymentField, PaymentFieldConfig, PriceCondition, Redirect, SelectField, SelectFieldOption, StateField, SubmissionValue, TextAreaField, TextField, } from '../types.js';
|
|
2
2
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,KAAK,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,KAAK,EACL,UAAU,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,cAAc,EACd,uBAAuB,IAAI,YAAY,EACvC,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,aAAa,EACb,SAAS,GACV,MAAM,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n BeforeEmail,\n BlockConfig,\n CheckboxField,\n CountryField,\n Email,\n EmailField,\n FieldConfig,\n
|
|
1
|
+
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n BeforeEmail,\n BlockConfig,\n CheckboxField,\n CountryField,\n Email,\n EmailField,\n FieldConfig,\n FieldsConfig,\n FieldValues,\n Form,\n FormattedEmail,\n FormBuilderPluginConfig as PluginConfig,\n FormFieldBlock,\n FormSubmission,\n HandlePayment,\n isValidBlockConfig,\n MessageField,\n PaymentField,\n PaymentFieldConfig,\n PriceCondition,\n Redirect,\n SelectField,\n SelectFieldOption,\n StateField,\n SubmissionValue,\n TextAreaField,\n TextField,\n} from '../types.js'\n"],"names":[],"mappings":"AAAA,WA4BoB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config } from 'payload
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
2
|
import type { FormBuilderPluginConfig } from './types.js';
|
|
3
3
|
export { fields } from './collections/Forms/fields.js';
|
|
4
4
|
export { getPaymentTotal } from './utilities/getPaymentTotal.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAKzD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAEhE,eAAO,MAAM,iBAAiB,uBACP,uBAAuB,cACnC,MAAM,KAAG,MA0BjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { generateSubmissionCollection } from './collections/FormSubmissions/index.js';
|
|
2
1
|
import { generateFormCollection } from './collections/Forms/index.js';
|
|
2
|
+
import { generateSubmissionCollection } from './collections/FormSubmissions/index.js';
|
|
3
3
|
export { fields } from './collections/Forms/fields.js';
|
|
4
4
|
export { getPaymentTotal } from './utilities/getPaymentTotal.js';
|
|
5
5
|
export const formBuilderPlugin = (incomingFormConfig)=>(config)=>{
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload'\n\nimport type { FormBuilderPluginConfig } from './types.js'\n\nimport { generateFormCollection } from './collections/Forms/index.js'\nimport { generateSubmissionCollection } from './collections/FormSubmissions/index.js'\n\nexport { fields } from './collections/Forms/fields.js'\nexport { getPaymentTotal } from './utilities/getPaymentTotal.js'\n\nexport const formBuilderPlugin =\n (incomingFormConfig: FormBuilderPluginConfig) =>\n (config: Config): Config => {\n const formConfig: FormBuilderPluginConfig = {\n ...incomingFormConfig,\n fields: {\n checkbox: true,\n country: true,\n email: true,\n message: true,\n number: true,\n payment: false,\n select: true,\n state: true,\n text: true,\n textarea: true,\n ...incomingFormConfig.fields,\n },\n }\n\n return {\n ...config,\n collections: [\n ...(config?.collections || []),\n generateFormCollection(formConfig),\n generateSubmissionCollection(formConfig),\n ],\n }\n }\n"],"names":["generateFormCollection","generateSubmissionCollection","fields","getPaymentTotal","formBuilderPlugin","incomingFormConfig","config","formConfig","checkbox","country","email","message","number","payment","select","state","text","textarea","collections"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,+BAA8B;AACrE,SAASC,4BAA4B,QAAQ,yCAAwC;AAErF,SAASC,MAAM,QAAQ,gCAA+B;AACtD,SAASC,eAAe,QAAQ,iCAAgC;AAEhE,OAAO,MAAMC,oBACX,CAACC,qBACD,CAACC;QACC,MAAMC,aAAsC;YAC1C,GAAGF,kBAAkB;YACrBH,QAAQ;gBACNM,UAAU;gBACVC,SAAS;gBACTC,OAAO;gBACPC,SAAS;gBACTC,QAAQ;gBACRC,SAAS;gBACTC,QAAQ;gBACRC,OAAO;gBACPC,MAAM;gBACNC,UAAU;gBACV,GAAGZ,mBAAmBH,MAAM;YAC9B;QACF;QAEA,OAAO;YACL,GAAGI,MAAM;YACTY,aAAa;mBACPZ,QAAQY,eAAe,EAAE;gBAC7BlB,uBAAuBO;gBACvBN,6BAA6BM;aAC9B;QACH;IACF,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Block, CollectionConfig, Field } from 'payload
|
|
1
|
+
import type { Block, CollectionBeforeChangeHook, CollectionConfig, Field, TypeWithID } from 'payload';
|
|
2
2
|
export interface BlockConfig {
|
|
3
3
|
block: Block;
|
|
4
4
|
validate?: (value: unknown) => boolean | string;
|
|
@@ -7,37 +7,43 @@ export declare function isValidBlockConfig(blockConfig: BlockConfig | string): b
|
|
|
7
7
|
export interface FieldValues {
|
|
8
8
|
[key: string]: boolean | null | number | string | undefined;
|
|
9
9
|
}
|
|
10
|
-
export type PaymentFieldConfig =
|
|
10
|
+
export type PaymentFieldConfig = {
|
|
11
11
|
paymentProcessor: Partial<SelectField>;
|
|
12
|
-
}
|
|
12
|
+
} & Partial<Field>;
|
|
13
13
|
export type FieldConfig = Partial<Field> | PaymentFieldConfig;
|
|
14
14
|
export interface FieldsConfig {
|
|
15
|
-
[key: string]:
|
|
16
|
-
checkbox?:
|
|
17
|
-
country?:
|
|
18
|
-
email?:
|
|
19
|
-
message?:
|
|
20
|
-
number?:
|
|
21
|
-
payment?:
|
|
22
|
-
select?:
|
|
23
|
-
state?:
|
|
24
|
-
text?:
|
|
25
|
-
textarea?:
|
|
26
|
-
}
|
|
27
|
-
|
|
15
|
+
[key: string]: boolean | FieldConfig | undefined;
|
|
16
|
+
checkbox?: boolean | FieldConfig;
|
|
17
|
+
country?: boolean | FieldConfig;
|
|
18
|
+
email?: boolean | FieldConfig;
|
|
19
|
+
message?: boolean | FieldConfig;
|
|
20
|
+
number?: boolean | FieldConfig;
|
|
21
|
+
payment?: boolean | FieldConfig;
|
|
22
|
+
select?: boolean | FieldConfig;
|
|
23
|
+
state?: boolean | FieldConfig;
|
|
24
|
+
text?: boolean | FieldConfig;
|
|
25
|
+
textarea?: boolean | FieldConfig;
|
|
26
|
+
}
|
|
27
|
+
type BeforeChangeParams<T extends TypeWithID = any> = Parameters<CollectionBeforeChangeHook<T>>[0];
|
|
28
|
+
export type BeforeEmail<T extends TypeWithID = any> = (emails: FormattedEmail[], beforeChangeParams: BeforeChangeParams<T>) => FormattedEmail[] | Promise<FormattedEmail[]>;
|
|
28
29
|
export type HandlePayment = (data: any) => void;
|
|
29
30
|
export type FieldsOverride = (args: {
|
|
30
31
|
defaultFields: Field[];
|
|
31
32
|
}) => Field[];
|
|
32
33
|
export type FormBuilderPluginConfig = {
|
|
33
34
|
beforeEmail?: BeforeEmail;
|
|
35
|
+
/**
|
|
36
|
+
* Set a default email address to send form submissions to if no email is provided in the form configuration
|
|
37
|
+
* Falls back to the defaultFromAddress in the email configuration
|
|
38
|
+
*/
|
|
39
|
+
defaultToEmail?: string;
|
|
34
40
|
fields?: FieldsConfig;
|
|
35
|
-
formOverrides?:
|
|
36
|
-
fields
|
|
37
|
-
}
|
|
38
|
-
formSubmissionOverrides?:
|
|
39
|
-
fields
|
|
40
|
-
}
|
|
41
|
+
formOverrides?: {
|
|
42
|
+
fields?: FieldsOverride;
|
|
43
|
+
} & Partial<Omit<CollectionConfig, 'fields'>>;
|
|
44
|
+
formSubmissionOverrides?: {
|
|
45
|
+
fields?: FieldsOverride;
|
|
46
|
+
} & Partial<Omit<CollectionConfig, 'fields'>>;
|
|
41
47
|
handlePayment?: HandlePayment;
|
|
42
48
|
redirectRelationships?: string[];
|
|
43
49
|
};
|
|
@@ -179,4 +185,5 @@ export interface FormSubmission {
|
|
|
179
185
|
form: Form | string;
|
|
180
186
|
submissionData: SubmissionValue[];
|
|
181
187
|
}
|
|
188
|
+
export {};
|
|
182
189
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","s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EAAE,CAAA;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,IAAI,GAAG,MAAM,CAAA;IACnB,cAAc,EAAE,eAAe,EAAE,CAAA;CAClC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n Block,\n CollectionBeforeChangeHook,\n CollectionConfig,\n Field,\n TypeWithID,\n} from 'payload'\n\nexport interface BlockConfig {\n block: Block\n validate?: (value: unknown) => boolean | string\n}\n\nexport function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig {\n return (\n typeof blockConfig !== 'string' &&\n typeof blockConfig?.block?.slug === 'string' &&\n Array.isArray(blockConfig?.block?.fields)\n )\n}\n\nexport interface FieldValues {\n [key: string]: boolean | null | number | string | undefined\n}\n\nexport type PaymentFieldConfig = {\n paymentProcessor: Partial<SelectField>\n} & Partial<Field>\n\nexport type FieldConfig = Partial<Field> | PaymentFieldConfig\n\nexport interface FieldsConfig {\n [key: string]: boolean | FieldConfig | undefined\n checkbox?: boolean | FieldConfig\n country?: boolean | FieldConfig\n email?: boolean | FieldConfig\n message?: boolean | FieldConfig\n number?: boolean | FieldConfig\n payment?: boolean | FieldConfig\n select?: boolean | FieldConfig\n state?: boolean | FieldConfig\n text?: boolean | FieldConfig\n textarea?: boolean | FieldConfig\n}\n\ntype BeforeChangeParams<T extends TypeWithID = any> = Parameters<CollectionBeforeChangeHook<T>>[0]\nexport type BeforeEmail<T extends TypeWithID = any> = (\n emails: FormattedEmail[],\n beforeChangeParams: BeforeChangeParams<T>,\n) => FormattedEmail[] | Promise<FormattedEmail[]>\nexport type HandlePayment = (data: any) => void\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type FormBuilderPluginConfig = {\n beforeEmail?: BeforeEmail\n /**\n * Set a default email address to send form submissions to if no email is provided in the form configuration\n * Falls back to the defaultFromAddress in the email configuration\n */\n defaultToEmail?: string\n fields?: FieldsConfig\n formOverrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n formSubmissionOverrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n handlePayment?: HandlePayment\n redirectRelationships?: string[]\n}\n\nexport interface TextField {\n blockName?: string\n blockType: 'text'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface TextAreaField {\n blockName?: string\n blockType: 'textarea'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface SelectFieldOption {\n label: string\n value: string\n}\n\nexport interface SelectField {\n blockName?: string\n blockType: 'select'\n defaultValue?: string\n label?: string\n name: string\n options: SelectFieldOption[]\n required?: boolean\n width?: number\n}\n\nexport interface PriceCondition {\n condition: 'equals' | 'hasValue' | 'notEquals'\n fieldToUse: string\n operator: 'add' | 'divide' | 'multiply' | 'subtract'\n valueForCondition: string\n valueForOperator: number | string // TODO: make this a number, see ./collections/Forms/DynamicPriceSelector.tsx\n valueType: 'static' | 'valueOfField'\n}\n\nexport interface PaymentField {\n basePrice: number\n blockName?: string\n blockType: 'payment'\n defaultValue?: string\n label?: string\n name: string\n paymentProcessor: string\n priceConditions: PriceCondition[]\n required?: boolean\n width?: number\n}\n\nexport interface EmailField {\n blockName?: string\n blockType: 'email'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface StateField {\n blockName?: string\n blockType: 'state'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface CountryField {\n blockName?: string\n blockType: 'country'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface CheckboxField {\n blockName?: string\n blockType: 'checkbox'\n defaultValue?: boolean\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface MessageField {\n blockName?: string\n blockType: 'message'\n message: unknown\n}\n\nexport type FormFieldBlock =\n | CheckboxField\n | CountryField\n | EmailField\n | MessageField\n | PaymentField\n | SelectField\n | StateField\n | TextAreaField\n | TextField\n\nexport interface Email {\n bcc?: string\n cc?: string\n emailFrom: string\n emailTo: string\n message?: any // TODO: configure rich text type\n replyTo?: string\n subject: string\n}\n\nexport interface FormattedEmail {\n bcc?: string\n cc?: string\n from: string\n html: string\n replyTo: string\n subject: string\n to: string\n}\n\nexport interface Redirect {\n reference?: {\n relationTo: string\n value: string | unknown\n }\n type: 'custom' | 'reference'\n url: string\n}\n\nexport interface Form {\n confirmationMessage?: any // TODO: configure rich text type\n confirmationType: 'message' | 'redirect'\n emails: Email[]\n fields: FormFieldBlock[]\n id: string\n redirect?: Redirect\n submitButtonLabel?: string\n title: string\n}\n\nexport interface SubmissionValue {\n field: string\n value: unknown\n}\n\nexport interface FormSubmission {\n form: Form | string\n submissionData: SubmissionValue[]\n}\n"],"names":["isValidBlockConfig","blockConfig","block","slug","Array","isArray","fields"],"mappings":"AAaA,OAAO,SAASA,mBAAmBC,WAAiC;IAClE,OACE,OAAOA,gBAAgB,YACvB,OAAOA,aAAaC,OAAOC,SAAS,YACpCC,MAAMC,OAAO,CAACJ,aAAaC,OAAOI;AAEtC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FieldValues, PaymentField } from '../types.js';
|
|
2
|
-
export declare const getPaymentTotal: (args:
|
|
2
|
+
export declare const getPaymentTotal: (args: {
|
|
3
3
|
fieldValues: FieldValues;
|
|
4
|
-
}) => number;
|
|
4
|
+
} & Partial<PaymentField>) => number;
|
|
5
5
|
//# sourceMappingURL=getPaymentTotal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPaymentTotal.d.ts","sourceRoot":"","sources":["../../src/utilities/getPaymentTotal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAA;AAE5E,eAAO,MAAM,eAAe,SACpB
|
|
1
|
+
{"version":3,"file":"getPaymentTotal.d.ts","sourceRoot":"","sources":["../../src/utilities/getPaymentTotal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAA;AAE5E,eAAO,MAAM,eAAe,SACpB;IACJ,WAAW,EAAE,WAAW,CAAA;CACzB,GAAG,OAAO,CAAC,YAAY,CAAC,KACxB,MA8CF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/getPaymentTotal.ts"],"sourcesContent":["import type { FieldValues, PaymentField, PriceCondition } from '../types.js'\n\nexport const getPaymentTotal = (\n args:
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getPaymentTotal.ts"],"sourcesContent":["import type { FieldValues, PaymentField, PriceCondition } from '../types.js'\n\nexport const getPaymentTotal = (\n args: {\n fieldValues: FieldValues\n } & Partial<PaymentField>,\n): number => {\n const { basePrice = 0, fieldValues, priceConditions } = args\n\n let total = basePrice\n\n if (Array.isArray(priceConditions) && priceConditions.length > 0) {\n priceConditions.forEach((priceCondition: PriceCondition) => {\n const { condition, fieldToUse, operator, valueForCondition, valueForOperator, valueType } =\n priceCondition\n\n const valueOfField = fieldValues?.[fieldToUse]\n\n if (valueOfField) {\n if (\n condition === 'hasValue' ||\n (condition === 'equals' && valueOfField === valueForCondition) ||\n (condition === 'notEquals' && valueOfField !== valueForCondition)\n ) {\n const valueToUse = Number(valueType === 'valueOfField' ? valueOfField : valueForOperator)\n switch (operator) {\n case 'add': {\n total += valueToUse\n break\n }\n case 'subtract': {\n total -= valueToUse\n break\n }\n case 'multiply': {\n total *= valueToUse\n break\n }\n case 'divide': {\n total /= valueToUse\n break\n }\n default: {\n break\n }\n }\n }\n }\n })\n }\n\n return total\n}\n"],"names":["getPaymentTotal","args","basePrice","fieldValues","priceConditions","total","Array","isArray","length","forEach","priceCondition","condition","fieldToUse","operator","valueForCondition","valueForOperator","valueType","valueOfField","valueToUse","Number"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,CAC7BC;IAIA,MAAM,EAAEC,YAAY,CAAC,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGH;IAExD,IAAII,QAAQH;IAEZ,IAAII,MAAMC,OAAO,CAACH,oBAAoBA,gBAAgBI,MAAM,GAAG,GAAG;QAChEJ,gBAAgBK,OAAO,CAAC,CAACC;YACvB,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,SAAS,EAAE,GACvFN;YAEF,MAAMO,eAAed,aAAa,CAACS,WAAW;YAE9C,IAAIK,cAAc;gBAChB,IACEN,cAAc,cACbA,cAAc,YAAYM,iBAAiBH,qBAC3CH,cAAc,eAAeM,iBAAiBH,mBAC/C;oBACA,MAAMI,aAAaC,OAAOH,cAAc,iBAAiBC,eAAeF;oBACxE,OAAQF;wBACN,KAAK;4BAAO;gCACVR,SAASa;gCACT;4BACF;wBACA,KAAK;4BAAY;gCACfb,SAASa;gCACT;4BACF;wBACA,KAAK;4BAAY;gCACfb,SAASa;gCACT;4BACF;wBACA,KAAK;4BAAU;gCACbb,SAASa;gCACT;4BACF;wBACA;4BAAS;gCACP;4BACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOb;AACT,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyValuePairToHtmlTable.d.ts","sourceRoot":"","sources":["../../src/utilities/keyValuePairToHtmlTable.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,GAAG,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,MAAM,CAS9E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function keyValuePairToHtmlTable(obj) {
|
|
2
|
+
let htmlTable = '<table>';
|
|
3
|
+
for (const [key, value] of Object.entries(obj)){
|
|
4
|
+
htmlTable += `<tr><td>${key}</td><td>${value}</td></tr>`;
|
|
5
|
+
}
|
|
6
|
+
htmlTable += '</table>';
|
|
7
|
+
return htmlTable;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=keyValuePairToHtmlTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/keyValuePairToHtmlTable.ts"],"sourcesContent":["export function keyValuePairToHtmlTable(obj: { [key: string]: string }): string {\n let htmlTable = '<table>'\n\n for (const [key, value] of Object.entries(obj)) {\n htmlTable += `<tr><td>${key}</td><td>${value}</td></tr>`\n }\n\n htmlTable += '</table>'\n return htmlTable\n}\n"],"names":["keyValuePairToHtmlTable","obj","htmlTable","key","value","Object","entries"],"mappings":"AAAA,OAAO,SAASA,wBAAwBC,GAA8B;IACpE,IAAIC,YAAY;IAEhB,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,KAAM;QAC9CC,aAAa,CAAC,QAAQ,EAAEC,IAAI,SAAS,EAAEC,MAAM,UAAU,CAAC;IAC1D;IAEAF,aAAa;IACb,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/lexical/converters/heading.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const HeadingHTMLConverter: 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 return '<' + node?.tag + '>' + childrenText + '</' + node?.tag + '>'\n },\n nodeTypes: ['heading'],\n}\n"],"names":["convertLexicalNodesToHTML","HeadingHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","tag","nodeTypes"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/lexical/converters/heading.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const HeadingHTMLConverter: 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 return '<' + node?.tag + '>' + childrenText + '</' + node?.tag + '>'\n },\n nodeTypes: ['heading'],\n}\n"],"names":["convertLexicalNodesToHTML","HeadingHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","tag","nodeTypes"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,yBAAwB;AAElE,OAAO,MAAMC,uBAA2C;IACtD,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,OAAO,MAAMF,MAAMM,MAAM,MAAMH,eAAe,OAAOH,MAAMM,MAAM;IACnE;IACAC,WAAW;QAAC;KAAU;AACxB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/lexical/converters/linebreak.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nexport const LinebreakHTMLConverter: HTMLConverter<any> = {\n converter() {\n return `<br>`\n },\n nodeTypes: ['linebreak'],\n}\n"],"names":["LinebreakHTMLConverter","converter","nodeTypes"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/lexical/converters/linebreak.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nexport const LinebreakHTMLConverter: HTMLConverter<any> = {\n converter() {\n return `<br>`\n },\n nodeTypes: ['linebreak'],\n}\n"],"names":["LinebreakHTMLConverter","converter","nodeTypes"],"mappings":"AAEA,OAAO,MAAMA,yBAA6C;IACxDC;QACE,OAAO,CAAC,IAAI,CAAC;IACf;IACAC,WAAW;QAAC;KAAY;AAC1B,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/lexical/converters/link.ts"],"sourcesContent":["import 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 const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n let href: string =\n node.fields.linkType === 'custom' ? node.fields.url : node.fields.doc?.value?.id\n\n if (submissionData) {\n href = replaceDoubleCurlys(href, submissionData)\n }\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: ['link'],\n}\n"],"names":["replaceDoubleCurlys","convertLexicalNodesToHTML","LinkHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","rel","fields","newTab","target","href","linkType","url","doc","value","id","nodeTypes"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/lexical/converters/link.ts"],"sourcesContent":["import 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 const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n let href: string =\n node.fields.linkType === 'custom' ? node.fields.url : node.fields.doc?.value?.id\n\n if (submissionData) {\n href = replaceDoubleCurlys(href, submissionData)\n }\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: ['link'],\n}\n"],"names":["replaceDoubleCurlys","convertLexicalNodesToHTML","LinkHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","rel","fields","newTab","target","href","linkType","url","doc","value","id","nodeTypes"],"mappings":"AAEA,SAASA,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,MAAMI,MAAcN,KAAKO,MAAM,CAACC,MAAM,GAAG,+BAA+B;QACxE,MAAMC,SAAiBT,KAAKO,MAAM,CAACC,MAAM,GAAG,qBAAqB;QAEjE,IAAIE,OACFV,KAAKO,MAAM,CAACI,QAAQ,KAAK,WAAWX,KAAKO,MAAM,CAACK,GAAG,GAAGZ,KAAKO,MAAM,CAACM,GAAG,EAAEC,OAAOC;QAEhF,IAAIb,gBAAgB;YAClBQ,OAAOf,oBAAoBe,MAAMR;QACnC;QAEA,OAAO,CAAC,SAAS,EAAEQ,KAAK,CAAC,EAAED,OAAO,EAAEH,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;IAC/D;IACAa,WAAW;QAAC;KAAO;AACrB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/lexical/converters/list.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const ListHTMLConverter: HTMLConverter<any> = {\n converter: async ({ 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 return `<${node?.tag} class=\"${node?.listType}\">${childrenText}</${node?.tag}>`\n },\n nodeTypes: ['list'],\n}\n\nexport const ListItemHTMLConverter: HTMLConverter<any> = {\n converter: async ({ converters, node, parent }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n return `<li aria-checked=${node.checked ? 'true' : 'false'} class=\"${\n 'list-item-checkbox' + node.checked\n ? 'list-item-checkbox-checked'\n : 'list-item-checkbox-unchecked'\n }\"\n role=\"checkbox\"\n tabIndex=${-1}\n value=${node?.value}\n >\n ${childrenText}\n </li>`\n } else {\n return `<li value=${node?.value}>${childrenText}</li>`\n }\n },\n nodeTypes: ['listitem'],\n}\n"],"names":["convertLexicalNodesToHTML","ListHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","tag","listType","nodeTypes","ListItemHTMLConverter","checked","value"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/lexical/converters/list.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const ListHTMLConverter: HTMLConverter<any> = {\n converter: async ({ 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 return `<${node?.tag} class=\"${node?.listType}\">${childrenText}</${node?.tag}>`\n },\n nodeTypes: ['list'],\n}\n\nexport const ListItemHTMLConverter: HTMLConverter<any> = {\n converter: async ({ converters, node, parent }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n return `<li aria-checked=${node.checked ? 'true' : 'false'} class=\"${\n 'list-item-checkbox' + node.checked\n ? 'list-item-checkbox-checked'\n : 'list-item-checkbox-unchecked'\n }\"\n role=\"checkbox\"\n tabIndex=${-1}\n value=${node?.value}\n >\n ${childrenText}\n </li>`\n } else {\n return `<li value=${node?.value}>${childrenText}</li>`\n }\n },\n nodeTypes: ['listitem'],\n}\n"],"names":["convertLexicalNodesToHTML","ListHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","tag","listType","nodeTypes","ListItemHTMLConverter","checked","value"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,yBAAwB;AAElE,OAAO,MAAMC,oBAAwC;IACnDC,WAAW,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,cAAc,EAAE;QAC5D,MAAMC,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;YACAC;QACF;QAEA,OAAO,CAAC,CAAC,EAAEF,MAAMM,IAAI,QAAQ,EAAEN,MAAMO,SAAS,EAAE,EAAEJ,aAAa,EAAE,EAAEH,MAAMM,IAAI,CAAC,CAAC;IACjF;IACAE,WAAW;QAAC;KAAO;AACrB,EAAC;AAED,OAAO,MAAMC,wBAA4C;IACvDX,WAAW,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAE;QAC5C,MAAME,eAAe,MAAMP,0BAA0B;YACnDG;YACAK,cAAcJ,KAAKK,QAAQ;YAC3BJ,QAAQ;gBACN,GAAGD,IAAI;gBACPC;YACF;QACF;QAEA,IAAI,cAAcA,UAAUA,QAAQM,aAAa,SAAS;YACxD,OAAO,CAAC,iBAAiB,EAAEP,KAAKU,OAAO,GAAG,SAAS,QAAQ,QAAQ,EACjE,uBAAuBV,KAAKU,OAAO,GAC/B,+BACA,+BACL;;mBAEY,EAAE,CAAC,EAAE;gBACR,EAAEV,MAAMW,MAAM;;UAEpB,EAAER,aAAa;eACV,CAAC;QACZ,OAAO;YACL,OAAO,CAAC,UAAU,EAAEH,MAAMW,MAAM,CAAC,EAAER,aAAa,KAAK,CAAC;QACxD;IACF;IACAK,WAAW;QAAC;KAAW;AACzB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/lexical/converters/paragraph.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const ParagraphHTMLConverter: 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 return `<p>${childrenText}</p>`\n },\n nodeTypes: ['paragraph'],\n}\n"],"names":["convertLexicalNodesToHTML","ParagraphHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","nodeTypes"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/lexical/converters/paragraph.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const ParagraphHTMLConverter: 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 return `<p>${childrenText}</p>`\n },\n nodeTypes: ['paragraph'],\n}\n"],"names":["convertLexicalNodesToHTML","ParagraphHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","nodeTypes"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,yBAAwB;AAElE,OAAO,MAAMC,yBAA6C;IACxD,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;QACA,OAAO,CAAC,GAAG,EAAEC,aAAa,IAAI,CAAC;IACjC;IACAG,WAAW;QAAC;KAAY;AAC1B,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/lexical/converters/quote.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const QuoteHTMLConverter: 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 return `<blockquote>${childrenText}</blockquote>`\n },\n nodeTypes: ['quote'],\n}\n"],"names":["convertLexicalNodesToHTML","QuoteHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","nodeTypes"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/lexical/converters/quote.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../serializeLexical.js'\n\nexport const QuoteHTMLConverter: 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 return `<blockquote>${childrenText}</blockquote>`\n },\n nodeTypes: ['quote'],\n}\n"],"names":["convertLexicalNodesToHTML","QuoteHTMLConverter","converter","converters","node","parent","submissionData","childrenText","lexicalNodes","children","nodeTypes"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,yBAAwB;AAElE,OAAO,MAAMC,qBAAyC;IACpD,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,OAAO,CAAC,YAAY,EAAEC,aAAa,aAAa,CAAC;IACnD;IACAG,WAAW;QAAC;KAAQ;AACtB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utilities/lexical/converters/text.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { replaceDoubleCurlys } from '../../replaceDoubleCurlys.js'\nimport { NodeFormat } from '../nodeFormat.js'\n\nexport const TextHTMLConverter: HTMLConverter<any> = {\n converter({ node, submissionData }) {\n let text = node.text\n\n if (submissionData) {\n text = replaceDoubleCurlys(text, submissionData)\n }\n\n if (node.format & NodeFormat.IS_BOLD) {\n text = `<strong>${text}</strong>`\n }\n if (node.format & NodeFormat.IS_ITALIC) {\n text = `<em>${text}</em>`\n }\n if (node.format & NodeFormat.IS_STRIKETHROUGH) {\n text = `<span style=\"text-decoration: line-through\">${text}</span>`\n }\n if (node.format & NodeFormat.IS_UNDERLINE) {\n text = `<span style=\"text-decoration: underline\">${text}</span>`\n }\n if (node.format & NodeFormat.IS_CODE) {\n text = `<code>${text}</code>`\n }\n if (node.format & NodeFormat.IS_SUBSCRIPT) {\n text = `<sub>${text}</sub>`\n }\n if (node.format & NodeFormat.IS_SUPERSCRIPT) {\n text = `<sup>${text}</sup>`\n }\n\n return text\n },\n nodeTypes: ['text'],\n}\n"],"names":["replaceDoubleCurlys","NodeFormat","TextHTMLConverter","converter","node","submissionData","text","format","IS_BOLD","IS_ITALIC","IS_STRIKETHROUGH","IS_UNDERLINE","IS_CODE","IS_SUBSCRIPT","IS_SUPERSCRIPT","nodeTypes"],"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utilities/lexical/converters/text.ts"],"sourcesContent":["import type { HTMLConverter } from '../types.js'\n\nimport { replaceDoubleCurlys } from '../../replaceDoubleCurlys.js'\nimport { NodeFormat } from '../nodeFormat.js'\n\nexport const TextHTMLConverter: HTMLConverter<any> = {\n converter({ node, submissionData }) {\n let text = node.text\n\n if (submissionData) {\n text = replaceDoubleCurlys(text, submissionData)\n }\n\n if (node.format & NodeFormat.IS_BOLD) {\n text = `<strong>${text}</strong>`\n }\n if (node.format & NodeFormat.IS_ITALIC) {\n text = `<em>${text}</em>`\n }\n if (node.format & NodeFormat.IS_STRIKETHROUGH) {\n text = `<span style=\"text-decoration: line-through\">${text}</span>`\n }\n if (node.format & NodeFormat.IS_UNDERLINE) {\n text = `<span style=\"text-decoration: underline\">${text}</span>`\n }\n if (node.format & NodeFormat.IS_CODE) {\n text = `<code>${text}</code>`\n }\n if (node.format & NodeFormat.IS_SUBSCRIPT) {\n text = `<sub>${text}</sub>`\n }\n if (node.format & NodeFormat.IS_SUPERSCRIPT) {\n text = `<sup>${text}</sup>`\n }\n\n return text\n },\n nodeTypes: ['text'],\n}\n"],"names":["replaceDoubleCurlys","NodeFormat","TextHTMLConverter","converter","node","submissionData","text","format","IS_BOLD","IS_ITALIC","IS_STRIKETHROUGH","IS_UNDERLINE","IS_CODE","IS_SUBSCRIPT","IS_SUPERSCRIPT","nodeTypes"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ,+BAA8B;AAClE,SAASC,UAAU,QAAQ,mBAAkB;AAE7C,OAAO,MAAMC,oBAAwC;IACnDC,WAAU,EAAEC,IAAI,EAAEC,cAAc,EAAE;QAChC,IAAIC,OAAOF,KAAKE,IAAI;QAEpB,IAAID,gBAAgB;YAClBC,OAAON,oBAAoBM,MAAMD;QACnC;QAEA,IAAID,KAAKG,MAAM,GAAGN,WAAWO,OAAO,EAAE;YACpCF,OAAO,CAAC,QAAQ,EAAEA,KAAK,SAAS,CAAC;QACnC;QACA,IAAIF,KAAKG,MAAM,GAAGN,WAAWQ,SAAS,EAAE;YACtCH,OAAO,CAAC,IAAI,EAAEA,KAAK,KAAK,CAAC;QAC3B;QACA,IAAIF,KAAKG,MAAM,GAAGN,WAAWS,gBAAgB,EAAE;YAC7CJ,OAAO,CAAC,4CAA4C,EAAEA,KAAK,OAAO,CAAC;QACrE;QACA,IAAIF,KAAKG,MAAM,GAAGN,WAAWU,YAAY,EAAE;YACzCL,OAAO,CAAC,yCAAyC,EAAEA,KAAK,OAAO,CAAC;QAClE;QACA,IAAIF,KAAKG,MAAM,GAAGN,WAAWW,OAAO,EAAE;YACpCN,OAAO,CAAC,MAAM,EAAEA,KAAK,OAAO,CAAC;QAC/B;QACA,IAAIF,KAAKG,MAAM,GAAGN,WAAWY,YAAY,EAAE;YACzCP,OAAO,CAAC,KAAK,EAAEA,KAAK,MAAM,CAAC;QAC7B;QACA,IAAIF,KAAKG,MAAM,GAAGN,WAAWa,cAAc,EAAE;YAC3CR,OAAO,CAAC,KAAK,EAAEA,KAAK,MAAM,CAAC;QAC7B;QAEA,OAAOA;IACT;IACAS,WAAW;QAAC;KAAO;AACrB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/lexical/defaultConverters.ts"],"sourcesContent":["import type { HTMLConverter } from './types.js'\n\nimport { HeadingHTMLConverter } from './converters/heading.js'\nimport { LinebreakHTMLConverter } from './converters/linebreak.js'\nimport { LinkHTMLConverter } from './converters/link.js'\nimport { ListHTMLConverter, ListItemHTMLConverter } from './converters/list.js'\nimport { ParagraphHTMLConverter } from './converters/paragraph.js'\nimport { QuoteHTMLConverter } from './converters/quote.js'\nimport { TextHTMLConverter } from './converters/text.js'\n\nexport const defaultHTMLConverters: HTMLConverter[] = [\n ParagraphHTMLConverter,\n TextHTMLConverter,\n LinebreakHTMLConverter,\n LinkHTMLConverter,\n HeadingHTMLConverter,\n QuoteHTMLConverter,\n ListHTMLConverter,\n ListItemHTMLConverter,\n]\n"],"names":["HeadingHTMLConverter","LinebreakHTMLConverter","LinkHTMLConverter","ListHTMLConverter","ListItemHTMLConverter","ParagraphHTMLConverter","QuoteHTMLConverter","TextHTMLConverter","defaultHTMLConverters"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/lexical/defaultConverters.ts"],"sourcesContent":["import type { HTMLConverter } from './types.js'\n\nimport { HeadingHTMLConverter } from './converters/heading.js'\nimport { LinebreakHTMLConverter } from './converters/linebreak.js'\nimport { LinkHTMLConverter } from './converters/link.js'\nimport { ListHTMLConverter, ListItemHTMLConverter } from './converters/list.js'\nimport { ParagraphHTMLConverter } from './converters/paragraph.js'\nimport { QuoteHTMLConverter } from './converters/quote.js'\nimport { TextHTMLConverter } from './converters/text.js'\n\nexport const defaultHTMLConverters: HTMLConverter[] = [\n ParagraphHTMLConverter,\n TextHTMLConverter,\n LinebreakHTMLConverter,\n LinkHTMLConverter,\n HeadingHTMLConverter,\n QuoteHTMLConverter,\n ListHTMLConverter,\n ListItemHTMLConverter,\n]\n"],"names":["HeadingHTMLConverter","LinebreakHTMLConverter","LinkHTMLConverter","ListHTMLConverter","ListItemHTMLConverter","ParagraphHTMLConverter","QuoteHTMLConverter","TextHTMLConverter","defaultHTMLConverters"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,0BAAyB;AAC9D,SAASC,sBAAsB,QAAQ,4BAA2B;AAClE,SAASC,iBAAiB,QAAQ,uBAAsB;AACxD,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,uBAAsB;AAC/E,SAASC,sBAAsB,QAAQ,4BAA2B;AAClE,SAASC,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,iBAAiB,QAAQ,uBAAsB;AAExD,OAAO,MAAMC,wBAAyC;IACpDH;IACAE;IACAN;IACAC;IACAF;IACAM;IACAH;IACAC;CACD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/lexical/nodeFormat.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-objects */\n/* eslint-disable regexp/no-obscure-range */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n//This copy-and-pasted from lexical here: https://github.com/facebook/lexical/blob/c2ceee223f46543d12c574e62155e619f9a18a5d/packages/lexical/src/LexicalConstants.ts\n\n// DOM\nexport const NodeFormat = {\n DOM_ELEMENT_TYPE: 1,\n DOM_TEXT_TYPE: 3,\n // Reconciling\n NO_DIRTY_NODES: 0,\n HAS_DIRTY_NODES: 1,\n FULL_RECONCILE: 2,\n // Text node modes\n IS_NORMAL: 0,\n IS_TOKEN: 1,\n IS_SEGMENTED: 2,\n IS_INERT: 3,\n // Text node formatting\n IS_BOLD: 1,\n IS_ITALIC: 1 << 1,\n IS_STRIKETHROUGH: 1 << 2,\n IS_UNDERLINE: 1 << 3,\n IS_CODE: 1 << 4,\n IS_SUBSCRIPT: 1 << 5,\n IS_SUPERSCRIPT: 1 << 6,\n IS_HIGHLIGHT: 1 << 7,\n // Text node details\n IS_DIRECTIONLESS: 1,\n IS_UNMERGEABLE: 1 << 1,\n // Element node formatting\n IS_ALIGN_LEFT: 1,\n IS_ALIGN_CENTER: 2,\n IS_ALIGN_RIGHT: 3,\n IS_ALIGN_JUSTIFY: 4,\n IS_ALIGN_START: 5,\n IS_ALIGN_END: 6,\n} as const\n\nexport const IS_ALL_FORMATTING =\n NodeFormat.IS_BOLD |\n NodeFormat.IS_ITALIC |\n NodeFormat.IS_STRIKETHROUGH |\n NodeFormat.IS_UNDERLINE |\n NodeFormat.IS_CODE |\n NodeFormat.IS_SUBSCRIPT |\n NodeFormat.IS_SUPERSCRIPT |\n NodeFormat.IS_HIGHLIGHT\n\n// Reconciliation\nexport const NON_BREAKING_SPACE = '\\u00A0'\n\nexport const DOUBLE_LINE_BREAK = '\\n\\n'\n\n// For FF, we need to use a non-breaking space, or it gets composition\n// in a stuck state.\n\nconst RTL = '\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC'\nconst LTR =\n 'A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6' +\n '\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF\\u200E\\u2C00-\\uFB1C' +\n '\\uFE00-\\uFE6F\\uFEFD-\\uFFFF'\n\n// eslint-disable-next-line no-misleading-character-class,regexp/no-misleading-unicode-character\nexport const RTL_REGEX = new RegExp('^[^' + LTR + ']*[' + RTL + ']')\n// eslint-disable-next-line no-misleading-character-class,regexp/no-misleading-unicode-character\nexport const LTR_REGEX = new RegExp('^[^' + RTL + ']*[' + LTR + ']')\n\nexport const TEXT_TYPE_TO_FORMAT: Record<any | string, number> = {\n bold: NodeFormat.IS_BOLD,\n code: NodeFormat.IS_CODE,\n highlight: NodeFormat.IS_HIGHLIGHT,\n italic: NodeFormat.IS_ITALIC,\n strikethrough: NodeFormat.IS_STRIKETHROUGH,\n subscript: NodeFormat.IS_SUBSCRIPT,\n superscript: NodeFormat.IS_SUPERSCRIPT,\n underline: NodeFormat.IS_UNDERLINE,\n}\n\nexport const DETAIL_TYPE_TO_DETAIL: Record<any | string, number> = {\n directionless: NodeFormat.IS_DIRECTIONLESS,\n unmergeable: NodeFormat.IS_UNMERGEABLE,\n}\n\nexport const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<any, ''>, number> = {\n center: NodeFormat.IS_ALIGN_CENTER,\n end: NodeFormat.IS_ALIGN_END,\n justify: NodeFormat.IS_ALIGN_JUSTIFY,\n left: NodeFormat.IS_ALIGN_LEFT,\n right: NodeFormat.IS_ALIGN_RIGHT,\n start: NodeFormat.IS_ALIGN_START,\n}\n\nexport const ELEMENT_FORMAT_TO_TYPE: Record<number, any> = {\n [NodeFormat.IS_ALIGN_CENTER]: 'center',\n [NodeFormat.IS_ALIGN_END]: 'end',\n [NodeFormat.IS_ALIGN_JUSTIFY]: 'justify',\n [NodeFormat.IS_ALIGN_LEFT]: 'left',\n [NodeFormat.IS_ALIGN_RIGHT]: 'right',\n [NodeFormat.IS_ALIGN_START]: 'start',\n}\n\nexport const TEXT_MODE_TO_TYPE: Record<any, 0 | 1 | 2> = {\n normal: NodeFormat.IS_NORMAL,\n segmented: NodeFormat.IS_SEGMENTED,\n token: NodeFormat.IS_TOKEN,\n}\n\nexport const TEXT_TYPE_TO_MODE: Record<number, any> = {\n [NodeFormat.IS_NORMAL]: 'normal',\n [NodeFormat.IS_SEGMENTED]: 'segmented',\n [NodeFormat.IS_TOKEN]: 'token',\n}\n"],"names":["NodeFormat","DOM_ELEMENT_TYPE","DOM_TEXT_TYPE","NO_DIRTY_NODES","HAS_DIRTY_NODES","FULL_RECONCILE","IS_NORMAL","IS_TOKEN","IS_SEGMENTED","IS_INERT","IS_BOLD","IS_ITALIC","IS_STRIKETHROUGH","IS_UNDERLINE","IS_CODE","IS_SUBSCRIPT","IS_SUPERSCRIPT","IS_HIGHLIGHT","IS_DIRECTIONLESS","IS_UNMERGEABLE","IS_ALIGN_LEFT","IS_ALIGN_CENTER","IS_ALIGN_RIGHT","IS_ALIGN_JUSTIFY","IS_ALIGN_START","IS_ALIGN_END","IS_ALL_FORMATTING","NON_BREAKING_SPACE","DOUBLE_LINE_BREAK","RTL","LTR","RTL_REGEX","RegExp","LTR_REGEX","TEXT_TYPE_TO_FORMAT","bold","code","highlight","italic","strikethrough","subscript","superscript","underline","DETAIL_TYPE_TO_DETAIL","directionless","unmergeable","ELEMENT_TYPE_TO_FORMAT","center","end","justify","left","right","start","ELEMENT_FORMAT_TO_TYPE","TEXT_MODE_TO_TYPE","normal","segmented","token","TEXT_TYPE_TO_MODE"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/lexical/nodeFormat.ts"],"sourcesContent":["/* eslint-disable perfectionist/sort-objects */\n/* eslint-disable regexp/no-obscure-range */\n/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n//This copy-and-pasted from lexical here: https://github.com/facebook/lexical/blob/c2ceee223f46543d12c574e62155e619f9a18a5d/packages/lexical/src/LexicalConstants.ts\n\n// DOM\nexport const NodeFormat = {\n DOM_ELEMENT_TYPE: 1,\n DOM_TEXT_TYPE: 3,\n // Reconciling\n NO_DIRTY_NODES: 0,\n HAS_DIRTY_NODES: 1,\n FULL_RECONCILE: 2,\n // Text node modes\n IS_NORMAL: 0,\n IS_TOKEN: 1,\n IS_SEGMENTED: 2,\n IS_INERT: 3,\n // Text node formatting\n IS_BOLD: 1,\n IS_ITALIC: 1 << 1,\n IS_STRIKETHROUGH: 1 << 2,\n IS_UNDERLINE: 1 << 3,\n IS_CODE: 1 << 4,\n IS_SUBSCRIPT: 1 << 5,\n IS_SUPERSCRIPT: 1 << 6,\n IS_HIGHLIGHT: 1 << 7,\n // Text node details\n IS_DIRECTIONLESS: 1,\n IS_UNMERGEABLE: 1 << 1,\n // Element node formatting\n IS_ALIGN_LEFT: 1,\n IS_ALIGN_CENTER: 2,\n IS_ALIGN_RIGHT: 3,\n IS_ALIGN_JUSTIFY: 4,\n IS_ALIGN_START: 5,\n IS_ALIGN_END: 6,\n} as const\n\nexport const IS_ALL_FORMATTING =\n NodeFormat.IS_BOLD |\n NodeFormat.IS_ITALIC |\n NodeFormat.IS_STRIKETHROUGH |\n NodeFormat.IS_UNDERLINE |\n NodeFormat.IS_CODE |\n NodeFormat.IS_SUBSCRIPT |\n NodeFormat.IS_SUPERSCRIPT |\n NodeFormat.IS_HIGHLIGHT\n\n// Reconciliation\nexport const NON_BREAKING_SPACE = '\\u00A0'\n\nexport const DOUBLE_LINE_BREAK = '\\n\\n'\n\n// For FF, we need to use a non-breaking space, or it gets composition\n// in a stuck state.\n\nconst RTL = '\\u0591-\\u07FF\\uFB1D-\\uFDFD\\uFE70-\\uFEFC'\nconst LTR =\n 'A-Za-z\\u00C0-\\u00D6\\u00D8-\\u00F6' +\n '\\u00F8-\\u02B8\\u0300-\\u0590\\u0800-\\u1FFF\\u200E\\u2C00-\\uFB1C' +\n '\\uFE00-\\uFE6F\\uFEFD-\\uFFFF'\n\n// eslint-disable-next-line no-misleading-character-class,regexp/no-misleading-unicode-character\nexport const RTL_REGEX = new RegExp('^[^' + LTR + ']*[' + RTL + ']')\n// eslint-disable-next-line no-misleading-character-class,regexp/no-misleading-unicode-character\nexport const LTR_REGEX = new RegExp('^[^' + RTL + ']*[' + LTR + ']')\n\nexport const TEXT_TYPE_TO_FORMAT: Record<any | string, number> = {\n bold: NodeFormat.IS_BOLD,\n code: NodeFormat.IS_CODE,\n highlight: NodeFormat.IS_HIGHLIGHT,\n italic: NodeFormat.IS_ITALIC,\n strikethrough: NodeFormat.IS_STRIKETHROUGH,\n subscript: NodeFormat.IS_SUBSCRIPT,\n superscript: NodeFormat.IS_SUPERSCRIPT,\n underline: NodeFormat.IS_UNDERLINE,\n}\n\nexport const DETAIL_TYPE_TO_DETAIL: Record<any | string, number> = {\n directionless: NodeFormat.IS_DIRECTIONLESS,\n unmergeable: NodeFormat.IS_UNMERGEABLE,\n}\n\nexport const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<any, ''>, number> = {\n center: NodeFormat.IS_ALIGN_CENTER,\n end: NodeFormat.IS_ALIGN_END,\n justify: NodeFormat.IS_ALIGN_JUSTIFY,\n left: NodeFormat.IS_ALIGN_LEFT,\n right: NodeFormat.IS_ALIGN_RIGHT,\n start: NodeFormat.IS_ALIGN_START,\n}\n\nexport const ELEMENT_FORMAT_TO_TYPE: Record<number, any> = {\n [NodeFormat.IS_ALIGN_CENTER]: 'center',\n [NodeFormat.IS_ALIGN_END]: 'end',\n [NodeFormat.IS_ALIGN_JUSTIFY]: 'justify',\n [NodeFormat.IS_ALIGN_LEFT]: 'left',\n [NodeFormat.IS_ALIGN_RIGHT]: 'right',\n [NodeFormat.IS_ALIGN_START]: 'start',\n}\n\nexport const TEXT_MODE_TO_TYPE: Record<any, 0 | 1 | 2> = {\n normal: NodeFormat.IS_NORMAL,\n segmented: NodeFormat.IS_SEGMENTED,\n token: NodeFormat.IS_TOKEN,\n}\n\nexport const TEXT_TYPE_TO_MODE: Record<number, any> = {\n [NodeFormat.IS_NORMAL]: 'normal',\n [NodeFormat.IS_SEGMENTED]: 'segmented',\n [NodeFormat.IS_TOKEN]: 'token',\n}\n"],"names":["NodeFormat","DOM_ELEMENT_TYPE","DOM_TEXT_TYPE","NO_DIRTY_NODES","HAS_DIRTY_NODES","FULL_RECONCILE","IS_NORMAL","IS_TOKEN","IS_SEGMENTED","IS_INERT","IS_BOLD","IS_ITALIC","IS_STRIKETHROUGH","IS_UNDERLINE","IS_CODE","IS_SUBSCRIPT","IS_SUPERSCRIPT","IS_HIGHLIGHT","IS_DIRECTIONLESS","IS_UNMERGEABLE","IS_ALIGN_LEFT","IS_ALIGN_CENTER","IS_ALIGN_RIGHT","IS_ALIGN_JUSTIFY","IS_ALIGN_START","IS_ALIGN_END","IS_ALL_FORMATTING","NON_BREAKING_SPACE","DOUBLE_LINE_BREAK","RTL","LTR","RTL_REGEX","RegExp","LTR_REGEX","TEXT_TYPE_TO_FORMAT","bold","code","highlight","italic","strikethrough","subscript","superscript","underline","DETAIL_TYPE_TO_DETAIL","directionless","unmergeable","ELEMENT_TYPE_TO_FORMAT","center","end","justify","left","right","start","ELEMENT_FORMAT_TO_TYPE","TEXT_MODE_TO_TYPE","normal","segmented","token","TEXT_TYPE_TO_MODE"],"mappings":"AAAA,6CAA6C,GAC7C,0CAA0C,GAC1C,oEAAoE,GACpE,oKAAoK;AAEpK,MAAM;AACN,OAAO,MAAMA,aAAa;IACxBC,kBAAkB;IAClBC,eAAe;IACf,cAAc;IACdC,gBAAgB;IAChBC,iBAAiB;IACjBC,gBAAgB;IAChB,kBAAkB;IAClBC,WAAW;IACXC,UAAU;IACVC,cAAc;IACdC,UAAU;IACV,uBAAuB;IACvBC,SAAS;IACTC,WAAW,KAAK;IAChBC,kBAAkB,KAAK;IACvBC,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WqB,eAAe;IAClC2B,KAAKhD,WAAWyB,YAAY;IAC5BwB,SAASjD,WAAWuB,gBAAgB;IACpC2B,MAAMlD,WAAWoB,aAAa;IAC9B+B,OAAOnD,WAAWsB,cAAc;IAChC8B,OAAOpD,WAAWwB,cAAc;AAClC,EAAC;AAED,OAAO,MAAM6B,yBAA8C;IACzD,CAACrD,WAAWqB,eAAe,CAAC,EAAE;IAC9B,CAACrB,WAAWyB,YAAY,CAAC,EAAE;IAC3B,CAACzB,WAAWuB,gBAAgB,CAAC,EAAE;IAC/B,CAACvB,WAAWoB,aAAa,CAAC,EAAE;IAC5B,CAACpB,WAAWsB,cAAc,CAAC,EAAE;IAC7B,CAACtB,WAAWwB,cAAc,CAAC,EAAE;AAC/B,EAAC;AAED,OAAO,MAAM8B,oBAA4C;IACvDC,QAAQvD,WAAWM,SAAS;IAC5BkD,WAAWxD,WAAWQ,YAAY;IAClCiD,OAAOzD,WAAWO,QAAQ;AAC5B,EAAC;AAED,OAAO,MAAMmD,oBAAyC;IACpD,CAAC1D,WAAWM,SAAS,CAAC,EAAE;IACxB,CAACN,WAAWQ,YAAY,CAAC,EAAE;IAC3B,CAACR,WAAWO,QAAQ,CAAC,EAAE;AACzB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/lexical/serializeLexical.ts"],"sourcesContent":["import type { HTMLConverter, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { defaultHTMLConverters } from './defaultConverters.js'\n\nexport async function serializeLexical(data?: any, submissionData?: any): Promise<string> {\n const converters: HTMLConverter[] = defaultHTMLConverters\n\n if (data?.root?.children?.length) {\n return await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: data?.root?.children,\n parent: data?.root,\n submissionData,\n })\n }\n return ''\n}\n\nexport async function convertLexicalNodesToHTML({\n converters,\n lexicalNodes,\n parent,\n submissionData,\n}: {\n converters: HTMLConverter[]\n lexicalNodes: any[]\n parent: SerializedLexicalNodeWithParent\n submissionData?: any\n}): Promise<string> {\n const unknownConverter = converters.find((converter) => converter.nodeTypes.includes('unknown'))\n\n const htmlArray = await Promise.all(\n lexicalNodes.map(async (node, i) => {\n const converterForNode = converters.find((converter) =>\n converter.nodeTypes.includes(node.type),\n )\n if (!converterForNode) {\n if (unknownConverter) {\n return unknownConverter.converter({\n childIndex: i,\n converters,\n node,\n parent,\n submissionData,\n })\n }\n return '<span>unknown node</span>'\n }\n\n return converterForNode.converter({\n childIndex: i,\n converters,\n node,\n parent,\n submissionData,\n })\n }),\n )\n\n return htmlArray.join('') || ''\n}\n"],"names":["defaultHTMLConverters","serializeLexical","data","submissionData","converters","root","children","length","convertLexicalNodesToHTML","lexicalNodes","parent","unknownConverter","find","converter","nodeTypes","includes","htmlArray","Promise","all","map","node","i","converterForNode","type","childIndex","join"],"
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/lexical/serializeLexical.ts"],"sourcesContent":["import type { HTMLConverter, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { defaultHTMLConverters } from './defaultConverters.js'\n\nexport async function serializeLexical(data?: any, submissionData?: any): Promise<string> {\n const converters: HTMLConverter[] = defaultHTMLConverters\n\n if (data?.root?.children?.length) {\n return await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: data?.root?.children,\n parent: data?.root,\n submissionData,\n })\n }\n return ''\n}\n\nexport async function convertLexicalNodesToHTML({\n converters,\n lexicalNodes,\n parent,\n submissionData,\n}: {\n converters: HTMLConverter[]\n lexicalNodes: any[]\n parent: SerializedLexicalNodeWithParent\n submissionData?: any\n}): Promise<string> {\n const unknownConverter = converters.find((converter) => converter.nodeTypes.includes('unknown'))\n\n const htmlArray = await Promise.all(\n lexicalNodes.map(async (node, i) => {\n const converterForNode = converters.find((converter) =>\n converter.nodeTypes.includes(node.type),\n )\n if (!converterForNode) {\n if (unknownConverter) {\n return unknownConverter.converter({\n childIndex: i,\n converters,\n node,\n parent,\n submissionData,\n })\n }\n return '<span>unknown node</span>'\n }\n\n return converterForNode.converter({\n childIndex: i,\n converters,\n node,\n parent,\n submissionData,\n })\n }),\n )\n\n return htmlArray.join('') || ''\n}\n"],"names":["defaultHTMLConverters","serializeLexical","data","submissionData","converters","root","children","length","convertLexicalNodesToHTML","lexicalNodes","parent","unknownConverter","find","converter","nodeTypes","includes","htmlArray","Promise","all","map","node","i","converterForNode","type","childIndex","join"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,yBAAwB;AAE9D,OAAO,eAAeC,iBAAiBC,IAAU,EAAEC,cAAoB;IACrE,MAAMC,aAA8BJ;IAEpC,IAAIE,MAAMG,MAAMC,UAAUC,QAAQ;QAChC,OAAO,MAAMC,0BAA0B;YACrCJ;YACAK,cAAcP,MAAMG,MAAMC;YAC1BI,QAAQR,MAAMG;YACdF;QACF;IACF;IACA,OAAO;AACT;AAEA,OAAO,eAAeK,0BAA0B,EAC9CJ,UAAU,EACVK,YAAY,EACZC,MAAM,EACNP,cAAc,EAMf;IACC,MAAMQ,mBAAmBP,WAAWQ,IAAI,CAAC,CAACC,YAAcA,UAAUC,SAAS,CAACC,QAAQ,CAAC;IAErF,MAAMC,YAAY,MAAMC,QAAQC,GAAG,CACjCT,aAAaU,GAAG,CAAC,OAAOC,MAAMC;QAC5B,MAAMC,mBAAmBlB,WAAWQ,IAAI,CAAC,CAACC,YACxCA,UAAUC,SAAS,CAACC,QAAQ,CAACK,KAAKG,IAAI;QAExC,IAAI,CAACD,kBAAkB;YACrB,IAAIX,kBAAkB;gBACpB,OAAOA,iBAAiBE,SAAS,CAAC;oBAChCW,YAAYH;oBACZjB;oBACAgB;oBACAV;oBACAP;gBACF;YACF;YACA,OAAO;QACT;QAEA,OAAOmB,iBAAiBT,SAAS,CAAC;YAChCW,YAAYH;YACZjB;YACAgB;YACAV;YACAP;QACF;IACF;IAGF,OAAOa,UAAUS,IAAI,CAAC,OAAO;AAC/B"}
|
|
@@ -8,7 +8,7 @@ export type HTMLConverter<T = any> = {
|
|
|
8
8
|
}) => Promise<string> | string;
|
|
9
9
|
nodeTypes: string[];
|
|
10
10
|
};
|
|
11
|
-
export type SerializedLexicalNodeWithParent =
|
|
11
|
+
export type SerializedLexicalNodeWithParent = {
|
|
12
12
|
parent?: any;
|
|
13
|
-
};
|
|
13
|
+
} & any;
|
|
14
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utilities/lexical/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,GAAG,IAAI;IACnC,SAAS,EAAE,CAAC,EACV,UAAU,EACV,UAAU,EACV,IAAI,EACJ,MAAM,EACN,cAAc,GACf,EAAE;QACD,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,aAAa,EAAE,CAAA;QAC3B,IAAI,EAAE,CAAC,CAAA;QACP,MAAM,EAAE,+BAA+B,CAAA;QACvC,cAAc,CAAC,EAAE,GAAG,CAAA;KACrB,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utilities/lexical/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,GAAG,IAAI;IACnC,SAAS,EAAE,CAAC,EACV,UAAU,EACV,UAAU,EACV,IAAI,EACJ,MAAM,EACN,cAAc,GACf,EAAE;QACD,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,aAAa,EAAE,CAAA;QAC3B,IAAI,EAAE,CAAC,CAAA;QACP,MAAM,EAAE,+BAA+B,CAAA;QACvC,cAAc,CAAC,EAAE,GAAG,CAAA;KACrB,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,CAAC,EAAE,GAAG,CAAA;CACb,GAAG,GAAG,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/lexical/types.ts"],"sourcesContent":["export type HTMLConverter<T = any> = {\n converter: ({\n childIndex,\n converters,\n node,\n parent,\n submissionData,\n }: {\n childIndex: number\n converters: HTMLConverter[]\n node: T\n parent: SerializedLexicalNodeWithParent\n submissionData?: any\n }) => Promise<string> | string\n nodeTypes: string[]\n}\n\nexport type SerializedLexicalNodeWithParent =
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/lexical/types.ts"],"sourcesContent":["export type HTMLConverter<T = any> = {\n converter: ({\n childIndex,\n converters,\n node,\n parent,\n submissionData,\n }: {\n childIndex: number\n converters: HTMLConverter[]\n node: T\n parent: SerializedLexicalNodeWithParent\n submissionData?: any\n }) => Promise<string> | string\n nodeTypes: string[]\n}\n\nexport type SerializedLexicalNodeWithParent = {\n parent?: any\n} & any\n"],"names":[],"mappings":"AAiBA,WAEO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replaceDoubleCurlys.d.ts","sourceRoot":"","sources":["../../src/utilities/replaceDoubleCurlys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replaceDoubleCurlys.d.ts","sourceRoot":"","sources":["../../src/utilities/replaceDoubleCurlys.ts"],"names":[],"mappings":"AAEA,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,KAAK,cAAc,GAAG,aAAa,EAAE,CAAA;AAErC,eAAO,MAAM,mBAAmB,QAAS,MAAM,cAAc,cAAc,KAAG,MA4B7E,CAAA"}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
import { keyValuePairToHtmlTable } from './keyValuePairToHtmlTable.js';
|
|
1
2
|
export const replaceDoubleCurlys = (str, variables)=>{
|
|
2
3
|
const regex = /\{\{(.+?)\}\}/g;
|
|
3
4
|
if (str && variables) {
|
|
4
5
|
return str.replace(regex, (_, variable)=>{
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
if (variable.includes('*')) {
|
|
7
|
+
if (variable === '*') {
|
|
8
|
+
return variables.map(({ field, value })=>`${field} : ${value}`).join(' <br /> ');
|
|
9
|
+
} else if (variable === '*:table') {
|
|
10
|
+
return keyValuePairToHtmlTable(variables.reduce((acc, { field, value })=>{
|
|
11
|
+
acc[field] = value;
|
|
12
|
+
return acc;
|
|
13
|
+
}, {}));
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
const foundVariable = variables.find(({ field: fieldName })=>{
|
|
17
|
+
return variable === fieldName;
|
|
18
|
+
});
|
|
19
|
+
if (foundVariable) {
|
|
20
|
+
return foundVariable.value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
return variable;
|
|
8
24
|
});
|
|
9
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/replaceDoubleCurlys.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/replaceDoubleCurlys.ts"],"sourcesContent":["import { keyValuePairToHtmlTable } from './keyValuePairToHtmlTable.js'\n\ninterface EmailVariable {\n field: string\n value: string\n}\n\ntype EmailVariables = EmailVariable[]\n\nexport const replaceDoubleCurlys = (str: string, variables?: EmailVariables): string => {\n const regex = /\\{\\{(.+?)\\}\\}/g\n if (str && variables) {\n return str.replace(regex, (_, variable: string) => {\n if (variable.includes('*')) {\n if (variable === '*') {\n return variables.map(({ field, value }) => `${field} : ${value}`).join(' <br /> ')\n } else if (variable === '*:table') {\n return keyValuePairToHtmlTable(\n variables.reduce((acc, { field, value }) => {\n acc[field] = value\n return acc\n }, {}),\n )\n }\n } else {\n const foundVariable = variables.find(({ field: fieldName }) => {\n return variable === fieldName\n })\n if (foundVariable) {\n return foundVariable.value\n }\n }\n\n return variable\n })\n }\n return str\n}\n"],"names":["keyValuePairToHtmlTable","replaceDoubleCurlys","str","variables","regex","replace","_","variable","includes","map","field","value","join","reduce","acc","foundVariable","find","fieldName"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,+BAA8B;AAStE,OAAO,MAAMC,sBAAsB,CAACC,KAAaC;IAC/C,MAAMC,QAAQ;IACd,IAAIF,OAAOC,WAAW;QACpB,OAAOD,IAAIG,OAAO,CAACD,OAAO,CAACE,GAAGC;YAC5B,IAAIA,SAASC,QAAQ,CAAC,MAAM;gBAC1B,IAAID,aAAa,KAAK;oBACpB,OAAOJ,UAAUM,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAK,CAAC,EAAED,MAAM,GAAG,EAAEC,MAAM,CAAC,EAAEC,IAAI,CAAC;gBACzE,OAAO,IAAIL,aAAa,WAAW;oBACjC,OAAOP,wBACLG,UAAUU,MAAM,CAAC,CAACC,KAAK,EAAEJ,KAAK,EAAEC,KAAK,EAAE;wBACrCG,GAAG,CAACJ,MAAM,GAAGC;wBACb,OAAOG;oBACT,GAAG,CAAC;gBAER;YACF,OAAO;gBACL,MAAMC,gBAAgBZ,UAAUa,IAAI,CAAC,CAAC,EAAEN,OAAOO,SAAS,EAAE;oBACxD,OAAOV,aAAaU;gBACtB;gBACA,IAAIF,eAAe;oBACjB,OAAOA,cAAcJ,KAAK;gBAC5B;YACF;YAEA,OAAOJ;QACT;IACF;IACA,OAAOL;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeSlate.d.ts","sourceRoot":"","sources":["../../../src/utilities/slate/serializeSlate.ts"],"names":[],"mappings":"AAIA,UAAU,IAAI;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA;IACjB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAMD,eAAO,MAAM,cAAc,cAAe,IAAI,EAAE,mBAAmB,GAAG,KAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"serializeSlate.d.ts","sourceRoot":"","sources":["../../../src/utilities/slate/serializeSlate.ts"],"names":[],"mappings":"AAIA,UAAU,IAAI;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA;IACjB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAMD,eAAO,MAAM,cAAc,cAAe,IAAI,EAAE,mBAAmB,GAAG,KAAG,MAAM,GAAG,SA0HrE,CAAA"}
|
|
@@ -5,7 +5,7 @@ const isTextNode = (node)=>{
|
|
|
5
5
|
};
|
|
6
6
|
export const serializeSlate = (children, submissionData)=>children?.map((node)=>{
|
|
7
7
|
if (isTextNode(node)) {
|
|
8
|
-
let text = `<span>${escapeHTML(replaceDoubleCurlys(node.text, submissionData))}</span>`;
|
|
8
|
+
let text = node.text.includes('{{*') ? replaceDoubleCurlys(node.text, submissionData) : `<span>${escapeHTML(replaceDoubleCurlys(node.text, submissionData))}</span>`;
|
|
9
9
|
if (node.bold) {
|
|
10
10
|
text = `
|
|
11
11
|
<strong>
|