@rebasepro/cms 0.30.1 → 0.31.0-canary.g902a0ce

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 (583) hide show
  1. package/README.md +8 -8
  2. package/dist/collection_editor/ConfigControllerProvider.js +25 -22
  3. package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
  4. package/dist/collection_editor/firestore_callee.d.ts +10 -0
  5. package/dist/collection_editor/firestore_callee.js +15 -0
  6. package/dist/collection_editor/firestore_callee.js.map +1 -0
  7. package/dist/collection_editor/firestore_edit.d.ts +62 -0
  8. package/dist/collection_editor/firestore_edit.js +339 -0
  9. package/dist/collection_editor/firestore_edit.js.map +1 -0
  10. package/dist/collection_editor/index.d.ts +2 -3
  11. package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
  12. package/dist/collection_editor/liveSchemaClient.js +9 -3
  13. package/dist/collection_editor/liveSchemaClient.js.map +1 -1
  14. package/dist/collection_editor/property_column.d.ts +86 -0
  15. package/dist/collection_editor/property_column.js +719 -0
  16. package/dist/collection_editor/property_column.js.map +1 -0
  17. package/dist/collection_editor/serializable_types.d.ts +2 -24
  18. package/dist/collection_editor/serializable_utils.d.ts +1 -1
  19. package/dist/collection_editor/serializable_utils.js +2 -1
  20. package/dist/collection_editor/serializable_utils.js.map +1 -1
  21. package/dist/collection_editor/split_edit.d.ts +106 -0
  22. package/dist/collection_editor/split_edit.js +564 -0
  23. package/dist/collection_editor/split_edit.js.map +1 -0
  24. package/dist/collection_editor/split_edit_error.d.ts +25 -0
  25. package/dist/collection_editor/split_edit_error.js +35 -0
  26. package/dist/collection_editor/split_edit_error.js.map +1 -0
  27. package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
  28. package/dist/collection_editor/types/config_controller.d.ts +67 -1
  29. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
  30. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
  31. package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
  32. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
  33. package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
  34. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
  35. package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
  36. package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
  37. package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
  38. package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
  39. package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
  40. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
  41. package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
  42. package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
  43. package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
  44. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
  45. package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
  46. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
  47. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
  48. package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
  49. package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
  50. package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
  51. package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
  52. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
  53. package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
  54. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
  55. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
  56. package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
  57. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
  58. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
  59. package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
  60. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
  61. package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
  62. package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
  63. package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
  64. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
  65. package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
  66. package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
  67. package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
  68. package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
  69. package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
  70. package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
  71. package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
  72. package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
  73. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
  74. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
  75. package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
  76. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
  77. package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
  78. package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
  79. package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
  80. package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
  81. package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
  82. package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
  83. package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
  84. package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
  85. package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
  86. package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
  87. package/dist/collection_editor/validateCollectionJson.js.map +1 -1
  88. package/dist/components/CollectionPanel.d.ts +10 -9
  89. package/dist/components/CollectionPanel.js +5 -2
  90. package/dist/components/CollectionPanel.js.map +1 -1
  91. package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
  92. package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
  93. package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
  94. package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
  95. package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
  96. package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
  97. package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
  98. package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
  99. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
  100. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
  101. package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
  102. package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
  103. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
  104. package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
  105. package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
  106. package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
  107. package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
  108. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
  109. package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
  110. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
  111. package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
  112. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
  113. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
  114. package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
  115. package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
  116. package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
  117. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
  118. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
  119. package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
  120. package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
  121. package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
  122. package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
  123. package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
  124. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
  125. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
  126. package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
  127. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
  128. package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
  129. package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
  130. package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
  131. package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
  132. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
  133. package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
  134. package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
  135. package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
  136. package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
  137. package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
  138. package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
  139. package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
  140. package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
  141. package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
  142. package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
  143. package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
  144. package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
  145. package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
  146. package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
  147. package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
  148. package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
  149. package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
  150. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
  151. package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
  152. package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
  153. package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
  154. package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
  155. package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
  156. package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
  157. package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
  158. package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
  159. package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
  160. package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
  161. package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
  162. package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
  163. package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
  164. package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
  165. package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
  166. package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
  167. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
  168. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
  169. package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
  170. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
  171. package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
  172. package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
  173. package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
  174. package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
  175. package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
  176. package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
  177. package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
  178. package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
  179. package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
  180. package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
  181. package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
  182. package/dist/components/CollectionsProvider.d.ts +23 -8
  183. package/dist/components/CollectionsProvider.js +23 -7
  184. package/dist/components/CollectionsProvider.js.map +1 -1
  185. package/dist/components/DefaultDrawer.js +1 -1
  186. package/dist/components/DeleteEntityDialog.d.ts +1 -1
  187. package/dist/components/DeleteEntityDialog.js +1 -1
  188. package/dist/components/DeleteEntityDialog.js.map +1 -1
  189. package/dist/components/DetailViewBinding.js +3 -3
  190. package/dist/components/DetailViewBinding.js.map +1 -1
  191. package/dist/components/EditFormActions.js.map +1 -1
  192. package/dist/components/EditViewBinding.d.ts +2 -1
  193. package/dist/components/EditViewBinding.js +6 -6
  194. package/dist/components/EditViewBinding.js.map +1 -1
  195. package/dist/components/EntityDisplayHeader.d.ts +1 -2
  196. package/dist/components/EntityDisplayHeader.js.map +1 -1
  197. package/dist/components/EntityInspector.d.ts +1 -2
  198. package/dist/components/EntityInspector.js.map +1 -1
  199. package/dist/components/EntityPreviewBinding.d.ts +1 -1
  200. package/dist/components/EntityPreviewBinding.js +1 -1
  201. package/dist/components/EntityPreviewBinding.js.map +1 -1
  202. package/dist/components/EntityViewBinding.d.ts +1 -1
  203. package/dist/components/EntityViewBinding.js.map +1 -1
  204. package/dist/components/EntityViewBody.d.ts +1 -1
  205. package/dist/components/EntityViewBody.js +3 -4
  206. package/dist/components/EntityViewBody.js.map +1 -1
  207. package/dist/components/FieldValue.js +2 -2
  208. package/dist/components/FieldValue.js.map +1 -1
  209. package/dist/components/HomePage/ContentHomePage.js +12 -3
  210. package/dist/components/HomePage/ContentHomePage.js.map +1 -1
  211. package/dist/components/InlineEntityPreview.d.ts +1 -1
  212. package/dist/components/InlineEntityPreview.js.map +1 -1
  213. package/dist/components/PropertyCollectionView.d.ts +2 -2
  214. package/dist/components/PropertyCollectionView.js.map +1 -1
  215. package/dist/components/PropertyConfigBadge.js.map +1 -1
  216. package/dist/components/RebaseCMS.d.ts +22 -3
  217. package/dist/components/RebaseCMS.js +32 -14
  218. package/dist/components/RebaseCMS.js.map +1 -1
  219. package/dist/components/RebaseNavigation.js +106 -31
  220. package/dist/components/RebaseNavigation.js.map +1 -1
  221. package/dist/components/RecordDetail.js +4 -1
  222. package/dist/components/RecordDetail.js.map +1 -1
  223. package/dist/components/RecordForm.d.ts +5 -5
  224. package/dist/components/RecordForm.js +5 -2
  225. package/dist/components/RecordForm.js.map +1 -1
  226. package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
  227. package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
  228. package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
  229. package/dist/components/ReferenceWidget.d.ts +2 -1
  230. package/dist/components/ReferenceWidget.js +2 -2
  231. package/dist/components/ReferenceWidget.js.map +1 -1
  232. package/dist/components/RelationSelector.d.ts +2 -1
  233. package/dist/components/RelationSelector.js +2 -3
  234. package/dist/components/RelationSelector.js.map +1 -1
  235. package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
  236. package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
  237. package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
  238. package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
  239. package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
  240. package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
  241. package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
  242. package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
  243. package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
  244. package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
  245. package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
  246. package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
  247. package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
  248. package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
  249. package/dist/components/SidePanelBinding.js +1 -1
  250. package/dist/components/SidePanelBinding.js.map +1 -1
  251. package/dist/components/field_configs.d.ts +1 -2
  252. package/dist/components/field_configs.js.map +1 -1
  253. package/dist/components/field_ids.d.ts +1 -1
  254. package/dist/components/field_ids.js +1 -1
  255. package/dist/components/field_ids.js.map +1 -1
  256. package/dist/components/history/EntityHistoryEntry.js.map +1 -1
  257. package/dist/components/history/EntityHistoryView.d.ts +1 -2
  258. package/dist/components/history/EntityHistoryView.js +1 -1
  259. package/dist/components/history/EntityHistoryView.js.map +1 -1
  260. package/dist/data_export/export/BasicExportAction.d.ts +1 -1
  261. package/dist/data_export/export/BasicExportAction.js.map +1 -1
  262. package/dist/data_export/export/ExportCollectionAction.js +2 -2
  263. package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
  264. package/dist/data_export/export/additional_fields.d.ts +1 -1
  265. package/dist/data_export/export/additional_fields.js.map +1 -1
  266. package/dist/data_export/export/export.d.ts +1 -1
  267. package/dist/data_export/export/export.js +1 -1
  268. package/dist/data_export/export/export.js.map +1 -1
  269. package/dist/data_export/export/fetch_export_data.d.ts +3 -2
  270. package/dist/data_export/export/fetch_export_data.js.map +1 -1
  271. package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
  272. package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
  273. package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
  274. package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
  275. package/dist/data_import/hooks/useImportConfig.js.map +1 -1
  276. package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
  277. package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
  278. package/dist/data_import/types/column_mapping.d.ts +1 -1
  279. package/dist/data_import/utils/data.d.ts +1 -2
  280. package/dist/data_import/utils/data.js +1 -2
  281. package/dist/data_import/utils/data.js.map +1 -1
  282. package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
  283. package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
  284. package/dist/data_import/utils/id_column.d.ts +1 -1
  285. package/dist/data_import/utils/id_column.js.map +1 -1
  286. package/dist/data_import/utils/import_columns.d.ts +1 -1
  287. package/dist/data_import/utils/import_columns.js.map +1 -1
  288. package/dist/data_import/utils/save_entities.d.ts +3 -3
  289. package/dist/data_import/utils/save_entities.js +1 -1
  290. package/dist/data_import/utils/save_entities.js.map +1 -1
  291. package/dist/form/EntityForm.js +2 -1
  292. package/dist/form/EntityForm.js.map +1 -1
  293. package/dist/form/EntityFormActions.js.map +1 -1
  294. package/dist/form/EntityFormBinding.js +2 -2
  295. package/dist/form/EntityFormBinding.js.map +1 -1
  296. package/dist/form/FormFieldsContext.d.ts +1 -4
  297. package/dist/form/FormFieldsContext.js +1 -1
  298. package/dist/form/FormFieldsContext.js.map +1 -1
  299. package/dist/form/PropertyFieldBinding.js +6 -8
  300. package/dist/form/PropertyFieldBinding.js.map +1 -1
  301. package/dist/form/components/FieldBlock.d.ts +1 -2
  302. package/dist/form/components/FieldBlock.js.map +1 -1
  303. package/dist/form/components/FieldHelperText.d.ts +1 -1
  304. package/dist/form/components/FieldHelperText.js.map +1 -1
  305. package/dist/form/components/FormRail.d.ts +1 -1
  306. package/dist/form/components/FormRail.js.map +1 -1
  307. package/dist/form/components/LocalChangesMenu.d.ts +1 -1
  308. package/dist/form/components/LocalChangesMenu.js.map +1 -1
  309. package/dist/form/components/StorageItemPreview.d.ts +1 -1
  310. package/dist/form/components/StorageItemPreview.js.map +1 -1
  311. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  312. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
  313. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
  314. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
  315. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
  316. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
  317. package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
  318. package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
  319. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  320. package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
  321. package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
  322. package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
  323. package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
  324. package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
  325. package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
  326. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  327. package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
  328. package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
  329. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  330. package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
  331. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  332. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
  333. package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
  334. package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
  335. package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
  336. package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
  337. package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
  338. package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
  339. package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
  340. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  341. package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
  342. package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
  343. package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
  344. package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
  345. package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
  346. package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
  347. package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
  348. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  349. package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
  350. package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
  351. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  352. package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
  353. package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
  354. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
  355. package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
  356. package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
  357. package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
  358. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  359. package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
  360. package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
  361. package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
  362. package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
  363. package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
  364. package/dist/form/form_utils.d.ts +3 -3
  365. package/dist/form/form_utils.js +1 -2
  366. package/dist/form/form_utils.js.map +1 -1
  367. package/dist/form/label_placement.d.ts +1 -2
  368. package/dist/form/label_placement.js.map +1 -1
  369. package/dist/form/resolve_cell_property.d.ts +1 -2
  370. package/dist/form/resolve_cell_property.js +1 -1
  371. package/dist/form/resolve_cell_property.js.map +1 -1
  372. package/dist/form/resolve_form_properties.d.ts +2 -2
  373. package/dist/form/resolve_form_properties.js +1 -1
  374. package/dist/form/resolve_form_properties.js.map +1 -1
  375. package/dist/form/useClearRestoreValue.d.ts +1 -1
  376. package/dist/form/useClearRestoreValue.js.map +1 -1
  377. package/dist/form/validation.d.ts +2 -2
  378. package/dist/form/validation.js +1 -1
  379. package/dist/form/validation.js.map +1 -1
  380. package/dist/hooks/navigation/compose_collections.d.ts +59 -0
  381. package/dist/hooks/navigation/compose_collections.js +48 -0
  382. package/dist/hooks/navigation/compose_collections.js.map +1 -0
  383. package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
  384. package/dist/hooks/navigation/compose_collections_input.js +17 -0
  385. package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
  386. package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
  387. package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
  388. package/dist/hooks/navigation/registered_collection.d.ts +15 -0
  389. package/dist/hooks/navigation/registered_collection.js +20 -0
  390. package/dist/hooks/navigation/registered_collection.js.map +1 -0
  391. package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
  392. package/dist/hooks/navigation/ui_preferences.js +179 -0
  393. package/dist/hooks/navigation/ui_preferences.js.map +1 -0
  394. package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
  395. package/dist/hooks/navigation/useAsyncResolver.js +9 -3
  396. package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
  397. package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
  398. package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
  399. package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
  400. package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
  401. package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
  402. package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
  403. package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
  404. package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
  405. package/dist/hooks/navigation/useNavigationResolution.js +1 -2
  406. package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
  407. package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
  408. package/dist/hooks/navigation/usePanelTables.js +33 -0
  409. package/dist/hooks/navigation/usePanelTables.js.map +1 -0
  410. package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
  411. package/dist/hooks/navigation/useResolvedCollections.js +3 -2
  412. package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
  413. package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
  414. package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
  415. package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
  416. package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
  417. package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
  418. package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
  419. package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
  420. package/dist/hooks/navigation/utils.js +1 -1
  421. package/dist/hooks/navigation/utils.js.map +1 -1
  422. package/dist/hooks/useAdminContext.d.ts +1 -2
  423. package/dist/hooks/useAdminContext.js.map +1 -1
  424. package/dist/hooks/useBuildSidePanel.d.ts +1 -2
  425. package/dist/hooks/useBuildSidePanel.js +2 -1
  426. package/dist/hooks/useBuildSidePanel.js.map +1 -1
  427. package/dist/hooks/useChildViewSource.d.ts +1 -1
  428. package/dist/hooks/useChildViewSource.js +1 -1
  429. package/dist/hooks/useChildViewSource.js.map +1 -1
  430. package/dist/hooks/useEntityDisplay.d.ts +1 -2
  431. package/dist/hooks/useEntityDisplay.js +1 -1
  432. package/dist/hooks/useEntityDisplay.js.map +1 -1
  433. package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
  434. package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
  435. package/dist/hooks/useHistory.js +1 -1
  436. package/dist/hooks/useHistory.js.map +1 -1
  437. package/dist/hooks/useRecordActions.d.ts +1 -2
  438. package/dist/hooks/useRecordActions.js.map +1 -1
  439. package/dist/hooks/useReferencePaths.d.ts +21 -7
  440. package/dist/hooks/useReferencePaths.js +23 -6
  441. package/dist/hooks/useReferencePaths.js.map +1 -1
  442. package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
  443. package/dist/hooks/useResolvedNavigationFrom.js +1 -1
  444. package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
  445. package/dist/index.d.ts +11 -0
  446. package/dist/index.js +8 -2
  447. package/dist/mcp_view/app_modules.d.ts +2 -2
  448. package/dist/mcp_view/app_modules.js +4 -4
  449. package/dist/mcp_view/app_modules.js.map +1 -1
  450. package/dist/mcp_view/index.d.ts +16 -19
  451. package/dist/mcp_view/index.js +43 -62
  452. package/dist/mcp_view/index.js.map +1 -1
  453. package/dist/mcp_view/payload.d.ts +54 -18
  454. package/dist/mcp_view/payload.js +49 -24
  455. package/dist/mcp_view/payload.js.map +1 -1
  456. package/dist/mcp_view/screen.js +11 -11
  457. package/dist/mcp_view/screen.js.map +1 -1
  458. package/dist/mcp_view/tool_driver.d.ts +5 -34
  459. package/dist/mcp_view/tool_driver.js +17 -16
  460. package/dist/mcp_view/tool_driver.js.map +1 -1
  461. package/dist/mcp_view/write_review.d.ts +1 -2
  462. package/dist/mcp_view/write_review.js +1 -1
  463. package/dist/mcp_view/write_review.js.map +1 -1
  464. package/dist/preview/PropertyPreview.d.ts +1 -1
  465. package/dist/preview/PropertyPreview.js +4 -3
  466. package/dist/preview/PropertyPreview.js.map +1 -1
  467. package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
  468. package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
  469. package/dist/preview/components/BooleanPreview.d.ts +1 -1
  470. package/dist/preview/components/BooleanPreview.js.map +1 -1
  471. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  472. package/dist/preview/components/EnumValuesChip.js +1 -1
  473. package/dist/preview/components/EnumValuesChip.js.map +1 -1
  474. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  475. package/dist/preview/components/ReferencePreview.js.map +1 -1
  476. package/dist/preview/components/RelationPreview.d.ts +1 -1
  477. package/dist/preview/components/RelationPreview.js.map +1 -1
  478. package/dist/preview/components/StorageThumbnail.js +2 -1
  479. package/dist/preview/components/StorageThumbnail.js.map +1 -1
  480. package/dist/preview/components/UserPreview.d.ts +1 -1
  481. package/dist/preview/components/UserPreview.js.map +1 -1
  482. package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
  483. package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
  484. package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
  485. package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
  486. package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
  487. package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
  488. package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
  489. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
  490. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
  491. package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
  492. package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
  493. package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
  494. package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
  495. package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
  496. package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
  497. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
  498. package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
  499. package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
  500. package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
  501. package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
  502. package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
  503. package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
  504. package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
  505. package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
  506. package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
  507. package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
  508. package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
  509. package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
  510. package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
  511. package/dist/preview/util.d.ts +1 -1
  512. package/dist/preview/util.js.map +1 -1
  513. package/dist/routes/RebaseRoute.js +2 -2
  514. package/dist/routes/RebaseRoute.js.map +1 -1
  515. package/dist/saved_apps/SavedAppsView.d.ts +1 -1
  516. package/dist/saved_apps/SavedAppsView.js +1 -1
  517. package/dist/saved_apps/SavedAppsView.js.map +1 -1
  518. package/dist/selection/SelectionMenu.d.ts +1 -1
  519. package/dist/selection/SelectionMenu.js.map +1 -1
  520. package/dist/selection/resolve_selection.d.ts +3 -3
  521. package/dist/selection/resolve_selection.js +3 -2
  522. package/dist/selection/resolve_selection.js.map +1 -1
  523. package/dist/tables/apply_customization.d.ts +65 -0
  524. package/dist/tables/apply_customization.js +644 -0
  525. package/dist/tables/apply_customization.js.map +1 -0
  526. package/dist/tables/column_property.d.ts +64 -0
  527. package/dist/tables/column_property.js +549 -0
  528. package/dist/tables/column_property.js.map +1 -0
  529. package/dist/tables/customize_table.d.ts +39 -0
  530. package/dist/tables/customize_table.js +247 -0
  531. package/dist/tables/customize_table.js.map +1 -0
  532. package/dist/tables/index.d.ts +12 -0
  533. package/dist/tables/labels.d.ts +18 -0
  534. package/dist/tables/labels.js +18 -0
  535. package/dist/tables/labels.js.map +1 -0
  536. package/dist/tables/project_table.d.ts +79 -0
  537. package/dist/tables/project_table.js +148 -0
  538. package/dist/tables/project_table.js.map +1 -0
  539. package/dist/tables/relations.d.ts +47 -0
  540. package/dist/tables/relations.js +112 -0
  541. package/dist/tables/relations.js.map +1 -0
  542. package/dist/tables/rls.d.ts +39 -0
  543. package/dist/tables/rls.js +111 -0
  544. package/dist/tables/rls.js.map +1 -0
  545. package/dist/tables/update_record.d.ts +32 -0
  546. package/dist/tables/update_record.js +40 -0
  547. package/dist/tables/update_record.js.map +1 -0
  548. package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
  549. package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
  550. package/dist/types/fields.d.ts +2 -2
  551. package/dist/util/dataControllerAdapter.js.map +1 -1
  552. package/dist/util/entity_pages.d.ts +2 -1
  553. package/dist/util/entity_pages.js.map +1 -1
  554. package/dist/util/find_entities_by_ids.d.ts +2 -2
  555. package/dist/util/find_entities_by_ids.js +1 -1
  556. package/dist/util/find_entities_by_ids.js.map +1 -1
  557. package/dist/util/format_collection_date.d.ts +1 -1
  558. package/dist/util/format_collection_date.js.map +1 -1
  559. package/dist/util/identity.d.ts +8 -0
  560. package/dist/util/identity.js +16 -0
  561. package/dist/util/identity.js.map +1 -0
  562. package/dist/util/navigation_utils.js +1 -1
  563. package/dist/util/navigation_utils.js.map +1 -1
  564. package/dist/util/previews.js +1 -1
  565. package/dist/util/previews.js.map +1 -1
  566. package/dist/util/propertyConfigMapper.d.ts +1 -1
  567. package/dist/util/propertyConfigMapper.js.map +1 -1
  568. package/dist/util/property_utils.d.ts +1 -3
  569. package/dist/util/property_utils.js +1 -1
  570. package/dist/util/property_utils.js.map +1 -1
  571. package/dist/util/relations.d.ts +18 -0
  572. package/dist/util/relations.js +32 -0
  573. package/dist/util/relations.js.map +1 -0
  574. package/package.json +12 -10
  575. package/recipes/README.md +4 -4
  576. package/recipes/my-preferences.tsx +34 -26
  577. package/recipes/site-settings.tsx +34 -27
  578. package/dist/collection_editor/collection_wire.d.ts +0 -13
  579. package/dist/collection_editor/collection_wire.js +0 -49
  580. package/dist/collection_editor/collection_wire.js.map +0 -1
  581. package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
  582. package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
  583. package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectionController.js","names":[],"sources":["../../../src/components/CollectionViewBinding/useSelectionController.tsx"],"sourcesContent":["import { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { CollectionConfig, Entity } from \"@rebasepro/types\";\nimport type { EntitySelection, EntitySelectionController, SelectionController, SelectionQuery } from \"@rebasepro/cms-types\";\nimport { selectionControllerOf } from \"@rebasepro/app\";\n\n/**\n * Same row: id alone is not unique across a junction-backed tab's two paths.\n * Ids compare as the strings they address a record by — an integer key's `5`\n * and `\"5\"` are one record, whichever of the two a caller handed back.\n */\nfunction sameEntity(a: Entity<any>, b: Entity<any>): boolean {\n return String(a.id) === String(b.id) && a.path === b.path;\n}\n\n/**\n * The rows of a list, by path and then by id, for asking about one row in\n * constant time. Keyed in two levels rather than by a joined string: a path\n * and an id may both contain a slash.\n */\ntype RowIndex = Map<string, Set<string>>;\n\nfunction indexRows(entities: Entity<any>[]): RowIndex {\n const index: RowIndex = new Map();\n for (const entity of entities) {\n let ids = index.get(entity.path);\n if (!ids) {\n ids = new Set();\n index.set(entity.path, ids);\n }\n ids.add(String(entity.id));\n }\n return index;\n}\n\nfunction indexHas(index: RowIndex, entity: Entity<any>): boolean {\n return index.get(entity.path)?.has(String(entity.id)) ?? false;\n}\n\nconst EMPTY_SELECTION: EntitySelection<any> = {\n type: \"entities\",\n entities: []\n};\n\nexport function useEntitySelectionController<M extends Record<string, unknown> = Record<string, unknown>>(\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void\n): EntitySelectionController<M> {\n\n const [selection, setSelection] = useState<EntitySelection<M>>(EMPTY_SELECTION as EntitySelection<M>);\n\n const onSelectionChangeRef = useRef(onSelectionChange);\n onSelectionChangeRef.current = onSelectionChange;\n\n const toggleEntitySelection = useCallback((entity: Entity<M>, newSelectedState?: boolean) => {\n setSelection(prev => {\n\n // In query mode a row is selected unless it was taken back out, so\n // unticking one ADDS to the exclusions rather than removing from a\n // list of the selected — the list does not exist, and building it\n // would mean reading every matching row first.\n if (prev.type === \"query\") {\n const isExcluded = prev.excluded.some(e => sameEntity(e, entity));\n const shouldSelect = newSelectedState ?? isExcluded;\n if (shouldSelect === !isExcluded) return prev;\n onSelectionChangeRef.current?.(entity, shouldSelect);\n return {\n ...prev,\n excluded: shouldSelect\n ? prev.excluded.filter(e => !sameEntity(e, entity))\n : [...prev.excluded, entity]\n };\n }\n\n const isSelected = prev.entities.some(e => sameEntity(e, entity));\n const shouldSelect = newSelectedState ?? !isSelected;\n if (shouldSelect === isSelected) return prev;\n onSelectionChangeRef.current?.(entity, shouldSelect);\n return {\n type: \"entities\",\n entities: shouldSelect\n ? [...prev.entities, entity]\n : prev.entities.filter(e => !sameEntity(e, entity))\n };\n });\n }, []);\n\n // Built once per selection. The views ask about every row they hold —\n // the selection menu and the list or card view, after each change — and a\n // linear search per row made \"select all loaded rows\" quadratic: 10,000\n // rows, ~200 ms per view per change.\n const selectionIndex = useMemo(\n () => indexRows(selection.type === \"query\" ? selection.excluded : selection.entities),\n [selection]);\n\n const isEntitySelected = useCallback((entity: Entity<M>) => {\n // Every row a view can show you in query mode came out of that query,\n // so membership is the exclusion list and nothing else. The binding\n // clears the selection if the filter moves underneath it, which is what\n // keeps that true.\n if (selection.type === \"query\")\n return !indexHas(selectionIndex, entity);\n return indexHas(selectionIndex, entity);\n }, [selection, selectionIndex]);\n\n const setSelectedEntities = useCallback((entities: Entity<M>[]) => {\n setSelection({\n type: \"entities\",\n entities\n });\n }, []);\n\n const selectAllMatching = useCallback((query: SelectionQuery<M>, count?: number) => {\n setSelection({\n type: \"query\",\n query,\n excluded: [],\n count\n });\n }, []);\n\n const clearSelection = useCallback(() => {\n setSelection(EMPTY_SELECTION as EntitySelection<M>);\n }, []);\n\n const selectedCount = useMemo(() => {\n if (selection.type === \"entities\") return selection.entities.length;\n // An accessor with no `count` can still be selected in full; the number\n // is genuinely unknown and says so, rather than reading as zero.\n if (selection.count === undefined) return undefined;\n return Math.max(0, selection.count - selection.excluded.length);\n }, [selection]);\n\n const hasSelection = selection.type === \"query\"\n ? (selectedCount === undefined || selectedCount > 0)\n : selection.entities.length > 0;\n\n return useMemo(() => ({\n selection,\n setSelection,\n selectedCount,\n hasSelection,\n setSelectedEntities,\n selectAllMatching,\n clearSelection,\n isEntitySelected,\n toggleEntitySelection\n }), [selection, selectedCount, hasSelection, setSelectedEntities, selectAllMatching, clearSelection, isEntitySelected, toggleEntitySelection]);\n}\n\n/**\n * A selection of rows in a collection, for a view of it you control: hand it\n * to the collection as `admin.selectionController` (on a `CollectionPanel`,\n * through `collectionOverrides`) and read what the person ticks here, as rows\n * and ids.\n *\n * ```tsx\n * const selection = useSelectionController(ordersCollection);\n * <CollectionPanel collection={ordersCollection}\n * collectionOverrides={{ selectionController: selection }}/>\n * <Button disabled={!selection.hasSelection}>Ship {selection.selectedCount}</Button>\n * ```\n *\n * @param collection the collection the rows belong to\n * @param path where it is addressed; defaults to `collection.slug`\n * @group Hooks and utilities\n */\nexport function useSelectionController<M extends Record<string, unknown> = Record<string, unknown>>(\n collection: CollectionConfig,\n path?: string\n): SelectionController<M> {\n const controller = useEntitySelectionController<M>();\n const at = path ?? collection.slug;\n return useMemo(() => selectionControllerOf(controller, collection, at), [controller, collection, at]);\n}\n"],"mappings":";;;;;;;;AAUA,SAAS,WAAW,GAAgB,GAAyB;CACzD,OAAO,OAAO,EAAE,EAAE,MAAM,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;AACzD;AASA,SAAS,UAAU,UAAmC;CAClD,MAAM,wBAAkB,IAAI,IAAI;CAChC,KAAK,MAAM,UAAU,UAAU;EAC3B,IAAI,MAAM,MAAM,IAAI,OAAO,IAAI;EAC/B,IAAI,CAAC,KAAK;GACN,sBAAM,IAAI,IAAI;GACd,MAAM,IAAI,OAAO,MAAM,GAAG;EAC9B;EACA,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC;CAC7B;CACA,OAAO;AACX;AAEA,SAAS,SAAS,OAAiB,QAA8B;CAC7D,OAAO,MAAM,IAAI,OAAO,IAAI,CAAC,EAAE,IAAI,OAAO,OAAO,EAAE,CAAC,KAAK;AAC7D;AAEA,IAAM,kBAAwC;CAC1C,MAAM;CACN,UAAU,CAAC;AACf;AAEA,SAAgB,6BACZ,mBAC4B;CAE5B,MAAM,CAAC,WA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,aAAa;GACT,MAAM;GACN;GACA,UAAU,CAAC;GACX;EACJ,CAAC;CACL,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,kBAAkB;EACrC,aAAa,eAAqC;CACtD,GAAG,CAAC,CAAC;CAEL,MAAM,gBAAgB,cAAc;EAChC,IAAI,UAAU,SAAS,YAAY,OAAO,UAAU,SAAS;EAG7D,IAAI,UAAU,UAAU,KAAA,GAAW,OAAO,KAAA;EAC1C,OAAO,KAAK,IAAI,GAAG,UAAU,QAAQ,UAAU,SAAS,MAAM;CAClE,GAAG,CAAC,SAAS,CAAC;CAEd,MAAM,eAAe,UAAU,SAAS,UACjC,kBAAkB,KAAA,KAAa,gBAAgB,IAChD,UAAU,SAAS,SAAS;CAElC,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IAAI;EAAC;EAAW;EAAe;EAAc;EAAqB;EAAmB;EAAgB;EAAkB;CAAqB,CAAC;AACjJ;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,uBACZ,YACA,MACsB;CACtB,MAAM,aAAa,6BAAgC;CACnD,MAAM,KAAK,QAAQ,WAAW;CAC9B,OAAO,cAAc,sBAAsB,YAAY,YAAY,EAAE,GAAG;EAAC;EAAY;EAAY;CAAE,CAAC;AACxG"}
1
+ {"version":3,"file":"useSelectionController.js","names":[],"sources":["../../../src/components/CollectionViewBinding/useSelectionController.tsx"],"sourcesContent":["import { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { EntitySelection, EntitySelectionController, SelectionController, SelectionQuery, CollectionConfig, Entity } from \"@rebasepro/cms-types\";\nimport { selectionControllerOf } from \"@rebasepro/app\";\n\n/**\n * Same row: id alone is not unique across a junction-backed tab's two paths.\n * Ids compare as the strings they address a record by — an integer key's `5`\n * and `\"5\"` are one record, whichever of the two a caller handed back.\n */\nfunction sameEntity(a: Entity<any>, b: Entity<any>): boolean {\n return String(a.id) === String(b.id) && a.path === b.path;\n}\n\n/**\n * The rows of a list, by path and then by id, for asking about one row in\n * constant time. Keyed in two levels rather than by a joined string: a path\n * and an id may both contain a slash.\n */\ntype RowIndex = Map<string, Set<string>>;\n\nfunction indexRows(entities: Entity<any>[]): RowIndex {\n const index: RowIndex = new Map();\n for (const entity of entities) {\n let ids = index.get(entity.path);\n if (!ids) {\n ids = new Set();\n index.set(entity.path, ids);\n }\n ids.add(String(entity.id));\n }\n return index;\n}\n\nfunction indexHas(index: RowIndex, entity: Entity<any>): boolean {\n return index.get(entity.path)?.has(String(entity.id)) ?? false;\n}\n\nconst EMPTY_SELECTION: EntitySelection<any> = {\n type: \"entities\",\n entities: []\n};\n\nexport function useEntitySelectionController<M extends Record<string, unknown> = Record<string, unknown>>(\n onSelectionChange?: (entity: Entity<M>, selected: boolean) => void\n): EntitySelectionController<M> {\n\n const [selection, setSelection] = useState<EntitySelection<M>>(EMPTY_SELECTION as EntitySelection<M>);\n\n const onSelectionChangeRef = useRef(onSelectionChange);\n onSelectionChangeRef.current = onSelectionChange;\n\n const toggleEntitySelection = useCallback((entity: Entity<M>, newSelectedState?: boolean) => {\n setSelection(prev => {\n\n // In query mode a row is selected unless it was taken back out, so\n // unticking one ADDS to the exclusions rather than removing from a\n // list of the selected — the list does not exist, and building it\n // would mean reading every matching row first.\n if (prev.type === \"query\") {\n const isExcluded = prev.excluded.some(e => sameEntity(e, entity));\n const shouldSelect = newSelectedState ?? isExcluded;\n if (shouldSelect === !isExcluded) return prev;\n onSelectionChangeRef.current?.(entity, shouldSelect);\n return {\n ...prev,\n excluded: shouldSelect\n ? prev.excluded.filter(e => !sameEntity(e, entity))\n : [...prev.excluded, entity]\n };\n }\n\n const isSelected = prev.entities.some(e => sameEntity(e, entity));\n const shouldSelect = newSelectedState ?? !isSelected;\n if (shouldSelect === isSelected) return prev;\n onSelectionChangeRef.current?.(entity, shouldSelect);\n return {\n type: \"entities\",\n entities: shouldSelect\n ? [...prev.entities, entity]\n : prev.entities.filter(e => !sameEntity(e, entity))\n };\n });\n }, []);\n\n // Built once per selection. The views ask about every row they hold —\n // the selection menu and the list or card view, after each change — and a\n // linear search per row made \"select all loaded rows\" quadratic: 10,000\n // rows, ~200 ms per view per change.\n const selectionIndex = useMemo(\n () => indexRows(selection.type === \"query\" ? selection.excluded : selection.entities),\n [selection]);\n\n const isEntitySelected = useCallback((entity: Entity<M>) => {\n // Every row a view can show you in query mode came out of that query,\n // so membership is the exclusion list and nothing else. The binding\n // clears the selection if the filter moves underneath it, which is what\n // keeps that true.\n if (selection.type === \"query\")\n return !indexHas(selectionIndex, entity);\n return indexHas(selectionIndex, entity);\n }, [selection, selectionIndex]);\n\n const setSelectedEntities = useCallback((entities: Entity<M>[]) => {\n setSelection({\n type: \"entities\",\n entities\n });\n }, []);\n\n const selectAllMatching = useCallback((query: SelectionQuery<M>, count?: number) => {\n setSelection({\n type: \"query\",\n query,\n excluded: [],\n count\n });\n }, []);\n\n const clearSelection = useCallback(() => {\n setSelection(EMPTY_SELECTION as EntitySelection<M>);\n }, []);\n\n const selectedCount = useMemo(() => {\n if (selection.type === \"entities\") return selection.entities.length;\n // An accessor with no `count` can still be selected in full; the number\n // is genuinely unknown and says so, rather than reading as zero.\n if (selection.count === undefined) return undefined;\n return Math.max(0, selection.count - selection.excluded.length);\n }, [selection]);\n\n const hasSelection = selection.type === \"query\"\n ? (selectedCount === undefined || selectedCount > 0)\n : selection.entities.length > 0;\n\n return useMemo(() => ({\n selection,\n setSelection,\n selectedCount,\n hasSelection,\n setSelectedEntities,\n selectAllMatching,\n clearSelection,\n isEntitySelected,\n toggleEntitySelection\n }), [selection, selectedCount, hasSelection, setSelectedEntities, selectAllMatching, clearSelection, isEntitySelected, toggleEntitySelection]);\n}\n\n/**\n * A selection of rows in a collection, for a view of it you control: hand it\n * to the collection as `admin.selectionController` (on a `CollectionPanel`,\n * through `collectionOverrides`) and read what the person ticks here, as rows\n * and ids.\n *\n * ```tsx\n * const selection = useSelectionController(ordersCollection);\n * <CollectionPanel collection={ordersCollection}\n * collectionOverrides={{ selectionController: selection }}/>\n * <Button disabled={!selection.hasSelection}>Ship {selection.selectedCount}</Button>\n * ```\n *\n * @param collection the collection the rows belong to\n * @param path where it is addressed; defaults to `collection.slug`\n * @group Hooks and utilities\n */\nexport function useSelectionController<M extends Record<string, unknown> = Record<string, unknown>>(\n collection: CollectionConfig,\n path?: string\n): SelectionController<M> {\n const controller = useEntitySelectionController<M>();\n const at = path ?? collection.slug;\n return useMemo(() => selectionControllerOf(controller, collection, at), [controller, collection, at]);\n}\n"],"mappings":";;;;;;;;AASA,SAAS,WAAW,GAAgB,GAAyB;CACzD,OAAO,OAAO,EAAE,EAAE,MAAM,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;AACzD;AASA,SAAS,UAAU,UAAmC;CAClD,MAAM,wBAAkB,IAAI,IAAI;CAChC,KAAK,MAAM,UAAU,UAAU;EAC3B,IAAI,MAAM,MAAM,IAAI,OAAO,IAAI;EAC/B,IAAI,CAAC,KAAK;GACN,sBAAM,IAAI,IAAI;GACd,MAAM,IAAI,OAAO,MAAM,GAAG;EAC9B;EACA,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC;CAC7B;CACA,OAAO;AACX;AAEA,SAAS,SAAS,OAAiB,QAA8B;CAC7D,OAAO,MAAM,IAAI,OAAO,IAAI,CAAC,EAAE,IAAI,OAAO,OAAO,EAAE,CAAC,KAAK;AAC7D;AAEA,IAAM,kBAAwC;CAC1C,MAAM;CACN,UAAU,CAAC;AACf;AAEA,SAAgB,6BACZ,mBAC4B;CAE5B,MAAM,CAAC,WAAW,gBAAgB,SAA6B,eAAqC;CAEpG,MAAM,uBAAuB,OAAO,iBAAiB;CACrD,qBAAqB,UAAU;CAE/B,MAAM,wBAAwB,aAAa,QAAmB,qBAA+B;EACzF,cAAa,SAAQ;GAMjB,IAAI,KAAK,SAAS,SAAS;IACvB,MAAM,aAAa,KAAK,SAAS,MAAK,MAAK,WAAW,GAAG,MAAM,CAAC;IAChE,MAAM,eAAe,oBAAoB;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KAAA;EAC1C,OAAO,KAAK,IAAI,GAAG,UAAU,QAAQ,UAAU,SAAS,MAAM;CAClE,GAAG,CAAC,SAAS,CAAC;CAEd,MAAM,eAAe,UAAU,SAAS,UACjC,kBAAkB,KAAA,KAAa,gBAAgB,IAChD,UAAU,SAAS,SAAS;CAElC,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IAAI;EAAC;EAAW;EAAe;EAAc;EAAqB;EAAmB;EAAgB;EAAkB;CAAqB,CAAC;AACjJ;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,uBACZ,YACA,MACsB;CACtB,MAAM,aAAa,6BAAgC;CACnD,MAAM,KAAK,QAAQ,WAAW;CAC9B,OAAO,cAAc,sBAAsB,YAAY,YAAY,EAAE,GAAG;EAAC;EAAY;EAAY;CAAE,CAAC;AACxG"}
@@ -1,21 +1,36 @@
1
1
  import React from "react";
2
- import type { AdminCollection } from "@rebasepro/cms-types";
2
+ import type { AdminCollection, TableCustomization } from "@rebasepro/cms-types";
3
+ import type { TableDescriptor } from "@rebasepro/types";
3
4
  /**
4
5
  * @group Components
5
6
  */
6
7
  export interface CollectionsProviderProps {
7
8
  /**
8
- * The collections this scope can show and edit — `defineCollection`
9
- * configs or resolved collections. Keep the array stable (a module
10
- * constant, or `useMemo`): a new array is a new set of collections.
9
+ * Presentation for the tables the server serves, one `customizeTable(...)`
10
+ * result per table — as on `<RebaseCMS>`. Every served table is known to
11
+ * this scope without one.
11
12
  */
12
- collections: AdminCollection[];
13
+ tableCustomizations?: readonly TableCustomization[];
14
+ /**
15
+ * Collections whose rows live outside the Rebase backend
16
+ * (`defineFirestoreCollection`), known to this scope beside the tables —
17
+ * as on `<RebaseCMS>`. Keep the array stable (a module constant, or
18
+ * `useMemo`): a new array is a new set of collections.
19
+ */
20
+ externalCollections?: readonly AdminCollection[];
21
+ /**
22
+ * For embedding and tests: the tables to render instead of the ones the
23
+ * server serves — as on `<RebaseCMS>`. Given, the server is asked for
24
+ * none.
25
+ */
26
+ tables?: readonly TableDescriptor[];
13
27
  children: React.ReactNode;
14
28
  }
15
29
  /**
16
30
  * Everything a collection view or a record form needs to work in a page of
17
31
  * your own app, without `<RebaseCMS>`, `<RebaseNavigation>` or
18
- * `<RebaseShell>`: a registry of the collections you hand it, the record side
32
+ * `<RebaseShell>`: a registry of the tables the server serves (with your
33
+ * `tableCustomizations`) and of your `externalCollections`, the record side
19
34
  * panel and dialogs (rendered here), and the navigation guard.
20
35
  *
21
36
  * It needs `<Rebase>` above it and a React Router router — any router, at any
@@ -31,7 +46,7 @@ export interface CollectionsProviderProps {
31
46
  * ```tsx
32
47
  * <Rebase client={client} authController={authController}>
33
48
  * <BrowserRouter>
34
- * <CollectionsProvider collections={[postsCollection, authorsCollection]}>
49
+ * <CollectionsProvider tableCustomizations={[postsCms]}>
35
50
  * <CollectionPanel collection="posts"/>
36
51
  * <CollectionPanel collection="authors"/>
37
52
  * </CollectionsProvider>
@@ -41,4 +56,4 @@ export interface CollectionsProviderProps {
41
56
  *
42
57
  * @group Components
43
58
  */
44
- export declare function CollectionsProvider({ collections, children }: CollectionsProviderProps): React.JSX.Element;
59
+ export declare function CollectionsProvider({ tableCustomizations, externalCollections, tables: givenTables, children }: CollectionsProviderProps): React.JSX.Element;
@@ -6,12 +6,14 @@ import { useBuildNavigationStateController } from "../hooks/navigation/useBuildN
6
6
  import { useBuildUrlController } from "../hooks/navigation/useBuildUrlController.js";
7
7
  import { SideDialogs } from "./SideDialogs.js";
8
8
  import { SidePanelProvider } from "./SidePanelProvider.js";
9
+ import { composeCollectionsInput } from "../hooks/navigation/compose_collections_input.js";
10
+ import { usePanelTables } from "../hooks/navigation/usePanelTables.js";
9
11
  import { CollectionsScopeContext } from "./CollectionsScopeContext.js";
10
12
  import { useCallback, useContext, useEffect, useId, useMemo, useRef } from "react";
11
13
  import { jsx, jsxs } from "react/jsx-runtime";
12
- import { buildRoutedRebaseData, resolveDataSource } from "@rebasepro/common";
14
+ import { buildRoutedRebaseData } from "@rebasepro/cms-types";
13
15
  import { CollectionResolverRegistrationContext, RebaseDataContext, StudioBridgeRegistryContext, useAdminModeController, useCustomizationController, useData, useDataSources, useRebaseContext, useUserConfigurationPersistence } from "@rebasepro/app";
14
- import { resolveAdminCollection } from "@rebasepro/cms-types";
16
+ import { resolveDataSource } from "@rebasepro/common";
15
17
  //#region src/components/CollectionsProvider.tsx
16
18
  var EMPTY_PLUGINS = [];
17
19
  /**
@@ -24,10 +26,13 @@ function holdsLeadingCollection(registry, path) {
24
26
  return false;
25
27
  }
26
28
  var NO_VIEWS = [];
29
+ var NO_CUSTOMIZATIONS = [];
30
+ var NO_EXTERNAL_COLLECTIONS = [];
27
31
  /**
28
32
  * Everything a collection view or a record form needs to work in a page of
29
33
  * your own app, without `<RebaseCMS>`, `<RebaseNavigation>` or
30
- * `<RebaseShell>`: a registry of the collections you hand it, the record side
34
+ * `<RebaseShell>`: a registry of the tables the server serves (with your
35
+ * `tableCustomizations`) and of your `externalCollections`, the record side
31
36
  * panel and dialogs (rendered here), and the navigation guard.
32
37
  *
33
38
  * It needs `<Rebase>` above it and a React Router router — any router, at any
@@ -43,7 +48,7 @@ var NO_VIEWS = [];
43
48
  * ```tsx
44
49
  * <Rebase client={client} authController={authController}>
45
50
  * <BrowserRouter>
46
- * <CollectionsProvider collections={[postsCollection, authorsCollection]}>
51
+ * <CollectionsProvider tableCustomizations={[postsCms]}>
47
52
  * <CollectionPanel collection="posts"/>
48
53
  * <CollectionPanel collection="authors"/>
49
54
  * </CollectionsProvider>
@@ -53,7 +58,7 @@ var NO_VIEWS = [];
53
58
  *
54
59
  * @group Components
55
60
  */
56
- function CollectionsProvider({ collections, children }) {
61
+ function CollectionsProvider({ tableCustomizations = NO_CUSTOMIZATIONS, externalCollections = NO_EXTERNAL_COLLECTIONS, tables: givenTables, children }) {
57
62
  const context = useRebaseContext();
58
63
  const adminModeController = useAdminModeController();
59
64
  const userConfigPersistence = useUserConfigurationPersistence();
@@ -100,10 +105,21 @@ function CollectionsProvider({ collections, children }) {
100
105
  isUrlCollectionPath: () => false,
101
106
  routesMounted: false
102
107
  }), [builtUrlController]);
103
- const resolvedCollections = useMemo(() => collections.map((collection) => resolveAdminCollection(collection)), [collections]);
108
+ const descriptors = usePanelTables(givenTables, true);
109
+ const servedTables = descriptors.tables;
110
+ const collectionsBuilder = useMemo(() => composeCollectionsInput({
111
+ tables: servedTables,
112
+ tableCustomizations,
113
+ externalCollections
114
+ }), [
115
+ servedTables,
116
+ tableCustomizations,
117
+ externalCollections
118
+ ]);
104
119
  const navigationStateController = useBuildNavigationStateController({
105
120
  plugins: customizationController.plugins ?? EMPTY_PLUGINS,
106
- collections: resolvedCollections,
121
+ collections: collectionsBuilder,
122
+ collectionsPending: descriptors.status === "loading",
107
123
  views: NO_VIEWS,
108
124
  authController: context.authController,
109
125
  data: context.data,
@@ -1 +1 @@
1
- {"version":3,"file":"CollectionsProvider.js","names":[],"sources":["../../src/components/CollectionsProvider.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useId, useMemo, useRef } from \"react\";\nimport {\n CollectionResolverRegistrationContext,\n RebaseDataContext,\n StudioBridgeRegistryContext,\n useAdminModeController,\n useCustomizationController,\n useData,\n useDataSources,\n useRebaseContext,\n useUserConfigurationPersistence\n} from \"@rebasepro/app\";\nimport { buildRoutedRebaseData, CollectionRegistry, resolveDataSource } from \"@rebasepro/common\";\nimport { resolveAdminCollection } from \"@rebasepro/cms-types\";\nimport type { AdminCollection, AppView, RebasePlugin, UrlController } from \"@rebasepro/cms-types\";\n\nimport { useBuildCollectionRegistryController } from \"../hooks/navigation/useBuildCollectionRegistryController\";\nimport { useBuildUrlController } from \"../hooks/navigation/useBuildUrlController\";\nimport { useBuildNavigationStateController } from \"../hooks/navigation/useBuildNavigationStateController\";\nimport { CollectionRegistryContext } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { UrlContext } from \"../hooks/navigation/contexts/UrlContext\";\nimport { NavigationStateContext } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { SidePanelProvider } from \"./SidePanelProvider\";\nimport { SideDialogs } from \"./SideDialogs\";\nimport { CollectionsScopeContext } from \"./CollectionsScopeContext\";\n\nconst EMPTY_PLUGINS: RebasePlugin[] = [];\n\n/**\n * Whether `path` starts with a collection this registry holds — the longest\n * leading run of whole segments, since a slug may contain slashes.\n */\nfunction holdsLeadingCollection(registry: CollectionRegistry, path: string): boolean {\n const segments = path.split(\"/\").filter(Boolean);\n for (let length = segments.length; length > 0; length--) {\n if (registry.get(segments.slice(0, length).join(\"/\"))) return true;\n }\n return false;\n}\nconst NO_VIEWS: AppView[] = [];\n\n/**\n * @group Components\n */\nexport interface CollectionsProviderProps {\n /**\n * The collections this scope can show and edit — `defineCollection`\n * configs or resolved collections. Keep the array stable (a module\n * constant, or `useMemo`): a new array is a new set of collections.\n */\n collections: AdminCollection[];\n children: React.ReactNode;\n}\n\n/**\n * Everything a collection view or a record form needs to work in a page of\n * your own app, without `<RebaseCMS>`, `<RebaseNavigation>` or\n * `<RebaseShell>`: a registry of the collections you hand it, the record side\n * panel and dialogs (rendered here), and the navigation guard.\n *\n * It needs `<Rebase>` above it and a React Router router — any router, at any\n * path; a data router is not required. No CMS route serves the page, so a\n * record opens in a side panel or a dialog over it, never by URL.\n *\n * `CollectionPanel` and `RecordForm` given a `collection` bring one of\n * these themselves when none is above; mount it yourself to share one between\n * several of them, or to use the lower-level pieces (`CollectionViewBinding`,\n * `useSidePanel`) directly.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <CollectionsProvider collections={[postsCollection, authorsCollection]}>\n * <CollectionPanel collection=\"posts\"/>\n * <CollectionPanel collection=\"authors\"/>\n * </CollectionsProvider>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function CollectionsProvider({ collections, children }: CollectionsProviderProps) {\n const context = useRebaseContext();\n const adminModeController = useAdminModeController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const dataSources = useDataSources();\n const collectionRegistryController = useBuildCollectionRegistryController({ userConfigPersistence, dataSources: dataSources.registry });\n\n // The data layer gives a row its address from its collection's primary\n // key, and these collections are known only here. Registered under this\n // scope's own owner, so several scopes on one page — and the full CMS\n // beside them — do not overwrite each other. During render for the reason\n // `RebaseNavigation` gives (the views that fetch rows are below), and again\n // on mount, since a strict-mode remount runs the cleanup in between.\n const registerCollectionResolver = useContext(CollectionResolverRegistrationContext);\n const owner = useId();\n const getCollectionRef = useRef(collectionRegistryController.getCollection);\n getCollectionRef.current = collectionRegistryController.getCollection;\n const registryRef = collectionRegistryController.collectionRegistryRef;\n // Asked about every collection any owner has, so a path this scope does\n // not hold is answered quietly rather than by the registry's warning.\n const resolveCollection = useCallback((slug: string) =>\n holdsLeadingCollection(registryRef.current, slug) ? getCollectionRef.current(slug) : undefined, [registryRef]);\n const resolveDataPath = collectionRegistryController.resolveDataPath;\n registerCollectionResolver(resolveCollection, resolveDataPath, owner);\n useEffect(() => {\n registerCollectionResolver(resolveCollection, resolveDataPath, owner);\n return () => registerCollectionResolver(undefined, undefined, owner);\n }, [registerCollectionResolver, resolveCollection, resolveDataPath, owner]);\n\n // Each collection routed to the data source it declares, as in the CMS.\n const defaultData = useData();\n const routedData = useMemo(() => buildRoutedRebaseData({\n defaultData,\n sources: dataSources.sources,\n resolveKey: (slugOrPath) => resolveDataSource(resolveCollection(slugOrPath), dataSources.registry).key\n }), [defaultData, dataSources, resolveCollection]);\n\n // Paths are still built — a panel keys its records by them — but nothing\n // navigates to one, and no URL is read as a record to open.\n const builtUrlController = useBuildUrlController({\n basePath: \"/\",\n baseCollectionPath: \"/c\",\n collectionRegistryController\n });\n const urlController = useMemo<UrlController>(() => ({\n ...builtUrlController,\n isUrlCollectionPath: () => false,\n routesMounted: false\n }), [builtUrlController]);\n\n const resolvedCollections = useMemo(() => collections.map(collection => resolveAdminCollection(collection)), [collections]);\n const navigationStateController = useBuildNavigationStateController({\n plugins: customizationController.plugins ?? EMPTY_PLUGINS,\n collections: resolvedCollections,\n views: NO_VIEWS,\n authController: context.authController!,\n // The collection and view builders get the rows the server sends.\n data: context.data,\n collectionRegistryController,\n urlController,\n adminMode: adminModeController?.mode\n });\n\n // The Studio bridge describes the CMS's own controllers. A scope embedded\n // in the shell must not replace them there, so its registrations go nowhere.\n return (\n <CollectionsScopeContext.Provider value={true}>\n <StudioBridgeRegistryContext.Provider value={null}>\n <RebaseDataContext.Provider value={routedData}>\n <CollectionRegistryContext.Provider value={collectionRegistryController}>\n <UrlContext.Provider value={urlController}>\n <NavigationStateContext.Provider value={navigationStateController}>\n <SidePanelProvider>\n {children}\n <SideDialogs/>\n </SidePanelProvider>\n </NavigationStateContext.Provider>\n </UrlContext.Provider>\n </CollectionRegistryContext.Provider>\n </RebaseDataContext.Provider>\n </StudioBridgeRegistryContext.Provider>\n </CollectionsScopeContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAM,gBAAgC,CAAC;;;;;AAMvC,SAAS,uBAAuB,UAA8B,MAAuB;CACjF,MAAM,WAAW,KAAK,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC/C,KAAK,IAAI,SAAS,SAAS,QAAQ,SAAS,GAAG,UAC3C,IAAI,SAAS,IAAI,SAAS,MAAM,GAAG,MAAM,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,OAAO;CAElE,OAAO;AACX;AACA,IAAM,WAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4C7B,SAAgB,oBAAoB,EAAE,aAAa,YAAsC;CACrF,MAAM,UAAU,iBAAiB;CACjC,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,wBAAwB,gCAAgC;CAC9D,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,cAAc,eAAe;CACnC,MAAM,+BAA+B,qCAAqC;EAAE;EAAuB,aAAa,YAAY;CAAS,CAAC;CAQtI,MAAM,6BAA6B,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OAAO;cAC/B,oBAAC,0BAA0B,UAA3B;KAAoC,OAAO;eACvC,oBAAC,WAAW,UAAZ;MAAqB,OAAO;gBACxB,oBAAC,uBAAuB,UAAxB;OAAiC,OAAO;iBACpC,qBAAC,mBAAD,EAAA,UAAA,CACK,UACD,oBAAC,aAAD,CAAa,CAAA,CACE,EAAA,CAAA;MACU,CAAA;KAChB,CAAA;IACW,CAAA;GACZ,CAAA;EACM,CAAA;CACR,CAAA;AAE1C"}
1
+ {"version":3,"file":"CollectionsProvider.js","names":[],"sources":["../../src/components/CollectionsProvider.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useId, useMemo, useRef } from \"react\";\nimport {\n CollectionResolverRegistrationContext,\n RebaseDataContext,\n StudioBridgeRegistryContext,\n useAdminModeController,\n useCustomizationController,\n useData,\n useDataSources,\n useRebaseContext,\n useUserConfigurationPersistence\n} from \"@rebasepro/app\";\nimport { resolveDataSource } from \"@rebasepro/common\";\nimport { CollectionRegistry, buildRoutedRebaseData } from \"@rebasepro/cms-types\";\nimport type { AdminCollection, AppView, RebasePlugin, TableCustomization, UrlController } from \"@rebasepro/cms-types\";\nimport type { TableDescriptor } from \"@rebasepro/types\";\n\nimport { useBuildCollectionRegistryController } from \"../hooks/navigation/useBuildCollectionRegistryController\";\nimport { useBuildUrlController } from \"../hooks/navigation/useBuildUrlController\";\nimport { useBuildNavigationStateController } from \"../hooks/navigation/useBuildNavigationStateController\";\nimport { composeCollectionsInput } from \"../hooks/navigation/compose_collections_input\";\nimport { usePanelTables } from \"../hooks/navigation/usePanelTables\";\nimport { CollectionRegistryContext } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { UrlContext } from \"../hooks/navigation/contexts/UrlContext\";\nimport { NavigationStateContext } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { SidePanelProvider } from \"./SidePanelProvider\";\nimport { SideDialogs } from \"./SideDialogs\";\nimport { CollectionsScopeContext } from \"./CollectionsScopeContext\";\n\nconst EMPTY_PLUGINS: RebasePlugin[] = [];\n\n/**\n * Whether `path` starts with a collection this registry holds — the longest\n * leading run of whole segments, since a slug may contain slashes.\n */\nfunction holdsLeadingCollection(registry: CollectionRegistry, path: string): boolean {\n const segments = path.split(\"/\").filter(Boolean);\n for (let length = segments.length; length > 0; length--) {\n if (registry.get(segments.slice(0, length).join(\"/\"))) return true;\n }\n return false;\n}\nconst NO_VIEWS: AppView[] = [];\nconst NO_CUSTOMIZATIONS: readonly TableCustomization[] = [];\nconst NO_EXTERNAL_COLLECTIONS: readonly AdminCollection[] = [];\n\n/**\n * @group Components\n */\nexport interface CollectionsProviderProps {\n /**\n * Presentation for the tables the server serves, one `customizeTable(...)`\n * result per table — as on `<RebaseCMS>`. Every served table is known to\n * this scope without one.\n */\n tableCustomizations?: readonly TableCustomization[];\n /**\n * Collections whose rows live outside the Rebase backend\n * (`defineFirestoreCollection`), known to this scope beside the tables —\n * as on `<RebaseCMS>`. Keep the array stable (a module constant, or\n * `useMemo`): a new array is a new set of collections.\n */\n externalCollections?: readonly AdminCollection[];\n /**\n * For embedding and tests: the tables to render instead of the ones the\n * server serves — as on `<RebaseCMS>`. Given, the server is asked for\n * none.\n */\n tables?: readonly TableDescriptor[];\n children: React.ReactNode;\n}\n\n/**\n * Everything a collection view or a record form needs to work in a page of\n * your own app, without `<RebaseCMS>`, `<RebaseNavigation>` or\n * `<RebaseShell>`: a registry of the tables the server serves (with your\n * `tableCustomizations`) and of your `externalCollections`, the record side\n * panel and dialogs (rendered here), and the navigation guard.\n *\n * It needs `<Rebase>` above it and a React Router router — any router, at any\n * path; a data router is not required. No CMS route serves the page, so a\n * record opens in a side panel or a dialog over it, never by URL.\n *\n * `CollectionPanel` and `RecordForm` given a `collection` bring one of\n * these themselves when none is above; mount it yourself to share one between\n * several of them, or to use the lower-level pieces (`CollectionViewBinding`,\n * `useSidePanel`) directly.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <CollectionsProvider tableCustomizations={[postsCms]}>\n * <CollectionPanel collection=\"posts\"/>\n * <CollectionPanel collection=\"authors\"/>\n * </CollectionsProvider>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function CollectionsProvider({\n tableCustomizations = NO_CUSTOMIZATIONS,\n externalCollections = NO_EXTERNAL_COLLECTIONS,\n tables: givenTables,\n children\n}: CollectionsProviderProps) {\n const context = useRebaseContext();\n const adminModeController = useAdminModeController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const customizationController = useCustomizationController();\n const dataSources = useDataSources();\n const collectionRegistryController = useBuildCollectionRegistryController({ userConfigPersistence, dataSources: dataSources.registry });\n\n // The data layer gives a row its address from its collection's primary\n // key, and these collections are known only here. Registered under this\n // scope's own owner, so several scopes on one page — and the full CMS\n // beside them — do not overwrite each other. During render for the reason\n // `RebaseNavigation` gives (the views that fetch rows are below), and again\n // on mount, since a strict-mode remount runs the cleanup in between.\n const registerCollectionResolver = useContext(CollectionResolverRegistrationContext);\n const owner = useId();\n const getCollectionRef = useRef(collectionRegistryController.getCollection);\n getCollectionRef.current = collectionRegistryController.getCollection;\n const registryRef = collectionRegistryController.collectionRegistryRef;\n // Asked about every collection any owner has, so a path this scope does\n // not hold is answered quietly rather than by the registry's warning.\n const resolveCollection = useCallback((slug: string) =>\n holdsLeadingCollection(registryRef.current, slug) ? getCollectionRef.current(slug) : undefined, [registryRef]);\n const resolveDataPath = collectionRegistryController.resolveDataPath;\n registerCollectionResolver(resolveCollection, resolveDataPath, owner);\n useEffect(() => {\n registerCollectionResolver(resolveCollection, resolveDataPath, owner);\n return () => registerCollectionResolver(undefined, undefined, owner);\n }, [registerCollectionResolver, resolveCollection, resolveDataPath, owner]);\n\n // Each collection routed to the data source it declares, as in the CMS.\n const defaultData = useData();\n const routedData = useMemo(() => buildRoutedRebaseData({\n defaultData,\n sources: dataSources.sources,\n resolveKey: (slugOrPath) => resolveDataSource(resolveCollection(slugOrPath), dataSources.registry).key\n }), [defaultData, dataSources, resolveCollection]);\n\n // Paths are still built — a panel keys its records by them — but nothing\n // navigates to one, and no URL is read as a record to open.\n const builtUrlController = useBuildUrlController({\n basePath: \"/\",\n baseCollectionPath: \"/c\",\n collectionRegistryController\n });\n const urlController = useMemo<UrlController>(() => ({\n ...builtUrlController,\n isUrlCollectionPath: () => false,\n routesMounted: false\n }), [builtUrlController]);\n\n // The same two inputs as <RebaseCMS>: the tables, customized, and the\n // external collections.\n const descriptors = usePanelTables(givenTables, true);\n const servedTables = descriptors.tables;\n const collectionsBuilder = useMemo(\n () => composeCollectionsInput({ tables: servedTables, tableCustomizations, externalCollections }),\n [servedTables, tableCustomizations, externalCollections]);\n const navigationStateController = useBuildNavigationStateController({\n plugins: customizationController.plugins ?? EMPTY_PLUGINS,\n collections: collectionsBuilder,\n // Until the tables arrive, a panel shows its loading state rather\n // than \"collection not found\".\n collectionsPending: descriptors.status === \"loading\",\n views: NO_VIEWS,\n authController: context.authController!,\n // The collection and view builders get the rows the server sends.\n data: context.data,\n collectionRegistryController,\n urlController,\n adminMode: adminModeController?.mode\n });\n\n // The Studio bridge describes the CMS's own controllers. A scope embedded\n // in the shell must not replace them there, so its registrations go nowhere.\n return (\n <CollectionsScopeContext.Provider value={true}>\n <StudioBridgeRegistryContext.Provider value={null}>\n <RebaseDataContext.Provider value={routedData}>\n <CollectionRegistryContext.Provider value={collectionRegistryController}>\n <UrlContext.Provider value={urlController}>\n <NavigationStateContext.Provider value={navigationStateController}>\n <SidePanelProvider>\n {children}\n <SideDialogs/>\n </SidePanelProvider>\n </NavigationStateContext.Provider>\n </UrlContext.Provider>\n </CollectionRegistryContext.Provider>\n </RebaseDataContext.Provider>\n </StudioBridgeRegistryContext.Provider>\n </CollectionsScopeContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,IAAM,gBAAgC,CAAC;;;;;AAMvC,SAAS,uBAAuB,UAA8B,MAAuB;CACjF,MAAM,WAAW,KAAK,MAAM,GAAG,CAAC,CAAC,O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G,CAAC,GAAG;EAAC;EAAa;EAAa;CAAiB,CAAC;CAIjD,MAAM,qBAAqB,sBAAsB;EAC7C,UAAU;EACV,oBAAoB;EACpB;CACJ,CAAC;CACD,MAAM,gBAAgB,eAA8B;EAChD,GAAG;EACH,2BAA2B;EAC3B,eAAe;CACnB,IAAI,CAAC,kBAAkB,CAAC;CAIxB,MAAM,cAAc,eAAe,aAAa,IAAI;CACpD,MAAM,eAAe,YAAY;CACjC,MAAM,qBAAqB,cACjB,wBAAwB;EAAE,QAAQ;EAAc;EAAqB;CAAoB,CAAC,GAChG;EAAC;EAAc;EAAqB;CAAmB,CAAC;CAC5D,MAAM,4BAA4B,kCAAkC;EAChE,SAAS,wBAAwB,WAAW;EAC5C,aAAa;EAGb,oBAAoB,YAAY,WAAW;EAC3C,OAAO;EACP,gBAAgB,QAAQ;EAExB,MAAM,QAAQ;EACd;EACA;EACA,WAAW,qBAAqB;CACpC,CAAC;CAID,OACI,oBAAC,wBAAwB,UAAzB;EAAkC,OAAO;YACrC,oBAAC,4BAA4B,UAA7B;GAAsC,OAAO;aACzC,oBAAC,kBAAkB,UAAnB;IAA4B,OAAO;cAC/B,oBAAC,0BAA0B,UAA3B;KAAoC,OAAO;eACvC,oBAAC,WAAW,UAAZ;MAAqB,OAAO;gBACxB,oBAAC,uBAAuB,UAAxB;OAAiC,OAAO;iBACpC,qBAAC,mBAAD,EAAA,UAAA,CACK,UACD,oBAAC,aAAD,CAAa,CAAA,CACE,EAAA,CAAA;MACU,CAAA;KAChB,CAAA;IACW,CAAA;GACZ,CAAA;EACM,CAAA;CACR,CAAA;AAE1C"}
@@ -6,8 +6,8 @@ import { DrawerNavigationGroup } from "./DrawerNavigationGroup.js";
6
6
  import React, { useCallback, useMemo } from "react";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { Avatar, ChevronsLeftIcon, ChevronsRightIcon, IconButton, LogOutIcon, Menu, MenuItem, MoonIcon, SettingsIcon, Skeleton, SunIcon, SunMoonIcon, ToggleButtonGroup, Tooltip, Typography, cls, iconSize } from "@rebasepro/ui";
9
- import { LanguageToggle, RebaseLogo, RlsSimulatorBar, buildCollapsedDefaults, useAdminModeController, useAnalyticsController, useAuthController, useCanSimulateAccess, useCollapsedGroups, useComponentOverride, useLargeLayout, useModeController, useRebaseContext, useRebaseRegistry, useSlot, useTranslation } from "@rebasepro/app";
10
9
  import { studioSchemaToolEnabled } from "@rebasepro/cms-types";
10
+ import { LanguageToggle, RebaseLogo, RlsSimulatorBar, buildCollapsedDefaults, useAdminModeController, useAnalyticsController, useAuthController, useCanSimulateAccess, useCollapsedGroups, useComponentOverride, useLargeLayout, useModeController, useRebaseContext, useRebaseRegistry, useSlot, useTranslation } from "@rebasepro/app";
11
11
  import { Link, useNavigate } from "react-router";
12
12
  //#region src/components/DefaultDrawer.tsx
13
13
  /**
@@ -1,4 +1,4 @@
1
- import { Entity } from "@rebasepro/types";
1
+ import { Entity } from "@rebasepro/cms-types";
2
2
  import React from "react";
3
3
  import type { AdminCollection, EntitySelection } from "@rebasepro/cms-types";
4
4
  export interface DeleteEntityDialogProps<M extends Record<string, unknown>> {
@@ -98,7 +98,7 @@ function DeleteEntityDialog({ target, collection, onClose, open, onEntityDelete,
98
98
  try {
99
99
  entities = await resolveEntitySelection({
100
100
  selection,
101
- accessor: dataClient.collection(path),
101
+ accessor: dataClient.table(path),
102
102
  signal: cancelledRef.current,
103
103
  onProgress: (loaded, total) => setProgress(total === void 0 ? t("selection_reading_rows_unknown", { loaded: loaded.toLocaleString() }) : t("selection_reading_rows", {
104
104
  loaded: loaded.toLocaleString(),
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteEntityDialog.js","names":[],"sources":["../../src/components/DeleteEntityDialog.tsx"],"sourcesContent":["import { Entity } from \"@rebasepro/types\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from \"@rebasepro/ui\";\nimport {\n deleteEntityWithCallbacks,\n useData,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport type { AdminCollection, EntitySelection } from \"@rebasepro/cms-types\";\nimport { resolveEntitySelection } from \"../selection/resolve_selection\";\nimport { mapWithConcurrency } from \"../util/map_with_concurrency\";\n\n/**\n * Deletes in flight at once.\n *\n * The bulk delete used to be `Promise.all(entities.map(performDelete))`, which\n * is unremarkable for the handful of rows anyone could tick by hand and\n * untenable the moment \"select all 12,480 matching\" can reach it.\n */\nconst DELETE_CONCURRENCY = 8;\n\nexport interface DeleteEntityDialogProps<M extends Record<string, unknown>> {\n /**\n * What to delete: one row, or a whole selection.\n *\n * A selection may be a *query* — every row matching a filter, most of them\n * never read. That is why this is not an `Entity[]`: the rows do not exist\n * until {@link resolveEntitySelection} reads them, and it only does that once the\n * user has confirmed.\n */\n target?: Entity<M> | EntitySelection<M>,\n path: string,\n collection: AdminCollection<M>\n open: boolean;\n onClose: () => void;\n\n onEntityDelete?(path: string, entity: Entity<M>): void;\n\n onMultipleEntitiesDelete?(path: string, entities: Entity<M>[]): void;\n\n /**\n * What the DELETE at this path actually does.\n *\n * `\"unlink\"` when the rows are shared through a junction: the server removes\n * the link and leaves the row alone, so a dialog promising deletion would be\n * describing something else.\n */\n variant?: \"delete\" | \"unlink\";\n}\n\nfunction isSelection<M extends Record<string, unknown>>(\n target: Entity<M> | EntitySelection<M>\n): target is EntitySelection<M> {\n return (target as EntitySelection<M>).type === \"entities\" || (target as EntitySelection<M>).type === \"query\";\n}\n\nexport function DeleteEntityDialog<M extends Record<string, unknown>>({\n target,\n collection,\n onClose,\n open,\n onEntityDelete,\n onMultipleEntitiesDelete,\n path,\n variant = \"delete\"\n}: DeleteEntityDialogProps<M>) {\n const dataClient = useData();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const [loading, setLoading] = useState(false);\n const [progress, setProgress] = useState<string | undefined>(undefined);\n const cancelledRef = useRef({ aborted: false });\n\n const context = useAdminContext();\n\n // A one-row selection is a single delete: the dialog shows that row rather\n // than the anonymous \"these entities\" copy, which is what anyone ticking\n // exactly one checkbox expects to see.\n const { singleEntity, selection } = useMemo(() => {\n if (!target)\n return { singleEntity: undefined,\n selection: undefined };\n if (!isSelection(target))\n return { singleEntity: target,\n selection: undefined };\n if (target.type === \"entities\" && target.entities.length === 1)\n return { singleEntity: target.entities[0],\n selection: undefined };\n return { singleEntity: undefined,\n selection: target };\n }, [target]);\n\n /** How many rows this will delete; `undefined` when only the server knows. */\n const selectionCount = selection === undefined\n ? 1\n : selection.type === \"entities\"\n ? selection.entities.length\n : selection.count === undefined\n ? undefined\n : Math.max(0, selection.count - selection.excluded.length);\n\n const handleCancel = useCallback(() => {\n cancelledRef.current.aborted = true;\n onClose();\n }, [onClose]);\n\n const onDeleteSuccess = useCallback((entity: Entity<any>) => {\n console.debug(\"Deleted\", entity);\n }, []);\n\n const onDeleteFailure = useCallback((entity: Entity<any>, e: Error) => {\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting\"),\n message: e?.message\n });\n\n console.error(\"Error deleting entity\");\n console.error(e);\n }, [collection.name]);\n\n const performDelete = useCallback((entity: Entity<M>, onFailure: (entity: Entity<any>, e: Error) => void = onDeleteFailure): Promise<boolean> =>\n deleteEntityWithCallbacks({\n data: dataClient,\n entity,\n collection: collection,\n onDeleteSuccess,\n onDeleteFailure: onFailure,\n context\n }), [dataClient, collection, onDeleteSuccess, onDeleteFailure, context]);\n\n const handleOk = useCallback(async () => {\n\n if (singleEntity) {\n setLoading(true);\n const success = await performDelete(singleEntity);\n setLoading(false);\n if (success) {\n onEntityDelete?.(path, singleEntity);\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"deleted\", { name: collection.singularName ?? collection.name })\n });\n onClose();\n }\n return;\n }\n\n if (!selection) return;\n\n setLoading(true);\n cancelledRef.current = { aborted: false };\n\n let entities: Entity<M>[];\n try {\n // Reading happens *after* the confirmation, not before it: a query\n // selection over a large collection is tens of requests, and doing\n // them up front would make clicking the bin — an action the user has\n // not yet agreed to — the expensive part.\n entities = await resolveEntitySelection<M>({\n selection,\n accessor: dataClient.collection<M>(path),\n signal: cancelledRef.current,\n onProgress: (loaded, total) => setProgress(\n total === undefined\n ? t(\"selection_reading_rows_unknown\", { loaded: loaded.toLocaleString() })\n : t(\"selection_reading_rows\", {\n loaded: loaded.toLocaleString(),\n total: total.toLocaleString()\n })\n )\n });\n } catch (e) {\n setLoading(false);\n setProgress(undefined);\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting_entities\", { collection: collection.name }),\n message: (e as Error)?.message\n });\n return;\n }\n\n if (cancelledRef.current.aborted) {\n setLoading(false);\n setProgress(undefined);\n return;\n }\n\n // Collected, not one snackbar per row: a mass refusal (a foreign key\n // every row trips) queued a toast per row of a delete that can walk\n // 20,000 of them. The summary below names how many, and the first cause.\n const failures: Error[] = [];\n const recordFailure = (_entity: Entity<any>, e: Error) => {\n failures.push(e);\n console.error(\"Error deleting entity\", e);\n };\n\n let results: boolean[] = [];\n try {\n results = await mapWithConcurrency(\n entities,\n DELETE_CONCURRENCY,\n // Cancel has to reach the deletes too, not just the read that\n // precedes them. It cannot recall the ones already in flight,\n // but it stops the queue — otherwise closing the dialog on a\n // 12,000-row delete would leave it running with nothing on\n // screen saying so.\n (entity) => cancelledRef.current.aborted\n ? Promise.resolve(false)\n : performDelete(entity, recordFailure),\n (completed, total) => setProgress(t(\"selection_deleting_progress\", {\n completed: completed.toLocaleString(),\n total: total.toLocaleString()\n }))\n );\n } catch (e) {\n // `mapWithConcurrency` runs every task before it rethrows, so the\n // rows that could be deleted have been. The per-row failure handler\n // has already reported the cause.\n console.error(\"Error deleting entities\", e);\n }\n\n setLoading(false);\n setProgress(undefined);\n\n onMultipleEntitiesDelete?.(path, entities.filter((_, i) => results[i]));\n\n const deleted = results.filter(Boolean).length;\n const failedSummary = failures.length > 0\n ? t(\"delete_rows_failed\", {\n failed: failures.length.toLocaleString(),\n total: entities.length.toLocaleString(),\n reason: failures[0]?.message ?? \"\"\n })\n : undefined;\n if (deleted === entities.length && entities.length > 0) {\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"multiple_deleted\", { collection: collection.name })\n });\n } else if (deleted > 0) {\n snackbarController.open({\n type: \"warning\",\n title: failedSummary ? t(\"some_entities_deleted\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"some_entities_deleted\", { collection: collection.name })\n });\n } else {\n snackbarController.open({\n type: \"error\",\n title: failedSummary ? t(\"error_deleting_entities\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"error_deleting_entities\", { collection: collection.name })\n });\n }\n onClose();\n }, [singleEntity, selection, performDelete, dataClient, path, onEntityDelete, onMultipleEntitiesDelete, onClose, snackbarController, collection.name, collection.singularName, t, variant]);\n\n const entityName = collection.singularName ?? collection.name;\n\n let dialogTitle: React.ReactNode;\n if (singleEntity) {\n dialogTitle = variant === \"unlink\"\n ? t(\"unlink_entity_confirm_title\", { entityName })\n : t(\"delete_entity_confirm_title\", { entityName });\n } else if (variant === \"unlink\") {\n dialogTitle = <><b>{collection.name}</b>: {t(\"confirm_multiple_unlink\")}</>;\n } else if (selectionCount === undefined) {\n // \"Every matching row, and the server has not said how many.\" Naming a\n // number here would be inventing one for an irreversible action.\n dialogTitle = t(\"confirm_delete_selection_unknown\");\n } else {\n dialogTitle = t(\"confirm_delete_selection\", {\n total: selectionCount.toLocaleString(),\n collection: collection.name\n });\n }\n\n return (\n <Dialog\n maxWidth={singleEntity ? \"2xl\" : \"lg\"}\n aria-labelledby=\"delete-dialog\"\n open={open}\n // Escape and a click outside are a cancel, not just a close: the\n // abort flag is what stops a bulk delete's queue, and a dialog that\n // only closed left it deleting with nothing on screen.\n onOpenChange={(open) => {\n if (!open) handleCancel();\n }}\n >\n <DialogTitle id=\"delete-dialog-title\">\n {dialogTitle}\n </DialogTitle>\n <DialogContent fullHeight={true}>\n {variant === \"unlink\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"unlink_entity_confirm_body\", { collectionName: collection.name })}\n </Typography>\n </div>}\n {singleEntity && <div className={\"p-4\"}>\n <EntityViewBinding\n entity={singleEntity}\n collection={collection}\n path={path}/>\n </div>}\n {!singleEntity && variant === \"delete\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"confirm_delete_selection_body\")}\n </Typography>\n </div>}\n </DialogContent>\n <DialogActions>\n\n {loading && <CircularProgress size={\"smallest\"}/>}\n {progress && <Typography variant={\"caption\"} color={\"secondary\"}>{progress}</Typography>}\n\n <Button onClick={handleCancel}\n variant=\"text\">\n {t(\"cancel\")}\n </Button>\n <Button\n autoFocus\n disabled={loading}\n onClick={handleOk}\n variant=\"filled\">\n {t(\"ok\")}\n </Button>\n </DialogActions>\n\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAM,qBAAqB;AA+B3B,SAAS,YACL,QAC4B;CAC5B,OAAQ,OAA8B,SAAS,cAAe,OAA8B,SAAS;AACzG;AAEA,SAAgB,mBAAsD,EAClE,QACA,YACA,SACA,MACA,gBACA,0BACA,MACA,UAAU,YACiB;CAC3B,MAAM,aAAa,QAAQ;CAC3B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,SAA6B,KAAA,CAAS;CACtE,MAAM,eAAe,OAAO,EAAE,SAAS,MAAM,CAAC;CAE9C,MAAM,UAAU,gBAAgB;CAKhC,MAAM,EAAE,cAAc,cAAc,cAAc;EAC9C,IAAI,CAAC,QACD,OAAO;GAAE,cAAc,KAAA;GACnB,WAAW,KAAA;EAAU;EAC7B,IAAI,CAAC,YAAY,MAA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ntityDialog.tsx"],"sourcesContent":["import { Entity } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from \"@rebasepro/ui\";\nimport {\n deleteEntityWithCallbacks,\n useData,\n useSnackbarController,\n useTranslation\n} from \"@rebasepro/app\";\nimport { useAdminContext } from \"../hooks\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport type { AdminCollection, EntitySelection } from \"@rebasepro/cms-types\";\nimport { resolveEntitySelection } from \"../selection/resolve_selection\";\nimport { mapWithConcurrency } from \"../util/map_with_concurrency\";\n\n/**\n * Deletes in flight at once.\n *\n * The bulk delete used to be `Promise.all(entities.map(performDelete))`, which\n * is unremarkable for the handful of rows anyone could tick by hand and\n * untenable the moment \"select all 12,480 matching\" can reach it.\n */\nconst DELETE_CONCURRENCY = 8;\n\nexport interface DeleteEntityDialogProps<M extends Record<string, unknown>> {\n /**\n * What to delete: one row, or a whole selection.\n *\n * A selection may be a *query* — every row matching a filter, most of them\n * never read. That is why this is not an `Entity[]`: the rows do not exist\n * until {@link resolveEntitySelection} reads them, and it only does that once the\n * user has confirmed.\n */\n target?: Entity<M> | EntitySelection<M>,\n path: string,\n collection: AdminCollection<M>\n open: boolean;\n onClose: () => void;\n\n onEntityDelete?(path: string, entity: Entity<M>): void;\n\n onMultipleEntitiesDelete?(path: string, entities: Entity<M>[]): void;\n\n /**\n * What the DELETE at this path actually does.\n *\n * `\"unlink\"` when the rows are shared through a junction: the server removes\n * the link and leaves the row alone, so a dialog promising deletion would be\n * describing something else.\n */\n variant?: \"delete\" | \"unlink\";\n}\n\nfunction isSelection<M extends Record<string, unknown>>(\n target: Entity<M> | EntitySelection<M>\n): target is EntitySelection<M> {\n return (target as EntitySelection<M>).type === \"entities\" || (target as EntitySelection<M>).type === \"query\";\n}\n\nexport function DeleteEntityDialog<M extends Record<string, unknown>>({\n target,\n collection,\n onClose,\n open,\n onEntityDelete,\n onMultipleEntitiesDelete,\n path,\n variant = \"delete\"\n}: DeleteEntityDialogProps<M>) {\n const dataClient = useData();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n const [loading, setLoading] = useState(false);\n const [progress, setProgress] = useState<string | undefined>(undefined);\n const cancelledRef = useRef({ aborted: false });\n\n const context = useAdminContext();\n\n // A one-row selection is a single delete: the dialog shows that row rather\n // than the anonymous \"these entities\" copy, which is what anyone ticking\n // exactly one checkbox expects to see.\n const { singleEntity, selection } = useMemo(() => {\n if (!target)\n return { singleEntity: undefined,\n selection: undefined };\n if (!isSelection(target))\n return { singleEntity: target,\n selection: undefined };\n if (target.type === \"entities\" && target.entities.length === 1)\n return { singleEntity: target.entities[0],\n selection: undefined };\n return { singleEntity: undefined,\n selection: target };\n }, [target]);\n\n /** How many rows this will delete; `undefined` when only the server knows. */\n const selectionCount = selection === undefined\n ? 1\n : selection.type === \"entities\"\n ? selection.entities.length\n : selection.count === undefined\n ? undefined\n : Math.max(0, selection.count - selection.excluded.length);\n\n const handleCancel = useCallback(() => {\n cancelledRef.current.aborted = true;\n onClose();\n }, [onClose]);\n\n const onDeleteSuccess = useCallback((entity: Entity<any>) => {\n console.debug(\"Deleted\", entity);\n }, []);\n\n const onDeleteFailure = useCallback((entity: Entity<any>, e: Error) => {\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting\"),\n message: e?.message\n });\n\n console.error(\"Error deleting entity\");\n console.error(e);\n }, [collection.name]);\n\n const performDelete = useCallback((entity: Entity<M>, onFailure: (entity: Entity<any>, e: Error) => void = onDeleteFailure): Promise<boolean> =>\n deleteEntityWithCallbacks({\n data: dataClient,\n entity,\n collection: collection,\n onDeleteSuccess,\n onDeleteFailure: onFailure,\n context\n }), [dataClient, collection, onDeleteSuccess, onDeleteFailure, context]);\n\n const handleOk = useCallback(async () => {\n\n if (singleEntity) {\n setLoading(true);\n const success = await performDelete(singleEntity);\n setLoading(false);\n if (success) {\n onEntityDelete?.(path, singleEntity);\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"deleted\", { name: collection.singularName ?? collection.name })\n });\n onClose();\n }\n return;\n }\n\n if (!selection) return;\n\n setLoading(true);\n cancelledRef.current = { aborted: false };\n\n let entities: Entity<M>[];\n try {\n // Reading happens *after* the confirmation, not before it: a query\n // selection over a large collection is tens of requests, and doing\n // them up front would make clicking the bin — an action the user has\n // not yet agreed to — the expensive part.\n entities = await resolveEntitySelection<M>({\n selection,\n accessor: dataClient.table<M>(path),\n signal: cancelledRef.current,\n onProgress: (loaded, total) => setProgress(\n total === undefined\n ? t(\"selection_reading_rows_unknown\", { loaded: loaded.toLocaleString() })\n : t(\"selection_reading_rows\", {\n loaded: loaded.toLocaleString(),\n total: total.toLocaleString()\n })\n )\n });\n } catch (e) {\n setLoading(false);\n setProgress(undefined);\n snackbarController.open({\n type: \"error\",\n title: t(\"error_deleting_entities\", { collection: collection.name }),\n message: (e as Error)?.message\n });\n return;\n }\n\n if (cancelledRef.current.aborted) {\n setLoading(false);\n setProgress(undefined);\n return;\n }\n\n // Collected, not one snackbar per row: a mass refusal (a foreign key\n // every row trips) queued a toast per row of a delete that can walk\n // 20,000 of them. The summary below names how many, and the first cause.\n const failures: Error[] = [];\n const recordFailure = (_entity: Entity<any>, e: Error) => {\n failures.push(e);\n console.error(\"Error deleting entity\", e);\n };\n\n let results: boolean[] = [];\n try {\n results = await mapWithConcurrency(\n entities,\n DELETE_CONCURRENCY,\n // Cancel has to reach the deletes too, not just the read that\n // precedes them. It cannot recall the ones already in flight,\n // but it stops the queue — otherwise closing the dialog on a\n // 12,000-row delete would leave it running with nothing on\n // screen saying so.\n (entity) => cancelledRef.current.aborted\n ? Promise.resolve(false)\n : performDelete(entity, recordFailure),\n (completed, total) => setProgress(t(\"selection_deleting_progress\", {\n completed: completed.toLocaleString(),\n total: total.toLocaleString()\n }))\n );\n } catch (e) {\n // `mapWithConcurrency` runs every task before it rethrows, so the\n // rows that could be deleted have been. The per-row failure handler\n // has already reported the cause.\n console.error(\"Error deleting entities\", e);\n }\n\n setLoading(false);\n setProgress(undefined);\n\n onMultipleEntitiesDelete?.(path, entities.filter((_, i) => results[i]));\n\n const deleted = results.filter(Boolean).length;\n const failedSummary = failures.length > 0\n ? t(\"delete_rows_failed\", {\n failed: failures.length.toLocaleString(),\n total: entities.length.toLocaleString(),\n reason: failures[0]?.message ?? \"\"\n })\n : undefined;\n if (deleted === entities.length && entities.length > 0) {\n snackbarController.open({\n type: \"success\",\n message: variant === \"unlink\"\n ? t(\"removed_from_record\")\n : t(\"multiple_deleted\", { collection: collection.name })\n });\n } else if (deleted > 0) {\n snackbarController.open({\n type: \"warning\",\n title: failedSummary ? t(\"some_entities_deleted\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"some_entities_deleted\", { collection: collection.name })\n });\n } else {\n snackbarController.open({\n type: \"error\",\n title: failedSummary ? t(\"error_deleting_entities\", { collection: collection.name }) : undefined,\n message: failedSummary ?? t(\"error_deleting_entities\", { collection: collection.name })\n });\n }\n onClose();\n }, [singleEntity, selection, performDelete, dataClient, path, onEntityDelete, onMultipleEntitiesDelete, onClose, snackbarController, collection.name, collection.singularName, t, variant]);\n\n const entityName = collection.singularName ?? collection.name;\n\n let dialogTitle: React.ReactNode;\n if (singleEntity) {\n dialogTitle = variant === \"unlink\"\n ? t(\"unlink_entity_confirm_title\", { entityName })\n : t(\"delete_entity_confirm_title\", { entityName });\n } else if (variant === \"unlink\") {\n dialogTitle = <><b>{collection.name}</b>: {t(\"confirm_multiple_unlink\")}</>;\n } else if (selectionCount === undefined) {\n // \"Every matching row, and the server has not said how many.\" Naming a\n // number here would be inventing one for an irreversible action.\n dialogTitle = t(\"confirm_delete_selection_unknown\");\n } else {\n dialogTitle = t(\"confirm_delete_selection\", {\n total: selectionCount.toLocaleString(),\n collection: collection.name\n });\n }\n\n return (\n <Dialog\n maxWidth={singleEntity ? \"2xl\" : \"lg\"}\n aria-labelledby=\"delete-dialog\"\n open={open}\n // Escape and a click outside are a cancel, not just a close: the\n // abort flag is what stops a bulk delete's queue, and a dialog that\n // only closed left it deleting with nothing on screen.\n onOpenChange={(open) => {\n if (!open) handleCancel();\n }}\n >\n <DialogTitle id=\"delete-dialog-title\">\n {dialogTitle}\n </DialogTitle>\n <DialogContent fullHeight={true}>\n {variant === \"unlink\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"unlink_entity_confirm_body\", { collectionName: collection.name })}\n </Typography>\n </div>}\n {singleEntity && <div className={\"p-4\"}>\n <EntityViewBinding\n entity={singleEntity}\n collection={collection}\n path={path}/>\n </div>}\n {!singleEntity && variant === \"delete\" && <div className={\"px-4 pt-4\"}>\n <Typography variant={\"body2\"} color={\"secondary\"}>\n {t(\"confirm_delete_selection_body\")}\n </Typography>\n </div>}\n </DialogContent>\n <DialogActions>\n\n {loading && <CircularProgress size={\"smallest\"}/>}\n {progress && <Typography variant={\"caption\"} color={\"secondary\"}>{progress}</Typography>}\n\n <Button onClick={handleCancel}\n variant=\"text\">\n {t(\"cancel\")}\n </Button>\n <Button\n autoFocus\n disabled={loading}\n onClick={handleOk}\n variant=\"filled\">\n {t(\"ok\")}\n </Button>\n </DialogActions>\n\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAM,qBAAqB;AA+B3B,SAAS,YACL,QAC4B;CAC5B,OAAQ,OAA8B,SAAS,cAAe,OAA8B,SAAS;AACzG;AAEA,SAAgB,mBAAsD,EAClE,QACA,YACA,SACA,MACA,gBACA,0BACA,MACA,UAAU,YACiB;CAC3B,MAAM,aAAa,QAAQ;CAC3B,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,SAA6B,KAAA,CAAS;CACtE,MAAM,eAAe,OAAO,EAAE,SAAS,MAAM,CAAC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AAD;KACI,WAAA;KACA,UAAU;KACV,SAAS;KACT,SAAQ;eACP,EAAE,IAAI;IACH,CAAA;GACG,EAAA,CAAA;EAEX;;AAEhB"}
@@ -1,3 +1,4 @@
1
+ import { hasEntityId } from "../util/identity.js";
1
2
  import { useCollectionRegistryController } from "../hooks/navigation/contexts/CollectionRegistryContext.js";
2
3
  import { useUrlController } from "../hooks/navigation/contexts/UrlContext.js";
3
4
  import { useAdminContext } from "../hooks/useAdminContext.js";
@@ -15,8 +16,7 @@ import { EntityViewBody, useReadOnlyFormContext } from "./EntityViewBody.js";
15
16
  import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
16
17
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
18
  import { Button, CenteredView, CircularProgressCenter, ErrorBoundary, IconButton, Maximize2Icon, PencilIcon, Skeleton, Tab, Tabs, Tooltip, Typography, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
18
- import { hasEntityId } from "@rebasepro/common";
19
- import { CollectionScopeProvider, ErrorView, PluginProviderStack, getAdminEntityChildViews, getIcon, removeInitialAndTrailingSlashes, resolveComponentRef, resolveDefaultSelectedView, rowOfEntity, useComponentOverride, useCustomizationController, useFetch, usePermissions, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
19
+ import { CollectionScopeProvider, ErrorView, PluginProviderStack, getAdminEntityChildViews, getIcon, removeInitialAndTrailingSlashes, resolveDefaultSelectedView, rowOfEntity, useComponentOverride, useCustomizationController, useFetch, usePermissions, useRebaseContext, useSlot, useTranslation } from "@rebasepro/app";
20
20
  import { useNavigate } from "react-router";
21
21
  //#region src/components/DetailViewBinding.tsx
22
22
  function DetailViewBinding({ entityId, ...props }) {
@@ -173,7 +173,7 @@ function DetailViewBindingInner({ path, entityId, selectedTab: selectedTabProp,
173
173
  const nonActionCustomViews = useMemo(() => resolvedEntityViews.filter((e) => !e.includeActions), [resolvedEntityViews]);
174
174
  const customViewsView = customViews && nonActionCustomViews.map((customView) => {
175
175
  if (!customView) return null;
176
- const Builder = resolveComponentRef(customView.Builder);
176
+ const Builder = customView.Builder;
177
177
  if (!Builder) return null;
178
178
  if (!hasEntityId(entityId)) return null;
179
179
  const isActive = activeTab === customView.key;
@@ -1 +1 @@
1
- {"version":3,"file":"DetailViewBinding.js","names":[],"sources":["../../src/components/DetailViewBinding.tsx"],"sourcesContent":["import { hasEntityId } from \"@rebasepro/common\";\nimport type { EntityCustomViewParams, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { FormContext } from \"../types/fields\";\nimport type { PluginFormActionProps } from \"@rebasepro/cms-types\";\nimport React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity, EntityStatus, Property } from \"@rebasepro/types\";\nimport { PluginProviderStack, resolveComponentRef, useComponentOverride, CollectionScopeProvider, getAdminEntityChildViews } from \"@rebasepro/app\";\n\nimport { CollectionViewBinding } from \"./CollectionViewBinding/CollectionViewBinding\";\nimport { EntityViewBody, useReadOnlyFormContext } from \"./EntityViewBody\";\nimport { EntityIdentityBar } from \"./EntityIdentityBar\";\nimport { SplitListCloseButton } from \"./CollectionViewBinding/SplitListCloseButton\";\nimport { SplitListShowButton } from \"./CollectionViewBinding/SplitListShowButton\";\nimport { EntityInspector, InspectorTab } from \"./EntityInspector\";\nimport { CircularProgressCenter, iconSize } from \"@rebasepro/ui\";\nimport {\n Alert,\n Button,\n CenteredView,\n cls,\n CodeIcon,\n defaultBorderMixin,\n HistoryIcon,\n IconButton,\n Maximize2Icon,\n PencilIcon,\n Skeleton,\n Tab,\n Tabs,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView, usePermissions, useTranslation, getIcon } from \"@rebasepro/app\";\n\nimport { removeInitialAndTrailingSlashes, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { withListState } from \"../util/view_mode\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport { rowOfEntity } from \"@rebasepro/app\";\nimport {\n useCustomizationController,\n useFetch,\n useRebaseContext,\n useLargeLayout,\n useSlot\n} from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate } from \"react-router\";\nimport { useEntityDisplayTitle } from \"../hooks/useEntityDisplayTitle\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useLeaveRecord, useRecordActions } from \"../hooks/useRecordActions\";\n\n\nimport {\n MAIN_TAB_VALUE,\n JSON_TAB_VALUE,\n HISTORY_TAB_VALUE,\n ENTITY_VIEW_TAB_BAR_CLASS,\n ENTITY_VIEW_TAB_CLASS,\n ENTITY_VIEW_TAB_LABEL_CLASS\n} from \"../util/view_constants\";\n\nexport type BarActionsParams = {\n values: object,\n status: EntityStatus,\n path: string,\n entityId?: string | number;\n /** Always false here — this view reads a record, it does not edit one. */\n dirty: boolean;\n};\n\nexport type OnTabChangeParams<M extends Record<string, unknown>> = {\n path: string;\n entityId?: string | number;\n selectedTab?: string;\n collection: AdminCollection<M>;\n};\n\nexport interface DetailViewBindingProps<M extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n collection: AdminCollection<M>;\n entityId: string | number;\n selectedTab?: string;\n parentCollectionSlugs: string[];\n parentEntityIds: string[];\n onTabChange?: (props: OnTabChangeParams<M>) => void;\n onEditClick?: () => void;\n /**\n * Dismiss this record — the ✕ at the identity bar's trailing edge.\n *\n * Set by the layouts that own the record's place on screen but are not side\n * dialogs: the split, where dismissing is navigating back to the collection.\n */\n onCloseRequest?: () => void;\n layout?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n barActions?: (params: BarActionsParams) => React.ReactNode;\n /**\n * Controls the owning panel puts at the identity bar's leading edge, ahead\n * of the breadcrumb — the side panel's close button.\n */\n barActionsStart?: React.ReactNode;\n /**\n * Full screen only: bring the list back beside this record. Set when the\n * record was opened out of a split collection, so folding the list away is\n * reversible; it takes the place of the back arrow when present.\n */\n onShowList?: () => void;\n}\n\nexport function DetailViewBinding<M extends Record<string, unknown>>({\n entityId,\n ...props\n}: DetailViewBindingProps<M>) {\n\n const { t } = useTranslation();\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch<M>({\n path: props.path,\n entityId: entityId,\n collection: props.collection,\n // The relation fields' values, read with the record (see `useFetch`).\n relations: true,\n useCache: false\n });\n\n if (!dataLoading && dataLoadingError) {\n return <CenteredView>\n <ErrorView error={dataLoadingError} />\n </CenteredView>;\n }\n\n if (!dataLoading && !entity) {\n return <CenteredView>\n <Typography variant=\"label\">{t(\"entity_not_found\")}</Typography>\n </CenteredView>;\n }\n\n const content = (\n <DetailViewBindingInner<M>\n {...props}\n entityId={entityId}\n entity={entity}\n dataLoading={dataLoading}\n />\n );\n\n return (\n <CollectionScopeProvider collection={props.collection}>\n {content}\n </CollectionScopeProvider>\n );\n}\n\nfunction DetailViewBindingInner<M extends Record<string, unknown>>({\n path,\n entityId,\n selectedTab: selectedTabProp,\n collection,\n parentCollectionSlugs,\n parentEntityIds,\n onTabChange,\n onEditClick,\n onCloseRequest,\n entity,\n dataLoading,\n layout = \"full_screen\",\n barActions,\n barActionsStart,\n onShowList\n}: DetailViewBindingProps<M> & {\n entity?: Entity<M>,\n dataLoading: boolean,\n}) {\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const { t } = useTranslation();\n const context = useRebaseContext();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const customizationController = useCustomizationController();\n const plugins = customizationController.plugins;\n const collectionRegistryController = useCollectionRegistryController();\n const { canEdit: canEditHook } = usePermissions();\n\n const canEdit = useMemo(() => {\n return entity ? canEditHook(collection, path, entity.values) : false;\n }, [canEditHook, entity, collection, path]);\n\n const [usedEntity, setUsedEntity] = useState<Entity<M> | undefined>(entity);\n useEffect(() => {\n if (entity) setUsedEntity(entity);\n }, [entity]);\n // The record as the entity views and the actions are handed it.\n const usedRow = usedEntity ? rowOfEntity(usedEntity, collection) : undefined;\n\n const defaultSelectedView = useMemo(() => resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\", id: entityId }\n ), [collection, entityId]);\n\n // Track whether the user has explicitly clicked a tab in this component\n // instance. See EditViewBindingInner for full explanation.\n const userHasChangedTab = useRef(false);\n\n const [selectedTab, setSelectedTab] = useState<string>(() => {\n const val = selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE;\n return val === \"edit\" ? MAIN_TAB_VALUE : val;\n });\n useEffect(() => {\n const val = userHasChangedTab.current\n ? (selectedTabProp ?? MAIN_TAB_VALUE)\n : (selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);\n const target = val === \"edit\" ? MAIN_TAB_VALUE : val;\n if (target !== selectedTab) {\n setSelectedTab(target);\n }\n }, [selectedTabProp, defaultSelectedView]);\n\n // `hideFromEntityViews`, not `hideFromNavigation`: the latter governs the\n // drawer. Filtering tabs on it defeated the introspection generator, which\n // sets `hideFromNavigation` on owned-child tables precisely *because* \"every\n // inbound foreign key renders as a tab on the parent\" — so the rows it\n // deliberately kept out of the drawer became reachable from nowhere.\n const childViews = getAdminEntityChildViews(collection).filter(v => !v.collection.hideFromEntityViews);\n const subcollections = childViews.map(v => v.collection);\n const subcollectionsCount = subcollections?.length ?? 0;\n const customViews = collection.entityViews ?? [];\n const customViewsCount = customViews?.length ?? 0;\n const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;\n const includeHistoryView = Boolean(collection.history);\n // Same split as the edit view: the strip is for destinations, the inspector\n // for the developer tools that used to sit in front of them.\n const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;\n\n const [inspectorTab, setInspectorTab] = useState<InspectorTab | null>(null);\n\n const legacyInspectorTab: InspectorTab | undefined = selectedTab === JSON_TAB_VALUE\n ? \"json\"\n : selectedTab === HISTORY_TAB_VALUE ? \"history\" : undefined;\n useEffect(() => {\n if (legacyInspectorTab) setInspectorTab(legacyInspectorTab);\n }, [legacyInspectorTab]);\n\n const {\n resolvedEntityViews\n } = resolvedSelectedEntityView(customViews, customizationController, undefined, canEdit);\n\n const validTabValues = useMemo(() => {\n const set = new Set<string>([\n MAIN_TAB_VALUE,\n ...resolvedEntityViews.map(v => v.key),\n ...subcollections.map(s => s.slug)\n ]);\n return set;\n }, [resolvedEntityViews, subcollections]);\n\n const activeTab = validTabValues.has(selectedTab) ? selectedTab : MAIN_TAB_VALUE;\n\n const {\n selectedEntityView\n } = resolvedSelectedEntityView(customViews, customizationController, activeTab, canEdit);\n\n const mainViewVisible = activeTab === MAIN_TAB_VALUE;\n\n // Track which custom view tabs have been visited\n const mountedTabsRef = useRef<Set<string>>(new Set());\n if (activeTab) {\n mountedTabsRef.current.add(activeTab);\n }\n\n // Read-only form context for custom entity views\n const readOnlyFormContext = useReadOnlyFormContext<M>({\n entityId,\n entity: usedEntity,\n collection,\n path,\n openEntityMode: layout\n });\n\n // Plugin slots\n const formActionTopProps: PluginFormActionProps = useMemo(() => ({\n id: entityId,\n parentCollectionSlugs,\n parentEntityIds,\n path,\n status: \"existing\",\n collection: collection!,\n context,\n formContext: readOnlyFormContext as FormContext<Record<string, unknown>> | undefined,\n openEntityMode: layout,\n disabled: true\n }), [entityId, parentCollectionSlugs, parentEntityIds, path, collection, context, readOnlyFormContext, layout]);\n const pluginActionsTop = useSlot(\"form.actions.top\", formActionTopProps);\n\n // The record's own actions, as on the edit view: a read-only record is\n // still one you can recalculate, resend or delete. There is no form here,\n // so they are called without a `formContext`.\n const adminContext = useAdminContext();\n const leaveRecord = useLeaveRecord({ layout, path, onCloseRequest });\n const recordActionClickProps = useMemo(() => usedEntity\n ? {\n view: \"form\" as const,\n row: usedRow,\n id: String(usedEntity.id),\n path,\n collection: collection as AdminCollection,\n context,\n sidePanelController: adminContext.sidePanelController,\n openEntityMode: layout,\n navigateBack: leaveRecord\n }\n : undefined, [usedEntity, usedRow, path, collection, context, adminContext.sidePanelController, layout, leaveRecord]);\n const recordActions = useRecordActions({\n collection,\n path,\n entity: usedEntity,\n clickProps: recordActionClickProps\n });\n\n // The heading, resolved the one way — this used to be a copy of\n // `useEntityDisplayTitle`'s body, and the two had already drifted.\n const title = useEntityDisplayTitle({\n collection,\n entity: usedEntity,\n status: \"existing\"\n });\n\n // Non-action custom views\n const nonActionCustomViews = useMemo(() =>\n resolvedEntityViews.filter(e => !e.includeActions),\n [resolvedEntityViews]\n );\n\n const customViewsView = customViews && nonActionCustomViews\n .map((customView) => {\n if (!customView) return null;\n const Builder = resolveComponentRef<EntityCustomViewParams>(customView.Builder);\n if (!Builder) return null;\n if (!hasEntityId(entityId)) return null;\n\n const isActive = activeTab === customView.key;\n const hasBeenMounted = mountedTabsRef.current.has(customView.key);\n if (!isActive && !hasBeenMounted) return null;\n\n return <div\n className={cls(defaultBorderMixin,\n \"relative flex-1 w-full h-full overflow-auto\",\n { \"hidden\": !isActive }\n )}\n key={`custom_view_${customView.key}`}\n role=\"tabpanel\">\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n {readOnlyFormContext && <Builder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n row={usedRow}\n id={usedEntity ? String(usedEntity.id) : undefined}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />}\n </Suspense>\n </ErrorBoundary>\n </div>;\n }).filter(Boolean);\n\n const globalLoading = dataLoading && !usedEntity;\n\n // Subcollection views\n const subCollectionsViews = childViews && childViews.map(({ collection: subcollection }) => {\n const subcollectionId = subcollection.slug;\n // By slug, like the path it extends: the data layer hands the driver\n // the stored path, `path` included, for the whole of it at once.\n const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollection.slug)}` : undefined;\n\n if (activeTab !== subcollectionId) return null;\n return (\n <div\n className={\"relative flex-1 h-full overflow-auto w-full\"}\n key={`subcol_${subcollectionId}`}\n role=\"tabpanel\">\n {globalLoading && <CircularProgressCenter />}\n {!globalLoading &&\n (usedEntity && newFullPath\n ? <ResolvedCollectionView\n path={newFullPath}\n parentCollectionSlugs={[...parentCollectionSlugs, collection.slug]}\n parentEntityIds={[...parentEntityIds, String(usedEntity?.id)]}\n updateUrl={false}\n {...subcollection}\n openEntityMode={layout} />\n : <div className=\"flex items-center justify-center w-full h-full p-3\">\n <Typography variant={\"label\"}>\n {/* No `?? \"…\"` here: `t` returns the key itself\n when it cannot find one, never null, so the\n fallback never ran and this rendered the raw\n `save_entity_before_subcollections`. The key\n exists now, in all seven locales. */}\n {t(\"save_entity_before_subcollections\")}\n </Typography>\n </div>)\n }\n </div>\n );\n }).filter(Boolean);\n\n const onSideTabClick = useCallback((value: string) => {\n userHasChangedTab.current = true;\n setSelectedTab(value);\n onTabChange?.({\n path,\n entityId,\n selectedTab: value === MAIN_TAB_VALUE ? undefined : value,\n collection\n });\n }, [onTabChange, path, entityId, collection]);\n\n // The record's body, drawn where `RecordDetail` draws it.\n const propertyDetailView = () => usedEntity\n ? <EntityViewBody<M>\n entity={usedEntity}\n collection={collection}\n path={path}\n formContext={readOnlyFormContext}\n openEntityMode={layout}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n />\n : null;\n\n // Tabs\n const subcollectionTabs = subcollections && subcollections.map((subcollection) => {\n const icon = getIcon(subcollection.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={subcollection.slug}\n key={`entity_detail_collection_tab_${subcollection.name}`}>\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {subcollection.name}\n </span>\n </Tab>\n );\n });\n\n const customViewTabsStart = resolvedEntityViews.filter(view => view.position === \"start\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n const customViewTabsEnd = resolvedEntityViews.filter(view => !view.position || view.position === \"end\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n\n // The breadcrumb's destination, and the back arrow's when it renders. Both\n // keep the list's whole URL state: a collection reached from one of its own\n // records must come back as the user left it — the same view mode, search,\n // filters and sort.\n const collectionUrl = withListState(urlController.buildUrlCollectionPath(path));\n\n // Full screen is the one layout with no way out of its own: a side panel and a\n // dialog can be dismissed, and a split keeps the list beside it, but opening an\n // entity full screen replaces the collection entirely and left browser Back as\n // the only route back to it — which is not an affordance the page shows, and is\n // wrong anyway once the user has moved between tabs inside the entity.\n //\n // Unless the list can be unfolded back beside the record: that chevron\n // leads to the same collection while keeping the record open, so it stands\n // alone rather than beside an arrow going almost the same place.\n //\n // It goes to the bar's leading edge — where a back control reads as back,\n // and where the edit view has always put the same arrow — rather than to\n // the trailing edge among the record's own actions.\n const backToCollection = layout === \"full_screen\" && !onShowList\n ? () => navigate(collectionUrl)\n : undefined;\n\n const fullScreenButton = !barActions && // Not in split: the list panel beside it carries the close control,\n // and an expand button there competes with it.\n (layout === \"side_panel\" || layout === \"dialog\") && hasEntityId(entityId) ? (\n <Tooltip title={\"Open full screen\"}>\n <IconButton aria-label={\"Open full screen\"}\n size=\"small\"\n onClick={() => {\n const entityUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(`${entityUrl}#full`);\n }}\n >\n <Maximize2Icon size={iconSize.smallest} />\n </IconButton>\n </Tooltip>\n ) : null;\n\n // Edit button — only rendered when the user has edit permissions\n const editButton = canEdit && onEditClick ? (\n <Button\n variant=\"filled\"\n color=\"primary\"\n size=\"small\"\n startIcon={<PencilIcon size={iconSize.smallest} />}\n onClick={onEditClick}>\n {t(\"edit_entity\")}\n </Button>\n ) : null;\n\n // Main content view. The title, the `path/id` chip and the empty band under\n // them have moved into the identity bar, and the `w-80 2xl:w-96` rail that\n // held a single Edit button is gone — the bar holds it now.\n //\n // The scroll now lives on the record's own column rather than on this row,\n // so the metadata rail beside it stays put while the record scrolls — the\n // same arrangement the form uses.\n const mainView = <div\n className={cls(\n \"flex-1 flex flex-row w-full min-h-0\",\n !mainViewVisible ? \"hidden\" : \"\"\n )}>\n {propertyDetailView()}\n </div>;\n\n let result = <div className=\"relative flex flex-col h-full w-full bg-surface-card\">\n\n <EntityIdentityBar\n collection={collection as AdminCollection}\n collectionUrl={layout === \"full_screen\" || layout === \"split\" ? collectionUrl : undefined}\n title={title}\n entityId={entityId}\n status={\"existing\"}\n dirty={false}\n saving={false}\n onBack={backToCollection}\n onClose={onCloseRequest}\n onInspect={includeJsonView ? () => setInspectorTab(\"json\") : undefined}\n onViewHistory={includeHistoryView ? () => setInspectorTab(\"history\") : undefined}\n externalLink={usedEntity\n ? customizationController?.entityLinkBuilder?.({\n row: rowOfEntity(usedEntity, collection),\n id: String(usedEntity.id),\n path: usedEntity.path\n })\n : undefined}\n recordActions={recordActions}\n // Where Save stands on the edit view: after the record's own\n // buttons, ahead of the menu.\n primaryAction={editButton}\n leading={<>\n {barActionsStart}\n {/* Split view: closing the list is opening this record\n full screen, and the control for it belongs at this\n bar's leading edge. Full screen carries its mirror. */}\n {layout === \"split\" && <SplitListCloseButton/>}\n {layout === \"full_screen\" && onShowList && <SplitListShowButton onClick={onShowList}/>}\n </>}\n trailing={<>\n {pluginActionsTop}\n {fullScreenButton}\n {barActions?.({\n path,\n entityId,\n values: usedEntity?.values ?? {},\n status: \"existing\",\n dirty: false\n })}\n </>}\n />\n\n {hasAdditionalViews && <div className={cls(\n \"h-10 shrink-0 flex items-stretch border-b px-2 min-w-0\",\n ENTITY_VIEW_TAB_BAR_CLASS,\n defaultBorderMixin\n )}>\n <Tabs\n className={\"!w-full items-stretch\"}\n innerClassName={\"h-full\"}\n variant={\"boxy\"}\n value={activeTab}\n onValueChange={(value) => {\n onSideTabClick(value);\n }}>\n\n {/* Before the record, not after it.\n\n `position: \"start\"` used to mean \"first among the custom\n views\", which put it after a tab it was already after: the\n record's own tab is drawn here unconditionally, so \"start\"\n and \"end\" only ever ordered the custom views against each\n other, and no collection could open with anything but the\n form on the left.\n\n A cover — a read-only summary of the record, the thing an\n operator opens a row to see — belongs in front of the form\n that edits it. That is what `defaultSelectedView` already\n allowed, and the strip contradicted it by drawing the\n selected tab second. Views that say nothing still land after\n the record, so nothing moves for a collection that never\n asked. */}\n {customViewTabsStart}\n\n <Tab value={MAIN_TAB_VALUE}\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}>\n <span className=\"flex items-center gap-1.5\">\n {getIcon(collection.icon, undefined, undefined, \"smallest\")}\n {collection.singularName ?? collection.name}\n </span>\n </Tab>\n\n {customViewTabsEnd}\n {subcollectionTabs}\n </Tabs>\n </div>}\n\n {/* See EditViewBinding: the inspector docks beside the record rather\n than over it, so the record stays readable and scrollable. */}\n <div className={\"flex-1 min-h-0 flex\"}>\n\n <div className={\"flex-1 min-w-0 flex flex-col\"}>\n {globalLoading\n ? <DetailViewSkeleton collection={collection} />\n : mainView}\n\n {customViewsView}\n {subCollectionsViews}\n </div>\n\n <EntityInspector\n tab={inspectorTab}\n onTabChange={setInspectorTab}\n onClose={() => setInspectorTab(null)}\n collection={collection as AdminCollection}\n entity={usedEntity as Entity<Record<string, unknown>> | undefined}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>> | undefined}\n values={usedEntity?.values}\n includeHistory={includeHistoryView}/>\n </div>\n\n </div>;\n\n if (plugins && plugins.length > 0) {\n result = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity: usedEntity,\n context,\n formContext: readOnlyFormContext\n }}>\n {result}\n </PluginProviderStack>\n );\n }\n\n return result;\n}\n\nfunction DetailViewSkeleton({ collection }: { collection: AdminCollection<Record<string, unknown>> }) {\n return (\n <div className=\"flex-1 flex flex-row w-full overflow-y-auto justify-center\">\n <div className=\"relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit\">\n <div className=\"flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10\">\n <div className=\"w-full flex flex-col items-start my-4 lg:my-6\">\n <div className={`py-1 my-4 w-2/3 ${collection.hideIdFromForm ? \"mb-6\" : \"\"}`}>\n <Skeleton height={28} className=\"w-full rounded-md\" />\n </div>\n <Skeleton height={32} className=\"w-full rounded-md\" />\n </div>\n <div className=\"mt-12 flex flex-col gap-8\">\n <div className=\"flex flex-wrap gap-x-4 w-full space-y-8\">\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8GA,SAAgB,kBAAqD,EACjE,UACA,GAAG,SACuB;CAE1B,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,QACA,aACA,qBACA,SAAY;EACZ,MAAM,MAAM;EACF;EACV,YAAY,MAAM;EAElB,WAAW;EACX,UAAU;CACd,CAAC;CAED,IAAI,CAAC,eAAe,kBAChB,OAAO,oBAAC,cAAD,EAAA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AAwE;CAClG,OACI,oBAAC,OAAD;EAAK,WAAU;YACX,oBAAC,OAAD;GAAK,WAAU;aACX,qBAAC,OAAD;IAAK,WAAU;cAAf,CACI,qBAAC,OAAD;KAAK,WAAU;eAAf,CACI,oBAAC,OAAD;MAAK,WAAW,mBAAmB,WAAW,iBAAiB,SAAS;gBACpE,oBAAC,UAAD;OAAU,QAAQ;OAAI,WAAU;MAAqB,CAAA;KACpD,CAAA,GACL,oBAAC,UAAD;MAAU,QAAQ;MAAI,WAAU;KAAqB,CAAA,CACpD;QACL,oBAAC,OAAD;KAAK,WAAU;eACX,qBAAC,OAAD;MAAK,WAAU;gBAAf;OACI,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;OACL,oBAAC,OAAD;QAAK,WAAU;kBACX,oBAAC,UAAD;SAAU,QAAQ;SAAI,WAAU;QAAqB,CAAA;OACpD,CAAA;MACJ;;IACJ,CAAA,CACJ;;EACJ,CAAA;CACJ,CAAA;AAEb"}
1
+ {"version":3,"file":"DetailViewBinding.js","names":[],"sources":["../../src/components/DetailViewBinding.tsx"],"sourcesContent":["import { hasEntityId } from \"../util/identity\";\nimport type { EntityCustomViewParams, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { FormContext } from \"../types/fields\";\nimport type { PluginFormActionProps } from \"@rebasepro/cms-types\";\nimport React, { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { EntityStatus } from \"@rebasepro/types\";\nimport { Property, Entity } from \"@rebasepro/cms-types\";\nimport { PluginProviderStack, useComponentOverride, CollectionScopeProvider, getAdminEntityChildViews } from \"@rebasepro/app\";\n\nimport { CollectionViewBinding } from \"./CollectionViewBinding/CollectionViewBinding\";\nimport { EntityViewBody, useReadOnlyFormContext } from \"./EntityViewBody\";\nimport { EntityIdentityBar } from \"./EntityIdentityBar\";\nimport { SplitListCloseButton } from \"./CollectionViewBinding/SplitListCloseButton\";\nimport { SplitListShowButton } from \"./CollectionViewBinding/SplitListShowButton\";\nimport { EntityInspector, InspectorTab } from \"./EntityInspector\";\nimport { CircularProgressCenter, iconSize } from \"@rebasepro/ui\";\nimport {\n Alert,\n Button,\n CenteredView,\n cls,\n CodeIcon,\n defaultBorderMixin,\n HistoryIcon,\n IconButton,\n Maximize2Icon,\n PencilIcon,\n Skeleton,\n Tab,\n Tabs,\n Tooltip,\n Typography\n} from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView, usePermissions, useTranslation, getIcon } from \"@rebasepro/app\";\n\nimport { removeInitialAndTrailingSlashes, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { withListState } from \"../util/view_mode\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport { rowOfEntity } from \"@rebasepro/app\";\nimport {\n useCustomizationController,\n useFetch,\n useRebaseContext,\n useLargeLayout,\n useSlot\n} from \"@rebasepro/app\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate } from \"react-router\";\nimport { useEntityDisplayTitle } from \"../hooks/useEntityDisplayTitle\";\nimport { useAdminContext } from \"../hooks/useAdminContext\";\nimport { useLeaveRecord, useRecordActions } from \"../hooks/useRecordActions\";\n\n\nimport {\n MAIN_TAB_VALUE,\n JSON_TAB_VALUE,\n HISTORY_TAB_VALUE,\n ENTITY_VIEW_TAB_BAR_CLASS,\n ENTITY_VIEW_TAB_CLASS,\n ENTITY_VIEW_TAB_LABEL_CLASS\n} from \"../util/view_constants\";\n\nexport type BarActionsParams = {\n values: object,\n status: EntityStatus,\n path: string,\n entityId?: string | number;\n /** Always false here — this view reads a record, it does not edit one. */\n dirty: boolean;\n};\n\nexport type OnTabChangeParams<M extends Record<string, unknown>> = {\n path: string;\n entityId?: string | number;\n selectedTab?: string;\n collection: AdminCollection<M>;\n};\n\nexport interface DetailViewBindingProps<M extends Record<string, unknown> = Record<string, unknown>> {\n path: string;\n collection: AdminCollection<M>;\n entityId: string | number;\n selectedTab?: string;\n parentCollectionSlugs: string[];\n parentEntityIds: string[];\n onTabChange?: (props: OnTabChangeParams<M>) => void;\n onEditClick?: () => void;\n /**\n * Dismiss this record — the ✕ at the identity bar's trailing edge.\n *\n * Set by the layouts that own the record's place on screen but are not side\n * dialogs: the split, where dismissing is navigating back to the collection.\n */\n onCloseRequest?: () => void;\n layout?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n barActions?: (params: BarActionsParams) => React.ReactNode;\n /**\n * Controls the owning panel puts at the identity bar's leading edge, ahead\n * of the breadcrumb — the side panel's close button.\n */\n barActionsStart?: React.ReactNode;\n /**\n * Full screen only: bring the list back beside this record. Set when the\n * record was opened out of a split collection, so folding the list away is\n * reversible; it takes the place of the back arrow when present.\n */\n onShowList?: () => void;\n}\n\nexport function DetailViewBinding<M extends Record<string, unknown>>({\n entityId,\n ...props\n}: DetailViewBindingProps<M>) {\n\n const { t } = useTranslation();\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch<M>({\n path: props.path,\n entityId: entityId,\n collection: props.collection,\n // The relation fields' values, read with the record (see `useFetch`).\n relations: true,\n useCache: false\n });\n\n if (!dataLoading && dataLoadingError) {\n return <CenteredView>\n <ErrorView error={dataLoadingError} />\n </CenteredView>;\n }\n\n if (!dataLoading && !entity) {\n return <CenteredView>\n <Typography variant=\"label\">{t(\"entity_not_found\")}</Typography>\n </CenteredView>;\n }\n\n const content = (\n <DetailViewBindingInner<M>\n {...props}\n entityId={entityId}\n entity={entity}\n dataLoading={dataLoading}\n />\n );\n\n return (\n <CollectionScopeProvider collection={props.collection}>\n {content}\n </CollectionScopeProvider>\n );\n}\n\nfunction DetailViewBindingInner<M extends Record<string, unknown>>({\n path,\n entityId,\n selectedTab: selectedTabProp,\n collection,\n parentCollectionSlugs,\n parentEntityIds,\n onTabChange,\n onEditClick,\n onCloseRequest,\n entity,\n dataLoading,\n layout = \"full_screen\",\n barActions,\n barActionsStart,\n onShowList\n}: DetailViewBindingProps<M> & {\n entity?: Entity<M>,\n dataLoading: boolean,\n}) {\n const ResolvedCollectionView = useComponentOverride(\"Collection.View\", CollectionViewBinding);\n const { t } = useTranslation();\n const context = useRebaseContext();\n const urlController = useUrlController();\n const navigate = useNavigate();\n const customizationController = useCustomizationController();\n const plugins = customizationController.plugins;\n const collectionRegistryController = useCollectionRegistryController();\n const { canEdit: canEditHook } = usePermissions();\n\n const canEdit = useMemo(() => {\n return entity ? canEditHook(collection, path, entity.values) : false;\n }, [canEditHook, entity, collection, path]);\n\n const [usedEntity, setUsedEntity] = useState<Entity<M> | undefined>(entity);\n useEffect(() => {\n if (entity) setUsedEntity(entity);\n }, [entity]);\n // The record as the entity views and the actions are handed it.\n const usedRow = usedEntity ? rowOfEntity(usedEntity, collection) : undefined;\n\n const defaultSelectedView = useMemo(() => resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\", id: entityId }\n ), [collection, entityId]);\n\n // Track whether the user has explicitly clicked a tab in this component\n // instance. See EditViewBindingInner for full explanation.\n const userHasChangedTab = useRef(false);\n\n const [selectedTab, setSelectedTab] = useState<string>(() => {\n const val = selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE;\n return val === \"edit\" ? MAIN_TAB_VALUE : val;\n });\n useEffect(() => {\n const val = userHasChangedTab.current\n ? (selectedTabProp ?? MAIN_TAB_VALUE)\n : (selectedTabProp ?? defaultSelectedView ?? MAIN_TAB_VALUE);\n const target = val === \"edit\" ? MAIN_TAB_VALUE : val;\n if (target !== selectedTab) {\n setSelectedTab(target);\n }\n }, [selectedTabProp, defaultSelectedView]);\n\n // `hideFromEntityViews`, not `hideFromNavigation`: the latter governs the\n // drawer. Filtering tabs on it defeated the introspection generator, which\n // sets `hideFromNavigation` on owned-child tables precisely *because* \"every\n // inbound foreign key renders as a tab on the parent\" — so the rows it\n // deliberately kept out of the drawer became reachable from nowhere.\n const childViews = getAdminEntityChildViews(collection).filter(v => !v.collection.hideFromEntityViews);\n const subcollections = childViews.map(v => v.collection);\n const subcollectionsCount = subcollections?.length ?? 0;\n const customViews = collection.entityViews ?? [];\n const customViewsCount = customViews?.length ?? 0;\n const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;\n const includeHistoryView = Boolean(collection.history);\n // Same split as the edit view: the strip is for destinations, the inspector\n // for the developer tools that used to sit in front of them.\n const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0;\n\n const [inspectorTab, setInspectorTab] = useState<InspectorTab | null>(null);\n\n const legacyInspectorTab: InspectorTab | undefined = selectedTab === JSON_TAB_VALUE\n ? \"json\"\n : selectedTab === HISTORY_TAB_VALUE ? \"history\" : undefined;\n useEffect(() => {\n if (legacyInspectorTab) setInspectorTab(legacyInspectorTab);\n }, [legacyInspectorTab]);\n\n const {\n resolvedEntityViews\n } = resolvedSelectedEntityView(customViews, customizationController, undefined, canEdit);\n\n const validTabValues = useMemo(() => {\n const set = new Set<string>([\n MAIN_TAB_VALUE,\n ...resolvedEntityViews.map(v => v.key),\n ...subcollections.map(s => s.slug)\n ]);\n return set;\n }, [resolvedEntityViews, subcollections]);\n\n const activeTab = validTabValues.has(selectedTab) ? selectedTab : MAIN_TAB_VALUE;\n\n const {\n selectedEntityView\n } = resolvedSelectedEntityView(customViews, customizationController, activeTab, canEdit);\n\n const mainViewVisible = activeTab === MAIN_TAB_VALUE;\n\n // Track which custom view tabs have been visited\n const mountedTabsRef = useRef<Set<string>>(new Set());\n if (activeTab) {\n mountedTabsRef.current.add(activeTab);\n }\n\n // Read-only form context for custom entity views\n const readOnlyFormContext = useReadOnlyFormContext<M>({\n entityId,\n entity: usedEntity,\n collection,\n path,\n openEntityMode: layout\n });\n\n // Plugin slots\n const formActionTopProps: PluginFormActionProps = useMemo(() => ({\n id: entityId,\n parentCollectionSlugs,\n parentEntityIds,\n path,\n status: \"existing\",\n collection: collection!,\n context,\n formContext: readOnlyFormContext as FormContext<Record<string, unknown>> | undefined,\n openEntityMode: layout,\n disabled: true\n }), [entityId, parentCollectionSlugs, parentEntityIds, path, collection, context, readOnlyFormContext, layout]);\n const pluginActionsTop = useSlot(\"form.actions.top\", formActionTopProps);\n\n // The record's own actions, as on the edit view: a read-only record is\n // still one you can recalculate, resend or delete. There is no form here,\n // so they are called without a `formContext`.\n const adminContext = useAdminContext();\n const leaveRecord = useLeaveRecord({ layout, path, onCloseRequest });\n const recordActionClickProps = useMemo(() => usedEntity\n ? {\n view: \"form\" as const,\n row: usedRow,\n id: String(usedEntity.id),\n path,\n collection: collection as AdminCollection,\n context,\n sidePanelController: adminContext.sidePanelController,\n openEntityMode: layout,\n navigateBack: leaveRecord\n }\n : undefined, [usedEntity, usedRow, path, collection, context, adminContext.sidePanelController, layout, leaveRecord]);\n const recordActions = useRecordActions({\n collection,\n path,\n entity: usedEntity,\n clickProps: recordActionClickProps\n });\n\n // The heading, resolved the one way — this used to be a copy of\n // `useEntityDisplayTitle`'s body, and the two had already drifted.\n const title = useEntityDisplayTitle({\n collection,\n entity: usedEntity,\n status: \"existing\"\n });\n\n // Non-action custom views\n const nonActionCustomViews = useMemo(() =>\n resolvedEntityViews.filter(e => !e.includeActions),\n [resolvedEntityViews]\n );\n\n const customViewsView = customViews && nonActionCustomViews\n .map((customView) => {\n if (!customView) return null;\n const Builder = customView.Builder;\n if (!Builder) return null;\n if (!hasEntityId(entityId)) return null;\n\n const isActive = activeTab === customView.key;\n const hasBeenMounted = mountedTabsRef.current.has(customView.key);\n if (!isActive && !hasBeenMounted) return null;\n\n return <div\n className={cls(defaultBorderMixin,\n \"relative flex-1 w-full h-full overflow-auto\",\n { \"hidden\": !isActive }\n )}\n key={`custom_view_${customView.key}`}\n role=\"tabpanel\">\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter />}>\n {readOnlyFormContext && <Builder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n row={usedRow}\n id={usedEntity ? String(usedEntity.id) : undefined}\n modifiedValues={usedEntity?.values}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>>}\n />}\n </Suspense>\n </ErrorBoundary>\n </div>;\n }).filter(Boolean);\n\n const globalLoading = dataLoading && !usedEntity;\n\n // Subcollection views\n const subCollectionsViews = childViews && childViews.map(({ collection: subcollection }) => {\n const subcollectionId = subcollection.slug;\n // By slug, like the path it extends: the data layer hands the driver\n // the stored path, `path` included, for the whole of it at once.\n const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollection.slug)}` : undefined;\n\n if (activeTab !== subcollectionId) return null;\n return (\n <div\n className={\"relative flex-1 h-full overflow-auto w-full\"}\n key={`subcol_${subcollectionId}`}\n role=\"tabpanel\">\n {globalLoading && <CircularProgressCenter />}\n {!globalLoading &&\n (usedEntity && newFullPath\n ? <ResolvedCollectionView\n path={newFullPath}\n parentCollectionSlugs={[...parentCollectionSlugs, collection.slug]}\n parentEntityIds={[...parentEntityIds, String(usedEntity?.id)]}\n updateUrl={false}\n {...subcollection}\n openEntityMode={layout} />\n : <div className=\"flex items-center justify-center w-full h-full p-3\">\n <Typography variant={\"label\"}>\n {/* No `?? \"…\"` here: `t` returns the key itself\n when it cannot find one, never null, so the\n fallback never ran and this rendered the raw\n `save_entity_before_subcollections`. The key\n exists now, in all seven locales. */}\n {t(\"save_entity_before_subcollections\")}\n </Typography>\n </div>)\n }\n </div>\n );\n }).filter(Boolean);\n\n const onSideTabClick = useCallback((value: string) => {\n userHasChangedTab.current = true;\n setSelectedTab(value);\n onTabChange?.({\n path,\n entityId,\n selectedTab: value === MAIN_TAB_VALUE ? undefined : value,\n collection\n });\n }, [onTabChange, path, entityId, collection]);\n\n // The record's body, drawn where `RecordDetail` draws it.\n const propertyDetailView = () => usedEntity\n ? <EntityViewBody<M>\n entity={usedEntity}\n collection={collection}\n path={path}\n formContext={readOnlyFormContext}\n openEntityMode={layout}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n />\n : null;\n\n // Tabs\n const subcollectionTabs = subcollections && subcollections.map((subcollection) => {\n const icon = getIcon(subcollection.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={subcollection.slug}\n key={`entity_detail_collection_tab_${subcollection.name}`}>\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {subcollection.name}\n </span>\n </Tab>\n );\n });\n\n const customViewTabsStart = resolvedEntityViews.filter(view => view.position === \"start\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n const customViewTabsEnd = resolvedEntityViews.filter(view => !view.position || view.position === \"end\")\n .map((view) => {\n const icon = getIcon(view.icon, undefined, undefined, \"smallest\");\n return (\n <Tab\n className={cls(ENTITY_VIEW_TAB_CLASS, !view.tabComponent && ENTITY_VIEW_TAB_LABEL_CLASS)}\n value={view.key}\n key={`entity_detail_collection_tab_${view.name}`}>\n {view.tabComponent ?? (\n <span className=\"flex items-center gap-1.5\">\n {icon}\n {view.name}\n </span>\n )}\n </Tab>\n );\n });\n\n // The breadcrumb's destination, and the back arrow's when it renders. Both\n // keep the list's whole URL state: a collection reached from one of its own\n // records must come back as the user left it — the same view mode, search,\n // filters and sort.\n const collectionUrl = withListState(urlController.buildUrlCollectionPath(path));\n\n // Full screen is the one layout with no way out of its own: a side panel and a\n // dialog can be dismissed, and a split keeps the list beside it, but opening an\n // entity full screen replaces the collection entirely and left browser Back as\n // the only route back to it — which is not an affordance the page shows, and is\n // wrong anyway once the user has moved between tabs inside the entity.\n //\n // Unless the list can be unfolded back beside the record: that chevron\n // leads to the same collection while keeping the record open, so it stands\n // alone rather than beside an arrow going almost the same place.\n //\n // It goes to the bar's leading edge — where a back control reads as back,\n // and where the edit view has always put the same arrow — rather than to\n // the trailing edge among the record's own actions.\n const backToCollection = layout === \"full_screen\" && !onShowList\n ? () => navigate(collectionUrl)\n : undefined;\n\n const fullScreenButton = !barActions && // Not in split: the list panel beside it carries the close control,\n // and an expand button there competes with it.\n (layout === \"side_panel\" || layout === \"dialog\") && hasEntityId(entityId) ? (\n <Tooltip title={\"Open full screen\"}>\n <IconButton aria-label={\"Open full screen\"}\n size=\"small\"\n onClick={() => {\n const entityUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(`${entityUrl}#full`);\n }}\n >\n <Maximize2Icon size={iconSize.smallest} />\n </IconButton>\n </Tooltip>\n ) : null;\n\n // Edit button — only rendered when the user has edit permissions\n const editButton = canEdit && onEditClick ? (\n <Button\n variant=\"filled\"\n color=\"primary\"\n size=\"small\"\n startIcon={<PencilIcon size={iconSize.smallest} />}\n onClick={onEditClick}>\n {t(\"edit_entity\")}\n </Button>\n ) : null;\n\n // Main content view. The title, the `path/id` chip and the empty band under\n // them have moved into the identity bar, and the `w-80 2xl:w-96` rail that\n // held a single Edit button is gone — the bar holds it now.\n //\n // The scroll now lives on the record's own column rather than on this row,\n // so the metadata rail beside it stays put while the record scrolls — the\n // same arrangement the form uses.\n const mainView = <div\n className={cls(\n \"flex-1 flex flex-row w-full min-h-0\",\n !mainViewVisible ? \"hidden\" : \"\"\n )}>\n {propertyDetailView()}\n </div>;\n\n let result = <div className=\"relative flex flex-col h-full w-full bg-surface-card\">\n\n <EntityIdentityBar\n collection={collection as AdminCollection}\n collectionUrl={layout === \"full_screen\" || layout === \"split\" ? collectionUrl : undefined}\n title={title}\n entityId={entityId}\n status={\"existing\"}\n dirty={false}\n saving={false}\n onBack={backToCollection}\n onClose={onCloseRequest}\n onInspect={includeJsonView ? () => setInspectorTab(\"json\") : undefined}\n onViewHistory={includeHistoryView ? () => setInspectorTab(\"history\") : undefined}\n externalLink={usedEntity\n ? customizationController?.entityLinkBuilder?.({\n row: rowOfEntity(usedEntity, collection),\n id: String(usedEntity.id),\n path: usedEntity.path\n })\n : undefined}\n recordActions={recordActions}\n // Where Save stands on the edit view: after the record's own\n // buttons, ahead of the menu.\n primaryAction={editButton}\n leading={<>\n {barActionsStart}\n {/* Split view: closing the list is opening this record\n full screen, and the control for it belongs at this\n bar's leading edge. Full screen carries its mirror. */}\n {layout === \"split\" && <SplitListCloseButton/>}\n {layout === \"full_screen\" && onShowList && <SplitListShowButton onClick={onShowList}/>}\n </>}\n trailing={<>\n {pluginActionsTop}\n {fullScreenButton}\n {barActions?.({\n path,\n entityId,\n values: usedEntity?.values ?? {},\n status: \"existing\",\n dirty: false\n })}\n </>}\n />\n\n {hasAdditionalViews && <div className={cls(\n \"h-10 shrink-0 flex items-stretch border-b px-2 min-w-0\",\n ENTITY_VIEW_TAB_BAR_CLASS,\n defaultBorderMixin\n )}>\n <Tabs\n className={\"!w-full items-stretch\"}\n innerClassName={\"h-full\"}\n variant={\"boxy\"}\n value={activeTab}\n onValueChange={(value) => {\n onSideTabClick(value);\n }}>\n\n {/* Before the record, not after it.\n\n `position: \"start\"` used to mean \"first among the custom\n views\", which put it after a tab it was already after: the\n record's own tab is drawn here unconditionally, so \"start\"\n and \"end\" only ever ordered the custom views against each\n other, and no collection could open with anything but the\n form on the left.\n\n A cover — a read-only summary of the record, the thing an\n operator opens a row to see — belongs in front of the form\n that edits it. That is what `defaultSelectedView` already\n allowed, and the strip contradicted it by drawing the\n selected tab second. Views that say nothing still land after\n the record, so nothing moves for a collection that never\n asked. */}\n {customViewTabsStart}\n\n <Tab value={MAIN_TAB_VALUE}\n className={cls(ENTITY_VIEW_TAB_CLASS, ENTITY_VIEW_TAB_LABEL_CLASS)}>\n <span className=\"flex items-center gap-1.5\">\n {getIcon(collection.icon, undefined, undefined, \"smallest\")}\n {collection.singularName ?? collection.name}\n </span>\n </Tab>\n\n {customViewTabsEnd}\n {subcollectionTabs}\n </Tabs>\n </div>}\n\n {/* See EditViewBinding: the inspector docks beside the record rather\n than over it, so the record stays readable and scrollable. */}\n <div className={\"flex-1 min-h-0 flex\"}>\n\n <div className={\"flex-1 min-w-0 flex flex-col\"}>\n {globalLoading\n ? <DetailViewSkeleton collection={collection} />\n : mainView}\n\n {customViewsView}\n {subCollectionsViews}\n </div>\n\n <EntityInspector\n tab={inspectorTab}\n onTabChange={setInspectorTab}\n onClose={() => setInspectorTab(null)}\n collection={collection as AdminCollection}\n entity={usedEntity as Entity<Record<string, unknown>> | undefined}\n formContext={readOnlyFormContext as FormContext<Record<string, unknown>> | undefined}\n values={usedEntity?.values}\n includeHistory={includeHistoryView}/>\n </div>\n\n </div>;\n\n if (plugins && plugins.length > 0) {\n result = (\n <PluginProviderStack\n plugins={plugins}\n scope=\"form\"\n scopeProps={{\n status: \"existing\",\n path,\n collection,\n entity: usedEntity,\n context,\n formContext: readOnlyFormContext\n }}>\n {result}\n </PluginProviderStack>\n );\n }\n\n return result;\n}\n\nfunction DetailViewSkeleton({ collection }: { collection: AdminCollection<Record<string, unknown>> }) {\n return (\n <div className=\"flex-1 flex flex-row w-full overflow-y-auto justify-center\">\n <div className=\"relative flex flex-row max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit\">\n <div className=\"flex flex-col w-full pt-12 pb-16 px-4 sm:px-8 md:px-10\">\n <div className=\"w-full flex flex-col items-start my-4 lg:my-6\">\n <div className={`py-1 my-4 w-2/3 ${collection.hideIdFromForm ? \"mb-6\" : \"\"}`}>\n <Skeleton height={28} className=\"w-full rounded-md\" />\n </div>\n <Skeleton height={32} className=\"w-full rounded-md\" />\n </div>\n <div className=\"mt-12 flex flex-col gap-8\">\n <div className=\"flex flex-wrap gap-x-4 w-full space-y-8\">\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n <div className=\"relative w-full\">\n <Skeleton height={60} className=\"w-full rounded-md\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+GA,SAAgB,kBAAqD,EACjE,UACA,GAAG,SACuB;CAE1B,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,QACA,aACA,qBACA,SAAY;EACZ,MAAM,MAAM;EACF;EACV,YAAY,MAAM;EAElB,WAAW;EACX,UAAU;CACd,CAAC;CAED,IAAI,CAAC,eAAe,kBAChB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,WAAD,EAAW,OAAO,iBAAmB,CAAA,EAC3B,CAAA;CAGlB,IAAI,CAAC,eAAe,CAAC,QACjB,OAAO,oBAAC,cAAD,EAAA,UACH,oBAAC,YAAD;EAAY,SAAQ;YAAS,EAAE,kBAAkB;CAAc,CAAA,EACrD,CAAA;CAGlB,MAAM,UACF,oBAAC,wBAAD;EACI,GAAI;EACM;EACF;EACK;CAChB,CAAA;CAGL,OACI,oBAAC,yBAAD;EAAyB,YAAY,MAAM;YACtC;CACoB,CAAA;AAEjC;AAEA,SAAS,uBAA0D,EAC/D,MACA,UACA,aAAa,iBACb,YACA,uBACA,iBACA,aACA,aACA,gBACA,QACA,aACA,SAAS,eACT,YACA,iBACA,cAID;CACC,MAAM,yBAAyB,qBAAqB,mBAAmB,qBAAqB;CAC5F,MAAM,EAAE,MAAM,eAAe;CAC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