@payloadcms/plugin-form-builder 3.0.0-beta.1 → 3.0.0-beta.100
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 +6 -0
- package/dist/collections/FormSubmissions/hooks/sendEmail.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/hooks/sendEmail.js +5 -6
- 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 +66 -62
- package/dist/collections/FormSubmissions/index.js.map +1 -1
- package/dist/collections/Forms/DynamicFieldSelector.d.ts +6 -0
- package/dist/collections/Forms/DynamicFieldSelector.d.ts.map +1 -0
- package/dist/collections/Forms/DynamicFieldSelector.js +7 -6
- 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 +24 -15
- 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/fields.js +2 -5
- package/dist/collections/Forms/fields.js.map +1 -1
- 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 +152 -146
- 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 +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 +2 -17
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +184 -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/getPaymentTotal.js.map +1 -1
- 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/heading.js.map +1 -1
- 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/linebreak.js.map +1 -1
- 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/link.js.map +1 -1
- 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/list.js.map +1 -1
- 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/paragraph.js.map +1 -1
- 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/quote.js.map +1 -1
- 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/converters/text.js.map +1 -1
- package/dist/utilities/lexical/defaultConverters.d.ts +3 -0
- package/dist/utilities/lexical/defaultConverters.d.ts.map +1 -0
- package/dist/utilities/lexical/defaultConverters.js.map +1 -1
- package/dist/utilities/lexical/nodeFormat.d.ts +39 -0
- package/dist/utilities/lexical/nodeFormat.d.ts.map +1 -0
- package/dist/utilities/lexical/nodeFormat.js.map +1 -1
- package/dist/utilities/lexical/serializeLexical.d.ts +9 -0
- package/dist/utilities/lexical/serializeLexical.d.ts.map +1 -0
- package/dist/utilities/lexical/serializeLexical.js.map +1 -1
- package/dist/utilities/lexical/types.d.ts +14 -0
- package/dist/utilities/lexical/types.d.ts.map +1 -0
- package/dist/utilities/lexical/types.js.map +1 -1
- package/dist/utilities/replaceDoubleCurlys.d.ts +8 -0
- package/dist/utilities/replaceDoubleCurlys.d.ts.map +1 -0
- package/dist/utilities/replaceDoubleCurlys.js +3 -1
- package/dist/utilities/replaceDoubleCurlys.js.map +1 -1
- package/dist/utilities/slate/serializeSlate.d.ts +12 -0
- package/dist/utilities/slate/serializeSlate.d.ts.map +1 -0
- package/dist/utilities/slate/serializeSlate.js.map +1 -1
- package/package.json +55 -40
- package/src/index.ts +0 -55
- package/types.d.ts +0 -1
- package/types.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAK7D,eAAO,MAAM,sBAAsB,eAAgB,uBAAuB,KAAG,gBAyO5E,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { deepMergeWithSourceArrays } from 'payload';
|
|
2
2
|
import { fields } from './fields.js';
|
|
3
3
|
// all settings can be overridden by the config
|
|
4
4
|
export const generateFormCollection = (formConfig)=>{
|
|
@@ -48,11 +48,158 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
48
48
|
}
|
|
49
49
|
]
|
|
50
50
|
});
|
|
51
|
-
if (redirect.fields[2].type !== 'row')
|
|
51
|
+
if (redirect.fields[2].type !== 'row') {
|
|
52
|
+
redirect.fields[2].label = 'Custom URL';
|
|
53
|
+
}
|
|
52
54
|
redirect.fields[2].admin = {
|
|
53
55
|
condition: (_, siblingData)=>siblingData?.type === 'custom'
|
|
54
56
|
};
|
|
55
57
|
}
|
|
58
|
+
const defaultFields = [
|
|
59
|
+
{
|
|
60
|
+
name: 'title',
|
|
61
|
+
type: 'text',
|
|
62
|
+
required: true
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'fields',
|
|
66
|
+
type: 'blocks',
|
|
67
|
+
blocks: Object.entries(formConfig?.fields || {}).map(([fieldKey, fieldConfig])=>{
|
|
68
|
+
// let the config enable/disable fields with either boolean values or objects
|
|
69
|
+
if (fieldConfig !== false) {
|
|
70
|
+
const block = fields[fieldKey];
|
|
71
|
+
if (block === undefined && typeof fieldConfig === 'object') {
|
|
72
|
+
return fieldConfig;
|
|
73
|
+
}
|
|
74
|
+
if (typeof block === 'object' && typeof fieldConfig === 'object') {
|
|
75
|
+
return deepMergeWithSourceArrays(block, fieldConfig);
|
|
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
|
+
style: {
|
|
143
|
+
maxWidth: '50%'
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
label: 'CC'
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'bcc',
|
|
150
|
+
type: 'text',
|
|
151
|
+
admin: {
|
|
152
|
+
style: {
|
|
153
|
+
maxWidth: '50%'
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
label: 'BCC'
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: 'row',
|
|
162
|
+
fields: [
|
|
163
|
+
{
|
|
164
|
+
name: 'replyTo',
|
|
165
|
+
type: 'text',
|
|
166
|
+
admin: {
|
|
167
|
+
placeholder: '"Reply To" <reply-to@email.com>',
|
|
168
|
+
width: '50%'
|
|
169
|
+
},
|
|
170
|
+
label: 'Reply To'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'emailFrom',
|
|
174
|
+
type: 'text',
|
|
175
|
+
admin: {
|
|
176
|
+
placeholder: '"Email From" <email-from@email.com>',
|
|
177
|
+
width: '50%'
|
|
178
|
+
},
|
|
179
|
+
label: 'Email From'
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'subject',
|
|
185
|
+
type: 'text',
|
|
186
|
+
defaultValue: "You've received a new message.",
|
|
187
|
+
label: 'Subject',
|
|
188
|
+
localized: true,
|
|
189
|
+
required: true
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'message',
|
|
193
|
+
type: 'richText',
|
|
194
|
+
admin: {
|
|
195
|
+
description: 'Enter the message that should be sent in this email.'
|
|
196
|
+
},
|
|
197
|
+
label: 'Message',
|
|
198
|
+
localized: true
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
];
|
|
56
203
|
const config = {
|
|
57
204
|
...formConfig?.formOverrides || {},
|
|
58
205
|
slug: formConfig?.formOverrides?.slug || 'forms',
|
|
@@ -65,150 +212,9 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
65
212
|
useAsTitle: 'title',
|
|
66
213
|
...formConfig?.formOverrides?.admin || {}
|
|
67
214
|
},
|
|
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
|
-
]
|
|
215
|
+
fields: formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function' ? formConfig.formOverrides.fields({
|
|
216
|
+
defaultFields
|
|
217
|
+
}) : defaultFields
|
|
212
218
|
};
|
|
213
219
|
return config;
|
|
214
220
|
};
|
|
@@ -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;AA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MAAM;gCACNC,OAAO;oCACLsC,OAAO;gCACT;gCACAhC,OAAO;4BACT;4BACA;gCACER,MAAM;gCACNC,MAAM;gCACNC,OAAO;oCACLsC,OAAO;gCACT;gCACAhC,OAAO;4BACT;yBACD;oBACH;oBACA;wBACEP,MAAM;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'\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 admin: {\n description:\n \"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}.\",\n },\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'emailTo',\n type: 'text',\n admin: {\n placeholder: '\"Email Sender\" <sender@email.com>',\n width: '100%',\n },\n label: 'Email To',\n },\n {\n name: 'cc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: 'CC',\n },\n {\n name: 'bcc',\n type: 'text',\n admin: {\n style: {\n maxWidth: '50%',\n },\n },\n label: 'BCC',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n name: 'replyTo',\n type: 'text',\n admin: {\n placeholder: '\"Reply To\" <reply-to@email.com>',\n width: '50%',\n },\n label: 'Reply To',\n },\n {\n name: 'emailFrom',\n type: 'text',\n admin: {\n placeholder: '\"Email From\" <email-from@email.com>',\n width: '50%',\n },\n label: 'Email From',\n },\n ],\n },\n {\n name: 'subject',\n type: 'text',\n defaultValue: \"You've received a new message.\",\n label: 'Subject',\n localized: true,\n required: true,\n },\n {\n name: 'message',\n type: 'richText',\n admin: {\n description: 'Enter the message that should be sent in this email.',\n },\n label: 'Message',\n localized: true,\n },\n ],\n },\n ]\n\n const config: CollectionConfig = {\n ...(formConfig?.formOverrides || {}),\n slug: formConfig?.formOverrides?.slug || 'forms',\n access: {\n read: () => true,\n ...(formConfig?.formOverrides?.access || {}),\n },\n admin: {\n enableRichTextRelationship: false,\n useAsTitle: 'title',\n ...(formConfig?.formOverrides?.admin || {}),\n },\n fields:\n formConfig?.formOverrides?.fields && typeof formConfig?.formOverrides?.fields === 'function'\n ? formConfig.formOverrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return config\n}\n"],"names":["deepMergeWithSourceArrays","fields","generateFormCollection","formConfig","redirect","name","type","admin","condition","_","siblingData","confirmationType","hideGutter","label","required","redirectRelationships","unshift","maxDepth","relationTo","layout","defaultValue","options","value","defaultFields","blocks","Object","entries","map","fieldKey","fieldConfig","block","undefined","filter","Boolean","localized","description","placeholder","width","style","maxWidth","config","formOverrides","slug","access","read","enableRichTextRelationship","useAsTitle"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAInD,SAASC,MAAM,QAAQ,cAAa;AAE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M;4BACNC,MAAM;4BACNC,OAAO;gCACL6B,aAAa;gCACbC,OAAO;4BACT;4BACAxB,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,MAAMM,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 @@
|
|
|
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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
+
//# 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,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"}
|
|
@@ -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 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
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
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,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,8 +1,8 @@
|
|
|
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
|
-
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
|
|
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
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Block, CollectionBeforeChangeHook, CollectionConfig, Field, TypeWithID } from 'payload';
|
|
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 = {
|
|
11
|
+
paymentProcessor: Partial<SelectField>;
|
|
12
|
+
} & Partial<Field>;
|
|
13
|
+
export type FieldConfig = Partial<Field> | PaymentFieldConfig;
|
|
14
|
+
export interface FieldsConfig {
|
|
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[]>;
|
|
29
|
+
export type HandlePayment = (data: any) => void;
|
|
30
|
+
export type FieldsOverride = (args: {
|
|
31
|
+
defaultFields: Field[];
|
|
32
|
+
}) => Field[];
|
|
33
|
+
export type FormBuilderPluginConfig = {
|
|
34
|
+
beforeEmail?: BeforeEmail;
|
|
35
|
+
fields?: FieldsConfig;
|
|
36
|
+
formOverrides?: {
|
|
37
|
+
fields?: FieldsOverride;
|
|
38
|
+
} & Partial<Omit<CollectionConfig, 'fields'>>;
|
|
39
|
+
formSubmissionOverrides?: {
|
|
40
|
+
fields?: FieldsOverride;
|
|
41
|
+
} & Partial<Omit<CollectionConfig, 'fields'>>;
|
|
42
|
+
handlePayment?: HandlePayment;
|
|
43
|
+
redirectRelationships?: string[];
|
|
44
|
+
};
|
|
45
|
+
export interface TextField {
|
|
46
|
+
blockName?: string;
|
|
47
|
+
blockType: 'text';
|
|
48
|
+
defaultValue?: string;
|
|
49
|
+
label?: string;
|
|
50
|
+
name: string;
|
|
51
|
+
required?: boolean;
|
|
52
|
+
width?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface TextAreaField {
|
|
55
|
+
blockName?: string;
|
|
56
|
+
blockType: 'textarea';
|
|
57
|
+
defaultValue?: string;
|
|
58
|
+
label?: string;
|
|
59
|
+
name: string;
|
|
60
|
+
required?: boolean;
|
|
61
|
+
width?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface SelectFieldOption {
|
|
64
|
+
label: string;
|
|
65
|
+
value: string;
|
|
66
|
+
}
|
|
67
|
+
export interface SelectField {
|
|
68
|
+
blockName?: string;
|
|
69
|
+
blockType: 'select';
|
|
70
|
+
defaultValue?: string;
|
|
71
|
+
label?: string;
|
|
72
|
+
name: string;
|
|
73
|
+
options: SelectFieldOption[];
|
|
74
|
+
required?: boolean;
|
|
75
|
+
width?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface PriceCondition {
|
|
78
|
+
condition: 'equals' | 'hasValue' | 'notEquals';
|
|
79
|
+
fieldToUse: string;
|
|
80
|
+
operator: 'add' | 'divide' | 'multiply' | 'subtract';
|
|
81
|
+
valueForCondition: string;
|
|
82
|
+
valueForOperator: number | string;
|
|
83
|
+
valueType: 'static' | 'valueOfField';
|
|
84
|
+
}
|
|
85
|
+
export interface PaymentField {
|
|
86
|
+
basePrice: number;
|
|
87
|
+
blockName?: string;
|
|
88
|
+
blockType: 'payment';
|
|
89
|
+
defaultValue?: string;
|
|
90
|
+
label?: string;
|
|
91
|
+
name: string;
|
|
92
|
+
paymentProcessor: string;
|
|
93
|
+
priceConditions: PriceCondition[];
|
|
94
|
+
required?: boolean;
|
|
95
|
+
width?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface EmailField {
|
|
98
|
+
blockName?: string;
|
|
99
|
+
blockType: 'email';
|
|
100
|
+
defaultValue?: string;
|
|
101
|
+
label?: string;
|
|
102
|
+
name: string;
|
|
103
|
+
required?: boolean;
|
|
104
|
+
width?: number;
|
|
105
|
+
}
|
|
106
|
+
export interface StateField {
|
|
107
|
+
blockName?: string;
|
|
108
|
+
blockType: 'state';
|
|
109
|
+
defaultValue?: string;
|
|
110
|
+
label?: string;
|
|
111
|
+
name: string;
|
|
112
|
+
required?: boolean;
|
|
113
|
+
width?: number;
|
|
114
|
+
}
|
|
115
|
+
export interface CountryField {
|
|
116
|
+
blockName?: string;
|
|
117
|
+
blockType: 'country';
|
|
118
|
+
defaultValue?: string;
|
|
119
|
+
label?: string;
|
|
120
|
+
name: string;
|
|
121
|
+
required?: boolean;
|
|
122
|
+
width?: number;
|
|
123
|
+
}
|
|
124
|
+
export interface CheckboxField {
|
|
125
|
+
blockName?: string;
|
|
126
|
+
blockType: 'checkbox';
|
|
127
|
+
defaultValue?: boolean;
|
|
128
|
+
label?: string;
|
|
129
|
+
name: string;
|
|
130
|
+
required?: boolean;
|
|
131
|
+
width?: number;
|
|
132
|
+
}
|
|
133
|
+
export interface MessageField {
|
|
134
|
+
blockName?: string;
|
|
135
|
+
blockType: 'message';
|
|
136
|
+
message: unknown;
|
|
137
|
+
}
|
|
138
|
+
export type FormFieldBlock = CheckboxField | CountryField | EmailField | MessageField | PaymentField | SelectField | StateField | TextAreaField | TextField;
|
|
139
|
+
export interface Email {
|
|
140
|
+
bcc?: string;
|
|
141
|
+
cc?: string;
|
|
142
|
+
emailFrom: string;
|
|
143
|
+
emailTo: string;
|
|
144
|
+
message?: any;
|
|
145
|
+
replyTo?: string;
|
|
146
|
+
subject: string;
|
|
147
|
+
}
|
|
148
|
+
export interface FormattedEmail {
|
|
149
|
+
bcc?: string;
|
|
150
|
+
cc?: string;
|
|
151
|
+
from: string;
|
|
152
|
+
html: string;
|
|
153
|
+
replyTo: string;
|
|
154
|
+
subject: string;
|
|
155
|
+
to: string;
|
|
156
|
+
}
|
|
157
|
+
export interface Redirect {
|
|
158
|
+
reference?: {
|
|
159
|
+
relationTo: string;
|
|
160
|
+
value: string | unknown;
|
|
161
|
+
};
|
|
162
|
+
type: 'custom' | 'reference';
|
|
163
|
+
url: string;
|
|
164
|
+
}
|
|
165
|
+
export interface Form {
|
|
166
|
+
confirmationMessage?: any;
|
|
167
|
+
confirmationType: 'message' | 'redirect';
|
|
168
|
+
emails: Email[];
|
|
169
|
+
fields: FormFieldBlock[];
|
|
170
|
+
id: string;
|
|
171
|
+
redirect?: Redirect;
|
|
172
|
+
submitButtonLabel?: string;
|
|
173
|
+
title: string;
|
|
174
|
+
}
|
|
175
|
+
export interface SubmissionValue {
|
|
176
|
+
field: string;
|
|
177
|
+
value: unknown;
|
|
178
|
+
}
|
|
179
|
+
export interface FormSubmission {
|
|
180
|
+
form: Form | string;
|
|
181
|
+
submissionData: SubmissionValue[];
|
|
182
|
+
}
|
|
183
|
+
export {};
|
|
184
|
+
//# sourceMappingURL=types.d.ts.map
|