@rebasepro/cms 0.30.1 → 0.31.0-canary.g59cd6fd

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
@@ -0,0 +1,47 @@
1
+ /**
2
+ * UI preferences folded into a table's collection.
3
+ *
4
+ * A preference is a {@link UiTablePreferences} delta — JSON data in the
5
+ * `customizeTable` vocabulary — so folding one in is folding in a
6
+ * customization: it is translated here to `customizeTable`'s options and
7
+ * applied with `applyTableCustomization`, the one place the vocabulary meets
8
+ * the panel's view model. Two things differ from a code customization:
9
+ *
10
+ * - it is data from a file or the server, so each value is narrowed (a chip
11
+ * colour that is not a colour key, a condition that is not JSON logic, is
12
+ * dropped) rather than trusted;
13
+ * - registered keys (`entityActions`, `entityViews`, `customViews`) are added
14
+ * beside what the code declares, not instead of it: code can hold objects a
15
+ * preference cannot, and a preference must not delete them.
16
+ */
17
+ import type { AnyFieldCustomization, TableCustomizationOptions, UserConfigurationPersistence, ColorKey } from "@rebasepro/cms-types";
18
+ import type { UiFieldPreferences, UiPreferences, UiTablePreferences } from "@rebasepro/types";
19
+ import { type TableCollection } from "../../tables/apply_customization.js";
20
+ /** Whether a string is a chip colour key (`"green"`, `"orangeDark"`). */
21
+ export declare function isColorKey(value: unknown): value is ColorKey;
22
+ /** One field's preferences, as a field customization. */
23
+ export declare function fieldCustomizationOf(field: UiFieldPreferences): AnyFieldCustomization;
24
+ /** A table's preferences, as `customizeTable`'s options. */
25
+ export declare function customizationOptionsOf(preferences: UiTablePreferences): TableCustomizationOptions;
26
+ /**
27
+ * A table's collection with a preference delta folded in. `undefined` or an
28
+ * empty delta leaves it as it is.
29
+ */
30
+ export declare function applyUiPreferences(collection: TableCollection, preferences: UiTablePreferences | undefined): TableCollection;
31
+ /**
32
+ * The tables of `<RebaseCMS uiConfig>` (the contents of
33
+ * `frontend/src/cms/ui-config.json`), keeping only valid preferences: an
34
+ * entry that is not one is skipped, with a warning in development.
35
+ */
36
+ export declare function uiConfigPreferences(config: {
37
+ tables?: {
38
+ [slug: string]: object;
39
+ };
40
+ } | undefined): UiPreferences;
41
+ /**
42
+ * A user's persistence with a layer of their preferences beneath it: what
43
+ * the server stores for them, received by an embedding that asks the server
44
+ * for nothing itself. What they change there is kept by `persistence` and
45
+ * read over the layer.
46
+ */
47
+ export declare function withUserLayer(persistence: UserConfigurationPersistence, user: UiPreferences): UserConfigurationPersistence;
@@ -0,0 +1,179 @@
1
+ import { customizeTable } from "../../tables/customize_table.js";
2
+ import { applyTableCustomization } from "../../tables/apply_customization.js";
3
+ import { stripCollectionPath } from "@rebasepro/cms-types";
4
+ import { isUiTablePreferences, mergeUiTablePreferences } from "@rebasepro/types";
5
+ //#region src/hooks/navigation/ui_preferences.ts
6
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
7
+ var HUES = [
8
+ "blue",
9
+ "cyan",
10
+ "teal",
11
+ "green",
12
+ "yellow",
13
+ "orange",
14
+ "red",
15
+ "pink",
16
+ "purple",
17
+ "gray",
18
+ "indigo",
19
+ "violet",
20
+ "fuchsia",
21
+ "rose",
22
+ "emerald"
23
+ ];
24
+ var TONES = [
25
+ "",
26
+ "Lighter",
27
+ "Light",
28
+ "Dark",
29
+ "Darker"
30
+ ];
31
+ /** Whether a string is a chip colour key (`"green"`, `"orangeDark"`). */
32
+ function isColorKey(value) {
33
+ if (typeof value !== "string") return false;
34
+ const tone = TONES.find((t) => t !== "" && value.endsWith(t)) ?? "";
35
+ return HUES.includes(value.slice(0, value.length - tone.length));
36
+ }
37
+ var asRule = (value) => typeof value === "boolean" || isRecord(value) ? value : void 0;
38
+ var asLogic = (value) => isRecord(value) ? value : void 0;
39
+ var asNumberOrLogic = (value) => typeof value === "number" ? value : asLogic(value);
40
+ var asString = (value) => typeof value === "string" ? value : void 0;
41
+ function enumConditionsOf(value) {
42
+ if (!isRecord(value)) return void 0;
43
+ const out = {};
44
+ for (const [id, entry] of Object.entries(value)) {
45
+ if (!isRecord(entry)) continue;
46
+ const conditions = {};
47
+ const disabled = asLogic(entry.disabled);
48
+ const hidden = asLogic(entry.hidden);
49
+ if (disabled) conditions.disabled = disabled;
50
+ if (hidden) conditions.hidden = hidden;
51
+ if (typeof entry.disabledMessage === "string") conditions.disabledMessage = entry.disabledMessage;
52
+ out[id] = conditions;
53
+ }
54
+ return out;
55
+ }
56
+ /** JSON-logic conditions, narrowed to the keys a property's conditions take. */
57
+ function conditionsOf(value) {
58
+ if (!value) return void 0;
59
+ const out = {};
60
+ const set = (key, next) => {
61
+ if (next !== void 0) out[key] = next;
62
+ };
63
+ set("disabled", asRule(value.disabled));
64
+ set("hidden", asRule(value.hidden));
65
+ set("readOnly", asRule(value.readOnly));
66
+ set("required", asRule(value.required));
67
+ set("disabledMessage", asString(value.disabledMessage));
68
+ set("requiredMessage", asString(value.requiredMessage));
69
+ if (typeof value.clearOnDisabled === "boolean") out.clearOnDisabled = value.clearOnDisabled;
70
+ set("min", asNumberOrLogic(value.min));
71
+ set("max", asNumberOrLogic(value.max));
72
+ set("maxFileSize", asNumberOrLogic(value.maxFileSize));
73
+ for (const key of [
74
+ "defaultValue",
75
+ "allowedEnumValues",
76
+ "excludedEnumValues",
77
+ "referencePath",
78
+ "referenceFilter",
79
+ "canAddElements",
80
+ "sortable",
81
+ "acceptedFiles"
82
+ ]) set(key, asLogic(value[key]));
83
+ set("enumConditions", enumConditionsOf(value.enumConditions));
84
+ return Object.keys(out).length > 0 ? out : void 0;
85
+ }
86
+ /** One field's preferences, as a field customization. */
87
+ function fieldCustomizationOf(field) {
88
+ const { enumLabels, conditions, fields, of, ...plain } = field;
89
+ const out = { ...plain };
90
+ if (enumLabels) {
91
+ const labels = {};
92
+ for (const [value, label] of Object.entries(enumLabels)) labels[value] = typeof label === "string" ? label : {
93
+ label: label.label,
94
+ ...isColorKey(label.color) ? { color: label.color } : {},
95
+ ...label.disabled !== void 0 ? { disabled: label.disabled } : {}
96
+ };
97
+ out.enumLabels = labels;
98
+ }
99
+ const narrowed = conditionsOf(conditions);
100
+ if (narrowed) out.conditions = narrowed;
101
+ if (fields) {
102
+ const nested = {};
103
+ for (const [key, value] of Object.entries(fields)) nested[key] = fieldCustomizationOf(value);
104
+ out.fields = nested;
105
+ }
106
+ if (of) out.of = fieldCustomizationOf(of);
107
+ return out;
108
+ }
109
+ /** A table's preferences, as `customizeTable`'s options. */
110
+ function customizationOptionsOf(preferences) {
111
+ const { fields, ...table } = preferences;
112
+ const out = { ...table };
113
+ if (fields) {
114
+ const customized = {};
115
+ for (const [key, field] of Object.entries(fields)) customized[key] = fieldCustomizationOf(field);
116
+ out.fields = customized;
117
+ }
118
+ return out;
119
+ }
120
+ /** The registered keys a preference adds beside what the code declares. */
121
+ var REGISTERED_LISTS = [
122
+ "entityActions",
123
+ "entityViews",
124
+ "customViews"
125
+ ];
126
+ function keepCodeEntries(before, after, preferences) {
127
+ const out = { ...after };
128
+ for (const key of REGISTERED_LISTS) {
129
+ const added = preferences[key];
130
+ if (!added) continue;
131
+ const declared = Reflect.get(before, key);
132
+ const merged = [...Array.isArray(declared) ? declared.filter((entry) => typeof entry !== "string") : [], ...added];
133
+ Reflect.set(out, key, merged);
134
+ if (out.admin) out.admin = {
135
+ ...out.admin,
136
+ [key]: merged
137
+ };
138
+ }
139
+ return out;
140
+ }
141
+ /**
142
+ * A table's collection with a preference delta folded in. `undefined` or an
143
+ * empty delta leaves it as it is.
144
+ */
145
+ function applyUiPreferences(collection, preferences) {
146
+ if (!preferences || Object.keys(preferences).length === 0) return collection;
147
+ return keepCodeEntries(collection, applyTableCustomization(collection, customizeTable(collection.slug, customizationOptionsOf(preferences))), preferences);
148
+ }
149
+ /**
150
+ * The tables of `<RebaseCMS uiConfig>` (the contents of
151
+ * `frontend/src/cms/ui-config.json`), keeping only valid preferences: an
152
+ * entry that is not one is skipped, with a warning in development.
153
+ */
154
+ function uiConfigPreferences(config) {
155
+ const tables = {};
156
+ for (const [slug, preferences] of Object.entries(config?.tables ?? {})) if (isUiTablePreferences(preferences)) tables[slug] = preferences;
157
+ else if (process.env.NODE_ENV !== "production") console.warn(`[rebase] uiConfig.tables["${slug}"] holds keys that are not table preferences. Skipped.`);
158
+ return { tables };
159
+ }
160
+ /**
161
+ * A user's persistence with a layer of their preferences beneath it: what
162
+ * the server stores for them, received by an embedding that asks the server
163
+ * for nothing itself. What they change there is kept by `persistence` and
164
+ * read over the layer.
165
+ */
166
+ function withUserLayer(persistence, user) {
167
+ return {
168
+ ...persistence,
169
+ getTablePreferences: (path) => {
170
+ const stored = user.tables[stripCollectionPath(path)];
171
+ const local = persistence.getTablePreferences(path);
172
+ return stored ? mergeUiTablePreferences(stored, local) : local;
173
+ }
174
+ };
175
+ }
176
+ //#endregion
177
+ export { applyUiPreferences, customizationOptionsOf, fieldCustomizationOf, isColorKey, uiConfigPreferences, withUserLayer };
178
+
179
+ //# sourceMappingURL=ui_preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui_preferences.js","names":[],"sources":["../../../src/hooks/navigation/ui_preferences.ts"],"sourcesContent":["/**\n * UI preferences folded into a table's collection.\n *\n * A preference is a {@link UiTablePreferences} delta — JSON data in the\n * `customizeTable` vocabulary — so folding one in is folding in a\n * customization: it is translated here to `customizeTable`'s options and\n * applied with `applyTableCustomization`, the one place the vocabulary meets\n * the panel's view model. Two things differ from a code customization:\n *\n * - it is data from a file or the server, so each value is narrowed (a chip\n * colour that is not a colour key, a condition that is not JSON logic, is\n * dropped) rather than trusted;\n * - registered keys (`entityActions`, `entityViews`, `customViews`) are added\n * beside what the code declares, not instead of it: code can hold objects a\n * preference cannot, and a preference must not delete them.\n */\nimport type { AnyFieldCustomization, EnumLabel, TableCustomizationOptions, UserConfigurationPersistence, EnumValueConditions, PropertyConditions, ColorKey } from \"@rebasepro/cms-types\";\nimport type { UiFieldPreferences, UiPreferences, UiTablePreferences } from \"@rebasepro/types\";\nimport { isUiTablePreferences, mergeUiTablePreferences } from \"@rebasepro/types\";\nimport { stripCollectionPath } from \"@rebasepro/cms-types\";\n\nimport { customizeTable } from \"../../tables/customize_table\";\nimport { applyTableCustomization, type TableCollection } from \"../../tables/apply_customization\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst HUES = [\"blue\", \"cyan\", \"teal\", \"green\", \"yellow\", \"orange\", \"red\", \"pink\", \"purple\", \"gray\", \"indigo\", \"violet\", \"fuchsia\", \"rose\", \"emerald\"];\nconst TONES = [\"\", \"Lighter\", \"Light\", \"Dark\", \"Darker\"];\n\n/** Whether a string is a chip colour key (`\"green\"`, `\"orangeDark\"`). */\nexport function isColorKey(value: unknown): value is ColorKey {\n if (typeof value !== \"string\") return false;\n const tone = TONES.find(t => t !== \"\" && value.endsWith(t)) ?? \"\";\n return HUES.includes(value.slice(0, value.length - tone.length));\n}\n\ntype ConditionRule = NonNullable<PropertyConditions[\"disabled\"]>;\nconst asRule = (value: unknown): ConditionRule | undefined =>\n typeof value === \"boolean\" || isRecord(value) ? value : undefined;\nconst asLogic = (value: unknown): Record<string, unknown> | undefined => isRecord(value) ? value : undefined;\nconst asNumberOrLogic = (value: unknown): number | Record<string, unknown> | undefined =>\n typeof value === \"number\" ? value : asLogic(value);\nconst asString = (value: unknown): string | undefined => typeof value === \"string\" ? value : undefined;\n\nfunction enumConditionsOf(value: unknown): Record<string, EnumValueConditions> | undefined {\n if (!isRecord(value)) return undefined;\n const out: Record<string, EnumValueConditions> = {};\n for (const [id, entry] of Object.entries(value)) {\n if (!isRecord(entry)) continue;\n const conditions: EnumValueConditions = {};\n const disabled = asLogic(entry.disabled);\n const hidden = asLogic(entry.hidden);\n if (disabled) conditions.disabled = disabled;\n if (hidden) conditions.hidden = hidden;\n if (typeof entry.disabledMessage === \"string\") conditions.disabledMessage = entry.disabledMessage;\n out[id] = conditions;\n }\n return out;\n}\n\n/** JSON-logic conditions, narrowed to the keys a property's conditions take. */\nfunction conditionsOf(value: UiFieldPreferences[\"conditions\"]): PropertyConditions | undefined {\n if (!value) return undefined;\n const out: PropertyConditions = {};\n const set = <K extends keyof PropertyConditions>(key: K, next: PropertyConditions[K] | undefined): void => {\n if (next !== undefined) out[key] = next;\n };\n set(\"disabled\", asRule(value.disabled));\n set(\"hidden\", asRule(value.hidden));\n set(\"readOnly\", asRule(value.readOnly));\n set(\"required\", asRule(value.required));\n set(\"disabledMessage\", asString(value.disabledMessage));\n set(\"requiredMessage\", asString(value.requiredMessage));\n if (typeof value.clearOnDisabled === \"boolean\") out.clearOnDisabled = value.clearOnDisabled;\n set(\"min\", asNumberOrLogic(value.min));\n set(\"max\", asNumberOrLogic(value.max));\n set(\"maxFileSize\", asNumberOrLogic(value.maxFileSize));\n for (const key of [\"defaultValue\", \"allowedEnumValues\", \"excludedEnumValues\", \"referencePath\", \"referenceFilter\", \"canAddElements\", \"sortable\", \"acceptedFiles\"] as const) {\n set(key, asLogic(value[key]));\n }\n set(\"enumConditions\", enumConditionsOf(value.enumConditions));\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** One field's preferences, as a field customization. */\nexport function fieldCustomizationOf(field: UiFieldPreferences): AnyFieldCustomization {\n const { enumLabels, conditions, fields, of, ...plain } = field;\n const out: AnyFieldCustomization = { ...plain };\n if (enumLabels) {\n const labels: Record<string, string | EnumLabel> = {};\n for (const [value, label] of Object.entries(enumLabels)) {\n labels[value] = typeof label === \"string\"\n ? label\n : {\n label: label.label,\n ...(isColorKey(label.color) ? { color: label.color } : {}),\n ...(label.disabled !== undefined ? { disabled: label.disabled } : {})\n };\n }\n out.enumLabels = labels;\n }\n const narrowed = conditionsOf(conditions);\n if (narrowed) out.conditions = narrowed;\n if (fields) {\n const nested: Record<string, AnyFieldCustomization> = {};\n for (const [key, value] of Object.entries(fields)) nested[key] = fieldCustomizationOf(value);\n out.fields = nested;\n }\n if (of) out.of = fieldCustomizationOf(of);\n return out;\n}\n\n/** A table's preferences, as `customizeTable`'s options. */\nexport function customizationOptionsOf(preferences: UiTablePreferences): TableCustomizationOptions {\n const { fields, ...table } = preferences;\n const out: TableCustomizationOptions = { ...table };\n if (fields) {\n const customized: Record<string, AnyFieldCustomization> = {};\n for (const [key, field] of Object.entries(fields)) customized[key] = fieldCustomizationOf(field);\n out.fields = customized;\n }\n return out;\n}\n\n/** The registered keys a preference adds beside what the code declares. */\nconst REGISTERED_LISTS = [\"entityActions\", \"entityViews\", \"customViews\"] as const;\n\nfunction keepCodeEntries(before: TableCollection, after: TableCollection, preferences: UiTablePreferences): TableCollection {\n const out: TableCollection = { ...after };\n for (const key of REGISTERED_LISTS) {\n const added = preferences[key];\n if (!added) continue;\n const declared: unknown = Reflect.get(before, key);\n const objects = Array.isArray(declared) ? declared.filter(entry => typeof entry !== \"string\") : [];\n const merged = [...objects, ...added];\n Reflect.set(out, key, merged);\n if (out.admin) out.admin = { ...out.admin, [key]: merged };\n }\n return out;\n}\n\n/**\n * A table's collection with a preference delta folded in. `undefined` or an\n * empty delta leaves it as it is.\n */\nexport function applyUiPreferences(collection: TableCollection, preferences: UiTablePreferences | undefined): TableCollection {\n if (!preferences || Object.keys(preferences).length === 0) return collection;\n const customized = applyTableCustomization(collection, customizeTable(collection.slug, customizationOptionsOf(preferences)));\n return keepCodeEntries(collection, customized, preferences);\n}\n\n/**\n * The tables of `<RebaseCMS uiConfig>` (the contents of\n * `frontend/src/cms/ui-config.json`), keeping only valid preferences: an\n * entry that is not one is skipped, with a warning in development.\n */\nexport function uiConfigPreferences(config: { tables?: { [slug: string]: object } } | undefined): UiPreferences {\n const tables: UiPreferences[\"tables\"] = {};\n for (const [slug, preferences] of Object.entries(config?.tables ?? {})) {\n if (isUiTablePreferences(preferences)) tables[slug] = preferences;\n else if (process.env.NODE_ENV !== \"production\") {\n console.warn(`[rebase] uiConfig.tables[\"${slug}\"] holds keys that are not table preferences. Skipped.`);\n }\n }\n return { tables };\n}\n\n/**\n * A user's persistence with a layer of their preferences beneath it: what\n * the server stores for them, received by an embedding that asks the server\n * for nothing itself. What they change there is kept by `persistence` and\n * read over the layer.\n */\nexport function withUserLayer(persistence: UserConfigurationPersistence, user: UiPreferences): UserConfigurationPersistence {\n return {\n ...persistence,\n getTablePreferences: (path: string) => {\n const stored = user.tables[stripCollectionPath(path)];\n const local = persistence.getTablePreferences(path);\n return stored ? mergeUiTablePreferences(stored, local) : local;\n }\n };\n}\n"],"mappings":";;;;;AAwBA,IAAM,YAAY,UACd,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAEvE,IAAM,OAAO;C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,CACvF,GAAY,WAAW;AAC9D;;;;;;AAOA,SAAgB,oBAAoB,QAA4E;CAC5G,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,MAAM,gBAAgB,OAAO,QAAQ,QAAQ,UAAU,CAAC,CAAC,GACjE,IAAI,qBAAqB,WAAW,GAAG,OAAO,QAAQ;MACjD,IAAA,QAAA,IAAA,aAA6B,cAC9B,QAAQ,KAAK,6BAA6B,KAAK,uDAAuD;CAG9G,OAAO,EAAE,OAAO;AACpB;;;;;;;AAQA,SAAgB,cAAc,aAA2C,MAAmD;CACxH,OAAO;EACH,GAAG;EACH,sBAAsB,SAAiB;GACnC,MAAM,SAAS,KAAK,OAAO,oBAAoB,IAAI;GACnD,MAAM,QAAQ,YAAY,oBAAoB,IAAI;GAClD,OAAO,SAAS,wBAAwB,QAAQ,KAAK,IAAI;EAC7D;CACJ;AACJ"}
@@ -12,7 +12,7 @@ export type UseAsyncResolverResult<T> = {
12
12
  * Extracted from the common pattern in useResolvedCollections and
13
13
  * useResolvedViews.
14
14
  */
15
- export declare function useAsyncResolver<T>({ resolver, initialValue, isEqual, deps, disabled, }: {
15
+ export declare function useAsyncResolver<T>({ resolver, initialValue, isEqual, deps, disabled, pending, }: {
16
16
  /** Async function that resolves the data */
17
17
  resolver: () => Promise<T>;
18
18
  /** Initial value before first resolution */
@@ -23,4 +23,11 @@ export declare function useAsyncResolver<T>({ resolver, initialValue, isEqual, d
23
23
  deps: React.DependencyList;
24
24
  /** When true, skip resolution */
25
25
  disabled?: boolean;
26
+ /**
27
+ * The input is not ready yet (it is being fetched): do not resolve, and
28
+ * report `loading` — not only now but until the first resolution after it
29
+ * clears has finished, so no render sees the input ready and the result
30
+ * still the old one.
31
+ */
32
+ pending?: boolean;
26
33
  }): UseAsyncResolverResult<T>;
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
8
8
  * Extracted from the common pattern in useResolvedCollections and
9
9
  * useResolvedViews.
10
10
  */
11
- function useAsyncResolver({ resolver, initialValue, isEqual, deps, disabled }) {
11
+ function useAsyncResolver({ resolver, initialValue, isEqual, deps, disabled, pending = false }) {
12
12
  const [data, setData] = useState(initialValue);
13
13
  const [loading, setLoading] = useState(true);
14
14
  const [error, setError] = useState(void 0);
@@ -22,6 +22,10 @@ function useAsyncResolver({ resolver, initialValue, isEqual, deps, disabled }) {
22
22
  const isEqualRef = useRef(isEqual);
23
23
  isEqualRef.current = isEqual;
24
24
  useEffect(() => {
25
+ if (pending) {
26
+ setLoading(true);
27
+ return;
28
+ }
25
29
  if (disabled) return;
26
30
  let cancelled = false;
27
31
  (async () => {
@@ -48,16 +52,18 @@ function useAsyncResolver({ resolver, initialValue, isEqual, deps, disabled }) {
48
52
  }, [
49
53
  ...deps,
50
54
  refreshTrigger,
51
- disabled
55
+ disabled,
56
+ pending
52
57
  ]);
53
58
  return useMemo(() => ({
54
59
  data,
55
- loading,
60
+ loading: loading || pending,
56
61
  error,
57
62
  refresh
58
63
  }), [
59
64
  data,
60
65
  loading,
66
+ pending,
61
67
  error,
62
68
  refresh
63
69
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"useAsyncResolver.js","names":[],"sources":["../../../src/hooks/navigation/useAsyncResolver.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\n\nexport type UseAsyncResolverResult<T> = {\n data: T;\n loading: boolean;\n error: Error | undefined;\n refresh: () => void;\n};\n\n/**\n * Generic hook that resolves an async value with loading/error/refresh\n * state management, cancellation on unmount or deps change, and\n * ref-based change detection to prevent unnecessary state updates.\n *\n * Extracted from the common pattern in useResolvedCollections and\n * useResolvedViews.\n */\nexport function useAsyncResolver<T>({\n resolver,\n initialValue,\n isEqual,\n deps,\n disabled,\n}: {\n /** Async function that resolves the data */\n resolver: () => Promise<T>;\n /** Initial value before first resolution */\n initialValue: T;\n /** Equality check to prevent unnecessary state updates */\n isEqual: (a: T, b: T) => boolean;\n /** Effect dependencies — when these change, resolver re-runs */\n deps: React.DependencyList;\n /** When true, skip resolution */\n disabled?: boolean;\n}): UseAsyncResolverResult<T> {\n\n const [data, setData] = useState<T>(initialValue);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n const [refreshTrigger, setRefreshTrigger] = useState(0);\n\n const refresh = useCallback(() => {\n setRefreshTrigger(prev => prev + 1);\n }, []);\n\n // Ref for change detection — avoids state updates when data hasn't changed\n const dataRef = useRef<T>(initialValue);\n\n // Store resolver in a ref so we always call the latest version\n // without adding it to effect deps (it's typically a new closure each render)\n const resolverRef = useRef(resolver);\n resolverRef.current = resolver;\n\n // Same for isEqual\n const isEqualRef = useRef(isEqual);\n isEqualRef.current = isEqual;\n\n useEffect(() => {\n if (disabled) return;\n\n let cancelled = false;\n\n (async () => {\n try {\n const result = await resolverRef.current();\n\n if (cancelled) return;\n\n // Only update state if data actually changed\n if (!isEqualRef.current(dataRef.current, result)) {\n dataRef.current = result;\n setData(result);\n }\n\n setError(undefined);\n } catch (e) {\n if (!cancelled) {\n console.error(e);\n setError(e as Error);\n }\n } finally {\n if (!cancelled) {\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...deps, refreshTrigger, disabled]);\n\n return useMemo(() => ({\n data,\n loading,\n error,\n refresh\n }), [data, loading, error, refresh]);\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,iBAAoB,EAChC,UACA,cACA,SACA,MACA,YAY0B;CAE1B,MAAM,CAAC,MAAM,WAAW,SAAY,YAAY;CAChD,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAC3C,MAAM,CAAC,OAAO,YAAY,SAA4B,KAAA,CAAS;CAC/D,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,CAAC;CAEtD,MAAM,UAAU,kBAAkB;EAC9B,mBAAkB,SAAQ,OAAO,CAAC;CACtC,GAAG,CAAC,CAAC;CAGL,MAAM,UAAU,OAAU,YAAY;CAItC,MAAM,cAAc,OAAO,QAAQ;CACnC,YAAY,UAAU;CAGtB,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAErB,gBAAgB;EACZ,IAAI,UAAU;EAEd,IAAI,YAAY;EAEhB,CAAC,YAAY;GACT,IAAI;IACA,MAAM,SAAS,MAAM,YAAY,QAAQ;IAEzC,IAAI,WAAW;IAGf,IAAI,CAAC,WAAW,QAAQ,QAAQ,SAAS,MAAM,GAAG;KAC9C,QAAQ,UAAU;KAClB,QAAQ,MAAM;IAClB;IAEA,SAAS,KAAA,CAAS;GACtB,SAAS,GAAG;IACR,IAAI,CAAC,WAAW;KACZ,QAAQ,MAAM,CAAC;KACf,SAAS,CAAU;IACvB;GACJ,UAAU;IACN,IAAI,CAAC,WACD,WAAW,KAAK;GAExB;EACJ,EAAA,CAAG;EAEH,aAAa;GACT,YAAY;EAChB;CAEJ,GAAG;EAAC,GAAG;EAAM;EAAgB;CAAQ,CAAC;CAEtC,OAAO,eAAe;EAClB;EACA;EACA;EACA;CACJ,IAAI;EAAC;EAAM;EAAS;EAAO;CAAO,CAAC;AACvC"}
1
+ {"version":3,"file":"useAsyncResolver.js","names":[],"sources":["../../../src/hooks/navigation/useAsyncResolver.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\n\nexport type UseAsyncResolverResult<T> = {\n data: T;\n loading: boolean;\n error: Error | undefined;\n refresh: () => void;\n};\n\n/**\n * Generic hook that resolves an async value with loading/error/refresh\n * state management, cancellation on unmount or deps change, and\n * ref-based change detection to prevent unnecessary state updates.\n *\n * Extracted from the common pattern in useResolvedCollections and\n * useResolvedViews.\n */\nexport function useAsyncResolver<T>({\n resolver,\n initialValue,\n isEqual,\n deps,\n disabled,\n pending = false,\n}: {\n /** Async function that resolves the data */\n resolver: () => Promise<T>;\n /** Initial value before first resolution */\n initialValue: T;\n /** Equality check to prevent unnecessary state updates */\n isEqual: (a: T, b: T) => boolean;\n /** Effect dependencies — when these change, resolver re-runs */\n deps: React.DependencyList;\n /** When true, skip resolution */\n disabled?: boolean;\n /**\n * The input is not ready yet (it is being fetched): do not resolve, and\n * report `loading` — not only now but until the first resolution after it\n * clears has finished, so no render sees the input ready and the result\n * still the old one.\n */\n pending?: boolean;\n}): UseAsyncResolverResult<T> {\n\n const [data, setData] = useState<T>(initialValue);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>(undefined);\n const [refreshTrigger, setRefreshTrigger] = useState(0);\n\n const refresh = useCallback(() => {\n setRefreshTrigger(prev => prev + 1);\n }, []);\n\n // Ref for change detection — avoids state updates when data hasn't changed\n const dataRef = useRef<T>(initialValue);\n\n // Store resolver in a ref so we always call the latest version\n // without adding it to effect deps (it's typically a new closure each render)\n const resolverRef = useRef(resolver);\n resolverRef.current = resolver;\n\n // Same for isEqual\n const isEqualRef = useRef(isEqual);\n isEqualRef.current = isEqual;\n\n useEffect(() => {\n if (pending) {\n setLoading(true);\n return;\n }\n if (disabled) return;\n\n let cancelled = false;\n\n (async () => {\n try {\n const result = await resolverRef.current();\n\n if (cancelled) return;\n\n // Only update state if data actually changed\n if (!isEqualRef.current(dataRef.current, result)) {\n dataRef.current = result;\n setData(result);\n }\n\n setError(undefined);\n } catch (e) {\n if (!cancelled) {\n console.error(e);\n setError(e as Error);\n }\n } finally {\n if (!cancelled) {\n setLoading(false);\n }\n }\n })();\n\n return () => {\n cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...deps, refreshTrigger, disabled, pending]);\n\n return useMemo(() => ({\n data,\n loading: loading || pending,\n error,\n refresh\n }), [data, loading, pending, error, refresh]);\n}\n"],"mappings":";;;;;;;;;;AAiBA,SAAgB,iBAAoB,EAChC,UACA,cACA,SACA,MACA,UACA,UAAU,SAmBgB;CAE1B,MAAM,CAAC,MAAM,WAAW,SAAY,YAAY;CAChD,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAC3C,MAAM,CAAC,OAAO,YAAY,SAA4B,KAAA,CAAS;CAC/D,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,CAAC;CAEtD,MAAM,UAAU,kBAAkB;EAC9B,mBAAkB,SAAQ,OAAO,CAAC;CACtC,GAAG,CAAC,CAAC;CAGL,MAAM,UAAU,OAAU,YAAY;CAItC,MAAM,cAAc,OAAO,QAAQ;CACnC,YAAY,UAAU;CAGtB,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAErB,gBAAgB;EACZ,IAAI,SAAS;GACT,WAAW,IAAI;GACf;EACJ;EACA,IAAI,UAAU;EAEd,IAAI,YAAY;EAEhB,CAAC,YAAY;GACT,IAAI;IACA,MAAM,SAAS,MAAM,YAAY,QAAQ;IAEzC,IAAI,WAAW;IAGf,IAAI,CAAC,WAAW,QAAQ,QAAQ,SAAS,MAAM,GAAG;KAC9C,QAAQ,UAAU;KAClB,QAAQ,MAAM;IAClB;IAEA,SAAS,KAAA,CAAS;GACtB,SAAS,GAAG;IACR,IAAI,CAAC,WAAW;KACZ,QAAQ,MAAM,CAAC;KACf,SAAS,CAAU;IACvB;GACJ,UAAU;IACN,IAAI,CAAC,WACD,WAAW,KAAK;GAExB;EACJ,EAAA,CAAG;EAEH,aAAa;GACT,YAAY;EAChB;CAEJ,GAAG;EAAC,GAAG;EAAM;EAAgB;EAAU;CAAO,CAAC;CAE/C,OAAO,eAAe;EAClB;EACA,SAAS,WAAW;EACpB;EACA;CACJ,IAAI;EAAC;EAAM;EAAS;EAAS;EAAO;CAAO,CAAC;AAChD"}
@@ -1,7 +1,5 @@
1
1
  import type { DataSourceDefinition } from "@rebasepro/types";
2
- import { CollectionRegistry } from "@rebasepro/common";
3
- import { CollectionRegistryController } from "@rebasepro/types";
4
- import { UserConfigurationPersistence } from "@rebasepro/cms-types";
2
+ import { UserConfigurationPersistence, CollectionRegistryController, CollectionRegistry } from "@rebasepro/cms-types";
5
3
  export declare function useBuildCollectionRegistryController(props: {
6
4
  userConfigPersistence?: UserConfigurationPersistence;
7
5
  dataSources?: Record<string, DataSourceDefinition>;
@@ -1,8 +1,8 @@
1
+ import { userPreferencesOverlay } from "./user_preferences_overlay.js";
1
2
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
- import { CollectionRegistry, getSubcollections } from "@rebasepro/common";
3
+ import { CollectionRegistry, getSubcollections, resolveAdminCollection } from "@rebasepro/cms-types";
3
4
  import { getParentReferencesFromPath, removeInitialAndTrailingSlashes } from "@rebasepro/app";
4
5
  import { mergeDeep } from "@rebasepro/utils";
5
- import { resolveAdminCollection } from "@rebasepro/cms-types";
6
6
  //#region src/hooks/navigation/useBuildCollectionRegistryController.tsx
7
7
  function useBuildCollectionRegistryController(props) {
8
8
  const { userConfigPersistence, dataSources } = props;
@@ -20,7 +20,7 @@ function useBuildCollectionRegistryController(props) {
20
20
  console.warn(`[rebase] Could not resolve a collection for "${cleanedPath}"`, e);
21
21
  return;
22
22
  }
23
- const userOverride = includeUserOverride ? userConfigPersistence?.getCollectionConfig(slugOrPath) : void 0;
23
+ const userOverride = includeUserOverride && collection ? userPreferencesOverlay(userConfigPersistence?.getTablePreferences(slugOrPath), new Set(Object.keys(collection.properties ?? {}))) : void 0;
24
24
  const overriddenCollection = collection ? mergeDeep(collection, userOverride ?? {}) : void 0;
25
25
  if (!overriddenCollection) return void 0;
26
26
  let result = overriddenCollection;
@@ -1 +1 @@
1
- {"version":3,"file":"useBuildCollectionRegistryController.js","names":[],"sources":["../../../src/hooks/navigation/useBuildCollectionRegistryController.tsx"],"sourcesContent":["import type { DataSourceDefinition } from \"@rebasepro/types\";\nimport { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\nimport { CollectionRegistry, getSubcollections } from \"@rebasepro/common\";\nimport { getParentReferencesFromPath as commonGetParentReferencesFromPath, removeInitialAndTrailingSlashes } from \"@rebasepro/app\";\nimport { EntityReference, CollectionRegistryController } from \"@rebasepro/types\";\nimport { UserConfigurationPersistence, resolveAdminCollection, AdminCollection } from \"@rebasepro/cms-types\";\nimport { mergeDeep } from \"@rebasepro/utils\";\n\nexport function useBuildCollectionRegistryController(props: {\n userConfigPersistence?: UserConfigurationPersistence,\n dataSources?: Record<string, DataSourceDefinition>\n}): CollectionRegistryController & {\n collectionRegistryRef: React.MutableRefObject<CollectionRegistry>;\n} {\n const { userConfigPersistence, dataSources } = props;\n const collectionRegistryRef = useRef<CollectionRegistry>(new CollectionRegistry(undefined, dataSources));\n // Keep the registry's data sources in sync (used to resolve engine during\n // normalization). Applied synchronously before the async registration\n // effect in useResolvedCollections runs.\n if (dataSources) collectionRegistryRef.current.setDataSources(dataSources);\n const [initialised, setInitialised] = useState(false);\n\n const getCollection = useCallback((\n slugOrPath: string,\n includeUserOverride = false\n ): AdminCollection | undefined => {\n\n const registry = collectionRegistryRef.current;\n\n const cleanedPath = removeInitialAndTrailingSlashes(slugOrPath);\n if (!cleanedPath) return undefined;\n\n let collection: AdminCollection | undefined;\n\n // A slug is allowed to contain slashes, and several drivers need it\n // to: a Firestore collection partitioned by locale is declared as\n // `content/de-DE/podcasts`, and that string is its *name*, not a path\n // to walk. Reading any `a/b/c` as collection/entity/subcollection looked\n // for a root collection called `content`, found none and threw, and the\n // view came out blank. Thirty-five collections in one app were\n // unreachable that way.\n //\n // Matching the whole path as a slug first fixed the collection itself\n // and nothing under it: `medico/v2.0.0/joints/j1/movements` is not a\n // slug either, so it went back to a walker starting from `medico`, and\n // the joint's tabs rendered empty. The registry now takes the longest\n // leading run of segments that names a collection as the root, and\n // pairs up what follows — which also decides whether the path ends at a\n // record. The segment count cannot: `content/podcasts` is two segments\n // and a collection, `content/de-DE/podcasts/abc123` four and a record.\n try {\n collection = registry.resolvePathToCollections(cleanedPath, { allowRecordPath: true }).finalCollection as AdminCollection;\n } catch (e) {\n // Warn, not debug. An unresolved collection ends as a route with\n // nothing in it, and at `debug` there was no way to tell that\n // from a collection that legitimately has no rows.\n console.warn(`[rebase] Could not resolve a collection for \"${cleanedPath}\"`, e);\n return undefined;\n }\n\n const userOverride = includeUserOverride ? userConfigPersistence?.getCollectionConfig(slugOrPath) : undefined;\n const overriddenCollection = collection ? mergeDeep(collection, userOverride ?? {}) : undefined;\n\n if (!overriddenCollection) return undefined;\n\n let result: Partial<AdminCollection> | undefined = overriddenCollection;\n const subcollections = \"subcollections\" in overriddenCollection ? overriddenCollection.subcollections : undefined;\n const callbacks = overriddenCollection.callbacks;\n result = {\n ...result,\n callbacks: result?.callbacks ?? callbacks\n };\n // Preserve subcollections if they exist\n if (subcollections && \"subcollections\" in result) {\n (result as Record<string, unknown>).subcollections = (result as Record<string, unknown>).subcollections ?? subcollections;\n }\n\n // Flatten the admin block: everything downstream of here is the panel's\n // view model, not the authoring shape. Applied after the user-override\n // merge so an override of a presentation field still wins.\n return resolveAdminCollection({ ...overriddenCollection,\n...result } as AdminCollection);\n\n }, [userConfigPersistence]);\n\n const getRawCollection = useCallback((slugOrPath: string): AdminCollection | undefined => {\n const registry = collectionRegistryRef.current;\n if (registry === undefined) return undefined;\n\n const cleanedPath = removeInitialAndTrailingSlashes(slugOrPath);\n if (!cleanedPath) return undefined;\n\n const pathSegments = cleanedPath.split(\"/\");\n\n return registry.getRaw(pathSegments.join(\"/\")) as AdminCollection | undefined;\n }, []);\n\n // Both hand a path back exactly as given when there is nothing to\n // translate, slashes and all: most collections are stored under their slug.\n const resolveDataPath = useCallback((path: string): string => {\n const cleanedPath = removeInitialAndTrailingSlashes(path);\n const dataPath = cleanedPath ? collectionRegistryRef.current.resolveDataPath(cleanedPath) : cleanedPath;\n return dataPath === cleanedPath ? path : dataPath;\n }, []);\n\n const resolveCollectionPath = useCallback((path: string, preferredDriver?: string): string => {\n const cleanedPath = removeInitialAndTrailingSlashes(path);\n const collectionPath = cleanedPath ? collectionRegistryRef.current.resolveCollectionPath(cleanedPath, preferredDriver) : cleanedPath;\n return collectionPath === cleanedPath ? path : collectionPath;\n }, []);\n\n const getParentReferencesFromPath = useCallback((path: string): EntityReference[] => {\n const registry = collectionRegistryRef.current;\n if (!registry) {\n return [];\n }\n const cleanedPath = removeInitialAndTrailingSlashes(path);\n const pathSegments = cleanedPath.split(\"/\");\n\n return commonGetParentReferencesFromPath({\n path: pathSegments.join(\"/\"),\n collections: registry.getCollections()\n });\n }, []);\n\n // Both read the registry's walk rather than taking alternate segments of\n // the path as collections and ids. Alternate segments only line up while no\n // slug contains a slash: they read `medico/v2.0.0/joints/j1/movements` as\n // having `v2.0.0` for a parent id and no parent collection at all.\n const getParentCollectionSlugs = useCallback((path: string): string[] => {\n const resolved = walkPath(collectionRegistryRef.current, path);\n if (!resolved) return [];\n // Every collection on the way down except the one the path addresses.\n return resolved.collections.slice(0, -1).map(collection => collection.slug);\n }, []);\n\n const getParentEntityIds = useCallback((path: string): string[] => {\n const resolved = walkPath(collectionRegistryRef.current, path);\n if (!resolved) return [];\n const { collections, entityIds } = resolved;\n // A path ending at a record has one id per collection, and the last is\n // the record itself rather than a parent of it.\n const parentIds = entityIds.length === collections.length ? entityIds.slice(0, -1) : entityIds;\n return parentIds.map(String);\n }, []);\n\n const convertIdsToPaths = useCallback((ids: string[]): string[] => {\n const registry = collectionRegistryRef.current;\n if (!registry) return [];\n let currentCollections: AdminCollection[] = registry.getCollections();\n const paths: string[] = [];\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i];\n const collection: AdminCollection | undefined = currentCollections.find(c => c.slug === id);\n if (!collection)\n throw Error(`Collection with id ${id} not found`);\n paths.push(collection.slug);\n currentCollections = getSubcollections(collection) ?? [];\n }\n return paths;\n }, []);\n\n const collections = collectionRegistryRef.current.getCollections().map(resolveAdminCollection);\n\n // Determine initialised automatically based on whether collections exist,\n // though the NavigationStateController also plays a role in overall init\n useEffect(() => {\n if (!initialised && collections.length > 0) {\n setInitialised(true);\n }\n }, [initialised, collections.length]);\n\n return useMemo(() => ({\n collections,\n initialised,\n getCollection,\n getRawCollection,\n resolveDataPath,\n resolveCollectionPath,\n getParentReferencesFromPath,\n getParentCollectionSlugs,\n getParentEntityIds,\n convertIdsToPaths,\n collectionRegistryRef\n }), [\n collections,\n initialised,\n getCollection,\n getRawCollection,\n resolveDataPath,\n resolveCollectionPath,\n getParentReferencesFromPath,\n getParentCollectionSlugs,\n getParentEntityIds,\n convertIdsToPaths\n ]);\n}\n\n/**\n * The collections and record ids a path runs through, whether it ends at a\n * collection or at one of its records; `undefined` when the registry cannot\n * walk it.\n *\n * A route to a record can also end in the tab it opens — `…/{id}/history`,\n * `…/{id}/edit` — which is not a subcollection, and whose parents are the\n * record's. So a path that does not walk is tried once more without its last\n * segment.\n */\nfunction walkPath(registry: CollectionRegistry, path: string): ReturnType<CollectionRegistry[\"resolvePathToCollections\"]> | undefined {\n const segments = removeInitialAndTrailingSlashes(path).split(\"/\").filter(Boolean);\n for (const candidate of [segments, segments.slice(0, -1)]) {\n if (candidate.length === 0) continue;\n try {\n return registry.resolvePathToCollections(candidate.join(\"/\"), { allowRecordPath: true });\n } catch {\n // Try the next candidate.\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;AAQA,SAAgB,qCAAqC,OAKnD;CACE,MAAM,EAAE,uBAAuB,gBAAgB;CAC/C,MAAM,wBAAwB,OAA2B,IAAI,mBAAmB,KAAA,GAAW,WAAW,CAAC;CAIvG,IAAI,aAAa,sBAAsB,QAAQ,eAAe,WAAW;CACzE,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,MAAM,gBAAgB,aAClB,YACA,sBAAsB,UACQ;EAE9B,MAAM,WAAW,sBAAsB;EAEvC,MAAM,cAAc,gCAAgC,UAAU;EAC9D,IAAI,CAAC,aAAa,OAAO,KAAA;EAEzB,IAAI;EAkBJ,IAAI;GACA,aAAa,SAAS,yBAAyB,aAAa,EAAE,iBAAiB,KAAK,CAAC,CAAC,CAAC;EAC3F,SAAS,GAAG;GAIR,QAAQ,KAAK,gDAAgD,YAAY,IAAI,CAAC;GAC9E;EACJ;EAEA,MAAM,eAAe,sBAAsB,uBAAuB,oBAAoB,UAAU,IAAI,KAAA;EACpG,MAAM,uBAAuB,aAAa,UA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;EAClB;EACA;EACA;EACA;EACA;EACA;EACA,6BAAA;EACA;EACA;EACA;EACA;CACJ,IAAI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL;;;;;;;;;;;AAYA,SAAS,SAAS,UAA8B,MAAsF;CAClI,MAAM,WAAW,gCAAgC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAChF,KAAK,MAAM,aAAa,CAAC,UAAU,SAAS,MAAM,GAAG,EAAE,CAAC,GAAG;EACvD,IAAI,UAAU,WAAW,GAAG;EAC5B,IAAI;GACA,OAAO,SAAS,yBAAyB,UAAU,KAAK,GAAG,GAAG,EAAE,iBAAiB,KAAK,CAAC;EAC3F,QAAQ,CAER;CACJ;AAEJ"}
1
+ {"version":3,"file":"useBuildCollectionRegistryController.js","names":[],"sources":["../../../src/hooks/navigation/useBuildCollectionRegistryController.tsx"],"sourcesContent":["import type { DataSourceDefinition } from \"@rebasepro/types\";\nimport { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\nimport { getParentReferencesFromPath as commonGetParentReferencesFromPath, removeInitialAndTrailingSlashes } from \"@rebasepro/app\";\nimport { UserConfigurationPersistence, resolveAdminCollection, AdminCollection, CollectionRegistryController, CollectionRegistry, getSubcollections, EntityReference } from \"@rebasepro/cms-types\";\nimport { mergeDeep } from \"@rebasepro/utils\";\nimport { userPreferencesOverlay } from \"./user_preferences_overlay\";\n\nexport function useBuildCollectionRegistryController(props: {\n userConfigPersistence?: UserConfigurationPersistence,\n dataSources?: Record<string, DataSourceDefinition>\n}): CollectionRegistryController & {\n collectionRegistryRef: React.MutableRefObject<CollectionRegistry>;\n} {\n const { userConfigPersistence, dataSources } = props;\n const collectionRegistryRef = useRef<CollectionRegistry>(new CollectionRegistry(undefined, dataSources));\n // Keep the registry's data sources in sync (used to resolve engine during\n // normalization). Applied synchronously before the async registration\n // effect in useResolvedCollections runs.\n if (dataSources) collectionRegistryRef.current.setDataSources(dataSources);\n const [initialised, setInitialised] = useState(false);\n\n const getCollection = useCallback((\n slugOrPath: string,\n includeUserOverride = false\n ): AdminCollection | undefined => {\n\n const registry = collectionRegistryRef.current;\n\n const cleanedPath = removeInitialAndTrailingSlashes(slugOrPath);\n if (!cleanedPath) return undefined;\n\n let collection: AdminCollection | undefined;\n\n // A slug is allowed to contain slashes, and several drivers need it\n // to: a Firestore collection partitioned by locale is declared as\n // `content/de-DE/podcasts`, and that string is its *name*, not a path\n // to walk. Reading any `a/b/c` as collection/entity/subcollection looked\n // for a root collection called `content`, found none and threw, and the\n // view came out blank. Thirty-five collections in one app were\n // unreachable that way.\n //\n // Matching the whole path as a slug first fixed the collection itself\n // and nothing under it: `medico/v2.0.0/joints/j1/movements` is not a\n // slug either, so it went back to a walker starting from `medico`, and\n // the joint's tabs rendered empty. The registry now takes the longest\n // leading run of segments that names a collection as the root, and\n // pairs up what follows — which also decides whether the path ends at a\n // record. The segment count cannot: `content/podcasts` is two segments\n // and a collection, `content/de-DE/podcasts/abc123` four and a record.\n try {\n collection = registry.resolvePathToCollections(cleanedPath, { allowRecordPath: true }).finalCollection as AdminCollection;\n } catch (e) {\n // Warn, not debug. An unresolved collection ends as a route with\n // nothing in it, and at `debug` there was no way to tell that\n // from a collection that legitimately has no rows.\n console.warn(`[rebase] Could not resolve a collection for \"${cleanedPath}\"`, e);\n return undefined;\n }\n\n // The last layer of the composition (`compose_collections.ts`): the\n // signed-in user's own preferences — column widths, order, view mode.\n const userOverride = includeUserOverride && collection\n ? userPreferencesOverlay(userConfigPersistence?.getTablePreferences(slugOrPath), new Set(Object.keys(collection.properties ?? {})))\n : undefined;\n const overriddenCollection = collection ? mergeDeep(collection, userOverride ?? {}) : undefined;\n\n if (!overriddenCollection) return undefined;\n\n let result: Partial<AdminCollection> | undefined = overriddenCollection;\n const subcollections = \"subcollections\" in overriddenCollection ? overriddenCollection.subcollections : undefined;\n const callbacks = overriddenCollection.callbacks;\n result = {\n ...result,\n callbacks: result?.callbacks ?? callbacks\n };\n // Preserve subcollections if they exist\n if (subcollections && \"subcollections\" in result) {\n (result as Record<string, unknown>).subcollections = (result as Record<string, unknown>).subcollections ?? subcollections;\n }\n\n // Flatten the admin block: everything downstream of here is the panel's\n // view model, not the authoring shape. Applied after the user-override\n // merge so an override of a presentation field still wins.\n return resolveAdminCollection({ ...overriddenCollection,\n...result } as AdminCollection);\n\n }, [userConfigPersistence]);\n\n const getRawCollection = useCallback((slugOrPath: string): AdminCollection | undefined => {\n const registry = collectionRegistryRef.current;\n if (registry === undefined) return undefined;\n\n const cleanedPath = removeInitialAndTrailingSlashes(slugOrPath);\n if (!cleanedPath) return undefined;\n\n const pathSegments = cleanedPath.split(\"/\");\n\n return registry.getRaw(pathSegments.join(\"/\")) as AdminCollection | undefined;\n }, []);\n\n // Both hand a path back exactly as given when there is nothing to\n // translate, slashes and all: most collections are stored under their slug.\n const resolveDataPath = useCallback((path: string): string => {\n const cleanedPath = removeInitialAndTrailingSlashes(path);\n const dataPath = cleanedPath ? collectionRegistryRef.current.resolveDataPath(cleanedPath) : cleanedPath;\n return dataPath === cleanedPath ? path : dataPath;\n }, []);\n\n const resolveCollectionPath = useCallback((path: string, preferredDriver?: string): string => {\n const cleanedPath = removeInitialAndTrailingSlashes(path);\n const collectionPath = cleanedPath ? collectionRegistryRef.current.resolveCollectionPath(cleanedPath, preferredDriver) : cleanedPath;\n return collectionPath === cleanedPath ? path : collectionPath;\n }, []);\n\n const getParentReferencesFromPath = useCallback((path: string): EntityReference[] => {\n const registry = collectionRegistryRef.current;\n if (!registry) {\n return [];\n }\n const cleanedPath = removeInitialAndTrailingSlashes(path);\n const pathSegments = cleanedPath.split(\"/\");\n\n return commonGetParentReferencesFromPath({\n path: pathSegments.join(\"/\"),\n collections: registry.getCollections()\n });\n }, []);\n\n // Both read the registry's walk rather than taking alternate segments of\n // the path as collections and ids. Alternate segments only line up while no\n // slug contains a slash: they read `medico/v2.0.0/joints/j1/movements` as\n // having `v2.0.0` for a parent id and no parent collection at all.\n const getParentCollectionSlugs = useCallback((path: string): string[] => {\n const resolved = walkPath(collectionRegistryRef.current, path);\n if (!resolved) return [];\n // Every collection on the way down except the one the path addresses.\n return resolved.collections.slice(0, -1).map(collection => collection.slug);\n }, []);\n\n const getParentEntityIds = useCallback((path: string): string[] => {\n const resolved = walkPath(collectionRegistryRef.current, path);\n if (!resolved) return [];\n const { collections, entityIds } = resolved;\n // A path ending at a record has one id per collection, and the last is\n // the record itself rather than a parent of it.\n const parentIds = entityIds.length === collections.length ? entityIds.slice(0, -1) : entityIds;\n return parentIds.map(String);\n }, []);\n\n const convertIdsToPaths = useCallback((ids: string[]): string[] => {\n const registry = collectionRegistryRef.current;\n if (!registry) return [];\n let currentCollections: AdminCollection[] = registry.getCollections();\n const paths: string[] = [];\n for (let i = 0; i < ids.length; i++) {\n const id = ids[i];\n const collection: AdminCollection | undefined = currentCollections.find(c => c.slug === id);\n if (!collection)\n throw Error(`Collection with id ${id} not found`);\n paths.push(collection.slug);\n currentCollections = getSubcollections(collection) ?? [];\n }\n return paths;\n }, []);\n\n const collections = collectionRegistryRef.current.getCollections().map(resolveAdminCollection);\n\n // Determine initialised automatically based on whether collections exist,\n // though the NavigationStateController also plays a role in overall init\n useEffect(() => {\n if (!initialised && collections.length > 0) {\n setInitialised(true);\n }\n }, [initialised, collections.length]);\n\n return useMemo(() => ({\n collections,\n initialised,\n getCollection,\n getRawCollection,\n resolveDataPath,\n resolveCollectionPath,\n getParentReferencesFromPath,\n getParentCollectionSlugs,\n getParentEntityIds,\n convertIdsToPaths,\n collectionRegistryRef\n }), [\n collections,\n initialised,\n getCollection,\n getRawCollection,\n resolveDataPath,\n resolveCollectionPath,\n getParentReferencesFromPath,\n getParentCollectionSlugs,\n getParentEntityIds,\n convertIdsToPaths\n ]);\n}\n\n/**\n * The collections and record ids a path runs through, whether it ends at a\n * collection or at one of its records; `undefined` when the registry cannot\n * walk it.\n *\n * A route to a record can also end in the tab it opens — `…/{id}/history`,\n * `…/{id}/edit` — which is not a subcollection, and whose parents are the\n * record's. So a path that does not walk is tried once more without its last\n * segment.\n */\nfunction walkPath(registry: CollectionRegistry, path: string): ReturnType<CollectionRegistry[\"resolvePathToCollections\"]> | undefined {\n const segments = removeInitialAndTrailingSlashes(path).split(\"/\").filter(Boolean);\n for (const candidate of [segments, segments.slice(0, -1)]) {\n if (candidate.length === 0) continue;\n try {\n return registry.resolvePathToCollections(candidate.join(\"/\"), { allowRecordPath: true });\n } catch {\n // Try the next candidate.\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;AAOA,SAAgB,qCAAqC,OAKnD;CACE,MAAM,EAAE,uBAAuB,gBAAgB;CAC/C,MAAM,wBAAwB,OAA2B,IAAI,mBAAmB,KAAA,GAAW,WAAW,CAAC;CAIvG,IAAI,aAAa,sBAAsB,QAAQ,eAAe,WAAW;CACzE,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,MAAM,gBAAgB,aAClB,YACA,sBAAsB,UACQ;EAE9B,MAAM,WAAW,sBAAsB;EAEvC,MAAM,cAAc,gCAAgC,UAAU;EAC9D,IAAI,CAAC,aAAa,OAAO,KAAA;EAEzB,IAAI;EAkBJ,IAAI;GACA,aAAa,SAAS,yBAAyB,aAAa,EAAE,iBAAiB,KAAK,CAAC,CAAC,CAAC;EAC3F,SAAS,GAAG;GAIR,QAAQ,KAAK,gDAAgD,YAAY,IAAI,CAAC;GAC9E;EACJ;EAIA,MAAM,eAAe,uBAAuB,aACtC,uBAAuB,uBAAuB,oBAAoB,UAAU,GAAG,IAAI,IAAI,OAAO,KAAK,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,IAChI,KAAA;EACN,MAAM,uBAAuB,aAAa,UAAU,YAAY,gBAAgB,CAAC,CAAC,IAAI,KAAA;EAEtF,IAAI,CAAC,sBAAsB,OAAO,KAAA;EAElC,IAAI,SAA+C;EACnD,MAAM,iBAAiB,oBAAoB,uBAAuB,qBAAqB,iBAAiB,KAAA;EACxG,M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,UAA8B,MAAsF;CAClI,MAAM,WAAW,gCAAgC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAChF,KAAK,MAAM,aAAa,CAAC,UAAU,SAAS,MAAM,GAAG,EAAE,CAAC,GAAG;EACvD,IAAI,UAAU,WAAW,GAAG;EAC5B,IAAI;GACA,OAAO,SAAS,yBAAyB,UAAU,KAAK,GAAG,GAAG,EAAE,iBAAiB,KAAK,CAAC;EAC3F,QAAQ,CAER;CACJ;AAEJ"}
@@ -1,9 +1,7 @@
1
1
  import type { AppView, RebasePlugin, NavigationStateController, UrlController, NavigationGroupMapping, AdminCollection } from "@rebasepro/cms-types";
2
- import { RebaseSdkData, CollectionRegistryController, User } from "@rebasepro/types";
3
- import { AuthController } from "@rebasepro/cms-types";
4
- import type { EffectiveRoleController } from "@rebasepro/types";
5
- import type { CollectionConfigsBuilder, AppViewsBuilder } from "@rebasepro/cms-types";
6
- import { CollectionRegistry } from "@rebasepro/common";
2
+ import { RebaseSdkData, User } from "@rebasepro/types";
3
+ import { AuthController, CollectionRegistryController, CollectionRegistry } from "@rebasepro/cms-types";
4
+ import type { CollectionConfigsBuilder, AppViewsBuilder, EffectiveRoleController } from "@rebasepro/cms-types";
7
5
  export type BuildNavigationStateProps<EC extends AdminCollection, USER extends User> = {
8
6
  authController: AuthController<USER>;
9
7
  collections?: EC[] | CollectionConfigsBuilder<EC>;
@@ -13,6 +11,12 @@ export type BuildNavigationStateProps<EC extends AdminCollection, USER extends U
13
11
  plugins?: RebasePlugin[];
14
12
  navigationGroupMappings?: NavigationGroupMapping[];
15
13
  disabled?: boolean;
14
+ /**
15
+ * What the collections are built from is still being fetched: the
16
+ * navigation reports `loading` until the collections built from what
17
+ * arrives are registered. See `useResolvedCollections`.
18
+ */
19
+ collectionsPending?: boolean;
16
20
  viewsOrder?: string[];
17
21
  collectionRegistryController: CollectionRegistryController<EC> & {
18
22
  collectionRegistryRef: React.MutableRefObject<CollectionRegistry>;
@@ -14,13 +14,14 @@ import { useCallback, useMemo, useRef } from "react";
14
14
  * The NavigationStateController type is preserved as a public API.
15
15
  */
16
16
  function useBuildNavigationStateController(props) {
17
- const { authController, collections: collectionsProp, views: viewsProp, adminViews: adminViewsProp, viewsOrder, plugins, data, disabled, navigationGroupMappings, collectionRegistryController, urlController, adminMode = "cms", effectiveRoleController } = props;
17
+ const { authController, collections: collectionsProp, views: viewsProp, adminViews: adminViewsProp, viewsOrder, plugins, data, disabled, collectionsPending, navigationGroupMappings, collectionRegistryController, urlController, adminMode = "cms", effectiveRoleController } = props;
18
18
  const { collections, loading: collectionsLoading, error: collectionsError, refresh: refreshCollections } = useResolvedCollections({
19
19
  authController,
20
20
  collections: collectionsProp,
21
21
  data,
22
22
  plugins,
23
23
  disabled,
24
+ pending: collectionsPending,
24
25
  collectionRegistryController
25
26
  });
26
27
  const { views, adminViews, loading: viewsLoading, error: viewsError, refresh: refreshViews } = useResolvedViews({
@@ -1 +1 @@
1
- {"version":3,"file":"useBuildNavigationStateController.js","names":[],"sources":["../../../src/hooks/navigation/useBuildNavigationStateController.tsx"],"sourcesContent":["\nimport type { AppView, NavigationResult, RebasePlugin, NavigationStateController, UrlController, NavigationGroupMapping, AdminCollection } from \"@rebasepro/cms-types\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\nimport { RebaseSdkData, CollectionRegistryController, User } from \"@rebasepro/types\";\nimport { AuthController } from \"@rebasepro/cms-types\";\nimport type { EffectiveRoleController } from \"@rebasepro/types\";\nimport type { CollectionConfigsBuilder, AppViewsBuilder } from \"@rebasepro/cms-types\";\nimport { CollectionRegistry } from \"@rebasepro/common\";\n\nimport { useResolvedCollections } from \"./useResolvedCollections\";\nimport { useResolvedViews } from \"./useResolvedViews\";\nimport { useTopLevelNavigation } from \"./useTopLevelNavigation\";\n\nexport type BuildNavigationStateProps<EC extends AdminCollection, USER extends User> = {\n authController: AuthController<USER>;\n collections?: EC[] | CollectionConfigsBuilder<EC>;\n views?: AppView[] | AppViewsBuilder;\n adminViews?: AppView[] | AppViewsBuilder;\n data: RebaseSdkData;\n plugins?: RebasePlugin[];\n navigationGroupMappings?: NavigationGroupMapping[];\n disabled?: boolean;\n viewsOrder?: string[];\n collectionRegistryController: CollectionRegistryController<EC> & { collectionRegistryRef: React.MutableRefObject<CollectionRegistry> };\n urlController: UrlController;\n adminMode?: \"cms\" | \"studio\";\n effectiveRoleController?: EffectiveRoleController;\n\n};\n\n/**\n * Main hook that resolves collections, views, and admin views into a\n * NavigationStateController. This is a thin composition of three focused hooks:\n *\n * - useResolvedCollections: resolves collection props and registers with CollectionRegistry\n * - useResolvedViews: resolves view/admin view props\n * - useTopLevelNavigation: computes the NavigationResult from resolved data\n *\n * The NavigationStateController type is preserved as a public API.\n */\nexport function useBuildNavigationStateController<EC extends AdminCollection, USER extends User>(\n props: BuildNavigationStateProps<EC, USER>\n): NavigationStateController {\n\n const {\n authController,\n collections: collectionsProp,\n views: viewsProp,\n adminViews: adminViewsProp,\n viewsOrder,\n plugins,\n data,\n disabled,\n navigationGroupMappings,\n collectionRegistryController,\n urlController,\n adminMode = \"cms\",\n effectiveRoleController\n } = props;\n\n const {\n collections,\n loading: collectionsLoading,\n error: collectionsError,\n refresh: refreshCollections\n } = useResolvedCollections({\n authController,\n collections: collectionsProp,\n data,\n plugins,\n disabled,\n collectionRegistryController\n });\n\n const {\n views,\n adminViews,\n loading: viewsLoading,\n error: viewsError,\n refresh: refreshViews\n } = useResolvedViews({\n authController,\n views: viewsProp,\n adminViews: adminViewsProp,\n data,\n plugins,\n adminMode,\n effectiveRoleController\n });\n\n // Step 3: Compute top-level navigation (pure derived state)\n const { topLevelNavigation } = useTopLevelNavigation({\n collections,\n views,\n adminViews,\n plugins,\n navigationGroupMappings,\n viewsOrder,\n urlController,\n adminMode,\n collectionRegistryController\n });\n\n // Expose a combined refresh function with microtask batching\n const pendingRefreshRef = useRef(false);\n const refreshNavigation = useCallback(() => {\n if (pendingRefreshRef.current) return;\n pendingRefreshRef.current = true;\n queueMicrotask(() => {\n pendingRefreshRef.current = false;\n refreshCollections();\n refreshViews();\n });\n }, [refreshCollections, refreshViews]);\n\n return useMemo(() => ({\n views,\n adminViews,\n topLevelNavigation,\n loading: collectionsLoading || viewsLoading,\n navigationLoadingError: collectionsError ?? viewsError,\n refreshNavigation\n }), [\n views,\n adminViews,\n topLevelNavigation,\n collectionsLoading,\n viewsLoading,\n collectionsError,\n viewsError,\n refreshNavigation\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,SAAgB,kCACZ,OACyB;CAEzB,MAAM,EACF,gBACA,aAAa,iBACb,OAAO,WACP,YAAY,gBACZ,YACA,SACA,MACA,UACA,yBACA,8BACA,eACA,YAAY,OACZ,4BACA;CAEJ,MAAM,EACF,aACA,SAAS,oBACT,OAAO,kBACP,SAAS,uBACT,uBAAuB;EACvB;EACA,aAAa;EACb;EACA;EACA;EACA;CACJ,CAAC;CAED,MAAM,EACF,OACA,YACA,SAAS,cACT,OAAO,YACP,SAAS,iBACT,iBAAiB;EACjB;EACA,OAAO;EACP,YAAY;EACZ;EACA;EACA;EACA;CACJ,CAAC;CAGD,MAAM,EAAE,uBAAuB,sBAAsB;EACjD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;CAGD,MAAM,oBAAoB,OAAO,KAAK;CACtC,MAAM,oBAAoB,kBAAkB;EACxC,IAAI,kBAAkB,SAAS;EAC/B,kBAAkB,UAAU;EAC5B,qBAAqB;GACjB,kBAAkB,UAAU;GAC5B,mBAAmB;GACnB,aAAa;EACjB,CAAC;CACL,GAAG,CAAC,oBAAoB,YAAY,CAAC;CAErC,OAAO,eAAe;EAClB;EACA;EACA;EACA,SAAS,sBAAsB;EAC/B,wBAAwB,oBAAoB;EAC5C;CACJ,IAAI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"useBuildNavigationStateController.js","names":[],"sources":["../../../src/hooks/navigation/useBuildNavigationStateController.tsx"],"sourcesContent":["\nimport type { AppView, NavigationResult, RebasePlugin, NavigationStateController, UrlController, NavigationGroupMapping, AdminCollection } from \"@rebasepro/cms-types\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\nimport { RebaseSdkData, User } from \"@rebasepro/types\";\nimport { AuthController, CollectionRegistryController, CollectionRegistry } from \"@rebasepro/cms-types\";\nimport type { CollectionConfigsBuilder, AppViewsBuilder, EffectiveRoleController } from \"@rebasepro/cms-types\";\n\nimport { useResolvedCollections } from \"./useResolvedCollections\";\nimport { useResolvedViews } from \"./useResolvedViews\";\nimport { useTopLevelNavigation } from \"./useTopLevelNavigation\";\n\nexport type BuildNavigationStateProps<EC extends AdminCollection, USER extends User> = {\n authController: AuthController<USER>;\n collections?: EC[] | CollectionConfigsBuilder<EC>;\n views?: AppView[] | AppViewsBuilder;\n adminViews?: AppView[] | AppViewsBuilder;\n data: RebaseSdkData;\n plugins?: RebasePlugin[];\n navigationGroupMappings?: NavigationGroupMapping[];\n disabled?: boolean;\n /**\n * What the collections are built from is still being fetched: the\n * navigation reports `loading` until the collections built from what\n * arrives are registered. See `useResolvedCollections`.\n */\n collectionsPending?: boolean;\n viewsOrder?: string[];\n collectionRegistryController: CollectionRegistryController<EC> & { collectionRegistryRef: React.MutableRefObject<CollectionRegistry> };\n urlController: UrlController;\n adminMode?: \"cms\" | \"studio\";\n effectiveRoleController?: EffectiveRoleController;\n\n};\n\n/**\n * Main hook that resolves collections, views, and admin views into a\n * NavigationStateController. This is a thin composition of three focused hooks:\n *\n * - useResolvedCollections: resolves collection props and registers with CollectionRegistry\n * - useResolvedViews: resolves view/admin view props\n * - useTopLevelNavigation: computes the NavigationResult from resolved data\n *\n * The NavigationStateController type is preserved as a public API.\n */\nexport function useBuildNavigationStateController<EC extends AdminCollection, USER extends User>(\n props: BuildNavigationStateProps<EC, USER>\n): NavigationStateController {\n\n const {\n authController,\n collections: collectionsProp,\n views: viewsProp,\n adminViews: adminViewsProp,\n viewsOrder,\n plugins,\n data,\n disabled,\n collectionsPending,\n navigationGroupMappings,\n collectionRegistryController,\n urlController,\n adminMode = \"cms\",\n effectiveRoleController\n } = props;\n\n const {\n collections,\n loading: collectionsLoading,\n error: collectionsError,\n refresh: refreshCollections\n } = useResolvedCollections({\n authController,\n collections: collectionsProp,\n data,\n plugins,\n disabled,\n pending: collectionsPending,\n collectionRegistryController\n });\n\n const {\n views,\n adminViews,\n loading: viewsLoading,\n error: viewsError,\n refresh: refreshViews\n } = useResolvedViews({\n authController,\n views: viewsProp,\n adminViews: adminViewsProp,\n data,\n plugins,\n adminMode,\n effectiveRoleController\n });\n\n // Step 3: Compute top-level navigation (pure derived state)\n const { topLevelNavigation } = useTopLevelNavigation({\n collections,\n views,\n adminViews,\n plugins,\n navigationGroupMappings,\n viewsOrder,\n urlController,\n adminMode,\n collectionRegistryController\n });\n\n // Expose a combined refresh function with microtask batching\n const pendingRefreshRef = useRef(false);\n const refreshNavigation = useCallback(() => {\n if (pendingRefreshRef.current) return;\n pendingRefreshRef.current = true;\n queueMicrotask(() => {\n pendingRefreshRef.current = false;\n refreshCollections();\n refreshViews();\n });\n }, [refreshCollections, refreshViews]);\n\n return useMemo(() => ({\n views,\n adminViews,\n topLevelNavigation,\n loading: collectionsLoading || viewsLoading,\n navigationLoadingError: collectionsError ?? viewsError,\n refreshNavigation\n }), [\n views,\n adminViews,\n topLevelNavigation,\n collectionsLoading,\n viewsLoading,\n collectionsError,\n viewsError,\n refreshNavigation\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6CA,SAAgB,kCACZ,OACyB;CAEzB,MAAM,EACF,gBACA,aAAa,iBACb,OAAO,WACP,YAAY,gBACZ,YACA,SACA,MACA,UACA,oBACA,yBACA,8BACA,eACA,YAAY,OACZ,4BACA;CAEJ,MAAM,EACF,aACA,SAAS,oBACT,OAAO,kBACP,SAAS,uBACT,uBAAuB;EACvB;EACA,aAAa;EACb;EACA;EACA;EACA,SAAS;EACT;CACJ,CAAC;CAED,MAAM,EACF,OACA,YACA,SAAS,cACT,OAAO,YACP,SAAS,iBACT,iBAAiB;EACjB;EACA,OAAO;EACP,YAAY;EACZ;EACA;EACA;EACA;CACJ,CAAC;CAGD,MAAM,EAAE,uBAAuB,sBAAsB;EACjD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;CAGD,MAAM,oBAAoB,OAAO,KAAK;CACtC,MAAM,oBAAoB,kBAAkB;EACxC,IAAI,kBAAkB,SAAS;EAC/B,kBAAkB,UAAU;EAC5B,qBAAqB;GACjB,kBAAkB,UAAU;GAC5B,mBAAmB;GACnB,aAAa;EACjB,CAAC;CACL,GAAG,CAAC,oBAAoB,YAAY,CAAC;CAErC,OAAO,eAAe;EAClB;EACA;EACA;EACA,SAAS,sBAAsB;EAC/B,wBAAwB,oBAAoB;EAC5C;CACJ,IAAI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL"}
@@ -1,5 +1,5 @@
1
1
  import type { UrlController } from "@rebasepro/cms-types";
2
- import { CollectionRegistryController } from "@rebasepro/types";
2
+ import { CollectionRegistryController } from "@rebasepro/cms-types";
3
3
  export declare function useBuildUrlController(props: {
4
4
  basePath: string;
5
5
  baseCollectionPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useBuildUrlController.js","names":[],"sources":["../../../src/hooks/navigation/useBuildUrlController.tsx"],"sourcesContent":["import type { UrlController, NavigateOptions } from \"@rebasepro/cms-types\";\nimport { useCallback, useMemo } from \"react\";\nimport { removeInitialAndTrailingSlashes, resolveCollectionPathIds } from \"@rebasepro/app\";\nimport { CollectionRegistryController } from \"@rebasepro/types\";\nimport { useNavigate } from \"react-router\";\nimport { decodeUrlPath, encodeUrlPath } from \"./url_segments\";\n\nexport function useBuildUrlController(props: {\n basePath: string,\n baseCollectionPath: string,\n collectionRegistryController: CollectionRegistryController\n}): UrlController {\n\n const { basePath, baseCollectionPath, collectionRegistryController } = props;\n const navigate = useNavigate();\n\n const homeUrl = basePath === \"/\" ? \"/\" : `/${removeInitialAndTrailingSlashes(basePath)}`;\n\n // `path` is a data path: each of its segments, record ids included, is\n // written percent-encoded, and a query or hash goes after the result.\n const buildUrlCollectionPath = useCallback((path: string): string => {\n const urlPath = encodeUrlPath(path);\n const fullPath = basePath === \"/\" ? `${baseCollectionPath}/${urlPath}` : `${basePath}${baseCollectionPath}/${urlPath}`;\n return fullPath.replace(/\\/\\//g, \"/\");\n }, [basePath, baseCollectionPath]);\n\n const buildAppUrlPath = useCallback((path: string): string => {\n const fullPath = basePath === \"/\" ? `/${path}` : `${basePath}/${path}`;\n return fullPath.replace(/\\/\\//g, \"/\");\n }, [basePath]);\n\n const urlPathToDataPath = useCallback((cmsPath: string): string => {\n let path = cmsPath;\n if (basePath !== \"/\" && path.startsWith(basePath)) {\n path = path.replace(basePath, \"\");\n }\n if (path.startsWith(baseCollectionPath)) {\n path = path.replace(baseCollectionPath, \"\");\n }\n // The pathname arrives percent-encoded, by the browser or by\n // `buildUrlCollectionPath`; the data path holds the ids themselves.\n return decodeUrlPath(removeInitialAndTrailingSlashes(path));\n }, [basePath, baseCollectionPath]);\n\n const isUrlCollectionPath = useCallback((urlPath: string): boolean => {\n let path = urlPath;\n if (basePath !== \"/\" && path.startsWith(basePath)) {\n path = path.replace(basePath, \"\");\n }\n return path === baseCollectionPath || path.startsWith(baseCollectionPath + \"/\");\n }, [basePath, baseCollectionPath]);\n\n const resolveDatabasePathsFrom = useCallback((path: string): string => {\n return resolveCollectionPathIds(path, collectionRegistryController.collections ?? []);\n }, [collectionRegistryController]);\n\n const navigateTo = useCallback((to: string, options?: NavigateOptions) => {\n navigate(to, options);\n }, [navigate]);\n\n return useMemo(() => ({\n basePath,\n baseCollectionPath,\n urlPathToDataPath,\n homeUrl,\n isUrlCollectionPath,\n buildUrlCollectionPath,\n buildAppUrlPath,\n resolveDatabasePathsFrom,\n navigate: navigateTo\n }), [basePath, baseCollectionPath, urlPathToDataPath, homeUrl, isUrlColl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EjC,MAAM,aAAa,aAAa,IAAY,YAA8B;EACtE,SAAS,IAAI,OAAO;CACxB,GAAG,CAAC,QAAQ,CAAC;CAEb,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;CACd,IAAI;EAAC;EAAU;EAAoB;EAAmB;EAAS;EAAqB;EAAwB;EAAiB;EAA0B;CAAU,CAAC;AACtK"}
1
+ {"version":3,"file":"useBuildUrlController.js","names":[],"sources":["../../../src/hooks/navigation/useBuildUrlController.tsx"],"sourcesContent":["import type { UrlController, NavigateOptions } from \"@rebasepro/cms-types\";\nimport { useCallback, useMemo } from \"react\";\nimport { removeInitialAndTrailingSlashes, resolveCollectionPathIds } from \"@rebasepro/app\";\nimport { CollectionRegistryController } from \"@rebasepro/cms-types\";\nimport { useNavigate } from \"react-router\";\nimport { decodeUrlPath, encodeUrlPath } from \"./url_segments\";\n\nexport function useBuildUrlController(props: {\n basePath: string,\n baseCollectionPath: string,\n collectionRegistryController: CollectionRegistryController\n}): UrlController {\n\n const { basePath, baseCollectionPath, collectionRegistryController } = props;\n const navigate = useNavigate();\n\n const homeUrl = basePath === \"/\" ? \"/\" : `/${removeInitialAndTrailingSlashes(basePath)}`;\n\n // `path` is a data path: each of its segments, record ids included, is\n // written percent-encoded, and a query or hash goes after the result.\n const buildUrlCollectionPath = useCallback((path: string): string => {\n const urlPath = encodeUrlPath(path);\n const fullPath = basePath === \"/\" ? `${baseCollectionPath}/${urlPath}` : `${basePath}${baseCollectionPath}/${urlPath}`;\n return fullPath.replace(/\\/\\//g, \"/\");\n }, [basePath, baseCollectionPath]);\n\n const buildAppUrlPath = useCallback((path: string): string => {\n const fullPath = basePath === \"/\" ? `/${path}` : `${basePath}/${path}`;\n return fullPath.replace(/\\/\\//g, \"/\");\n }, [basePath]);\n\n const urlPathToDataPath = useCallback((cmsPath: string): string => {\n let path = cmsPath;\n if (basePath !== \"/\" && path.startsWith(basePath)) {\n path = path.replace(basePath, \"\");\n }\n if (path.startsWith(baseCollectionPath)) {\n path = path.replace(baseCollectionPath, \"\");\n }\n // The pathname arrives percent-encoded, by the browser or by\n // `buildUrlCollectionPath`; the data path holds the ids themselves.\n return decodeUrlPath(removeInitialAndTrailingSlashes(path));\n }, [basePath, baseCollectionPath]);\n\n const isUrlCollectionPath = useCallback((urlPath: string): boolean => {\n let path = urlPath;\n if (basePath !== \"/\" && path.startsWith(basePath)) {\n path = path.replace(basePath, \"\");\n }\n return path === baseCollectionPath || path.startsWith(baseCollectionPath + \"/\");\n }, [basePath, baseCollectionPath]);\n\n const resolveDatabasePathsFrom = useCallback((path: string): string => {\n return resolveCollectionPathIds(path, collectionRegistryController.collections ?? []);\n }, [collectionRegistryController]);\n\n const navigateTo = useCallback((to: string, options?: NavigateOptions) => {\n navigate(to, options);\n }, [navigate]);\n\n return useMemo(() => ({\n basePath,\n baseCollectionPath,\n urlPathToDataPath,\n homeUrl,\n isUrlCollectionPath,\n buildUrlCollectionPath,\n buildAppUrlPath,\n resolveDatabasePathsFrom,\n navigate: navigateTo\n }), [basePath, baseCollectionPath, urlPathToDataPath, homeUrl, isUrlCollectionPath, buildUrlCollectionPath, buildAppUrlPath, resolveDatabasePathsFrom, navigateTo]);\n}\n"],"mappings":";;;;;AAOA,SAAgB,sBAAsB,OAIpB;CAEd,MAAM,EAAE,UAAU,oBAAoB,iCAAiC;CACvE,MAAM,WAAW,YAAY;CAE7B,MAAM,UAAU,aAAa,MAAM,MAAM,IAAI,gCAAgC,QAAQ;CAIrF,MAAM,yBAAyB,aAAa,SAAyB;EACjE,MAAM,UAAU,cAAc,IAAI;EAElC,QADiB,aAAa,MAAM,GAAG,mBAAmB,GAAG,YAAY,GAAG,WAAW,mBAAmB,GAAG,UAAA,CAC7F,QAAQ,SAAS,GAAG;CACxC,GAAG,CAAC,UAAU,kBAAkB,CAAC;CAEjC,MAAM,kBAAkB,aAAa,SAAyB;EAE1D,QADiB,aAAa,MAAM,IAAI,SAAS,GAAG,SAAS,GAAG,OAAA,CAChD,QAAQ,SAAS,GAAG;CACxC,GAAG,CAAC,QAAQ,CAAC;CAEb,MAAM,oBAAoB,aAAa,YAA4B;EAC/D,IAAI,OAAO;EACX,IAAI,aAAa,OAAO,KAAK,WAAW,QAAQ,GAC5C,OAAO,KAAK,QAAQ,UAAU,EAAE;EAEpC,IAAI,KAAK,WAAW,kBAAkB,GAClC,OAAO,KAAK,QAAQ,oBAAoB,EAAE;EAI9C,OAAO,cAAc,gCAAgC,IAAI,CAAC;CAC9D,GAAG,CAAC,UAAU,kBAAkB,CAAC;CAEjC,MAAM,sBAAsB,aAAa,YAA6B;EAClE,IAAI,OAAO;EACX,IAAI,aAAa,OAAO,KAAK,WAAW,QAAQ,GAC5C,OAAO,KAAK,QAAQ,UAAU,EAAE;EAEpC,OAAO,SAAS,sBAAsB,KAAK,WAAW,qBAAqB,GAAG;CAClF,GAAG,CAAC,UAAU,kBAAkB,CAAC;CAEjC,MAAM,2BAA2B,aAAa,SAAyB;EACnE,OAAO,yBAAyB,MAAM,6BAA6B,eAAe,CAAC,CAAC;CACxF,GAAG,CAAC,4BAA4B,CAAC;CAEjC,MAAM,aAAa,aAAa,IAAY,YAA8B;EACtE,SAAS,IAAI,OAAO;CACxB,GAAG,CAAC,QAAQ,CAAC;CAEb,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;CACd,IAAI;EAAC;EAAU;EAAoB;EAAmB;EAAS;EAAqB;EAAwB;EAAiB;EAA0B;CAAU,CAAC;AACtK"}
@@ -1,8 +1,7 @@
1
1
  import { CreationResultDialog } from "../../components/admin/CreationResultDialog.js";
2
2
  import { accountAccessAction, resetMfaAction, resetPasswordAction } from "../../components/common/default_entity_actions.js";
3
3
  import React from "react";
4
- import { canReadCollection } from "@rebasepro/common";
5
- import { resolveAdminCollection } from "@rebasepro/cms-types";
4
+ import { canReadCollection, resolveAdminCollection } from "@rebasepro/cms-types";
6
5
  //#region src/hooks/navigation/useNavigationResolution.ts
7
6
  /**
8
7
  * Check whether a `RebaseCallContext` is actually the full frontend