@rebasepro/cms 0.28.2 → 0.29.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 (339) hide show
  1. package/README.md +3 -3
  2. package/dist/collection_editor/_cms_internals.d.ts +0 -1
  3. package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
  4. package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
  5. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
  6. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
  7. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
  8. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
  9. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
  10. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
  11. package/dist/components/AdditionalFieldValue.d.ts +9 -3
  12. package/dist/components/AdditionalFieldValue.js +7 -4
  13. package/dist/components/AdditionalFieldValue.js.map +1 -1
  14. package/dist/components/CollectionPanel.d.ts +117 -18
  15. package/dist/components/CollectionPanel.js +115 -37
  16. package/dist/components/CollectionPanel.js.map +1 -1
  17. package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
  18. package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
  19. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
  20. package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
  21. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
  22. package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
  23. package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
  24. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
  25. package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
  26. package/dist/components/CollectionTableBinding/column_utils.js +6 -3
  27. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
  28. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
  29. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
  30. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
  31. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  32. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
  33. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
  34. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
  35. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
  36. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  37. package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
  38. package/dist/components/CollectionTableBinding/internal/common.js +88 -4
  39. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
  40. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
  41. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  42. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
  43. package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
  44. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  45. package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
  46. package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
  47. package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
  48. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
  49. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
  50. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
  51. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
  52. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
  53. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  54. package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
  55. package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
  56. package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
  57. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
  58. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
  59. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  60. package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
  61. package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
  62. package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
  63. package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
  64. package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
  65. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  66. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
  67. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
  68. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  69. package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
  70. package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
  71. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
  72. package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
  73. package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
  74. package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
  75. package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
  76. package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
  77. package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
  78. package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
  79. package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
  80. package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
  81. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
  82. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
  83. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
  84. package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
  85. package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
  86. package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
  87. package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
  88. package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
  89. package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
  90. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
  91. package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
  92. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  93. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
  94. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
  95. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
  96. package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
  97. package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
  98. package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
  99. package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
  100. package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
  101. package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
  102. package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
  103. package/dist/components/CollectionViewBinding/RowActions.js +60 -0
  104. package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
  105. package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
  106. package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
  107. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
  108. package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
  109. package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
  110. package/dist/components/CollectionViewBinding/fields.js +47 -0
  111. package/dist/components/CollectionViewBinding/fields.js.map +1 -0
  112. package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
  113. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
  114. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
  115. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
  116. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
  117. package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
  118. package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
  119. package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
  120. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
  121. package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
  122. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  123. package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
  124. package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
  125. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
  126. package/dist/components/CollectionsProvider.d.ts +3 -3
  127. package/dist/components/CollectionsProvider.js +4 -4
  128. package/dist/components/CollectionsProvider.js.map +1 -1
  129. package/dist/components/CollectionsScopeContext.d.ts +1 -1
  130. package/dist/components/CollectionsScopeContext.js +1 -1
  131. package/dist/components/CollectionsScopeContext.js.map +1 -1
  132. package/dist/components/DeleteEntityDialog.d.ts +1 -1
  133. package/dist/components/DeleteEntityDialog.js +2 -2
  134. package/dist/components/DeleteEntityDialog.js.map +1 -1
  135. package/dist/components/DetailViewBinding.js +32 -68
  136. package/dist/components/DetailViewBinding.js.map +1 -1
  137. package/dist/components/EditFormActions.js +5 -4
  138. package/dist/components/EditFormActions.js.map +1 -1
  139. package/dist/components/EditViewBinding.d.ts +2 -2
  140. package/dist/components/EditViewBinding.js +25 -15
  141. package/dist/components/EditViewBinding.js.map +1 -1
  142. package/dist/components/EntityDisplayHeader.js +8 -5
  143. package/dist/components/EntityDisplayHeader.js.map +1 -1
  144. package/dist/components/EntityPreviewBinding.js +1 -1
  145. package/dist/components/EntityPreviewBinding.js.map +1 -1
  146. package/dist/components/EntityViewBinding.d.ts +8 -1
  147. package/dist/components/EntityViewBinding.js +43 -14
  148. package/dist/components/EntityViewBinding.js.map +1 -1
  149. package/dist/components/EntityViewBody.d.ts +40 -0
  150. package/dist/components/EntityViewBody.js +90 -0
  151. package/dist/components/EntityViewBody.js.map +1 -0
  152. package/dist/components/FieldValue.d.ts +50 -0
  153. package/dist/components/FieldValue.js +81 -0
  154. package/dist/components/FieldValue.js.map +1 -0
  155. package/dist/components/InlineEntityPreview.js +1 -1
  156. package/dist/components/InlineEntityPreview.js.map +1 -1
  157. package/dist/components/PanelNotFound.d.ts +5 -0
  158. package/dist/components/PanelNotFound.js +21 -0
  159. package/dist/components/PanelNotFound.js.map +1 -0
  160. package/dist/components/RebaseCMS.d.ts +1 -1
  161. package/dist/components/RebaseCMS.js +11 -3
  162. package/dist/components/RebaseCMS.js.map +1 -1
  163. package/dist/components/RebaseNavigation.js +9 -3
  164. package/dist/components/RebaseNavigation.js.map +1 -1
  165. package/dist/components/RebaseShell.js +10 -5
  166. package/dist/components/RebaseShell.js.map +1 -1
  167. package/dist/components/RecordDetail.d.ts +61 -0
  168. package/dist/components/RecordDetail.js +123 -0
  169. package/dist/components/RecordDetail.js.map +1 -0
  170. package/dist/components/RecordForm.d.ts +126 -0
  171. package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
  172. package/dist/components/RecordForm.js.map +1 -0
  173. package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
  174. package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
  175. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  176. package/dist/components/ReferenceWidget.d.ts +5 -3
  177. package/dist/components/ReferenceWidget.js +10 -7
  178. package/dist/components/ReferenceWidget.js.map +1 -1
  179. package/dist/components/RelationSelector.js +4 -4
  180. package/dist/components/RelationSelector.js.map +1 -1
  181. package/dist/components/SelectableTable/SelectableTable.js +2 -3
  182. package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
  183. package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
  184. package/dist/components/SelectableTable/SelectionStore.js +1 -1
  185. package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
  186. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
  187. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
  188. package/dist/components/SidePanelBinding.js +13 -12
  189. package/dist/components/SidePanelBinding.js.map +1 -1
  190. package/dist/components/collection_prop.d.ts +18 -0
  191. package/dist/components/collection_prop.js +23 -0
  192. package/dist/components/collection_prop.js.map +1 -0
  193. package/dist/components/common/default_entity_actions.js +54 -54
  194. package/dist/components/common/default_entity_actions.js.map +1 -1
  195. package/dist/components/history/EntityHistoryView.d.ts +4 -1
  196. package/dist/components/history/EntityHistoryView.js +1 -1
  197. package/dist/components/history/EntityHistoryView.js.map +1 -1
  198. package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
  199. package/dist/components/index.d.ts +4 -2
  200. package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
  201. package/dist/data_export/export/ExportCollectionAction.js +4 -3
  202. package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
  203. package/dist/data_export/export/additional_fields.d.ts +6 -3
  204. package/dist/data_export/export/additional_fields.js +8 -4
  205. package/dist/data_export/export/additional_fields.js.map +1 -1
  206. package/dist/data_import/import/ImportCollectionAction.js +2 -2
  207. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  208. package/dist/form/EntityForm.d.ts +1 -1
  209. package/dist/form/EntityForm.js +255 -150
  210. package/dist/form/EntityForm.js.map +1 -1
  211. package/dist/form/EntityFormActions.js +3 -2
  212. package/dist/form/EntityFormActions.js.map +1 -1
  213. package/dist/form/EntityFormBinding.d.ts +1 -1
  214. package/dist/form/EntityFormBinding.js +22 -11
  215. package/dist/form/EntityFormBinding.js.map +1 -1
  216. package/dist/form/FormField.d.ts +36 -0
  217. package/dist/form/FormField.js +41 -0
  218. package/dist/form/FormField.js.map +1 -0
  219. package/dist/form/FormFieldsContext.d.ts +69 -0
  220. package/dist/form/FormFieldsContext.js +143 -0
  221. package/dist/form/FormFieldsContext.js.map +1 -0
  222. package/dist/form/PropertyFieldBinding.js +4 -4
  223. package/dist/form/PropertyFieldBinding.js.map +1 -1
  224. package/dist/form/collection_showing.d.ts +8 -0
  225. package/dist/form/collection_showing.js +29 -0
  226. package/dist/form/collection_showing.js.map +1 -0
  227. package/dist/form/components/ErrorFocus.js +2 -1
  228. package/dist/form/components/ErrorFocus.js.map +1 -1
  229. package/dist/form/components/FieldBlock.js +3 -1
  230. package/dist/form/components/FieldBlock.js.map +1 -1
  231. package/dist/form/components/FormRail.d.ts +5 -1
  232. package/dist/form/components/FormRail.js +5 -1
  233. package/dist/form/components/FormRail.js.map +1 -1
  234. package/dist/form/components/FormSections.d.ts +5 -1
  235. package/dist/form/components/FormSections.js +11 -4
  236. package/dist/form/components/FormSections.js.map +1 -1
  237. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
  238. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
  239. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
  240. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
  241. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
  242. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
  243. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  244. package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
  245. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
  246. package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
  247. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  248. package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
  249. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
  250. package/dist/form/form_dom_ids.d.ts +25 -0
  251. package/dist/form/form_dom_ids.js +42 -0
  252. package/dist/form/form_dom_ids.js.map +1 -0
  253. package/dist/form/index.d.ts +3 -1
  254. package/dist/form/resolve_cell_property.d.ts +5 -0
  255. package/dist/form/resolve_cell_property.js +22 -1
  256. package/dist/form/resolve_cell_property.js.map +1 -1
  257. package/dist/hooks/index.d.ts +1 -1
  258. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
  259. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
  260. package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
  261. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
  262. package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
  263. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
  264. package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
  265. package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
  266. package/dist/hooks/useBuildSidePanel.js +9 -9
  267. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  268. package/dist/hooks/useEntityDisplay.js +6 -4
  269. package/dist/hooks/useEntityDisplay.js.map +1 -1
  270. package/dist/hooks/useRecordActions.js +2 -2
  271. package/dist/hooks/useRecordActions.js.map +1 -1
  272. package/dist/hooks/useSelectionDialog.d.ts +20 -7
  273. package/dist/hooks/useSelectionDialog.js +29 -8
  274. package/dist/hooks/useSelectionDialog.js.map +1 -1
  275. package/dist/index.d.ts +8 -3
  276. package/dist/index.js +15 -9
  277. package/dist/mcp-view.d.ts +9 -0
  278. package/dist/mcp-view.js +2 -0
  279. package/dist/mcp_view/app_modules.d.ts +29 -0
  280. package/dist/mcp_view/app_modules.js +163 -0
  281. package/dist/mcp_view/app_modules.js.map +1 -0
  282. package/dist/mcp_view/bridge.d.ts +90 -0
  283. package/dist/mcp_view/bridge.js +205 -0
  284. package/dist/mcp_view/bridge.js.map +1 -0
  285. package/dist/mcp_view/code_app.d.ts +65 -0
  286. package/dist/mcp_view/code_app.js +139 -0
  287. package/dist/mcp_view/code_app.js.map +1 -0
  288. package/dist/mcp_view/index.d.ts +54 -0
  289. package/dist/mcp_view/index.js +262 -0
  290. package/dist/mcp_view/index.js.map +1 -0
  291. package/dist/mcp_view/payload.d.ts +78 -0
  292. package/dist/mcp_view/payload.js +155 -0
  293. package/dist/mcp_view/payload.js.map +1 -0
  294. package/dist/mcp_view/screen.d.ts +30 -0
  295. package/dist/mcp_view/screen.js +245 -0
  296. package/dist/mcp_view/screen.js.map +1 -0
  297. package/dist/mcp_view/storage_source.d.ts +14 -0
  298. package/dist/mcp_view/storage_source.js +29 -0
  299. package/dist/mcp_view/storage_source.js.map +1 -0
  300. package/dist/mcp_view/store.d.ts +9 -0
  301. package/dist/mcp_view/store.js +27 -0
  302. package/dist/mcp_view/store.js.map +1 -0
  303. package/dist/mcp_view/tool_driver.d.ts +160 -0
  304. package/dist/mcp_view/tool_driver.js +575 -0
  305. package/dist/mcp_view/tool_driver.js.map +1 -0
  306. package/dist/preview/components/DatePreview.d.ts +34 -1
  307. package/dist/preview/components/DatePreview.js +72 -37
  308. package/dist/preview/components/DatePreview.js.map +1 -1
  309. package/dist/routes/RebaseRoute.js +1 -1
  310. package/dist/routes/RebaseRoute.js.map +1 -1
  311. package/dist/selection/SelectionMenu.d.ts +5 -3
  312. package/dist/selection/SelectionMenu.js +16 -9
  313. package/dist/selection/SelectionMenu.js.map +1 -1
  314. package/dist/selection/index.d.ts +2 -1
  315. package/dist/selection/resolve_selection.d.ts +61 -7
  316. package/dist/selection/resolve_selection.js +93 -11
  317. package/dist/selection/resolve_selection.js.map +1 -1
  318. package/dist/types/components/EntityFormProps.d.ts +60 -10
  319. package/dist/types/fields.d.ts +2 -65
  320. package/dist/util/dataControllerAdapter.d.ts +8 -0
  321. package/dist/util/dataControllerAdapter.js +11 -0
  322. package/dist/util/dataControllerAdapter.js.map +1 -1
  323. package/dist/util/navigation_utils.d.ts +5 -4
  324. package/dist/util/navigation_utils.js +6 -6
  325. package/dist/util/navigation_utils.js.map +1 -1
  326. package/dist/util/propertyConfigMapper.d.ts +8 -0
  327. package/dist/util/propertyConfigMapper.js +16 -2
  328. package/dist/util/propertyConfigMapper.js.map +1 -1
  329. package/package.json +15 -9
  330. package/recipes/README.md +79 -26
  331. package/recipes/approval-queue.tsx +79 -0
  332. package/recipes/bulk-set-status.tsx +23 -17
  333. package/recipes/calendar-view.tsx +28 -23
  334. package/recipes/master-detail.tsx +75 -0
  335. package/recipes/my-preferences.tsx +3 -3
  336. package/recipes/orders-dashboard.tsx +58 -84
  337. package/recipes/site-settings.tsx +4 -4
  338. package/dist/components/EntityFormPanel.d.ts +0 -63
  339. package/dist/components/EntityFormPanel.js.map +0 -1
@@ -3,8 +3,10 @@
3
3
  *
4
4
  * A custom view mode sits in the collection's view switcher next to table,
5
5
  * cards and board. Its `Builder` is handed the live `tableController`, so the
6
- * toolbar's search and filters drive it, and `onEntityClick`, which opens a
7
- * row the way the collection opens rows. All this file decides is the layout.
6
+ * toolbar's search and filters drive it, and `onRowClick`, which opens a row
7
+ * the way the collection opens rows. The rows are the server's: a date is an
8
+ * ISO string, `YYYY-MM-DD` for a date-only column. All this file decides is
9
+ * the layout.
8
10
  *
9
11
  * To use it:
10
12
  * 1. Register it: `<RebaseCMS collectionViews={[calendarView]}>`
@@ -15,7 +17,6 @@
15
17
  */
16
18
  import React, { useMemo, useState } from "react";
17
19
  import type { CollectionCustomView, CollectionCustomViewParams } from "@rebasepro/cms-types";
18
- import type { Entity } from "@rebasepro/types";
19
20
  import { Button, Typography } from "@rebasepro/ui";
20
21
  import { getDatePropertyTimezone } from "@rebasepro/cms";
21
22
 
@@ -29,12 +30,16 @@ function dayKey(date: Date): string {
29
30
  }
30
31
 
31
32
  /**
32
- * The day a stored date falls on, in the zone the admin shows it in: UTC for a
33
- * `columnType: "date"` column (a calendar day, delivered as that day's UTC
34
- * midnight — in local time it is the day before west of Greenwich), the
35
- * property's `timezone` when it declares one, else the browser's.
33
+ * The day a stored date falls on, in the zone the admin shows it in: the day
34
+ * itself for a `columnType: "date"` column, which arrives as `YYYY-MM-DD`;
35
+ * for a timestamp, its day in the property's `timezone` when it declares
36
+ * one, else the browser's.
36
37
  */
37
- function storedDayKey(date: Date, timeZone: string | undefined): string {
38
+ function storedDayKey(raw: string, timeZone: string | undefined): string | undefined {
39
+ const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw);
40
+ if (day) return `${Number(day[1])}-${Number(day[2]) - 1}-${Number(day[3])}`;
41
+ const date = new Date(raw);
42
+ if (Number.isNaN(date.getTime())) return undefined;
38
43
  if (!timeZone) return dayKey(date);
39
44
  const parts = new Intl.DateTimeFormat("en-US", { timeZone, year: "numeric", month: "numeric", day: "numeric" })
40
45
  .formatToParts(date);
@@ -54,7 +59,7 @@ function monthGrid(month: Date): Date[] {
54
59
  return days;
55
60
  }
56
61
 
57
- export function CalendarView({ collection, tableController, onEntityClick }: CollectionCustomViewParams) {
62
+ export function CalendarView({ collection, tableController, onRowClick }: CollectionCustomViewParams) {
58
63
  const [month, setMonth] = useState(() => {
59
64
  const now = new Date();
60
65
  return new Date(now.getFullYear(), now.getMonth(), 1);
@@ -63,18 +68,18 @@ export function CalendarView({ collection, tableController, onEntityClick }: Col
63
68
  const dateProperty = collection.properties[DATE_FIELD];
64
69
  const timeZone = dateProperty?.type === "date" ? getDatePropertyTimezone(dateProperty) : undefined;
65
70
 
71
+ // Each row with its id, which `tableController.ids` holds at the row's position.
66
72
  const byDay = useMemo(() => {
67
- const map = new Map<string, Entity[]>();
68
- for (const entity of tableController.data ?? []) {
69
- const raw = entity.values[DATE_FIELD];
70
- if (raw === null || raw === undefined) continue;
71
- const date = raw instanceof Date ? raw : new Date(String(raw));
72
- if (Number.isNaN(date.getTime())) continue;
73
- const key = storedDayKey(date, timeZone);
74
- map.set(key, [...(map.get(key) ?? []), entity]);
75
- }
73
+ const map = new Map<string, { row: Record<string, unknown>; id: string }[]>();
74
+ tableController.rows.forEach((row, i) => {
75
+ const raw = row[DATE_FIELD];
76
+ if (typeof raw !== "string") return;
77
+ const key = storedDayKey(raw, timeZone);
78
+ if (key === undefined) return;
79
+ map.set(key, [...(map.get(key) ?? []), { row, id: tableController.ids[i] }]);
80
+ });
76
81
  return map;
77
- }, [tableController.data, timeZone]);
82
+ }, [tableController.rows, tableController.ids, timeZone]);
78
83
 
79
84
  const shift = (months: number) => setMonth(m => new Date(m.getFullYear(), m.getMonth() + months, 1));
80
85
 
@@ -98,14 +103,14 @@ export function CalendarView({ collection, tableController, onEntityClick }: Col
98
103
  className={"min-h-24 bg-surface-card p-1 flex flex-col gap-1"
99
104
  + (day.getMonth() === month.getMonth() ? "" : " opacity-40")}>
100
105
  <Typography variant={"caption"} color={"secondary"}>{day.getDate()}</Typography>
101
- {(byDay.get(dayKey(day)) ?? []).map(entity => (
102
- <Button key={String(entity.id)}
106
+ {(byDay.get(dayKey(day)) ?? []).map(({ row, id }) => (
107
+ <Button key={id}
103
108
  variant={"text"}
104
109
  size={"smallest"}
105
110
  fullWidth
106
- onClick={() => onEntityClick?.(entity)}
111
+ onClick={() => onRowClick?.(row)}
107
112
  className={"justify-start min-w-0"}>
108
- <span className={"truncate"}>{String(entity.values[TITLE_FIELD] ?? entity.id)}</span>
113
+ <span className={"truncate"}>{String(row[TITLE_FIELD] ?? id)}</span>
109
114
  </Button>
110
115
  ))}
111
116
  </div>
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Recipe: master-detail — a list of rows beside the form of the one picked.
3
+ *
4
+ * `SplitView` from `@rebasepro/ui` lays the two out by the width of its own
5
+ * container, not the window's: side by side when there is room, and in a
6
+ * narrow container (a phone, a side panel, Claude's frame) the form covers the
7
+ * list under a back bar. Both stay mounted across the switch, so the list
8
+ * keeps its scroll and the form its edits.
9
+ *
10
+ * The master is a `CollectionPanel`: `fields` picks its columns, `onRowClick`
11
+ * hands over the clicked row and its id instead of opening it, and
12
+ * `highlightedIds` draws that row as the selected one. The row is the
13
+ * server's: its columns, dates as ISO strings. The id is the string the admin
14
+ * addresses the record by. The detail is an `RecordForm` at that id,
15
+ * named by the same path, with `fields` choosing what it edits. A save there reaches the list by
16
+ * itself.
17
+ *
18
+ * To use it: add `customersMasterDetailView` to `<RebaseCMS views={[…]}>`.
19
+ * Change `COLLECTION`, the field lists, and `TITLE_FIELD` to your own.
20
+ */
21
+ import React, { useState } from "react";
22
+ import type { AppView } from "@rebasepro/cms-types";
23
+ import { CollectionPanel, RecordForm } from "@rebasepro/cms";
24
+ import { SplitView } from "@rebasepro/ui";
25
+
26
+ const COLLECTION = "customers";
27
+ /** The list's columns, in order. */
28
+ const LIST_FIELDS = ["name", "status"];
29
+ /** What the form edits, in order. A required field left out must have a default. */
30
+ const FORM_FIELDS = ["name", "email", "status", "notes"];
31
+ /** Names the open record in the narrow layout's back bar. */
32
+ const TITLE_FIELD = "name";
33
+
34
+ type Row = Record<string, unknown>;
35
+
36
+ export function CustomersMasterDetail() {
37
+ // The row picked, and its id: what `RecordForm` and `highlightedIds` take.
38
+ const [selected, setSelected] = useState<{ row: Row; id: string } | null>(null);
39
+ const selectedId = selected?.id;
40
+
41
+ return (
42
+ // SplitView fills its parent, so the parent needs a height.
43
+ <div className={"h-full min-h-0"}>
44
+ <SplitView
45
+ master={
46
+ <CollectionPanel collection={COLLECTION}
47
+ title={false}
48
+ fields={LIST_FIELDS}
49
+ onRowClick={(row, id) => setSelected({ row, id })}
50
+ highlightedIds={selectedId !== undefined ? [selectedId] : []}
51
+ className={"h-full"}/>
52
+ }
53
+ detail={selectedId !== undefined && (
54
+ <div className={"h-full overflow-auto p-4"}>
55
+ <RecordForm
56
+ // Another record is another form: remount rather
57
+ // than carry one record's edits into the next.
58
+ key={selectedId}
59
+ collection={COLLECTION}
60
+ id={selectedId}
61
+ fields={FORM_FIELDS}/>
62
+ </div>
63
+ )}
64
+ detailTitle={selected ? String(selected.row[TITLE_FIELD] ?? selected.id) : undefined}
65
+ onClearSelection={() => setSelected(null)}/>
66
+ </div>
67
+ );
68
+ }
69
+
70
+ export const customersMasterDetailView: AppView = {
71
+ slug: "customers/browse",
72
+ name: "Customers",
73
+ icon: "Users",
74
+ view: <CustomersMasterDetail/>
75
+ };
@@ -15,7 +15,7 @@ import React from "react";
15
15
  import { defineCollection } from "@rebasepro/cms-types";
16
16
  import type { AppView } from "@rebasepro/cms-types";
17
17
  import { useAuthController } from "@rebasepro/app";
18
- import { EntityFormPanel } from "@rebasepro/cms";
18
+ import { RecordForm } from "@rebasepro/cms";
19
19
  import { Container, Typography } from "@rebasepro/ui";
20
20
 
21
21
  export const userPreferencesCollection = defineCollection({
@@ -49,12 +49,12 @@ export function MyPreferencesPage() {
49
49
  return (
50
50
  <Container maxWidth={"3xl"} className={"py-8"}>
51
51
  <Typography variant={"h4"} gutterBottom>My preferences</Typography>
52
- <EntityFormPanel
52
+ <RecordForm
53
53
  // A new user is a new record: remount rather than carry one
54
54
  // user's form state into another's.
55
55
  key={user.uid}
56
56
  collection={userPreferencesCollection}
57
- entityId={user.uid}
57
+ id={user.uid}
58
58
  defaultValues={{ theme: "system", weeklyDigest: true }}/>
59
59
  </Container>
60
60
  );
@@ -1,34 +1,36 @@
1
1
  /**
2
- * Recipe: a dashboard page — read data, draw it, link into the admin.
2
+ * Recipe: a dashboard page — count, group, chart, link into the admin.
3
3
  *
4
- * A page of the admin is a React component on a route. It reads through
5
- * `useData()` (the same data layer, permissions and server callbacks as the
6
- * rest of the admin) and can draw with anything: this one uses plain divs so
7
- * it needs no chart library; swap in recharts or visx if you have one.
4
+ * A page of the admin is a React component on a route. This one asks the data
5
+ * source for two numbers rather than reading rows: `useRowCount` for the
6
+ * total and `useAggregate` for a `count` per status, grouped and sorted by
7
+ * the database. Both are true however many orders there are, and both follow
8
+ * every write to the collection made in the admin.
8
9
  *
9
- * Grouping happens in the browser, over the first `MAX_ROWS` rows, which is
10
- * right for a few thousand. The total is counted by the data source, so it
11
- * stays true past that, and the page says when the groups cover only part of
12
- * it. For more, add a custom function on the server that runs the `GROUP BY`
13
- * and call it from here instead.
10
+ * It draws with the metric blocks of `@rebasepro/ui` — `KpiGrid` / `KpiTile`
11
+ * for the figure, `ChartCard` / `BarChart` for the groups — which are what the
12
+ * admin's own dashboards are drawn with, in its tokens and dark mode. Each
13
+ * bar opens the collection filtered to its group, the filter in the URL as
14
+ * the collection's toolbar writes it, through the admin's router.
14
15
  *
15
- * Each bar opens the collection filtered to its group — the filter rides in
16
- * the URL, as the collection writes it — through the admin's router.
16
+ * Aggregates need a data source that computes them: Postgres through the
17
+ * server does. Where one cannot, the chart says so in place of the bars.
17
18
  *
18
19
  * To use it: add `ordersDashboardView` to `<RebaseCMS views={[…]}>`. Change
19
20
  * `COLLECTION` / `GROUP_FIELD` to your own.
20
21
  */
21
- import React, { useEffect, useState } from "react";
22
+ import React from "react";
22
23
  import type { AppView } from "@rebasepro/cms-types";
23
- import { useData } from "@rebasepro/app";
24
+ import { useAggregate, useRowCount } from "@rebasepro/app";
24
25
  import { useUrlController } from "@rebasepro/cms";
25
- import { Card, CircularProgressCenter, Container, Typography } from "@rebasepro/ui";
26
+ import { BarChart, ChartCard, Container, KpiGrid, KpiTile, Typography } from "@rebasepro/ui";
27
+ import type { Bar } from "@rebasepro/ui";
26
28
 
27
29
  const COLLECTION = "orders";
28
30
  const GROUP_FIELD = "status";
29
- const MAX_ROWS = 5000;
30
31
 
31
- type Group = { value: string | null; count: number };
32
+ /** The bar of the rows with no value in `GROUP_FIELD`; a bar's key is its value otherwise. */
33
+ const NO_VALUE = "\u0000none";
32
34
 
33
35
  /** The collection's URL filtered to one value of `GROUP_FIELD`, as its toolbar writes it. */
34
36
  function filteredUrl(collectionUrl: string, value: string | null): string {
@@ -37,82 +39,54 @@ function filteredUrl(collectionUrl: string, value: string | null): string {
37
39
  return `${collectionUrl}?${GROUP_FIELD}_op=${op}&${GROUP_FIELD}_value=${encoded}`;
38
40
  }
39
41
 
42
+ /** The hooks report a failure as its message; the blocks take an `Error`. */
43
+ function asError(message: string | undefined): Error | undefined {
44
+ return message === undefined ? undefined : new Error(message);
45
+ }
46
+
40
47
  export function OrdersDashboard() {
41
- const data = useData();
42
48
  const urls = useUrlController();
43
- const [groups, setGroups] = useState<Group[] | undefined>();
44
- const [total, setTotal] = useState(0);
45
- const [error, setError] = useState<string | undefined>();
49
+ const total = useRowCount(COLLECTION);
50
+ // One row per status, `{ status, count }`, largest first. Over HTTP a
51
+ // grouped aggregate returns 50 groups unless `limit` asks for more.
52
+ const groups = useAggregate(COLLECTION, {
53
+ select: [{ fn: "count" }],
54
+ groupBy: [GROUP_FIELD],
55
+ orderBy: ["count", "desc"]
56
+ });
46
57
 
47
- useEffect(() => {
48
- let cancelled = false;
49
- const orders = data.collection(COLLECTION);
50
- // `count` is optional on an accessor: not every data source can count.
51
- Promise.all([orders.find({ limit: MAX_ROWS }), orders.count ? orders.count() : undefined])
52
- .then(([{ data: rows }, counted]) => {
53
- const counts = new Map<string | null, number>();
54
- for (const row of rows) {
55
- const raw = row.values[GROUP_FIELD];
56
- const value = raw === null || raw === undefined ? null : String(raw);
57
- counts.set(value, (counts.get(value) ?? 0) + 1);
58
- }
59
- if (!cancelled) {
60
- setTotal(Math.max(counted ?? 0, rows.length));
61
- setGroups([...counts].map(([value, count]) => ({ value, count })).sort((a, b) => b.count - a.count));
62
- }
63
- })
64
- .catch((e: unknown) => {
65
- if (!cancelled) setError(e instanceof Error ? e.message : String(e));
66
- });
67
- return () => {
68
- cancelled = true;
58
+ const collectionUrl = urls.buildUrlCollectionPath(COLLECTION);
59
+ const bars: Bar[] = (groups.result ?? []).map(row => {
60
+ const value = row[GROUP_FIELD];
61
+ const missing = value === null || value === undefined;
62
+ return {
63
+ key: missing ? NO_VALUE : String(value),
64
+ label: missing ? "—" : String(value),
65
+ value: Number(row.count),
66
+ // For "open in a new tab"; a plain click navigates in place.
67
+ href: filteredUrl(collectionUrl, missing ? null : String(value))
69
68
  };
70
- }, [data]);
69
+ });
71
70
 
72
- if (error) return <Typography color={"error"} className={"p-8"}>{error}</Typography>;
73
- if (!groups) return <CircularProgressCenter/>;
74
-
75
- const grouped = groups.reduce((sum, g) => sum + g.count, 0);
76
- const max = Math.max(1, ...groups.map(g => g.count));
77
- const collectionUrl = urls.buildUrlCollectionPath(COLLECTION);
71
+ const openGroup = (bar: Bar) => {
72
+ if (bar.href) urls.navigate(bar.href);
73
+ };
78
74
 
79
75
  return (
80
76
  <Container maxWidth={"4xl"} className={"py-8 flex flex-col gap-4"}>
81
77
  <Typography variant={"h4"}>Orders</Typography>
82
- <Card className={"p-4 flex flex-col gap-1"}>
83
- <Typography variant={"caption"} color={"secondary"}>Total</Typography>
84
- <Typography variant={"stat"}>{total}</Typography>
85
- {grouped < total && (
86
- <Typography variant={"caption"} color={"secondary"}>
87
- {`Grouped over the first ${grouped} of ${total} orders`}
88
- </Typography>
89
- )}
90
- </Card>
91
- <Card className={"p-4 flex flex-col gap-3"}>
92
- <Typography variant={"subtitle2"}>By {GROUP_FIELD}</Typography>
93
- {groups.map(group => {
94
- const href = filteredUrl(collectionUrl, group.value);
95
- const label = group.value ?? "—";
96
- return (
97
- <a key={label}
98
- href={href}
99
- // The href is for "open in a new tab"; a plain
100
- // click goes through the admin's router instead
101
- // of reloading the page.
102
- onClick={(event) => {
103
- if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
104
- event.preventDefault();
105
- urls.navigate(href);
106
- }}
107
- aria-label={`${label}: ${group.count}`}
108
- className={"grid grid-cols-[8rem_1fr_3rem] items-center gap-3 no-underline"}>
109
- <Typography variant={"body2"}>{label}</Typography>
110
- <div className={"h-3 rounded bg-primary/80"} style={{ width: `${(group.count / max) * 100}%` }}/>
111
- <Typography variant={"body2"} align={"right"}>{group.count}</Typography>
112
- </a>
113
- );
114
- })}
115
- </Card>
78
+ <KpiGrid>
79
+ <KpiTile label={"Total"} icon={"ShoppingCart"}
80
+ value={total.count}
81
+ loading={total.loading}
82
+ error={asError(total.error)}/>
83
+ </KpiGrid>
84
+ <ChartCard title={`By ${GROUP_FIELD}`} icon={"ChartBar"}>
85
+ <BarChart bars={bars}
86
+ loading={groups.loading}
87
+ error={asError(groups.error)}
88
+ onBarClick={openGroup}/>
89
+ </ChartCard>
116
90
  </Container>
117
91
  );
118
92
  }
@@ -2,7 +2,7 @@
2
2
  * Recipe: a singleton — one settings record, edited on a page of its own.
3
3
  *
4
4
  * A singleton is not a special kind of collection. It is an ordinary table
5
- * whose admin page always opens the same row. `EntityFormPanel` given an id
5
+ * whose admin page always opens the same row. `RecordForm` given an id
6
6
  * edits that record, and creates it under that id the first time, so there is
7
7
  * nothing to seed.
8
8
  *
@@ -16,7 +16,7 @@
16
16
  import React from "react";
17
17
  import { defineCollection } from "@rebasepro/cms-types";
18
18
  import type { AppView } from "@rebasepro/cms-types";
19
- import { EntityFormPanel } from "@rebasepro/cms";
19
+ import { RecordForm } from "@rebasepro/cms";
20
20
  import { Container, Typography } from "@rebasepro/ui";
21
21
 
22
22
  /** The one row every visit to the page edits. */
@@ -46,9 +46,9 @@ export function SiteSettingsPage() {
46
46
  return (
47
47
  <Container maxWidth={"3xl"} className={"py-8"}>
48
48
  <Typography variant={"h4"} gutterBottom>Site settings</Typography>
49
- <EntityFormPanel
49
+ <RecordForm
50
50
  collection={siteSettingsCollection}
51
- entityId={SITE_SETTINGS_ID}
51
+ id={SITE_SETTINGS_ID}
52
52
  defaultValues={{ siteName: "My site", maintenanceMode: false }}/>
53
53
  </Container>
54
54
  );
@@ -1,63 +0,0 @@
1
- import React from "react";
2
- import type { AdminCollection } from "@rebasepro/cms-types";
3
- import type { EntityFormBindingProps } from "../form/EntityFormBinding.js";
4
- import type { OnUpdateParams } from "../types/components/EntityFormProps.js";
5
- /**
6
- * Props for {@link EntityFormPanel}.
7
- *
8
- * @group Components
9
- */
10
- export type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {
11
- /**
12
- * The collection the record belongs to, as a value — a `defineCollection`
13
- * config or a resolved collection.
14
- */
15
- collection: AdminCollection<M>;
16
- /**
17
- * The record to edit. When no record has this id yet, the form creates
18
- * it under this id — so a record kept at a known key (a settings record,
19
- * a profile keyed by its user's id) needs no seeding. Omit it to create a
20
- * new record under an id the data source assigns.
21
- */
22
- entityId?: string | number;
23
- /**
24
- * Where the collection is addressed. Defaults to `collection.slug`; a
25
- * subcollection's record takes its full path (`posts/p1/comments`).
26
- */
27
- path?: string;
28
- /** Called after every successful save, with the saved record. */
29
- onSaved?: (params: OnUpdateParams) => void;
30
- /**
31
- * Called when the form asks to be left — after its record is deleted, or
32
- * by an action that closes it. The form is your page's, so where that
33
- * leads is yours to say; without it, nothing happens.
34
- */
35
- onClose?: () => void;
36
- /** Values a new record starts with — one created without an id, or under an id no record has yet. */
37
- defaultValues?: Partial<M>;
38
- className?: string;
39
- /** Anything else {@link EntityFormBinding} takes. */
40
- formProps?: Partial<Omit<EntityFormBindingProps<M>, "path" | "collection" | "entityId" | "entity" | "initialStatus">>;
41
- };
42
- /**
43
- * One record's form — loaded by id, saved through `<Rebase>`'s data layer —
44
- * to drop into a page of your own app.
45
- *
46
- * Needs `<Rebase>` and a React Router router above it (any router, any path).
47
- * Where no CMS navigation is mounted above, it brings its own
48
- * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and
49
- * `<RebaseShell>` are not needed.
50
- *
51
- * @example
52
- * ```tsx
53
- * <Rebase client={client} authController={authController}>
54
- * <BrowserRouter>
55
- * <EntityFormPanel collection={postsCollection} entityId="123"
56
- * onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>
57
- * </BrowserRouter>
58
- * </Rebase>
59
- * ```
60
- *
61
- * @group Components
62
- */
63
- export declare function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>): React.JSX.Element;
@@ -1 +0,0 @@
1
- {"version":3,"file":"EntityFormPanel.js","names":[],"sources":["../../src/components/EntityFormPanel.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter, Typography } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnUpdateParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\n\n/**\n * Props for {@link EntityFormPanel}.\n *\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to, as a value — a `defineCollection`\n * config or a resolved collection.\n */\n collection: AdminCollection<M>;\n\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n entityId?: string | number;\n\n /**\n * Where the collection is addressed. Defaults to `collection.slug`; a\n * subcollection's record takes its full path (`posts/p1/comments`).\n */\n path?: string;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnUpdateParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"entityId\" | \"entity\" | \"initialStatus\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <EntityFormPanel collection={postsCollection} entityId=\"123\"\n * onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection } = props;\n const ownCollections = useMemo(() => [collection], [collection]);\n\n // As `CollectionPanel`: its own scope where none is above, or where the\n // one above has settled without this collection.\n const needsOwnScope = !inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${props.path ?? collection.slug}/${props.entityId ?? \"new\"}`;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <EntityFormPanelInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <EntityFormPanelInScope key={recordKey} {...props}/>;\n}\n\nfunction EntityFormPanelInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n formProps\n}: EntityFormPanelProps<M>) {\n const { t } = useTranslation();\n const path = pathProp ?? collectionProp.slug;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(\n () => lookUp ? collectionRegistry.getCollection(path) : undefined,\n [lookUp, collectionRegistry, path]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return (\n <CenteredView className={className}>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"entity_not_found\")}\n </Typography>\n </CenteredView>\n );\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entity={asNew.saved}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onEntityChange={(changed) => {\n // The record it created, which it edits from then on.\n setAsNew(current => current && { ...current, saved: changed });\n formProps?.onEntityChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entityId={entityId}\n entity={shownEntity}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n disabled={!editable || formProps?.disabled}\n onEntityChange={(changed) => {\n setSavedEntity(changed);\n formProps?.onEntityChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,SAAgB,gBAA6E,OAAgC;CACzH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,eAAe;CACvB,MAAM,iBAAiB,cAAc,CAAC,UAAU,GAAG,CAAC,UAAU,CAAC;CAI/D,MAAM,gBAAgB,CAAC,WACf,CAAC,gBAAgB,WAAW,CAAC,aAAa,mBAAmB,aAAa,MAAM,QAAQ,WAAW,IAAI;CAK/G,MAAM,YAAY,GAAG,MAAM,QAAQ,WAAW,KAAK,GAAG,MAAM,YAAY;CACxE,IAAI,eACA,OACI,oBAAC,qBAAD;EAAqB,aAAa;YAC9B,oBAAC,wBAAD,EAAwC,GAAI,MAAO,GAAtB,SAAsB;CAClC,CAAA;CAG7B,OAAO,oBAAC,wBAAD,EAAwC,GAAI,MAAO,GAAtB,SAAsB;AAC9D;AAEA,SAAS,uBAA0D,EAC/D,YAAY,gBACZ,UACA,MAAM,UACN,SACA,SACA,eACA,WACA,aACwB;CACxB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,OAAO,YAAY,eAAe;CACxC,MAAM,qBAAqB,gCAA6E;CACxG,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,WAAW,YAAY,eAAe;CAM9C,MAAM,SAAS,mBAAmB,eAAe,CAAC,gBAAgB;CAClE,MAAM,aAAa,cACT,SAAS,mBAAmB,cAAc,IAAI,IAAI,KAAA,GACxD;EAAC;EAAQ;EAAoB;CAAI,CAAC;CAEtC,MAAM,EAAE,QAAQ,aAAa,qBAAqB,SAAY;EAC1D;EACA;EACA,YAAY,cAAc;EAC1B,WAAW;EACX,UAAU;CACd,CAAC;CAKD,MAAM,CAAC,aAAa,kBAAkB,SAAgC,KAAA,CAAS;CAM/E,MAAM,CAAC,gBAAgB,qBAAqB,SAAgC,KAAA,CAAS;CACrF,gBAAgB;EACZ,IAAI,QAAQ,kBAAkB,MAAM;CACxC,GAAG,CAAC,MAAM,CAAC;CAGX,MAAM,CAAC,OAAO,YAAY,SAAsE,IAAI;CACpG,MAAM,cAAc,OAA+B,KAAA,CAAS;CAC5D,MAAM,mBAAmB,CAAC,SAAS,aAAa,KAAA,KAAa,CAAC,eAAe,CAAC,UACvE,mBAAmB,KAAA,KAAa,OAAO,eAAe,EAAE,MAAM,OAAO,QAAQ;CACpF,MAAM,cAAc,mBAAmB,iBAAkB,UAAU;CAEnE,MAAM,eAAe,kBAAkB,UAAU,GAAG,CAAC,OAAO,CAAC;CAC7D,MAAM,YAAY,kBAAkB;EAChC,MAAM,SAAqB,YAAY,WAAW,gBAAgB,UAAU,CAAC;EAC7E,UAAS,cAAa;GAAE;GAAQ,IAAI,UAAU,KAAK,KAAK;EAAE,EAAE;CAChE,GAAG,CAAC,cAAc,CAAC;CAEnB,IAAI,CAAC,YAAY;EACb,IAAI,gBAAgB,SAAS,OAAO,oBAAC,wBAAD,CAAwB,CAAA;EAC5D,OACI,oBAAC,cAAD;GAAyB;aACrB,oBAAC,YAAD;IAAY,SAAQ;IAAQ,OAAM;cAC7B,EAAE,kBAAkB;GACb,CAAA;EACF,CAAA;CAEtB;CAEA,IAAI,OACA,OACI,oBAAC,yBAAD;EAAqC;YACjC,8BAAC,mBAAD;GACI,GAAI;GACJ,KAAK,UAAU,MAAM;GACrB,WAAW,aAAa,WAAW;GAC7B;GACM;GACZ,QAAQ,MAAM;GACd,eAAe;GACf,oBAAoB,MAAM;GAC1B,UAAU,CAAC,UAAU,YAAY,IAAI,KAAK,WAAW;GACrD,iBAAiB,YAAY;IAEzB,UAAS,YAAW,WAAW;KAAE,GAAG;KAAS,OAAO;IAAQ,CAAC;IAC7D,WAAW,iBAAiB,OAAO;GACvC;GACA,UAAU,WAAW;IACjB,WAAW,UAAU,MAAM;IAC3B,UAAU,MAAM;GACpB;GACc;EACjB,CAAA;CACoB,CAAA;CAIjC,IAAI,aAAa,KAAA,KAAa,kBAC1B,OAAO,oBAAC,cAAD;EAAyB;YAAW,oBAAC,WAAD,EAAW,OAAO,iBAAkB,CAAA;CAAe,CAAA;CAElG,IAAI,aAAa,KAAA,KAAa,CAAC,eAAe,aAAa,OAAO,oBAAC,wBAAD,CAAwB,CAAA;CAK1F,MAAM,WAAW,gBAAgB,KAAA;CAGjC,MAAM,WAAW,WAAW,UAAU,YAAY,IAAI,IAAI,QAAQ,YAAY,MAAM,WAAW;CAE/F,OACI,oBAAC,yBAAD;EAAqC;YACjC,qBAAC,mBAAD;GACI,GAAI;GACJ,WAAW,aAAa,WAAW;GAC7B;GACM;GACF;GACV,QAAQ;GACR,eAAe,WAAW,QAAQ;GAClC,oBAAoB,WAAW,gBAAgB,WAAW;GAC1D,UAAU,CAAC,YAAY,WAAW;GAClC,iBAAiB,YAAY;IACzB,eAAe,OAAO;IACtB,WAAW,iBAAiB,OAAO;GACvC;GACA,mBAAmB,UAAU,WAAW;IACpC,YAAY,UAAU;IACtB,WAAW,mBAAmB,UAAU,MAAM;GAClD;GACA,UAAU,WAAW;IACjB,WAAW,UAAU,MAAM;IAC3B,UAAU,MAAM;GACpB;GACc;aAtBlB,CAwBK,oBACG,oBAAC,OAAD;IAAO,OAAO;IAAW,MAAM;IAAS,gBAAgB;IACpD,QAAQ,oBAAC,QAAD;KAAQ,MAAM;KAAS,SAAS;KAAQ,SAAS;eAAY,EAAE,aAAa;IAAU,CAAA;cAC7F,EAAE,0BAA0B;GAC1B,CAAA,GACV,WAAW,QACG;;CACE,CAAA;AAEjC"}