@payloadcms/plugin-form-builder 3.73.0-canary.2 → 3.73.0-internal.783bc97
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/handleUploads.d.ts +16 -0
- package/dist/collections/FormSubmissions/hooks/handleUploads.d.ts.map +1 -0
- package/dist/collections/FormSubmissions/hooks/handleUploads.js +216 -0
- package/dist/collections/FormSubmissions/hooks/handleUploads.js.map +1 -0
- package/dist/collections/FormSubmissions/index.d.ts.map +1 -1
- package/dist/collections/FormSubmissions/index.js +2 -0
- package/dist/collections/FormSubmissions/index.js.map +1 -1
- package/dist/collections/Forms/fields.d.ts +1 -2
- package/dist/collections/Forms/fields.d.ts.map +1 -1
- package/dist/collections/Forms/fields.js +102 -1
- package/dist/collections/Forms/fields.js.map +1 -1
- package/dist/collections/Forms/index.d.ts.map +1 -1
- package/dist/collections/Forms/index.js +4 -0
- package/dist/collections/Forms/index.js.map +1 -1
- 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.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +28 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CollectionBeforeChangeHook } from 'payload';
|
|
2
|
+
import type { FormBuilderPluginConfig } from '../../../types.js';
|
|
3
|
+
type BeforeChangeParams = Parameters<CollectionBeforeChangeHook>[0];
|
|
4
|
+
/**
|
|
5
|
+
* Handles upload fields in form submissions.
|
|
6
|
+
*
|
|
7
|
+
* This hook:
|
|
8
|
+
* 1. Checks req.files for files matching upload field names
|
|
9
|
+
* 2. Validates MIME types and file sizes before uploading
|
|
10
|
+
* 3. Creates media documents in the appropriate upload collection
|
|
11
|
+
* 4. Updates submissionData with the created file IDs
|
|
12
|
+
* 5. Validates pre-uploaded file IDs for backwards compatibility
|
|
13
|
+
*/
|
|
14
|
+
export declare const handleUploads: (beforeChangeParams: BeforeChangeParams, formConfig: FormBuilderPluginConfig) => Promise<Partial<any>>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=handleUploads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleUploads.d.ts","sourceRoot":"","sources":["../../../../src/collections/FormSubmissions/hooks/handleUploads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAwB,MAAM,SAAS,CAAA;AAK/E,OAAO,KAAK,EAAE,uBAAuB,EAAgC,MAAM,mBAAmB,CAAA;AAE9F,KAAK,kBAAkB,GAAG,UAAU,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAA;AAOnE;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,uBACJ,kBAAkB,cAC1B,uBAAuB,0BA8OpC,CAAA"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { ValidationError } from 'payload';
|
|
2
|
+
import { validateMimeType } from 'payload/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Handles upload fields in form submissions.
|
|
5
|
+
*
|
|
6
|
+
* This hook:
|
|
7
|
+
* 1. Checks req.files for files matching upload field names
|
|
8
|
+
* 2. Validates MIME types and file sizes before uploading
|
|
9
|
+
* 3. Creates media documents in the appropriate upload collection
|
|
10
|
+
* 4. Updates submissionData with the created file IDs
|
|
11
|
+
* 5. Validates pre-uploaded file IDs for backwards compatibility
|
|
12
|
+
*/ export const handleUploads = async (beforeChangeParams, formConfig)=>{
|
|
13
|
+
const { data, operation, req } = beforeChangeParams;
|
|
14
|
+
const { payload } = req;
|
|
15
|
+
// Only handle on create
|
|
16
|
+
if (operation !== 'create') {
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
const { form: formID, submissionData } = data || {};
|
|
20
|
+
if (!formID || !submissionData) {
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
const formSlug = formConfig?.formOverrides?.slug || 'forms';
|
|
24
|
+
// Fetch the form to get field configurations
|
|
25
|
+
let form;
|
|
26
|
+
try {
|
|
27
|
+
form = await payload.findByID({
|
|
28
|
+
id: formID,
|
|
29
|
+
collection: formSlug,
|
|
30
|
+
req
|
|
31
|
+
});
|
|
32
|
+
} catch {
|
|
33
|
+
// If form doesn't exist, let the form relationship validation handle it
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
const formFields = form?.fields || [];
|
|
37
|
+
const uploadFields = formFields.filter((field)=>field.blockType === 'upload');
|
|
38
|
+
if (uploadFields.length === 0) {
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
// Build a map of submission values for easy lookup
|
|
42
|
+
const submissionMap = new Map();
|
|
43
|
+
const submissionDataArray = submissionData;
|
|
44
|
+
for(let i = 0; i < submissionDataArray.length; i++){
|
|
45
|
+
const item = submissionDataArray[i];
|
|
46
|
+
if (item) {
|
|
47
|
+
submissionMap.set(item.field, {
|
|
48
|
+
index: i,
|
|
49
|
+
value: item.value
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Get files from request (populated by addDataAndFileToRequest)
|
|
54
|
+
// Type assertion needed as `files` is added to PayloadRequest for multipart form handling
|
|
55
|
+
const requestFiles = req.files || {};
|
|
56
|
+
const errors = [];
|
|
57
|
+
const updatedSubmissionData = [
|
|
58
|
+
...submissionDataArray
|
|
59
|
+
];
|
|
60
|
+
for (const uploadField of uploadFields){
|
|
61
|
+
const { name, maxFileSize, mimeTypes, multiple, required, uploadCollection } = uploadField;
|
|
62
|
+
const fieldLabel = uploadField.label || name;
|
|
63
|
+
// Check if there's a file in the request for this field
|
|
64
|
+
const requestFile = requestFiles[name];
|
|
65
|
+
const existingSubmission = submissionMap.get(name);
|
|
66
|
+
// Handle direct file upload from request
|
|
67
|
+
if (requestFile) {
|
|
68
|
+
// Validate MIME type before uploading
|
|
69
|
+
if (mimeTypes && mimeTypes.length > 0) {
|
|
70
|
+
const allowedPatterns = mimeTypes.map((m)=>m.mimeType);
|
|
71
|
+
if (!validateMimeType(requestFile.mimetype, allowedPatterns)) {
|
|
72
|
+
errors.push({
|
|
73
|
+
field: name,
|
|
74
|
+
message: `${fieldLabel}: File type "${requestFile.mimetype}" is not allowed. Allowed types: ${allowedPatterns.join(', ')}`
|
|
75
|
+
});
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Validate file size before uploading
|
|
80
|
+
if (maxFileSize && maxFileSize > 0 && requestFile.size > maxFileSize) {
|
|
81
|
+
const maxSizeMB = (maxFileSize / (1024 * 1024)).toFixed(2);
|
|
82
|
+
const fileSizeMB = (requestFile.size / (1024 * 1024)).toFixed(2);
|
|
83
|
+
errors.push({
|
|
84
|
+
field: name,
|
|
85
|
+
message: `${fieldLabel}: File size (${fileSizeMB}MB) exceeds maximum allowed size (${maxSizeMB}MB)`
|
|
86
|
+
});
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
// Create the media document
|
|
90
|
+
try {
|
|
91
|
+
const mediaDoc = await payload.create({
|
|
92
|
+
collection: uploadCollection,
|
|
93
|
+
data: {},
|
|
94
|
+
file: {
|
|
95
|
+
name: requestFile.name,
|
|
96
|
+
data: requestFile.data,
|
|
97
|
+
mimetype: requestFile.mimetype,
|
|
98
|
+
size: requestFile.size
|
|
99
|
+
},
|
|
100
|
+
req
|
|
101
|
+
});
|
|
102
|
+
// Update or add the submission data entry with the file ID
|
|
103
|
+
const fileId = String(mediaDoc.id);
|
|
104
|
+
if (existingSubmission) {
|
|
105
|
+
// If multiple files and there's already a value, append
|
|
106
|
+
if (multiple && existingSubmission.value) {
|
|
107
|
+
updatedSubmissionData[existingSubmission.index] = {
|
|
108
|
+
field: name,
|
|
109
|
+
value: `${existingSubmission.value},${fileId}`
|
|
110
|
+
};
|
|
111
|
+
} else {
|
|
112
|
+
updatedSubmissionData[existingSubmission.index] = {
|
|
113
|
+
field: name,
|
|
114
|
+
value: fileId
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
// Add new submission entry
|
|
119
|
+
updatedSubmissionData.push({
|
|
120
|
+
field: name,
|
|
121
|
+
value: fileId
|
|
122
|
+
});
|
|
123
|
+
// Update the map for potential subsequent iterations
|
|
124
|
+
submissionMap.set(name, {
|
|
125
|
+
index: updatedSubmissionData.length - 1,
|
|
126
|
+
value: fileId
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
} catch (err) {
|
|
130
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
131
|
+
errors.push({
|
|
132
|
+
field: name,
|
|
133
|
+
message: `${fieldLabel}: Failed to upload file - ${errorMessage}`
|
|
134
|
+
});
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
} else if (existingSubmission && existingSubmission.value) {
|
|
138
|
+
// Backwards compatibility: validate pre-uploaded file IDs
|
|
139
|
+
const submittedValue = existingSubmission.value;
|
|
140
|
+
// Parse file IDs (comma-separated for multiple files)
|
|
141
|
+
const fileIds = multiple ? String(submittedValue).split(',').map((id)=>id.trim()).filter(Boolean) : [
|
|
142
|
+
String(submittedValue)
|
|
143
|
+
];
|
|
144
|
+
// Validate each file
|
|
145
|
+
for (const fileId of fileIds){
|
|
146
|
+
let fileDoc = null;
|
|
147
|
+
try {
|
|
148
|
+
fileDoc = await payload.findByID({
|
|
149
|
+
id: fileId,
|
|
150
|
+
collection: uploadCollection,
|
|
151
|
+
req
|
|
152
|
+
});
|
|
153
|
+
} catch {
|
|
154
|
+
errors.push({
|
|
155
|
+
field: name,
|
|
156
|
+
message: `${fieldLabel}: File with ID "${fileId}" not found in collection "${uploadCollection}"`
|
|
157
|
+
});
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (!fileDoc) {
|
|
161
|
+
errors.push({
|
|
162
|
+
field: name,
|
|
163
|
+
message: `${fieldLabel}: File with ID "${fileId}" not found`
|
|
164
|
+
});
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// Validate mimeType
|
|
168
|
+
if (mimeTypes && mimeTypes.length > 0) {
|
|
169
|
+
const allowedPatterns = mimeTypes.map((m)=>m.mimeType);
|
|
170
|
+
const fileMimeType = fileDoc.mimeType;
|
|
171
|
+
if (fileMimeType && !validateMimeType(fileMimeType, allowedPatterns)) {
|
|
172
|
+
errors.push({
|
|
173
|
+
field: name,
|
|
174
|
+
message: `${fieldLabel}: File type "${fileMimeType}" is not allowed. Allowed types: ${allowedPatterns.join(', ')}`
|
|
175
|
+
});
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Validate file size
|
|
180
|
+
if (maxFileSize && maxFileSize > 0) {
|
|
181
|
+
const fileSize = fileDoc.filesize;
|
|
182
|
+
if (fileSize && fileSize > maxFileSize) {
|
|
183
|
+
const maxSizeMB = (maxFileSize / (1024 * 1024)).toFixed(2);
|
|
184
|
+
const fileSizeMB = (fileSize / (1024 * 1024)).toFixed(2);
|
|
185
|
+
errors.push({
|
|
186
|
+
field: name,
|
|
187
|
+
message: `${fieldLabel}: File size (${fileSizeMB}MB) exceeds maximum allowed size (${maxSizeMB}MB)`
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} else if (required) {
|
|
193
|
+
// No file in request and no pre-uploaded file ID, but field is required
|
|
194
|
+
errors.push({
|
|
195
|
+
field: name,
|
|
196
|
+
message: `${fieldLabel} is required`
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (errors.length > 0) {
|
|
201
|
+
throw new ValidationError({
|
|
202
|
+
collection: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',
|
|
203
|
+
errors: errors.map((error)=>({
|
|
204
|
+
message: error.message,
|
|
205
|
+
path: error.field
|
|
206
|
+
}))
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// Return updated data with new submission data
|
|
210
|
+
return {
|
|
211
|
+
...data,
|
|
212
|
+
submissionData: updatedSubmissionData
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
//# sourceMappingURL=handleUploads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/FormSubmissions/hooks/handleUploads.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook, FileData, TypeWithID } from 'payload'\n\nimport { ValidationError } from 'payload'\nimport { validateMimeType } from 'payload/shared'\n\nimport type { FormBuilderPluginConfig, SubmissionValue, UploadField } from '../../../types.js'\n\ntype BeforeChangeParams = Parameters<CollectionBeforeChangeHook>[0]\n\ninterface UploadError {\n field: string\n message: string\n}\n\n/**\n * Handles upload fields in form submissions.\n *\n * This hook:\n * 1. Checks req.files for files matching upload field names\n * 2. Validates MIME types and file sizes before uploading\n * 3. Creates media documents in the appropriate upload collection\n * 4. Updates submissionData with the created file IDs\n * 5. Validates pre-uploaded file IDs for backwards compatibility\n */\nexport const handleUploads = async (\n beforeChangeParams: BeforeChangeParams,\n formConfig: FormBuilderPluginConfig,\n) => {\n const { data, operation, req } = beforeChangeParams\n const { payload } = req\n\n // Only handle on create\n if (operation !== 'create') {\n return data\n }\n\n const { form: formID, submissionData } = data || {}\n\n if (!formID || !submissionData) {\n return data\n }\n\n const formSlug = formConfig?.formOverrides?.slug || 'forms'\n\n // Fetch the form to get field configurations\n let form\n try {\n form = await payload.findByID({\n id: formID,\n collection: formSlug,\n req,\n })\n } catch {\n // If form doesn't exist, let the form relationship validation handle it\n return data\n }\n\n const formFields = form?.fields || []\n const uploadFields = formFields.filter(\n (field: { blockType: string }) => field.blockType === 'upload',\n ) as UploadField[]\n\n if (uploadFields.length === 0) {\n return data\n }\n\n // Build a map of submission values for easy lookup\n const submissionMap = new Map<string, { index: number; value: unknown }>()\n const submissionDataArray = submissionData as SubmissionValue[]\n\n for (let i = 0; i < submissionDataArray.length; i++) {\n const item = submissionDataArray[i]\n\n if (item) {\n submissionMap.set(item.field, { index: i, value: item.value })\n }\n }\n\n // Get files from request (populated by addDataAndFileToRequest)\n // Type assertion needed as `files` is added to PayloadRequest for multipart form handling\n const requestFiles =\n (\n req as {\n files?: Record<string, { data: Buffer; mimetype: string; name: string; size: number }>\n }\n ).files || {}\n\n const errors: UploadError[] = []\n const updatedSubmissionData = [...submissionDataArray]\n\n for (const uploadField of uploadFields) {\n const { name, maxFileSize, mimeTypes, multiple, required, uploadCollection } = uploadField\n const fieldLabel = uploadField.label || name\n\n // Check if there's a file in the request for this field\n const requestFile = requestFiles[name]\n const existingSubmission = submissionMap.get(name)\n\n // Handle direct file upload from request\n if (requestFile) {\n // Validate MIME type before uploading\n if (mimeTypes && mimeTypes.length > 0) {\n const allowedPatterns = mimeTypes.map((m) => m.mimeType)\n\n if (!validateMimeType(requestFile.mimetype, allowedPatterns)) {\n errors.push({\n field: name,\n message: `${fieldLabel}: File type \"${requestFile.mimetype}\" is not allowed. Allowed types: ${allowedPatterns.join(', ')}`,\n })\n continue\n }\n }\n\n // Validate file size before uploading\n if (maxFileSize && maxFileSize > 0 && requestFile.size > maxFileSize) {\n const maxSizeMB = (maxFileSize / (1024 * 1024)).toFixed(2)\n const fileSizeMB = (requestFile.size / (1024 * 1024)).toFixed(2)\n\n errors.push({\n field: name,\n message: `${fieldLabel}: File size (${fileSizeMB}MB) exceeds maximum allowed size (${maxSizeMB}MB)`,\n })\n continue\n }\n\n // Create the media document\n try {\n const mediaDoc = await payload.create({\n collection: uploadCollection,\n data: {},\n file: {\n name: requestFile.name,\n data: requestFile.data,\n mimetype: requestFile.mimetype,\n size: requestFile.size,\n },\n req,\n })\n\n // Update or add the submission data entry with the file ID\n const fileId = String(mediaDoc.id)\n\n if (existingSubmission) {\n // If multiple files and there's already a value, append\n if (multiple && existingSubmission.value) {\n updatedSubmissionData[existingSubmission.index] = {\n field: name,\n value: `${existingSubmission.value},${fileId}`,\n }\n } else {\n updatedSubmissionData[existingSubmission.index] = {\n field: name,\n value: fileId,\n }\n }\n } else {\n // Add new submission entry\n updatedSubmissionData.push({\n field: name,\n value: fileId,\n })\n // Update the map for potential subsequent iterations\n submissionMap.set(name, { index: updatedSubmissionData.length - 1, value: fileId })\n }\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : 'Unknown error'\n\n errors.push({\n field: name,\n message: `${fieldLabel}: Failed to upload file - ${errorMessage}`,\n })\n continue\n }\n } else if (existingSubmission && existingSubmission.value) {\n // Backwards compatibility: validate pre-uploaded file IDs\n const submittedValue = existingSubmission.value\n\n // Parse file IDs (comma-separated for multiple files)\n const fileIds = multiple\n ? String(submittedValue)\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n : [String(submittedValue)]\n\n // Validate each file\n for (const fileId of fileIds) {\n let fileDoc: (FileData & TypeWithID) | null = null\n\n try {\n fileDoc = (await payload.findByID({\n id: fileId,\n collection: uploadCollection,\n req,\n })) as FileData & TypeWithID\n } catch {\n errors.push({\n field: name,\n message: `${fieldLabel}: File with ID \"${fileId}\" not found in collection \"${uploadCollection}\"`,\n })\n continue\n }\n\n if (!fileDoc) {\n errors.push({\n field: name,\n message: `${fieldLabel}: File with ID \"${fileId}\" not found`,\n })\n continue\n }\n\n // Validate mimeType\n if (mimeTypes && mimeTypes.length > 0) {\n const allowedPatterns = mimeTypes.map((m) => m.mimeType)\n const fileMimeType = fileDoc.mimeType\n\n if (fileMimeType && !validateMimeType(fileMimeType, allowedPatterns)) {\n errors.push({\n field: name,\n message: `${fieldLabel}: File type \"${fileMimeType}\" is not allowed. Allowed types: ${allowedPatterns.join(', ')}`,\n })\n continue\n }\n }\n\n // Validate file size\n if (maxFileSize && maxFileSize > 0) {\n const fileSize = fileDoc.filesize\n\n if (fileSize && fileSize > maxFileSize) {\n const maxSizeMB = (maxFileSize / (1024 * 1024)).toFixed(2)\n const fileSizeMB = (fileSize / (1024 * 1024)).toFixed(2)\n\n errors.push({\n field: name,\n message: `${fieldLabel}: File size (${fileSizeMB}MB) exceeds maximum allowed size (${maxSizeMB}MB)`,\n })\n }\n }\n }\n } else if (required) {\n // No file in request and no pre-uploaded file ID, but field is required\n errors.push({\n field: name,\n message: `${fieldLabel} is required`,\n })\n }\n }\n\n if (errors.length > 0) {\n throw new ValidationError({\n collection: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',\n errors: errors.map((error) => ({\n message: error.message,\n path: error.field,\n })),\n })\n }\n\n // Return updated data with new submission data\n return {\n ...data,\n submissionData: updatedSubmissionData,\n }\n}\n"],"names":["ValidationError","validateMimeType","handleUploads","beforeChangeParams","formConfig","data","operation","req","payload","form","formID","submissionData","formSlug","formOverrides","slug","findByID","id","collection","formFields","fields","uploadFields","filter","field","blockType","length","submissionMap","Map","submissionDataArray","i","item","set","index","value","requestFiles","files","errors","updatedSubmissionData","uploadField","name","maxFileSize","mimeTypes","multiple","required","uploadCollection","fieldLabel","label","requestFile","existingSubmission","get","allowedPatterns","map","m","mimeType","mimetype","push","message","join","size","maxSizeMB","toFixed","fileSizeMB","mediaDoc","create","file","fileId","String","err","errorMessage","Error","submittedValue","fileIds","split","trim","Boolean","fileDoc","fileMimeType","fileSize","filesize","formSubmissionOverrides","error","path"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AACzC,SAASC,gBAAgB,QAAQ,iBAAgB;AAWjD;;;;;;;;;CASC,GACD,OAAO,MAAMC,gBAAgB,OAC3BC,oBACAC;IAEA,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,GAAG,EAAE,GAAGJ;IACjC,MAAM,EAAEK,OAAO,EAAE,GAAGD;IAEpB,wBAAwB;IACxB,IAAID,cAAc,UAAU;QAC1B,OAAOD;IACT;IAEA,MAAM,EAAEI,MAAMC,MAAM,EAAEC,cAAc,EAAE,GAAGN,QAAQ,CAAC;IAElD,IAAI,CAACK,UAAU,CAACC,gBAAgB;QAC9B,OAAON;IACT;IAEA,MAAMO,WAAWR,YAA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,CAAA;oBAC7BxB,SAASwB,MAAMxB,OAAO;oBACtByB,MAAMD,MAAMzD,KAAK;gBACnB,CAAA;QACF;IACF;IAEA,+CAA+C;IAC/C,OAAO;QACL,GAAGjB,IAAI;QACPM,gBAAgByB;IAClB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/FormSubmissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/FormSubmissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAQ7D,eAAO,MAAM,4BAA4B,eAC3B,uBAAuB,KAClC,gBAuGF,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defaultPaymentFields } from './fields/defaultPaymentFields.js';
|
|
2
2
|
import { createCharge } from './hooks/createCharge.js';
|
|
3
|
+
import { handleUploads } from './hooks/handleUploads.js';
|
|
3
4
|
import { sendEmail } from './hooks/sendEmail.js';
|
|
4
5
|
// all settings can be overridden by the config
|
|
5
6
|
export const generateSubmissionCollection = (formConfig)=>{
|
|
@@ -87,6 +88,7 @@ export const generateSubmissionCollection = (formConfig)=>{
|
|
|
87
88
|
...formConfig?.formSubmissionOverrides?.hooks?.afterChange || []
|
|
88
89
|
],
|
|
89
90
|
beforeChange: [
|
|
91
|
+
(data)=>handleUploads(data, formConfig),
|
|
90
92
|
(data)=>createCharge(data, formConfig),
|
|
91
93
|
...formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []
|
|
92
94
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { defaultPaymentFields } from './fields/defaultPaymentFields.js'\nimport { createCharge } from './hooks/createCharge.js'\nimport { sendEmail } from './hooks/sendEmail.js'\n\n// all settings can be overridden by the config\nexport const generateSubmissionCollection = (\n formConfig: FormBuilderPluginConfig,\n): CollectionConfig => {\n const formSlug = formConfig?.formOverrides?.slug || 'forms'\n\n const enablePaymentFields = Boolean(formConfig?.fields?.payment)\n\n const defaultFields: Field[] = [\n {\n name: 'form',\n type: 'relationship',\n relationTo: formSlug,\n required: true,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n validate: async (value, { req: { payload }, req }) => {\n /* Don't run in the client side */\n if (!payload) {\n return true\n }\n\n if (payload) {\n let _existingForm\n\n try {\n _existingForm = await payload.findByID({\n id: value,\n collection: formSlug,\n req,\n })\n\n return true\n } catch (_error) {\n return 'Cannot create this submission because this form does not exist.'\n }\n }\n },\n },\n {\n name: 'submissionData',\n type: 'array',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'textarea',\n required: true,\n validate: (value: unknown) => {\n // TODO:\n // create a validation function that dynamically\n // relies on the field type and its options as configured.\n\n // How to access sibling data from this field?\n // Need the `name` of the field in order to validate it.\n\n // Might not be possible to use this validation function.\n // Instead, might need to do all validation in a `beforeValidate` collection hook.\n\n if (typeof value !== 'undefined') {\n return true\n }\n\n return 'This field is required.'\n },\n },\n ],\n },\n ...(enablePaymentFields ? [defaultPaymentFields] : []),\n ]\n\n const newConfig: CollectionConfig = {\n ...(formConfig?.formSubmissionOverrides || {}),\n slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',\n access: {\n create: () => true,\n read: ({ req: { user } }) => !!user, // logged-in users,\n update: () => false,\n ...(formConfig?.formSubmissionOverrides?.access || {}),\n },\n admin: {\n ...(formConfig?.formSubmissionOverrides?.admin || {}),\n enableRichTextRelationship: false,\n },\n fields:\n formConfig?.formSubmissionOverrides?.fields &&\n typeof formConfig?.formSubmissionOverrides?.fields === 'function'\n ? formConfig.formSubmissionOverrides.fields({ defaultFields })\n : defaultFields,\n hooks: {\n ...(formConfig?.formSubmissionOverrides?.hooks || {}),\n afterChange: [\n (data) => sendEmail(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.afterChange || []),\n ],\n beforeChange: [\n (data) => createCharge(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []),\n ],\n },\n }\n return newConfig\n}\n"],"names":["defaultPaymentFields","createCharge","sendEmail","generateSubmissionCollection","formConfig","formSlug","formOverrides","slug","enablePaymentFields","Boolean","fields","payment","defaultFields","name","type","relationTo","required","validate","value","req","payload","_existingForm","findByID","id","collection","_error","newConfig","formSubmissionOverrides","access","create","read","user","update","admin","enableRichTextRelationship","hooks","afterChange","data","beforeChange"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,+CAA+C;AAC/C,OAAO,MAAMC,+BAA+B,CAC1CC;IAEA,MAAMC,WAAWD,YAAYE,eAAeC,QAAQ;IAEpD,MAAMC,sBAAsBC,QAAQL,YAAYM,QAAQC;IAExD,MAAMC,gBAAyB;QAC7B;YACEC,MAAM;YACNC,MAAM;YACNC,YAAYV;YACZW,UAAU;YACV,oFAAoF;YACpFC,UAAU,OAAOC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAE,EAAED,GAAG,EAAE;gBAC/C,gCAAgC,GAChC,IAAI,CAACC,SAAS;oBACZ,OAAO;gBACT;gBAEA,IAAIA,SAAS;oBACX,IAAIC;oBAEJ,IAAI;wBACFA,gBAAgB,MAAMD,QAAQE,QAAQ,CAAC;4BACrCC,IAAIL;4BACJM,YAAYnB;4BACZc;wBACF;wBAEA,OAAO;oBACT,EAAE,OAAOM,QAAQ;wBACf,OAAO;oBACT;gBACF;YACF;QACF;QACA;YACEZ,MAAM;YACNC,MAAM;YACNJ,QAAQ;gBACN;oBACEG,MAAM;oBACNC,MAAM;oBACNE,UAAU;gBACZ;gBACA;oBACEH,MAAM;oBACNC,MAAM;oBACNE,UAAU;oBACVC,UAAU,CAACC;wBACT,QAAQ;wBACR,gDAAgD;wBAChD,0DAA0D;wBAE1D,8CAA8C;wBAC9C,wDAAwD;wBAExD,yDAAyD;wBACzD,kFAAkF;wBAElF,IAAI,OAAOA,UAAU,aAAa;4BAChC,OAAO;wBACT;wBAEA,OAAO;oBACT;gBACF;aACD;QACH;WACIV,sBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/FormSubmissions/index.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { FormBuilderPluginConfig } from '../../types.js'\n\nimport { defaultPaymentFields } from './fields/defaultPaymentFields.js'\nimport { createCharge } from './hooks/createCharge.js'\nimport { handleUploads } from './hooks/handleUploads.js'\nimport { sendEmail } from './hooks/sendEmail.js'\n\n// all settings can be overridden by the config\nexport const generateSubmissionCollection = (\n formConfig: FormBuilderPluginConfig,\n): CollectionConfig => {\n const formSlug = formConfig?.formOverrides?.slug || 'forms'\n\n const enablePaymentFields = Boolean(formConfig?.fields?.payment)\n\n const defaultFields: Field[] = [\n {\n name: 'form',\n type: 'relationship',\n relationTo: formSlug,\n required: true,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n validate: async (value, { req: { payload }, req }) => {\n /* Don't run in the client side */\n if (!payload) {\n return true\n }\n\n if (payload) {\n let _existingForm\n\n try {\n _existingForm = await payload.findByID({\n id: value,\n collection: formSlug,\n req,\n })\n\n return true\n } catch (_error) {\n return 'Cannot create this submission because this form does not exist.'\n }\n }\n },\n },\n {\n name: 'submissionData',\n type: 'array',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n {\n name: 'value',\n type: 'textarea',\n required: true,\n validate: (value: unknown) => {\n // TODO:\n // create a validation function that dynamically\n // relies on the field type and its options as configured.\n\n // How to access sibling data from this field?\n // Need the `name` of the field in order to validate it.\n\n // Might not be possible to use this validation function.\n // Instead, might need to do all validation in a `beforeValidate` collection hook.\n\n if (typeof value !== 'undefined') {\n return true\n }\n\n return 'This field is required.'\n },\n },\n ],\n },\n ...(enablePaymentFields ? [defaultPaymentFields] : []),\n ]\n\n const newConfig: CollectionConfig = {\n ...(formConfig?.formSubmissionOverrides || {}),\n slug: formConfig?.formSubmissionOverrides?.slug || 'form-submissions',\n access: {\n create: () => true,\n read: ({ req: { user } }) => !!user, // logged-in users,\n update: () => false,\n ...(formConfig?.formSubmissionOverrides?.access || {}),\n },\n admin: {\n ...(formConfig?.formSubmissionOverrides?.admin || {}),\n enableRichTextRelationship: false,\n },\n fields:\n formConfig?.formSubmissionOverrides?.fields &&\n typeof formConfig?.formSubmissionOverrides?.fields === 'function'\n ? formConfig.formSubmissionOverrides.fields({ defaultFields })\n : defaultFields,\n hooks: {\n ...(formConfig?.formSubmissionOverrides?.hooks || {}),\n afterChange: [\n (data) => sendEmail(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.afterChange || []),\n ],\n beforeChange: [\n (data) => handleUploads(data, formConfig),\n (data) => createCharge(data, formConfig),\n ...(formConfig?.formSubmissionOverrides?.hooks?.beforeChange || []),\n ],\n },\n }\n return newConfig\n}\n"],"names":["defaultPaymentFields","createCharge","handleUploads","sendEmail","generateSubmissionCollection","formConfig","formSlug","formOverrides","slug","enablePaymentFields","Boolean","fields","payment","defaultFields","name","type","relationTo","required","validate","value","req","payload","_existingForm","findByID","id","collection","_error","newConfig","formSubmissionOverrides","access","create","read","user","update","admin","enableRichTextRelationship","hooks","afterChange","data","beforeChange"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,aAAa,QAAQ,2BAA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A;YAC/BC,QAAQ,IAAM;YACd,GAAI5B,YAAYuB,yBAAyBC,UAAU,CAAC,CAAC;QACvD;QACAK,OAAO;YACL,GAAI7B,YAAYuB,yBAAyBM,SAAS,CAAC,CAAC;YACpDC,4BAA4B;QAC9B;QACAxB,QACEN,YAAYuB,yBAAyBjB,UACrC,OAAON,YAAYuB,yBAAyBjB,WAAW,aACnDN,WAAWuB,uBAAuB,CAACjB,MAAM,CAAC;YAAEE;QAAc,KAC1DA;QACNuB,OAAO;YACL,GAAI/B,YAAYuB,yBAAyBQ,SAAS,CAAC,CAAC;YACpDC,aAAa;gBACX,CAACC,OAASnC,UAAUmC,MAAMjC;mBACtBA,YAAYuB,yBAAyBQ,OAAOC,eAAe,EAAE;aAClE;YACDE,cAAc;gBACZ,CAACD,OAASpC,cAAcoC,MAAMjC;gBAC9B,CAACiC,OAASrC,aAAaqC,MAAMjC;mBACzBA,YAAYuB,yBAAyBQ,OAAOG,gBAAgB,EAAE;aACnE;QACH;IACF;IACA,OAAOZ;AACT,EAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Block } from 'payload';
|
|
2
|
-
import type { FieldConfig } from '../../types.js';
|
|
3
2
|
export declare const fields: {
|
|
4
|
-
[key: string]: ((
|
|
3
|
+
[key: string]: ((arg?: any) => Block) | Block;
|
|
5
4
|
};
|
|
6
5
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,SAAS,CAAA;AAmzB3C,eAAO,MAAM,MAAM,EAAE;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,CAAA;CAe9C,CAAA"}
|
|
@@ -691,6 +691,106 @@ const Message = {
|
|
|
691
691
|
singular: 'Message'
|
|
692
692
|
}
|
|
693
693
|
};
|
|
694
|
+
const Upload = (uploadCollections)=>{
|
|
695
|
+
return {
|
|
696
|
+
slug: 'upload',
|
|
697
|
+
fields: [
|
|
698
|
+
{
|
|
699
|
+
type: 'row',
|
|
700
|
+
fields: [
|
|
701
|
+
{
|
|
702
|
+
...name,
|
|
703
|
+
admin: {
|
|
704
|
+
width: '50%'
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
...label,
|
|
709
|
+
admin: {
|
|
710
|
+
width: '50%'
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
]
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
name: 'uploadCollection',
|
|
717
|
+
type: 'select',
|
|
718
|
+
admin: {
|
|
719
|
+
description: 'Select which upload collection to store files in'
|
|
720
|
+
},
|
|
721
|
+
label: 'Upload Collection',
|
|
722
|
+
options: uploadCollections.map((slug)=>({
|
|
723
|
+
label: slug,
|
|
724
|
+
value: slug
|
|
725
|
+
})),
|
|
726
|
+
required: true
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: 'mimeTypes',
|
|
730
|
+
type: 'array',
|
|
731
|
+
admin: {
|
|
732
|
+
description: 'Restrict allowed file types (e.g., image/*, application/pdf). Leave empty to allow all types.'
|
|
733
|
+
},
|
|
734
|
+
fields: [
|
|
735
|
+
{
|
|
736
|
+
name: 'mimeType',
|
|
737
|
+
type: 'text',
|
|
738
|
+
label: 'MIME Type',
|
|
739
|
+
required: true
|
|
740
|
+
}
|
|
741
|
+
],
|
|
742
|
+
label: 'Allowed File Types',
|
|
743
|
+
labels: {
|
|
744
|
+
plural: 'MIME Types',
|
|
745
|
+
singular: 'MIME Type'
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
type: 'row',
|
|
750
|
+
fields: [
|
|
751
|
+
{
|
|
752
|
+
...width,
|
|
753
|
+
admin: {
|
|
754
|
+
width: '50%'
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
name: 'maxFileSize',
|
|
759
|
+
type: 'number',
|
|
760
|
+
admin: {
|
|
761
|
+
description: 'Maximum file size in bytes. Leave empty for no limit.',
|
|
762
|
+
width: '50%'
|
|
763
|
+
},
|
|
764
|
+
label: 'Max File Size (bytes)'
|
|
765
|
+
}
|
|
766
|
+
]
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
type: 'row',
|
|
770
|
+
fields: [
|
|
771
|
+
{
|
|
772
|
+
...required,
|
|
773
|
+
admin: {
|
|
774
|
+
width: '50%'
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
name: 'multiple',
|
|
779
|
+
type: 'checkbox',
|
|
780
|
+
admin: {
|
|
781
|
+
width: '50%'
|
|
782
|
+
},
|
|
783
|
+
label: 'Allow Multiple Files'
|
|
784
|
+
}
|
|
785
|
+
]
|
|
786
|
+
}
|
|
787
|
+
],
|
|
788
|
+
labels: {
|
|
789
|
+
plural: 'Upload Fields',
|
|
790
|
+
singular: 'Upload'
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
};
|
|
694
794
|
export const fields = {
|
|
695
795
|
checkbox: Checkbox,
|
|
696
796
|
country: Country,
|
|
@@ -703,7 +803,8 @@ export const fields = {
|
|
|
703
803
|
select: Select,
|
|
704
804
|
state: State,
|
|
705
805
|
text: Text,
|
|
706
|
-
textarea: TextArea
|
|
806
|
+
textarea: TextArea,
|
|
807
|
+
upload: Upload
|
|
707
808
|
};
|
|
708
809
|
|
|
709
810
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/Forms/fields.ts"],"sourcesContent":["import type { Block, Field } from 'payload'\n\nimport type { FieldConfig, PaymentFieldConfig } from '../../types.js'\n\nconst name: Field = {\n name: 'name',\n type: 'text',\n label: 'Name (lowercase, no special characters)',\n required: true,\n}\n\nconst label: Field = {\n name: 'label',\n type: 'text',\n label: 'Label',\n localized: true,\n}\n\nconst required: Field = {\n name: 'required',\n type: 'checkbox',\n label: 'Required',\n}\n\nconst width: Field = {\n name: 'width',\n type: 'number',\n label: 'Field Width (percentage)',\n}\n\nconst placeholder: Field = {\n name: 'placeholder',\n type: 'text',\n label: 'Placeholder',\n}\n\nconst Radio: Block = {\n slug: 'radio',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Radio Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Radio Fields',\n singular: 'Radio',\n },\n}\n\nconst Select: Block = {\n slug: 'select',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...placeholder,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Select Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Select Fields',\n singular: 'Select',\n },\n}\n\nconst Text: Block = {\n slug: 'text',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Fields',\n singular: 'Text',\n },\n}\n\nconst TextArea: Block = {\n slug: 'textarea',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Area Fields',\n singular: 'Text Area',\n },\n}\n\nconst Number: Block = {\n slug: 'number',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Number Fields',\n singular: 'Number',\n },\n}\n\nconst Email: Block = {\n slug: 'email',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Email Fields',\n singular: 'Email',\n },\n}\n\nconst State: Block = {\n slug: 'state',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'State Fields',\n singular: 'State',\n },\n}\n\nconst Country: Block = {\n slug: 'country',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Country Fields',\n singular: 'Country',\n },\n}\n\nconst Checkbox: Block = {\n slug: 'checkbox',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'checkbox',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Checkbox Fields',\n singular: 'Checkbox',\n },\n}\n\nconst Date: Block = {\n slug: 'date',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'date',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Date Fields',\n singular: 'Date',\n },\n}\n\nconst Payment = (fieldConfig: PaymentFieldConfig): Block => {\n let paymentProcessorField = null\n if (fieldConfig?.paymentProcessor) {\n paymentProcessorField = {\n name: 'paymentProcessor',\n type: 'select',\n label: 'Payment Processor',\n options: [],\n ...fieldConfig.paymentProcessor,\n }\n }\n\n const fields = {\n slug: 'payment',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'basePrice',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Base Price',\n },\n ],\n },\n paymentProcessorField,\n {\n name: 'priceConditions',\n type: 'array',\n fields: [\n {\n name: 'fieldToUse',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-form-builder/client#DynamicFieldSelector',\n },\n },\n },\n {\n name: 'condition',\n type: 'select',\n defaultValue: 'hasValue',\n label: 'Condition',\n options: [\n {\n label: 'Has Any Value',\n value: 'hasValue',\n },\n {\n label: 'Equals',\n value: 'equals',\n },\n {\n label: 'Does Not Equal',\n value: 'notEquals',\n },\n ],\n },\n {\n name: 'valueForCondition',\n type: 'text',\n admin: {\n condition: (_: any, { condition }: any) =>\n condition === 'equals' || condition === 'notEquals',\n },\n label: 'Value',\n },\n {\n name: 'operator',\n type: 'select',\n defaultValue: 'add',\n options: [\n {\n label: 'Add',\n value: 'add',\n },\n {\n label: 'Subtract',\n value: 'subtract',\n },\n {\n label: 'Multiply',\n value: 'multiply',\n },\n {\n label: 'Divide',\n value: 'divide',\n },\n ],\n },\n {\n name: 'valueType',\n type: 'radio',\n admin: {\n width: '100%',\n },\n defaultValue: 'static',\n label: 'Value Type',\n options: [\n {\n label: 'Static Value',\n value: 'static',\n },\n {\n label: 'Value Of Field',\n value: 'valueOfField',\n },\n ],\n },\n {\n name: 'valueForOperator',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-form-builder/client#DynamicPriceSelector',\n },\n },\n label: 'Value',\n },\n ],\n label: 'Price Conditions',\n labels: {\n plural: 'Price Conditions',\n singular: 'Price Condition',\n },\n },\n required,\n ].filter(Boolean) as Field[],\n labels: {\n plural: 'Payment Fields',\n singular: 'Payment',\n },\n }\n\n return fields\n}\n\nconst Message: Block = {\n slug: 'message',\n fields: [\n {\n name: 'message',\n type: 'richText',\n localized: true,\n },\n ],\n labels: {\n plural: 'Message Blocks',\n singular: 'Message',\n },\n}\n\nexport const fields = {\n checkbox: Checkbox,\n country: Country,\n date: Date,\n email: Email,\n message: Message,\n number: Number,\n payment: Payment,\n radio: Radio,\n select: Select,\n state: State,\n text: Text,\n textarea: TextArea,\n} as {\n [key: string]: ((fieldConfig?: boolean | FieldConfig) => Block) | Block\n}\n"],"names":["name","type","label","required","localized","width","placeholder","Radio","slug","fields","admin","labels","plural","singular","Select","Text","TextArea","Number","Email","State","Country","Checkbox","Date","Payment","fieldConfig","paymentProcessorField","paymentProcessor","options","components","Field","defaultValue","value","condition","_","filter","Boolean","Message","checkbox","country","date","email","message","number","payment","radio","select","state","text","textarea"],"mappings":"AAIA,MAAMA,OAAc;IAClBA,MAAM;IACNC,MAAM;IACNC,OAAO;IACPC,UAAU;AACZ;AAEA,MAAMD,QAAe;IACnBF,MAAM;IACNC,MAAM;IACNC,OAAO;IACPE,WAAW;AACb;AAEA,MAAMD,WAAkB;IACtBH,MAAM;IACNC,MAAM;IACNC,OAAO;AACT;AAEA,MAAMG,QAAe;IACnBL,MAAM;IACNC,MAAM;IACNC,OAAO;AACT;AAEA,MAAMI,cAAqB;IACzBN,MAAM;IACNC,MAAM;IACNC,OAAO;AACT;AAEA,MAAMK,QAAe;IACnBC,MAAM;IACNC,QAAQ;QACN;YACER,MAAM;YACNQ,QAAQ;gBACN;oBACE,GAAGT,IAAI;oBACPU,OAAO;w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E7B,OAAO;gCACP6B,OAAO;4BACT;4BACA;gCACE7B,OAAO;gCACP6B,OAAO;4BACT;yBACD;oBACH;oBACA;wBACE/B,MAAM;wBACNC,MAAM;wBACNS,OAAO;4BACLL,OAAO;wBACT;wBACAyB,cAAc;wBACd5B,OAAO;wBACPyB,SAAS;4BACP;gCACEzB,OAAO;gCACP6B,OAAO;4BACT;4BACA;gCACE7B,OAAO;gCACP6B,OAAO;4BACT;yBACD;oBACH;oBACA;wBACE/B,MAAM;wBACNC,MAAM;wBACNS,OAAO;4BACLkB,YAAY;gCACVC,OAAO;4BACT;wBACF;wBACA3B,OAAO;oBACT;iBACD;gBACDA,OAAO;gBACPS,QAAQ;oBACNC,QAAQ;oBACRC,UAAU;gBACZ;YACF;YACAV;SACD,CAAC+B,MAAM,CAACC;QACTxB,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF;IAEA,OAAOJ;AACT;AAEA,MAAM2B,UAAiB;IACrB5B,MAAM;IACNC,QAAQ;QACN;YACET,MAAM;YACNC,MAAM;YACNG,WAAW;QACb;KACD;IACDO,QAAQ;QACNC,QAAQ;QACRC,UAAU;IACZ;AACF;AAEA,OAAO,MAAMJ,SAAS;IACpB4B,UAAUhB;IACViB,SAASlB;IACTmB,MAAMjB;IACNkB,OAAOtB;IACPuB,SAASL;IACTM,QAAQzB;IACR0B,SAASpB;IACTqB,OAAOrC;IACPsC,QAAQ/B;IACRgC,OAAO3B;IACP4B,MAAMhC;IACNiC,UAAUhC;AACZ,EAEC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/Forms/fields.ts"],"sourcesContent":["import type { Block, Field } from 'payload'\n\nimport type { FieldConfig, PaymentFieldConfig } from '../../types.js'\n\nconst name: Field = {\n name: 'name',\n type: 'text',\n label: 'Name (lowercase, no special characters)',\n required: true,\n}\n\nconst label: Field = {\n name: 'label',\n type: 'text',\n label: 'Label',\n localized: true,\n}\n\nconst required: Field = {\n name: 'required',\n type: 'checkbox',\n label: 'Required',\n}\n\nconst width: Field = {\n name: 'width',\n type: 'number',\n label: 'Field Width (percentage)',\n}\n\nconst placeholder: Field = {\n name: 'placeholder',\n type: 'text',\n label: 'Placeholder',\n}\n\nconst Radio: Block = {\n slug: 'radio',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Radio Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Radio Fields',\n singular: 'Radio',\n },\n}\n\nconst Select: Block = {\n slug: 'select',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...placeholder,\n },\n ],\n },\n {\n name: 'options',\n type: 'array',\n fields: [\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Label',\n localized: true,\n required: true,\n },\n {\n name: 'value',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Value',\n required: true,\n },\n ],\n },\n ],\n label: 'Select Attribute Options',\n labels: {\n plural: 'Options',\n singular: 'Option',\n },\n },\n required,\n ],\n labels: {\n plural: 'Select Fields',\n singular: 'Select',\n },\n}\n\nconst Text: Block = {\n slug: 'text',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Fields',\n singular: 'Text',\n },\n}\n\nconst TextArea: Block = {\n slug: 'textarea',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'text',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n localized: true,\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Text Area Fields',\n singular: 'Text Area',\n },\n}\n\nconst Number: Block = {\n slug: 'number',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'defaultValue',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Default Value',\n },\n ],\n },\n required,\n ],\n labels: {\n plural: 'Number Fields',\n singular: 'Number',\n },\n}\n\nconst Email: Block = {\n slug: 'email',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Email Fields',\n singular: 'Email',\n },\n}\n\nconst State: Block = {\n slug: 'state',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'State Fields',\n singular: 'State',\n },\n}\n\nconst Country: Block = {\n slug: 'country',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n width,\n required,\n ],\n labels: {\n plural: 'Country Fields',\n singular: 'Country',\n },\n}\n\nconst Checkbox: Block = {\n slug: 'checkbox',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'checkbox',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Checkbox Fields',\n singular: 'Checkbox',\n },\n}\n\nconst Date: Block = {\n slug: 'date',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'defaultValue',\n type: 'date',\n label: 'Default Value',\n },\n ],\n labels: {\n plural: 'Date Fields',\n singular: 'Date',\n },\n}\n\nconst Payment = (fieldConfig: PaymentFieldConfig): Block => {\n let paymentProcessorField = null\n if (fieldConfig?.paymentProcessor) {\n paymentProcessorField = {\n name: 'paymentProcessor',\n type: 'select',\n label: 'Payment Processor',\n options: [],\n ...fieldConfig.paymentProcessor,\n }\n }\n\n const fields = {\n slug: 'payment',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'basePrice',\n type: 'number',\n admin: {\n width: '50%',\n },\n label: 'Base Price',\n },\n ],\n },\n paymentProcessorField,\n {\n name: 'priceConditions',\n type: 'array',\n fields: [\n {\n name: 'fieldToUse',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-form-builder/client#DynamicFieldSelector',\n },\n },\n },\n {\n name: 'condition',\n type: 'select',\n defaultValue: 'hasValue',\n label: 'Condition',\n options: [\n {\n label: 'Has Any Value',\n value: 'hasValue',\n },\n {\n label: 'Equals',\n value: 'equals',\n },\n {\n label: 'Does Not Equal',\n value: 'notEquals',\n },\n ],\n },\n {\n name: 'valueForCondition',\n type: 'text',\n admin: {\n condition: (_: any, { condition }: any) =>\n condition === 'equals' || condition === 'notEquals',\n },\n label: 'Value',\n },\n {\n name: 'operator',\n type: 'select',\n defaultValue: 'add',\n options: [\n {\n label: 'Add',\n value: 'add',\n },\n {\n label: 'Subtract',\n value: 'subtract',\n },\n {\n label: 'Multiply',\n value: 'multiply',\n },\n {\n label: 'Divide',\n value: 'divide',\n },\n ],\n },\n {\n name: 'valueType',\n type: 'radio',\n admin: {\n width: '100%',\n },\n defaultValue: 'static',\n label: 'Value Type',\n options: [\n {\n label: 'Static Value',\n value: 'static',\n },\n {\n label: 'Value Of Field',\n value: 'valueOfField',\n },\n ],\n },\n {\n name: 'valueForOperator',\n type: 'text',\n admin: {\n components: {\n Field: '@payloadcms/plugin-form-builder/client#DynamicPriceSelector',\n },\n },\n label: 'Value',\n },\n ],\n label: 'Price Conditions',\n labels: {\n plural: 'Price Conditions',\n singular: 'Price Condition',\n },\n },\n required,\n ].filter(Boolean) as Field[],\n labels: {\n plural: 'Payment Fields',\n singular: 'Payment',\n },\n }\n\n return fields\n}\n\nconst Message: Block = {\n slug: 'message',\n fields: [\n {\n name: 'message',\n type: 'richText',\n localized: true,\n },\n ],\n labels: {\n plural: 'Message Blocks',\n singular: 'Message',\n },\n}\n\nconst Upload = (uploadCollections: string[]): Block => {\n return {\n slug: 'upload',\n fields: [\n {\n type: 'row',\n fields: [\n {\n ...name,\n admin: {\n width: '50%',\n },\n },\n {\n ...label,\n admin: {\n width: '50%',\n },\n },\n ],\n },\n {\n name: 'uploadCollection',\n type: 'select',\n admin: {\n description: 'Select which upload collection to store files in',\n },\n label: 'Upload Collection',\n options: uploadCollections.map((slug) => ({\n label: slug,\n value: slug,\n })),\n required: true,\n },\n {\n name: 'mimeTypes',\n type: 'array',\n admin: {\n description:\n 'Restrict allowed file types (e.g., image/*, application/pdf). Leave empty to allow all types.',\n },\n fields: [\n {\n name: 'mimeType',\n type: 'text',\n label: 'MIME Type',\n required: true,\n },\n ],\n label: 'Allowed File Types',\n labels: {\n plural: 'MIME Types',\n singular: 'MIME Type',\n },\n },\n {\n type: 'row',\n fields: [\n {\n ...width,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'maxFileSize',\n type: 'number',\n admin: {\n description: 'Maximum file size in bytes. Leave empty for no limit.',\n width: '50%',\n },\n label: 'Max File Size (bytes)',\n },\n ],\n },\n {\n type: 'row',\n fields: [\n {\n ...required,\n admin: {\n width: '50%',\n },\n },\n {\n name: 'multiple',\n type: 'checkbox',\n admin: {\n width: '50%',\n },\n label: 'Allow Multiple Files',\n },\n ],\n },\n ],\n labels: {\n plural: 'Upload Fields',\n singular: 'Upload',\n },\n }\n}\n\nexport const fields: {\n [key: string]: ((arg?: any) => Block) | Block\n} = {\n checkbox: Checkbox,\n country: Country,\n date: Date,\n email: Email,\n message: Message,\n number: Number,\n payment: Payment,\n radio: Radio,\n select: Select,\n state: State,\n text: Text,\n textarea: TextArea,\n upload: Upload,\n}\n"],"names":["name","type","label","required","localized","width","placeholder","Radio","slug","fields","admin","labels","plural","singular","Select","Text","TextArea","Number","Email","State","Country","Checkbox","Date","Payment","fieldConfig","paymentProcessorField","paymentProcessor","options","components","Field","defaultValue","value","condition","_","filter","Boolean","Message","Upload","uploadCollections","description","map","checkbox","country","date","email","message","number","payment","radio","select","state","text","textarea","upload"],"mappings":"AAIA,MAAMA,OAAc;IAClBA,MAAM;IACNC,MAAM;IACNC,OAAO;IACPC,UAAU;AACZ;AAEA,MAAMD,QAAe;IACnBF,MAAM;IACNC,MAAM;IACNC,OAAO;IACPE,WAAW;AACb;AAEA,MAAMD,WAAkB;IACtBH,MAAM;IACNC,MAAM;IACNC,OAAO;AACT;AAEA,MAAMG,QAAe;IACnBL,MAAM;IACNC,MAAM;IACNC,OAAO;AACT;AAEA,MAAMI,cAAqB;IACzBN,MAAM;IACNC,MAAM;IACNC,OAAO;AACT;AAEA,MAAMK,QAAe;IACnBC,MAAM;IACNC,QAAQ;QACN;YACER,MAAM;YACNQ,QAAQ;gBACN;oBACE,GAAGT,IAAI;oBACPU,OAAO;wBACLL,OAAO;oBACT;gBACF;gBACA;oBACE,GAAGH,KAAK;oBACRQ,OAAO;wBACLL,OAAO;oBACT;gBACF;aACD;QACH;QACA;YACEJ,MAAM;YACNQ,QAAQ;gBACN;oBACE,GAAGJ,KAAK;oBACRK,OAAO;wBACLL,OAAO;oBACT;gBACF;gBACA;oBACEL,MAAM;oBACNC,MAAM;oBACNS,OAAO;wBACLL,OAAO;oBACT;oBACAH,OAAO;oBACPE,WAAW;gBACb;aACD;QACH;QACA;YACEJ,MAAM;YACNC,MAAM;YACNQ,QAAQ;gBACN;oBACER,MAAM;oBACNQ,QAAQ;wBACN;4BACET,MAAM;4BACNC,MAAM;4BACNS,OAAO;gCACLL,OAAO;4BACT;4BACAH,OAAO;4BACPE,WAAW;4BACXD,UAAU;wBACZ;wBACA;4BACEH,MAAM;4BACNC,MAAM;4BACNS,OAAO;gCACLL,OAAO;4BACT;4BACAH,OAAO;4BACPC,UAAU;wBACZ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ACF;AACF;AAEA,OAAO,MAAMJ,SAET;IACFgC,UAAUpB;IACVqB,SAAStB;IACTuB,MAAMrB;IACNsB,OAAO1B;IACP2B,SAAST;IACTU,QAAQ7B;IACR8B,SAASxB;IACTyB,OAAOzC;IACP0C,QAAQnC;IACRoC,OAAO/B;IACPgC,MAAMpC;IACNqC,UAAUpC;IACVqC,QAAQhB;AACV,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collections/Forms/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAS,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAK7D,eAAO,MAAM,sBAAsB,eAAgB,uBAAuB,KAAG,
|
|
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,gBAgP5E,CAAA"}
|
|
@@ -75,6 +75,10 @@ export const generateFormCollection = (formConfig)=>{
|
|
|
75
75
|
return deepMergeWithSourceArrays(block, fieldConfig);
|
|
76
76
|
}
|
|
77
77
|
if (typeof block === 'function') {
|
|
78
|
+
// Special handling for upload field - pass uploadCollections from top-level config
|
|
79
|
+
if (fieldKey === 'upload') {
|
|
80
|
+
return block(formConfig.uploadCollections || []);
|
|
81
|
+
}
|
|
78
82
|
return block(fieldConfig);
|
|
79
83
|
}
|
|
80
84
|
return block;
|
|
@@ -1 +1 @@
|
|
|
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,MAAM;YACNC,OAAO;gBACLC,WAAW,CAACC,GAAGC,cAAgBA,aAAaJ,SAAS;YACvD;YACAO,OAAO;YACPI,UAAU;YACVC,YAAYf,WAAWY,qBAAqB;YAC5CD,UAAU;QACZ;QAEAV,SAASH,MAAM,CAACe,OAAO,CAAC;YACtBX,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLY,QAAQ;YACV;YACAC,cAAc;YACdC,SAAS;gBACP;oBACER,OAAO;oBACPS,OAAO;gBACT;gBACA;oBACET,OAAO;oBACPS,OAAO;gBACT;aACD;QACH;QAEA,I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YAAY0C,eAAe5C,UAAU,OAAOE,YAAY0C,eAAe5C,WAAW,aAC9EE,WAAW0C,aAAa,CAAC5C,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOqB;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 // Special handling for upload field - pass uploadCollections from top-level config\n if (fieldKey === 'upload') {\n return block(formConfig.uploadCollections || [])\n }\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","uploadCollections","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,MAAM;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;YACT,GACCG,MAAM,CAACC;QACZ;QACA;YACE7B,MAAM;YACNC,MAAM;YACN6B,WAAW;QACb;QACA;YACE9B,MAAM;YACNC,MAAM;YACNC,OAAO;gBACL6B,aACE;gBACFjB,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;YACAwB,WAAW;YACXrB,UAAU;QACZ;QACAV;QACA;YACEC,MAAM;YACNC,MAAM;YACN+B,QAAQ;gBACNC,MAAM,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAK,CAAC,CAACA;YACjC;YACAjC,OAAO;gBACL6B,aACE;YACJ;YACAnC,QAAQ;gBACN;oBACEK,MAAM;oBACNL,QAAQ;wBACN;4BACEI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLkC,aAAa;gCACbC,OAAO;4BACT;4BACA7B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLoC,OAAO;oCACLC,UAAU;gCACZ;4BACF;4BACA/B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLoC,OAAO;oCACLC,UAAU;gCACZ;4BACF;4BACA/B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACEP,MAAM;oBACNL,QAAQ;wBACN;4BACEI,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLkC,aAAa;gCACbC,OAAO;4BACT;4BACA7B,OAAO;wBACT;wBACA;4BACER,MAAM;4BACNC,MAAM;4BACNC,OAAO;gCACLkC,aAAa;gCACbC,OAAO;4BACT;4BACA7B,OAAO;wBACT;qBACD;gBACH;gBACA;oBACER,MAAM;oBACNC,MAAM;oBACNc,cAAc;oBACdP,OAAO;oBACPsB,WAAW;oBACXrB,UAAU;gBACZ;gBACA;oBACET,MAAM;oBACNC,MAAM;oBACNC,OAAO;wBACL6B,aAAa;oBACf;oBACAvB,OAAO;oBACPsB,WAAW;gBACb;aACD;QACH;KACD;IAED,MAAMU,SAA2B;QAC/B,GAAI1C,YAAY2C,iBAAiB,CAAC,CAAC;QACnCC,MAAM5C,YAAY2C,eAAeC,QAAQ;QACzCV,QAAQ;YACNC,MAAM,IAAM;YACZ,GAAInC,YAAY2C,eAAeT,UAAU,CAAC,CAAC;QAC7C;QACA9B,OAAO;YACLyC,4BAA4B;YAC5BC,YAAY;YACZ,GAAI9C,YAAY2C,eAAevC,SAAS,CAAC,CAAC;QAC5C;QACAN,QACEE,YAAY2C,eAAe7C,UAAU,OAAOE,YAAY2C,eAAe7C,WAAW,aAC9EE,WAAW2C,aAAa,CAAC7C,MAAM,CAAC;YAAEsB;QAAc,KAChDA;IACR;IAEA,OAAOsB;AACT,EAAC"}
|
package/dist/exports/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { BeforeEmail, BlockConfig, CheckboxField, CountryField, DateField, Email, EmailField, FieldConfig, FieldsConfig, FieldValues, Form, FormattedEmail, FormBuilderPluginConfig as PluginConfig, FormFieldBlock, FormSubmission, HandlePayment, isValidBlockConfig, MessageField, PaymentField, PaymentFieldConfig, PriceCondition, RadioField, Redirect, SelectField, SelectFieldOption, StateField, SubmissionValue, TextAreaField, TextField, } from '../types.js';
|
|
1
|
+
export type { BeforeEmail, BlockConfig, CheckboxField, CountryField, DateField, Email, EmailField, FieldConfig, FieldsConfig, FieldValues, Form, FormattedEmail, FormBuilderPluginConfig as PluginConfig, FormFieldBlock, FormSubmission, HandlePayment, isValidBlockConfig, MessageField, PaymentField, PaymentFieldConfig, PriceCondition, RadioField, Redirect, SelectField, SelectFieldOption, StateField, SubmissionValue, TextAreaField, TextField, UploadField, UploadFieldMimeType, } 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,SAAS,EACT,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,UAAU,EACV,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,aAAa,EACb,SAAS,
|
|
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,SAAS,EACT,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,UAAU,EACV,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,aAAa,EACb,SAAS,EACT,WAAW,EACX,mBAAmB,GACpB,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 DateField,\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 RadioField,\n Redirect,\n SelectField,\n SelectFieldOption,\n StateField,\n SubmissionValue,\n TextAreaField,\n TextField,\n} from '../types.js'\n"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type {\n BeforeEmail,\n BlockConfig,\n CheckboxField,\n CountryField,\n DateField,\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 RadioField,\n Redirect,\n SelectField,\n SelectFieldOption,\n StateField,\n SubmissionValue,\n TextAreaField,\n TextField,\n UploadField,\n UploadFieldMimeType,\n} from '../types.js'\n"],"names":[],"mappings":"AAAA,WAgCoB"}
|
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,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,
|
|
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,MA2BjB,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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 upload: false,\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","upload","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;gBACVC,QAAQ;gBACR,GAAGb,mBAAmBH,MAAM;YAC9B;QACF;QAEA,OAAO;YACL,GAAGI,MAAM;YACTa,aAAa;mBACPb,QAAQa,eAAe,EAAE;gBAC7BnB,uBAAuBO;gBACvBN,6BAA6BM;aAC9B;QACH;IACF,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Block, CollectionBeforeChangeHook, CollectionConfig, Field, TypeWithID } from 'payload';
|
|
1
|
+
import type { Block, CollectionBeforeChangeHook, CollectionConfig, Field, TypeWithID, UploadCollectionSlug } from 'payload';
|
|
2
2
|
export interface BlockConfig {
|
|
3
3
|
block: Block;
|
|
4
4
|
validate?: (value: unknown) => boolean | string;
|
|
@@ -11,6 +11,7 @@ export type PaymentFieldConfig = {
|
|
|
11
11
|
paymentProcessor: Partial<SelectField>;
|
|
12
12
|
} & Partial<Field>;
|
|
13
13
|
export type FieldConfig = Partial<Field> | PaymentFieldConfig;
|
|
14
|
+
export type UploadFieldConfig = Partial<Field>;
|
|
14
15
|
export interface FieldsConfig {
|
|
15
16
|
[key: string]: boolean | FieldConfig | undefined;
|
|
16
17
|
checkbox?: boolean | FieldConfig;
|
|
@@ -24,6 +25,7 @@ export interface FieldsConfig {
|
|
|
24
25
|
state?: boolean | FieldConfig;
|
|
25
26
|
text?: boolean | FieldConfig;
|
|
26
27
|
textarea?: boolean | FieldConfig;
|
|
28
|
+
upload?: boolean | FieldConfig;
|
|
27
29
|
}
|
|
28
30
|
type BeforeChangeParams<T extends TypeWithID = any> = Parameters<CollectionBeforeChangeHook<T>>[0];
|
|
29
31
|
export type BeforeEmail<T extends TypeWithID = any> = (emails: FormattedEmail[], beforeChangeParams: BeforeChangeParams<T>) => FormattedEmail[] | Promise<FormattedEmail[]>;
|
|
@@ -47,6 +49,11 @@ export type FormBuilderPluginConfig = {
|
|
|
47
49
|
} & Partial<Omit<CollectionConfig, 'fields'>>;
|
|
48
50
|
handlePayment?: HandlePayment;
|
|
49
51
|
redirectRelationships?: string[];
|
|
52
|
+
/**
|
|
53
|
+
* Upload-enabled collection slugs available for upload fields.
|
|
54
|
+
* Required when using upload fields.
|
|
55
|
+
*/
|
|
56
|
+
uploadCollections?: UploadCollectionSlug[];
|
|
50
57
|
};
|
|
51
58
|
export interface TextField {
|
|
52
59
|
blockName?: string;
|
|
@@ -162,7 +169,26 @@ export interface MessageField {
|
|
|
162
169
|
blockType: 'message';
|
|
163
170
|
message: object;
|
|
164
171
|
}
|
|
165
|
-
export
|
|
172
|
+
export interface UploadFieldMimeType {
|
|
173
|
+
mimeType: string;
|
|
174
|
+
}
|
|
175
|
+
export interface UploadField {
|
|
176
|
+
blockName?: string;
|
|
177
|
+
blockType: 'upload';
|
|
178
|
+
label?: string;
|
|
179
|
+
/** Maximum file size in bytes */
|
|
180
|
+
maxFileSize?: number;
|
|
181
|
+
/** Array of allowed MIME types (e.g., image/*, application/pdf) */
|
|
182
|
+
mimeTypes?: UploadFieldMimeType[];
|
|
183
|
+
/** Whether to allow multiple file uploads */
|
|
184
|
+
multiple?: boolean;
|
|
185
|
+
name: string;
|
|
186
|
+
required?: boolean;
|
|
187
|
+
/** The upload collection slug to store files in */
|
|
188
|
+
uploadCollection: string;
|
|
189
|
+
width?: number;
|
|
190
|
+
}
|
|
191
|
+
export type FormFieldBlock = CheckboxField | CountryField | DateField | EmailField | MessageField | PaymentField | RadioField | SelectField | StateField | TextAreaField | TextField | UploadField;
|
|
166
192
|
export interface Email {
|
|
167
193
|
bcc?: string;
|
|
168
194
|
cc?: string;
|
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,EACV,KAAK,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,CAAC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AE,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 {\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 date?: 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 placeholder?: string\n required?: boolean\n width?: number\n}\n\nexport interface RadioField {\n blockName?: string\n blockType: 'radio'\n defaultValue?: string\n label?: string\n name: string\n options: SelectFieldOption[]\n placeholder?: string\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 DateField {\n blockName?: string\n blockType: 'date'\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: object\n}\n\nexport type FormFieldBlock =\n | CheckboxField\n | CountryField\n | DateField\n | EmailField\n | MessageField\n | PaymentField\n | RadioField\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":"
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n Block,\n CollectionBeforeChangeHook,\n CollectionConfig,\n Field,\n TypeWithID,\n UploadCollectionSlug,\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 type UploadFieldConfig = Partial<Field>\n\nexport interface FieldsConfig {\n [key: string]: boolean | FieldConfig | undefined\n checkbox?: boolean | FieldConfig\n country?: boolean | FieldConfig\n date?: 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 upload?: 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 * Upload-enabled collection slugs available for upload fields.\n * Required when using upload fields.\n */\n uploadCollections?: UploadCollectionSlug[]\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 placeholder?: string\n required?: boolean\n width?: number\n}\n\nexport interface RadioField {\n blockName?: string\n blockType: 'radio'\n defaultValue?: string\n label?: string\n name: string\n options: SelectFieldOption[]\n placeholder?: string\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 DateField {\n blockName?: string\n blockType: 'date'\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: object\n}\n\nexport interface UploadFieldMimeType {\n mimeType: string\n}\n\nexport interface UploadField {\n blockName?: string\n blockType: 'upload'\n label?: string\n /** Maximum file size in bytes */\n maxFileSize?: number\n /** Array of allowed MIME types (e.g., image/*, application/pdf) */\n mimeTypes?: UploadFieldMimeType[]\n /** Whether to allow multiple file uploads */\n multiple?: boolean\n name: string\n required?: boolean\n /** The upload collection slug to store files in */\n uploadCollection: string\n width?: number\n}\n\nexport type FormFieldBlock =\n | CheckboxField\n | CountryField\n | DateField\n | EmailField\n | MessageField\n | PaymentField\n | RadioField\n | SelectField\n | StateField\n | TextAreaField\n | TextField\n | UploadField\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":"AAcA,OAAO,SAASA,mBAAmBC,WAAiC;IAClE,OACE,OAAOA,gBAAgB,YACvB,OAAOA,aAAaC,OAAOC,SAAS,YACpCC,MAAMC,OAAO,CAACJ,aAAaC,OAAOI;AAEtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-form-builder",
|
|
3
|
-
"version": "3.73.0-
|
|
3
|
+
"version": "3.73.0-internal.783bc97",
|
|
4
4
|
"description": "Form builder plugin for Payload CMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"escape-html": "^1.0.3",
|
|
56
|
-
"@payloadcms/ui": "3.73.0-
|
|
56
|
+
"@payloadcms/ui": "3.73.0-internal.783bc97"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/escape-html": "^1.0.4",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"@types/react-dom": "19.2.1",
|
|
62
62
|
"copyfiles": "^2.4.1",
|
|
63
63
|
"cross-env": "^7.0.3",
|
|
64
|
-
"payload": "3.73.0-
|
|
64
|
+
"payload": "3.73.0-internal.783bc97",
|
|
65
65
|
"@payloadcms/eslint-config": "3.28.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
69
69
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
70
|
-
"payload": "3.73.0-
|
|
70
|
+
"payload": "3.73.0-internal.783bc97"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"registry": "https://registry.npmjs.org/"
|