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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (406) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +45 -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 +157 -0
  63. package/dist/collections/formSubmissions.js.map +1 -0
  64. package/dist/collections/forms.js +198 -0
  65. package/dist/collections/forms.js.map +1 -0
  66. package/dist/collections/uploads.d.ts +30 -0
  67. package/dist/collections/uploads.js +55 -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 +28 -5
  118. package/dist/fields/buildFieldBlocks.js +60 -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 +27 -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/repeater.js +44 -0
  135. package/dist/fields/builtin/repeater.js.map +1 -0
  136. package/dist/fields/builtin/select.js +44 -0
  137. package/dist/fields/builtin/select.js.map +1 -0
  138. package/dist/fields/builtin/text.js +13 -0
  139. package/dist/fields/builtin/text.js.map +1 -0
  140. package/dist/fields/builtin/textarea.js +13 -0
  141. package/dist/fields/builtin/textarea.js.map +1 -0
  142. package/dist/fields/defineFormField.d.ts +13 -0
  143. package/dist/fields/defineFormField.js +12 -0
  144. package/dist/fields/defineFormField.js.map +1 -0
  145. package/dist/fields/registry.d.ts +10 -0
  146. package/dist/fields/registry.js +24 -0
  147. package/dist/fields/registry.js.map +1 -0
  148. package/dist/fields/sharedConfig.js +89 -0
  149. package/dist/fields/sharedConfig.js.map +1 -0
  150. package/dist/fields/types.d.ts +89 -0
  151. package/dist/flow/engine.d.ts +17 -0
  152. package/dist/flow/engine.js +24 -0
  153. package/dist/flow/engine.js.map +1 -0
  154. package/dist/flow/normalizeFlow.js +35 -0
  155. package/dist/flow/normalizeFlow.js.map +1 -0
  156. package/dist/{types-DsJ_6kGJ.d.ts → flow/types.d.ts} +2 -2
  157. package/dist/index.d.ts +93 -4
  158. package/dist/index.js +43 -1890
  159. package/dist/index.js.map +1 -1
  160. package/dist/plugin/access.js +12 -0
  161. package/dist/plugin/access.js.map +1 -0
  162. package/dist/plugin/collectionOverrides.d.ts +22 -0
  163. package/dist/plugin/registerCollections.js +68 -0
  164. package/dist/plugin/registerCollections.js.map +1 -0
  165. package/dist/plugin/registerTranslations.js +19 -0
  166. package/dist/plugin/registerTranslations.js.map +1 -0
  167. package/dist/prefill/valuesFromSearchParams.d.ts +18 -0
  168. package/dist/prefill/valuesFromSearchParams.js +45 -0
  169. package/dist/prefill/valuesFromSearchParams.js.map +1 -0
  170. package/dist/presentations/defaults.d.ts +33 -0
  171. package/dist/presentations/defaults.js +35 -0
  172. package/dist/presentations/defaults.js.map +1 -0
  173. package/dist/presentations/registry.d.ts +15 -0
  174. package/dist/presentations/registry.js +15 -0
  175. package/dist/presentations/registry.js.map +1 -0
  176. package/dist/presentations/types.d.ts +18 -0
  177. package/dist/react/Form.d.ts +110 -0
  178. package/dist/react/Form.js +499 -0
  179. package/dist/react/Form.js.map +1 -0
  180. package/dist/react/FormContext.d.ts +16 -0
  181. package/dist/react/FormContext.js +14 -0
  182. package/dist/react/FormContext.js.map +1 -0
  183. package/dist/react/FormLayout.d.ts +20 -0
  184. package/dist/react/FormLayout.js +14 -0
  185. package/dist/react/FormLayout.js.map +1 -0
  186. package/dist/react/FormResults.d.ts +25 -0
  187. package/dist/react/FormResults.js +85 -0
  188. package/dist/react/FormResults.js.map +1 -0
  189. package/dist/react/Honeypot.d.ts +22 -0
  190. package/dist/react/Honeypot.js +38 -0
  191. package/dist/react/Honeypot.js.map +1 -0
  192. package/dist/react/Poll.d.ts +32 -0
  193. package/dist/react/Poll.js +77 -0
  194. package/dist/react/Poll.js.map +1 -0
  195. package/dist/react/cn.d.ts +6 -0
  196. package/dist/react/cn.js +8 -0
  197. package/dist/react/cn.js.map +1 -0
  198. package/dist/react/contract.d.ts +32 -0
  199. package/dist/react/contract.js +7 -0
  200. package/dist/react/contract.js.map +1 -0
  201. package/dist/react/events.js +14 -0
  202. package/dist/react/events.js.map +1 -0
  203. package/dist/react/fetchResults.d.ts +25 -0
  204. package/dist/react/fetchResults.js +31 -0
  205. package/dist/react/fetchResults.js.map +1 -0
  206. package/dist/react/presentation/Backdrop.d.ts +18 -0
  207. package/dist/react/presentation/Backdrop.js +14 -0
  208. package/dist/react/presentation/Backdrop.js.map +1 -0
  209. package/dist/react/presentation/DialogSurface.d.ts +35 -0
  210. package/dist/react/presentation/DialogSurface.js +56 -0
  211. package/dist/react/presentation/DialogSurface.js.map +1 -0
  212. package/dist/react/presentation/presentations.d.ts +7 -0
  213. package/dist/react/presentation/presentations.js +32 -0
  214. package/dist/react/presentation/presentations.js.map +1 -0
  215. package/dist/react/presentation/registry.d.ts +11 -0
  216. package/dist/react/presentation/registry.js +12 -0
  217. package/dist/react/presentation/registry.js.map +1 -0
  218. package/dist/react/presentation/types.d.ts +19 -0
  219. package/dist/react/presentation/useDismiss.d.ts +19 -0
  220. package/dist/react/presentation/useDismiss.js +33 -0
  221. package/dist/react/presentation/useDismiss.js.map +1 -0
  222. package/dist/react/presentation/useFocusTrap.d.ts +8 -0
  223. package/dist/react/presentation/useFocusTrap.js +35 -0
  224. package/dist/react/presentation/useFocusTrap.js.map +1 -0
  225. package/dist/react/presentation/useScrollLock.d.ts +6 -0
  226. package/dist/react/presentation/useScrollLock.js +18 -0
  227. package/dist/react/presentation/useScrollLock.js.map +1 -0
  228. package/dist/react/primitives/Checkbox.d.ts +26 -0
  229. package/dist/react/primitives/Checkbox.js +20 -0
  230. package/dist/react/primitives/Checkbox.js.map +1 -0
  231. package/dist/react/primitives/FieldShell.d.ts +31 -0
  232. package/dist/react/primitives/FieldShell.js +51 -0
  233. package/dist/react/primitives/FieldShell.js.map +1 -0
  234. package/dist/react/primitives/Input.d.ts +30 -0
  235. package/dist/react/primitives/Input.js +21 -0
  236. package/dist/react/primitives/Input.js.map +1 -0
  237. package/dist/react/primitives/Select.d.ts +34 -0
  238. package/dist/react/primitives/Select.js +26 -0
  239. package/dist/react/primitives/Select.js.map +1 -0
  240. package/dist/react/primitives/Textarea.d.ts +28 -0
  241. package/dist/react/primitives/Textarea.js +20 -0
  242. package/dist/react/primitives/Textarea.js.map +1 -0
  243. package/dist/react/recall.js +20 -0
  244. package/dist/react/recall.js.map +1 -0
  245. package/dist/react/registry.d.ts +16 -0
  246. package/dist/react/registry.js +16 -0
  247. package/dist/react/registry.js.map +1 -0
  248. package/dist/react/renderers/calculation.js +30 -0
  249. package/dist/react/renderers/calculation.js.map +1 -0
  250. package/dist/react/renderers/checkbox.js +35 -0
  251. package/dist/react/renderers/checkbox.js.map +1 -0
  252. package/dist/react/renderers/consent.js +54 -0
  253. package/dist/react/renderers/consent.js.map +1 -0
  254. package/dist/react/renderers/email.js +37 -0
  255. package/dist/react/renderers/email.js.map +1 -0
  256. package/dist/react/renderers/file.js +92 -0
  257. package/dist/react/renderers/file.js.map +1 -0
  258. package/dist/react/renderers/index.d.ts +8 -0
  259. package/dist/react/renderers/index.js +28 -0
  260. package/dist/react/renderers/index.js.map +1 -0
  261. package/dist/react/renderers/number.js +40 -0
  262. package/dist/react/renderers/number.js.map +1 -0
  263. package/dist/react/renderers/repeater.js +113 -0
  264. package/dist/react/renderers/repeater.js.map +1 -0
  265. package/dist/react/renderers/select.js +38 -0
  266. package/dist/react/renderers/select.js.map +1 -0
  267. package/dist/react/renderers/text.js +37 -0
  268. package/dist/react/renderers/text.js.map +1 -0
  269. package/dist/react/renderers/textarea.js +36 -0
  270. package/dist/react/renderers/textarea.js.map +1 -0
  271. package/dist/react/resolveForm.js +16 -0
  272. package/dist/react/resolveForm.js.map +1 -0
  273. package/dist/react/state.d.ts +15 -0
  274. package/dist/react/state.js +70 -0
  275. package/dist/react/state.js.map +1 -0
  276. package/dist/react/submitForm.d.ts +31 -0
  277. package/dist/react/submitForm.js +58 -0
  278. package/dist/react/submitForm.js.map +1 -0
  279. package/dist/react/toFormDocument.d.ts +24 -0
  280. package/dist/react/toFormDocument.js +22 -0
  281. package/dist/react/toFormDocument.js.map +1 -0
  282. package/dist/react/uploadFile.d.ts +23 -0
  283. package/dist/react/uploadFile.js +39 -0
  284. package/dist/react/uploadFile.js.map +1 -0
  285. package/dist/react/useField.d.ts +14 -0
  286. package/dist/react/useField.js +49 -0
  287. package/dist/react/useField.js.map +1 -0
  288. package/dist/react/useFormState.d.ts +8 -0
  289. package/dist/react/useFormState.js +9 -0
  290. package/dist/react/useFormState.js.map +1 -0
  291. package/dist/react/useFormStep.d.ts +8 -0
  292. package/dist/react/useFormStep.js +9 -0
  293. package/dist/react/useFormStep.js.map +1 -0
  294. package/dist/react/validateField.js +30 -0
  295. package/dist/react/validateField.js.map +1 -0
  296. package/dist/recall/interpolate.d.ts +10 -0
  297. package/dist/recall/interpolate.js +16 -0
  298. package/dist/recall/interpolate.js.map +1 -0
  299. package/dist/recall/resolver.d.ts +22 -0
  300. package/dist/recall/resolver.js +36 -0
  301. package/dist/recall/resolver.js.map +1 -0
  302. package/dist/spam/captcha.d.ts +12 -0
  303. package/dist/spam/captcha.js +11 -0
  304. package/dist/spam/captcha.js.map +1 -0
  305. package/dist/spam/constants.d.ts +12 -0
  306. package/dist/spam/constants.js +15 -0
  307. package/dist/spam/constants.js.map +1 -0
  308. package/dist/spam/identify.d.ts +12 -0
  309. package/dist/spam/identify.js +20 -0
  310. package/dist/spam/identify.js.map +1 -0
  311. package/dist/spam/rateLimiter.d.ts +18 -0
  312. package/dist/spam/rateLimiter.js +41 -0
  313. package/dist/spam/rateLimiter.js.map +1 -0
  314. package/dist/spam/reserved.js +30 -0
  315. package/dist/spam/reserved.js.map +1 -0
  316. package/dist/spam/resolveSpam.d.ts +12 -0
  317. package/dist/spam/resolveSpam.js +42 -0
  318. package/dist/spam/resolveSpam.js.map +1 -0
  319. package/dist/spam/spamGuard.js +68 -0
  320. package/dist/spam/spamGuard.js.map +1 -0
  321. package/dist/spam/types.d.ts +73 -0
  322. package/dist/spam/uploadHooks.js +33 -0
  323. package/dist/spam/uploadHooks.js.map +1 -0
  324. package/dist/submissions/SubmissionAnswers.d.ts +14 -0
  325. package/dist/submissions/SubmissionAnswers.js +133 -0
  326. package/dist/submissions/SubmissionAnswers.js.map +1 -0
  327. package/dist/submissions/SubmissionAnswersClient.js +142 -0
  328. package/dist/submissions/SubmissionAnswersClient.js.map +1 -0
  329. package/dist/submissions/runSubmission.js +257 -0
  330. package/dist/submissions/runSubmission.js.map +1 -0
  331. package/dist/submissions/types.d.ts +34 -0
  332. package/dist/submissions/validateSubmission.js +59 -0
  333. package/dist/submissions/validateSubmission.js.map +1 -0
  334. package/dist/translations/en.d.ts +12 -0
  335. package/dist/{translations-edMqq_2e.js → translations/en.js} +29 -23
  336. package/dist/translations/en.js.map +1 -0
  337. package/dist/translations/index.d.ts +14 -0
  338. package/dist/translations/index.js +26 -0
  339. package/dist/translations/index.js.map +1 -0
  340. package/dist/translations/keys.d.ts +157 -0
  341. package/dist/{keys-N5xGiUsh.js → translations/keys.js} +28 -3
  342. package/dist/translations/keys.js.map +1 -0
  343. package/dist/translations/makeTranslate.d.ts +11 -0
  344. package/dist/translations/makeTranslate.js +11 -0
  345. package/dist/translations/makeTranslate.js.map +1 -0
  346. package/dist/translations/server.js +25 -0
  347. package/dist/translations/server.js.map +1 -0
  348. package/dist/translations/useTranslation.js +12 -0
  349. package/dist/translations/useTranslation.js.map +1 -0
  350. package/dist/uploads/captureFileRef.d.ts +27 -0
  351. package/dist/uploads/captureFileRef.js +34 -0
  352. package/dist/uploads/captureFileRef.js.map +1 -0
  353. package/dist/uploads/resolveFileRef.d.ts +26 -0
  354. package/dist/uploads/resolveFileRef.js +44 -0
  355. package/dist/uploads/resolveFileRef.js.map +1 -0
  356. package/dist/uploads/types.d.ts +20 -0
  357. package/dist/validation/buildRuleBlocks.js +46 -0
  358. package/dist/validation/buildRuleBlocks.js.map +1 -0
  359. package/dist/validation/builtin/email.js +19 -0
  360. package/dist/validation/builtin/email.js.map +1 -0
  361. package/dist/validation/builtin/index.js +27 -0
  362. package/dist/validation/builtin/index.js.map +1 -0
  363. package/dist/validation/builtin/matchesField.js +20 -0
  364. package/dist/validation/builtin/matchesField.js.map +1 -0
  365. package/dist/validation/builtin/max.js +21 -0
  366. package/dist/validation/builtin/max.js.map +1 -0
  367. package/dist/validation/builtin/maxLength.js +26 -0
  368. package/dist/validation/builtin/maxLength.js.map +1 -0
  369. package/dist/validation/builtin/min.js +21 -0
  370. package/dist/validation/builtin/min.js.map +1 -0
  371. package/dist/validation/builtin/minLength.js +26 -0
  372. package/dist/validation/builtin/minLength.js.map +1 -0
  373. package/dist/validation/builtin/notAlreadySubmitted.js +32 -0
  374. package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -0
  375. package/dist/validation/builtin/oneOf.js +34 -0
  376. package/dist/validation/builtin/oneOf.js.map +1 -0
  377. package/dist/validation/builtin/pattern.js +41 -0
  378. package/dist/validation/builtin/pattern.js.map +1 -0
  379. package/dist/validation/builtin/url.js +22 -0
  380. package/dist/validation/builtin/url.js.map +1 -0
  381. package/dist/validation/defineValidationRule.d.ts +12 -0
  382. package/dist/validation/defineValidationRule.js +11 -0
  383. package/dist/validation/defineValidationRule.js.map +1 -0
  384. package/dist/validation/message.js +14 -0
  385. package/dist/validation/message.js.map +1 -0
  386. package/dist/validation/registry.d.ts +10 -0
  387. package/dist/validation/registry.js +20 -0
  388. package/dist/validation/registry.js.map +1 -0
  389. package/dist/validation/runValidation.js +111 -0
  390. package/dist/validation/runValidation.js.map +1 -0
  391. package/dist/validation/types.d.ts +76 -0
  392. package/package.json +8 -5
  393. package/styles/form-builder.css +201 -11
  394. package/dist/constants-B-BUfetP.d.ts +0 -288
  395. package/dist/exports/client.js.map +0 -1
  396. package/dist/exports/react.js.map +0 -1
  397. package/dist/exports/rsc.js.map +0 -1
  398. package/dist/fieldTypes-B8jkNRob.d.ts +0 -188
  399. package/dist/fieldTypes-CzhhJXjg.js.map +0 -1
  400. package/dist/index-DfFYGbVF.d.ts +0 -481
  401. package/dist/keys-N5xGiUsh.js.map +0 -1
  402. package/dist/registry-CoCyhtvB.js +0 -282
  403. package/dist/registry-CoCyhtvB.js.map +0 -1
  404. package/dist/resolver-OeQyVH2N.js +0 -665
  405. package/dist/resolver-OeQyVH2N.js.map +0 -1
  406. package/dist/translations-edMqq_2e.js.map +0 -1
@@ -0,0 +1,121 @@
1
+ "use client";
2
+ import { keys } from "../translations/keys.js";
3
+ import { firstOperatorFor } from "../conditions/fieldTypes.js";
4
+ import { useTranslation as useTranslation$1 } from "../translations/useTranslation.js";
5
+ import { operandFromRow } from "./synthesizeClientField.js";
6
+ import { ConditionRow } from "./ConditionRow.js";
7
+ import { reduceFieldsToValues, transformWhereQuery } from "payload/shared";
8
+ import { Button, useFormFields } from "@payloadcms/ui";
9
+ import { useMemo } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ //#region src/client/ConditionBuilder.tsx
12
+ const toRow = (constraint) => {
13
+ const field = Object.keys(constraint)[0];
14
+ if (!field) return null;
15
+ const ops = constraint[field];
16
+ const operator = Object.keys(ops)[0];
17
+ if (!operator) return null;
18
+ return {
19
+ field,
20
+ operator,
21
+ value: ops[operator]
22
+ };
23
+ };
24
+ const fromRow = (row) => ({ [row.field]: { [row.operator]: row.value } });
25
+ const readGroups = (value) => {
26
+ if (!value || Object.keys(value).length === 0) return [];
27
+ const canonical = transformWhereQuery(value);
28
+ return (Array.isArray(canonical.or) ? canonical.or : []).map((group) => {
29
+ return (Array.isArray(group.and) ? group.and : []).map((constraint) => toRow(constraint)).filter((row) => row !== null);
30
+ });
31
+ };
32
+ const writeGroups = (groups) => ({ or: groups.filter((group) => group.length > 0).map((group) => ({ and: group.map(fromRow) })) });
33
+ const operandsFromData = (data, conditionTypes, selfName) => {
34
+ return (Array.isArray(data.fields) ? data.fields : []).map((row) => operandFromRow(row, conditionTypes)).filter((operand) => operand !== null && operand.name !== selfName);
35
+ };
36
+ const ConditionBuilder = ({ value, onChange, conditionTypes, selfName }) => {
37
+ const { t } = useTranslation$1();
38
+ const operandsJson = useFormFields(([fields]) => JSON.stringify(operandsFromData(reduceFieldsToValues(fields, true), conditionTypes, selfName)));
39
+ const operands = useMemo(() => JSON.parse(operandsJson), [operandsJson]);
40
+ const groups = readGroups(value);
41
+ const emit = (next) => onChange(writeGroups(next));
42
+ const addCondition = (groupIndex) => {
43
+ const first = operands[0];
44
+ if (!first) return;
45
+ const row = {
46
+ field: first.name,
47
+ operator: firstOperatorFor(first.conditionType),
48
+ value: void 0
49
+ };
50
+ emit(groups.length === 0 ? [[row]] : groups.map((group, index) => index === groupIndex ? [...group, row] : group));
51
+ };
52
+ const addOrGroup = () => {
53
+ const first = operands[0];
54
+ if (!first) return;
55
+ emit([...groups, [{
56
+ field: first.name,
57
+ operator: firstOperatorFor(first.conditionType),
58
+ value: void 0
59
+ }]]);
60
+ };
61
+ const updateRow = (groupIndex, rowIndex, row) => emit(groups.map((group, index) => index === groupIndex ? group.map((existing, position) => position === rowIndex ? row : existing) : group));
62
+ const removeRow = (groupIndex, rowIndex) => emit(groups.map((group, index) => index === groupIndex ? group.filter((_, position) => position !== rowIndex) : group).filter((group) => group.length > 0));
63
+ if (operands.length === 0) return /* @__PURE__ */ jsx("p", {
64
+ className: "fb-condition-builder__hint",
65
+ children: t(keys.conditionNoFields)
66
+ });
67
+ return /* @__PURE__ */ jsxs("div", {
68
+ className: "fb-condition-builder",
69
+ children: [groups.length === 0 ? /* @__PURE__ */ jsx("p", {
70
+ className: "fb-condition-builder__hint",
71
+ children: t(keys.conditionEmpty)
72
+ }) : groups.map((group, groupIndex) => /* @__PURE__ */ jsxs("div", {
73
+ className: "fb-condition-builder__group",
74
+ children: [
75
+ groupIndex > 0 ? /* @__PURE__ */ jsx("div", {
76
+ className: "fb-condition-builder__or-label",
77
+ children: t(keys.conditionOr)
78
+ }) : null,
79
+ group.map((row, rowIndex) => /* @__PURE__ */ jsxs("div", {
80
+ className: "fb-condition-builder__and-row",
81
+ children: [rowIndex > 0 ? /* @__PURE__ */ jsx("span", {
82
+ className: "fb-condition-builder__and-label",
83
+ children: t(keys.conditionAnd)
84
+ }) : null, /* @__PURE__ */ jsx(ConditionRow, {
85
+ condition: row,
86
+ operands,
87
+ onChange: (next) => updateRow(groupIndex, rowIndex, next),
88
+ onRemove: () => removeRow(groupIndex, rowIndex)
89
+ })]
90
+ }, rowIndex)),
91
+ /* @__PURE__ */ jsx("div", {
92
+ className: "fb-condition-builder__add-condition",
93
+ children: /* @__PURE__ */ jsx(Button, {
94
+ buttonStyle: "icon-label",
95
+ icon: "plus",
96
+ iconStyle: "with-border",
97
+ iconPosition: "left",
98
+ onClick: () => addCondition(groupIndex),
99
+ margin: false,
100
+ children: t(keys.conditionAddCondition)
101
+ })
102
+ })
103
+ ]
104
+ }, groupIndex)), /* @__PURE__ */ jsx("div", {
105
+ className: "fb-condition-builder__actions",
106
+ children: /* @__PURE__ */ jsx(Button, {
107
+ buttonStyle: "icon-label",
108
+ icon: "plus",
109
+ iconStyle: "with-border",
110
+ iconPosition: "left",
111
+ onClick: () => groups.length === 0 ? addCondition(0) : addOrGroup(),
112
+ margin: false,
113
+ children: groups.length === 0 ? t(keys.conditionAddCondition) : t(keys.conditionAddOr)
114
+ })
115
+ })]
116
+ });
117
+ };
118
+ //#endregion
119
+ export { ConditionBuilder };
120
+
121
+ //# sourceMappingURL=ConditionBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionBuilder.js","names":["useTranslation"],"sources":["../../src/client/ConditionBuilder.tsx"],"sourcesContent":["'use client'\n\nimport { Button, useFormFields } from '@payloadcms/ui'\nimport type { Operator, Where } from 'payload'\nimport { reduceFieldsToValues, transformWhereQuery } from 'payload/shared'\nimport { useMemo } from 'react'\nimport { type ConditionFieldType, firstOperatorFor } from '../conditions/fieldTypes'\nimport { keys } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport { ConditionRow, type RowCondition } from './ConditionRow'\nimport { type ConditionOperand, type FieldRow, operandFromRow } from './synthesizeClientField'\n\nexport type ConditionBuilderProps = {\n\tvalue?: Where\n\tonChange: (next: Where) => void\n\tconditionTypes: Record<string, ConditionFieldType>\n\t/** This field's own machine name, excluded from the operand list (a field cannot condition on itself). */\n\tselfName?: string\n}\n\nconst toRow = (constraint: Record<string, unknown>): RowCondition | null => {\n\tconst field = Object.keys(constraint)[0]\n\tif (!field) {\n\t\treturn null\n\t}\n\tconst ops = constraint[field] as Record<string, unknown>\n\tconst operator = Object.keys(ops)[0] as Operator | undefined\n\tif (!operator) {\n\t\treturn null\n\t}\n\treturn { field, operator, value: ops[operator] }\n}\n\nconst fromRow = (row: RowCondition): Where => ({ [row.field]: { [row.operator]: row.value } })\n\nconst readGroups = (value: Where | undefined): RowCondition[][] => {\n\tif (!value || Object.keys(value).length === 0) {\n\t\treturn []\n\t}\n\tconst canonical = transformWhereQuery(value)\n\tconst or = Array.isArray(canonical.or) ? canonical.or : []\n\treturn or.map((group) => {\n\t\tconst and = Array.isArray((group as Where).and) ? ((group as Where).and as Where[]) : []\n\t\treturn and\n\t\t\t.map((constraint) => toRow(constraint as Record<string, unknown>))\n\t\t\t.filter((row): row is RowCondition => row !== null)\n\t})\n}\n\nconst writeGroups = (groups: RowCondition[][]): Where => ({\n\tor: groups.filter((group) => group.length > 0).map((group) => ({ and: group.map(fromRow) })),\n})\n\nconst operandsFromData = (\n\tdata: Record<string, unknown>,\n\tconditionTypes: Record<string, ConditionFieldType>,\n\tselfName: string | undefined\n): ConditionOperand[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as FieldRow[]) : []\n\treturn rows\n\t\t.map((row) => operandFromRow(row, conditionTypes))\n\t\t.filter((operand): operand is ConditionOperand => operand !== null && operand.name !== selfName)\n}\n\nexport const ConditionBuilder = ({\n\tvalue,\n\tonChange,\n\tconditionTypes,\n\tselfName,\n}: ConditionBuilderProps) => {\n\tconst { t } = useTranslation()\n\t// Serialize the operand list so the builder re-renders only when operands actually change (a field\n\t// added, renamed, retyped, or its options edited), not on every unrelated form-state update.\n\tconst operandsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(operandsFromData(reduceFieldsToValues(fields, true), conditionTypes, selfName))\n\t)\n\tconst operands = useMemo(() => JSON.parse(operandsJson) as ConditionOperand[], [operandsJson])\n\n\tconst groups = readGroups(value)\n\tconst emit = (next: RowCondition[][]) => onChange(writeGroups(next))\n\n\tconst addCondition = (groupIndex: number) => {\n\t\tconst first = operands[0]\n\t\tif (!first) {\n\t\t\treturn\n\t\t}\n\t\tconst row: RowCondition = {\n\t\t\tfield: first.name,\n\t\t\toperator: firstOperatorFor(first.conditionType),\n\t\t\tvalue: undefined,\n\t\t}\n\t\temit(\n\t\t\tgroups.length === 0\n\t\t\t\t? [[row]]\n\t\t\t\t: groups.map((group, index) => (index === groupIndex ? [...group, row] : group))\n\t\t)\n\t}\n\n\tconst addOrGroup = () => {\n\t\tconst first = operands[0]\n\t\tif (!first) {\n\t\t\treturn\n\t\t}\n\t\temit([\n\t\t\t...groups,\n\t\t\t[{ field: first.name, operator: firstOperatorFor(first.conditionType), value: undefined }],\n\t\t])\n\t}\n\n\tconst updateRow = (groupIndex: number, rowIndex: number, row: RowCondition) =>\n\t\temit(\n\t\t\tgroups.map((group, index) =>\n\t\t\t\tindex === groupIndex\n\t\t\t\t\t? group.map((existing, position) => (position === rowIndex ? row : existing))\n\t\t\t\t\t: group\n\t\t\t)\n\t\t)\n\n\tconst removeRow = (groupIndex: number, rowIndex: number) =>\n\t\temit(\n\t\t\tgroups\n\t\t\t\t.map((group, index) =>\n\t\t\t\t\tindex === groupIndex ? group.filter((_, position) => position !== rowIndex) : group\n\t\t\t\t)\n\t\t\t\t.filter((group) => group.length > 0)\n\t\t)\n\n\tif (operands.length === 0) {\n\t\treturn <p className=\"fb-condition-builder__hint\">{t(keys.conditionNoFields)}</p>\n\t}\n\n\treturn (\n\t\t<div className=\"fb-condition-builder\">\n\t\t\t{groups.length === 0 ? (\n\t\t\t\t<p className=\"fb-condition-builder__hint\">{t(keys.conditionEmpty)}</p>\n\t\t\t) : (\n\t\t\t\tgroups.map((group, groupIndex) => (\n\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: groups are positional and never reordered\n\t\t\t\t\t<div key={groupIndex} className=\"fb-condition-builder__group\">\n\t\t\t\t\t\t{groupIndex > 0 ? (\n\t\t\t\t\t\t\t<div className=\"fb-condition-builder__or-label\">{t(keys.conditionOr)}</div>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{group.map((row, rowIndex) => (\n\t\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and never reordered\n\t\t\t\t\t\t\t<div key={rowIndex} className=\"fb-condition-builder__and-row\">\n\t\t\t\t\t\t\t\t{rowIndex > 0 ? (\n\t\t\t\t\t\t\t\t\t<span className=\"fb-condition-builder__and-label\">{t(keys.conditionAnd)}</span>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t<ConditionRow\n\t\t\t\t\t\t\t\t\tcondition={row}\n\t\t\t\t\t\t\t\t\toperands={operands}\n\t\t\t\t\t\t\t\t\tonChange={(next) => updateRow(groupIndex, rowIndex, next)}\n\t\t\t\t\t\t\t\t\tonRemove={() => removeRow(groupIndex, rowIndex)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t<div className=\"fb-condition-builder__add-condition\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tbuttonStyle=\"icon-label\"\n\t\t\t\t\t\t\t\ticon=\"plus\"\n\t\t\t\t\t\t\t\ticonStyle=\"with-border\"\n\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\tonClick={() => addCondition(groupIndex)}\n\t\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(keys.conditionAddCondition)}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t))\n\t\t\t)}\n\t\t\t<div className=\"fb-condition-builder__actions\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"icon-label\"\n\t\t\t\t\ticon=\"plus\"\n\t\t\t\t\ticonStyle=\"with-border\"\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tonClick={() => (groups.length === 0 ? addCondition(0) : addOrGroup())}\n\t\t\t\t\tmargin={false}\n\t\t\t\t>\n\t\t\t\t\t{groups.length === 0 ? t(keys.conditionAddCondition) : t(keys.conditionAddOr)}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,SAAS,eAA6D;CAC3E,MAAM,QAAQ,OAAO,KAAK,UAAU,EAAE;CACtC,IAAI,CAAC,OACJ,OAAO;CAER,MAAM,MAAM,WAAW;CACvB,MAAM,WAAW,OAAO,KAAK,GAAG,EAAE;CAClC,IAAI,CAAC,UACJ,OAAO;CAER,OAAO;EAAE;EAAO;EAAU,OAAO,IAAI;CAAU;AAChD;AAEA,MAAM,WAAW,SAA8B,GAAG,IAAI,QAAQ,GAAG,IAAI,WAAW,IAAI,MAAM,EAAE;AAE5F,MAAM,cAAc,UAA+C;CAClE,IAAI,CAAC,SAAS,OAAO,KAAK,KAAK,EAAE,WAAW,GAC3C,OAAO,CAAC;CAET,MAAM,YAAY,oBAAoB,KAAK;CAE3C,QADW,MAAM,QAAQ,UAAU,EAAE,IAAI,UAAU,KAAK,CAAC,GAC/C,KAAK,UAAU;EAExB,QADY,MAAM,QAAS,MAAgB,GAAG,IAAM,MAAgB,MAAkB,CAAC,GAErF,KAAK,eAAe,MAAM,UAAqC,CAAC,EAChE,QAAQ,QAA6B,QAAQ,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AAY;IACZ,MAAK;IACL,WAAU;IACV,cAAa;IACb,eAAgB,OAAO,WAAW,IAAI,aAAa,CAAC,IAAI,WAAW;IACnE,QAAQ;cAEP,OAAO,WAAW,IAAI,EAAE,KAAK,qBAAqB,IAAI,EAAE,KAAK,cAAc;GACrE,CAAA;EACJ,CAAA,CACD;;AAEP"}
@@ -0,0 +1,150 @@
1
+ "use client";
2
+ import { keys } from "../translations/keys.js";
3
+ import { conditionOperators, firstOperatorFor, operatorLabelKey, operatorValueShape } from "../conditions/fieldTypes.js";
4
+ import { useTranslation as useTranslation$1 } from "../translations/useTranslation.js";
5
+ import { dateClientField, numberClientField, selectClientField, textClientField } from "./synthesizeClientField.js";
6
+ import { Button, DateCondition, NumberCondition, ReactSelect, SelectCondition, TextCondition } from "@payloadcms/ui";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/client/ConditionRow.tsx
9
+ /** ReactSelect's `onChange` hands back `Option | Option[]`; narrow it to the single chosen option. */
10
+ const singleOption = (selected) => Array.isArray(selected) ? selected[0] : selected;
11
+ const ConditionRow = ({ condition, operands, onChange, onRemove }) => {
12
+ const { t, i18n } = useTranslation$1();
13
+ const operand = operands.find((entry) => entry.name === condition.field);
14
+ const conditionType = operand?.conditionType ?? "text";
15
+ const operators = conditionOperators[conditionType];
16
+ const fieldOptions = operands.map((entry) => ({
17
+ label: entry.label,
18
+ value: entry.name
19
+ }));
20
+ const operatorOptions = operators.map((operator) => ({
21
+ label: i18n.t(operatorLabelKey(operator)),
22
+ value: operator
23
+ }));
24
+ const handleFieldChange = (selected) => {
25
+ const chosen = singleOption(selected);
26
+ const next = operands.find((entry) => entry.name === chosen?.value);
27
+ if (!next) return;
28
+ onChange({
29
+ field: next.name,
30
+ operator: firstOperatorFor(next.conditionType),
31
+ value: void 0
32
+ });
33
+ };
34
+ const handleOperatorChange = (selected) => {
35
+ const chosen = singleOption(selected);
36
+ if (!chosen) return;
37
+ const operator = chosen.value;
38
+ const keepValue = operatorValueShape(condition.operator) === operatorValueShape(operator);
39
+ onChange({
40
+ ...condition,
41
+ operator,
42
+ value: keepValue ? condition.value : void 0
43
+ });
44
+ };
45
+ return /* @__PURE__ */ jsxs("div", {
46
+ className: "fb-condition-row",
47
+ children: [
48
+ /* @__PURE__ */ jsx("div", {
49
+ className: "fb-condition-row__field",
50
+ children: /* @__PURE__ */ jsx(ReactSelect, {
51
+ options: fieldOptions,
52
+ value: fieldOptions.find((option) => option.value === condition.field),
53
+ placeholder: t(keys.conditionSelectField),
54
+ isClearable: false,
55
+ onChange: handleFieldChange
56
+ })
57
+ }),
58
+ /* @__PURE__ */ jsx("div", {
59
+ className: "fb-condition-row__operator",
60
+ children: /* @__PURE__ */ jsx(ReactSelect, {
61
+ options: operatorOptions,
62
+ value: operatorOptions.find((option) => option.value === condition.operator),
63
+ disabled: !operand,
64
+ isClearable: false,
65
+ onChange: handleOperatorChange
66
+ })
67
+ }),
68
+ /* @__PURE__ */ jsx("div", {
69
+ className: "fb-condition-row__value",
70
+ children: /* @__PURE__ */ jsx(ConditionValue, {
71
+ conditionType,
72
+ operand,
73
+ operator: condition.operator,
74
+ value: condition.value,
75
+ onChange: (value) => onChange({
76
+ ...condition,
77
+ value
78
+ })
79
+ })
80
+ }),
81
+ /* @__PURE__ */ jsx("div", {
82
+ className: "fb-condition-row__remove",
83
+ children: /* @__PURE__ */ jsx(Button, {
84
+ buttonStyle: "icon-label",
85
+ icon: "x",
86
+ onClick: onRemove,
87
+ "aria-label": t(keys.conditionRemove),
88
+ margin: false
89
+ })
90
+ })
91
+ ]
92
+ });
93
+ };
94
+ const ConditionValue = ({ conditionType, operand, operator, value, onChange }) => {
95
+ const { t } = useTranslation$1();
96
+ if (conditionType === "checkbox" || operatorValueShape(operator) === "boolean") {
97
+ const options = [{
98
+ label: t(keys.conditionTrue),
99
+ value: "true"
100
+ }, {
101
+ label: t(keys.conditionFalse),
102
+ value: "false"
103
+ }];
104
+ const handleBooleanChange = (selected) => {
105
+ onChange(singleOption(selected)?.value === "true");
106
+ };
107
+ return /* @__PURE__ */ jsx(ReactSelect, {
108
+ options,
109
+ value: options.find((option) => String(option.value) === String(value)) ?? options[0],
110
+ isClearable: false,
111
+ onChange: handleBooleanChange
112
+ });
113
+ }
114
+ if (!operand) return null;
115
+ switch (conditionType) {
116
+ case "number": return /* @__PURE__ */ jsx(NumberCondition, {
117
+ disabled: false,
118
+ field: numberClientField(operand),
119
+ operator,
120
+ value,
121
+ onChange: (next) => onChange(next)
122
+ });
123
+ case "date": return /* @__PURE__ */ jsx(DateCondition, {
124
+ disabled: false,
125
+ field: dateClientField(operand),
126
+ operator,
127
+ value,
128
+ onChange: (next) => onChange(next)
129
+ });
130
+ case "select": return /* @__PURE__ */ jsx(SelectCondition, {
131
+ disabled: false,
132
+ field: selectClientField(operand),
133
+ operator,
134
+ options: operand.options ?? [],
135
+ value,
136
+ onChange: (next) => onChange(next)
137
+ });
138
+ default: return /* @__PURE__ */ jsx(TextCondition, {
139
+ disabled: false,
140
+ field: textClientField(operand),
141
+ operator,
142
+ value,
143
+ onChange: (next) => onChange(next)
144
+ });
145
+ }
146
+ };
147
+ //#endregion
148
+ export { ConditionRow };
149
+
150
+ //# sourceMappingURL=ConditionRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionRow.js","names":["useTranslation"],"sources":["../../src/client/ConditionRow.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tButton,\n\tDateCondition,\n\tNumberCondition,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tSelectCondition,\n\tTextCondition,\n} from '@payloadcms/ui'\nimport type { Operator } from 'payload'\nimport {\n\tconditionOperators,\n\tfirstOperatorFor,\n\toperatorLabelKey,\n\toperatorValueShape,\n} from '../conditions/fieldTypes'\nimport { keys } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport {\n\ttype ConditionOperand,\n\tdateClientField,\n\tnumberClientField,\n\tselectClientField,\n\ttextClientField,\n} from './synthesizeClientField'\n\nexport type RowCondition = { field: string; operator: Operator; value: unknown }\n\nexport type ConditionRowProps = {\n\tcondition: RowCondition\n\toperands: ConditionOperand[]\n\tonChange: (next: RowCondition) => void\n\tonRemove: () => void\n}\n\n/** ReactSelect's `onChange` hands back `Option | Option[]`; narrow it to the single chosen option. */\nconst singleOption = (\n\tselected: ReactSelectOption | ReactSelectOption[]\n): ReactSelectOption | undefined => (Array.isArray(selected) ? selected[0] : selected)\n\nexport const ConditionRow = ({ condition, operands, onChange, onRemove }: ConditionRowProps) => {\n\tconst { t, i18n } = useTranslation()\n\tconst operand = operands.find((entry) => entry.name === condition.field)\n\tconst conditionType = operand?.conditionType ?? 'text'\n\tconst operators = conditionOperators[conditionType]\n\n\tconst fieldOptions: ReactSelectOption[] = operands.map((entry) => ({\n\t\tlabel: entry.label,\n\t\tvalue: entry.name,\n\t}))\n\tconst operatorOptions: ReactSelectOption[] = operators.map((operator) => ({\n\t\tlabel: i18n.t(operatorLabelKey(operator)),\n\t\tvalue: operator,\n\t}))\n\n\tconst handleFieldChange = (selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\tconst chosen = singleOption(selected)\n\t\tconst next = operands.find((entry) => entry.name === chosen?.value)\n\t\tif (!next) {\n\t\t\treturn\n\t\t}\n\t\tonChange({\n\t\t\tfield: next.name,\n\t\t\toperator: firstOperatorFor(next.conditionType),\n\t\t\tvalue: undefined,\n\t\t})\n\t}\n\n\tconst handleOperatorChange = (selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\tconst chosen = singleOption(selected)\n\t\tif (!chosen) {\n\t\t\treturn\n\t\t}\n\t\tconst operator = chosen.value as Operator\n\t\tconst keepValue = operatorValueShape(condition.operator) === operatorValueShape(operator)\n\t\tonChange({ ...condition, operator, value: keepValue ? condition.value : undefined })\n\t}\n\n\treturn (\n\t\t<div className=\"fb-condition-row\">\n\t\t\t<div className=\"fb-condition-row__field\">\n\t\t\t\t<ReactSelect\n\t\t\t\t\toptions={fieldOptions}\n\t\t\t\t\tvalue={fieldOptions.find((option) => option.value === condition.field)}\n\t\t\t\t\tplaceholder={t(keys.conditionSelectField)}\n\t\t\t\t\tisClearable={false}\n\t\t\t\t\tonChange={handleFieldChange}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"fb-condition-row__operator\">\n\t\t\t\t<ReactSelect\n\t\t\t\t\toptions={operatorOptions}\n\t\t\t\t\tvalue={operatorOptions.find((option) => option.value === condition.operator)}\n\t\t\t\t\tdisabled={!operand}\n\t\t\t\t\tisClearable={false}\n\t\t\t\t\tonChange={handleOperatorChange}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"fb-condition-row__value\">\n\t\t\t\t<ConditionValue\n\t\t\t\t\tconditionType={conditionType}\n\t\t\t\t\toperand={operand}\n\t\t\t\t\toperator={condition.operator}\n\t\t\t\t\tvalue={condition.value}\n\t\t\t\t\tonChange={(value) => onChange({ ...condition, value })}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"fb-condition-row__remove\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"icon-label\"\n\t\t\t\t\ticon=\"x\"\n\t\t\t\t\tonClick={onRemove}\n\t\t\t\t\taria-label={t(keys.conditionRemove)}\n\t\t\t\t\tmargin={false}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\ntype ConditionValueProps = {\n\tconditionType: ConditionOperand['conditionType']\n\toperand?: ConditionOperand\n\toperator: Operator\n\tvalue: unknown\n\tonChange: (value: unknown) => void\n}\n\nconst ConditionValue = ({\n\tconditionType,\n\toperand,\n\toperator,\n\tvalue,\n\tonChange,\n}: ConditionValueProps) => {\n\tconst { t } = useTranslation()\n\tif (conditionType === 'checkbox' || operatorValueShape(operator) === 'boolean') {\n\t\tconst options: ReactSelectOption[] = [\n\t\t\t{ label: t(keys.conditionTrue), value: 'true' },\n\t\t\t{ label: t(keys.conditionFalse), value: 'false' },\n\t\t]\n\t\tconst handleBooleanChange = (selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\t\tconst chosen = singleOption(selected)\n\t\t\tonChange(chosen?.value === 'true')\n\t\t}\n\t\treturn (\n\t\t\t<ReactSelect\n\t\t\t\toptions={options}\n\t\t\t\tvalue={options.find((option) => String(option.value) === String(value)) ?? options[0]}\n\t\t\t\tisClearable={false}\n\t\t\t\tonChange={handleBooleanChange}\n\t\t\t/>\n\t\t)\n\t}\n\tif (!operand) {\n\t\treturn null\n\t}\n\tswitch (conditionType) {\n\t\tcase 'number':\n\t\t\treturn (\n\t\t\t\t<NumberCondition\n\t\t\t\t\tdisabled={false}\n\t\t\t\t\tfield={numberClientField(operand)}\n\t\t\t\t\toperator={operator}\n\t\t\t\t\tvalue={value as number | number[]}\n\t\t\t\t\tonChange={(next: string) => onChange(next)}\n\t\t\t\t/>\n\t\t\t)\n\t\tcase 'date':\n\t\t\treturn (\n\t\t\t\t<DateCondition\n\t\t\t\t\tdisabled={false}\n\t\t\t\t\tfield={dateClientField(operand)}\n\t\t\t\t\toperator={operator}\n\t\t\t\t\tvalue={value as Date | string}\n\t\t\t\t\tonChange={(next: Date | string) => onChange(next)}\n\t\t\t\t/>\n\t\t\t)\n\t\tcase 'select':\n\t\t\treturn (\n\t\t\t\t<SelectCondition\n\t\t\t\t\tdisabled={false}\n\t\t\t\t\tfield={selectClientField(operand)}\n\t\t\t\t\toperator={operator}\n\t\t\t\t\toptions={operand.options ?? []}\n\t\t\t\t\tvalue={value as string}\n\t\t\t\t\tonChange={(next: string) => onChange(next)}\n\t\t\t\t/>\n\t\t\t)\n\t\tdefault:\n\t\t\treturn (\n\t\t\t\t<TextCondition\n\t\t\t\t\tdisabled={false}\n\t\t\t\t\tfield={textClientField(operand)}\n\t\t\t\t\toperator={operator}\n\t\t\t\t\tvalue={value as string | string[]}\n\t\t\t\t\tonChange={(next: string) => onChange(next)}\n\t\t\t\t/>\n\t\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;AAsCA,MAAM,gBACL,aACoC,MAAM,QAAQ,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,KAAK,UACJ,OACC,oBAAC,iBAAD;GACC,UAAU;GACV,OAAO,kBAAkB,OAAO;GACtB;GACV,SAAS,QAAQ,WAAW,CAAC;GACtB;GACP,WAAW,SAAiB,SAAS,IAAI;EACzC,CAAA;EAEH,SACC,OACC,oBAAC,eAAD;GACC,UAAU;GACV,OAAO,gBAAgB,OAAO;GACpB;GACH;GACP,WAAW,SAAiB,SAAS,IAAI;EACzC,CAAA;CAEJ;AACD"}
@@ -0,0 +1,15 @@
1
+ import { ConditionFieldType } from "../conditions/fieldTypes.js";
2
+
3
+ //#region src/client/FlowBuilder.d.ts
4
+ type FlowBuilderProps = {
5
+ path?: string;
6
+ field?: {
7
+ label?: unknown;
8
+ };
9
+ label?: unknown;
10
+ conditionTypes: Record<string, ConditionFieldType>;
11
+ };
12
+ declare const FlowBuilder: (props: FlowBuilderProps) => import("react/jsx-runtime").JSX.Element;
13
+ //#endregion
14
+ export { FlowBuilder };
15
+ //# sourceMappingURL=FlowBuilder.d.ts.map