@10x-media/form-builder 0.1.0-beta.3 → 0.1.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (406) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +4 -4
  3. package/dist/actions/body/serializeBody.d.ts +22 -4
  4. package/dist/actions/body/serializeBody.js +3 -1
  5. package/dist/actions/body/serializeBody.js.map +1 -1
  6. package/dist/actions/body/textOfBody.d.ts +13 -0
  7. package/dist/actions/body/textOfBody.js +35 -0
  8. package/dist/actions/body/textOfBody.js.map +1 -0
  9. package/dist/actions/builtin/confirmation.js +51 -12
  10. package/dist/actions/builtin/confirmation.js.map +1 -1
  11. package/dist/actions/builtin/emailTeam.js +82 -34
  12. package/dist/actions/builtin/emailTeam.js.map +1 -1
  13. package/dist/actions/builtin/index.d.ts +18 -1
  14. package/dist/actions/builtin/index.js +21 -7
  15. package/dist/actions/builtin/index.js.map +1 -1
  16. package/dist/actions/builtin/signedWebhook.js +2 -16
  17. package/dist/actions/builtin/signedWebhook.js.map +1 -1
  18. package/dist/actions/defineAction.d.ts +1 -1
  19. package/dist/actions/fromAddresses.d.ts +21 -0
  20. package/dist/actions/fromAddresses.js +74 -0
  21. package/dist/actions/fromAddresses.js.map +1 -0
  22. package/dist/actions/runActions.js +2 -0
  23. package/dist/actions/runActions.js.map +1 -1
  24. package/dist/actions/task.js +9 -8
  25. package/dist/actions/task.js.map +1 -1
  26. package/dist/aggregation/aggregateResponses.d.ts +9 -0
  27. package/dist/aggregation/aggregateResponses.js +8 -14
  28. package/dist/aggregation/aggregateResponses.js.map +1 -1
  29. package/dist/aggregation/resolveResultsRequest.d.ts +35 -6
  30. package/dist/aggregation/resolveResultsRequest.js +68 -11
  31. package/dist/aggregation/resolveResultsRequest.js.map +1 -1
  32. package/dist/calc/computeCalcFields.js +2 -1
  33. package/dist/calc/computeCalcFields.js.map +1 -1
  34. package/dist/client/ByteSizeField.d.ts +8 -0
  35. package/dist/client/ByteSizeField.js +3 -1
  36. package/dist/client/ByteSizeField.js.map +1 -1
  37. package/dist/client/ClosePollButton.d.ts +15 -0
  38. package/dist/client/ClosePollButton.js +80 -0
  39. package/dist/client/ClosePollButton.js.map +1 -0
  40. package/dist/client/CondensedArray.d.ts +15 -0
  41. package/dist/client/CondensedArray.js +97 -0
  42. package/dist/client/CondensedArray.js.map +1 -0
  43. package/dist/client/EndpointOptionsSelect.d.ts +45 -0
  44. package/dist/client/EndpointOptionsSelect.js +103 -0
  45. package/dist/client/EndpointOptionsSelect.js.map +1 -0
  46. package/dist/client/FieldBlockLabel.d.ts +18 -0
  47. package/dist/client/FieldBlockLabel.js +34 -0
  48. package/dist/client/FieldBlockLabel.js.map +1 -0
  49. package/dist/client/FieldNameSelect.d.ts +20 -4
  50. package/dist/client/FieldNameSelect.js +25 -14
  51. package/dist/client/FieldNameSelect.js.map +1 -1
  52. package/dist/client/FlowBuilder.d.ts +2 -1
  53. package/dist/client/FlowBuilder.js +134 -83
  54. package/dist/client/FlowBuilder.js.map +1 -1
  55. package/dist/client/RuleDescription.d.ts +21 -0
  56. package/dist/client/RuleDescription.js +19 -0
  57. package/dist/client/RuleDescription.js.map +1 -0
  58. package/dist/client/admin.css +83 -5
  59. package/dist/client/endpointOptions.js +29 -0
  60. package/dist/client/endpointOptions.js.map +1 -0
  61. package/dist/client/flowAuthoring.js +142 -0
  62. package/dist/client/flowAuthoring.js.map +1 -0
  63. package/dist/client/synthesizeClientField.js +21 -10
  64. package/dist/client/synthesizeClientField.js.map +1 -1
  65. package/dist/collections/buttonFields.d.ts +34 -0
  66. package/dist/collections/buttonFields.js +35 -0
  67. package/dist/collections/buttonFields.js.map +1 -0
  68. package/dist/collections/cells/FieldCountCell.d.ts +15 -0
  69. package/dist/collections/cells/FieldCountCell.js +18 -0
  70. package/dist/collections/cells/FieldCountCell.js.map +1 -0
  71. package/dist/collections/cells/FlowStepsCell.d.ts +14 -0
  72. package/dist/collections/cells/FlowStepsCell.js +17 -0
  73. package/dist/collections/cells/FlowStepsCell.js.map +1 -0
  74. package/dist/collections/formSubmissions.js +55 -12
  75. package/dist/collections/formSubmissions.js.map +1 -1
  76. package/dist/collections/forms.js +376 -57
  77. package/dist/collections/forms.js.map +1 -1
  78. package/dist/collections/redirectFields.d.ts +29 -0
  79. package/dist/conditions/conditionType.js +9 -2
  80. package/dist/conditions/conditionType.js.map +1 -1
  81. package/dist/conditions/normalizeConditions.js +2 -1
  82. package/dist/conditions/normalizeConditions.js.map +1 -1
  83. package/dist/consent/applyConsentStatements.d.ts +14 -0
  84. package/dist/consent/applyConsentStatements.js +17 -0
  85. package/dist/consent/applyConsentStatements.js.map +1 -0
  86. package/dist/consent/captureConsent.d.ts +19 -8
  87. package/dist/consent/captureConsent.js +34 -11
  88. package/dist/consent/captureConsent.js.map +1 -1
  89. package/dist/consent/consentSourcesField.d.ts +58 -0
  90. package/dist/consent/consentSourcesField.js +79 -0
  91. package/dist/consent/consentSourcesField.js.map +1 -0
  92. package/dist/consent/resolveConsentEntries.d.ts +24 -0
  93. package/dist/consent/resolveConsentEntries.js +43 -0
  94. package/dist/consent/resolveConsentEntries.js.map +1 -0
  95. package/dist/consent/resolveConsentSourcesRequest.d.ts +37 -0
  96. package/dist/consent/resolveConsentSourcesRequest.js +55 -0
  97. package/dist/consent/resolveConsentSourcesRequest.js.map +1 -0
  98. package/dist/consent/resolveConsentStatements.d.ts +45 -0
  99. package/dist/consent/resolveConsentStatements.js +44 -0
  100. package/dist/consent/resolveConsentStatements.js.map +1 -0
  101. package/dist/consent/resolvePublishedVersionRef.d.ts +17 -11
  102. package/dist/consent/resolvePublishedVersionRef.js +13 -10
  103. package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
  104. package/dist/consent/types.d.ts +49 -0
  105. package/dist/email/departments.d.ts +55 -0
  106. package/dist/email/departments.js +130 -0
  107. package/dist/email/departments.js.map +1 -0
  108. package/dist/email/departmentsField.d.ts +49 -0
  109. package/dist/email/departmentsField.js +69 -0
  110. package/dist/email/departmentsField.js.map +1 -0
  111. package/dist/exports/client.d.ts +8 -1
  112. package/dist/exports/client.js +8 -1
  113. package/dist/exports/react.d.ts +15 -6
  114. package/dist/exports/react.js +11 -3
  115. package/dist/exports/rsc.d.ts +8 -1
  116. package/dist/exports/rsc.js +8 -1
  117. package/dist/exports/types.d.ts +18 -10
  118. package/dist/fields/buildFieldBlocks.js +43 -19
  119. package/dist/fields/buildFieldBlocks.js.map +1 -1
  120. package/dist/fields/builtin/calculation.js +7 -0
  121. package/dist/fields/builtin/calculation.js.map +1 -1
  122. package/dist/fields/builtin/checkbox.js +8 -0
  123. package/dist/fields/builtin/checkbox.js.map +1 -1
  124. package/dist/fields/builtin/consent.js +25 -15
  125. package/dist/fields/builtin/consent.js.map +1 -1
  126. package/dist/fields/builtin/country.d.ts +13 -0
  127. package/dist/fields/builtin/country.js +30 -0
  128. package/dist/fields/builtin/country.js.map +1 -0
  129. package/dist/fields/builtin/date.js +2 -0
  130. package/dist/fields/builtin/date.js.map +1 -1
  131. package/dist/fields/builtin/file.js +13 -8
  132. package/dist/fields/builtin/file.js.map +1 -1
  133. package/dist/fields/builtin/index.d.ts +13 -1
  134. package/dist/fields/builtin/index.js +20 -7
  135. package/dist/fields/builtin/index.js.map +1 -1
  136. package/dist/fields/builtin/message.js +30 -0
  137. package/dist/fields/builtin/message.js.map +1 -0
  138. package/dist/fields/builtin/repeater.js +8 -3
  139. package/dist/fields/builtin/repeater.js.map +1 -1
  140. package/dist/fields/builtin/select.js +8 -3
  141. package/dist/fields/builtin/select.js.map +1 -1
  142. package/dist/fields/builtin/state.d.ts +13 -0
  143. package/dist/fields/builtin/state.js +30 -0
  144. package/dist/fields/builtin/state.js.map +1 -0
  145. package/dist/fields/data/regions.d.ts +21 -0
  146. package/dist/fields/data/regions.js +1238 -0
  147. package/dist/fields/data/regions.js.map +1 -0
  148. package/dist/fields/fieldKey.d.ts +15 -0
  149. package/dist/fields/fieldKey.js +16 -0
  150. package/dist/fields/fieldKey.js.map +1 -0
  151. package/dist/fields/fieldNamesOfType.js +13 -8
  152. package/dist/fields/fieldNamesOfType.js.map +1 -1
  153. package/dist/fields/instanceOptions.js +20 -0
  154. package/dist/fields/instanceOptions.js.map +1 -0
  155. package/dist/fields/localizedIf.d.ts +13 -0
  156. package/dist/fields/localizedIf.js +12 -0
  157. package/dist/fields/localizedIf.js.map +1 -0
  158. package/dist/fields/registry.d.ts +1 -0
  159. package/dist/fields/registry.js +21 -2
  160. package/dist/fields/registry.js.map +1 -1
  161. package/dist/fields/sharedConfig.js +101 -51
  162. package/dist/fields/sharedConfig.js.map +1 -1
  163. package/dist/fields/types.d.ts +61 -5
  164. package/dist/flow/engine.d.ts +6 -4
  165. package/dist/flow/engine.js +11 -6
  166. package/dist/flow/engine.js.map +1 -1
  167. package/dist/flow/normalizeFlow.js +22 -7
  168. package/dist/flow/normalizeFlow.js.map +1 -1
  169. package/dist/flow/stepLabel.js +15 -0
  170. package/dist/flow/stepLabel.js.map +1 -0
  171. package/dist/flow/types.d.ts +12 -3
  172. package/dist/flow/types.js +11 -0
  173. package/dist/flow/types.js.map +1 -0
  174. package/dist/form/pollState.d.ts +22 -0
  175. package/dist/form/pollState.js +17 -0
  176. package/dist/form/pollState.js.map +1 -0
  177. package/dist/form/toFormDocument.d.ts +85 -0
  178. package/dist/form/toFormDocument.js +75 -0
  179. package/dist/form/toFormDocument.js.map +1 -0
  180. package/dist/form/types.d.ts +65 -0
  181. package/dist/index.d.ts +193 -27
  182. package/dist/index.js +59 -19
  183. package/dist/index.js.map +1 -1
  184. package/dist/plugin/customState.js +26 -0
  185. package/dist/plugin/customState.js.map +1 -0
  186. package/dist/plugin/registerCollections.js +33 -44
  187. package/dist/plugin/registerCollections.js.map +1 -1
  188. package/dist/plugin/uploadsCollection.d.ts +13 -0
  189. package/dist/plugin/uploadsCollection.js +44 -0
  190. package/dist/plugin/uploadsCollection.js.map +1 -0
  191. package/dist/poll/applyPollOptions.js +18 -0
  192. package/dist/poll/applyPollOptions.js.map +1 -0
  193. package/dist/poll/buildPollOptionSourceFields.js +50 -0
  194. package/dist/poll/buildPollOptionSourceFields.js.map +1 -0
  195. package/dist/poll/closeJob.d.ts +52 -0
  196. package/dist/poll/closeJob.js +119 -0
  197. package/dist/poll/closeJob.js.map +1 -0
  198. package/dist/poll/definePollOptionSource.d.ts +44 -0
  199. package/dist/poll/definePollOptionSource.js +6 -0
  200. package/dist/poll/definePollOptionSource.js.map +1 -0
  201. package/dist/poll/definePollType.d.ts +34 -0
  202. package/dist/poll/definePollType.js +6 -0
  203. package/dist/poll/definePollType.js.map +1 -0
  204. package/dist/poll/effectivePollOptions.d.ts +38 -0
  205. package/dist/poll/effectivePollOptions.js +64 -0
  206. package/dist/poll/effectivePollOptions.js.map +1 -0
  207. package/dist/poll/mostVoted.d.ts +21 -0
  208. package/dist/poll/mostVoted.js +32 -0
  209. package/dist/poll/mostVoted.js.map +1 -0
  210. package/dist/poll/outcomeBeforeChange.js +91 -0
  211. package/dist/poll/outcomeBeforeChange.js.map +1 -0
  212. package/dist/poll/outcomeFields.d.ts +38 -0
  213. package/dist/poll/outcomeFields.js +52 -0
  214. package/dist/poll/outcomeFields.js.map +1 -0
  215. package/dist/poll/pollTypeRegistry.d.ts +34 -0
  216. package/dist/poll/pollTypeRegistry.js +71 -0
  217. package/dist/poll/pollTypeRegistry.js.map +1 -0
  218. package/dist/poll/registry.d.ts +16 -0
  219. package/dist/poll/registry.js +16 -0
  220. package/dist/poll/registry.js.map +1 -0
  221. package/dist/poll/resolvePollCloseRequest.js +105 -0
  222. package/dist/poll/resolvePollCloseRequest.js.map +1 -0
  223. package/dist/poll/resolvePollOptions.d.ts +29 -0
  224. package/dist/poll/resolvePollOptions.js +52 -0
  225. package/dist/poll/resolvePollOptions.js.map +1 -0
  226. package/dist/poll/resolvePollOptionsRequest.js +51 -0
  227. package/dist/poll/resolvePollOptionsRequest.js.map +1 -0
  228. package/dist/poll/resolvePollOutcome.d.ts +34 -0
  229. package/dist/poll/resolvePollOutcome.js +76 -0
  230. package/dist/poll/resolvePollOutcome.js.map +1 -0
  231. package/dist/poll/resultsField.js +21 -0
  232. package/dist/poll/resultsField.js.map +1 -0
  233. package/dist/prefill/valuesFromSearchParams.js +3 -2
  234. package/dist/prefill/valuesFromSearchParams.js.map +1 -1
  235. package/dist/presentations/types.d.ts +3 -2
  236. package/dist/react/Form.d.ts +15 -33
  237. package/dist/react/Form.js +144 -119
  238. package/dist/react/Form.js.map +1 -1
  239. package/dist/react/FormContext.d.ts +37 -1
  240. package/dist/react/FormContext.js.map +1 -1
  241. package/dist/react/FormControls.d.ts +55 -0
  242. package/dist/react/FormControls.js +56 -0
  243. package/dist/react/FormControls.js.map +1 -0
  244. package/dist/react/FormResults.d.ts +6 -3
  245. package/dist/react/FormResults.js +37 -29
  246. package/dist/react/FormResults.js.map +1 -1
  247. package/dist/react/FormSteps.d.ts +17 -0
  248. package/dist/react/FormSteps.js +35 -0
  249. package/dist/react/FormSteps.js.map +1 -0
  250. package/dist/react/Poll.d.ts +17 -6
  251. package/dist/react/Poll.js +66 -18
  252. package/dist/react/Poll.js.map +1 -1
  253. package/dist/react/contract.d.ts +2 -3
  254. package/dist/react/contract.js.map +1 -1
  255. package/dist/react/fetchResults.d.ts +1 -1
  256. package/dist/react/fetchResults.js +1 -1
  257. package/dist/react/fetchResults.js.map +1 -1
  258. package/dist/react/primitives/Checkbox.d.ts +4 -2
  259. package/dist/react/primitives/Checkbox.js +2 -1
  260. package/dist/react/primitives/Checkbox.js.map +1 -1
  261. package/dist/react/primitives/FieldShell.d.ts +2 -4
  262. package/dist/react/primitives/FieldShell.js +12 -19
  263. package/dist/react/primitives/FieldShell.js.map +1 -1
  264. package/dist/react/renderers/calculation.js +1 -2
  265. package/dist/react/renderers/calculation.js.map +1 -1
  266. package/dist/react/renderers/checkbox.js +1 -2
  267. package/dist/react/renderers/checkbox.js.map +1 -1
  268. package/dist/react/renderers/consent.js +78 -34
  269. package/dist/react/renderers/consent.js.map +1 -1
  270. package/dist/react/renderers/date.js +1 -3
  271. package/dist/react/renderers/date.js.map +1 -1
  272. package/dist/react/renderers/email.js +1 -2
  273. package/dist/react/renderers/email.js.map +1 -1
  274. package/dist/react/renderers/file.js +6 -3
  275. package/dist/react/renderers/file.js.map +1 -1
  276. package/dist/react/renderers/index.js +5 -0
  277. package/dist/react/renderers/index.js.map +1 -1
  278. package/dist/react/renderers/message.js +35 -0
  279. package/dist/react/renderers/message.js.map +1 -0
  280. package/dist/react/renderers/number.js +1 -2
  281. package/dist/react/renderers/number.js.map +1 -1
  282. package/dist/react/renderers/region.js +45 -0
  283. package/dist/react/renderers/region.js.map +1 -0
  284. package/dist/react/renderers/repeater.js +7 -10
  285. package/dist/react/renderers/repeater.js.map +1 -1
  286. package/dist/react/renderers/select.js +1 -2
  287. package/dist/react/renderers/select.js.map +1 -1
  288. package/dist/react/renderers/text.js +1 -2
  289. package/dist/react/renderers/text.js.map +1 -1
  290. package/dist/react/renderers/textarea.js +1 -2
  291. package/dist/react/renderers/textarea.js.map +1 -1
  292. package/dist/react/state.d.ts +23 -2
  293. package/dist/react/state.js +16 -7
  294. package/dist/react/state.js.map +1 -1
  295. package/dist/react/uploadFile.d.ts +2 -2
  296. package/dist/react/uploadFile.js +1 -1
  297. package/dist/react/uploadFile.js.map +1 -1
  298. package/dist/react/useField.d.ts +0 -1
  299. package/dist/react/useField.js +0 -1
  300. package/dist/react/useField.js.map +1 -1
  301. package/dist/react/useFormState.d.ts +1 -1
  302. package/dist/react/useFormState.js +1 -1
  303. package/dist/react/useFormState.js.map +1 -1
  304. package/dist/react/validateField.js +3 -6
  305. package/dist/react/validateField.js.map +1 -1
  306. package/dist/recall/interpolate.d.ts +4 -3
  307. package/dist/recall/interpolate.js +5 -4
  308. package/dist/recall/interpolate.js.map +1 -1
  309. package/dist/recall/resolver.d.ts +1 -1
  310. package/dist/recall/resolver.js +14 -2
  311. package/dist/recall/resolver.js.map +1 -1
  312. package/dist/spam/captcha.d.ts +1 -1
  313. package/dist/spam/captcha.js +1 -1
  314. package/dist/spam/captcha.js.map +1 -1
  315. package/dist/submissions/SubmissionAnswers.js +6 -2
  316. package/dist/submissions/SubmissionAnswers.js.map +1 -1
  317. package/dist/submissions/SubmissionAnswersClient.js +91 -62
  318. package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
  319. package/dist/submissions/createSubmission.d.ts +36 -0
  320. package/dist/submissions/createSubmission.js +26 -0
  321. package/dist/submissions/createSubmission.js.map +1 -0
  322. package/dist/submissions/runSubmission.d.ts +10 -0
  323. package/dist/submissions/runSubmission.js +92 -44
  324. package/dist/submissions/runSubmission.js.map +1 -1
  325. package/dist/submissions/types.d.ts +11 -4
  326. package/dist/submissions/validateSubmission.js +59 -10
  327. package/dist/submissions/validateSubmission.js.map +1 -1
  328. package/dist/submissions/votedCookie.d.ts +13 -0
  329. package/dist/submissions/votedCookie.js +27 -0
  330. package/dist/submissions/votedCookie.js.map +1 -0
  331. package/dist/translations/de.js +295 -0
  332. package/dist/translations/de.js.map +1 -0
  333. package/dist/translations/en.js +138 -23
  334. package/dist/translations/en.js.map +1 -1
  335. package/dist/translations/index.d.ts +2 -1
  336. package/dist/translations/index.js +6 -2
  337. package/dist/translations/index.js.map +1 -1
  338. package/dist/translations/keys.d.ts +134 -19
  339. package/dist/translations/keys.js +135 -20
  340. package/dist/translations/keys.js.map +1 -1
  341. package/dist/uploads/types.d.ts +1 -2
  342. package/dist/validation/buildRuleBlocks.js +18 -17
  343. package/dist/validation/buildRuleBlocks.js.map +1 -1
  344. package/dist/validation/builtin/email.js +1 -0
  345. package/dist/validation/builtin/email.js.map +1 -1
  346. package/dist/validation/builtin/matchesField.js +3 -7
  347. package/dist/validation/builtin/matchesField.js.map +1 -1
  348. package/dist/validation/builtin/max.js +1 -0
  349. package/dist/validation/builtin/max.js.map +1 -1
  350. package/dist/validation/builtin/maxDate.js +1 -0
  351. package/dist/validation/builtin/maxDate.js.map +1 -1
  352. package/dist/validation/builtin/maxLength.js +1 -0
  353. package/dist/validation/builtin/maxLength.js.map +1 -1
  354. package/dist/validation/builtin/min.js +1 -0
  355. package/dist/validation/builtin/min.js.map +1 -1
  356. package/dist/validation/builtin/minDate.js +1 -0
  357. package/dist/validation/builtin/minDate.js.map +1 -1
  358. package/dist/validation/builtin/minLength.js +1 -0
  359. package/dist/validation/builtin/minLength.js.map +1 -1
  360. package/dist/validation/builtin/notAlreadySubmitted.js +1 -0
  361. package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
  362. package/dist/validation/builtin/oneOf.js +1 -0
  363. package/dist/validation/builtin/oneOf.js.map +1 -1
  364. package/dist/validation/builtin/pattern.js +11 -2
  365. package/dist/validation/builtin/pattern.js.map +1 -1
  366. package/dist/validation/builtin/url.js +1 -0
  367. package/dist/validation/builtin/url.js.map +1 -1
  368. package/dist/validation/builtin/validateRegexParams.js +44 -0
  369. package/dist/validation/builtin/validateRegexParams.js.map +1 -0
  370. package/dist/validation/fieldTargetParam.d.ts +22 -0
  371. package/dist/validation/fieldTargetParam.js +38 -0
  372. package/dist/validation/fieldTargetParam.js.map +1 -0
  373. package/dist/validation/runValidation.js +8 -29
  374. package/dist/validation/runValidation.js.map +1 -1
  375. package/dist/validation/types.d.ts +5 -11
  376. package/dist/validation/validateUrl.js +22 -0
  377. package/dist/validation/validateUrl.js.map +1 -0
  378. package/package.json +7 -6
  379. package/styles/form-builder.css +10 -0
  380. package/dist/collections/uploads.d.ts +0 -30
  381. package/dist/collections/uploads.js +0 -55
  382. package/dist/collections/uploads.js.map +0 -1
  383. package/dist/consent/buildConsentSourceConfig.js +0 -49
  384. package/dist/consent/buildConsentSourceConfig.js.map +0 -1
  385. package/dist/consent/builtin/index.d.ts +0 -7
  386. package/dist/consent/builtin/index.js +0 -11
  387. package/dist/consent/builtin/index.js.map +0 -1
  388. package/dist/consent/builtin/pageReference.js +0 -75
  389. package/dist/consent/builtin/pageReference.js.map +0 -1
  390. package/dist/consent/builtin/static.js +0 -44
  391. package/dist/consent/builtin/static.js.map +0 -1
  392. package/dist/consent/defineConsentSource.d.ts +0 -35
  393. package/dist/consent/defineConsentSource.js +0 -6
  394. package/dist/consent/defineConsentSource.js.map +0 -1
  395. package/dist/consent/registry.d.ts +0 -16
  396. package/dist/consent/registry.js +0 -16
  397. package/dist/consent/registry.js.map +0 -1
  398. package/dist/consent/resolveConsentLinks.d.ts +0 -19
  399. package/dist/consent/resolveConsentLinks.js +0 -26
  400. package/dist/consent/resolveConsentLinks.js.map +0 -1
  401. package/dist/presentations/registry.d.ts +0 -15
  402. package/dist/presentations/registry.js +0 -15
  403. package/dist/presentations/registry.js.map +0 -1
  404. package/dist/react/toFormDocument.d.ts +0 -24
  405. package/dist/react/toFormDocument.js +0 -22
  406. package/dist/react/toFormDocument.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,48 +1,73 @@
1
+ import { AnyPollOptionSource, PollOption, PollOptionResolveArgs, PollOptionSource, definePollOptionSource } from "./poll/definePollOptionSource.js";
1
2
  import { FileFieldConfig, FileRef, FileRefError } from "./uploads/types.js";
2
- import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind } from "./fields/types.js";
3
+ import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind, OmittableSharedField, ResolveFieldOptionsArgs } from "./fields/types.js";
3
4
  import { TranslationsOption } from "./translations/index.js";
5
+ import { BodyConverter, BodyConverterArgs, BodyRender, defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js";
6
+ import { BodyContext, RichTextBodyOption, SerializeBodyArgs, serializeBody } from "./actions/body/serializeBody.js";
7
+ import { textOfBody } from "./actions/body/textOfBody.js";
4
8
  import { AggregationBucket, AggregationRow, FieldAggregation, FieldMeta, SubmissionStatusFilter } from "./aggregation/types.js";
5
9
  import { CalcExpression } from "./calc/types.js";
6
10
  import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
7
11
  import { evaluateCalc } from "./calc/evaluate.js";
8
12
  import { evaluateCondition } from "./conditions/evaluate.js";
13
+ import { ConsentSourceEntry, ConsentSourcePage, ConsentSourcesResolver } from "./consent/types.js";
14
+ import { ConsentStatement, ConsentStatements, ResolveConsentStatementsArgs, resolveConsentStatements } from "./consent/resolveConsentStatements.js";
15
+ import { fieldKey } from "./fields/fieldKey.js";
16
+ import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSettings } from "./form/types.js";
17
+ import { ToFormDocumentOptions, toFormDocument } from "./form/toFormDocument.js";
9
18
  import { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from "./fields/registry.js";
10
19
  import { PrefillOptions, valuesFromSearchParams } from "./prefill/valuesFromSearchParams.js";
11
20
  import { FormEventSink } from "./events/types.js";
12
- import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult, ValidationSeverity } from "./validation/types.js";
21
+ import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult } from "./validation/types.js";
13
22
  import { PresentationDensity, PresentationDescriptor, PresentationSurface } from "./presentations/types.js";
14
23
  import { interpolate } from "./recall/interpolate.js";
15
24
  import { RecallResolver, buildRecallResolver, optionLabelsFor } from "./recall/resolver.js";
16
25
  import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "./spam/constants.js";
17
26
  import { formatBytes } from "./uploads/formatBytes.js";
27
+ import { isPollClosed } from "./form/pollState.js";
28
+ import { PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig, resolvePollOptionSources } from "./poll/registry.js";
29
+ import { ResolveEffectivePollOptionsArgs, resolveEffectivePollOptions } from "./poll/effectivePollOptions.js";
30
+ import { ResolvePollOptionsArgs, resolvePollOptions } from "./poll/resolvePollOptions.js";
31
+ import { ResolvePollOutcomeArgs, resolvePollOutcome } from "./poll/resolvePollOutcome.js";
32
+ import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
18
33
  import { ActionDefinition, ActionRunArgs, AnyActionDefinition, defineAction } from "./actions/defineAction.js";
34
+ import { FromAddressOption, FromAddressesResolver } from "./actions/fromAddresses.js";
19
35
  import { ActionOption, ActionRegistry, ActionsConfig, resolveActions } from "./actions/registry.js";
20
- import { BodyConverter, BodyConverterArgs, BodyRender, defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js";
21
- import { BodyContext, RichTextBodyOption, SerializeBodyArgs, serializeBody } from "./actions/body/serializeBody.js";
22
36
  import { ActionResult } from "./actions/runActions.js";
23
37
  import { AggregateFieldResponsesArgs, AggregateFormResponsesArgs, aggregateFieldResponses, aggregateFormResponses, fieldHasOptions } from "./aggregation/aggregateResponses.js";
24
- import { ResolveResultsRequestArgs, ResolveResultsRequestResult, resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
25
- import { CollectionOverrides } from "./plugin/collectionOverrides.js";
26
- import { FORM_UPLOADS_SLUG, UploadsCollectionConfig, UploadsOption, buildUploadsCollection, resolveUploads } from "./collections/uploads.js";
38
+ import { FormResultsAccess, FormResultsAccessArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
39
+ import { ButtonFieldsOverride, ButtonsOption, DefaultButtonFields, buildDefaultButtonFields, buildNextLabelField, buildPrevLabelField, buildSubmitLabelField } from "./collections/buttonFields.js";
27
40
  import { FieldCondition } from "./conditions/types.js";
28
- import { AnyConsentSource, ConsentLink, ConsentResolveArgs, ConsentResolved, ConsentSource, defineConsentSource } from "./consent/defineConsentSource.js";
29
- import { ConsentSourceOption, ConsentSourceRegistry, ConsentSourcesConfig, resolveConsentSources } from "./consent/registry.js";
30
41
  import { ConsentProof, captureConsent } from "./consent/captureConsent.js";
31
- import { PresentationDescriptorOption, PresentationDescriptorRegistry, PresentationsDescriptorConfig, resolvePresentationDescriptors } from "./presentations/registry.js";
42
+ import { ConsentSourcesFieldOptions, consentSourcesField } from "./consent/consentSourcesField.js";
43
+ import { ResolveConsentEntriesArgs, resolveConsentEntries } from "./consent/resolveConsentEntries.js";
44
+ import { ConsentSourceOption, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult, resolveConsentSourcesRequest } from "./consent/resolveConsentSourcesRequest.js";
45
+ import { ResolvePublishedVersionRefArgs, resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
46
+ import { RedirectFieldsOverride, RedirectOption, ResponseOption } from "./collections/redirectFields.js";
47
+ import { DepartmentEmailsResolver, DepartmentOption, ResolveDepartmentOptionsArgs, ResolveDepartmentsRequestArgs, ResolveDepartmentsRequestResult, resolveDepartmentOptions } from "./email/departments.js";
48
+ import { CollectionOverrides } from "./plugin/collectionOverrides.js";
32
49
  import { CaptchaProvider, CaptchaVerifyArgs, IdentifyFn, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, SpamConfig, SpamMetadataConfig, SpamOption } from "./spam/types.js";
50
+ import { UploadsOption } from "./plugin/uploadsCollection.js";
51
+ import { DefaultOutcomeFields, OutcomeFieldsOverride, buildDefaultOutcomeFields, buildResolvedAtField, buildWinningValuesField } from "./poll/outcomeFields.js";
52
+ import { PollOutcomeStrategy, PollOutcomeStrategyArgs, definePollType } from "./poll/definePollType.js";
53
+ import { PollTypeRegistry, PollTypesConfig, manualStrategy, pollTypesOf, resolvePollTypes, sourceStrategy, stashPollTypes } from "./poll/pollTypeRegistry.js";
33
54
  import { ValidationRuleOption, ValidationRuleRegistry, ValidationRulesConfig } from "./validation/registry.js";
34
55
  import { escapeHtml } from "./actions/body/escapeHtml.js";
35
56
  import { renderAllValues, renderAllValuesTable } from "./actions/body/wildcards.js";
36
- import { defaultActionDefinitions } from "./actions/builtin/index.js";
57
+ import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actions/builtin/index.js";
37
58
  import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
38
59
  import { aggregateRowForField, aggregateRowsForFields } from "./aggregation/aggregateRows.js";
39
60
  import { normalizeCalc } from "./calc/normalizeCalc.js";
40
- import { defaultConsentSources } from "./consent/builtin/index.js";
41
- import { resolveConsentLinks } from "./consent/resolveConsentLinks.js";
42
- import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
43
- import { defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
61
+ import { applyConsentStatements } from "./consent/applyConsentStatements.js";
62
+ import { DepartmentsFieldOptions, departmentsField } from "./email/departmentsField.js";
63
+ import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
64
+ import { countryField } from "./fields/builtin/country.js";
44
65
  import { fileMimeTypeOptions } from "./fields/builtin/file.js";
66
+ import { stateField } from "./fields/builtin/state.js";
45
67
  import { defineFormField } from "./fields/defineFormField.js";
68
+ import { localizedIf } from "./fields/localizedIf.js";
69
+ import { POLL_CLOSE_TASK_SLUG, PollCloseTaskInput, buildPollCloseTask, enqueuePollClose, registerPollCloseTask, runPollClose, shouldAutoResolvePoll } from "./poll/closeJob.js";
70
+ import { mostVotedStrategy, topBucketValues } from "./poll/mostVoted.js";
46
71
  import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
47
72
  import { defineCaptchaProvider } from "./spam/captcha.js";
48
73
  import { defaultIdentify } from "./spam/identify.js";
@@ -51,10 +76,13 @@ import { RecaptchaProviderOptions, recaptchaProvider } from "./spam/providers/re
51
76
  import { TurnstileProviderOptions, turnstileProvider } from "./spam/providers/turnstile.js";
52
77
  import { createKvRateLimiter } from "./spam/rateLimiter.js";
53
78
  import { resolveSpamConfig } from "./spam/resolveSpam.js";
79
+ import { CreateSubmissionArgs, CreatedSubmission, createSubmission } from "./submissions/createSubmission.js";
54
80
  import { resolveFileRef } from "./uploads/resolveFileRef.js";
55
81
  import { captureFileRef } from "./uploads/captureFileRef.js";
56
82
  import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
57
83
  import { defineValidationRule } from "./validation/defineValidationRule.js";
84
+ import { FieldTargetParamOptions, fieldTargetParam } from "./validation/fieldTargetParam.js";
85
+ import { CollectionSlug } from "payload";
58
86
 
59
87
  //#region src/index.d.ts
60
88
  type FormBuilderPluginOptions = {
@@ -66,24 +94,163 @@ type FormBuilderPluginOptions = {
66
94
  * added whole. App-level `i18n.translations` still wins over both.
67
95
  */
68
96
  translations?: TranslationsOption; /** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */
69
- events?: FormEventSink; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
70
- fields?: FieldTypesConfig; /** Add, override, or remove presentations. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
71
- presentations?: PresentationsDescriptorConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
97
+ events?: FormEventSink;
98
+ /**
99
+ * Content-bearing author fields (labels, placeholders, option labels, action subjects and
100
+ * bodies) are localized by default. Payload strips the `localized` flag on hosts without
101
+ * `localization` configured, so the default is safe everywhere. Set `false` to keep form
102
+ * content single-locale even on localized hosts. Spread-overrides of the prebuilt default
103
+ * exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`
104
+ * flags from the default-true set; when opting out, derive overrides from
105
+ * `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions(false)` instead.
106
+ * Consent statements are unaffected either way: they live on the host's own
107
+ * `consentSourcesField()`, which carries its own `localized` option.
108
+ */
109
+ localizeContent?: boolean; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
110
+ fields?: FieldTypesConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
72
111
  rules?: ValidationRulesConfig; /** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
73
112
  actions?: ActionsConfig;
74
113
  /**
75
- * Customize how rich text action bodies are rendered. `converters` spread over the default
76
- * Lexical node converters; `serialize` replaces the whole pipeline (e.g. to target chat or
77
- * plain-text channels instead of email HTML).
114
+ * Customize how the plugin's rich text is authored and rendered. `editor` is the default
115
+ * Lexical/richText editor for every plugin richText field (message content, consent
116
+ * statement, response message, action bodies); `bodyEditor` overrides the action body
117
+ * fields specifically, falling back to `editor`. `converters` spread over the default
118
+ * Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to
119
+ * target chat or plain-text channels instead of email HTML). A custom `serialize` receives
120
+ * the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw
121
+ * body off to a renderer like react-email.
122
+ */
123
+ richText?: RichTextBodyOption;
124
+ /**
125
+ * Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the
126
+ * presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped
127
+ * resolver, evaluated per request via an endpoint, whose choice is validated at save time only and
128
+ * never re-checked when the action sends (the config is admin-authored, not visitor-controlled).
129
+ *
130
+ * `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,
131
+ * neither action has a `from` field and every send uses the email adapter's default sender. The
132
+ * intended use is multi-tenant hosts where each tenant may only send from particular addresses
133
+ * (derive the tenant from `req`, return its allowed senders). Values are the literal string
134
+ * `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).
135
+ *
136
+ * `departments` turns the `emailTeam` `to` into a select whose options come from the resolver
137
+ * (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document
138
+ * you own and read it back with `resolveDepartmentOptions`, which resolves each department's address
139
+ * for the requesting locale. Because `to` is localized, each admin locale stores its own resolved
140
+ * address and a submission's locale selects the address it routes to (Payload-native, no per-send
141
+ * lookup). Storing the resolved address, rather than a department id resolved live at send (consent's
142
+ * model), is deliberate: the routing target a form was saved with stays audit-stable even if the
143
+ * resolver's data later changes, so do not "fix" it into a live lookup. Multi-tenant hosts scope
144
+ * which document they read by the tenant derived from `req`; absent, `to` stays a plain localized
145
+ * text field.
146
+ */
147
+ email?: {
148
+ fromAddresses?: FromAddressesResolver;
149
+ departments?: DepartmentEmailsResolver;
150
+ };
151
+ /**
152
+ * Where the consent statements a form can reference come from. Absent (the default): no sources,
153
+ * so the built-in `consent` field type is not registered at all and authors cannot add a consent
154
+ * field with nothing to reference (a developer-registered custom `consent` type via `fields`
155
+ * still wins).
156
+ *
157
+ * `sources` is an async `req`-scoped resolver returning the sources available to this request.
158
+ * The intended shape: place `consentSourcesField()` on a collection or global you own and read it
159
+ * back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's
160
+ * authors only ever see, and their visitors only ever agree to, their own statements. A form
161
+ * stores only a source's row `id`; the statement is resolved live per request (see
162
+ * `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is
163
+ * ever a copy the client could stale or forge.
164
+ */
165
+ consent?: {
166
+ sources: ConsentSourcesResolver;
167
+ };
168
+ /**
169
+ * Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and
170
+ * `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The
171
+ * rendered chrome resolves each label as `<Form>` prop, then the stored value, then the
172
+ * translated default. `fields` composes them: it receives the three default fields as a
173
+ * `{ submit, prev, next }` map with the content localization flag already applied and returns
174
+ * the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing
175
+ * one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a
176
+ * host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.
177
+ */
178
+ buttons?: ButtonsOption;
179
+ /**
180
+ * The success-response group. `redirect.fields` composes the fields inside the `response.redirect`
181
+ * group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the
182
+ * polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's
183
+ * final field array, so a host can prepend a custom link field (the pattern most projects already
184
+ * have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the
185
+ * built-in `url` (+ optional `reference`), unchanged.
186
+ *
187
+ * The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when
188
+ * configured); `toFormDocument` passes the whole `response` group through, so a host that replaces
189
+ * `url` with their own link field owns resolving it to a destination in their frontend, the same as
190
+ * the internal-reference case.
191
+ */
192
+ response?: ResponseOption;
193
+ /**
194
+ * Collections whose documents `response.redirect` can reference (`response.redirect.reference`),
195
+ * letting an author redirect a visitor to an internal document instead of a URL after a
196
+ * successful submit. Absent (the default): no `reference` field exists at all, matching today's
197
+ * URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not
198
+ * a bare `CollectionSlug`), so a host adding a second collection later never changes the stored
199
+ * shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves
200
+ * the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes
201
+ * the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for
202
+ * the host to resolve. Mirrors the `redirectRelationships` option of Payload's native
203
+ * `plugin-form-builder`.
204
+ */
205
+ redirectRelationships?: CollectionSlug[];
206
+ /**
207
+ * File uploads are bring-your-own. Default `false`: no upload collection is involved and the
208
+ * built-in `file` field type is removed from the registry, so form authors cannot add a field
209
+ * with nowhere to land (a developer-registered custom `file` type via `fields` still wins).
210
+ * `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with
211
+ * its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when
212
+ * absent, and prepends the spam upload hooks.
78
213
  */
79
- richText?: RichTextBodyOption; /** Add, override, or remove consent source types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
80
- consentSources?: ConsentSourcesConfig; /** The built-in `form-uploads` collection backing file fields. `false` disables it (bring your own); an object overrides slug/upload/access/fields. */
81
214
  uploads?: UploadsOption; /** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */
82
215
  spam?: SpamOption;
216
+ /**
217
+ * Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded
218
+ * and before anything is served; absent keeps the plugin-default gating (poll opt-in +
219
+ * visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against
220
+ * the tenant derived from `req` so one tenant's poll counts are never readable under another
221
+ * tenant's id. Authenticated callers bypass this seam.
222
+ */
223
+ results?: {
224
+ access?: FormResultsAccess;
225
+ };
226
+ /**
227
+ * Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each
228
+ * successful submission to a poll-enabled form, letting SSR hosts read the voted state via
229
+ * `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.
230
+ * `sources` registers poll option sources (`definePollOptionSource`), letting authors populate
231
+ * a poll's choices from host domain data with stable values; there are no built-ins. With at
232
+ * least one source registered, the forms poll group gains an `optionSource` select plus its
233
+ * per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.
234
+ * `outcomeFields` composes the poll `outcome` group: it receives the two default fields
235
+ * (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host
236
+ * can swap `winningValues` for its own component (e.g. a relationship picker over the voteable
237
+ * records). Membership validation runs server-side regardless, so a swap cannot bypass it.
238
+ * `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The
239
+ * built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on
240
+ * close), and `source` (delegates to the option source) are always registered; a host entry keyed
241
+ * by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`
242
+ * auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.
243
+ */
244
+ poll?: {
245
+ votedCookie?: boolean;
246
+ sources?: PollOptionSourcesConfig;
247
+ types?: PollTypesConfig;
248
+ outcomeFields?: OutcomeFieldsOverride;
249
+ };
83
250
  /**
84
251
  * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the
85
- * submission admin view. Default `false` — those fields are fully represented by the
86
- * `SubmissionAnswers` UI component and are noisy when shown alongside it.
252
+ * submission admin view. Default `false`, because the `SubmissionAnswers` UI component already
253
+ * represents those fields fully and they are noisy shown alongside it.
87
254
  */
88
255
  showSubmissionRawFields?: boolean;
89
256
  /**
@@ -96,7 +263,6 @@ type FormBuilderPluginOptions = {
96
263
  overrides?: {
97
264
  forms?: CollectionOverrides;
98
265
  formSubmissions?: CollectionOverrides;
99
- uploads?: CollectionOverrides;
100
266
  };
101
267
  };
102
268
  declare module 'payload' {
@@ -106,5 +272,5 @@ declare module 'payload' {
106
272
  }
107
273
  declare const formBuilder: (options: FormBuilderPluginOptions) => import("payload").Plugin;
108
274
  //#endregion
109
- export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type AnyConsentSource, type AnyFormFieldDefinition, type AnyValidationRuleDefinition, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaProvider, type CaptchaVerifyArgs, type ConsentLink, type ConsentProof, type ConsentResolveArgs, type ConsentResolved, type ConsentSource, type ConsentSourceOption, type ConsentSourceRegistry, type ConsentSourcesConfig, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, FORM_UPLOADS_SLUG, type FieldAggregation, type FieldCondition, type FieldMeta, type FieldTypeOption, type FieldTypeRegistry, type FieldTypesConfig, type FileFieldConfig, type FileRef, type FileRefError, FormBuilderPluginOptions, type FormBuilderPluginOptions as PluginOptions, type FormFieldDefinition, type FormFieldFormat, type FormFieldValidate, type FormFieldValueKind, type HcaptchaProviderOptions, type IdentifyFn, type PrefillOptions, type PresentationDensity, type PresentationDescriptor, type PresentationDescriptorOption, type PresentationDescriptorRegistry, type PresentationSurface, type PresentationsDescriptorConfig, type RateLimitCheckArgs, type RateLimitConfig, type RateLimitResult, type RateLimiter, type RecallResolver, type RecaptchaProviderOptions, type ResolveResultsRequestArgs, type ResolveResultsRequestResult, type RichTextBodyOption, SIGNATURE_HEADER, type SerializeBodyArgs, type SpamConfig, type SpamMetadataConfig, type SpamOption, type SubmissionStatusFilter, type TurnstileProviderOptions, type UploadsCollectionConfig, type UploadsOption, type ValidationRuleDefinition, type ValidationRuleOption, type ValidationRuleRegistry, type ValidationRuleResult, type ValidationRulesConfig, type ValidationSeverity, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, buildRecallResolver, buildUploadsCollection, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, createKvRateLimiter, defaultActionDefinitions, defaultBodyConverters, defaultConsentSources, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineConsentSource, defineFormField, defineValidationRule, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fileMimeTypeOptions, formBuilder, formatBytes, hcaptchaProvider, interpolate, normalizeCalc, optionLabelsFor, recaptchaProvider, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentLinks, resolveConsentSources, resolveFileRef, resolveFormResultsRequest, resolvePresentationDescriptors, resolvePublishedVersionRef, resolveSpamConfig, resolveUploads, sanitizeUrl, serializeBody, signPayload, turnstileProvider, valuesFromSearchParams };
275
+ export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type AnyFormFieldDefinition, type AnyPollOptionSource, type AnyValidationRuleDefinition, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, type ButtonFieldsOverride, type ButtonsOption, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaProvider, type CaptchaVerifyArgs, type ConsentProof, type ConsentSourceEntry, type ConsentSourceOption, type ConsentSourcePage, type ConsentSourcesFieldOptions, type ConsentSourcesResolver, type ConsentStatement, type ConsentStatements, type CreateSubmissionArgs, type CreatedSubmission, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, type DefaultButtonFields, type DefaultOutcomeFields, type DepartmentEmailsResolver, type DepartmentOption, type DepartmentsFieldOptions, type FieldAggregation, type FieldCondition, type FieldMeta, type FieldTargetParamOptions, type FieldTypeOption, type FieldTypeRegistry, type FieldTypesConfig, type FileFieldConfig, type FileRef, type FileRefError, FormBuilderPluginOptions, type FormBuilderPluginOptions as PluginOptions, type FormButtonSettings, type FormDocument, type FormFieldDefinition, type FormFieldFormat, type FormFieldValidate, type FormFieldValueKind, type FormPollSettings, type FormResponseSettings, type FormResultsAccess, type FormResultsAccessArgs, type FromAddressOption, type FromAddressesResolver, type HcaptchaProviderOptions, type IdentifyFn, type OmittableSharedField, type OutcomeFieldsOverride, POLL_CLOSE_TASK_SLUG, type PollCloseTaskInput, type PollOption, type PollOptionResolveArgs, type PollOptionSource, type PollOptionSourceOption, type PollOptionSourceRegistry, type PollOptionSourcesConfig, type PollOutcomeStrategy, type PollOutcomeStrategyArgs, type PollTypeRegistry, type PollTypesConfig, type PrefillOptions, type PresentationDensity, type PresentationDescriptor, type PresentationSurface, type RateLimitCheckArgs, type RateLimitConfig, type RateLimitResult, type RateLimiter, type RecallResolver, type RecaptchaProviderOptions, type RedirectFieldsOverride, type RedirectOption, type ResolveConsentEntriesArgs, type ResolveConsentSourcesRequestArgs, type ResolveConsentSourcesRequestResult, type ResolveConsentStatementsArgs, type ResolveDepartmentOptionsArgs, type ResolveDepartmentsRequestArgs, type ResolveDepartmentsRequestResult, type ResolveEffectivePollOptionsArgs, type ResolveFieldOptionsArgs, type ResolvePollOptionsArgs, type ResolvePollOutcomeArgs, type ResolvePublishedVersionRefArgs, type ResolveResultsRequestArgs, type ResolveResultsRequestResult, type ResponseOption, type RichTextBodyOption, SIGNATURE_HEADER, type SerializeBodyArgs, type SpamConfig, type SpamMetadataConfig, type SpamOption, type SubmissionStatusFilter, type ToFormDocumentOptions, type TurnstileProviderOptions, type UploadsOption, type ValidationRuleDefinition, type ValidationRuleOption, type ValidationRuleRegistry, type ValidationRuleResult, type ValidationRulesConfig, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, applyConsentStatements, buildDefaultActionDefinitions, buildDefaultButtonFields, buildDefaultFieldDefinitions, buildDefaultOutcomeFields, buildNextLabelField, buildPollCloseTask, buildPrevLabelField, buildRecallResolver, buildResolvedAtField, buildSubmitLabelField, buildWinningValuesField, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, consentSourcesField, countryField, createKvRateLimiter, createSubmission, defaultActionDefinitions, defaultBodyConverters, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineFormField, definePollOptionSource, definePollType, defineValidationRule, departmentsField, enqueuePollClose, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fieldKey, fieldTargetParam, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, manualStrategy, mostVotedStrategy, normalizeCalc, optionLabelsFor, pollTypesOf, recaptchaProvider, registerPollCloseTask, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentEntries, resolveConsentSourcesRequest, resolveConsentStatements, resolveDepartmentOptions, resolveEffectivePollOptions, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePollTypes, resolvePublishedVersionRef, resolveSpamConfig, runPollClose, sanitizeUrl, serializeBody, shouldAutoResolvePoll, signPayload, sourceStrategy, stashPollTypes, stateField, textOfBody, toFormDocument, topBucketValues, turnstileProvider, valuesFromSearchParams, votedCookieName };
110
276
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,49 +1,71 @@
1
+ import { localizedIf } from "./fields/localizedIf.js";
1
2
  import { interpolate } from "./recall/interpolate.js";
2
3
  import { escapeHtml } from "./actions/body/escapeHtml.js";
3
4
  import { defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js";
4
5
  import { renderAllValues, renderAllValuesTable } from "./actions/body/wildcards.js";
5
6
  import { serializeBody } from "./actions/body/serializeBody.js";
6
7
  import { defineAction } from "./actions/defineAction.js";
8
+ import { resolveDepartmentOptions } from "./email/departments.js";
7
9
  import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
8
- import { defaultActionDefinitions } from "./actions/builtin/index.js";
10
+ import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actions/builtin/index.js";
9
11
  import { resolveActions } from "./actions/registry.js";
10
- import { FORM_UPLOADS_SLUG, buildUploadsCollection, resolveUploads } from "./collections/uploads.js";
11
- import { defineConsentSource } from "./consent/defineConsentSource.js";
12
- import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
13
- import { defaultConsentSources } from "./consent/builtin/index.js";
14
- import { resolveConsentSources } from "./consent/registry.js";
12
+ import { resolveConsentEntries, stashConsentSources } from "./consent/resolveConsentEntries.js";
15
13
  import { normalizeCalc } from "./calc/normalizeCalc.js";
16
14
  import { defineFormField } from "./fields/defineFormField.js";
17
15
  import { fileMimeTypeOptions } from "./fields/builtin/file.js";
18
- import { defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
19
- import { resolveFieldTypes } from "./fields/registry.js";
16
+ import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
17
+ import { resolveFieldTypes, stashFieldTypes } from "./fields/registry.js";
20
18
  import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "./spam/constants.js";
19
+ import { isPollClosed } from "./form/pollState.js";
20
+ import { fieldKey } from "./fields/fieldKey.js";
21
21
  import { aggregateRowForField, aggregateRowsForFields } from "./aggregation/aggregateRows.js";
22
22
  import { aggregateFieldResponses, aggregateFormResponses, fieldHasOptions } from "./aggregation/aggregateResponses.js";
23
+ import { definePollType } from "./poll/definePollType.js";
24
+ import { mostVotedStrategy, topBucketValues } from "./poll/mostVoted.js";
25
+ import { resolvePollOptions, stashPollOptionSources } from "./poll/resolvePollOptions.js";
26
+ import { manualStrategy, pollTypesOf, resolvePollTypes, sourceStrategy, stashPollTypes } from "./poll/pollTypeRegistry.js";
27
+ import { resolvePollOutcome } from "./poll/resolvePollOutcome.js";
28
+ import { POLL_CLOSE_TASK_SLUG, buildPollCloseTask, enqueuePollClose, registerPollCloseTask, runPollClose, shouldAutoResolvePoll } from "./poll/closeJob.js";
29
+ import { resolveEffectivePollOptions } from "./poll/effectivePollOptions.js";
23
30
  import { resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
24
- import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
31
+ import { resolveConsentSourcesRequest } from "./consent/resolveConsentSourcesRequest.js";
32
+ import { buildDefaultOutcomeFields, buildResolvedAtField, buildWinningValuesField } from "./poll/outcomeFields.js";
33
+ import { buildDefaultButtonFields, buildNextLabelField, buildPrevLabelField, buildSubmitLabelField } from "./collections/buttonFields.js";
25
34
  import { evaluateCalc } from "./calc/evaluate.js";
26
35
  import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
27
36
  import { evaluateCondition } from "./conditions/evaluate.js";
28
- import { resolveConsentLinks } from "./consent/resolveConsentLinks.js";
37
+ import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
29
38
  import { captureConsent } from "./consent/captureConsent.js";
30
39
  import { resolveFileRef } from "./uploads/resolveFileRef.js";
31
40
  import { captureFileRef } from "./uploads/captureFileRef.js";
41
+ import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
32
42
  import { registerCollections } from "./plugin/registerCollections.js";
33
43
  import { registerTranslations } from "./plugin/registerTranslations.js";
34
- import { resolvePresentationDescriptors } from "./presentations/registry.js";
44
+ import { resolvePollOptionSources } from "./poll/registry.js";
35
45
  import { defaultIdentify } from "./spam/identify.js";
36
46
  import { createKvRateLimiter } from "./spam/rateLimiter.js";
37
47
  import { resolveSpamConfig } from "./spam/resolveSpam.js";
38
48
  import { defineValidationRule } from "./validation/defineValidationRule.js";
49
+ import { fieldTargetParam } from "./validation/fieldTargetParam.js";
39
50
  import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
40
51
  import { resolveValidationRules } from "./validation/registry.js";
52
+ import { textOfBody } from "./actions/body/textOfBody.js";
53
+ import { applyConsentStatements } from "./consent/applyConsentStatements.js";
54
+ import { consentSourcesField } from "./consent/consentSourcesField.js";
55
+ import { resolveConsentStatements } from "./consent/resolveConsentStatements.js";
56
+ import { departmentsField } from "./email/departmentsField.js";
57
+ import { countryField } from "./fields/builtin/country.js";
58
+ import { stateField } from "./fields/builtin/state.js";
59
+ import { toFormDocument } from "./form/toFormDocument.js";
60
+ import { definePollOptionSource } from "./poll/definePollOptionSource.js";
41
61
  import { valuesFromSearchParams } from "./prefill/valuesFromSearchParams.js";
62
+ import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
42
63
  import { buildRecallResolver, optionLabelsFor } from "./recall/resolver.js";
43
64
  import { defineCaptchaProvider } from "./spam/captcha.js";
44
65
  import { hcaptchaProvider } from "./spam/providers/hcaptcha.js";
45
66
  import { recaptchaProvider } from "./spam/providers/recaptcha.js";
46
67
  import { turnstileProvider } from "./spam/providers/turnstile.js";
68
+ import { createSubmission } from "./submissions/createSubmission.js";
47
69
  import { formatBytes } from "./uploads/formatBytes.js";
48
70
  import { definePlugin } from "payload";
49
71
  //#region src/index.ts
@@ -52,20 +74,27 @@ const formBuilder = definePlugin({
52
74
  order: 50,
53
75
  plugin: ({ config, plugins, ...options }) => {
54
76
  if (options.disabled === true) return config;
55
- const registry = resolveFieldTypes(defaultFieldDefinitions, options.fields);
77
+ const localizeContent = options.localizeContent !== false;
78
+ const uploads = options.uploads ?? false;
79
+ const consentSources = options.consent?.sources;
80
+ const registry = resolveFieldTypes(buildDefaultFieldDefinitions(localizeContent, options.richText?.editor).filter((definition) => (uploads !== false || definition.type !== "file") && (consentSources !== void 0 || definition.type !== "consent")), options.fields);
56
81
  const ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules);
57
- const consentRegistry = resolveConsentSources(defaultConsentSources, options.consentSources);
58
- const presentationRegistry = resolvePresentationDescriptors(defaultPresentationDescriptors, options.presentations);
59
- const actionRegistry = resolveActions(defaultActionDefinitions, options.actions);
60
- const uploads = resolveUploads(options.uploads);
82
+ const fromAddresses = options.email?.fromAddresses;
83
+ const departments = options.email?.departments;
84
+ const actionRegistry = resolveActions(buildDefaultActionDefinitions(localizeContent, options.richText?.bodyEditor ?? options.richText?.editor, fromAddresses, departments), options.actions);
61
85
  const spam = resolveSpamConfig(options.spam);
86
+ const pollSourceRegistry = resolvePollOptionSources(options.poll?.sources);
87
+ const pollTypeRegistry = resolvePollTypes(options.poll?.types);
88
+ config.custom = stashPollOptionSources(config.custom, pollSourceRegistry);
89
+ config.custom = stashPollTypes(config.custom, pollTypeRegistry);
90
+ config.custom = stashFieldTypes(config.custom, registry);
91
+ if (consentSources) config.custom = stashConsentSources(config.custom, consentSources);
62
92
  registerTranslations(config, options.translations);
63
93
  registerCollections({
64
94
  config,
65
95
  registry,
66
96
  ruleRegistry,
67
- consentRegistry,
68
- presentationRegistry,
97
+ consentSources,
69
98
  actionRegistry,
70
99
  richText: options.richText,
71
100
  hasJobsPlugin: Boolean(plugins["@10x-media/jobs"]),
@@ -73,12 +102,23 @@ const formBuilder = definePlugin({
73
102
  uploads,
74
103
  spam,
75
104
  showSubmissionRawFields: options.showSubmissionRawFields ?? false,
105
+ localizeContent,
106
+ resultsAccess: options.results?.access,
107
+ votedCookie: options.poll?.votedCookie === true,
108
+ pollSourceRegistry,
109
+ pollTypeRegistry,
110
+ outcomeFields: options.poll?.outcomeFields,
111
+ buttons: options.buttons,
112
+ response: options.response,
113
+ fromAddresses,
114
+ departments,
115
+ redirectRelationships: options.redirectRelationships,
76
116
  overrides: options.overrides
77
117
  });
78
118
  return config;
79
119
  }
80
120
  });
81
121
  //#endregion
82
- export { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, FORM_UPLOADS_SLUG, SIGNATURE_HEADER, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, buildRecallResolver, buildUploadsCollection, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, createKvRateLimiter, defaultActionDefinitions, defaultBodyConverters, defaultConsentSources, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineConsentSource, defineFormField, defineValidationRule, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fileMimeTypeOptions, formBuilder, formatBytes, hcaptchaProvider, interpolate, normalizeCalc, optionLabelsFor, recaptchaProvider, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentLinks, resolveConsentSources, resolveFileRef, resolveFormResultsRequest, resolvePresentationDescriptors, resolvePublishedVersionRef, resolveSpamConfig, resolveUploads, sanitizeUrl, serializeBody, signPayload, turnstileProvider, valuesFromSearchParams };
122
+ export { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, POLL_CLOSE_TASK_SLUG, SIGNATURE_HEADER, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, applyConsentStatements, buildDefaultActionDefinitions, buildDefaultButtonFields, buildDefaultFieldDefinitions, buildDefaultOutcomeFields, buildNextLabelField, buildPollCloseTask, buildPrevLabelField, buildRecallResolver, buildResolvedAtField, buildSubmitLabelField, buildWinningValuesField, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, consentSourcesField, countryField, createKvRateLimiter, createSubmission, defaultActionDefinitions, defaultBodyConverters, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineFormField, definePollOptionSource, definePollType, defineValidationRule, departmentsField, enqueuePollClose, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fieldKey, fieldTargetParam, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, manualStrategy, mostVotedStrategy, normalizeCalc, optionLabelsFor, pollTypesOf, recaptchaProvider, registerPollCloseTask, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentEntries, resolveConsentSourcesRequest, resolveConsentStatements, resolveDepartmentOptions, resolveEffectivePollOptions, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePollTypes, resolvePublishedVersionRef, resolveSpamConfig, runPollClose, sanitizeUrl, serializeBody, shouldAutoResolvePoll, signPayload, sourceStrategy, stashPollTypes, stateField, textOfBody, toFormDocument, topBucketValues, turnstileProvider, valuesFromSearchParams, votedCookieName };
83
123
 
84
124
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type Config, definePlugin } from 'payload'\nimport type { RichTextBodyOption } from './actions/body/serializeBody'\nimport { defaultActionDefinitions } from './actions/builtin'\nimport type { ActionsConfig } from './actions/registry'\nimport { resolveActions } from './actions/registry'\nimport { resolveUploads, type UploadsOption } from './collections/uploads'\nimport { defaultConsentSources } from './consent/builtin'\nimport type { ConsentSourcesConfig } from './consent/registry'\nimport { resolveConsentSources } from './consent/registry'\nimport type { FormEventSink } from './events/types'\nimport { defaultFieldDefinitions } from './fields/builtin'\nimport { type FieldTypesConfig, resolveFieldTypes } from './fields/registry'\nimport type { CollectionOverrides } from './plugin/collectionOverrides'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { defaultPresentationDescriptors } from './presentations/defaults'\nimport type { PresentationsDescriptorConfig } from './presentations/registry'\nimport { resolvePresentationDescriptors } from './presentations/registry'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport type { SpamOption } from './spam/types'\nimport type { TranslationsOption } from './translations'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules, type ValidationRulesConfig } from './validation/registry'\n\nexport type FormBuilderPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/form-builder/i18n`. Values win\n\t * over the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */\n\tevents?: FormEventSink\n\t/** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tfields?: FieldTypesConfig\n\t/** Add, override, or remove presentations. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tpresentations?: PresentationsDescriptorConfig\n\t/** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\trules?: ValidationRulesConfig\n\t/** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tactions?: ActionsConfig\n\t/**\n\t * Customize how rich text action bodies are rendered. `converters` spread over the default\n\t * Lexical node converters; `serialize` replaces the whole pipeline (e.g. to target chat or\n\t * plain-text channels instead of email HTML).\n\t */\n\trichText?: RichTextBodyOption\n\t/** Add, override, or remove consent source types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tconsentSources?: ConsentSourcesConfig\n\t/** The built-in `form-uploads` collection backing file fields. `false` disables it (bring your own); an object overrides slug/upload/access/fields. */\n\tuploads?: UploadsOption\n\t/** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */\n\tspam?: SpamOption\n\t/**\n\t * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the\n\t * submission admin view. Default `false` — those fields are fully represented by the\n\t * `SubmissionAnswers` UI component and are noisy when shown alongside it.\n\t */\n\tshowSubmissionRawFields?: boolean\n\t/**\n\t * Override individual plugin-managed collections using explicit spreads. Each key accepts a\n\t * `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread\n\t * order per key determines who wins), hooks are appended after the plugin's own hooks, and\n\t * `fields` is a function that receives the default fields and returns the final array so\n\t * additions/removals are always intentional.\n\t */\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t\tuploads?: CollectionOverrides\n\t}\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/form-builder': FormBuilderPluginOptions\n\t}\n}\n\nexport const formBuilder = definePlugin<FormBuilderPluginOptions>({\n\tslug: '@10x-media/form-builder',\n\torder: 50,\n\tplugin: ({ config, plugins, ...options }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tconst registry = resolveFieldTypes(defaultFieldDefinitions, options.fields)\n\t\tconst ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules)\n\t\tconst consentRegistry = resolveConsentSources(defaultConsentSources, options.consentSources)\n\t\tconst presentationRegistry = resolvePresentationDescriptors(\n\t\t\tdefaultPresentationDescriptors,\n\t\t\toptions.presentations\n\t\t)\n\t\tconst actionRegistry = resolveActions(defaultActionDefinitions, options.actions)\n\t\tconst uploads = resolveUploads(options.uploads)\n\t\tconst spam = resolveSpamConfig(options.spam)\n\t\tregisterTranslations(config, options.translations)\n\t\tregisterCollections({\n\t\t\tconfig,\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentRegistry,\n\t\t\tpresentationRegistry,\n\t\t\tactionRegistry,\n\t\t\trichText: options.richText,\n\t\t\thasJobsPlugin: Boolean(plugins['@10x-media/jobs']),\n\t\t\tevents: options.events,\n\t\t\tuploads,\n\t\t\tspam,\n\t\t\tshowSubmissionRawFields: options.showSubmissionRawFields ?? false,\n\t\t\toverrides: options.overrides,\n\t\t})\n\t\treturn config\n\t},\n})\n\nexport type {\n\tBodyConverter,\n\tBodyConverterArgs,\n\tBodyRender,\n} from './actions/body/converters'\nexport { defaultBodyConverters, sanitizeUrl } from './actions/body/converters'\nexport { escapeHtml } from './actions/body/escapeHtml'\nexport type {\n\tBodyContext,\n\tRichTextBodyOption,\n\tSerializeBodyArgs,\n} from './actions/body/serializeBody'\nexport { serializeBody } from './actions/body/serializeBody'\nexport { renderAllValues, renderAllValuesTable } from './actions/body/wildcards'\nexport { defaultActionDefinitions } from './actions/builtin'\nexport type { ActionDefinition, ActionRunArgs, AnyActionDefinition } from './actions/defineAction'\nexport { defineAction } from './actions/defineAction'\nexport type { ActionOption, ActionRegistry, ActionsConfig } from './actions/registry'\nexport { resolveActions } from './actions/registry'\nexport type { ActionResult } from './actions/runActions'\nexport { SIGNATURE_HEADER, signPayload } from './actions/sign'\nexport type {\n\tAggregateFieldResponsesArgs,\n\tAggregateFormResponsesArgs,\n} from './aggregation/aggregateResponses'\nexport {\n\taggregateFieldResponses,\n\taggregateFormResponses,\n\tfieldHasOptions,\n} from './aggregation/aggregateResponses'\nexport { aggregateRowForField, aggregateRowsForFields } from './aggregation/aggregateRows'\nexport type {\n\tResolveResultsRequestArgs,\n\tResolveResultsRequestResult,\n} from './aggregation/resolveResultsRequest'\nexport { resolveFormResultsRequest } from './aggregation/resolveResultsRequest'\nexport type {\n\tAggregationBucket,\n\tAggregationRow,\n\tFieldAggregation,\n\tFieldMeta,\n\tSubmissionStatusFilter,\n} from './aggregation/types'\nexport { calcExpressionOf, computeCalcFields } from './calc/computeCalcFields'\nexport { evaluateCalc } from './calc/evaluate'\nexport { normalizeCalc } from './calc/normalizeCalc'\nexport type { CalcExpression } from './calc/types'\nexport type { UploadsCollectionConfig, UploadsOption } from './collections/uploads'\nexport { buildUploadsCollection, FORM_UPLOADS_SLUG, resolveUploads } from './collections/uploads'\nexport { evaluateCondition } from './conditions/evaluate'\nexport type { FieldCondition } from './conditions/types'\nexport { defaultConsentSources } from './consent/builtin'\nexport type { ConsentProof } from './consent/captureConsent'\nexport { captureConsent } from './consent/captureConsent'\nexport type {\n\tAnyConsentSource,\n\tConsentLink,\n\tConsentResolveArgs,\n\tConsentResolved,\n\tConsentSource,\n} from './consent/defineConsentSource'\nexport { defineConsentSource } from './consent/defineConsentSource'\nexport type {\n\tConsentSourceOption,\n\tConsentSourceRegistry,\n\tConsentSourcesConfig,\n} from './consent/registry'\nexport { resolveConsentSources } from './consent/registry'\nexport { resolveConsentLinks } from './consent/resolveConsentLinks'\nexport { resolvePublishedVersionRef } from './consent/resolvePublishedVersionRef'\nexport { defaultFieldDefinitions, defaultFieldDefinitionsByType } from './fields/builtin'\nexport { fileMimeTypeOptions } from './fields/builtin/file'\nexport { defineFormField } from './fields/defineFormField'\nexport type { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from './fields/registry'\nexport type {\n\tAnyFormFieldDefinition,\n\tFormFieldDefinition,\n\tFormFieldFormat,\n\tFormFieldValidate,\n\tFormFieldValueKind,\n} from './fields/types'\nexport type { PrefillOptions } from './prefill/valuesFromSearchParams'\nexport { valuesFromSearchParams } from './prefill/valuesFromSearchParams'\nexport { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from './presentations/defaults'\nexport type {\n\tPresentationDescriptorOption,\n\tPresentationDescriptorRegistry,\n\tPresentationsDescriptorConfig,\n} from './presentations/registry'\nexport { resolvePresentationDescriptors } from './presentations/registry'\nexport type {\n\tPresentationDensity,\n\tPresentationDescriptor,\n\tPresentationSurface,\n} from './presentations/types'\nexport { interpolate } from './recall/interpolate'\nexport type { RecallResolver } from './recall/resolver'\nexport { buildRecallResolver, optionLabelsFor } from './recall/resolver'\nexport { defineCaptchaProvider } from './spam/captcha'\nexport { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from './spam/constants'\nexport { defaultIdentify } from './spam/identify'\nexport type { HcaptchaProviderOptions } from './spam/providers/hcaptcha'\nexport { hcaptchaProvider } from './spam/providers/hcaptcha'\nexport type { RecaptchaProviderOptions } from './spam/providers/recaptcha'\nexport { recaptchaProvider } from './spam/providers/recaptcha'\nexport type { TurnstileProviderOptions } from './spam/providers/turnstile'\nexport { turnstileProvider } from './spam/providers/turnstile'\nexport { createKvRateLimiter } from './spam/rateLimiter'\nexport { resolveSpamConfig } from './spam/resolveSpam'\nexport type {\n\tCaptchaProvider,\n\tCaptchaVerifyArgs,\n\tIdentifyFn,\n\tRateLimitCheckArgs,\n\tRateLimitConfig,\n\tRateLimiter,\n\tRateLimitResult,\n\tSpamConfig,\n\tSpamMetadataConfig,\n\tSpamOption,\n} from './spam/types'\nexport { captureFileRef } from './uploads/captureFileRef'\nexport { formatBytes } from './uploads/formatBytes'\nexport { resolveFileRef } from './uploads/resolveFileRef'\nexport type { FileFieldConfig, FileRef, FileRefError } from './uploads/types'\nexport { defaultValidationRules, defaultValidationRulesByType } from './validation/builtin'\nexport { defineValidationRule } from './validation/defineValidationRule'\nexport type {\n\tValidationRuleOption,\n\tValidationRuleRegistry,\n\tValidationRulesConfig,\n} from './validation/registry'\nexport type {\n\tAnyValidationRuleDefinition,\n\tValidationRuleDefinition,\n\tValidationRuleResult,\n\tValidationSeverity,\n} from './validation/types'\nexport type { FormBuilderPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFA,MAAa,cAAc,aAAuC;CACjE,MAAM;CACN,OAAO;CACP,SAAS,EAAE,QAAQ,SAAS,GAAG,cAAsB;EACpD,IAAI,QAAQ,aAAa,MACxB,OAAO;EAER,MAAM,WAAW,kBAAkB,yBAAyB,QAAQ,MAAM;EAC1E,MAAM,eAAe,uBAAuB,wBAAwB,QAAQ,KAAK;EACjF,MAAM,kBAAkB,sBAAsB,uBAAuB,QAAQ,cAAc;EAC3F,MAAM,uBAAuB,+BAC5B,gCACA,QAAQ,aACT;EACA,MAAM,iBAAiB,eAAe,0BAA0B,QAAQ,OAAO;EAC/E,MAAM,UAAU,eAAe,QAAQ,OAAO;EAC9C,MAAM,OAAO,kBAAkB,QAAQ,IAAI;EAC3C,qBAAqB,QAAQ,QAAQ,YAAY;EACjD,oBAAoB;GACnB;GACA;GACA;GACA;GACA;GACA;GACA,UAAU,QAAQ;GAClB,eAAe,QAAQ,QAAQ,kBAAkB;GACjD,QAAQ,QAAQ;GAChB;GACA;GACA,yBAAyB,QAAQ,2BAA2B;GAC5D,WAAW,QAAQ;EACpB,CAAC;EACD,OAAO;CACR;AACD,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type CollectionSlug, type Config, definePlugin } from 'payload'\nimport type { RichTextBodyOption } from './actions/body/serializeBody'\nimport { buildDefaultActionDefinitions } from './actions/builtin'\nimport type { FromAddressesResolver } from './actions/fromAddresses'\nimport type { ActionsConfig } from './actions/registry'\nimport { resolveActions } from './actions/registry'\nimport type { FormResultsAccess } from './aggregation/resolveResultsRequest'\nimport type { ButtonsOption } from './collections/buttonFields'\nimport type { ResponseOption } from './collections/redirectFields'\nimport { stashConsentSources } from './consent/resolveConsentEntries'\nimport type { ConsentSourcesResolver } from './consent/types'\nimport type { DepartmentEmailsResolver } from './email/departments'\nimport type { FormEventSink } from './events/types'\nimport { buildDefaultFieldDefinitions } from './fields/builtin'\nimport { type FieldTypesConfig, resolveFieldTypes, stashFieldTypes } from './fields/registry'\nimport type { CollectionOverrides } from './plugin/collectionOverrides'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport type { UploadsOption } from './plugin/uploadsCollection'\nimport type { OutcomeFieldsOverride } from './poll/outcomeFields'\nimport type { PollTypesConfig } from './poll/pollTypeRegistry'\nimport { resolvePollTypes, stashPollTypes } from './poll/pollTypeRegistry'\nimport type { PollOptionSourcesConfig } from './poll/registry'\nimport { resolvePollOptionSources } from './poll/registry'\nimport { stashPollOptionSources } from './poll/resolvePollOptions'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport type { SpamOption } from './spam/types'\nimport type { TranslationsOption } from './translations'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules, type ValidationRulesConfig } from './validation/registry'\n\nexport type FormBuilderPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/form-builder/i18n`. Values win\n\t * over the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */\n\tevents?: FormEventSink\n\t/**\n\t * Content-bearing author fields (labels, placeholders, option labels, action subjects and\n\t * bodies) are localized by default. Payload strips the `localized` flag on hosts without\n\t * `localization` configured, so the default is safe everywhere. Set `false` to keep form\n\t * content single-locale even on localized hosts. Spread-overrides of the prebuilt default\n\t * exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`\n\t * flags from the default-true set; when opting out, derive overrides from\n\t * `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions(false)` instead.\n\t * Consent statements are unaffected either way: they live on the host's own\n\t * `consentSourcesField()`, which carries its own `localized` option.\n\t */\n\tlocalizeContent?: boolean\n\t/** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tfields?: FieldTypesConfig\n\t/** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\trules?: ValidationRulesConfig\n\t/** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tactions?: ActionsConfig\n\t/**\n\t * Customize how the plugin's rich text is authored and rendered. `editor` is the default\n\t * Lexical/richText editor for every plugin richText field (message content, consent\n\t * statement, response message, action bodies); `bodyEditor` overrides the action body\n\t * fields specifically, falling back to `editor`. `converters` spread over the default\n\t * Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to\n\t * target chat or plain-text channels instead of email HTML). A custom `serialize` receives\n\t * the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw\n\t * body off to a renderer like react-email.\n\t */\n\trichText?: RichTextBodyOption\n\t/**\n\t * Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the\n\t * presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped\n\t * resolver, evaluated per request via an endpoint, whose choice is validated at save time only and\n\t * never re-checked when the action sends (the config is admin-authored, not visitor-controlled).\n\t *\n\t * `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,\n\t * neither action has a `from` field and every send uses the email adapter's default sender. The\n\t * intended use is multi-tenant hosts where each tenant may only send from particular addresses\n\t * (derive the tenant from `req`, return its allowed senders). Values are the literal string\n\t * `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).\n\t *\n\t * `departments` turns the `emailTeam` `to` into a select whose options come from the resolver\n\t * (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document\n\t * you own and read it back with `resolveDepartmentOptions`, which resolves each department's address\n\t * for the requesting locale. Because `to` is localized, each admin locale stores its own resolved\n\t * address and a submission's locale selects the address it routes to (Payload-native, no per-send\n\t * lookup). Storing the resolved address, rather than a department id resolved live at send (consent's\n\t * model), is deliberate: the routing target a form was saved with stays audit-stable even if the\n\t * resolver's data later changes, so do not \"fix\" it into a live lookup. Multi-tenant hosts scope\n\t * which document they read by the tenant derived from `req`; absent, `to` stays a plain localized\n\t * text field.\n\t */\n\temail?: { fromAddresses?: FromAddressesResolver; departments?: DepartmentEmailsResolver }\n\t/**\n\t * Where the consent statements a form can reference come from. Absent (the default): no sources,\n\t * so the built-in `consent` field type is not registered at all and authors cannot add a consent\n\t * field with nothing to reference (a developer-registered custom `consent` type via `fields`\n\t * still wins).\n\t *\n\t * `sources` is an async `req`-scoped resolver returning the sources available to this request.\n\t * The intended shape: place `consentSourcesField()` on a collection or global you own and read it\n\t * back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's\n\t * authors only ever see, and their visitors only ever agree to, their own statements. A form\n\t * stores only a source's row `id`; the statement is resolved live per request (see\n\t * `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is\n\t * ever a copy the client could stale or forge.\n\t */\n\tconsent?: { sources: ConsentSourcesResolver }\n\t/**\n\t * Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and\n\t * `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The\n\t * rendered chrome resolves each label as `<Form>` prop, then the stored value, then the\n\t * translated default. `fields` composes them: it receives the three default fields as a\n\t * `{ submit, prev, next }` map with the content localization flag already applied and returns\n\t * the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing\n\t * one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a\n\t * host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.\n\t */\n\tbuttons?: ButtonsOption\n\t/**\n\t * The success-response group. `redirect.fields` composes the fields inside the `response.redirect`\n\t * group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the\n\t * polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's\n\t * final field array, so a host can prepend a custom link field (the pattern most projects already\n\t * have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the\n\t * built-in `url` (+ optional `reference`), unchanged.\n\t *\n\t * The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when\n\t * configured); `toFormDocument` passes the whole `response` group through, so a host that replaces\n\t * `url` with their own link field owns resolving it to a destination in their frontend, the same as\n\t * the internal-reference case.\n\t */\n\tresponse?: ResponseOption\n\t/**\n\t * Collections whose documents `response.redirect` can reference (`response.redirect.reference`),\n\t * letting an author redirect a visitor to an internal document instead of a URL after a\n\t * successful submit. Absent (the default): no `reference` field exists at all, matching today's\n\t * URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not\n\t * a bare `CollectionSlug`), so a host adding a second collection later never changes the stored\n\t * shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves\n\t * the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes\n\t * the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for\n\t * the host to resolve. Mirrors the `redirectRelationships` option of Payload's native\n\t * `plugin-form-builder`.\n\t */\n\tredirectRelationships?: CollectionSlug[]\n\t/**\n\t * File uploads are bring-your-own. Default `false`: no upload collection is involved and the\n\t * built-in `file` field type is removed from the registry, so form authors cannot add a field\n\t * with nowhere to land (a developer-registered custom `file` type via `fields` still wins).\n\t * `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with\n\t * its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when\n\t * absent, and prepends the spam upload hooks.\n\t */\n\tuploads?: UploadsOption\n\t/** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */\n\tspam?: SpamOption\n\t/**\n\t * Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded\n\t * and before anything is served; absent keeps the plugin-default gating (poll opt-in +\n\t * visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against\n\t * the tenant derived from `req` so one tenant's poll counts are never readable under another\n\t * tenant's id. Authenticated callers bypass this seam.\n\t */\n\tresults?: { access?: FormResultsAccess }\n\t/**\n\t * Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each\n\t * successful submission to a poll-enabled form, letting SSR hosts read the voted state via\n\t * `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.\n\t * `sources` registers poll option sources (`definePollOptionSource`), letting authors populate\n\t * a poll's choices from host domain data with stable values; there are no built-ins. With at\n\t * least one source registered, the forms poll group gains an `optionSource` select plus its\n\t * per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.\n\t * `outcomeFields` composes the poll `outcome` group: it receives the two default fields\n\t * (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host\n\t * can swap `winningValues` for its own component (e.g. a relationship picker over the voteable\n\t * records). Membership validation runs server-side regardless, so a swap cannot bypass it.\n\t * `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The\n\t * built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on\n\t * close), and `source` (delegates to the option source) are always registered; a host entry keyed\n\t * by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`\n\t * auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.\n\t */\n\tpoll?: {\n\t\tvotedCookie?: boolean\n\t\tsources?: PollOptionSourcesConfig\n\t\ttypes?: PollTypesConfig\n\t\toutcomeFields?: OutcomeFieldsOverride\n\t}\n\t/**\n\t * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the\n\t * submission admin view. Default `false`, because the `SubmissionAnswers` UI component already\n\t * represents those fields fully and they are noisy shown alongside it.\n\t */\n\tshowSubmissionRawFields?: boolean\n\t/**\n\t * Override individual plugin-managed collections using explicit spreads. Each key accepts a\n\t * `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread\n\t * order per key determines who wins), hooks are appended after the plugin's own hooks, and\n\t * `fields` is a function that receives the default fields and returns the final array so\n\t * additions/removals are always intentional.\n\t */\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/form-builder': FormBuilderPluginOptions\n\t}\n}\n\nexport const formBuilder = definePlugin<FormBuilderPluginOptions>({\n\tslug: '@10x-media/form-builder',\n\torder: 50,\n\tplugin: ({ config, plugins, ...options }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tconst localizeContent = options.localizeContent !== false\n\t\tconst uploads = options.uploads ?? false\n\t\tconst consentSources = options.consent?.sources\n\t\t// A built-in with nowhere to point never enters the registry, so an author is never offered a\n\t\t// field that cannot work: file without an uploads collection has nowhere to store anything,\n\t\t// consent without sources has no statement to reference. An explicit `fields.file` /\n\t\t// `fields.consent` definition remains a developer choice.\n\t\tconst defaultFieldDefinitions = buildDefaultFieldDefinitions(\n\t\t\tlocalizeContent,\n\t\t\toptions.richText?.editor\n\t\t).filter(\n\t\t\t(definition) =>\n\t\t\t\t(uploads !== false || definition.type !== 'file') &&\n\t\t\t\t(consentSources !== undefined || definition.type !== 'consent')\n\t\t)\n\t\tconst registry = resolveFieldTypes(defaultFieldDefinitions, options.fields)\n\t\tconst ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules)\n\t\tconst fromAddresses = options.email?.fromAddresses\n\t\tconst departments = options.email?.departments\n\t\tconst actionRegistry = resolveActions(\n\t\t\tbuildDefaultActionDefinitions(\n\t\t\t\tlocalizeContent,\n\t\t\t\toptions.richText?.bodyEditor ?? options.richText?.editor,\n\t\t\t\tfromAddresses,\n\t\t\t\tdepartments\n\t\t\t),\n\t\t\toptions.actions\n\t\t)\n\t\tconst spam = resolveSpamConfig(options.spam)\n\t\tconst pollSourceRegistry = resolvePollOptionSources(options.poll?.sources)\n\t\tconst pollTypeRegistry = resolvePollTypes(options.poll?.types)\n\t\t// Stashed on config.custom so the root-level resolvePollOptions, resolveEffectivePollOptions,\n\t\t// resolvePollOutcome, and resolveConsentStatements helpers can reach these through\n\t\t// `payload.config` at request time, without threading plugin state through the host's own\n\t\t// server code. The field-type registry rides along so resolveEffectivePollOptions can look up a\n\t\t// results field's definition (and its `resolveOptions`) from a bare `payload` instance.\n\t\tconfig.custom = stashPollOptionSources(config.custom, pollSourceRegistry)\n\t\tconfig.custom = stashPollTypes(config.custom, pollTypeRegistry)\n\t\tconfig.custom = stashFieldTypes(config.custom, registry)\n\t\tif (consentSources) {\n\t\t\tconfig.custom = stashConsentSources(config.custom, consentSources)\n\t\t}\n\t\tregisterTranslations(config, options.translations)\n\t\tregisterCollections({\n\t\t\tconfig,\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tactionRegistry,\n\t\t\trichText: options.richText,\n\t\t\thasJobsPlugin: Boolean(plugins['@10x-media/jobs']),\n\t\t\tevents: options.events,\n\t\t\tuploads,\n\t\t\tspam,\n\t\t\tshowSubmissionRawFields: options.showSubmissionRawFields ?? false,\n\t\t\tlocalizeContent,\n\t\t\tresultsAccess: options.results?.access,\n\t\t\tvotedCookie: options.poll?.votedCookie === true,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields: options.poll?.outcomeFields,\n\t\t\tbuttons: options.buttons,\n\t\t\tresponse: options.response,\n\t\t\tfromAddresses,\n\t\t\tdepartments,\n\t\t\tredirectRelationships: options.redirectRelationships,\n\t\t\toverrides: options.overrides,\n\t\t})\n\t\treturn config\n\t},\n})\n\nexport type {\n\tBodyConverter,\n\tBodyConverterArgs,\n\tBodyRender,\n} from './actions/body/converters'\nexport { defaultBodyConverters, sanitizeUrl } from './actions/body/converters'\nexport { escapeHtml } from './actions/body/escapeHtml'\nexport type {\n\tBodyContext,\n\tRichTextBodyOption,\n\tSerializeBodyArgs,\n} from './actions/body/serializeBody'\nexport { serializeBody } from './actions/body/serializeBody'\nexport { textOfBody } from './actions/body/textOfBody'\nexport { renderAllValues, renderAllValuesTable } from './actions/body/wildcards'\nexport { buildDefaultActionDefinitions, defaultActionDefinitions } from './actions/builtin'\nexport type { ActionDefinition, ActionRunArgs, AnyActionDefinition } from './actions/defineAction'\nexport { defineAction } from './actions/defineAction'\nexport type { FromAddressesResolver, FromAddressOption } from './actions/fromAddresses'\nexport type { ActionOption, ActionRegistry, ActionsConfig } from './actions/registry'\nexport { resolveActions } from './actions/registry'\nexport type { ActionResult } from './actions/runActions'\nexport { SIGNATURE_HEADER, signPayload } from './actions/sign'\nexport type {\n\tAggregateFieldResponsesArgs,\n\tAggregateFormResponsesArgs,\n} from './aggregation/aggregateResponses'\nexport {\n\taggregateFieldResponses,\n\taggregateFormResponses,\n\tfieldHasOptions,\n} from './aggregation/aggregateResponses'\nexport { aggregateRowForField, aggregateRowsForFields } from './aggregation/aggregateRows'\nexport type {\n\tFormResultsAccess,\n\tFormResultsAccessArgs,\n\tResolveResultsRequestArgs,\n\tResolveResultsRequestResult,\n} from './aggregation/resolveResultsRequest'\nexport { resolveFormResultsRequest } from './aggregation/resolveResultsRequest'\nexport type {\n\tAggregationBucket,\n\tAggregationRow,\n\tFieldAggregation,\n\tFieldMeta,\n\tSubmissionStatusFilter,\n} from './aggregation/types'\nexport { calcExpressionOf, computeCalcFields } from './calc/computeCalcFields'\nexport { evaluateCalc } from './calc/evaluate'\nexport { normalizeCalc } from './calc/normalizeCalc'\nexport type { CalcExpression } from './calc/types'\nexport type {\n\tButtonFieldsOverride,\n\tButtonsOption,\n\tDefaultButtonFields,\n} from './collections/buttonFields'\nexport {\n\tbuildDefaultButtonFields,\n\tbuildNextLabelField,\n\tbuildPrevLabelField,\n\tbuildSubmitLabelField,\n} from './collections/buttonFields'\nexport type {\n\tRedirectFieldsOverride,\n\tRedirectOption,\n\tResponseOption,\n} from './collections/redirectFields'\nexport { evaluateCondition } from './conditions/evaluate'\nexport type { FieldCondition } from './conditions/types'\nexport { applyConsentStatements } from './consent/applyConsentStatements'\nexport type { ConsentProof } from './consent/captureConsent'\nexport { captureConsent } from './consent/captureConsent'\nexport type { ConsentSourcesFieldOptions } from './consent/consentSourcesField'\nexport { consentSourcesField } from './consent/consentSourcesField'\nexport type { ResolveConsentEntriesArgs } from './consent/resolveConsentEntries'\nexport { resolveConsentEntries } from './consent/resolveConsentEntries'\nexport type {\n\tConsentSourceOption,\n\tResolveConsentSourcesRequestArgs,\n\tResolveConsentSourcesRequestResult,\n} from './consent/resolveConsentSourcesRequest'\nexport { resolveConsentSourcesRequest } from './consent/resolveConsentSourcesRequest'\nexport type {\n\tConsentStatement,\n\tConsentStatements,\n\tResolveConsentStatementsArgs,\n} from './consent/resolveConsentStatements'\nexport { resolveConsentStatements } from './consent/resolveConsentStatements'\nexport type { ResolvePublishedVersionRefArgs } from './consent/resolvePublishedVersionRef'\nexport { resolvePublishedVersionRef } from './consent/resolvePublishedVersionRef'\nexport type {\n\tConsentSourceEntry,\n\tConsentSourcePage,\n\tConsentSourcesResolver,\n} from './consent/types'\nexport type {\n\tDepartmentEmailsResolver,\n\tDepartmentOption,\n\tResolveDepartmentOptionsArgs,\n\tResolveDepartmentsRequestArgs,\n\tResolveDepartmentsRequestResult,\n} from './email/departments'\nexport { resolveDepartmentOptions } from './email/departments'\nexport type { DepartmentsFieldOptions } from './email/departmentsField'\nexport { departmentsField } from './email/departmentsField'\nexport {\n\tbuildDefaultFieldDefinitions,\n\tdefaultFieldDefinitions,\n\tdefaultFieldDefinitionsByType,\n} from './fields/builtin'\nexport { countryField } from './fields/builtin/country'\nexport { fileMimeTypeOptions } from './fields/builtin/file'\nexport { stateField } from './fields/builtin/state'\nexport { defineFormField } from './fields/defineFormField'\nexport { fieldKey } from './fields/fieldKey'\nexport { localizedIf } from './fields/localizedIf'\nexport type { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from './fields/registry'\nexport type {\n\tAnyFormFieldDefinition,\n\tFormFieldDefinition,\n\tFormFieldFormat,\n\tFormFieldValidate,\n\tFormFieldValueKind,\n\tOmittableSharedField,\n\tResolveFieldOptionsArgs,\n} from './fields/types'\nexport { isPollClosed } from './form/pollState'\nexport type { ToFormDocumentOptions } from './form/toFormDocument'\nexport { toFormDocument } from './form/toFormDocument'\nexport type {\n\tFormButtonSettings,\n\tFormDocument,\n\tFormPollSettings,\n\tFormResponseSettings,\n} from './form/types'\nexport type { UploadsOption } from './plugin/uploadsCollection'\nexport type { PollCloseTaskInput } from './poll/closeJob'\nexport {\n\tbuildPollCloseTask,\n\tenqueuePollClose,\n\tPOLL_CLOSE_TASK_SLUG,\n\tregisterPollCloseTask,\n\trunPollClose,\n\tshouldAutoResolvePoll,\n} from './poll/closeJob'\nexport type {\n\tAnyPollOptionSource,\n\tPollOption,\n\tPollOptionResolveArgs,\n\tPollOptionSource,\n} from './poll/definePollOptionSource'\nexport { definePollOptionSource } from './poll/definePollOptionSource'\nexport type { PollOutcomeStrategy, PollOutcomeStrategyArgs } from './poll/definePollType'\nexport { definePollType } from './poll/definePollType'\nexport type { ResolveEffectivePollOptionsArgs } from './poll/effectivePollOptions'\nexport { resolveEffectivePollOptions } from './poll/effectivePollOptions'\nexport { mostVotedStrategy, topBucketValues } from './poll/mostVoted'\nexport type { DefaultOutcomeFields, OutcomeFieldsOverride } from './poll/outcomeFields'\nexport {\n\tbuildDefaultOutcomeFields,\n\tbuildResolvedAtField,\n\tbuildWinningValuesField,\n} from './poll/outcomeFields'\nexport type { PollTypeRegistry, PollTypesConfig } from './poll/pollTypeRegistry'\nexport {\n\tmanualStrategy,\n\tpollTypesOf,\n\tresolvePollTypes,\n\tsourceStrategy,\n\tstashPollTypes,\n} from './poll/pollTypeRegistry'\nexport type {\n\tPollOptionSourceOption,\n\tPollOptionSourceRegistry,\n\tPollOptionSourcesConfig,\n} from './poll/registry'\nexport { resolvePollOptionSources } from './poll/registry'\nexport type { ResolvePollOptionsArgs } from './poll/resolvePollOptions'\nexport { resolvePollOptions } from './poll/resolvePollOptions'\nexport type { ResolvePollOutcomeArgs } from './poll/resolvePollOutcome'\nexport { resolvePollOutcome } from './poll/resolvePollOutcome'\nexport type { PrefillOptions } from './prefill/valuesFromSearchParams'\nexport { valuesFromSearchParams } from './prefill/valuesFromSearchParams'\nexport { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from './presentations/defaults'\nexport type {\n\tPresentationDensity,\n\tPresentationDescriptor,\n\tPresentationSurface,\n} from './presentations/types'\nexport { interpolate } from './recall/interpolate'\nexport type { RecallResolver } from './recall/resolver'\nexport { buildRecallResolver, optionLabelsFor } from './recall/resolver'\nexport { defineCaptchaProvider } from './spam/captcha'\nexport { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from './spam/constants'\nexport { defaultIdentify } from './spam/identify'\nexport type { HcaptchaProviderOptions } from './spam/providers/hcaptcha'\nexport { hcaptchaProvider } from './spam/providers/hcaptcha'\nexport type { RecaptchaProviderOptions } from './spam/providers/recaptcha'\nexport { recaptchaProvider } from './spam/providers/recaptcha'\nexport type { TurnstileProviderOptions } from './spam/providers/turnstile'\nexport { turnstileProvider } from './spam/providers/turnstile'\nexport { createKvRateLimiter } from './spam/rateLimiter'\nexport { resolveSpamConfig } from './spam/resolveSpam'\nexport type {\n\tCaptchaProvider,\n\tCaptchaVerifyArgs,\n\tIdentifyFn,\n\tRateLimitCheckArgs,\n\tRateLimitConfig,\n\tRateLimiter,\n\tRateLimitResult,\n\tSpamConfig,\n\tSpamMetadataConfig,\n\tSpamOption,\n} from './spam/types'\nexport type { CreatedSubmission, CreateSubmissionArgs } from './submissions/createSubmission'\nexport { createSubmission } from './submissions/createSubmission'\nexport { hasVotedCookie, votedCookieName } from './submissions/votedCookie'\nexport { captureFileRef } from './uploads/captureFileRef'\nexport { formatBytes } from './uploads/formatBytes'\nexport { resolveFileRef } from './uploads/resolveFileRef'\nexport type { FileFieldConfig, FileRef, FileRefError } from './uploads/types'\nexport { defaultValidationRules, defaultValidationRulesByType } from './validation/builtin'\nexport { defineValidationRule } from './validation/defineValidationRule'\nexport type { FieldTargetParamOptions } from './validation/fieldTargetParam'\nexport { fieldTargetParam } from './validation/fieldTargetParam'\nexport type {\n\tValidationRuleOption,\n\tValidationRuleRegistry,\n\tValidationRulesConfig,\n} from './validation/registry'\nexport type {\n\tAnyValidationRuleDefinition,\n\tValidationRuleDefinition,\n\tValidationRuleResult,\n} from './validation/types'\nexport type { FormBuilderPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwNA,MAAa,cAAc,aAAuC;CACjE,MAAM;CACN,OAAO;CACP,SAAS,EAAE,QAAQ,SAAS,GAAG,cAAsB;EACpD,IAAI,QAAQ,aAAa,MACxB,OAAO;EAER,MAAM,kBAAkB,QAAQ,oBAAoB;EACpD,MAAM,UAAU,QAAQ,WAAW;EACnC,MAAM,iBAAiB,QAAQ,SAAS;EAaxC,MAAM,WAAW,kBARe,6BAC/B,iBACA,QAAQ,UAAU,MACnB,EAAE,QACA,gBACC,YAAY,SAAS,WAAW,SAAS,YACzC,mBAAmB,KAAA,KAAa,WAAW,SAAS,UAEE,GAAG,QAAQ,MAAM;EAC1E,MAAM,eAAe,uBAAuB,wBAAwB,QAAQ,KAAK;EACjF,MAAM,gBAAgB,QAAQ,OAAO;EACrC,MAAM,cAAc,QAAQ,OAAO;EACnC,MAAM,iBAAiB,eACtB,8BACC,iBACA,QAAQ,UAAU,cAAc,QAAQ,UAAU,QAClD,eACA,WACD,GACA,QAAQ,OACT;EACA,MAAM,OAAO,kBAAkB,QAAQ,IAAI;EAC3C,MAAM,qBAAqB,yBAAyB,QAAQ,MAAM,OAAO;EACzE,MAAM,mBAAmB,iBAAiB,QAAQ,MAAM,KAAK;EAM7D,OAAO,SAAS,uBAAuB,OAAO,QAAQ,kBAAkB;EACxE,OAAO,SAAS,eAAe,OAAO,QAAQ,gBAAgB;EAC9D,OAAO,SAAS,gBAAgB,OAAO,QAAQ,QAAQ;EACvD,IAAI,gBACH,OAAO,SAAS,oBAAoB,OAAO,QAAQ,cAAc;EAElE,qBAAqB,QAAQ,QAAQ,YAAY;EACjD,oBAAoB;GACnB;GACA;GACA;GACA;GACA;GACA,UAAU,QAAQ;GAClB,eAAe,QAAQ,QAAQ,kBAAkB;GACjD,QAAQ,QAAQ;GAChB;GACA;GACA,yBAAyB,QAAQ,2BAA2B;GAC5D;GACA,eAAe,QAAQ,SAAS;GAChC,aAAa,QAAQ,MAAM,gBAAgB;GAC3C;GACA;GACA,eAAe,QAAQ,MAAM;GAC7B,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB;GACA;GACA,uBAAuB,QAAQ;GAC/B,WAAW,QAAQ;EACpB,CAAC;EACD,OAAO;CACR;AACD,CAAC"}
@@ -0,0 +1,26 @@
1
+ //#region src/plugin/customState.ts
2
+ /** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */
3
+ const CUSTOM_KEY = "@10x-media/form-builder";
4
+ /**
5
+ * Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.
6
+ * Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a
7
+ * `payload` instance and no plugin state, so the plugin parks what they need on the config at boot
8
+ * and they read it back through `payload.config`. Both readers share one key, so the plugin's slice
9
+ * is patched rather than replaced.
10
+ */
11
+ const stashCustomState = (custom, patch) => {
12
+ const existing = custom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === "object" ? custom[CUSTOM_KEY] : {};
13
+ return {
14
+ ...custom ?? {},
15
+ [CUSTOM_KEY]: {
16
+ ...existing,
17
+ ...patch
18
+ }
19
+ };
20
+ };
21
+ /** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */
22
+ const customStateOf = (payload) => payload.config.custom?.[CUSTOM_KEY] ?? {};
23
+ //#endregion
24
+ export { customStateOf, stashCustomState };
25
+
26
+ //# sourceMappingURL=customState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customState.js","names":[],"sources":["../../src/plugin/customState.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n/** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */\nconst CUSTOM_KEY = '@10x-media/form-builder'\n\n/**\n * Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.\n * Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a\n * `payload` instance and no plugin state, so the plugin parks what they need on the config at boot\n * and they read it back through `payload.config`. Both readers share one key, so the plugin's slice\n * is patched rather than replaced.\n */\nexport const stashCustomState = <TState extends Record<string, unknown>>(\n\tcustom: Record<string, unknown> | undefined,\n\tpatch: TState\n): Record<string, unknown> => {\n\tconst existing =\n\t\tcustom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === 'object'\n\t\t\t? (custom[CUSTOM_KEY] as Record<string, unknown>)\n\t\t\t: {}\n\treturn { ...(custom ?? {}), [CUSTOM_KEY]: { ...existing, ...patch } }\n}\n\n/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */\nexport const customStateOf = <TState extends Record<string, unknown>>(\n\tpayload: Payload\n): Partial<TState> => (payload.config.custom?.[CUSTOM_KEY] as Partial<TState> | undefined) ?? {}\n"],"mappings":";;AAGA,MAAM,aAAa;;;;;;;;AASnB,MAAa,oBACZ,QACA,UAC6B;CAC7B,MAAM,WACL,SAAS,eAAe,QAAQ,OAAO,OAAO,gBAAgB,WAC1D,OAAO,cACR,CAAC;CACL,OAAO;EAAE,GAAI,UAAU,CAAC;GAAK,aAAa;GAAE,GAAG;GAAU,GAAG;EAAM;CAAE;AACrE;;AAGA,MAAa,iBACZ,YACsB,QAAQ,OAAO,SAAS,eAA+C,CAAC"}