@rebasepro/cms 0.28.1 → 0.29.0-canary.g0e3a0e7
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 +3 -3
- package/dist/collection_editor/_cms_internals.d.ts +0 -1
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
- package/dist/components/AdditionalFieldValue.d.ts +9 -3
- package/dist/components/AdditionalFieldValue.js +7 -4
- package/dist/components/AdditionalFieldValue.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +117 -18
- package/dist/components/CollectionPanel.js +115 -37
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
- package/dist/components/CollectionTableBinding/column_utils.js +6 -3
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- 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.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
- package/dist/components/CollectionTableBinding/internal/common.js +88 -4
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
- package/dist/components/CollectionViewBinding/RowActions.js +60 -0
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
- package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
- package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
- package/dist/components/CollectionViewBinding/fields.js +47 -0
- package/dist/components/CollectionViewBinding/fields.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
- package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +3 -3
- package/dist/components/CollectionsProvider.js +4 -4
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/CollectionsScopeContext.d.ts +1 -1
- package/dist/components/CollectionsScopeContext.js +1 -1
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +2 -2
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +32 -68
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js +5 -4
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -2
- package/dist/components/EditViewBinding.js +25 -15
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.js +8 -5
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +8 -1
- package/dist/components/EntityViewBinding.js +43 -14
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +40 -0
- package/dist/components/EntityViewBody.js +90 -0
- package/dist/components/EntityViewBody.js.map +1 -0
- package/dist/components/FieldValue.d.ts +50 -0
- package/dist/components/FieldValue.js +81 -0
- package/dist/components/FieldValue.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PanelNotFound.d.ts +5 -0
- package/dist/components/PanelNotFound.js +21 -0
- package/dist/components/PanelNotFound.js.map +1 -0
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/components/RebaseCMS.js +11 -3
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +9 -3
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RebaseShell.js +10 -5
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/RecordDetail.d.ts +61 -0
- package/dist/components/RecordDetail.js +123 -0
- package/dist/components/RecordDetail.js.map +1 -0
- package/dist/components/RecordForm.d.ts +126 -0
- package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
- package/dist/components/RecordForm.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
- package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +5 -3
- package/dist/components/ReferenceWidget.js +10 -7
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.js +4 -4
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +2 -3
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.js +1 -1
- package/dist/components/SelectableTable/SelectionStore.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/SidePanelBinding.js +13 -12
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/collection_prop.d.ts +18 -0
- package/dist/components/collection_prop.js +23 -0
- package/dist/components/collection_prop.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +54 -54
- package/dist/components/common/default_entity_actions.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +4 -1
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
- package/dist/data_export/export/ExportCollectionAction.js +4 -3
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +6 -3
- package/dist/data_export/export/additional_fields.js +8 -4
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +252 -150
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js +3 -2
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +22 -11
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormField.d.ts +36 -0
- package/dist/form/FormField.js +41 -0
- package/dist/form/FormField.js.map +1 -0
- package/dist/form/FormFieldsContext.d.ts +69 -0
- package/dist/form/FormFieldsContext.js +143 -0
- package/dist/form/FormFieldsContext.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +4 -4
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/collection_showing.d.ts +8 -0
- package/dist/form/collection_showing.js +29 -0
- package/dist/form/collection_showing.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +2 -1
- package/dist/form/components/ErrorFocus.js.map +1 -1
- package/dist/form/components/FieldBlock.js +3 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +5 -1
- package/dist/form/components/FormRail.js +5 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/FormSections.d.ts +5 -1
- package/dist/form/components/FormSections.js +11 -4
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +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/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +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.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/form_dom_ids.d.ts +25 -0
- package/dist/form/form_dom_ids.js +42 -0
- package/dist/form/form_dom_ids.js.map +1 -0
- package/dist/form/index.d.ts +3 -1
- package/dist/form/resolve_cell_property.d.ts +5 -0
- package/dist/form/resolve_cell_property.js +22 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +9 -9
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useEntityDisplay.js +6 -4
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useRecordActions.js +2 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useSelectionDialog.d.ts +20 -7
- package/dist/hooks/useSelectionDialog.js +29 -8
- package/dist/hooks/useSelectionDialog.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -9
- package/dist/mcp-view.d.ts +9 -0
- package/dist/mcp-view.js +2 -0
- package/dist/mcp_view/app_modules.d.ts +29 -0
- package/dist/mcp_view/app_modules.js +163 -0
- package/dist/mcp_view/app_modules.js.map +1 -0
- package/dist/mcp_view/bridge.d.ts +90 -0
- package/dist/mcp_view/bridge.js +205 -0
- package/dist/mcp_view/bridge.js.map +1 -0
- package/dist/mcp_view/code_app.d.ts +65 -0
- package/dist/mcp_view/code_app.js +139 -0
- package/dist/mcp_view/code_app.js.map +1 -0
- package/dist/mcp_view/index.d.ts +48 -0
- package/dist/mcp_view/index.js +235 -0
- package/dist/mcp_view/index.js.map +1 -0
- package/dist/mcp_view/payload.d.ts +78 -0
- package/dist/mcp_view/payload.js +155 -0
- package/dist/mcp_view/payload.js.map +1 -0
- package/dist/mcp_view/screen.d.ts +28 -0
- package/dist/mcp_view/screen.js +223 -0
- package/dist/mcp_view/screen.js.map +1 -0
- package/dist/mcp_view/storage_source.d.ts +14 -0
- package/dist/mcp_view/storage_source.js +29 -0
- package/dist/mcp_view/storage_source.js.map +1 -0
- package/dist/mcp_view/store.d.ts +9 -0
- package/dist/mcp_view/store.js +27 -0
- package/dist/mcp_view/store.js.map +1 -0
- package/dist/mcp_view/tool_driver.d.ts +135 -0
- package/dist/mcp_view/tool_driver.js +527 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recipe: master-detail — a list of rows beside the form of the one picked.
|
|
3
|
+
*
|
|
4
|
+
* `SplitView` from `@rebasepro/ui` lays the two out by the width of its own
|
|
5
|
+
* container, not the window's: side by side when there is room, and in a
|
|
6
|
+
* narrow container (a phone, a side panel, Claude's frame) the form covers the
|
|
7
|
+
* list under a back bar. Both stay mounted across the switch, so the list
|
|
8
|
+
* keeps its scroll and the form its edits.
|
|
9
|
+
*
|
|
10
|
+
* The master is a `CollectionPanel`: `fields` picks its columns, `onRowClick`
|
|
11
|
+
* hands over the clicked row and its id instead of opening it, and
|
|
12
|
+
* `highlightedIds` draws that row as the selected one. The row is the
|
|
13
|
+
* server's: its columns, dates as ISO strings. The id is the string the admin
|
|
14
|
+
* addresses the record by. The detail is an `RecordForm` at that id,
|
|
15
|
+
* named by the same path, with `fields` choosing what it edits. A save there reaches the list by
|
|
16
|
+
* itself.
|
|
17
|
+
*
|
|
18
|
+
* To use it: add `customersMasterDetailView` to `<RebaseCMS views={[…]}>`.
|
|
19
|
+
* Change `COLLECTION`, the field lists, and `TITLE_FIELD` to your own.
|
|
20
|
+
*/
|
|
21
|
+
import React, { useState } from "react";
|
|
22
|
+
import type { AppView } from "@rebasepro/cms-types";
|
|
23
|
+
import { CollectionPanel, RecordForm } from "@rebasepro/cms";
|
|
24
|
+
import { SplitView } from "@rebasepro/ui";
|
|
25
|
+
|
|
26
|
+
const COLLECTION = "customers";
|
|
27
|
+
/** The list's columns, in order. */
|
|
28
|
+
const LIST_FIELDS = ["name", "status"];
|
|
29
|
+
/** What the form edits, in order. A required field left out must have a default. */
|
|
30
|
+
const FORM_FIELDS = ["name", "email", "status", "notes"];
|
|
31
|
+
/** Names the open record in the narrow layout's back bar. */
|
|
32
|
+
const TITLE_FIELD = "name";
|
|
33
|
+
|
|
34
|
+
type Row = Record<string, unknown>;
|
|
35
|
+
|
|
36
|
+
export function CustomersMasterDetail() {
|
|
37
|
+
// The row picked, and its id: what `RecordForm` and `highlightedIds` take.
|
|
38
|
+
const [selected, setSelected] = useState<{ row: Row; id: string } | null>(null);
|
|
39
|
+
const selectedId = selected?.id;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
// SplitView fills its parent, so the parent needs a height.
|
|
43
|
+
<div className={"h-full min-h-0"}>
|
|
44
|
+
<SplitView
|
|
45
|
+
master={
|
|
46
|
+
<CollectionPanel collection={COLLECTION}
|
|
47
|
+
title={false}
|
|
48
|
+
fields={LIST_FIELDS}
|
|
49
|
+
onRowClick={(row, id) => setSelected({ row, id })}
|
|
50
|
+
highlightedIds={selectedId !== undefined ? [selectedId] : []}
|
|
51
|
+
className={"h-full"}/>
|
|
52
|
+
}
|
|
53
|
+
detail={selectedId !== undefined && (
|
|
54
|
+
<div className={"h-full overflow-auto p-4"}>
|
|
55
|
+
<RecordForm
|
|
56
|
+
// Another record is another form: remount rather
|
|
57
|
+
// than carry one record's edits into the next.
|
|
58
|
+
key={selectedId}
|
|
59
|
+
collection={COLLECTION}
|
|
60
|
+
id={selectedId}
|
|
61
|
+
fields={FORM_FIELDS}/>
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
detailTitle={selected ? String(selected.row[TITLE_FIELD] ?? selected.id) : undefined}
|
|
65
|
+
onClearSelection={() => setSelected(null)}/>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const customersMasterDetailView: AppView = {
|
|
71
|
+
slug: "customers/browse",
|
|
72
|
+
name: "Customers",
|
|
73
|
+
icon: "Users",
|
|
74
|
+
view: <CustomersMasterDetail/>
|
|
75
|
+
};
|
|
@@ -15,7 +15,7 @@ import React from "react";
|
|
|
15
15
|
import { defineCollection } from "@rebasepro/cms-types";
|
|
16
16
|
import type { AppView } from "@rebasepro/cms-types";
|
|
17
17
|
import { useAuthController } from "@rebasepro/app";
|
|
18
|
-
import {
|
|
18
|
+
import { RecordForm } from "@rebasepro/cms";
|
|
19
19
|
import { Container, Typography } from "@rebasepro/ui";
|
|
20
20
|
|
|
21
21
|
export const userPreferencesCollection = defineCollection({
|
|
@@ -49,12 +49,12 @@ export function MyPreferencesPage() {
|
|
|
49
49
|
return (
|
|
50
50
|
<Container maxWidth={"3xl"} className={"py-8"}>
|
|
51
51
|
<Typography variant={"h4"} gutterBottom>My preferences</Typography>
|
|
52
|
-
<
|
|
52
|
+
<RecordForm
|
|
53
53
|
// A new user is a new record: remount rather than carry one
|
|
54
54
|
// user's form state into another's.
|
|
55
55
|
key={user.uid}
|
|
56
56
|
collection={userPreferencesCollection}
|
|
57
|
-
|
|
57
|
+
id={user.uid}
|
|
58
58
|
defaultValues={{ theme: "system", weeklyDigest: true }}/>
|
|
59
59
|
</Container>
|
|
60
60
|
);
|
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Recipe: a dashboard page —
|
|
2
|
+
* Recipe: a dashboard page — count, group, chart, link into the admin.
|
|
3
3
|
*
|
|
4
|
-
* A page of the admin is a React component on a route.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* A page of the admin is a React component on a route. This one asks the data
|
|
5
|
+
* source for two numbers rather than reading rows: `useRowCount` for the
|
|
6
|
+
* total and `useAggregate` for a `count` per status, grouped and sorted by
|
|
7
|
+
* the database. Both are true however many orders there are, and both follow
|
|
8
|
+
* every write to the collection made in the admin.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* It draws with the metric blocks of `@rebasepro/ui` — `KpiGrid` / `KpiTile`
|
|
11
|
+
* for the figure, `ChartCard` / `BarChart` for the groups — which are what the
|
|
12
|
+
* admin's own dashboards are drawn with, in its tokens and dark mode. Each
|
|
13
|
+
* bar opens the collection filtered to its group, the filter in the URL as
|
|
14
|
+
* the collection's toolbar writes it, through the admin's router.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* Aggregates need a data source that computes them: Postgres through the
|
|
17
|
+
* server does. Where one cannot, the chart says so in place of the bars.
|
|
17
18
|
*
|
|
18
19
|
* To use it: add `ordersDashboardView` to `<RebaseCMS views={[…]}>`. Change
|
|
19
20
|
* `COLLECTION` / `GROUP_FIELD` to your own.
|
|
20
21
|
*/
|
|
21
|
-
import React
|
|
22
|
+
import React from "react";
|
|
22
23
|
import type { AppView } from "@rebasepro/cms-types";
|
|
23
|
-
import {
|
|
24
|
+
import { useAggregate, useRowCount } from "@rebasepro/app";
|
|
24
25
|
import { useUrlController } from "@rebasepro/cms";
|
|
25
|
-
import {
|
|
26
|
+
import { BarChart, ChartCard, Container, KpiGrid, KpiTile, Typography } from "@rebasepro/ui";
|
|
27
|
+
import type { Bar } from "@rebasepro/ui";
|
|
26
28
|
|
|
27
29
|
const COLLECTION = "orders";
|
|
28
30
|
const GROUP_FIELD = "status";
|
|
29
|
-
const MAX_ROWS = 5000;
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
/** The bar of the rows with no value in `GROUP_FIELD`; a bar's key is its value otherwise. */
|
|
33
|
+
const NO_VALUE = "\u0000none";
|
|
32
34
|
|
|
33
35
|
/** The collection's URL filtered to one value of `GROUP_FIELD`, as its toolbar writes it. */
|
|
34
36
|
function filteredUrl(collectionUrl: string, value: string | null): string {
|
|
@@ -37,82 +39,54 @@ function filteredUrl(collectionUrl: string, value: string | null): string {
|
|
|
37
39
|
return `${collectionUrl}?${GROUP_FIELD}_op=${op}&${GROUP_FIELD}_value=${encoded}`;
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
/** The hooks report a failure as its message; the blocks take an `Error`. */
|
|
43
|
+
function asError(message: string | undefined): Error | undefined {
|
|
44
|
+
return message === undefined ? undefined : new Error(message);
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
export function OrdersDashboard() {
|
|
41
|
-
const data = useData();
|
|
42
48
|
const urls = useUrlController();
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const total = useRowCount(COLLECTION);
|
|
50
|
+
// One row per status, `{ status, count }`, largest first. Over HTTP a
|
|
51
|
+
// grouped aggregate returns 50 groups unless `limit` asks for more.
|
|
52
|
+
const groups = useAggregate(COLLECTION, {
|
|
53
|
+
select: [{ fn: "count" }],
|
|
54
|
+
groupBy: [GROUP_FIELD],
|
|
55
|
+
orderBy: ["count", "desc"]
|
|
56
|
+
});
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
58
|
-
}
|
|
59
|
-
if (!cancelled) {
|
|
60
|
-
setTotal(Math.max(counted ?? 0, rows.length));
|
|
61
|
-
setGroups([...counts].map(([value, count]) => ({ value, count })).sort((a, b) => b.count - a.count));
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
.catch((e: unknown) => {
|
|
65
|
-
if (!cancelled) setError(e instanceof Error ? e.message : String(e));
|
|
66
|
-
});
|
|
67
|
-
return () => {
|
|
68
|
-
cancelled = true;
|
|
58
|
+
const collectionUrl = urls.buildUrlCollectionPath(COLLECTION);
|
|
59
|
+
const bars: Bar[] = (groups.result ?? []).map(row => {
|
|
60
|
+
const value = row[GROUP_FIELD];
|
|
61
|
+
const missing = value === null || value === undefined;
|
|
62
|
+
return {
|
|
63
|
+
key: missing ? NO_VALUE : String(value),
|
|
64
|
+
label: missing ? "—" : String(value),
|
|
65
|
+
value: Number(row.count),
|
|
66
|
+
// For "open in a new tab"; a plain click navigates in place.
|
|
67
|
+
href: filteredUrl(collectionUrl, missing ? null : String(value))
|
|
69
68
|
};
|
|
70
|
-
}
|
|
69
|
+
});
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const grouped = groups.reduce((sum, g) => sum + g.count, 0);
|
|
76
|
-
const max = Math.max(1, ...groups.map(g => g.count));
|
|
77
|
-
const collectionUrl = urls.buildUrlCollectionPath(COLLECTION);
|
|
71
|
+
const openGroup = (bar: Bar) => {
|
|
72
|
+
if (bar.href) urls.navigate(bar.href);
|
|
73
|
+
};
|
|
78
74
|
|
|
79
75
|
return (
|
|
80
76
|
<Container maxWidth={"4xl"} className={"py-8 flex flex-col gap-4"}>
|
|
81
77
|
<Typography variant={"h4"}>Orders</Typography>
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const href = filteredUrl(collectionUrl, group.value);
|
|
95
|
-
const label = group.value ?? "—";
|
|
96
|
-
return (
|
|
97
|
-
<a key={label}
|
|
98
|
-
href={href}
|
|
99
|
-
// The href is for "open in a new tab"; a plain
|
|
100
|
-
// click goes through the admin's router instead
|
|
101
|
-
// of reloading the page.
|
|
102
|
-
onClick={(event) => {
|
|
103
|
-
if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
|
|
104
|
-
event.preventDefault();
|
|
105
|
-
urls.navigate(href);
|
|
106
|
-
}}
|
|
107
|
-
aria-label={`${label}: ${group.count}`}
|
|
108
|
-
className={"grid grid-cols-[8rem_1fr_3rem] items-center gap-3 no-underline"}>
|
|
109
|
-
<Typography variant={"body2"}>{label}</Typography>
|
|
110
|
-
<div className={"h-3 rounded bg-primary/80"} style={{ width: `${(group.count / max) * 100}%` }}/>
|
|
111
|
-
<Typography variant={"body2"} align={"right"}>{group.count}</Typography>
|
|
112
|
-
</a>
|
|
113
|
-
);
|
|
114
|
-
})}
|
|
115
|
-
</Card>
|
|
78
|
+
<KpiGrid>
|
|
79
|
+
<KpiTile label={"Total"} icon={"ShoppingCart"}
|
|
80
|
+
value={total.count}
|
|
81
|
+
loading={total.loading}
|
|
82
|
+
error={asError(total.error)}/>
|
|
83
|
+
</KpiGrid>
|
|
84
|
+
<ChartCard title={`By ${GROUP_FIELD}`} icon={"ChartBar"}>
|
|
85
|
+
<BarChart bars={bars}
|
|
86
|
+
loading={groups.loading}
|
|
87
|
+
error={asError(groups.error)}
|
|
88
|
+
onBarClick={openGroup}/>
|
|
89
|
+
</ChartCard>
|
|
116
90
|
</Container>
|
|
117
91
|
);
|
|
118
92
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Recipe: a singleton — one settings record, edited on a page of its own.
|
|
3
3
|
*
|
|
4
4
|
* A singleton is not a special kind of collection. It is an ordinary table
|
|
5
|
-
* whose admin page always opens the same row. `
|
|
5
|
+
* whose admin page always opens the same row. `RecordForm` given an id
|
|
6
6
|
* edits that record, and creates it under that id the first time, so there is
|
|
7
7
|
* nothing to seed.
|
|
8
8
|
*
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import React from "react";
|
|
17
17
|
import { defineCollection } from "@rebasepro/cms-types";
|
|
18
18
|
import type { AppView } from "@rebasepro/cms-types";
|
|
19
|
-
import {
|
|
19
|
+
import { RecordForm } from "@rebasepro/cms";
|
|
20
20
|
import { Container, Typography } from "@rebasepro/ui";
|
|
21
21
|
|
|
22
22
|
/** The one row every visit to the page edits. */
|
|
@@ -46,9 +46,9 @@ export function SiteSettingsPage() {
|
|
|
46
46
|
return (
|
|
47
47
|
<Container maxWidth={"3xl"} className={"py-8"}>
|
|
48
48
|
<Typography variant={"h4"} gutterBottom>Site settings</Typography>
|
|
49
|
-
<
|
|
49
|
+
<RecordForm
|
|
50
50
|
collection={siteSettingsCollection}
|
|
51
|
-
|
|
51
|
+
id={SITE_SETTINGS_ID}
|
|
52
52
|
defaultValues={{ siteName: "My site", maintenanceMode: false }}/>
|
|
53
53
|
</Container>
|
|
54
54
|
);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
3
|
-
import type { EntityFormBindingProps } from "../form/EntityFormBinding.js";
|
|
4
|
-
import type { OnUpdateParams } from "../types/components/EntityFormProps.js";
|
|
5
|
-
/**
|
|
6
|
-
* Props for {@link EntityFormPanel}.
|
|
7
|
-
*
|
|
8
|
-
* @group Components
|
|
9
|
-
*/
|
|
10
|
-
export type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {
|
|
11
|
-
/**
|
|
12
|
-
* The collection the record belongs to, as a value — a `defineCollection`
|
|
13
|
-
* config or a resolved collection.
|
|
14
|
-
*/
|
|
15
|
-
collection: AdminCollection<M>;
|
|
16
|
-
/**
|
|
17
|
-
* The record to edit. When no record has this id yet, the form creates
|
|
18
|
-
* it under this id — so a record kept at a known key (a settings record,
|
|
19
|
-
* a profile keyed by its user's id) needs no seeding. Omit it to create a
|
|
20
|
-
* new record under an id the data source assigns.
|
|
21
|
-
*/
|
|
22
|
-
entityId?: string | number;
|
|
23
|
-
/**
|
|
24
|
-
* Where the collection is addressed. Defaults to `collection.slug`; a
|
|
25
|
-
* subcollection's record takes its full path (`posts/p1/comments`).
|
|
26
|
-
*/
|
|
27
|
-
path?: string;
|
|
28
|
-
/** Called after every successful save, with the saved record. */
|
|
29
|
-
onSaved?: (params: OnUpdateParams) => void;
|
|
30
|
-
/**
|
|
31
|
-
* Called when the form asks to be left — after its record is deleted, or
|
|
32
|
-
* by an action that closes it. The form is your page's, so where that
|
|
33
|
-
* leads is yours to say; without it, nothing happens.
|
|
34
|
-
*/
|
|
35
|
-
onClose?: () => void;
|
|
36
|
-
/** Values a new record starts with — one created without an id, or under an id no record has yet. */
|
|
37
|
-
defaultValues?: Partial<M>;
|
|
38
|
-
className?: string;
|
|
39
|
-
/** Anything else {@link EntityFormBinding} takes. */
|
|
40
|
-
formProps?: Partial<Omit<EntityFormBindingProps<M>, "path" | "collection" | "entityId" | "entity" | "initialStatus">>;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* One record's form — loaded by id, saved through `<Rebase>`'s data layer —
|
|
44
|
-
* to drop into a page of your own app.
|
|
45
|
-
*
|
|
46
|
-
* Needs `<Rebase>` and a React Router router above it (any router, any path).
|
|
47
|
-
* Where no CMS navigation is mounted above, it brings its own
|
|
48
|
-
* {@link CollectionsProvider}, so `<RebaseCMS>`, `<RebaseNavigation>` and
|
|
49
|
-
* `<RebaseShell>` are not needed.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```tsx
|
|
53
|
-
* <Rebase client={client} authController={authController}>
|
|
54
|
-
* <BrowserRouter>
|
|
55
|
-
* <EntityFormPanel collection={postsCollection} entityId="123"
|
|
56
|
-
* onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>
|
|
57
|
-
* </BrowserRouter>
|
|
58
|
-
* </Rebase>
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* @group Components
|
|
62
|
-
*/
|
|
63
|
-
export declare function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>): React.JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFormPanel.js","names":[],"sources":["../../src/components/EntityFormPanel.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { Entity } from \"@rebasepro/types\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { Alert, Button, CenteredView, CircularProgressCenter, Typography } from \"@rebasepro/ui\";\nimport { CollectionScopeProvider, ErrorView, useFetch, usePermissions, useTranslation } from \"@rebasepro/app\";\n\nimport { EntityFormBinding } from \"../form/EntityFormBinding\";\nimport type { EntityFormBindingProps } from \"../form/EntityFormBinding\";\nimport type { OnUpdateParams } 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\";\n\n/**\n * Props for {@link EntityFormPanel}.\n *\n * @group Components\n */\nexport type EntityFormPanelProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n /**\n * The collection the record belongs to, as a value — a `defineCollection`\n * config or a resolved collection.\n */\n collection: AdminCollection<M>;\n\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 entityId?: string | number;\n\n /**\n * Where the collection is addressed. Defaults to `collection.slug`; a\n * subcollection's record takes its full path (`posts/p1/comments`).\n */\n path?: string;\n\n /** Called after every successful save, with the saved record. */\n onSaved?: (params: OnUpdateParams) => 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 /** Anything else {@link EntityFormBinding} takes. */\n formProps?: Partial<Omit<EntityFormBindingProps<M>, \"path\" | \"collection\" | \"entityId\" | \"entity\" | \"initialStatus\">>;\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 * <EntityFormPanel collection={postsCollection} entityId=\"123\"\n * onSaved={({ entity }) => toast(`Saved ${entity.id}`)}/>\n * </BrowserRouter>\n * </Rebase>\n * ```\n *\n * @group Components\n */\nexport function EntityFormPanel<M extends Record<string, unknown> = Record<string, unknown>>(props: EntityFormPanelProps<M>) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n const { collection } = props;\n const ownCollections = useMemo(() => [collection], [collection]);\n\n // As `CollectionPanel`: its own scope where none is above, or where the\n // one above has settled without this collection.\n const needsOwnScope = !inScope\n || (!navigationState.loading && !isRegistered(collectionRegistry.collections, props.path ?? collection.slug));\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 = `${props.path ?? collection.slug}/${props.entityId ?? \"new\"}`;\n if (needsOwnScope) {\n return (\n <CollectionsProvider collections={ownCollections}>\n <EntityFormPanelInScope key={recordKey} {...props}/>\n </CollectionsProvider>\n );\n }\n return <EntityFormPanelInScope key={recordKey} {...props}/>;\n}\n\nfunction EntityFormPanelInScope<M extends Record<string, unknown>>({\n collection: collectionProp,\n entityId,\n path: pathProp,\n onSaved,\n onClose,\n defaultValues,\n className,\n formProps\n}: EntityFormPanelProps<M>) {\n const { t } = useTranslation();\n const path = pathProp ?? collectionProp.slug;\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 const lookUp = collectionRegistry.initialised || !navigationState.loading;\n const collection = useMemo(\n () => lookUp ? collectionRegistry.getCollection(path) : undefined,\n [lookUp, collectionRegistry, path]);\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 (\n <CenteredView className={className}>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"entity_not_found\")}\n </Typography>\n </CenteredView>\n );\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 entity={asNew.saved}\n initialStatus={\"new\"}\n initialDirtyValues={asNew.values}\n disabled={!canCreate(collection, path) || formProps?.disabled}\n onEntityChange={(changed) => {\n // The record it created, which it edits from then on.\n setAsNew(current => current && { ...current, saved: changed });\n formProps?.onEntityChange?.(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);\n\n return (\n <CollectionScopeProvider collection={collection}>\n <EntityFormBinding<M>\n {...formProps}\n className={className ?? formProps?.className}\n path={path}\n collection={collection}\n entityId={entityId}\n entity={shownEntity}\n initialStatus={creating ? \"new\" : \"existing\"}\n initialDirtyValues={creating ? defaultValues : formProps?.initialDirtyValues}\n disabled={!editable || formProps?.disabled}\n onEntityChange={(changed) => {\n setSavedEntity(changed);\n formProps?.onEntityChange?.(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"],"mappings":"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"}
|