@rebasepro/cms 0.28.2 → 0.29.0-canary.g0e3a0e7

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 +252 -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 +48 -0
  289. package/dist/mcp_view/index.js +235 -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 +28 -0
  295. package/dist/mcp_view/screen.js +223 -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 +135 -0
  304. package/dist/mcp_view/tool_driver.js +527 -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
@@ -1,17 +1,50 @@
1
1
  import React from "react";
2
+ import type { Locale as DateFnsLocale } from "date-fns";
2
3
  export interface DatePreviewProps {
3
4
  date: Date;
4
5
  /**
5
6
  * Display mode: "date" for date-only, "date_time" for date and time,
6
7
  * "time" for a time of day (a `time` column) with no day at all
7
8
  */
8
- mode?: "date" | "date_time" | "time";
9
+ mode?: DatePreviewMode;
9
10
  /**
10
11
  * IANA timezone identifier (e.g., "America/New_York")
11
12
  * When specified, the date will be displayed in this timezone
12
13
  */
13
14
  timezone?: string;
14
15
  }
16
+ export type DatePreviewMode = "date" | "date_time" | "time";
17
+ export interface DatePreviewFormatOptions {
18
+ mode?: DatePreviewMode;
19
+ timezone?: string;
20
+ /** The admin's configured locale (`customizationController.locale`). */
21
+ locale?: string;
22
+ /** The admin's configured format (`customizationController.dateTimeFormat`). */
23
+ dateTimeFormat?: string;
24
+ /** The date-fns locale matching `locale`, once it has loaded. */
25
+ dateFnsLocale?: DateFnsLocale;
26
+ }
27
+ /**
28
+ * The text a `DatePreview` shows, and the zone abbreviation drawn after it.
29
+ *
30
+ * Pulled out of the component so the table can size a date column from the
31
+ * very string its cells will render — see `getDateColumnWidth`. Two copies of
32
+ * this logic would drift, and a column a few characters too narrow wraps every
33
+ * date in it onto a second line the row has no height for.
34
+ */
35
+ export declare function formatDatePreview(date: Date, { mode, timezone, locale, dateTimeFormat, dateFnsLocale }: DatePreviewFormatOptions): {
36
+ text: string;
37
+ zone?: string;
38
+ };
39
+ /**
40
+ * The date-fns locale for the admin's configured locale.
41
+ *
42
+ * The locale arrives asynchronously (see `date_fns_locales`). Seeded from the
43
+ * cache so only the very first date on a page renders un-localised: by the
44
+ * time a table of them mounts, the module is already resolved and there is no
45
+ * second pass.
46
+ */
47
+ export declare function useDateFnsLocale(): DateFnsLocale | undefined;
15
48
  /**
16
49
  * @group Preview components
17
50
  */
@@ -27,22 +27,14 @@ function cachedFormatter(key, build) {
27
27
  return formatter;
28
28
  }
29
29
  /**
30
- * @group Preview components
30
+ * The text a `DatePreview` shows, and the zone abbreviation drawn after it.
31
+ *
32
+ * Pulled out of the component so the table can size a date column from the
33
+ * very string its cells will render — see `getDateColumnWidth`. Two copies of
34
+ * this logic would drift, and a column a few characters too narrow wraps every
35
+ * date in it onto a second line the row has no height for.
31
36
  */
32
- function DatePreview({ date, mode = "date_time", timezone }) {
33
- const customizationController = useCustomizationController();
34
- const configuredLocale = customizationController?.locale;
35
- const [dateUtilsLocale, setDateUtilsLocale] = React.useState(() => getLoadedDateFnsLocale(configuredLocale));
36
- React.useEffect(() => {
37
- let cancelled = false;
38
- loadDateFnsLocale(configuredLocale).then((loaded) => {
39
- if (!cancelled) setDateUtilsLocale(loaded);
40
- }).catch((error) => console.error(`[rebase] could not load the "${configuredLocale}" date locale`, error));
41
- return () => {
42
- cancelled = true;
43
- };
44
- }, [configuredLocale]);
45
- if (!date || !(date instanceof Date) || isNaN(date.getTime())) return /* @__PURE__ */ jsx(Fragment, {});
37
+ function formatDatePreview(date, { mode = "date_time", timezone, locale, dateTimeFormat, dateFnsLocale }) {
46
38
  if (timezone) {
47
39
  const options = mode === "time" ? { timeZone: timezone } : {
48
40
  year: "numeric",
@@ -54,34 +46,77 @@ function DatePreview({ date, mode = "date_time", timezone }) {
54
46
  options.hour = "2-digit";
55
47
  options.minute = "2-digit";
56
48
  }
57
- const locale = customizationController?.locale ?? "en-US";
58
- const formattedDate = cachedFormatter(`${locale}|${timezone}|${mode}`, () => new Intl.DateTimeFormat(locale, options)).format(date);
59
- const tzAbbrev = mode === "date_time" ? cachedFormatter(`en-US|${timezone}|zone`, () => new Intl.DateTimeFormat("en-US", {
60
- timeZone: timezone,
61
- timeZoneName: "short"
62
- })).formatToParts(date).find((p) => p.type === "timeZoneName")?.value ?? "" : "";
63
- return /* @__PURE__ */ jsxs("span", {
64
- className: "flex items-center gap-1 font-mono tabular-nums",
65
- children: [formattedDate, tzAbbrev && /* @__PURE__ */ jsxs("span", {
66
- className: "text-xs text-slate-500 dark:text-slate-400",
67
- children: [
68
- "(",
69
- tzAbbrev,
70
- ")"
71
- ]
72
- })]
73
- });
49
+ const intlLocale = locale ?? "en-US";
50
+ return {
51
+ text: cachedFormatter(`${intlLocale}|${timezone}|${mode}`, () => new Intl.DateTimeFormat(intlLocale, options)).format(date),
52
+ zone: (mode === "date_time" ? cachedFormatter(`en-US|${timezone}|zone`, () => new Intl.DateTimeFormat("en-US", {
53
+ timeZone: timezone,
54
+ timeZoneName: "short"
55
+ })).formatToParts(date).find((p) => p.type === "timeZoneName")?.value : void 0) || void 0
56
+ };
74
57
  }
75
58
  let dateFormat;
76
59
  if (mode === "time") dateFormat = "p";
77
- else if (mode === "date") dateFormat = customizationController?.dateTimeFormat ? customizationController.dateTimeFormat.replace(/[, ]*[HhKk].*$/, "").trim() : "PP";
78
- else dateFormat = customizationController?.dateTimeFormat ?? defaultDateFormat;
60
+ else if (mode === "date") dateFormat = dateTimeFormat ? dateTimeFormat.replace(/[, ]*[HhKk].*$/, "").trim() : "PP";
61
+ else dateFormat = dateTimeFormat ?? defaultDateFormat;
62
+ return { text: format(date, dateFormat, { locale: dateFnsLocale }) };
63
+ }
64
+ /**
65
+ * The date-fns locale for the admin's configured locale.
66
+ *
67
+ * The locale arrives asynchronously (see `date_fns_locales`). Seeded from the
68
+ * cache so only the very first date on a page renders un-localised: by the
69
+ * time a table of them mounts, the module is already resolved and there is no
70
+ * second pass.
71
+ */
72
+ function useDateFnsLocale() {
73
+ const configuredLocale = useCustomizationController()?.locale;
74
+ const [dateFnsLocale, setDateFnsLocale] = React.useState(() => getLoadedDateFnsLocale(configuredLocale));
75
+ React.useEffect(() => {
76
+ let cancelled = false;
77
+ loadDateFnsLocale(configuredLocale).then((loaded) => {
78
+ if (!cancelled) setDateFnsLocale(loaded);
79
+ }).catch((error) => console.error(`[rebase] could not load the "${configuredLocale}" date locale`, error));
80
+ return () => {
81
+ cancelled = true;
82
+ };
83
+ }, [configuredLocale]);
84
+ return dateFnsLocale;
85
+ }
86
+ /**
87
+ * @group Preview components
88
+ */
89
+ function DatePreview({ date, mode = "date_time", timezone }) {
90
+ const customizationController = useCustomizationController();
91
+ const dateFnsLocale = useDateFnsLocale();
92
+ if (!date || !(date instanceof Date) || isNaN(date.getTime())) return /* @__PURE__ */ jsx(Fragment, {});
93
+ const { text, zone } = formatDatePreview(date, {
94
+ mode,
95
+ timezone,
96
+ locale: customizationController?.locale,
97
+ dateTimeFormat: customizationController?.dateTimeFormat,
98
+ dateFnsLocale
99
+ });
100
+ if (zone) return /* @__PURE__ */ jsxs("span", {
101
+ className: "flex items-center gap-1 min-w-0 font-mono tabular-nums whitespace-nowrap",
102
+ children: [/* @__PURE__ */ jsx("span", {
103
+ className: "truncate",
104
+ children: text
105
+ }), /* @__PURE__ */ jsxs("span", {
106
+ className: "shrink-0 text-xs text-slate-500 dark:text-slate-400",
107
+ children: [
108
+ "(",
109
+ zone,
110
+ ")"
111
+ ]
112
+ })]
113
+ });
79
114
  return /* @__PURE__ */ jsx("span", {
80
- className: "font-mono tabular-nums",
81
- children: format(date, dateFormat, { locale: dateUtilsLocale })
115
+ className: "min-w-0 truncate font-mono tabular-nums",
116
+ children: text
82
117
  });
83
118
  }
84
119
  //#endregion
85
- export { DatePreview };
120
+ export { DatePreview, formatDatePreview, useDateFnsLocale };
86
121
 
87
122
  //# sourceMappingURL=DatePreview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePreview.js","names":[],"sources":["../../../src/preview/components/DatePreview.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { format } from \"date-fns\";\nimport { useCustomizationController } from \"@rebasepro/app\";\nimport { defaultDateFormat } from \"@rebasepro/utils\";\nimport { getLoadedDateFnsLocale, loadDateFnsLocale } from \"./date_fns_locales\";\n\nexport interface DatePreviewProps {\n date: Date;\n /**\n * Display mode: \"date\" for date-only, \"date_time\" for date and time,\n * \"time\" for a time of day (a `time` column) with no day at all\n */\n mode?: \"date\" | \"date_time\" | \"time\";\n /**\n * IANA timezone identifier (e.g., \"America/New_York\")\n * When specified, the date will be displayed in this timezone\n */\n timezone?: string;\n}\n\n/**\n * `Intl.DateTimeFormat`s already built, for dates shown in a fixed timezone.\n *\n * Building one is the expensive part of formatting (~90 µs, against ~6 µs to\n * format with it), and a table column of zoned dates used to build two per\n * cell per render. Key: locale, timezone and what is shown — everything the\n * options are made of, so a cached formatter formats exactly as a fresh one\n * would. Nothing invalidates an entry: a formatter is a pure function of its\n * key and holds no record data. Bounded anyway, since a timezone can come from\n * data: past the cap the map starts over.\n */\nconst FORMATTERS = new Map<string, Intl.DateTimeFormat>();\nconst MAX_FORMATTERS = 200;\n\nfunction cachedFormatter(key: string, build: () => Intl.DateTimeFormat): Intl.DateTimeFormat {\n const cached = FORMATTERS.get(key);\n if (cached) return cached;\n // Built before it is stored: an unknown timezone throws here exactly as it\n // did uncached, and leaves nothing behind.\n const formatter = build();\n if (FORMATTERS.size >= MAX_FORMATTERS) FORMATTERS.clear();\n FORMATTERS.set(key, formatter);\n return formatter;\n}\n\n/**\n * @group Preview components\n */\nexport function DatePreview({\n date,\n mode = \"date_time\",\n timezone\n}: DatePreviewProps): React.ReactElement {\n\n const customizationController = useCustomizationController();\n const configuredLocale = customizationController?.locale;\n\n // The locale arrives asynchronously now (see `date_fns_locales`). Seed from\n // the cache so only the very first date on a page renders un-localised: by\n // the time a table of them mounts, the module is already resolved and there\n // is no second pass.\n const [dateUtilsLocale, setDateUtilsLocale] = React.useState(() => getLoadedDateFnsLocale(configuredLocale));\n React.useEffect(() => {\n let cancelled = false;\n loadDateFnsLocale(configuredLocale)\n .then(loaded => { if (!cancelled) setDateUtilsLocale(loaded); })\n .catch(error => console.error(`[rebase] could not load the \"${configuredLocale}\" date locale`, error));\n return () => { cancelled = true; };\n }, [configuredLocale]);\n\n if (!date || !(date instanceof Date) || isNaN(date.getTime())) {\n return <></>;\n }\n\n // If timezone is specified, format in that timezone using Intl.DateTimeFormat\n if (timezone) {\n // A time of day travels on 1970-01-01; that day is not part of it.\n const options: Intl.DateTimeFormatOptions = mode === \"time\"\n ? { timeZone: timezone }\n : {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n timeZone: timezone\n };\n\n if (mode === \"date_time\" || mode === \"time\") {\n options.hour = \"2-digit\";\n options.minute = \"2-digit\";\n }\n\n const locale = customizationController?.locale ?? \"en-US\";\n const formatter = cachedFormatter(`${locale}|${timezone}|${mode}`, () => new Intl.DateTimeFormat(locale, options));\n const formattedDate = formatter.format(date);\n\n // A day on its own has no time for a zone to qualify.\n const tzAbbrev = mode === \"date_time\"\n ? cachedFormatter(`en-US|${timezone}|zone`, () => new Intl.DateTimeFormat(\"en-US\", {\n timeZone: timezone,\n timeZoneName: \"short\"\n })).formatToParts(date).find(p => p.type === \"timeZoneName\")?.value ?? \"\"\n : \"\";\n\n return (\n // A date is a measured value: the mono tier, tabular, so a column of\n // them lines up and a live one does not jitter. Size and colour are\n // inherited from where it sits — a table cell, a form value.\n <span className=\"flex items-center gap-1 font-mono tabular-nums\">\n {formattedDate}\n {tzAbbrev && (\n <span className=\"text-xs text-slate-500 dark:text-slate-400\">\n ({tzAbbrev})\n </span>\n )}\n </span>\n );\n }\n\n // No timezone specified: use local formatting with date-fns\n let dateFormat: string;\n if (mode === \"time\") {\n dateFormat = \"p\"; // e.g., \"9:30 AM\"\n } else if (mode === \"date\") {\n // Date-only format (no time)\n dateFormat = customizationController?.dateTimeFormat\n ? customizationController.dateTimeFormat.replace(/[, ]*[HhKk].*$/, \"\").trim()\n : \"PP\"; // e.g., \"Apr 29, 2024\"\n } else {\n // Full date-time format\n dateFormat = customizationController?.dateTimeFormat ?? defaultDateFormat;\n }\n\n const formattedDate = format(date, dateFormat, { locale: dateUtilsLocale });\n\n return (\n <span className=\"font-mono tabular-nums\">\n {formattedDate}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgCA,IAAM,6BAAa,IAAI,IAAiC;AACxD,IAAM,iBAAiB;AAEvB,SAAS,gBAAgB,KAAa,OAAuD;CACzF,MAAM,SAAS,WAAW,IAAI,GAAG;CACjC,IAAI,QAAQ,OAAO;CAGnB,MAAM,YAAY,MAAM;CACxB,IAAI,WAAW,QAAQ,gBAAgB,WAAW,MAAM;CACxD,WAAW,IAAI,KAAK,SAAS;CAC7B,OAAO;AACX;;;;AAKA,SAAgB,YAAY,EACxB,MACA,OAAO,aACP,YACqC;CAErC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,mBAAmB,yBAAyB;CAMlD,MAAM,CAAC,iBAAiB,sBAAsB,MAAM,eAAe,uBAAuB,gBAAgB,CAAC;CAC3G,MAAM,gBAAgB;EAClB,IAAI,YAAY;EAChB,kBAAkB,gBAAgB,CAAC,CAC9B,MAAK,WAAU;GAAE,IAAI,CAAC,WAAW,mBAAmB,MAAM;EAAG,CAAC,CAAC,CAC/D,OAAM,UAAS,QAAQ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names":[],"sources":["../../../src/preview/components/DatePreview.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { format } from \"date-fns\";\nimport { useCustomizationController } from \"@rebasepro/app\";\nimport { defaultDateFormat } from \"@rebasepro/utils\";\nimport type { Locale as DateFnsLocale } from \"date-fns\";\nimport { getLoadedDateFnsLocale, loadDateFnsLocale } from \"./date_fns_locales\";\n\nexport interface DatePreviewProps {\n date: Date;\n /**\n * Display mode: \"date\" for date-only, \"date_time\" for date and time,\n * \"time\" for a time of day (a `time` column) with no day at all\n */\n mode?: DatePreviewMode;\n /**\n * IANA timezone identifier (e.g., \"America/New_York\")\n * When specified, the date will be displayed in this timezone\n */\n timezone?: string;\n}\n\n/**\n * `Intl.DateTimeFormat`s already built, for dates shown in a fixed timezone.\n *\n * Building one is the expensive part of formatting (~90 µs, against ~6 µs to\n * format with it), and a table column of zoned dates used to build two per\n * cell per render. Key: locale, timezone and what is shown — everything the\n * options are made of, so a cached formatter formats exactly as a fresh one\n * would. Nothing invalidates an entry: a formatter is a pure function of its\n * key and holds no record data. Bounded anyway, since a timezone can come from\n * data: past the cap the map starts over.\n */\nconst FORMATTERS = new Map<string, Intl.DateTimeFormat>();\nconst MAX_FORMATTERS = 200;\n\nfunction cachedFormatter(key: string, build: () => Intl.DateTimeFormat): Intl.DateTimeFormat {\n const cached = FORMATTERS.get(key);\n if (cached) return cached;\n // Built before it is stored: an unknown timezone throws here exactly as it\n // did uncached, and leaves nothing behind.\n const formatter = build();\n if (FORMATTERS.size >= MAX_FORMATTERS) FORMATTERS.clear();\n FORMATTERS.set(key, formatter);\n return formatter;\n}\n\nexport type DatePreviewMode = \"date\" | \"date_time\" | \"time\";\n\nexport interface DatePreviewFormatOptions {\n mode?: DatePreviewMode;\n timezone?: string;\n /** The admin's configured locale (`customizationController.locale`). */\n locale?: string;\n /** The admin's configured format (`customizationController.dateTimeFormat`). */\n dateTimeFormat?: string;\n /** The date-fns locale matching `locale`, once it has loaded. */\n dateFnsLocale?: DateFnsLocale;\n}\n\n/**\n * The text a `DatePreview` shows, and the zone abbreviation drawn after it.\n *\n * Pulled out of the component so the table can size a date column from the\n * very string its cells will render — see `getDateColumnWidth`. Two copies of\n * this logic would drift, and a column a few characters too narrow wraps every\n * date in it onto a second line the row has no height for.\n */\nexport function formatDatePreview(date: Date, {\n mode = \"date_time\",\n timezone,\n locale,\n dateTimeFormat,\n dateFnsLocale\n}: DatePreviewFormatOptions): { text: string, zone?: string } {\n\n // If timezone is specified, format in that timezone using Intl.DateTimeFormat\n if (timezone) {\n // A time of day travels on 1970-01-01; that day is not part of it.\n const options: Intl.DateTimeFormatOptions = mode === \"time\"\n ? { timeZone: timezone }\n : {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n timeZone: timezone\n };\n\n if (mode === \"date_time\" || mode === \"time\") {\n options.hour = \"2-digit\";\n options.minute = \"2-digit\";\n }\n\n const intlLocale = locale ?? \"en-US\";\n const formatter = cachedFormatter(`${intlLocale}|${timezone}|${mode}`, () => new Intl.DateTimeFormat(intlLocale, options));\n const text = formatter.format(date);\n\n // A day on its own has no time for a zone to qualify.\n const zone = mode === \"date_time\"\n ? cachedFormatter(`en-US|${timezone}|zone`, () => new Intl.DateTimeFormat(\"en-US\", {\n timeZone: timezone,\n timeZoneName: \"short\"\n })).formatToParts(date).find(p => p.type === \"timeZoneName\")?.value\n : undefined;\n\n return {\n text,\n zone: zone || undefined\n };\n }\n\n // No timezone specified: use local formatting with date-fns\n let dateFormat: string;\n if (mode === \"time\") {\n dateFormat = \"p\"; // e.g., \"9:30 AM\"\n } else if (mode === \"date\") {\n // Date-only format (no time)\n dateFormat = dateTimeFormat\n ? dateTimeFormat.replace(/[, ]*[HhKk].*$/, \"\").trim()\n : \"PP\"; // e.g., \"Apr 29, 2024\"\n } else {\n // Full date-time format\n dateFormat = dateTimeFormat ?? defaultDateFormat;\n }\n\n return { text: format(date, dateFormat, { locale: dateFnsLocale }) };\n}\n\n/**\n * The date-fns locale for the admin's configured locale.\n *\n * The locale arrives asynchronously (see `date_fns_locales`). Seeded from the\n * cache so only the very first date on a page renders un-localised: by the\n * time a table of them mounts, the module is already resolved and there is no\n * second pass.\n */\nexport function useDateFnsLocale(): DateFnsLocale | undefined {\n const customizationController = useCustomizationController();\n const configuredLocale = customizationController?.locale;\n const [dateFnsLocale, setDateFnsLocale] = React.useState(() => getLoadedDateFnsLocale(configuredLocale));\n React.useEffect(() => {\n let cancelled = false;\n loadDateFnsLocale(configuredLocale)\n .then(loaded => { if (!cancelled) setDateFnsLocale(loaded); })\n .catch(error => console.error(`[rebase] could not load the \"${configuredLocale}\" date locale`, error));\n return () => { cancelled = true; };\n }, [configuredLocale]);\n return dateFnsLocale;\n}\n\n/**\n * @group Preview components\n */\nexport function DatePreview({\n date,\n mode = \"date_time\",\n timezone\n}: DatePreviewProps): React.ReactElement {\n\n const customizationController = useCustomizationController();\n const dateFnsLocale = useDateFnsLocale();\n\n if (!date || !(date instanceof Date) || isNaN(date.getTime())) {\n return <></>;\n }\n\n const { text, zone } = formatDatePreview(date, {\n mode,\n timezone,\n locale: customizationController?.locale,\n dateTimeFormat: customizationController?.dateTimeFormat,\n dateFnsLocale\n });\n\n // A date is a measured value: the mono tier, tabular, so a column of them\n // lines up and a live one does not jitter. Size and colour are inherited\n // from where it sits — a table cell, a form value. One line, always: a\n // date broken after its year reads as two values, and in a table row the\n // second line is cut off by the row. Too narrow a space ends it in \"…\".\n if (zone) {\n return (\n <span className=\"flex items-center gap-1 min-w-0 font-mono tabular-nums whitespace-nowrap\">\n <span className=\"truncate\">{text}</span>\n <span className=\"shrink-0 text-xs text-slate-500 dark:text-slate-400\">\n ({zone})\n </span>\n </span>\n );\n }\n\n return (\n <span className=\"min-w-0 truncate font-mono tabular-nums\">\n {text}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiCA,IAAM,6BAAa,IAAI,IAAiC;AACxD,IAAM,iBAAiB;AAEvB,SAAS,gBAAgB,KAAa,OAAuD;CACzF,MAA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EAClB,IAAI,YAAY;EAChB,kBAAkB,gBAAgB,CAAC,CAC9B,MAAK,WAAU;GAAE,IAAI,CAAC,WAAW,iBAAiB,MAAM;EAAG,CAAC,CAAC,CAC7D,OAAM,UAAS,QAAQ,MAAM,gCAAgC,iBAAiB,gBAAgB,KAAK,CAAC;EACzG,aAAa;GAAE,YAAY;EAAM;CACrC,GAAG,CAAC,gBAAgB,CAAC;CACrB,OAAO;AACX;;;;AAKA,SAAgB,YAAY,EACxB,MACA,OAAO,aACP,YACqC;CAErC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,gBAAgB,iBAAiB;CAEvC,IAAI,CAAC,QAAQ,EAAE,gBAAgB,SAAS,MAAM,KAAK,QAAQ,CAAC,GACxD,OAAO,oBAAA,UAAA,CAAI,CAAA;CAGf,MAAM,EAAE,MAAM,SAAS,kBAAkB,MAAM;EAC3C;EACA;EACA,QAAQ,yBAAyB;EACjC,gBAAgB,yBAAyB;EACzC;CACJ,CAAC;CAOD,IAAI,MACA,OACI,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACI,oBAAC,QAAD;GAAM,WAAU;aAAY;EAAW,CAAA,GACvC,qBAAC,QAAD;GAAM,WAAU;aAAhB;IAAsE;IAChE;IAAK;GACL;IACJ;;CAId,OACI,oBAAC,QAAD;EAAM,WAAU;YACX;CACC,CAAA;AAEd"}
@@ -253,7 +253,7 @@ function EntityFullScreenRoute({ pathname, navigationEntries, isNew, isCopy }) {
253
253
  },
254
254
  onSaved: (params) => {
255
255
  const newSelectedTab = params.selectedTab;
256
- const newEntityId = params.entityId ?? params.entity.id;
256
+ const newEntityId = params.id;
257
257
  const savedHash = isNew ? "" : hash;
258
258
  navigate(`${recordTabUrl(newEntityId, newSelectedTab)}${savedHash}`, { replace: true });
259
259
  },
@@ -1 +1 @@
1
- {"version":3,"file":"RebaseRoute.js","names":[],"sources":["../../src/routes/RebaseRoute.tsx"],"sourcesContent":["\nimport type { ViewMode, AdminCollection } from \"@rebasepro/cms-types\";\nimport { useLocation } from \"react-router\";\nimport { Suspense, useCallback, useEffect, useRef, useState } from \"react\";\nimport { useNavigate } from \"react-router\";\n// Lazy: the table, the record views and the form behind them are not needed\n// until a collection opens, and a static import here preloaded all of them on\n// the login screen. See components/lazy_record_views.ts.\nimport {\n LazyCollectionViewBinding as CollectionViewBinding,\n LazyDetailViewBinding as DetailViewBinding,\n LazyEditViewBinding as EditViewBinding\n} from \"../components/lazy_record_views\";\nimport { ErrorView, NotFoundPage, useCustomizationController, useTranslation, useUserConfigurationPersistence, useComponentOverride, useNavigationBlocker } from \"@rebasepro/app\";\nimport { resolveCollectionOpenMode } from \"../util/collection_open_mode\";\nimport { isPathWithinRecord } from \"../util/navigation_utils\";\nimport { UnsavedChangesDialog } from \"@rebasepro/app\";\nimport { CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { NavigationViewCollectionInternal, NavigationViewEntityCustomInternal, NavigationViewInternal } from \"@rebasepro/app\";\nimport { getNavigationEntriesFromPath } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useBreadcrumbsController } from \"../hooks/useBreadcrumbsController\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { NavigationLoadingErrorView } from \"../components/NavigationLoadingErrorView\";\nimport { decodeUrlPath, encodeUrlPathSegment, getPathAfterRecord } from \"../hooks/navigation/url_segments\";\n\nexport function RebaseRoute() {\n return <Suspense fallback={<CircularProgressCenter/>}>\n <RebaseRouteContent/>\n </Suspense>;\n}\n\nfunction RebaseRouteContent() {\n\n const location = useLocation();\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const breadcrumbs = useBreadcrumbsController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const navigationState = useNavigationStateController();\n\n const hash = location.hash;\n // `#new_side` is a new record in the side panel, drawn by the side panel\n // (`useBuildSidePanel`); under it this route shows the collection, as it\n // does for `#side`. It contains `#new`, which made a pasted\n // `/c/products#new_side` draw a second, full-screen new form under the panel.\n const isNewInSidePanel = hash.includes(\"#new_side\");\n const isSidePanel = hash.includes(\"#side\") || isNewInSidePanel;\n const isNew = hash.includes(\"#new\") && !isNewInSidePanel;\n const isCopy = hash.includes(\"#copy\");\n const isFullScreen = hash.includes(\"#full\");\n\n const pathname = location.pathname;\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n const navigationEntries = getNavigationEntriesFromPath({\n path: navigationPath,\n collections: collectionRegistry.collections ?? []\n });\n\n useEffect(() => {\n breadcrumbs.set({\n breadcrumbs: navigationEntries.map((entry) => {\n\n if (entry.type === \"entity\") {\n return ({\n title: String(entry.entityId),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"custom_view\") {\n return ({\n title: String(entry.view.name ?? entry.view.key),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"collection\") {\n return ({\n title: entry.collection.name,\n url: urlController.buildUrlCollectionPath(entry.path),\n id: entry.path\n });\n } else {\n throw new Error(\"Unexpected navigation entry type\");\n }\n })\n });\n }, [navigationEntries.map(entry => entry.path).join(\",\")]);\n\n // The collections failed to load, so this URL cannot resolve to anything:\n // say why, rather than spin until a registry that will never fill does, or\n // report the collection as unregistered.\n if (navigationState.navigationLoadingError && !navigationEntries.some((entry) => entry.type === \"collection\")) {\n return <CenteredView>\n <NavigationLoadingErrorView error={navigationState.navigationLoadingError}\n onRetry={navigationState.refreshNavigation}/>\n </CenteredView>;\n }\n\n if (isNew) {\n // New entities always use full-screen mode, even for split-layout collections\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={true}\n isCopy={false}\n />;\n }\n\n if (navigationEntries.length === 1 && navigationEntries[0].type === \"collection\") {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(navigationEntries[0].id);\n if (!collection)\n collection = collectionRegistry.getCollection(navigationEntries[0].slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={navigationEntries[0].slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>\n }\n\n if (isSidePanel) {\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n if (lastCollectionEntry) {\n let collection: AdminCollection<any> | undefined;\n const firstEntry = navigationEntries[0] as NavigationViewCollectionInternal<any>;\n collection = collectionRegistry.getCollection(firstEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstEntry.slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={firstEntry.slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n // Check if this is a simple entity route (collection + entity) for a split-layout collection.\n // If so, render the collection view with the entity shown in the split detail panel\n // instead of the full-screen editor. This keeps the master-detail UX with clean URLs.\n //\n // Also handles subcollection tabs: /c/customers/39/orders produces 3 entries\n // (collection→entity→subcollection). We extract the subcollection slug as selectedTab.\n const lastEntityEntry = navigationEntries.find((entry) => entry.type === \"entity\");\n const firstCollectionEntry = navigationEntries[0];\n if (\n !isFullScreen &&\n !isCopy &&\n firstCollectionEntry?.type === \"collection\" &&\n lastEntityEntry?.type === \"entity\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3)\n ) {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(firstCollectionEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstCollectionEntry.slug);\n\n const effectiveOpenMode = collection\n ? resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n })\n : undefined;\n if (collection && effectiveOpenMode === \"split\") {\n // Extract subcollection tab from the 3rd entry if present\n let selectedTab: string | undefined;\n if (navigationEntries.length === 3) {\n const thirdEntry = navigationEntries[2];\n if (thirdEntry.type === \"collection\") {\n selectedTab = thirdEntry.collection.slug;\n } else if (thirdEntry.type === \"custom_view\") {\n selectedTab = thirdEntry.view.key;\n }\n }\n // Fallback: check for unregistered tabs (e.g. __json, __rebase_history)\n // that aren't parsed as navigation entries\n if (!selectedTab && (navigationEntries.length === 2) && lastEntityEntry) {\n const trailingSegment = getPathAfterRecord(pathname, urlController.buildUrlCollectionPath(lastEntityEntry.path));\n if (trailingSegment) {\n selectedTab = trailingSegment;\n }\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n selectedEntityId={lastEntityEntry.entityId}\n selectedTab={selectedTab}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={isNew}\n isCopy={isCopy}\n />;\n\n}\n\nfunction getSelectedTabFromUrl(isNew: boolean, lastCustomView: NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined) {\n if (isNew) {\n return undefined;\n } else if (lastCustomView) {\n if (lastCustomView.type === \"custom_view\") {\n return lastCustomView.view.key;\n } else if (lastCustomView.type === \"collection\") {\n return lastCustomView.id ?? lastCustomView.slug;\n }\n }\n return undefined;\n}\n\nfunction EntityFullScreenRoute({\n pathname,\n navigationEntries,\n isNew,\n isCopy\n}: {\n pathname: string;\n navigationEntries: NavigationViewInternal[],\n isNew: boolean,\n isCopy: boolean\n}) {\n\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const location = useLocation();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const { t } = useTranslation();\n\n // defaultValues may be carried via location.state when openNewDocument() is called\n // for full-screen mode. We read it once on mount — after that, the form owns its state.\n const defaultValues = (location.state as { defaultValues?: Record<string, unknown> } | null)?.defaultValues;\n\n // Preserve the current hash (e.g. #full) across tab/save navigations\n const hash = location.hash;\n\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n // is navigating away blocked\n const blocked = useRef(false);\n\n const lastEntityEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"entity\");\n const navigationEntriesAfterEntity = lastEntityEntry ? navigationEntries.slice(navigationEntries.indexOf(lastEntityEntry) + 1) : [];\n\n const lastCustomView = [...navigationEntriesAfterEntity].reverse().find(\n (entry) => entry.type === \"custom_view\" || entry.type === \"collection\"\n ) as NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined;\n\n const entityId = lastEntityEntry && \"entityId\" in lastEntityEntry ? lastEntityEntry.entityId : undefined;\n\n // The record's own URL, and the URL of the collection that holds it. Built\n // from the data path, so the id in them is percent-encoded once, however\n // the pathname spells it.\n const recordUrl = lastEntityEntry && entityId !== undefined && !isNew\n ? urlController.buildUrlCollectionPath(lastEntityEntry.path)\n : undefined;\n const basePath = lastEntityEntry && recordUrl !== undefined\n ? urlController.buildUrlCollectionPath(lastEntityEntry.slug)\n : pathname;\n\n // Derive tab from navigation entries (works for registered custom views)\n let urlTab = getSelectedTabFromUrl(isNew, lastCustomView);\n\n // Fallback: internal tabs like __json or __rebase_history aren't registered as\n // entity views, so the navigation parser ignores them. Check the raw pathname\n // for a trailing segment after the entity ID to catch those cases.\n if (!urlTab && recordUrl !== undefined) {\n const trailingSegment = getPathAfterRecord(pathname, recordUrl);\n if (trailingSegment && trailingSegment !== \"edit\") {\n urlTab = trailingSegment;\n }\n }\n\n const [selectedTab, setSelectedTab] = useState<string | undefined>(urlTab);\n\n const parentCollectionSlugs = collectionRegistry.getParentCollectionSlugs(navigationPath);\n const parentEntityIds = collectionRegistry.getParentEntityIds(navigationPath);\n useEffect(() => {\n if (urlTab !== selectedTab) {\n setSelectedTab(urlTab);\n }\n }, [urlTab]);\n\n // The URL of a record in this collection, or of one of its tabs.\n const recordTabUrl = (id: string | number, tab?: string) =>\n `${basePath}/${encodeUrlPathSegment(String(id))}${tab ? \"/\" + encodeUrlPathSegment(tab) : \"\"}`;\n\n // Compared decoded: a location's pathname spells an id the way whoever\n // wrote it encoded it, and these paths are built here.\n const entityPath = decodeUrlPath(recordUrl ?? `${basePath}/${entityId}`);\n const decodedBasePath = decodeUrlPath(basePath);\n\n const blocker = useNavigationBlocker(useCallback(({\n currentLocation,\n nextLocation\n }) => {\n const nextPathname = decodeUrlPath(nextLocation.pathname);\n // Inside this record — a tab, `/edit`. By path segment: a bare\n // prefix let Back to `/c/products/12` out of `/c/products/1` without\n // asking.\n if (isPathWithinRecord(nextPathname, entityPath))\n return false;\n\n // Side panel overlay navigations preserve the underlying form via\n // base_location in router state — no data is lost in either direction.\n\n // Opening a side panel (e.g. clicking a relation arrow)\n const nextHash = nextLocation.hash;\n if (nextHash === \"#side\" || nextHash === \"#new_side\")\n return false;\n\n // Closing a side panel (navigate(-1) back to the form's own path)\n const currentHash = currentLocation.hash;\n if ((currentHash === \"#side\" || currentHash === \"#new_side\") &&\n (nextPathname === decodedBasePath ||\n isPathWithinRecord(nextPathname, entityPath)))\n return false;\n\n return blocked.current;\n }, [entityPath, decodedBasePath]));\n\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n\n if (isNew && !lastCollectionEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n throw new Error(\"INTERNAL: No collection found in the navigation\");\n }\n\n if (!isNew && !lastEntityEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <NotFoundPage/>;\n }\n\n const rawCollection = isNew\n ? (lastCollectionEntry && \"collection\" in lastCollectionEntry ? lastCollectionEntry.collection : undefined)!\n : (lastEntityEntry && \"parentCollection\" in lastEntityEntry ? lastEntityEntry.parentCollection : undefined)!;\n const collection = collectionRegistry.getCollection(rawCollection.slug) || rawCollection;\n const fullIdPath = isNew ? lastCollectionEntry!.slug : lastEntityEntry!.slug;\n const collectionPath = urlController.resolveDatabasePathsFrom(fullIdPath);\n const isEditRoute = pathname.endsWith(\"/edit\") || pathname.split(\"/\").pop() === \"edit\";\n // Determine if this is a detail-view-first collection showing the view page\n const isDetailMode = collection.defaultEntityAction === \"view\" && !isNew && !isCopy && entityId && !isEditRoute;\n\n // A record is full screen either because its collection has no list to show\n // beside it, or because the user folded that list away. Only the second is\n // reversible, and it is reversible by dropping `#full` alone: this is the\n // same URL the split route reads, so the same conditions decide it.\n const splitListAvailable = !isNew && !isCopy && entityId !== undefined &&\n navigationEntries[0]?.type === \"collection\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3) &&\n resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n }) === \"split\";\n\n const showList = splitListAvailable\n ? () => navigate({\n pathname,\n search: location.search,\n hash: \"\"\n })\n : undefined;\n\n if (isDetailMode) {\n return <>\n <DetailViewBinding\n key={collection.slug + \"_view_\" + entityId}\n entityId={entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n onEditClick={() => {\n const editUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`) + \"/edit\";\n navigate(editUrl + hash);\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });\n }}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n />\n </>;\n }\n\n return <>\n <EditViewBinding\n key={collection.slug + \"_\" + (isNew ? \"new\" : (isCopy ? entityId + \"_copy\" : entityId))}\n entityId={isNew ? undefined : entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n copy={isCopy}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n defaultValues={isNew ? defaultValues : undefined}\n onValuesModified={(modified) => blocked.current = modified}\n navigateBack={() => {\n const detailUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`);\n navigate(detailUrl + hash);\n }}\n onSaved={(params) => {\n const newSelectedTab = params.selectedTab;\n const newEntityId = params.entityId ?? params.entity.id;\n const savedHash = isNew ? \"\" : hash;\n navigate(`${recordTabUrl(newEntityId, newSelectedTab)}${savedHash}`, { replace: true });\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n if (isNew || entityId === undefined) {\n return;\n }\n navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });\n }}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n />\n\n <UnsavedChangesDialog\n open={blocker?.state === \"blocked\"}\n handleOk={() => blocker?.proceed?.()}\n handleCancel={() => blocker?.reset?.()}\n body={t(\"unsaved_changes_in_entity\")}/>\n </>;\n}\n\n/**\n * Shown when a URL names a collection the registry cannot resolve.\n *\n * This used to be `return null`, which renders an empty pane inside the app\n * chrome: the sidebar, the nav highlight and the breadcrumb all still work,\n * because those read the collections array directly, while the view itself is\n * blank. Nothing is thrown, and the only trace is a `console.debug` — so the\n * panel looks like it lost its data rather than like it failed to find the\n * collection, and there is no string to search for.\n *\n * A slug containing slashes went unresolvable this way and cost an afternoon to\n * find. The lookup is fixed; this is the part that made it expensive.\n */\nfunction UnresolvedCollectionView({ path }: { path: string }) {\n const { t } = useTranslation();\n // Warn, not debug: this is a route that renders nothing useful, and it\n // should be visible at the console's default level.\n useEffect(() => {\n console.warn(\n `[rebase] No collection is registered for \"${path}\", so this route has nothing to render. ` +\n \"Check that the collection is in the collections array and that its slug matches the URL.\"\n );\n }, [path]);\n\n return <CenteredView>\n <ErrorView\n title={t(\"collection_not_found\")}\n error={t(\"collection_not_found_body\", { path })}\n tooltip={t(\"collection_not_found_hint\")}/>\n </CenteredView>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAc;CAC1B,OAAO,oBAAC,UAAD;EAAU,UAAU,oBAAC,wBAAD,CAAwB,CAAA;YAC/C,oBAAC,oBAAD,CAAoB,CAAA;CACd,CAAA;AACd;AAEA,SAAS,qBAAqB;CAE1B,MAAM,WAAW,YAAY;CAC7B,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,cAAc,yBAAyB;CAC7C,MAAM,wBAAwB,gCAAgC;CAC9D,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,yBAAyB,qBAAqB,mBAAmB,yBAAqB;CAC5F,MAAM,kBAAkB,6BAA6B;CAErD,MAAM,OAAO,SAAS;CAKtB,MAAM,mBAAmB,KAAK,SAAS,WAAW;CAClD,MAAM,cAAc,KAAK,SAAS,OAAO,KAAK;CAC9C,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,CAAC;CACxC,MAAM,SAAS,KAAK,SAAS,OAAO;CACpC,MAAM,eAAe,KAAK,SAAS,OAAO;CAE1C,MAAM,WAAW,SAAS;CAG1B,MAAM,oBAAoB,6BAA6B;EACnD,MAHmB,cAAc,kBAAkB,QAG7C;EACN,aAAa,mBAAmB,eAAe,CAAC;CACpD,CAAC;CAED,gBAAgB;EACZ,YAAY,IAAI,EACZ,aAAa,kBAAkB,KAAK,UAAU;GAE1C,IAAI,MAAM,SAAS,UACf,OAAQ;IACJ,OAAO,OAAO,MAAM,QAAQ;IAC5B,KAAK,cAAc,uBAAuB,MAAM,IAAI;GACxD;QACG,IAAI,MAAM,SAAS,eACtB,OAAQ;IACJ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UAAU;EACnC,oBAAoB,SAAS,QAAQ;EACrC,MAAM,EAAE,2BAA2B;CAAG,CAAA,CAC5C,EAAA,CAAA;AACN;;;;;;;;;;;;;;AAeA,SAAS,yBAAyB,EAAE,QAA0B;CAC1D,MAAM,EAAE,MAAM,eAAe;CAG7B,gBAAgB;EACZ,QAAQ,KACJ,6CAA6C,KAAK,iIAEtD;CACJ,GAAG,CAAC,IAAI,CAAC;CAET,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,WAAD;EACI,OAAO,EAAE,sBAAsB;EAC/B,OAAO,EAAE,6BAA6B,EAAE,KAAK,CAAC;EAC9C,SAAS,EAAE,2BAA2B;CAAG,CAAA,EACnC,CAAA;AAClB"}
1
+ {"version":3,"file":"RebaseRoute.js","names":[],"sources":["../../src/routes/RebaseRoute.tsx"],"sourcesContent":["\nimport type { ViewMode, AdminCollection } from \"@rebasepro/cms-types\";\nimport { useLocation } from \"react-router\";\nimport { Suspense, useCallback, useEffect, useRef, useState } from \"react\";\nimport { useNavigate } from \"react-router\";\n// Lazy: the table, the record views and the form behind them are not needed\n// until a collection opens, and a static import here preloaded all of them on\n// the login screen. See components/lazy_record_views.ts.\nimport {\n LazyCollectionViewBinding as CollectionViewBinding,\n LazyDetailViewBinding as DetailViewBinding,\n LazyEditViewBinding as EditViewBinding\n} from \"../components/lazy_record_views\";\nimport { ErrorView, NotFoundPage, useCustomizationController, useTranslation, useUserConfigurationPersistence, useComponentOverride, useNavigationBlocker } from \"@rebasepro/app\";\nimport { resolveCollectionOpenMode } from \"../util/collection_open_mode\";\nimport { isPathWithinRecord } from \"../util/navigation_utils\";\nimport { UnsavedChangesDialog } from \"@rebasepro/app\";\nimport { CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { NavigationViewCollectionInternal, NavigationViewEntityCustomInternal, NavigationViewInternal } from \"@rebasepro/app\";\nimport { getNavigationEntriesFromPath } from \"@rebasepro/app\";\nimport { toArray } from \"@rebasepro/utils\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useBreadcrumbsController } from \"../hooks/useBreadcrumbsController\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { NavigationLoadingErrorView } from \"../components/NavigationLoadingErrorView\";\nimport { decodeUrlPath, encodeUrlPathSegment, getPathAfterRecord } from \"../hooks/navigation/url_segments\";\n\nexport function RebaseRoute() {\n return <Suspense fallback={<CircularProgressCenter/>}>\n <RebaseRouteContent/>\n </Suspense>;\n}\n\nfunction RebaseRouteContent() {\n\n const location = useLocation();\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const breadcrumbs = useBreadcrumbsController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const navigationState = useNavigationStateController();\n\n const hash = location.hash;\n // `#new_side` is a new record in the side panel, drawn by the side panel\n // (`useBuildSidePanel`); under it this route shows the collection, as it\n // does for `#side`. It contains `#new`, which made a pasted\n // `/c/products#new_side` draw a second, full-screen new form under the panel.\n const isNewInSidePanel = hash.includes(\"#new_side\");\n const isSidePanel = hash.includes(\"#side\") || isNewInSidePanel;\n const isNew = hash.includes(\"#new\") && !isNewInSidePanel;\n const isCopy = hash.includes(\"#copy\");\n const isFullScreen = hash.includes(\"#full\");\n\n const pathname = location.pathname;\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n const navigationEntries = getNavigationEntriesFromPath({\n path: navigationPath,\n collections: collectionRegistry.collections ?? []\n });\n\n useEffect(() => {\n breadcrumbs.set({\n breadcrumbs: navigationEntries.map((entry) => {\n\n if (entry.type === \"entity\") {\n return ({\n title: String(entry.entityId),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"custom_view\") {\n return ({\n title: String(entry.view.name ?? entry.view.key),\n url: urlController.buildUrlCollectionPath(entry.path)\n });\n } else if (entry.type === \"collection\") {\n return ({\n title: entry.collection.name,\n url: urlController.buildUrlCollectionPath(entry.path),\n id: entry.path\n });\n } else {\n throw new Error(\"Unexpected navigation entry type\");\n }\n })\n });\n }, [navigationEntries.map(entry => entry.path).join(\",\")]);\n\n // The collections failed to load, so this URL cannot resolve to anything:\n // say why, rather than spin until a registry that will never fill does, or\n // report the collection as unregistered.\n if (navigationState.navigationLoadingError && !navigationEntries.some((entry) => entry.type === \"collection\")) {\n return <CenteredView>\n <NavigationLoadingErrorView error={navigationState.navigationLoadingError}\n onRetry={navigationState.refreshNavigation}/>\n </CenteredView>;\n }\n\n if (isNew) {\n // New entities always use full-screen mode, even for split-layout collections\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={true}\n isCopy={false}\n />;\n }\n\n if (navigationEntries.length === 1 && navigationEntries[0].type === \"collection\") {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(navigationEntries[0].id);\n if (!collection)\n collection = collectionRegistry.getCollection(navigationEntries[0].slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={navigationEntries[0].slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>\n }\n\n if (isSidePanel) {\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n if (lastCollectionEntry) {\n let collection: AdminCollection<any> | undefined;\n const firstEntry = navigationEntries[0] as NavigationViewCollectionInternal<any>;\n collection = collectionRegistry.getCollection(firstEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstEntry.slug);\n if (!collection) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <UnresolvedCollectionView path={firstEntry.slug}/>;\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n // Check if this is a simple entity route (collection + entity) for a split-layout collection.\n // If so, render the collection view with the entity shown in the split detail panel\n // instead of the full-screen editor. This keeps the master-detail UX with clean URLs.\n //\n // Also handles subcollection tabs: /c/customers/39/orders produces 3 entries\n // (collection→entity→subcollection). We extract the subcollection slug as selectedTab.\n const lastEntityEntry = navigationEntries.find((entry) => entry.type === \"entity\");\n const firstCollectionEntry = navigationEntries[0];\n if (\n !isFullScreen &&\n !isCopy &&\n firstCollectionEntry?.type === \"collection\" &&\n lastEntityEntry?.type === \"entity\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3)\n ) {\n let collection: AdminCollection<any> | undefined;\n collection = collectionRegistry.getCollection(firstCollectionEntry.id);\n if (!collection)\n collection = collectionRegistry.getCollection(firstCollectionEntry.slug);\n\n const effectiveOpenMode = collection\n ? resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n })\n : undefined;\n if (collection && effectiveOpenMode === \"split\") {\n // Extract subcollection tab from the 3rd entry if present\n let selectedTab: string | undefined;\n if (navigationEntries.length === 3) {\n const thirdEntry = navigationEntries[2];\n if (thirdEntry.type === \"collection\") {\n selectedTab = thirdEntry.collection.slug;\n } else if (thirdEntry.type === \"custom_view\") {\n selectedTab = thirdEntry.view.key;\n }\n }\n // Fallback: check for unregistered tabs (e.g. __json, __rebase_history)\n // that aren't parsed as navigation entries\n if (!selectedTab && (navigationEntries.length === 2) && lastEntityEntry) {\n const trailingSegment = getPathAfterRecord(pathname, urlController.buildUrlCollectionPath(lastEntityEntry.path));\n if (trailingSegment) {\n selectedTab = trailingSegment;\n }\n }\n return <ResolvedCollectionView\n key={`collection_view_${collection.slug}`}\n {...collection}\n parentCollectionSlugs={[]} parentEntityIds={[]}\n path={collection.slug}\n updateUrl={true}\n selectedEntityId={lastEntityEntry.entityId}\n selectedTab={selectedTab}\n Actions={toArray(collection.Actions)}/>;\n }\n }\n\n return <EntityFullScreenRoute\n pathname={pathname}\n navigationEntries={navigationEntries}\n isNew={isNew}\n isCopy={isCopy}\n />;\n\n}\n\nfunction getSelectedTabFromUrl(isNew: boolean, lastCustomView: NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined) {\n if (isNew) {\n return undefined;\n } else if (lastCustomView) {\n if (lastCustomView.type === \"custom_view\") {\n return lastCustomView.view.key;\n } else if (lastCustomView.type === \"collection\") {\n return lastCustomView.id ?? lastCustomView.slug;\n }\n }\n return undefined;\n}\n\nfunction EntityFullScreenRoute({\n pathname,\n navigationEntries,\n isNew,\n isCopy\n}: {\n pathname: string;\n navigationEntries: NavigationViewInternal[],\n isNew: boolean,\n isCopy: boolean\n}) {\n\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const location = useLocation();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const { t } = useTranslation();\n\n // defaultValues may be carried via location.state when openNewDocument() is called\n // for full-screen mode. We read it once on mount — after that, the form owns its state.\n const defaultValues = (location.state as { defaultValues?: Record<string, unknown> } | null)?.defaultValues;\n\n // Preserve the current hash (e.g. #full) across tab/save navigations\n const hash = location.hash;\n\n const navigationPath = urlController.urlPathToDataPath(pathname);\n\n // is navigating away blocked\n const blocked = useRef(false);\n\n const lastEntityEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"entity\");\n const navigationEntriesAfterEntity = lastEntityEntry ? navigationEntries.slice(navigationEntries.indexOf(lastEntityEntry) + 1) : [];\n\n const lastCustomView = [...navigationEntriesAfterEntity].reverse().find(\n (entry) => entry.type === \"custom_view\" || entry.type === \"collection\"\n ) as NavigationViewCollectionInternal<any> | NavigationViewEntityCustomInternal<any> | undefined;\n\n const entityId = lastEntityEntry && \"entityId\" in lastEntityEntry ? lastEntityEntry.entityId : undefined;\n\n // The record's own URL, and the URL of the collection that holds it. Built\n // from the data path, so the id in them is percent-encoded once, however\n // the pathname spells it.\n const recordUrl = lastEntityEntry && entityId !== undefined && !isNew\n ? urlController.buildUrlCollectionPath(lastEntityEntry.path)\n : undefined;\n const basePath = lastEntityEntry && recordUrl !== undefined\n ? urlController.buildUrlCollectionPath(lastEntityEntry.slug)\n : pathname;\n\n // Derive tab from navigation entries (works for registered custom views)\n let urlTab = getSelectedTabFromUrl(isNew, lastCustomView);\n\n // Fallback: internal tabs like __json or __rebase_history aren't registered as\n // entity views, so the navigation parser ignores them. Check the raw pathname\n // for a trailing segment after the entity ID to catch those cases.\n if (!urlTab && recordUrl !== undefined) {\n const trailingSegment = getPathAfterRecord(pathname, recordUrl);\n if (trailingSegment && trailingSegment !== \"edit\") {\n urlTab = trailingSegment;\n }\n }\n\n const [selectedTab, setSelectedTab] = useState<string | undefined>(urlTab);\n\n const parentCollectionSlugs = collectionRegistry.getParentCollectionSlugs(navigationPath);\n const parentEntityIds = collectionRegistry.getParentEntityIds(navigationPath);\n useEffect(() => {\n if (urlTab !== selectedTab) {\n setSelectedTab(urlTab);\n }\n }, [urlTab]);\n\n // The URL of a record in this collection, or of one of its tabs.\n const recordTabUrl = (id: string | number, tab?: string) =>\n `${basePath}/${encodeUrlPathSegment(String(id))}${tab ? \"/\" + encodeUrlPathSegment(tab) : \"\"}`;\n\n // Compared decoded: a location's pathname spells an id the way whoever\n // wrote it encoded it, and these paths are built here.\n const entityPath = decodeUrlPath(recordUrl ?? `${basePath}/${entityId}`);\n const decodedBasePath = decodeUrlPath(basePath);\n\n const blocker = useNavigationBlocker(useCallback(({\n currentLocation,\n nextLocation\n }) => {\n const nextPathname = decodeUrlPath(nextLocation.pathname);\n // Inside this record — a tab, `/edit`. By path segment: a bare\n // prefix let Back to `/c/products/12` out of `/c/products/1` without\n // asking.\n if (isPathWithinRecord(nextPathname, entityPath))\n return false;\n\n // Side panel overlay navigations preserve the underlying form via\n // base_location in router state — no data is lost in either direction.\n\n // Opening a side panel (e.g. clicking a relation arrow)\n const nextHash = nextLocation.hash;\n if (nextHash === \"#side\" || nextHash === \"#new_side\")\n return false;\n\n // Closing a side panel (navigate(-1) back to the form's own path)\n const currentHash = currentLocation.hash;\n if ((currentHash === \"#side\" || currentHash === \"#new_side\") &&\n (nextPathname === decodedBasePath ||\n isPathWithinRecord(nextPathname, entityPath)))\n return false;\n\n return blocked.current;\n }, [entityPath, decodedBasePath]));\n\n const lastCollectionEntry = [...navigationEntries].reverse().find((entry) => entry.type === \"collection\");\n\n if (isNew && !lastCollectionEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n throw new Error(\"INTERNAL: No collection found in the navigation\");\n }\n\n if (!isNew && !lastEntityEntry) {\n if (!collectionRegistry.initialised) {\n return <CircularProgressCenter/>;\n }\n return <NotFoundPage/>;\n }\n\n const rawCollection = isNew\n ? (lastCollectionEntry && \"collection\" in lastCollectionEntry ? lastCollectionEntry.collection : undefined)!\n : (lastEntityEntry && \"parentCollection\" in lastEntityEntry ? lastEntityEntry.parentCollection : undefined)!;\n const collection = collectionRegistry.getCollection(rawCollection.slug) || rawCollection;\n const fullIdPath = isNew ? lastCollectionEntry!.slug : lastEntityEntry!.slug;\n const collectionPath = urlController.resolveDatabasePathsFrom(fullIdPath);\n const isEditRoute = pathname.endsWith(\"/edit\") || pathname.split(\"/\").pop() === \"edit\";\n // Determine if this is a detail-view-first collection showing the view page\n const isDetailMode = collection.defaultEntityAction === \"view\" && !isNew && !isCopy && entityId && !isEditRoute;\n\n // A record is full screen either because its collection has no list to show\n // beside it, or because the user folded that list away. Only the second is\n // reversible, and it is reversible by dropping `#full` alone: this is the\n // same URL the split route reads, so the same conditions decide it.\n const splitListAvailable = !isNew && !isCopy && entityId !== undefined &&\n navigationEntries[0]?.type === \"collection\" &&\n (navigationEntries.length === 2 || navigationEntries.length === 3) &&\n resolveCollectionOpenMode({\n collection,\n search: location.search,\n savedViewMode: userConfigPersistence?.getCollectionConfig(collection.slug)?.defaultViewMode as ViewMode | undefined,\n registeredViews: customizationController.collectionViews\n }) === \"split\";\n\n const showList = splitListAvailable\n ? () => navigate({\n pathname,\n search: location.search,\n hash: \"\"\n })\n : undefined;\n\n if (isDetailMode) {\n return <>\n <DetailViewBinding\n key={collection.slug + \"_view_\" + entityId}\n entityId={entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n onEditClick={() => {\n const editUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`) + \"/edit\";\n navigate(editUrl + hash);\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });\n }}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n />\n </>;\n }\n\n return <>\n <EditViewBinding\n key={collection.slug + \"_\" + (isNew ? \"new\" : (isCopy ? entityId + \"_copy\" : entityId))}\n entityId={isNew ? undefined : entityId}\n collection={collection}\n layout={\"full_screen\"}\n path={collectionPath}\n copy={isCopy}\n selectedTab={selectedTab ?? undefined}\n onShowList={showList}\n defaultValues={isNew ? defaultValues : undefined}\n onValuesModified={(modified) => blocked.current = modified}\n navigateBack={() => {\n const detailUrl = urlController.buildUrlCollectionPath(`${collectionPath}/${entityId}`);\n navigate(detailUrl + hash);\n }}\n onSaved={(params) => {\n const newSelectedTab = params.selectedTab;\n const newEntityId = params.id;\n const savedHash = isNew ? \"\" : hash;\n navigate(`${recordTabUrl(newEntityId, newSelectedTab)}${savedHash}`, { replace: true });\n }}\n onTabChange={(params) => {\n setSelectedTab(params.selectedTab);\n if (isNew || entityId === undefined) {\n return;\n }\n navigate(`${recordTabUrl(entityId, params.selectedTab)}${hash}`, { replace: true });\n }}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n />\n\n <UnsavedChangesDialog\n open={blocker?.state === \"blocked\"}\n handleOk={() => blocker?.proceed?.()}\n handleCancel={() => blocker?.reset?.()}\n body={t(\"unsaved_changes_in_entity\")}/>\n </>;\n}\n\n/**\n * Shown when a URL names a collection the registry cannot resolve.\n *\n * This used to be `return null`, which renders an empty pane inside the app\n * chrome: the sidebar, the nav highlight and the breadcrumb all still work,\n * because those read the collections array directly, while the view itself is\n * blank. Nothing is thrown, and the only trace is a `console.debug` — so the\n * panel looks like it lost its data rather than like it failed to find the\n * collection, and there is no string to search for.\n *\n * A slug containing slashes went unresolvable this way and cost an afternoon to\n * find. The lookup is fixed; this is the part that made it expensive.\n */\nfunction UnresolvedCollectionView({ path }: { path: string }) {\n const { t } = useTranslation();\n // Warn, not debug: this is a route that renders nothing useful, and it\n // should be visible at the console's default level.\n useEffect(() => {\n console.warn(\n `[rebase] No collection is registered for \"${path}\", so this route has nothing to render. ` +\n \"Check that the collection is in the collections array and that its slug matches the URL.\"\n );\n }, [path]);\n\n return <CenteredView>\n <ErrorView\n title={t(\"collection_not_found\")}\n error={t(\"collection_not_found_body\", { path })}\n tooltip={t(\"collection_not_found_hint\")}/>\n </CenteredView>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAc;CAC1B,OAAO,oBAAC,UAAD;EAAU,UAAU,oBAAC,wBAAD,CAAwB,CAAA;YAC/C,oBAAC,oBAAD,CAAoB,CAAA;CACd,CAAA;AACd;AAEA,SAAS,qBAAqB;CAE1B,MAAM,WAAW,YAAY;CAC7B,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,cAAc,yBAAyB;CAC7C,MAAM,wBAAwB,gCAAgC;CAC9D,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,yBAAyB,qBAAqB,mBAAmB,yBAAqB;CAC5F,MAAM,kBAAkB,6BAA6B;CAErD,MAAM,OAAO,SAAS;CAKtB,MAAM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AU;GACtF,SAAS,YAAY,IAAI;EAC7B;EACA,UAAU,WAAW;GACjB,MAAM,iBAAiB,OAAO;GAC9B,MAAM,cAAc,OAAO;GAC3B,MAAM,YAAY,QAAQ,KAAK;GAC/B,SAAS,GAAG,aAAa,aAAa,cAAc,IAAI,aAAa,EAAE,SAAS,KAAK,CAAC;EAC1F;EACA,cAAc,WAAW;GACrB,eAAe,OAAO,WAAW;GACjC,IAAI,SAAS,aAAa,KAAA,GACtB;GAEJ,SAAS,GAAG,aAAa,UAAU,OAAO,WAAW,IAAI,QAAQ,EAAE,SAAS,KAAK,CAAC;EACtF;EACuB;EAAwC;CAClE,GA5BQ,WAAW,OAAO,OAAO,QAAQ,QAAS,SAAS,WAAW,UAAU,SA4BhF,GAED,oBAAC,sBAAD;EACI,MAAM,SAAS,UAAU;EACzB,gBAAgB,SAAS,UAAU;EACnC,oBAAoB,SAAS,QAAQ;EACrC,MAAM,EAAE,2BAA2B;CAAG,CAAA,CAC5C,EAAA,CAAA;AACN;;;;;;;;;;;;;;AAeA,SAAS,yBAAyB,EAAE,QAA0B;CAC1D,MAAM,EAAE,MAAM,eAAe;CAG7B,gBAAgB;EACZ,QAAQ,KACJ,6CAA6C,KAAK,iIAEtD;CACJ,GAAG,CAAC,IAAI,CAAC;CAET,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,WAAD;EACI,OAAO,EAAE,sBAAsB;EAC/B,OAAO,EAAE,6BAA6B,EAAE,KAAK,CAAC;EAC9C,SAAS,EAAE,2BAA2B;CAAG,CAAA,EACnC,CAAA;AAClB"}
@@ -1,10 +1,12 @@
1
1
  import React from "react";
2
- import { Entity } from "@rebasepro/types";
2
+ import type { CollectionConfig } from "@rebasepro/types";
3
3
  import { SelectionController, SelectionQuery } from "@rebasepro/cms-types";
4
4
  export interface SelectionMenuProps<M extends Record<string, unknown>> {
5
5
  selectionController: SelectionController<M>;
6
6
  /** The rows the view is holding right now. */
7
- loadedEntities: Entity<M>[];
7
+ loadedRows: Record<string, unknown>[];
8
+ /** The rows' collection: what a row's id is read by. */
9
+ collection: CollectionConfig;
8
10
  /** The view's live query — what "all matching" stands for. */
9
11
  query: SelectionQuery<M>;
10
12
  /** The view's filtered count. `undefined` while loading, or where the accessor has none. */
@@ -24,4 +26,4 @@ export interface SelectionMenuProps<M extends Record<string, unknown>> {
24
26
  * So the escalation is a menu item — clicked deliberately, costing no layout,
25
27
  * and in the place you already go to select everything.
26
28
  */
27
- export declare function SelectionMenu<M extends Record<string, unknown>>({ selectionController, loadedEntities, query, collectionEntitiesCount, collectionName }: SelectionMenuProps<M>): React.JSX.Element;
29
+ export declare function SelectionMenu<M extends Record<string, unknown>>({ selectionController, loadedRows, collection, query, collectionEntitiesCount, collectionName }: SelectionMenuProps<M>): React.JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { Checkbox, ChevronDownIcon, Menu, MenuItem, Tooltip, cls, iconSize } from "@rebasepro/ui";
4
- import { useTranslation } from "@rebasepro/app";
4
+ import { idOfRow, useTranslation } from "@rebasepro/app";
5
5
  //#region src/selection/SelectionMenu.tsx
6
6
  /**
7
7
  * The whole of selecting rows, in one control: a checkbox for the common case
@@ -16,14 +16,21 @@ import { useTranslation } from "@rebasepro/app";
16
16
  * So the escalation is a menu item — clicked deliberately, costing no layout,
17
17
  * and in the place you already go to select everything.
18
18
  */
19
- function SelectionMenu({ selectionController, loadedEntities, query, collectionEntitiesCount, collectionName }) {
19
+ function SelectionMenu({ selectionController, loadedRows, collection, query, collectionEntitiesCount, collectionName }) {
20
20
  const { t } = useTranslation();
21
- const { selection, selectedCount, hasSelection, isEntitySelected, setSelectedEntities, selectAllMatching, clearSelection } = selectionController;
22
- const selectedLoaded = useMemo(() => loadedEntities.filter((e) => isEntitySelected(e)).length, [loadedEntities, isEntitySelected]);
23
- const allLoadedSelected = loadedEntities.length > 0 && selectedLoaded === loadedEntities.length;
21
+ const { selection, selectedCount, hasSelection, isSelected, setSelectedRows, selectAllMatching, clearSelection } = selectionController;
22
+ const selectedLoaded = useMemo(() => loadedRows.filter((row) => {
23
+ const id = idOfRow(row, collection);
24
+ return id !== void 0 && isSelected(id);
25
+ }).length, [
26
+ loadedRows,
27
+ collection,
28
+ isSelected
29
+ ]);
30
+ const allLoadedSelected = loadedRows.length > 0 && selectedLoaded === loadedRows.length;
24
31
  const someSelected = selectedLoaded > 0 && !allLoadedSelected;
25
32
  const isQuery = selection.type === "query";
26
- const moreThanLoaded = collectionEntitiesCount !== void 0 && collectionEntitiesCount > loadedEntities.length;
33
+ const moreThanLoaded = collectionEntitiesCount !== void 0 && collectionEntitiesCount > loadedRows.length;
27
34
  const label = hasSelection ? t("selection_deselect_all") ?? "Deselect all" : t("selection_select_all_loaded") ?? "Select all loaded rows";
28
35
  return /* @__PURE__ */ jsxs("div", {
29
36
  className: cls("flex items-center rounded-md", hasSelection && "bg-surface-hover"),
@@ -36,11 +43,11 @@ function SelectionMenu({ selectionController, loadedEntities, query, collectionE
36
43
  size: "small",
37
44
  padding: false,
38
45
  "aria-label": label,
39
- disabled: loadedEntities.length === 0 && !isQuery,
46
+ disabled: loadedRows.length === 0 && !isQuery,
40
47
  checked: allLoadedSelected || isQuery,
41
48
  indeterminate: someSelected,
42
49
  onCheckedChange: (checked) => {
43
- if (checked) setSelectedEntities(loadedEntities);
50
+ if (checked) setSelectedRows(loadedRows);
44
51
  else clearSelection();
45
52
  }
46
53
  })
@@ -57,7 +64,7 @@ function SelectionMenu({ selectionController, loadedEntities, query, collectionE
57
64
  children: [
58
65
  /* @__PURE__ */ jsx(MenuItem, {
59
66
  dense: true,
60
- onClick: () => setSelectedEntities(loadedEntities),
67
+ onClick: () => setSelectedRows(loadedRows),
61
68
  children: t("selection_menu_all_loaded") ?? "All on this page"
62
69
  }),
63
70
  moreThanLoaded && /* @__PURE__ */ jsx(MenuItem, {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionMenu.js","names":[],"sources":["../../src/selection/SelectionMenu.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { SelectionController, SelectionQuery } from \"@rebasepro/cms-types\";\nimport { Checkbox, ChevronDownIcon, Menu, MenuItem, Tooltip, cls, iconSize } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\n\nexport interface SelectionMenuProps<M extends Record<string, unknown>> {\n selectionController: SelectionController<M>;\n /** The rows the view is holding right now. */\n loadedEntities: Entity<M>[];\n /** The view's live query — what \"all matching\" stands for. */\n query: SelectionQuery<M>;\n /** The view's filtered count. `undefined` while loading, or where the accessor has none. */\n collectionEntitiesCount?: number;\n collectionName: string;\n}\n\n/**\n * The whole of selecting rows, in one control: a checkbox for the common case\n * and a caret for everything else.\n *\n * The escalation from \"the rows on screen\" to \"every row that matches\" lived in\n * a strip under the toolbar, which was wrong in a way that only shows up in\n * use: it appears the moment you tick a single checkbox, and the list you were\n * reading jumps down by its height. A control that punishes the first click is\n * not worth whatever the strip was explaining.\n *\n * So the escalation is a menu item — clicked deliberately, costing no layout,\n * and in the place you already go to select everything.\n */\nexport function SelectionMenu<M extends Record<string, unknown>>({\n selectionController,\n loadedEntities,\n query,\n collectionEntitiesCount,\n collectionName\n}: SelectionMenuProps<M>) {\n\n const { t } = useTranslation();\n const {\n selection,\n selectedCount,\n hasSelection,\n isEntitySelected,\n setSelectedEntities,\n selectAllMatching,\n clearSelection\n } = selectionController;\n\n const selectedLoaded = useMemo(\n () => loadedEntities.filter(e => isEntitySelected(e)).length,\n [loadedEntities, isEntitySelected]\n );\n\n const allLoadedSelected = loadedEntities.length > 0 && selectedLoaded === loadedEntities.length;\n const someSelected = selectedLoaded > 0 && !allLoadedSelected;\n const isQuery = selection.type === \"query\";\n\n // The count can outrun the loaded rows without there being more to select —\n // it is fetched separately and settles at its own pace.\n const moreThanLoaded = collectionEntitiesCount !== undefined\n && collectionEntitiesCount > loadedEntities.length;\n\n const label = hasSelection\n ? (t(\"selection_deselect_all\") ?? \"Deselect all\")\n : (t(\"selection_select_all_loaded\") ?? \"Select all loaded rows\");\n\n return (\n <div className={cls(\"flex items-center rounded-md\",\n hasSelection && \"bg-surface-hover\")}>\n\n <Tooltip title={label}>\n <div className=\"pl-1.5 pr-0.5 py-1 flex items-center\">\n <Checkbox\n size=\"small\"\n padding={false}\n aria-label={label}\n disabled={loadedEntities.length === 0 && !isQuery}\n checked={allLoadedSelected || isQuery}\n indeterminate={someSelected}\n onCheckedChange={(checked) => {\n if (checked) setSelectedEntities(loadedEntities);\n else clearSelection();\n }}/>\n </div>\n </Tooltip>\n\n <Menu\n align=\"start\"\n trigger={\n <button\n type=\"button\"\n aria-label={t(\"selection_options\") ?? \"Selection options\"}\n className={cls(\n \"pr-1 pl-0 py-1 flex items-center rounded-r-md\",\n \"hover:bg-surface-hover focus:outline-none\",\n \"text-surface-accent-500 dark:text-surface-accent-300\"\n )}>\n <ChevronDownIcon size={iconSize.smallest}/>\n </button>\n }>\n\n <MenuItem dense onClick={() => setSelectedEntities(loadedEntities)}>\n {t(\"selection_menu_all_loaded\") ?? \"All on this page\"}\n </MenuItem>\n\n {/* The point of the whole feature, and the only place it is\n offered. Absent when the view already holds every matching\n row, because then it is the item above under another name. */}\n {moreThanLoaded && <MenuItem\n dense\n onClick={() => selectAllMatching(query, collectionEntitiesCount)}>\n {t(\"selection_menu_all_matching\", {\n total: collectionEntitiesCount!.toLocaleString(),\n collection: collectionName\n }) ?? `All ${collectionEntitiesCount!.toLocaleString()} ${collectionName}`}\n </MenuItem>}\n\n <MenuItem dense disabled={!hasSelection} onClick={clearSelection}>\n {t(\"selection_menu_none\") ?? \"None\"}\n </MenuItem>\n </Menu>\n\n {/* What is selected, where the control is — not in a strip that\n moves the rows. `undefined` is \"every matching row, and nobody\n knows how many\", which is why it is not defaulted to a number. */}\n {hasSelection && <span\n data-testid=\"selection-count\"\n className=\"pl-1 pr-2 text-xs font-mono tabular-nums text-text-secondary dark:text-text-secondary-dark\">\n {selectedCount === undefined ? \"…\" : selectedCount.toLocaleString()}\n </span>}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,SAAgB,cAAiD,EAC7D,qBACA,gBACA,OACA,yBACA,kBACsB;CAEtB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EACF,WACA,eACA,cACA,kBACA,qBACA,mBACA,mBACA;CAEJ,MAAM,iBAAiB,cACb,eAAe,QAAO,MAAK,iBAAiB,CAAC,CAAC,CAAC,CAAC,QACtD,CAAC,gBAAgB,gBAAgB,CACrC;CAEA,MAAM,oBAAoB,eAAe,SAAS,KAAK,mBAAmB,eAAe;CACzF,MAAM,eAAe,iBAAiB,KAAK,CAAC;CAC5C,MAAM,UAAU,UAAU,SAAS;CAInC,MAAM,iBAAiB,4BAA4B,KAAA,KAC5C,0BAA0B,eAAe;CAEhD,MAAM,QAAQ,eACP,EAAE,wBAAwB,KAAK,iBAC/B,EAAE,6BAA6B,KAAK;CAE3C,OACI,qBAAC,OAAD;EAAK,WAAW,IAAI,gCAChB,gBAAgB,kBAAkB;YADtC;GAGI,oBAAC,SAAD;IAAS,OAAO;cACZ,oBAAC,OAAD;KAAK,WAAU;eACX,oBAAC,UAAD;MACI,MAAK;MACL,SAAS;MACT,cAAY;MACZ,UAAU,eAAe,WAAW,KAAK,CAAC;MAC1C,SAAS,qBAAqB;MAC9B,eAAe;MACf,kBAAkB,YAAY;OAC1B,IAAI,SAAS,oBAAoB,cAAc;YAC1C,eAAe;MACxB;KAAG,CAAA;IACN,CAAA;GACA,CAAA;GAET,qBAAC,MAAD;IACI,OAAM;IACN,SACI,oBAAC,UAAD;KACI,MAAK;KACL,cAAY,EAAE,mBAAmB,KAAK;KACtC,WAAW,IACP,iDACA,6CACA,sDACJ;eACA,oBAAC,iBAAD,EAAiB,MAAM,SAAS,SAAU,CAAA;IACtC,CAAA;cAZhB;KAeI,oBAAC,UAAD;MAAU,OAAA;MAAM,eAAe,oBAAoB,cAAc;gBAC5D,EAAE,2BAA2B,KAAK;KAC7B,CAAA;KAKT,kBAAkB,oBAAC,UAAD;MACf,OAAA;MACA,eAAe,kBAAkB,OAAO,uBAAuB;gBAC9D,EAAE,+BAA+B;OAC9B,OAAO,wBAAyB,eAAe;OAC/C,YAAY;MAChB,CAAC,KAAK,OAAO,wBAAyB,eAAe,EAAE,GAAG;KACpD,CAAA;KAEV,oBAAC,UAAD;MAAU,OAAA;MAAM,UAAU,CAAC;MAAc,SAAS;gBAC7C,EAAE,qBAAqB,KAAK;KACvB,CAAA;IACR;;GAKL,gBAAgB,oBAAC,QAAD;IACb,eAAY;IACZ,WAAU;cACT,kBAAkB,KAAA,IAAY,MAAM,cAAc,eAAe;GAChE,CAAA;EACL;;AAEb"}
1
+ {"version":3,"file":"SelectionMenu.js","names":[],"sources":["../../src/selection/SelectionMenu.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport type { CollectionConfig } from \"@rebasepro/types\";\nimport { SelectionController, SelectionQuery } from \"@rebasepro/cms-types\";\nimport { Checkbox, ChevronDownIcon, Menu, MenuItem, Tooltip, cls, iconSize } from \"@rebasepro/ui\";\nimport { idOfRow, useTranslation } from \"@rebasepro/app\";\n\nexport interface SelectionMenuProps<M extends Record<string, unknown>> {\n selectionController: SelectionController<M>;\n /** The rows the view is holding right now. */\n loadedRows: Record<string, unknown>[];\n /** The rows' collection: what a row's id is read by. */\n collection: CollectionConfig;\n /** The view's live query — what \"all matching\" stands for. */\n query: SelectionQuery<M>;\n /** The view's filtered count. `undefined` while loading, or where the accessor has none. */\n collectionEntitiesCount?: number;\n collectionName: string;\n}\n\n/**\n * The whole of selecting rows, in one control: a checkbox for the common case\n * and a caret for everything else.\n *\n * The escalation from \"the rows on screen\" to \"every row that matches\" lived in\n * a strip under the toolbar, which was wrong in a way that only shows up in\n * use: it appears the moment you tick a single checkbox, and the list you were\n * reading jumps down by its height. A control that punishes the first click is\n * not worth whatever the strip was explaining.\n *\n * So the escalation is a menu item — clicked deliberately, costing no layout,\n * and in the place you already go to select everything.\n */\nexport function SelectionMenu<M extends Record<string, unknown>>({\n selectionController,\n loadedRows,\n collection,\n query,\n collectionEntitiesCount,\n collectionName\n}: SelectionMenuProps<M>) {\n\n const { t } = useTranslation();\n const {\n selection,\n selectedCount,\n hasSelection,\n isSelected,\n setSelectedRows,\n selectAllMatching,\n clearSelection\n } = selectionController;\n\n const selectedLoaded = useMemo(\n () => loadedRows.filter(row => {\n const id = idOfRow(row, collection);\n return id !== undefined && isSelected(id);\n }).length,\n [loadedRows, collection, isSelected]\n );\n\n const allLoadedSelected = loadedRows.length > 0 && selectedLoaded === loadedRows.length;\n const someSelected = selectedLoaded > 0 && !allLoadedSelected;\n const isQuery = selection.type === \"query\";\n\n // The count can outrun the loaded rows without there being more to select —\n // it is fetched separately and settles at its own pace.\n const moreThanLoaded = collectionEntitiesCount !== undefined\n && collectionEntitiesCount > loadedRows.length;\n\n const label = hasSelection\n ? (t(\"selection_deselect_all\") ?? \"Deselect all\")\n : (t(\"selection_select_all_loaded\") ?? \"Select all loaded rows\");\n\n return (\n <div className={cls(\"flex items-center rounded-md\",\n hasSelection && \"bg-surface-hover\")}>\n\n <Tooltip title={label}>\n <div className=\"pl-1.5 pr-0.5 py-1 flex items-center\">\n <Checkbox\n size=\"small\"\n padding={false}\n aria-label={label}\n disabled={loadedRows.length === 0 && !isQuery}\n checked={allLoadedSelected || isQuery}\n indeterminate={someSelected}\n onCheckedChange={(checked) => {\n if (checked) setSelectedRows(loadedRows);\n else clearSelection();\n }}/>\n </div>\n </Tooltip>\n\n <Menu\n align=\"start\"\n trigger={\n <button\n type=\"button\"\n aria-label={t(\"selection_options\") ?? \"Selection options\"}\n className={cls(\n \"pr-1 pl-0 py-1 flex items-center rounded-r-md\",\n \"hover:bg-surface-hover focus:outline-none\",\n \"text-surface-accent-500 dark:text-surface-accent-300\"\n )}>\n <ChevronDownIcon size={iconSize.smallest}/>\n </button>\n }>\n\n <MenuItem dense onClick={() => setSelectedRows(loadedRows)}>\n {t(\"selection_menu_all_loaded\") ?? \"All on this page\"}\n </MenuItem>\n\n {/* The point of the whole feature, and the only place it is\n offered. Absent when the view already holds every matching\n row, because then it is the item above under another name. */}\n {moreThanLoaded && <MenuItem\n dense\n onClick={() => selectAllMatching(query, collectionEntitiesCount)}>\n {t(\"selection_menu_all_matching\", {\n total: collectionEntitiesCount!.toLocaleString(),\n collection: collectionName\n }) ?? `All ${collectionEntitiesCount!.toLocaleString()} ${collectionName}`}\n </MenuItem>}\n\n <MenuItem dense disabled={!hasSelection} onClick={clearSelection}>\n {t(\"selection_menu_none\") ?? \"None\"}\n </MenuItem>\n </Menu>\n\n {/* What is selected, where the control is — not in a strip that\n moves the rows. `undefined` is \"every matching row, and nobody\n knows how many\", which is why it is not defaulted to a number. */}\n {hasSelection && <span\n data-testid=\"selection-count\"\n className=\"pl-1 pr-2 text-xs font-mono tabular-nums text-text-secondary dark:text-text-secondary-dark\">\n {selectedCount === undefined ? \"…\" : selectedCount.toLocaleString()}\n </span>}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgCA,SAAgB,cAAiD,EAC7D,qBACA,YACA,YACA,OACA,yBACA,kBACsB;CAEtB,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,EACF,WACA,eACA,cACA,YACA,iBACA,mBACA,mBACA;CAEJ,MAAM,iBAAiB,cACb,WAAW,QAAO,QAAO;EAC3B,MAAM,KAAK,QAAQ,KAAK,UAAU;EAClC,OAAO,OAAO,KAAA,KAAa,WAAW,EAAE;CAC5C,CAAC,CAAC,CAAC,QACH;EAAC;EAAY;EAAY;CAAU,CACvC;CAEA,MAAM,oBAAoB,WAAW,SAAS,KAAK,mBAAmB,WAAW;CACjF,MAAM,eAAe,iBAAiB,KAAK,CAAC;CAC5C,MAAM,UAAU,UAAU,SAAS;CAInC,MAAM,iBAAiB,4BAA4B,KAAA,KAC5C,0BAA0B,WAAW;CAE5C,MAAM,QAAQ,eACP,EAAE,wBAAw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indParams, resolveSelection } from "./resolve_selection.js";
2
+ export type { ResolveSelectionParams, ResolvedSelection } from "./resolve_selection.js";
2
3
  export * from "./SelectionMenu.js";