@10x-media/form-builder 0.1.0-beta.0 → 0.1.0-beta.1

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 (399) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +43 -1402
  3. package/dist/actions/buildActionBlocks.js +19 -0
  4. package/dist/actions/buildActionBlocks.js.map +1 -0
  5. package/dist/actions/builtin/confirmation.js +49 -0
  6. package/dist/actions/builtin/confirmation.js.map +1 -0
  7. package/dist/actions/builtin/emailTeam.js +46 -0
  8. package/dist/actions/builtin/emailTeam.js.map +1 -0
  9. package/dist/actions/builtin/index.d.ts +7 -0
  10. package/dist/actions/builtin/index.js +13 -0
  11. package/dist/actions/builtin/index.js.map +1 -0
  12. package/dist/actions/builtin/signedWebhook.js +49 -0
  13. package/dist/actions/builtin/signedWebhook.js.map +1 -0
  14. package/dist/actions/defineAction.d.ts +36 -0
  15. package/dist/actions/defineAction.js +6 -0
  16. package/dist/actions/defineAction.js.map +1 -0
  17. package/dist/actions/dispatch.js +48 -0
  18. package/dist/actions/dispatch.js.map +1 -0
  19. package/dist/actions/registry.d.ts +16 -0
  20. package/dist/actions/registry.js +16 -0
  21. package/dist/actions/registry.js.map +1 -0
  22. package/dist/actions/runActions.d.ts +9 -0
  23. package/dist/actions/runActions.js +34 -0
  24. package/dist/actions/runActions.js.map +1 -0
  25. package/dist/actions/sign.d.ts +7 -0
  26. package/dist/actions/sign.js +9 -0
  27. package/dist/actions/sign.js.map +1 -0
  28. package/dist/actions/task.js +82 -0
  29. package/dist/actions/task.js.map +1 -0
  30. package/dist/aggregation/aggregateResponses.d.ts +31 -0
  31. package/dist/aggregation/aggregateResponses.js +86 -0
  32. package/dist/aggregation/aggregateResponses.js.map +1 -0
  33. package/dist/aggregation/aggregateRows.d.ts +10 -0
  34. package/dist/aggregation/aggregateRows.js +64 -0
  35. package/dist/aggregation/aggregateRows.js.map +1 -0
  36. package/dist/aggregation/resolveResultsRequest.d.ts +32 -0
  37. package/dist/aggregation/resolveResultsRequest.js +56 -0
  38. package/dist/aggregation/resolveResultsRequest.js.map +1 -0
  39. package/dist/aggregation/types.d.ts +39 -0
  40. package/dist/calc/computeCalcFields.d.ts +15 -0
  41. package/dist/calc/computeCalcFields.js +27 -0
  42. package/dist/calc/computeCalcFields.js.map +1 -0
  43. package/dist/calc/evaluate.d.ts +8 -0
  44. package/dist/calc/evaluate.js +59 -0
  45. package/dist/calc/evaluate.js.map +1 -0
  46. package/dist/calc/normalizeCalc.d.ts +8 -0
  47. package/dist/calc/normalizeCalc.js +100 -0
  48. package/dist/calc/normalizeCalc.js.map +1 -0
  49. package/dist/calc/types.d.ts +28 -0
  50. package/dist/client/ConditionBuilder.js +121 -0
  51. package/dist/client/ConditionBuilder.js.map +1 -0
  52. package/dist/client/ConditionRow.js +150 -0
  53. package/dist/client/ConditionRow.js.map +1 -0
  54. package/dist/client/FlowBuilder.d.ts +15 -0
  55. package/dist/client/FlowBuilder.js +408 -0
  56. package/dist/client/FlowBuilder.js.map +1 -0
  57. package/dist/client/FormConditionField.d.ts +21 -0
  58. package/dist/client/FormConditionField.js +33 -0
  59. package/dist/client/FormConditionField.js.map +1 -0
  60. package/dist/client/synthesizeClientField.js +46 -0
  61. package/dist/client/synthesizeClientField.js.map +1 -0
  62. package/dist/collections/formSubmissions.js +138 -0
  63. package/dist/collections/formSubmissions.js.map +1 -0
  64. package/dist/collections/forms.js +187 -0
  65. package/dist/collections/forms.js.map +1 -0
  66. package/dist/collections/uploads.d.ts +29 -0
  67. package/dist/collections/uploads.js +46 -0
  68. package/dist/collections/uploads.js.map +1 -0
  69. package/dist/conditions/conditionType.js +14 -0
  70. package/dist/conditions/conditionType.js.map +1 -0
  71. package/dist/conditions/evaluate.d.ts +17 -0
  72. package/dist/conditions/evaluate.js +94 -0
  73. package/dist/conditions/evaluate.js.map +1 -0
  74. package/dist/conditions/fieldTypes.d.ts +9 -0
  75. package/dist/{fieldTypes-CzhhJXjg.js → conditions/fieldTypes.js} +2 -2
  76. package/dist/conditions/fieldTypes.js.map +1 -0
  77. package/dist/conditions/normalizeConditions.js +47 -0
  78. package/dist/conditions/normalizeConditions.js.map +1 -0
  79. package/dist/conditions/types.d.ts +8 -0
  80. package/dist/consent/buildConsentSourceConfig.js +49 -0
  81. package/dist/consent/buildConsentSourceConfig.js.map +1 -0
  82. package/dist/consent/builtin/index.d.ts +7 -0
  83. package/dist/consent/builtin/index.js +11 -0
  84. package/dist/consent/builtin/index.js.map +1 -0
  85. package/dist/consent/builtin/pageReference.js +75 -0
  86. package/dist/consent/builtin/pageReference.js.map +1 -0
  87. package/dist/consent/builtin/static.js +44 -0
  88. package/dist/consent/builtin/static.js.map +1 -0
  89. package/dist/consent/captureConsent.d.ts +28 -0
  90. package/dist/consent/captureConsent.js +26 -0
  91. package/dist/consent/captureConsent.js.map +1 -0
  92. package/dist/consent/defineConsentSource.d.ts +35 -0
  93. package/dist/consent/defineConsentSource.js +6 -0
  94. package/dist/consent/defineConsentSource.js.map +1 -0
  95. package/dist/consent/registry.d.ts +16 -0
  96. package/dist/consent/registry.js +16 -0
  97. package/dist/consent/registry.js.map +1 -0
  98. package/dist/consent/resolveConsentLinks.d.ts +19 -0
  99. package/dist/consent/resolveConsentLinks.js +26 -0
  100. package/dist/consent/resolveConsentLinks.js.map +1 -0
  101. package/dist/consent/resolvePublishedVersionRef.d.ts +17 -0
  102. package/dist/consent/resolvePublishedVersionRef.js +27 -0
  103. package/dist/consent/resolvePublishedVersionRef.js.map +1 -0
  104. package/dist/events/noopSink.js +6 -0
  105. package/dist/events/noopSink.js.map +1 -0
  106. package/dist/events/resolveEventSink.js +8 -0
  107. package/dist/events/resolveEventSink.js.map +1 -0
  108. package/dist/events/types.d.ts +31 -0
  109. package/dist/exports/client.d.ts +3 -21
  110. package/dist/exports/client.js +3 -319
  111. package/dist/exports/i18n.d.ts +3 -138
  112. package/dist/exports/i18n.js +2 -2
  113. package/dist/exports/react.d.ts +45 -550
  114. package/dist/exports/react.js +39 -1563
  115. package/dist/exports/rsc.d.ts +2 -16
  116. package/dist/exports/rsc.js +1 -54
  117. package/dist/exports/types.d.ts +27 -5
  118. package/dist/fields/buildFieldBlocks.js +46 -0
  119. package/dist/fields/buildFieldBlocks.js.map +1 -0
  120. package/dist/fields/builtin/calculation.js +24 -0
  121. package/dist/fields/builtin/calculation.js.map +1 -0
  122. package/dist/fields/builtin/checkbox.js +13 -0
  123. package/dist/fields/builtin/checkbox.js.map +1 -0
  124. package/dist/fields/builtin/consent.js +32 -0
  125. package/dist/fields/builtin/consent.js.map +1 -0
  126. package/dist/fields/builtin/email.js +18 -0
  127. package/dist/fields/builtin/email.js.map +1 -0
  128. package/dist/fields/builtin/file.js +40 -0
  129. package/dist/fields/builtin/file.js.map +1 -0
  130. package/dist/fields/builtin/index.js +25 -0
  131. package/dist/fields/builtin/index.js.map +1 -0
  132. package/dist/fields/builtin/number.js +17 -0
  133. package/dist/fields/builtin/number.js.map +1 -0
  134. package/dist/fields/builtin/select.js +44 -0
  135. package/dist/fields/builtin/select.js.map +1 -0
  136. package/dist/fields/builtin/text.js +13 -0
  137. package/dist/fields/builtin/text.js.map +1 -0
  138. package/dist/fields/builtin/textarea.js +13 -0
  139. package/dist/fields/builtin/textarea.js.map +1 -0
  140. package/dist/fields/defineFormField.d.ts +13 -0
  141. package/dist/fields/defineFormField.js +12 -0
  142. package/dist/fields/defineFormField.js.map +1 -0
  143. package/dist/fields/registry.d.ts +10 -0
  144. package/dist/fields/registry.js +24 -0
  145. package/dist/fields/registry.js.map +1 -0
  146. package/dist/fields/sharedConfig.js +89 -0
  147. package/dist/fields/sharedConfig.js.map +1 -0
  148. package/dist/fields/types.d.ts +88 -0
  149. package/dist/flow/engine.d.ts +17 -0
  150. package/dist/flow/engine.js +24 -0
  151. package/dist/flow/engine.js.map +1 -0
  152. package/dist/flow/normalizeFlow.js +35 -0
  153. package/dist/flow/normalizeFlow.js.map +1 -0
  154. package/dist/{types-DsJ_6kGJ.d.ts → flow/types.d.ts} +2 -2
  155. package/dist/index.d.ts +74 -4
  156. package/dist/index.js +40 -1889
  157. package/dist/index.js.map +1 -1
  158. package/dist/plugin/access.js +12 -0
  159. package/dist/plugin/access.js.map +1 -0
  160. package/dist/plugin/registerCollections.js +40 -0
  161. package/dist/plugin/registerCollections.js.map +1 -0
  162. package/dist/plugin/registerTranslations.js +19 -0
  163. package/dist/plugin/registerTranslations.js.map +1 -0
  164. package/dist/prefill/valuesFromSearchParams.d.ts +18 -0
  165. package/dist/prefill/valuesFromSearchParams.js +45 -0
  166. package/dist/prefill/valuesFromSearchParams.js.map +1 -0
  167. package/dist/presentations/defaults.d.ts +33 -0
  168. package/dist/presentations/defaults.js +35 -0
  169. package/dist/presentations/defaults.js.map +1 -0
  170. package/dist/presentations/registry.d.ts +15 -0
  171. package/dist/presentations/registry.js +15 -0
  172. package/dist/presentations/registry.js.map +1 -0
  173. package/dist/presentations/types.d.ts +18 -0
  174. package/dist/react/Form.d.ts +81 -0
  175. package/dist/react/Form.js +457 -0
  176. package/dist/react/Form.js.map +1 -0
  177. package/dist/react/FormContext.d.ts +16 -0
  178. package/dist/react/FormContext.js +14 -0
  179. package/dist/react/FormContext.js.map +1 -0
  180. package/dist/react/FormLayout.d.ts +20 -0
  181. package/dist/react/FormLayout.js +14 -0
  182. package/dist/react/FormLayout.js.map +1 -0
  183. package/dist/react/FormResults.d.ts +25 -0
  184. package/dist/react/FormResults.js +85 -0
  185. package/dist/react/FormResults.js.map +1 -0
  186. package/dist/react/Honeypot.d.ts +22 -0
  187. package/dist/react/Honeypot.js +38 -0
  188. package/dist/react/Honeypot.js.map +1 -0
  189. package/dist/react/Poll.d.ts +32 -0
  190. package/dist/react/Poll.js +77 -0
  191. package/dist/react/Poll.js.map +1 -0
  192. package/dist/react/cn.d.ts +6 -0
  193. package/dist/react/cn.js +8 -0
  194. package/dist/react/cn.js.map +1 -0
  195. package/dist/react/contract.d.ts +32 -0
  196. package/dist/react/contract.js +7 -0
  197. package/dist/react/contract.js.map +1 -0
  198. package/dist/react/events.js +14 -0
  199. package/dist/react/events.js.map +1 -0
  200. package/dist/react/fetchResults.d.ts +25 -0
  201. package/dist/react/fetchResults.js +31 -0
  202. package/dist/react/fetchResults.js.map +1 -0
  203. package/dist/react/presentation/Backdrop.d.ts +18 -0
  204. package/dist/react/presentation/Backdrop.js +14 -0
  205. package/dist/react/presentation/Backdrop.js.map +1 -0
  206. package/dist/react/presentation/DialogSurface.d.ts +35 -0
  207. package/dist/react/presentation/DialogSurface.js +56 -0
  208. package/dist/react/presentation/DialogSurface.js.map +1 -0
  209. package/dist/react/presentation/presentations.d.ts +7 -0
  210. package/dist/react/presentation/presentations.js +32 -0
  211. package/dist/react/presentation/presentations.js.map +1 -0
  212. package/dist/react/presentation/registry.d.ts +11 -0
  213. package/dist/react/presentation/registry.js +12 -0
  214. package/dist/react/presentation/registry.js.map +1 -0
  215. package/dist/react/presentation/types.d.ts +19 -0
  216. package/dist/react/presentation/useDismiss.d.ts +19 -0
  217. package/dist/react/presentation/useDismiss.js +33 -0
  218. package/dist/react/presentation/useDismiss.js.map +1 -0
  219. package/dist/react/presentation/useFocusTrap.d.ts +8 -0
  220. package/dist/react/presentation/useFocusTrap.js +35 -0
  221. package/dist/react/presentation/useFocusTrap.js.map +1 -0
  222. package/dist/react/presentation/useScrollLock.d.ts +6 -0
  223. package/dist/react/presentation/useScrollLock.js +18 -0
  224. package/dist/react/presentation/useScrollLock.js.map +1 -0
  225. package/dist/react/primitives/Checkbox.d.ts +26 -0
  226. package/dist/react/primitives/Checkbox.js +20 -0
  227. package/dist/react/primitives/Checkbox.js.map +1 -0
  228. package/dist/react/primitives/FieldShell.d.ts +31 -0
  229. package/dist/react/primitives/FieldShell.js +51 -0
  230. package/dist/react/primitives/FieldShell.js.map +1 -0
  231. package/dist/react/primitives/Input.d.ts +30 -0
  232. package/dist/react/primitives/Input.js +21 -0
  233. package/dist/react/primitives/Input.js.map +1 -0
  234. package/dist/react/primitives/Select.d.ts +34 -0
  235. package/dist/react/primitives/Select.js +26 -0
  236. package/dist/react/primitives/Select.js.map +1 -0
  237. package/dist/react/primitives/Textarea.d.ts +28 -0
  238. package/dist/react/primitives/Textarea.js +20 -0
  239. package/dist/react/primitives/Textarea.js.map +1 -0
  240. package/dist/react/recall.js +20 -0
  241. package/dist/react/recall.js.map +1 -0
  242. package/dist/react/registry.d.ts +16 -0
  243. package/dist/react/registry.js +16 -0
  244. package/dist/react/registry.js.map +1 -0
  245. package/dist/react/renderers/calculation.js +30 -0
  246. package/dist/react/renderers/calculation.js.map +1 -0
  247. package/dist/react/renderers/checkbox.js +35 -0
  248. package/dist/react/renderers/checkbox.js.map +1 -0
  249. package/dist/react/renderers/consent.js +54 -0
  250. package/dist/react/renderers/consent.js.map +1 -0
  251. package/dist/react/renderers/email.js +37 -0
  252. package/dist/react/renderers/email.js.map +1 -0
  253. package/dist/react/renderers/file.js +92 -0
  254. package/dist/react/renderers/file.js.map +1 -0
  255. package/dist/react/renderers/index.d.ts +8 -0
  256. package/dist/react/renderers/index.js +26 -0
  257. package/dist/react/renderers/index.js.map +1 -0
  258. package/dist/react/renderers/number.js +40 -0
  259. package/dist/react/renderers/number.js.map +1 -0
  260. package/dist/react/renderers/select.js +38 -0
  261. package/dist/react/renderers/select.js.map +1 -0
  262. package/dist/react/renderers/text.js +37 -0
  263. package/dist/react/renderers/text.js.map +1 -0
  264. package/dist/react/renderers/textarea.js +36 -0
  265. package/dist/react/renderers/textarea.js.map +1 -0
  266. package/dist/react/resolveForm.js +16 -0
  267. package/dist/react/resolveForm.js.map +1 -0
  268. package/dist/react/state.d.ts +15 -0
  269. package/dist/react/state.js +70 -0
  270. package/dist/react/state.js.map +1 -0
  271. package/dist/react/submitForm.d.ts +31 -0
  272. package/dist/react/submitForm.js +58 -0
  273. package/dist/react/submitForm.js.map +1 -0
  274. package/dist/react/toFormDocument.d.ts +24 -0
  275. package/dist/react/toFormDocument.js +22 -0
  276. package/dist/react/toFormDocument.js.map +1 -0
  277. package/dist/react/uploadFile.d.ts +23 -0
  278. package/dist/react/uploadFile.js +39 -0
  279. package/dist/react/uploadFile.js.map +1 -0
  280. package/dist/react/useField.d.ts +14 -0
  281. package/dist/react/useField.js +49 -0
  282. package/dist/react/useField.js.map +1 -0
  283. package/dist/react/useFormState.d.ts +8 -0
  284. package/dist/react/useFormState.js +9 -0
  285. package/dist/react/useFormState.js.map +1 -0
  286. package/dist/react/useFormStep.d.ts +8 -0
  287. package/dist/react/useFormStep.js +9 -0
  288. package/dist/react/useFormStep.js.map +1 -0
  289. package/dist/react/validateField.js +30 -0
  290. package/dist/react/validateField.js.map +1 -0
  291. package/dist/recall/interpolate.d.ts +10 -0
  292. package/dist/recall/interpolate.js +16 -0
  293. package/dist/recall/interpolate.js.map +1 -0
  294. package/dist/recall/resolver.d.ts +22 -0
  295. package/dist/recall/resolver.js +36 -0
  296. package/dist/recall/resolver.js.map +1 -0
  297. package/dist/spam/captcha.d.ts +12 -0
  298. package/dist/spam/captcha.js +11 -0
  299. package/dist/spam/captcha.js.map +1 -0
  300. package/dist/spam/constants.d.ts +12 -0
  301. package/dist/spam/constants.js +15 -0
  302. package/dist/spam/constants.js.map +1 -0
  303. package/dist/spam/identify.d.ts +12 -0
  304. package/dist/spam/identify.js +20 -0
  305. package/dist/spam/identify.js.map +1 -0
  306. package/dist/spam/rateLimiter.d.ts +18 -0
  307. package/dist/spam/rateLimiter.js +41 -0
  308. package/dist/spam/rateLimiter.js.map +1 -0
  309. package/dist/spam/reserved.js +30 -0
  310. package/dist/spam/reserved.js.map +1 -0
  311. package/dist/spam/resolveSpam.d.ts +12 -0
  312. package/dist/spam/resolveSpam.js +42 -0
  313. package/dist/spam/resolveSpam.js.map +1 -0
  314. package/dist/spam/spamGuard.js +68 -0
  315. package/dist/spam/spamGuard.js.map +1 -0
  316. package/dist/spam/types.d.ts +73 -0
  317. package/dist/spam/uploadHooks.js +33 -0
  318. package/dist/spam/uploadHooks.js.map +1 -0
  319. package/dist/submissions/SubmissionAnswers.d.ts +16 -0
  320. package/dist/submissions/SubmissionAnswers.js +57 -0
  321. package/dist/submissions/SubmissionAnswers.js.map +1 -0
  322. package/dist/submissions/runSubmission.js +205 -0
  323. package/dist/submissions/runSubmission.js.map +1 -0
  324. package/dist/submissions/types.d.ts +33 -0
  325. package/dist/submissions/validateSubmission.js +59 -0
  326. package/dist/submissions/validateSubmission.js.map +1 -0
  327. package/dist/translations/en.d.ts +12 -0
  328. package/dist/{translations-edMqq_2e.js → translations/en.js} +3 -22
  329. package/dist/translations/en.js.map +1 -0
  330. package/dist/translations/index.d.ts +14 -0
  331. package/dist/translations/index.js +26 -0
  332. package/dist/translations/index.js.map +1 -0
  333. package/dist/translations/keys.d.ts +132 -0
  334. package/dist/{keys-N5xGiUsh.js → translations/keys.js} +2 -2
  335. package/dist/translations/keys.js.map +1 -0
  336. package/dist/translations/makeTranslate.d.ts +11 -0
  337. package/dist/translations/makeTranslate.js +11 -0
  338. package/dist/translations/makeTranslate.js.map +1 -0
  339. package/dist/translations/server.js +25 -0
  340. package/dist/translations/server.js.map +1 -0
  341. package/dist/translations/useTranslation.js +12 -0
  342. package/dist/translations/useTranslation.js.map +1 -0
  343. package/dist/uploads/captureFileRef.d.ts +27 -0
  344. package/dist/uploads/captureFileRef.js +34 -0
  345. package/dist/uploads/captureFileRef.js.map +1 -0
  346. package/dist/uploads/resolveFileRef.d.ts +26 -0
  347. package/dist/uploads/resolveFileRef.js +44 -0
  348. package/dist/uploads/resolveFileRef.js.map +1 -0
  349. package/dist/uploads/types.d.ts +20 -0
  350. package/dist/validation/buildRuleBlocks.js +46 -0
  351. package/dist/validation/buildRuleBlocks.js.map +1 -0
  352. package/dist/validation/builtin/email.js +19 -0
  353. package/dist/validation/builtin/email.js.map +1 -0
  354. package/dist/validation/builtin/index.js +27 -0
  355. package/dist/validation/builtin/index.js.map +1 -0
  356. package/dist/validation/builtin/matchesField.js +20 -0
  357. package/dist/validation/builtin/matchesField.js.map +1 -0
  358. package/dist/validation/builtin/max.js +21 -0
  359. package/dist/validation/builtin/max.js.map +1 -0
  360. package/dist/validation/builtin/maxLength.js +26 -0
  361. package/dist/validation/builtin/maxLength.js.map +1 -0
  362. package/dist/validation/builtin/min.js +21 -0
  363. package/dist/validation/builtin/min.js.map +1 -0
  364. package/dist/validation/builtin/minLength.js +26 -0
  365. package/dist/validation/builtin/minLength.js.map +1 -0
  366. package/dist/validation/builtin/notAlreadySubmitted.js +32 -0
  367. package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -0
  368. package/dist/validation/builtin/oneOf.js +34 -0
  369. package/dist/validation/builtin/oneOf.js.map +1 -0
  370. package/dist/validation/builtin/pattern.js +41 -0
  371. package/dist/validation/builtin/pattern.js.map +1 -0
  372. package/dist/validation/builtin/url.js +22 -0
  373. package/dist/validation/builtin/url.js.map +1 -0
  374. package/dist/validation/defineValidationRule.d.ts +12 -0
  375. package/dist/validation/defineValidationRule.js +11 -0
  376. package/dist/validation/defineValidationRule.js.map +1 -0
  377. package/dist/validation/message.js +14 -0
  378. package/dist/validation/message.js.map +1 -0
  379. package/dist/validation/registry.d.ts +10 -0
  380. package/dist/validation/registry.js +20 -0
  381. package/dist/validation/registry.js.map +1 -0
  382. package/dist/validation/runValidation.js +111 -0
  383. package/dist/validation/runValidation.js.map +1 -0
  384. package/dist/validation/types.d.ts +76 -0
  385. package/package.json +8 -5
  386. package/styles/form-builder.css +201 -11
  387. package/dist/constants-B-BUfetP.d.ts +0 -288
  388. package/dist/exports/client.js.map +0 -1
  389. package/dist/exports/react.js.map +0 -1
  390. package/dist/exports/rsc.js.map +0 -1
  391. package/dist/fieldTypes-B8jkNRob.d.ts +0 -188
  392. package/dist/fieldTypes-CzhhJXjg.js.map +0 -1
  393. package/dist/index-DfFYGbVF.d.ts +0 -481
  394. package/dist/keys-N5xGiUsh.js.map +0 -1
  395. package/dist/registry-CoCyhtvB.js +0 -282
  396. package/dist/registry-CoCyhtvB.js.map +0 -1
  397. package/dist/resolver-OeQyVH2N.js +0 -665
  398. package/dist/resolver-OeQyVH2N.js.map +0 -1
  399. package/dist/translations-edMqq_2e.js.map +0 -1
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ //#region src/translations/makeTranslate.ts
3
+ /**
4
+ * Creates a `RendererTranslate` function from a flat key→string map (e.g. the bundled `en` map).
5
+ * Unknown keys fall back to the key itself so nothing crashes when running against an incomplete map.
6
+ */
7
+ const makeTranslate = (map) => (key) => map[key] ?? key;
8
+ //#endregion
9
+ export { makeTranslate };
10
+
11
+ //# sourceMappingURL=makeTranslate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeTranslate.js","names":[],"sources":["../../src/translations/makeTranslate.ts"],"sourcesContent":["'use client'\n\nimport type { RendererTranslate } from '../react/contract'\n\n/**\n * Creates a `RendererTranslate` function from a flat key→string map (e.g. the bundled `en` map).\n * Unknown keys fall back to the key itself so nothing crashes when running against an incomplete map.\n */\nexport const makeTranslate =\n\t(map: Record<string, string>): RendererTranslate =>\n\t(key) =>\n\t\tmap[key] ?? key\n"],"mappings":";;;;;;AAQA,MAAa,iBACX,SACA,QACA,IAAI,QAAQ"}
@@ -0,0 +1,25 @@
1
+ //#region src/translations/server.ts
2
+ /**
3
+ * Adapt a Payload request `t` (typed to core keys only) so it also accepts this
4
+ * plugin's keys. They are registered at config time and resolve at runtime; the
5
+ * cast only widens the compile-time key domain.
6
+ */
7
+ const asTranslate = (t) => t;
8
+ /**
9
+ * Adapt a Payload request `t` to the engine-facing `Translate` the submission core and field-type
10
+ * `format`/`validate` speak (any key string). Same runtime function as `asTranslate`; this widening
11
+ * accepts arbitrary keys because the engine resolves both this plugin's and a host's registered keys.
12
+ */
13
+ const asFieldTranslate = (t) => t;
14
+ /** A field `label`/`description` backed by a typed key, resolved per request. */
15
+ const labelForKey = (key) => ({ t }) => asTranslate(t)(key);
16
+ /**
17
+ * A `label`/`description` from an arbitrary key string (a field-type-supplied label, which may be a
18
+ * host-registered key or a literal; Payload's `t` returns the input unchanged when unknown). Distinct
19
+ * from `labelForKey`, which constrains to this plugin's typed keys.
20
+ */
21
+ const labelFor = (key) => ({ t }) => asTranslate(t)(key);
22
+ //#endregion
23
+ export { asFieldTranslate, asTranslate, labelFor, labelForKey };
24
+
25
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","names":[],"sources":["../../src/translations/server.ts"],"sourcesContent":["import type { LabelFunction } from 'payload'\n\nimport type { Translate as FieldTranslate } from '../fields/types'\nimport type { TranslationKey } from './keys'\n\n/** A `t`-like function narrowed to this plugin's typed keys. */\ntype Translate = (key: TranslationKey) => string\n\n/**\n * Adapt a Payload request `t` (typed to core keys only) so it also accepts this\n * plugin's keys. They are registered at config time and resolve at runtime; the\n * cast only widens the compile-time key domain.\n */\nexport const asTranslate = (t: unknown): Translate => t as Translate\n\n/**\n * Adapt a Payload request `t` to the engine-facing `Translate` the submission core and field-type\n * `format`/`validate` speak (any key string). Same runtime function as `asTranslate`; this widening\n * accepts arbitrary keys because the engine resolves both this plugin's and a host's registered keys.\n */\nexport const asFieldTranslate = (t: unknown): FieldTranslate => t as FieldTranslate\n\n/** A field `label`/`description` backed by a typed key, resolved per request. */\nexport const labelForKey =\n\t(key: TranslationKey): LabelFunction =>\n\t({ t }) =>\n\t\tasTranslate(t)(key)\n\n/**\n * A `label`/`description` from an arbitrary key string (a field-type-supplied label, which may be a\n * host-registered key or a literal; Payload's `t` returns the input unchanged when unknown). Distinct\n * from `labelForKey`, which constrains to this plugin's typed keys.\n */\nexport const labelFor =\n\t(key: string): LabelFunction =>\n\t({ t }) =>\n\t\tasTranslate(t)(key as TranslationKey)\n"],"mappings":";;;;;;AAaA,MAAa,eAAe,MAA0B;;;;;;AAOtD,MAAa,oBAAoB,MAA+B;;AAGhE,MAAa,eACX,SACA,EAAE,QACF,YAAY,CAAC,EAAE,GAAG;;;;;;AAOpB,MAAa,YACX,SACA,EAAE,QACF,YAAY,CAAC,EAAE,GAAqB"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useTranslation } from "@payloadcms/ui";
3
+ //#region src/translations/useTranslation.ts
4
+ /**
5
+ * `useTranslation` bound to this plugin's keys, so `t(keys.X)` typechecks without
6
+ * a per-call `@ts-expect-error`. Returns Payload's `{ t, i18n }` unchanged.
7
+ */
8
+ const useTranslation$1 = () => useTranslation();
9
+ //#endregion
10
+ export { useTranslation$1 as useTranslation };
11
+
12
+ //# sourceMappingURL=useTranslation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTranslation.js","names":["useTranslation","usePayloadTranslation"],"sources":["../../src/translations/useTranslation.ts"],"sourcesContent":["'use client'\n\nimport { useTranslation as usePayloadTranslation } from '@payloadcms/ui'\n\nimport type { TranslationKey } from './keys'\n\n/**\n * `useTranslation` bound to this plugin's keys, so `t(keys.X)` typechecks without\n * a per-call `@ts-expect-error`. Returns Payload's `{ t, i18n }` unchanged.\n */\nexport const useTranslation = () => usePayloadTranslation<Record<string, never>, TranslationKey>()\n"],"mappings":";;;;;;;AAUA,MAAaA,yBAAuBC,eAA6D"}
@@ -0,0 +1,27 @@
1
+ import { FileFieldConfig } from "./types.js";
2
+ import { ResolveFileRefResult } from "./resolveFileRef.js";
3
+ import { Payload, PayloadRequest } from "payload";
4
+
5
+ //#region src/uploads/captureFileRef.d.ts
6
+ type CaptureFileRefArgs = {
7
+ payload: Payload;
8
+ collectionSlug: string;
9
+ uploadId: string | number;
10
+ config: FileFieldConfig;
11
+ req?: PayloadRequest; /** Resolved submitter identity; must match the upload's `owner` stamp when both are present. */
12
+ expectedOwner?: string;
13
+ };
14
+ /**
15
+ * Load the referenced upload doc and run the pure trust-boundary check. The client sends only the id; the
16
+ * filename/mimeType/filesize are read authoritatively from the stored doc, never from the client. When the
17
+ * upload carries an `owner` stamp AND the submitter is identifiable, the two must match, so an anonymous
18
+ * submitter cannot capture another identity's upload; a mismatch collapses to `missing`, indistinguishable
19
+ * from a deleted upload. When the submitter cannot be identified (no `expectedOwner`), ownership is not
20
+ * enforced (fail-open, consistent with rate-limiting): a proxy-configured deployment identifies every
21
+ * request, so this only relaxes scoping where it could not be applied fairly anyway. Unstamped uploads
22
+ * (no identity at upload time, or a BYO collection without the field) pass unchanged.
23
+ */
24
+ declare const captureFileRef: (args: CaptureFileRefArgs) => Promise<ResolveFileRefResult>;
25
+ //#endregion
26
+ export { captureFileRef };
27
+ //# sourceMappingURL=captureFileRef.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { resolveFileRef } from "./resolveFileRef.js";
2
+ //#region src/uploads/captureFileRef.ts
3
+ /**
4
+ * Load the referenced upload doc and run the pure trust-boundary check. The client sends only the id; the
5
+ * filename/mimeType/filesize are read authoritatively from the stored doc, never from the client. When the
6
+ * upload carries an `owner` stamp AND the submitter is identifiable, the two must match, so an anonymous
7
+ * submitter cannot capture another identity's upload; a mismatch collapses to `missing`, indistinguishable
8
+ * from a deleted upload. When the submitter cannot be identified (no `expectedOwner`), ownership is not
9
+ * enforced (fail-open, consistent with rate-limiting): a proxy-configured deployment identifies every
10
+ * request, so this only relaxes scoping where it could not be applied fairly anyway. Unstamped uploads
11
+ * (no identity at upload time, or a BYO collection without the field) pass unchanged.
12
+ */
13
+ const captureFileRef = async (args) => {
14
+ const { payload, collectionSlug, uploadId, config, req, expectedOwner } = args;
15
+ const doc = await payload.findByID({
16
+ collection: collectionSlug,
17
+ id: uploadId,
18
+ depth: 0,
19
+ overrideAccess: true,
20
+ req
21
+ }).catch(() => null);
22
+ if (doc && expectedOwner != null) {
23
+ const owner = doc.owner;
24
+ if (typeof owner === "string" && owner.length > 0 && owner !== expectedOwner) return {
25
+ ok: false,
26
+ code: "missing"
27
+ };
28
+ }
29
+ return resolveFileRef(doc, config);
30
+ };
31
+ //#endregion
32
+ export { captureFileRef };
33
+
34
+ //# sourceMappingURL=captureFileRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureFileRef.js","names":[],"sources":["../../src/uploads/captureFileRef.ts"],"sourcesContent":["import type { CollectionSlug, Payload, PayloadRequest } from 'payload'\nimport { type ResolveFileRefResult, resolveFileRef } from './resolveFileRef'\nimport type { FileFieldConfig } from './types'\n\nexport type CaptureFileRefArgs = {\n\tpayload: Payload\n\tcollectionSlug: string\n\tuploadId: string | number\n\tconfig: FileFieldConfig\n\treq?: PayloadRequest\n\t/** Resolved submitter identity; must match the upload's `owner` stamp when both are present. */\n\texpectedOwner?: string\n}\n\n/**\n * Load the referenced upload doc and run the pure trust-boundary check. The client sends only the id; the\n * filename/mimeType/filesize are read authoritatively from the stored doc, never from the client. When the\n * upload carries an `owner` stamp AND the submitter is identifiable, the two must match, so an anonymous\n * submitter cannot capture another identity's upload; a mismatch collapses to `missing`, indistinguishable\n * from a deleted upload. When the submitter cannot be identified (no `expectedOwner`), ownership is not\n * enforced (fail-open, consistent with rate-limiting): a proxy-configured deployment identifies every\n * request, so this only relaxes scoping where it could not be applied fairly anyway. Unstamped uploads\n * (no identity at upload time, or a BYO collection without the field) pass unchanged.\n */\nexport const captureFileRef = async (args: CaptureFileRefArgs): Promise<ResolveFileRefResult> => {\n\tconst { payload, collectionSlug, uploadId, config, req, expectedOwner } = args\n\tconst doc = await payload\n\t\t.findByID({\n\t\t\tcollection: collectionSlug as CollectionSlug,\n\t\t\tid: uploadId,\n\t\t\tdepth: 0,\n\t\t\toverrideAccess: true,\n\t\t\treq,\n\t\t})\n\t\t.catch(() => null)\n\tif (doc && expectedOwner != null) {\n\t\tconst owner = (doc as { owner?: unknown }).owner\n\t\tif (typeof owner === 'string' && owner.length > 0 && owner !== expectedOwner) {\n\t\t\treturn { ok: false, code: 'missing' }\n\t\t}\n\t}\n\treturn resolveFileRef(doc, config)\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAa,iBAAiB,OAAO,SAA4D;CAChG,MAAM,EAAE,SAAS,gBAAgB,UAAU,QAAQ,KAAK,kBAAkB;CAC1E,MAAM,MAAM,MAAM,QAChB,SAAS;EACT,YAAY;EACZ,IAAI;EACJ,OAAO;EACP,gBAAgB;EAChB;CACD,CAAC,EACA,YAAY,IAAI;CAClB,IAAI,OAAO,iBAAiB,MAAM;EACjC,MAAM,QAAS,IAA4B;EAC3C,IAAI,OAAO,UAAU,YAAY,MAAM,SAAS,KAAK,UAAU,eAC9D,OAAO;GAAE,IAAI;GAAO,MAAM;EAAU;CAEtC;CACA,OAAO,eAAe,KAAK,MAAM;AAClC"}
@@ -0,0 +1,26 @@
1
+ import { FileFieldConfig, FileRef, FileRefError } from "./types.js";
2
+
3
+ //#region src/uploads/resolveFileRef.d.ts
4
+ type UploadDoc = {
5
+ id?: string | number;
6
+ filename?: unknown;
7
+ mimeType?: unknown;
8
+ filesize?: unknown;
9
+ url?: unknown;
10
+ };
11
+ type ResolveFileRefResult = {
12
+ ok: true;
13
+ ref: FileRef;
14
+ } | {
15
+ ok: false;
16
+ code: FileRefError;
17
+ };
18
+ /**
19
+ * Pure server trust-boundary check for an uploaded file: given the loaded upload doc (or null) and the
20
+ * field's constraints, either return an authoritative `FileRef` snapshot or a rejection code. Never trusts
21
+ * client metadata; the caller passes the doc it loaded from the upload collection.
22
+ */
23
+ declare const resolveFileRef: (doc: UploadDoc | null | undefined, config: FileFieldConfig) => ResolveFileRefResult;
24
+ //#endregion
25
+ export { ResolveFileRefResult, resolveFileRef };
26
+ //# sourceMappingURL=resolveFileRef.d.ts.map
@@ -0,0 +1,44 @@
1
+ //#region src/uploads/resolveFileRef.ts
2
+ const mimeAllowed = (mimeType, allow) => {
3
+ if (!allow || allow.length === 0) return true;
4
+ return allow.some((pattern) => {
5
+ if (pattern.endsWith("/*")) return mimeType.startsWith(pattern.slice(0, -1));
6
+ return mimeType === pattern;
7
+ });
8
+ };
9
+ /**
10
+ * Pure server trust-boundary check for an uploaded file: given the loaded upload doc (or null) and the
11
+ * field's constraints, either return an authoritative `FileRef` snapshot or a rejection code. Never trusts
12
+ * client metadata; the caller passes the doc it loaded from the upload collection.
13
+ */
14
+ const resolveFileRef = (doc, config) => {
15
+ if (doc == null || doc.id == null) return {
16
+ ok: false,
17
+ code: "missing"
18
+ };
19
+ const mimeType = typeof doc.mimeType === "string" ? doc.mimeType : "";
20
+ const filesize = typeof doc.filesize === "number" ? doc.filesize : 0;
21
+ if (!mimeAllowed(mimeType, config.mimeTypes)) return {
22
+ ok: false,
23
+ code: "mimeType"
24
+ };
25
+ if (typeof config.maxSize === "number" && filesize > config.maxSize) return {
26
+ ok: false,
27
+ code: "tooLarge"
28
+ };
29
+ const ref = {
30
+ id: doc.id,
31
+ filename: typeof doc.filename === "string" ? doc.filename : "",
32
+ mimeType,
33
+ filesize
34
+ };
35
+ if (typeof doc.url === "string" && doc.url.length > 0) ref.url = doc.url;
36
+ return {
37
+ ok: true,
38
+ ref
39
+ };
40
+ };
41
+ //#endregion
42
+ export { resolveFileRef };
43
+
44
+ //# sourceMappingURL=resolveFileRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveFileRef.js","names":[],"sources":["../../src/uploads/resolveFileRef.ts"],"sourcesContent":["import type { FileFieldConfig, FileRef, FileRefError } from './types'\n\ntype UploadDoc = {\n\tid?: string | number\n\tfilename?: unknown\n\tmimeType?: unknown\n\tfilesize?: unknown\n\turl?: unknown\n}\n\nexport type ResolveFileRefResult = { ok: true; ref: FileRef } | { ok: false; code: FileRefError }\n\nconst mimeAllowed = (mimeType: string, allow: string[] | undefined): boolean => {\n\tif (!allow || allow.length === 0) {\n\t\treturn true\n\t}\n\treturn allow.some((pattern) => {\n\t\tif (pattern.endsWith('/*')) {\n\t\t\treturn mimeType.startsWith(pattern.slice(0, -1))\n\t\t}\n\t\treturn mimeType === pattern\n\t})\n}\n\n/**\n * Pure server trust-boundary check for an uploaded file: given the loaded upload doc (or null) and the\n * field's constraints, either return an authoritative `FileRef` snapshot or a rejection code. Never trusts\n * client metadata; the caller passes the doc it loaded from the upload collection.\n */\nexport const resolveFileRef = (\n\tdoc: UploadDoc | null | undefined,\n\tconfig: FileFieldConfig\n): ResolveFileRefResult => {\n\tif (doc == null || doc.id == null) {\n\t\treturn { ok: false, code: 'missing' }\n\t}\n\tconst mimeType = typeof doc.mimeType === 'string' ? doc.mimeType : ''\n\tconst filesize = typeof doc.filesize === 'number' ? doc.filesize : 0\n\tif (!mimeAllowed(mimeType, config.mimeTypes)) {\n\t\treturn { ok: false, code: 'mimeType' }\n\t}\n\tif (typeof config.maxSize === 'number' && filesize > config.maxSize) {\n\t\treturn { ok: false, code: 'tooLarge' }\n\t}\n\tconst ref: FileRef = {\n\t\tid: doc.id,\n\t\tfilename: typeof doc.filename === 'string' ? doc.filename : '',\n\t\tmimeType,\n\t\tfilesize,\n\t}\n\tif (typeof doc.url === 'string' && doc.url.length > 0) {\n\t\tref.url = doc.url\n\t}\n\treturn { ok: true, ref }\n}\n"],"mappings":";AAYA,MAAM,eAAe,UAAkB,UAAyC;CAC/E,IAAI,CAAC,SAAS,MAAM,WAAW,GAC9B,OAAO;CAER,OAAO,MAAM,MAAM,YAAY;EAC9B,IAAI,QAAQ,SAAS,IAAI,GACxB,OAAO,SAAS,WAAW,QAAQ,MAAM,GAAG,EAAE,CAAC;EAEhD,OAAO,aAAa;CACrB,CAAC;AACF;;;;;;AAOA,MAAa,kBACZ,KACA,WAC0B;CAC1B,IAAI,OAAO,QAAQ,IAAI,MAAM,MAC5B,OAAO;EAAE,IAAI;EAAO,MAAM;CAAU;CAErC,MAAM,WAAW,OAAO,IAAI,aAAa,WAAW,IAAI,WAAW;CACnE,MAAM,WAAW,OAAO,IAAI,aAAa,WAAW,IAAI,WAAW;CACnE,IAAI,CAAC,YAAY,UAAU,OAAO,SAAS,GAC1C,OAAO;EAAE,IAAI;EAAO,MAAM;CAAW;CAEtC,IAAI,OAAO,OAAO,YAAY,YAAY,WAAW,OAAO,SAC3D,OAAO;EAAE,IAAI;EAAO,MAAM;CAAW;CAEtC,MAAM,MAAe;EACpB,IAAI,IAAI;EACR,UAAU,OAAO,IAAI,aAAa,WAAW,IAAI,WAAW;EAC5D;EACA;CACD;CACA,IAAI,OAAO,IAAI,QAAQ,YAAY,IAAI,IAAI,SAAS,GACnD,IAAI,MAAM,IAAI;CAEf,OAAO;EAAE,IAAI;EAAM;CAAI;AACxB"}
@@ -0,0 +1,20 @@
1
+ //#region src/uploads/types.d.ts
2
+ /** A self-describing reference to an uploaded file, captured server-side and stored as the field's value. */
3
+ type FileRef = {
4
+ id: string | number;
5
+ filename: string;
6
+ mimeType: string;
7
+ filesize: number;
8
+ url?: string;
9
+ };
10
+ /** Per-field file constraints, authored in the field config. */
11
+ type FileFieldConfig = {
12
+ /** Upload collection slug to read from. Defaults to the plugin's `form-uploads`. */relationTo?: string; /** Allowed MIME types (exact match or a `type/*` wildcard). Empty/absent allows any. */
13
+ mimeTypes?: string[]; /** Maximum file size in bytes. Absent allows any size (subject to the collection limit). */
14
+ maxSize?: number;
15
+ };
16
+ /** Why a file reference was rejected at the server trust boundary. */
17
+ type FileRefError = 'missing' | 'mimeType' | 'tooLarge';
18
+ //#endregion
19
+ export { FileFieldConfig, FileRef, FileRefError };
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { keys } from "../translations/keys.js";
2
+ import { labelFor } from "../translations/server.js";
3
+ //#region src/validation/buildRuleBlocks.ts
4
+ /** Each rule block appends its own `message` and `severity` fields, so a rule param of either name would collide and be silently dropped by Payload. */
5
+ const RESERVED_PARAM_NAMES = new Set(["message", "severity"]);
6
+ /** One block per rule applicable to `fieldType` (gated by `appliesTo`): the rule params, then a message override and severity. */
7
+ const buildRuleBlocks = (registry, fieldType) => {
8
+ const blocks = [];
9
+ for (const rule of registry.values()) {
10
+ if (rule.appliesTo && !rule.appliesTo.includes(fieldType)) continue;
11
+ for (const param of rule.params ?? []) if ("name" in param && RESERVED_PARAM_NAMES.has(param.name)) throw new Error(`form-builder: validation rule "${rule.type}" declares a reserved param name "${param.name}". The names "message" and "severity" are reserved for the constraint-list UI.`);
12
+ blocks.push({
13
+ slug: rule.type,
14
+ labels: {
15
+ singular: labelFor(rule.label),
16
+ plural: labelFor(rule.label)
17
+ },
18
+ fields: [
19
+ ...rule.params ?? [],
20
+ {
21
+ name: "message",
22
+ type: "text",
23
+ label: labelFor(keys.validationMessageLabel)
24
+ },
25
+ {
26
+ name: "severity",
27
+ type: "select",
28
+ defaultValue: "error",
29
+ label: labelFor(keys.validationSeverityLabel),
30
+ options: [{
31
+ label: labelFor(keys.validationSeverityError),
32
+ value: "error"
33
+ }, {
34
+ label: labelFor(keys.validationSeverityWarning),
35
+ value: "warning"
36
+ }]
37
+ }
38
+ ]
39
+ });
40
+ }
41
+ return blocks;
42
+ };
43
+ //#endregion
44
+ export { buildRuleBlocks };
45
+
46
+ //# sourceMappingURL=buildRuleBlocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildRuleBlocks.js","names":[],"sources":["../../src/validation/buildRuleBlocks.ts"],"sourcesContent":["import type { Block } from 'payload'\nimport { keys } from '../translations/keys'\nimport { labelFor } from '../translations/server'\nimport type { ValidationRuleRegistry } from './registry'\n\n/** Each rule block appends its own `message` and `severity` fields, so a rule param of either name would collide and be silently dropped by Payload. */\nconst RESERVED_PARAM_NAMES = new Set(['message', 'severity'])\n\n/** One block per rule applicable to `fieldType` (gated by `appliesTo`): the rule params, then a message override and severity. */\nexport const buildRuleBlocks = (registry: ValidationRuleRegistry, fieldType: string): Block[] => {\n\tconst blocks: Block[] = []\n\tfor (const rule of registry.values()) {\n\t\tif (rule.appliesTo && !rule.appliesTo.includes(fieldType)) {\n\t\t\tcontinue\n\t\t}\n\t\tfor (const param of rule.params ?? []) {\n\t\t\tif ('name' in param && RESERVED_PARAM_NAMES.has(param.name)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`form-builder: validation rule \"${rule.type}\" declares a reserved param name \"${param.name}\". The names \"message\" and \"severity\" are reserved for the constraint-list UI.`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tblocks.push({\n\t\t\tslug: rule.type,\n\t\t\tlabels: { singular: labelFor(rule.label), plural: labelFor(rule.label) },\n\t\t\tfields: [\n\t\t\t\t...(rule.params ?? []),\n\t\t\t\t{ name: 'message', type: 'text', label: labelFor(keys.validationMessageLabel) },\n\t\t\t\t{\n\t\t\t\t\tname: 'severity',\n\t\t\t\t\ttype: 'select',\n\t\t\t\t\tdefaultValue: 'error',\n\t\t\t\t\tlabel: labelFor(keys.validationSeverityLabel),\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ label: labelFor(keys.validationSeverityError), value: 'error' },\n\t\t\t\t\t\t{ label: labelFor(keys.validationSeverityWarning), value: 'warning' },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\t}\n\treturn blocks\n}\n"],"mappings":";;;;AAMA,MAAM,uBAAuB,IAAI,IAAI,CAAC,WAAW,UAAU,CAAC;;AAG5D,MAAa,mBAAmB,UAAkC,cAA+B;CAChG,MAAM,SAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,SAAS,OAAO,GAAG;EACrC,IAAI,KAAK,aAAa,CAAC,KAAK,UAAU,SAAS,SAAS,GACvD;EAED,KAAK,MAAM,SAAS,KAAK,UAAU,CAAC,GACnC,IAAI,UAAU,SAAS,qBAAqB,IAAI,MAAM,IAAI,GACzD,MAAM,IAAI,MACT,kCAAkC,KAAK,KAAK,oCAAoC,MAAM,KAAK,+EAC5F;EAGF,OAAO,KAAK;GACX,MAAM,KAAK;GACX,QAAQ;IAAE,UAAU,SAAS,KAAK,KAAK;IAAG,QAAQ,SAAS,KAAK,KAAK;GAAE;GACvE,QAAQ;IACP,GAAI,KAAK,UAAU,CAAC;IACpB;KAAE,MAAM;KAAW,MAAM;KAAQ,OAAO,SAAS,KAAK,sBAAsB;IAAE;IAC9E;KACC,MAAM;KACN,MAAM;KACN,cAAc;KACd,OAAO,SAAS,KAAK,uBAAuB;KAC5C,SAAS,CACR;MAAE,OAAO,SAAS,KAAK,uBAAuB;MAAG,OAAO;KAAQ,GAChE;MAAE,OAAO,SAAS,KAAK,yBAAyB;MAAG,OAAO;KAAU,CACrE;IACD;GACD;EACD,CAAC;CACF;CACA,OAAO;AACR"}
@@ -0,0 +1,19 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { defineValidationRule } from "../defineValidationRule.js";
3
+ //#region src/validation/builtin/email.ts
4
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
5
+ const emailRule = defineValidationRule({
6
+ type: "email",
7
+ label: keys.ruleEmail,
8
+ appliesTo: [
9
+ "text",
10
+ "textarea",
11
+ "email"
12
+ ],
13
+ defaultMessage: keys.ruleEmailMessage,
14
+ validate: ({ value, message }) => value == null || value === "" || EMAIL_PATTERN.test(value) ? true : message()
15
+ });
16
+ //#endregion
17
+ export { emailRule };
18
+
19
+ //# sourceMappingURL=email.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.js","names":[],"sources":["../../../src/validation/builtin/email.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { defineValidationRule } from '../defineValidationRule'\n\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\nexport const emailRule = defineValidationRule<Record<string, never>, string>({\n\ttype: 'email',\n\tlabel: keys.ruleEmail,\n\tappliesTo: ['text', 'textarea', 'email'],\n\tdefaultMessage: keys.ruleEmailMessage,\n\tvalidate: ({ value, message }) =>\n\t\tvalue == null || value === '' || EMAIL_PATTERN.test(value) ? true : message(),\n})\n"],"mappings":";;;AAGA,MAAM,gBAAgB;AAEtB,MAAa,YAAY,qBAAoD;CAC5E,MAAM;CACN,OAAO,KAAK;CACZ,WAAW;EAAC;EAAQ;EAAY;CAAO;CACvC,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,cACnB,SAAS,QAAQ,UAAU,MAAM,cAAc,KAAK,KAAK,IAAI,OAAO,QAAQ;AAC9E,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { emailRule } from "./email.js";
2
+ import { matchesFieldRule } from "./matchesField.js";
3
+ import { maxRule } from "./max.js";
4
+ import { maxLengthRule } from "./maxLength.js";
5
+ import { minRule } from "./min.js";
6
+ import { minLengthRule } from "./minLength.js";
7
+ import { notAlreadySubmittedRule } from "./notAlreadySubmitted.js";
8
+ import { oneOfRule } from "./oneOf.js";
9
+ import { patternRule } from "./pattern.js";
10
+ import { urlRule } from "./url.js";
11
+ //#region src/validation/builtin/index.ts
12
+ const defaultValidationRules = [
13
+ minLengthRule,
14
+ maxLengthRule,
15
+ minRule,
16
+ maxRule,
17
+ patternRule,
18
+ emailRule,
19
+ urlRule,
20
+ oneOfRule,
21
+ matchesFieldRule,
22
+ notAlreadySubmittedRule
23
+ ];
24
+ //#endregion
25
+ export { defaultValidationRules };
26
+
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/validation/builtin/index.ts"],"sourcesContent":["import type { AnyValidationRuleDefinition } from '../types'\nimport { emailRule } from './email'\nimport { matchesFieldRule } from './matchesField'\nimport { maxRule } from './max'\nimport { maxLengthRule } from './maxLength'\nimport { minRule } from './min'\nimport { minLengthRule } from './minLength'\nimport { notAlreadySubmittedRule } from './notAlreadySubmitted'\nimport { oneOfRule } from './oneOf'\nimport { patternRule } from './pattern'\nimport { urlRule } from './url'\n\n// Rules are authored with precise param/value generics; the registry stores them erased (params\n// re-narrow per matched rule at execution). One cast per rule, no `any`.\nexport const defaultValidationRules: AnyValidationRuleDefinition[] = [\n\tminLengthRule as AnyValidationRuleDefinition,\n\tmaxLengthRule as AnyValidationRuleDefinition,\n\tminRule as AnyValidationRuleDefinition,\n\tmaxRule as AnyValidationRuleDefinition,\n\tpatternRule as AnyValidationRuleDefinition,\n\temailRule as AnyValidationRuleDefinition,\n\turlRule as AnyValidationRuleDefinition,\n\toneOfRule as AnyValidationRuleDefinition,\n\tmatchesFieldRule as AnyValidationRuleDefinition,\n\tnotAlreadySubmittedRule as AnyValidationRuleDefinition,\n]\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,yBAAwD;CACpE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD"}
@@ -0,0 +1,20 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { labelFor } from "../../translations/server.js";
3
+ import { defineValidationRule } from "../defineValidationRule.js";
4
+ //#region src/validation/builtin/matchesField.ts
5
+ const matchesFieldRule = defineValidationRule({
6
+ type: "matchesField",
7
+ label: keys.ruleMatchesField,
8
+ params: [{
9
+ name: "field",
10
+ type: "text",
11
+ required: true,
12
+ label: labelFor(keys.ruleParamField)
13
+ }],
14
+ defaultMessage: keys.ruleMatchesFieldMessage,
15
+ validate: ({ value, params, siblingData, message }) => value === siblingData[params.field] ? true : message()
16
+ });
17
+ //#endregion
18
+ export { matchesFieldRule };
19
+
20
+ //# sourceMappingURL=matchesField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchesField.js","names":[],"sources":["../../../src/validation/builtin/matchesField.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineValidationRule } from '../defineValidationRule'\n\nexport const matchesFieldRule = defineValidationRule<{ field: string }, unknown>({\n\ttype: 'matchesField',\n\tlabel: keys.ruleMatchesField,\n\tparams: [{ name: 'field', type: 'text', required: true, label: labelFor(keys.ruleParamField) }],\n\tdefaultMessage: keys.ruleMatchesFieldMessage,\n\tvalidate: ({ value, params, siblingData, message }) =>\n\t\tvalue === siblingData[params.field] ? true : message(),\n})\n"],"mappings":";;;;AAIA,MAAa,mBAAmB,qBAAiD;CAChF,MAAM;CACN,OAAO,KAAK;CACZ,QAAQ,CAAC;EAAE,MAAM;EAAS,MAAM;EAAQ,UAAU;EAAM,OAAO,SAAS,KAAK,cAAc;CAAE,CAAC;CAC9F,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,QAAQ,aAAa,cACxC,UAAU,YAAY,OAAO,SAAS,OAAO,QAAQ;AACvD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { labelFor } from "../../translations/server.js";
3
+ import { defineValidationRule } from "../defineValidationRule.js";
4
+ //#region src/validation/builtin/max.ts
5
+ const maxRule = defineValidationRule({
6
+ type: "max",
7
+ label: keys.ruleMax,
8
+ appliesTo: ["number"],
9
+ params: [{
10
+ name: "max",
11
+ type: "number",
12
+ required: true,
13
+ label: labelFor(keys.ruleParamMax)
14
+ }],
15
+ defaultMessage: keys.ruleMaxMessage,
16
+ validate: ({ value, params, message }) => value == null || value <= params.max ? true : message({ max: params.max })
17
+ });
18
+ //#endregion
19
+ export { maxRule };
20
+
21
+ //# sourceMappingURL=max.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max.js","names":[],"sources":["../../../src/validation/builtin/max.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineValidationRule } from '../defineValidationRule'\n\nexport const maxRule = defineValidationRule<{ max: number }, number>({\n\ttype: 'max',\n\tlabel: keys.ruleMax,\n\tappliesTo: ['number'],\n\tparams: [{ name: 'max', type: 'number', required: true, label: labelFor(keys.ruleParamMax) }],\n\tdefaultMessage: keys.ruleMaxMessage,\n\tvalidate: ({ value, params, message }) =>\n\t\tvalue == null || value <= params.max ? true : message({ max: params.max }),\n})\n"],"mappings":";;;;AAIA,MAAa,UAAU,qBAA8C;CACpE,MAAM;CACN,OAAO,KAAK;CACZ,WAAW,CAAC,QAAQ;CACpB,QAAQ,CAAC;EAAE,MAAM;EAAO,MAAM;EAAU,UAAU;EAAM,OAAO,SAAS,KAAK,YAAY;CAAE,CAAC;CAC5F,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,QAAQ,cAC3B,SAAS,QAAQ,SAAS,OAAO,MAAM,OAAO,QAAQ,EAAE,KAAK,OAAO,IAAI,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { labelFor } from "../../translations/server.js";
3
+ import { defineValidationRule } from "../defineValidationRule.js";
4
+ //#region src/validation/builtin/maxLength.ts
5
+ const maxLengthRule = defineValidationRule({
6
+ type: "maxLength",
7
+ label: keys.ruleMaxLength,
8
+ appliesTo: [
9
+ "text",
10
+ "textarea",
11
+ "email"
12
+ ],
13
+ params: [{
14
+ name: "max",
15
+ type: "number",
16
+ required: true,
17
+ min: 0,
18
+ label: labelFor(keys.ruleParamMax)
19
+ }],
20
+ defaultMessage: keys.ruleMaxLengthMessage,
21
+ validate: ({ value, params, message }) => value == null || value === "" || value.length <= params.max ? true : message({ max: params.max })
22
+ });
23
+ //#endregion
24
+ export { maxLengthRule };
25
+
26
+ //# sourceMappingURL=maxLength.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maxLength.js","names":[],"sources":["../../../src/validation/builtin/maxLength.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineValidationRule } from '../defineValidationRule'\n\nexport const maxLengthRule = defineValidationRule<{ max: number }, string>({\n\ttype: 'maxLength',\n\tlabel: keys.ruleMaxLength,\n\tappliesTo: ['text', 'textarea', 'email'],\n\tparams: [\n\t\t{ name: 'max', type: 'number', required: true, min: 0, label: labelFor(keys.ruleParamMax) },\n\t],\n\tdefaultMessage: keys.ruleMaxLengthMessage,\n\tvalidate: ({ value, params, message }) =>\n\t\tvalue == null || value === '' || value.length <= params.max\n\t\t\t? true\n\t\t\t: message({ max: params.max }),\n})\n"],"mappings":";;;;AAIA,MAAa,gBAAgB,qBAA8C;CAC1E,MAAM;CACN,OAAO,KAAK;CACZ,WAAW;EAAC;EAAQ;EAAY;CAAO;CACvC,QAAQ,CACP;EAAE,MAAM;EAAO,MAAM;EAAU,UAAU;EAAM,KAAK;EAAG,OAAO,SAAS,KAAK,YAAY;CAAE,CAC3F;CACA,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,QAAQ,cAC3B,SAAS,QAAQ,UAAU,MAAM,MAAM,UAAU,OAAO,MACrD,OACA,QAAQ,EAAE,KAAK,OAAO,IAAI,CAAC;AAChC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { labelFor } from "../../translations/server.js";
3
+ import { defineValidationRule } from "../defineValidationRule.js";
4
+ //#region src/validation/builtin/min.ts
5
+ const minRule = defineValidationRule({
6
+ type: "min",
7
+ label: keys.ruleMin,
8
+ appliesTo: ["number"],
9
+ params: [{
10
+ name: "min",
11
+ type: "number",
12
+ required: true,
13
+ label: labelFor(keys.ruleParamMin)
14
+ }],
15
+ defaultMessage: keys.ruleMinMessage,
16
+ validate: ({ value, params, message }) => value == null || value >= params.min ? true : message({ min: params.min })
17
+ });
18
+ //#endregion
19
+ export { minRule };
20
+
21
+ //# sourceMappingURL=min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min.js","names":[],"sources":["../../../src/validation/builtin/min.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineValidationRule } from '../defineValidationRule'\n\nexport const minRule = defineValidationRule<{ min: number }, number>({\n\ttype: 'min',\n\tlabel: keys.ruleMin,\n\tappliesTo: ['number'],\n\tparams: [{ name: 'min', type: 'number', required: true, label: labelFor(keys.ruleParamMin) }],\n\tdefaultMessage: keys.ruleMinMessage,\n\tvalidate: ({ value, params, message }) =>\n\t\tvalue == null || value >= params.min ? true : message({ min: params.min }),\n})\n"],"mappings":";;;;AAIA,MAAa,UAAU,qBAA8C;CACpE,MAAM;CACN,OAAO,KAAK;CACZ,WAAW,CAAC,QAAQ;CACpB,QAAQ,CAAC;EAAE,MAAM;EAAO,MAAM;EAAU,UAAU;EAAM,OAAO,SAAS,KAAK,YAAY;CAAE,CAAC;CAC5F,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,QAAQ,cAC3B,SAAS,QAAQ,SAAS,OAAO,MAAM,OAAO,QAAQ,EAAE,KAAK,OAAO,IAAI,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { labelFor } from "../../translations/server.js";
3
+ import { defineValidationRule } from "../defineValidationRule.js";
4
+ //#region src/validation/builtin/minLength.ts
5
+ const minLengthRule = defineValidationRule({
6
+ type: "minLength",
7
+ label: keys.ruleMinLength,
8
+ appliesTo: [
9
+ "text",
10
+ "textarea",
11
+ "email"
12
+ ],
13
+ params: [{
14
+ name: "min",
15
+ type: "number",
16
+ required: true,
17
+ min: 0,
18
+ label: labelFor(keys.ruleParamMin)
19
+ }],
20
+ defaultMessage: keys.ruleMinLengthMessage,
21
+ validate: ({ value, params, message }) => value == null || value === "" || value.length >= params.min ? true : message({ min: params.min })
22
+ });
23
+ //#endregion
24
+ export { minLengthRule };
25
+
26
+ //# sourceMappingURL=minLength.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minLength.js","names":[],"sources":["../../../src/validation/builtin/minLength.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineValidationRule } from '../defineValidationRule'\n\nexport const minLengthRule = defineValidationRule<{ min: number }, string>({\n\ttype: 'minLength',\n\tlabel: keys.ruleMinLength,\n\tappliesTo: ['text', 'textarea', 'email'],\n\tparams: [\n\t\t{ name: 'min', type: 'number', required: true, min: 0, label: labelFor(keys.ruleParamMin) },\n\t],\n\tdefaultMessage: keys.ruleMinLengthMessage,\n\tvalidate: ({ value, params, message }) =>\n\t\tvalue == null || value === '' || value.length >= params.min\n\t\t\t? true\n\t\t\t: message({ min: params.min }),\n})\n"],"mappings":";;;;AAIA,MAAa,gBAAgB,qBAA8C;CAC1E,MAAM;CACN,OAAO,KAAK;CACZ,WAAW;EAAC;EAAQ;EAAY;CAAO;CACvC,QAAQ,CACP;EAAE,MAAM;EAAO,MAAM;EAAU,UAAU;EAAM,KAAK;EAAG,OAAO,SAAS,KAAK,YAAY;CAAE,CAC3F;CACA,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,QAAQ,cAC3B,SAAS,QAAQ,UAAU,MAAM,MAAM,UAAU,OAAO,MACrD,OACA,QAAQ,EAAE,KAAK,OAAO,IAAI,CAAC;AAChC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { defineValidationRule } from "../defineValidationRule.js";
3
+ //#region src/validation/builtin/notAlreadySubmitted.ts
4
+ const FORM_SUBMISSIONS_SLUG = "form-submissions";
5
+ const SCAN_LIMIT = 500;
6
+ /**
7
+ * Server-only async exemplar: rejects a value already present for the same form. Scans up to
8
+ * `SCAN_LIMIT` recent submissions in JS (the values live in a json column, so a portable DB query is
9
+ * not available); a future phase can add an indexed dedup column for scale.
10
+ */
11
+ const notAlreadySubmittedRule = defineValidationRule({
12
+ type: "notAlreadySubmitted",
13
+ label: keys.ruleNotAlreadySubmitted,
14
+ client: false,
15
+ defaultMessage: keys.ruleNotAlreadySubmittedMessage,
16
+ validate: async ({ value, field, payload, req, formId, message }) => {
17
+ if (value == null || value === "" || !payload || formId == null) return true;
18
+ return (await payload.find({
19
+ collection: FORM_SUBMISSIONS_SLUG,
20
+ where: { form: { equals: formId } },
21
+ limit: SCAN_LIMIT,
22
+ depth: 0,
23
+ req
24
+ })).docs.some((doc) => {
25
+ return (doc.values ?? []).some((entry) => entry.field === field.name && entry.value === value);
26
+ }) ? message() : true;
27
+ }
28
+ });
29
+ //#endregion
30
+ export { notAlreadySubmittedRule };
31
+
32
+ //# sourceMappingURL=notAlreadySubmitted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notAlreadySubmitted.js","names":[],"sources":["../../../src/validation/builtin/notAlreadySubmitted.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { defineValidationRule } from '../defineValidationRule'\n\nconst FORM_SUBMISSIONS_SLUG = 'form-submissions'\nconst SCAN_LIMIT = 500\n\n/**\n * Server-only async exemplar: rejects a value already present for the same form. Scans up to\n * `SCAN_LIMIT` recent submissions in JS (the values live in a json column, so a portable DB query is\n * not available); a future phase can add an indexed dedup column for scale.\n */\nexport const notAlreadySubmittedRule = defineValidationRule<Record<string, never>, unknown>({\n\ttype: 'notAlreadySubmitted',\n\tlabel: keys.ruleNotAlreadySubmitted,\n\tclient: false,\n\tdefaultMessage: keys.ruleNotAlreadySubmittedMessage,\n\tvalidate: async ({ value, field, payload, req, formId, message }) => {\n\t\tif (value == null || value === '' || !payload || formId == null) {\n\t\t\treturn true\n\t\t}\n\t\tconst result = await payload.find({\n\t\t\tcollection: FORM_SUBMISSIONS_SLUG,\n\t\t\twhere: { form: { equals: formId } },\n\t\t\tlimit: SCAN_LIMIT,\n\t\t\tdepth: 0,\n\t\t\treq,\n\t\t})\n\t\tconst clash = result.docs.some((doc) => {\n\t\t\tconst values = (doc as { values?: { field: string; value: unknown }[] }).values ?? []\n\t\t\treturn values.some((entry) => entry.field === field.name && entry.value === value)\n\t\t})\n\t\treturn clash ? message() : true\n\t},\n})\n"],"mappings":";;;AAGA,MAAM,wBAAwB;AAC9B,MAAM,aAAa;;;;;;AAOnB,MAAa,0BAA0B,qBAAqD;CAC3F,MAAM;CACN,OAAO,KAAK;CACZ,QAAQ;CACR,gBAAgB,KAAK;CACrB,UAAU,OAAO,EAAE,OAAO,OAAO,SAAS,KAAK,QAAQ,cAAc;EACpE,IAAI,SAAS,QAAQ,UAAU,MAAM,CAAC,WAAW,UAAU,MAC1D,OAAO;EAaR,QAJc,MAPO,QAAQ,KAAK;GACjC,YAAY;GACZ,OAAO,EAAE,MAAM,EAAE,QAAQ,OAAO,EAAE;GAClC,OAAO;GACP,OAAO;GACP;EACD,CAAC,GACoB,KAAK,MAAM,QAAQ;GAEvC,QADgB,IAAyD,UAAU,CAAC,GACtE,MAAM,UAAU,MAAM,UAAU,MAAM,QAAQ,MAAM,UAAU,KAAK;EAClF,CACW,IAAI,QAAQ,IAAI;CAC5B;AACD,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { labelFor } from "../../translations/server.js";
3
+ import { defineValidationRule } from "../defineValidationRule.js";
4
+ //#region src/validation/builtin/oneOf.ts
5
+ const oneOfRule = defineValidationRule({
6
+ type: "oneOf",
7
+ label: keys.ruleOneOf,
8
+ appliesTo: [
9
+ "text",
10
+ "textarea",
11
+ "select"
12
+ ],
13
+ params: [{
14
+ name: "values",
15
+ type: "array",
16
+ label: labelFor(keys.ruleParamValues),
17
+ fields: [{
18
+ name: "value",
19
+ type: "text",
20
+ required: true
21
+ }]
22
+ }],
23
+ defaultMessage: keys.ruleOneOfMessage,
24
+ validate: ({ value, params, message }) => {
25
+ if (value == null || value === "") return true;
26
+ const allowed = (params.values ?? []).map((entry) => entry.value);
27
+ if (allowed.length === 0) return true;
28
+ return allowed.includes(value) ? true : message();
29
+ }
30
+ });
31
+ //#endregion
32
+ export { oneOfRule };
33
+
34
+ //# sourceMappingURL=oneOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneOf.js","names":[],"sources":["../../../src/validation/builtin/oneOf.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineValidationRule } from '../defineValidationRule'\n\nexport const oneOfRule = defineValidationRule<{ values?: { value: string }[] }, string>({\n\ttype: 'oneOf',\n\tlabel: keys.ruleOneOf,\n\tappliesTo: ['text', 'textarea', 'select'],\n\tparams: [\n\t\t{\n\t\t\tname: 'values',\n\t\t\ttype: 'array',\n\t\t\tlabel: labelFor(keys.ruleParamValues),\n\t\t\tfields: [{ name: 'value', type: 'text', required: true }],\n\t\t},\n\t],\n\tdefaultMessage: keys.ruleOneOfMessage,\n\tvalidate: ({ value, params, message }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn true\n\t\t}\n\t\tconst allowed = (params.values ?? []).map((entry) => entry.value)\n\t\tif (allowed.length === 0) {\n\t\t\treturn true\n\t\t}\n\t\treturn allowed.includes(value) ? true : message()\n\t},\n})\n"],"mappings":";;;;AAIA,MAAa,YAAY,qBAA+D;CACvF,MAAM;CACN,OAAO,KAAK;CACZ,WAAW;EAAC;EAAQ;EAAY;CAAQ;CACxC,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,SAAS,KAAK,eAAe;EACpC,QAAQ,CAAC;GAAE,MAAM;GAAS,MAAM;GAAQ,UAAU;EAAK,CAAC;CACzD,CACD;CACA,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,QAAQ,cAAc;EACzC,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,MAAM,WAAW,OAAO,UAAU,CAAC,GAAG,KAAK,UAAU,MAAM,KAAK;EAChE,IAAI,QAAQ,WAAW,GACtB,OAAO;EAER,OAAO,QAAQ,SAAS,KAAK,IAAI,OAAO,QAAQ;CACjD;AACD,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { keys } from "../../translations/keys.js";
2
+ import { labelFor } from "../../translations/server.js";
3
+ import { defineValidationRule } from "../defineValidationRule.js";
4
+ //#region src/validation/builtin/pattern.ts
5
+ const tryRegExp = (pattern, flags) => {
6
+ try {
7
+ return new RegExp(pattern, flags);
8
+ } catch {
9
+ return;
10
+ }
11
+ };
12
+ const patternRule = defineValidationRule({
13
+ type: "pattern",
14
+ label: keys.rulePattern,
15
+ appliesTo: [
16
+ "text",
17
+ "textarea",
18
+ "email"
19
+ ],
20
+ params: [{
21
+ name: "pattern",
22
+ type: "text",
23
+ required: true,
24
+ label: labelFor(keys.ruleParamPattern)
25
+ }, {
26
+ name: "flags",
27
+ type: "text",
28
+ label: labelFor(keys.ruleParamFlags)
29
+ }],
30
+ defaultMessage: keys.rulePatternMessage,
31
+ validate: ({ value, params, message }) => {
32
+ if (value == null || value === "") return true;
33
+ const regex = tryRegExp(params.pattern, params.flags);
34
+ if (!regex) return true;
35
+ return regex.test(value) ? true : message();
36
+ }
37
+ });
38
+ //#endregion
39
+ export { patternRule };
40
+
41
+ //# sourceMappingURL=pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern.js","names":[],"sources":["../../../src/validation/builtin/pattern.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineValidationRule } from '../defineValidationRule'\n\nconst tryRegExp = (pattern: string, flags?: string): RegExp | undefined => {\n\ttry {\n\t\treturn new RegExp(pattern, flags)\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nexport const patternRule = defineValidationRule<{ pattern: string; flags?: string }, string>({\n\ttype: 'pattern',\n\tlabel: keys.rulePattern,\n\tappliesTo: ['text', 'textarea', 'email'],\n\tparams: [\n\t\t{ name: 'pattern', type: 'text', required: true, label: labelFor(keys.ruleParamPattern) },\n\t\t{ name: 'flags', type: 'text', label: labelFor(keys.ruleParamFlags) },\n\t],\n\tdefaultMessage: keys.rulePatternMessage,\n\tvalidate: ({ value, params, message }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn true\n\t\t}\n\t\tconst regex = tryRegExp(params.pattern, params.flags)\n\t\tif (!regex) {\n\t\t\treturn true\n\t\t}\n\t\treturn regex.test(value) ? true : message()\n\t},\n})\n"],"mappings":";;;;AAIA,MAAM,aAAa,SAAiB,UAAuC;CAC1E,IAAI;EACH,OAAO,IAAI,OAAO,SAAS,KAAK;CACjC,QAAQ;EACP;CACD;AACD;AAEA,MAAa,cAAc,qBAAkE;CAC5F,MAAM;CACN,OAAO,KAAK;CACZ,WAAW;EAAC;EAAQ;EAAY;CAAO;CACvC,QAAQ,CACP;EAAE,MAAM;EAAW,MAAM;EAAQ,UAAU;EAAM,OAAO,SAAS,KAAK,gBAAgB;CAAE,GACxF;EAAE,MAAM;EAAS,MAAM;EAAQ,OAAO,SAAS,KAAK,cAAc;CAAE,CACrE;CACA,gBAAgB,KAAK;CACrB,WAAW,EAAE,OAAO,QAAQ,cAAc;EACzC,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,MAAM,QAAQ,UAAU,OAAO,SAAS,OAAO,KAAK;EACpD,IAAI,CAAC,OACJ,OAAO;EAER,OAAO,MAAM,KAAK,KAAK,IAAI,OAAO,QAAQ;CAC3C;AACD,CAAC"}