@10x-media/form-builder 0.1.0-beta.4 → 0.1.0-beta.6

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 (372) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +3 -3
  3. package/dist/actions/body/serializeBody.d.ts +8 -5
  4. package/dist/actions/body/serializeBody.js.map +1 -1
  5. package/dist/actions/body/textOfBody.d.ts +13 -0
  6. package/dist/actions/body/textOfBody.js +35 -0
  7. package/dist/actions/body/textOfBody.js.map +1 -0
  8. package/dist/actions/builtin/confirmation.js +81 -48
  9. package/dist/actions/builtin/confirmation.js.map +1 -1
  10. package/dist/actions/builtin/emailTeam.js +67 -38
  11. package/dist/actions/builtin/emailTeam.js.map +1 -1
  12. package/dist/actions/builtin/index.d.ts +9 -3
  13. package/dist/actions/builtin/index.js +8 -5
  14. package/dist/actions/builtin/index.js.map +1 -1
  15. package/dist/actions/defineAction.d.ts +1 -1
  16. package/dist/actions/emailRecipients.d.ts +12 -0
  17. package/dist/actions/emailRecipients.js +72 -0
  18. package/dist/actions/emailRecipients.js.map +1 -0
  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/task.js +9 -8
  23. package/dist/actions/task.js.map +1 -1
  24. package/dist/aggregation/aggregateResponses.d.ts +9 -0
  25. package/dist/aggregation/aggregateResponses.js +8 -14
  26. package/dist/aggregation/aggregateResponses.js.map +1 -1
  27. package/dist/aggregation/resolveResultsRequest.d.ts +19 -6
  28. package/dist/aggregation/resolveResultsRequest.js +58 -12
  29. package/dist/aggregation/resolveResultsRequest.js.map +1 -1
  30. package/dist/calc/computeCalcFields.js +2 -1
  31. package/dist/calc/computeCalcFields.js.map +1 -1
  32. package/dist/client/ByteSizeField.d.ts +8 -0
  33. package/dist/client/ByteSizeField.js +3 -1
  34. package/dist/client/ByteSizeField.js.map +1 -1
  35. package/dist/client/ClosePollButton.d.ts +15 -0
  36. package/dist/client/ClosePollButton.js +80 -0
  37. package/dist/client/ClosePollButton.js.map +1 -0
  38. package/dist/client/CondensedArray.d.ts +15 -0
  39. package/dist/client/CondensedArray.js +97 -0
  40. package/dist/client/CondensedArray.js.map +1 -0
  41. package/dist/client/ConsentBlockLabel.d.ts +15 -0
  42. package/dist/client/ConsentBlockLabel.js +71 -0
  43. package/dist/client/ConsentBlockLabel.js.map +1 -0
  44. package/dist/client/ConsentSourceRowLabel.d.ts +9 -0
  45. package/dist/client/ConsentSourceRowLabel.js +21 -0
  46. package/dist/client/ConsentSourceRowLabel.js.map +1 -0
  47. package/dist/client/EndpointOptionsSelect.d.ts +46 -0
  48. package/dist/client/EndpointOptionsSelect.js +106 -0
  49. package/dist/client/EndpointOptionsSelect.js.map +1 -0
  50. package/dist/client/FieldBlockLabel.d.ts +18 -0
  51. package/dist/client/FieldBlockLabel.js +34 -0
  52. package/dist/client/FieldBlockLabel.js.map +1 -0
  53. package/dist/client/FieldNameSelect.d.ts +21 -4
  54. package/dist/client/FieldNameSelect.js +29 -15
  55. package/dist/client/FieldNameSelect.js.map +1 -1
  56. package/dist/client/FlowBuilder.d.ts +2 -1
  57. package/dist/client/FlowBuilder.js +63 -57
  58. package/dist/client/FlowBuilder.js.map +1 -1
  59. package/dist/client/RecipientsSelect.d.ts +31 -0
  60. package/dist/client/RecipientsSelect.js +174 -0
  61. package/dist/client/RecipientsSelect.js.map +1 -0
  62. package/dist/client/RuleDescription.d.ts +21 -0
  63. package/dist/client/RuleDescription.js +19 -0
  64. package/dist/client/RuleDescription.js.map +1 -0
  65. package/dist/client/admin.css +41 -0
  66. package/dist/client/endpointOptions.js +29 -0
  67. package/dist/client/endpointOptions.js.map +1 -0
  68. package/dist/client/flowAuthoring.js +114 -7
  69. package/dist/client/flowAuthoring.js.map +1 -1
  70. package/dist/client/synthesizeClientField.js +15 -8
  71. package/dist/client/synthesizeClientField.js.map +1 -1
  72. package/dist/collections/buttonFields.d.ts +34 -0
  73. package/dist/collections/buttonFields.js +35 -0
  74. package/dist/collections/buttonFields.js.map +1 -0
  75. package/dist/collections/cells/FieldCountCell.d.ts +15 -0
  76. package/dist/collections/cells/FieldCountCell.js +18 -0
  77. package/dist/collections/cells/FieldCountCell.js.map +1 -0
  78. package/dist/collections/cells/FlowStepsCell.d.ts +14 -0
  79. package/dist/collections/cells/FlowStepsCell.js +17 -0
  80. package/dist/collections/cells/FlowStepsCell.js.map +1 -0
  81. package/dist/collections/formSubmissions.js +23 -17
  82. package/dist/collections/formSubmissions.js.map +1 -1
  83. package/dist/collections/forms.js +323 -134
  84. package/dist/collections/forms.js.map +1 -1
  85. package/dist/collections/redirectFields.d.ts +29 -0
  86. package/dist/consent/applyConsentStatements.d.ts +14 -0
  87. package/dist/consent/applyConsentStatements.js +17 -0
  88. package/dist/consent/applyConsentStatements.js.map +1 -0
  89. package/dist/consent/captureConsent.d.ts +31 -11
  90. package/dist/consent/captureConsent.js +53 -13
  91. package/dist/consent/captureConsent.js.map +1 -1
  92. package/dist/consent/consentSourcesField.d.ts +62 -0
  93. package/dist/consent/consentSourcesField.js +86 -0
  94. package/dist/consent/consentSourcesField.js.map +1 -0
  95. package/dist/consent/resolveConsentEntries.d.ts +24 -0
  96. package/dist/consent/resolveConsentEntries.js +43 -0
  97. package/dist/consent/resolveConsentEntries.js.map +1 -0
  98. package/dist/consent/resolveConsentSourcesRequest.d.ts +37 -0
  99. package/dist/consent/resolveConsentSourcesRequest.js +55 -0
  100. package/dist/consent/resolveConsentSourcesRequest.js.map +1 -0
  101. package/dist/consent/resolveConsentStatements.d.ts +45 -0
  102. package/dist/consent/resolveConsentStatements.js +44 -0
  103. package/dist/consent/resolveConsentStatements.js.map +1 -0
  104. package/dist/consent/resolvePublishedVersionRef.d.ts +17 -11
  105. package/dist/consent/resolvePublishedVersionRef.js +13 -10
  106. package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
  107. package/dist/consent/types.d.ts +53 -0
  108. package/dist/email/departments.d.ts +59 -0
  109. package/dist/email/departments.js +87 -0
  110. package/dist/email/departments.js.map +1 -0
  111. package/dist/email/departmentsField.d.ts +53 -0
  112. package/dist/email/departmentsField.js +73 -0
  113. package/dist/email/departmentsField.js.map +1 -0
  114. package/dist/exports/client.d.ts +11 -1
  115. package/dist/exports/client.js +11 -1
  116. package/dist/exports/react.d.ts +8 -3
  117. package/dist/exports/react.js +6 -2
  118. package/dist/exports/rsc.d.ts +3 -1
  119. package/dist/exports/rsc.js +4 -2
  120. package/dist/exports/types.d.ts +16 -8
  121. package/dist/fields/buildFieldBlocks.js +28 -13
  122. package/dist/fields/buildFieldBlocks.js.map +1 -1
  123. package/dist/fields/builtin/calculation.js +7 -0
  124. package/dist/fields/builtin/calculation.js.map +1 -1
  125. package/dist/fields/builtin/checkbox.js +8 -0
  126. package/dist/fields/builtin/checkbox.js.map +1 -1
  127. package/dist/fields/builtin/consent.js +32 -21
  128. package/dist/fields/builtin/consent.js.map +1 -1
  129. package/dist/fields/builtin/country.d.ts +13 -0
  130. package/dist/fields/builtin/country.js +30 -0
  131. package/dist/fields/builtin/country.js.map +1 -0
  132. package/dist/fields/builtin/date.js +2 -0
  133. package/dist/fields/builtin/date.js.map +1 -1
  134. package/dist/fields/builtin/file.js +14 -7
  135. package/dist/fields/builtin/file.js.map +1 -1
  136. package/dist/fields/builtin/index.d.ts +8 -6
  137. package/dist/fields/builtin/index.js +12 -11
  138. package/dist/fields/builtin/index.js.map +1 -1
  139. package/dist/fields/builtin/message.js +8 -4
  140. package/dist/fields/builtin/message.js.map +1 -1
  141. package/dist/fields/builtin/repeater.js +1 -0
  142. package/dist/fields/builtin/repeater.js.map +1 -1
  143. package/dist/fields/builtin/select.js +1 -0
  144. package/dist/fields/builtin/select.js.map +1 -1
  145. package/dist/fields/builtin/state.d.ts +13 -0
  146. package/dist/fields/builtin/state.js +30 -0
  147. package/dist/fields/builtin/state.js.map +1 -0
  148. package/dist/fields/data/regions.d.ts +21 -0
  149. package/dist/fields/data/regions.js +1238 -0
  150. package/dist/fields/data/regions.js.map +1 -0
  151. package/dist/fields/fieldKey.d.ts +15 -0
  152. package/dist/fields/fieldKey.js +16 -0
  153. package/dist/fields/fieldKey.js.map +1 -0
  154. package/dist/fields/fieldNamesOfType.js +13 -8
  155. package/dist/fields/fieldNamesOfType.js.map +1 -1
  156. package/dist/fields/instanceOptions.js +20 -0
  157. package/dist/fields/instanceOptions.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 +46 -9
  162. package/dist/fields/sharedConfig.js.map +1 -1
  163. package/dist/fields/types.d.ts +63 -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 +16 -7
  168. package/dist/flow/normalizeFlow.js.map +1 -1
  169. package/dist/flow/types.d.ts +12 -3
  170. package/dist/flow/types.js +11 -0
  171. package/dist/flow/types.js.map +1 -0
  172. package/dist/form/pollState.d.ts +4 -4
  173. package/dist/form/pollState.js.map +1 -1
  174. package/dist/form/toFormDocument.d.ts +54 -12
  175. package/dist/form/toFormDocument.js +56 -8
  176. package/dist/form/toFormDocument.js.map +1 -1
  177. package/dist/form/types.d.ts +31 -14
  178. package/dist/index.d.ts +153 -29
  179. package/dist/index.js +47 -15
  180. package/dist/index.js.map +1 -1
  181. package/dist/plugin/customState.js +26 -0
  182. package/dist/plugin/customState.js.map +1 -0
  183. package/dist/plugin/registerCollections.js +24 -13
  184. package/dist/plugin/registerCollections.js.map +1 -1
  185. package/dist/plugin/uploadsCollection.d.ts +5 -0
  186. package/dist/plugin/uploadsCollection.js +10 -1
  187. package/dist/plugin/uploadsCollection.js.map +1 -1
  188. package/dist/poll/applyPollOptions.js +3 -2
  189. package/dist/poll/applyPollOptions.js.map +1 -1
  190. package/dist/poll/buildPollOptionSourceFields.js +2 -5
  191. package/dist/poll/buildPollOptionSourceFields.js.map +1 -1
  192. package/dist/poll/closeJob.d.ts +52 -0
  193. package/dist/poll/closeJob.js +119 -0
  194. package/dist/poll/closeJob.js.map +1 -0
  195. package/dist/poll/definePollOptionSource.d.ts +10 -1
  196. package/dist/poll/definePollOptionSource.js.map +1 -1
  197. package/dist/poll/definePollType.d.ts +34 -0
  198. package/dist/poll/definePollType.js +6 -0
  199. package/dist/poll/definePollType.js.map +1 -0
  200. package/dist/poll/effectivePollOptions.d.ts +38 -0
  201. package/dist/poll/effectivePollOptions.js +64 -0
  202. package/dist/poll/effectivePollOptions.js.map +1 -0
  203. package/dist/poll/mostVoted.d.ts +21 -0
  204. package/dist/poll/mostVoted.js +32 -0
  205. package/dist/poll/mostVoted.js.map +1 -0
  206. package/dist/poll/outcomeBeforeChange.js +91 -0
  207. package/dist/poll/outcomeBeforeChange.js.map +1 -0
  208. package/dist/poll/outcomeFields.d.ts +38 -0
  209. package/dist/poll/outcomeFields.js +52 -0
  210. package/dist/poll/outcomeFields.js.map +1 -0
  211. package/dist/poll/pollTypeRegistry.d.ts +34 -0
  212. package/dist/poll/pollTypeRegistry.js +71 -0
  213. package/dist/poll/pollTypeRegistry.js.map +1 -0
  214. package/dist/poll/resolvePollCloseRequest.js +105 -0
  215. package/dist/poll/resolvePollCloseRequest.js.map +1 -0
  216. package/dist/poll/resolvePollOptions.d.ts +2 -1
  217. package/dist/poll/resolvePollOptions.js +5 -17
  218. package/dist/poll/resolvePollOptions.js.map +1 -1
  219. package/dist/poll/resolvePollOptionsRequest.js +51 -0
  220. package/dist/poll/resolvePollOptionsRequest.js.map +1 -0
  221. package/dist/poll/resolvePollOutcome.d.ts +22 -9
  222. package/dist/poll/resolvePollOutcome.js +54 -14
  223. package/dist/poll/resolvePollOutcome.js.map +1 -1
  224. package/dist/poll/resultsField.js +21 -0
  225. package/dist/poll/resultsField.js.map +1 -0
  226. package/dist/prefill/valuesFromSearchParams.js +2 -1
  227. package/dist/prefill/valuesFromSearchParams.js.map +1 -1
  228. package/dist/react/Form.d.ts +8 -8
  229. package/dist/react/Form.js +74 -62
  230. package/dist/react/Form.js.map +1 -1
  231. package/dist/react/FormContext.d.ts +6 -4
  232. package/dist/react/FormContext.js.map +1 -1
  233. package/dist/react/FormControls.d.ts +3 -3
  234. package/dist/react/FormControls.js +3 -3
  235. package/dist/react/FormControls.js.map +1 -1
  236. package/dist/react/FormResults.d.ts +5 -5
  237. package/dist/react/FormResults.js +6 -6
  238. package/dist/react/FormResults.js.map +1 -1
  239. package/dist/react/Poll.d.ts +2 -2
  240. package/dist/react/Poll.js +5 -5
  241. package/dist/react/Poll.js.map +1 -1
  242. package/dist/react/contract.d.ts +2 -3
  243. package/dist/react/contract.js.map +1 -1
  244. package/dist/react/primitives/Checkbox.d.ts +4 -2
  245. package/dist/react/primitives/Checkbox.js +2 -1
  246. package/dist/react/primitives/Checkbox.js.map +1 -1
  247. package/dist/react/primitives/FieldShell.d.ts +2 -4
  248. package/dist/react/primitives/FieldShell.js +12 -19
  249. package/dist/react/primitives/FieldShell.js.map +1 -1
  250. package/dist/react/renderers/calculation.js +1 -2
  251. package/dist/react/renderers/calculation.js.map +1 -1
  252. package/dist/react/renderers/checkbox.js +1 -2
  253. package/dist/react/renderers/checkbox.js.map +1 -1
  254. package/dist/react/renderers/consent.js +78 -34
  255. package/dist/react/renderers/consent.js.map +1 -1
  256. package/dist/react/renderers/date.js +1 -3
  257. package/dist/react/renderers/date.js.map +1 -1
  258. package/dist/react/renderers/email.js +1 -2
  259. package/dist/react/renderers/email.js.map +1 -1
  260. package/dist/react/renderers/file.js +1 -2
  261. package/dist/react/renderers/file.js.map +1 -1
  262. package/dist/react/renderers/index.js +3 -0
  263. package/dist/react/renderers/index.js.map +1 -1
  264. package/dist/react/renderers/number.js +1 -2
  265. package/dist/react/renderers/number.js.map +1 -1
  266. package/dist/react/renderers/region.js +45 -0
  267. package/dist/react/renderers/region.js.map +1 -0
  268. package/dist/react/renderers/repeater.js +7 -10
  269. package/dist/react/renderers/repeater.js.map +1 -1
  270. package/dist/react/renderers/select.js +1 -2
  271. package/dist/react/renderers/select.js.map +1 -1
  272. package/dist/react/renderers/text.js +1 -2
  273. package/dist/react/renderers/text.js.map +1 -1
  274. package/dist/react/renderers/textarea.js +1 -2
  275. package/dist/react/renderers/textarea.js.map +1 -1
  276. package/dist/react/state.d.ts +0 -3
  277. package/dist/react/state.js +7 -11
  278. package/dist/react/state.js.map +1 -1
  279. package/dist/react/useField.d.ts +0 -1
  280. package/dist/react/useField.js +0 -1
  281. package/dist/react/useField.js.map +1 -1
  282. package/dist/react/useFormState.d.ts +1 -1
  283. package/dist/react/useFormState.js +1 -1
  284. package/dist/react/useFormState.js.map +1 -1
  285. package/dist/react/validateField.js +3 -6
  286. package/dist/react/validateField.js.map +1 -1
  287. package/dist/recall/interpolate.d.ts +4 -3
  288. package/dist/recall/interpolate.js +5 -4
  289. package/dist/recall/interpolate.js.map +1 -1
  290. package/dist/recall/resolver.d.ts +1 -1
  291. package/dist/recall/resolver.js +14 -2
  292. package/dist/recall/resolver.js.map +1 -1
  293. package/dist/spam/captcha.d.ts +1 -1
  294. package/dist/spam/captcha.js +1 -1
  295. package/dist/spam/captcha.js.map +1 -1
  296. package/dist/submissions/SubmissionAnswers.js +6 -2
  297. package/dist/submissions/SubmissionAnswers.js.map +1 -1
  298. package/dist/submissions/SubmissionAnswersClient.js +100 -64
  299. package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
  300. package/dist/submissions/createSubmission.d.ts +36 -0
  301. package/dist/submissions/createSubmission.js +26 -0
  302. package/dist/submissions/createSubmission.js.map +1 -0
  303. package/dist/submissions/runSubmission.d.ts +10 -0
  304. package/dist/submissions/runSubmission.js +31 -19
  305. package/dist/submissions/runSubmission.js.map +1 -1
  306. package/dist/submissions/types.d.ts +11 -4
  307. package/dist/submissions/validateSubmission.js +39 -23
  308. package/dist/submissions/validateSubmission.js.map +1 -1
  309. package/dist/submissions/votedCookie.js +3 -3
  310. package/dist/submissions/votedCookie.js.map +1 -1
  311. package/dist/translations/de.js +104 -26
  312. package/dist/translations/de.js.map +1 -1
  313. package/dist/translations/en.js +105 -27
  314. package/dist/translations/en.js.map +1 -1
  315. package/dist/translations/keys.d.ts +99 -21
  316. package/dist/translations/keys.js +100 -22
  317. package/dist/translations/keys.js.map +1 -1
  318. package/dist/uploads/resolveFileRef.js +2 -1
  319. package/dist/uploads/resolveFileRef.js.map +1 -1
  320. package/dist/validation/buildRuleBlocks.js +18 -17
  321. package/dist/validation/buildRuleBlocks.js.map +1 -1
  322. package/dist/validation/builtin/email.js +1 -0
  323. package/dist/validation/builtin/email.js.map +1 -1
  324. package/dist/validation/builtin/matchesField.js +3 -7
  325. package/dist/validation/builtin/matchesField.js.map +1 -1
  326. package/dist/validation/builtin/max.js +1 -0
  327. package/dist/validation/builtin/max.js.map +1 -1
  328. package/dist/validation/builtin/maxDate.js +1 -0
  329. package/dist/validation/builtin/maxDate.js.map +1 -1
  330. package/dist/validation/builtin/maxLength.js +1 -0
  331. package/dist/validation/builtin/maxLength.js.map +1 -1
  332. package/dist/validation/builtin/min.js +1 -0
  333. package/dist/validation/builtin/min.js.map +1 -1
  334. package/dist/validation/builtin/minDate.js +1 -0
  335. package/dist/validation/builtin/minDate.js.map +1 -1
  336. package/dist/validation/builtin/minLength.js +1 -0
  337. package/dist/validation/builtin/minLength.js.map +1 -1
  338. package/dist/validation/builtin/notAlreadySubmitted.js +1 -0
  339. package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
  340. package/dist/validation/builtin/oneOf.js +1 -0
  341. package/dist/validation/builtin/oneOf.js.map +1 -1
  342. package/dist/validation/builtin/pattern.js +11 -2
  343. package/dist/validation/builtin/pattern.js.map +1 -1
  344. package/dist/validation/builtin/url.js +1 -0
  345. package/dist/validation/builtin/url.js.map +1 -1
  346. package/dist/validation/builtin/validateRegexParams.js +44 -0
  347. package/dist/validation/builtin/validateRegexParams.js.map +1 -0
  348. package/dist/validation/fieldTargetParam.d.ts +22 -0
  349. package/dist/validation/fieldTargetParam.js +38 -0
  350. package/dist/validation/fieldTargetParam.js.map +1 -0
  351. package/dist/validation/runValidation.js +8 -29
  352. package/dist/validation/runValidation.js.map +1 -1
  353. package/dist/validation/types.d.ts +5 -11
  354. package/package.json +6 -6
  355. package/dist/consent/buildConsentSourceConfig.js +0 -49
  356. package/dist/consent/buildConsentSourceConfig.js.map +0 -1
  357. package/dist/consent/builtin/index.d.ts +0 -17
  358. package/dist/consent/builtin/index.js +0 -21
  359. package/dist/consent/builtin/index.js.map +0 -1
  360. package/dist/consent/builtin/pageReference.js +0 -75
  361. package/dist/consent/builtin/pageReference.js.map +0 -1
  362. package/dist/consent/builtin/static.js +0 -48
  363. package/dist/consent/builtin/static.js.map +0 -1
  364. package/dist/consent/defineConsentSource.d.ts +0 -35
  365. package/dist/consent/defineConsentSource.js +0 -6
  366. package/dist/consent/defineConsentSource.js.map +0 -1
  367. package/dist/consent/registry.d.ts +0 -16
  368. package/dist/consent/registry.js +0 -16
  369. package/dist/consent/registry.js.map +0 -1
  370. package/dist/consent/resolveConsentLinks.d.ts +0 -19
  371. package/dist/consent/resolveConsentLinks.js +0 -26
  372. package/dist/consent/resolveConsentLinks.js.map +0 -1
@@ -0,0 +1,73 @@
1
+ import { localizedIf } from "../fields/localizedIf.js";
2
+ import { keys } from "../translations/keys.js";
3
+ import { labelForKey } from "../translations/server.js";
4
+ //#region src/email/departmentsField.ts
5
+ /**
6
+ * The department-emails array, for the host to place on any collection or global they own: a
7
+ * settings global, a tenants collection, a departments parent, wherever the addresses belong. The
8
+ * plugin never registers it and never guesses where it lives; the `email.departments` resolver reads
9
+ * it back, which is also where multi-tenant scoping goes: place this on the tenant-scoped document
10
+ * and have the resolver return only that tenant's addresses, derived from `req`.
11
+ *
12
+ * A row is a `label` (how the address is named when routing a submission to it) and the `email` it
13
+ * resolves to. Because `email` is `localized` by default, a host can hold a different address per
14
+ * locale without changing the stored shape. The array itself is not localized, so per-locale edits
15
+ * must address existing rows by their own auto-assigned `id` rather than re-sending id-less rows.
16
+ *
17
+ * It renders condensed: `admin.components.Field` is {@link CondensedArray}, which lays each row out
18
+ * flat as `[label, email]` at 50% each with no per-row collapsible, while keeping Payload's native
19
+ * per-locale storage and row ids.
20
+ *
21
+ * ```ts
22
+ * // The host's own collection or global:
23
+ * fields: [departmentsField()]
24
+ *
25
+ * // The plugin, reading it back to route a submission. `resolveDepartmentOptions` reads the array
26
+ * // (fetched at `locale: 'all'`) and resolves each row's address for the requesting locale:
27
+ * formBuilder({
28
+ * email: {
29
+ * departments: async ({ req }) => {
30
+ * const settings = await req.payload.findGlobal({ slug: 'settings', depth: 0, locale: 'all' })
31
+ * return resolveDepartmentOptions({ payload: req.payload, req, doc: settings })
32
+ * },
33
+ * },
34
+ * })
35
+ * ```
36
+ *
37
+ * The read above omits the save's `req` on purpose: threading it into a `locale: 'all'` read from
38
+ * within a form's save validation flips `req.locale` to `all` and corrupts the localized write of the
39
+ * document being saved. It reads already-committed data, so no transaction (`req`) is needed.
40
+ */
41
+ const departmentsField = (options = {}) => {
42
+ const localize = options.localized !== false;
43
+ return {
44
+ name: options.name ?? "departmentEmails",
45
+ type: "array",
46
+ label: options.label ?? labelForKey(keys.departmentsField),
47
+ labels: {
48
+ singular: labelForKey(keys.departmentSingular),
49
+ plural: labelForKey(keys.departmentPlural)
50
+ },
51
+ admin: {
52
+ description: labelForKey(keys.departmentsFieldDescription),
53
+ components: { Field: "@10x-media/form-builder/client#CondensedArray" }
54
+ },
55
+ fields: [{
56
+ name: "label",
57
+ type: "text",
58
+ label: labelForKey(keys.departmentLabel),
59
+ admin: { width: "50%" },
60
+ ...localizedIf(localize)
61
+ }, {
62
+ name: "email",
63
+ type: "text",
64
+ label: labelForKey(keys.departmentEmail),
65
+ admin: { width: "50%" },
66
+ ...localizedIf(localize)
67
+ }]
68
+ };
69
+ };
70
+ //#endregion
71
+ export { departmentsField };
72
+
73
+ //# sourceMappingURL=departmentsField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"departmentsField.js","names":[],"sources":["../../src/email/departmentsField.ts"],"sourcesContent":["import type { ArrayField } from 'payload'\nimport { localizedIf } from '../fields/localizedIf'\nimport { keys } from '../translations/keys'\nimport { labelForKey } from '../translations/server'\n\nexport type DepartmentsFieldOptions = {\n\t/** Field name, i.e. what the row array is stored under. Defaults to `departmentEmails`. */\n\tname?: string\n\t/** Field label. Defaults to the plugin's translated one. */\n\tlabel?: ArrayField['label']\n\t/**\n\t * Whether each row's `email` (and its `label`) carry `localized: true`, so the same field can\n\t * hold a different address per locale. Default `true`; Payload strips the flag on hosts without\n\t * `localization`, so it is safe either way.\n\t */\n\tlocalized?: boolean\n}\n\n/**\n * The department-emails array, for the host to place on any collection or global they own: a\n * settings global, a tenants collection, a departments parent, wherever the addresses belong. The\n * plugin never registers it and never guesses where it lives; the `email.departments` resolver reads\n * it back, which is also where multi-tenant scoping goes: place this on the tenant-scoped document\n * and have the resolver return only that tenant's addresses, derived from `req`.\n *\n * A row is a `label` (how the address is named when routing a submission to it) and the `email` it\n * resolves to. Because `email` is `localized` by default, a host can hold a different address per\n * locale without changing the stored shape. The array itself is not localized, so per-locale edits\n * must address existing rows by their own auto-assigned `id` rather than re-sending id-less rows.\n *\n * It renders condensed: `admin.components.Field` is {@link CondensedArray}, which lays each row out\n * flat as `[label, email]` at 50% each with no per-row collapsible, while keeping Payload's native\n * per-locale storage and row ids.\n *\n * ```ts\n * // The host's own collection or global:\n * fields: [departmentsField()]\n *\n * // The plugin, reading it back to route a submission. `resolveDepartmentOptions` reads the array\n * // (fetched at `locale: 'all'`) and resolves each row's address for the requesting locale:\n * formBuilder({\n * email: {\n * departments: async ({ req }) => {\n * const settings = await req.payload.findGlobal({ slug: 'settings', depth: 0, locale: 'all' })\n * return resolveDepartmentOptions({ payload: req.payload, req, doc: settings })\n * },\n * },\n * })\n * ```\n *\n * The read above omits the save's `req` on purpose: threading it into a `locale: 'all'` read from\n * within a form's save validation flips `req.locale` to `all` and corrupts the localized write of the\n * document being saved. It reads already-committed data, so no transaction (`req`) is needed.\n */\nexport const departmentsField = (options: DepartmentsFieldOptions = {}): ArrayField => {\n\tconst localize = options.localized !== false\n\n\treturn {\n\t\tname: options.name ?? 'departmentEmails',\n\t\ttype: 'array',\n\t\tlabel: options.label ?? labelForKey(keys.departmentsField),\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.departmentSingular),\n\t\t\tplural: labelForKey(keys.departmentPlural),\n\t\t},\n\t\tadmin: {\n\t\t\tdescription: labelForKey(keys.departmentsFieldDescription),\n\t\t\tcomponents: { Field: '@10x-media/form-builder/client#CondensedArray' },\n\t\t},\n\t\tfields: [\n\t\t\t{\n\t\t\t\tname: 'label',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: labelForKey(keys.departmentLabel),\n\t\t\t\tadmin: { width: '50%' },\n\t\t\t\t...localizedIf(localize),\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'email',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: labelForKey(keys.departmentEmail),\n\t\t\t\tadmin: { width: '50%' },\n\t\t\t\t...localizedIf(localize),\n\t\t\t},\n\t\t],\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAa,oBAAoB,UAAmC,CAAC,MAAkB;CACtF,MAAM,WAAW,QAAQ,cAAc;CAEvC,OAAO;EACN,MAAM,QAAQ,QAAQ;EACtB,MAAM;EACN,OAAO,QAAQ,SAAS,YAAY,KAAK,gBAAgB;EACzD,QAAQ;GACP,UAAU,YAAY,KAAK,kBAAkB;GAC7C,QAAQ,YAAY,KAAK,gBAAgB;EAC1C;EACA,OAAO;GACN,aAAa,YAAY,KAAK,2BAA2B;GACzD,YAAY,EAAE,OAAO,gDAAgD;EACtE;EACA,QAAQ,CACP;GACC,MAAM;GACN,MAAM;GACN,OAAO,YAAY,KAAK,eAAe;GACvC,OAAO,EAAE,OAAO,MAAM;GACtB,GAAG,YAAY,QAAQ;EACxB,GACA;GACC,MAAM;GACN,MAAM;GACN,OAAO,YAAY,KAAK,eAAe;GACvC,OAAO,EAAE,OAAO,MAAM;GACtB,GAAG,YAAY,QAAQ;EACxB,CACD;CACD;AACD"}
@@ -1,5 +1,15 @@
1
1
  import { ByteSizeField } from "../client/ByteSizeField.js";
2
+ import { ClosePollButton } from "../client/ClosePollButton.js";
3
+ import { CondensedArray } from "../client/CondensedArray.js";
4
+ import { ConsentBlockLabel } from "../client/ConsentBlockLabel.js";
5
+ import { ConsentSourceRowLabel } from "../client/ConsentSourceRowLabel.js";
6
+ import { EndpointOptionsSelect } from "../client/EndpointOptionsSelect.js";
7
+ import { FieldBlockLabel } from "../client/FieldBlockLabel.js";
2
8
  import { FieldNameSelect } from "../client/FieldNameSelect.js";
3
9
  import { FlowBuilder } from "../client/FlowBuilder.js";
4
10
  import { FormConditionField } from "../client/FormConditionField.js";
5
- export { ByteSizeField, FieldNameSelect, FlowBuilder, FormConditionField };
11
+ import { RecipientsSelect } from "../client/RecipientsSelect.js";
12
+ import { RuleDescription } from "../client/RuleDescription.js";
13
+ import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
14
+ import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
15
+ export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
@@ -1,6 +1,16 @@
1
1
  "use client";
2
2
  import { ByteSizeField } from "../client/ByteSizeField.js";
3
+ import { ClosePollButton } from "../client/ClosePollButton.js";
4
+ import { CondensedArray } from "../client/CondensedArray.js";
5
+ import { ConsentBlockLabel } from "../client/ConsentBlockLabel.js";
6
+ import { ConsentSourceRowLabel } from "../client/ConsentSourceRowLabel.js";
7
+ import { EndpointOptionsSelect } from "../client/EndpointOptionsSelect.js";
8
+ import { FieldBlockLabel } from "../client/FieldBlockLabel.js";
3
9
  import { FieldNameSelect } from "../client/FieldNameSelect.js";
4
10
  import { FlowBuilder } from "../client/FlowBuilder.js";
5
11
  import { FormConditionField } from "../client/FormConditionField.js";
6
- export { ByteSizeField, FieldNameSelect, FlowBuilder, FormConditionField };
12
+ import { RecipientsSelect } from "../client/RecipientsSelect.js";
13
+ import { RuleDescription } from "../client/RuleDescription.js";
14
+ import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
15
+ import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
16
+ export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
@@ -1,13 +1,18 @@
1
1
  import { FormFieldInstance, SubmissionValue } from "../submissions/types.js";
2
+ import { sanitizeUrl } from "../actions/body/converters.js";
2
3
  import { BodyContext, serializeBody } from "../actions/body/serializeBody.js";
4
+ import { textOfBody } from "../actions/body/textOfBody.js";
3
5
  import { AggregationBucket, FieldAggregation } from "../aggregation/types.js";
4
6
  import { CalcExpression } from "../calc/types.js";
5
7
  import { computeCalcFields } from "../calc/computeCalcFields.js";
6
8
  import { evaluateCalc } from "../calc/evaluate.js";
7
9
  import { evaluateCondition } from "../conditions/evaluate.js";
10
+ import { ConsentStatement, ConsentStatements } from "../consent/resolveConsentStatements.js";
11
+ import { COUNTRIES, US_STATES } from "../fields/data/regions.js";
12
+ import { fieldKey } from "../fields/fieldKey.js";
8
13
  import { firstStepId, isTerminalStepId, resolveNextStepId, stepFieldNames } from "../flow/engine.js";
9
- import { FormDisplaySettings, FormDocument, FormPollSettings, FormResponseSettings } from "../form/types.js";
10
- import { toFormDocument } from "../form/toFormDocument.js";
14
+ import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSettings } from "../form/types.js";
15
+ import { ToFormDocumentOptions, toFormDocument } from "../form/toFormDocument.js";
11
16
  import { PrefillOptions, valuesFromSearchParams } from "../prefill/valuesFromSearchParams.js";
12
17
  import { CaptchaWidgetHandle } from "../react/captcha/types.js";
13
18
  import { HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, HcaptchaCaptchaProps } from "../react/captcha/HcaptchaCaptcha.js";
@@ -51,4 +56,4 @@ import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "../spam/constants.js"
51
56
  import { en } from "../translations/en.js";
52
57
  import { makeTranslate } from "../translations/makeTranslate.js";
53
58
  import { formatBytes } from "../uploads/formatBytes.js";
54
- export { type AggregationBucket, type BackButtonRenderProps, Backdrop, type BackdropProps, type BodyContext, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaWidgetHandle, Checkbox, type CheckboxProps, DEFAULT_HONEYPOT_FIELD, DialogSurface, type DialogSurfaceProps, type FetchResultsInput, type FetchResultsResult, type FieldAggregation, type FieldErrors, type FieldRenderer, type FieldRendererProps, FieldShell, type FieldShellProps, type FieldWidth, Form, type FormAction, type FormContextValue, type FormControlLabels, FormControls, type FormControlsProps, type FormDisplaySettings, type FormDocument, type FormFieldInstance, FormLayout, type FormLayoutProps, type FormPollSettings, type FormPresentation, type FormProps, type FormResponseSettings, FormResults, type FormResultsProps, type FormState, type FormStepInfo, FormSteps, type FormStepsProps, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, type HcaptchaCaptchaProps, Honeypot, type HoneypotProps, Input, type InputProps, type NextButtonRenderProps, Poll, type PollProps, type PrefillOptions, type PresentationOption, type PresentationRegistry, type PresentationWrapperProps, type PresentationsConfig, RECAPTCHA_SCRIPT_URL, type RecallResolver, RecaptchaCaptcha, type RecaptchaCaptchaHandle, type RecaptchaCaptchaProps, type RendererOption, type RendererRegistry, type RendererTranslate, type RenderersConfig, Select, type SelectOption, type SelectProps, type SubmissionValue, type SubmitButtonRenderProps, type SubmitFormResult, type SubmitHandler, TURNSTILE_SCRIPT_URL, Textarea, type TextareaProps, TurnstileCaptcha, type TurnstileCaptchaProps, type UploadFileInput, type UploadFileResult, type UseDismissOptions, type UseFieldResult, buildRecallResolver, cn, computeCalcFields, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, firstStepId, formatBytes, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, serializeBody, stepFieldNames, submitForm, toFormDocument, uploadFile, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
59
+ export { type AggregationBucket, type BackButtonRenderProps, Backdrop, type BackdropProps, type BodyContext, CAPTCHA_TOKEN_KEY, COUNTRIES, type CalcExpression, type CaptchaWidgetHandle, Checkbox, type CheckboxProps, type ConsentStatement, type ConsentStatements, DEFAULT_HONEYPOT_FIELD, DialogSurface, type DialogSurfaceProps, type FetchResultsInput, type FetchResultsResult, type FieldAggregation, type FieldErrors, type FieldRenderer, type FieldRendererProps, FieldShell, type FieldShellProps, type FieldWidth, Form, type FormAction, type FormButtonSettings, type FormContextValue, type FormControlLabels, FormControls, type FormControlsProps, type FormDocument, type FormFieldInstance, FormLayout, type FormLayoutProps, type FormPollSettings, type FormPresentation, type FormProps, type FormResponseSettings, FormResults, type FormResultsProps, type FormState, type FormStepInfo, FormSteps, type FormStepsProps, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, type HcaptchaCaptchaProps, Honeypot, type HoneypotProps, Input, type InputProps, type NextButtonRenderProps, Poll, type PollProps, type PrefillOptions, type PresentationOption, type PresentationRegistry, type PresentationWrapperProps, type PresentationsConfig, RECAPTCHA_SCRIPT_URL, type RecallResolver, RecaptchaCaptcha, type RecaptchaCaptchaHandle, type RecaptchaCaptchaProps, type RendererOption, type RendererRegistry, type RendererTranslate, type RenderersConfig, Select, type SelectOption, type SelectProps, type SubmissionValue, type SubmitButtonRenderProps, type SubmitFormResult, type SubmitHandler, TURNSTILE_SCRIPT_URL, Textarea, type TextareaProps, type ToFormDocumentOptions, TurnstileCaptcha, type TurnstileCaptchaProps, US_STATES, type UploadFileInput, type UploadFileResult, type UseDismissOptions, type UseFieldResult, buildRecallResolver, cn, computeCalcFields, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uploadFile, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
@@ -1,11 +1,15 @@
1
1
  "use client";
2
2
  import { interpolate } from "../recall/interpolate.js";
3
+ import { sanitizeUrl } from "../actions/body/converters.js";
3
4
  import { serializeBody } from "../actions/body/serializeBody.js";
4
5
  import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "../spam/constants.js";
6
+ import { fieldKey } from "../fields/fieldKey.js";
5
7
  import { evaluateCalc } from "../calc/evaluate.js";
6
8
  import { computeCalcFields } from "../calc/computeCalcFields.js";
7
9
  import { evaluateCondition } from "../conditions/evaluate.js";
10
+ import { textOfBody } from "../actions/body/textOfBody.js";
8
11
  import { en } from "../translations/en.js";
12
+ import { COUNTRIES, US_STATES } from "../fields/data/regions.js";
9
13
  import { toFormDocument } from "../form/toFormDocument.js";
10
14
  import { valuesFromSearchParams } from "../prefill/valuesFromSearchParams.js";
11
15
  import { buildRecallResolver } from "../recall/resolver.js";
@@ -33,8 +37,8 @@ import { FieldShell } from "../react/primitives/FieldShell.js";
33
37
  import { Checkbox } from "../react/primitives/Checkbox.js";
34
38
  import { Input } from "../react/primitives/Input.js";
35
39
  import { uploadFile } from "../react/uploadFile.js";
36
- import { useField } from "../react/useField.js";
37
40
  import { Select } from "../react/primitives/Select.js";
41
+ import { useField } from "../react/useField.js";
38
42
  import { Textarea } from "../react/primitives/Textarea.js";
39
43
  import { defaultRenderers } from "../react/renderers/index.js";
40
44
  import { submitForm } from "../react/submitForm.js";
@@ -45,4 +49,4 @@ import { fetchFormResults } from "../react/fetchResults.js";
45
49
  import { Poll } from "../react/Poll.js";
46
50
  import { useFormState } from "../react/useFormState.js";
47
51
  import { useFormStep } from "../react/useFormStep.js";
48
- export { Backdrop, CAPTCHA_TOKEN_KEY, Checkbox, DEFAULT_HONEYPOT_FIELD, DialogSurface, FieldShell, Form, FormControls, FormLayout, FormResults, FormSteps, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, Honeypot, Input, Poll, RECAPTCHA_SCRIPT_URL, RecaptchaCaptcha, Select, TURNSTILE_SCRIPT_URL, Textarea, TurnstileCaptcha, buildRecallResolver, cn, computeCalcFields, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, firstStepId, formatBytes, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, serializeBody, stepFieldNames, submitForm, toFormDocument, uploadFile, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
52
+ export { Backdrop, CAPTCHA_TOKEN_KEY, COUNTRIES, Checkbox, DEFAULT_HONEYPOT_FIELD, DialogSurface, FieldShell, Form, FormControls, FormLayout, FormResults, FormSteps, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, Honeypot, Input, Poll, RECAPTCHA_SCRIPT_URL, RecaptchaCaptcha, Select, TURNSTILE_SCRIPT_URL, Textarea, TurnstileCaptcha, US_STATES, buildRecallResolver, cn, computeCalcFields, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uploadFile, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
@@ -1,7 +1,9 @@
1
+ import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
1
2
  import { toFormDocument } from "../form/toFormDocument.js";
2
3
  import { isPollClosed } from "../form/pollState.js";
4
+ import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
3
5
  import { resolvePollOptions } from "../poll/resolvePollOptions.js";
4
6
  import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
5
7
  import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
6
8
  import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
7
- export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
9
+ export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
@@ -1,7 +1,9 @@
1
1
  import { isPollClosed } from "../form/pollState.js";
2
2
  import { resolvePollOptions } from "../poll/resolvePollOptions.js";
3
+ import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
4
+ import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
5
+ import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
3
6
  import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
4
7
  import { toFormDocument } from "../form/toFormDocument.js";
5
- import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
6
8
  import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
7
- export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
9
+ export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
@@ -1,28 +1,36 @@
1
+ import { FormFieldInstance, SubmissionDescriptor, SubmissionFieldError, SubmissionValue, SubmissionWidth } from "../submissions/types.js";
1
2
  import { FileFieldConfig, FileRef, FileRefError } from "../uploads/types.js";
2
- import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind } from "../fields/types.js";
3
- import { FormFieldInstance, SubmissionDescriptor, SubmissionFieldError, SubmissionValue } from "../submissions/types.js";
3
+ import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind, OmittableSharedField } from "../fields/types.js";
4
+ import { RichTextBodyOption } from "../actions/body/serializeBody.js";
4
5
  import { AggregationBucket, AggregationRow, FieldAggregation, FieldMeta, SubmissionStatusFilter } from "../aggregation/types.js";
5
6
  import { CalcExpression } from "../calc/types.js";
7
+ import { ConsentSourceEntry, ConsentSourcePage, ConsentSourcesResolver } from "../consent/types.js";
8
+ import { ConsentStatement, ConsentStatements, ResolveConsentStatementsArgs } from "../consent/resolveConsentStatements.js";
6
9
  import { FlowStep, FlowTransition, FormFlow } from "../flow/types.js";
7
- import { FormDisplaySettings, FormDocument, FormPollSettings, FormResponseSettings } from "../form/types.js";
10
+ import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSettings } from "../form/types.js";
8
11
  import { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from "../fields/registry.js";
9
12
  import { PrefillOptions } from "../prefill/valuesFromSearchParams.js";
10
13
  import { FormEvent, FormEventSink } from "../events/types.js";
11
- import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult, ValidationSeverity } from "../validation/types.js";
14
+ import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult } from "../validation/types.js";
12
15
  import { PresentationDensity, PresentationDescriptor, PresentationSurface } from "../presentations/types.js";
13
16
  import { RecallResolver } from "../recall/resolver.js";
17
+ import { PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig } from "../poll/registry.js";
14
18
  import { ActionDefinition, ActionRunArgs, AnyActionDefinition } from "../actions/defineAction.js";
19
+ import { FromAddressOption, FromAddressesResolver } from "../actions/fromAddresses.js";
15
20
  import { ActionOption, ActionRegistry, ActionsConfig } from "../actions/registry.js";
16
21
  import { ActionResult } from "../actions/runActions.js";
17
22
  import { AggregateFieldResponsesArgs, AggregateFormResponsesArgs } from "../aggregation/aggregateResponses.js";
18
- import { ResolveResultsRequestArgs, ResolveResultsRequestResult } from "../aggregation/resolveResultsRequest.js";
23
+ import { FormResultsAccess, FormResultsAccessArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult } from "../aggregation/resolveResultsRequest.js";
24
+ import { ButtonFieldsOverride, ButtonsOption, DefaultButtonFields } from "../collections/buttonFields.js";
19
25
  import { FieldCondition } from "../conditions/types.js";
20
- import { AnyConsentSource, ConsentLink, ConsentResolveArgs, ConsentResolved, ConsentSource } from "../consent/defineConsentSource.js";
21
- import { ConsentSourceOption, ConsentSourceRegistry, ConsentSourcesConfig } from "../consent/registry.js";
22
26
  import { ConsentProof } from "../consent/captureConsent.js";
27
+ import { ConsentSourcesFieldOptions } from "../consent/consentSourcesField.js";
28
+ import { ResolveConsentEntriesArgs } from "../consent/resolveConsentEntries.js";
29
+ import { ConsentSourceOption, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult } from "../consent/resolveConsentSourcesRequest.js";
30
+ import { ResolvePublishedVersionRefArgs } from "../consent/resolvePublishedVersionRef.js";
23
31
  import { CollectionOverrides, FieldsOverride } from "../plugin/collectionOverrides.js";
24
32
  import { CaptchaProvider, CaptchaVerifyArgs, IdentifyFn, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, SpamConfig, SpamMetadataConfig, SpamOption } from "../spam/types.js";
25
33
  import { UploadsOption } from "../plugin/uploadsCollection.js";
26
34
  import { ValidationRuleOption, ValidationRuleRegistry, ValidationRulesConfig } from "../validation/registry.js";
27
35
  import { FormBuilderPluginOptions } from "../index.js";
28
- export type { ActionDefinition, ActionOption, ActionRegistry, ActionResult, ActionRunArgs, ActionsConfig, AggregateFieldResponsesArgs, AggregateFormResponsesArgs, AggregationBucket, AggregationRow, AnyActionDefinition, AnyConsentSource, AnyFormFieldDefinition, AnyValidationRuleDefinition, CalcExpression, CaptchaProvider, CaptchaVerifyArgs, CollectionOverrides, ConsentLink, ConsentProof, ConsentResolveArgs, ConsentResolved, ConsentSource, ConsentSourceOption, ConsentSourceRegistry, ConsentSourcesConfig, FieldAggregation, FieldCondition, FieldMeta, FieldTypeOption, FieldTypeRegistry, FieldTypesConfig, FieldsOverride, FileFieldConfig, FileRef, FileRefError, FlowStep, FlowTransition, FormBuilderPluginOptions, FormDisplaySettings, FormDocument, FormEvent, FormEventSink, FormFieldDefinition, FormFieldFormat, FormFieldInstance, FormFieldValidate, FormFieldValueKind, FormFlow, FormPollSettings, FormResponseSettings, IdentifyFn, PrefillOptions, PresentationDensity, PresentationDescriptor, PresentationSurface, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, RecallResolver, ResolveResultsRequestArgs, ResolveResultsRequestResult, SpamConfig, SpamMetadataConfig, SpamOption, SubmissionDescriptor, SubmissionFieldError, SubmissionStatusFilter, SubmissionValue, UploadsOption, ValidationRuleDefinition, ValidationRuleOption, ValidationRuleRegistry, ValidationRuleResult, ValidationRulesConfig, ValidationSeverity };
36
+ export type { ActionDefinition, ActionOption, ActionRegistry, ActionResult, ActionRunArgs, ActionsConfig, AggregateFieldResponsesArgs, AggregateFormResponsesArgs, AggregationBucket, AggregationRow, AnyActionDefinition, AnyFormFieldDefinition, AnyValidationRuleDefinition, ButtonFieldsOverride, ButtonsOption, CalcExpression, CaptchaProvider, CaptchaVerifyArgs, CollectionOverrides, ConsentProof, ConsentSourceEntry, ConsentSourceOption, ConsentSourcePage, ConsentSourcesFieldOptions, ConsentSourcesResolver, ConsentStatement, ConsentStatements, DefaultButtonFields, FieldAggregation, FieldCondition, FieldMeta, FieldTypeOption, FieldTypeRegistry, FieldTypesConfig, FieldsOverride, FileFieldConfig, FileRef, FileRefError, FlowStep, FlowTransition, FormBuilderPluginOptions, FormButtonSettings, FormDocument, FormEvent, FormEventSink, FormFieldDefinition, FormFieldFormat, FormFieldInstance, FormFieldValidate, FormFieldValueKind, FormFlow, FormPollSettings, FormResponseSettings, FormResultsAccess, FormResultsAccessArgs, FromAddressOption, FromAddressesResolver, IdentifyFn, OmittableSharedField, PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig, PrefillOptions, PresentationDensity, PresentationDescriptor, PresentationSurface, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, RecallResolver, ResolveConsentEntriesArgs, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult, ResolveConsentStatementsArgs, ResolvePublishedVersionRefArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, RichTextBodyOption, SpamConfig, SpamMetadataConfig, SpamOption, SubmissionDescriptor, SubmissionFieldError, SubmissionStatusFilter, SubmissionValue, SubmissionWidth, UploadsOption, ValidationRuleDefinition, ValidationRuleOption, ValidationRuleRegistry, ValidationRuleResult, ValidationRulesConfig };
@@ -1,10 +1,18 @@
1
1
  import { keys } from "../translations/keys.js";
2
2
  import { labelFor } from "../translations/server.js";
3
3
  import { buildConditionTypeMap } from "../conditions/conditionType.js";
4
- import { buildConsentSourceConfig } from "../consent/buildConsentSourceConfig.js";
5
4
  import { buildRuleBlocks } from "../validation/buildRuleBlocks.js";
6
5
  import { fieldBlockTabs } from "./sharedConfig.js";
7
6
  //#region src/fields/buildFieldBlocks.ts
7
+ const FIELD_BLOCK_LABEL_REF = "@10x-media/form-builder/client#FieldBlockLabel";
8
+ /**
9
+ * Replace Payload's default `blockName` row header (which reads "Untitled" until filled) with the
10
+ * field's own `label`, keyed to the type label as fallback. See `FieldBlockLabel`.
11
+ */
12
+ const blockLabelAdmin = (typeLabelKey, ref = FIELD_BLOCK_LABEL_REF) => ({ components: { Label: {
13
+ path: ref,
14
+ clientProps: { typeLabelKey }
15
+ } } });
8
16
  /** Whether `fields` contains a field named `name`, descending into presentational rows. */
9
17
  const hasNameField = (fields) => fields.some((f) => {
10
18
  if ("name" in f && f.name === "name") return true;
@@ -14,19 +22,24 @@ const hasNameField = (fields) => fields.some((f) => {
14
22
  const fieldTabOf = (block) => {
15
23
  return block.fields.find((f) => f.type === "tabs")?.tabs.find((tab) => hasNameField(tab.fields))?.fields;
16
24
  };
17
- const buildFieldBlocks = ({ registry, ruleRegistry, consentRegistry, localize = true }) => {
25
+ const buildFieldBlocks = ({ registry, ruleRegistry, localize = true }) => {
18
26
  const conditionTypes = buildConditionTypeMap(registry);
19
27
  const blocks = [];
28
+ const bareSlugs = /* @__PURE__ */ new Set();
20
29
  for (const definition of registry.values()) {
21
- let typeConfig = definition.config ?? [];
22
- if (definition.type === "consent" && consentRegistry) {
23
- const statement = typeConfig.find((f) => f.name === "statement");
24
- const optional = typeConfig.find((f) => f.name === "optional");
25
- typeConfig = [
26
- ...statement ? [statement] : [],
27
- ...buildConsentSourceConfig(consentRegistry),
28
- ...optional ? [optional] : []
29
- ];
30
+ const typeConfig = definition.config ?? [];
31
+ if (definition.bare === true) {
32
+ bareSlugs.add(definition.type);
33
+ blocks.push({
34
+ slug: definition.type,
35
+ labels: {
36
+ singular: labelFor(definition.label),
37
+ plural: labelFor(definition.label)
38
+ },
39
+ admin: blockLabelAdmin(definition.label, definition.blockLabel),
40
+ fields: typeConfig
41
+ });
42
+ continue;
30
43
  }
31
44
  blocks.push({
32
45
  slug: definition.type,
@@ -34,6 +47,7 @@ const buildFieldBlocks = ({ registry, ruleRegistry, consentRegistry, localize =
34
47
  singular: labelFor(definition.label),
35
48
  plural: labelFor(definition.label)
36
49
  },
50
+ admin: blockLabelAdmin(definition.label, definition.blockLabel),
37
51
  fields: [fieldBlockTabs({
38
52
  conditionTypes,
39
53
  typeConfig,
@@ -43,7 +57,8 @@ const buildFieldBlocks = ({ registry, ruleRegistry, consentRegistry, localize =
43
57
  label: labelFor(keys.validationsLabel),
44
58
  blocks: buildRuleBlocks(ruleRegistry, definition.type)
45
59
  },
46
- localize
60
+ localize,
61
+ omitShared: definition.omitShared
47
62
  })]
48
63
  });
49
64
  }
@@ -53,7 +68,7 @@ const buildFieldBlocks = ({ registry, ruleRegistry, consentRegistry, localize =
53
68
  name: "subFields",
54
69
  type: "blocks",
55
70
  label: labelFor(keys.configSubFields),
56
- blocks: blocks.filter((b) => b.slug !== "repeater")
71
+ blocks: blocks.filter((b) => b.slug !== "repeater" && !bareSlugs.has(b.slug))
57
72
  };
58
73
  (fieldTabOf(repeaterBlock) ?? repeaterBlock.fields).push(subFieldsField);
59
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"buildFieldBlocks.js","names":[],"sources":["../../src/fields/buildFieldBlocks.ts"],"sourcesContent":["import type { Block, Field, TabsField } from 'payload'\nimport { buildConditionTypeMap } from '../conditions/conditionType'\nimport { buildConsentSourceConfig } from '../consent/buildConsentSourceConfig'\nimport type { ConsentSourceRegistry } from '../consent/registry'\nimport { keys } from '../translations/keys'\nimport { labelFor } from '../translations/server'\nimport { buildRuleBlocks } from '../validation/buildRuleBlocks'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { FieldTypeRegistry } from './registry'\nimport { fieldBlockTabs } from './sharedConfig'\n\n/** Whether `fields` contains a field named `name`, descending into presentational rows. */\nconst hasNameField = (fields: Field[]): boolean =>\n\tfields.some((f) => {\n\t\tif ('name' in f && f.name === 'name') {\n\t\t\treturn true\n\t\t}\n\t\treturn f.type === 'row' && hasNameField(f.fields)\n\t})\n\n/** The tab whose fields hold the shared basics and type config, found by the `name` field it carries. */\nconst fieldTabOf = (block: Block): Field[] | undefined => {\n\tconst tabsField = block.fields.find((f): f is TabsField => f.type === 'tabs')\n\treturn tabsField?.tabs.find((tab) => hasNameField(tab.fields))?.fields\n}\n\n/**\n * One add-field block per registered type: tabs holding shared config, type config, and\n * validations. `localize` controls whether the shared content fields carry `localized: true`;\n * per-type config fields carry their own flag from the registry definitions.\n */\ntype BuildFieldBlocksArgs = {\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tconsentRegistry?: ConsentSourceRegistry\n\tlocalize?: boolean\n}\n\nexport const buildFieldBlocks = ({\n\tregistry,\n\truleRegistry,\n\tconsentRegistry,\n\tlocalize = true,\n}: BuildFieldBlocksArgs): Block[] => {\n\tconst conditionTypes = buildConditionTypeMap(registry)\n\tconst blocks: Block[] = []\n\tfor (const definition of registry.values()) {\n\t\tlet typeConfig: Field[] = definition.config ?? []\n\n\t\t// Inject dynamic source select + conditional sourceConfig group for the consent field.\n\t\t// consent.ts intentionally omits source/sourceConfig; the live registry drives the\n\t\t// select options and per-source field visibility (admin.condition).\n\t\tif (definition.type === 'consent' && consentRegistry) {\n\t\t\t// statement is first; optional is last; source/sourceConfig go in between.\n\t\t\tconst statement = typeConfig.find((f) => (f as { name?: string }).name === 'statement')\n\t\t\tconst optional = typeConfig.find((f) => (f as { name?: string }).name === 'optional')\n\t\t\ttypeConfig = [\n\t\t\t\t...(statement ? [statement] : []),\n\t\t\t\t...buildConsentSourceConfig(consentRegistry),\n\t\t\t\t...(optional ? [optional] : []),\n\t\t\t]\n\t\t}\n\n\t\tblocks.push({\n\t\t\tslug: definition.type,\n\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\tfields: [\n\t\t\t\tfieldBlockTabs({\n\t\t\t\t\tconditionTypes,\n\t\t\t\t\ttypeConfig,\n\t\t\t\t\tvalidations: {\n\t\t\t\t\t\tname: 'validations',\n\t\t\t\t\t\ttype: 'blocks',\n\t\t\t\t\t\tlabel: labelFor(keys.validationsLabel),\n\t\t\t\t\t\tblocks: buildRuleBlocks(ruleRegistry, definition.type),\n\t\t\t\t\t},\n\t\t\t\t\tlocalize,\n\t\t\t\t}),\n\t\t\t],\n\t\t})\n\t}\n\n\t// Second pass: inject subFields into the repeater block using all non-repeater blocks.\n\t// Done after the main loop so every sibling block is already built.\n\t// Repeater-in-repeater is not supported in v1; the repeater block is excluded from subFields.\n\tconst repeaterBlock = blocks.find((b) => b.slug === 'repeater')\n\tif (repeaterBlock) {\n\t\tconst subFieldsField: Field = {\n\t\t\tname: 'subFields',\n\t\t\ttype: 'blocks',\n\t\t\tlabel: labelFor(keys.configSubFields),\n\t\t\tblocks: blocks.filter((b) => b.slug !== 'repeater'),\n\t\t}\n\t\tconst fieldTabFields = fieldTabOf(repeaterBlock)\n\t\t;(fieldTabFields ?? (repeaterBlock.fields as Field[])).push(subFieldsField)\n\t}\n\n\treturn blocks\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,gBAAgB,WACrB,OAAO,MAAM,MAAM;CAClB,IAAI,UAAU,KAAK,EAAE,SAAS,QAC7B,OAAO;CAER,OAAO,EAAE,SAAS,SAAS,aAAa,EAAE,MAAM;AACjD,CAAC;;AAGF,MAAM,cAAc,UAAsC;CAEzD,OADkB,MAAM,OAAO,MAAM,MAAsB,EAAE,SAAS,MACvD,GAAG,KAAK,MAAM,QAAQ,aAAa,IAAI,MAAM,CAAC,GAAG;AACjE;AAcA,MAAa,oBAAoB,EAChC,UACA,cACA,iBACA,WAAW,WACyB;CACpC,MAAM,iBAAiB,sBAAsB,QAAQ;CACrD,MAAM,SAAkB,CAAC;CACzB,KAAK,MAAM,cAAc,SAAS,OAAO,GAAG;EAC3C,IAAI,aAAsB,WAAW,UAAU,CAAC;EAKhD,IAAI,WAAW,SAAS,aAAa,iBAAiB;GAErD,MAAM,YAAY,WAAW,MAAM,MAAO,EAAwB,SAAS,WAAW;GACtF,MAAM,WAAW,WAAW,MAAM,MAAO,EAAwB,SAAS,UAAU;GACpF,aAAa;IACZ,GAAI,YAAY,CAAC,SAAS,IAAI,CAAC;IAC/B,GAAG,yBAAyB,eAAe;IAC3C,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;GAC9B;EACD;EAEA,OAAO,KAAK;GACX,MAAM,WAAW;GACjB,QAAQ;IAAE,UAAU,SAAS,WAAW,KAAK;IAAG,QAAQ,SAAS,WAAW,KAAK;GAAE;GACnF,QAAQ,CACP,eAAe;IACd;IACA;IACA,aAAa;KACZ,MAAM;KACN,MAAM;KACN,OAAO,SAAS,KAAK,gBAAgB;KACrC,QAAQ,gBAAgB,cAAc,WAAW,IAAI;IACtD;IACA;GACD,CAAC,CACF;EACD,CAAC;CACF;CAKA,MAAM,gBAAgB,OAAO,MAAM,MAAM,EAAE,SAAS,UAAU;CAC9D,IAAI,eAAe;EAClB,MAAM,iBAAwB;GAC7B,MAAM;GACN,MAAM;GACN,OAAO,SAAS,KAAK,eAAe;GACpC,QAAQ,OAAO,QAAQ,MAAM,EAAE,SAAS,UAAU;EACnD;EAEC,CADsB,WAAW,aACnB,KAAM,cAAc,QAAoB,KAAK,cAAc;CAC3E;CAEA,OAAO;AACR"}
1
+ {"version":3,"file":"buildFieldBlocks.js","names":[],"sources":["../../src/fields/buildFieldBlocks.ts"],"sourcesContent":["import type { Block, Field, TabsField } from 'payload'\nimport { buildConditionTypeMap } from '../conditions/conditionType'\nimport { keys } from '../translations/keys'\nimport { labelFor } from '../translations/server'\nimport { buildRuleBlocks } from '../validation/buildRuleBlocks'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { FieldTypeRegistry } from './registry'\nimport { fieldBlockTabs } from './sharedConfig'\n\nconst FIELD_BLOCK_LABEL_REF = '@10x-media/form-builder/client#FieldBlockLabel'\n\n/**\n * Replace Payload's default `blockName` row header (which reads \"Untitled\" until filled) with the\n * field's own `label`, keyed to the type label as fallback. See `FieldBlockLabel`.\n */\nconst blockLabelAdmin = (\n\ttypeLabelKey: string,\n\tref: string = FIELD_BLOCK_LABEL_REF\n): NonNullable<Block['admin']> => ({\n\tcomponents: { Label: { path: ref, clientProps: { typeLabelKey } } },\n})\n\n/** Whether `fields` contains a field named `name`, descending into presentational rows. */\nconst hasNameField = (fields: Field[]): boolean =>\n\tfields.some((f) => {\n\t\tif ('name' in f && f.name === 'name') {\n\t\t\treturn true\n\t\t}\n\t\treturn f.type === 'row' && hasNameField(f.fields)\n\t})\n\n/** The tab whose fields hold the shared basics and type config, found by the `name` field it carries. */\nconst fieldTabOf = (block: Block): Field[] | undefined => {\n\tconst tabsField = block.fields.find((f): f is TabsField => f.type === 'tabs')\n\treturn tabsField?.tabs.find((tab) => hasNameField(tab.fields))?.fields\n}\n\n/**\n * One add-field block per registered type: tabs holding shared config, type config, and\n * validations. Bare definitions (e.g. `message`) skip all of that: their block is the\n * definition's `config` alone, no name/shared basics/tabs. `localize` controls whether the\n * shared content fields carry `localized: true`; per-type config fields carry their own flag\n * from the registry definitions.\n */\ntype BuildFieldBlocksArgs = {\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tlocalize?: boolean\n}\n\nexport const buildFieldBlocks = ({\n\tregistry,\n\truleRegistry,\n\tlocalize = true,\n}: BuildFieldBlocksArgs): Block[] => {\n\tconst conditionTypes = buildConditionTypeMap(registry)\n\tconst blocks: Block[] = []\n\tconst bareSlugs = new Set<string>()\n\tfor (const definition of registry.values()) {\n\t\tconst typeConfig: Field[] = definition.config ?? []\n\n\t\tif (definition.bare === true) {\n\t\t\tbareSlugs.add(definition.type)\n\t\t\tblocks.push({\n\t\t\t\tslug: definition.type,\n\t\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\t\tfields: typeConfig,\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tblocks.push({\n\t\t\tslug: definition.type,\n\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\tfields: [\n\t\t\t\tfieldBlockTabs({\n\t\t\t\t\tconditionTypes,\n\t\t\t\t\ttypeConfig,\n\t\t\t\t\tvalidations: {\n\t\t\t\t\t\tname: 'validations',\n\t\t\t\t\t\ttype: 'blocks',\n\t\t\t\t\t\tlabel: labelFor(keys.validationsLabel),\n\t\t\t\t\t\tblocks: buildRuleBlocks(ruleRegistry, definition.type),\n\t\t\t\t\t},\n\t\t\t\t\tlocalize,\n\t\t\t\t\tomitShared: definition.omitShared,\n\t\t\t\t}),\n\t\t\t],\n\t\t})\n\t}\n\n\t// Second pass: inject subFields into the repeater block using all non-repeater blocks.\n\t// Done after the main loop so every sibling block is already built.\n\t// Repeater-in-repeater is not supported in v1; the repeater block is excluded from subFields.\n\t// Bare blocks are excluded too: repeater row plumbing (values, composite error paths) is name-keyed.\n\tconst repeaterBlock = blocks.find((b) => b.slug === 'repeater')\n\tif (repeaterBlock) {\n\t\tconst subFieldsField: Field = {\n\t\t\tname: 'subFields',\n\t\t\ttype: 'blocks',\n\t\t\tlabel: labelFor(keys.configSubFields),\n\t\t\tblocks: blocks.filter((b) => b.slug !== 'repeater' && !bareSlugs.has(b.slug)),\n\t\t}\n\t\tconst fieldTabFields = fieldTabOf(repeaterBlock)\n\t\t;(fieldTabFields ?? (repeaterBlock.fields as Field[])).push(subFieldsField)\n\t}\n\n\treturn blocks\n}\n"],"mappings":";;;;;;AASA,MAAM,wBAAwB;;;;;AAM9B,MAAM,mBACL,cACA,MAAc,2BACoB,EAClC,YAAY,EAAE,OAAO;CAAE,MAAM;CAAK,aAAa,EAAE,aAAa;AAAE,EAAE,EACnE;;AAGA,MAAM,gBAAgB,WACrB,OAAO,MAAM,MAAM;CAClB,IAAI,UAAU,KAAK,EAAE,SAAS,QAC7B,OAAO;CAER,OAAO,EAAE,SAAS,SAAS,aAAa,EAAE,MAAM;AACjD,CAAC;;AAGF,MAAM,cAAc,UAAsC;CAEzD,OADkB,MAAM,OAAO,MAAM,MAAsB,EAAE,SAAS,MACvD,GAAG,KAAK,MAAM,QAAQ,aAAa,IAAI,MAAM,CAAC,GAAG;AACjE;AAeA,MAAa,oBAAoB,EAChC,UACA,cACA,WAAW,WACyB;CACpC,MAAM,iBAAiB,sBAAsB,QAAQ;CACrD,MAAM,SAAkB,CAAC;CACzB,MAAM,4BAAY,IAAI,IAAY;CAClC,KAAK,MAAM,cAAc,SAAS,OAAO,GAAG;EAC3C,MAAM,aAAsB,WAAW,UAAU,CAAC;EAElD,IAAI,WAAW,SAAS,MAAM;GAC7B,UAAU,IAAI,WAAW,IAAI;GAC7B,OAAO,KAAK;IACX,MAAM,WAAW;IACjB,QAAQ;KAAE,UAAU,SAAS,WAAW,KAAK;KAAG,QAAQ,SAAS,WAAW,KAAK;IAAE;IACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;IAC9D,QAAQ;GACT,CAAC;GACD;EACD;EAEA,OAAO,KAAK;GACX,MAAM,WAAW;GACjB,QAAQ;IAAE,UAAU,SAAS,WAAW,KAAK;IAAG,QAAQ,SAAS,WAAW,KAAK;GAAE;GACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;GAC9D,QAAQ,CACP,eAAe;IACd;IACA;IACA,aAAa;KACZ,MAAM;KACN,MAAM;KACN,OAAO,SAAS,KAAK,gBAAgB;KACrC,QAAQ,gBAAgB,cAAc,WAAW,IAAI;IACtD;IACA;IACA,YAAY,WAAW;GACxB,CAAC,CACF;EACD,CAAC;CACF;CAMA,MAAM,gBAAgB,OAAO,MAAM,MAAM,EAAE,SAAS,UAAU;CAC9D,IAAI,eAAe;EAClB,MAAM,iBAAwB;GAC7B,MAAM;GACN,MAAM;GACN,OAAO,SAAS,KAAK,eAAe;GACpC,QAAQ,OAAO,QAAQ,MAAM,EAAE,SAAS,cAAc,CAAC,UAAU,IAAI,EAAE,IAAI,CAAC;EAC7E;EAEC,CADsB,WAAW,aACnB,KAAM,cAAc,QAAoB,KAAK,cAAc;CAC3E;CAEA,OAAO;AACR"}
@@ -111,10 +111,17 @@ const validateExpression = (value, { req }) => {
111
111
  if (value == null || value === "") return true;
112
112
  return normalizeCalc(value) !== void 0 ? true : asTranslate(req.t)(keys.validationCalcExpressionInvalid);
113
113
  };
114
+ /**
115
+ * A calculation is derived and read-only: it renders disabled with no text affordance (no
116
+ * `placeholder`), and it is never validated (`runSubmission` stores its computed value and skips
117
+ * `runValidation` entirely), so an authored `required` could never fire. Both are omitted rather
118
+ * than offered as settings that do nothing.
119
+ */
114
120
  const calculationField = defineFormField({
115
121
  type: "calculation",
116
122
  label: keys.fieldTypeCalculation,
117
123
  value: "number",
124
+ omitShared: ["placeholder", "required"],
118
125
  config: [{
119
126
  name: "expression",
120
127
  type: "json",
@@ -1 +1 @@
1
- {"version":3,"file":"calculation.js","names":[],"sources":["../../../src/fields/builtin/calculation.ts"],"sourcesContent":["import type { JSONField, PayloadRequest } from 'payload'\nimport { normalizeCalc } from '../../calc/normalizeCalc'\nimport { CALC_FNS, CALC_OPS } from '../../calc/types'\nimport { keys } from '../../translations/keys'\nimport { asTranslate, labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\n\ntype CalcExpressionSchema = NonNullable<JSONField['jsonSchema']>\n\n/**\n * Editor-facing JSON schema for `CalcExpression` (src/calc/types.ts), used by the admin JSON\n * field's Monaco editor for autocomplete and inline diagnostics. The real validity gate is\n * `validateExpression`/`normalizeCalc`; this schema is a convenience, not the source of truth.\n */\nconst calcExpressionSchema: CalcExpressionSchema = {\n\turi: 'https://10xmedia.de/schemas/form-builder/calc-expression.json',\n\tfileMatch: ['https://10xmedia.de/schemas/form-builder/calc-expression.json'],\n\tschema: {\n\t\t$ref: '#/definitions/expr',\n\t\tdefinitions: {\n\t\t\texpr: {\n\t\t\t\toneOf: [\n\t\t\t\t\t{ $ref: '#/definitions/lit' },\n\t\t\t\t\t{ $ref: '#/definitions/ref' },\n\t\t\t\t\t{ $ref: '#/definitions/op' },\n\t\t\t\t\t{ $ref: '#/definitions/neg' },\n\t\t\t\t\t{ $ref: '#/definitions/fn' },\n\t\t\t\t\t{ $ref: '#/definitions/weight' },\n\t\t\t\t],\n\t\t\t},\n\t\t\tlit: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['lit'] }, value: { type: 'number' } },\n\t\t\t\trequired: ['type', 'value'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tref: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['ref'] }, field: { type: 'string' } },\n\t\t\t\trequired: ['type', 'field'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\top: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['op'] },\n\t\t\t\t\top: { enum: [...CALC_OPS] },\n\t\t\t\t\tleft: { $ref: '#/definitions/expr' },\n\t\t\t\t\tright: { $ref: '#/definitions/expr' },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'op', 'left', 'right'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tneg: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['neg'] }, operand: { $ref: '#/definitions/expr' } },\n\t\t\t\trequired: ['type', 'operand'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tfn: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['fn'] },\n\t\t\t\t\tfn: { enum: [...CALC_FNS] },\n\t\t\t\t\targs: { type: 'array', items: { $ref: '#/definitions/expr' } },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'fn', 'args'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tweight: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['weight'] },\n\t\t\t\t\tfield: { type: 'string' },\n\t\t\t\t\tweights: { type: 'object', additionalProperties: { type: 'number' } },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'field', 'weights'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n}\n\n/**\n * Validates the calculation field's `expression`: unset/empty is fine, otherwise it must\n * normalize into a well-formed `CalcExpression` tree. Exported for unit testing.\n */\nexport const validateExpression = (\n\tvalue: unknown,\n\t{ req }: { data?: unknown; req: PayloadRequest }\n): string | true => {\n\tif (value == null || value === '') {\n\t\treturn true\n\t}\n\treturn normalizeCalc(value) !== undefined\n\t\t? true\n\t\t: asTranslate(req.t)(keys.validationCalcExpressionInvalid)\n}\n\nexport const calculationField = defineFormField<'number'>({\n\ttype: 'calculation',\n\tlabel: keys.fieldTypeCalculation,\n\tvalue: 'number',\n\tconfig: [\n\t\t{\n\t\t\tname: 'expression',\n\t\t\ttype: 'json',\n\t\t\tlabel: labelFor(keys.configExpression),\n\t\t\tadmin: { description: labelFor(keys.configExpressionDescription) },\n\t\t\tjsonSchema: calcExpressionSchema,\n\t\t\t// generate:types embeds jsonSchema.schema into the config-level schema, where its\n\t\t\t// document-root-relative $refs cannot resolve; hand type generation a flat shape instead.\n\t\t\ttypescriptSchema: [() => ({ type: 'object' })],\n\t\t\tvalidate: validateExpression,\n\t\t},\n\t\t{\n\t\t\tname: 'calcDisplay',\n\t\t\ttype: 'checkbox',\n\t\t\tdefaultValue: true,\n\t\t\tlabel: labelFor(keys.configCalcDisplay),\n\t\t},\n\t],\n\tformat: ({ value }) => (value == null ? '' : String(value)),\n})\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,uBAA6C;CAClD,KAAK;CACL,WAAW,CAAC,+DAA+D;CAC3E,QAAQ;EACP,MAAM;EACN,aAAa;GACZ,MAAM,EACL,OAAO;IACN,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,mBAAmB;IAC3B,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,mBAAmB;IAC3B,EAAE,MAAM,uBAAuB;GAChC,EACD;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,OAAO,EAAE,MAAM,SAAS;IAAE;IACjE,UAAU,CAAC,QAAQ,OAAO;IAC1B,sBAAsB;GACvB;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,OAAO,EAAE,MAAM,SAAS;IAAE;IACjE,UAAU,CAAC,QAAQ,OAAO;IAC1B,sBAAsB;GACvB;GACA,IAAI;IACH,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;KACrB,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE;KAC1B,MAAM,EAAE,MAAM,qBAAqB;KACnC,OAAO,EAAE,MAAM,qBAAqB;IACrC;IACA,UAAU;KAAC;KAAQ;KAAM;KAAQ;IAAO;IACxC,sBAAsB;GACvB;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,SAAS,EAAE,MAAM,qBAAqB;IAAE;IAC/E,UAAU,CAAC,QAAQ,SAAS;IAC5B,sBAAsB;GACvB;GACA,IAAI;IACH,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;KACrB,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE;KAC1B,MAAM;MAAE,MAAM;MAAS,OAAO,EAAE,MAAM,qBAAqB;KAAE;IAC9D;IACA,UAAU;KAAC;KAAQ;KAAM;IAAM;IAC/B,sBAAsB;GACvB;GACA,QAAQ;IACP,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;KACzB,OAAO,EAAE,MAAM,SAAS;KACxB,SAAS;MAAE,MAAM;MAAU,sBAAsB,EAAE,MAAM,SAAS;KAAE;IACrE;IACA,UAAU;KAAC;KAAQ;KAAS;IAAS;IACrC,sBAAsB;GACvB;EACD;CACD;AACD;;;;;AAMA,MAAa,sBACZ,OACA,EAAE,UACiB;CACnB,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;CAER,OAAO,cAAc,KAAK,MAAM,KAAA,IAC7B,OACA,YAAY,IAAI,CAAC,EAAE,KAAK,+BAA+B;AAC3D;AAEA,MAAa,mBAAmB,gBAA0B;CACzD,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,SAAS,KAAK,gBAAgB;EACrC,OAAO,EAAE,aAAa,SAAS,KAAK,2BAA2B,EAAE;EACjE,YAAY;EAGZ,kBAAkB,QAAQ,EAAE,MAAM,SAAS,EAAE;EAC7C,UAAU;CACX,GACA;EACC,MAAM;EACN,MAAM;EACN,cAAc;EACd,OAAO,SAAS,KAAK,iBAAiB;CACvC,CACD;CACA,SAAS,EAAE,YAAa,SAAS,OAAO,KAAK,OAAO,KAAK;AAC1D,CAAC"}
1
+ {"version":3,"file":"calculation.js","names":[],"sources":["../../../src/fields/builtin/calculation.ts"],"sourcesContent":["import type { JSONField, PayloadRequest } from 'payload'\nimport { normalizeCalc } from '../../calc/normalizeCalc'\nimport { CALC_FNS, CALC_OPS } from '../../calc/types'\nimport { keys } from '../../translations/keys'\nimport { asTranslate, labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\n\ntype CalcExpressionSchema = NonNullable<JSONField['jsonSchema']>\n\n/**\n * Editor-facing JSON schema for `CalcExpression` (src/calc/types.ts), used by the admin JSON\n * field's Monaco editor for autocomplete and inline diagnostics. The real validity gate is\n * `validateExpression`/`normalizeCalc`; this schema is a convenience, not the source of truth.\n */\nconst calcExpressionSchema: CalcExpressionSchema = {\n\turi: 'https://10xmedia.de/schemas/form-builder/calc-expression.json',\n\tfileMatch: ['https://10xmedia.de/schemas/form-builder/calc-expression.json'],\n\tschema: {\n\t\t$ref: '#/definitions/expr',\n\t\tdefinitions: {\n\t\t\texpr: {\n\t\t\t\toneOf: [\n\t\t\t\t\t{ $ref: '#/definitions/lit' },\n\t\t\t\t\t{ $ref: '#/definitions/ref' },\n\t\t\t\t\t{ $ref: '#/definitions/op' },\n\t\t\t\t\t{ $ref: '#/definitions/neg' },\n\t\t\t\t\t{ $ref: '#/definitions/fn' },\n\t\t\t\t\t{ $ref: '#/definitions/weight' },\n\t\t\t\t],\n\t\t\t},\n\t\t\tlit: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['lit'] }, value: { type: 'number' } },\n\t\t\t\trequired: ['type', 'value'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tref: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['ref'] }, field: { type: 'string' } },\n\t\t\t\trequired: ['type', 'field'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\top: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['op'] },\n\t\t\t\t\top: { enum: [...CALC_OPS] },\n\t\t\t\t\tleft: { $ref: '#/definitions/expr' },\n\t\t\t\t\tright: { $ref: '#/definitions/expr' },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'op', 'left', 'right'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tneg: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['neg'] }, operand: { $ref: '#/definitions/expr' } },\n\t\t\t\trequired: ['type', 'operand'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tfn: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['fn'] },\n\t\t\t\t\tfn: { enum: [...CALC_FNS] },\n\t\t\t\t\targs: { type: 'array', items: { $ref: '#/definitions/expr' } },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'fn', 'args'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tweight: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['weight'] },\n\t\t\t\t\tfield: { type: 'string' },\n\t\t\t\t\tweights: { type: 'object', additionalProperties: { type: 'number' } },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'field', 'weights'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n}\n\n/**\n * Validates the calculation field's `expression`: unset/empty is fine, otherwise it must\n * normalize into a well-formed `CalcExpression` tree. Exported for unit testing.\n */\nexport const validateExpression = (\n\tvalue: unknown,\n\t{ req }: { data?: unknown; req: PayloadRequest }\n): string | true => {\n\tif (value == null || value === '') {\n\t\treturn true\n\t}\n\treturn normalizeCalc(value) !== undefined\n\t\t? true\n\t\t: asTranslate(req.t)(keys.validationCalcExpressionInvalid)\n}\n\n/**\n * A calculation is derived and read-only: it renders disabled with no text affordance (no\n * `placeholder`), and it is never validated (`runSubmission` stores its computed value and skips\n * `runValidation` entirely), so an authored `required` could never fire. Both are omitted rather\n * than offered as settings that do nothing.\n */\nexport const calculationField = defineFormField<'number'>({\n\ttype: 'calculation',\n\tlabel: keys.fieldTypeCalculation,\n\tvalue: 'number',\n\tomitShared: ['placeholder', 'required'],\n\tconfig: [\n\t\t{\n\t\t\tname: 'expression',\n\t\t\ttype: 'json',\n\t\t\tlabel: labelFor(keys.configExpression),\n\t\t\tadmin: { description: labelFor(keys.configExpressionDescription) },\n\t\t\tjsonSchema: calcExpressionSchema,\n\t\t\t// generate:types embeds jsonSchema.schema into the config-level schema, where its\n\t\t\t// document-root-relative $refs cannot resolve; hand type generation a flat shape instead.\n\t\t\ttypescriptSchema: [() => ({ type: 'object' })],\n\t\t\tvalidate: validateExpression,\n\t\t},\n\t\t{\n\t\t\tname: 'calcDisplay',\n\t\t\ttype: 'checkbox',\n\t\t\tdefaultValue: true,\n\t\t\tlabel: labelFor(keys.configCalcDisplay),\n\t\t},\n\t],\n\tformat: ({ value }) => (value == null ? '' : String(value)),\n})\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,uBAA6C;CAClD,KAAK;CACL,WAAW,CAAC,+DAA+D;CAC3E,QAAQ;EACP,MAAM;EACN,aAAa;GACZ,MAAM,EACL,OAAO;IACN,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,mBAAmB;IAC3B,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,mBAAmB;IAC3B,EAAE,MAAM,uBAAuB;GAChC,EACD;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,OAAO,EAAE,MAAM,SAAS;IAAE;IACjE,UAAU,CAAC,QAAQ,OAAO;IAC1B,sBAAsB;GACvB;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,OAAO,EAAE,MAAM,SAAS;IAAE;IACjE,UAAU,CAAC,QAAQ,OAAO;IAC1B,sBAAsB;GACvB;GACA,IAAI;IACH,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;KACrB,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE;KAC1B,MAAM,EAAE,MAAM,qBAAqB;KACnC,OAAO,EAAE,MAAM,qBAAqB;IACrC;IACA,UAAU;KAAC;KAAQ;KAAM;KAAQ;IAAO;IACxC,sBAAsB;GACvB;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,SAAS,EAAE,MAAM,qBAAqB;IAAE;IAC/E,UAAU,CAAC,QAAQ,SAAS;IAC5B,sBAAsB;GACvB;GACA,IAAI;IACH,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;KACrB,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE;KAC1B,MAAM;MAAE,MAAM;MAAS,OAAO,EAAE,MAAM,qBAAqB;KAAE;IAC9D;IACA,UAAU;KAAC;KAAQ;KAAM;IAAM;IAC/B,sBAAsB;GACvB;GACA,QAAQ;IACP,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;KACzB,OAAO,EAAE,MAAM,SAAS;KACxB,SAAS;MAAE,MAAM;MAAU,sBAAsB,EAAE,MAAM,SAAS;KAAE;IACrE;IACA,UAAU;KAAC;KAAQ;KAAS;IAAS;IACrC,sBAAsB;GACvB;EACD;CACD;AACD;;;;;AAMA,MAAa,sBACZ,OACA,EAAE,UACiB;CACnB,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;CAER,OAAO,cAAc,KAAK,MAAM,KAAA,IAC7B,OACA,YAAY,IAAI,CAAC,EAAE,KAAK,+BAA+B;AAC3D;;;;;;;AAQA,MAAa,mBAAmB,gBAA0B;CACzD,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY,CAAC,eAAe,UAAU;CACtC,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,SAAS,KAAK,gBAAgB;EACrC,OAAO,EAAE,aAAa,SAAS,KAAK,2BAA2B,EAAE;EACjE,YAAY;EAGZ,kBAAkB,QAAQ,EAAE,MAAM,SAAS,EAAE;EAC7C,UAAU;CACX,GACA;EACC,MAAM;EACN,MAAM;EACN,cAAc;EACd,OAAO,SAAS,KAAK,iBAAiB;CACvC,CACD;CACA,SAAS,EAAE,YAAa,SAAS,OAAO,KAAK,OAAO,KAAK;AAC1D,CAAC"}
@@ -1,10 +1,18 @@
1
1
  import { keys } from "../../translations/keys.js";
2
2
  import { defineFormField } from "../defineFormField.js";
3
3
  //#region src/fields/builtin/checkbox.ts
4
+ /**
5
+ * A checkbox renders as a lone box with no free-text affordance, so `placeholder` is never read.
6
+ * The intrinsic validator owns `required`: the engine's shared required guard only fires on an
7
+ * empty value, and `false` (checked, then unchecked) is a present one, so without this a required
8
+ * checkbox would accept an explicit refusal.
9
+ */
4
10
  const checkboxField = defineFormField({
5
11
  type: "checkbox",
6
12
  label: keys.fieldTypeCheckbox,
7
13
  value: "boolean",
14
+ omitShared: ["placeholder"],
15
+ validate: ({ value, config, t }) => config.required === true && value !== true ? t(keys.validationRequired) : true,
8
16
  format: ({ value, t }) => value ? t(keys.formatYes) : t(keys.formatNo)
9
17
  });
10
18
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.js","names":[],"sources":["../../../src/fields/builtin/checkbox.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { defineFormField } from '../defineFormField'\n\nexport const checkboxField = defineFormField<'boolean'>({\n\ttype: 'checkbox',\n\tlabel: keys.fieldTypeCheckbox,\n\tvalue: 'boolean',\n\tformat: ({ value, t }) => (value ? t(keys.formatYes) : t(keys.formatNo)),\n})\n"],"mappings":";;;AAGA,MAAa,gBAAgB,gBAA2B;CACvD,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,SAAS,EAAE,OAAO,QAAS,QAAQ,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,QAAQ;AACvE,CAAC"}
1
+ {"version":3,"file":"checkbox.js","names":[],"sources":["../../../src/fields/builtin/checkbox.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { defineFormField } from '../defineFormField'\n\ntype CheckboxConfig = { required?: boolean }\n\n/**\n * A checkbox renders as a lone box with no free-text affordance, so `placeholder` is never read.\n * The intrinsic validator owns `required`: the engine's shared required guard only fires on an\n * empty value, and `false` (checked, then unchecked) is a present one, so without this a required\n * checkbox would accept an explicit refusal.\n */\nexport const checkboxField = defineFormField<'boolean', CheckboxConfig>({\n\ttype: 'checkbox',\n\tlabel: keys.fieldTypeCheckbox,\n\tvalue: 'boolean',\n\tomitShared: ['placeholder'],\n\tvalidate: ({ value, config, t }) =>\n\t\tconfig.required === true && value !== true ? t(keys.validationRequired) : true,\n\tformat: ({ value, t }) => (value ? t(keys.formatYes) : t(keys.formatNo)),\n})\n"],"mappings":";;;;;;;;;AAWA,MAAa,gBAAgB,gBAA2C;CACvE,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY,CAAC,aAAa;CAC1B,WAAW,EAAE,OAAO,QAAQ,QAC3B,OAAO,aAAa,QAAQ,UAAU,OAAO,EAAE,KAAK,kBAAkB,IAAI;CAC3E,SAAS,EAAE,OAAO,QAAS,QAAQ,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,QAAQ;AACvE,CAAC"}
@@ -1,36 +1,47 @@
1
- import { localizedIf } from "../localizedIf.js";
2
1
  import { keys } from "../../translations/keys.js";
3
- import { labelFor } from "../../translations/server.js";
2
+ import { labelForKey } from "../../translations/server.js";
4
3
  import { defineFormField } from "../defineFormField.js";
5
- //#region src/fields/builtin/consent.ts
6
4
  /**
7
- * Base consent field definition. `source` select and `sourceConfig` group are injected
8
- * by `buildFieldBlocks` from the live `consentRegistry`, so only the selected source's
9
- * fields are visible in the admin UI via `admin.condition`. The `statement` is
10
- * author-facing content and follows `localize`.
5
+ * Consent is a reference, so the field is a reference: the author picks a source and nothing else.
6
+ * The statement, the policy page, and its version all live with the source (see
7
+ * `consentSourcesField`), so there is no wording to copy per form, no URL to paste, and no version
8
+ * to type; correcting a statement corrects every form pointing at it. `label` and `placeholder` are
9
+ * dropped for the same reason: the statement is the visible text and the checkbox's accessible name.
10
+ *
11
+ * Registered only when the plugin's `consent.sources` resolver is set, since a consent field with
12
+ * no source to reference has nothing to say and nothing to prove.
13
+ *
14
+ * The intrinsic validator owns `required`: the engine's shared required guard only fires on an
15
+ * empty value, and `false` (the coerced state of both an unchecked box and an absent answer) is a
16
+ * present one, so without this a required consent would accept an explicit refusal.
11
17
  */
12
- const buildConsentField = (localize) => defineFormField({
18
+ const consentField = defineFormField({
13
19
  type: "consent",
14
20
  label: keys.fieldTypeConsent,
15
21
  value: "boolean",
22
+ omitShared: [
23
+ "label",
24
+ "placeholder",
25
+ "description"
26
+ ],
27
+ blockLabel: "@10x-media/form-builder/client#ConsentBlockLabel",
16
28
  config: [{
17
- name: "statement",
29
+ name: "source",
18
30
  type: "text",
19
- label: labelFor(keys.consentConfigStatement),
20
- ...localizedIf(localize)
21
- }, {
22
- name: "optional",
23
- type: "checkbox",
24
- label: labelFor(keys.consentConfigOptional)
31
+ label: labelForKey(keys.consentConfigSource),
32
+ admin: { components: { Field: {
33
+ path: "@10x-media/form-builder/client#EndpointOptionsSelect",
34
+ clientProps: {
35
+ endpoint: "consent-sources",
36
+ descriptionKey: keys.consentConfigSourceDescription,
37
+ isClearable: false
38
+ }
39
+ } } }
25
40
  }],
26
- validate: ({ value, config, t }) => {
27
- if (!(config.optional === true) && value !== true) return t(keys.validationRequired);
28
- return true;
29
- },
41
+ validate: ({ value, config, t }) => config.required === true && value !== true ? t(keys.validationRequired) : true,
30
42
  format: ({ value, t }) => t(value === true ? keys.formatYes : keys.formatNo)
31
43
  });
32
- buildConsentField(true);
33
44
  //#endregion
34
- export { buildConsentField };
45
+ export { consentField };
35
46
 
36
47
  //# sourceMappingURL=consent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consent.js","names":[],"sources":["../../../src/fields/builtin/consent.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\nimport { localizedIf } from '../localizedIf'\n\ntype ConsentConfig = {\n\tstatement?: string\n\tsource?: string\n\tsourceConfig?: Record<string, unknown>\n\toptional?: boolean\n}\n\n/**\n * Base consent field definition. `source` select and `sourceConfig` group are injected\n * by `buildFieldBlocks` from the live `consentRegistry`, so only the selected source's\n * fields are visible in the admin UI via `admin.condition`. The `statement` is\n * author-facing content and follows `localize`.\n */\nexport const buildConsentField = (localize: boolean) =>\n\tdefineFormField<'boolean', ConsentConfig>({\n\t\ttype: 'consent',\n\t\tlabel: keys.fieldTypeConsent,\n\t\tvalue: 'boolean',\n\t\tconfig: [\n\t\t\t{\n\t\t\t\tname: 'statement',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: labelFor(keys.consentConfigStatement),\n\t\t\t\t...localizedIf(localize),\n\t\t\t},\n\t\t\t// source select and sourceConfig group are injected by buildFieldBlocks at plugin boot\n\t\t\t// so the options reflect the live consentRegistry rather than this static list.\n\t\t\t{ name: 'optional', type: 'checkbox', label: labelFor(keys.consentConfigOptional) },\n\t\t],\n\t\tvalidate: ({ value, config, t }) => {\n\t\t\tconst optional = (config as ConsentConfig).optional === true\n\t\t\tif (!optional && value !== true) {\n\t\t\t\treturn t(keys.validationRequired)\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\t\tformat: ({ value, t }) => t(value === true ? keys.formatYes : keys.formatNo),\n\t})\n\nexport const consentField = buildConsentField(true)\n"],"mappings":";;;;;;;;;;;AAkBA,MAAa,qBAAqB,aACjC,gBAA0C;CACzC,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,SAAS,KAAK,sBAAsB;EAC3C,GAAG,YAAY,QAAQ;CACxB,GAGA;EAAE,MAAM;EAAY,MAAM;EAAY,OAAO,SAAS,KAAK,qBAAqB;CAAE,CACnF;CACA,WAAW,EAAE,OAAO,QAAQ,QAAQ;EAEnC,IAAI,EADc,OAAyB,aAAa,SACvC,UAAU,MAC1B,OAAO,EAAE,KAAK,kBAAkB;EAEjC,OAAO;CACR;CACA,SAAS,EAAE,OAAO,QAAQ,EAAE,UAAU,OAAO,KAAK,YAAY,KAAK,QAAQ;AAC5E,CAAC;AAE0B,kBAAkB,IAAI"}
1
+ {"version":3,"file":"consent.js","names":[],"sources":["../../../src/fields/builtin/consent.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelForKey } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\n\ntype ConsentConfig = { source?: string; required?: boolean }\n\nconst SOURCE_FIELD_REF = '@10x-media/form-builder/client#EndpointOptionsSelect'\n\n/**\n * Consent is a reference, so the field is a reference: the author picks a source and nothing else.\n * The statement, the policy page, and its version all live with the source (see\n * `consentSourcesField`), so there is no wording to copy per form, no URL to paste, and no version\n * to type; correcting a statement corrects every form pointing at it. `label` and `placeholder` are\n * dropped for the same reason: the statement is the visible text and the checkbox's accessible name.\n *\n * Registered only when the plugin's `consent.sources` resolver is set, since a consent field with\n * no source to reference has nothing to say and nothing to prove.\n *\n * The intrinsic validator owns `required`: the engine's shared required guard only fires on an\n * empty value, and `false` (the coerced state of both an unchecked box and an absent answer) is a\n * present one, so without this a required consent would accept an explicit refusal.\n */\nexport const consentField = defineFormField<'boolean', ConsentConfig>({\n\ttype: 'consent',\n\tlabel: keys.fieldTypeConsent,\n\tvalue: 'boolean',\n\tomitShared: ['label', 'placeholder', 'description'],\n\tblockLabel: '@10x-media/form-builder/client#ConsentBlockLabel',\n\tconfig: [\n\t\t{\n\t\t\tname: 'source',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.consentConfigSource),\n\t\t\tadmin: {\n\t\t\t\tcomponents: {\n\t\t\t\t\tField: {\n\t\t\t\t\t\tpath: SOURCE_FIELD_REF,\n\t\t\t\t\t\tclientProps: {\n\t\t\t\t\t\t\tendpoint: 'consent-sources',\n\t\t\t\t\t\t\tdescriptionKey: keys.consentConfigSourceDescription,\n\t\t\t\t\t\t\tisClearable: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\tvalidate: ({ value, config, t }) =>\n\t\tconfig.required === true && value !== true ? t(keys.validationRequired) : true,\n\tformat: ({ value, t }) => t(value === true ? keys.formatYes : keys.formatNo),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,MAAa,eAAe,gBAA0C;CACrE,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY;EAAC;EAAS;EAAe;CAAa;CAClD,YAAY;CACZ,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,YAAY,KAAK,mBAAmB;EAC3C,OAAO,EACN,YAAY,EACX,OAAO;GACN,MAAM;GACN,aAAa;IACZ,UAAU;IACV,gBAAgB,KAAK;IACrB,aAAa;GACd;EACD,EACD,EACD;CACD,CACD;CACA,WAAW,EAAE,OAAO,QAAQ,QAC3B,OAAO,aAAa,QAAQ,UAAU,OAAO,EAAE,KAAK,kBAAkB,IAAI;CAC3E,SAAS,EAAE,OAAO,QAAQ,EAAE,UAAU,OAAO,KAAK,YAAY,KAAK,QAAQ;AAC5E,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { FormFieldConfigValues, FormFieldDefinition } from "../types.js";
2
+
3
+ //#region src/fields/builtin/country.d.ts
4
+ /**
5
+ * A country picker fronted by the fixed ISO 3166-1 alpha-2 set (see {@link COUNTRIES}). Unlike
6
+ * `select` the author does not author options, so there is no `config`; the stored value is the
7
+ * two-letter code and `format` resolves it to the English name. `resolveOptions` exposes the same
8
+ * set as poll choices so a country field can back a poll despite carrying no authored options.
9
+ */
10
+ declare const countryField: FormFieldDefinition<"text", FormFieldConfigValues>;
11
+ //#endregion
12
+ export { countryField };
13
+ //# sourceMappingURL=country.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { defineFormField } from "../defineFormField.js";
3
+ import { COUNTRIES, countryLabel, isCountryCode } from "../data/regions.js";
4
+ //#region src/fields/builtin/country.ts
5
+ /**
6
+ * A country picker fronted by the fixed ISO 3166-1 alpha-2 set (see {@link COUNTRIES}). Unlike
7
+ * `select` the author does not author options, so there is no `config`; the stored value is the
8
+ * two-letter code and `format` resolves it to the English name. `resolveOptions` exposes the same
9
+ * set as poll choices so a country field can back a poll despite carrying no authored options.
10
+ */
11
+ const countryField = defineFormField({
12
+ type: "country",
13
+ label: keys.fieldTypeCountry,
14
+ value: "text",
15
+ conditionType: "select",
16
+ pollEligible: true,
17
+ resolveOptions: () => COUNTRIES,
18
+ validate: ({ value, t }) => {
19
+ if (value == null || value === "") return true;
20
+ return isCountryCode(value) ? true : t(keys.validationCountry);
21
+ },
22
+ format: ({ value }) => {
23
+ if (value == null || value === "") return "";
24
+ return countryLabel(value) ?? String(value);
25
+ }
26
+ });
27
+ //#endregion
28
+ export { countryField };
29
+
30
+ //# sourceMappingURL=country.js.map