@rebasepro/cms 0.30.1 → 0.31.0-canary.g902a0ce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/collection_editor/ConfigControllerProvider.js +25 -22
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
- package/dist/collection_editor/firestore_callee.d.ts +10 -0
- package/dist/collection_editor/firestore_callee.js +15 -0
- package/dist/collection_editor/firestore_callee.js.map +1 -0
- package/dist/collection_editor/firestore_edit.d.ts +62 -0
- package/dist/collection_editor/firestore_edit.js +339 -0
- package/dist/collection_editor/firestore_edit.js.map +1 -0
- package/dist/collection_editor/index.d.ts +2 -3
- package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
- package/dist/collection_editor/liveSchemaClient.js +9 -3
- package/dist/collection_editor/liveSchemaClient.js.map +1 -1
- package/dist/collection_editor/property_column.d.ts +86 -0
- package/dist/collection_editor/property_column.js +719 -0
- package/dist/collection_editor/property_column.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +2 -24
- package/dist/collection_editor/serializable_utils.d.ts +1 -1
- package/dist/collection_editor/serializable_utils.js +2 -1
- package/dist/collection_editor/serializable_utils.js.map +1 -1
- package/dist/collection_editor/split_edit.d.ts +106 -0
- package/dist/collection_editor/split_edit.js +564 -0
- package/dist/collection_editor/split_edit.js.map +1 -0
- package/dist/collection_editor/split_edit_error.d.ts +25 -0
- package/dist/collection_editor/split_edit_error.js +35 -0
- package/dist/collection_editor/split_edit_error.js.map +1 -0
- package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
- package/dist/collection_editor/types/config_controller.d.ts +67 -1
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
- package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
- package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
- package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
- package/dist/collection_editor/validateCollectionJson.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +10 -9
- package/dist/components/CollectionPanel.js +5 -2
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
- package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +23 -8
- package/dist/components/CollectionsProvider.js +23 -7
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/DefaultDrawer.js +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +1 -1
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +3 -3
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -1
- package/dist/components/EditViewBinding.js +6 -6
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.d.ts +1 -2
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityInspector.d.ts +1 -2
- package/dist/components/EntityInspector.js.map +1 -1
- package/dist/components/EntityPreviewBinding.d.ts +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +1 -1
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +1 -1
- package/dist/components/EntityViewBody.js +3 -4
- package/dist/components/EntityViewBody.js.map +1 -1
- package/dist/components/FieldValue.js +2 -2
- package/dist/components/FieldValue.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +12 -3
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/InlineEntityPreview.d.ts +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PropertyCollectionView.d.ts +2 -2
- package/dist/components/PropertyCollectionView.js.map +1 -1
- package/dist/components/PropertyConfigBadge.js.map +1 -1
- package/dist/components/RebaseCMS.d.ts +22 -3
- package/dist/components/RebaseCMS.js +32 -14
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +106 -31
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RecordDetail.js +4 -1
- package/dist/components/RecordDetail.js.map +1 -1
- package/dist/components/RecordForm.d.ts +5 -5
- package/dist/components/RecordForm.js +5 -2
- package/dist/components/RecordForm.js.map +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
- package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +2 -1
- package/dist/components/ReferenceWidget.js +2 -2
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.d.ts +2 -1
- package/dist/components/RelationSelector.js +2 -3
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
- package/dist/components/SidePanelBinding.js +1 -1
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/field_configs.d.ts +1 -2
- package/dist/components/field_configs.js.map +1 -1
- package/dist/components/field_ids.d.ts +1 -1
- package/dist/components/field_ids.js +1 -1
- package/dist/components/field_ids.js.map +1 -1
- package/dist/components/history/EntityHistoryEntry.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +1 -2
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/data_export/export/BasicExportAction.d.ts +1 -1
- package/dist/data_export/export/BasicExportAction.js.map +1 -1
- package/dist/data_export/export/ExportCollectionAction.js +2 -2
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +1 -1
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_export/export/export.d.ts +1 -1
- package/dist/data_export/export/export.js +1 -1
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/data_export/export/fetch_export_data.d.ts +3 -2
- package/dist/data_export/export/fetch_export_data.js.map +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
- package/dist/data_import/hooks/useImportConfig.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/data_import/types/column_mapping.d.ts +1 -1
- package/dist/data_import/utils/data.d.ts +1 -2
- package/dist/data_import/utils/data.js +1 -2
- package/dist/data_import/utils/data.js.map +1 -1
- package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
- package/dist/data_import/utils/id_column.d.ts +1 -1
- package/dist/data_import/utils/id_column.js.map +1 -1
- package/dist/data_import/utils/import_columns.d.ts +1 -1
- package/dist/data_import/utils/import_columns.js.map +1 -1
- package/dist/data_import/utils/save_entities.d.ts +3 -3
- package/dist/data_import/utils/save_entities.js +1 -1
- package/dist/data_import/utils/save_entities.js.map +1 -1
- package/dist/form/EntityForm.js +2 -1
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.js +2 -2
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormFieldsContext.d.ts +1 -4
- package/dist/form/FormFieldsContext.js +1 -1
- package/dist/form/FormFieldsContext.js.map +1 -1
- package/dist/form/PropertyFieldBinding.js +6 -8
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/components/FieldBlock.d.ts +1 -2
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FieldHelperText.d.ts +1 -1
- package/dist/form/components/FieldHelperText.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +1 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/LocalChangesMenu.d.ts +1 -1
- package/dist/form/components/LocalChangesMenu.js.map +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.js.map +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
- package/dist/form/form_utils.d.ts +3 -3
- package/dist/form/form_utils.js +1 -2
- package/dist/form/form_utils.js.map +1 -1
- package/dist/form/label_placement.d.ts +1 -2
- package/dist/form/label_placement.js.map +1 -1
- package/dist/form/resolve_cell_property.d.ts +1 -2
- package/dist/form/resolve_cell_property.js +1 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/form/resolve_form_properties.d.ts +2 -2
- package/dist/form/resolve_form_properties.js +1 -1
- package/dist/form/resolve_form_properties.js.map +1 -1
- package/dist/form/useClearRestoreValue.d.ts +1 -1
- package/dist/form/useClearRestoreValue.js.map +1 -1
- package/dist/form/validation.d.ts +2 -2
- package/dist/form/validation.js +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hooks/navigation/compose_collections.d.ts +59 -0
- package/dist/hooks/navigation/compose_collections.js +48 -0
- package/dist/hooks/navigation/compose_collections.js.map +1 -0
- package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
- package/dist/hooks/navigation/compose_collections_input.js +17 -0
- package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
- package/dist/hooks/navigation/registered_collection.d.ts +15 -0
- package/dist/hooks/navigation/registered_collection.js +20 -0
- package/dist/hooks/navigation/registered_collection.js.map +1 -0
- package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
- package/dist/hooks/navigation/ui_preferences.js +179 -0
- package/dist/hooks/navigation/ui_preferences.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
- package/dist/hooks/navigation/useAsyncResolver.js +9 -3
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
- package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.js +1 -2
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
- package/dist/hooks/navigation/usePanelTables.js +33 -0
- package/dist/hooks/navigation/usePanelTables.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
- package/dist/hooks/navigation/useResolvedCollections.js +3 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
- package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
- package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
- package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
- package/dist/hooks/navigation/utils.js +1 -1
- package/dist/hooks/navigation/utils.js.map +1 -1
- package/dist/hooks/useAdminContext.d.ts +1 -2
- package/dist/hooks/useAdminContext.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.d.ts +1 -2
- package/dist/hooks/useBuildSidePanel.js +2 -1
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useChildViewSource.d.ts +1 -1
- package/dist/hooks/useChildViewSource.js +1 -1
- package/dist/hooks/useChildViewSource.js.map +1 -1
- package/dist/hooks/useEntityDisplay.d.ts +1 -2
- package/dist/hooks/useEntityDisplay.js +1 -1
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
- package/dist/hooks/useHistory.js +1 -1
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/hooks/useRecordActions.d.ts +1 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useReferencePaths.d.ts +21 -7
- package/dist/hooks/useReferencePaths.js +23 -6
- package/dist/hooks/useReferencePaths.js.map +1 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useResolvedNavigationFrom.js +1 -1
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +8 -2
- package/dist/mcp_view/app_modules.d.ts +2 -2
- package/dist/mcp_view/app_modules.js +4 -4
- package/dist/mcp_view/app_modules.js.map +1 -1
- package/dist/mcp_view/index.d.ts +16 -19
- package/dist/mcp_view/index.js +43 -62
- package/dist/mcp_view/index.js.map +1 -1
- package/dist/mcp_view/payload.d.ts +54 -18
- package/dist/mcp_view/payload.js +49 -24
- package/dist/mcp_view/payload.js.map +1 -1
- package/dist/mcp_view/screen.js +11 -11
- package/dist/mcp_view/screen.js.map +1 -1
- package/dist/mcp_view/tool_driver.d.ts +5 -34
- package/dist/mcp_view/tool_driver.js +17 -16
- package/dist/mcp_view/tool_driver.js.map +1 -1
- package/dist/mcp_view/write_review.d.ts +1 -2
- package/dist/mcp_view/write_review.js +1 -1
- package/dist/mcp_view/write_review.js.map +1 -1
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreview.js +4 -3
- package/dist/preview/PropertyPreview.js.map +1 -1
- package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
- package/dist/preview/components/BooleanPreview.d.ts +1 -1
- package/dist/preview/components/BooleanPreview.js.map +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.js +1 -1
- package/dist/preview/components/EnumValuesChip.js.map +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.js.map +1 -1
- package/dist/preview/components/RelationPreview.d.ts +1 -1
- package/dist/preview/components/RelationPreview.js.map +1 -1
- package/dist/preview/components/StorageThumbnail.js +2 -1
- package/dist/preview/components/StorageThumbnail.js.map +1 -1
- package/dist/preview/components/UserPreview.d.ts +1 -1
- package/dist/preview/components/UserPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
- package/dist/preview/util.d.ts +1 -1
- package/dist/preview/util.js.map +1 -1
- package/dist/routes/RebaseRoute.js +2 -2
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/saved_apps/SavedAppsView.d.ts +1 -1
- package/dist/saved_apps/SavedAppsView.js +1 -1
- package/dist/saved_apps/SavedAppsView.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +1 -1
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/resolve_selection.d.ts +3 -3
- package/dist/selection/resolve_selection.js +3 -2
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/tables/apply_customization.d.ts +65 -0
- package/dist/tables/apply_customization.js +644 -0
- package/dist/tables/apply_customization.js.map +1 -0
- package/dist/tables/column_property.d.ts +64 -0
- package/dist/tables/column_property.js +549 -0
- package/dist/tables/column_property.js.map +1 -0
- package/dist/tables/customize_table.d.ts +39 -0
- package/dist/tables/customize_table.js +247 -0
- package/dist/tables/customize_table.js.map +1 -0
- package/dist/tables/index.d.ts +12 -0
- package/dist/tables/labels.d.ts +18 -0
- package/dist/tables/labels.js +18 -0
- package/dist/tables/labels.js.map +1 -0
- package/dist/tables/project_table.d.ts +79 -0
- package/dist/tables/project_table.js +148 -0
- package/dist/tables/project_table.js.map +1 -0
- package/dist/tables/relations.d.ts +47 -0
- package/dist/tables/relations.js +112 -0
- package/dist/tables/relations.js.map +1 -0
- package/dist/tables/rls.d.ts +39 -0
- package/dist/tables/rls.js +111 -0
- package/dist/tables/rls.js.map +1 -0
- package/dist/tables/update_record.d.ts +32 -0
- package/dist/tables/update_record.js +40 -0
- package/dist/tables/update_record.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
- package/dist/types/fields.d.ts +2 -2
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/entity_pages.d.ts +2 -1
- package/dist/util/entity_pages.js.map +1 -1
- package/dist/util/find_entities_by_ids.d.ts +2 -2
- package/dist/util/find_entities_by_ids.js +1 -1
- package/dist/util/find_entities_by_ids.js.map +1 -1
- package/dist/util/format_collection_date.d.ts +1 -1
- package/dist/util/format_collection_date.js.map +1 -1
- package/dist/util/identity.d.ts +8 -0
- package/dist/util/identity.js +16 -0
- package/dist/util/identity.js.map +1 -0
- package/dist/util/navigation_utils.js +1 -1
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/previews.js +1 -1
- package/dist/util/previews.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +1 -1
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/dist/util/property_utils.d.ts +1 -3
- package/dist/util/property_utils.js +1 -1
- package/dist/util/property_utils.js.map +1 -1
- package/dist/util/relations.d.ts +18 -0
- package/dist/util/relations.js +32 -0
- package/dist/util/relations.js.map +1 -0
- package/package.json +12 -10
- package/recipes/README.md +4 -4
- package/recipes/my-preferences.tsx +34 -26
- package/recipes/site-settings.tsx +34 -27
- package/dist/collection_editor/collection_wire.d.ts +0 -13
- package/dist/collection_editor/collection_wire.js +0 -49
- package/dist/collection_editor/collection_wire.js.map +0 -1
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
- package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuildSidePanel.js","names":[],"sources":["../../src/hooks/useBuildSidePanel.tsx"],"sourcesContent":["\nimport type { Property } from \"@rebasepro/types\";\nimport { hasEntityId, warnDeprecated } from \"@rebasepro/common\";\nimport type { CustomizationController, SidePanelBindingProps, SideDialogPanelProps, SideDialogsController, SidePanelController, UrlController, NavigationStateController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { useCallback, useEffect, useRef, useMemo } from \"react\";\nimport { CollectionRegistryController } from \"@rebasepro/types\";\nimport { AuthController } from \"@rebasepro/cms-types\";\nimport { useLocation } from \"react-router\";\nimport { NavigationViewInternal } from \"@rebasepro/app\";\nimport { getNavigationEntriesFromPath, removeInitialAndTrailingSlashes, removeTrailingSlash, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport { CONTAINER_FULL_WIDTH, SIDE_PANEL_DEFAULT_WIDTH } from \"@rebasepro/app\";\nimport { useCustomizationController, useLargeLayout, useComponentOverride, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { JSON_TAB_VALUE, HISTORY_TAB_VALUE } from \"../util/view_constants\";\nimport React, { Suspense } from \"react\";\nimport { CircularProgressCenter } from \"@rebasepro/ui\";\n// Lazy: this hook runs on every page (the side-panel provider is mounted by\n// RebaseNavigation), and the panel's form stack is not needed until one opens.\nimport { LazySidePanelBinding as SidePanelBinding } from \"../components/lazy_record_views\";\n\n/**\n * Thin wrapper that resolves the Entity.SidePanel component override.\n * Because the JSX is created inside `propsToSidePanel` (a plain function,\n * not a React component), we need this wrapper so the hook is called at the\n * top level of a React component per the Rules of Hooks.\n */\nfunction ResolvedSidePanelBindingInner(props: SidePanelBindingProps) {\n const Resolved = useComponentOverride<SidePanelBindingProps>(\"Entity.SidePanel\", SidePanelBinding);\n return <Suspense fallback={<CircularProgressCenter/>}>\n <Resolved {...props}/>\n </Suspense>;\n}\n\nfunction ResolvedSidePanelBinding(props: SidePanelBindingProps) {\n if (props.collection) {\n return (\n <CollectionScopeProvider collection={props.collection}>\n <ResolvedSidePanelBindingInner {...props}/>\n </CollectionScopeProvider>\n );\n }\n return <ResolvedSidePanelBindingInner {...props}/>;\n}\n\nconst NEW_URL_HASH = \"new_side\";\nconst SIDE_URL_HASH = \"side\";\n\n/**\n * How wide the side panel opens.\n *\n * One width for the whole panel, whatever tab is showing. It used to depend on\n * the selected tab — the form got one width and a subcollection or custom view\n * got `calc(55vw + 768px)` — so the panel physically resized under the cursor\n * every time you switched tabs. And the \"form\" width was derived from how\n * deeply nested the collection's *properties* were, which is not a thing anyone\n * can predict from looking at the panel.\n *\n * Now: `width` prop, then the collection's `sideDialogWidth`, then a default\n * sized for the content the panel actually has to hold — the form column plus\n * its metadata rail — capped so it never eats the whole window.\n */\nexport function getEntityViewWidth(props: SidePanelBindingProps<any>, small: boolean, customizationController: CustomizationController): string {\n if (small) return CONTAINER_FULL_WIDTH;\n\n if (props.width) {\n return typeof props.width === \"number\" ? `${props.width}px` : props.width;\n }\n if (props.collection?.sideDialogWidth) {\n return typeof props.collection.sideDialogWidth === \"number\"\n ? `${props.collection.sideDialogWidth}px`\n : props.collection.sideDialogWidth;\n }\n return SIDE_PANEL_DEFAULT_WIDTH;\n}\n\n/**\n * Accept the names `open` / `replace` took in 0.28: `entityId` for `id`, and\n * `onUpdate` for `onSaved`. Untyped callers still passing them would\n * otherwise open a blank \"new record\" form for a record that exists (and\n * duplicate it on save), and never hear about the save.\n *\n * `onUpdate` used to receive the saved entity; it now gets `{ entity }` built\n * from the saved row, after any `onSaved`.\n */\nexport function normalizeDeprecatedSidePanelProps<M extends Record<string, unknown>>(props: SidePanelBindingProps<M>): SidePanelBindingProps<M> {\n const { entityId, onUpdate, ...current } = props;\n let result: SidePanelBindingProps<M> = current;\n if (entityId !== undefined) {\n warnDeprecated(\"SidePanelBindingProps.entityId\",\n \"`entityId` in `useSidePanel().open()` / `replace()` is deprecated; use `id` instead.\");\n if (current.id === undefined) result = { ...result, id: entityId };\n }\n if (onUpdate) {\n warnDeprecated(\"SidePanelBindingProps.onUpdate\",\n \"`onUpdate` in `useSidePanel().open()` / `replace()` is deprecated; use `onSaved` instead.\");\n const onSaved = current.onSaved;\n const path = current.path;\n result = {\n ...result,\n onSaved: (params) => {\n onSaved?.(params);\n onUpdate({ entity: { id: params.id, path, values: params.row } });\n }\n };\n }\n return result;\n}\n\nexport const useBuildSidePanel = (collectionRegistryController: CollectionRegistryController,\n urlController: UrlController,\n navigationStateController: NavigationStateController,\n sideDialogsController: SideDialogsController,\n authController: AuthController\n): SidePanelController => {\n\n const location = useLocation();\n const initialised = useRef<boolean>(false);\n const currentPanelKeysRef = useRef<string[]>([]);\n const customizationController = useCustomizationController();\n\n const smallLayout = !useLargeLayout();\n\n useEffect(() => {\n\n const newFlag = location.hash === `#${NEW_URL_HASH}`;\n const sideFlag = location.hash === `#${SIDE_URL_HASH}`;\n\n if (!navigationStateController.loading) {\n if ((newFlag || sideFlag) && urlController.isUrlCollectionPath(location.pathname)) {\n const entityOrCollectionPath = urlController.urlPathToDataPath(location.pathname);\n const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, collectionRegistryController.collections ?? [], newFlag);\n for (let i = 0; i < panelsFromUrl.length; i++) {\n const props = panelsFromUrl[i];\n if (i === 0)\n sideDialogsController.replace(propsToSidePanel(props, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController));\n else\n sideDialogsController.open(propsToSidePanel(props, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController))\n }\n }\n initialised.current = true;\n }\n }, [navigationStateController.loading]);\n\n // sync panels if URL changes with #side\n // Use a ref for currentPanelKeys so this effect only fires on URL changes,\n // not on panel state changes. This prevents a race condition with React Router 7\n // where close() clears panels before the URL updates, causing the effect to\n // re-open the panel from the stale #side hash.\n currentPanelKeysRef.current = sideDialogsController.sidePanels.map(p => p.key);\n useEffect(() => {\n if (initialised.current) {\n const sideFlag = location.hash === `#${SIDE_URL_HASH}`;\n if (sideFlag) {\n const currentKeys = currentPanelKeysRef.current;\n const entityOrCollectionPath = urlController.urlPathToDataPath(location.pathname);\n const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, collectionRegistryController.collections ?? [], false);\n // if we have more panels than determined by the url, we ignore the url. We might have references open\n if (panelsFromUrl.length <= currentKeys.length) {\n return;\n }\n const lastPanel = panelsFromUrl[panelsFromUrl.length - 1];\n const panelProps = propsToSidePanel(lastPanel, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController);\n const lastCurrentPanel = currentKeys.length > 0 ? currentKeys[currentKeys.length - 1] : undefined;\n if (!lastCurrentPanel || lastCurrentPanel !== panelProps.key) {\n sideDialogsController.replace(panelProps);\n }\n }\n }\n }, [location.pathname, location.hash]);\n\n // update side panels to match browser size\n // Only update panel widths on layout change — don't recreate components.\n // Recreating components would unmount/remount SidePanelBinding, losing\n // scroll position, unsaved form state, and triggering unnecessary data fetches.\n useEffect(() => {\n const updatedSidePanels = sideDialogsController.sidePanels.map(sidePanelProps => {\n if (sidePanelProps.additional) {\n const entityProps = sidePanelProps.additional as SidePanelBindingProps;\n const newWidth = getEntityViewWidth(entityProps, smallLayout, customizationController);\n if (sidePanelProps.width !== newWidth) {\n return { ...sidePanelProps,\nwidth: newWidth };\n }\n }\n return sidePanelProps;\n });\n sideDialogsController.setSidePanels(updatedSidePanels);\n }, [smallLayout]);\n\n const close = useCallback(() => {\n sideDialogsController.close();\n }, [sideDialogsController]);\n\n // Where no CMS route serves the page, a panel is an overlay and nothing\n // more: it writes no URL (one would lead nowhere) and offers no way to a\n // full-screen route that does not exist.\n const routesMounted = urlController.routesMounted !== false;\n\n const open = useCallback((propsGiven: SidePanelBindingProps<any>) => {\n const propsIn = normalizeDeprecatedSidePanelProps(propsGiven);\n const props = routesMounted ? propsIn : { ...propsIn, updateUrl: false, allowFullScreen: false };\n\n if (props.copy && !hasEntityId(props.id)) {\n throw Error(\"To open a copy, pass the id of the record to copy\");\n }\n\n const defaultSelectedView = resolveDefaultSelectedView(\n props.collection ? props.collection.defaultSelectedView : undefined,\n {\n status: props.copy ? \"copy\" : (hasEntityId(props.id) ? \"existing\" : \"new\"),\n id: props.id\n }\n );\n\n sideDialogsController.open(\n propsToSidePanel({\n ...props,\n selectedTab: props.selectedTab ?? defaultSelectedView\n },\n urlController.buildUrlCollectionPath,\n urlController.resolveDatabasePathsFrom,\n smallLayout,\n customizationController,\n authController\n ));\n\n }, [sideDialogsController, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, authController.user, routesMounted]);\n\n const replace = useCallback((propsGiven: SidePanelBindingProps<any>) => {\n const propsIn = normalizeDeprecatedSidePanelProps(propsGiven);\n const props = routesMounted ? propsIn : { ...propsIn, updateUrl: false, allowFullScreen: false };\n\n if (props.copy && !hasEntityId(props.id)) {\n throw Error(\"To open a copy, pass the id of the record to copy\");\n }\n\n sideDialogsController.replace(propsToSidePanel(props, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController));\n\n }, [urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, sideDialogsController, smallLayout, authController.user, routesMounted]);\n\n return useMemo(() => ({\n close,\n open,\n replace\n }), [close, open, replace]);\n};\n\nexport function buildSidePanelsFromUrl(path: string, collections: AdminCollection[], newFlag: boolean): SidePanelBindingProps<any>[] {\n\n const navigationViewsForPath: NavigationViewInternal<any>[] = getNavigationEntriesFromPath({\n path,\n collections\n });\n\n let sidePanel: SidePanelBindingProps<any> | undefined = undefined;\n let lastCollectionPath = \"\";\n let lastCollectionId: string | undefined = undefined;\n for (let i = 0; i < navigationViewsForPath.length; i++) {\n const navigationEntry = navigationViewsForPath[i];\n\n if (navigationEntry.type === \"collection\") {\n lastCollectionPath = navigationEntry.slug;\n lastCollectionId = navigationEntry.collection.slug;\n }\n\n const previousEntry = navigationViewsForPath[i - 1];\n if (navigationEntry.type === \"entity\") {\n sidePanel = {\n path: navigationEntry.slug,\n id: navigationEntry.entityId,\n copy: false,\n collection: navigationEntry.parentCollection,\n width: navigationEntry.parentCollection?.sideDialogWidth\n };\n } else if (navigationEntry.type === \"custom_view\") {\n if (previousEntry?.type === \"entity\") {\n if (sidePanel)\n sidePanel.selectedTab = navigationEntry.view.key;\n }\n } else if (navigationEntry.type === \"collection\") {\n if (previousEntry?.type === \"entity\") {\n if (sidePanel)\n sidePanel.selectedTab = navigationEntry.collection.slug;\n }\n }\n\n }\n\n // `edit` is not a registered view, so the navigation parser skips it. Pick it\n // up from the raw path so that reloading an edit URL reopens the edit form\n // rather than silently dropping the user back on the detail view.\n if (sidePanel && !sidePanel.selectedTab && removeTrailingSlash(path).endsWith(\"/edit\")) {\n sidePanel.selectedTab = \"edit\";\n }\n\n // When the URL doesn't contain a tab segment but the collection has a\n // defaultSelectedView, resolve it so the panel opens with the correct\n // width and the URL is updated on the next replace() cycle.\n if (sidePanel && !sidePanel.selectedTab && sidePanel.collection) {\n const defaultView = resolveDefaultSelectedView(\n sidePanel.collection.defaultSelectedView,\n {\n status: sidePanel.copy ? \"copy\" : (hasEntityId(sidePanel.id) ? \"existing\" : \"new\"),\n id: sidePanel.id\n }\n );\n if (defaultView) {\n sidePanel.selectedTab = defaultView;\n }\n }\n\n if (newFlag) {\n sidePanel = {\n path: lastCollectionPath,\n copy: false\n }\n }\n\n return sidePanel ? [sidePanel] : [];\n}\n\nconst propsToSidePanel = (props: SidePanelBindingProps,\n buildUrlCollectionPath: (path: string) => string,\n resolveIdsFrom: (pathWithAliases: string) => string,\n smallLayout: boolean,\n customizationController: CustomizationController,\n authController: AuthController\n): SideDialogPanelProps => {\n\n const collectionPath = removeInitialAndTrailingSlashes(props.path);\n\n // The list's state — search, filters, sort, view mode — read from the\n // address bar at the moment the panel opens. Not react-router's\n // `location.search`: the list writes its state with `replaceState`, which\n // the router does not observe, so that value is whatever the view mounted\n // with, and the list reads a panel URL built from it back as its state.\n const locationSearch = typeof window !== \"undefined\" ? window.location.search : \"\";\n\n // When updateUrl is explicitly false, don't generate URL paths — the dialog\n // opens as an overlay without affecting the browser URL / router.\n const shouldUpdateUrl = props.updateUrl !== false;\n\n // `buildUrlCollectionPath` encodes every segment of the data path it is\n // given, the record id among them, so the query and the hash go after it.\n const urlPath = shouldUpdateUrl\n ? (hasEntityId(props.id)\n ? `${buildUrlCollectionPath(`${collectionPath}/${props.id}${props.selectedTab ? \"/\" + props.selectedTab : \"\"}`)}${locationSearch}#${SIDE_URL_HASH}`\n : `${buildUrlCollectionPath(collectionPath)}${locationSearch}#${NEW_URL_HASH}`)\n : undefined;\n\n const parentUrlPath = shouldUpdateUrl\n ? buildUrlCollectionPath(collectionPath)\n : undefined;\n\n const resolvedPanelProps: SidePanelBindingProps<any> = {\n ...props,\n formProps: props.formProps\n };\n\n const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController);\n return {\n key: `${props.path}/${props.id}`,\n component: <ResolvedSidePanelBinding {...resolvedPanelProps}/>,\n urlPath: urlPath,\n parentUrlPath: parentUrlPath,\n width: entityViewWidth,\n onClose: props.onClose,\n additional: resolvedPanelProps\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,SAAS,8BAA8B,OAA8B;CACjE,MAAM,WAAW,qBAA4C,oBAAoB,oBAAgB;CACjG,OAAO,oBAAC,UAAD;EAAU,UAAU,oBAAC,wBAAD,CAAwB,CAAA;YAC/C,oBAAC,UAAD,EAAU,GAAI,MAAO,CAAA;CACf,CAAA;AACd;AAEA,SAAS,yBAAyB,OAA8B;CAC5D,IAAI,MAAM,YACN,OACI,oBAAC,yBAAD;EAAyB,YAAY,MAAM;YACvC,oBAAC,+BAAD,EAA+B,GAAI,MAAO,CAAA;CACrB,CAAA;CAGjC,OAAO,oBAAC,+BAAD,EAA+B,GAAI,MAAO,CAAA;AACrD;AAEA,IAAM,eAAe;AACrB,IAAM,gBAAgB;;;;;;;;;;;;;;;AAgBtB,SAAgB,mBAAmB,OAAmC,OAAgB,yBAA0D;CAC5I,IAAI,OAAO,OAAO;CAElB,IAAI,MAAM,OACN,OAAO,OAAO,MAAM,UAAU,WAAW,GAAG,MAAM,MAAM,MAAM,MAAM;CAExE,IAAI,MAAM,YAAY,iBAClB,OAAO,OAAO,MAAM,WAAW,oBAAoB,WAC7C,GAAG,MAAM,WAAW,gBAAgB,MACpC,MAAM,WAAW;CAE3B,OAAO;AACX;;;;;;;;;;AAWA,SAAgB,kCAAqE,OAA2D;CAC5I,MAAM,EAAE,UAAU,UAAU,GAAG,YAAY;CAC3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AM,qBAAiD;EACnD,GAAG;EACH,WAAW,MAAM;CACrB;CAEA,MAAM,kBAAkB,mBAAmB,OAAO,aAAa,uBAAuB;CACtF,OAAO;EACH,KAAK,GAAG,MAAM,KAAK,GAAG,MAAM;EAC5B,WAAW,oBAAC,0BAAD,EAA0B,GAAI,mBAAoB,CAAA;EACpD;EACM;EACf,OAAO;EACP,SAAS,MAAM;EACf,YAAY;CAChB;AACJ"}
|
|
1
|
+
{"version":3,"file":"useBuildSidePanel.js","names":[],"sources":["../../src/hooks/useBuildSidePanel.tsx"],"sourcesContent":["\nimport { warnDeprecated } from \"@rebasepro/common\";\nimport { hasEntityId } from \"../util/identity\";\nimport type { CustomizationController, SidePanelBindingProps, SideDialogPanelProps, SideDialogsController, SidePanelController, UrlController, NavigationStateController, AdminCollection, Property } from \"@rebasepro/cms-types\";\nimport { useCallback, useEffect, useRef, useMemo } from \"react\";\nimport { AuthController, CollectionRegistryController } from \"@rebasepro/cms-types\";\nimport { useLocation } from \"react-router\";\nimport { NavigationViewInternal } from \"@rebasepro/app\";\nimport { getNavigationEntriesFromPath, removeInitialAndTrailingSlashes, removeTrailingSlash, resolveDefaultSelectedView } from \"@rebasepro/app\";\nimport { resolvedSelectedEntityView } from \"../util/resolutions\";\nimport { CONTAINER_FULL_WIDTH, SIDE_PANEL_DEFAULT_WIDTH } from \"@rebasepro/app\";\nimport { useCustomizationController, useLargeLayout, useComponentOverride, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { JSON_TAB_VALUE, HISTORY_TAB_VALUE } from \"../util/view_constants\";\nimport React, { Suspense } from \"react\";\nimport { CircularProgressCenter } from \"@rebasepro/ui\";\n// Lazy: this hook runs on every page (the side-panel provider is mounted by\n// RebaseNavigation), and the panel's form stack is not needed until one opens.\nimport { LazySidePanelBinding as SidePanelBinding } from \"../components/lazy_record_views\";\n\n/**\n * Thin wrapper that resolves the Entity.SidePanel component override.\n * Because the JSX is created inside `propsToSidePanel` (a plain function,\n * not a React component), we need this wrapper so the hook is called at the\n * top level of a React component per the Rules of Hooks.\n */\nfunction ResolvedSidePanelBindingInner(props: SidePanelBindingProps) {\n const Resolved = useComponentOverride<SidePanelBindingProps>(\"Entity.SidePanel\", SidePanelBinding);\n return <Suspense fallback={<CircularProgressCenter/>}>\n <Resolved {...props}/>\n </Suspense>;\n}\n\nfunction ResolvedSidePanelBinding(props: SidePanelBindingProps) {\n if (props.collection) {\n return (\n <CollectionScopeProvider collection={props.collection}>\n <ResolvedSidePanelBindingInner {...props}/>\n </CollectionScopeProvider>\n );\n }\n return <ResolvedSidePanelBindingInner {...props}/>;\n}\n\nconst NEW_URL_HASH = \"new_side\";\nconst SIDE_URL_HASH = \"side\";\n\n/**\n * How wide the side panel opens.\n *\n * One width for the whole panel, whatever tab is showing. It used to depend on\n * the selected tab — the form got one width and a subcollection or custom view\n * got `calc(55vw + 768px)` — so the panel physically resized under the cursor\n * every time you switched tabs. And the \"form\" width was derived from how\n * deeply nested the collection's *properties* were, which is not a thing anyone\n * can predict from looking at the panel.\n *\n * Now: `width` prop, then the collection's `sideDialogWidth`, then a default\n * sized for the content the panel actually has to hold — the form column plus\n * its metadata rail — capped so it never eats the whole window.\n */\nexport function getEntityViewWidth(props: SidePanelBindingProps<any>, small: boolean, customizationController: CustomizationController): string {\n if (small) return CONTAINER_FULL_WIDTH;\n\n if (props.width) {\n return typeof props.width === \"number\" ? `${props.width}px` : props.width;\n }\n if (props.collection?.sideDialogWidth) {\n return typeof props.collection.sideDialogWidth === \"number\"\n ? `${props.collection.sideDialogWidth}px`\n : props.collection.sideDialogWidth;\n }\n return SIDE_PANEL_DEFAULT_WIDTH;\n}\n\n/**\n * Accept the names `open` / `replace` took in 0.28: `entityId` for `id`, and\n * `onUpdate` for `onSaved`. Untyped callers still passing them would\n * otherwise open a blank \"new record\" form for a record that exists (and\n * duplicate it on save), and never hear about the save.\n *\n * `onUpdate` used to receive the saved entity; it now gets `{ entity }` built\n * from the saved row, after any `onSaved`.\n */\nexport function normalizeDeprecatedSidePanelProps<M extends Record<string, unknown>>(props: SidePanelBindingProps<M>): SidePanelBindingProps<M> {\n const { entityId, onUpdate, ...current } = props;\n let result: SidePanelBindingProps<M> = current;\n if (entityId !== undefined) {\n warnDeprecated(\"SidePanelBindingProps.entityId\",\n \"`entityId` in `useSidePanel().open()` / `replace()` is deprecated; use `id` instead.\");\n if (current.id === undefined) result = { ...result, id: entityId };\n }\n if (onUpdate) {\n warnDeprecated(\"SidePanelBindingProps.onUpdate\",\n \"`onUpdate` in `useSidePanel().open()` / `replace()` is deprecated; use `onSaved` instead.\");\n const onSaved = current.onSaved;\n const path = current.path;\n result = {\n ...result,\n onSaved: (params) => {\n onSaved?.(params);\n onUpdate({ entity: { id: params.id, path, values: params.row } });\n }\n };\n }\n return result;\n}\n\nexport const useBuildSidePanel = (collectionRegistryController: CollectionRegistryController,\n urlController: UrlController,\n navigationStateController: NavigationStateController,\n sideDialogsController: SideDialogsController,\n authController: AuthController\n): SidePanelController => {\n\n const location = useLocation();\n const initialised = useRef<boolean>(false);\n const currentPanelKeysRef = useRef<string[]>([]);\n const customizationController = useCustomizationController();\n\n const smallLayout = !useLargeLayout();\n\n useEffect(() => {\n\n const newFlag = location.hash === `#${NEW_URL_HASH}`;\n const sideFlag = location.hash === `#${SIDE_URL_HASH}`;\n\n if (!navigationStateController.loading) {\n if ((newFlag || sideFlag) && urlController.isUrlCollectionPath(location.pathname)) {\n const entityOrCollectionPath = urlController.urlPathToDataPath(location.pathname);\n const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, collectionRegistryController.collections ?? [], newFlag);\n for (let i = 0; i < panelsFromUrl.length; i++) {\n const props = panelsFromUrl[i];\n if (i === 0)\n sideDialogsController.replace(propsToSidePanel(props, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController));\n else\n sideDialogsController.open(propsToSidePanel(props, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController))\n }\n }\n initialised.current = true;\n }\n }, [navigationStateController.loading]);\n\n // sync panels if URL changes with #side\n // Use a ref for currentPanelKeys so this effect only fires on URL changes,\n // not on panel state changes. This prevents a race condition with React Router 7\n // where close() clears panels before the URL updates, causing the effect to\n // re-open the panel from the stale #side hash.\n currentPanelKeysRef.current = sideDialogsController.sidePanels.map(p => p.key);\n useEffect(() => {\n if (initialised.current) {\n const sideFlag = location.hash === `#${SIDE_URL_HASH}`;\n if (sideFlag) {\n const currentKeys = currentPanelKeysRef.current;\n const entityOrCollectionPath = urlController.urlPathToDataPath(location.pathname);\n const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, collectionRegistryController.collections ?? [], false);\n // if we have more panels than determined by the url, we ignore the url. We might have references open\n if (panelsFromUrl.length <= currentKeys.length) {\n return;\n }\n const lastPanel = panelsFromUrl[panelsFromUrl.length - 1];\n const panelProps = propsToSidePanel(lastPanel, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController);\n const lastCurrentPanel = currentKeys.length > 0 ? currentKeys[currentKeys.length - 1] : undefined;\n if (!lastCurrentPanel || lastCurrentPanel !== panelProps.key) {\n sideDialogsController.replace(panelProps);\n }\n }\n }\n }, [location.pathname, location.hash]);\n\n // update side panels to match browser size\n // Only update panel widths on layout change — don't recreate components.\n // Recreating components would unmount/remount SidePanelBinding, losing\n // scroll position, unsaved form state, and triggering unnecessary data fetches.\n useEffect(() => {\n const updatedSidePanels = sideDialogsController.sidePanels.map(sidePanelProps => {\n if (sidePanelProps.additional) {\n const entityProps = sidePanelProps.additional as SidePanelBindingProps;\n const newWidth = getEntityViewWidth(entityProps, smallLayout, customizationController);\n if (sidePanelProps.width !== newWidth) {\n return { ...sidePanelProps,\nwidth: newWidth };\n }\n }\n return sidePanelProps;\n });\n sideDialogsController.setSidePanels(updatedSidePanels);\n }, [smallLayout]);\n\n const close = useCallback(() => {\n sideDialogsController.close();\n }, [sideDialogsController]);\n\n // Where no CMS route serves the page, a panel is an overlay and nothing\n // more: it writes no URL (one would lead nowhere) and offers no way to a\n // full-screen route that does not exist.\n const routesMounted = urlController.routesMounted !== false;\n\n const open = useCallback((propsGiven: SidePanelBindingProps<any>) => {\n const propsIn = normalizeDeprecatedSidePanelProps(propsGiven);\n const props = routesMounted ? propsIn : { ...propsIn, updateUrl: false, allowFullScreen: false };\n\n if (props.copy && !hasEntityId(props.id)) {\n throw Error(\"To open a copy, pass the id of the record to copy\");\n }\n\n const defaultSelectedView = resolveDefaultSelectedView(\n props.collection ? props.collection.defaultSelectedView : undefined,\n {\n status: props.copy ? \"copy\" : (hasEntityId(props.id) ? \"existing\" : \"new\"),\n id: props.id\n }\n );\n\n sideDialogsController.open(\n propsToSidePanel({\n ...props,\n selectedTab: props.selectedTab ?? defaultSelectedView\n },\n urlController.buildUrlCollectionPath,\n urlController.resolveDatabasePathsFrom,\n smallLayout,\n customizationController,\n authController\n ));\n\n }, [sideDialogsController, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, authController.user, routesMounted]);\n\n const replace = useCallback((propsGiven: SidePanelBindingProps<any>) => {\n const propsIn = normalizeDeprecatedSidePanelProps(propsGiven);\n const props = routesMounted ? propsIn : { ...propsIn, updateUrl: false, allowFullScreen: false };\n\n if (props.copy && !hasEntityId(props.id)) {\n throw Error(\"To open a copy, pass the id of the record to copy\");\n }\n\n sideDialogsController.replace(propsToSidePanel(props, urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController));\n\n }, [urlController.buildUrlCollectionPath, urlController.resolveDatabasePathsFrom, sideDialogsController, smallLayout, authController.user, routesMounted]);\n\n return useMemo(() => ({\n close,\n open,\n replace\n }), [close, open, replace]);\n};\n\nexport function buildSidePanelsFromUrl(path: string, collections: AdminCollection[], newFlag: boolean): SidePanelBindingProps<any>[] {\n\n const navigationViewsForPath: NavigationViewInternal<any>[] = getNavigationEntriesFromPath({\n path,\n collections\n });\n\n let sidePanel: SidePanelBindingProps<any> | undefined = undefined;\n let lastCollectionPath = \"\";\n let lastCollectionId: string | undefined = undefined;\n for (let i = 0; i < navigationViewsForPath.length; i++) {\n const navigationEntry = navigationViewsForPath[i];\n\n if (navigationEntry.type === \"collection\") {\n lastCollectionPath = navigationEntry.slug;\n lastCollectionId = navigationEntry.collection.slug;\n }\n\n const previousEntry = navigationViewsForPath[i - 1];\n if (navigationEntry.type === \"entity\") {\n sidePanel = {\n path: navigationEntry.slug,\n id: navigationEntry.entityId,\n copy: false,\n collection: navigationEntry.parentCollection,\n width: navigationEntry.parentCollection?.sideDialogWidth\n };\n } else if (navigationEntry.type === \"custom_view\") {\n if (previousEntry?.type === \"entity\") {\n if (sidePanel)\n sidePanel.selectedTab = navigationEntry.view.key;\n }\n } else if (navigationEntry.type === \"collection\") {\n if (previousEntry?.type === \"entity\") {\n if (sidePanel)\n sidePanel.selectedTab = navigationEntry.collection.slug;\n }\n }\n\n }\n\n // `edit` is not a registered view, so the navigation parser skips it. Pick it\n // up from the raw path so that reloading an edit URL reopens the edit form\n // rather than silently dropping the user back on the detail view.\n if (sidePanel && !sidePanel.selectedTab && removeTrailingSlash(path).endsWith(\"/edit\")) {\n sidePanel.selectedTab = \"edit\";\n }\n\n // When the URL doesn't contain a tab segment but the collection has a\n // defaultSelectedView, resolve it so the panel opens with the correct\n // width and the URL is updated on the next replace() cycle.\n if (sidePanel && !sidePanel.selectedTab && sidePanel.collection) {\n const defaultView = resolveDefaultSelectedView(\n sidePanel.collection.defaultSelectedView,\n {\n status: sidePanel.copy ? \"copy\" : (hasEntityId(sidePanel.id) ? \"existing\" : \"new\"),\n id: sidePanel.id\n }\n );\n if (defaultView) {\n sidePanel.selectedTab = defaultView;\n }\n }\n\n if (newFlag) {\n sidePanel = {\n path: lastCollectionPath,\n copy: false\n }\n }\n\n return sidePanel ? [sidePanel] : [];\n}\n\nconst propsToSidePanel = (props: SidePanelBindingProps,\n buildUrlCollectionPath: (path: string) => string,\n resolveIdsFrom: (pathWithAliases: string) => string,\n smallLayout: boolean,\n customizationController: CustomizationController,\n authController: AuthController\n): SideDialogPanelProps => {\n\n const collectionPath = removeInitialAndTrailingSlashes(props.path);\n\n // The list's state — search, filters, sort, view mode — read from the\n // address bar at the moment the panel opens. Not react-router's\n // `location.search`: the list writes its state with `replaceState`, which\n // the router does not observe, so that value is whatever the view mounted\n // with, and the list reads a panel URL built from it back as its state.\n const locationSearch = typeof window !== \"undefined\" ? window.location.search : \"\";\n\n // When updateUrl is explicitly false, don't generate URL paths — the dialog\n // opens as an overlay without affecting the browser URL / router.\n const shouldUpdateUrl = props.updateUrl !== false;\n\n // `buildUrlCollectionPath` encodes every segment of the data path it is\n // given, the record id among them, so the query and the hash go after it.\n const urlPath = shouldUpdateUrl\n ? (hasEntityId(props.id)\n ? `${buildUrlCollectionPath(`${collectionPath}/${props.id}${props.selectedTab ? \"/\" + props.selectedTab : \"\"}`)}${locationSearch}#${SIDE_URL_HASH}`\n : `${buildUrlCollectionPath(collectionPath)}${locationSearch}#${NEW_URL_HASH}`)\n : undefined;\n\n const parentUrlPath = shouldUpdateUrl\n ? buildUrlCollectionPath(collectionPath)\n : undefined;\n\n const resolvedPanelProps: SidePanelBindingProps<any> = {\n ...props,\n formProps: props.formProps\n };\n\n const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController);\n return {\n key: `${props.path}/${props.id}`,\n component: <ResolvedSidePanelBinding {...resolvedPanelProps}/>,\n urlPath: urlPath,\n parentUrlPath: parentUrlPath,\n width: entityViewWidth,\n onClose: props.onClose,\n additional: resolvedPanelProps\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyBA,SAAS,8BAA8B,OAA8B;CACjE,MAAM,WAAW,qBAA4C,oBAAoB,oBAAgB;CACjG,OAAO,oBAAC,UAAD;EAAU,UAAU,oBAAC,wBAAD,CAAwB,CAAA;YAC/C,oBAAC,UAAD,EAAU,GAAI,MAAO,CAAA;CACf,CAAA;AACd;AAEA,SAAS,yBAAyB,OAA8B;CAC5D,IA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B,CACJ;EACA,IAAI,aACA,UAAU,cAAc;CAEhC;CAEA,IAAI,SACA,YAAY;EACR,MAAM;EACN,MAAM;CACV;CAGJ,OAAO,YAAY,CAAC,SAAS,IAAI,CAAC;AACtC;AAEA,IAAM,oBAAoB,OACtB,wBACA,gBACA,aACA,yBACA,mBACuB;CAEvB,MAAM,iBAAiB,gCAAgC,MAAM,IAAI;CAOjE,MAAM,iBAAiB,OAAO,WAAW,cAAc,OAAO,SAAS,SAAS;CAIhF,MAAM,kBAAkB,MAAM,cAAc;CAI5C,MAAM,UAAU,kBACT,YAAY,MAAM,EAAE,IACjB,GAAG,uBAAuB,GAAG,eAAe,GAAG,MAAM,KAAK,MAAM,cAAc,MAAM,MAAM,cAAc,IAAI,IAAI,eAAe,GAAG,kBAClI,GAAG,uBAAuB,cAAc,IAAI,eAAe,GAAG,iBAClE,KAAA;CAEN,MAAM,gBAAgB,kBAChB,uBAAuB,cAAc,IACrC,KAAA;CAEN,MAAM,qBAAiD;EACnD,GAAG;EACH,WAAW,MAAM;CACrB;CAEA,MAAM,kBAAkB,mBAAmB,OAAO,aAAa,uBAAuB;CACtF,OAAO;EACH,KAAK,GAAG,MAAM,KAAK,GAAG,MAAM;EAC5B,WAAW,oBAAC,0BAAD,EAA0B,GAAI,mBAAoB,CAAA;EACpD;EACM;EACf,OAAO;EACP,SAAS,MAAM;EACf,YAAY;CAChB;AACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChildViewSource } from "@rebasepro/types";
|
|
1
|
+
import type { ChildViewSource } from "@rebasepro/cms-types";
|
|
2
2
|
/**
|
|
3
3
|
* What kind of list a path addresses: a root collection, a contained
|
|
4
4
|
* subcollection, or a relation — and if a relation, whether the rows are owned
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCollectionRegistryController } from "./navigation/contexts/CollectionRegistryContext.js";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { getEntityChildViews } from "@rebasepro/
|
|
3
|
+
import { getEntityChildViews } from "@rebasepro/cms-types";
|
|
4
4
|
//#region src/hooks/useChildViewSource.ts
|
|
5
5
|
/**
|
|
6
6
|
* What kind of list a path addresses: a root collection, a contained
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChildViewSource.js","names":[],"sources":["../../src/hooks/useChildViewSource.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { ChildViewSource } from \"@rebasepro/types\";\nimport { getEntityChildViews } from \"@rebasepro/
|
|
1
|
+
{"version":3,"file":"useChildViewSource.js","names":[],"sources":["../../src/hooks/useChildViewSource.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { ChildViewSource } from \"@rebasepro/cms-types\";\nimport { getEntityChildViews } from \"@rebasepro/cms-types\";\n\nimport { useCollectionRegistryController } from \"./navigation/contexts/CollectionRegistryContext\";\n\n/**\n * What kind of list a path addresses: a root collection, a contained\n * subcollection, or a relation — and if a relation, whether the rows are owned\n * by the parent or shared through a junction.\n *\n * Derived from the path rather than passed down, because the same question is\n * asked from places a prop does not reach: the collection view's row actions,\n * the entity form's own delete button, a deep link straight into a tab. All\n * three have the path; only one of them was ever handed a descriptor.\n *\n * Returns `undefined` for a root collection path, and for any path whose parent\n * or relation cannot be resolved — callers should read that as \"an ordinary\n * collection\", which is the pre-existing behaviour.\n */\nexport function useChildViewSource(path: string | undefined): ChildViewSource | undefined {\n const collectionRegistry = useCollectionRegistryController();\n\n return useMemo(() => {\n if (!path) return undefined;\n\n const segments = path.split(\"/\").filter(s => s && s !== \"undefined\");\n // `parent/id/child` is the shortest addressable child list.\n if (segments.length < 3) return undefined;\n // ...but three segments are not always a child list: a slug may contain\n // slashes, and `medico/v2.0.0/joints` is one root collection. Only the\n // registry knows where a slug ends, so ask it whether anything sits\n // above the collection this path addresses.\n if (collectionRegistry.getParentCollectionSlugs(path).length === 0) return undefined;\n\n const childKey = segments[segments.length - 1];\n // Drop the child segment and the parent's id: what remains addresses the\n // collection the child hangs off, however deeply nested it is.\n const parentPath = segments.slice(0, -2).join(\"/\");\n\n let parentCollection;\n try {\n parentCollection = collectionRegistry.getCollection(parentPath);\n } catch {\n return undefined;\n }\n if (!parentCollection) return undefined;\n\n return getEntityChildViews(parentCollection).find(view => view.key === childKey)?.source;\n }, [path, collectionRegistry]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,SAAgB,mBAAmB,MAAuD;CACtF,MAAM,qBAAqB,gCAAgC;CAE3D,OAAO,cAAc;EACjB,IAAI,CAAC,MAAM,OAAO,KAAA;EAElB,MAAM,WAAW,KAAK,MAAM,GAAG,CAAC,CAAC,QAAO,MAAK,KAAK,MAAM,WAAW;EAEnE,IAAI,SAAS,SAAS,GAAG,OAAO,KAAA;EAKhC,IAAI,mBAAmB,yBAAyB,IAAI,CAAC,CAAC,WAAW,GAAG,OAAO,KAAA;EAE3E,MAAM,WAAW,SAAS,SAAS,SAAS;EAG5C,MAAM,aAAa,SAAS,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,GAAG;EAEjD,IAAI;EACJ,IAAI;GACA,mBAAmB,mBAAmB,cAAc,UAAU;EAClE,QAAQ;GACJ;EACJ;EACA,IAAI,CAAC,kBAAkB,OAAO,KAAA;EAE9B,OAAO,oBAAoB,gBAAgB,CAAC,CAAC,MAAK,SAAQ,KAAK,QAAQ,QAAQ,CAAC,EAAE;CACtF,GAAG,CAAC,MAAM,kBAAkB,CAAC;AACjC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { AdminCollection, EntityDisplayRole } from "@rebasepro/cms-types";
|
|
2
|
-
import type { Entity, Property } from "@rebasepro/types";
|
|
1
|
+
import type { AdminCollection, EntityDisplayRole, Property, Entity } from "@rebasepro/cms-types";
|
|
3
2
|
import { ENTITY_DISPLAY_ROLES } from "@rebasepro/cms-types";
|
|
4
3
|
import { type EntityDisplayCache } from "@rebasepro/app";
|
|
5
4
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getEntityTitlePropertyKeyForEntity, isUserSelectProperty, resolveTitleToString } from "../util/previews.js";
|
|
2
2
|
import { getUserLabel, useResolvedUser } from "./useResolvedUsers.js";
|
|
3
3
|
import { useEffect, useMemo, useSyncExternalStore } from "react";
|
|
4
|
+
import "@rebasepro/cms-types";
|
|
4
5
|
import { entityDisplayKey, getDisplayPropertyKey, getDisplayResolver, getPropertyInPath, getSharedEntityDisplayCache, rowOfEntity, useRebaseContext } from "@rebasepro/app";
|
|
5
6
|
import { getValueInPath } from "@rebasepro/utils";
|
|
6
|
-
import "@rebasepro/cms-types";
|
|
7
7
|
//#region src/hooks/useEntityDisplay.tsx
|
|
8
8
|
/**
|
|
9
9
|
* The store behind {@link useEntityDisplay}, for invalidating after a write.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntityDisplay.js","names":[],"sources":["../../src/hooks/useEntityDisplay.tsx"],"sourcesContent":["import type { AdminCollection, EntityDisplayRole } from \"@rebasepro/cms-types\";\nimport type { Entity, Property } from \"@rebasepro/types\";\nimport { ENTITY_DISPLAY_ROLES } from \"@rebasepro/cms-types\";\nimport { useEffect, useMemo, useSyncExternalStore } from \"react\";\nimport {\n type EntityDisplayCache,\n entityDisplayKey,\n getSharedEntityDisplayCache,\n getDisplayPropertyKey,\n getDisplayResolver,\n getPropertyInPath,\n useRebaseContext\n} from \"@rebasepro/app\";\nimport { getValueInPath } from \"@rebasepro/utils\";\n\nimport { getEntityTitlePropertyKeyForEntity, isUserSelectProperty, resolveTitleToString } from \"../util/previews\";\nimport { getUserLabel, useResolvedUser } from \"./useResolvedUsers\";\nimport { rowOfEntity } from \"@rebasepro/app\";\n\n/**\n * What fills one display role for one record.\n *\n * `value` is `undefined` rather than a placeholder when nothing resolved,\n * because the substitute differs by surface and each one knows its own better\n * than this hook does: a page heading wants the singular collection name, a link\n * wants the id, a draft wants \"New customer\". A single baked-in fallback is\n * exactly what produced three different ones scattered across the consumers.\n */\nexport interface ResolvedDisplayValue<T = unknown> {\n /** What goes in the slot. `undefined` when the record has nothing for it. */\n value: T | undefined;\n /**\n * A resolver is in flight, and `value` currently holds the derived answer or\n * nothing. Surfaces that can show a skeleton may; none has to.\n */\n loading: boolean;\n /**\n * Set only when the value came from a property of this collection. Carries\n * what a rich renderer needs — a status shows as its enum's coloured chip,\n * an image as a storage thumbnail — which a bare resolved string cannot\n * describe.\n */\n source?: {\n key: string;\n property: Property | undefined;\n value: unknown;\n };\n}\n\n/**\n * The store behind {@link useEntityDisplay}, for invalidating after a write.\n *\n * The app's one shared store, so every surface agrees on a record and resolves\n * it once, and so it is emptied with the rest of the session's caches when the\n * user signs out.\n */\nexport function useEntityDisplayCache(): EntityDisplayCache {\n return getSharedEntityDisplayCache();\n}\n\nexport interface UseEntityDisplayParams<M extends Record<string, unknown>> {\n /**\n * Optional because several callers look the collection up in the registry by\n * path and may not find it — a relation into a collection the panel does not\n * register. A hook that could not be called until that succeeded would have\n * to sit below an early return, which is not where hooks go.\n */\n collection?: AdminCollection<M>;\n /**\n * The record. A resolver is handed the whole entity — its id and path are\n * how it reaches anything the record does not carry — so a computed value is\n * only available once there is an entity to compute it from.\n */\n entity?: Entity<M>;\n /**\n * Values to read a declared path from when they are newer than the entity:\n * the live form values while editing. Falls back to `entity.values`.\n */\n values?: Record<string, unknown>;\n /** Set false to skip resolver work entirely — a draft has nothing to show. */\n enabled?: boolean;\n}\n\n/**\n * What fills one display role of one record.\n *\n * This is the only implementation. Before it there were seven for the title\n * alone — the identity bar, the detail header, inline previews, reference cards,\n * list slots, relation chips and the headless view — each re-deriving it from\n * `collection.properties` and disagreeing about the answer.\n *\n * Resolution order, per role:\n *\n * 1. `admin.display[role]` as a **resolver** — awaited, cached per record and\n * role, with the derived value showing meanwhile so nothing flickers empty.\n * 2. `admin.display[role]` as a **property path** (or, for the title, the\n * deprecated `titleProperty`).\n * 3. The **derived** answer: for the title, the best-ranked property carrying a\n * readable value; for the rest, today's per-role heuristics.\n *\n * A user-picker title resolves to the person behind the id, as it always did —\n * that path is now here rather than in two of the seven.\n */\nexport function useEntityDisplay<T = unknown, M extends Record<string, unknown> = Record<string, unknown>>(\n role: EntityDisplayRole,\n {\n collection,\n entity,\n values: valuesProp,\n enabled = true\n }: UseEntityDisplayParams<M>\n): ResolvedDisplayValue<T> {\n\n const context = useRebaseContext();\n const cache = useEntityDisplayCache();\n\n const values = valuesProp ?? entity?.values;\n\n /* ---- the declared or derived key ------------------------------------- */\n\n // The title is the one role with a ranking behind it: several candidates,\n // best first, skipping the ones that hold nothing for *this* record. The\n // others are a single declared or derived key.\n const declaredKey = collection ? getDisplayPropertyKey(collection, role) : undefined;\n const propertyKey = collection && role === \"title\" && !declaredKey\n ? getEntityTitlePropertyKeyForEntity(collection, values, entity?.id)\n : declaredKey;\n\n const rawValue = values && propertyKey ? getValueInPath(values, propertyKey) : undefined;\n\n // A user picker stores an auth id and renders the person: resolved like a\n // relation, and hooked unconditionally so the hook order never changes.\n const titleUser = useResolvedUser(\n collection && role === \"title\" && isUserSelectProperty(collection, propertyKey) && typeof rawValue === \"string\"\n ? rawValue\n : undefined\n );\n\n const derived = useMemo<T | undefined>(() => {\n if (titleUser) return getUserLabel(titleUser) as T;\n if (rawValue === undefined || rawValue === null) return undefined;\n // Only text roles get flattened to a string; a date stays a date and an\n // image stays whatever the storage property holds, so the renderer can\n // still format them.\n if (role === \"title\" || role === \"subtitle\" || role === \"status\") {\n return (resolveTitleToString(rawValue) || undefined) as T | undefined;\n }\n return rawValue as T;\n }, [titleUser, rawValue, role]);\n\n /* ---- the computed answer --------------------------------------------- */\n\n const resolver = collection ? getDisplayResolver(collection, role) : undefined;\n const canResolve = Boolean(enabled && resolver && entity);\n const key = entity ? entityDisplayKey(entity.path, entity.id, role) : undefined;\n\n const resolved = useSyncExternalStore<unknown>(\n // Subscribing unconditionally keeps the hook order stable. The store\n // only notifies when an entry changes, so a collection with no resolver\n // never re-renders from it.\n cb => cache.subscribe(cb),\n () => (canResolve && key ? cache.peek(key) : undefined),\n // Server render: nothing is resolved, so every slot starts at its\n // fallback and hydration does not disagree with the markup.\n () => undefined\n );\n\n const loading = Boolean(canResolve && key && resolved === undefined);\n\n useEffect(() => {\n if (!canResolve || !key || !resolver || !entity) return;\n // Asked every time the record changes, with the row the resolver is\n // handed: the cache answers from what it holds while that row is the\n // one it was computed from, and resolves again once it is not.\n const row = rowOfEntity(entity, collection);\n cache.resolve(key, () => resolver({\n row,\n id: String(entity.id),\n context\n }), row).catch(() => {\n // Unreachable, and kept only so it stays that way: `resolve` records a\n // failure as \"nothing\" and returns a RESOLVED promise, which is why\n // the warning that used to live here could never run — see the note on\n // `EntityDisplayCache.resolve`. The cache reports the failure itself\n // now, once per key. This exists so that if `resolve` ever starts\n // rejecting, it surfaces as a caught no-op rather than an unhandled\n // rejection during render.\n });\n }, [cache, canResolve, key, resolver, entity, collection, context, role]);\n\n /* ---- the answer ------------------------------------------------------ */\n\n // A resolver that produced nothing falls back to the derived value rather\n // than to blank: it said this record has no computed answer for the role,\n // not that the role should be empty.\n const computed = canResolve && resolved !== null ? resolved as T | undefined : undefined;\n const value = computed ?? derived;\n\n return useMemo(() => ({\n value,\n loading,\n source: collection && propertyKey && value === derived && derived !== undefined\n ? {\n key: propertyKey,\n property: getPropertyInPath(collection.properties, propertyKey),\n value: rawValue\n }\n : undefined\n }), [value, loading, propertyKey, derived, collection, rawValue]);\n}\n\n/**\n * Every display role of a record at once — what a list row, a card or a board\n * card needs, in one call rather than six.\n *\n * The role list is iterated from {@link ENTITY_DISPLAY_ROLES} so the hook order\n * is fixed and adding a role does not mean editing every caller.\n */\nexport function useEntityDisplayValues<M extends Record<string, unknown>>(\n params: UseEntityDisplayParams<M>\n): Record<EntityDisplayRole, ResolvedDisplayValue> & { loading: boolean } {\n\n // Not a loop over `useEntityDisplay`: the number of hooks a component calls\n // has to be fixed at compile time, and a role added to the array later would\n // silently change it. Written out, it is checked by the return type.\n const title = useEntityDisplay<string, M>(\"title\", params);\n const subtitle = useEntityDisplay<string, M>(\"subtitle\", params);\n const image = useEntityDisplay<string, M>(\"image\", params);\n const status = useEntityDisplay<string, M>(\"status\", params);\n const date = useEntityDisplay<Date | string | number, M>(\"date\", params);\n const tags = useEntityDisplay<string[] | string, M>(\"tags\", params);\n\n return useMemo(() => ({\n title,\n subtitle,\n image,\n status,\n date,\n tags,\n loading: title.loading || subtitle.loading || image.loading\n || status.loading || date.loading || tags.loading\n }), [title, subtitle, image, status, date, tags]);\n}\n\n/**\n * What the record is called — the one role asked for often enough on its own to\n * deserve a name.\n */\nexport function useEntityTitle<M extends Record<string, unknown>>(\n params: UseEntityDisplayParams<M>\n): ResolvedDisplayValue<string> {\n return useEntityDisplay<string, M>(\"title\", params);\n}\n\n/** Re-exported so a caller can iterate roles without reaching into types. */\nexport { ENTITY_DISPLAY_ROLES };\n"],"mappings":";;;;;;;;;;;;;;AAwDA,SAAgB,wBAA4C;CACxD,OAAO,4BAA4B;AACvC;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,iBACZ,MACA,EACI,YACA,QACA,QAAQ,YACR,UAAU,QAES;CAEvB,MAAM,UAAU,iBAAiB;CACjC,MAAM,QAAQ,sBAAsB;CAEpC,MAAM,SAAS,cAAc,QAAQ;CAOrC,MAAM,cAAc,aAAa,sBAAsB,YAAY,IAAI,IAAI,KAAA;CAC3E,MAAM,cAAc,cAAc,SAAS,WAAW,CAAC,cACjD,mCAAmC,YAAY,QAAQ,QAAQ,EAAE,IACjE;CAEN,MAAM,WAAW,UAAU,cAAc,eAAe,QAAQ,WAAW,IAAI,KAAA;CAI/E,MAAM,YAAY,gBACd,cAAc,SAAS,WAAW,qBAAqB,YAAY,WAAW,KAAK,OAAO,aAAa,WACjG,WACA,KAAA,CACV;CAEA,MAAM,UAAU,cAA6B;EACzC,IAAI,WAAW,OAAO,aAAa,SAAS;EAC5C,IAAI,aAAa,KAAA,KAAa,aAAa,MAAM,OAAO,KAAA;EAIxD,IAAI,SAAS,WAAW,SAAS,cAAc,SAAS,UACpD,OAAQ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AAM,OAAO,iBAA4C,QAAQ,MAAM;CACvE,MAAM,OAAO,iBAAuC,QAAQ,MAAM;CAElE,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA,SAAS,MAAM,WAAW,SAAS,WAAW,MAAM,WAC7C,OAAO,WAAW,KAAK,WAAW,KAAK;CAClD,IAAI;EAAC;EAAO;EAAU;EAAO;EAAQ;EAAM;CAAI,CAAC;AACpD;;;;;AAMA,SAAgB,eACZ,QAC4B;CAC5B,OAAO,iBAA4B,SAAS,MAAM;AACtD"}
|
|
1
|
+
{"version":3,"file":"useEntityDisplay.js","names":[],"sources":["../../src/hooks/useEntityDisplay.tsx"],"sourcesContent":["import type { AdminCollection, EntityDisplayRole, Property, Entity } from \"@rebasepro/cms-types\";\nimport { ENTITY_DISPLAY_ROLES } from \"@rebasepro/cms-types\";\nimport { useEffect, useMemo, useSyncExternalStore } from \"react\";\nimport {\n type EntityDisplayCache,\n entityDisplayKey,\n getSharedEntityDisplayCache,\n getDisplayPropertyKey,\n getDisplayResolver,\n getPropertyInPath,\n useRebaseContext\n} from \"@rebasepro/app\";\nimport { getValueInPath } from \"@rebasepro/utils\";\n\nimport { getEntityTitlePropertyKeyForEntity, isUserSelectProperty, resolveTitleToString } from \"../util/previews\";\nimport { getUserLabel, useResolvedUser } from \"./useResolvedUsers\";\nimport { rowOfEntity } from \"@rebasepro/app\";\n\n/**\n * What fills one display role for one record.\n *\n * `value` is `undefined` rather than a placeholder when nothing resolved,\n * because the substitute differs by surface and each one knows its own better\n * than this hook does: a page heading wants the singular collection name, a link\n * wants the id, a draft wants \"New customer\". A single baked-in fallback is\n * exactly what produced three different ones scattered across the consumers.\n */\nexport interface ResolvedDisplayValue<T = unknown> {\n /** What goes in the slot. `undefined` when the record has nothing for it. */\n value: T | undefined;\n /**\n * A resolver is in flight, and `value` currently holds the derived answer or\n * nothing. Surfaces that can show a skeleton may; none has to.\n */\n loading: boolean;\n /**\n * Set only when the value came from a property of this collection. Carries\n * what a rich renderer needs — a status shows as its enum's coloured chip,\n * an image as a storage thumbnail — which a bare resolved string cannot\n * describe.\n */\n source?: {\n key: string;\n property: Property | undefined;\n value: unknown;\n };\n}\n\n/**\n * The store behind {@link useEntityDisplay}, for invalidating after a write.\n *\n * The app's one shared store, so every surface agrees on a record and resolves\n * it once, and so it is emptied with the rest of the session's caches when the\n * user signs out.\n */\nexport function useEntityDisplayCache(): EntityDisplayCache {\n return getSharedEntityDisplayCache();\n}\n\nexport interface UseEntityDisplayParams<M extends Record<string, unknown>> {\n /**\n * Optional because several callers look the collection up in the registry by\n * path and may not find it — a relation into a collection the panel does not\n * register. A hook that could not be called until that succeeded would have\n * to sit below an early return, which is not where hooks go.\n */\n collection?: AdminCollection<M>;\n /**\n * The record. A resolver is handed the whole entity — its id and path are\n * how it reaches anything the record does not carry — so a computed value is\n * only available once there is an entity to compute it from.\n */\n entity?: Entity<M>;\n /**\n * Values to read a declared path from when they are newer than the entity:\n * the live form values while editing. Falls back to `entity.values`.\n */\n values?: Record<string, unknown>;\n /** Set false to skip resolver work entirely — a draft has nothing to show. */\n enabled?: boolean;\n}\n\n/**\n * What fills one display role of one record.\n *\n * This is the only implementation. Before it there were seven for the title\n * alone — the identity bar, the detail header, inline previews, reference cards,\n * list slots, relation chips and the headless view — each re-deriving it from\n * `collection.properties` and disagreeing about the answer.\n *\n * Resolution order, per role:\n *\n * 1. `admin.display[role]` as a **resolver** — awaited, cached per record and\n * role, with the derived value showing meanwhile so nothing flickers empty.\n * 2. `admin.display[role]` as a **property path** (or, for the title, the\n * deprecated `titleProperty`).\n * 3. The **derived** answer: for the title, the best-ranked property carrying a\n * readable value; for the rest, today's per-role heuristics.\n *\n * A user-picker title resolves to the person behind the id, as it always did —\n * that path is now here rather than in two of the seven.\n */\nexport function useEntityDisplay<T = unknown, M extends Record<string, unknown> = Record<string, unknown>>(\n role: EntityDisplayRole,\n {\n collection,\n entity,\n values: valuesProp,\n enabled = true\n }: UseEntityDisplayParams<M>\n): ResolvedDisplayValue<T> {\n\n const context = useRebaseContext();\n const cache = useEntityDisplayCache();\n\n const values = valuesProp ?? entity?.values;\n\n /* ---- the declared or derived key ------------------------------------- */\n\n // The title is the one role with a ranking behind it: several candidates,\n // best first, skipping the ones that hold nothing for *this* record. The\n // others are a single declared or derived key.\n const declaredKey = collection ? getDisplayPropertyKey(collection, role) : undefined;\n const propertyKey = collection && role === \"title\" && !declaredKey\n ? getEntityTitlePropertyKeyForEntity(collection, values, entity?.id)\n : declaredKey;\n\n const rawValue = values && propertyKey ? getValueInPath(values, propertyKey) : undefined;\n\n // A user picker stores an auth id and renders the person: resolved like a\n // relation, and hooked unconditionally so the hook order never changes.\n const titleUser = useResolvedUser(\n collection && role === \"title\" && isUserSelectProperty(collection, propertyKey) && typeof rawValue === \"string\"\n ? rawValue\n : undefined\n );\n\n const derived = useMemo<T | undefined>(() => {\n if (titleUser) return getUserLabel(titleUser) as T;\n if (rawValue === undefined || rawValue === null) return undefined;\n // Only text roles get flattened to a string; a date stays a date and an\n // image stays whatever the storage property holds, so the renderer can\n // still format them.\n if (role === \"title\" || role === \"subtitle\" || role === \"status\") {\n return (resolveTitleToString(rawValue) || undefined) as T | undefined;\n }\n return rawValue as T;\n }, [titleUser, rawValue, role]);\n\n /* ---- the computed answer --------------------------------------------- */\n\n const resolver = collection ? getDisplayResolver(collection, role) : undefined;\n const canResolve = Boolean(enabled && resolver && entity);\n const key = entity ? entityDisplayKey(entity.path, entity.id, role) : undefined;\n\n const resolved = useSyncExternalStore<unknown>(\n // Subscribing unconditionally keeps the hook order stable. The store\n // only notifies when an entry changes, so a collection with no resolver\n // never re-renders from it.\n cb => cache.subscribe(cb),\n () => (canResolve && key ? cache.peek(key) : undefined),\n // Server render: nothing is resolved, so every slot starts at its\n // fallback and hydration does not disagree with the markup.\n () => undefined\n );\n\n const loading = Boolean(canResolve && key && resolved === undefined);\n\n useEffect(() => {\n if (!canResolve || !key || !resolver || !entity) return;\n // Asked every time the record changes, with the row the resolver is\n // handed: the cache answers from what it holds while that row is the\n // one it was computed from, and resolves again once it is not.\n const row = rowOfEntity(entity, collection);\n cache.resolve(key, () => resolver({\n row,\n id: String(entity.id),\n context\n }), row).catch(() => {\n // Unreachable, and kept only so it stays that way: `resolve` records a\n // failure as \"nothing\" and returns a RESOLVED promise, which is why\n // the warning that used to live here could never run — see the note on\n // `EntityDisplayCache.resolve`. The cache reports the failure itself\n // now, once per key. This exists so that if `resolve` ever starts\n // rejecting, it surfaces as a caught no-op rather than an unhandled\n // rejection during render.\n });\n }, [cache, canResolve, key, resolver, entity, collection, context, role]);\n\n /* ---- the answer ------------------------------------------------------ */\n\n // A resolver that produced nothing falls back to the derived value rather\n // than to blank: it said this record has no computed answer for the role,\n // not that the role should be empty.\n const computed = canResolve && resolved !== null ? resolved as T | undefined : undefined;\n const value = computed ?? derived;\n\n return useMemo(() => ({\n value,\n loading,\n source: collection && propertyKey && value === derived && derived !== undefined\n ? {\n key: propertyKey,\n property: getPropertyInPath(collection.properties, propertyKey),\n value: rawValue\n }\n : undefined\n }), [value, loading, propertyKey, derived, collection, rawValue]);\n}\n\n/**\n * Every display role of a record at once — what a list row, a card or a board\n * card needs, in one call rather than six.\n *\n * The role list is iterated from {@link ENTITY_DISPLAY_ROLES} so the hook order\n * is fixed and adding a role does not mean editing every caller.\n */\nexport function useEntityDisplayValues<M extends Record<string, unknown>>(\n params: UseEntityDisplayParams<M>\n): Record<EntityDisplayRole, ResolvedDisplayValue> & { loading: boolean } {\n\n // Not a loop over `useEntityDisplay`: the number of hooks a component calls\n // has to be fixed at compile time, and a role added to the array later would\n // silently change it. Written out, it is checked by the return type.\n const title = useEntityDisplay<string, M>(\"title\", params);\n const subtitle = useEntityDisplay<string, M>(\"subtitle\", params);\n const image = useEntityDisplay<string, M>(\"image\", params);\n const status = useEntityDisplay<string, M>(\"status\", params);\n const date = useEntityDisplay<Date | string | number, M>(\"date\", params);\n const tags = useEntityDisplay<string[] | string, M>(\"tags\", params);\n\n return useMemo(() => ({\n title,\n subtitle,\n image,\n status,\n date,\n tags,\n loading: title.loading || subtitle.loading || image.loading\n || status.loading || date.loading || tags.loading\n }), [title, subtitle, image, status, date, tags]);\n}\n\n/**\n * What the record is called — the one role asked for often enough on its own to\n * deserve a name.\n */\nexport function useEntityTitle<M extends Record<string, unknown>>(\n params: UseEntityDisplayParams<M>\n): ResolvedDisplayValue<string> {\n return useEntityDisplay<string, M>(\"title\", params);\n}\n\n/** Re-exported so a caller can iterate roles without reaching into types. */\nexport { ENTITY_DISPLAY_ROLES };\n"],"mappings":";;;;;;;;;;;;;;AAuDA,SAAgB,wBAA4C;CACxD,OAAO,4BAA4B;AACvC;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,iBACZ,MACA,EACI,YACA,QACA,QAAQ,YACR,UAAU,QAES;CAEvB,MAAM,UAAU,iBAAiB;CACjC,MAAM,QAAQ,sBAAsB;CAEpC,MAAM,SAAS,cAAc,QAAQ;CAOrC,MAAM,cAAc,aAAa,sBAAsB,YAAY,IAAI,IAAI,KAAA;CAC3E,MAAM,cAAc,cAAc,SAAS,WAAW,CAAC,cACjD,mCAAmC,YAAY,QAAQ,QAAQ,EAAE,IACjE;CAEN,MAAM,WAAW,UAAU,cAAc,eAAe,QAAQ,WAAW,IAAI,KAAA;CAI/E,MAAM,YAAY,gBACd,cAAc,SAAS,WAAW,qBAAqB,YAAY,WAAW,KAAK,OAAO,aAAa,WACjG,WACA,KAAA,CACV;CAEA,MAAM,UAAU,cAA6B;EACzC,IAAI,WAAW,OAAO,aAAa,SAAS;EAC5C,IAAI,aAAa,KAAA,KAAa,aAAa,MAAM,OAAO,KAAA;EAIxD,IAAI,SAAS,WAAW,SAAS,cAAc,SAAS,UACpD,OAAQ,qBAAqB,QAAQ,KAAK,KAAA;EAE9C,OAAO;CACX,GAAG;EAAC;EAAW;EAAU;CAAI,CAAC;CAI9B,MAAM,WAAW,aAAa,mBAAmB,YAAY,IAAI,IAAI,KAAA;CACrE,MAAM,aAAa,QA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WAC7C,OAAO,WAAW,KAAK,WAAW,KAAK;CAClD,IAAI;EAAC;EAAO;EAAU;EAAO;EAAQ;EAAM;CAAI,CAAC;AACpD;;;;;AAMA,SAAgB,eACZ,QAC4B;CAC5B,OAAO,iBAA4B,SAAS,MAAM;AACtD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
-
import type {
|
|
1
|
+
import type { AdminCollection, Entity } from "@rebasepro/cms-types";
|
|
2
|
+
import type { EntityStatus } from "@rebasepro/types";
|
|
3
3
|
export interface UseEntityDisplayTitleParams<M extends Record<string, unknown>> {
|
|
4
4
|
collection: AdminCollection<M>;
|
|
5
5
|
/** The record. Needed for a computed title; see {@link useEntityTitle}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntityDisplayTitle.js","names":[],"sources":["../../src/hooks/useEntityDisplayTitle.tsx"],"sourcesContent":["import type { AdminCollection } from \"@rebasepro/cms-types\";\nimport type {
|
|
1
|
+
{"version":3,"file":"useEntityDisplayTitle.js","names":[],"sources":["../../src/hooks/useEntityDisplayTitle.tsx"],"sourcesContent":["import type { AdminCollection, Entity } from \"@rebasepro/cms-types\";\nimport type { EntityStatus } from \"@rebasepro/types\";\nimport { useEntityTitle } from \"./useEntityDisplay\";\n\nexport interface UseEntityDisplayTitleParams<M extends Record<string, unknown>> {\n collection: AdminCollection<M>;\n /** The record. Needed for a computed title; see {@link useEntityTitle}. */\n entity?: Entity<M>;\n /** Live form values, when they are ahead of the entity. */\n values?: Record<string, unknown>;\n status: EntityStatus;\n}\n\n/**\n * The heading for a record: the identity bar and the breadcrumb.\n *\n * Everything about *what a record is called* lives in {@link useEntityTitle}.\n * What is left here is the heading's own two rules, which are presentation, not\n * identity:\n *\n * The guard on `status` is the first. The title resolver returns the first\n * candidate carrying a value, and on a brand new entity the only values are the\n * property defaults — so creating a blog post opened a page headed **draft**,\n * the default of its `status` enum. A record that does not exist yet has no\n * name; it has an intent.\n *\n * The fallback is the second. A page needs a heading even when the record has\n * nothing readable in it, and the honest one is what kind of thing it is.\n */\nexport function useEntityDisplayTitle<M extends Record<string, unknown>>({\n collection,\n entity,\n values,\n status\n}: UseEntityDisplayTitleParams<M>): string {\n\n const isNew = status === \"new\";\n const singular = collection.singularName ?? collection.name;\n\n const { value: title } = useEntityTitle<M>({\n collection,\n entity,\n values,\n enabled: !isNew\n });\n\n if (isNew) return `New ${singular.toLowerCase()}`;\n return title ?? singular;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,sBAAyD,EACrE,YACA,QACA,QACA,UACuC;CAEvC,MAAM,QAAQ,WAAW;CACzB,MAAM,WAAW,WAAW,gBAAgB,WAAW;CAEvD,MAAM,EAAE,OAAO,UAAU,eAAkB;EACvC;EACA;EACA;EACA,SAAS,CAAC;CACd,CAAC;CAED,IAAI,OAAO,OAAO,OAAO,SAAS,YAAY;CAC9C,OAAO,SAAS;AACpB"}
|
package/dist/hooks/useHistory.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { hasEntityId } from "../util/identity.js";
|
|
1
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { hasEntityId } from "@rebasepro/common";
|
|
3
3
|
import { useApiBase, useApiConfig, useRlsSimulation } from "@rebasepro/app";
|
|
4
4
|
import { simulationHeaders } from "@rebasepro/types";
|
|
5
5
|
//#region src/hooks/useHistory.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHistory.js","names":[],"sources":["../../src/hooks/useHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport { useApiBase, useApiConfig, useRlsSimulation } from \"@rebasepro/app\";\nimport { simulationHeaders } from \"@rebasepro/types\";\nimport type { EntityHistoryEntry } from \"@rebasepro/types\";\n\n/**\n * What the history REST endpoint returns. The fourth declaration of this shape\n * — the two drivers had one each and disagreed on `updated_at` — now an alias\n * of the one in `@rebasepro/types`.\n */\nexport type HistoryEntryData = EntityHistoryEntry;\n\nexport interface UseEntityHistoryResult {\n entries: HistoryEntryData[];\n total: number;\n isLoading: boolean;\n hasMore: boolean;\n error?: Error;\n loadMore: () => void;\n revert: (historyId: string) => Promise<Record<string, unknown>>;\n}\n\n/**\n * Hook to fetch entity history from the backend REST API.\n * Replaces the old subcollection-based approach with a proper API call.\n *\n * While access is simulated (\"Simulate access\") every request carries the\n * simulation, as the data views' `client.simulate()` does: the history is read\n * as the simulated identity, and the server refuses a revert as the simulated\n * write it would be.\n */\nexport function useHistory(params: {\n slug: string;\n entityId: string | number | undefined;\n enabled?: boolean;\n pageSize?: number;\n /**\n * Bumped by the caller when the record is saved. A save is the one event\n * that adds a revision, and nothing else here would notice it: without\n * this the open panel keeps showing the list it fetched when it opened,\n * so the revision you just created never appears.\n */\n refreshToken?: number;\n}): UseEntityHistoryResult {\n const { slug, entityId, enabled = true, pageSize = 10, refreshToken } = params;\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n const { simulation } = useRlsSimulation();\n const simulated = useMemo(() => simulationHeaders(simulation), [simulation]);\n\n const [entries, setEntries] = useState<HistoryEntryData[]>([]);\n const [total, setTotal] = useState(0);\n const [isLoading, setIsLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n const [offset, setOffset] = useState(0);\n const [refreshTrigger, setRefreshTrigger] = useState(0);\n\n // Track the current entity identity so we can detect stale responses.\n // `refreshToken` is part of the identity on purpose: a save makes the list\n // we are holding a stale page of a longer list, which is the same problem\n // as having moved to a different record.\n // So is the simulation: another identity reads another history.\n const entityKey = `${slug}/${entityId}/${refreshToken ?? 0}/${JSON.stringify(simulated)}`;\n const currentEntityRef = useRef<string | undefined>(undefined);\n\n const fetchEntries = useCallback(async (\n currentOffset: number,\n signal?: AbortSignal\n ) => {\n if (!apiConfig?.apiUrl || !hasEntityId(entityId) || !enabled) return;\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history?limit=${pageSize}&offset=${currentOffset}`;\n const response = await fetch(url, { headers,\nsignal });\n\n // Check if the request was aborted or the entity changed while in-flight\n if (signal?.aborted) return;\n if (currentEntityRef.current !== entityKey) return;\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to fetch history (${response.status})`);\n }\n\n const result = await response.json();\n\n if (currentOffset === 0) {\n setEntries(result.data);\n } else {\n setEntries(prev => [...prev, ...result.data]);\n }\n\n setTotal(result.meta.total);\n setHasMore(result.meta.hasMore);\n } catch (err) {\n // Don't set error state for intentional aborts\n if (err instanceof DOMException && err.name === \"AbortError\") return;\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [apiConfig, apiBase, slug, entityId, entityKey, enabled, pageSize, simulated]);\n\n // Single unified effect: reset state when entity changes, fetch when offset changes.\n // Uses AbortController to cancel stale requests on entity change or unmount.\n useEffect(() => {\n const isNewEntity = currentEntityRef.current !== entityKey;\n\n if (isNewEntity) {\n // Reset state for new entity\n currentEntityRef.current = entityKey;\n setEntries([]);\n setTotal(0);\n setHasMore(true);\n setOffset(0);\n }\n\n if (!enabled || !hasEntityId(entityId)) return;\n\n const abortController = new AbortController();\n // When entity changed, always fetch from offset 0\n const effectiveOffset = isNewEntity ? 0 : offset;\n fetchEntries(effectiveOffset, abortController.signal);\n\n return () => {\n abortController.abort();\n };\n }, [fetchEntries, offset, enabled, entityId, entityKey, refreshTrigger]);\n\n const loadMore = useCallback(() => {\n // `entries` already holds every page up to the current offset; adding\n // the offset to it counted those pages twice and stopped the scroll\n // short of the oldest revisions.\n if (!isLoading && hasMore && entries.length < total) {\n setOffset(prev => prev + pageSize);\n }\n }, [isLoading, hasMore, pageSize, entries.length, total]);\n\n const revert = useCallback(async (historyId: string): Promise<Record<string, unknown>> => {\n if (!apiConfig?.apiUrl || !hasEntityId(entityId)) {\n throw new Error(\"Cannot revert: missing API configuration or entity ID\");\n }\n\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history/${historyId}/revert`;\n const response = await fetch(url, { method: \"POST\",\nheaders });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to revert (${response.status})`);\n }\n\n const result = await response.json();\n\n // Refresh the history list after revert by resetting the entity ref\n // and triggering the effect.\n currentEntityRef.current = undefined;\n setRefreshTrigger(prev => prev + 1);\n\n // Return the reverted entity data so callers can update the form\n return result.data as Record<string, unknown>;\n }, [apiConfig, apiBase, slug, entityId, simulated]);\n\n return useMemo(() => ({\n entries,\n total,\n isLoading,\n hasMore,\n error,\n loadMore,\n revert\n }), [entries, total, isLoading, hasMore, error, loadMore, revert]);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,WAAW,QAYA;CACvB,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM,WAAW,IAAI,iBAAiB;CACxE,MAAM,YAAY,aAAa;CAC/B,MAAM,UAAU,WAAW;CAC3B,MAAM,EAAE,eAAe,iBAAiB;CACxC,MAAM,YAAY,cAAc,kBAAkB,UAAU,GAAG,CAAC,UAAU,CAAC;CAE3E,MAAM,CAAC,SAAS,cAAc,SAA6B,CAAC,CAAC;CAC7D,MAAM,CAAC,OAAO,YAAY,SAAS,CAAC;CACpC,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAC3C,MAAM,CAAC,O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jG,MAAM,IAAI,MAAM,UAAU,OAAO,WAAW,qBAAqB,SAAS,OAAO,EAAE;EACvF;EAEA,MAAM,SAAS,MAAM,SAAS,KAAK;EAInC,iBAAiB,UAAU,KAAA;EAC3B,mBAAkB,SAAQ,OAAO,CAAC;EAGlC,OAAO,OAAO;CAClB,GAAG;EAAC;EAAW;EAAS;EAAM;EAAU;CAAS,CAAC;CAElD,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IAAI;EAAC;EAAS;EAAO;EAAW;EAAS;EAAO;EAAU;CAAM,CAAC;AACrE"}
|
|
1
|
+
{"version":3,"file":"useHistory.js","names":[],"sources":["../../src/hooks/useHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from \"react\";\nimport { hasEntityId } from \"../util/identity\";\nimport { useApiBase, useApiConfig, useRlsSimulation } from \"@rebasepro/app\";\nimport { simulationHeaders } from \"@rebasepro/types\";\nimport type { EntityHistoryEntry } from \"@rebasepro/types\";\n\n/**\n * What the history REST endpoint returns. The fourth declaration of this shape\n * — the two drivers had one each and disagreed on `updated_at` — now an alias\n * of the one in `@rebasepro/types`.\n */\nexport type HistoryEntryData = EntityHistoryEntry;\n\nexport interface UseEntityHistoryResult {\n entries: HistoryEntryData[];\n total: number;\n isLoading: boolean;\n hasMore: boolean;\n error?: Error;\n loadMore: () => void;\n revert: (historyId: string) => Promise<Record<string, unknown>>;\n}\n\n/**\n * Hook to fetch entity history from the backend REST API.\n * Replaces the old subcollection-based approach with a proper API call.\n *\n * While access is simulated (\"Simulate access\") every request carries the\n * simulation, as the data views' `client.simulate()` does: the history is read\n * as the simulated identity, and the server refuses a revert as the simulated\n * write it would be.\n */\nexport function useHistory(params: {\n slug: string;\n entityId: string | number | undefined;\n enabled?: boolean;\n pageSize?: number;\n /**\n * Bumped by the caller when the record is saved. A save is the one event\n * that adds a revision, and nothing else here would notice it: without\n * this the open panel keeps showing the list it fetched when it opened,\n * so the revision you just created never appears.\n */\n refreshToken?: number;\n}): UseEntityHistoryResult {\n const { slug, entityId, enabled = true, pageSize = 10, refreshToken } = params;\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n const { simulation } = useRlsSimulation();\n const simulated = useMemo(() => simulationHeaders(simulation), [simulation]);\n\n const [entries, setEntries] = useState<HistoryEntryData[]>([]);\n const [total, setTotal] = useState(0);\n const [isLoading, setIsLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n const [offset, setOffset] = useState(0);\n const [refreshTrigger, setRefreshTrigger] = useState(0);\n\n // Track the current entity identity so we can detect stale responses.\n // `refreshToken` is part of the identity on purpose: a save makes the list\n // we are holding a stale page of a longer list, which is the same problem\n // as having moved to a different record.\n // So is the simulation: another identity reads another history.\n const entityKey = `${slug}/${entityId}/${refreshToken ?? 0}/${JSON.stringify(simulated)}`;\n const currentEntityRef = useRef<string | undefined>(undefined);\n\n const fetchEntries = useCallback(async (\n currentOffset: number,\n signal?: AbortSignal\n ) => {\n if (!apiConfig?.apiUrl || !hasEntityId(entityId) || !enabled) return;\n\n setIsLoading(true);\n setError(undefined);\n\n try {\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history?limit=${pageSize}&offset=${currentOffset}`;\n const response = await fetch(url, { headers,\nsignal });\n\n // Check if the request was aborted or the entity changed while in-flight\n if (signal?.aborted) return;\n if (currentEntityRef.current !== entityKey) return;\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to fetch history (${response.status})`);\n }\n\n const result = await response.json();\n\n if (currentOffset === 0) {\n setEntries(result.data);\n } else {\n setEntries(prev => [...prev, ...result.data]);\n }\n\n setTotal(result.meta.total);\n setHasMore(result.meta.hasMore);\n } catch (err) {\n // Don't set error state for intentional aborts\n if (err instanceof DOMException && err.name === \"AbortError\") return;\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [apiConfig, apiBase, slug, entityId, entityKey, enabled, pageSize, simulated]);\n\n // Single unified effect: reset state when entity changes, fetch when offset changes.\n // Uses AbortController to cancel stale requests on entity change or unmount.\n useEffect(() => {\n const isNewEntity = currentEntityRef.current !== entityKey;\n\n if (isNewEntity) {\n // Reset state for new entity\n currentEntityRef.current = entityKey;\n setEntries([]);\n setTotal(0);\n setHasMore(true);\n setOffset(0);\n }\n\n if (!enabled || !hasEntityId(entityId)) return;\n\n const abortController = new AbortController();\n // When entity changed, always fetch from offset 0\n const effectiveOffset = isNewEntity ? 0 : offset;\n fetchEntries(effectiveOffset, abortController.signal);\n\n return () => {\n abortController.abort();\n };\n }, [fetchEntries, offset, enabled, entityId, entityKey, refreshTrigger]);\n\n const loadMore = useCallback(() => {\n // `entries` already holds every page up to the current offset; adding\n // the offset to it counted those pages twice and stopped the scroll\n // short of the oldest revisions.\n if (!isLoading && hasMore && entries.length < total) {\n setOffset(prev => prev + pageSize);\n }\n }, [isLoading, hasMore, pageSize, entries.length, total]);\n\n const revert = useCallback(async (historyId: string): Promise<Record<string, unknown>> => {\n if (!apiConfig?.apiUrl || !hasEntityId(entityId)) {\n throw new Error(\"Cannot revert: missing API configuration or entity ID\");\n }\n\n const token = await apiConfig.getAuthToken?.();\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n ...simulated\n };\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n\n const url = `${apiBase}/data/${slug}/${entityId}/history/${historyId}/revert`;\n const response = await fetch(url, { method: \"POST\",\nheaders });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({ error: { message: response.statusText } }));\n throw new Error(errorData.error?.message || `Failed to revert (${response.status})`);\n }\n\n const result = await response.json();\n\n // Refresh the history list after revert by resetting the entity ref\n // and triggering the effect.\n currentEntityRef.current = undefined;\n setRefreshTrigger(prev => prev + 1);\n\n // Return the reverted entity data so callers can update the form\n return result.data as Record<string, unknown>;\n }, [apiConfig, apiBase, slug, entityId, simulated]);\n\n return useMemo(() => ({\n entries,\n total,\n isLoading,\n hasMore,\n error,\n loadMore,\n revert\n }), [entries, total, isLoading, hasMore, error, loadMore, revert]);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,WAAW,QAYA;CACvB,MAAM,EAAE,MAAM,UAAU,UAAU,MAAM,WAAW,IAAI,iBAAiB;CACxE,MAAM,YAAY,aAAa;CAC/B,MAAM,UAAU,WAAW;CAC3B,MAAM,EAAE,eAAe,iBAAiB;CACxC,MAAM,YAAY,cAAc,kBAAkB,UAAU,GAAG,CAAC,UAAU,CAAC;CAE3E,MAAM,CAAC,SAAS,cAAc,SAA6B,CAAC,CAAC;CAC7D,MAAM,CAAC,OAAO,YAAY,SAAS,CAAC;CACpC,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,SAAS,cAAc,SAAS,IAAI;CAC3C,MAAM,CAAC,OAAO,YAAY,SAA4B;CACtD,MAAM,CAAC,QAAQ,aAAa,SAAS,CAAC;CACtC,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,CAAC;CAOtD,MAAM,YAAY,GAAG,KAAK,GAAG,SAAS,GAAG,gBAAgB,EAAE,GAAG,KAAK,UAAU,SAAS;CACtF,MAAM,mBAAmB,OAA2B,KAAA,CAAS;CAE7D,MAAM,eAAe,YAAY,OAC7B,eACA,WACC;EACD,IAAI,CAAC,WAAW,UAAU,CAAC,YAAY,QAAQ,KAAK,CAAC,SAAS;EAE9D,aAAa,IAAI;EACjB,SAAS,KAAA,CAAS;EAElB,IAAI;GACA,MAAM,QAAQ,MAAM,UAAU,eAAe;GAC7C,MAAM,UAAkC;IACpC,gBAAgB;IAChB,GAAG;GACP;GACA,IAAI,OAAO,QAAQ,mBAAmB,UAAU;GAEhD,MAAM,MAAM,GAAG,QAAQ,QAAQ,K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kB;EAI/B,IAAI,CAAC,aAAa,WAAW,QAAQ,SAAS,OAC1C,WAAU,SAAQ,OAAO,QAAQ;CAEzC,GAAG;EAAC;EAAW;EAAS;EAAU,QAAQ;EAAQ;CAAK,CAAC;CAExD,MAAM,SAAS,YAAY,OAAO,cAAwD;EACtF,IAAI,CAAC,WAAW,UAAU,CAAC,YAAY,QAAQ,GAC3C,MAAM,IAAI,MAAM,uDAAuD;EAG3E,MAAM,QAAQ,MAAM,UAAU,eAAe;EAC7C,MAAM,UAAkC;GACpC,gBAAgB;GAChB,GAAG;EACP;EACA,IAAI,OAAO,QAAQ,mBAAmB,UAAU;EAEhD,MAAM,MAAM,GAAG,QAAQ,QAAQ,KAAK,GAAG,SAAS,WAAW,UAAU;EACrE,MAAM,WAAW,MAAM,MAAM,KAAK;GAAE,QAAQ;GACpD;EAAQ,CAAC;EAED,IAAI,CAAC,SAAS,IAAI;GACd,MAAM,YAAY,MAAM,SAAS,KAAK,CAAC,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,SAAS,WAAW,EAAE,EAAE;GACjG,MAAM,IAAI,MAAM,UAAU,OAAO,WAAW,qBAAqB,SAAS,OAAO,EAAE;EACvF;EAEA,MAAM,SAAS,MAAM,SAAS,KAAK;EAInC,iBAAiB,UAAU,KAAA;EAC3B,mBAAkB,SAAQ,OAAO,CAAC;EAGlC,OAAO,OAAO;CAClB,GAAG;EAAC;EAAW;EAAS;EAAM;EAAU;CAAS,CAAC;CAElD,OAAO,eAAe;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IAAI;EAAC;EAAS;EAAO;EAAW;EAAS;EAAO;EAAU;CAAM,CAAC;AACrE"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { EntityActionClickProps, AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
-
import type { Entity } from "@rebasepro/types";
|
|
1
|
+
import type { EntityActionClickProps, AdminCollection, Entity } from "@rebasepro/cms-types";
|
|
3
2
|
import { type PlacedEntityActions } from "../util/entity_actions.js";
|
|
4
3
|
import type { RecordActionItem } from "../components/EntityIdentityBar.js";
|
|
5
4
|
export interface UseRecordActionsParams<M extends Record<string, unknown>> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRecordActions.js","names":[],"sources":["../../src/hooks/useRecordActions.tsx"],"sourcesContent":["import type { EntityAction, EntityActionClickProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport
|
|
1
|
+
{"version":3,"file":"useRecordActions.js","names":[],"sources":["../../src/hooks/useRecordActions.tsx"],"sourcesContent":["import type { EntityAction, EntityActionClickProps, AdminCollection, Entity } from \"@rebasepro/cms-types\";\nimport { useCallback, useMemo } from \"react\";\nimport { useNavigate } from \"react-router\";\nimport { getIcon, useCustomizationController, usePermissions, useSnackbarController, useTranslation } from \"@rebasepro/app\";\nimport { copyEntityAction, deleteEntityAction, unlinkEntityAction } from \"../components/common/default_entity_actions\";\nimport { entityActionName, mergeEntityActions, placeEntityActions, resolveEntityActionState, type PlacedEntityActions } from \"../util/entity_actions\";\nimport { resolveEntityAction } from \"../util/resolutions\";\nimport { useChildViewSource } from \"./useChildViewSource\";\nimport { useUrlController } from \"./navigation/contexts/UrlContext\";\nimport { withListState } from \"../util/view_mode\";\nimport type { RecordActionItem } from \"../components/EntityIdentityBar\";\nimport { useSideDialogContext } from \"../components/SideDialogs\";\n\nexport interface UseRecordActionsParams<M extends Record<string, unknown>> {\n collection: AdminCollection<M>;\n path: string;\n entity?: Entity<M>;\n /**\n * What every action is called with — and asked `isEnabled` with. Undefined\n * until there is a record to act on.\n */\n clickProps?: EntityActionClickProps<Record<string, unknown>>;\n}\n\n/**\n * The actions you can perform *on* a record — copy, delete, and whatever the\n * collection adds — resolved against the current user's permissions, and\n * placed for the record's identity bar: buttons for the ones declared\n * `collapsed: false`, menu groups for the rest.\n *\n * Extracted from the form's footer so the identity bar can own them. They are\n * not ways to leave the form, so they never belonged next to Save's footer;\n * the bar carries them on the edit view and the read-only view alike.\n */\nexport function useRecordActions<M extends Record<string, unknown>>({\n collection,\n path,\n entity,\n clickProps\n}: UseRecordActionsParams<M>): PlacedEntityActions<RecordActionItem> | undefined {\n\n const { canCreate, canDelete } = usePermissions();\n const customizationController = useCustomizationController();\n const snackbarController = useSnackbarController();\n const { t } = useTranslation();\n\n // Rows shared through a junction: the delete action here removes the link,\n // because that is what the server does for this path.\n const childViewSource = useChildViewSource(path);\n const isLinkedChildView = childViewSource?.kind === \"relation\" && childViewSource.mode === \"linked\";\n\n const actions = useMemo((): EntityAction[] => {\n const customEntityActions = (collection.entityActions ?? [])\n .map(action => resolveEntityAction(action, customizationController.entityActions))\n .filter(Boolean) as EntityAction[];\n\n const createEnabled = canCreate(collection, path);\n const deleteEnabled = entity ? canDelete(collection, path, entity.values) : false;\n const disableActions = collection.disableDefaultActions ?? [];\n\n const defaults: EntityAction[] = [];\n if (createEnabled && !disableActions.includes(\"copy\"))\n defaults.push(copyEntityAction);\n if (deleteEnabled && !disableActions.includes(\"delete\"))\n defaults.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);\n\n const merged = customEntityActions.length\n ? mergeEntityActions(defaults, customEntityActions)\n : defaults;\n\n return merged.filter(a => a.includeInForm === undefined || a.includeInForm);\n }, [\n canCreate,\n canDelete,\n collection,\n path,\n customizationController.entityActions?.length,\n entity,\n collection.disableDefaultActions,\n isLinkedChildView\n ]);\n\n return useMemo(() => {\n if (!clickProps?.row || !actions.length) return undefined;\n\n const report = (action: EntityAction, error: unknown) => {\n console.error(\"Error executing action\", action.key ?? action.name, error);\n snackbarController.open({\n type: \"error\",\n message: `${entityActionName(action, t)}: ${error instanceof Error ? error.message : String(error)}`\n });\n };\n\n const items = actions.map((action, index): RecordActionItem & Pick<EntityAction, \"collapsed\"> => ({\n key: action.key ?? `${action.name}_${index}`,\n name: entityActionName(action, t),\n icon: getIcon(action.icon, undefined, undefined, \"smallest\"),\n collapsed: action.collapsed,\n ...resolveEntityActionState(action, clickProps),\n // A failure reaches the user rather than the console alone, wherever\n // the action was clicked from. A promise is handed back only when the\n // action returned one, so a button shows a spinner for work that is\n // actually running and never flashes one for a synchronous call.\n run: () => {\n try {\n const result = action.onClick(clickProps);\n if (result instanceof Promise) return result.catch(error => report(action, error));\n } catch (error: unknown) {\n report(action, error);\n }\n return undefined;\n }\n }));\n\n return placeEntityActions(items);\n }, [actions, clickProps, snackbarController, t]);\n}\n\n/**\n * What a record's own actions mean by `navigateBack`: leave the record. The\n * delete action calls it once the row is gone.\n *\n * It is not the edit view's `navigateBack` prop, which every layout wires to\n * \"leave the edit view for the record's detail view\" — after a delete that is a\n * record that no longer exists, and the split, the side panel and the dialog\n * stayed open on it.\n */\nexport function useLeaveRecord({\n layout,\n path,\n onCloseRequest\n}: {\n layout: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n path: string;\n onCloseRequest?: () => void;\n}): () => void {\n const sideDialogContext = useSideDialogContext();\n const navigate = useNavigate();\n const urlController = useUrlController();\n return useCallback(() => {\n if (layout === \"side_panel\" || layout === \"dialog\") {\n sideDialogContext.close(true);\n } else if (onCloseRequest) {\n onCloseRequest();\n } else {\n navigate(withListState(urlController.buildUrlCollectionPath(path)), { replace: true });\n }\n }, [layout, sideDialogContext, onCloseRequest, navigate, urlController, path]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,iBAAoD,EAChE,YACA,MACA,QACA,cAC6E;CAE7E,MAAM,EAAE,WAAW,cAAc,eAAe;CAChD,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,qBAAqB,sBAAsB;CACjD,MAAM,EAAE,MAAM,eAAe;CAI7B,MAAM,kBAAkB,mBAAmB,IAAI;CAC/C,MAAM,oBAAoB,iBAAiB,SAAS,cAAc,gBAAgB,SAAS;CAE3F,MAAM,UAAU,cAA8B;EAC1C,MAAM,uBAAuB,WAAW,iBAAiB,CAAC,EAAA,CACrD,KAAI,WAAU,oBAAoB,QAAQ,wBAAwB,aAAa,CAAC,CAAC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AQ,KAAK,CAAC;IACrF,SAAS,OAAgB;KACrB,OAAO,QAAQ,KAAK;IACxB;GAEJ;EACJ,EAE0B,CAAK;CACnC,GAAG;EAAC;EAAS;EAAY;EAAoB;CAAC,CAAC;AACnD;;;;;;;;;;AAWA,SAAgB,eAAe,EAC3B,QACA,MACA,kBAKW;CACX,MAAM,oBAAoB,qBAAqB;CAC/C,MAAM,WAAW,YAAY;CAC7B,MAAM,gBAAgB,iBAAiB;CACvC,OAAO,kBAAkB;EACrB,IAAI,WAAW,gBAAgB,WAAW,UACtC,kBAAkB,MAAM,IAAI;OACzB,IAAI,gBACP,eAAe;OAEf,SAAS,cAAc,cAAc,uBAAuB,IAAI,CAAC,GAAG,EAAE,SAAS,KAAK,CAAC;CAE7F,GAAG;EAAC;EAAQ;EAAmB;EAAgB;EAAU;EAAe;CAAI,CAAC;AACjF"}
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EntityReference, Entity } from "@rebasepro/cms-types";
|
|
2
2
|
/**
|
|
3
3
|
* Where a reference points, as stored and as the admin addresses it.
|
|
4
4
|
*
|
|
5
|
-
* The two differ for a Firestore
|
|
5
|
+
* The two differ for a Firestore collection that declares a `path`
|
|
6
6
|
* for its store: `slug: "fs_diagnosis", path: "diagnosis"`. A reference stores
|
|
7
7
|
* `diagnosis`, because that is where its driver finds the record. The admin
|
|
8
8
|
* lists, routes and fetches by `fs_diagnosis`, and `diagnosis` can be the slug
|
|
9
9
|
* of a Postgres collection beside it — which is what declaring the `path` was
|
|
10
|
-
* for.
|
|
10
|
+
* for.
|
|
11
11
|
*
|
|
12
|
-
* A stored path is read in favour of the
|
|
12
|
+
* A **stored** path is read in favour of the reference's `driver` (the data
|
|
13
|
+
* source it points into), else of the data source of the collection in
|
|
13
14
|
* scope: a reference is read from a record, and points into that record's
|
|
14
|
-
* store unless
|
|
15
|
+
* store unless it says otherwise.
|
|
16
|
+
*
|
|
17
|
+
* A reference **property's** `path` names its target the way the admin
|
|
18
|
+
* addresses collections: by slug, whatever data source the target is on — so
|
|
19
|
+
* a Firestore field targeting `customers` means the Postgres `customers`
|
|
20
|
+
* collection even when a Firestore collection is stored at `customers`. A
|
|
21
|
+
* store path is read as one only where no collection has it as its slug.
|
|
15
22
|
*/
|
|
16
23
|
export declare function useReferencePaths(): {
|
|
17
|
-
/** The path the admin addresses the target of a stored reference
|
|
24
|
+
/** The path the admin addresses the target of a stored reference by. */
|
|
18
25
|
toCollectionPath: (path: string, driver?: string) => string;
|
|
19
|
-
/**
|
|
26
|
+
/** The path the admin addresses the target of a reference property's `path` by. */
|
|
27
|
+
targetPath: (path: string) => string;
|
|
28
|
+
/**
|
|
29
|
+
* A reference to `entity`, carrying the path its record is stored under
|
|
30
|
+
* and — when it lives in another data source than the collection in
|
|
31
|
+
* scope — that source's key as its `driver`, which routes its preview
|
|
32
|
+
* there and makes it stored as an id.
|
|
33
|
+
*/
|
|
20
34
|
referenceTo: (entity: Entity<Record<string, unknown>>) => EntityReference;
|
|
21
35
|
};
|
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
import { useCollectionRegistryController } from "./navigation/contexts/CollectionRegistryContext.js";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import { getReferenceFrom } from "@rebasepro/
|
|
3
|
+
import { getReferenceFrom } from "@rebasepro/cms-types";
|
|
4
4
|
import { useCollectionScope } from "@rebasepro/app";
|
|
5
|
+
import { resolveDataSource } from "@rebasepro/common";
|
|
5
6
|
//#region src/hooks/useReferencePaths.ts
|
|
6
7
|
/**
|
|
7
8
|
* Where a reference points, as stored and as the admin addresses it.
|
|
8
9
|
*
|
|
9
|
-
* The two differ for a Firestore
|
|
10
|
+
* The two differ for a Firestore collection that declares a `path`
|
|
10
11
|
* for its store: `slug: "fs_diagnosis", path: "diagnosis"`. A reference stores
|
|
11
12
|
* `diagnosis`, because that is where its driver finds the record. The admin
|
|
12
13
|
* lists, routes and fetches by `fs_diagnosis`, and `diagnosis` can be the slug
|
|
13
14
|
* of a Postgres collection beside it — which is what declaring the `path` was
|
|
14
|
-
* for.
|
|
15
|
+
* for.
|
|
15
16
|
*
|
|
16
|
-
* A stored path is read in favour of the
|
|
17
|
+
* A **stored** path is read in favour of the reference's `driver` (the data
|
|
18
|
+
* source it points into), else of the data source of the collection in
|
|
17
19
|
* scope: a reference is read from a record, and points into that record's
|
|
18
|
-
* store unless
|
|
20
|
+
* store unless it says otherwise.
|
|
21
|
+
*
|
|
22
|
+
* A reference **property's** `path` names its target the way the admin
|
|
23
|
+
* addresses collections: by slug, whatever data source the target is on — so
|
|
24
|
+
* a Firestore field targeting `customers` means the Postgres `customers`
|
|
25
|
+
* collection even when a Firestore collection is stored at `customers`. A
|
|
26
|
+
* store path is read as one only where no collection has it as its slug.
|
|
19
27
|
*/
|
|
20
28
|
function useReferencePaths() {
|
|
21
29
|
const collectionRegistry = useCollectionRegistryController();
|
|
22
30
|
const scope = useCollectionScope();
|
|
23
31
|
const scopeDriver = scope?.dataSource ?? scope?.engine;
|
|
32
|
+
const scopeKey = resolveDataSource(scope).key;
|
|
24
33
|
return {
|
|
25
34
|
toCollectionPath: useCallback((path, driver) => collectionRegistry.resolveCollectionPath(path, driver ?? scopeDriver), [collectionRegistry, scopeDriver]),
|
|
26
|
-
|
|
35
|
+
targetPath: useCallback((path) => collectionRegistry.resolveCollectionPath(path), [collectionRegistry]),
|
|
36
|
+
referenceTo: useCallback((entity) => {
|
|
37
|
+
const targetKey = resolveDataSource(collectionRegistry.getCollection(entity.path)).key;
|
|
38
|
+
const driver = entity.driver ?? (targetKey !== scopeKey ? targetKey : void 0);
|
|
39
|
+
return getReferenceFrom({
|
|
40
|
+
...entity,
|
|
41
|
+
driver
|
|
42
|
+
}, collectionRegistry.resolveDataPath(entity.path));
|
|
43
|
+
}, [collectionRegistry, scopeKey])
|
|
27
44
|
};
|
|
28
45
|
}
|
|
29
46
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReferencePaths.js","names":[],"sources":["../../src/hooks/useReferencePaths.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"file":"useReferencePaths.js","names":[],"sources":["../../src/hooks/useReferencePaths.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport type { EntityReference, Entity } from \"@rebasepro/cms-types\";\nimport { useCollectionScope } from \"@rebasepro/app\";\nimport { resolveDataSource } from \"@rebasepro/common\";\nimport { getReferenceFrom } from \"@rebasepro/cms-types\";\nimport { useCollectionRegistryController } from \"./navigation/contexts/CollectionRegistryContext\";\n\n/**\n * Where a reference points, as stored and as the admin addresses it.\n *\n * The two differ for a Firestore collection that declares a `path`\n * for its store: `slug: \"fs_diagnosis\", path: \"diagnosis\"`. A reference stores\n * `diagnosis`, because that is where its driver finds the record. The admin\n * lists, routes and fetches by `fs_diagnosis`, and `diagnosis` can be the slug\n * of a Postgres collection beside it — which is what declaring the `path` was\n * for.\n *\n * A **stored** path is read in favour of the reference's `driver` (the data\n * source it points into), else of the data source of the collection in\n * scope: a reference is read from a record, and points into that record's\n * store unless it says otherwise.\n *\n * A reference **property's** `path` names its target the way the admin\n * addresses collections: by slug, whatever data source the target is on — so\n * a Firestore field targeting `customers` means the Postgres `customers`\n * collection even when a Firestore collection is stored at `customers`. A\n * store path is read as one only where no collection has it as its slug.\n */\nexport function useReferencePaths(): {\n /** The path the admin addresses the target of a stored reference by. */\n toCollectionPath: (path: string, driver?: string) => string;\n /** The path the admin addresses the target of a reference property's `path` by. */\n targetPath: (path: string) => string;\n /**\n * A reference to `entity`, carrying the path its record is stored under\n * and — when it lives in another data source than the collection in\n * scope — that source's key as its `driver`, which routes its preview\n * there and makes it stored as an id.\n */\n referenceTo: (entity: Entity<Record<string, unknown>>) => EntityReference;\n} {\n const collectionRegistry = useCollectionRegistryController();\n const scope = useCollectionScope();\n const scopeDriver = scope?.dataSource ?? scope?.engine;\n const scopeKey = resolveDataSource(scope).key;\n\n const toCollectionPath = useCallback(\n (path: string, driver?: string) => collectionRegistry.resolveCollectionPath(path, driver ?? scopeDriver),\n [collectionRegistry, scopeDriver]);\n\n const targetPath = useCallback(\n (path: string) => collectionRegistry.resolveCollectionPath(path),\n [collectionRegistry]);\n\n const referenceTo = useCallback(\n (entity: Entity<Record<string, unknown>>) => {\n const targetKey = resolveDataSource(collectionRegistry.getCollection(entity.path)).key;\n const driver = entity.driver ?? (targetKey !== scopeKey ? targetKey : undefined);\n return getReferenceFrom({ ...entity, driver }, collectionRegistry.resolveDataPath(entity.path));\n },\n [collectionRegistry, scopeKey]);\n\n return { toCollectionPath, targetPath, referenceTo };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,oBAYd;CACE,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,QAAQ,mBAAmB;CACjC,MAAM,cAAc,OAAO,cAAc,OAAO;CAChD,MAAM,WAAW,kBAAkB,KAAK,CAAC,CAAC;CAkB1C,OAAO;EAAE,kBAhBgB,aACpB,MAAc,WAAoB,mBAAmB,sBAAsB,MAAM,UAAU,WAAW,GACvG,CAAC,oBAAoB,WAAW,CAc3B;EAAkB,YAZR,aACd,SAAiB,mBAAmB,sBAAsB,IAAI,GAC/D,CAAC,kBAAkB,CAUI;EAAY,aARnB,aACf,WAA4C;GACzC,MAAM,YAAY,kBAAkB,mBAAmB,cAAc,OAAO,IAAI,CAAC,CAAC,CAAC;GACnF,MAAM,SAAS,OAAO,WAAW,cAAc,WAAW,YAAY,KAAA;GACtE,OAAO,iBAAiB;IAAE,GAAG;IAAQ;GAAO,GAAG,mBAAmB,gBAAgB,OAAO,IAAI,CAAC;EAClG,GACA,CAAC,oBAAoB,QAAQ,CAEM;CAAY;AACvD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EntityCustomView, AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
-
import {
|
|
3
|
-
import { RebaseContext } from "@rebasepro/cms-types";
|
|
2
|
+
import { SDKTableClient, User } from "@rebasepro/types";
|
|
3
|
+
import { RebaseContext, Entity } from "@rebasepro/cms-types";
|
|
4
4
|
/**
|
|
5
5
|
* @see resolveNavigationFrom
|
|
6
6
|
* @group Hooks and utilities
|
|
@@ -44,7 +44,7 @@ interface ResolvedNavigationEntityCustom<M extends Record<string, unknown>> {
|
|
|
44
44
|
*/
|
|
45
45
|
export type NavigationResolutionContext<USER extends User = User> = Pick<RebaseContext<USER>, "navigationStateController" | "collectionRegistryController"> & {
|
|
46
46
|
data: {
|
|
47
|
-
|
|
47
|
+
table(slug: string): Pick<SDKTableClient, "findById">;
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
@@ -24,7 +24,7 @@ function resolveNavigationFrom({ path, context }) {
|
|
|
24
24
|
if (entry.type === "collection") return Promise.resolve(entry);
|
|
25
25
|
else if (entry.type === "entity") {
|
|
26
26
|
if (!collectionRegistryController.getCollection(entry.slug)) throw Error(`No collection defined in the navigation for the entity with path ${entry.slug}`);
|
|
27
|
-
return data.
|
|
27
|
+
return data.table(entry.slug).findById(entry.entityId).then((row) => {
|
|
28
28
|
if (!row) return void 0;
|
|
29
29
|
const entity = {
|
|
30
30
|
id: entry.entityId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResolvedNavigationFrom.js","names":[],"sources":["../../src/hooks/useResolvedNavigationFrom.tsx"],"sourcesContent":["\nimport type { EntityCustomView, AdminCollection } from \"@rebasepro/cms-types\";\nimport {
|
|
1
|
+
{"version":3,"file":"useResolvedNavigationFrom.js","names":[],"sources":["../../src/hooks/useResolvedNavigationFrom.tsx"],"sourcesContent":["\nimport type { EntityCustomView, AdminCollection } from \"@rebasepro/cms-types\";\nimport { SDKTableClient, User } from \"@rebasepro/types\";\nimport { RebaseContext, Entity } from \"@rebasepro/cms-types\";\nimport { useEffect, useState, useMemo } from \"react\";\nimport { getNavigationEntriesFromPath } from \"@rebasepro/app\";\nimport { useAdminContext } from \"./useAdminContext\";\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\nexport type ResolvedNavigationEntry<M extends Record<string, unknown>> =\n | ResolvedNavigationEntity<M>\n | ResolvedNavigationCollection<M>\n | ResolvedNavigationEntityCustom<M>;\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\nexport interface ResolvedNavigationEntity<M extends Record<string, unknown>> {\n type: \"entity\";\n entity: Entity<M>;\n entityId: string | number;\n path: string;\n parentCollection: AdminCollection<M>;\n}\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\nexport interface ResolvedNavigationCollection<M extends Record<string, unknown>> {\n type: \"collection\";\n path: string;\n collection: AdminCollection<M>;\n}\n\n/**\n * @see resolveNavigationFrom\n * @group Hooks and utilities\n */\ninterface ResolvedNavigationEntityCustom<M extends Record<string, unknown>> {\n type: \"custom_view\";\n path: string;\n view: EntityCustomView<M>;\n}\n\n/**\n * What {@link resolveNavigationFrom} reads from the context it is handed: the\n * navigation and the registry, and `data` to read an entity by its id. A\n * `RebaseContext` is one.\n *\n * @group Hooks and utilities\n */\nexport type NavigationResolutionContext<USER extends User = User> =\n Pick<RebaseContext<USER>, \"navigationStateController\" | \"collectionRegistryController\"> & {\n data: { table(slug: string): Pick<SDKTableClient, \"findById\"> };\n };\n\n/**\n * Use this function to retrieve an array of navigation entries (resolved\n * collection, entity or entity custom_view) for the given path. You need to pass the app context\n * that you receive in different callbacks, such as the save hooks.\n *\n * It will take into account the `navigation` provided at the `Rebase` level.\n *\n * @param path\n * @param context\n * @group Hooks and utilities\n */\nexport function resolveNavigationFrom<M extends Record<string, unknown>, USER extends User>({\n path,\n context\n}: {\n path: string,\n context: NavigationResolutionContext<USER>\n}): Promise<ResolvedNavigationEntry<M>[]> {\n\n const data = context.data;\n const { navigationStateController, collectionRegistryController } = context;\n\n if (!navigationStateController || !collectionRegistryController) {\n throw Error(\"Calling resolveNavigationFrom, but main navigation has not yet been initialised\");\n }\n\n const navigationEntries = getNavigationEntriesFromPath({\n path,\n collections: collectionRegistryController.collections ?? []\n });\n\n const resultPromises: Promise<ResolvedNavigationEntry<any>>[] = navigationEntries\n .map((entry) => {\n if (entry.type === \"collection\") {\n return Promise.resolve(entry);\n } else if (entry.type === \"entity\") {\n const collection = collectionRegistryController.getCollection(entry.slug);\n if (!collection) {\n throw Error(`No collection defined in the navigation for the entity with path ${entry.slug}`);\n }\n // `context.data` is the flat SDK layer; re-wrap the row into the\n // Entity view-model the navigation entry expects. The address is\n // the one we just fetched by — reading it back off the row would\n // find nothing, since a row is only its columns.\n return data.table(entry.slug).findById(entry.entityId)\n .then((row) => {\n if (!row) return undefined;\n const entity = { id: entry.entityId, path: entry.slug, values: row };\n return { ...entry,\nentity };\n });\n } else if (entry.type === \"custom_view\") {\n return Promise.resolve(entry);\n } else {\n throw Error(\"Unmapped element in useEntitiesFromPath\");\n }\n })\n .filter(v => Boolean(v)) as Promise<ResolvedNavigationEntry<any>>[];\n\n return Promise.all(resultPromises);\n}\n\n/**\n * @group Hooks and utilities\n */\nexport interface NavigationFromProps {\n path: string;\n}\n\n/**\n * @group Hooks and utilities\n */\nexport interface NavigationFrom<M extends Record<string, unknown>> {\n data?: ResolvedNavigationEntry<M>[]\n dataLoading: boolean,\n dataLoadingError?: Error\n}\n\n/**\n * Use this hook to retrieve an array of navigation entries (resolved\n * collection or entity) for the given path. You can use this hook\n * in any React component that lives under `Rebase`\n * @group Hooks and utilities\n */\nexport function useResolvedNavigationFrom<M extends Record<string, unknown>>(\n {\n path\n }: NavigationFromProps): NavigationFrom<M> {\n\n const context = useAdminContext();\n const { navigationStateController, collectionRegistryController } = context;\n\n const [data, setData] = useState<ResolvedNavigationEntry<M>[] | undefined>();\n const [dataLoading, setDataLoading] = useState<boolean>(false);\n const [dataLoadingError, setDataLoadingError] = useState<Error | undefined>();\n\n useEffect(() => {\n if (navigationStateController && collectionRegistryController) {\n setDataLoading(true);\n setDataLoadingError(undefined);\n resolveNavigationFrom<M, User>({ path,\ncontext })\n .then(setData)\n .catch((e) => setDataLoadingError(e))\n .finally(() => setDataLoading(false));\n }\n\n }, [path, context]);\n\n return useMemo(() => {\n if (!navigationStateController) {\n return { dataLoading: true };\n }\n return { data,\ndataLoading,\ndataLoadingError };\n }, [navigationStateController, data, dataLoading, dataLoadingError]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwEA,SAAgB,sBAA4E,EACxF,MACA,WAIsC;CAEtC,MAAM,OAAO,QAAQ;CACrB,MAAM,EAAE,2BAA2B,iCAAiC;CAEpE,IAAI,CAAC,6BAA6B,CAAC,8BAC/B,MAAM,MAAM,iFAAiF;CAQjG,MAAM,iBALoB,6BAA6B;EACnD;EACA,aAAa,6BAA6B,eAAe,CAAC;CAC9D,CAEgE,CAAA,CAC3D,KAAK,UAAU;EACZ,IAAI,MAAM,SAAS,cACf,OAAO,QAAQ,QAAQ,KAAK;OACzB,IAAI,MAAM,SAAS,UAAU;GAEhC,IAAI,CADe,6BAA6B,cAAc,MAAM,IAC/D,GACD,MAAM,MAAM,oEAAoE,MAAM,MAAM;GAMhG,OAAO,KAAK,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,CAAC,CACjD,MAAM,QAAQ;IACX,IAAI,CAAC,KAAK,OAAO,KAAA;IACjB,MAAM,SAAS;KAAE,IAAI,MAAM;KAAU,MAAM,MAAM;KAAM,QAAQ;IAAI;IACnE,OAAO;KAAE,GAAG;KACpC;IAAO;GACa,CAAC;EACT,OAAO,IAAI,MAAM,SAAS,eACtB,OAAO,QAAQ,QAAQ,KAAK;OAE5B,MAAM,MAAM,yCAAyC;CAE7D,CAAC,CAAC,CACD,QAAO,MAAK,QAAQ,CAAC,CAAC;CAE3B,OAAO,QAAQ,IAAI,cAAc;AACrC;;;;;;;AAwBA,SAAgB,0BACZ,EACI,QACuC;CAE3C,MAAM,UAAU,gBAAgB;CAChC,MAAM,EAAE,2BAA2B,iCAAiC;CAEpE,MAAM,CAAC,MAAM,WAAW,SAAmD;CAC3E,MAAM,C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