@rebasepro/cms 0.28.2 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/README.md +3 -3
  2. package/dist/collection_editor/_cms_internals.d.ts +0 -1
  3. package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
  4. package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
  5. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
  6. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
  7. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
  8. package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
  9. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
  10. package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
  11. package/dist/components/AdditionalFieldValue.d.ts +9 -3
  12. package/dist/components/AdditionalFieldValue.js +7 -4
  13. package/dist/components/AdditionalFieldValue.js.map +1 -1
  14. package/dist/components/CollectionPanel.d.ts +117 -18
  15. package/dist/components/CollectionPanel.js +115 -37
  16. package/dist/components/CollectionPanel.js.map +1 -1
  17. package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
  18. package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
  19. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
  20. package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
  21. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
  22. package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
  23. package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
  24. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
  25. package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
  26. package/dist/components/CollectionTableBinding/column_utils.js +6 -3
  27. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
  28. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
  29. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
  30. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
  31. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  32. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
  33. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
  34. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
  35. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
  36. package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
  37. package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
  38. package/dist/components/CollectionTableBinding/internal/common.js +88 -4
  39. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
  40. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
  41. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  42. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
  43. package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
  44. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  45. package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
  46. package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
  47. package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
  48. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
  49. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
  50. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
  51. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
  52. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
  53. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  54. package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
  55. package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
  56. package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
  57. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
  58. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
  59. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  60. package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
  61. package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
  62. package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
  63. package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
  64. package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
  65. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  66. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
  67. package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
  68. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  69. package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
  70. package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
  71. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
  72. package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
  73. package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
  74. package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
  75. package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
  76. package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
  77. package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
  78. package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
  79. package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
  80. package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
  81. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
  82. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
  83. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
  84. package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
  85. package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
  86. package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
  87. package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
  88. package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
  89. package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
  90. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
  91. package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
  92. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  93. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
  94. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
  95. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
  96. package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
  97. package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
  98. package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
  99. package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
  100. package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
  101. package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
  102. package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
  103. package/dist/components/CollectionViewBinding/RowActions.js +60 -0
  104. package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
  105. package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
  106. package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
  107. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
  108. package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
  109. package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
  110. package/dist/components/CollectionViewBinding/fields.js +47 -0
  111. package/dist/components/CollectionViewBinding/fields.js.map +1 -0
  112. package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
  113. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
  114. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
  115. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
  116. package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
  117. package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
  118. package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
  119. package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
  120. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
  121. package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
  122. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  123. package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
  124. package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
  125. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
  126. package/dist/components/CollectionsProvider.d.ts +3 -3
  127. package/dist/components/CollectionsProvider.js +4 -4
  128. package/dist/components/CollectionsProvider.js.map +1 -1
  129. package/dist/components/CollectionsScopeContext.d.ts +1 -1
  130. package/dist/components/CollectionsScopeContext.js +1 -1
  131. package/dist/components/CollectionsScopeContext.js.map +1 -1
  132. package/dist/components/DeleteEntityDialog.d.ts +1 -1
  133. package/dist/components/DeleteEntityDialog.js +2 -2
  134. package/dist/components/DeleteEntityDialog.js.map +1 -1
  135. package/dist/components/DetailViewBinding.js +32 -68
  136. package/dist/components/DetailViewBinding.js.map +1 -1
  137. package/dist/components/EditFormActions.js +5 -4
  138. package/dist/components/EditFormActions.js.map +1 -1
  139. package/dist/components/EditViewBinding.d.ts +2 -2
  140. package/dist/components/EditViewBinding.js +25 -15
  141. package/dist/components/EditViewBinding.js.map +1 -1
  142. package/dist/components/EntityDisplayHeader.js +8 -5
  143. package/dist/components/EntityDisplayHeader.js.map +1 -1
  144. package/dist/components/EntityPreviewBinding.js +1 -1
  145. package/dist/components/EntityPreviewBinding.js.map +1 -1
  146. package/dist/components/EntityViewBinding.d.ts +8 -1
  147. package/dist/components/EntityViewBinding.js +43 -14
  148. package/dist/components/EntityViewBinding.js.map +1 -1
  149. package/dist/components/EntityViewBody.d.ts +40 -0
  150. package/dist/components/EntityViewBody.js +90 -0
  151. package/dist/components/EntityViewBody.js.map +1 -0
  152. package/dist/components/FieldValue.d.ts +50 -0
  153. package/dist/components/FieldValue.js +81 -0
  154. package/dist/components/FieldValue.js.map +1 -0
  155. package/dist/components/InlineEntityPreview.js +1 -1
  156. package/dist/components/InlineEntityPreview.js.map +1 -1
  157. package/dist/components/PanelNotFound.d.ts +5 -0
  158. package/dist/components/PanelNotFound.js +21 -0
  159. package/dist/components/PanelNotFound.js.map +1 -0
  160. package/dist/components/RebaseCMS.d.ts +1 -1
  161. package/dist/components/RebaseCMS.js +11 -3
  162. package/dist/components/RebaseCMS.js.map +1 -1
  163. package/dist/components/RebaseNavigation.js +9 -3
  164. package/dist/components/RebaseNavigation.js.map +1 -1
  165. package/dist/components/RebaseShell.js +10 -5
  166. package/dist/components/RebaseShell.js.map +1 -1
  167. package/dist/components/RecordDetail.d.ts +61 -0
  168. package/dist/components/RecordDetail.js +123 -0
  169. package/dist/components/RecordDetail.js.map +1 -0
  170. package/dist/components/RecordForm.d.ts +126 -0
  171. package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
  172. package/dist/components/RecordForm.js.map +1 -0
  173. package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
  174. package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
  175. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  176. package/dist/components/ReferenceWidget.d.ts +5 -3
  177. package/dist/components/ReferenceWidget.js +10 -7
  178. package/dist/components/ReferenceWidget.js.map +1 -1
  179. package/dist/components/RelationSelector.js +4 -4
  180. package/dist/components/RelationSelector.js.map +1 -1
  181. package/dist/components/SelectableTable/SelectableTable.js +2 -3
  182. package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
  183. package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
  184. package/dist/components/SelectableTable/SelectionStore.js +1 -1
  185. package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
  186. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
  187. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
  188. package/dist/components/SidePanelBinding.js +13 -12
  189. package/dist/components/SidePanelBinding.js.map +1 -1
  190. package/dist/components/collection_prop.d.ts +18 -0
  191. package/dist/components/collection_prop.js +23 -0
  192. package/dist/components/collection_prop.js.map +1 -0
  193. package/dist/components/common/default_entity_actions.js +54 -54
  194. package/dist/components/common/default_entity_actions.js.map +1 -1
  195. package/dist/components/history/EntityHistoryView.d.ts +4 -1
  196. package/dist/components/history/EntityHistoryView.js +1 -1
  197. package/dist/components/history/EntityHistoryView.js.map +1 -1
  198. package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
  199. package/dist/components/index.d.ts +4 -2
  200. package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
  201. package/dist/data_export/export/ExportCollectionAction.js +4 -3
  202. package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
  203. package/dist/data_export/export/additional_fields.d.ts +6 -3
  204. package/dist/data_export/export/additional_fields.js +8 -4
  205. package/dist/data_export/export/additional_fields.js.map +1 -1
  206. package/dist/data_import/import/ImportCollectionAction.js +2 -2
  207. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  208. package/dist/form/EntityForm.d.ts +1 -1
  209. package/dist/form/EntityForm.js +255 -150
  210. package/dist/form/EntityForm.js.map +1 -1
  211. package/dist/form/EntityFormActions.js +3 -2
  212. package/dist/form/EntityFormActions.js.map +1 -1
  213. package/dist/form/EntityFormBinding.d.ts +1 -1
  214. package/dist/form/EntityFormBinding.js +22 -11
  215. package/dist/form/EntityFormBinding.js.map +1 -1
  216. package/dist/form/FormField.d.ts +36 -0
  217. package/dist/form/FormField.js +41 -0
  218. package/dist/form/FormField.js.map +1 -0
  219. package/dist/form/FormFieldsContext.d.ts +69 -0
  220. package/dist/form/FormFieldsContext.js +143 -0
  221. package/dist/form/FormFieldsContext.js.map +1 -0
  222. package/dist/form/PropertyFieldBinding.js +4 -4
  223. package/dist/form/PropertyFieldBinding.js.map +1 -1
  224. package/dist/form/collection_showing.d.ts +8 -0
  225. package/dist/form/collection_showing.js +29 -0
  226. package/dist/form/collection_showing.js.map +1 -0
  227. package/dist/form/components/ErrorFocus.js +2 -1
  228. package/dist/form/components/ErrorFocus.js.map +1 -1
  229. package/dist/form/components/FieldBlock.js +3 -1
  230. package/dist/form/components/FieldBlock.js.map +1 -1
  231. package/dist/form/components/FormRail.d.ts +5 -1
  232. package/dist/form/components/FormRail.js +5 -1
  233. package/dist/form/components/FormRail.js.map +1 -1
  234. package/dist/form/components/FormSections.d.ts +5 -1
  235. package/dist/form/components/FormSections.js +11 -4
  236. package/dist/form/components/FormSections.js.map +1 -1
  237. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
  238. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
  239. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
  240. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
  241. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
  242. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
  243. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  244. package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
  245. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
  246. package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
  247. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  248. package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
  249. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
  250. package/dist/form/form_dom_ids.d.ts +25 -0
  251. package/dist/form/form_dom_ids.js +42 -0
  252. package/dist/form/form_dom_ids.js.map +1 -0
  253. package/dist/form/index.d.ts +3 -1
  254. package/dist/form/resolve_cell_property.d.ts +5 -0
  255. package/dist/form/resolve_cell_property.js +22 -1
  256. package/dist/form/resolve_cell_property.js.map +1 -1
  257. package/dist/hooks/index.d.ts +1 -1
  258. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
  259. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
  260. package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
  261. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
  262. package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
  263. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
  264. package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
  265. package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
  266. package/dist/hooks/useBuildSidePanel.js +9 -9
  267. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  268. package/dist/hooks/useEntityDisplay.js +6 -4
  269. package/dist/hooks/useEntityDisplay.js.map +1 -1
  270. package/dist/hooks/useRecordActions.js +2 -2
  271. package/dist/hooks/useRecordActions.js.map +1 -1
  272. package/dist/hooks/useSelectionDialog.d.ts +20 -7
  273. package/dist/hooks/useSelectionDialog.js +29 -8
  274. package/dist/hooks/useSelectionDialog.js.map +1 -1
  275. package/dist/index.d.ts +8 -3
  276. package/dist/index.js +15 -9
  277. package/dist/mcp-view.d.ts +9 -0
  278. package/dist/mcp-view.js +2 -0
  279. package/dist/mcp_view/app_modules.d.ts +29 -0
  280. package/dist/mcp_view/app_modules.js +163 -0
  281. package/dist/mcp_view/app_modules.js.map +1 -0
  282. package/dist/mcp_view/bridge.d.ts +90 -0
  283. package/dist/mcp_view/bridge.js +205 -0
  284. package/dist/mcp_view/bridge.js.map +1 -0
  285. package/dist/mcp_view/code_app.d.ts +65 -0
  286. package/dist/mcp_view/code_app.js +139 -0
  287. package/dist/mcp_view/code_app.js.map +1 -0
  288. package/dist/mcp_view/index.d.ts +54 -0
  289. package/dist/mcp_view/index.js +262 -0
  290. package/dist/mcp_view/index.js.map +1 -0
  291. package/dist/mcp_view/payload.d.ts +78 -0
  292. package/dist/mcp_view/payload.js +155 -0
  293. package/dist/mcp_view/payload.js.map +1 -0
  294. package/dist/mcp_view/screen.d.ts +30 -0
  295. package/dist/mcp_view/screen.js +245 -0
  296. package/dist/mcp_view/screen.js.map +1 -0
  297. package/dist/mcp_view/storage_source.d.ts +14 -0
  298. package/dist/mcp_view/storage_source.js +29 -0
  299. package/dist/mcp_view/storage_source.js.map +1 -0
  300. package/dist/mcp_view/store.d.ts +9 -0
  301. package/dist/mcp_view/store.js +27 -0
  302. package/dist/mcp_view/store.js.map +1 -0
  303. package/dist/mcp_view/tool_driver.d.ts +160 -0
  304. package/dist/mcp_view/tool_driver.js +575 -0
  305. package/dist/mcp_view/tool_driver.js.map +1 -0
  306. package/dist/preview/components/DatePreview.d.ts +34 -1
  307. package/dist/preview/components/DatePreview.js +72 -37
  308. package/dist/preview/components/DatePreview.js.map +1 -1
  309. package/dist/routes/RebaseRoute.js +1 -1
  310. package/dist/routes/RebaseRoute.js.map +1 -1
  311. package/dist/selection/SelectionMenu.d.ts +5 -3
  312. package/dist/selection/SelectionMenu.js +16 -9
  313. package/dist/selection/SelectionMenu.js.map +1 -1
  314. package/dist/selection/index.d.ts +2 -1
  315. package/dist/selection/resolve_selection.d.ts +61 -7
  316. package/dist/selection/resolve_selection.js +93 -11
  317. package/dist/selection/resolve_selection.js.map +1 -1
  318. package/dist/types/components/EntityFormProps.d.ts +60 -10
  319. package/dist/types/fields.d.ts +2 -65
  320. package/dist/util/dataControllerAdapter.d.ts +8 -0
  321. package/dist/util/dataControllerAdapter.js +11 -0
  322. package/dist/util/dataControllerAdapter.js.map +1 -1
  323. package/dist/util/navigation_utils.d.ts +5 -4
  324. package/dist/util/navigation_utils.js +6 -6
  325. package/dist/util/navigation_utils.js.map +1 -1
  326. package/dist/util/propertyConfigMapper.d.ts +8 -0
  327. package/dist/util/propertyConfigMapper.js +16 -2
  328. package/dist/util/propertyConfigMapper.js.map +1 -1
  329. package/package.json +15 -9
  330. package/recipes/README.md +79 -26
  331. package/recipes/approval-queue.tsx +79 -0
  332. package/recipes/bulk-set-status.tsx +23 -17
  333. package/recipes/calendar-view.tsx +28 -23
  334. package/recipes/master-detail.tsx +75 -0
  335. package/recipes/my-preferences.tsx +3 -3
  336. package/recipes/orders-dashboard.tsx +58 -84
  337. package/recipes/site-settings.tsx +4 -4
  338. package/dist/components/EntityFormPanel.d.ts +0 -63
  339. package/dist/components/EntityFormPanel.js.map +0 -1
@@ -1,82 +1,18 @@
1
- import { getPropertyInPath as getPropertyInPath$1 } from "../../util/property_utils.js";
2
1
  import { useCollectionRegistryController } from "../../hooks/navigation/contexts/CollectionRegistryContext.js";
3
- import { useSidePanel } from "../../hooks/useSidePanel.js";
4
- import { ReferencePreview } from "../../preview/components/ReferencePreview.js";
5
- import { useUrlController } from "../../hooks/navigation/contexts/UrlContext.js";
6
- import { useAdminContext } from "../../hooks/useAdminContext.js";
7
- import { mergeEntityActions } from "../../util/entity_actions.js";
8
- import { CollectionRowActions } from "../CollectionTableBinding/CollectionRowActions.js";
9
- import { CollectionTableToolbar } from "../CollectionTableBinding/internal/CollectionTableToolbar.js";
10
- import { getSubcollectionColumnId } from "../CollectionTableBinding/internal/common.js";
11
- import { CollectionTableBinding } from "../CollectionTableBinding/CollectionTableBinding.js";
12
- import { useSelectionController } from "./useSelectionController.js";
13
- import { addRecentId, getRecentIds } from "./utils.js";
14
- import { VIEW_MODES, VIEW_MODE_PARAM, isViewMode, resolveOpenEntityMode } from "../../util/view_mode.js";
15
- import { navigateToEntity } from "../../util/navigation_utils.js";
16
- import { copyEntityAction, deleteEntityAction, editEntityAction, unlinkEntityAction } from "../common/default_entity_actions.js";
17
- import { useSelectionDialog } from "../../hooks/useSelectionDialog.js";
18
- import { resolveCollectionViews, resolveEntityAction } from "../../util/resolutions.js";
19
- import { serializeSelectionQuery } from "../../selection/resolve_selection.js";
20
- import { useCollectionInlineEditor } from "./hooks/useCollectionInlineEditor.js";
21
- import { CollectionViewActions } from "./CollectionViewActions.js";
22
- import { CollectionCardViewBinding } from "./CollectionCardViewBinding.js";
23
- import { CollectionListViewBinding } from "./CollectionListViewBinding.js";
24
- import { useChildViewSource } from "../../hooks/useChildViewSource.js";
25
2
  import { SplitListView } from "./SplitListView.js";
26
- import { CollectionBoardViewBinding } from "./CollectionBoardViewBinding.js";
27
- import { ViewModeToggle } from "./ViewModeToggle.js";
28
- import { DefaultCollectionEmptyState } from "./DefaultCollectionEmptyState.js";
29
- import { resolveCellProperty } from "../../form/resolve_cell_property.js";
30
- import { PopupFormField } from "../CollectionTableBinding/internal/popup_field/PopupFormField.js";
31
- import { DeleteEntityDialog } from "../DeleteEntityDialog.js";
32
- import { CollectionViewStartActions } from "./CollectionViewStartActions.js";
33
- import React, { useCallback, useEffect, useMemo, useState } from "react";
3
+ import { CollectionViewScopeContext } from "./CollectionViewScope.js";
4
+ import { useCollectionViewState } from "./useCollectionViewState.js";
5
+ import { CollectionToolbarSlot, CollectionToolbarSlotContext, DEFAULT_TOOLBAR } from "./CollectionToolbar.js";
6
+ import { CollectionViewContent } from "./CollectionViewContent.js";
7
+ import { CollectionViewDialogs } from "./CollectionViewDialogs.js";
8
+ import { CollectionViewFrame } from "./CollectionViewFrame.js";
9
+ import { EntitiesCount } from "./EntitiesCount.js";
10
+ import React, { useCallback, useRef } from "react";
34
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
35
- import { deepEqual, shallowEqual } from "fast-equals";
36
- import { Alert, ArrowRightToLineIcon, Button, ErrorBoundary, IconButton, Popover, SearchIcon, TextField, Tooltip, Typography, cls, focusedDisabled, iconSize } from "@rebasepro/ui";
37
- import { getEntityChildViews, serializeOrderBy } from "@rebasepro/common";
38
- import { CollectionScopeProvider, getRedundantChildViewColumnIds, populateFetchCache, resolveComponentRef, saveEntityWithCallbacks, useAnalyticsController, useAuthController, useColumnIds, useComponentOverride, useCustomizationController, useData, useDataTableController, useLargeLayout, usePermissions, useScrollRestoration, useSlot, useTranslation, useUserConfigurationPersistence } from "@rebasepro/app";
39
- import { EntityReference, getCollectionDataPath } from "@rebasepro/types";
40
- import { mergeDeep } from "@rebasepro/utils";
41
- import { useSearchParams } from "react-router";
12
+ import { deepEqual } from "fast-equals";
13
+ import { Alert, cls } from "@rebasepro/ui";
14
+ import { CollectionScopeProvider } from "@rebasepro/app";
42
15
  //#region src/components/CollectionViewBinding/CollectionViewBinding.tsx
43
- var EMPTY_ARRAY = [];
44
- /** What the plugins contributed to the table's add-column slot, for {@link PluginAddColumnComponents}. */
45
- var PluginAddColumnsContext = React.createContext(EMPTY_ARRAY);
46
- function PluginAddColumnComponents() {
47
- return /* @__PURE__ */ jsx("div", {
48
- className: "flex flex-row items-center gap-2",
49
- children: React.useContext(PluginAddColumnsContext)
50
- });
51
- }
52
- var PluginHeaderActionsContext = React.createContext(null);
53
- /**
54
- * The `collection.header.action` contributions for one column. One component
55
- * type for the life of the view, like {@link PluginAddColumnComponents}: the
56
- * table's columns are built once, and their headers re-render only when their
57
- * own props change, so what the actions are handed reaches them through
58
- * context. It was closed over when the header was built — the table controller
59
- * of the first render (a search, filter or sort typed since never reached a
60
- * header action) and the collection of the render before.
61
- */
62
- function PluginHeaderActions({ property, propertyKey, onHover }) {
63
- const scope = React.useContext(PluginHeaderActionsContext);
64
- if (!scope) return null;
65
- const headerSlotProps = {
66
- property,
67
- propertyKey,
68
- onHover,
69
- path: scope.path,
70
- collection: scope.collection,
71
- tableController: scope.tableController,
72
- parentCollectionSlugs: scope.parentCollectionSlugs,
73
- parentEntityIds: scope.parentEntityIds
74
- };
75
- return /* @__PURE__ */ jsx(Fragment, { children: scope.contributions.map((s, i) => /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(s.Component, {
76
- ...headerSlotProps,
77
- ...s.props ?? {}
78
- }) }, `header_action_${propertyKey}_${i}`)) });
79
- }
80
16
  /**
81
17
  * Props a caller commonly rebuilds on every render — a parent path array, a
82
18
  * properties object, an `Actions` list made with `toArray` — compared by value,
@@ -104,7 +40,10 @@ var PROPS_COMPARED_BY_VALUE = /* @__PURE__ */ new Set([
104
40
  "history",
105
41
  "fixedFilter",
106
42
  "selectedEntityId",
107
- "selectedTab"
43
+ "selectedTab",
44
+ "collectionOverrides",
45
+ "highlightedIds",
46
+ "fields"
108
47
  ]);
109
48
  /**
110
49
  * Whether the view would draw the same thing with these props.
@@ -151,1032 +90,85 @@ function collectionViewPropsEqual(a, b) {
151
90
 
152
91
  * @group Components
153
92
  */
154
- var CollectionViewBindingInner = React.memo(function CollectionViewBindingInner({ path: pathProp, parentCollectionSlugs, parentEntityIds, isSubCollection, className, updateUrl, selectedEntityId: selectedEntityIdProp, selectedTab: selectedTabProp, ...collectionProp }) {
155
- const { t } = useTranslation();
156
- const context = useAdminContext();
157
- const collectionRegistry = useCollectionRegistryController();
158
- const urlController = useUrlController();
159
- const path = pathProp ?? collectionProp.slug;
160
- const dataClient = useData();
161
- const sidePanelController = useSidePanel();
162
- const authController = useAuthController();
163
- const userConfigPersistence = useUserConfigurationPersistence();
164
- const analyticsController = useAnalyticsController();
165
- const customizationController = useCustomizationController();
166
- const { canCreate, canEdit, canDelete } = usePermissions();
167
- /**
168
- * Rows shared with other parents through a junction. The parent owns
169
- * the link, not the row — so the destructive action is a removal from
170
- * this record, which is what the server performs for such a path.
171
- */
172
- const childViewSource = useChildViewSource(path);
173
- const isLinkedChildView = childViewSource?.kind === "relation" && childViewSource.mode === "linked";
174
- const linkedTargetSlug = isLinkedChildView && childViewSource.kind === "relation" ? childViewSource.targetSlug : void 0;
175
- const containerRef = React.useRef(null);
176
- const scrollRestoration = useScrollRestoration();
177
- const collectionPropRef = React.useRef(collectionProp);
178
- if (!shallowEqual(collectionPropRef.current, collectionProp)) collectionPropRef.current = collectionProp;
179
- const stableCollectionProp = collectionPropRef.current;
180
- const collection = useMemo(() => {
181
- const registryCollection = collectionRegistry.getCollection(path) || stableCollectionProp;
182
- const userOverride = userConfigPersistence?.getCollectionConfig(path);
183
- return userOverride ? mergeDeep(registryCollection, userOverride) : registryCollection;
184
- }, [
185
- stableCollectionProp,
186
- path,
187
- userConfigPersistence,
188
- collectionRegistry
189
- ]);
190
- const collectionRef = React.useRef(collection);
191
- useEffect(() => {
192
- collectionRef.current = collection;
193
- }, [collection]);
194
- const canCreateEntities = canCreate(collection, path);
195
- const [highlightedEntity, setHighlightedEntity] = useState(void 0);
196
- const [deleteEntityClicked, setDeleteEntityClicked] = React.useState(void 0);
197
- const [lastDeleteTimestamp, setLastDeleteTimestamp] = React.useState(0);
198
- const [deletedEntities, setDeletedEntities] = React.useState([]);
199
- const [docsCount, setDocsCount] = useState(null);
200
- const [localPropertiesOrder, setLocalPropertiesOrder] = useState(collection.propertiesOrder);
201
- useEffect(() => {
202
- setLocalPropertiesOrder((previous) => deepEqual(previous, collection.propertiesOrder) ? previous : collection.propertiesOrder);
203
- }, [collection.propertiesOrder]);
204
- const unselectNavigatedEntity = useCallback(() => {
205
- const currentSelection = highlightedEntity;
206
- setTimeout(() => {
207
- if (currentSelection === highlightedEntity) setHighlightedEntity(void 0);
208
- }, 2400);
209
- }, [highlightedEntity]);
210
- const inlineEditingEnabled = canEdit(collection, path, null) && (collection.inlineEditing === void 0 || collection.inlineEditing);
211
- const selectionEnabled = collection.selectionEnabled === void 0 || collection.selectionEnabled;
212
- const hoverRow = !inlineEditingEnabled;
213
- const [popOverOpen, setPopOverOpen] = useState(false);
214
- const resolvedCustomViews = useMemo(() => resolveCollectionViews(collection.customViews, customizationController.collectionViews), [collection.customViews, customizationController]);
215
- const customViewKeys = useMemo(() => resolvedCustomViews.map((v) => v.key), [resolvedCustomViews]);
216
- const defaultViewMode = isViewMode(collection.defaultViewMode, customViewKeys) ? collection.defaultViewMode : "list";
217
- const [searchParams, setSearchParams] = useSearchParams();
218
- const urlView = useMemo(() => {
219
- const v = searchParams.get(VIEW_MODE_PARAM);
220
- return isViewMode(v, customViewKeys) ? v : null;
221
- }, [searchParams, customViewKeys]);
222
- const getSavedView = useCallback(() => {
223
- const saved = userConfigPersistence?.getCollectionConfig(path)?.defaultViewMode;
224
- return isViewMode(saved, customViewKeys) ? saved : null;
225
- }, [
226
- userConfigPersistence,
227
- path,
228
- customViewKeys
229
- ]);
230
- const [viewMode, setViewModeState] = useState(() => {
231
- if (urlView) return urlView;
232
- const savedView = getSavedView();
233
- if (savedView) return savedView;
234
- return defaultViewMode;
235
- });
236
- const activeCustomView = useMemo(() => resolvedCustomViews.find((v) => v.key === viewMode), [resolvedCustomViews, viewMode]);
237
- const openEntityMode = resolveOpenEntityMode({
238
- collection,
239
- viewMode,
240
- customView: activeCustomView
241
- });
242
- useEffect(() => {
243
- if (!urlView && viewMode !== defaultViewMode) setSearchParams(() => {
244
- const next = new URLSearchParams(window.location.search);
245
- next.set(VIEW_MODE_PARAM, viewMode);
246
- return next;
247
- }, { replace: true });
248
- }, []);
249
- const setViewMode = useCallback((newMode) => {
250
- setViewModeState(newMode);
251
- setSearchParams(() => {
252
- const next = new URLSearchParams(window.location.search);
253
- if (newMode === defaultViewMode) next.delete(VIEW_MODE_PARAM);
254
- else next.set(VIEW_MODE_PARAM, newMode);
255
- return next;
256
- });
257
- }, [defaultViewMode, setSearchParams]);
258
- useEffect(() => {
259
- if (urlView) setViewModeState(urlView);
260
- else {
261
- const savedView = getSavedView();
262
- setViewModeState(savedView ?? defaultViewMode);
263
- }
264
- }, [
265
- urlView,
266
- getSavedView,
267
- defaultViewMode
268
- ]);
269
- const [listSize, setListSize] = useState(collection.defaultSize ?? "m");
270
- const [cardSize, setCardSize] = useState(collection.defaultSize ?? "m");
271
- const [tableSize, setTableSize] = useState(collection.defaultSize ?? "m");
272
- const [customViewSize, setCustomViewSize] = useState(collection.defaultSize ?? "m");
273
- const selectionController = useSelectionController();
274
- const usedSelectionController = collection.selectionController ?? selectionController;
275
- const { selection, clearSelection, toggleEntitySelection } = usedSelectionController;
276
- const tableController = useDataTableController({
277
- path,
278
- collection,
279
- lastDeleteTimestamp,
280
- scrollRestoration,
281
- updateUrl,
282
- enabled: viewMode !== "kanban"
283
- });
284
- const tableKey = React.useRef(Math.random().toString(36));
285
- const popupCell = tableController.popupCell;
286
- const onPopupClose = useCallback(() => {
287
- tableController.setPopupCell?.(void 0);
288
- }, [tableController.setPopupCell]);
289
- const onEntityClick = useCallback((clickedEntity) => {
290
- const collection = collectionRef.current;
291
- setHighlightedEntity(clickedEntity);
292
- analyticsController.onAnalyticsEvent?.("edit_entity_clicked", {
293
- path: clickedEntity.path,
294
- entityId: clickedEntity.id
295
- });
296
- if (collection) addRecentId(collection.slug, clickedEntity.id);
297
- const entityPath = path ?? clickedEntity.path;
298
- populateFetchCache(entityPath, [clickedEntity]);
299
- navigateToEntity({
300
- navigation: urlController,
301
- path: entityPath,
302
- sidePanelController,
303
- openEntityMode,
304
- collection,
305
- entityId: clickedEntity.id,
306
- replace: openEntityMode === "split" && selectedEntityIdProp !== void 0
307
- });
308
- }, [
309
- sidePanelController,
310
- openEntityMode,
311
- selectedEntityIdProp,
312
- path,
313
- urlController,
314
- analyticsController
315
- ]);
316
- const onCreatedInPanel = useCallback(() => {
317
- setLastDeleteTimestamp(Date.now());
318
- }, []);
319
- /**
320
- * Attach rows that already exist to this parent.
321
- *
322
- * Writing to the row's own address under this parent — `PUT
323
- * posts/1/tags/5` — is what asserts membership; the backend writes the
324
- * junction row idempotently. Sending no values keeps it a pure link:
325
- * the target's own fields are none of this tab's business.
326
- */
327
- const linkExistingEntities = useCallback(async (entities) => {
328
- const alreadyLinked = new Set(tableController.data.map((e) => String(e.id)));
329
- const toLink = entities.filter((e) => !alreadyLinked.has(String(e.id)));
330
- if (toLink.length === 0) return;
331
- try {
332
- await Promise.all(toLink.map((entity) => saveEntityWithCallbacks({
333
- path,
334
- entityId: entity.id,
335
- values: {},
336
- status: "existing",
337
- collection,
338
- data: dataClient,
339
- context
340
- })));
341
- setLastDeleteTimestamp(Date.now());
342
- } catch (e) {
343
- context.snackbarController?.open({
344
- type: "error",
345
- message: e instanceof Error ? e.message : String(e)
346
- });
347
- }
348
- }, [
349
- dataClient,
350
- path,
351
- tableController.data,
352
- collection,
353
- context
354
- ]);
355
- const selectionDialog = useSelectionDialog({
356
- path: linkedTargetSlug ?? false,
357
- multiselect: true,
358
- onSelectionDone: linkExistingEntities
359
- });
360
- const openNewDocument = useCallback((defaultValues) => {
361
- const collection = collectionRef.current;
362
- analyticsController.onAnalyticsEvent?.("new_entity_click", { path });
363
- navigateToEntity({
364
- openEntityMode,
365
- collection,
366
- entityId: void 0,
367
- defaultValues,
368
- path,
369
- sidePanelController,
370
- navigation: urlController,
371
- onClose: unselectNavigatedEntity,
372
- onUpdate: onCreatedInPanel
373
- });
374
- }, [
375
- path,
376
- sidePanelController,
377
- openEntityMode,
378
- urlController,
379
- unselectNavigatedEntity,
380
- onCreatedInPanel
381
- ]);
382
- const onNewClick = useCallback(() => openNewDocument(), [openNewDocument]);
383
- const onMultipleDeleteClick = () => {
384
- analyticsController.onAnalyticsEvent?.("multiple_delete_dialog_open", { path });
385
- setDeleteEntityClicked(selection);
386
- };
387
- const internalOnEntityDelete = (_path, entity) => {
388
- analyticsController.onAnalyticsEvent?.("single_entity_deleted", { path });
389
- toggleEntitySelection(entity, false);
390
- setDeletedEntities((prev) => [...prev, entity]);
391
- setLastDeleteTimestamp(Date.now());
392
- };
393
- const internalOnMultipleEntitiesDelete = (_path, entities) => {
394
- analyticsController.onAnalyticsEvent?.("multiple_entities_deleted", { path });
395
- clearSelection();
396
- setDeleteEntityClicked(void 0);
397
- setDeletedEntities((prev) => [...prev, ...entities]);
398
- setLastDeleteTimestamp(Date.now());
399
- };
400
- const pluginAddColumnComponents = useSlot("collection.add-column", {
401
- path,
402
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
403
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
404
- collection,
405
- tableController
406
- });
407
- const pluginToolbarWidgets = useSlot("collection.toolbar", {
408
- path,
409
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
410
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
411
- collection,
412
- tableController,
413
- selectionController: usedSelectionController
414
- });
415
- const pluginEmptyStates = useSlot("collection.empty-state", {
416
- path,
417
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
418
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
419
- collection,
420
- canCreate: canCreateEntities,
421
- onNewClick
422
- });
423
- const pluginWidgets = useSlot("collection.widgets", {
424
- path,
425
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
426
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
427
- collection
428
- });
429
- const onCollectionModifiedForUser = useCallback((path, partialCollection) => {
430
- if (userConfigPersistence) {
431
- const updatedConfig = mergeDeep(userConfigPersistence.getCollectionConfig(path), partialCollection);
432
- userConfigPersistence.onCollectionModified(path, updatedConfig);
433
- }
434
- }, [userConfigPersistence]);
435
- const onColumnResize = useCallback(({ width, key }) => {
436
- const collection = collectionRef.current;
437
- if (!getPropertyInPath$1(collection.properties, key)) return;
438
- const localCollection = buildPropertyWidthOverwrite(key, width);
439
- onCollectionModifiedForUser(path, localCollection);
440
- }, [onCollectionModifiedForUser, path]);
441
- const onListSizeChanged = useCallback((size) => {
442
- setListSize(size);
443
- if (userConfigPersistence) onCollectionModifiedForUser(path, { defaultSize: size });
444
- }, [
445
- onCollectionModifiedForUser,
446
- path,
447
- userConfigPersistence
448
- ]);
449
- const onTableSizeChanged = useCallback((size) => {
450
- setTableSize(size);
451
- if (userConfigPersistence) onCollectionModifiedForUser(path, { defaultSize: size });
452
- }, [
453
- onCollectionModifiedForUser,
454
- path,
455
- userConfigPersistence
456
- ]);
457
- const onViewModeChange = useCallback((mode) => {
458
- analyticsController.onAnalyticsEvent?.("view_mode_changed", {
459
- path,
460
- from: viewMode,
461
- to: mode
462
- });
463
- setViewMode(mode);
464
- if (userConfigPersistence) onCollectionModifiedForUser(path, { defaultViewMode: mode });
465
- }, [
466
- setViewMode,
467
- userConfigPersistence,
468
- onCollectionModifiedForUser,
469
- path,
470
- analyticsController,
471
- viewMode
472
- ]);
473
- const createEnabled = canCreate(collection, path);
474
- const { onValueChange, uniqueFieldValidator } = useCollectionInlineEditor({
475
- path,
476
- collection,
477
- dataClient,
478
- context
479
- });
480
- const resolvedCollection = collection;
481
- useMemo(() => {
482
- if (!collection.kanban?.columnProperty) return false;
483
- const property = getPropertyInPath$1(resolvedCollection.properties, collection.kanban.columnProperty);
484
- if (!property || property.type !== "string") return false;
485
- return Boolean("enum" in property && property.enum);
486
- }, [collection.kanban?.columnProperty, resolvedCollection.properties]);
487
- const hasEnumProperty = useMemo(() => {
488
- return Object.values(resolvedCollection.properties).some((p) => p.type === "string" && "enum" in p && p.enum);
489
- }, [resolvedCollection.properties]);
490
- const enabledViews = useMemo(() => {
491
- const renderable = (collection.enabledViews ?? [...VIEW_MODES, ...customViewKeys]).filter((v) => isViewMode(v, customViewKeys));
492
- if (!hasEnumProperty) return renderable.filter((v) => v !== "kanban");
493
- return renderable;
494
- }, [
495
- collection.enabledViews,
496
- hasEnumProperty,
497
- customViewKeys
498
- ]);
499
- const kanbanPropertyOptions = useMemo(() => {
500
- const options = [];
501
- const properties = resolvedCollection.properties;
502
- for (const [key, property] of Object.entries(properties)) {
503
- const prop = property;
504
- if (prop && prop.type === "string" && "enum" in prop && prop.enum) options.push({
505
- key,
506
- label: prop.name || key
507
- });
508
- }
509
- return options;
510
- }, [resolvedCollection.properties]);
511
- const getSavedKanbanProperty = useCallback(() => {
512
- return (userConfigPersistence?.getCollectionConfig(path))?.kanbanColumnProperty;
513
- }, [userConfigPersistence, path]);
514
- const [selectedKanbanProperty, setSelectedKanbanProperty] = useState(() => {
515
- const saved = getSavedKanbanProperty();
516
- if (saved && kanbanPropertyOptions.some((o) => o.key === saved)) return saved;
517
- if (collection.kanban?.columnProperty) return collection.kanban.columnProperty;
518
- return kanbanPropertyOptions[0]?.key ?? "";
519
- });
520
- useEffect(() => {
521
- if (kanbanPropertyOptions.length > 0 && !kanbanPropertyOptions.some((o) => o.key === selectedKanbanProperty)) {
522
- const saved = getSavedKanbanProperty();
523
- if (saved && kanbanPropertyOptions.some((o) => o.key === saved)) setSelectedKanbanProperty(saved);
524
- else if (collection.kanban?.columnProperty && kanbanPropertyOptions.some((o) => o.key === collection.kanban?.columnProperty)) setSelectedKanbanProperty(collection.kanban.columnProperty);
525
- else setSelectedKanbanProperty(kanbanPropertyOptions[0]?.key ?? "");
526
- }
527
- }, [
528
- kanbanPropertyOptions,
529
- selectedKanbanProperty,
530
- getSavedKanbanProperty,
531
- collection.kanban?.columnProperty
532
- ]);
533
- const onKanbanPropertyChange = useCallback((property) => {
534
- analyticsController.onAnalyticsEvent?.("kanban_property_changed", {
535
- path,
536
- property
537
- });
538
- setSelectedKanbanProperty(property);
539
- if (userConfigPersistence) onCollectionModifiedForUser(path, { kanbanColumnProperty: property });
540
- }, [
541
- userConfigPersistence,
542
- onCollectionModifiedForUser,
543
- path,
544
- analyticsController
545
- ]);
546
- const getPropertyFor = useCallback(({ propertyKey, entity }) => {
547
- let property = getPropertyInPath$1(collection.properties, propertyKey);
548
- if (!property) property = getPropertyInPath$1(resolvedCollection.properties, propertyKey);
549
- if (!property) return null;
550
- return resolveCellProperty(property, propertyKey, entity, {
551
- path,
552
- authController,
553
- propertyConfigs: customizationController.propertyConfigs
554
- });
555
- }, [
556
- collection.properties,
557
- resolvedCollection.properties,
558
- path,
559
- authController,
560
- customizationController.propertyConfigs
561
- ]);
562
- const collectionWithLocalOrder = useMemo(() => {
563
- if (localPropertiesOrder && localPropertiesOrder !== resolvedCollection.propertiesOrder) return {
564
- ...resolvedCollection,
565
- propertiesOrder: localPropertiesOrder
566
- };
567
- return resolvedCollection;
568
- }, [resolvedCollection, localPropertiesOrder]);
569
- const displayedColumnIds = useColumnIds(collectionWithLocalOrder, true);
570
- const additionalFields = useMemo(() => {
571
- const redundant = getRedundantChildViewColumnIds(collectionWithLocalOrder);
572
- const subcollectionColumns = getEntityChildViews(collection).map((v) => v.collection).filter((child) => !redundant.has(getSubcollectionColumnId(child))).map((subcollection) => {
573
- return {
574
- key: getSubcollectionColumnId(subcollection),
575
- name: subcollection.name,
576
- width: 200,
577
- dependencies: [],
578
- Builder: ({ entity }) => /* @__PURE__ */ jsx(Button, {
579
- className: "max-w-full truncate justify-start",
580
- startIcon: /* @__PURE__ */ jsx(ArrowRightToLineIcon, { size: iconSize.small }),
581
- onClick: (event) => {
582
- event.stopPropagation();
583
- navigateToEntity({
584
- openEntityMode,
585
- collection,
586
- entityId: entity.id,
587
- selectedTab: subcollection.slug,
588
- path,
589
- navigation: urlController,
590
- sidePanelController
591
- });
592
- },
593
- children: subcollection.name
594
- })
595
- };
596
- }) ?? EMPTY_ARRAY;
597
- return [...collection.additionalFields ?? EMPTY_ARRAY, ...subcollectionColumns];
598
- }, [
599
- collection,
600
- collectionWithLocalOrder,
601
- path,
602
- sidePanelController,
603
- openEntityMode,
604
- urlController
605
- ]);
606
- const updateLastDeleteTimestamp = useCallback(() => {
607
- setLastDeleteTimestamp(Date.now());
608
- }, []);
609
- const largeLayout = useLargeLayout();
610
- const isSplitLayout = openEntityMode === "split";
611
- const isCompact = isSplitLayout && selectedEntityIdProp !== void 0;
612
- const activeSelectionEnabled = !isCompact && selectionEnabled;
613
- const getActionsForEntity = useCallback(({ entity, customEntityActions }) => {
614
- const deleteEnabled = entity ? canDelete(collection, path, entity) : true;
615
- const disableActions = collection.disableDefaultActions ?? [];
616
- const actions = [];
617
- if (!disableActions.includes("edit")) actions.push(editEntityAction);
618
- if (createEnabled && !disableActions.includes("copy")) actions.push(copyEntityAction);
619
- if (deleteEnabled && !disableActions.includes("delete")) actions.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);
620
- if (customEntityActions) return mergeEntityActions(actions, customEntityActions);
621
- return actions;
622
- }, [
623
- canDelete,
624
- collection,
625
- path,
626
- createEnabled,
627
- isLinkedChildView
628
- ]);
629
- const getIdColumnWidth = useCallback(() => {
630
- const entityActions = getActionsForEntity({});
631
- const collapsedActions = entityActions.filter((a) => a.collapsed !== false);
632
- const actionsWidth = entityActions.filter((a) => a.collapsed === false).length * (largeLayout ? 40 : 30);
633
- return (largeLayout ? 80 + actionsWidth : 70 + actionsWidth) + (collapsedActions.length > 0 ? largeLayout ? 40 : 30 : 0);
634
- }, [getActionsForEntity, largeLayout]);
635
- const customEntityActions = useMemo(() => (collection.entityActions ?? EMPTY_ARRAY).map((action) => resolveEntityAction(action, customizationController.entityActions)).filter(Boolean), [collection.entityActions, customizationController.entityActions]);
636
- const tableRowActionsBuilder = useCallback(({ entity, size, width, frozen }) => {
637
- const isSelected = usedSelectionController.isEntitySelected(entity);
638
- const actions = getActionsForEntity({
639
- entity,
640
- customEntityActions
641
- });
642
- return /* @__PURE__ */ jsx(CollectionRowActions, {
643
- entity,
644
- width,
645
- frozen,
646
- isSelected,
647
- selectionEnabled: activeSelectionEnabled,
648
- size,
649
- highlightEntity: setHighlightedEntity,
650
- unhighlightEntity: unselectNavigatedEntity,
651
- collection,
652
- path,
653
- actions,
654
- hideId: collection?.hideIdFromCollection,
655
- onCollectionChange: updateLastDeleteTimestamp,
656
- selectionController: usedSelectionController,
657
- openEntityMode
658
- });
659
- }, [
660
- updateLastDeleteTimestamp,
661
- usedSelectionController,
662
- customEntityActions,
663
- getActionsForEntity,
664
- activeSelectionEnabled,
665
- unselectNavigatedEntity,
666
- collection,
667
- path,
668
- openEntityMode
669
- ]);
670
- const highlightedEntities = useMemo(() => highlightedEntity ? [highlightedEntity] : EMPTY_ARRAY, [highlightedEntity]);
671
- const idHeaderWidget = useMemo(() => /* @__PURE__ */ jsx(EntityIdHeaderWidget, {
672
- path,
673
- idPath: path,
674
- collection,
675
- openEntityMode
676
- }), [
677
- path,
678
- collection,
679
- openEntityMode
680
- ]);
681
- const countFetcher = /* @__PURE__ */ jsx(EntitiesCount, {
682
- path,
683
- collection,
684
- filter: tableController.filterValues,
685
- sortBy: tableController.sortBy,
686
- searchString: tableController.searchString,
687
- onCountChange: setDocsCount,
688
- refreshKey: lastDeleteTimestamp
689
- });
690
- const liveSelectionQuery = useMemo(() => ({
691
- path,
692
- filterValues: tableController.filterValues,
693
- searchString: tableController.searchString,
694
- sortBy: tableController.sortBy
695
- }), [
696
- path,
697
- tableController.filterValues,
698
- tableController.searchString,
699
- tableController.sortBy
700
- ]);
701
- const selectionQueryKey = selection.type === "query" ? serializeSelectionQuery(selection.query) : void 0;
702
- const liveQueryKey = serializeSelectionQuery(liveSelectionQuery);
703
- useEffect(() => {
704
- if (selectionQueryKey !== void 0 && selectionQueryKey !== liveQueryKey) clearSelection();
705
- }, [
706
- selectionQueryKey,
707
- liveQueryKey,
708
- clearSelection
709
- ]);
710
- const { resolvedSlots } = customizationController;
711
- const headerActionContributions = useMemo(() => resolvedSlots.filter((s) => s.slot === "collection.header.action").sort((a, b) => (a.order ?? 50) - (b.order ?? 50)), [resolvedSlots]);
712
- const headerActionsScope = useMemo(() => headerActionContributions.length > 0 ? {
713
- contributions: headerActionContributions,
714
- path,
715
- collection,
716
- tableController,
717
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
718
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY
719
- } : null, [
720
- headerActionContributions,
721
- path,
722
- collection,
723
- tableController,
724
- parentCollectionSlugs,
725
- parentEntityIds
726
- ]);
727
- const addColumnComponentInternal = pluginAddColumnComponents.length > 0 ? PluginAddColumnComponents : void 0;
728
- const onColumnsOrderChange = useCallback((newColumns) => {
729
- const seenKeys = /* @__PURE__ */ new Set();
730
- const newPropertiesOrder = newColumns.filter((col) => !col.frozen && getPropertyInPath$1(collection.properties, col.key)).map((col) => col.key).filter((key) => {
731
- if (seenKeys.has(key)) return false;
732
- seenKeys.add(key);
733
- return true;
734
- });
735
- setLocalPropertiesOrder(newPropertiesOrder);
736
- if (customizationController?.plugins) customizationController.plugins.filter((plugin) => plugin.hooks?.onColumnsReorder).forEach((plugin) => {
737
- plugin.hooks.onColumnsReorder({
738
- fullPath: path,
739
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
740
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
741
- collection,
742
- newPropertiesOrder
743
- });
744
- });
745
- if (userConfigPersistence) onCollectionModifiedForUser(path, { propertiesOrder: newPropertiesOrder });
746
- }, [
747
- collection,
748
- setLocalPropertiesOrder,
749
- customizationController,
750
- path,
751
- parentCollectionSlugs,
752
- parentEntityIds,
753
- userConfigPersistence,
754
- onCollectionModifiedForUser
755
- ]);
756
- const [viewModePopoverOpen, setViewModePopoverOpen] = useState(false);
757
- const viewModeToggleElement = /* @__PURE__ */ jsx(ViewModeToggle, {
758
- viewMode,
759
- onViewModeChange,
760
- enabledViews,
761
- customViews: resolvedCustomViews,
762
- size: activeCustomView ? activeCustomView.sizeable ? customViewSize : void 0 : viewMode === "list" ? listSize : viewMode === "table" ? tableSize : viewMode === "cards" ? cardSize : void 0,
763
- onSizeChanged: activeCustomView ? activeCustomView.sizeable ? setCustomViewSize : void 0 : viewMode === "list" ? onListSizeChanged : viewMode === "table" ? onTableSizeChanged : viewMode === "cards" ? setCardSize : void 0,
764
- open: viewModePopoverOpen,
765
- onOpenChange: setViewModePopoverOpen,
766
- kanbanPropertyOptions,
767
- selectedKanbanProperty,
768
- onKanbanPropertyChange
769
- });
770
- const pluginErrorViews = useSlot("collection.error", {
771
- path,
772
- collection,
773
- parentCollectionSlugs,
774
- parentEntityIds,
775
- error: tableController.dataLoadingError
776
- });
777
- const pluginErrorView = tableController.dataLoadingError && pluginErrorViews.length > 0 ? pluginErrorViews[0] : null;
778
- const isSearching = !!tableController.searchString;
779
- const fixedFilter = collection.fixedFilter;
780
- const isFiltered = isSearching || Object.keys(tableController.filterValues ?? {}).some((key) => !fixedFilter || !(key in fixedFilter));
781
- const ResolvedEmptyState = useComponentOverride("Collection.EmptyState", DefaultCollectionEmptyState);
782
- const ResolvedCollectionActions = useComponentOverride("Collection.Actions", CollectionViewActions);
783
- const ResolvedCollectionTable = useComponentOverride("Collection.Table", CollectionTableBinding);
784
- const emptyComponent = pluginEmptyStates.length > 0 ? /* @__PURE__ */ jsx(Fragment, { children: pluginEmptyStates }) : /* @__PURE__ */ jsx(ResolvedEmptyState, {
785
- canCreate: canCreateEntities && !isFiltered,
786
- onNewClick,
787
- isSearching,
788
- isFiltered,
789
- searchString: tableController.searchString ?? ""
790
- });
791
- const toolbarNode = /* @__PURE__ */ jsx(CollectionTableToolbar, {
792
- compact: isCompact,
793
- loading: tableController.dataLoading,
794
- onTextSearch: tableController.setSearchString,
795
- initialSearchText: tableController.searchString,
796
- viewModeToggle: viewModeToggleElement,
797
- actionsStart: /* @__PURE__ */ jsx(CollectionViewStartActions, {
798
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
799
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
800
- collection,
801
- tableController,
802
- path,
803
- relativePath: getCollectionDataPath(collection),
804
- selectionController: usedSelectionController,
805
- collectionEntitiesCount: docsCount ?? void 0,
806
- resolvedProperties: resolvedCollection.properties,
807
- viewMode,
808
- selectionEnabled: activeSelectionEnabled,
809
- selectionQuery: liveSelectionQuery,
810
- entitiesCount: docsCount,
811
- openNewDocument,
812
- compact: isCompact
813
- }),
814
- actions: /* @__PURE__ */ jsx(ResolvedCollectionActions, {
815
- parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,
816
- parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,
817
- collection,
818
- tableController,
819
- onMultipleDeleteClick,
820
- removeUnlinks: isLinkedChildView,
821
- onNewClick,
822
- onAddExistingClick: linkedTargetSlug ? selectionDialog.open : void 0,
823
- openNewDocument,
824
- path,
825
- relativePath: getCollectionDataPath(collection),
826
- selectionController: usedSelectionController,
827
- selectionEnabled: activeSelectionEnabled,
828
- collectionEntitiesCount: docsCount ?? void 0,
829
- compact: isCompact,
830
- children: pluginToolbarWidgets
831
- })
832
- });
833
- const CustomViewBuilder = activeCustomView ? resolveComponentRef(activeCustomView.Builder) : void 0;
834
- const innerView = CustomViewBuilder ? /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(CustomViewBuilder, {
835
- collection,
836
- tableController,
837
- path,
838
- parentCollectionSlugs,
839
- parentEntityIds,
840
- onEntityClick,
841
- onNewClick: canCreateEntities ? onNewClick : void 0,
842
- canCreate: canCreateEntities,
843
- selectionController: usedSelectionController,
844
- selectionEnabled,
845
- highlightedEntities,
846
- deletedEntities,
847
- emptyComponent,
848
- size: activeCustomView.sizeable ? customViewSize : void 0,
849
- viewMode
850
- }, `custom-view-${activeCustomView.key}-${path}`) }) : viewMode === "kanban" ? /* @__PURE__ */ jsx(CollectionBoardViewBinding, {
851
- collection,
852
- tableController,
853
- fullPath: path,
854
- parentCollectionSlugs,
855
- parentEntityIds,
856
- columnProperty: selectedKanbanProperty,
857
- onEntityClick,
858
- selectionController: usedSelectionController,
859
- selectionEnabled,
860
- highlightedEntities,
861
- deletedEntities,
862
- emptyComponent
863
- }, `kanban-view-${path}-${selectedKanbanProperty}`) : viewMode === "cards" ? /* @__PURE__ */ jsx(CollectionCardViewBinding, {
864
- collection,
865
- tableController,
866
- onEntityClick,
867
- selectionController: usedSelectionController,
868
- selectionEnabled,
869
- highlightedEntities,
870
- onScroll: tableController.onScroll,
871
- initialScroll: tableController.initialScroll,
872
- size: cardSize,
873
- emptyComponent
874
- }, `cards-view-${path}`) : viewMode === "list" ? /* @__PURE__ */ jsx(CollectionListViewBinding, {
875
- collection,
876
- tableController,
877
- onEntityClick,
878
- selectionController: usedSelectionController,
879
- selectionEnabled,
880
- highlightedEntities,
881
- size: listSize,
882
- emptyComponent,
883
- selectedEntityId: selectedEntityIdProp,
884
- getActionsForEntity,
885
- path,
886
- openEntityMode
887
- }, `list-view-${path}`) : /* @__PURE__ */ jsx(PluginAddColumnsContext.Provider, {
888
- value: pluginAddColumnComponents,
889
- children: /* @__PURE__ */ jsx(PluginHeaderActionsContext.Provider, {
890
- value: headerActionsScope,
891
- children: /* @__PURE__ */ jsx(ResolvedCollectionTable, {
892
- hideToolbar: true,
893
- additionalFields,
894
- tableController,
895
- fixedFilter: collection.fixedFilter,
896
- enablePopupIcon: true,
897
- displayedColumnIds,
898
- onSizeChanged: onTableSizeChanged,
899
- onEntityClick,
900
- onColumnResize,
901
- onValueChange,
902
- tableRowActionsBuilder,
903
- uniqueFieldValidator,
904
- selectionController: usedSelectionController,
905
- highlightedEntities,
906
- defaultSize: tableSize,
907
- properties: resolvedCollection.properties,
908
- getPropertyFor,
909
- onScroll: tableController.onScroll,
910
- initialScroll: tableController.initialScroll,
911
- emptyComponent,
912
- hoverRow,
913
- inlineEditing: inlineEditingEnabled,
914
- AdditionalHeaderWidget: PluginHeaderActions,
915
- AddColumnComponent: addColumnComponentInternal,
916
- getIdColumnWidth,
917
- additionalIDHeaderWidget: idHeaderWidget,
918
- openEntityMode,
919
- onColumnsOrderChange
920
- }, `collection_table_${path}`)
921
- })
922
- });
923
- const detailOpen = selectedEntityIdProp !== void 0;
924
- const collectionSurface = viewMode === "list" ? /* @__PURE__ */ jsxs("div", {
925
- className: cls("flex flex-col w-full", detailOpen ? "" : "max-w-6xl mx-auto px-3 md:px-4 lg:px-6 py-4"),
926
- children: [
927
- /* @__PURE__ */ jsx("div", {
928
- className: cls("grid transition-[grid-template-rows,transform,margin] duration-150 ease-out", detailOpen ? "grid-rows-[0fr] -translate-y-2 mt-0 mb-0" : "grid-rows-[1fr] translate-y-0 mt-12 mb-6"),
929
- children: /* @__PURE__ */ jsx("div", {
930
- className: "overflow-hidden flex items-center gap-4",
931
- children: /* @__PURE__ */ jsx(Typography, {
932
- gutterBottom: true,
933
- variant: "h4",
934
- className: "grow mb-0",
935
- component: "h4",
936
- children: collection.name
93
+ var CollectionViewBindingInner = React.memo(function CollectionViewBindingInner(props) {
94
+ const state = useCollectionViewState(props);
95
+ const { t, containerRef, path, parentCollectionSlugs, parentEntityIds, selectedEntityId, selectedTab, collection, tableController, lastDeleteTimestamp, setDocsCount, pluginErrorView, isSplitLayout, viewMode, onEntityClick, onNewClick, usedSelectionController, selectionEnabled, highlightedEntities, listSize, emptyComponent } = state;
96
+ const toolbarNode = /* @__PURE__ */ jsx(CollectionToolbarSlot, {});
97
+ const collectionSurface = /* @__PURE__ */ jsx(CollectionViewContent, { state });
98
+ return /* @__PURE__ */ jsx(CollectionViewScopeContext.Provider, {
99
+ value: state,
100
+ children: /* @__PURE__ */ jsxs(CollectionViewFrame, {
101
+ className: props.className,
102
+ containerRef,
103
+ children: [
104
+ /* @__PURE__ */ jsx(EntitiesCount, {
105
+ path,
106
+ collection,
107
+ filter: tableController.filterValues,
108
+ sortBy: tableController.sortBy,
109
+ searchString: tableController.searchString,
110
+ onCountChange: setDocsCount,
111
+ refreshKey: lastDeleteTimestamp
112
+ }),
113
+ pluginErrorView ?? (tableController.dataLoadingError && tableController.data.length > 0 && /* @__PURE__ */ jsx("div", {
114
+ className: "px-4 pt-2 flex-shrink-0",
115
+ children: /* @__PURE__ */ jsxs(Alert, {
116
+ color: "error",
117
+ size: "small",
118
+ children: [/* @__PURE__ */ jsx("strong", { children: t("error_loading_data") }), tableController.dataLoadingError.message ? /* @__PURE__ */ jsxs(Fragment, { children: [": ", tableController.dataLoadingError.message] }) : null]
937
119
  })
938
- })
939
- }),
940
- pluginWidgets.length > 0 && /* @__PURE__ */ jsx("div", {
941
- className: cls("grid transition-[grid-template-rows] duration-150 ease-out", detailOpen ? "grid-rows-[0fr]" : "grid-rows-[1fr]"),
942
- children: /* @__PURE__ */ jsx("div", {
943
- className: "overflow-hidden flex-shrink-0",
944
- children: pluginWidgets
945
- })
946
- }),
947
- innerView
948
- ]
949
- }) : innerView;
950
- return /* @__PURE__ */ jsxs("div", {
951
- className: cls("overflow-hidden h-full w-full rounded-md flex flex-col bg-surface-sheet", className),
952
- ref: containerRef,
953
- children: [
954
- countFetcher,
955
- pluginErrorView ?? (tableController.dataLoadingError && tableController.data.length > 0 && /* @__PURE__ */ jsx("div", {
956
- className: "px-4 pt-2 flex-shrink-0",
957
- children: /* @__PURE__ */ jsxs(Alert, {
958
- color: "error",
959
- size: "small",
960
- children: [/* @__PURE__ */ jsx("strong", { children: t("error_loading_data") }), tableController.dataLoadingError.message ? /* @__PURE__ */ jsxs(Fragment, { children: [": ", tableController.dataLoadingError.message] }) : null]
961
- })
962
- })),
963
- isSplitLayout ? /* @__PURE__ */ jsx(SplitListView, {
964
- collection,
965
- tableController,
966
- onEntityClick,
967
- onNewClick,
968
- selectionController: usedSelectionController,
969
- selectionEnabled,
970
- highlightedEntities,
971
- onScroll: tableController.onScroll,
972
- initialScroll: tableController.initialScroll,
973
- size: listSize,
974
- emptyComponent,
975
- path,
976
- parentCollectionSlugs,
977
- parentEntityIds,
978
- selectedEntityId: selectedEntityIdProp,
979
- selectedTab: selectedTabProp,
980
- toolbar: toolbarNode,
981
- children: collectionSurface
982
- }, `split-list-view-${path}`) : /* @__PURE__ */ jsxs("div", {
983
- className: "flex flex-col w-full h-full",
984
- children: [toolbarNode, /* @__PURE__ */ jsx("div", {
985
- className: cls("flex-1 min-h-0 flex flex-col", (viewMode === "list" || viewMode === "cards") && "overflow-y-auto"),
120
+ })),
121
+ isSplitLayout ? /* @__PURE__ */ jsx(SplitListView, {
122
+ collection,
123
+ tableController,
124
+ onEntityClick,
125
+ onNewClick,
126
+ selectionController: usedSelectionController,
127
+ selectionEnabled,
128
+ highlightedEntities,
129
+ onScroll: tableController.onScroll,
130
+ initialScroll: tableController.initialScroll,
131
+ size: listSize,
132
+ emptyComponent,
133
+ path,
134
+ parentCollectionSlugs,
135
+ parentEntityIds,
136
+ selectedEntityId,
137
+ selectedTab,
138
+ toolbar: toolbarNode,
986
139
  children: collectionSurface
987
- })]
988
- }),
989
- popupCell && /* @__PURE__ */ jsx(PopupFormField, {
990
- open: Boolean(popupCell),
991
- onClose: onPopupClose,
992
- cellRect: popupCell?.cellRect,
993
- propertyKey: popupCell?.propertyKey,
994
- collection,
995
- entityId: popupCell.entityId,
996
- tableKey: tableKey.current,
997
- customFieldValidator: uniqueFieldValidator,
998
- path,
999
- onCellValueChange: onValueChange,
1000
- container: containerRef.current
1001
- }, `popup_form_${popupCell?.propertyKey}_${popupCell?.entityId}`),
1002
- deleteEntityClicked && /* @__PURE__ */ jsx(DeleteEntityDialog, {
1003
- target: deleteEntityClicked,
1004
- path,
1005
- collection,
1006
- variant: isLinkedChildView ? "unlink" : "delete",
1007
- open: Boolean(deleteEntityClicked),
1008
- onEntityDelete: internalOnEntityDelete,
1009
- onMultipleEntitiesDelete: internalOnMultipleEntitiesDelete,
1010
- onClose: () => setDeleteEntityClicked(void 0)
1011
- })
1012
- ]
140
+ }, `split-list-view-${path}`) : /* @__PURE__ */ jsxs("div", {
141
+ className: "flex flex-col w-full h-full min-h-0",
142
+ children: [toolbarNode, /* @__PURE__ */ jsx("div", {
143
+ className: cls("flex-1 min-h-0 max-h-dvh flex flex-col", (viewMode === "list" || viewMode === "cards") && "overflow-y-auto"),
144
+ children: collectionSurface
145
+ })]
146
+ }),
147
+ /* @__PURE__ */ jsx(CollectionViewDialogs, { state })
148
+ ]
149
+ })
1013
150
  });
1014
151
  }, collectionViewPropsEqual);
1015
- var CollectionViewBinding = React.memo(function CollectionViewBinding(props) {
152
+ var CollectionViewBinding = React.memo(function CollectionViewBinding({ toolbar, onRowClick, ...props }) {
1016
153
  const collectionRegistry = useCollectionRegistryController();
1017
154
  const path = props.path ?? props.slug;
1018
155
  const collection = collectionRegistry.getCollection(path) ?? props;
1019
- const content = /* @__PURE__ */ jsx(CollectionViewBindingInner, { ...props });
156
+ const onRowClickRef = useRef(onRowClick);
157
+ onRowClickRef.current = onRowClick;
158
+ const callRowClick = useCallback((row, id) => onRowClickRef.current?.(row, id), []);
159
+ const content = /* @__PURE__ */ jsx(CollectionToolbarSlotContext.Provider, {
160
+ value: toolbar === void 0 ? DEFAULT_TOOLBAR : toolbar,
161
+ children: /* @__PURE__ */ jsx(CollectionViewBindingInner, {
162
+ ...props,
163
+ onRowClick: onRowClick ? callRowClick : void 0
164
+ })
165
+ });
1020
166
  if (collection) return /* @__PURE__ */ jsx(CollectionScopeProvider, {
1021
167
  collection,
1022
168
  children: content
1023
169
  });
1024
170
  return content;
1025
171
  });
1026
- /**
1027
- * Inflight count request deduplication map.
1028
- * Keyed by `path|filterKey|sort|search` so that concurrent
1029
- * callers (e.g. React StrictMode double-mount) share the same promise.
1030
- */
1031
- var inflightCountRequests = /* @__PURE__ */ new Map();
1032
- function EntitiesCount({ path, collection, filter, sortBy, searchString, onCountChange, refreshKey }) {
1033
- const dataClient = useData();
1034
- const sortKey = React.useMemo(() => sortBy ? serializeOrderBy(sortBy) ?? "" : "", [sortBy]);
1035
- const dataClientRef = React.useRef(dataClient);
1036
- dataClientRef.current = dataClient;
1037
- const onCountChangeRef = React.useRef(onCountChange);
1038
- onCountChangeRef.current = onCountChange;
1039
- const filterKey = React.useMemo(() => filter ? JSON.stringify(filter) : "", [filter]);
1040
- useEffect(() => {
1041
- const accessor = dataClientRef.current.collection(path);
1042
- if (!accessor.count && !accessor.listenCount) {
1043
- onCountChangeRef.current?.(void 0);
1044
- return;
1045
- }
1046
- let cancelled = false;
1047
- const whereParams = filter && Object.keys(filter).length > 0 ? filter : void 0;
1048
- const orderByParams = sortBy && sortBy.length > 0 ? sortBy.map(([field, direction]) => [String(field), direction]) : void 0;
1049
- if (accessor.listenCount) return accessor.listenCount({
1050
- where: whereParams,
1051
- searchString
1052
- }, (total) => onCountChangeRef.current?.(total), (error) => {
1053
- console.warn("Error counting", error);
1054
- onCountChangeRef.current?.(void 0);
1055
- });
1056
- const cacheKey = `${path}|${filterKey}|${sortKey}|${searchString ?? ""}|${refreshKey ?? ""}`;
1057
- let countPromise = inflightCountRequests.get(cacheKey);
1058
- if (!countPromise) {
1059
- countPromise = accessor.count({
1060
- where: whereParams,
1061
- orderBy: orderByParams,
1062
- searchString
1063
- });
1064
- inflightCountRequests.set(cacheKey, countPromise);
1065
- countPromise.finally(() => inflightCountRequests.delete(cacheKey));
1066
- }
1067
- countPromise.then((c) => {
1068
- if (!cancelled) onCountChangeRef.current?.(c);
1069
- }).catch((e) => {
1070
- console.warn("Error fetching count", e);
1071
- if (!cancelled) onCountChangeRef.current?.(void 0);
1072
- });
1073
- return () => {
1074
- cancelled = true;
1075
- };
1076
- }, [
1077
- path,
1078
- filterKey,
1079
- sortKey,
1080
- searchString,
1081
- refreshKey
1082
- ]);
1083
- return null;
1084
- }
1085
- function buildPropertyWidthOverwrite(key, width) {
1086
- if (key.includes(".")) {
1087
- const [parentKey, ...childKey] = key.split(".");
1088
- return { properties: { [parentKey]: buildPropertyWidthOverwrite(childKey.join("."), width) } };
1089
- }
1090
- return { properties: { [key]: { admin: { columnWidth: width } } } };
1091
- }
1092
- function EntityIdHeaderWidget({ collection, path, idPath, openEntityMode }) {
1093
- const { t } = useTranslation();
1094
- const urlController = useUrlController();
1095
- const [openPopup, setOpenPopup] = React.useState(false);
1096
- const [searchString, setSearchString] = React.useState("");
1097
- const [recentIds, setRecentIds] = React.useState(getRecentIds(collection.slug).map(String));
1098
- const sidePanelController = useSidePanel();
1099
- return /* @__PURE__ */ jsx(Tooltip, {
1100
- title: !openPopup ? t("find_by_id") : void 0,
1101
- asChild: false,
1102
- children: /* @__PURE__ */ jsx(Popover, {
1103
- open: openPopup,
1104
- onOpenChange: setOpenPopup,
1105
- sideOffset: 0,
1106
- align: "start",
1107
- alignOffset: -117,
1108
- trigger: /* @__PURE__ */ jsx(IconButton, {
1109
- "aria-label": t("search"),
1110
- size: "small",
1111
- children: /* @__PURE__ */ jsx(SearchIcon, { size: iconSize.small })
1112
- }),
1113
- children: /* @__PURE__ */ jsxs("div", {
1114
- className: cls("my-2 rounded-lg bg-surface-sheet text-surface-900 dark:text-white"),
1115
- children: [/* @__PURE__ */ jsx("form", {
1116
- noValidate: true,
1117
- onSubmit: (e) => {
1118
- e.preventDefault();
1119
- if (!searchString) return;
1120
- setOpenPopup(false);
1121
- const entityId = searchString.trim();
1122
- setRecentIds(addRecentId(collection.slug, entityId).map(String));
1123
- navigateToEntity({
1124
- openEntityMode,
1125
- collection,
1126
- entityId,
1127
- path,
1128
- sidePanelController,
1129
- navigation: urlController
1130
- });
1131
- },
1132
- className: "w-96 max-w-full",
1133
- children: /* @__PURE__ */ jsxs("div", {
1134
- className: "flex p-2 w-full gap-2",
1135
- children: [/* @__PURE__ */ jsx(TextField, {
1136
- autoFocus: openPopup,
1137
- "aria-label": t("find_entity_by_id"),
1138
- placeholder: t("find_entity_by_id"),
1139
- size: "small",
1140
- onChange: (e) => {
1141
- setSearchString(e.target.value);
1142
- },
1143
- value: searchString,
1144
- className: "flex-grow",
1145
- inputClassName: cls("rounded-lg bg-surface-card", focusedDisabled)
1146
- }), /* @__PURE__ */ jsx(Button, {
1147
- variant: "text",
1148
- disabled: !searchString.trim(),
1149
- type: "submit",
1150
- children: /* @__PURE__ */ jsx(ArrowRightToLineIcon, {})
1151
- })]
1152
- })
1153
- }), recentIds && recentIds.length > 0 && /* @__PURE__ */ jsx("div", {
1154
- className: "flex flex-col gap-2 p-2",
1155
- children: recentIds.map((id) => /* @__PURE__ */ jsx(ReferencePreview, {
1156
- reference: new EntityReference({
1157
- id,
1158
- path
1159
- }),
1160
- hover: true,
1161
- onClick: () => {
1162
- setOpenPopup(false);
1163
- navigateToEntity({
1164
- openEntityMode,
1165
- collection,
1166
- entityId: id,
1167
- path,
1168
- sidePanelController,
1169
- navigation: urlController
1170
- });
1171
- },
1172
- includeEntityLink: false,
1173
- size: "small"
1174
- }, id))
1175
- })]
1176
- })
1177
- })
1178
- });
1179
- }
1180
172
  //#endregion
1181
173
  export { CollectionViewBinding, EntitiesCount };
1182
174