@sealcode/sealgen 0.18.10 → 0.19.0

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 (378) hide show
  1. package/.eslintrc.cjs +7 -2
  2. package/.xunit +74 -69
  3. package/@types/add-crud.d.sync-conflict-20250918-184311-TFDLWFG.ts +1 -0
  4. package/@types/builders/colors-builder.d.sync-conflict-20250918-184323-TFDLWFG.ts +10 -0
  5. package/@types/builders/colors-builder.d.ts +1 -1
  6. package/@types/builders/fonts-builder.d.sync-conflict-20250918-184322-TFDLWFG.ts +7 -0
  7. package/@types/builders/fonts-builder.d.ts +1 -1
  8. package/@types/controllers/table-add-button.d.ts +6 -0
  9. package/@types/controllers/table-add-button.stimulus.d.ts +6 -0
  10. package/@types/crud-field-snippets.d.sync-conflict-20250918-184323-TFDLWFG.ts +1 -0
  11. package/@types/crud-field-snippets.d.ts +1 -3
  12. package/@types/forms/controls/array.d.sync-conflict-20250918-184306-TFDLWFG.ts +33 -0
  13. package/@types/forms/controls/array.d.ts +1 -3
  14. package/@types/forms/controls/array.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
  15. package/@types/forms/controls/autocomplete.d.sync-conflict-20250918-222042-TFDLWFG.ts +22 -0
  16. package/@types/forms/controls/autocomplete.d.ts +1 -1
  17. package/@types/forms/controls/checkbox-group.d.sync-conflict-20250918-184319-TFDLWFG.ts +21 -0
  18. package/@types/forms/controls/checkbox-group.d.ts +3 -3
  19. package/@types/forms/controls/checkboxed-list-input.d.sync-conflict-20250918-184323-TFDLWFG.ts +21 -0
  20. package/@types/forms/controls/checkboxed-list-input.d.ts +3 -3
  21. package/@types/forms/controls/controls.d.ts +2 -2
  22. package/@types/forms/controls/derived-frame.d.sync-conflict-20250918-184314-TFDLWFG.ts +19 -0
  23. package/@types/forms/controls/derived-frame.d.ts +0 -2
  24. package/@types/forms/controls/dropdown.d.sync-conflict-20250918-222044-TFDLWFG.ts +30 -0
  25. package/@types/forms/controls/dropdown.d.ts +1 -1
  26. package/@types/forms/controls/file.d.sync-conflict-20250918-222045-TFDLWFG.ts +13 -0
  27. package/@types/forms/controls/file.d.ts +1 -2
  28. package/@types/forms/controls/form-control.d.sync-conflict-20250918-184322-TFDLWFG.ts +19 -0
  29. package/@types/forms/controls/form-control.d.sync-conflict-20250918-222046-TFDLWFG.ts +19 -0
  30. package/@types/forms/controls/form-control.d.ts +7 -4
  31. package/@types/forms/controls/image.d.ts +19 -0
  32. package/@types/forms/controls/image.test.d.ts +1 -0
  33. package/@types/forms/controls/multiple-files.d.sync-conflict-20250918-184318-TFDLWFG.ts +42 -0
  34. package/@types/forms/controls/multiple-files.d.ts +3 -1
  35. package/@types/forms/controls/multiple-images.d.ts +19 -0
  36. package/@types/forms/controls/number.d.sync-conflict-20250918-222046-TFDLWFG.ts +13 -0
  37. package/@types/forms/controls/number.d.ts +1 -1
  38. package/@types/forms/controls/photo.d.sync-conflict-20250918-184321-TFDLWFG.ts +19 -0
  39. package/@types/forms/controls/photo.d.ts +3 -5
  40. package/@types/forms/controls/simple-input.d.sync-conflict-20250918-184310-TFDLWFG.ts +33 -0
  41. package/@types/forms/controls/simple-input.d.sync-conflict-20250918-222042-TFDLWFG.ts +33 -0
  42. package/@types/forms/controls/simple-input.d.ts +5 -4
  43. package/@types/forms/controls/simple-input.sync-conflict-20250918-222045-TFDLWFG.d.ts +33 -0
  44. package/@types/forms/controls/single-reference.d.ts +3 -2
  45. package/@types/forms/controls/table.d.sync-conflict-20250918-184302-TFDLWFG.ts +39 -0
  46. package/@types/forms/controls/table.d.ts +8 -3
  47. package/@types/forms/controls/table.sync-conflict-20250918-222042-TFDLWFG.d.ts +39 -0
  48. package/@types/forms/controls/textarea.d.sync-conflict-20250918-222045-TFDLWFG.ts +25 -0
  49. package/@types/forms/controls/textarea.d.ts +3 -3
  50. package/@types/forms/fields/boolean.d.sync-conflict-20250918-184325-TFDLWFG.ts +22 -0
  51. package/@types/forms/fields/boolean.d.ts +6 -1
  52. package/@types/forms/fields/boolean.sync-conflict-20250918-222042-TFDLWFG.d.ts +22 -0
  53. package/@types/forms/fields/checkboxed-list.d.sync-conflict-20250918-184325-TFDLWFG.ts +23 -0
  54. package/@types/forms/fields/checkboxed-list.d.ts +3 -1
  55. package/@types/forms/fields/collection-field.d.sync-conflict-20250918-184319-TFDLWFG.ts +22 -0
  56. package/@types/forms/fields/collection-field.d.sync-conflict-20250918-222047-TFDLWFG.ts +22 -0
  57. package/@types/forms/fields/collection-field.d.ts +8 -1
  58. package/@types/forms/fields/color.d.ts +4 -0
  59. package/@types/forms/fields/coordinates.d.sync-conflict-20250918-222044-TFDLWFG.ts +14 -0
  60. package/@types/forms/fields/coordinates.d.ts +14 -0
  61. package/@types/forms/fields/date.d.ts +13 -0
  62. package/@types/forms/fields/datetime.d.sync-conflict-20250918-222050-TFDLWFG.ts +4 -0
  63. package/@types/forms/fields/datetime.d.ts +14 -0
  64. package/@types/forms/fields/deep-reverse-single-reference-list.d.ts +24 -0
  65. package/@types/forms/fields/deep-reverse-single-reference-table.d.ts +16 -0
  66. package/@types/forms/fields/email.d.sync-conflict-20250918-184303-TFDLWFG.ts +8 -0
  67. package/@types/forms/fields/email.d.ts +3 -0
  68. package/@types/forms/fields/enum-multiple-sealious.d.ts +16 -0
  69. package/@types/forms/fields/enum-multiple-sealious.sync-conflict-20250918-222047-TFDLWFG.d.ts +16 -0
  70. package/@types/forms/fields/field.d.sync-conflict-20250918-184306-TFDLWFG.ts +70 -0
  71. package/@types/forms/fields/field.d.ts +37 -5
  72. package/@types/forms/fields/fields.d.sync-conflict-20250918-184314-TFDLWFG.ts +29 -0
  73. package/@types/forms/fields/fields.d.ts +23 -8
  74. package/@types/forms/fields/file.d.sync-conflict-20250918-184310-TFDLWFG.ts +23 -0
  75. package/@types/forms/fields/file.d.sync-conflict-20250918-222046-TFDLWFG.ts +23 -0
  76. package/@types/forms/fields/file.d.ts +11 -5
  77. package/@types/forms/fields/file.sync-conflict-20250918-222049-TFDLWFG.d.ts +23 -0
  78. package/@types/forms/fields/float.d.ts +4 -0
  79. package/@types/forms/fields/get-field-for-sealious.d.sync-conflict-20250918-222046-TFDLWFG.ts +29 -0
  80. package/@types/forms/fields/get-field-for-sealious.d.ts +31 -0
  81. package/@types/forms/fields/get-field-for-sealious.sync-conflict-20250918-222042-TFDLWFG.d.ts +29 -0
  82. package/@types/forms/fields/html.d.ts +6 -0
  83. package/@types/forms/fields/image.d.sync-conflict-20250918-222042-TFDLWFG.ts +5 -0
  84. package/@types/forms/fields/image.d.ts +5 -0
  85. package/@types/forms/fields/int.d.ts +6 -0
  86. package/@types/forms/fields/json.d.ts +13 -0
  87. package/@types/forms/fields/markdown.d.ts +6 -0
  88. package/@types/forms/fields/multiple-files.d.sync-conflict-20250918-184304-TFDLWFG.ts +16 -0
  89. package/@types/forms/fields/multiple-files.d.ts +3 -1
  90. package/@types/forms/fields/number.d.sync-conflict-20250918-184317-TFDLWFG.ts +25 -0
  91. package/@types/forms/fields/number.d.sync-conflict-20250918-222047-TFDLWFG.ts +25 -0
  92. package/@types/forms/fields/number.d.ts +3 -1
  93. package/@types/forms/fields/password.d.ts +6 -0
  94. package/@types/forms/fields/pick-from-list-sealious.d.ts +11 -0
  95. package/@types/forms/fields/pick-from-list.d.sync-conflict-20250918-184322-TFDLWFG.ts +15 -0
  96. package/@types/forms/fields/pick-from-list.d.ts +4 -3
  97. package/@types/forms/fields/proxy-field.d.sync-conflict-20250918-184307-TFDLWFG.ts +15 -0
  98. package/@types/forms/fields/proxy-field.d.ts +3 -1
  99. package/@types/forms/fields/regexp.d.sync-conflict-20250918-184305-TFDLWFG.ts +21 -0
  100. package/@types/forms/fields/regexp.d.sync-conflict-20250918-222045-TFDLWFG.ts +21 -0
  101. package/@types/forms/fields/regexp.d.ts +6 -1
  102. package/@types/forms/fields/regexp.sync-conflict-20250918-222047-TFDLWFG.d.ts +21 -0
  103. package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-184309-TFDLWFG.ts +29 -0
  104. package/@types/forms/fields/simple-form-field.d.sync-conflict-20250918-222044-TFDLWFG.ts +29 -0
  105. package/@types/forms/fields/simple-form-field.d.ts +23 -3
  106. package/@types/forms/fields/simple-form-field.sync-conflict-20250918-222049-TFDLWFG.d.ts +29 -0
  107. package/@types/forms/fields/single-reference.d.ts +19 -0
  108. package/@types/forms/fields/single-reference.sync-conflict-20250918-222043-TFDLWFG.d.ts +10 -0
  109. package/@types/forms/fields/structured-array.d.sync-conflict-20250918-184302-TFDLWFG.ts +27 -0
  110. package/@types/forms/fields/structured-array.d.sync-conflict-20250918-222049-TFDLWFG.ts +27 -0
  111. package/@types/forms/fields/structured-array.d.ts +19 -10
  112. package/@types/forms/fields/structured-array.sync-conflict-20250918-222047-TFDLWFG.d.ts +27 -0
  113. package/@types/forms/fields/table.d.sync-conflict-20250918-184303-TFDLWFG.ts +16 -0
  114. package/@types/forms/fields/table.d.ts +3 -0
  115. package/@types/forms/fields/text.d.ts +6 -0
  116. package/@types/forms/fields/url.d.ts +6 -0
  117. package/@types/forms/form-types.d.sync-conflict-20250918-222045-TFDLWFG.ts +26 -0
  118. package/@types/forms/form-types.d.ts +2 -0
  119. package/@types/forms/form.d.sync-conflict-20250918-184315-TFDLWFG.ts +32 -0
  120. package/@types/forms/form.d.sync-conflict-20250918-222049-TFDLWFG.ts +32 -0
  121. package/@types/forms/form.d.ts +10 -8
  122. package/@types/forms/form.sync-conflict-20250918-222049-TFDLWFG.d.ts +33 -0
  123. package/@types/forms/form.test.d.sync-conflict-20250918-184318-TFDLWFG.ts +6 -0
  124. package/@types/forms/form.test.d.sync-conflict-20250918-222047-TFDLWFG.ts +6 -0
  125. package/@types/forms/form.test.d.ts +2 -2
  126. package/@types/forms/multiform.d.sync-conflict-20250918-184308-TFDLWFG.ts +23 -0
  127. package/@types/forms/multiform.d.ts +1 -2
  128. package/@types/forms/multiform.sync-conflict-20250918-222044-TFDLWFG.d.ts +23 -0
  129. package/@types/index.d.sync-conflict-20250918-184316-TFDLWFG.ts +46 -0
  130. package/@types/index.d.ts +2 -2
  131. package/@types/mount.d.sync-conflict-20250918-184320-TFDLWFG.ts +6 -0
  132. package/@types/mount.d.ts +0 -1
  133. package/@types/page/list.d.sync-conflict-20250918-184318-TFDLWFG.ts +48 -0
  134. package/@types/page/list.d.sync-conflict-20250918-222046-TFDLWFG.ts +48 -0
  135. package/@types/page/list.d.ts +2 -2
  136. package/@types/page/list.sync-conflict-20250918-222048-TFDLWFG.d.ts +48 -0
  137. package/@types/page/mountable-with-fields.d.sync-conflict-20250918-184321-TFDLWFG.ts +42 -0
  138. package/@types/page/mountable-with-fields.d.sync-conflict-20250918-222046-TFDLWFG.ts +42 -0
  139. package/@types/page/mountable-with-fields.d.ts +3 -3
  140. package/@types/page/mountable-with-fields.sync-conflict-20250918-222044-TFDLWFG.d.ts +42 -0
  141. package/@types/page/mountable.d.sync-conflict-20250918-184306-TFDLWFG.ts +10 -0
  142. package/@types/page/mountable.d.ts +0 -1
  143. package/@types/page/page.d.sync-conflict-20250918-184320-TFDLWFG.ts +18 -0
  144. package/@types/page/page.d.ts +0 -1
  145. package/@types/page/props-parser.d.sync-conflict-20250918-184305-TFDLWFG.ts +15 -0
  146. package/@types/page/props-parser.d.ts +0 -1
  147. package/@types/page/stateful-page.d.sync-conflict-20250918-184326-TFDLWFG.ts +62 -0
  148. package/@types/page/stateful-page.d.ts +0 -1
  149. package/@types/templates/shared/shared-crud-form-fields.d.sync-conflict-20250918-184306-TFDLWFG.ts +1 -0
  150. package/@types/templates/shared/shared-crud-form-fields.d.ts +0 -67
  151. package/@types/test_utils/test-on-real-app.d.sync-conflict-20250918-184320-TFDLWFG.ts +26 -0
  152. package/@types/test_utils/test-on-real-app.d.ts +0 -1
  153. package/@types/utils/extract-fields-from-collection.d.sync-conflict-20250918-184312-TFDLWFG.ts +18 -0
  154. package/@types/utils/extract-fields-from-collection.d.ts +5 -1
  155. package/@types/utils/extract-fields-from-collection.sync-conflict-20250918-222045-TFDLWFG.d.ts +18 -0
  156. package/@types/utils/wrap-attributes.d.ts +3 -0
  157. package/README.md +5 -0
  158. package/assets/file-icon.svg +5 -0
  159. package/lib/add-crud.js +80 -89
  160. package/lib/add-list-route.test.js +1 -1
  161. package/lib/add-route.js +0 -7
  162. package/lib/build.js +3 -1
  163. package/lib/cli.js +2 -5
  164. package/lib/controllers/table-add-button.stimulus.js +35 -0
  165. package/lib/forms/controls/array.js +20 -16
  166. package/lib/forms/controls/big-radio-group.js +2 -2
  167. package/lib/forms/controls/checkbox-group.js +7 -7
  168. package/lib/forms/controls/checkboxed-list-input.js +9 -2
  169. package/lib/forms/controls/controls.js +2 -2
  170. package/lib/forms/controls/derived-frame.js +5 -1
  171. package/lib/forms/controls/derived.js +1 -1
  172. package/lib/forms/controls/dropdown.js +4 -1
  173. package/lib/forms/controls/editable-collection-subset.js +2 -2
  174. package/lib/forms/controls/file.js +26 -2
  175. package/lib/forms/controls/file.test.js +2 -2
  176. package/lib/forms/controls/hidden-input.js +4 -1
  177. package/lib/forms/controls/{photo.js → image.js} +6 -7
  178. package/lib/forms/controls/{photo.test.js → image.test.js} +6 -21
  179. package/lib/forms/controls/multiple-files.js +10 -1
  180. package/lib/forms/controls/{multiple-photos.js → multiple-images.js} +3 -3
  181. package/lib/forms/controls/simple-input.js +13 -12
  182. package/lib/forms/controls/single-reference.js +4 -0
  183. package/lib/forms/controls/table.js +66 -24
  184. package/lib/forms/controls/textarea.js +4 -2
  185. package/lib/forms/controls/tickable.js +13 -5
  186. package/lib/forms/fields/boolean.js +14 -0
  187. package/lib/forms/fields/checkboxed-list.js +4 -0
  188. package/lib/forms/fields/collection-field.js +9 -0
  189. package/lib/forms/fields/color.js +10 -0
  190. package/lib/forms/fields/coordinates.js +49 -0
  191. package/lib/forms/fields/date.js +34 -0
  192. package/lib/forms/fields/datetime.js +46 -0
  193. package/lib/forms/fields/deep-reverse-single-reference-list.js +81 -0
  194. package/lib/forms/fields/deep-reverse-single-reference-table.js +122 -0
  195. package/lib/forms/fields/email.js +7 -0
  196. package/lib/forms/fields/enum-multiple-sealious.js +32 -0
  197. package/lib/forms/fields/field.js +32 -4
  198. package/lib/forms/fields/field.test.js +5 -5
  199. package/lib/forms/fields/fields.js +23 -8
  200. package/lib/forms/fields/file.js +33 -9
  201. package/lib/forms/fields/file.test.js +4 -16
  202. package/lib/forms/fields/float.js +10 -0
  203. package/lib/forms/fields/get-field-for-sealious.js +213 -0
  204. package/lib/forms/fields/html.js +14 -0
  205. package/lib/forms/fields/image.js +13 -0
  206. package/lib/forms/fields/int.js +23 -0
  207. package/lib/forms/fields/json.js +31 -0
  208. package/lib/forms/fields/markdown.js +14 -0
  209. package/lib/forms/fields/multiple-files.js +4 -0
  210. package/lib/forms/fields/number.js +6 -0
  211. package/lib/forms/fields/password.js +13 -0
  212. package/lib/forms/fields/pick-from-list-sealious.js +17 -0
  213. package/lib/forms/fields/pick-from-list.js +6 -2
  214. package/lib/forms/fields/proxy-field.js +3 -0
  215. package/lib/forms/fields/regexp.js +14 -0
  216. package/lib/forms/fields/simple-form-field.js +60 -2
  217. package/lib/forms/fields/single-reference.js +44 -0
  218. package/lib/forms/fields/structured-array.js +63 -12
  219. package/lib/forms/fields/table.js +28 -1
  220. package/lib/forms/fields/text.js +17 -0
  221. package/lib/forms/fields/url.js +17 -0
  222. package/lib/forms/form.js +30 -13
  223. package/lib/forms/form.test.js +3 -4
  224. package/lib/forms/multiform.js +4 -2
  225. package/lib/forms/multiform.test.js +3 -3
  226. package/lib/generate-stimulus.js +1 -0
  227. package/lib/index.js +1 -0
  228. package/lib/make-hidden-inputs.js +1 -1
  229. package/lib/mount.js +11 -0
  230. package/lib/notifier.js +0 -1
  231. package/lib/page/list.js +15 -8
  232. package/lib/page/mountable-with-fields.js +14 -6
  233. package/lib/page/mountable-with-fields.test.js +1 -1
  234. package/lib/templates/form.js +8 -9
  235. package/lib/templates/multiform.js +4 -4
  236. package/lib/templates/page.js +0 -2
  237. package/lib/templates/shared/collection-create-form.js +28 -40
  238. package/lib/templates/shared/collection-edit-form.js +40 -77
  239. package/lib/templates/shared/collection-list.js +12 -20
  240. package/lib/templates/shared/shared-crud-form-fields.js +27 -95
  241. package/lib/test_utils/test-on-real-app.js +3 -3
  242. package/lib/utils/extract-fields-from-collection.js +60 -20
  243. package/lib/utils/make-slug.js +1 -1
  244. package/lib/utils/wrap-attributes.js +20 -0
  245. package/package.json +4 -3
  246. package/src/add-crud.ts +86 -97
  247. package/src/add-list-route.test.ts +1 -1
  248. package/src/add-route.ts +0 -7
  249. package/src/build.ts +3 -1
  250. package/src/cli.ts +3 -5
  251. package/src/controllers/table-add-button.stimulus.ts +35 -0
  252. package/src/forms/controls/array.ts +23 -20
  253. package/src/forms/controls/autocomplete.ts +1 -1
  254. package/src/forms/controls/big-radio-group.ts +2 -2
  255. package/src/forms/controls/checkbox-group.ts +9 -9
  256. package/src/forms/controls/checkboxed-list-input.ts +27 -15
  257. package/src/forms/controls/controls.ts +2 -2
  258. package/src/forms/controls/derived-frame.ts +5 -1
  259. package/src/forms/controls/derived.ts +1 -1
  260. package/src/forms/controls/dropdown.ts +5 -2
  261. package/src/forms/controls/editable-collection-subset.ts +2 -2
  262. package/src/forms/controls/file.test.ts +4 -2
  263. package/src/forms/controls/file.ts +31 -5
  264. package/src/forms/controls/form-control.ts +7 -2
  265. package/src/forms/controls/hidden-input.ts +4 -1
  266. package/src/forms/controls/{photo.test.ts → image.test.ts} +5 -22
  267. package/src/forms/controls/{photo.ts → image.ts} +3 -5
  268. package/src/forms/controls/multiple-files.ts +18 -1
  269. package/src/forms/controls/{multiple-photos.ts → multiple-images.ts} +1 -1
  270. package/src/forms/controls/number.ts +1 -1
  271. package/src/forms/controls/simple-input.ts +18 -34
  272. package/src/forms/controls/single-reference.ts +10 -2
  273. package/src/forms/controls/table.ts +90 -31
  274. package/src/forms/controls/textarea.ts +6 -4
  275. package/src/forms/controls/tickable.ts +13 -5
  276. package/src/forms/fields/boolean.ts +23 -1
  277. package/src/forms/fields/checkboxed-list.ts +11 -2
  278. package/src/forms/fields/collection-field.ts +16 -1
  279. package/src/forms/fields/color.ts +9 -0
  280. package/src/forms/fields/coordinates.ts +66 -0
  281. package/src/forms/fields/date.ts +50 -0
  282. package/src/forms/fields/datetime.ts +66 -0
  283. package/src/forms/fields/deep-reverse-single-reference-list.ts +136 -0
  284. package/src/forms/fields/deep-reverse-single-reference-table.ts +213 -0
  285. package/src/forms/fields/email.ts +9 -0
  286. package/src/forms/fields/enum-multiple-sealious.ts +48 -0
  287. package/src/forms/fields/field.test.ts +5 -5
  288. package/src/forms/fields/field.ts +94 -8
  289. package/src/forms/fields/fields.ts +23 -8
  290. package/src/forms/fields/file.test.ts +4 -16
  291. package/src/forms/fields/file.ts +43 -15
  292. package/src/forms/fields/float.ts +9 -0
  293. package/src/forms/fields/get-field-for-sealious.ts +304 -0
  294. package/src/forms/fields/html.ts +15 -0
  295. package/src/forms/fields/image.ts +12 -0
  296. package/src/forms/fields/int.ts +25 -0
  297. package/src/forms/fields/json.ts +48 -0
  298. package/src/forms/fields/markdown.ts +15 -0
  299. package/src/forms/fields/multiple-files.ts +10 -1
  300. package/src/forms/fields/number.ts +8 -1
  301. package/src/forms/fields/password.ts +17 -0
  302. package/src/forms/fields/pick-from-list-sealious.ts +22 -0
  303. package/src/forms/fields/pick-from-list.ts +7 -3
  304. package/src/forms/fields/proxy-field.ts +6 -1
  305. package/src/forms/fields/regexp.ts +27 -1
  306. package/src/forms/fields/simple-form-field.ts +95 -7
  307. package/src/forms/fields/single-reference.ts +62 -0
  308. package/src/forms/fields/structured-array.ts +115 -18
  309. package/src/forms/fields/table.ts +32 -1
  310. package/src/forms/fields/text.ts +18 -0
  311. package/src/forms/fields/url.ts +20 -0
  312. package/src/forms/form-types.ts +2 -0
  313. package/src/forms/form.test.ts +3 -4
  314. package/src/forms/form.ts +37 -16
  315. package/src/forms/forms.css +0 -85
  316. package/src/forms/multiform.test.ts +3 -3
  317. package/src/forms/multiform.ts +2 -0
  318. package/src/generate-stimulus.ts +1 -0
  319. package/src/index.ts +2 -1
  320. package/src/make-hidden-inputs.ts +1 -1
  321. package/src/mount.ts +14 -0
  322. package/src/notifier.ts +0 -1
  323. package/src/page/list.ts +15 -8
  324. package/src/page/mountable-with-fields.test.ts +1 -1
  325. package/src/page/mountable-with-fields.ts +18 -9
  326. package/src/register-external.ts +1 -1
  327. package/src/templates/form.ts +8 -9
  328. package/src/templates/multiform.ts +4 -4
  329. package/src/templates/page.ts +0 -2
  330. package/src/templates/shared/collection-create-form.ts +30 -66
  331. package/src/templates/shared/collection-edit-form.ts +41 -102
  332. package/src/templates/shared/collection-list.ts +12 -20
  333. package/src/templates/shared/item-delete.ts +0 -1
  334. package/src/templates/shared/shared-crud-form-fields.ts +37 -171
  335. package/src/test_utils/test-on-real-app.ts +4 -3
  336. package/src/utils/extract-fields-from-collection.ts +76 -25
  337. package/src/utils/make-slug.ts +1 -1
  338. package/src/utils/wrap-attributes.ts +17 -0
  339. package/lib/add-verbose-crud.js +0 -119
  340. package/lib/crud-field-snippets.js +0 -52
  341. package/lib/find-css-includes.js +0 -3
  342. package/lib/forms/controls/reverse-single-reference.js +0 -1
  343. package/lib/forms/fields/enum-multiple.js +0 -47
  344. package/lib/forms/fields/enum-multiple.test.js +0 -27
  345. package/lib/forms/fields/enum.js +0 -41
  346. package/lib/forms/fields/enum.test.js +0 -21
  347. package/lib/forms/fields/reverse-single-reference.js +0 -17
  348. package/lib/templates/shared/handlers/boolean.js +0 -14
  349. package/lib/templates/shared/handlers/date.js +0 -8
  350. package/lib/templates/shared/handlers/deep-reverse-single-reference.js +0 -209
  351. package/lib/templates/shared/handlers/default.js +0 -49
  352. package/lib/templates/shared/handlers/enum.js +0 -19
  353. package/lib/templates/shared/handlers/file.js +0 -23
  354. package/lib/templates/shared/handlers/image.js +0 -32
  355. package/lib/templates/shared/handlers/int.js +0 -11
  356. package/lib/templates/shared/handlers/jdd.js +0 -10
  357. package/lib/templates/shared/handlers/single-reference.js +0 -12
  358. package/lib/templates/shared/handlers/structured-array.js +0 -33
  359. package/src/add-verbose-crud.ts +0 -138
  360. package/src/crud-field-snippets.ts +0 -57
  361. package/src/find-css-includes.ts +0 -3
  362. package/src/forms/controls/reverse-single-reference.ts +0 -50
  363. package/src/forms/fields/enum-multiple.test.ts +0 -31
  364. package/src/forms/fields/enum-multiple.ts +0 -62
  365. package/src/forms/fields/enum.test.ts +0 -25
  366. package/src/forms/fields/enum.ts +0 -56
  367. package/src/forms/fields/reverse-single-reference.ts +0 -20
  368. package/src/templates/shared/handlers/boolean.ts +0 -18
  369. package/src/templates/shared/handlers/date.ts +0 -12
  370. package/src/templates/shared/handlers/deep-reverse-single-reference.ts +0 -244
  371. package/src/templates/shared/handlers/default.ts +0 -64
  372. package/src/templates/shared/handlers/enum.ts +0 -23
  373. package/src/templates/shared/handlers/file.ts +0 -27
  374. package/src/templates/shared/handlers/image.ts +0 -45
  375. package/src/templates/shared/handlers/int.ts +0 -15
  376. package/src/templates/shared/handlers/jdd.ts +0 -14
  377. package/src/templates/shared/handlers/single-reference.ts +0 -16
  378. package/src/templates/shared/handlers/structured-array.ts +0 -42
@@ -1,22 +1,21 @@
1
1
  import { tempstream } from "tempstream";
2
2
  import { File } from "./file.js";
3
- class Photo extends File {
4
- constructor(field, imageRouter, options) {
3
+ class Image extends File {
4
+ constructor(field, options) {
5
5
  super(field, options);
6
6
  this.field = field;
7
- this.imageRouter = imageRouter;
8
7
  }
9
8
  async getImgStyle() {
10
9
  return "width: 100px; height: 100px; object-fit: contain";
11
10
  }
12
- async renderFilePreview(_ctx, file) {
11
+ async renderFilePreview(ctx, file) {
13
12
  const class_name = "file_preview";
14
13
  const empty_container = `<div class="${class_name}"></div>`;
15
14
  if (!file) {
16
15
  return empty_container;
17
16
  }
18
17
  return tempstream`<div class="${class_name}">
19
- ${this.imageRouter.image(await file.getPath(), {
18
+ ${ctx.$app.imageRouter.image(await file.getPath(), {
20
19
  resolutions: [100, 200],
21
20
  sizesAttr: "100px",
22
21
  crop: { width: 100, height: 100 },
@@ -54,6 +53,6 @@ class Photo extends File {
54
53
  }
55
54
  }
56
55
  export {
57
- Photo
56
+ Image
58
57
  };
59
- //# sourceMappingURL=photo.js.map
58
+ //# sourceMappingURL=image.js.map
@@ -5,8 +5,7 @@ import { mount } from "../../mount.js";
5
5
  import { Form } from "../form.js";
6
6
  import { getBrowser } from "../../utils/browser-creator.js";
7
7
  import { Fields } from "../../index.js";
8
- import { Photo } from "./photo.js";
9
- import { KoaResponsiveImageRouter } from "koa-responsive-image-router";
8
+ import { Image } from "./image.js";
10
9
  import _locreq from "locreq";
11
10
  import { module_dirname } from "../../utils/module-dirname.js";
12
11
  import { FileManager, PathFilePointer } from "@sealcode/file-manager";
@@ -26,16 +25,9 @@ describe("photo-control", () => {
26
25
  const app = new Koa();
27
26
  const router = new Router();
28
27
  const fields = {
29
- photo: new Fields.File(false, new FileManager("/tmp", "/uploaded_files"))
28
+ photo: new Fields.File(false)
30
29
  };
31
30
  let received_photo;
32
- const imageRouter = new KoaResponsiveImageRouter({
33
- staticPath: "/images",
34
- thumbnailSize: 20,
35
- cacheManagerResolutionThreshold: 50,
36
- imageStoragePath: `/tmp/image-cache-${port}`,
37
- smartCropStoragePath: `/tmp/smartcrop-storage-${port}`
38
- });
39
31
  mount(
40
32
  router,
41
33
  "/",
@@ -43,7 +35,7 @@ describe("photo-control", () => {
43
35
  constructor() {
44
36
  super(...arguments);
45
37
  this.fields = fields;
46
- this.controls = [new Photo(fields.photo, imageRouter)];
38
+ this.controls = [new Image(fields.photo)];
47
39
  }
48
40
  async onSubmit(ctx) {
49
41
  const data = await this.getParsedValues(ctx);
@@ -80,16 +72,9 @@ describe("photo-control", () => {
80
72
  const app = new Koa();
81
73
  const router = new Router();
82
74
  const fields = {
83
- photo: new Fields.File(true, new FileManager("/tmp", "/uploaded_files"))
75
+ photo: new Fields.File(true)
84
76
  };
85
77
  let received_photo;
86
- const imageRouter = new KoaResponsiveImageRouter({
87
- staticPath: "/images",
88
- thumbnailSize: 20,
89
- cacheManagerResolutionThreshold: 50,
90
- imageStoragePath: `/tmp/image-cache-${port}`,
91
- smartCropStoragePath: `/tmp/smartcrop-storage-${port}`
92
- });
93
78
  let submit_called = false;
94
79
  mount(
95
80
  router,
@@ -98,7 +83,7 @@ describe("photo-control", () => {
98
83
  constructor() {
99
84
  super(...arguments);
100
85
  this.fields = fields;
101
- this.controls = [new Photo(fields.photo, imageRouter)];
86
+ this.controls = [new Image(fields.photo)];
102
87
  }
103
88
  async onSubmit(ctx) {
104
89
  submit_called = true;
@@ -132,4 +117,4 @@ describe("photo-control", () => {
132
117
  });
133
118
  }).timeout(1e4);
134
119
  });
135
- //# sourceMappingURL=photo.test.js.map
120
+ //# sourceMappingURL=image.test.js.map
@@ -107,7 +107,7 @@ class MultipleFiles extends FormFieldControl {
107
107
  if (!token) {
108
108
  return null;
109
109
  }
110
- return await item.collection.app.FileManager.fromToken(token);
110
+ return await item.collection.app.fileManager.fromToken(token);
111
111
  }
112
112
  async renderFileItemPreview(_fileItem, file) {
113
113
  return file.getOriginalFilename();
@@ -186,6 +186,15 @@ class MultipleFiles extends FormFieldControl {
186
186
  `
187
187
  );
188
188
  }
189
+ setLabel(label) {
190
+ this.options.label = label;
191
+ }
192
+ setUploadLabel(label) {
193
+ this.options.uploadLabel = label;
194
+ }
195
+ setAdditionalFieldsGetter(fn) {
196
+ this.options.getAdditionalFields = fn;
197
+ }
189
198
  }
190
199
  export {
191
200
  MultipleFiles
@@ -1,7 +1,7 @@
1
1
  import { PathFilePointer } from "@sealcode/file-manager";
2
2
  import { tempstream } from "tempstream";
3
3
  import { MultipleFiles } from "./multiple-files.js";
4
- class MultiplePhotos extends MultipleFiles {
4
+ class MultipleImages extends MultipleFiles {
5
5
  constructor(field, imageRouter, options) {
6
6
  super(field, options);
7
7
  this.field = field;
@@ -37,6 +37,6 @@ class MultiplePhotos extends MultipleFiles {
37
37
  }
38
38
  }
39
39
  export {
40
- MultiplePhotos
40
+ MultipleImages
41
41
  };
42
- //# sourceMappingURL=multiple-photos.js.map
42
+ //# sourceMappingURL=multiple-images.js.map
@@ -26,25 +26,23 @@ class SimpleInput extends FormFieldControl {
26
26
  async getInputAttributes(fctx) {
27
27
  const readonly = this.options.readonly || false;
28
28
  const required = this.field.required;
29
- const { parsed, raw, valid } = await this.field.getValue(
29
+ const { raw, valid } = await this.field.getParsedValue(
30
30
  fctx.ctx,
31
- fctx.data,
31
+ fctx.data.raw_values,
32
32
  true
33
33
  );
34
34
  return Object.fromEntries([
35
35
  ["id", this.getID()],
36
36
  ["type", this.getType()],
37
37
  ["name", `${fctx.field_name_prefix}${this.field.name}`],
38
- [
39
- "value",
40
- !valid && raw ? raw.toString() : parsed !== void 0 && parsed !== null ? parsed?.toString() || "" : ""
41
- ],
38
+ ["value", raw],
42
39
  ...fctx.form_id ? [["form", fctx.form_id]] : [],
43
40
  ["placeholder", this.getPlaceholder()],
44
41
  ...readonly ? [["readonly", true]] : [],
45
42
  ...required ? [["required", true]] : [],
46
43
  ...!this.options.autocomplete ? [["autocomplete", "off"]] : [],
47
- ...this.options.step ? [["step", this.options.step]] : []
44
+ ...this.options.step ? [["step", this.options.step]] : [],
45
+ ["aria-invalid", String(!valid)]
48
46
  ]);
49
47
  }
50
48
  async postInput(_) {
@@ -67,9 +65,9 @@ class SimpleInput extends FormFieldControl {
67
65
  async render(fctx) {
68
66
  const id = this.getID();
69
67
  const label = this.getLabel();
70
- const { valid, message } = await this.field.getValue(
68
+ const { valid, message } = await this.field.getParsedValue(
71
69
  fctx.ctx,
72
- fctx.data,
70
+ fctx.data.raw_values,
73
71
  true
74
72
  );
75
73
  return inputWrapper(
@@ -77,14 +75,17 @@ class SimpleInput extends FormFieldControl {
77
75
  this.getWrapperModifiers(),
78
76
  tempstream`
79
77
  ${label ? `<label for="${id}">${label}</label>` : ""}
80
- ${await this.preInput(fctx, fctx.data)}
78
+ ${await this.preInput(fctx, fctx.data.raw_values)}
81
79
  ${this.renderInput(
82
80
  fctx.ctx,
83
81
  renderAttributes(await this.getInputAttributes(fctx)),
84
- fctx.data
82
+ fctx.data.raw_values
85
83
  )}
86
84
  ${this.postInput(fctx.ctx)}
87
- ${~valid && !this.options.hide_errors && fctx.validate ? `<div class="input__error">${message}</div>` : ""}
85
+ ${~valid && !this.options.hide_errors && fctx.validate ? `<div class="input__error">${[
86
+ message,
87
+ fctx.data.field_messages?.[this.field.name]?.message
88
+ ].filter((e) => !!e).join(" \xB7 ")}</div>` : ""}
88
89
  `
89
90
  );
90
91
  }
@@ -22,6 +22,10 @@ class SingleReferenceDropdown extends FreeformDropdown {
22
22
  this.field = field;
23
23
  this.options = options;
24
24
  }
25
+ setOptionLabelGetter(getter) {
26
+ this.options.getLabel = getter;
27
+ return this;
28
+ }
25
29
  }
26
30
  export {
27
31
  SingleReferenceDropdown
@@ -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,46 @@ 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
+ ${(await Promise.all(
39
+ Object.entries(this.table_field.columns).map(
40
+ ([column_name]) => {
41
+ const inner_fctx = get_row_fctx(
42
+ row,
43
+ row_index
44
+ );
45
+ return tempstream`<td>${this.options.subfield_controls[column_name].render({ ...fctx, ...inner_fctx })}</td>`;
46
+ }
47
+ )
48
+ )).map(
49
+ (html) => html.replaceAll(
50
+ TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER,
51
+ row_index.toString()
52
+ )
53
+ )}
33
54
  ${this.options.allow_removing ? (
34
55
  /* HTML */
35
56
  `<td>
@@ -79,26 +100,25 @@ class Table extends FormControl {
79
100
  ${rows?.map((row, index) => make_row(row, index))}
80
101
  </tbody>
81
102
  </table>
82
- <template> ${make_row(null, TO_REPLACE)} </template>
103
+ <template>
104
+ ${make_row(null, TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER)}
105
+ </template>
83
106
 
84
107
  ${/* because of https://github.com/ljharb/qs/issues/252 we have to
85
108
  put the indexes in the field names */
86
109
  this.options.allow_adding ? (
87
110
  /* HTML */
88
111
  `<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;"
112
+ data-controller="table-add-button"
113
+ data-action="click->table-add-button#addRow"
114
+ data-table-placeholder="${TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER}"
95
115
  >
96
- add
116
+ ${this.options.label_add || "add"}
97
117
  </button>
98
118
  <noscript>
99
119
  <input
100
120
  type="submit"
101
- value="${this.options.label_add || "add"}"
121
+ value="add"
102
122
  form="${fctx.form_id}"
103
123
  formnovalidate
104
124
  formaction="${this.getActionURL(
@@ -177,7 +197,8 @@ template.innerHTML = orig_template;"
177
197
  ctx,
178
198
  {
179
199
  raw_values: await form.extractRawValues(ctx),
180
- messages: []
200
+ messages: [],
201
+ field_messages: {}
181
202
  },
182
203
  false
183
204
  )
@@ -185,8 +206,29 @@ template.innerHTML = orig_template;"
185
206
  await next();
186
207
  });
187
208
  }
209
+ setAllowRemoving(value) {
210
+ this.options.allow_removing = value;
211
+ return this;
212
+ }
213
+ setAllowAdding(value) {
214
+ this.options.allow_adding = value;
215
+ return this;
216
+ }
217
+ setLabel(value) {
218
+ this.options.label = value;
219
+ return this;
220
+ }
221
+ setRemoveLabel(value) {
222
+ this.options.label_remove = value;
223
+ return this;
224
+ }
225
+ setAddLabel(value) {
226
+ this.options.label_add = value;
227
+ return this;
228
+ }
188
229
  }
189
230
  export {
231
+ TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER,
190
232
  Table
191
233
  };
192
234
  //# sourceMappingURL=table.js.map
@@ -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