@sealcode/sealgen 0.18.10 → 0.19.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 (444) hide show
  1. package/.xunit +74 -69
  2. package/@types/add-crud.d.sync-conflict-20250918-184311-TFDLWFG.ts +1 -0
  3. package/@types/builders/colors-builder.d.sync-conflict-20250918-184323-TFDLWFG.ts +10 -0
  4. package/@types/builders/colors-builder.d.ts +1 -1
  5. package/@types/builders/fonts-builder.d.sync-conflict-20250918-184322-TFDLWFG.ts +7 -0
  6. package/@types/builders/fonts-builder.d.ts +1 -1
  7. package/@types/controllers/table-add-button.d.ts +6 -0
  8. package/@types/controllers/table-add-button.stimulus.d.ts +6 -0
  9. package/@types/crud-field-snippets.d.sync-conflict-20250918-184323-TFDLWFG.ts +1 -0
  10. package/@types/crud-field-snippets.d.ts +1 -3
  11. package/@types/forms/controls/array.d.sync-conflict-20250918-184306-TFDLWFG.ts +33 -0
  12. package/@types/forms/controls/array.d.ts +1 -3
  13. package/@types/forms/controls/array.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
  14. package/@types/forms/controls/autocomplete.d.sync-conflict-20250918-222042-TFDLWFG.ts +22 -0
  15. package/@types/forms/controls/autocomplete.d.ts +1 -1
  16. package/@types/forms/controls/checkbox-group.d.sync-conflict-20250918-184319-TFDLWFG.ts +21 -0
  17. package/@types/forms/controls/checkbox-group.d.ts +3 -3
  18. package/@types/forms/controls/checkboxed-list-input.d.sync-conflict-20250918-184323-TFDLWFG.ts +21 -0
  19. package/@types/forms/controls/checkboxed-list-input.d.ts +3 -3
  20. package/@types/forms/controls/controls.d.ts +2 -2
  21. package/@types/forms/controls/derived-frame.d.sync-conflict-20250918-184314-TFDLWFG.ts +19 -0
  22. package/@types/forms/controls/derived-frame.d.ts +0 -2
  23. package/@types/forms/controls/dropdown.d.sync-conflict-20250918-222044-TFDLWFG.ts +30 -0
  24. package/@types/forms/controls/dropdown.d.ts +1 -1
  25. package/@types/forms/controls/file.d.sync-conflict-20250918-222045-TFDLWFG.ts +13 -0
  26. package/@types/forms/controls/file.d.ts +1 -2
  27. package/@types/forms/controls/form-control.d.sync-conflict-20250918-184322-TFDLWFG.ts +19 -0
  28. package/@types/forms/controls/form-control.d.sync-conflict-20250918-222046-TFDLWFG.ts +19 -0
  29. package/@types/forms/controls/form-control.d.ts +7 -4
  30. package/@types/forms/controls/image.d.ts +19 -0
  31. package/@types/forms/controls/image.test.d.ts +1 -0
  32. package/@types/forms/controls/multiple-files.d.sync-conflict-20250918-184318-TFDLWFG.ts +42 -0
  33. package/@types/forms/controls/multiple-files.d.ts +3 -1
  34. package/@types/forms/controls/multiple-images.d.ts +19 -0
  35. package/@types/forms/controls/number.d.sync-conflict-20250918-222046-TFDLWFG.ts +13 -0
  36. package/@types/forms/controls/number.d.ts +1 -1
  37. package/@types/forms/controls/photo.d.sync-conflict-20250918-184321-TFDLWFG.ts +19 -0
  38. package/@types/forms/controls/photo.d.ts +3 -5
  39. package/@types/forms/controls/simple-input.d.sync-conflict-20250918-184310-TFDLWFG.ts +33 -0
  40. package/@types/forms/controls/simple-input.d.sync-conflict-20250918-222042-TFDLWFG.ts +33 -0
  41. package/@types/forms/controls/simple-input.d.ts +5 -4
  42. package/@types/forms/controls/simple-input.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
  43. package/@types/forms/controls/single-reference.d.ts +3 -2
  44. package/@types/forms/controls/table.d.sync-conflict-20250918-184302-TFDLWFG.ts +39 -0
  45. package/@types/forms/controls/table.d.ts +8 -3
  46. package/@types/forms/controls/table.sync-conflict-20250918-222042-TFDLWFG.d.ts +39 -0
  47. package/@types/forms/controls/textarea.d.sync-conflict-20250918-222045-TFDLWFG.ts +25 -0
  48. package/@types/forms/controls/textarea.d.ts +3 -3
  49. package/@types/forms/fields/boolean.d.sync-conflict-20250918-184325-TFDLWFG.ts +22 -0
  50. package/@types/forms/fields/boolean.d.ts +6 -1
  51. package/@types/forms/fields/boolean.sync-conflict-20250918-222042-TFDLWFG.d.ts +22 -0
  52. package/@types/forms/fields/checkboxed-list.d.sync-conflict-20250918-184325-TFDLWFG.ts +23 -0
  53. package/@types/forms/fields/checkboxed-list.d.ts +3 -1
  54. package/@types/forms/fields/collection-field.d.sync-conflict-20250918-184319-TFDLWFG.ts +22 -0
  55. package/@types/forms/fields/collection-field.d.sync-conflict-20250918-222047-TFDLWFG.ts +22 -0
  56. package/@types/forms/fields/collection-field.d.ts +8 -1
  57. package/@types/forms/fields/color.d.ts +4 -0
  58. package/@types/forms/fields/coordinates.d.sync-conflict-20250918-222044-TFDLWFG.ts +14 -0
  59. package/@types/forms/fields/coordinates.d.ts +14 -0
  60. package/@types/forms/fields/date.d.ts +13 -0
  61. package/@types/forms/fields/datetime.d.sync-conflict-20250918-222050-TFDLWFG.ts +4 -0
  62. package/@types/forms/fields/datetime.d.ts +14 -0
  63. package/@types/forms/fields/deep-reverse-single-reference-list.d.ts +20 -0
  64. package/@types/forms/fields/deep-reverse-single-reference-table.d.ts +16 -0
  65. package/@types/forms/fields/email.d.sync-conflict-20250918-184303-TFDLWFG.ts +8 -0
  66. package/@types/forms/fields/email.d.ts +3 -0
  67. package/@types/forms/fields/enum-multiple-sealious.d.ts +16 -0
  68. package/@types/forms/fields/enum-multiple-sealious.sync-conflict-20250918-222047-TFDLWFG.d.ts +16 -0
  69. package/@types/forms/fields/field.d.sync-conflict-20250918-184306-TFDLWFG.ts +70 -0
  70. package/@types/forms/fields/field.d.ts +37 -5
  71. package/@types/forms/fields/fields.d.sync-conflict-20250918-184314-TFDLWFG.ts +29 -0
  72. package/@types/forms/fields/fields.d.ts +23 -8
  73. package/@types/forms/fields/file.d.sync-conflict-20250918-184310-TFDLWFG.ts +23 -0
  74. package/@types/forms/fields/file.d.sync-conflict-20250918-222046-TFDLWFG.ts +23 -0
  75. package/@types/forms/fields/file.d.ts +11 -5
  76. package/@types/forms/fields/file.sync-conflict-20250918-222049-TFDLWFG.d.ts +23 -0
  77. package/@types/forms/fields/float.d.ts +4 -0
  78. package/@types/forms/fields/get-field-for-sealious.d.sync-conflict-20250918-222046-TFDLWFG.ts +29 -0
  79. package/@types/forms/fields/get-field-for-sealious.d.ts +31 -0
  80. package/@types/forms/fields/get-field-for-sealious.sync-conflict-20250918-222042-TFDLWFG.d.ts +29 -0
  81. package/@types/forms/fields/html.d.ts +6 -0
  82. package/@types/forms/fields/image.d.sync-conflict-20250918-222042-TFDLWFG.ts +5 -0
  83. package/@types/forms/fields/image.d.ts +5 -0
  84. package/@types/forms/fields/int.d.ts +6 -0
  85. package/@types/forms/fields/json.d.ts +13 -0
  86. package/@types/forms/fields/markdown.d.ts +6 -0
  87. package/@types/forms/fields/multiple-files.d.sync-conflict-20250918-184304-TFDLWFG.ts +16 -0
  88. package/@types/forms/fields/multiple-files.d.ts +3 -1
  89. package/@types/forms/fields/number.d.sync-conflict-20250918-184317-TFDLWFG.ts +25 -0
  90. package/@types/forms/fields/number.d.sync-conflict-20250918-222047-TFDLWFG.ts +25 -0
  91. package/@types/forms/fields/number.d.ts +3 -1
  92. package/@types/forms/fields/password.d.ts +5 -0
  93. package/@types/forms/fields/pick-from-list-sealious.d.ts +11 -0
  94. package/@types/forms/fields/pick-from-list.d.sync-conflict-20250918-184322-TFDLWFG.ts +15 -0
  95. package/@types/forms/fields/pick-from-list.d.ts +4 -3
  96. package/@types/forms/fields/proxy-field.d.sync-conflict-20250918-184307-TFDLWFG.ts +15 -0
  97. package/@types/forms/fields/proxy-field.d.ts +3 -1
  98. package/@types/forms/fields/regexp.d.sync-conflict-20250918-184305-TFDLWFG.ts +21 -0
  99. package/@types/forms/fields/regexp.d.sync-conflict-20250918-222045-TFDLWFG.ts +21 -0
  100. package/@types/forms/fields/regexp.d.ts +6 -1
  101. package/@types/forms/fields/regexp.sync-conflict-20250918-222047-TFDLWFG.d.ts +21 -0
  102. package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-184309-TFDLWFG.ts +29 -0
  103. package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-222044-TFDLWFG.ts +29 -0
  104. package/@types/forms/fields/simple-form-field.d.ts +23 -3
  105. package/@types/forms/fields/simple-form-field.sync-conflict-20250918-222049-TFDLWFG.d.ts +29 -0
  106. package/@types/forms/fields/single-reference.d.ts +19 -0
  107. package/@types/forms/fields/single-reference.sync-conflict-20250918-222043-TFDLWFG.d.ts +10 -0
  108. package/@types/forms/fields/structured-array.d.sync-conflict-20250918-184302-TFDLWFG.ts +27 -0
  109. package/@types/forms/fields/structured-array.d.sync-conflict-20250918-222049-TFDLWFG.ts +27 -0
  110. package/@types/forms/fields/structured-array.d.ts +19 -10
  111. package/@types/forms/fields/structured-array.sync-conflict-20250918-222047-TFDLWFG.d.ts +27 -0
  112. package/@types/forms/fields/table.d.sync-conflict-20250918-184303-TFDLWFG.ts +16 -0
  113. package/@types/forms/fields/table.d.ts +3 -0
  114. package/@types/forms/fields/text.d.ts +6 -0
  115. package/@types/forms/fields/url.d.ts +6 -0
  116. package/@types/forms/form-types.d.sync-conflict-20250918-222045-TFDLWFG.ts +26 -0
  117. package/@types/forms/form-types.d.ts +2 -0
  118. package/@types/forms/form.d.sync-conflict-20250918-184315-TFDLWFG.ts +32 -0
  119. package/@types/forms/form.d.sync-conflict-20250918-222049-TFDLWFG.ts +32 -0
  120. package/@types/forms/form.d.ts +10 -8
  121. package/@types/forms/form.sync-conflict-20250918-222049-TFDLWFG.d.ts +33 -0
  122. package/@types/forms/form.test.d.sync-conflict-20250918-184318-TFDLWFG.ts +6 -0
  123. package/@types/forms/form.test.d.sync-conflict-20250918-222047-TFDLWFG.ts +6 -0
  124. package/@types/forms/form.test.d.ts +2 -2
  125. package/@types/forms/multiform.d.sync-conflict-20250918-184308-TFDLWFG.ts +23 -0
  126. package/@types/forms/multiform.d.ts +1 -2
  127. package/@types/forms/multiform.sync-conflict-20250918-222044-TFDLWFG.d.ts +23 -0
  128. package/@types/index.d.sync-conflict-20250918-184316-TFDLWFG.ts +46 -0
  129. package/@types/index.d.ts +2 -2
  130. package/@types/mount.d.sync-conflict-20250918-184320-TFDLWFG.ts +6 -0
  131. package/@types/mount.d.ts +0 -1
  132. package/@types/page/list.d.sync-conflict-20250918-184318-TFDLWFG.ts +48 -0
  133. package/@types/page/list.d.sync-conflict-20250918-222046-TFDLWFG.ts +48 -0
  134. package/@types/page/list.d.ts +2 -2
  135. package/@types/page/list.sync-conflict-20250918-222048-TFDLWFG.d.ts +48 -0
  136. package/@types/page/mountable-with-fields.d.sync-conflict-20250918-184321-TFDLWFG.ts +42 -0
  137. package/@types/page/mountable-with-fields.d.sync-conflict-20250918-222046-TFDLWFG.ts +42 -0
  138. package/@types/page/mountable-with-fields.d.ts +3 -3
  139. package/@types/page/mountable-with-fields.sync-conflict-20250918-222044-TFDLWFG.d.ts +42 -0
  140. package/@types/page/mountable.d.sync-conflict-20250918-184306-TFDLWFG.ts +10 -0
  141. package/@types/page/mountable.d.ts +0 -1
  142. package/@types/page/page.d.sync-conflict-20250918-184320-TFDLWFG.ts +18 -0
  143. package/@types/page/page.d.ts +0 -1
  144. package/@types/page/props-parser.d.sync-conflict-20250918-184305-TFDLWFG.ts +15 -0
  145. package/@types/page/props-parser.d.ts +0 -1
  146. package/@types/page/stateful-page.d.sync-conflict-20250918-184326-TFDLWFG.ts +62 -0
  147. package/@types/page/stateful-page.d.ts +0 -1
  148. package/@types/register-external.d.ts +2 -2
  149. package/@types/templates/form.d.ts +1 -3
  150. package/@types/templates/jdd-component.d.ts +1 -1
  151. package/@types/templates/page.d.ts +1 -1
  152. package/@types/templates/shared/shared-crud-form-fields.d.sync-conflict-20250918-184306-TFDLWFG.ts +1 -0
  153. package/@types/templates/shared/shared-crud-form-fields.d.ts +1 -68
  154. package/@types/templates/templates.d.ts +1 -21
  155. package/@types/test_utils/test-on-real-app.d.sync-conflict-20250918-184320-TFDLWFG.ts +26 -0
  156. package/@types/test_utils/test-on-real-app.d.ts +0 -1
  157. package/@types/utils/extract-fields-from-collection.d.sync-conflict-20250918-184312-TFDLWFG.ts +18 -0
  158. package/@types/utils/extract-fields-from-collection.d.ts +5 -1
  159. package/@types/utils/extract-fields-from-collection.sync-conflict-20250918-222045-TFDLWFG.d.ts +18 -0
  160. package/@types/utils/wrap-attributes.d.ts +3 -0
  161. package/README.md +5 -0
  162. package/assets/file-icon.svg +5 -0
  163. package/eslint.config.mjs +56 -0
  164. package/lib/add-crud.js +77 -89
  165. package/lib/add-jdd-component.js +3 -3
  166. package/lib/add-list-route.test.js +1 -1
  167. package/lib/add-route.js +2 -9
  168. package/lib/build.js +6 -4
  169. package/lib/builders/backend-ts-builder.js +0 -1
  170. package/lib/builders/colors-builder.js +11 -8
  171. package/lib/builders/fonts-builder.js +0 -1
  172. package/lib/builders/frontend-ts-builder.js +0 -1
  173. package/lib/cli.js +4 -7
  174. package/lib/components/tabs.js +36 -36
  175. package/lib/controllers/table-add-button.stimulus.js +35 -0
  176. package/lib/esbuild-plugins/rewrite-asset-imports.js +7 -10
  177. package/lib/forms/controls/array.js +25 -22
  178. package/lib/forms/controls/big-radio-group.js +2 -2
  179. package/lib/forms/controls/checkbox-group.js +7 -7
  180. package/lib/forms/controls/checkboxed-list-input.js +7 -1
  181. package/lib/forms/controls/checkboxed-list-input.test.js +6 -6
  182. package/lib/forms/controls/controls.js +2 -2
  183. package/lib/forms/controls/derived-frame.js +8 -4
  184. package/lib/forms/controls/derived.js +1 -1
  185. package/lib/forms/controls/dropdown.js +5 -3
  186. package/lib/forms/controls/editable-collection-subset.js +2 -2
  187. package/lib/forms/controls/file.js +26 -2
  188. package/lib/forms/controls/file.test.js +2 -2
  189. package/lib/forms/controls/form-control.js +1 -1
  190. package/lib/forms/controls/hidden-input.js +4 -1
  191. package/lib/forms/controls/{photo.js → image.js} +6 -7
  192. package/lib/forms/controls/{photo.test.js → image.test.js} +8 -23
  193. package/lib/forms/controls/multiple-files.js +10 -1
  194. package/lib/forms/controls/{multiple-photos.js → multiple-images.js} +3 -3
  195. package/lib/forms/controls/simple-input.js +13 -12
  196. package/lib/forms/controls/single-reference.js +4 -0
  197. package/lib/forms/controls/single-reference.test.js +1 -1
  198. package/lib/forms/controls/table.js +62 -25
  199. package/lib/forms/controls/textarea.js +5 -3
  200. package/lib/forms/controls/tickable.js +13 -5
  201. package/lib/forms/fields/boolean.js +14 -0
  202. package/lib/forms/fields/checkboxed-list.js +4 -0
  203. package/lib/forms/fields/collection-field.js +9 -0
  204. package/lib/forms/fields/color.js +10 -0
  205. package/lib/forms/fields/coordinates.js +49 -0
  206. package/lib/forms/fields/date.js +34 -0
  207. package/lib/forms/fields/datetime.js +46 -0
  208. package/lib/forms/fields/deep-reverse-single-reference-list.js +81 -0
  209. package/lib/forms/fields/deep-reverse-single-reference-table.js +122 -0
  210. package/lib/forms/fields/email.js +7 -0
  211. package/lib/forms/fields/enum-multiple-sealious.js +32 -0
  212. package/lib/forms/fields/field.js +32 -4
  213. package/lib/forms/fields/field.test.js +8 -8
  214. package/lib/forms/fields/fields.js +23 -8
  215. package/lib/forms/fields/file.js +33 -9
  216. package/lib/forms/fields/file.test.js +5 -17
  217. package/lib/forms/fields/float.js +10 -0
  218. package/lib/forms/fields/get-field-for-sealious.js +213 -0
  219. package/lib/forms/fields/html.js +14 -0
  220. package/lib/forms/fields/image.js +13 -0
  221. package/lib/forms/fields/int.js +23 -0
  222. package/lib/forms/fields/json.js +31 -0
  223. package/lib/forms/fields/markdown.js +14 -0
  224. package/lib/forms/fields/multiple-files.js +4 -0
  225. package/lib/forms/fields/number.js +6 -0
  226. package/lib/forms/fields/password.js +13 -0
  227. package/lib/forms/fields/pick-from-list-sealious.js +17 -0
  228. package/lib/forms/fields/pick-from-list.js +6 -2
  229. package/lib/forms/fields/proxy-field.js +3 -0
  230. package/lib/forms/fields/regexp.js +14 -0
  231. package/lib/forms/fields/simple-form-field.js +61 -2
  232. package/lib/forms/fields/single-reference.js +44 -0
  233. package/lib/forms/fields/structured-array.js +61 -12
  234. package/lib/forms/fields/table.js +29 -2
  235. package/lib/forms/fields/text.js +17 -0
  236. package/lib/forms/fields/url.js +17 -0
  237. package/lib/forms/form.js +30 -14
  238. package/lib/forms/form.test.js +5 -7
  239. package/lib/forms/multiform.js +10 -9
  240. package/lib/forms/multiform.test.js +5 -5
  241. package/lib/generate-collections.js +2 -3
  242. package/lib/generate-components.js +2 -3
  243. package/lib/generate-routes.js +3 -5
  244. package/lib/generate-routes.test.js +7 -16
  245. package/lib/generate-stimulus.js +4 -4
  246. package/lib/get-fonts.js +29 -27
  247. package/lib/index.js +1 -0
  248. package/lib/make-env.js +1 -1
  249. package/lib/make-hidden-inputs.js +4 -4
  250. package/lib/mount.js +11 -1
  251. package/lib/notifier.js +3 -4
  252. package/lib/page/list.js +20 -15
  253. package/lib/page/mountable-with-fields.js +14 -6
  254. package/lib/page/mountable-with-fields.test.js +1 -1
  255. package/lib/page/mountable.js +0 -1
  256. package/lib/page/page.js +0 -1
  257. package/lib/register-external.js +4 -4
  258. package/lib/templates/form.js +9 -10
  259. package/lib/templates/jdd-component.js +1 -1
  260. package/lib/templates/jdd-editor.js +1 -1
  261. package/lib/templates/multiform.js +4 -4
  262. package/lib/templates/page.js +1 -3
  263. package/lib/templates/shared/collection-create-form.js +31 -44
  264. package/lib/templates/shared/collection-edit-form.js +43 -81
  265. package/lib/templates/shared/collection-list.js +13 -21
  266. package/lib/templates/shared/shared-crud-form-fields.js +28 -98
  267. package/lib/test_utils/exec_async.js +3 -3
  268. package/lib/test_utils/test-on-real-app.js +12 -14
  269. package/lib/utils/extract-fields-from-collection.js +60 -20
  270. package/lib/utils/make-slug.js +1 -1
  271. package/lib/utils/wrap-attributes.js +20 -0
  272. package/lib/utils/write-file.js +1 -1
  273. package/package.json +11 -9
  274. package/src/add-collection.ts +1 -3
  275. package/src/add-crud.ts +84 -100
  276. package/src/add-jdd-component.ts +4 -5
  277. package/src/add-list-route.test.ts +1 -1
  278. package/src/add-route.ts +3 -13
  279. package/src/build.ts +6 -4
  280. package/src/builders/backend-ts-builder.ts +0 -1
  281. package/src/builders/builder.ts +4 -1
  282. package/src/builders/colors-builder.ts +11 -9
  283. package/src/builders/css-builder.ts +4 -1
  284. package/src/builders/fonts-builder.ts +0 -1
  285. package/src/builders/frontend-ts-builder.ts +0 -1
  286. package/src/cli.ts +5 -7
  287. package/src/components/tabs.ts +38 -37
  288. package/src/components/toggle-modal.ts +1 -1
  289. package/src/controllers/table-add-button.stimulus.ts +35 -0
  290. package/src/esbuild-plugins/rewrite-asset-imports.ts +7 -10
  291. package/src/forms/controls/array.ts +35 -36
  292. package/src/forms/controls/autocomplete.ts +2 -2
  293. package/src/forms/controls/big-radio-group.ts +4 -4
  294. package/src/forms/controls/checkbox-group.ts +10 -10
  295. package/src/forms/controls/checkboxed-list-input.test.ts +6 -6
  296. package/src/forms/controls/checkboxed-list-input.ts +16 -8
  297. package/src/forms/controls/controls.ts +2 -2
  298. package/src/forms/controls/derived-frame.ts +16 -11
  299. package/src/forms/controls/derived.ts +7 -6
  300. package/src/forms/controls/dropdown.ts +13 -13
  301. package/src/forms/controls/editable-collection-subset.ts +4 -3
  302. package/src/forms/controls/field-group.ts +1 -1
  303. package/src/forms/controls/file.test.ts +4 -2
  304. package/src/forms/controls/file.ts +30 -7
  305. package/src/forms/controls/form-control.ts +8 -3
  306. package/src/forms/controls/hidden-input.ts +5 -1
  307. package/src/forms/controls/html.ts +1 -0
  308. package/src/forms/controls/{photo.test.ts → image.test.ts} +7 -24
  309. package/src/forms/controls/{photo.ts → image.ts} +4 -6
  310. package/src/forms/controls/multiple-files.ts +23 -8
  311. package/src/forms/controls/{multiple-photos.ts → multiple-images.ts} +2 -2
  312. package/src/forms/controls/number.ts +1 -1
  313. package/src/forms/controls/simple-input.ts +21 -33
  314. package/src/forms/controls/single-reference.test.ts +1 -1
  315. package/src/forms/controls/single-reference.ts +11 -3
  316. package/src/forms/controls/table.ts +87 -33
  317. package/src/forms/controls/textarea.ts +7 -5
  318. package/src/forms/controls/tickable.ts +13 -7
  319. package/src/forms/fields/boolean.ts +27 -2
  320. package/src/forms/fields/checkboxed-list.ts +11 -2
  321. package/src/forms/fields/collection-field.ts +21 -3
  322. package/src/forms/fields/color.ts +9 -0
  323. package/src/forms/fields/coordinates.ts +66 -0
  324. package/src/forms/fields/date.ts +50 -0
  325. package/src/forms/fields/datetime.ts +66 -0
  326. package/src/forms/fields/deep-reverse-single-reference-list.ts +130 -0
  327. package/src/forms/fields/deep-reverse-single-reference-table.ts +213 -0
  328. package/src/forms/fields/email.ts +10 -1
  329. package/src/forms/fields/enum-multiple-sealious.ts +48 -0
  330. package/src/forms/fields/existing-sealious-value.ts +1 -1
  331. package/src/forms/fields/field.test.ts +8 -8
  332. package/src/forms/fields/field.ts +98 -11
  333. package/src/forms/fields/fields.ts +23 -8
  334. package/src/forms/fields/file.test.ts +5 -17
  335. package/src/forms/fields/file.ts +44 -16
  336. package/src/forms/fields/float.ts +9 -0
  337. package/src/forms/fields/get-field-for-sealious.ts +337 -0
  338. package/src/forms/fields/html.ts +15 -0
  339. package/src/forms/fields/image.ts +12 -0
  340. package/src/forms/fields/int.ts +25 -0
  341. package/src/forms/fields/json.ts +48 -0
  342. package/src/forms/fields/markdown.ts +15 -0
  343. package/src/forms/fields/multiple-files.ts +10 -1
  344. package/src/forms/fields/number.ts +10 -3
  345. package/src/forms/fields/password.ts +13 -0
  346. package/src/forms/fields/pick-from-list-sealious.ts +22 -0
  347. package/src/forms/fields/pick-from-list.ts +8 -4
  348. package/src/forms/fields/proxy-field.ts +7 -1
  349. package/src/forms/fields/regexp.ts +27 -1
  350. package/src/forms/fields/simple-form-field.ts +103 -7
  351. package/src/forms/fields/single-reference.ts +62 -0
  352. package/src/forms/fields/structured-array.ts +111 -18
  353. package/src/forms/fields/table.ts +39 -16
  354. package/src/forms/fields/text.ts +18 -0
  355. package/src/forms/fields/url.ts +20 -0
  356. package/src/forms/form-types.ts +5 -4
  357. package/src/forms/form.test.ts +5 -7
  358. package/src/forms/form.ts +42 -23
  359. package/src/forms/forms.css +0 -85
  360. package/src/forms/multiform.test.ts +9 -9
  361. package/src/forms/multiform.ts +12 -10
  362. package/src/generate-collections.ts +2 -3
  363. package/src/generate-components.ts +2 -3
  364. package/src/generate-routes.test.ts +7 -16
  365. package/src/generate-routes.ts +6 -10
  366. package/src/generate-stimulus.ts +4 -5
  367. package/src/get-fonts.ts +32 -30
  368. package/src/index.ts +2 -1
  369. package/src/make-env.ts +1 -1
  370. package/src/make-hidden-inputs.ts +8 -7
  371. package/src/mount.ts +16 -7
  372. package/src/notifier.ts +4 -7
  373. package/src/page/default-list-filters.ts +1 -0
  374. package/src/page/list.ts +33 -28
  375. package/src/page/mountable-with-fields.test.ts +1 -1
  376. package/src/page/mountable-with-fields.ts +21 -12
  377. package/src/page/mountable.ts +0 -1
  378. package/src/page/page.ts +2 -3
  379. package/src/page/props-parser.ts +1 -1
  380. package/src/page/sealious-list.ts +1 -1
  381. package/src/page/stateful-page.ts +6 -10
  382. package/src/register-external.ts +5 -5
  383. package/src/templates/form.ts +9 -11
  384. package/src/templates/jdd-component.ts +1 -1
  385. package/src/templates/jdd-editor.ts +2 -4
  386. package/src/templates/list.ts +0 -1
  387. package/src/templates/multiform.ts +4 -4
  388. package/src/templates/page.ts +1 -6
  389. package/src/templates/shared/collection-create-form.ts +34 -71
  390. package/src/templates/shared/collection-edit-form.ts +46 -108
  391. package/src/templates/shared/collection-list.ts +13 -21
  392. package/src/templates/shared/item-delete.ts +0 -1
  393. package/src/templates/shared/shared-crud-form-fields.ts +38 -177
  394. package/src/templates/templates.ts +5 -1
  395. package/src/test_utils/exec_async.ts +3 -4
  396. package/src/test_utils/test-on-real-app.ts +13 -14
  397. package/src/utils/browser-creator.js +0 -1
  398. package/src/utils/exec.ts +0 -1
  399. package/src/utils/extract-fields-from-collection.ts +76 -25
  400. package/src/utils/input-wrapper.ts +1 -1
  401. package/src/utils/make-slug.ts +1 -1
  402. package/src/utils/wrap-attributes.ts +17 -0
  403. package/src/utils/write-file.ts +1 -1
  404. package/.eslintrc.cjs +0 -39
  405. package/lib/add-verbose-crud.js +0 -119
  406. package/lib/crud-field-snippets.js +0 -52
  407. package/lib/find-css-includes.js +0 -3
  408. package/lib/forms/controls/reverse-single-reference.js +0 -1
  409. package/lib/forms/fields/enum-multiple.js +0 -47
  410. package/lib/forms/fields/enum-multiple.test.js +0 -27
  411. package/lib/forms/fields/enum.js +0 -41
  412. package/lib/forms/fields/enum.test.js +0 -21
  413. package/lib/forms/fields/reverse-single-reference.js +0 -17
  414. package/lib/templates/shared/handlers/boolean.js +0 -14
  415. package/lib/templates/shared/handlers/date.js +0 -8
  416. package/lib/templates/shared/handlers/deep-reverse-single-reference.js +0 -209
  417. package/lib/templates/shared/handlers/default.js +0 -49
  418. package/lib/templates/shared/handlers/enum.js +0 -19
  419. package/lib/templates/shared/handlers/file.js +0 -23
  420. package/lib/templates/shared/handlers/image.js +0 -32
  421. package/lib/templates/shared/handlers/int.js +0 -11
  422. package/lib/templates/shared/handlers/jdd.js +0 -10
  423. package/lib/templates/shared/handlers/single-reference.js +0 -12
  424. package/lib/templates/shared/handlers/structured-array.js +0 -33
  425. package/src/add-verbose-crud.ts +0 -138
  426. package/src/crud-field-snippets.ts +0 -57
  427. package/src/find-css-includes.ts +0 -3
  428. package/src/forms/controls/reverse-single-reference.ts +0 -50
  429. package/src/forms/fields/enum-multiple.test.ts +0 -31
  430. package/src/forms/fields/enum-multiple.ts +0 -62
  431. package/src/forms/fields/enum.test.ts +0 -25
  432. package/src/forms/fields/enum.ts +0 -56
  433. package/src/forms/fields/reverse-single-reference.ts +0 -20
  434. package/src/templates/shared/handlers/boolean.ts +0 -18
  435. package/src/templates/shared/handlers/date.ts +0 -12
  436. package/src/templates/shared/handlers/deep-reverse-single-reference.ts +0 -244
  437. package/src/templates/shared/handlers/default.ts +0 -64
  438. package/src/templates/shared/handlers/enum.ts +0 -23
  439. package/src/templates/shared/handlers/file.ts +0 -27
  440. package/src/templates/shared/handlers/image.ts +0 -45
  441. package/src/templates/shared/handlers/int.ts +0 -15
  442. package/src/templates/shared/handlers/jdd.ts +0 -14
  443. package/src/templates/shared/handlers/single-reference.ts +0 -16
  444. package/src/templates/shared/handlers/structured-array.ts +0 -42
@@ -2,7 +2,7 @@ import { hasShape, is, predicates } from "@sealcode/ts-predicates";
2
2
  import qs from "qs";
3
3
  import { tempstream } from "tempstream";
4
4
  import { FormControl } from "./form-control.js";
5
- const TO_REPLACE = "____$$$$";
5
+ const TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER = "TABLE_ROW_INDEX________________";
6
6
  class Table extends FormControl {
7
7
  constructor(table_field, options) {
8
8
  super();
@@ -11,25 +11,41 @@ class Table extends FormControl {
11
11
  this.role = "input";
12
12
  }
13
13
  async render(fctx) {
14
- let { parsed: rows } = await this.table_field.getValue(
15
- fctx.ctx,
16
- fctx.data
17
- );
14
+ let rows = fctx.data.raw_values?.[this.table_field.name];
18
15
  if (!rows) {
19
16
  rows = [];
20
17
  }
21
- const make_row = (row, row_index) => {
18
+ const get_row_fctx = (row, row_index) => {
19
+ return typeof row_index == "number" ? {
20
+ data: {
21
+ raw_values: Object.fromEntries(
22
+ Object.entries(
23
+ row
24
+ ).map(([key, value]) => [
25
+ this.table_field.columns[key].name,
26
+ value
27
+ ])
28
+ ) || {},
29
+ messages: [],
30
+ field_messages: {}
31
+ }
32
+ } : {};
33
+ };
34
+ const make_row = async (row, row_index) => {
22
35
  return (
23
36
  /* HTML */
24
37
  tempstream`<tr>
25
- ${Object.entries(this.table_field.columns).map(([key]) => {
26
- return tempstream`<td>${this.options.render_fields[key](
27
- fctx,
28
- `${this.table_field.name}[${row_index}][${key}]`,
29
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
30
- row?.[key] || ""
31
- )}</td>`;
32
- })}
38
+ ${Promise.all(
39
+ Object.entries(this.table_field.columns).map(([column_name]) => {
40
+ const inner_fctx = get_row_fctx(row, row_index);
41
+ return tempstream`<td>${this.options.subfield_controls[column_name].render({ ...fctx, ...inner_fctx })}</td>`;
42
+ }).map(
43
+ async (html) => (await html).replaceAll(
44
+ TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER,
45
+ row_index.toString()
46
+ )
47
+ )
48
+ )}
33
49
  ${this.options.allow_removing ? (
34
50
  /* HTML */
35
51
  `<td>
@@ -55,7 +71,7 @@ class Table extends FormControl {
55
71
  )}"
56
72
  />
57
73
  </noscript>
58
- </td>`
74
+ </td>`
59
75
  ) : ""}
60
76
  </tr>`
61
77
  );
@@ -79,26 +95,25 @@ class Table extends FormControl {
79
95
  ${rows?.map((row, index) => make_row(row, index))}
80
96
  </tbody>
81
97
  </table>
82
- <template> ${make_row(null, TO_REPLACE)} </template>
98
+ <template>
99
+ ${make_row(null, TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER)}
100
+ </template>
83
101
 
84
102
  ${/* because of https://github.com/ljharb/qs/issues/252 we have to
85
103
  put the indexes in the field names */
86
104
  this.options.allow_adding ? (
87
105
  /* HTML */
88
106
  `<button
89
- onclick="const template = this.closest('turbo-frame').querySelector('template');
90
- const tbody = this.closest('turbo-frame').querySelector('tbody');
91
- const orig_template = template.innerHTML;
92
- template.innerHTML = orig_template.replaceAll('${TO_REPLACE}', tbody.querySelectorAll('tr').length);
93
- tbody.appendChild(template.cloneNode(true).content);
94
- template.innerHTML = orig_template;"
107
+ data-controller="table-add-button"
108
+ data-action="click->table-add-button#addRow"
109
+ data-table-placeholder="${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}"
95
110
  >
96
- add
111
+ ${this.options.label_add || "add"}
97
112
  </button>
98
113
  <noscript>
99
114
  <input
100
115
  type="submit"
101
- value="${this.options.label_add || "add"}"
116
+ value="add"
102
117
  form="${fctx.form_id}"
103
118
  formnovalidate
104
119
  formaction="${this.getActionURL(
@@ -177,7 +192,8 @@ template.innerHTML = orig_template;"
177
192
  ctx,
178
193
  {
179
194
  raw_values: await form.extractRawValues(ctx),
180
- messages: []
195
+ messages: [],
196
+ field_messages: {}
181
197
  },
182
198
  false
183
199
  )
@@ -185,8 +201,29 @@ template.innerHTML = orig_template;"
185
201
  await next();
186
202
  });
187
203
  }
204
+ setAllowRemoving(value) {
205
+ this.options.allow_removing = value;
206
+ return this;
207
+ }
208
+ setAllowAdding(value) {
209
+ this.options.allow_adding = value;
210
+ return this;
211
+ }
212
+ setLabel(value) {
213
+ this.options.label = value;
214
+ return this;
215
+ }
216
+ setRemoveLabel(value) {
217
+ this.options.label_remove = value;
218
+ return this;
219
+ }
220
+ setAddLabel(value) {
221
+ this.options.label_add = value;
222
+ return this;
223
+ }
188
224
  }
189
225
  export {
226
+ TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER,
190
227
  Table
191
228
  };
192
229
  //# sourceMappingURL=table.js.map
@@ -10,7 +10,7 @@ class Textarea extends SimpleInput {
10
10
  /* HTML */
11
11
  `<div class="form-input__description">
12
12
  ${this.options.description}
13
- </div>`
13
+ </div>`
14
14
  ) : "";
15
15
  }
16
16
  async getInputAttributes(fctx) {
@@ -27,10 +27,12 @@ class Textarea extends SimpleInput {
27
27
  };
28
28
  }
29
29
  async renderInput(ctx, attributes, data) {
30
- const { parsed: value } = await this.field.getValue(ctx, data);
30
+ const { parsed: value } = await this.field.getParsedValue(ctx, data);
31
31
  return (
32
32
  /* HTML */
33
- `<textarea ${attributes}>${value || ""}</textarea>`
33
+ `<textarea ${attributes}>
34
+ ${String(value) || ""}</textarea
35
+ >`
34
36
  );
35
37
  }
36
38
  }
@@ -25,16 +25,24 @@ class Tickable extends FormFieldControl {
25
25
  parsed: _parsed,
26
26
  valid,
27
27
  message
28
- } = await this.field.getValue(fctx.ctx, fctx.data, true);
28
+ } = await this.field.getParsedValue(
29
+ fctx.ctx,
30
+ fctx.data.raw_values,
31
+ true
32
+ );
29
33
  const parsed = _parsed === null ? this.options.default_value : _parsed;
30
- const value = this.getValueAttribute(fctx.ctx, fctx.data, parsed);
31
- const id = this.makeInputID(fctx.ctx, fctx.data, parsed);
34
+ const value = this.getValueAttribute(
35
+ fctx.ctx,
36
+ fctx.data.raw_values,
37
+ parsed
38
+ );
39
+ const id = this.makeInputID(fctx.ctx, fctx.data.raw_values, parsed);
32
40
  const label = this.options.label != void 0 ? this.options.label : this.field.name;
33
41
  const readonly = this.options.readonly || false;
34
42
  const required = this.field.required;
35
43
  return inputWrapper(
36
44
  this.type,
37
- this.getWrapperClasses(fctx.ctx, fctx.data, parsed),
45
+ this.getWrapperClasses(fctx.ctx, fctx.data.raw_values, parsed),
38
46
  /* HTML */
39
47
  `
40
48
  <input
@@ -43,7 +51,7 @@ class Tickable extends FormFieldControl {
43
51
  name="${fctx.field_name_prefix}${this.options.name || this.field.name}"
44
52
  ${value ? `value="${attribute(value)}"` : ""}
45
53
  ${fctx.form_id ? `form="${fctx.form_id}"` : ""}
46
- ${this.isChecked(fctx.ctx, fctx.data, parsed) ? "checked" : ""}
54
+ ${this.isChecked(fctx.ctx, fctx.data.raw_values, parsed) ? "checked" : ""}
47
55
  ${readonly ? "readonly" : ""}
48
56
  ${required ? "required" : ""}
49
57
  autocomplete="off"
@@ -1,4 +1,5 @@
1
1
  import { is, predicates } from "@sealcode/ts-predicates";
2
+ import { Checkbox } from "../controls/checkbox.js";
2
3
  import { FormField } from "./field.js";
3
4
  const truthy = ["true", "on", "yes", "1"];
4
5
  const falsy = ["false", "off", "no", "0"];
@@ -42,6 +43,19 @@ class Boolean extends FormField {
42
43
  getEmptyValue() {
43
44
  return false;
44
45
  }
46
+ getControl() {
47
+ return new Checkbox(this, { label: this.name });
48
+ }
49
+ async getSealiousCreateValue(fctx) {
50
+ const { parsed } = await this.getParsedValue(
51
+ fctx.ctx,
52
+ fctx.data.raw_values
53
+ );
54
+ return !!parsed;
55
+ }
56
+ async sealiousValueToForm(_, value) {
57
+ return value ? "true" : "false";
58
+ }
45
59
  }
46
60
  export {
47
61
  Boolean
@@ -1,4 +1,5 @@
1
1
  import { is, predicates } from "@sealcode/ts-predicates";
2
+ import { CheckboxedListInput } from "../controls/checkboxed-list-input.js";
2
3
  import {
3
4
  FormField
4
5
  } from "./field.js";
@@ -42,6 +43,9 @@ class CheckboxedListField extends FormField {
42
43
  getEmptyValue() {
43
44
  return {};
44
45
  }
46
+ getControl() {
47
+ return new CheckboxedListInput(this, { label: this.name });
48
+ }
45
49
  }
46
50
  export {
47
51
  CheckboxedListField
@@ -1,4 +1,5 @@
1
1
  import { predicates } from "@sealcode/ts-predicates";
2
+ import { SimpleInput } from "../controls/controls.js";
2
3
  import {
3
4
  FormField
4
5
  } from "./field.js";
@@ -40,6 +41,14 @@ class CollectionField extends FormField {
40
41
  getEmptyValue() {
41
42
  return "";
42
43
  }
44
+ getControl() {
45
+ return new SimpleInput(this);
46
+ }
47
+ generateFieldDeclaration(field_info, vars) {
48
+ return `new ${vars.form_field_types}.${this.constructor.name}(${String(
49
+ field_info.is_required
50
+ )}, ${vars.sealious_field})`;
51
+ }
43
52
  }
44
53
  export {
45
54
  CollectionField
@@ -0,0 +1,10 @@
1
+ import { TextBasedSimpleField } from "./simple-form-field.js";
2
+ class Color extends TextBasedSimpleField {
3
+ constructor(required) {
4
+ super(required, "color");
5
+ }
6
+ }
7
+ export {
8
+ Color
9
+ };
10
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1,49 @@
1
+ import { SimpleInput } from "../controls/simple-input.js";
2
+ import { SimpleFormField } from "./simple-form-field.js";
3
+ class Coordinates extends SimpleFormField {
4
+ async parse(_, raw_value) {
5
+ if (typeof raw_value == "string") {
6
+ return {
7
+ parsed_value: raw_value?.split(",").map((e) => parseFloat(e)),
8
+ parsable: true,
9
+ error: null
10
+ };
11
+ }
12
+ if (Array.isArray(raw_value)) {
13
+ return {
14
+ parsed_value: raw_value.map((e) => parseFloat(e)),
15
+ parsable: true,
16
+ error: null
17
+ };
18
+ }
19
+ return {
20
+ parsed_value: null,
21
+ parsable: false,
22
+ error: "should be an array or string"
23
+ };
24
+ }
25
+ async getSealiousCreateValue(fctx) {
26
+ const { parsed } = await this.getParsedValue(
27
+ fctx.ctx,
28
+ fctx.data.raw_values
29
+ );
30
+ return parsed || void 0;
31
+ }
32
+ async postSealiousCreate() {
33
+ }
34
+ async postSealiousEdit() {
35
+ }
36
+ getControl() {
37
+ return new SimpleInput(this, {
38
+ label: this.name,
39
+ type: this.type
40
+ });
41
+ }
42
+ getEmptyValue() {
43
+ return [0, 0];
44
+ }
45
+ }
46
+ export {
47
+ Coordinates
48
+ };
49
+ //# sourceMappingURL=coordinates.js.map
@@ -0,0 +1,34 @@
1
+ import { SimpleInput } from "../controls/simple-input.js";
2
+ import { SimpleFormField } from "./simple-form-field.js";
3
+ class DateField extends SimpleFormField {
4
+ constructor(required) {
5
+ super(required, "date");
6
+ }
7
+ getEmptyValue() {
8
+ return /* @__PURE__ */ new Date("1970-01-01 00:00");
9
+ }
10
+ async parse(ctx, raw_value) {
11
+ return {
12
+ error: null,
13
+ parsable: true,
14
+ parsed_value: new Date(raw_value)
15
+ };
16
+ }
17
+ getControl() {
18
+ return new SimpleInput(this, { label: this.name, type: this.type });
19
+ }
20
+ async getSealiousCreateValue(fctx) {
21
+ const { parsed } = await this.getParsedValue(
22
+ fctx.ctx,
23
+ fctx.data.raw_values
24
+ );
25
+ if (!parsed) {
26
+ return null;
27
+ }
28
+ return `${parsed.getFullYear()}-${(parsed.getMonth() + 1).toString().padStart(2, "0")}-${parsed.getDate().toString().padStart(2, "0")}`;
29
+ }
30
+ }
31
+ export {
32
+ DateField
33
+ };
34
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1,46 @@
1
+ import { SimpleInput } from "../controls/controls.js";
2
+ import { SimpleFormField } from "./simple-form-field.js";
3
+ function pad(n) {
4
+ return String(n).padStart(2, "0");
5
+ }
6
+ class DateTime extends SimpleFormField {
7
+ constructor(required) {
8
+ super(required, "datetime-local");
9
+ }
10
+ getEmptyValue() {
11
+ return null;
12
+ }
13
+ async parse(ctx, raw_value) {
14
+ const parsed_value = new Date(raw_value);
15
+ return { parsable: true, error: null, parsed_value };
16
+ }
17
+ async getSealiousCreateValue(fctx) {
18
+ const { parsed } = await this.getParsedValue(
19
+ fctx.ctx,
20
+ fctx.data.raw_values
21
+ );
22
+ if (parsed == null) {
23
+ return null;
24
+ }
25
+ return new Date(parsed).getTime();
26
+ }
27
+ getControl() {
28
+ return new SimpleInput(this, {
29
+ label: this.name,
30
+ type: this.type
31
+ });
32
+ }
33
+ async sealiousValueToForm(ctx, value) {
34
+ if (value == null) {
35
+ return "";
36
+ }
37
+ const d = new Date(value);
38
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(
39
+ d.getDate()
40
+ )}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
41
+ }
42
+ }
43
+ export {
44
+ DateTime
45
+ };
46
+ //# sourceMappingURL=datetime.js.map
@@ -0,0 +1,81 @@
1
+ import { CheckboxedListField } from "./checkboxed-list.js";
2
+ import { wrapKeyName } from "../../utils/wrap-attributes.js";
3
+ class DeepReverseSingleReferenceList extends CheckboxedListField {
4
+ constructor(sealious_field) {
5
+ super(false, async (ctx) => {
6
+ const { items } = await ctx.$app.collections[sealious_field.target_collection].list(ctx.$context).fetch();
7
+ return items.map((s) => ({
8
+ label: this.item_label_getter(s),
9
+ value: s.id
10
+ }));
11
+ });
12
+ this.sealious_field = sealious_field;
13
+ this.item_label_getter = (item) => item.get("name");
14
+ }
15
+ setItemLabelGetter(getter) {
16
+ this.item_label_getter = getter;
17
+ }
18
+ getSealiousCreateValue() {
19
+ throw new Error(
20
+ "This field is not set directly through field value, but instead relies on postSealiousCreate and postSealiousEdit"
21
+ );
22
+ }
23
+ async postSealiousCreate(ctx, created_item, form_data) {
24
+ const { items: existing_links } = await ctx.$app.collections[this.sealious_field.intermediary_collection].list(ctx.$context).filter({
25
+ [this.sealious_field.referencing_field]: created_item.id
26
+ }).fetch();
27
+ const { parsed: value } = await this.getParsedValue(
28
+ ctx,
29
+ form_data.raw_values,
30
+ false
31
+ );
32
+ const should_exist_ids = Object.entries(value || {}).filter(([, value2]) => value2 === "on").map(([key]) => key);
33
+ const to_delete = existing_links.filter(
34
+ (link) => !should_exist_ids.includes(
35
+ link.get(
36
+ this.sealious_field.intermediary_field_that_points_there
37
+ )
38
+ )
39
+ );
40
+ const to_create_ids = should_exist_ids.filter(
41
+ (id) => !existing_links.map(
42
+ (link) => (
43
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
44
+ link.get(
45
+ this.sealious_field.intermediary_field_that_points_there
46
+ )
47
+ )
48
+ ).includes(id)
49
+ );
50
+ await Promise.all(
51
+ to_delete.map((item) => {
52
+ return item.remove(ctx.$context);
53
+ })
54
+ );
55
+ const promises = to_create_ids.map(async (id) => {
56
+ await this.sealious_field.getReferencingCollection().create(ctx.$context, {
57
+ [this.sealious_field.referencing_field]: created_item.id,
58
+ [this.sealious_field.intermediary_field_that_points_there]: id
59
+ });
60
+ });
61
+ await Promise.all(promises);
62
+ }
63
+ async postSealiousEdit(ctx, edited_item, value) {
64
+ return this.postSealiousCreate(ctx, edited_item, value);
65
+ }
66
+ async sealiousValueToForm(_ctx, value) {
67
+ return Object.fromEntries((value || []).map((id) => [id, "on"]));
68
+ }
69
+ generateFieldDeclaration(_field_info, vars) {
70
+ return `new ${vars.form_field_types}.${this.constructor.name}(${vars.sealious_field})`;
71
+ }
72
+ generateCreateValueGetter(field_info) {
73
+ return `${wrapKeyName(
74
+ field_info.name
75
+ )}: undefined /* handled below in postSealiousCreate */`;
76
+ }
77
+ }
78
+ export {
79
+ DeepReverseSingleReferenceList
80
+ };
81
+ //# sourceMappingURL=deep-reverse-single-reference-list.js.map
@@ -0,0 +1,122 @@
1
+ import {
2
+ FieldTypes as SealiousFieldTypes
3
+ } from "sealious";
4
+ import { Boolean, TextBasedSimpleField } from "./fields.js";
5
+ import { sealiousToFormField } from "./get-field-for-sealious.js";
6
+ import { Table } from "./table.js";
7
+ import { Table as TableControl } from "../controls/table.js";
8
+ import { HiddenInput } from "../controls/hidden-input.js";
9
+ function getReferencingFields(sealious_field) {
10
+ const referencing_collection = sealious_field.collection.app.collections[sealious_field.referencing_collection];
11
+ if (!referencing_collection) {
12
+ throw new Error(
13
+ "Unknown collection: " + sealious_field.referencing_collection
14
+ );
15
+ }
16
+ return referencing_collection.fields;
17
+ }
18
+ class DeepReverseSingleReferenceTable extends Table {
19
+ constructor(sealious_field) {
20
+ super({
21
+ selected: new Boolean(false),
22
+ [sealious_field.referencing_field]: new TextBasedSimpleField(true),
23
+ [sealious_field.intermediary_field_that_points_there]: new TextBasedSimpleField(true),
24
+ ...Object.fromEntries(
25
+ Object.values(getReferencingFields(sealious_field)).filter(
26
+ (field) => !(field instanceof SealiousFieldTypes.SingleReference)
27
+ ).map((field) => [field.name, sealiousToFormField(field)])
28
+ )
29
+ });
30
+ this.sealious_field = sealious_field;
31
+ }
32
+ getControl() {
33
+ return new TableControl(this, {
34
+ label: this.name,
35
+ allow_adding: false,
36
+ subfield_controls: {
37
+ selected: this.columns.selected.getControl(),
38
+ [this.sealious_field.referencing_field]: new HiddenInput(
39
+ this.columns[this.sealious_field.referencing_field]
40
+ ),
41
+ [this.sealious_field.intermediary_field_that_points_there]: new HiddenInput(
42
+ this.columns[this.sealious_field.intermediary_field_that_points_there]
43
+ ),
44
+ ...Object.fromEntries(
45
+ Object.values(getReferencingFields(this.sealious_field)).filter(
46
+ (field) => !(field instanceof SealiousFieldTypes.SingleReference)
47
+ ).map((field) => [
48
+ field.name,
49
+ this.columns[field.name].getControl()
50
+ ])
51
+ )
52
+ }
53
+ });
54
+ }
55
+ getSealiousCreateValue(_fctx) {
56
+ throw new Error("Method not implemented.");
57
+ }
58
+ async postSealiousCreate(ctx, created_item, form_data) {
59
+ const { items: to_delete } = await ctx.$app.collections["${toKebabCase(referencing_collection)}"].list(ctx.$context).filter({ "${referencing_field}": created_item.id }).fetch();
60
+ await Promise.all(to_delete.map((item) => item.remove(ctx.$context)));
61
+ const referencing_fields = getReferencingFields(this.sealious_field);
62
+ const { parsed: value } = await this.getParsedValue(
63
+ ctx,
64
+ form_data.raw_values,
65
+ false
66
+ );
67
+ const promises = (value || []).filter((s) => s.selected == true).map(async (link_info) => {
68
+ await ctx.$app.collections["${toKebabCase(referencing_collection)}"].create(ctx.$context, {
69
+ "${referencing_field}": created_item.id,
70
+ "${intermediary_field_that_points_there}": String(
71
+ link_info["${intermediary_field_that_points_there}"]
72
+ ),
73
+ ...Object.fromEntries(
74
+ Object.values(referencing_fields).filter(
75
+ (field) => !(field instanceof SealiousFieldTypes.SingleReference)
76
+ ).map((field) => [field.name, link_info[field.name]])
77
+ )
78
+ });
79
+ });
80
+ await Promise.all(promises);
81
+ }
82
+ postSealiousEdit(ctx, edited_item, form_data) {
83
+ return this.postSealiousCreate(ctx, edited_item, form_data);
84
+ }
85
+ async sealiousValueToForm(ctx, _value, item) {
86
+ const referencing_fields = getReferencingFields(this.sealious_field);
87
+ return Object.fromEntries(
88
+ await Promise.all([
89
+ this.sealious_field.collection.list(ctx.$context).fetch(),
90
+ this.sealious_field.getReferencingCollection().list(ctx.$context).fetch()
91
+ ]).then(
92
+ ([{ items: targets }, { items: links }]) => targets.map((target) => {
93
+ return {
94
+ selected: (item.get(
95
+ this.sealious_field.name
96
+ ) || []).includes(target.id) ? "on" : "off",
97
+ [this.sealious_field.referencing_field]: item.id,
98
+ [this.sealious_field.intermediary_field_that_points_there]: target.id,
99
+ ...Object.fromEntries(
100
+ Object.values(referencing_fields).filter(
101
+ (field) => !(field instanceof SealiousFieldTypes.SingleReference)
102
+ ).map((field) => [
103
+ field.name,
104
+ links.find(
105
+ (e) => e.get(
106
+ this.sealious_field.intermediary_field_that_points_there
107
+ ) == target.id && e.get(
108
+ this.sealious_field.referencing_field
109
+ ) == item.id
110
+ )?.get("rank") || 0
111
+ ])
112
+ )
113
+ };
114
+ }).entries()
115
+ )
116
+ );
117
+ }
118
+ }
119
+ export {
120
+ DeepReverseSingleReferenceTable
121
+ };
122
+ //# sourceMappingURL=deep-reverse-single-reference-table.js.map
@@ -1,5 +1,6 @@
1
1
  import { predicates } from "@sealcode/ts-predicates";
2
2
  import { RegExpField } from "./regexp.js";
3
+ import { SimpleInput } from "../controls/controls.js";
3
4
  class EmailField extends RegExpField {
4
5
  constructor(required, error_message = "Please enter a proper email address", default_value = "") {
5
6
  super(
@@ -12,6 +13,12 @@ class EmailField extends RegExpField {
12
13
  this.default_value = default_value;
13
14
  this.predicate = predicates.string;
14
15
  }
16
+ setErrorMessage(message) {
17
+ this.error_message = message;
18
+ }
19
+ getControl() {
20
+ return new SimpleInput(this, { label: this.name, type: "email" });
21
+ }
15
22
  }
16
23
  export {
17
24
  EmailField
@@ -0,0 +1,32 @@
1
+ import { CheckboxedListField } from "./checkboxed-list.js";
2
+ class EnumMultipleSealious extends CheckboxedListField {
3
+ constructor(sealious_field) {
4
+ super(
5
+ sealious_field.required,
6
+ async (ctx) => (await sealious_field.getAllowedValues(ctx.$context)).map(
7
+ (value) => ({ value, label: value })
8
+ )
9
+ );
10
+ this.sealious_field = sealious_field;
11
+ }
12
+ generateFieldDeclaration(field_info, vars) {
13
+ return `new ${vars.form_field_types}.${this.constructor.name}(${vars.sealious_field})`;
14
+ }
15
+ async getSealiousCreateValue(fctx) {
16
+ const { parsed } = await this.getParsedValue(
17
+ fctx.ctx,
18
+ fctx.data.raw_values
19
+ );
20
+ const result = Object.entries(parsed || {}).filter(([, value]) => value == "on").map(([key]) => key);
21
+ return result;
22
+ }
23
+ async sealiousValueToForm(ctx, sealious_value) {
24
+ return Object.fromEntries(
25
+ (sealious_value || []).map((key) => [key, "on"])
26
+ );
27
+ }
28
+ }
29
+ export {
30
+ EnumMultipleSealious
31
+ };
32
+ //# sourceMappingURL=enum-multiple-sealious.js.map