@payloadcms/plugin-form-builder 3.0.0-beta.9 → 3.0.0-canary.2077da8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collections/FormSubmissions/hooks/createCharge.d.ts +3 -0
- package/dist/collections/FormSubmissions/hooks/createCharge.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/hooks/createCharge.js.map +1 -1
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts +3 -0
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/hooks/sendEmail.js.map +1 -1
- package/dist/collections/FormSubmissions/index.d.ts +4 -0
- package/dist/collections/FormSubmissions/index.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/index.js +64 -62
- package/dist/collections/FormSubmissions/index.js.map +1 -1
- package/dist/collections/Forms/DynamicFieldSelector.d.ts +4 -0
- package/dist/collections/Forms/DynamicFieldSelector.d.ts.map +1 -0
- package/dist/collections/Forms/DynamicFieldSelector.js +2 -1
- package/dist/collections/Forms/DynamicFieldSelector.js.map +1 -1
- package/dist/collections/Forms/DynamicPriceSelector.d.ts +4 -0
- package/dist/collections/Forms/DynamicPriceSelector.d.ts.map +1 -0
- package/dist/collections/Forms/DynamicPriceSelector.js +17 -6
- package/dist/collections/Forms/DynamicPriceSelector.js.map +1 -1
- package/dist/collections/Forms/fields.d.ts +6 -0
- package/dist/collections/Forms/fields.d.ts.map +1 -0
- package/dist/collections/Forms/index.d.ts +4 -0
- package/dist/collections/Forms/index.d.ts.map +1 -0
- package/dist/collections/Forms/index.js +146 -144
- package/dist/collections/Forms/index.js.map +1 -1
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -16
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +182 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js.map +1 -1
- package/dist/utilities/getPaymentTotal.d.ts +5 -0
- package/dist/utilities/getPaymentTotal.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/heading.d.ts +3 -0
- package/dist/utilities/lexical/converters/heading.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/linebreak.d.ts +3 -0
- package/dist/utilities/lexical/converters/linebreak.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/link.d.ts +3 -0
- package/dist/utilities/lexical/converters/link.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/list.d.ts +4 -0
- package/dist/utilities/lexical/converters/list.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/paragraph.d.ts +3 -0
- package/dist/utilities/lexical/converters/paragraph.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/quote.d.ts +3 -0
- package/dist/utilities/lexical/converters/quote.d.ts.map +1 -0
- package/dist/utilities/lexical/converters/text.d.ts +3 -0
- package/dist/utilities/lexical/converters/text.d.ts.map +1 -0
- package/dist/utilities/lexical/defaultConverters.d.ts +3 -0
- package/dist/utilities/lexical/defaultConverters.d.ts.map +1 -0
- package/dist/utilities/lexical/nodeFormat.d.ts +39 -0
- package/dist/utilities/lexical/nodeFormat.d.ts.map +1 -0
- package/dist/utilities/lexical/serializeLexical.d.ts +9 -0
- package/dist/utilities/lexical/serializeLexical.d.ts.map +1 -0
- package/dist/utilities/lexical/types.d.ts +14 -0
- package/dist/utilities/lexical/types.d.ts.map +1 -0
- package/dist/utilities/replaceDoubleCurlys.d.ts +8 -0
- package/dist/utilities/replaceDoubleCurlys.d.ts.map +1 -0
- package/dist/utilities/slate/serializeSlate.d.ts +12 -0
- package/dist/utilities/slate/serializeSlate.d.ts.map +1 -0
- package/package.json +46 -35
- package/src/index.ts +0 -55
- package/types.d.ts +0 -1
- package/types.js +0 -1
|
@@ -53,6 +53,149 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
53
53
|
condition: (_, siblingData)=>siblingData?.type === 'custom'
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
+
const defaultFields = [
|
|
57
|
+
{
|
|
58
|
+
name: 'title',
|
|
59
|
+
type: 'text',
|
|
60
|
+
required: true
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'fields',
|
|
64
|
+
type: 'blocks',
|
|
65
|
+
blocks: Object.entries(formConfig?.fields || {}).map(([fieldKey, fieldConfig])=>{
|
|
66
|
+
// let the config enable/disable fields with either boolean values or objects
|
|
67
|
+
if (fieldConfig !== false) {
|
|
68
|
+
const block = fields[fieldKey];
|
|
69
|
+
if (block === undefined && typeof fieldConfig === 'object') {
|
|
70
|
+
return fieldConfig;
|
|
71
|
+
}
|
|
72
|
+
if (typeof block === 'object' && typeof fieldConfig === 'object') {
|
|
73
|
+
return merge(block, fieldConfig, {
|
|
74
|
+
arrayMerge: (_, sourceArray)=>sourceArray
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (typeof block === 'function') {
|
|
78
|
+
return block(fieldConfig);
|
|
79
|
+
}
|
|
80
|
+
return block;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}).filter(Boolean)
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'submitButtonLabel',
|
|
87
|
+
type: 'text',
|
|
88
|
+
localized: true
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'confirmationType',
|
|
92
|
+
type: 'radio',
|
|
93
|
+
admin: {
|
|
94
|
+
description: 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',
|
|
95
|
+
layout: 'horizontal'
|
|
96
|
+
},
|
|
97
|
+
defaultValue: 'message',
|
|
98
|
+
options: [
|
|
99
|
+
{
|
|
100
|
+
label: 'Message',
|
|
101
|
+
value: 'message'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
label: 'Redirect',
|
|
105
|
+
value: 'redirect'
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'confirmationMessage',
|
|
111
|
+
type: 'richText',
|
|
112
|
+
admin: {
|
|
113
|
+
condition: (_, siblingData)=>siblingData?.confirmationType === 'message'
|
|
114
|
+
},
|
|
115
|
+
localized: true,
|
|
116
|
+
required: true
|
|
117
|
+
},
|
|
118
|
+
redirect,
|
|
119
|
+
{
|
|
120
|
+
name: 'emails',
|
|
121
|
+
type: 'array',
|
|
122
|
+
admin: {
|
|
123
|
+
description: "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}}."
|
|
124
|
+
},
|
|
125
|
+
fields: [
|
|
126
|
+
{
|
|
127
|
+
type: 'row',
|
|
128
|
+
fields: [
|
|
129
|
+
{
|
|
130
|
+
name: 'emailTo',
|
|
131
|
+
type: 'text',
|
|
132
|
+
admin: {
|
|
133
|
+
placeholder: '"Email Sender" <sender@email.com>',
|
|
134
|
+
width: '100%'
|
|
135
|
+
},
|
|
136
|
+
label: 'Email To'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'cc',
|
|
140
|
+
type: 'text',
|
|
141
|
+
admin: {
|
|
142
|
+
width: '50%'
|
|
143
|
+
},
|
|
144
|
+
label: 'CC'
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'bcc',
|
|
148
|
+
type: 'text',
|
|
149
|
+
admin: {
|
|
150
|
+
width: '50%'
|
|
151
|
+
},
|
|
152
|
+
label: 'BCC'
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'row',
|
|
158
|
+
fields: [
|
|
159
|
+
{
|
|
160
|
+
name: 'replyTo',
|
|
161
|
+
type: 'text',
|
|
162
|
+
admin: {
|
|
163
|
+
placeholder: '"Reply To" <reply-to@email.com>',
|
|
164
|
+
width: '50%'
|
|
165
|
+
},
|
|
166
|
+
label: 'Reply To'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'emailFrom',
|
|
170
|
+
type: 'text',
|
|
171
|
+
admin: {
|
|
172
|
+
placeholder: '"Email From" <email-from@email.com>',
|
|
173
|
+
width: '50%'
|
|
174
|
+
},
|
|
175
|
+
label: 'Email From'
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'subject',
|
|
181
|
+
type: 'text',
|
|
182
|
+
defaultValue: "You've received a new message.",
|
|
183
|
+
label: 'Subject',
|
|
184
|
+
localized: true,
|
|
185
|
+
required: true
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'message',
|
|
189
|
+
type: 'richText',
|
|
190
|
+
admin: {
|
|
191
|
+
description: 'Enter the message that should be sent in this email.'
|
|
192
|
+
},
|
|
193
|
+
label: 'Message',
|
|
194
|
+
localized: true
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
];
|
|
56
199
|
const config = {
|
|
57
200
|
...formConfig?.formOverrides || {},
|
|
58
201
|
slug: formConfig?.formOverrides?.slug || 'forms',
|
|
@@ -65,150 +208,9 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
65
208
|
useAsTitle: 'title',
|
|
66
209
|
...formConfig?.formOverrides?.admin || {}
|
|
67
210
|
},
|
|
68
|
-
fields:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
type: 'text',
|
|
72
|
-
required: true
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'fields',
|
|
76
|
-
type: 'blocks',
|
|
77
|
-
blocks: Object.entries(formConfig?.fields || {}).map(([fieldKey, fieldConfig])=>{
|
|
78
|
-
// let the config enable/disable fields with either boolean values or objects
|
|
79
|
-
if (fieldConfig !== false) {
|
|
80
|
-
const block = fields[fieldKey];
|
|
81
|
-
if (block === undefined && typeof fieldConfig === 'object') {
|
|
82
|
-
return fieldConfig;
|
|
83
|
-
}
|
|
84
|
-
if (typeof block === 'object' && typeof fieldConfig === 'object') {
|
|
85
|
-
return merge(block, fieldConfig, {
|
|
86
|
-
arrayMerge: (_, sourceArray)=>sourceArray
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
if (typeof block === 'function') {
|
|
90
|
-
return block(fieldConfig);
|
|
91
|
-
}
|
|
92
|
-
return block;
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
}).filter(Boolean)
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: 'submitButtonLabel',
|
|
99
|
-
type: 'text',
|
|
100
|
-
localized: true
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: 'confirmationType',
|
|
104
|
-
type: 'radio',
|
|
105
|
-
admin: {
|
|
106
|
-
description: 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',
|
|
107
|
-
layout: 'horizontal'
|
|
108
|
-
},
|
|
109
|
-
defaultValue: 'message',
|
|
110
|
-
options: [
|
|
111
|
-
{
|
|
112
|
-
label: 'Message',
|
|
113
|
-
value: 'message'
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
label: 'Redirect',
|
|
117
|
-
value: 'redirect'
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: 'confirmationMessage',
|
|
123
|
-
type: 'richText',
|
|
124
|
-
admin: {
|
|
125
|
-
condition: (_, siblingData)=>siblingData?.confirmationType === 'message'
|
|
126
|
-
},
|
|
127
|
-
localized: true,
|
|
128
|
-
required: true
|
|
129
|
-
},
|
|
130
|
-
redirect,
|
|
131
|
-
{
|
|
132
|
-
name: 'emails',
|
|
133
|
-
type: 'array',
|
|
134
|
-
admin: {
|
|
135
|
-
description: "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}}."
|
|
136
|
-
},
|
|
137
|
-
fields: [
|
|
138
|
-
{
|
|
139
|
-
type: 'row',
|
|
140
|
-
fields: [
|
|
141
|
-
{
|
|
142
|
-
name: 'emailTo',
|
|
143
|
-
type: 'text',
|
|
144
|
-
admin: {
|
|
145
|
-
placeholder: '"Email Sender" <sender@email.com>',
|
|
146
|
-
width: '100%'
|
|
147
|
-
},
|
|
148
|
-
label: 'Email To'
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: 'cc',
|
|
152
|
-
type: 'text',
|
|
153
|
-
admin: {
|
|
154
|
-
width: '50%'
|
|
155
|
-
},
|
|
156
|
-
label: 'CC'
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
name: 'bcc',
|
|
160
|
-
type: 'text',
|
|
161
|
-
admin: {
|
|
162
|
-
width: '50%'
|
|
163
|
-
},
|
|
164
|
-
label: 'BCC'
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
type: 'row',
|
|
170
|
-
fields: [
|
|
171
|
-
{
|
|
172
|
-
name: 'replyTo',
|
|
173
|
-
type: 'text',
|
|
174
|
-
admin: {
|
|
175
|
-
placeholder: '"Reply To" <reply-to@email.com>',
|
|
176
|
-
width: '50%'
|
|
177
|
-
},
|
|
178
|
-
label: 'Reply To'
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
name: 'emailFrom',
|
|
182
|
-
type: 'text',
|
|
183
|
-
admin: {
|
|
184
|
-
placeholder: '"Email From" <email-from@email.com>',
|
|
185
|
-
width: '50%'
|
|
186
|
-
},
|
|
187
|
-
label: 'Email From'
|
|
188
|
-
}
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: 'subject',
|
|
193
|
-
type: 'text',
|
|
194
|
-
defaultValue: "You've received a new message.",
|
|
195
|
-
label: 'Subject',
|
|
196
|
-
localized: true,
|
|
197
|
-
required: true
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: 'message',
|
|
201
|
-
type: 'richText',
|
|
202
|
-
admin: {
|
|
203
|
-
description: 'Enter the message that should be sent in this email.'
|
|
204
|
-
},
|
|
205
|
-
label: 'Message',
|
|
206
|
-
localized: true
|
|
207
|
-
}
|
|
208
|
-
]
|
|
209
|
-
},
|
|
210
|
-
...formConfig?.formOverrides?.fields || []
|
|
211
|
-
]
|
|
211
|
+
fields: formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function' ? formConfig.formOverrides.fields({
|
|
212
|
+
defaultFields
|
|
213
|
+
}) : defaultFields
|
|
212
214
|
};
|
|
213
215
|
return config;
|
|
214
216
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\n\nimport merge from 'deepmerge'\n\nimport type { FieldConfig, PluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: PluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') redirect.fields[2].label = 'Custom URL'\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'fields',\n type: 'blocks',\n blocks: Object.entries(formConfig?.fields || {})\n .map(([fieldKey, fieldConfig]) => {\n // let the config enable/disable fields with either boolean values or objects\n if (fieldConfig !== false) {\n const block = fields[fieldKey]\n\n if (block === undefined && typeof fieldConfig === 'object') {\n return fieldConfig\n }\n\n if (typeof block === 'object' && typeof fieldConfig === 'object') {\n return merge<FieldConfig>(block, fieldConfig, {\n arrayMerge: (_, sourceArray) => sourceArray,\n })\n }\n\n if (typeof block === 'function') {\n return block(fieldConfig)\n }\n\n return block\n }\n\n return null\n })\n .filter(Boolean) as Block[],\n },\n {\n name: 'submitButtonLabel',\n type: 'text',\n localized: true,\n },\n {\n name: 'confirmationType',\n type: 'radio',\n admin: {\n description:\n 'Choose whether to display an on-page message or redirect to a different page after they submit the form.',\n layout: 'horizontal',\n },\n defaultValue: 'message',\n options: [\n {\n label: 'Message',\n value: 'message',\n },\n {\n label: 'Redirect',\n value: 'redirect',\n },\n ],\n },\n {\n name: 'confirmationMessage',\n type: 'richText',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'message',\n },\n localized: true,\n required: true,\n },\n redirect,\n {\n name: 'emails',\n type: 'array',\n admin: {\n description:\n \"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}.\",\n },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'emailTo',\n type: 'text',\n admin: {\n placeholder: '\"Email Sender\" <sender@email.com>',\n width: '100%',\n },\n label: 'Email To',\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ...(formConfig?.formOverrides?.fields || []),\n ],\n }\n\n return config\n}\n"],"names":["merge","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","arrayMerge","sourceArray","filter","Boolean","localized","description","placeholder","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,WAAW,YAAW;AAI7B,SAASC,MAAM,QAAQ,cAAa;AAEpC,+CAA+C;AAC/C,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAMC,WAAkB;QACtBC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaC,qBAAqB;YACjEC,YAAY;QACd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AAM;wBACNL,QAAQ;4BACN;gCACEI,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLqC,aAAa;oCACbC,OAAO;gCACT;gCACAhC,OAAO;4BACT;yBACD;oBACH;oBACA;wBACER,MAAM;wBACNC,MAAM;wBACNc,cAAc;wBACdP,OAAO;wBACP6B,WAAW;wBACX5B,UAAU;oBACZ;oBACA;wBACET,MAAM;wBACNC,MAAM;wBACNC,OAAO;4BACLoC,aAAa;wBACf;wBACA9B,OAAO;wBACP6B,WAAW;oBACb;iBACD;YACH;eACIvC,YAAYqB,eAAevB,UAAU,EAAE;SAC5C;IACH;IAEA,OAAOsB;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/index.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\n\nimport merge from 'deepmerge'\n\nimport type { FieldConfig, FormBuilderPluginConfig } from '../../types.js'\n\nimport { fields } from './fields.js'\n\n// all settings can be overridden by the config\nexport const generateFormCollection = (formConfig: FormBuilderPluginConfig): CollectionConfig => {\n const redirect: Field = {\n name: 'redirect',\n type: 'group',\n admin: {\n condition: (_, siblingData) => siblingData?.confirmationType === 'redirect',\n hideGutter: true,\n },\n fields: [\n {\n name: 'url',\n type: 'text',\n label: 'URL to redirect to',\n required: true,\n },\n ],\n }\n\n if (formConfig.redirectRelationships) {\n redirect.fields.unshift({\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to link to',\n maxDepth: 2,\n relationTo: formConfig.redirectRelationships,\n required: true,\n })\n\n redirect.fields.unshift({\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n })\n\n if (redirect.fields[2].type !== 'row') redirect.fields[2].label = 'Custom URL'\n\n redirect.fields[2].admin = {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n }\n }\n\n const 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CACL+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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { BeforeEmail, BlockConfig, CheckboxField, CountryField, Email, EmailField, FieldConfig, FieldValues, FieldsConfig, Form, FormBuilderPluginConfig as PluginConfig, FormFieldBlock, FormSubmission, FormattedEmail, HandlePayment, MessageField, PaymentField, PaymentFieldConfig, PriceCondition, Redirect, SelectField, SelectFieldOption, StateField, SubmissionValue, TextAreaField, TextField, isValidBlockConfig, } from '../types.js';
|
|
2
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,KAAK,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,uBAAuB,IAAI,YAAY,EACvC,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,aAAa,EACb,SAAS,EACT,kBAAkB,GACnB,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n BeforeEmail,\n BlockConfig,\n CheckboxField,\n CountryField,\n Email,\n EmailField,\n FieldConfig,\n FieldValues,\n FieldsConfig,\n Form,\n FormBuilderPluginConfig as PluginConfig,\n FormFieldBlock,\n FormSubmission,\n FormattedEmail,\n HandlePayment,\n MessageField,\n PaymentField,\n PaymentFieldConfig,\n PriceCondition,\n Redirect,\n SelectField,\n SelectFieldOption,\n StateField,\n SubmissionValue,\n TextAreaField,\n TextField,\n isValidBlockConfig,\n} from '../types.js'\n"],"names":[],"rangeMappings":"","mappings":"AAAA,WA4BoB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Config } from 'payload/config';
|
|
2
|
+
import type { FormBuilderPluginConfig } from './types.js';
|
|
3
|
+
export { fields } from './collections/Forms/fields.js';
|
|
4
|
+
export { getPaymentTotal } from './utilities/getPaymentTotal.js';
|
|
5
|
+
export declare const formBuilderPlugin: (incomingFormConfig: FormBuilderPluginConfig) => (config: Config) => Config;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAKzD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAEhE,eAAO,MAAM,iBAAiB,uBACP,uBAAuB,cACnC,MAAM,KAAG,MA0BjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { generateSubmissionCollection } from './collections/FormSubmissions/inde
|
|
|
2
2
|
import { generateFormCollection } from './collections/Forms/index.js';
|
|
3
3
|
export { fields } from './collections/Forms/fields.js';
|
|
4
4
|
export { getPaymentTotal } from './utilities/getPaymentTotal.js';
|
|
5
|
-
const
|
|
5
|
+
export const formBuilderPlugin = (incomingFormConfig)=>(config)=>{
|
|
6
6
|
const formConfig = {
|
|
7
7
|
...incomingFormConfig,
|
|
8
8
|
fields: {
|
|
@@ -21,20 +21,6 @@ const FormBuilder = (incomingFormConfig)=>(config)=>{
|
|
|
21
21
|
};
|
|
22
22
|
return {
|
|
23
23
|
...config,
|
|
24
|
-
// admin: {
|
|
25
|
-
// ...config.admin,
|
|
26
|
-
// webpack: (webpackConfig) => ({
|
|
27
|
-
// ...webpackConfig,
|
|
28
|
-
// resolve: {
|
|
29
|
-
// ...webpackConfig.resolve,
|
|
30
|
-
// alias: {
|
|
31
|
-
// ...webpackConfig.resolve.alias,
|
|
32
|
-
// [path.resolve(__dirname, 'collections/FormSubmissions/hooks/sendEmail.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),
|
|
33
|
-
// [path.resolve(__dirname, 'collections/FormSubmissions/hooks/createCharge.ts')]: path.resolve(__dirname, 'mocks/serverModule.js'),
|
|
34
|
-
// },
|
|
35
|
-
// },
|
|
36
|
-
// })
|
|
37
|
-
// },
|
|
38
24
|
collections: [
|
|
39
25
|
...config?.collections || [],
|
|
40
26
|
generateFormCollection(formConfig),
|
|
@@ -42,6 +28,5 @@ const FormBuilder = (incomingFormConfig)=>(config)=>{
|
|
|
42
28
|
]
|
|
43
29
|
};
|
|
44
30
|
};
|
|
45
|
-
export default FormBuilder;
|
|
46
31
|
|
|
47
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type { FormBuilderPluginConfig } from './types.js'\n\nimport { generateSubmissionCollection } from './collections/FormSubmissions/index.js'\nimport { generateFormCollection } from './collections/Forms/index.js'\n\nexport { fields } from './collections/Forms/fields.js'\nexport { getPaymentTotal } from './utilities/getPaymentTotal.js'\n\nexport const formBuilderPlugin =\n (incomingFormConfig: FormBuilderPluginConfig) =>\n (config: Config): Config => {\n const formConfig: FormBuilderPluginConfig = {\n ...incomingFormConfig,\n fields: {\n checkbox: true,\n country: true,\n email: true,\n message: true,\n number: true,\n payment: false,\n select: true,\n state: true,\n text: true,\n textarea: true,\n ...incomingFormConfig.fields,\n },\n }\n\n return {\n ...config,\n collections: [\n ...(config?.collections || []),\n generateFormCollection(formConfig),\n generateSubmissionCollection(formConfig),\n ],\n }\n }\n"],"names":["generateSubmissionCollection","generateFormCollection","fields","getPaymentTotal","formBuilderPlugin","incomingFormConfig","config","formConfig","checkbox","country","email","message","number","payment","select","state","text","textarea","collections"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,4BAA4B,QAAQ,yCAAwC;AACrF,SAASC,sBAAsB,QAAQ,+BAA8B;AAErE,SAASC,MAAM,QAAQ,gCAA+B;AACtD,SAASC,eAAe,QAAQ,iCAAgC;AAEhE,OAAO,MAAMC,oBACX,CAACC,qBACD,CAACC;QACC,MAAMC,aAAsC;YAC1C,GAAGF,kBAAkB;YACrBH,QAAQ;gBACNM,UAAU;gBACVC,SAAS;gBACTC,OAAO;gBACPC,SAAS;gBACTC,QAAQ;gBACRC,SAAS;gBACTC,QAAQ;gBACRC,OAAO;gBACPC,MAAM;gBACNC,UAAU;gBACV,GAAGZ,mBAAmBH,MAAM;YAC9B;QACF;QAEA,OAAO;YACL,GAAGI,MAAM;YACTY,aAAa;mBACPZ,QAAQY,eAAe,EAAE;gBAC7BjB,uBAAuBM;gBACvBP,6BAA6BO;aAC9B;QACH;IACF,EAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { Block, CollectionConfig, Field } from 'payload/types';
|
|
2
|
+
export interface BlockConfig {
|
|
3
|
+
block: Block;
|
|
4
|
+
validate?: (value: unknown) => boolean | string;
|
|
5
|
+
}
|
|
6
|
+
export declare function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig;
|
|
7
|
+
export interface FieldValues {
|
|
8
|
+
[key: string]: boolean | null | number | string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type PaymentFieldConfig = Partial<Field> & {
|
|
11
|
+
paymentProcessor: Partial<SelectField>;
|
|
12
|
+
};
|
|
13
|
+
export type FieldConfig = Partial<Field> | PaymentFieldConfig;
|
|
14
|
+
export interface FieldsConfig {
|
|
15
|
+
[key: string]: FieldConfig | boolean | undefined;
|
|
16
|
+
checkbox?: FieldConfig | boolean;
|
|
17
|
+
country?: FieldConfig | boolean;
|
|
18
|
+
email?: FieldConfig | boolean;
|
|
19
|
+
message?: FieldConfig | boolean;
|
|
20
|
+
number?: FieldConfig | boolean;
|
|
21
|
+
payment?: FieldConfig | boolean;
|
|
22
|
+
select?: FieldConfig | boolean;
|
|
23
|
+
state?: FieldConfig | boolean;
|
|
24
|
+
text?: FieldConfig | boolean;
|
|
25
|
+
textarea?: FieldConfig | boolean;
|
|
26
|
+
}
|
|
27
|
+
export type BeforeEmail = (emails: FormattedEmail[]) => FormattedEmail[] | Promise<FormattedEmail[]>;
|
|
28
|
+
export type HandlePayment = (data: any) => void;
|
|
29
|
+
export type FieldsOverride = (args: {
|
|
30
|
+
defaultFields: Field[];
|
|
31
|
+
}) => Field[];
|
|
32
|
+
export type FormBuilderPluginConfig = {
|
|
33
|
+
beforeEmail?: BeforeEmail;
|
|
34
|
+
fields?: FieldsConfig;
|
|
35
|
+
formOverrides?: Partial<Omit<CollectionConfig, 'fields'>> & {
|
|
36
|
+
fields: FieldsOverride;
|
|
37
|
+
};
|
|
38
|
+
formSubmissionOverrides?: Partial<Omit<CollectionConfig, 'fields'>> & {
|
|
39
|
+
fields: FieldsOverride;
|
|
40
|
+
};
|
|
41
|
+
handlePayment?: HandlePayment;
|
|
42
|
+
redirectRelationships?: string[];
|
|
43
|
+
};
|
|
44
|
+
export interface TextField {
|
|
45
|
+
blockName?: string;
|
|
46
|
+
blockType: 'text';
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
label?: string;
|
|
49
|
+
name: string;
|
|
50
|
+
required?: boolean;
|
|
51
|
+
width?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface TextAreaField {
|
|
54
|
+
blockName?: string;
|
|
55
|
+
blockType: 'textarea';
|
|
56
|
+
defaultValue?: string;
|
|
57
|
+
label?: string;
|
|
58
|
+
name: string;
|
|
59
|
+
required?: boolean;
|
|
60
|
+
width?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface SelectFieldOption {
|
|
63
|
+
label: string;
|
|
64
|
+
value: string;
|
|
65
|
+
}
|
|
66
|
+
export interface SelectField {
|
|
67
|
+
blockName?: string;
|
|
68
|
+
blockType: 'select';
|
|
69
|
+
defaultValue?: string;
|
|
70
|
+
label?: string;
|
|
71
|
+
name: string;
|
|
72
|
+
options: SelectFieldOption[];
|
|
73
|
+
required?: boolean;
|
|
74
|
+
width?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface PriceCondition {
|
|
77
|
+
condition: 'equals' | 'hasValue' | 'notEquals';
|
|
78
|
+
fieldToUse: string;
|
|
79
|
+
operator: 'add' | 'divide' | 'multiply' | 'subtract';
|
|
80
|
+
valueForCondition: string;
|
|
81
|
+
valueForOperator: number | string;
|
|
82
|
+
valueType: 'static' | 'valueOfField';
|
|
83
|
+
}
|
|
84
|
+
export interface PaymentField {
|
|
85
|
+
basePrice: number;
|
|
86
|
+
blockName?: string;
|
|
87
|
+
blockType: 'payment';
|
|
88
|
+
defaultValue?: string;
|
|
89
|
+
label?: string;
|
|
90
|
+
name: string;
|
|
91
|
+
paymentProcessor: string;
|
|
92
|
+
priceConditions: PriceCondition[];
|
|
93
|
+
required?: boolean;
|
|
94
|
+
width?: number;
|
|
95
|
+
}
|
|
96
|
+
export interface EmailField {
|
|
97
|
+
blockName?: string;
|
|
98
|
+
blockType: 'email';
|
|
99
|
+
defaultValue?: string;
|
|
100
|
+
label?: string;
|
|
101
|
+
name: string;
|
|
102
|
+
required?: boolean;
|
|
103
|
+
width?: number;
|
|
104
|
+
}
|
|
105
|
+
export interface StateField {
|
|
106
|
+
blockName?: string;
|
|
107
|
+
blockType: 'state';
|
|
108
|
+
defaultValue?: string;
|
|
109
|
+
label?: string;
|
|
110
|
+
name: string;
|
|
111
|
+
required?: boolean;
|
|
112
|
+
width?: number;
|
|
113
|
+
}
|
|
114
|
+
export interface CountryField {
|
|
115
|
+
blockName?: string;
|
|
116
|
+
blockType: 'country';
|
|
117
|
+
defaultValue?: string;
|
|
118
|
+
label?: string;
|
|
119
|
+
name: string;
|
|
120
|
+
required?: boolean;
|
|
121
|
+
width?: number;
|
|
122
|
+
}
|
|
123
|
+
export interface CheckboxField {
|
|
124
|
+
blockName?: string;
|
|
125
|
+
blockType: 'checkbox';
|
|
126
|
+
defaultValue?: boolean;
|
|
127
|
+
label?: string;
|
|
128
|
+
name: string;
|
|
129
|
+
required?: boolean;
|
|
130
|
+
width?: number;
|
|
131
|
+
}
|
|
132
|
+
export interface MessageField {
|
|
133
|
+
blockName?: string;
|
|
134
|
+
blockType: 'message';
|
|
135
|
+
message: unknown;
|
|
136
|
+
}
|
|
137
|
+
export type FormFieldBlock = CheckboxField | CountryField | EmailField | MessageField | PaymentField | SelectField | StateField | TextAreaField | TextField;
|
|
138
|
+
export interface Email {
|
|
139
|
+
bcc?: string;
|
|
140
|
+
cc?: string;
|
|
141
|
+
emailFrom: string;
|
|
142
|
+
emailTo: string;
|
|
143
|
+
message?: any;
|
|
144
|
+
replyTo?: string;
|
|
145
|
+
subject: string;
|
|
146
|
+
}
|
|
147
|
+
export interface FormattedEmail {
|
|
148
|
+
bcc?: string;
|
|
149
|
+
cc?: string;
|
|
150
|
+
from: string;
|
|
151
|
+
html: string;
|
|
152
|
+
replyTo: string;
|
|
153
|
+
subject: string;
|
|
154
|
+
to: string;
|
|
155
|
+
}
|
|
156
|
+
export interface Redirect {
|
|
157
|
+
reference?: {
|
|
158
|
+
relationTo: string;
|
|
159
|
+
value: string | unknown;
|
|
160
|
+
};
|
|
161
|
+
type: 'custom' | 'reference';
|
|
162
|
+
url: string;
|
|
163
|
+
}
|
|
164
|
+
export interface Form {
|
|
165
|
+
confirmationMessage?: any;
|
|
166
|
+
confirmationType: 'message' | 'redirect';
|
|
167
|
+
emails: Email[];
|
|
168
|
+
fields: FormFieldBlock[];
|
|
169
|
+
id: string;
|
|
170
|
+
redirect?: Redirect;
|
|
171
|
+
submitButtonLabel?: string;
|
|
172
|
+
title: string;
|
|
173
|
+
}
|
|
174
|
+
export interface SubmissionValue {
|
|
175
|
+
field: string;
|
|
176
|
+
value: unknown;
|
|
177
|
+
}
|
|
178
|
+
export interface FormSubmission {
|
|
179
|
+
form: Form | string;
|
|
180
|
+
submissionData: SubmissionValue[];
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,eAAe,C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-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\n\nexport interface BlockConfig {\n block: Block\n validate?: (value: unknown) => boolean | string\n}\n\nexport function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig {\n return (\n typeof blockConfig !== 'string' &&\n typeof blockConfig?.block?.slug === 'string' &&\n Array.isArray(blockConfig?.block?.fields)\n )\n}\n\nexport interface FieldValues {\n [key: string]: boolean | null | number | string | undefined\n}\n\nexport type PaymentFieldConfig = Partial<Field> & {\n paymentProcessor: Partial<SelectField>\n}\n\nexport type FieldConfig = Partial<Field> | PaymentFieldConfig\n\nexport interface FieldsConfig {\n [key: string]: FieldConfig | boolean | undefined\n checkbox?: FieldConfig | boolean\n country?: FieldConfig | boolean\n email?: FieldConfig | boolean\n message?: FieldConfig | boolean\n number?: FieldConfig | boolean\n payment?: FieldConfig | boolean\n select?: FieldConfig | boolean\n state?: FieldConfig | boolean\n text?: FieldConfig | boolean\n textarea?: FieldConfig | boolean\n}\n\nexport type BeforeEmail = (emails: FormattedEmail[]) => FormattedEmail[] | Promise<FormattedEmail[]>\nexport type HandlePayment = (data: any) => void\n\nexport
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Block, CollectionConfig, Field } from 'payload/types'\n\nexport interface BlockConfig {\n block: Block\n validate?: (value: unknown) => boolean | string\n}\n\nexport function isValidBlockConfig(blockConfig: BlockConfig | string): blockConfig is BlockConfig {\n return (\n typeof blockConfig !== 'string' &&\n typeof blockConfig?.block?.slug === 'string' &&\n Array.isArray(blockConfig?.block?.fields)\n )\n}\n\nexport interface FieldValues {\n [key: string]: boolean | null | number | string | undefined\n}\n\nexport type PaymentFieldConfig = Partial<Field> & {\n paymentProcessor: Partial<SelectField>\n}\n\nexport type FieldConfig = Partial<Field> | PaymentFieldConfig\n\nexport interface FieldsConfig {\n [key: string]: FieldConfig | boolean | undefined\n checkbox?: FieldConfig | boolean\n country?: FieldConfig | boolean\n email?: FieldConfig | boolean\n message?: FieldConfig | boolean\n number?: FieldConfig | boolean\n payment?: FieldConfig | boolean\n select?: FieldConfig | boolean\n state?: FieldConfig | boolean\n text?: FieldConfig | boolean\n textarea?: FieldConfig | boolean\n}\n\nexport type BeforeEmail = (emails: FormattedEmail[]) => FormattedEmail[] | Promise<FormattedEmail[]>\nexport type HandlePayment = (data: any) => void\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type FormBuilderPluginConfig = {\n beforeEmail?: BeforeEmail\n fields?: FieldsConfig\n formOverrides?: Partial<Omit<CollectionConfig, 'fields'>> & { fields: FieldsOverride }\n formSubmissionOverrides?: Partial<Omit<CollectionConfig, 'fields'>> & { fields: FieldsOverride }\n handlePayment?: HandlePayment\n redirectRelationships?: string[]\n}\n\nexport interface TextField {\n blockName?: string\n blockType: 'text'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface TextAreaField {\n blockName?: string\n blockType: 'textarea'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface SelectFieldOption {\n label: string\n value: string\n}\n\nexport interface SelectField {\n blockName?: string\n blockType: 'select'\n defaultValue?: string\n label?: string\n name: string\n options: SelectFieldOption[]\n required?: boolean\n width?: number\n}\n\nexport interface PriceCondition {\n condition: 'equals' | 'hasValue' | 'notEquals'\n fieldToUse: string\n operator: 'add' | 'divide' | 'multiply' | 'subtract'\n valueForCondition: string\n valueForOperator: number | string // TODO: make this a number, see ./collections/Forms/DynamicPriceSelector.tsx\n valueType: 'static' | 'valueOfField'\n}\n\nexport interface PaymentField {\n basePrice: number\n blockName?: string\n blockType: 'payment'\n defaultValue?: string\n label?: string\n name: string\n paymentProcessor: string\n priceConditions: PriceCondition[]\n required?: boolean\n width?: number\n}\n\nexport interface EmailField {\n blockName?: string\n blockType: 'email'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface StateField {\n blockName?: string\n blockType: 'state'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface CountryField {\n blockName?: string\n blockType: 'country'\n defaultValue?: string\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface CheckboxField {\n blockName?: string\n blockType: 'checkbox'\n defaultValue?: boolean\n label?: string\n name: string\n required?: boolean\n width?: number\n}\n\nexport interface MessageField {\n blockName?: string\n blockType: 'message'\n message: unknown\n}\n\nexport type FormFieldBlock =\n | CheckboxField\n | CountryField\n | EmailField\n | MessageField\n | PaymentField\n | SelectField\n | StateField\n | TextAreaField\n | TextField\n\nexport interface Email {\n bcc?: string\n cc?: string\n emailFrom: string\n emailTo: string\n message?: any // TODO: configure rich text type\n replyTo?: string\n subject: string\n}\n\nexport interface FormattedEmail {\n bcc?: string\n cc?: string\n from: string\n html: string\n replyTo: string\n subject: string\n to: string\n}\n\nexport interface Redirect {\n reference?: {\n relationTo: string\n value: string | unknown\n }\n type: 'custom' | 'reference'\n url: string\n}\n\nexport interface Form {\n confirmationMessage?: any // TODO: configure rich text type\n confirmationType: 'message' | 'redirect'\n emails: Email[]\n fields: FormFieldBlock[]\n id: string\n redirect?: Redirect\n submitButtonLabel?: string\n title: string\n}\n\nexport interface SubmissionValue {\n field: string\n value: unknown\n}\n\nexport interface FormSubmission {\n form: Form | string\n submissionData: SubmissionValue[]\n}\n"],"names":["isValidBlockConfig","blockConfig","block","slug","Array","isArray","fields"],"rangeMappings":";;","mappings":"AAOA,OAAO,SAASA,mBAAmBC,WAAiC;IAClE,OACE,OAAOA,gBAAgB,YACvB,OAAOA,aAAaC,OAAOC,SAAS,YACpCC,MAAMC,OAAO,CAACJ,aAAaC,OAAOI;AAEtC"}
|