@10x-media/form-builder 0.1.0-beta.2 → 0.1.0-beta.21

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 (619) hide show
  1. package/CHANGELOG.md +360 -0
  2. package/README.md +7 -5
  3. package/dist/actions/assertNoBlockCollision.js +18 -0
  4. package/dist/actions/assertNoBlockCollision.js.map +1 -0
  5. package/dist/actions/body/converters.d.ts +20 -0
  6. package/dist/actions/body/converters.js +57 -0
  7. package/dist/actions/body/converters.js.map +1 -0
  8. package/dist/actions/body/escapeHtml.d.ts +6 -0
  9. package/dist/actions/body/escapeHtml.js +14 -0
  10. package/dist/actions/body/escapeHtml.js.map +1 -0
  11. package/dist/actions/body/serializeBody.d.ts +55 -0
  12. package/dist/actions/body/serializeBody.js +78 -0
  13. package/dist/actions/body/serializeBody.js.map +1 -0
  14. package/dist/actions/body/serializeSlate.js +31 -0
  15. package/dist/actions/body/serializeSlate.js.map +1 -0
  16. package/dist/actions/body/textOfBody.d.ts +13 -0
  17. package/dist/actions/body/textOfBody.js +35 -0
  18. package/dist/actions/body/textOfBody.js.map +1 -0
  19. package/dist/actions/body/wildcards.d.ts +10 -0
  20. package/dist/actions/body/wildcards.js +33 -0
  21. package/dist/actions/body/wildcards.js.map +1 -0
  22. package/dist/actions/buildActionBlocks.js +12 -9
  23. package/dist/actions/buildActionBlocks.js.map +1 -1
  24. package/dist/actions/builtin/confirmation.js +47 -43
  25. package/dist/actions/builtin/confirmation.js.map +1 -1
  26. package/dist/actions/builtin/emailAction.d.ts +20 -0
  27. package/dist/actions/builtin/emailAction.js +120 -0
  28. package/dist/actions/builtin/emailAction.js.map +1 -0
  29. package/dist/actions/builtin/emailTeam.js +20 -38
  30. package/dist/actions/builtin/emailTeam.js.map +1 -1
  31. package/dist/actions/builtin/index.d.ts +16 -1
  32. package/dist/actions/builtin/index.js +21 -7
  33. package/dist/actions/builtin/index.js.map +1 -1
  34. package/dist/actions/builtin/signedWebhook.js +6 -2
  35. package/dist/actions/builtin/signedWebhook.js.map +1 -1
  36. package/dist/actions/defineAction.d.ts +17 -5
  37. package/dist/actions/defineAction.js.map +1 -1
  38. package/dist/actions/dispatch.js +51 -6
  39. package/dist/actions/dispatch.js.map +1 -1
  40. package/dist/actions/dispatchContext.js +13 -0
  41. package/dist/actions/dispatchContext.js.map +1 -0
  42. package/dist/actions/emailRecipients.d.ts +12 -0
  43. package/dist/actions/emailRecipients.js +146 -0
  44. package/dist/actions/emailRecipients.js.map +1 -0
  45. package/dist/actions/fromAddresses.d.ts +37 -0
  46. package/dist/actions/fromAddresses.js +131 -0
  47. package/dist/actions/fromAddresses.js.map +1 -0
  48. package/dist/actions/recipientSources.d.ts +34 -0
  49. package/dist/actions/recipientSources.js +11 -0
  50. package/dist/actions/recipientSources.js.map +1 -0
  51. package/dist/actions/registry.d.ts +2 -1
  52. package/dist/actions/registry.js +5 -7
  53. package/dist/actions/registry.js.map +1 -1
  54. package/dist/actions/runActions.js +10 -1
  55. package/dist/actions/runActions.js.map +1 -1
  56. package/dist/actions/task.js +47 -16
  57. package/dist/actions/task.js.map +1 -1
  58. package/dist/aggregation/aggregateResponses.d.ts +9 -0
  59. package/dist/aggregation/aggregateResponses.js +8 -14
  60. package/dist/aggregation/aggregateResponses.js.map +1 -1
  61. package/dist/aggregation/resolveResultsRequest.d.ts +41 -6
  62. package/dist/aggregation/resolveResultsRequest.js +97 -11
  63. package/dist/aggregation/resolveResultsRequest.js.map +1 -1
  64. package/dist/calc/computeCalcFields.d.ts +5 -3
  65. package/dist/calc/computeCalcFields.js +6 -4
  66. package/dist/calc/computeCalcFields.js.map +1 -1
  67. package/dist/calc/evaluate.d.ts +26 -3
  68. package/dist/calc/evaluate.js +34 -13
  69. package/dist/calc/evaluate.js.map +1 -1
  70. package/dist/calc/formatCalc.d.ts +11 -0
  71. package/dist/calc/formatCalc.js +35 -0
  72. package/dist/calc/formatCalc.js.map +1 -0
  73. package/dist/calc/formatCalcValue.d.ts +17 -0
  74. package/dist/calc/formatCalcValue.js +17 -0
  75. package/dist/calc/formatCalcValue.js.map +1 -0
  76. package/dist/calc/normalizeCalc.d.ts +17 -3
  77. package/dist/calc/normalizeCalc.js +42 -33
  78. package/dist/calc/normalizeCalc.js.map +1 -1
  79. package/dist/calc/registry.d.ts +43 -0
  80. package/dist/calc/registry.js +27 -0
  81. package/dist/calc/registry.js.map +1 -0
  82. package/dist/calc/resolveCalcContext.d.ts +36 -0
  83. package/dist/calc/resolveCalcContext.js +87 -0
  84. package/dist/calc/resolveCalcContext.js.map +1 -0
  85. package/dist/calc/types.d.ts +25 -4
  86. package/dist/calc/types.js +23 -0
  87. package/dist/calc/types.js.map +1 -0
  88. package/dist/client/ByteSizeField.d.ts +29 -0
  89. package/dist/client/ByteSizeField.js +58 -0
  90. package/dist/client/ByteSizeField.js.map +1 -0
  91. package/dist/client/CalcExpressionBuilder.d.ts +20 -0
  92. package/dist/client/CalcExpressionBuilder.js +890 -0
  93. package/dist/client/CalcExpressionBuilder.js.map +1 -0
  94. package/dist/client/ClosePollButton.d.ts +15 -0
  95. package/dist/client/ClosePollButton.js +80 -0
  96. package/dist/client/ClosePollButton.js.map +1 -0
  97. package/dist/client/CondensedArray.d.ts +15 -0
  98. package/dist/client/CondensedArray.js +97 -0
  99. package/dist/client/CondensedArray.js.map +1 -0
  100. package/dist/client/ConditionBuilder.js +2 -1
  101. package/dist/client/ConditionBuilder.js.map +1 -1
  102. package/dist/client/ConsentBlockLabel.d.ts +15 -0
  103. package/dist/client/ConsentBlockLabel.js +71 -0
  104. package/dist/client/ConsentBlockLabel.js.map +1 -0
  105. package/dist/client/ConsentSourceRowLabel.d.ts +9 -0
  106. package/dist/client/ConsentSourceRowLabel.js +21 -0
  107. package/dist/client/ConsentSourceRowLabel.js.map +1 -0
  108. package/dist/client/EndpointOptionsSelect.d.ts +55 -0
  109. package/dist/client/EndpointOptionsSelect.js +112 -0
  110. package/dist/client/EndpointOptionsSelect.js.map +1 -0
  111. package/dist/client/FieldBlockLabel.d.ts +18 -0
  112. package/dist/client/FieldBlockLabel.js +34 -0
  113. package/dist/client/FieldBlockLabel.js.map +1 -0
  114. package/dist/client/FieldNameSelect.d.ts +37 -0
  115. package/dist/client/FieldNameSelect.js +72 -0
  116. package/dist/client/FieldNameSelect.js.map +1 -0
  117. package/dist/client/FlowBuilder.d.ts +2 -2
  118. package/dist/client/FlowBuilder.js +137 -88
  119. package/dist/client/FlowBuilder.js.map +1 -1
  120. package/dist/client/FormConditionField.js +1 -4
  121. package/dist/client/FormConditionField.js.map +1 -1
  122. package/dist/client/RecipientsSelect.d.ts +37 -0
  123. package/dist/client/RecipientsSelect.js +197 -0
  124. package/dist/client/RecipientsSelect.js.map +1 -0
  125. package/dist/client/RuleDescription.d.ts +21 -0
  126. package/dist/client/RuleDescription.js +19 -0
  127. package/dist/client/RuleDescription.js.map +1 -0
  128. package/dist/client/admin.css +557 -0
  129. package/dist/client/endpointOptions.d.ts +11 -0
  130. package/dist/client/endpointOptions.js +38 -0
  131. package/dist/client/endpointOptions.js.map +1 -0
  132. package/dist/client/flowAuthoring.js +142 -0
  133. package/dist/client/flowAuthoring.js.map +1 -0
  134. package/dist/client/synthesizeClientField.js +21 -10
  135. package/dist/client/synthesizeClientField.js.map +1 -1
  136. package/dist/client/toStaticLabel.js +13 -0
  137. package/dist/client/toStaticLabel.js.map +1 -0
  138. package/dist/collections/buttonFields.d.ts +34 -0
  139. package/dist/collections/buttonFields.js +35 -0
  140. package/dist/collections/buttonFields.js.map +1 -0
  141. package/dist/collections/cells/FieldCountCell.d.ts +15 -0
  142. package/dist/collections/cells/FieldCountCell.js +18 -0
  143. package/dist/collections/cells/FieldCountCell.js.map +1 -0
  144. package/dist/collections/cells/FlowStepsCell.d.ts +14 -0
  145. package/dist/collections/cells/FlowStepsCell.js +17 -0
  146. package/dist/collections/cells/FlowStepsCell.js.map +1 -0
  147. package/dist/collections/formSubmissions.js +114 -28
  148. package/dist/collections/formSubmissions.js.map +1 -1
  149. package/dist/collections/forms.js +449 -112
  150. package/dist/collections/forms.js.map +1 -1
  151. package/dist/collections/formsEndpoints.js +106 -0
  152. package/dist/collections/formsEndpoints.js.map +1 -0
  153. package/dist/collections/redirectFields.d.ts +29 -0
  154. package/dist/collections/settingsFields.d.ts +31 -0
  155. package/dist/collections/settingsFields.js +45 -0
  156. package/dist/collections/settingsFields.js.map +1 -0
  157. package/dist/conditions/conditionType.js +9 -2
  158. package/dist/conditions/conditionType.js.map +1 -1
  159. package/dist/conditions/evaluate.js +1 -1
  160. package/dist/conditions/evaluate.js.map +1 -1
  161. package/dist/conditions/fieldTypes.d.ts +3 -1
  162. package/dist/conditions/fieldTypes.js +4 -1
  163. package/dist/conditions/fieldTypes.js.map +1 -1
  164. package/dist/conditions/normalizeConditions.js +20 -6
  165. package/dist/conditions/normalizeConditions.js.map +1 -1
  166. package/dist/consent/applyConsentStatements.d.ts +14 -0
  167. package/dist/consent/applyConsentStatements.js +17 -0
  168. package/dist/consent/applyConsentStatements.js.map +1 -0
  169. package/dist/consent/captureConsent.d.ts +39 -11
  170. package/dist/consent/captureConsent.js +63 -13
  171. package/dist/consent/captureConsent.js.map +1 -1
  172. package/dist/consent/consentSourcesField.d.ts +66 -0
  173. package/dist/consent/consentSourcesField.js +98 -0
  174. package/dist/consent/consentSourcesField.js.map +1 -0
  175. package/dist/consent/effectiveStatement.js +16 -0
  176. package/dist/consent/effectiveStatement.js.map +1 -0
  177. package/dist/consent/resolveConsentEntries.d.ts +24 -0
  178. package/dist/consent/resolveConsentEntries.js +40 -0
  179. package/dist/consent/resolveConsentEntries.js.map +1 -0
  180. package/dist/consent/resolveConsentSourcesRequest.d.ts +37 -0
  181. package/dist/consent/resolveConsentSourcesRequest.js +54 -0
  182. package/dist/consent/resolveConsentSourcesRequest.js.map +1 -0
  183. package/dist/consent/resolveConsentStatements.d.ts +45 -0
  184. package/dist/consent/resolveConsentStatements.js +46 -0
  185. package/dist/consent/resolveConsentStatements.js.map +1 -0
  186. package/dist/consent/resolvePublishedVersionRef.d.ts +17 -11
  187. package/dist/consent/resolvePublishedVersionRef.js +13 -10
  188. package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
  189. package/dist/consent/types.d.ts +69 -0
  190. package/dist/context/formContext.d.ts +30 -0
  191. package/dist/context/formContext.js +54 -0
  192. package/dist/context/formContext.js.map +1 -0
  193. package/dist/email/departments.d.ts +59 -0
  194. package/dist/email/departments.js +87 -0
  195. package/dist/email/departments.js.map +1 -0
  196. package/dist/email/departmentsField.d.ts +53 -0
  197. package/dist/email/departmentsField.js +73 -0
  198. package/dist/email/departmentsField.js.map +1 -0
  199. package/dist/exports/client.d.ts +14 -1
  200. package/dist/exports/client.js +14 -1
  201. package/dist/exports/i18n.d.ts +5 -2
  202. package/dist/exports/i18n.js +5 -2
  203. package/dist/exports/react.d.ts +34 -10
  204. package/dist/exports/react.js +24 -4
  205. package/dist/exports/rsc.d.ts +10 -1
  206. package/dist/exports/rsc.js +10 -1
  207. package/dist/exports/types.d.ts +20 -12
  208. package/dist/fields/buildFieldBlocks.js +46 -25
  209. package/dist/fields/buildFieldBlocks.js.map +1 -1
  210. package/dist/fields/builtin/calculation.d.ts +17 -0
  211. package/dist/fields/builtin/calculation.js +193 -18
  212. package/dist/fields/builtin/calculation.js.map +1 -1
  213. package/dist/fields/builtin/checkbox.js +23 -0
  214. package/dist/fields/builtin/checkbox.js.map +1 -1
  215. package/dist/fields/builtin/consent.js +49 -14
  216. package/dist/fields/builtin/consent.js.map +1 -1
  217. package/dist/fields/builtin/country.d.ts +13 -0
  218. package/dist/fields/builtin/country.js +30 -0
  219. package/dist/fields/builtin/country.js.map +1 -0
  220. package/dist/fields/builtin/date.js +31 -0
  221. package/dist/fields/builtin/date.js.map +1 -0
  222. package/dist/fields/builtin/email.js +8 -1
  223. package/dist/fields/builtin/email.js.map +1 -1
  224. package/dist/fields/builtin/file.d.ts +15 -0
  225. package/dist/fields/builtin/file.js +95 -8
  226. package/dist/fields/builtin/file.js.map +1 -1
  227. package/dist/fields/builtin/index.d.ts +30 -0
  228. package/dist/fields/builtin/index.js +37 -10
  229. package/dist/fields/builtin/index.js.map +1 -1
  230. package/dist/fields/builtin/message.js +30 -0
  231. package/dist/fields/builtin/message.js.map +1 -0
  232. package/dist/fields/builtin/repeater.js +8 -3
  233. package/dist/fields/builtin/repeater.js.map +1 -1
  234. package/dist/fields/builtin/select.js +28 -4
  235. package/dist/fields/builtin/select.js.map +1 -1
  236. package/dist/fields/builtin/state.d.ts +13 -0
  237. package/dist/fields/builtin/state.js +30 -0
  238. package/dist/fields/builtin/state.js.map +1 -0
  239. package/dist/fields/builtin/text.js +7 -0
  240. package/dist/fields/builtin/text.js.map +1 -1
  241. package/dist/fields/data/regions.d.ts +21 -0
  242. package/dist/fields/data/regions.js +1238 -0
  243. package/dist/fields/data/regions.js.map +1 -0
  244. package/dist/fields/fieldKey.d.ts +15 -0
  245. package/dist/fields/fieldKey.js +16 -0
  246. package/dist/fields/fieldKey.js.map +1 -0
  247. package/dist/fields/fieldNamesOfType.js +30 -0
  248. package/dist/fields/fieldNamesOfType.js.map +1 -0
  249. package/dist/fields/instanceOptions.js +20 -0
  250. package/dist/fields/instanceOptions.js.map +1 -0
  251. package/dist/fields/localizedIf.d.ts +13 -0
  252. package/dist/fields/localizedIf.js +12 -0
  253. package/dist/fields/localizedIf.js.map +1 -0
  254. package/dist/fields/registry.d.ts +3 -1
  255. package/dist/fields/registry.js +23 -8
  256. package/dist/fields/registry.js.map +1 -1
  257. package/dist/fields/sharedConfig.js +125 -59
  258. package/dist/fields/sharedConfig.js.map +1 -1
  259. package/dist/fields/types.d.ts +78 -9
  260. package/dist/flow/engine.d.ts +6 -4
  261. package/dist/flow/engine.js +11 -6
  262. package/dist/flow/engine.js.map +1 -1
  263. package/dist/flow/normalizeFlow.js +28 -9
  264. package/dist/flow/normalizeFlow.js.map +1 -1
  265. package/dist/flow/stepLabel.js +15 -0
  266. package/dist/flow/stepLabel.js.map +1 -0
  267. package/dist/flow/types.d.ts +12 -3
  268. package/dist/flow/types.js +11 -0
  269. package/dist/flow/types.js.map +1 -0
  270. package/dist/form/pollState.d.ts +23 -0
  271. package/dist/form/pollState.js +17 -0
  272. package/dist/form/pollState.js.map +1 -0
  273. package/dist/form/toFormDocument.d.ts +110 -0
  274. package/dist/form/toFormDocument.js +89 -0
  275. package/dist/form/toFormDocument.js.map +1 -0
  276. package/dist/form/types.d.ts +73 -0
  277. package/dist/index.d.ts +67 -61
  278. package/dist/index.js +120 -25
  279. package/dist/index.js.map +1 -1
  280. package/dist/options.d.ts +281 -0
  281. package/dist/plugin/applyRegistryConfig.d.ts +11 -0
  282. package/dist/plugin/applyRegistryConfig.js +20 -0
  283. package/dist/plugin/applyRegistryConfig.js.map +1 -0
  284. package/dist/plugin/customState.js +26 -0
  285. package/dist/plugin/customState.js.map +1 -0
  286. package/dist/plugin/registerCollections.js +43 -40
  287. package/dist/plugin/registerCollections.js.map +1 -1
  288. package/dist/plugin/uploadsCollection.d.ts +16 -0
  289. package/dist/plugin/uploadsCollection.js +53 -0
  290. package/dist/plugin/uploadsCollection.js.map +1 -0
  291. package/dist/poll/applyPollOptions.js +18 -0
  292. package/dist/poll/applyPollOptions.js.map +1 -0
  293. package/dist/poll/buildPollOptionSourceFields.js +50 -0
  294. package/dist/poll/buildPollOptionSourceFields.js.map +1 -0
  295. package/dist/poll/closeJob.d.ts +53 -0
  296. package/dist/poll/closeJob.js +121 -0
  297. package/dist/poll/closeJob.js.map +1 -0
  298. package/dist/poll/definePollOptionSource.d.ts +44 -0
  299. package/dist/poll/definePollOptionSource.js +6 -0
  300. package/dist/poll/definePollOptionSource.js.map +1 -0
  301. package/dist/poll/definePollType.d.ts +34 -0
  302. package/dist/poll/definePollType.js +6 -0
  303. package/dist/poll/definePollType.js.map +1 -0
  304. package/dist/poll/effectivePollOptions.d.ts +38 -0
  305. package/dist/poll/effectivePollOptions.js +64 -0
  306. package/dist/poll/effectivePollOptions.js.map +1 -0
  307. package/dist/poll/mostVoted.d.ts +21 -0
  308. package/dist/poll/mostVoted.js +32 -0
  309. package/dist/poll/mostVoted.js.map +1 -0
  310. package/dist/poll/outcomeBeforeChange.js +91 -0
  311. package/dist/poll/outcomeBeforeChange.js.map +1 -0
  312. package/dist/poll/outcomeFields.d.ts +38 -0
  313. package/dist/poll/outcomeFields.js +52 -0
  314. package/dist/poll/outcomeFields.js.map +1 -0
  315. package/dist/poll/pollTypeRegistry.d.ts +34 -0
  316. package/dist/poll/pollTypeRegistry.js +69 -0
  317. package/dist/poll/pollTypeRegistry.js.map +1 -0
  318. package/dist/poll/registry.d.ts +17 -0
  319. package/dist/poll/registry.js +12 -0
  320. package/dist/poll/registry.js.map +1 -0
  321. package/dist/poll/resolvePollCloseRequest.js +106 -0
  322. package/dist/poll/resolvePollCloseRequest.js.map +1 -0
  323. package/dist/poll/resolvePollOptions.d.ts +29 -0
  324. package/dist/poll/resolvePollOptions.js +52 -0
  325. package/dist/poll/resolvePollOptions.js.map +1 -0
  326. package/dist/poll/resolvePollOptionsRequest.js +50 -0
  327. package/dist/poll/resolvePollOptionsRequest.js.map +1 -0
  328. package/dist/poll/resolvePollOutcome.d.ts +40 -0
  329. package/dist/poll/resolvePollOutcome.js +90 -0
  330. package/dist/poll/resolvePollOutcome.js.map +1 -0
  331. package/dist/poll/resultsField.js +21 -0
  332. package/dist/poll/resultsField.js.map +1 -0
  333. package/dist/poll/votes/aggregateFromVotes.d.ts +27 -0
  334. package/dist/poll/votes/aggregateFromVotes.js +54 -0
  335. package/dist/poll/votes/aggregateFromVotes.js.map +1 -0
  336. package/dist/poll/votes/answerValues.js +16 -0
  337. package/dist/poll/votes/answerValues.js.map +1 -0
  338. package/dist/poll/votes/bumpPollVote.js +88 -0
  339. package/dist/poll/votes/bumpPollVote.js.map +1 -0
  340. package/dist/poll/votes/recountPollVotes.d.ts +20 -0
  341. package/dist/poll/votes/recountPollVotes.js +63 -0
  342. package/dist/poll/votes/recountPollVotes.js.map +1 -0
  343. package/dist/poll/votes/voteTallyHook.js +76 -0
  344. package/dist/poll/votes/voteTallyHook.js.map +1 -0
  345. package/dist/poll/votes/votesCollection.d.ts +19 -0
  346. package/dist/poll/votes/votesCollection.js +89 -0
  347. package/dist/poll/votes/votesCollection.js.map +1 -0
  348. package/dist/prefill/valuesFromSearchParams.js +5 -9
  349. package/dist/prefill/valuesFromSearchParams.js.map +1 -1
  350. package/dist/presentations/types.d.ts +3 -2
  351. package/dist/react/Form.d.ts +77 -35
  352. package/dist/react/Form.js +368 -222
  353. package/dist/react/Form.js.map +1 -1
  354. package/dist/react/FormContext.d.ts +51 -1
  355. package/dist/react/FormContext.js.map +1 -1
  356. package/dist/react/FormControls.d.ts +55 -0
  357. package/dist/react/FormControls.js +56 -0
  358. package/dist/react/FormControls.js.map +1 -0
  359. package/dist/react/FormFields.d.ts +18 -0
  360. package/dist/react/FormFields.js +114 -0
  361. package/dist/react/FormFields.js.map +1 -0
  362. package/dist/react/FormLayout.d.ts +4 -2
  363. package/dist/react/FormLayout.js +3 -2
  364. package/dist/react/FormLayout.js.map +1 -1
  365. package/dist/react/FormResults.d.ts +8 -3
  366. package/dist/react/FormResults.js +50 -29
  367. package/dist/react/FormResults.js.map +1 -1
  368. package/dist/react/FormSteps.d.ts +17 -0
  369. package/dist/react/FormSteps.js +35 -0
  370. package/dist/react/FormSteps.js.map +1 -0
  371. package/dist/react/Poll.d.ts +40 -6
  372. package/dist/react/Poll.js +137 -33
  373. package/dist/react/Poll.js.map +1 -1
  374. package/dist/react/adapters.d.ts +35 -0
  375. package/dist/react/adapters.js +11 -0
  376. package/dist/react/adapters.js.map +1 -0
  377. package/dist/react/captcha/HcaptchaCaptcha.d.ts +31 -0
  378. package/dist/react/captcha/HcaptchaCaptcha.js +53 -0
  379. package/dist/react/captcha/HcaptchaCaptcha.js.map +1 -0
  380. package/dist/react/captcha/RecaptchaCaptcha.d.ts +44 -0
  381. package/dist/react/captcha/RecaptchaCaptcha.js +93 -0
  382. package/dist/react/captcha/RecaptchaCaptcha.js.map +1 -0
  383. package/dist/react/captcha/TurnstileCaptcha.d.ts +31 -0
  384. package/dist/react/captcha/TurnstileCaptcha.js +53 -0
  385. package/dist/react/captcha/TurnstileCaptcha.js.map +1 -0
  386. package/dist/react/captcha/types.d.ts +8 -0
  387. package/dist/react/captcha/useCaptchaScript.js +63 -0
  388. package/dist/react/captcha/useCaptchaScript.js.map +1 -0
  389. package/dist/react/captcha/vendors.js +8 -0
  390. package/dist/react/captcha/vendors.js.map +1 -0
  391. package/dist/react/contract.d.ts +2 -3
  392. package/dist/react/contract.js.map +1 -1
  393. package/dist/react/fetchResults.d.ts +1 -1
  394. package/dist/react/fetchResults.js +1 -1
  395. package/dist/react/fetchResults.js.map +1 -1
  396. package/dist/react/presentation/DialogSurface.js +1 -4
  397. package/dist/react/presentation/DialogSurface.js.map +1 -1
  398. package/dist/react/primitives/Checkbox.d.ts +6 -2
  399. package/dist/react/primitives/Checkbox.js +4 -2
  400. package/dist/react/primitives/Checkbox.js.map +1 -1
  401. package/dist/react/primitives/ChoiceGroup.d.ts +40 -0
  402. package/dist/react/primitives/ChoiceGroup.js +33 -0
  403. package/dist/react/primitives/ChoiceGroup.js.map +1 -0
  404. package/dist/react/primitives/FieldShell.d.ts +13 -5
  405. package/dist/react/primitives/FieldShell.js +35 -32
  406. package/dist/react/primitives/FieldShell.js.map +1 -1
  407. package/dist/react/primitives/Input.d.ts +4 -2
  408. package/dist/react/primitives/Input.js +2 -1
  409. package/dist/react/primitives/Input.js.map +1 -1
  410. package/dist/react/renderers/calculation.js +7 -5
  411. package/dist/react/renderers/calculation.js.map +1 -1
  412. package/dist/react/renderers/checkbox.js +3 -5
  413. package/dist/react/renderers/checkbox.js.map +1 -1
  414. package/dist/react/renderers/consent.js +84 -36
  415. package/dist/react/renderers/consent.js.map +1 -1
  416. package/dist/react/renderers/date.js +33 -0
  417. package/dist/react/renderers/date.js.map +1 -0
  418. package/dist/react/renderers/email.js +4 -5
  419. package/dist/react/renderers/email.js.map +1 -1
  420. package/dist/react/renderers/file.js +29 -14
  421. package/dist/react/renderers/file.js.map +1 -1
  422. package/dist/react/renderers/index.js +7 -0
  423. package/dist/react/renderers/index.js.map +1 -1
  424. package/dist/react/renderers/message.js +41 -0
  425. package/dist/react/renderers/message.js.map +1 -0
  426. package/dist/react/renderers/number.js +1 -4
  427. package/dist/react/renderers/number.js.map +1 -1
  428. package/dist/react/renderers/region.js +43 -0
  429. package/dist/react/renderers/region.js.map +1 -0
  430. package/dist/react/renderers/repeater.js +32 -14
  431. package/dist/react/renderers/repeater.js.map +1 -1
  432. package/dist/react/renderers/select.js +21 -6
  433. package/dist/react/renderers/select.js.map +1 -1
  434. package/dist/react/renderers/text.js +4 -5
  435. package/dist/react/renderers/text.js.map +1 -1
  436. package/dist/react/renderers/textarea.js +1 -4
  437. package/dist/react/renderers/textarea.js.map +1 -1
  438. package/dist/react/state.d.ts +46 -3
  439. package/dist/react/state.js +73 -10
  440. package/dist/react/state.js.map +1 -1
  441. package/dist/react/submitForm.js +1 -1
  442. package/dist/react/submitForm.js.map +1 -1
  443. package/dist/react/uploadFile.d.ts +2 -2
  444. package/dist/react/uploadFile.js +1 -1
  445. package/dist/react/uploadFile.js.map +1 -1
  446. package/dist/react/useCalcValues.d.ts +10 -0
  447. package/dist/react/useCalcValues.js +13 -0
  448. package/dist/react/useCalcValues.js.map +1 -0
  449. package/dist/react/useField.d.ts +0 -1
  450. package/dist/react/useField.js +7 -6
  451. package/dist/react/useField.js.map +1 -1
  452. package/dist/react/useFormState.d.ts +1 -1
  453. package/dist/react/useFormState.js +1 -1
  454. package/dist/react/useFormState.js.map +1 -1
  455. package/dist/react/validateField.js +3 -6
  456. package/dist/react/validateField.js.map +1 -1
  457. package/dist/recall/interpolate.d.ts +4 -3
  458. package/dist/recall/interpolate.js +5 -4
  459. package/dist/recall/interpolate.js.map +1 -1
  460. package/dist/recall/resolver.d.ts +1 -1
  461. package/dist/recall/resolver.js +15 -3
  462. package/dist/recall/resolver.js.map +1 -1
  463. package/dist/spam/captcha.d.ts +4 -3
  464. package/dist/spam/captcha.js +4 -3
  465. package/dist/spam/captcha.js.map +1 -1
  466. package/dist/spam/clientIp.js +9 -0
  467. package/dist/spam/clientIp.js.map +1 -0
  468. package/dist/spam/constants.js +13 -1
  469. package/dist/spam/constants.js.map +1 -1
  470. package/dist/spam/identify.js +3 -6
  471. package/dist/spam/identify.js.map +1 -1
  472. package/dist/spam/providers/hcaptcha.d.ts +17 -0
  473. package/dist/spam/providers/hcaptcha.js +18 -0
  474. package/dist/spam/providers/hcaptcha.js.map +1 -0
  475. package/dist/spam/providers/recaptcha.d.ts +23 -0
  476. package/dist/spam/providers/recaptcha.js +23 -0
  477. package/dist/spam/providers/recaptcha.js.map +1 -0
  478. package/dist/spam/providers/siteverify.js +34 -0
  479. package/dist/spam/providers/siteverify.js.map +1 -0
  480. package/dist/spam/providers/turnstile.d.ts +17 -0
  481. package/dist/spam/providers/turnstile.js +18 -0
  482. package/dist/spam/providers/turnstile.js.map +1 -0
  483. package/dist/spam/resolveSpam.js +2 -1
  484. package/dist/spam/resolveSpam.js.map +1 -1
  485. package/dist/spam/spamGuard.js +25 -11
  486. package/dist/spam/spamGuard.js.map +1 -1
  487. package/dist/spam/types.d.ts +19 -4
  488. package/dist/submissions/SubmissionAnswers.js +6 -2
  489. package/dist/submissions/SubmissionAnswers.js.map +1 -1
  490. package/dist/submissions/SubmissionAnswersClient.js +100 -64
  491. package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
  492. package/dist/submissions/coerceBoolean.js +14 -0
  493. package/dist/submissions/coerceBoolean.js.map +1 -0
  494. package/dist/submissions/createSubmission.d.ts +36 -0
  495. package/dist/submissions/createSubmission.js +26 -0
  496. package/dist/submissions/createSubmission.js.map +1 -0
  497. package/dist/submissions/formIdOf.js +13 -0
  498. package/dist/submissions/formIdOf.js.map +1 -0
  499. package/dist/submissions/resolveVotedSubmission.d.ts +27 -0
  500. package/dist/submissions/resolveVotedSubmission.js +51 -0
  501. package/dist/submissions/resolveVotedSubmission.js.map +1 -0
  502. package/dist/submissions/runSubmission.d.ts +10 -0
  503. package/dist/submissions/runSubmission.js +104 -54
  504. package/dist/submissions/runSubmission.js.map +1 -1
  505. package/dist/submissions/types.d.ts +11 -4
  506. package/dist/submissions/validateSubmission.js +99 -13
  507. package/dist/submissions/validateSubmission.js.map +1 -1
  508. package/dist/submissions/verifyContext.js +35 -0
  509. package/dist/submissions/verifyContext.js.map +1 -0
  510. package/dist/submissions/voteChangeEndpoint.js +105 -0
  511. package/dist/submissions/voteChangeEndpoint.js.map +1 -0
  512. package/dist/submissions/votedCookie.d.ts +15 -0
  513. package/dist/submissions/votedCookie.js +74 -0
  514. package/dist/submissions/votedCookie.js.map +1 -0
  515. package/dist/translations/clientRuntimeKeys.d.ts +17 -0
  516. package/dist/translations/clientRuntimeKeys.js +48 -0
  517. package/dist/translations/clientRuntimeKeys.js.map +1 -0
  518. package/dist/translations/de.d.ts +12 -0
  519. package/dist/translations/de.js +380 -0
  520. package/dist/translations/de.js.map +1 -0
  521. package/dist/translations/en.js +250 -28
  522. package/dist/translations/en.js.map +1 -1
  523. package/dist/translations/index.d.ts +14 -5
  524. package/dist/translations/index.js +14 -3
  525. package/dist/translations/index.js.map +1 -1
  526. package/dist/translations/keys.d.ts +245 -23
  527. package/dist/translations/keys.js +246 -24
  528. package/dist/translations/keys.js.map +1 -1
  529. package/dist/translations/makeTranslate.d.ts +7 -3
  530. package/dist/translations/makeTranslate.js +12 -3
  531. package/dist/translations/makeTranslate.js.map +1 -1
  532. package/dist/translations/server.js +8 -1
  533. package/dist/translations/server.js.map +1 -1
  534. package/dist/uploads/captureFileRef.d.ts +10 -3
  535. package/dist/uploads/captureFileRef.js +18 -9
  536. package/dist/uploads/captureFileRef.js.map +1 -1
  537. package/dist/uploads/formatBytes.d.ts +9 -0
  538. package/dist/uploads/formatBytes.js +25 -0
  539. package/dist/uploads/formatBytes.js.map +1 -0
  540. package/dist/uploads/resolveFileRef.js +3 -2
  541. package/dist/uploads/resolveFileRef.js.map +1 -1
  542. package/dist/uploads/types.d.ts +1 -2
  543. package/dist/validation/buildRuleBlocks.js +18 -17
  544. package/dist/validation/buildRuleBlocks.js.map +1 -1
  545. package/dist/validation/builtin/email.js +2 -1
  546. package/dist/validation/builtin/email.js.map +1 -1
  547. package/dist/validation/builtin/index.d.ts +14 -0
  548. package/dist/validation/builtin/index.js +14 -1
  549. package/dist/validation/builtin/index.js.map +1 -1
  550. package/dist/validation/builtin/integer.js +15 -0
  551. package/dist/validation/builtin/integer.js.map +1 -0
  552. package/dist/validation/builtin/matchesField.js +3 -7
  553. package/dist/validation/builtin/matchesField.js.map +1 -1
  554. package/dist/validation/builtin/max.js +1 -0
  555. package/dist/validation/builtin/max.js.map +1 -1
  556. package/dist/validation/builtin/maxDate.js +24 -0
  557. package/dist/validation/builtin/maxDate.js.map +1 -0
  558. package/dist/validation/builtin/maxLength.js +1 -0
  559. package/dist/validation/builtin/maxLength.js.map +1 -1
  560. package/dist/validation/builtin/min.js +1 -0
  561. package/dist/validation/builtin/min.js.map +1 -1
  562. package/dist/validation/builtin/minDate.js +24 -0
  563. package/dist/validation/builtin/minDate.js.map +1 -0
  564. package/dist/validation/builtin/minLength.js +1 -0
  565. package/dist/validation/builtin/minLength.js.map +1 -1
  566. package/dist/validation/builtin/notAlreadySubmitted.js +5 -1
  567. package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
  568. package/dist/validation/builtin/oneOf.js +1 -0
  569. package/dist/validation/builtin/oneOf.js.map +1 -1
  570. package/dist/validation/builtin/pattern.js +11 -2
  571. package/dist/validation/builtin/pattern.js.map +1 -1
  572. package/dist/validation/builtin/url.js +1 -0
  573. package/dist/validation/builtin/url.js.map +1 -1
  574. package/dist/validation/builtin/validateDateBound.js +18 -0
  575. package/dist/validation/builtin/validateDateBound.js.map +1 -0
  576. package/dist/validation/builtin/validateRegexParams.js +44 -0
  577. package/dist/validation/builtin/validateRegexParams.js.map +1 -0
  578. package/dist/validation/emailPattern.js +10 -0
  579. package/dist/validation/emailPattern.js.map +1 -0
  580. package/dist/validation/fieldTargetParam.d.ts +22 -0
  581. package/dist/validation/fieldTargetParam.js +38 -0
  582. package/dist/validation/fieldTargetParam.js.map +1 -0
  583. package/dist/validation/registry.d.ts +2 -1
  584. package/dist/validation/registry.js +2 -9
  585. package/dist/validation/registry.js.map +1 -1
  586. package/dist/validation/runValidation.js +8 -29
  587. package/dist/validation/runValidation.js.map +1 -1
  588. package/dist/validation/types.d.ts +5 -11
  589. package/dist/validation/validateUrl.js +22 -0
  590. package/dist/validation/validateUrl.js.map +1 -0
  591. package/package.json +14 -6
  592. package/styles/form-builder.css +94 -190
  593. package/dist/collections/uploads.d.ts +0 -30
  594. package/dist/collections/uploads.js +0 -55
  595. package/dist/collections/uploads.js.map +0 -1
  596. package/dist/consent/buildConsentSourceConfig.js +0 -49
  597. package/dist/consent/buildConsentSourceConfig.js.map +0 -1
  598. package/dist/consent/builtin/index.d.ts +0 -7
  599. package/dist/consent/builtin/index.js +0 -11
  600. package/dist/consent/builtin/index.js.map +0 -1
  601. package/dist/consent/builtin/pageReference.js +0 -75
  602. package/dist/consent/builtin/pageReference.js.map +0 -1
  603. package/dist/consent/builtin/static.js +0 -44
  604. package/dist/consent/builtin/static.js.map +0 -1
  605. package/dist/consent/defineConsentSource.d.ts +0 -35
  606. package/dist/consent/defineConsentSource.js +0 -6
  607. package/dist/consent/defineConsentSource.js.map +0 -1
  608. package/dist/consent/registry.d.ts +0 -16
  609. package/dist/consent/registry.js +0 -16
  610. package/dist/consent/registry.js.map +0 -1
  611. package/dist/consent/resolveConsentLinks.d.ts +0 -19
  612. package/dist/consent/resolveConsentLinks.js +0 -26
  613. package/dist/consent/resolveConsentLinks.js.map +0 -1
  614. package/dist/presentations/registry.d.ts +0 -15
  615. package/dist/presentations/registry.js +0 -15
  616. package/dist/presentations/registry.js.map +0 -1
  617. package/dist/react/toFormDocument.d.ts +0 -24
  618. package/dist/react/toFormDocument.js +0 -22
  619. package/dist/react/toFormDocument.js.map +0 -1
@@ -0,0 +1,281 @@
1
+ import { TranslationsOption } from "./translations/index.js";
2
+ import { RichTextBodyOption } from "./actions/body/serializeBody.js";
3
+ import { ConsentSourcesResolver } from "./consent/types.js";
4
+ import { FieldTypesConfig } from "./fields/registry.js";
5
+ import { FormEventSink } from "./events/types.js";
6
+ import { PollOptionSourcesConfig } from "./poll/registry.js";
7
+ import { RecipientSourceRegistry } from "./actions/recipientSources.js";
8
+ import { FromAddressSourceRegistry, FromAddressesResolver } from "./actions/fromAddresses.js";
9
+ import { ActionsConfig } from "./actions/registry.js";
10
+ import { FormResultsAccess } from "./aggregation/resolveResultsRequest.js";
11
+ import { ButtonsOption } from "./collections/buttonFields.js";
12
+ import { ConsentSnapshotMode } from "./consent/captureConsent.js";
13
+ import { DepartmentEmailsResolver } from "./email/departments.js";
14
+ import { RecipientsConfig } from "./actions/emailRecipients.js";
15
+ import { CalcFunction, CalcSource } from "./calc/registry.js";
16
+ import { ResponseOption } from "./collections/redirectFields.js";
17
+ import { SettingsOption } from "./collections/settingsFields.js";
18
+ import { CollectionOverrides } from "./plugin/collectionOverrides.js";
19
+ import { SpamOption } from "./spam/types.js";
20
+ import { UploadsOption } from "./plugin/uploadsCollection.js";
21
+ import { OutcomeFieldsOverride } from "./poll/outcomeFields.js";
22
+ import { PollTypesConfig } from "./poll/pollTypeRegistry.js";
23
+ import { ValidationRulesConfig } from "./validation/registry.js";
24
+ import { CollectionSlug } from "payload";
25
+
26
+ //#region src/options.d.ts
27
+ type FormBuilderPluginOptions = {
28
+ disabled?: boolean;
29
+ /**
30
+ * Per-locale overrides for this plugin's UI strings, keyed by the typed
31
+ * translation keys exported from `@10x-media/form-builder/i18n`. Values win
32
+ * over the built-in locales key-by-key; locales the plugin does not ship are
33
+ * added whole. App-level `i18n.translations` still wins over both.
34
+ */
35
+ translations?: TranslationsOption; /** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */
36
+ events?: FormEventSink;
37
+ /**
38
+ * Content-bearing author fields (labels, placeholders, option labels, action subjects and
39
+ * bodies) are localized by default. Payload strips the `localized` flag on hosts without
40
+ * `localization` configured, so the default is safe everywhere. Set `false` to keep form
41
+ * content single-locale even on localized hosts. Spread-overrides of the prebuilt default
42
+ * exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`
43
+ * flags from the default-true set; when opting out, derive overrides from
44
+ * `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions({ localize: false })` instead.
45
+ * Consent statements are unaffected either way: they live on the host's own
46
+ * `consentSourcesField()`, which carries its own `localized` option.
47
+ */
48
+ localizeContent?: boolean; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
49
+ fields?: FieldTypesConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
50
+ rules?: ValidationRulesConfig; /** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
51
+ actions?: ActionsConfig;
52
+ /**
53
+ * Calculation extensions. `sources` registers named value resolvers the calculation field can
54
+ * reference: `resolve` supplies one number per render/submission (a tax rate, a member
55
+ * discount), `resolveWeights` supplies per-option numbers for a chosen field (a product's
56
+ * price per selectable product). Values resolve server-side, ride the form document for the
57
+ * client's live preview, and re-resolve at submit, so the client never supplies them.
58
+ * `functions` registers extra calculation functions; client-side live preview additionally
59
+ * needs the same map passed to the Form component.
60
+ *
61
+ * Resolvers receive an unauthenticated visitor `req` on public reads and submits: never feed
62
+ * data derived from it into access-escalated queries, and gate per-user-sensitive numbers on
63
+ * `req.user`, because resolved values are embedded on every readable form document.
64
+ */
65
+ calc?: {
66
+ sources?: Record<string, CalcSource>;
67
+ functions?: Record<string, CalcFunction>;
68
+ };
69
+ /**
70
+ * Customize how the plugin's rich text is authored and rendered. `editor` is the default
71
+ * Lexical/richText editor for every plugin richText field (message content, consent
72
+ * statement, response message, action bodies); `bodyEditor` overrides the action body
73
+ * fields and `responseEditor` overrides the success response message field, each falling
74
+ * back to `editor`. `converters` spread over the default
75
+ * Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to
76
+ * target chat or plain-text channels instead of email HTML). A custom `serialize` receives
77
+ * the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw
78
+ * body off to a renderer like react-email.
79
+ */
80
+ richText?: RichTextBodyOption;
81
+ /**
82
+ * Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the
83
+ * presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped
84
+ * resolver, evaluated per request via an endpoint, whose choice is validated at save time only and
85
+ * never re-checked when the action sends (the config is admin-authored, not visitor-controlled).
86
+ *
87
+ * `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,
88
+ * neither action has a `from` field and every send uses the email adapter's default sender. The
89
+ * intended use is multi-tenant hosts where each tenant may only send from particular addresses
90
+ * (derive the tenant from `req`, return its allowed senders). Values are the literal string
91
+ * `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).
92
+ *
93
+ * `departments` turns the `emailTeam` `to` into a select whose options come from the resolver
94
+ * (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document
95
+ * you own and read it back with `resolveDepartmentOptions`, which resolves each department's address
96
+ * for the requesting locale. Because `to` is localized, each admin locale stores its own resolved
97
+ * address and a submission's locale selects the address it routes to (Payload-native, no per-send
98
+ * lookup). Storing the resolved address, rather than a department id resolved live at send (consent's
99
+ * model), is deliberate: the routing target a form was saved with stays audit-stable even if the
100
+ * resolver's data later changes, so do not "fix" it into a live lookup. Multi-tenant hosts scope
101
+ * which document they read by the tenant derived from `req`; absent, the recipient fields simply
102
+ * offer no preset department options (still free-typed emails and field tokens).
103
+ */
104
+ email?: {
105
+ fromAddresses?: FromAddressesResolver;
106
+ /**
107
+ * Senders resolved at send time, offered in the `from` select alongside (and ahead of) the
108
+ * `fromAddresses` literals. Where a literal freezes the address an action was saved with, a
109
+ * source stores its namespaced `value` (e.g. `tenant:default`) and re-resolves the address on
110
+ * every send, so sender identity follows the host: a tenant that changes its from-address
111
+ * changes it for every existing form at once. `resolve` receives the same run-time args as a
112
+ * recipient source (the form, the submission, the request); the form document is the stable
113
+ * tenant handle on the queued path. See {@link FromAddressSource}.
114
+ */
115
+ fromSources?: FromAddressSourceRegistry;
116
+ departments?: DepartmentEmailsResolver; /** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */
117
+ recipients?: RecipientsConfig;
118
+ /**
119
+ * Server-resolved recipients, offered in every recipient field as their own option group and
120
+ * resolved to addresses at send time. Each source's `value` is a namespaced string (so it cannot
121
+ * collide with an address); its `resolve` receives the verified form context. See {@link RecipientSource}.
122
+ */
123
+ recipientSources?: RecipientSourceRegistry;
124
+ };
125
+ /**
126
+ * Where the consent statements a form can reference come from. Absent (the default): no sources,
127
+ * so the built-in `consent` field type is not registered at all and authors cannot add a consent
128
+ * field with nothing to reference (a developer-registered custom `consent` type via `fields`
129
+ * still wins).
130
+ *
131
+ * `sources` is an async `req`-scoped resolver returning the sources available to this request.
132
+ * The intended shape: place `consentSourcesField()` on a collection or global you own and read it
133
+ * back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's
134
+ * authors only ever see, and their visitors only ever agree to, their own statements. A form
135
+ * stores only a source's row `id`; the statement is resolved live per request (see
136
+ * `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is
137
+ * ever a copy the client could stale or forge.
138
+ */
139
+ consent?: {
140
+ sources: ConsentSourcesResolver;
141
+ /**
142
+ * What each submission snapshots of the agreed consent wording, for a versioned audit trail.
143
+ * `'both'` (default) stores a `statementHash`, the plain `statementText`, and the source name;
144
+ * `'hash'` keeps only the tamper-evident hash; `'text'` only the readable text; `false` keeps the
145
+ * lean id-only proof. The proof stays id-based regardless; this only adds the wording snapshot.
146
+ */
147
+ snapshot?: ConsentSnapshotMode;
148
+ /**
149
+ * Whether to resolve each form's consent statements on every read via an afterRead hook (the
150
+ * default, `true`). It attaches `consentStatements` to the form doc so a host can render the
151
+ * wording without a second call, at the cost of one source lookup per form read (N on a list).
152
+ * Set `false` to skip that hook and resolve statements yourself with the exported
153
+ * `resolveConsentStatements` when you render a form; submit-time proof capture is unaffected either
154
+ * way (it always re-resolves from the source).
155
+ */
156
+ resolveOnRead?: boolean;
157
+ };
158
+ /**
159
+ * Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and
160
+ * `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The
161
+ * rendered chrome resolves each label as `<Form>` prop, then the stored value, then the
162
+ * translated default. `fields` composes them: it receives the three default fields as a
163
+ * `{ submit, prev, next }` map with the content localization flag already applied and returns
164
+ * the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing
165
+ * one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a
166
+ * host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.
167
+ */
168
+ buttons?: ButtonsOption;
169
+ /**
170
+ * Form-level flag fields (`multistep`, `pollEnabled`, `persistSubmissions`), sidebar
171
+ * checkboxes by default. `fields` composes them from the defaults so a host can
172
+ * relocate, wrap, extend, or drop them.
173
+ */
174
+ settings?: SettingsOption;
175
+ /**
176
+ * The success-response group. `redirect.fields` composes the fields inside the `response.redirect`
177
+ * group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the
178
+ * polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's
179
+ * final field array, so a host can prepend a custom link field (the pattern most projects already
180
+ * have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the
181
+ * built-in `url` (+ optional `reference`), unchanged.
182
+ *
183
+ * The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when
184
+ * configured); `toFormDocument` passes the whole `response` group through, so a host that replaces
185
+ * `url` with their own link field owns resolving it to a destination in their frontend, the same as
186
+ * the internal-reference case.
187
+ */
188
+ response?: ResponseOption;
189
+ /**
190
+ * Collections whose documents `response.redirect` can reference (`response.redirect.reference`),
191
+ * letting an author redirect a visitor to an internal document instead of a URL after a
192
+ * successful submit. Absent (the default): no `reference` field exists at all, matching today's
193
+ * URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not
194
+ * a bare `CollectionSlug`), so a host adding a second collection later never changes the stored
195
+ * shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves
196
+ * the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes
197
+ * the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for
198
+ * the host to resolve. Mirrors the `redirectRelationships` option of Payload's native
199
+ * `plugin-form-builder`.
200
+ */
201
+ redirectRelationships?: CollectionSlug[];
202
+ /**
203
+ * File uploads are bring-your-own. Default `false`: no upload collection is involved and the
204
+ * built-in `file` field type is removed from the registry, so form authors cannot add a field
205
+ * with nowhere to land (a developer-registered custom `file` type via `fields` still wins).
206
+ * `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with
207
+ * its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when
208
+ * absent, and prepends the spam upload hooks.
209
+ */
210
+ uploads?: UploadsOption; /** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */
211
+ spam?: SpamOption;
212
+ /**
213
+ * Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded
214
+ * and before anything is served; absent keeps the plugin-default gating (poll opt-in +
215
+ * visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against
216
+ * the tenant derived from `req` so one tenant's poll counts are never readable under another
217
+ * tenant's id. Authenticated callers bypass this seam.
218
+ */
219
+ results?: {
220
+ access?: FormResultsAccess;
221
+ };
222
+ /**
223
+ * Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each
224
+ * successful submission to a poll-enabled form, letting SSR hosts read the voted state via
225
+ * `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.
226
+ * `sources` registers poll option sources (`definePollOptionSource`), letting authors populate
227
+ * a poll's choices from host domain data with stable values; there are no built-ins. With at
228
+ * least one source registered, the forms poll group gains an `optionSource` select plus its
229
+ * per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.
230
+ * `outcomeFields` composes the poll `outcome` group: it receives the two default fields
231
+ * (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host
232
+ * can swap `winningValues` for its own component (e.g. a relationship picker over the voteable
233
+ * records). Membership validation runs server-side regardless, so a swap cannot bypass it.
234
+ * `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The
235
+ * built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on
236
+ * close), and `source` (delegates to the option source) are always registered; a host entry keyed
237
+ * by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`
238
+ * auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.
239
+ */
240
+ poll?: {
241
+ votedCookie?: boolean;
242
+ sources?: PollOptionSourcesConfig;
243
+ types?: PollTypesConfig;
244
+ outcomeFields?: OutcomeFieldsOverride;
245
+ /**
246
+ * Poll vote tally store (default on). Votes are counted into an append-only hidden
247
+ * collection of aggregate rows at submit time, so results reads are O(options), never
248
+ * truncate, and survive `persistSubmissions: false`. `false` restores scan-based results
249
+ * (and then a persist-off poll is rejected at save). `overrides` opens the tally
250
+ * collection (slug stays `form-poll-votes`).
251
+ */
252
+ votes?: false | {
253
+ overrides?: CollectionOverrides;
254
+ };
255
+ };
256
+ /**
257
+ * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the
258
+ * submission admin view. Default `false`, because the `SubmissionAnswers` UI component already
259
+ * represents those fields fully and they are noisy shown alongside it.
260
+ */
261
+ showSubmissionRawFields?: boolean;
262
+ /**
263
+ * Override individual plugin-managed collections using explicit spreads. Each key accepts a
264
+ * `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread
265
+ * order per key determines who wins), hooks are appended after the plugin's own hooks, and
266
+ * `fields` is a function that receives the default fields and returns the final array so
267
+ * additions/removals are always intentional.
268
+ */
269
+ overrides?: {
270
+ forms?: CollectionOverrides;
271
+ formSubmissions?: CollectionOverrides;
272
+ };
273
+ };
274
+ declare module 'payload' {
275
+ interface RegisteredPlugins {
276
+ '@10x-media/form-builder': FormBuilderPluginOptions;
277
+ }
278
+ }
279
+ //#endregion
280
+ export { FormBuilderPluginOptions };
281
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1,11 @@
1
+ //#region src/plugin/applyRegistryConfig.d.ts
2
+ /** Any registry entry: an object carrying a string `type` discriminator, keyed by that type. */
3
+ type TypedDefinition = {
4
+ type: string;
5
+ };
6
+ /** Per-type opt-in: `false` removes a type, `true` keeps the seeded default, a definition adds or replaces one. */
7
+ type RegistryOption<T extends TypedDefinition> = boolean | T;
8
+ type RegistryConfig<T extends TypedDefinition> = Record<string, RegistryOption<T>>;
9
+ //#endregion
10
+ export { RegistryConfig };
11
+ //# sourceMappingURL=applyRegistryConfig.d.ts.map
@@ -0,0 +1,20 @@
1
+ //#region src/plugin/applyRegistryConfig.ts
2
+ /**
3
+ * Apply a per-type opt-in override map onto a seeded registry, in place. `false` removes the type,
4
+ * `true` keeps whatever default is already seeded (a no-op when none exists), and a definition adds
5
+ * or replaces one with its `type` forced to the config key, so the authored slug (derived from
6
+ * `type`) and the lookup key can never drift apart and silently orphan the entry. Shared by the
7
+ * field-type, validation-rule, action, poll-source, and poll-type registries.
8
+ */
9
+ const applyRegistryConfig = (registry, config) => {
10
+ for (const [type, option] of Object.entries(config)) if (option === false) registry.delete(type);
11
+ else if (option !== true) registry.set(type, {
12
+ ...option,
13
+ type
14
+ });
15
+ return registry;
16
+ };
17
+ //#endregion
18
+ export { applyRegistryConfig };
19
+
20
+ //# sourceMappingURL=applyRegistryConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyRegistryConfig.js","names":[],"sources":["../../src/plugin/applyRegistryConfig.ts"],"sourcesContent":["/** Any registry entry: an object carrying a string `type` discriminator, keyed by that type. */\nexport type TypedDefinition = { type: string }\n\n/** Per-type opt-in: `false` removes a type, `true` keeps the seeded default, a definition adds or replaces one. */\nexport type RegistryOption<T extends TypedDefinition> = boolean | T\n\nexport type RegistryConfig<T extends TypedDefinition> = Record<string, RegistryOption<T>>\n\n/**\n * Apply a per-type opt-in override map onto a seeded registry, in place. `false` removes the type,\n * `true` keeps whatever default is already seeded (a no-op when none exists), and a definition adds\n * or replaces one with its `type` forced to the config key, so the authored slug (derived from\n * `type`) and the lookup key can never drift apart and silently orphan the entry. Shared by the\n * field-type, validation-rule, action, poll-source, and poll-type registries.\n */\nexport const applyRegistryConfig = <T extends TypedDefinition>(\n\tregistry: Map<string, T>,\n\tconfig: RegistryConfig<T>\n): Map<string, T> => {\n\tfor (const [type, option] of Object.entries(config)) {\n\t\tif (option === false) {\n\t\t\tregistry.delete(type)\n\t\t} else if (option !== true) {\n\t\t\tregistry.set(type, { ...option, type })\n\t\t}\n\t}\n\treturn registry\n}\n"],"mappings":";;;;;;;;AAeA,MAAa,uBACZ,UACA,WACoB;CACpB,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GACjD,IAAI,WAAW,OACd,SAAS,OAAO,IAAI;MACd,IAAI,WAAW,MACrB,SAAS,IAAI,MAAM;EAAE,GAAG;EAAQ;CAAK,CAAC;CAGxC,OAAO;AACR"}
@@ -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"}
@@ -1,65 +1,68 @@
1
+ import { buildPollVotesCollection } from "../poll/votes/votesCollection.js";
2
+ import { registerPollCloseTask } from "../poll/closeJob.js";
1
3
  import { buildFormsCollection } from "../collections/forms.js";
2
4
  import { buildSubmissionsCollection } from "../collections/formSubmissions.js";
3
5
  import { registerActionsTask } from "../actions/task.js";
4
- import { buildUploadOwnerStamp, buildUploadRateLimit } from "../spam/uploadHooks.js";
6
+ import { attachUploadsCollection } from "./uploadsCollection.js";
5
7
  //#region src/plugin/registerCollections.ts
6
- const registerCollections = ({ config, registry, ruleRegistry, consentRegistry, presentationRegistry, actionRegistry, hasJobsPlugin, events, uploads, spam, showSubmissionRawFields, overrides }) => {
7
- registerActionsTask(config, actionRegistry);
8
+ const registerCollections = ({ config, registry, ruleRegistry, calcAllowed, calcSources, calcFunctions, consentSources, consentSnapshot, consentResolveOnRead, actionRegistry, richText, hasJobsPlugin, events, uploads, spam, showSubmissionRawFields, localizeContent, resultsAccess, votedCookie, pollSourceRegistry, pollTypeRegistry, outcomeFields, pollVotes, buttons, settings, response, fromAddresses, fromSources, departments, redirectRelationships, overrides }) => {
9
+ const pollVotesEnabled = pollVotes !== false;
10
+ registerActionsTask(config, actionRegistry, richText);
11
+ registerPollCloseTask(config, pollVotesEnabled);
8
12
  const hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin;
9
- let uploadsCollection = null;
10
- if (uploads.enabled && uploads.collection) {
11
- const col = uploads.collection;
12
- if (spam) {
13
- col.hooks = col.hooks ?? {};
14
- col.hooks.beforeOperation = [...col.hooks.beforeOperation ?? [], buildUploadRateLimit(spam)];
15
- col.hooks.beforeValidate = [...col.hooks.beforeValidate ?? [], buildUploadOwnerStamp(spam)];
16
- }
17
- const ov = overrides?.uploads;
18
- if (ov) {
19
- const defaultFields = col.fields ?? [];
20
- uploadsCollection = {
21
- ...col,
22
- ...ov ?? {},
23
- access: {
24
- ...col.access ?? {},
25
- ...ov.access ?? {}
26
- },
27
- admin: {
28
- ...col.admin ?? {},
29
- ...ov.admin ?? {}
30
- },
31
- hooks: {
32
- ...ov.hooks ?? {},
33
- beforeOperation: [...col.hooks?.beforeOperation ?? [], ...ov.hooks?.beforeOperation ?? []],
34
- beforeValidate: [...col.hooks?.beforeValidate ?? [], ...ov.hooks?.beforeValidate ?? []]
35
- },
36
- fields: ov.fields ? ov.fields({ defaultFields }) : defaultFields
37
- };
38
- } else uploadsCollection = col;
39
- }
13
+ const uploadSlug = uploads === false ? void 0 : uploads.collection;
14
+ if (uploads !== false) attachUploadsCollection({
15
+ config,
16
+ slug: uploads.collection,
17
+ spam
18
+ });
40
19
  config.collections = [
41
20
  ...config.collections ?? [],
42
- ...uploadsCollection ? [uploadsCollection] : [],
43
21
  buildFormsCollection({
44
22
  registry,
45
23
  ruleRegistry,
46
- consentRegistry,
47
- presentationRegistry,
24
+ calcAllowed,
25
+ calcSources,
26
+ consentSources,
27
+ consentResolveOnRead,
48
28
  actionRegistry,
29
+ localizeContent,
30
+ richText,
31
+ uploadsCollectionSlug: uploadSlug,
32
+ resultsAccess,
33
+ pollVotesEnabled,
34
+ pollSourceRegistry,
35
+ pollTypeRegistry,
36
+ outcomeFields,
37
+ buttons,
38
+ settings,
39
+ response,
40
+ fromAddresses,
41
+ fromSources,
42
+ departments,
43
+ redirectRelationships,
49
44
  overrides: overrides?.forms
50
45
  }),
51
46
  buildSubmissionsCollection({
52
47
  registry,
53
48
  ruleRegistry,
54
- consentRegistry,
49
+ calcSources,
50
+ calcFunctions,
51
+ consentSources,
52
+ consentSnapshot,
55
53
  actionRegistry,
54
+ richText,
56
55
  events,
57
56
  hasRunner,
58
- uploadSlug: uploads.slug,
57
+ uploadSlug,
59
58
  spam,
59
+ votedCookie,
60
+ pollSourceRegistry,
61
+ pollVotes,
60
62
  showRawFields: showSubmissionRawFields,
61
63
  overrides: overrides?.formSubmissions
62
- })
64
+ }),
65
+ ...pollVotes === false ? [] : [buildPollVotesCollection({ overrides: pollVotes.overrides })]
63
66
  ];
64
67
  };
65
68
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field } from 'payload'\nimport type { ActionRegistry } from '../actions/registry'\nimport { registerActionsTask } from '../actions/task'\nimport { buildSubmissionsCollection } from '../collections/formSubmissions'\nimport { buildFormsCollection } from '../collections/forms'\nimport type { ConsentSourceRegistry } from '../consent/registry'\nimport type { FormEventSink } from '../events/types'\nimport type { FieldTypeRegistry } from '../fields/registry'\nimport type { PresentationDescriptorRegistry } from '../presentations/registry'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport { buildUploadOwnerStamp, buildUploadRateLimit } from '../spam/uploadHooks'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { CollectionOverrides } from './collectionOverrides'\n\ntype RegisterCollectionsArgs = {\n\tconfig: Config\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tconsentRegistry: ConsentSourceRegistry\n\tpresentationRegistry: PresentationDescriptorRegistry\n\tactionRegistry: ActionRegistry\n\thasJobsPlugin: boolean\n\tevents?: FormEventSink\n\tuploads: { enabled: boolean; slug: string; collection?: CollectionConfig }\n\tspam: ResolvedSpamConfig | false\n\tshowSubmissionRawFields: boolean\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t\tuploads?: CollectionOverrides\n\t}\n}\n\nexport const registerCollections = ({\n\tconfig,\n\tregistry,\n\truleRegistry,\n\tconsentRegistry,\n\tpresentationRegistry,\n\tactionRegistry,\n\thasJobsPlugin,\n\tevents,\n\tuploads,\n\tspam,\n\tshowSubmissionRawFields,\n\toverrides,\n}: RegisterCollectionsArgs): void => {\n\tregisterActionsTask(config, actionRegistry)\n\tconst hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin\n\n\tlet uploadsCollection: CollectionConfig | null = null\n\tif (uploads.enabled && uploads.collection) {\n\t\tconst col = uploads.collection\n\n\t\t// Spam hooks are added first (plugin-owned invariant)\n\t\tif (spam) {\n\t\t\tcol.hooks = col.hooks ?? {}\n\t\t\tcol.hooks.beforeOperation = [...(col.hooks.beforeOperation ?? []), buildUploadRateLimit(spam)]\n\t\t\tcol.hooks.beforeValidate = [...(col.hooks.beforeValidate ?? []), buildUploadOwnerStamp(spam)]\n\t\t}\n\n\t\t// Apply CollectionOverrides using explicit spreads after spam hooks are in place.\n\t\t// ...col first so the plugin defaults are the base, ...(ov ?? {}) second so the consumer\n\t\t// wins for any top-level key not explicitly re-set below (consistent with forms/formSubmissions).\n\t\t// The locked keys (hooks array ordering, fields function) are spread last.\n\t\tconst ov = overrides?.uploads\n\t\tif (ov) {\n\t\t\tconst defaultFields = (col.fields ?? []) as Field[]\n\t\t\tuploadsCollection = {\n\t\t\t\t...col,\n\t\t\t\t...(ov ?? {}),\n\t\t\t\taccess: { ...(col.access ?? {}), ...(ov.access ?? {}) },\n\t\t\t\tadmin: { ...(col.admin ?? {}), ...(ov.admin ?? {}) },\n\t\t\t\thooks: {\n\t\t\t\t\t...(ov.hooks ?? {}),\n\t\t\t\t\t// Spam hooks stay first in each array; consumer hooks appended\n\t\t\t\t\tbeforeOperation: [\n\t\t\t\t\t\t...(col.hooks?.beforeOperation ?? []),\n\t\t\t\t\t\t...(ov.hooks?.beforeOperation ?? []),\n\t\t\t\t\t],\n\t\t\t\t\tbeforeValidate: [\n\t\t\t\t\t\t...(col.hooks?.beforeValidate ?? []),\n\t\t\t\t\t\t...(ov.hooks?.beforeValidate ?? []),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tfields: ov.fields ? ov.fields({ defaultFields }) : defaultFields,\n\t\t\t}\n\t\t} else {\n\t\t\tuploadsCollection = col\n\t\t}\n\t}\n\n\tconfig.collections = [\n\t\t...(config.collections ?? []),\n\t\t...(uploadsCollection ? [uploadsCollection] : []),\n\t\tbuildFormsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentRegistry,\n\t\t\tpresentationRegistry,\n\t\t\tactionRegistry,\n\t\t\toverrides: overrides?.forms,\n\t\t}),\n\t\tbuildSubmissionsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentRegistry,\n\t\t\tactionRegistry,\n\t\t\tevents,\n\t\t\thasRunner,\n\t\t\tuploadSlug: uploads.slug,\n\t\t\tspam,\n\t\t\tshowRawFields: showSubmissionRawFields,\n\t\t\toverrides: overrides?.formSubmissions,\n\t\t}),\n\t]\n}\n"],"mappings":";;;;;AAiCA,MAAa,uBAAuB,EACnC,QACA,UACA,cACA,iBACA,sBACA,gBACA,eACA,QACA,SACA,MACA,yBACA,gBACoC;CACpC,oBAAoB,QAAQ,cAAc;CAC1C,MAAM,YAAY,QAAQ,OAAO,MAAM,OAAO,KAAK;CAEnD,IAAI,oBAA6C;CACjD,IAAI,QAAQ,WAAW,QAAQ,YAAY;EAC1C,MAAM,MAAM,QAAQ;EAGpB,IAAI,MAAM;GACT,IAAI,QAAQ,IAAI,SAAS,CAAC;GAC1B,IAAI,MAAM,kBAAkB,CAAC,GAAI,IAAI,MAAM,mBAAmB,CAAC,GAAI,qBAAqB,IAAI,CAAC;GAC7F,IAAI,MAAM,iBAAiB,CAAC,GAAI,IAAI,MAAM,kBAAkB,CAAC,GAAI,sBAAsB,IAAI,CAAC;EAC7F;EAMA,MAAM,KAAK,WAAW;EACtB,IAAI,IAAI;GACP,MAAM,gBAAiB,IAAI,UAAU,CAAC;GACtC,oBAAoB;IACnB,GAAG;IACH,GAAI,MAAM,CAAC;IACX,QAAQ;KAAE,GAAI,IAAI,UAAU,CAAC;KAAI,GAAI,GAAG,UAAU,CAAC;IAAG;IACtD,OAAO;KAAE,GAAI,IAAI,SAAS,CAAC;KAAI,GAAI,GAAG,SAAS,CAAC;IAAG;IACnD,OAAO;KACN,GAAI,GAAG,SAAS,CAAC;KAEjB,iBAAiB,CAChB,GAAI,IAAI,OAAO,mBAAmB,CAAC,GACnC,GAAI,GAAG,OAAO,mBAAmB,CAAC,CACnC;KACA,gBAAgB,CACf,GAAI,IAAI,OAAO,kBAAkB,CAAC,GAClC,GAAI,GAAG,OAAO,kBAAkB,CAAC,CAClC;IACD;IACA,QAAQ,GAAG,SAAS,GAAG,OAAO,EAAE,cAAc,CAAC,IAAI;GACpD;EACD,OACC,oBAAoB;CAEtB;CAEA,OAAO,cAAc;EACpB,GAAI,OAAO,eAAe,CAAC;EAC3B,GAAI,oBAAoB,CAAC,iBAAiB,IAAI,CAAC;EAC/C,qBAAqB;GACpB;GACA;GACA;GACA;GACA;GACA,WAAW,WAAW;EACvB,CAAC;EACD,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA,YAAY,QAAQ;GACpB;GACA,eAAe;GACf,WAAW,WAAW;EACvB,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload'\nimport type { RichTextBodyOption } from '../actions/body/serializeBody'\nimport type { FromAddressesResolver, FromAddressSourceRegistry } from '../actions/fromAddresses'\nimport type { ActionRegistry } from '../actions/registry'\nimport { registerActionsTask } from '../actions/task'\nimport type { FormResultsAccess } from '../aggregation/resolveResultsRequest'\nimport type { CalcAllowed } from '../calc/normalizeCalc'\nimport type { CalcFunction, CalcSource } from '../calc/registry'\nimport type { ButtonsOption } from '../collections/buttonFields'\nimport { buildSubmissionsCollection } from '../collections/formSubmissions'\nimport { buildFormsCollection } from '../collections/forms'\nimport type { ResponseOption } from '../collections/redirectFields'\nimport type { SettingsOption } from '../collections/settingsFields'\nimport type { ConsentSnapshotMode } from '../consent/captureConsent'\nimport type { ConsentSourcesResolver } from '../consent/types'\nimport type { DepartmentEmailsResolver } from '../email/departments'\nimport type { FormEventSink } from '../events/types'\nimport type { FieldTypeRegistry } from '../fields/registry'\nimport { registerPollCloseTask } from '../poll/closeJob'\nimport type { OutcomeFieldsOverride } from '../poll/outcomeFields'\nimport type { PollTypeRegistry } from '../poll/pollTypeRegistry'\nimport type { PollOptionSourceRegistry } from '../poll/registry'\nimport { buildPollVotesCollection } from '../poll/votes/votesCollection'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { CollectionOverrides } from './collectionOverrides'\nimport { attachUploadsCollection, type UploadsOption } from './uploadsCollection'\n\ntype RegisterCollectionsArgs = {\n\tconfig: Config\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\t/** Registered calc extension names; gates which expressions the forms beforeValidate accepts. */\n\tcalcAllowed?: CalcAllowed\n\t/** Registered calc sources (plugin option `calc.sources`); resolved on form reads and at submit. */\n\tcalcSources?: Record<string, CalcSource>\n\t/** Registered calc functions (plugin option `calc.functions`); threaded into submit-time evaluation. */\n\tcalcFunctions?: Record<string, CalcFunction>\n\tconsentSources?: ConsentSourcesResolver\n\tconsentSnapshot?: ConsentSnapshotMode\n\t/** Plugin `consent.resolveOnRead` (default true); false skips the per-read consent afterRead hook. */\n\tconsentResolveOnRead?: boolean\n\tactionRegistry: ActionRegistry\n\trichText?: RichTextBodyOption\n\thasJobsPlugin: boolean\n\tevents?: FormEventSink\n\tuploads: UploadsOption\n\tspam: ResolvedSpamConfig | false\n\tshowSubmissionRawFields: boolean\n\tlocalizeContent: boolean\n\tresultsAccess?: FormResultsAccess\n\tvotedCookie: boolean\n\tpollSourceRegistry: PollOptionSourceRegistry\n\tpollTypeRegistry: PollTypeRegistry\n\toutcomeFields?: OutcomeFieldsOverride\n\t/** Resolved `poll.votes` option; `false` skips registering the hidden tally collection. */\n\tpollVotes: false | { overrides?: CollectionOverrides }\n\tbuttons?: ButtonsOption\n\tsettings?: SettingsOption\n\tresponse?: ResponseOption\n\tfromAddresses?: FromAddressesResolver\n\tfromSources?: FromAddressSourceRegistry\n\tdepartments?: DepartmentEmailsResolver\n\tredirectRelationships?: CollectionSlug[]\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\nexport const registerCollections = ({\n\tconfig,\n\tregistry,\n\truleRegistry,\n\tcalcAllowed,\n\tcalcSources,\n\tcalcFunctions,\n\tconsentSources,\n\tconsentSnapshot,\n\tconsentResolveOnRead,\n\tactionRegistry,\n\trichText,\n\thasJobsPlugin,\n\tevents,\n\tuploads,\n\tspam,\n\tshowSubmissionRawFields,\n\tlocalizeContent,\n\tresultsAccess,\n\tvotedCookie,\n\tpollSourceRegistry,\n\tpollTypeRegistry,\n\toutcomeFields,\n\tpollVotes,\n\tbuttons,\n\tsettings,\n\tresponse,\n\tfromAddresses,\n\tfromSources,\n\tdepartments,\n\tredirectRelationships,\n\toverrides,\n}: RegisterCollectionsArgs): void => {\n\tconst pollVotesEnabled = pollVotes !== false\n\tregisterActionsTask(config, actionRegistry, richText)\n\tregisterPollCloseTask(config, pollVotesEnabled)\n\tconst hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin\n\n\tconst uploadSlug = uploads === false ? undefined : uploads.collection\n\tif (uploads !== false) {\n\t\tattachUploadsCollection({ config, slug: uploads.collection, spam })\n\t}\n\n\t// Payload lists nav entries in registration order (no nav-sort option). The primary\n\t// collection leads: forms, then form-submissions. Ordering the plugin's nav group against\n\t// host collections (including a BYO uploads collection) stays a host concern.\n\tconfig.collections = [\n\t\t...(config.collections ?? []),\n\t\tbuildFormsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tcalcAllowed,\n\t\t\tcalcSources,\n\t\t\tconsentSources,\n\t\t\tconsentResolveOnRead,\n\t\t\tactionRegistry,\n\t\t\tlocalizeContent,\n\t\t\trichText,\n\t\t\tuploadsCollectionSlug: uploadSlug,\n\t\t\tresultsAccess,\n\t\t\tpollVotesEnabled,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields,\n\t\t\tbuttons,\n\t\t\tsettings,\n\t\t\tresponse,\n\t\t\tfromAddresses,\n\t\t\tfromSources,\n\t\t\tdepartments,\n\t\t\tredirectRelationships,\n\t\t\toverrides: overrides?.forms,\n\t\t}),\n\t\tbuildSubmissionsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tcalcSources,\n\t\t\tcalcFunctions,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot,\n\t\t\tactionRegistry,\n\t\t\trichText,\n\t\t\tevents,\n\t\t\thasRunner,\n\t\t\tuploadSlug,\n\t\t\tspam,\n\t\t\tvotedCookie,\n\t\t\tpollSourceRegistry,\n\t\t\tpollVotes,\n\t\t\tshowRawFields: showSubmissionRawFields,\n\t\t\toverrides: overrides?.formSubmissions,\n\t\t}),\n\t\t...(pollVotes === false ? [] : [buildPollVotesCollection({ overrides: pollVotes.overrides })]),\n\t]\n}\n"],"mappings":";;;;;;;AAsEA,MAAa,uBAAuB,EACnC,QACA,UACA,cACA,aACA,aACA,eACA,gBACA,iBACA,sBACA,gBACA,UACA,eACA,QACA,SACA,MACA,yBACA,iBACA,eACA,aACA,oBACA,kBACA,eACA,WACA,SACA,UACA,UACA,eACA,aACA,aACA,uBACA,gBACoC;CACpC,MAAM,mBAAmB,cAAc;CACvC,oBAAoB,QAAQ,gBAAgB,QAAQ;CACpD,sBAAsB,QAAQ,gBAAgB;CAC9C,MAAM,YAAY,QAAQ,OAAO,MAAM,OAAO,KAAK;CAEnD,MAAM,aAAa,YAAY,QAAQ,KAAA,IAAY,QAAQ;CAC3D,IAAI,YAAY,OACf,wBAAwB;EAAE;EAAQ,MAAM,QAAQ;EAAY;CAAK,CAAC;CAMnE,OAAO,cAAc;EACpB,GAAI,OAAO,eAAe,CAAC;EAC3B,qBAAqB;GACpB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,uBAAuB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,WAAW;EACvB,CAAC;EACD,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe;GACf,WAAW,WAAW;EACvB,CAAC;EACD,GAAI,cAAc,QAAQ,CAAC,IAAI,CAAC,yBAAyB,EAAE,WAAW,UAAU,UAAU,CAAC,CAAC;CAC7F;AACD"}
@@ -0,0 +1,16 @@
1
+ import { Config } from "payload";
2
+
3
+ //#region src/plugin/uploadsCollection.d.ts
4
+ /**
5
+ * Uploads are bring-your-own: `false` (the default) disables file fields entirely, an object points
6
+ * at a host-owned upload collection (created by the app with its storage adapter of choice).
7
+ * `mimeTypes` optionally constrains the file field's MIME picker for hosts that enforce types by other
8
+ * means than the collection's own `upload.mimeTypes` (which is read automatically when this is absent).
9
+ */
10
+ type UploadsOption = false | {
11
+ collection: string;
12
+ mimeTypes?: string[];
13
+ };
14
+ //#endregion
15
+ export { UploadsOption };
16
+ //# sourceMappingURL=uploadsCollection.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { buildUploadOwnerStamp, buildUploadRateLimit } from "../spam/uploadHooks.js";
2
+ //#region src/plugin/uploadsCollection.ts
3
+ /**
4
+ * The MIME types the file field's picker should offer: the host upload collection's own
5
+ * `upload.mimeTypes`, or undefined (no constraint, so the picker keeps its full list). Read at
6
+ * plugin-factory time, before the field registry freezes; `attachUploadsCollection` runs too late.
7
+ */
8
+ const readUploadCollectionMimeTypes = (config, slug) => {
9
+ const upload = (config.collections?.find((collection) => collection.slug === slug))?.upload;
10
+ return typeof upload === "object" && Array.isArray(upload.mimeTypes) ? upload.mimeTypes : void 0;
11
+ };
12
+ /** Descends presentational rows only: an `owner` field nested in a group/tabs/collapsible is not detected, so a top-level one gets appended alongside it. */
13
+ const hasFieldNamed = (fields, name) => fields.some((field) => {
14
+ if ("name" in field && field.name === name) return true;
15
+ return field.type === "row" && hasFieldNamed(field.fields, name);
16
+ });
17
+ /**
18
+ * Wire the plugin's upload concerns into the host-owned upload collection named by
19
+ * `uploads.collection`. The collection must already exist in `config.collections` and carry an
20
+ * `upload` config; anything else is a plugin misconfiguration and throws at boot. The plugin
21
+ * appends its hidden `owner` text field unless the host already defines a field named `owner`
22
+ * (then that field is reused and must stay a text-compatible identity slot), and prepends the
23
+ * spam upload hooks (rate limit, owner stamp) ahead of the host's own hooks so abuse checks run
24
+ * first. The host entry is replaced with a new object; the host's config is never mutated.
25
+ */
26
+ const attachUploadsCollection = ({ config, slug, spam }) => {
27
+ const collections = config.collections ?? [];
28
+ const target = collections.find((collection) => collection.slug === slug);
29
+ if (!target) throw new Error(`@10x-media/form-builder: uploads.collection "${slug}" was not found in config.collections. Create an upload-enabled collection (with your storage adapter) and pass its slug, e.g. formBuilder({ uploads: { collection: 'media' } }).`);
30
+ if (!target.upload) throw new Error(`@10x-media/form-builder: uploads.collection "${slug}" has no \`upload\` config. File fields store Payload uploads, so the collection must be an upload collection (set \`upload: true\` or an upload options object on it).`);
31
+ const fields = hasFieldNamed(target.fields, "owner") ? target.fields : [...target.fields, {
32
+ name: "owner",
33
+ type: "text",
34
+ admin: {
35
+ readOnly: true,
36
+ hidden: true
37
+ }
38
+ }];
39
+ const attached = {
40
+ ...target,
41
+ fields,
42
+ ...spam ? { hooks: {
43
+ ...target.hooks ?? {},
44
+ beforeOperation: [buildUploadRateLimit(spam), ...target.hooks?.beforeOperation ?? []],
45
+ beforeValidate: [buildUploadOwnerStamp(spam), ...target.hooks?.beforeValidate ?? []]
46
+ } } : {}
47
+ };
48
+ config.collections = collections.map((collection) => collection.slug === slug ? attached : collection);
49
+ };
50
+ //#endregion
51
+ export { attachUploadsCollection, readUploadCollectionMimeTypes };
52
+
53
+ //# sourceMappingURL=uploadsCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadsCollection.js","names":[],"sources":["../../src/plugin/uploadsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field } from 'payload'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport { buildUploadOwnerStamp, buildUploadRateLimit } from '../spam/uploadHooks'\n\n/**\n * Uploads are bring-your-own: `false` (the default) disables file fields entirely, an object points\n * at a host-owned upload collection (created by the app with its storage adapter of choice).\n * `mimeTypes` optionally constrains the file field's MIME picker for hosts that enforce types by other\n * means than the collection's own `upload.mimeTypes` (which is read automatically when this is absent).\n */\nexport type UploadsOption = false | { collection: string; mimeTypes?: string[] }\n\n/**\n * The MIME types the file field's picker should offer: the host upload collection's own\n * `upload.mimeTypes`, or undefined (no constraint, so the picker keeps its full list). Read at\n * plugin-factory time, before the field registry freezes; `attachUploadsCollection` runs too late.\n */\nexport const readUploadCollectionMimeTypes = (\n\tconfig: Config,\n\tslug: string\n): string[] | undefined => {\n\tconst target = config.collections?.find((collection) => collection.slug === slug)\n\tconst upload = target?.upload\n\treturn typeof upload === 'object' && Array.isArray(upload.mimeTypes)\n\t\t? upload.mimeTypes\n\t\t: undefined\n}\n\n/** Descends presentational rows only: an `owner` field nested in a group/tabs/collapsible is not detected, so a top-level one gets appended alongside it. */\nconst hasFieldNamed = (fields: Field[], name: string): boolean =>\n\tfields.some((field) => {\n\t\tif ('name' in field && field.name === name) {\n\t\t\treturn true\n\t\t}\n\t\treturn field.type === 'row' && hasFieldNamed(field.fields, name)\n\t})\n\ntype AttachUploadsCollectionArgs = {\n\tconfig: Config\n\tslug: string\n\tspam: ResolvedSpamConfig | false\n}\n\n/**\n * Wire the plugin's upload concerns into the host-owned upload collection named by\n * `uploads.collection`. The collection must already exist in `config.collections` and carry an\n * `upload` config; anything else is a plugin misconfiguration and throws at boot. The plugin\n * appends its hidden `owner` text field unless the host already defines a field named `owner`\n * (then that field is reused and must stay a text-compatible identity slot), and prepends the\n * spam upload hooks (rate limit, owner stamp) ahead of the host's own hooks so abuse checks run\n * first. The host entry is replaced with a new object; the host's config is never mutated.\n */\nexport const attachUploadsCollection = ({\n\tconfig,\n\tslug,\n\tspam,\n}: AttachUploadsCollectionArgs): void => {\n\tconst collections = config.collections ?? []\n\tconst target = collections.find((collection) => collection.slug === slug)\n\tif (!target) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" was not found in config.collections. ` +\n\t\t\t\t`Create an upload-enabled collection (with your storage adapter) and pass its slug, ` +\n\t\t\t\t`e.g. formBuilder({ uploads: { collection: 'media' } }).`\n\t\t)\n\t}\n\tif (!target.upload) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" has no \\`upload\\` config. ` +\n\t\t\t\t`File fields store Payload uploads, so the collection must be an upload collection ` +\n\t\t\t\t`(set \\`upload: true\\` or an upload options object on it).`\n\t\t)\n\t}\n\n\tconst fields = hasFieldNamed(target.fields, 'owner')\n\t\t? target.fields\n\t\t: [\n\t\t\t\t...target.fields,\n\t\t\t\t{ name: 'owner', type: 'text', admin: { readOnly: true, hidden: true } } as Field,\n\t\t\t]\n\n\tconst attached: CollectionConfig = {\n\t\t...target,\n\t\tfields,\n\t\t...(spam\n\t\t\t? {\n\t\t\t\t\thooks: {\n\t\t\t\t\t\t...(target.hooks ?? {}),\n\t\t\t\t\t\tbeforeOperation: [buildUploadRateLimit(spam), ...(target.hooks?.beforeOperation ?? [])],\n\t\t\t\t\t\tbeforeValidate: [buildUploadOwnerStamp(spam), ...(target.hooks?.beforeValidate ?? [])],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t}\n\n\tconfig.collections = collections.map((collection) =>\n\t\tcollection.slug === slug ? attached : collection\n\t)\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,iCACZ,QACA,SAC0B;CAE1B,MAAM,UADS,OAAO,aAAa,MAAM,eAAe,WAAW,SAAS,IAAI,IACzD;CACvB,OAAO,OAAO,WAAW,YAAY,MAAM,QAAQ,OAAO,SAAS,IAChE,OAAO,YACP,KAAA;AACJ;;AAGA,MAAM,iBAAiB,QAAiB,SACvC,OAAO,MAAM,UAAU;CACtB,IAAI,UAAU,SAAS,MAAM,SAAS,MACrC,OAAO;CAER,OAAO,MAAM,SAAS,SAAS,cAAc,MAAM,QAAQ,IAAI;AAChE,CAAC;;;;;;;;;;AAiBF,MAAa,2BAA2B,EACvC,QACA,MACA,WACwC;CACxC,MAAM,cAAc,OAAO,eAAe,CAAC;CAC3C,MAAM,SAAS,YAAY,MAAM,eAAe,WAAW,SAAS,IAAI;CACxE,IAAI,CAAC,QACJ,MAAM,IAAI,MACT,gDAAgD,KAAK,kLAGtD;CAED,IAAI,CAAC,OAAO,QACX,MAAM,IAAI,MACT,gDAAgD,KAAK,wKAGtD;CAGD,MAAM,SAAS,cAAc,OAAO,QAAQ,OAAO,IAChD,OAAO,SACP,CACA,GAAG,OAAO,QACV;EAAE,MAAM;EAAS,MAAM;EAAQ,OAAO;GAAE,UAAU;GAAM,QAAQ;EAAK;CAAE,CACxE;CAEF,MAAM,WAA6B;EAClC,GAAG;EACH;EACA,GAAI,OACD,EACA,OAAO;GACN,GAAI,OAAO,SAAS,CAAC;GACrB,iBAAiB,CAAC,qBAAqB,IAAI,GAAG,GAAI,OAAO,OAAO,mBAAmB,CAAC,CAAE;GACtF,gBAAgB,CAAC,sBAAsB,IAAI,GAAG,GAAI,OAAO,OAAO,kBAAkB,CAAC,CAAE;EACtF,EACD,IACC,CAAC;CACL;CAEA,OAAO,cAAc,YAAY,KAAK,eACrC,WAAW,SAAS,OAAO,WAAW,UACvC;AACD"}
@@ -0,0 +1,18 @@
1
+ //#region src/poll/applyPollOptions.ts
2
+ /**
3
+ * Replace the options of the field instance named `resultsField` with source-resolved options,
4
+ * without mutating the input. No-op when `resultsField` is unset or matches no instance
5
+ * (nameless bare rows never match), so hand-authored options stay untouched on forms without
6
+ * an option source.
7
+ */
8
+ const applyPollOptions = (fields, resultsField, options) => {
9
+ if (typeof resultsField !== "string" || resultsField.length === 0) return fields;
10
+ return fields.map((instance) => instance.name === resultsField ? {
11
+ ...instance,
12
+ options
13
+ } : instance);
14
+ };
15
+ //#endregion
16
+ export { applyPollOptions };
17
+
18
+ //# sourceMappingURL=applyPollOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPollOptions.js","names":[],"sources":["../../src/poll/applyPollOptions.ts"],"sourcesContent":["import type { PollOption } from './definePollOptionSource'\n\n/**\n * Replace the options of the field instance named `resultsField` with source-resolved options,\n * without mutating the input. No-op when `resultsField` is unset or matches no instance\n * (nameless bare rows never match), so hand-authored options stay untouched on forms without\n * an option source.\n */\nexport const applyPollOptions = <T extends { name?: string }>(\n\tfields: T[],\n\tresultsField: string | null | undefined,\n\toptions: PollOption[]\n): T[] => {\n\tif (typeof resultsField !== 'string' || resultsField.length === 0) {\n\t\treturn fields\n\t}\n\treturn fields.map((instance) =>\n\t\tinstance.name === resultsField ? { ...instance, options } : instance\n\t)\n}\n"],"mappings":";;;;;;;AAQA,MAAa,oBACZ,QACA,cACA,YACS;CACT,IAAI,OAAO,iBAAiB,YAAY,aAAa,WAAW,GAC/D,OAAO;CAER,OAAO,OAAO,KAAK,aAClB,SAAS,SAAS,eAAe;EAAE,GAAG;EAAU;CAAQ,IAAI,QAC7D;AACD"}