@rebasepro/cms 0.30.1 → 0.31.0-canary.g59cd6fd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -6,19 +6,26 @@ import { useBuildCollectionRegistryController } from "../hooks/navigation/useBui
|
|
|
6
6
|
import { callerHoldsScope, reportsScopes } from "../util/caller_scopes.js";
|
|
7
7
|
import { useBuildNavigationStateController } from "../hooks/navigation/useBuildNavigationStateController.js";
|
|
8
8
|
import { useBuildUrlController } from "../hooks/navigation/useBuildUrlController.js";
|
|
9
|
+
import { withUserLayer } from "../hooks/navigation/ui_preferences.js";
|
|
9
10
|
import { ConfigControllerProvider } from "../collection_editor/ConfigControllerProvider.js";
|
|
10
11
|
import { SidePanelProvider } from "./SidePanelProvider.js";
|
|
12
|
+
import { composeCollectionsInput } from "../hooks/navigation/compose_collections_input.js";
|
|
13
|
+
import { usePanelTables } from "../hooks/navigation/usePanelTables.js";
|
|
11
14
|
import { CollectionsScopeContext } from "./CollectionsScopeContext.js";
|
|
12
15
|
import { useLocalCollectionsConfigController } from "../collection_editor/useLocalCollectionsConfigController.js";
|
|
13
16
|
import { useCollectionsConfigController } from "../collection_editor/useCollectionsConfigController.js";
|
|
14
|
-
import { Suspense, useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
17
|
+
import { Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
15
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
19
|
import { CircularProgressCenter, lazyChunk } from "@rebasepro/ui";
|
|
17
|
-
import { buildRoutedRebaseData
|
|
18
|
-
import { CollectionResolverRegistrationContext, CustomizationControllerContext, RebaseDataContext, StudioBridgeRegistryProvider, useAdminModeController, useAuthController, useBridgeRegistration, useCustomizationController, useData, useDataSources, useRebaseClient, useRebaseContext, useRebaseEmbedHost, useRebaseRegistry, useUserConfigurationPersistence } from "@rebasepro/app";
|
|
20
|
+
import { buildRoutedRebaseData } from "@rebasepro/cms-types";
|
|
21
|
+
import { CollectionResolverRegistrationContext, CustomizationControllerContext, RebaseDataContext, StudioBridgeRegistryProvider, UserConfigurationPersistenceContext, useAdminModeController, useAuthController, useBridgeRegistration, useCustomizationController, useData, useDataSources, useRebaseClient, useRebaseContext, useRebaseEmbedHost, useRebaseRegistry, useTranslation, useUiPreferences, useUserConfigurationPersistence } from "@rebasepro/app";
|
|
22
|
+
import { RebaseApiError } from "@rebasepro/types";
|
|
23
|
+
import { resolveDataSource } from "@rebasepro/common";
|
|
19
24
|
//#region src/components/RebaseNavigation.tsx
|
|
20
25
|
var EMPTY_PLUGINS = [];
|
|
21
|
-
var
|
|
26
|
+
var NO_COLLECTIONS = [];
|
|
27
|
+
var NO_CUSTOMIZATIONS = [];
|
|
28
|
+
var NO_EXTERNAL_COLLECTIONS = [];
|
|
22
29
|
var CollectionsStudioView = lazyChunk(() => import("../collection_editor/ui/collection_editor/RouterCollectionsStudioView.js").then((m) => ({ default: m.RouterCollectionsStudioView })));
|
|
23
30
|
/**
|
|
24
31
|
* Navigation layer — builds and provides all admin navigation controllers:
|
|
@@ -44,15 +51,55 @@ function RebaseNavigation({ children }) {
|
|
|
44
51
|
useEffect(() => prefetchRecordViews(), []);
|
|
45
52
|
const context = useRebaseContext();
|
|
46
53
|
const adminModeController = useAdminModeController();
|
|
47
|
-
const
|
|
54
|
+
const browserUserConfigPersistence = useUserConfigurationPersistence();
|
|
48
55
|
const collectionEditorConfig = registry.cmsConfig?.collectionEditor;
|
|
49
56
|
const collectionEditorEnabled = Boolean(collectionEditorConfig) || Boolean(registry.studioConfig);
|
|
50
57
|
const collectionEditorOptions = useMemo(() => {
|
|
51
58
|
if (collectionEditorConfig === true || !collectionEditorConfig) return {};
|
|
52
59
|
return collectionEditorConfig;
|
|
53
60
|
}, [collectionEditorConfig]);
|
|
54
|
-
const
|
|
55
|
-
const
|
|
61
|
+
const tableCustomizations = registry.cmsConfig?.tableCustomizations ?? NO_CUSTOMIZATIONS;
|
|
62
|
+
const externalCollections = registry.cmsConfig?.externalCollections ?? NO_EXTERNAL_COLLECTIONS;
|
|
63
|
+
const descriptors = usePanelTables(registry.cmsConfig?.tables, registry.cmsConfig !== null);
|
|
64
|
+
const servedTables = descriptors.tables;
|
|
65
|
+
const embeddedPreferences = useRebaseEmbedHost()?.uiPreferences;
|
|
66
|
+
const uiConfig = registry.cmsConfig?.uiConfig ?? embeddedPreferences?.file;
|
|
67
|
+
const preferencesClient = useRebaseClient();
|
|
68
|
+
const preferencesAuth = useAuthController();
|
|
69
|
+
const inEmbedding = useRebaseEmbedHost() !== void 0;
|
|
70
|
+
const uiPreferences = useUiPreferences({
|
|
71
|
+
transport: preferencesClient,
|
|
72
|
+
getAuthToken: preferencesAuth?.getAuthToken,
|
|
73
|
+
authKey: preferencesAuth?.user?.uid ?? null,
|
|
74
|
+
enabled: registry.cmsConfig !== null && Boolean(preferencesAuth?.user) && !inEmbedding,
|
|
75
|
+
local: browserUserConfigPersistence
|
|
76
|
+
});
|
|
77
|
+
const embeddedUser = embeddedPreferences?.user;
|
|
78
|
+
const userConfigPersistence = useMemo(() => embeddedUser && uiPreferences.userPersistence ? withUserLayer(uiPreferences.userPersistence, embeddedUser) : uiPreferences.userPersistence, [embeddedUser, uiPreferences.userPersistence]);
|
|
79
|
+
const workspacePreferences = embeddedPreferences?.workspace ?? uiPreferences.controller.workspace;
|
|
80
|
+
const [composedCollections, setComposedCollections] = useState(NO_COLLECTIONS);
|
|
81
|
+
const narrow = useRebaseEmbedHost()?.narrowCollections;
|
|
82
|
+
const collectionsBuilder = useMemo(() => {
|
|
83
|
+
const composed = composeCollectionsInput({
|
|
84
|
+
tables: servedTables,
|
|
85
|
+
tableCustomizations,
|
|
86
|
+
externalCollections,
|
|
87
|
+
uiConfig,
|
|
88
|
+
workspacePreferences
|
|
89
|
+
});
|
|
90
|
+
return async (params) => {
|
|
91
|
+
const collections = await composed(params);
|
|
92
|
+
setComposedCollections(collections);
|
|
93
|
+
return narrow ? narrow(collections) : collections;
|
|
94
|
+
};
|
|
95
|
+
}, [
|
|
96
|
+
servedTables,
|
|
97
|
+
tableCustomizations,
|
|
98
|
+
externalCollections,
|
|
99
|
+
uiConfig,
|
|
100
|
+
workspacePreferences,
|
|
101
|
+
narrow
|
|
102
|
+
]);
|
|
56
103
|
const dataSources = useDataSources();
|
|
57
104
|
const collectionRegistryController = useBuildCollectionRegistryController({
|
|
58
105
|
userConfigPersistence,
|
|
@@ -85,18 +132,19 @@ function RebaseNavigation({ children }) {
|
|
|
85
132
|
} : builtUrlController, [builtUrlController, embedded]);
|
|
86
133
|
const rebaseClient = useRebaseClient();
|
|
87
134
|
const authController = useAuthController();
|
|
88
|
-
const resolvedCollections = useMemo(() => Array.isArray(cmsCollections) ? cmsCollections : [], [cmsCollections]);
|
|
89
135
|
useEffect(() => {
|
|
90
136
|
if (process.env.NODE_ENV === "production") return;
|
|
91
137
|
const { registry, sources } = dataSources;
|
|
92
138
|
const missing = Object.values(registry).filter((d) => (d.transport === "direct" || d.transport === "custom") && !sources[d.key]).map((d) => d.key);
|
|
93
139
|
if (missing.length > 0) console.warn(`[Rebase] These data source(s) declare a direct/custom transport but have no client-side driver and will fall back to the default data source: ${missing.map((k) => `"${k}"`).join(", ")}. Provide a \`driver\` for them in \`dataSources\` on <Rebase>.`);
|
|
94
140
|
}, [dataSources]);
|
|
95
|
-
const internalConfigController = useLocalCollectionsConfigController(rebaseClient,
|
|
141
|
+
const internalConfigController = useLocalCollectionsConfigController(rebaseClient, composedCollections, collectionEditorEnabled ? {
|
|
96
142
|
readOnly: collectionEditorOptions?.readOnly,
|
|
97
143
|
getAuthToken: collectionEditorOptions?.getAuthToken ?? authController?.getAuthToken,
|
|
98
144
|
authKey: authController?.user?.uid ?? null,
|
|
99
|
-
mayReadSchema: reportsScopes(authController) ? callerHoldsScope(authController, "schema:read") : void 0
|
|
145
|
+
mayReadSchema: reportsScopes(authController) ? callerHoldsScope(authController, "schema:read") : void 0,
|
|
146
|
+
tables: servedTables,
|
|
147
|
+
presentation: { save: uiPreferences.controller.saveWorkspace }
|
|
100
148
|
} : { readOnly: true });
|
|
101
149
|
const schemaView = useMemo(() => {
|
|
102
150
|
if (!collectionEditorEnabled) return void 0;
|
|
@@ -135,9 +183,10 @@ function RebaseNavigation({ children }) {
|
|
|
135
183
|
return [...cmsViews, ...devViews];
|
|
136
184
|
}, [cmsViews, devViews]);
|
|
137
185
|
const parentCustomizationController = useCustomizationController();
|
|
138
|
-
const
|
|
186
|
+
const builtNavigationStateController = useBuildNavigationStateController({
|
|
139
187
|
plugins: parentCustomizationController.plugins ?? EMPTY_PLUGINS,
|
|
140
188
|
collections: collectionsBuilder,
|
|
189
|
+
collectionsPending: descriptors.status === "loading",
|
|
141
190
|
views: mergedViews,
|
|
142
191
|
navigationGroupMappings: registry.cmsConfig?.navigationGroupMappings,
|
|
143
192
|
authController: context.authController,
|
|
@@ -146,6 +195,29 @@ function RebaseNavigation({ children }) {
|
|
|
146
195
|
urlController,
|
|
147
196
|
adminMode: adminModeController?.mode
|
|
148
197
|
});
|
|
198
|
+
const { t } = useTranslation();
|
|
199
|
+
const tablesError = descriptors.status === "error" ? descriptors.error : void 0;
|
|
200
|
+
const reloadTables = descriptors.reload;
|
|
201
|
+
const tablesInUse = registry.cmsConfig !== null && !descriptors.unavailable;
|
|
202
|
+
const navigationStateController = useMemo(() => {
|
|
203
|
+
if (!tablesInUse) return builtNavigationStateController;
|
|
204
|
+
const signedOut = tablesError instanceof RebaseApiError && tablesError.status === 401;
|
|
205
|
+
const error = tablesError ? new Error(signedOut ? t("tables_load_signed_out") : t("tables_load_failed", { message: tablesError.message }), { cause: tablesError }) : void 0;
|
|
206
|
+
return {
|
|
207
|
+
...builtNavigationStateController,
|
|
208
|
+
navigationLoadingError: builtNavigationStateController.navigationLoadingError ?? error,
|
|
209
|
+
refreshNavigation: () => {
|
|
210
|
+
reloadTables();
|
|
211
|
+
builtNavigationStateController.refreshNavigation();
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}, [
|
|
215
|
+
builtNavigationStateController,
|
|
216
|
+
tablesInUse,
|
|
217
|
+
tablesError,
|
|
218
|
+
reloadTables,
|
|
219
|
+
t
|
|
220
|
+
]);
|
|
149
221
|
const enrichedCustomizationController = useMemo(() => {
|
|
150
222
|
const cmsEntityViews = registry.cmsConfig?.entityViews ?? [];
|
|
151
223
|
const cmsEntityActions = registry.cmsConfig?.entityActions ?? [];
|
|
@@ -163,27 +235,30 @@ function RebaseNavigation({ children }) {
|
|
|
163
235
|
registry.cmsConfig?.entityActions,
|
|
164
236
|
registry.cmsConfig?.collectionViews
|
|
165
237
|
]);
|
|
166
|
-
const navigationContent = /* @__PURE__ */ jsx(
|
|
167
|
-
value:
|
|
168
|
-
children: /* @__PURE__ */ jsx(
|
|
169
|
-
value:
|
|
170
|
-
children: /* @__PURE__ */ jsx(
|
|
171
|
-
value:
|
|
172
|
-
children: /* @__PURE__ */ jsx(
|
|
173
|
-
value:
|
|
174
|
-
children: /* @__PURE__ */ jsx(
|
|
175
|
-
value:
|
|
176
|
-
children: /* @__PURE__ */ jsx(
|
|
177
|
-
value:
|
|
178
|
-
children: /* @__PURE__ */
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
238
|
+
const navigationContent = /* @__PURE__ */ jsx(UserConfigurationPersistenceContext.Provider, {
|
|
239
|
+
value: userConfigPersistence,
|
|
240
|
+
children: /* @__PURE__ */ jsx(CollectionsScopeContext.Provider, {
|
|
241
|
+
value: true,
|
|
242
|
+
children: /* @__PURE__ */ jsx(RebaseDataContext.Provider, {
|
|
243
|
+
value: routedData,
|
|
244
|
+
children: /* @__PURE__ */ jsx(CustomizationControllerContext.Provider, {
|
|
245
|
+
value: enrichedCustomizationController,
|
|
246
|
+
children: /* @__PURE__ */ jsx(StudioBridgeRegistryProvider, { children: /* @__PURE__ */ jsx(CollectionRegistryContext.Provider, {
|
|
247
|
+
value: collectionRegistryController,
|
|
248
|
+
children: /* @__PURE__ */ jsx(UrlContext.Provider, {
|
|
249
|
+
value: urlController,
|
|
250
|
+
children: /* @__PURE__ */ jsx(NavigationStateContext.Provider, {
|
|
251
|
+
value: navigationStateController,
|
|
252
|
+
children: /* @__PURE__ */ jsxs(SidePanelProvider, { children: [/* @__PURE__ */ jsx(BridgeAutoRegistrar, {
|
|
253
|
+
collectionRegistryController,
|
|
254
|
+
urlController,
|
|
255
|
+
navigationStateController,
|
|
256
|
+
canWriteToCodebase: !internalConfigController.readOnly
|
|
257
|
+
}), children] })
|
|
258
|
+
})
|
|
184
259
|
})
|
|
185
|
-
})
|
|
186
|
-
})
|
|
260
|
+
}) })
|
|
261
|
+
})
|
|
187
262
|
})
|
|
188
263
|
})
|
|
189
264
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RebaseNavigation.js","names":[],"sources":["../../src/components/RebaseNavigation.tsx"],"sourcesContent":["import React, { useMemo, useRef, useEffect, useCallback, useContext, Suspense } from \"react\";\nimport {\n useRebaseRegistry,\n useRebaseContext,\n useAuthController,\n useCustomizationController,\n useAdminModeController,\n useUserConfigurationPersistence,\n useRebaseClient,\n useData,\n useDataSources,\n CollectionResolverRegistrationContext,\n StudioBridgeRegistryProvider,\n useBridgeRegistration,\n CustomizationControllerContext,\n RebaseDataContext,\n useRebaseEmbedHost\n} from \"@rebasepro/app\";\nimport { buildRoutedRebaseData, resolveDataSource } from \"@rebasepro/common\";\nimport { CircularProgressCenter, lazyChunk } from \"@rebasepro/ui\";\n\nimport type { AppView, CollectionCustomView, CollectionEditorOptions, EntityCustomView, EntityAction, RebasePlugin, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { CollectionRegistryController } from \"@rebasepro/types\";\nimport type { UrlController, NavigationStateController } from \"@rebasepro/cms-types\";\n\nconst EMPTY_PLUGINS: RebasePlugin[] = [];\nconst EMPTY_COLLECTIONS: AdminCollection[] = [];\n\nimport { useBuildNavigationStateController } from \"../hooks/navigation/useBuildNavigationStateController\";\nimport { useBuildUrlController } from \"../hooks/navigation/useBuildUrlController\";\nimport { useBuildCollectionRegistryController } from \"../hooks/navigation/useBuildCollectionRegistryController\";\n\nimport { CollectionRegistryContext } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { UrlContext } from \"../hooks/navigation/contexts/UrlContext\";\nimport { NavigationStateContext } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\nimport { SidePanelProvider } from \"./SidePanelProvider\";\nimport { CollectionsScopeContext } from \"./CollectionsScopeContext\";\nimport { prefetchRecordViews } from \"./lazy_record_views\";\n\n// Collection editor internals — used when collectionEditor is enabled\nimport { useLocalCollectionsConfigController } from \"../collection_editor/useLocalCollectionsConfigController\";\nimport { ConfigControllerProvider } from \"../collection_editor/ConfigControllerProvider\";\nimport { useCollectionsConfigController } from \"../collection_editor/useCollectionsConfigController\";\nimport { callerHoldsScope, reportsScopes } from \"../util/caller_scopes\";\n\n// Lazy-load the schema view — only fetched when studio schema tool is active\nconst CollectionsStudioView = lazyChunk(() =>\n import(\"../collection_editor/ui/collection_editor/RouterCollectionsStudioView\")\n .then(m => ({ default: m.RouterCollectionsStudioView }))\n);\n\nexport interface RebaseNavigationProps {\n children: React.ReactNode;\n}\n\n/**\n * Navigation layer — builds and provides all admin navigation controllers:\n * collection registry, URL controller, navigation state, side entity,\n * and the self-assembling Studio bridge.\n *\n * Also handles the collection editor config controller when enabled.\n *\n * **Independently usable**: Use this when you need admin navigation\n * (entity tables, side panels) in a custom layout.\n *\n * @example\n * ```tsx\n * <RebaseNavigation>\n * <MyCustomLayout>\n * <CollectionViewBinding ... />\n * </MyCustomLayout>\n * </RebaseNavigation>\n * ```\n */\nexport function RebaseNavigation({ children }: RebaseNavigationProps) {\n const registry = useRebaseRegistry();\n // Mounted behind the auth gate: someone is signed in, so the collection\n // table and record views are about to be wanted. Fetch them while idle.\n useEffect(() => prefetchRecordViews(), []);\n const context = useRebaseContext();\n const adminModeController = useAdminModeController();\n // The store the rest of the panel reads. Built one level up, by\n // `<Rebase>`, so the registry here and the collection views below merge\n // from the same cache — a second instance built here would keep its own.\n const userConfigPersistence = useUserConfigurationPersistence();\n\n // ── Collection Editor resolution ──────────────────────────────────\n // The collection editor is ALWAYS enabled when Studio is registered.\n // The `collectionEditor` admin config is for fine-tuning (readOnly, auth, etc.),\n // not for opting-in. When omitted, the editor defaults to enabled\n // (read-only in production).\n const collectionEditorConfig = registry.cmsConfig?.collectionEditor;\n const collectionEditorEnabled = Boolean(collectionEditorConfig) || Boolean(registry.studioConfig);\n const collectionEditorOptions: CollectionEditorOptions | undefined = useMemo(() => {\n if (collectionEditorConfig === true || !collectionEditorConfig) return {};\n return collectionEditorConfig;\n }, [collectionEditorConfig]);\n\n // ── Combine admin and Studio Configs ────────────────────────────────\n const cmsCollections = registry.cmsConfig?.collections ?? EMPTY_COLLECTIONS;\n\n // ── Build the navigation controllers ──────────────────────────────\n const collectionsBuilder = useMemo(() => Array.isArray(cmsCollections) ? () => [...cmsCollections] : cmsCollections, [cmsCollections]);\n\n const dataSources = useDataSources();\n const collectionRegistryController = useBuildCollectionRegistryController({ userConfigPersistence, dataSources: dataSources.registry });\n\n // ── Multi-data-source routing ─────────────────────────────────────\n // Combine the default data source (server transport) with the registered\n // direct/custom sources from <Rebase> and route each collection by its\n // resolved data-source key, looked up by path against the collection\n // registry. A stable resolver ref keeps the routed data instance\n // referentially stable across registry rebuilds, so data-effect\n // dependencies don't thrash.\n const defaultData = useData();\n const getCollectionRef = useRef(collectionRegistryController.getCollection);\n getCollectionRef.current = collectionRegistryController.getCollection;\n\n // Hand the data layer a way to read this registry. It was built by <Rebase>,\n // above us, and needs a collection's primary keys to give its rows an\n // address — rows themselves carry only columns.\n //\n // Registered during render, not in an effect: the views that fetch rows are\n // below us, and their effects run before ours, so an effect here would bind\n // after the first page had already been converted. The call only assigns a\n // ref, so repeating it per render is free.\n //\n // With it goes where each collection is stored: a direct driver has to be\n // handed the `path` a Firestore collection declares, not its slug.\n const registerCollectionResolver = useContext(CollectionResolverRegistrationContext);\n const resolveCollection = useCallback(\n (slug: string) => getCollectionRef.current(slug),\n []);\n registerCollectionResolver(resolveCollection, collectionRegistryController.resolveDataPath);\n const routedData = useMemo(() => buildRoutedRebaseData({\n defaultData,\n sources: dataSources.sources,\n resolveKey: (slugOrPath) => resolveDataSource(getCollectionRef.current(slugOrPath), dataSources.registry).key\n }), [defaultData, dataSources]);\n\n // Normalize the configured mount prefix to a leading-slash, no-trailing-slash\n // form (e.g. \"admin\" or \"/admin/\" -> \"/admin\"); empty/\"/\" stays \"/\".\n const basePath = useMemo(() => {\n const raw = registry.cmsConfig?.basePath;\n if (!raw || raw === \"/\") return \"/\";\n const trimmed = raw.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n return trimmed ? `/${trimmed}` : \"/\";\n }, [registry.cmsConfig?.basePath]);\n\n const builtUrlController = useBuildUrlController({\n basePath,\n baseCollectionPath: \"/c\",\n collectionRegistryController\n });\n // In an embedding (an MCP App view) no route draws a record's page: a\n // record opens over the screen, as it does under a CollectionsProvider.\n const embedded = useRebaseEmbedHost() !== undefined;\n const urlController = useMemo<UrlController>(() => embedded ? {\n ...builtUrlController,\n isUrlCollectionPath: () => false,\n routesMounted: false\n } : builtUrlController, [builtUrlController, embedded]);\n\n // ── Build config controller internally when collection editor is enabled ──\n const rebaseClient = useRebaseClient();\n const authController = useAuthController();\n const resolvedCollections = useMemo(\n () => Array.isArray(cmsCollections) ? cmsCollections : [],\n [cmsCollections]\n );\n\n // ── Dev-only data-source sanity check ─────────────────────────────\n // Warn about data sources declared with a direct/custom transport that\n // have no client-side driver — these silently fall back to the default\n // (server) source, a common source of misrouting. Unambiguous: it never\n // false-positives on server-mediated sources (which intentionally have\n // no client driver).\n useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n const { registry, sources } = dataSources;\n const missing = Object.values(registry)\n .filter((d) => (d.transport === \"direct\" || d.transport === \"custom\") && !sources[d.key])\n .map((d) => d.key);\n if (missing.length > 0) {\n console.warn(\n `[Rebase] These data source(s) declare a direct/custom transport but have no client-side driver and will fall back to the default data source: ${missing.map(k => `\"${k}\"`).join(\", \")}. ` +\n `Provide a \\`driver\\` for them in \\`dataSources\\` on <Rebase>.`\n );\n }\n }, [dataSources]);\n\n // `readOnly` is left undefined unless the developer set it: the controller\n // asks the backend whether its schema editor will accept a write, which is\n // the only process that knows. Deciding it here from `process.env.NODE_ENV`\n // — the *frontend bundle's* build mode — is what made the editor offer\n // itself against production backends, `baas` projects and servers without\n // `ts-morph`, and turned every save into a bare 404.\n //\n // Both of its status routes require `schema:read`. Asked by someone\n // without it, each answers 403 on every page load. So when the controller\n // reports scopes, it is not asked until they include that one. A\n // controller that does not report them leaves the backend to answer.\n const internalConfigController = useLocalCollectionsConfigController(\n rebaseClient,\n resolvedCollections,\n collectionEditorEnabled ? {\n readOnly: collectionEditorOptions?.readOnly,\n getAuthToken: collectionEditorOptions?.getAuthToken ?? authController?.getAuthToken,\n authKey: authController?.user?.uid ?? null,\n mayReadSchema: reportsScopes(authController)\n ? callerHoldsScope(authController, \"schema:read\")\n : undefined\n } : { readOnly: true }\n );\n\n // ── Auto-inject schema view into Studio devViews ──────────────────\n const schemaView: AppView | undefined = useMemo(() => {\n if (!collectionEditorEnabled) return undefined;\n // Only inject when Studio is registered and includes \"schema\" tool (or all tools)\n const studioTools = registry.studioConfig?.tools ?? [\"sql\", \"js\", \"rls\", \"schema\", \"storage\"];\n if (!registry.studioConfig || !studioTools.includes(\"schema\")) return undefined;\n return {\n slug: \"schema\",\n name: \"Edit collections\",\n group: \"Database\",\n icon: \"LayoutList\",\n nestedRoutes: true,\n // Reads the controller from context at render time rather than\n // capturing it here. A view is a React *element*, and the\n // navigation state controller resolves the view list once and holds\n // on to the elements it resolved — so a controller passed as a prop\n // is frozen at whatever it was on the first render, forever. That\n // hid every later change: the editor stayed writable after the\n // backend said it was read-only, and the collection list never\n // refreshed. Everything else in the editor already reads this from\n // `ConfigControllerProvider`, which wraps this subtree.\n view: (\n <Suspense fallback={<CircularProgressCenter/>}>\n <CollectionsStudioViewFromContext/>\n </Suspense>\n )\n };\n }, [collectionEditorEnabled, registry.studioConfig]);\n\n const devViews = useMemo(() => {\n const base = registry.studioConfig?.devViews ?? [];\n if (schemaView) return [...base, schemaView];\n return base;\n }, [registry.studioConfig?.devViews, schemaView]);\n\n // Merge admin-registered views with Studio dev views.\n // Order: admin views (developer's primary content) → Studio dev views (tooling).\n // Plugin views are merged later inside resolveAppViews.\n const cmsViews = registry.cmsConfig?.views;\n const mergedViews = useMemo(() => {\n if (!cmsViews) return devViews;\n if (Array.isArray(cmsViews) && cmsViews.length === 0) return devViews;\n // When cmsViews is a builder function, wrap it to append devViews after resolution\n if (typeof cmsViews === \"function\") {\n return async (params: Parameters<typeof cmsViews>[0]) => {\n const resolved = await cmsViews(params) ?? [];\n return [...resolved, ...devViews];\n };\n }\n return [...cmsViews, ...devViews];\n }, [cmsViews, devViews]);\n\n const parentCustomizationController = useCustomizationController();\n\n const navigationStateController = useBuildNavigationStateController({\n plugins: parentCustomizationController.plugins ?? EMPTY_PLUGINS,\n collections: collectionsBuilder,\n views: mergedViews,\n navigationGroupMappings: registry.cmsConfig?.navigationGroupMappings,\n authController: context.authController!,\n // The collection and view builders get the rows the server sends.\n data: context.data,\n collectionRegistryController,\n urlController,\n adminMode: adminModeController?.mode\n });\n\n // ── Merge admin-registered entityViews/entityActions into the customization controller ──\n // The <Rebase> component builds the customizationController from its own props,\n // but entity views passed to <RebaseCMS> are stored in the registry and not\n // automatically merged. We re-provide an enriched controller here so that\n // downstream consumers (EditViewBinding, side panels, etc.) can resolve\n // string-keyed entity views like \"blog_preview\".\n const enrichedCustomizationController = useMemo(() => {\n const cmsEntityViews = (registry.cmsConfig?.entityViews ?? []) as EntityCustomView[];\n const cmsEntityActions = (registry.cmsConfig?.entityActions ?? []) as EntityAction[];\n // Collection view modes ride the same channel, for the same reason:\n // `admin.customViews: [\"map\"]` has to find the component somewhere.\n const cmsCollectionViews = (registry.cmsConfig?.collectionViews ?? []) as CollectionCustomView[];\n if (cmsEntityViews.length === 0 && cmsEntityActions.length === 0 && cmsCollectionViews.length === 0) {\n return parentCustomizationController;\n }\n return {\n ...parentCustomizationController,\n entityViews: [\n ...(parentCustomizationController.entityViews ?? []),\n ...cmsEntityViews.filter(v => !(parentCustomizationController.entityViews ?? []).some(ev => ev.key === v.key))\n ],\n entityActions: [\n ...(parentCustomizationController.entityActions ?? []),\n ...cmsEntityActions.filter(a => !(parentCustomizationController.entityActions ?? []).some(ea => ea.key === a.key))\n ],\n collectionViews: [\n ...(parentCustomizationController.collectionViews ?? []),\n ...cmsCollectionViews.filter(v => !(parentCustomizationController.collectionViews ?? []).some(cv => cv.key === v.key))\n ]\n };\n }, [parentCustomizationController, registry.cmsConfig?.entityViews, registry.cmsConfig?.entityActions, registry.cmsConfig?.collectionViews]);\n\n // ── Inner content with all context providers ──────────────────────\n // Re-provide RebaseDataContext with the routed data so that every admin\n // consumer (list/entity views, references, board, import/export, and\n // `context.data`) is routed to the correct driver by collection path.\n const navigationContent = (\n <CollectionsScopeContext.Provider value={true}>\n <RebaseDataContext.Provider value={routedData}>\n <CustomizationControllerContext.Provider value={enrichedCustomizationController}>\n <StudioBridgeRegistryProvider>\n <CollectionRegistryContext.Provider value={collectionRegistryController}>\n <UrlContext.Provider value={urlController}>\n <NavigationStateContext.Provider value={navigationStateController}>\n <SidePanelProvider>\n <BridgeAutoRegistrar\n collectionRegistryController={collectionRegistryController}\n urlController={urlController}\n navigationStateController={navigationStateController}\n canWriteToCodebase={!internalConfigController.readOnly}\n />\n {children}\n </SidePanelProvider>\n </NavigationStateContext.Provider>\n </UrlContext.Provider>\n </CollectionRegistryContext.Provider>\n </StudioBridgeRegistryProvider>\n </CustomizationControllerContext.Provider>\n </RebaseDataContext.Provider>\n </CollectionsScopeContext.Provider>\n );\n\n // ── Wrap with ConfigControllerProvider when collection editor is enabled ──\n if (collectionEditorEnabled) {\n return (\n <ConfigControllerProvider\n collectionConfigController={internalConfigController}\n pathSuggestions={collectionEditorOptions?.pathSuggestions}\n >\n {navigationContent}\n </ConfigControllerProvider>\n );\n }\n\n return navigationContent;\n}\n\n/**\n * The injected \"Edit collections\" view, bound to the live config controller.\n *\n * Exists so the element stored in the navigation state does not close over a\n * controller instance — see the comment at its construction site.\n */\nfunction CollectionsStudioViewFromContext() {\n const configController = useCollectionsConfigController();\n return <CollectionsStudioView configController={configController}/>;\n}\n\n/**\n * Internal component that auto-registers admin controllers into the\n * self-assembling Studio bridge. Must be rendered inside both the\n * navigation contexts and the StudioBridgeRegistryProvider.\n */\nfunction BridgeAutoRegistrar({\n collectionRegistryController,\n urlController,\n navigationStateController,\n canWriteToCodebase\n}: {\n collectionRegistryController: CollectionRegistryController;\n urlController: UrlController;\n navigationStateController: NavigationStateController;\n canWriteToCodebase: boolean;\n}) {\n useBridgeRegistration(\"collectionRegistry\", collectionRegistryController);\n useBridgeRegistration(\"urlController\", urlController);\n useBridgeRegistration(\"navigationState\", navigationStateController);\n\n // Studio tools that would write into the project's collection source — the\n // RLS editor's policy save for a mapped table, its \"Import to codebase\" —\n // ask the bridge whether that write can land. The default is `true`, which\n // is what an admin panel sitting next to its own `collectionsDir` assumes;\n // it is wrong for exactly the same backends that make the collection editor\n // read-only, so the two now answer from one source.\n const capabilities = useMemo(() => ({ codebase: canWriteToCodebase }), [canWriteToCodebase]);\n useBridgeRegistration(\"capabilities\", capabilities);\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,IAAM,gBAAgC,CAAC;AACvC,IAAM,oBAAuC,CAAC;AAqB9C,IAAM,wBAAwB,gBAC1B,OAAO,2EAAwE,CAC1E,MAAK,OAAM,EAAE,SAAS,EAAE,4BAA4B,EAAE,CAC/D;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,iBAAiB,EAAE,YAAmC;CAClE,MAAM,WAAW,kBAAkB;CAGnC,gBAAgB,oBAAoB,GAAG,CAAC,CAAC;CACzC,MAAM,UAAU,iBAAiB;CACjC,MAAM,sBAAsB,uBAAuB;CAInD,MAAM,wBAAwB,gCAAgC;CAO9D,MAAM,yBAAyB,SAAS,WAAW;CACnD,MAAM,0BAA0B,QAAQ,sBAAsB,KAAK,QAAQ,SAAS,YAAY;CAChG,MAAM,0BAA+D,cAAc;EAC/E,IAAI,2BAA2B,QAAQ,CAAC,wBAAwB,OAAO,CAAC;EACxE,OAAO;CACX,GAAG,CAAC,sBAAsB,CAAC;CAG3B,MAAM,iBAAiB,SAAS,WAAW,eAAe;CAG1D,MAAM,qBAAqB,cAAc,MAAM,QAAQ,cAAc,UAAU,CAAC,GAAG,cAAc,IAAI,gBAAgB,CAAC,cAAc,CAAC;CAErI,MAAM,cAAc,eAAe;CACnC,MAAM,+BAA+B,qCAAqC;EAAE;EA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W;EAAe,SAAS,WAAW;CAAe,CAAC;CAM3I,MAAM,oBACF,oBAAC,wBAAwB,UAAzB;EAAkC,OAAO;YACzC,oBAAC,kBAAkB,UAAnB;GAA4B,OAAO;aACnC,oBAAC,+BAA+B,UAAhC;IAAyC,OAAO;cAChD,oBAAC,8BAAD,EAAA,UACI,oBAAC,0BAA0B,UAA3B;KAAoC,OAAO;eACvC,oBAAC,WAAW,UAAZ;MAAqB,OAAO;gBACxB,oBAAC,uBAAuB,UAAxB;OAAiC,OAAO;iBACpC,qBAAC,mBAAD,EAAA,UAAA,CACI,oBAAC,qBAAD;QACkC;QACf;QACY;QAC3B,oBAAoB,CAAC,yBAAyB;OACjD,CAAA,GACA,QACc,EAAA,CAAA;MACU,CAAA;KAChB,CAAA;IACW,CAAA,EACV,CAAA;GACW,CAAA;EACb,CAAA;CACM,CAAA;CAItC,IAAI,yBACA,OACI,oBAAC,0BAAD;EACI,4BAA4B;EAC5B,iBAAiB,yBAAyB;YAEzC;CACqB,CAAA;CAIlC,OAAO;AACX;;;;;;;AAQA,SAAS,mCAAmC;CAExC,OAAO,oBAAC,uBAAD,EAAyC,kBADvB,+BACuB,EAAkB,CAAA;AACtE;;;;;;AAOA,SAAS,oBAAoB,EACzB,8BACA,eACA,2BACA,sBAMD;CACC,sBAAsB,sBAAsB,4BAA4B;CACxE,sBAAsB,iBAAiB,aAAa;CACpD,sBAAsB,mBAAmB,yBAAyB;CASlE,sBAAsB,gBADD,eAAe,EAAE,UAAU,mBAAmB,IAAI,CAAC,kBAAkB,CACpD,CAAY;CAClD,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"RebaseNavigation.js","names":[],"sources":["../../src/components/RebaseNavigation.tsx"],"sourcesContent":["import React, { useMemo, useRef, useEffect, useCallback, useContext, useState, Suspense } from \"react\";\nimport {\n useRebaseRegistry,\n useRebaseContext,\n useAuthController,\n useCustomizationController,\n useAdminModeController,\n useUserConfigurationPersistence,\n useRebaseClient,\n useData,\n useDataSources,\n CollectionResolverRegistrationContext,\n StudioBridgeRegistryProvider,\n useBridgeRegistration,\n CustomizationControllerContext,\n RebaseDataContext,\n UserConfigurationPersistenceContext,\n useRebaseEmbedHost,\n useTranslation,\n useUiPreferences\n} from \"@rebasepro/app\";\nimport { resolveDataSource } from \"@rebasepro/common\";\nimport { buildRoutedRebaseData } from \"@rebasepro/cms-types\";\nimport { CircularProgressCenter, lazyChunk } from \"@rebasepro/ui\";\n\nimport type { AppView, CollectionCustomView, CollectionEditorOptions, EntityCustomView, EntityAction, RebasePlugin, AdminCollection, TableCustomization } from \"@rebasepro/cms-types\";\nimport { RebaseApiError } from \"@rebasepro/types\";\nimport type { UrlController, NavigationStateController, CollectionRegistryController } from \"@rebasepro/cms-types\";\n\nconst EMPTY_PLUGINS: RebasePlugin[] = [];\nconst NO_COLLECTIONS: AdminCollection[] = [];\nconst NO_CUSTOMIZATIONS: readonly TableCustomization[] = [];\nconst NO_EXTERNAL_COLLECTIONS: readonly AdminCollection[] = [];\n\nimport { useBuildNavigationStateController } from \"../hooks/navigation/useBuildNavigationStateController\";\nimport { useBuildUrlController } from \"../hooks/navigation/useBuildUrlController\";\nimport { useBuildCollectionRegistryController } from \"../hooks/navigation/useBuildCollectionRegistryController\";\nimport { composeCollectionsInput } from \"../hooks/navigation/compose_collections_input\";\nimport { withUserLayer } from \"../hooks/navigation/ui_preferences\";\nimport { usePanelTables } from \"../hooks/navigation/usePanelTables\";\n\nimport { CollectionRegistryContext } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { UrlContext } from \"../hooks/navigation/contexts/UrlContext\";\nimport { NavigationStateContext } from \"../hooks/navigation/contexts/NavigationStateContext\";\n\nimport { SidePanelProvider } from \"./SidePanelProvider\";\nimport { CollectionsScopeContext } from \"./CollectionsScopeContext\";\nimport { prefetchRecordViews } from \"./lazy_record_views\";\n\n// Collection editor internals — used when collectionEditor is enabled\nimport { useLocalCollectionsConfigController } from \"../collection_editor/useLocalCollectionsConfigController\";\nimport { ConfigControllerProvider } from \"../collection_editor/ConfigControllerProvider\";\nimport { useCollectionsConfigController } from \"../collection_editor/useCollectionsConfigController\";\nimport { callerHoldsScope, reportsScopes } from \"../util/caller_scopes\";\n\n// Lazy-load the schema view — only fetched when studio schema tool is active\nconst CollectionsStudioView = lazyChunk(() =>\n import(\"../collection_editor/ui/collection_editor/RouterCollectionsStudioView\")\n .then(m => ({ default: m.RouterCollectionsStudioView }))\n);\n\nexport interface RebaseNavigationProps {\n children: React.ReactNode;\n}\n\n/**\n * Navigation layer — builds and provides all admin navigation controllers:\n * collection registry, URL controller, navigation state, side entity,\n * and the self-assembling Studio bridge.\n *\n * Also handles the collection editor config controller when enabled.\n *\n * **Independently usable**: Use this when you need admin navigation\n * (entity tables, side panels) in a custom layout.\n *\n * @example\n * ```tsx\n * <RebaseNavigation>\n * <MyCustomLayout>\n * <CollectionViewBinding ... />\n * </MyCustomLayout>\n * </RebaseNavigation>\n * ```\n */\nexport function RebaseNavigation({ children }: RebaseNavigationProps) {\n const registry = useRebaseRegistry();\n // Mounted behind the auth gate: someone is signed in, so the collection\n // table and record views are about to be wanted. Fetch them while idle.\n useEffect(() => prefetchRecordViews(), []);\n const context = useRebaseContext();\n const adminModeController = useAdminModeController();\n // The store the rest of the panel reads. Built one level up, by\n // `<Rebase>`, so the registry here and the collection views below merge\n // from the same cache — a second instance built here would keep its own.\n const browserUserConfigPersistence = useUserConfigurationPersistence();\n\n // ── Collection Editor resolution ──────────────────────────────────\n // The collection editor is ALWAYS enabled when Studio is registered.\n // The `collectionEditor` admin config is for fine-tuning (readOnly, auth, etc.),\n // not for opting-in. When omitted, the editor defaults to enabled\n // (read-only in production).\n const collectionEditorConfig = registry.cmsConfig?.collectionEditor;\n const collectionEditorEnabled = Boolean(collectionEditorConfig) || Boolean(registry.studioConfig);\n const collectionEditorOptions: CollectionEditorOptions | undefined = useMemo(() => {\n if (collectionEditorConfig === true || !collectionEditorConfig) return {};\n return collectionEditorConfig;\n }, [collectionEditorConfig]);\n\n // ── The collections: served tables and external ones ──────────────\n // Every table the server serves the signed-in user (or the ones handed\n // to <RebaseCMS tables>), projected and customized, beside the\n // collections whose rows live elsewhere (Firestore). Only with a\n // <RebaseCMS> registered: a Studio alone shows no collections.\n const tableCustomizations = registry.cmsConfig?.tableCustomizations ?? NO_CUSTOMIZATIONS;\n const externalCollections = registry.cmsConfig?.externalCollections ?? NO_EXTERNAL_COLLECTIONS;\n const descriptors = usePanelTables(registry.cmsConfig?.tables, registry.cmsConfig !== null);\n const servedTables = descriptors.tables;\n // In an embedding (an MCP App view) the panel asks the server for no\n // preferences: the embedding received them with the screen, and they are\n // folded here exactly as the panel's own — the server's `ui-config.json`\n // where the app passes no `uiConfig` of its own.\n const embeddedPreferences = useRebaseEmbedHost()?.uiPreferences;\n const uiConfig = registry.cmsConfig?.uiConfig ?? embeddedPreferences?.file;\n\n // ── UI preferences: the workspace's, and the signed-in user's own ──\n // How each table is presented, as the collection editor saved it for\n // everybody and as the views remember it for this user. The user's live\n // on the server when it keeps them, in the browser otherwise; everything\n // below reads them through the persistence provided here.\n const preferencesClient = useRebaseClient();\n const preferencesAuth = useAuthController();\n const inEmbedding = useRebaseEmbedHost() !== undefined;\n const uiPreferences = useUiPreferences({\n transport: preferencesClient,\n getAuthToken: preferencesAuth?.getAuthToken,\n authKey: preferencesAuth?.user?.uid ?? null,\n enabled: registry.cmsConfig !== null && Boolean(preferencesAuth?.user) && !inEmbedding,\n local: browserUserConfigPersistence\n });\n const embeddedUser = embeddedPreferences?.user;\n const userConfigPersistence = useMemo(\n () => embeddedUser && uiPreferences.userPersistence\n ? withUserLayer(uiPreferences.userPersistence, embeddedUser)\n : uiPreferences.userPersistence,\n [embeddedUser, uiPreferences.userPersistence]);\n const workspacePreferences = embeddedPreferences?.workspace ?? uiPreferences.controller.workspace;\n\n // What the composition last produced, for the collection editor, which\n // lists and edits the collections the panel shows.\n const [composedCollections, setComposedCollections] = useState<AdminCollection[]>(NO_COLLECTIONS);\n\n // In an embedding (an MCP App view, `embed_host.ts`), the collections are\n // the app's own — custom fields, previews, views and actions included —\n // narrowed to what the person may see and do there.\n const narrow = useRebaseEmbedHost()?.narrowCollections;\n\n // ── Build the navigation controllers ──────────────────────────────\n const collectionsBuilder = useMemo(() => {\n const composed = composeCollectionsInput({\n tables: servedTables,\n tableCustomizations,\n externalCollections,\n uiConfig,\n workspacePreferences\n });\n return async (params: Parameters<typeof composed>[0]) => {\n const collections = await composed(params);\n setComposedCollections(collections);\n return narrow ? narrow(collections) : collections;\n };\n }, [servedTables, tableCustomizations, externalCollections, uiConfig, workspacePreferences, narrow]);\n\n const dataSources = useDataSources();\n const collectionRegistryController = useBuildCollectionRegistryController({ userConfigPersistence, dataSources: dataSources.registry });\n\n // ── Multi-data-source routing ─────────────────────────────────────\n // Combine the default data source (server transport) with the registered\n // direct/custom sources from <Rebase> and route each collection by its\n // resolved data-source key, looked up by path against the collection\n // registry. A stable resolver ref keeps the routed data instance\n // referentially stable across registry rebuilds, so data-effect\n // dependencies don't thrash.\n const defaultData = useData();\n const getCollectionRef = useRef(collectionRegistryController.getCollection);\n getCollectionRef.current = collectionRegistryController.getCollection;\n\n // Hand the data layer a way to read this registry. It was built by <Rebase>,\n // above us, and needs a collection's primary keys to give its rows an\n // address — rows themselves carry only columns.\n //\n // Registered during render, not in an effect: the views that fetch rows are\n // below us, and their effects run before ours, so an effect here would bind\n // after the first page had already been converted. The call only assigns a\n // ref, so repeating it per render is free.\n //\n // With it goes where each collection is stored: a direct driver has to be\n // handed the `path` a Firestore collection declares, not its slug.\n const registerCollectionResolver = useContext(CollectionResolverRegistrationContext);\n const resolveCollection = useCallback(\n (slug: string) => getCollectionRef.current(slug),\n []);\n registerCollectionResolver(resolveCollection, collectionRegistryController.resolveDataPath);\n const routedData = useMemo(() => buildRoutedRebaseData({\n defaultData,\n sources: dataSources.sources,\n resolveKey: (slugOrPath) => resolveDataSource(getCollectionRef.current(slugOrPath), dataSources.registry).key\n }), [defaultData, dataSources]);\n\n // Normalize the configured mount prefix to a leading-slash, no-trailing-slash\n // form (e.g. \"admin\" or \"/admin/\" -> \"/admin\"); empty/\"/\" stays \"/\".\n const basePath = useMemo(() => {\n const raw = registry.cmsConfig?.basePath;\n if (!raw || raw === \"/\") return \"/\";\n const trimmed = raw.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n return trimmed ? `/${trimmed}` : \"/\";\n }, [registry.cmsConfig?.basePath]);\n\n const builtUrlController = useBuildUrlController({\n basePath,\n baseCollectionPath: \"/c\",\n collectionRegistryController\n });\n // In an embedding (an MCP App view) no route draws a record's page: a\n // record opens over the screen, as it does under a CollectionsProvider.\n const embedded = useRebaseEmbedHost() !== undefined;\n const urlController = useMemo<UrlController>(() => embedded ? {\n ...builtUrlController,\n isUrlCollectionPath: () => false,\n routesMounted: false\n } : builtUrlController, [builtUrlController, embedded]);\n\n // ── Build config controller internally when collection editor is enabled ──\n const rebaseClient = useRebaseClient();\n const authController = useAuthController();\n\n // ── Dev-only data-source sanity check ─────────────────────────────\n // Warn about data sources declared with a direct/custom transport that\n // have no client-side driver — these silently fall back to the default\n // (server) source, a common source of misrouting. Unambiguous: it never\n // false-positives on server-mediated sources (which intentionally have\n // no client driver).\n useEffect(() => {\n if (process.env.NODE_ENV === \"production\") return;\n const { registry, sources } = dataSources;\n const missing = Object.values(registry)\n .filter((d) => (d.transport === \"direct\" || d.transport === \"custom\") && !sources[d.key])\n .map((d) => d.key);\n if (missing.length > 0) {\n console.warn(\n `[Rebase] These data source(s) declare a direct/custom transport but have no client-side driver and will fall back to the default data source: ${missing.map(k => `\"${k}\"`).join(\", \")}. ` +\n `Provide a \\`driver\\` for them in \\`dataSources\\` on <Rebase>.`\n );\n }\n }, [dataSources]);\n\n // `readOnly` is left undefined unless the developer set it: the controller\n // asks the backend whether its schema editor will accept a write, which is\n // the only process that knows. Deciding it here from `process.env.NODE_ENV`\n // — the *frontend bundle's* build mode — is what made the editor offer\n // itself against production backends, `baas` projects and servers without\n // `ts-morph`, and turned every save into a bare 404.\n //\n // Both of its status routes require `schema:read`. Asked by someone\n // without it, each answers 403 on every page load. So when the controller\n // reports scopes, it is not asked until they include that one. A\n // controller that does not report them leaves the backend to answer.\n const internalConfigController = useLocalCollectionsConfigController(\n rebaseClient,\n composedCollections,\n collectionEditorEnabled ? {\n readOnly: collectionEditorOptions?.readOnly,\n getAuthToken: collectionEditorOptions?.getAuthToken ?? authController?.getAuthToken,\n authKey: authController?.user?.uid ?? null,\n mayReadSchema: reportsScopes(authController)\n ? callerHoldsScope(authController, \"schema:read\")\n : undefined,\n tables: servedTables,\n presentation: { save: uiPreferences.controller.saveWorkspace }\n } : { readOnly: true }\n );\n\n // ── Auto-inject schema view into Studio devViews ──────────────────\n const schemaView: AppView | undefined = useMemo(() => {\n if (!collectionEditorEnabled) return undefined;\n // Only inject when Studio is registered and includes \"schema\" tool (or all tools)\n const studioTools = registry.studioConfig?.tools ?? [\"sql\", \"js\", \"rls\", \"schema\", \"storage\"];\n if (!registry.studioConfig || !studioTools.includes(\"schema\")) return undefined;\n return {\n slug: \"schema\",\n name: \"Edit collections\",\n group: \"Database\",\n icon: \"LayoutList\",\n nestedRoutes: true,\n // Reads the controller from context at render time rather than\n // capturing it here. A view is a React *element*, and the\n // navigation state controller resolves the view list once and holds\n // on to the elements it resolved — so a controller passed as a prop\n // is frozen at whatever it was on the first render, forever. That\n // hid every later change: the editor stayed writable after the\n // backend said it was read-only, and the collection list never\n // refreshed. Everything else in the editor already reads this from\n // `ConfigControllerProvider`, which wraps this subtree.\n view: (\n <Suspense fallback={<CircularProgressCenter/>}>\n <CollectionsStudioViewFromContext/>\n </Suspense>\n )\n };\n }, [collectionEditorEnabled, registry.studioConfig]);\n\n const devViews = useMemo(() => {\n const base = registry.studioConfig?.devViews ?? [];\n if (schemaView) return [...base, schemaView];\n return base;\n }, [registry.studioConfig?.devViews, schemaView]);\n\n // Merge admin-registered views with Studio dev views.\n // Order: admin views (developer's primary content) → Studio dev views (tooling).\n // Plugin views are merged later inside resolveAppViews.\n const cmsViews = registry.cmsConfig?.views;\n const mergedViews = useMemo(() => {\n if (!cmsViews) return devViews;\n if (Array.isArray(cmsViews) && cmsViews.length === 0) return devViews;\n // When cmsViews is a builder function, wrap it to append devViews after resolution\n if (typeof cmsViews === \"function\") {\n return async (params: Parameters<typeof cmsViews>[0]) => {\n const resolved = await cmsViews(params) ?? [];\n return [...resolved, ...devViews];\n };\n }\n return [...cmsViews, ...devViews];\n }, [cmsViews, devViews]);\n\n const parentCustomizationController = useCustomizationController();\n\n const builtNavigationStateController = useBuildNavigationStateController({\n plugins: parentCustomizationController.plugins ?? EMPTY_PLUGINS,\n collections: collectionsBuilder,\n // Until the tables arrive, no route that needs a collection renders:\n // they show the loading state, not \"collection not found\", and a deep\n // link resolves once the collections built from them are registered.\n collectionsPending: descriptors.status === \"loading\",\n views: mergedViews,\n navigationGroupMappings: registry.cmsConfig?.navigationGroupMappings,\n authController: context.authController!,\n // The collection and view builders get the rows the server sends.\n data: context.data,\n collectionRegistryController,\n urlController,\n adminMode: adminModeController?.mode\n });\n\n // A failure to load the tables is the navigation's loading error: the home\n // page and a route to a collection that could not be built say what failed\n // and offer to retry. A session the server no longer accepts is the\n // client's to renew, and it signs out when it cannot — so the error says to\n // sign in again.\n //\n // Refreshing the navigation asks for the tables again too: it is what the\n // collection editor calls after it changed the schema, and with an `ETag`\n // an unchanged schema costs a 304.\n const { t } = useTranslation();\n const tablesError = descriptors.status === \"error\" ? descriptors.error : undefined;\n const reloadTables = descriptors.reload;\n const tablesInUse = registry.cmsConfig !== null && !descriptors.unavailable;\n const navigationStateController = useMemo<NavigationStateController>(() => {\n if (!tablesInUse) return builtNavigationStateController;\n const signedOut = tablesError instanceof RebaseApiError && tablesError.status === 401;\n const error = tablesError\n ? new Error(signedOut\n ? t(\"tables_load_signed_out\")\n : t(\"tables_load_failed\", { message: tablesError.message }), { cause: tablesError })\n : undefined;\n return {\n ...builtNavigationStateController,\n navigationLoadingError: builtNavigationStateController.navigationLoadingError ?? error,\n refreshNavigation: () => {\n reloadTables();\n builtNavigationStateController.refreshNavigation();\n }\n };\n }, [builtNavigationStateController, tablesInUse, tablesError, reloadTables, t]);\n\n // ── Merge admin-registered entityViews/entityActions into the customization controller ──\n // The <Rebase> component builds the customizationController from its own props,\n // but entity views passed to <RebaseCMS> are stored in the registry and not\n // automatically merged. We re-provide an enriched controller here so that\n // downstream consumers (EditViewBinding, side panels, etc.) can resolve\n // string-keyed entity views like \"blog_preview\".\n const enrichedCustomizationController = useMemo(() => {\n const cmsEntityViews = (registry.cmsConfig?.entityViews ?? []) as EntityCustomView[];\n const cmsEntityActions = (registry.cmsConfig?.entityActions ?? []) as EntityAction[];\n // Collection view modes ride the same channel, for the same reason:\n // `admin.customViews: [\"map\"]` has to find the component somewhere.\n const cmsCollectionViews = (registry.cmsConfig?.collectionViews ?? []) as CollectionCustomView[];\n if (cmsEntityViews.length === 0 && cmsEntityActions.length === 0 && cmsCollectionViews.length === 0) {\n return parentCustomizationController;\n }\n return {\n ...parentCustomizationController,\n entityViews: [\n ...(parentCustomizationController.entityViews ?? []),\n ...cmsEntityViews.filter(v => !(parentCustomizationController.entityViews ?? []).some(ev => ev.key === v.key))\n ],\n entityActions: [\n ...(parentCustomizationController.entityActions ?? []),\n ...cmsEntityActions.filter(a => !(parentCustomizationController.entityActions ?? []).some(ea => ea.key === a.key))\n ],\n collectionViews: [\n ...(parentCustomizationController.collectionViews ?? []),\n ...cmsCollectionViews.filter(v => !(parentCustomizationController.collectionViews ?? []).some(cv => cv.key === v.key))\n ]\n };\n }, [parentCustomizationController, registry.cmsConfig?.entityViews, registry.cmsConfig?.entityActions, registry.cmsConfig?.collectionViews]);\n\n // ── Inner content with all context providers ──────────────────────\n // Re-provide RebaseDataContext with the routed data so that every admin\n // consumer (list/entity views, references, board, import/export, and\n // `context.data`) is routed to the correct driver by collection path.\n const navigationContent = (\n <UserConfigurationPersistenceContext.Provider value={userConfigPersistence}>\n <CollectionsScopeContext.Provider value={true}>\n <RebaseDataContext.Provider value={routedData}>\n <CustomizationControllerContext.Provider value={enrichedCustomizationController}>\n <StudioBridgeRegistryProvider>\n <CollectionRegistryContext.Provider value={collectionRegistryController}>\n <UrlContext.Provider value={urlController}>\n <NavigationStateContext.Provider value={navigationStateController}>\n <SidePanelProvider>\n <BridgeAutoRegistrar\n collectionRegistryController={collectionRegistryController}\n urlController={urlController}\n navigationStateController={navigationStateController}\n canWriteToCodebase={!internalConfigController.readOnly}\n />\n {children}\n </SidePanelProvider>\n </NavigationStateContext.Provider>\n </UrlContext.Provider>\n </CollectionRegistryContext.Provider>\n </StudioBridgeRegistryProvider>\n </CustomizationControllerContext.Provider>\n </RebaseDataContext.Provider>\n </CollectionsScopeContext.Provider>\n </UserConfigurationPersistenceContext.Provider>\n );\n\n // ── Wrap with ConfigControllerProvider when collection editor is enabled ──\n if (collectionEditorEnabled) {\n return (\n <ConfigControllerProvider\n collectionConfigController={internalConfigController}\n pathSuggestions={collectionEditorOptions?.pathSuggestions}\n >\n {navigationContent}\n </ConfigControllerProvider>\n );\n }\n\n return navigationContent;\n}\n\n/**\n * The injected \"Edit collections\" view, bound to the live config controller.\n *\n * Exists so the element stored in the navigation state does not close over a\n * controller instance — see the comment at its construction site.\n */\nfunction CollectionsStudioViewFromContext() {\n const configController = useCollectionsConfigController();\n return <CollectionsStudioView configController={configController}/>;\n}\n\n/**\n * Internal component that auto-registers admin controllers into the\n * self-assembling Studio bridge. Must be rendered inside both the\n * navigation contexts and the StudioBridgeRegistryProvider.\n */\nfunction BridgeAutoRegistrar({\n collectionRegistryController,\n urlController,\n navigationStateController,\n canWriteToCodebase\n}: {\n collectionRegistryController: CollectionRegistryController;\n urlController: UrlController;\n navigationStateController: NavigationStateController;\n canWriteToCodebase: boolean;\n}) {\n useBridgeRegistration(\"collectionRegistry\", collectionRegistryController);\n useBridgeRegistration(\"urlController\", urlController);\n useBridgeRegistration(\"navigationState\", navigationStateController);\n\n // Studio tools that would write into the project's collection source — the\n // RLS editor's policy save for a mapped table, its \"Import to codebase\" —\n // ask the bridge whether that write can land. The default is `true`, which\n // is what an admin panel sitting next to its own `collectionsDir` assumes;\n // it is wrong for exactly the same backends that make the collection editor\n // read-only, so the two now answer from one source.\n const capabilities = useMemo(() => ({ codebase: canWriteToCodebase }), [canWriteToCodebase]);\n useBridgeRegistration(\"capabilities\", capabilities);\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,gBAAgC,CAAC;AACvC,IAAM,iBAAoC,CAAC;AAC3C,IAAM,oBAAmD,CAAC;AAC1D,IAAM,0BAAsD,CAAC;AAwB7D,IAAM,wBAAwB,gBAC1B,OAAO,2EAAwE,CAC1E,MAAK,OAAM,EAAE,SAAS,EAAE,4BAA4B,EAAE,CAC/D;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,iBAAiB,EAAE,YAAmC;CAClE,MAAM,WAAW,kBAAkB;CAGnC,gBAAgB,oBAAoB,GAAG,CAAC,CAAC;CACzC,MAAM,UAAU,iBAAiB;CACjC,MAAM,sBAAsB,uBAAuB;CAInD,MAAM,+BAA+B,gCAAgC;CAOrE,MAAM,yBAAyB,SAAS,WAAW;CACnD,MAAM,0BAA0B,QAAQ,sBAAsB,KAAK,QAAQ,SAAS,YAAY;CAChG,MAAM,0BAA+D,cAAc;EAC/E,IAAI,2BAA2B,QAAQ,CAAC,wBAAwB,OAAO,CAAC;EACxE,OAAO;CACX,GAAG,CAAC,sBAAsB,CAAC;CAO3B,MAAM,sBAAsB,SAAS,WAAW,uBAAuB;CACvE,MAAM,sBAAsB,SAAS,WAAW,uBAAuB;CACvE,MAAM,cAAc,eAAe,SAAS,WAAW,QAAQ,SAAS,cAAc,IAAI;CAC1F,MAAM,eAAe,YAAY;CAKjC,MAAM,sBAAsB,mBAAmB,CAAC,EAAE;CAClD,MAAM,WAAW,SAAS,WAAW,YAAY,qBAAqB;CAOtE,MAAM,oBAAoB,gBAAgB;CAC1C,MAAM,kBAAk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AAY;CAClD,OAAO;AACX"}
|
|
@@ -11,6 +11,8 @@ import { deepEqual } from "fast-equals";
|
|
|
11
11
|
import { CenteredView, CircularProgressCenter } from "@rebasepro/ui";
|
|
12
12
|
import { CollectionScopeProvider, ErrorView, useFetch } from "@rebasepro/app";
|
|
13
13
|
//#region src/components/RecordDetail.tsx
|
|
14
|
+
/** A collection handed over as a value is shown on its own: no served table beside it. */
|
|
15
|
+
var NO_TABLES = [];
|
|
14
16
|
/**
|
|
15
17
|
* One record, read-only — loaded by id, drawn the way the CMS's own detail
|
|
16
18
|
* view draws it — to drop into a page of your own app. The read-only twin of
|
|
@@ -54,7 +56,8 @@ function RecordDetail(rawProps) {
|
|
|
54
56
|
const recordKey = `${path}/${props.id}`;
|
|
55
57
|
if (!inScope && collection === void 0) return /* @__PURE__ */ jsx(PanelNotFound, { className: props.className });
|
|
56
58
|
if (needsOwnScope) return /* @__PURE__ */ jsx(CollectionsProvider, {
|
|
57
|
-
|
|
59
|
+
externalCollections: ownCollections,
|
|
60
|
+
tables: NO_TABLES,
|
|
58
61
|
children: /* @__PURE__ */ jsx(RecordDetailInScope, { ...props }, recordKey)
|
|
59
62
|
});
|
|
60
63
|
return /* @__PURE__ */ jsx(RecordDetailInScope, { ...props }, recordKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordDetail.js","names":[],"sources":["../../src/components/RecordDetail.tsx"],"sourcesContent":["import React, { useContext, useMemo, useRef } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch } from \"@rebasepro/app\";\n\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { EntityViewBody, useReadOnlyFormContext } from \"./EntityViewBody\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\nimport type { RecordPanelCollection } from \"./RecordForm\";\n\n/**\n * Props for {@link RecordDetail}.\n *\n * @group Components\n */\nexport type RecordDetailProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordDetailOptions<M> & RecordPanelCollection<M>;\n\n/**\n * The options of an {@link RecordDetail}, beside its collection.\n *\n * @group Components\n */\nexport type RecordDetailOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /** The record to show. */\n id: string | number;\n\n className?: string;\n\n /**\n * The fields the view shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. Wins over the collection's `formView.Builder`.\n */\n fields?: string[];\n\n /**\n * Collection settings for this view only, applied over the registered\n * collection the way `CollectionPanel` and `RecordForm` apply their\n * own: a shallow merge, so `properties` given here replaces the\n * collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n};\n\n/**\n * One record, read-only — loaded by id, drawn the way the CMS's own detail\n * view draws it — to drop into a page of your own app. The read-only twin of\n * `RecordForm`.\n *\n * Each field renders its `PropertyPreview`: an enum as its chip, a date in its\n * timezone, a relation as its target's title, a property's own\n * `admin.Preview`. A field a dynamic `conditions` rule hides for this record,\n * or that the signed-in user may not read, is left out, exactly as the form\n * leaves it out.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordDetail collection={ordersCollection} id=\"123\"\n * fields={[\"customer\", \"status\", \"total\"]}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordDetail<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordDetailProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordDetailOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `RecordForm`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n const recordKey = `${path}/${props.id}`;\n // As `RecordForm`: named by path with no scope above, it is not found.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider
|
|
1
|
+
{"version":3,"file":"RecordDetail.js","names":[],"sources":["../../src/components/RecordDetail.tsx"],"sourcesContent":["import React, { useContext, useMemo, useRef } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch } from \"@rebasepro/app\";\n\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { EntityViewBody, useReadOnlyFormContext } from \"./EntityViewBody\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\nimport type { RecordPanelCollection } from \"./RecordForm\";\n\nimport type { TableDescriptor } from \"@rebasepro/types\";\n\n/** A collection handed over as a value is shown on its own: no served table beside it. */\nconst NO_TABLES: readonly TableDescriptor[] = [];\n\n/**\n * Props for {@link RecordDetail}.\n *\n * @group Components\n */\nexport type RecordDetailProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordDetailOptions<M> & RecordPanelCollection<M>;\n\n/**\n * The options of an {@link RecordDetail}, beside its collection.\n *\n * @group Components\n */\nexport type RecordDetailOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /** The record to show. */\n id: string | number;\n\n className?: string;\n\n /**\n * The fields the view shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. Wins over the collection's `formView.Builder`.\n */\n fields?: string[];\n\n /**\n * Collection settings for this view only, applied over the registered\n * collection the way `CollectionPanel` and `RecordForm` apply their\n * own: a shallow merge, so `properties` given here replaces the\n * collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n};\n\n/**\n * One record, read-only — loaded by id, drawn the way the CMS's own detail\n * view draws it — to drop into a page of your own app. The read-only twin of\n * `RecordForm`.\n *\n * Each field renders its `PropertyPreview`: an enum as its chip, a date in its\n * timezone, a relation as its target's title, a property's own\n * `admin.Preview`. A field a dynamic `conditions` rule hides for this record,\n * or that the signed-in user may not read, is left out, exactly as the form\n * leaves it out.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordDetail collection={ordersCollection} id=\"123\"\n * fields={[\"customer\", \"status\", \"total\"]}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordDetail<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordDetailProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordDetailOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `RecordForm`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n const recordKey = `${path}/${props.id}`;\n // As `RecordForm`: named by path with no scope above, it is not found.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider externalCollections={ownCollections} tables={NO_TABLES}>\n <RecordDetailInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <RecordDetailInScope key={recordKey} {...props}/>;\n}\n\nfunction RecordDetailInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n id: entityId,\n path: pathProp,\n className,\n fields,\n collectionOverrides\n}: ScopedRecordPanelProps<RecordDetailOptions<M>, M>) {\n const path = pathProp;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n\n // The registry's copy, as in `RecordForm`: it carries the plugins'\n // changes and the user's saved overrides. Looked up once per registry, and\n // the overrides compared by value, because the record's subscription is\n // keyed on the collection it was opened with.\n const overridesRef = useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(() => {\n const registered = lookUp ? collectionRegistry.getCollection(path) : undefined;\n return registered && stableOverrides\n ? { ...registered, ...stableOverrides } as AdminCollection<M>\n : registered;\n }, [lookUp, collectionRegistry, path, stableOverrides]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n const formContext = useReadOnlyFormContext<M>({\n entityId,\n entity,\n collection: collection ?? collectionProp,\n path,\n openEntityMode: \"full_screen\"\n });\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n if (dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (!entity) {\n if (dataLoading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityViewBody<M>\n entity={entity}\n collection={collection}\n path={path}\n formContext={formContext}\n fields={fields}\n className={className}\n />\n </CollectionScopeProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,IAAM,YAAwC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiE/C,SAAgB,aAA0E,UAAgC;CACtH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,YAAY,SAAS,iBAAqC,SAAS,YAAY,SAAS,IAAI;CACpG,MAAM,QAA2D;EAAE,GAAG;EAAU;EAAY;CAAK;CACjG,MAAM,iBAAiB,cAAc,aAAa,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;CAKjF,MAAM,gBAAgB,eAAe,KAAA,MAAc,CAAC,WAC5C,CAAC,gBAAgB,WAAW,CAAC,aAAa,mBAAmB,aAAa,IAAI;CACtF,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM;CAEnC,IAAI,CAAC,WAAW,eAAe,KAAA,GAAW,OAAO,oBAAC,eAAD,EAAe,WAAW,MAAM,UAAW,CAAA;CAC5F,IAAI,eACA,OACI,oBAAC,qBAAD;EAAqB,qBAAqB;EAAgB,QAAQ;YAC9D,oBAAC,qBAAD,EAAqC,GAAI,MAAO,GAAtB,SAAsB;CAC/B,CAAA;CAG7B,OAAO,oBAAC,qBAAD,EAAqC,GAAI,MAAO,GAAtB,SAAsB;AAC3D;AAEA,SAAS,oB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|
-
import type { Entity } from "@rebasepro/types";
|
|
3
|
-
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import type { AdminCollection, Entity } from "@rebasepro/cms-types";
|
|
4
3
|
import type { EntityFormBindingProps } from "../form/EntityFormBinding.js";
|
|
5
4
|
import type { OnSavedParams } from "../types/components/EntityFormProps.js";
|
|
6
5
|
/**
|
|
@@ -19,9 +18,10 @@ export type RecordPanelCollection<M extends Record<string, unknown> = Record<str
|
|
|
19
18
|
/**
|
|
20
19
|
* The collection the record belongs to: its name (`"orders"`), registered
|
|
21
20
|
* with `<RebaseCMS>` or a {@link CollectionsProvider} above, or the
|
|
22
|
-
* collection as a value — a `
|
|
23
|
-
* collection. Handed over as a value
|
|
24
|
-
* above, the panel brings its own
|
|
21
|
+
* collection as a value — a `defineFirestoreCollection`, or a table's
|
|
22
|
+
* collection you built (`collectionFromTable`). Handed over as a value
|
|
23
|
+
* where no CMS navigation is mounted above, the panel brings its own
|
|
24
|
+
* {@link CollectionsProvider} for it, holding that collection alone.
|
|
25
25
|
*/
|
|
26
26
|
collection: AdminCollection<M> | string;
|
|
27
27
|
/**
|
|
@@ -9,9 +9,11 @@ import { createElement, useCallback, useContext, useEffect, useMemo, useRef, use
|
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { deepEqual } from "fast-equals";
|
|
11
11
|
import { Alert, Button, CenteredView, CircularProgressCenter } from "@rebasepro/ui";
|
|
12
|
-
import { warnDeprecated } from "@rebasepro/common";
|
|
13
12
|
import { CollectionScopeProvider, ErrorView, entityOfRow, rowOfEntity, useFetch, usePermissions, useTranslation } from "@rebasepro/app";
|
|
13
|
+
import { warnDeprecated } from "@rebasepro/common";
|
|
14
14
|
//#region src/components/RecordForm.tsx
|
|
15
|
+
/** A collection handed over as a value is shown on its own: no served table beside it. */
|
|
16
|
+
var NO_TABLES = [];
|
|
15
17
|
/**
|
|
16
18
|
* One record's form — loaded by id, saved through `<Rebase>`'s data layer —
|
|
17
19
|
* to drop into a page of your own app.
|
|
@@ -48,7 +50,8 @@ function RecordForm(rawProps) {
|
|
|
48
50
|
const recordKey = `${path}/${props.id ?? "new"}`;
|
|
49
51
|
if (!inScope && collection === void 0) return /* @__PURE__ */ jsx(PanelNotFound, { className: props.className });
|
|
50
52
|
if (needsOwnScope) return /* @__PURE__ */ jsx(CollectionsProvider, {
|
|
51
|
-
|
|
53
|
+
externalCollections: ownCollections,
|
|
54
|
+
tables: NO_TABLES,
|
|
52
55
|
children: /* @__PURE__ */ jsx(RecordFormInScope, { ...props }, recordKey)
|
|
53
56
|
});
|
|
54
57
|
return /* @__PURE__ */ jsx(RecordFormInScope, { ...props }, recordKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordForm.js","names":[],"sources":["../../src/components/RecordForm.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { warnDeprecated } from \"@rebasepro/common\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, entityOfRow, ErrorView, rowOfEntity, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\n\n/**\n * Props for {@link RecordForm}.\n *\n * @group Components\n */\nexport type RecordFormProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordFormOptions<M> & RecordPanelCollection<M>;\n\n/**\n * Which collection a record panel's record belongs to: named, the way\n * {@link CollectionPanel} names it, or handed over as a value.\n *\n * @group Components\n */\nexport type RecordPanelCollection<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to: its name (`\"orders\"`), registered\n * with `<RebaseCMS>` or a {@link CollectionsProvider} above, or the\n * collection as a value — a `defineCollection` config or a resolved\n * collection. Handed over as a value where no CMS navigation is mounted\n * above, the panel brings its own {@link CollectionsProvider} for it.\n */\n collection: AdminCollection<M> | string;\n /**\n * Where the record lives, where that is not the collection's name: a\n * subcollection's full path, `posts/p1/comments`.\n */\n path?: string;\n};\n\n/**\n * The options of an {@link RecordForm}, beside its collection.\n *\n * @group Components\n */\nexport type RecordFormOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n id?: string | number;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnSavedParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /**\n * The fields the form shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. The form validates only what it shows, and, creating a record,\n * refuses with an error naming them when a required field it leaves out\n * has no default value and is not filled by the server or the database.\n */\n fields?: string[];\n\n /**\n * A denser form, for a side card or a narrow panel: no rail beside the\n * fields, no record metadata, medium-height controls and tighter padding.\n */\n compact?: boolean;\n\n /**\n * Your own arrangement of the fields, in place of the generated ones:\n * `<FormField name=\"…\"/>`s inside any JSX. Validation covers the fields\n * its `<FormField>`s render, with the same create-time check as\n * {@link fields}. Wins over the collection's `formView.Builder`.\n *\n * ```tsx\n * <RecordForm collection=\"orders\" id={id}>\n * <div className=\"grid grid-cols-2 gap-3\">\n * <FormField name=\"status\"/>\n * <FormField name=\"tracking_number\"/>\n * </div>\n * <FormField name=\"notes\"/>\n * </RecordForm>\n * ```\n */\n children?: React.ReactNode;\n\n /**\n * Collection settings for this form only, applied over the registered\n * collection the way `CollectionPanel` applies its own: a shallow merge,\n * so `properties` given here replaces the collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"id\" | \"row\" | \"initialStatus\" | \"fields\" | \"layout\" | \"compact\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordForm collection={postsCollection} id=\"123\"\n * onSaved={({ id }) => toast(`Saved ${id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordFormOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `CollectionPanel`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${path}/${props.id ?? \"new\"}`;\n // Named by path with no scope above to look it up in: nothing will ever\n // register it, so it is not found rather than loading.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <RecordFormInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <RecordFormInScope key={recordKey} {...props}/>;\n}\n\nfunction RecordFormInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n id: entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n fields,\n children,\n compact,\n collectionOverrides,\n formProps\n}: ScopedRecordPanelProps<RecordFormOptions<M>, M>) {\n const { t } = useTranslation();\n const path = pathProp;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n // The overrides are compared by value for the same reason: they are an\n // inline object at most call sites, a new one on every render.\n const overridesRef = useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(() => {\n const registered = lookUp ? collectionRegistry.getCollection(path) : undefined;\n return registered && stableOverrides\n ? { ...registered, ...stableOverrides } as AdminCollection<M>\n : registered;\n }, [lookUp, collectionRegistry, path, stableOverrides]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n row={asNew.saved ? rowOfEntity(asNew.saved, collection) : undefined}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onRowChange={(changed) => {\n // The record it created, which it edits from then on.\n const saved = entityOfRow(changed.row, changed.id, path, collection) as Entity<M>;\n setAsNew(current => current && { ...current, saved });\n formProps?.onRowChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity?.values ?? null);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n id={entityId}\n row={shownEntity ? rowOfEntity(shownEntity, collection) : undefined}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!editable || formProps?.disabled}\n onRowChange={(changed) => {\n setSavedEntity(entityOfRow(changed.row, changed.id, path, collection) as Entity<M>);\n formProps?.onRowChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProvider>\n );\n}\n\n/**\n * What {@link EntityFormPanel}'s `onSaved` is called with: {@link OnSavedParams},\n * and the saved record as 0.28 handed it over.\n *\n * @deprecated Use {@link RecordForm}, whose `onSaved` gets {@link OnSavedParams}.\n * @group Components\n */\nexport type EntityFormPanelSavedParams = OnSavedParams & {\n /** @deprecated The saved record as an `Entity`: read `row` and `id`. It warns once. */\n entity: Entity<Record<string, unknown>>;\n};\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> =\n Omit<RecordFormProps<M>, \"onSaved\"> & {\n /** @deprecated The record to edit is `id`. It warns once. */\n entityId?: string | number;\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: EntityFormPanelSavedParams) => void;\n };\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>({\n entityId,\n onSaved,\n ...props\n}: EntityFormPanelProps<M>) {\n warnDeprecated(\"EntityFormPanel\", \"`EntityFormPanel` is now `RecordForm`, with the same props.\");\n if (entityId !== undefined) {\n warnDeprecated(\"EntityFormPanel.entityId\", \"`EntityFormPanel`'s `entityId` is `id` now: `<RecordForm id=\\\"…\\\"/>`.\");\n }\n const onSavedWithEntity = onSaved && ((params: OnSavedParams) => {\n let entity: Entity<Record<string, unknown>> | undefined;\n onSaved({\n ...params,\n get entity() {\n warnDeprecated(\"EntityFormPanel.onSaved.entity\", \"`EntityFormPanel`'s `onSaved` hands over the saved record as `row` and `id` now; `entity` is going away.\");\n entity ??= entityOfRow(params.row, params.id, params.path, params.collection);\n return entity;\n }\n });\n });\n return <RecordForm<M> {...props} id={props.id ?? entityId} onSaved={onSavedWithEntity}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IA,SAAgB,WAAw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zBlB,CA2BK,oBACG,oBAAC,OAAD;IAAO,OAAO;IAAW,MAAM;IAAS,gBAAgB;IACpD,QAAQ,oBAAC,QAAD;KAAQ,MAAM;KAAS,SAAS;KAAQ,SAAS;eAAY,EAAE,aAAa;IAAU,CAAA;cAC7F,EAAE,0BAA0B;GAC1B,CAAA,GACV,WAAW,QACG;;CACE,CAAA;AAEjC;;;;;;;AAkCA,SAAgB,gBAA6E,EACzF,UACA,SACA,GAAG,SACqB;CACxB,eAAe,mBAAmB,6DAA6D;CAC/F,IAAI,aAAa,KAAA,GACb,eAAe,4BAA4B,uEAAuE;CAEtH,MAAM,oBAAoB,aAAa,WAA0B;EAC7D,IAAI;EACJ,QAAQ;GACJ,GAAG;GACH,IAAI,SAAS;IACT,eAAe,kCAAkC,0GAA0G;IAC3J,WAAW,YAAY,OAAO,KAAK,OAAO,IAAI,OAAO,MAAM,OAAO,UAAU;IAC5E,OAAO;GACX;EACJ,CAAC;CACL;CACA,OAAO,oBAAC,YAAD;EAAe,GAAI;EAAO,IAAI,MAAM,MAAM;EAAU,SAAS;CAAmB,CAAA;AAC3F"}
|
|
1
|
+
{"version":3,"file":"RecordForm.js","names":[],"sources":["../../src/components/RecordForm.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\nimport { warnDeprecated } from \"@rebasepro/common\";\nimport type { AdminCollection, Entity } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, entityOfRow, ErrorView, rowOfEntity, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\nimport { CollectionsProvider } from \"./CollectionsProvider\";\nimport { PanelNotFound } from \"./PanelNotFound\";\nimport { collectionPropOf, type ScopedRecordPanelProps } from \"./collection_prop\";\n\nimport type { TableDescriptor } from \"@rebasepro/types\";\n\n/** A collection handed over as a value is shown on its own: no served table beside it. */\nconst NO_TABLES: readonly TableDescriptor[] = [];\n\n/**\n * Props for {@link RecordForm}.\n *\n * @group Components\n */\nexport type RecordFormProps<M extends Record<string, unknown> = Record<string, unknown>> =\n RecordFormOptions<M> & RecordPanelCollection<M>;\n\n/**\n * Which collection a record panel's record belongs to: named, the way\n * {@link CollectionPanel} names it, or handed over as a value.\n *\n * @group Components\n */\nexport type RecordPanelCollection<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to: its name (`\"orders\"`), registered\n * with `<RebaseCMS>` or a {@link CollectionsProvider} above, or the\n * collection as a value — a `defineFirestoreCollection`, or a table's\n * collection you built (`collectionFromTable`). Handed over as a value\n * where no CMS navigation is mounted above, the panel brings its own\n * {@link CollectionsProvider} for it, holding that collection alone.\n */\n collection: AdminCollection<M> | string;\n /**\n * Where the record lives, where that is not the collection's name: a\n * subcollection's full path, `posts/p1/comments`.\n */\n path?: string;\n};\n\n/**\n * The options of an {@link RecordForm}, beside its collection.\n *\n * @group Components\n */\nexport type RecordFormOptions<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The record to edit. When no record has this id yet, the form creates\n * it under this id — so a record kept at a known key (a settings record,\n * a profile keyed by its user's id) needs no seeding. Omit it to create a\n * new record under an id the data source assigns.\n */\n id?: string | number;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnSavedParams) => void;\n\n /**\n * Called when the form asks to be left — after its record is deleted, or\n * by an action that closes it. The form is your page's, so where that\n * leads is yours to say; without it, nothing happens.\n */\n onClose?: () => void;\n\n /** Values a new record starts with — one created without an id, or under an id no record has yet. */\n defaultValues?: Partial<M>;\n\n className?: string;\n\n /**\n * The fields the form shows, in this order; any other property is left\n * out. Sections and the rail keep their grouping, each holding only these\n * fields. The form validates only what it shows, and, creating a record,\n * refuses with an error naming them when a required field it leaves out\n * has no default value and is not filled by the server or the database.\n */\n fields?: string[];\n\n /**\n * A denser form, for a side card or a narrow panel: no rail beside the\n * fields, no record metadata, medium-height controls and tighter padding.\n */\n compact?: boolean;\n\n /**\n * Your own arrangement of the fields, in place of the generated ones:\n * `<FormField name=\"…\"/>`s inside any JSX. Validation covers the fields\n * its `<FormField>`s render, with the same create-time check as\n * {@link fields}. Wins over the collection's `formView.Builder`.\n *\n * ```tsx\n * <RecordForm collection=\"orders\" id={id}>\n * <div className=\"grid grid-cols-2 gap-3\">\n * <FormField name=\"status\"/>\n * <FormField name=\"tracking_number\"/>\n * </div>\n * <FormField name=\"notes\"/>\n * </RecordForm>\n * ```\n */\n children?: React.ReactNode;\n\n /**\n * Collection settings for this form only, applied over the registered\n * collection the way `CollectionPanel` applies its own: a shallow merge,\n * so `properties` given here replaces the collection's whole map.\n */\n collectionOverrides?: Partial<AdminCollection>;\n\n /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"id\" | \"row\" | \"initialStatus\" | \"fields\" | \"layout\" | \"compact\">>;\n};\n\n/**\n * One record's form — loaded by id, saved through `<Rebase>`'s data layer —\n * to drop into a page of your own app.\n *\n * Needs `<Rebase>` and a React Router router above it (any router, any path).\n * Where no CMS navigation is mounted above, it brings its own\n * {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and\n * `<RebaseShell>` are not needed.\n *\n * @example\n * ```tsx\n * <Rebase client={client} authController={authController}>\n * <BrowserRouter>\n * <RecordForm collection={postsCollection} id=\"123\"\n * onSaved={({ id }) => toast(`Saved ${id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function RecordForm<M extends Record<string, unknown> = Record<string, unknown>>(rawProps: RecordFormProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection, path } = collectionPropOf<AdminCollection<M>>(rawProps.collection, rawProps.path);\n const props: ScopedRecordPanelProps<RecordFormOptions<M>, M> = { ...rawProps, collection, path };\n const ownCollections = useMemo(() => collection ? [collection] : [], [collection]);\n\n // As `CollectionPanel`: a collection handed over as a value brings its own\n // scope where none is above, or where the one above has settled without\n // it. One named by path is looked up in the scope above.\n const needsOwnScope = collection !== undefined && (!inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, path)));\n // One form per record: the binding keeps the id and status it mounted\n // with, so a page that hands over another id (a route `/posts/:id` going\n // from p1 to p2) gets a fresh form instead of one that shows p2 and saves\n // into p1. Keyed on the prop, so the id a create assigns keeps the form.\n const recordKey = `${path}/${props.id ?? \"new\"}`;\n // Named by path with no scope above to look it up in: nothing will ever\n // register it, so it is not found rather than loading.\n if (!inScope && collection === undefined) return <PanelNotFound className={props.className}/>;\n if (needsOwnScope) {\n return (\n <CollectionsProvider externalCollections={ownCollections} tables={NO_TABLES}>\n <RecordFormInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <RecordFormInScope key={recordKey} {...props}/>;\n}\n\nfunction RecordFormInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n id: entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n fields,\n children,\n compact,\n collectionOverrides,\n formProps\n}: ScopedRecordPanelProps<RecordFormOptions<M>, M>) {\n const { t } = useTranslation();\n const path = pathProp;\n const collectionRegistry = useCollectionRegistryController<Record<string, unknown>, AdminCollection<M>>();\n const navigationState = useNavigationStateController();\n const { canCreate, canEdit } = usePermissions();\n\n // The registry's copy: it carries the plugins' changes and the user's\n // saved overrides.\n // Looked up once per registry: each lookup builds a new object, and the\n // record's subscription is keyed on the collection it was opened with.\n // The overrides are compared by value for the same reason: they are an\n // inline object at most call sites, a new one on every render.\n const overridesRef = useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(() => {\n const registered = lookUp ? collectionRegistry.getCollection(path) : undefined;\n return registered && stableOverrides\n ? { ...registered, ...stableOverrides } as AdminCollection<M>\n : registered;\n }, [lookUp, collectionRegistry, path, stableOverrides]);\n\n const { entity, dataLoading, dataLoadingError } = useFetch<M>({\n path,\n entityId,\n collection: collection ?? collectionProp,\n relations: true,\n useCache: false\n });\n\n // The record as the form last saved it. A record created here has no id\n // to read it back by from the outside, and the form, existing from then\n // on, needs it.\n const [savedEntity, setSavedEntity] = useState<Entity<M> | undefined>(undefined);\n\n // The record as it was last delivered. A live read that stops delivering\n // it — someone deleted it — is not a record that was never there: as in\n // the CMS's own edit view, the form keeps showing it, with what was typed,\n // and says so. Without this the form lost its record mid-edit and threw.\n const [lastSeenEntity, setLastSeenEntity] = useState<Entity<M> | undefined>(undefined);\n useEffect(() => {\n if (entity) setLastSeenEntity(entity);\n }, [entity]);\n // \"Save as new\": the same values, in a form that creates a record. Counted,\n // so that each one is a fresh form.\n const [asNew, setAsNew] = useState<{ values: Partial<M>, n: number, saved?: Entity<M> } | null>(null);\n const typedValues = useRef<Partial<M> | undefined>(undefined);\n const deletedElsewhere = !asNew && entityId !== undefined && !dataLoading && !entity\n && lastSeenEntity !== undefined && String(lastSeenEntity.id) === String(entityId);\n const shownEntity = deletedElsewhere ? lastSeenEntity : (entity ?? savedEntity);\n\n const navigateBack = useCallback(() => onClose?.(), [onClose]);\n const saveAsNew = useCallback(() => {\n const values: Partial<M> = typedValues.current ?? lastSeenEntity?.values ?? {};\n setAsNew(previous => ({ values, n: (previous?.n ?? 0) + 1 }));\n }, [lastSeenEntity]);\n\n if (!collection) {\n if (navigationState.loading) return <CircularProgressCenter/>;\n return <PanelNotFound className={className}/>;\n }\n\n if (asNew) {\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n key={`as-new-${asNew.n}`}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n row={asNew.saved ? rowOfEntity(asNew.saved, collection) : undefined}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onRowChange={(changed) => {\n // The record it created, which it edits from then on.\n const saved = entityOfRow(changed.row, changed.id, path, collection) as Entity<M>;\n setAsNew(current => current && { ...current, saved });\n formProps?.onRowChange?.(changed);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n />\n </CollectionScopeProvider>\n );\n }\n\n if (entityId !== undefined && dataLoadingError) {\n return <CenteredView className={className}><ErrorView error={dataLoadingError}/></CenteredView>;\n }\n if (entityId !== undefined && !shownEntity && dataLoading) return <CircularProgressCenter/>;\n\n // An id no record has yet is a record to create under that id. The form\n // keeps the status it opened with, so once it creates the record it edits\n // it from then on.\n const creating = shownEntity === undefined;\n // As the CMS's own New button and save actions: a record to create needs\n // canCreate (false while access is simulated), an existing one canEdit.\n const editable = creating ? canCreate(collection, path) : canEdit(collection, path, shownEntity?.values ?? null);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n id={entityId}\n row={shownEntity ? rowOfEntity(shownEntity, collection) : undefined}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n fields={fields}\n layout={children}\n compact={compact}\n disabled={!editable || formProps?.disabled}\n onRowChange={(changed) => {\n setSavedEntity(entityOfRow(changed.row, changed.id, path, collection) as Entity<M>);\n formProps?.onRowChange?.(changed);\n }}\n onValuesModified={(modified, values) => {\n typedValues.current = values;\n formProps?.onValuesModified?.(modified, values);\n }}\n onSaved={(params) => {\n formProps?.onSaved?.(params);\n onSaved?.(params);\n }}\n navigateBack={navigateBack}\n >\n {deletedElsewhere &&\n <Alert color={\"warning\"} size={\"small\"} outerClassName={\"w-full mb-4\"}\n action={<Button size={\"small\"} variant={\"text\"} onClick={saveAsNew}>{t(\"save_as_new\")}</Button>}>\n {t(\"entity_deleted_elsewhere\")}\n </Alert>}\n {formProps?.children}\n </EntityFormBinding>\n </CollectionScopeProvider>\n );\n}\n\n/**\n * What {@link EntityFormPanel}'s `onSaved` is called with: {@link OnSavedParams},\n * and the saved record as 0.28 handed it over.\n *\n * @deprecated Use {@link RecordForm}, whose `onSaved` gets {@link OnSavedParams}.\n * @group Components\n */\nexport type EntityFormPanelSavedParams = OnSavedParams & {\n /** @deprecated The saved record as an `Entity`: read `row` and `id`. It warns once. */\n entity: Entity<Record<string, unknown>>;\n};\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> =\n Omit<RecordFormProps<M>, \"onSaved\"> & {\n /** @deprecated The record to edit is `id`. It warns once. */\n entityId?: string | number;\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: EntityFormPanelSavedParams) => void;\n };\n\n/**\n * @deprecated Renamed {@link RecordForm}. It also takes 0.28's `entityId`\n * for `id`, and hands `onSaved` the saved record as `entity` beside `row` and\n * `id`. It warns once.\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>({\n entityId,\n onSaved,\n ...props\n}: EntityFormPanelProps<M>) {\n warnDeprecated(\"EntityFormPanel\", \"`EntityFormPanel` is now `RecordForm`, with the same props.\");\n if (entityId !== undefined) {\n warnDeprecated(\"EntityFormPanel.entityId\", \"`EntityFormPanel`'s `entityId` is `id` now: `<RecordForm id=\\\"…\\\"/>`.\");\n }\n const onSavedWithEntity = onSaved && ((params: OnSavedParams) => {\n let entity: Entity<Record<string, unknown>> | undefined;\n onSaved({\n ...params,\n get entity() {\n warnDeprecated(\"EntityFormPanel.onSaved.entity\", \"`EntityFormPanel`'s `onSaved` hands over the saved record as `row` and `id` now; `entity` is going away.\");\n entity ??= entityOfRow(params.row, params.id, params.path, params.collection);\n return entity;\n }\n });\n });\n return <RecordForm<M> {...props} id={props.id ?? entityId} onSaved={onSavedWithEntity}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,IAAM,YAAwC,CAAC;;;;;;;;;;;;;;;;;;;;;;AA+H/C,SAAgB,WAAwE,UAA8B;CAClH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,kBAAkB,6BAA6B;CACrD,MAAM,EAAE,YAAY,SAAS,iBAAqC,SAAS,YAAY,SAAS,IAAI;CACpG,MAAM,QAAyD;EAAE,GAAG;EAAU;EAAY;CAAK;CAC/F,MAAM,iBAAiB,cAAc,aAAa,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;CAKjF,MAAM,gBAAgB,eAAe,KAAA,MAAc,CAAC,WAC5C,CAAC,gBAAgB,WAAW,CAAC,aAAa,mBAAmB,aAAa,IAAI;CAKtF,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,MAAM;CAGzC,IAAI,CAAC,WAAW,eAAe,KAAA,GAAW,OAAO,oBAAC,eAAD,EAAe,WAAW,MAAM,UAAW,CAAA;CAC5F,IAAI,eACA,OACI,oBAAC,qBAAD;EAAqB,qBAAqB;EAAgB,QAAQ;YAC9D,oBAAC,mBAAD,EAAmC,GAAI,MAAO,GAAtB,SAAsB;CAC7B,CAAA;CAG7B,OAAO,oBAAC,mBAAD,EAAmC,GAAI,MAAO,GAAtB,SAAsB;AACzD;AAEA,SAAS,kBAAqD,EAC1D,YAAY,gBACZ,IAAI,UACJ,MAAM,UACN,SACA,SACA,eACA,WACA,QACA,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"@rebasepro/types";
|
|
3
|
+
import { AdminCollection, Entity } from "@rebasepro/cms-types";
|
|
4
4
|
/**
|
|
5
5
|
* What {@link useSelectionDialog} and {@link SelectionTableBinding} take: a
|
|
6
6
|
* collection to pick rows from, and what to do with the rows picked. The rows
|
|
@@ -75,7 +75,7 @@ function SelectionTableBindingInternal({ onSingleEntitySelected, onMultipleEntit
|
|
|
75
75
|
useEffect(() => {
|
|
76
76
|
let unmounted = false;
|
|
77
77
|
const selectedEntityIds = selectedEntityIdsProp?.map((id) => id?.toString()).filter(Boolean);
|
|
78
|
-
if (selectedEntityIds && selectedEntityIds.length > 0 && collection) findEntitiesByIds(dataClient.
|
|
78
|
+
if (selectedEntityIds && selectedEntityIds.length > 0 && collection) findEntitiesByIds(dataClient.table(path), collection, selectedEntityIds).then((found) => {
|
|
79
79
|
if (!unmounted) {
|
|
80
80
|
const result = selectedEntityIds.map((id) => found.get(id)).filter((e) => !!e);
|
|
81
81
|
selectionController.setSelectedEntities(result);
|