@rebasepro/cms 0.28.2 → 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
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { FieldBlock, spanClass } from "../form/components/FieldBlock.js";
|
|
2
1
|
import { AdditionalFieldValue } from "./AdditionalFieldValue.js";
|
|
2
|
+
import { FieldBlock, spanClass } from "../form/components/FieldBlock.js";
|
|
3
|
+
import { useEntityDisplayValues } from "../hooks/useEntityDisplay.js";
|
|
4
|
+
import { PropertyPreview } from "../preview/PropertyPreview.js";
|
|
5
|
+
import { isFieldShown } from "../form/FormFieldsContext.js";
|
|
3
6
|
import { FormRail, RecordMeta } from "../form/components/FormRail.js";
|
|
4
7
|
import { FormSections } from "../form/components/FormSections.js";
|
|
5
8
|
import { useRailVisible } from "../form/components/useRailVisible.js";
|
|
6
|
-
import {
|
|
7
|
-
import { PropertyPreview } from "../preview/PropertyPreview.js";
|
|
9
|
+
import { collectionShowing } from "../form/collection_showing.js";
|
|
8
10
|
import { EntityDisplayHeader, HEADER_DISPLAY_ROLES } from "./EntityDisplayHeader.js";
|
|
9
11
|
import { useCallback, useMemo, useRef, useState } from "react";
|
|
10
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
13
|
import { AlignLeftIcon, cls, defaultBorderMixin, paperMixin } from "@rebasepro/ui";
|
|
12
|
-
import { getFormFieldKeys, resolveFormLayout, useRebaseContext } from "@rebasepro/app";
|
|
14
|
+
import { getFormFieldKeys, resolveFormLayout, rowOfEntity, useAuthController, useCustomizationController, useRebaseContext } from "@rebasepro/app";
|
|
13
15
|
import { getValueInPath } from "@rebasepro/utils";
|
|
14
16
|
//#region src/components/EntityViewBinding.tsx
|
|
15
17
|
/** Nothing can be in error in a view that cannot be submitted. */
|
|
@@ -66,30 +68,53 @@ function readOnlyFieldKeys(collection, hasFormContext, headerKeys) {
|
|
|
66
68
|
* one; a value is bare text, so the rows and sections are opened up rather than
|
|
67
69
|
* inheriting spacing sized for inputs.
|
|
68
70
|
*/
|
|
69
|
-
function EntityViewBinding({ entity, collection, className, asPage = false, openEntityMode = "full_screen", formContext }) {
|
|
71
|
+
function EntityViewBinding({ entity, collection, path, className, asPage = false, openEntityMode = "full_screen", formContext, fields }) {
|
|
72
|
+
const authController = useAuthController();
|
|
73
|
+
const customizationController = useCustomizationController();
|
|
70
74
|
const display = useEntityDisplayValues({
|
|
71
75
|
collection,
|
|
72
76
|
entity
|
|
73
77
|
});
|
|
78
|
+
const showHeader = !fields;
|
|
74
79
|
const headerKeys = useMemo(() => {
|
|
75
80
|
const keys = /* @__PURE__ */ new Set();
|
|
81
|
+
if (!showHeader) return keys;
|
|
76
82
|
for (const role of HEADER_DISPLAY_ROLES) {
|
|
77
83
|
const key = display[role].source?.key;
|
|
78
84
|
if (key) keys.add(key);
|
|
79
85
|
}
|
|
80
86
|
return keys;
|
|
81
|
-
}, [display]);
|
|
87
|
+
}, [display, showHeader]);
|
|
88
|
+
const shownCollection = useMemo(() => fields ? collectionShowing(collection, fields) : collection, [collection, fields?.join(",")]);
|
|
82
89
|
const hasFormContext = Boolean(formContext);
|
|
83
|
-
const fieldKeys = useMemo(() => readOnlyFieldKeys(
|
|
84
|
-
collection
|
|
90
|
+
const fieldKeys = useMemo(() => readOnlyFieldKeys(shownCollection, hasFormContext, headerKeys).filter((key) => {
|
|
91
|
+
const property = collection.properties?.[key];
|
|
92
|
+
return !property || isFieldShown({
|
|
93
|
+
propertyKey: key,
|
|
94
|
+
property,
|
|
95
|
+
values: entity.values,
|
|
96
|
+
previousValues: entity.values,
|
|
97
|
+
path,
|
|
98
|
+
entityId: entity.id,
|
|
99
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
100
|
+
authController
|
|
101
|
+
});
|
|
102
|
+
}), [
|
|
103
|
+
shownCollection,
|
|
85
104
|
hasFormContext,
|
|
86
|
-
headerKeys
|
|
105
|
+
headerKeys,
|
|
106
|
+
collection.properties,
|
|
107
|
+
entity.values,
|
|
108
|
+
entity.id,
|
|
109
|
+
path,
|
|
110
|
+
customizationController.propertyConfigs,
|
|
111
|
+
authController
|
|
87
112
|
]);
|
|
88
113
|
const layout = useMemo(() => resolveFormLayout({
|
|
89
|
-
collection,
|
|
114
|
+
collection: shownCollection,
|
|
90
115
|
fieldKeys,
|
|
91
116
|
status: "existing"
|
|
92
|
-
}), [
|
|
117
|
+
}), [shownCollection, fieldKeys]);
|
|
93
118
|
const containerRef = useRef(null);
|
|
94
119
|
const railVisible = useRailVisible(containerRef);
|
|
95
120
|
const showRail = asPage && layout.hasRail && railVisible;
|
|
@@ -108,14 +133,18 @@ function EntityViewBinding({ entity, collection, className, asPage = false, open
|
|
|
108
133
|
const additionalField = collection.additionalFields?.find((f) => f.key === field.key);
|
|
109
134
|
if (!additionalField || !formContext) return null;
|
|
110
135
|
const AdditionalFieldBuilder = additionalField.Builder;
|
|
136
|
+
const row = rowOfEntity(entity, collection);
|
|
137
|
+
const id = String(entity.id);
|
|
111
138
|
const child = AdditionalFieldBuilder ? /* @__PURE__ */ jsx(AdditionalFieldBuilder, {
|
|
112
|
-
|
|
139
|
+
row,
|
|
140
|
+
id,
|
|
113
141
|
context: rebaseContext
|
|
114
142
|
}) : /* @__PURE__ */ jsx("div", {
|
|
115
143
|
className: "w-full",
|
|
116
144
|
children: /* @__PURE__ */ jsx(AdditionalFieldValue, {
|
|
117
145
|
field: additionalField,
|
|
118
|
-
|
|
146
|
+
row,
|
|
147
|
+
id,
|
|
119
148
|
context: rebaseContext
|
|
120
149
|
})
|
|
121
150
|
});
|
|
@@ -198,7 +227,7 @@ function EntityViewBinding({ entity, collection, className, asPage = false, open
|
|
|
198
227
|
fields: layout.sidebar
|
|
199
228
|
}];
|
|
200
229
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
201
|
-
/* @__PURE__ */ jsx(EntityDisplayHeader, {
|
|
230
|
+
showHeader && /* @__PURE__ */ jsx(EntityDisplayHeader, {
|
|
202
231
|
entity,
|
|
203
232
|
collection,
|
|
204
233
|
showTitle: !asPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityViewBinding.js","names":[],"sources":["../../src/components/EntityViewBinding.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\n\nimport type { AdditionalFieldDelegateProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { ResolvedFormField, ResolvedFormSection } from \"@rebasepro/app\";\nimport type { FormContext } from \"../types/fields\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport {\n AlignLeftIcon,\n cls,\n defaultBorderMixin,\n ErrorBoundary,\n paperMixin\n} from \"@rebasepro/ui\";\nimport { getFormFieldKeys, resolveFormLayout } from \"@rebasepro/app\";\nimport { useRebaseContext } from \"@rebasepro/app\";\nimport { getValueInPath } from \"@rebasepro/utils\";\n\nimport { FieldBlock, LABEL_ICON_SIZE, spanClass } from \"../form/components/FieldBlock\";\nimport { AdditionalFieldValue } from \"./AdditionalFieldValue\";\nimport { EntityDisplayHeader, HEADER_DISPLAY_ROLES } from \"./EntityDisplayHeader\";\nimport { FormSections } from \"../form/components/FormSections\";\nimport { FormRail, RecordMeta } from \"../form/components/FormRail\";\nimport { useEntityDisplayValues } from \"../hooks/useEntityDisplay\";\nimport { useRailVisible } from \"../form/components/useRailVisible\";\nimport { PropertyPreview } from \"../preview\";\n\n/** Nothing can be in error in a view that cannot be submitted. */\nconst NO_ERRORS: ReadonlySet<string> = new Set<string>();\n\n/**\n * The fields the read-only view lays out, in render order.\n *\n * The same set the form uses, minus two groups. Both are dropped *before* the\n * layout resolves rather than skipped while rendering, because the resolver has\n * by then given each one a place on the grid — skipping later leaves that place\n * as a hole.\n *\n * - The `additionalFields` when there is no form context to hand them: those\n * entries are arbitrary components, not values, and one rendered against no\n * context is nothing at all.\n * - `headerKeys` — the properties {@link EntityDisplayHeader} has already\n * rendered as the record's picture, subtitle, state and labels. Leaving one in\n * prints its value twice on one screen.\n *\n * The record's **title property is not among them**, deliberately. It names the\n * page in the identity bar, but a heading and a labelled field are different\n * things: `Order #` is a column with a name and a description that someone opens\n * the record to read, and dropping it because its text also appears in the\n * breadcrumb removes a value from the record on the grounds that it is legible\n * somewhere else. See {@link HEADER_DISPLAY_ROLES}.\n */\nexport function readOnlyFieldKeys(\n collection: AdminCollection,\n hasFormContext: boolean,\n headerKeys?: ReadonlySet<string>\n): string[] {\n const keys = getFormFieldKeys(collection);\n const additional = hasFormContext\n ? undefined\n : new Set((collection.additionalFields ?? []).map(field => field.key));\n\n return keys.filter(key =>\n !additional?.has(key)\n && !headerKeys?.has(key));\n}\n\n/**\n * @group Components\n */\nexport interface EntityViewBindingProps<M extends Record<string, unknown>> {\n entity: Entity<M>;\n collection: AdminCollection<M>;\n path: string;\n className?: string;\n /**\n * Lay the record out as a page: a centred, scrolling column with the\n * metadata rail beside it, exactly as the form does. Off for the inline\n * uses — the delete dialog renders the record inside a box it already owns.\n */\n asPage?: boolean;\n /** Padding preset, matching the form's. Only read when `asPage`. */\n openEntityMode?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n /**\n * Needed only to render `additionalFields`, which are arbitrary components\n * that take a form context. Without one those entries are left out rather\n * than rendered against a fake context.\n */\n formContext?: FormContext<M>;\n}\n\n/**\n * The read-only rendering of a record's values.\n *\n * This is the same layout as {@link EntityForm}: the sections, the grid spans,\n * the labels and the rail all come from the one resolver, so the record does\n * not rearrange itself when you press Edit. Only the controls differ — each\n * field renders its {@link PropertyPreview} instead of an input.\n *\n * It used to be a flat two-column table of every value in the record: no\n * grouping, no widths, a label column sized for short names and a value column\n * that wrapped emails over two lines while the pane beside it stayed empty. A\n * boolean and a markdown body were given the same room.\n *\n * The synthetic `Id` row it used to prepend is gone with the same reasoning the\n * form applies: between that row, the collection's own id property and the\n * `path/id` chip above them, one UUID appeared three times. The id is a\n * copyable chip in the identity bar, and the rail's record block, once each.\n *\n * The labels are the form's labels, icon and all: a field is the same field\n * whether or not you are editing it. What `mode: \"read\"` drops is the per-field\n * *description*, which is input help rather than part of the label — and what it\n * adds is room. A control is a bordered box that separates itself from the next\n * one; a value is bare text, so the rows and sections are opened up rather than\n * inheriting spacing sized for inputs.\n */\nexport function EntityViewBinding<M extends Record<string, unknown>>(\n {\n entity,\n collection,\n className,\n asPage = false,\n openEntityMode = \"full_screen\",\n formContext\n }: EntityViewBindingProps<M>) {\n\n // The record's name, picture, state and labels, lifted out of the grid and\n // into a header. Resolved here rather than inside it because the fields it\n // renders have to come *out* of the layout, and the layout is resolved here.\n const display = useEntityDisplayValues<M>({\n collection,\n entity\n });\n\n const headerKeys = useMemo(() => {\n const keys = new Set<string>();\n for (const role of HEADER_DISPLAY_ROLES) {\n // Set only for a role filled by a property of this collection. A\n // role filled by a resolver has no field on the grid to remove.\n const key = display[role].source?.key;\n if (key) keys.add(key);\n }\n return keys;\n }, [display]);\n\n // Only *whether* there is a form context changes the field list, not which\n // one it is — so the memo turns on the boolean rather than on the context\n // object, which is rebuilt on every keystroke of the form above it.\n const hasFormContext = Boolean(formContext);\n const fieldKeys = useMemo(\n () => readOnlyFieldKeys(collection as AdminCollection, hasFormContext, headerKeys),\n [collection, hasFormContext, headerKeys]\n );\n\n // `status: \"existing\"` — a record you are reading exists by definition, and\n // that is what routes a generated id and the audit timestamps out of the\n // column and into the record block.\n const layout = useMemo(() => resolveFormLayout({\n collection,\n fieldKeys,\n status: \"existing\"\n }), [collection, fieldKeys]);\n\n const containerRef = useRef<HTMLDivElement>(null);\n // Measured, not a breakpoint — see `useRailVisible`. The same reasoning as\n // the form's: the resolver *moves* fields into the rail, so when the rail\n // cannot be shown they have to fold back into the column.\n const railVisible = useRailVisible(containerRef);\n const showRail = asPage && layout.hasRail && railVisible;\n\n const [collapsedSections, setCollapsedSections] = useState<Set<string>>(\n () => new Set(layout.sections.filter(section => section.collapsed).map(section => section.key))\n );\n const toggleSection = useCallback((key: string) => {\n setCollapsedSections(prev => {\n const next = new Set(prev);\n if (next.has(key)) next.delete(key); else next.add(key);\n return next;\n });\n }, []);\n\n // See the same line in `EntityForm`: the context an `additionalFields`\n // Builder is documented to receive, in place of a `FormContext` asserted\n // into its shape.\n const rebaseContext = useRebaseContext();\n\n const renderField = useCallback((field: ResolvedFormField): React.ReactNode => {\n\n if (field.additional) {\n const additionalField = collection.additionalFields?.find(f => f.key === field.key);\n if (!additionalField || !formContext) return null;\n\n const AdditionalFieldBuilder = additionalField.Builder;\n const child = AdditionalFieldBuilder\n ? <AdditionalFieldBuilder entity={entity} context={rebaseContext}/>\n : <div className={\"w-full\"}>\n <AdditionalFieldValue\n field={additionalField}\n entity={entity}\n context={rebaseContext}/>\n </div>;\n\n return (\n // Through FieldBlock like every other cell, so a computed\n // column is labelled at the same size, with the same gap to its\n // box, as the property next to it on the grid.\n <div key={`additional_${field.key}`} className={spanClass(field.span)}>\n <FieldBlock propertyKey={field.key}\n showLabel={true}\n mode={\"read\"}\n label={additionalField.name}\n icon={<AlignLeftIcon size={LABEL_ICON_SIZE}/>}>\n <div className={cls(paperMixin, \"w-full min-h-12 p-4 md:p-6 overflow-x-auto no-scrollbar\")}>\n {child}\n </div>\n </FieldBlock>\n </div>\n );\n }\n\n const property = collection.properties?.[field.key] as Property | undefined;\n if (!property) return null;\n\n return (\n <div key={`field_${field.key}`} className={spanClass(field.span)}>\n {/* Always labelled from here, unlike the form. The panel editors\n that carry their own header have no header in preview — a map\n previews as a table of its children and an array as its items,\n so leaving the label to them would leave them unlabelled. */}\n <FieldBlock propertyKey={field.key}\n property={property}\n showLabel={true}\n mode={\"read\"}>\n {/* One control's height for a single-line value, so a row of\n short fields lines up with the taller ones beside it, and\n anything longer simply grows. Matched to the form's row\n rather than shrunk to the text: it is what keeps a value\n from sitting directly on the label of the row below. */}\n <div className={\"min-h-8 flex flex-col justify-center min-w-0 text-sm text-text-primary dark:text-text-primary-dark\"}>\n <PropertyPreview propertyKey={field.key}\n value={getValueInPath(entity.values, field.key)}\n property={property}\n hideLabel\n size={\"medium\"}/>\n </div>\n </FieldBlock>\n </div>\n );\n // `rebaseContext` is read twice above and was not declared, so every\n // `additionalFields` Builder kept receiving the context captured on the\n // first render — the stale closure this dependency array exists to\n // prevent. It is handed straight to customer code, which is the worst\n // place to be one version behind: a Builder that resolves a reference or\n // checks a permission would do it against a context that has since\n // changed user, auth or data source.\n }, [collection, entity, formContext, rebaseContext]);\n\n /**\n * One field of a `readVariant: \"summary\"` section: a label/value row rather\n * than a grid cell, with the last one emphasised.\n *\n * The last row is the one a summary exists for — a run of figures is read to\n * arrive at its final line — so it is separated by a rule and set at the\n * weight the grid gave every cell equally.\n */\n const renderSummaryField = useCallback((\n field: ResolvedFormField,\n index: number,\n total: number\n ): React.ReactNode => {\n\n const property = collection.properties?.[field.key] as Property | undefined;\n if (!property) return null;\n\n const last = index === total - 1;\n\n return (\n <div key={`summary_${field.key}`}\n className={cls(\n \"flex items-baseline justify-between gap-4 min-w-0 py-2\",\n last && total > 1 && cls(\"mt-1.5 pt-3 border-t\", defaultBorderMixin)\n )}>\n <span className={cls(\n \"min-w-0 truncate\",\n last\n ? \"text-sm font-semibold text-text-primary dark:text-text-primary-dark\"\n : \"text-sm text-text-secondary dark:text-text-secondary-dark\"\n )}>\n {property.name ?? field.key}\n </span>\n <span className={cls(\n \"shrink-0 text-right text-text-primary dark:text-text-primary-dark\",\n last ? \"text-base font-semibold\" : \"text-sm\"\n )}>\n <PropertyPreview propertyKey={field.key}\n value={getValueInPath(entity.values, field.key)}\n property={property}\n hideLabel\n size={\"medium\"}/>\n </span>\n </div>\n );\n }, [collection, entity]);\n\n // Same fold-back as the form: with no room for the rail its fields become a\n // trailing group rather than disappearing.\n const sections: ResolvedFormSection[] = showRail || !layout.sidebar.length\n ? layout.sections\n : [\n ...layout.sections,\n {\n key: \"__rail\",\n title: \"Settings\",\n collapsible: false,\n collapsed: false,\n fields: layout.sidebar\n }\n ];\n\n const content = <>\n {/* The title only when nothing above is already showing it. Every\n full-page use sits under an identity bar that carries it; the\n inline ones — the delete dialog — have no bar. */}\n <EntityDisplayHeader entity={entity}\n collection={collection}\n showTitle={!asPage}\n className={\"mb-10\"}/>\n\n <FormSections sections={sections}\n collapsed={collapsedSections}\n onToggle={toggleSection}\n errorKeys={NO_ERRORS}\n renderField={renderField}\n renderSummaryField={renderSummaryField}\n mode={\"read\"}/>\n\n {/* Folded back with the rail's fields, and for the same reason. The rail\n renders only where it has been measured to fit, so on the split pane,\n the side panel and the dialog this block was dropped outright and the\n record's id was nowhere on screen but the truncated chip in the bar.\n An id you cannot read or copy is the one piece of a record you most\n often opened it for. */}\n {!showRail && layout.showRecordMeta && (\n <div className={cls(\"mt-10 pt-6 border-t max-w-sm\", defaultBorderMixin)}>\n <RecordMeta entity={entity as Entity<Record<string, unknown>>}/>\n </div>\n )}\n </>;\n\n if (!asPage) {\n // `@container/col` even here: the spans resolve against the column they\n // sit in, and inside a dialog that column is the dialog.\n return (\n <div ref={containerRef} className={cls(\"@container/col w-full min-w-0\", className)}>\n {content}\n </div>\n );\n }\n\n return (\n <div ref={containerRef} className={cls(\"@container/form flex-1 flex flex-row w-full min-h-0\", className)}>\n\n {/* `items-start`: without it the cross-axis default stretches the\n column to the scroller's height and its bottom padding lands at\n the bottom of the viewport instead of after the last field. */}\n <div className={\"flex-1 min-w-0 overflow-y-auto flex justify-center items-start\"}>\n <div className={cls(\n // Same widths as the editable form (see EntityForm) — toggling\n // between read-only and edit must not move the column.\n \"@container/col w-full max-w-3xl @7xl/form:max-w-4xl 2xl:max-w-4xl flex flex-col\",\n openEntityMode === \"dialog\"\n ? \"pt-5 pb-8 px-6 sm:px-8\"\n : \"pt-6 pb-12 px-5 sm:px-8\"\n )}>\n {content}\n </div>\n </div>\n\n {showRail && <FormRail\n fields={layout.sidebar}\n showRecordMeta={layout.showRecordMeta}\n entity={entity as Entity<Record<string, unknown>>}\n renderField={renderField}/>}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,IAAM,4BAAiC,IAAI,IAAY;;;;;;;;;;;;;;;;;;;;;;;AAwBvD,SAAgB,kBACZ,YACA,gBACA,YACQ;CACR,MAAM,OAAO,iBAAiB,UAAU;CACxC,MAAM,aAAa,iBACb,KAAA,IACA,IAAI,KAAK,WAAW,oBAAoB,CAAC,EAAA,CAAG,KAAI,UAAS,MAAM,GAAG,CAAC;CAEzE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,mFACA,mBAAmB,WACb,2BACA,yBACV;cACK;GACA,CAAA;EACJ,CAAA,GAEJ,YAAY,oBAAC,UAAD;GACT,QAAQ,OAAO;GACf,gBAAgB,OAAO;GACf;GACK;EAAa,CAAA,CAC7B;;AAEb"}
|
|
1
|
+
{"version":3,"file":"EntityViewBinding.js","names":[],"sources":["../../src/components/EntityViewBinding.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\n\nimport type { AdditionalFieldDelegateProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport type { ResolvedFormField, ResolvedFormSection } from \"@rebasepro/app\";\nimport type { FormContext } from \"../types/fields\";\nimport React, { useCallback, useMemo, useRef, useState } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport {\n AlignLeftIcon,\n cls,\n defaultBorderMixin,\n ErrorBoundary,\n paperMixin\n} from \"@rebasepro/ui\";\nimport { getFormFieldKeys, resolveFormLayout } from \"@rebasepro/app\";\nimport { useAuthController, useCustomizationController, useRebaseContext } from \"@rebasepro/app\";\nimport { getValueInPath } from \"@rebasepro/utils\";\n\nimport { FieldBlock, LABEL_ICON_SIZE, spanClass } from \"../form/components/FieldBlock\";\nimport { AdditionalFieldValue } from \"./AdditionalFieldValue\";\nimport { rowOfEntity } from \"@rebasepro/app\";\nimport { EntityDisplayHeader, HEADER_DISPLAY_ROLES } from \"./EntityDisplayHeader\";\nimport { FormSections } from \"../form/components/FormSections\";\nimport { FormRail, RecordMeta } from \"../form/components/FormRail\";\nimport { collectionShowing } from \"../form/collection_showing\";\nimport { isFieldShown } from \"../form/FormFieldsContext\";\nimport { useEntityDisplayValues } from \"../hooks/useEntityDisplay\";\nimport { useRailVisible } from \"../form/components/useRailVisible\";\nimport { PropertyPreview } from \"../preview\";\n\n/** Nothing can be in error in a view that cannot be submitted. */\nconst NO_ERRORS: ReadonlySet<string> = new Set<string>();\n\n/**\n * The fields the read-only view lays out, in render order.\n *\n * The same set the form uses, minus two groups. Both are dropped *before* the\n * layout resolves rather than skipped while rendering, because the resolver has\n * by then given each one a place on the grid — skipping later leaves that place\n * as a hole.\n *\n * - The `additionalFields` when there is no form context to hand them: those\n * entries are arbitrary components, not values, and one rendered against no\n * context is nothing at all.\n * - `headerKeys` — the properties {@link EntityDisplayHeader} has already\n * rendered as the record's picture, subtitle, state and labels. Leaving one in\n * prints its value twice on one screen.\n *\n * The record's **title property is not among them**, deliberately. It names the\n * page in the identity bar, but a heading and a labelled field are different\n * things: `Order #` is a column with a name and a description that someone opens\n * the record to read, and dropping it because its text also appears in the\n * breadcrumb removes a value from the record on the grounds that it is legible\n * somewhere else. See {@link HEADER_DISPLAY_ROLES}.\n */\nexport function readOnlyFieldKeys(\n collection: AdminCollection,\n hasFormContext: boolean,\n headerKeys?: ReadonlySet<string>\n): string[] {\n const keys = getFormFieldKeys(collection);\n const additional = hasFormContext\n ? undefined\n : new Set((collection.additionalFields ?? []).map(field => field.key));\n\n return keys.filter(key =>\n !additional?.has(key)\n && !headerKeys?.has(key));\n}\n\n/**\n * @group Components\n */\nexport interface EntityViewBindingProps<M extends Record<string, unknown>> {\n entity: Entity<M>;\n collection: AdminCollection<M>;\n path: string;\n className?: string;\n /**\n * Lay the record out as a page: a centred, scrolling column with the\n * metadata rail beside it, exactly as the form does. Off for the inline\n * uses — the delete dialog renders the record inside a box it already owns.\n */\n asPage?: boolean;\n /** Padding preset, matching the form's. Only read when `asPage`. */\n openEntityMode?: \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n /**\n * Needed only to render `additionalFields`, which are arbitrary components\n * that take a form context. Without one those entries are left out rather\n * than rendered against a fake context.\n */\n formContext?: FormContext<M>;\n /**\n * The fields to show, in this order; any other property is left out, and\n * so is the header that lifts the record's picture, subtitle, status and\n * tags out of the grid. Sections and the rail keep their grouping, each\n * holding only these fields — as `RecordForm`'s `fields` does.\n */\n fields?: string[];\n}\n\n/**\n * The read-only rendering of a record's values.\n *\n * This is the same layout as {@link EntityForm}: the sections, the grid spans,\n * the labels and the rail all come from the one resolver, so the record does\n * not rearrange itself when you press Edit. Only the controls differ — each\n * field renders its {@link PropertyPreview} instead of an input.\n *\n * It used to be a flat two-column table of every value in the record: no\n * grouping, no widths, a label column sized for short names and a value column\n * that wrapped emails over two lines while the pane beside it stayed empty. A\n * boolean and a markdown body were given the same room.\n *\n * The synthetic `Id` row it used to prepend is gone with the same reasoning the\n * form applies: between that row, the collection's own id property and the\n * `path/id` chip above them, one UUID appeared three times. The id is a\n * copyable chip in the identity bar, and the rail's record block, once each.\n *\n * The labels are the form's labels, icon and all: a field is the same field\n * whether or not you are editing it. What `mode: \"read\"` drops is the per-field\n * *description*, which is input help rather than part of the label — and what it\n * adds is room. A control is a bordered box that separates itself from the next\n * one; a value is bare text, so the rows and sections are opened up rather than\n * inheriting spacing sized for inputs.\n */\nexport function EntityViewBinding<M extends Record<string, unknown>>(\n {\n entity,\n collection,\n path,\n className,\n asPage = false,\n openEntityMode = \"full_screen\",\n formContext,\n fields\n }: EntityViewBindingProps<M>) {\n\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n // The record's name, picture, state and labels, lifted out of the grid and\n // into a header. Resolved here rather than inside it because the fields it\n // renders have to come *out* of the layout, and the layout is resolved here.\n const display = useEntityDisplayValues<M>({\n collection,\n entity\n });\n\n // A view showing some fields shows only those, so no header: it draws\n // properties nobody named.\n const showHeader = !fields;\n const headerKeys = useMemo(() => {\n const keys = new Set<string>();\n if (!showHeader) return keys;\n for (const role of HEADER_DISPLAY_ROLES) {\n // Set only for a role filled by a property of this collection. A\n // role filled by a resolver has no field on the grid to remove.\n const key = display[role].source?.key;\n if (key) keys.add(key);\n }\n return keys;\n }, [display, showHeader]);\n\n const shownCollection = useMemo(\n () => fields ? collectionShowing(collection, fields) : collection,\n // eslint-disable-next-line react-hooks/exhaustive-deps -- `fields` is an inline array at most call sites: its contents, not its identity\n [collection, fields?.join(\",\")]);\n\n // Only *whether* there is a form context changes the field list, not which\n // one it is — so the memo turns on the boolean rather than on the context\n // object, which is rebuilt on every keystroke of the form above it.\n const hasFormContext = Boolean(formContext);\n const fieldKeys = useMemo(\n () => readOnlyFieldKeys(shownCollection as AdminCollection, hasFormContext, headerKeys)\n // The form's rules: a field a dynamic condition hides for this\n // record's values, or one this user may not read, is not shown.\n // Dropped before the layout resolves, like the groups above, so it\n // leaves no hole on the grid.\n .filter(key => {\n const property = collection.properties?.[key] as Property | undefined;\n return !property || isFieldShown<M>({\n propertyKey: key,\n property,\n values: entity.values,\n previousValues: entity.values,\n path,\n entityId: entity.id,\n propertyConfigs: customizationController.propertyConfigs,\n authController\n });\n }),\n [shownCollection, hasFormContext, headerKeys, collection.properties, entity.values, entity.id, path, customizationController.propertyConfigs, authController]\n );\n\n // `status: \"existing\"` — a record you are reading exists by definition, and\n // that is what routes a generated id and the audit timestamps out of the\n // column and into the record block.\n const layout = useMemo(() => resolveFormLayout({\n collection: shownCollection,\n fieldKeys,\n status: \"existing\"\n }), [shownCollection, fieldKeys]);\n\n const containerRef = useRef<HTMLDivElement>(null);\n // Measured, not a breakpoint — see `useRailVisible`. The same reasoning as\n // the form's: the resolver *moves* fields into the rail, so when the rail\n // cannot be shown they have to fold back into the column.\n const railVisible = useRailVisible(containerRef);\n const showRail = asPage && layout.hasRail && railVisible;\n\n const [collapsedSections, setCollapsedSections] = useState<Set<string>>(\n () => new Set(layout.sections.filter(section => section.collapsed).map(section => section.key))\n );\n const toggleSection = useCallback((key: string) => {\n setCollapsedSections(prev => {\n const next = new Set(prev);\n if (next.has(key)) next.delete(key); else next.add(key);\n return next;\n });\n }, []);\n\n // See the same line in `EntityForm`: the context an `additionalFields`\n // Builder is documented to receive, in place of a `FormContext` asserted\n // into its shape.\n const rebaseContext = useRebaseContext();\n\n const renderField = useCallback((field: ResolvedFormField): React.ReactNode => {\n\n if (field.additional) {\n const additionalField = collection.additionalFields?.find(f => f.key === field.key);\n if (!additionalField || !formContext) return null;\n\n const AdditionalFieldBuilder = additionalField.Builder;\n const row = rowOfEntity(entity, collection);\n const id = String(entity.id);\n const child = AdditionalFieldBuilder\n ? <AdditionalFieldBuilder row={row} id={id} context={rebaseContext}/>\n : <div className={\"w-full\"}>\n <AdditionalFieldValue\n field={additionalField}\n row={row}\n id={id}\n context={rebaseContext}/>\n </div>;\n\n return (\n // Through FieldBlock like every other cell, so a computed\n // column is labelled at the same size, with the same gap to its\n // box, as the property next to it on the grid.\n <div key={`additional_${field.key}`} className={spanClass(field.span)}>\n <FieldBlock propertyKey={field.key}\n showLabel={true}\n mode={\"read\"}\n label={additionalField.name}\n icon={<AlignLeftIcon size={LABEL_ICON_SIZE}/>}>\n <div className={cls(paperMixin, \"w-full min-h-12 p-4 md:p-6 overflow-x-auto no-scrollbar\")}>\n {child}\n </div>\n </FieldBlock>\n </div>\n );\n }\n\n const property = collection.properties?.[field.key] as Property | undefined;\n if (!property) return null;\n\n return (\n <div key={`field_${field.key}`} className={spanClass(field.span)}>\n {/* Always labelled from here, unlike the form. The panel editors\n that carry their own header have no header in preview — a map\n previews as a table of its children and an array as its items,\n so leaving the label to them would leave them unlabelled. */}\n <FieldBlock propertyKey={field.key}\n property={property}\n showLabel={true}\n mode={\"read\"}>\n {/* One control's height for a single-line value, so a row of\n short fields lines up with the taller ones beside it, and\n anything longer simply grows. Matched to the form's row\n rather than shrunk to the text: it is what keeps a value\n from sitting directly on the label of the row below. */}\n <div className={\"min-h-8 flex flex-col justify-center min-w-0 text-sm text-text-primary dark:text-text-primary-dark\"}>\n <PropertyPreview propertyKey={field.key}\n value={getValueInPath(entity.values, field.key)}\n property={property}\n hideLabel\n size={\"medium\"}/>\n </div>\n </FieldBlock>\n </div>\n );\n // `rebaseContext` is read twice above and was not declared, so every\n // `additionalFields` Builder kept receiving the context captured on the\n // first render — the stale closure this dependency array exists to\n // prevent. It is handed straight to customer code, which is the worst\n // place to be one version behind: a Builder that resolves a reference or\n // checks a permission would do it against a context that has since\n // changed user, auth or data source.\n }, [collection, entity, formContext, rebaseContext]);\n\n /**\n * One field of a `readVariant: \"summary\"` section: a label/value row rather\n * than a grid cell, with the last one emphasised.\n *\n * The last row is the one a summary exists for — a run of figures is read to\n * arrive at its final line — so it is separated by a rule and set at the\n * weight the grid gave every cell equally.\n */\n const renderSummaryField = useCallback((\n field: ResolvedFormField,\n index: number,\n total: number\n ): React.ReactNode => {\n\n const property = collection.properties?.[field.key] as Property | undefined;\n if (!property) return null;\n\n const last = index === total - 1;\n\n return (\n <div key={`summary_${field.key}`}\n className={cls(\n \"flex items-baseline justify-between gap-4 min-w-0 py-2\",\n last && total > 1 && cls(\"mt-1.5 pt-3 border-t\", defaultBorderMixin)\n )}>\n <span className={cls(\n \"min-w-0 truncate\",\n last\n ? \"text-sm font-semibold text-text-primary dark:text-text-primary-dark\"\n : \"text-sm text-text-secondary dark:text-text-secondary-dark\"\n )}>\n {property.name ?? field.key}\n </span>\n <span className={cls(\n \"shrink-0 text-right text-text-primary dark:text-text-primary-dark\",\n last ? \"text-base font-semibold\" : \"text-sm\"\n )}>\n <PropertyPreview propertyKey={field.key}\n value={getValueInPath(entity.values, field.key)}\n property={property}\n hideLabel\n size={\"medium\"}/>\n </span>\n </div>\n );\n }, [collection, entity]);\n\n // Same fold-back as the form: with no room for the rail its fields become a\n // trailing group rather than disappearing.\n const sections: ResolvedFormSection[] = showRail || !layout.sidebar.length\n ? layout.sections\n : [\n ...layout.sections,\n {\n key: \"__rail\",\n title: \"Settings\",\n collapsible: false,\n collapsed: false,\n fields: layout.sidebar\n }\n ];\n\n const content = <>\n {/* The title only when nothing above is already showing it. Every\n full-page use sits under an identity bar that carries it; the\n inline ones — the delete dialog — have no bar. */}\n {showHeader && <EntityDisplayHeader entity={entity}\n collection={collection}\n showTitle={!asPage}\n className={\"mb-10\"}/>}\n\n <FormSections sections={sections}\n collapsed={collapsedSections}\n onToggle={toggleSection}\n errorKeys={NO_ERRORS}\n renderField={renderField}\n renderSummaryField={renderSummaryField}\n mode={\"read\"}/>\n\n {/* Folded back with the rail's fields, and for the same reason. The rail\n renders only where it has been measured to fit, so on the split pane,\n the side panel and the dialog this block was dropped outright and the\n record's id was nowhere on screen but the truncated chip in the bar.\n An id you cannot read or copy is the one piece of a record you most\n often opened it for. */}\n {!showRail && layout.showRecordMeta && (\n <div className={cls(\"mt-10 pt-6 border-t max-w-sm\", defaultBorderMixin)}>\n <RecordMeta entity={entity as Entity<Record<string, unknown>>}/>\n </div>\n )}\n </>;\n\n if (!asPage) {\n // `@container/col` even here: the spans resolve against the column they\n // sit in, and inside a dialog that column is the dialog.\n return (\n <div ref={containerRef} className={cls(\"@container/col w-full min-w-0\", className)}>\n {content}\n </div>\n );\n }\n\n return (\n <div ref={containerRef} className={cls(\"@container/form flex-1 flex flex-row w-full min-h-0\", className)}>\n\n {/* `items-start`: without it the cross-axis default stretches the\n column to the scroller's height and its bottom padding lands at\n the bottom of the viewport instead of after the last field. */}\n <div className={\"flex-1 min-w-0 overflow-y-auto flex justify-center items-start\"}>\n <div className={cls(\n // Same widths as the editable form (see EntityForm) — toggling\n // between read-only and edit must not move the column.\n \"@container/col w-full max-w-3xl @7xl/form:max-w-4xl 2xl:max-w-4xl flex flex-col\",\n openEntityMode === \"dialog\"\n ? \"pt-5 pb-8 px-6 sm:px-8\"\n : \"pt-6 pb-12 px-5 sm:px-8\"\n )}>\n {content}\n </div>\n </div>\n\n {showRail && <FormRail\n fields={layout.sidebar}\n showRecordMeta={layout.showRecordMeta}\n entity={entity as Entity<Record<string, unknown>>}\n renderField={renderField}/>}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,IAAM,4BAAiC,IAAI,IAAY;;;;;;;;;;;;;;;;;;;;;;;AAwBvD,SAAgB,kBACZ,YACA,gBACA,YACQ;CACR,MAAM,OAAO,iBAAiB,UAAU;CACxC,MAAM,aAAa,iBACb,KAAA,IACA,IAAI,KAAK,WAAW,oBAAoB,CAAC,EAAA,CAAG,KAAI,UAAS,MAAM,GAAG,CAAC;CAEzE,OAAO,KAAK,QAAO,QACf,CAAC,YAAY,IAAI,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AIX,cAAc,oBAAC,qBAAD;GAA6B;GAC5B;GACZ,WAAW,CAAC;GACZ,WAAW;EAAS,CAAA;EAExB,oBAAC,cAAD;GAAwB;GACpB,WAAW;GACX,UAAU;GACV,WAAW;GACE;GACO;GACpB,MAAM;EAAQ,CAAA;EAQjB,CAAC,YAAY,OAAO,kBACjB,oBAAC,OAAD;GAAK,WAAW,IAAI,gCAAgC,kBAAkB;aAClE,oBAAC,YAAD,EAAoB,OAA2C,CAAA;EAC9D,CAAA;CAEX,EAAA,CAAA;CAEF,IAAI,CAAC,QAGD,OACI,oBAAC,OAAD;EAAK,KAAK;EAAc,WAAW,IAAI,iCAAiC,SAAS;YAC5E;CACA,CAAA;CAIb,OACI,qBAAC,OAAD;EAAK,KAAK;EAAc,WAAW,IAAI,uDAAuD,SAAS;YAAvG,CAKI,oBAAC,OAAD;GAAK,WAAW;aACZ,oBAAC,OAAD;IAAK,WAAW,IAGZ,mFACA,mBAAmB,WACb,2BACA,yBACV;cACK;GACA,CAAA;EACJ,CAAA,GAEJ,YAAY,oBAAC,UAAD;GACT,QAAQ,OAAO;GACf,gBAAgB,OAAO;GACf;GACK;EAAa,CAAA,CAC7B;;AAEb"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Entity } from "@rebasepro/types";
|
|
4
|
+
import type { FormContext } from "../types/fields.js";
|
|
5
|
+
type OpenEntityMode = "side_panel" | "full_screen" | "split" | "dialog";
|
|
6
|
+
/**
|
|
7
|
+
* The context a read-only record hands what it renders but does not own — an
|
|
8
|
+
* `additionalFields` entry, the collection's `formView.Builder`, a custom
|
|
9
|
+
* entity view, a plugin slot. Every write on it throws: nothing on a page that
|
|
10
|
+
* reads a record may change it. Undefined without an id to read by.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useReadOnlyFormContext<M extends Record<string, unknown>>({ entityId, entity, collection, path, openEntityMode }: {
|
|
13
|
+
entityId?: string | number;
|
|
14
|
+
entity?: Entity<M>;
|
|
15
|
+
collection: AdminCollection<M> | undefined;
|
|
16
|
+
path: string;
|
|
17
|
+
openEntityMode: OpenEntityMode;
|
|
18
|
+
}): FormContext<M> | undefined;
|
|
19
|
+
export interface EntityViewBodyProps<M extends Record<string, unknown>> {
|
|
20
|
+
entity: Entity<M>;
|
|
21
|
+
collection: AdminCollection<M>;
|
|
22
|
+
path: string;
|
|
23
|
+
/** See {@link useReadOnlyFormContext}. */
|
|
24
|
+
formContext?: FormContext<M>;
|
|
25
|
+
/** See `EntityViewBinding`'s `fields`. Wins over the collection's `formView.Builder`, which cannot be told which fields to draw. */
|
|
26
|
+
fields?: string[];
|
|
27
|
+
openEntityMode?: OpenEntityMode;
|
|
28
|
+
parentCollectionSlugs?: string[];
|
|
29
|
+
parentEntityIds?: string[];
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A record's values as a page: the collection's `formView.Builder` when it
|
|
34
|
+
* has one, otherwise the generated read-only grid.
|
|
35
|
+
*
|
|
36
|
+
* `RecordDetail` and the CMS's own detail view both draw a record's body
|
|
37
|
+
* here, so a record reads the same in a page of your app as in the admin.
|
|
38
|
+
*/
|
|
39
|
+
export declare function EntityViewBody<M extends Record<string, unknown>>({ entity, collection, path, formContext, fields, openEntityMode, parentCollectionSlugs, parentEntityIds, className }: EntityViewBodyProps<M>): React.JSX.Element;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { EntityViewBinding } from "./EntityViewBinding.js";
|
|
2
|
+
import { Suspense, useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { CircularProgressCenter, ErrorBoundary, cls } from "@rebasepro/ui";
|
|
5
|
+
import { hasEntityId } from "@rebasepro/common";
|
|
6
|
+
import { createFormexStub, resolveComponentRef, rowOfEntity } from "@rebasepro/app";
|
|
7
|
+
//#region src/components/EntityViewBody.tsx
|
|
8
|
+
/**
|
|
9
|
+
* The context a read-only record hands what it renders but does not own — an
|
|
10
|
+
* `additionalFields` entry, the collection's `formView.Builder`, a custom
|
|
11
|
+
* entity view, a plugin slot. Every write on it throws: nothing on a page that
|
|
12
|
+
* reads a record may change it. Undefined without an id to read by.
|
|
13
|
+
*/
|
|
14
|
+
function useReadOnlyFormContext({ entityId, entity, collection, path, openEntityMode }) {
|
|
15
|
+
return useMemo(() => {
|
|
16
|
+
if (!hasEntityId(entityId) || !collection) return void 0;
|
|
17
|
+
const values = entity?.values ?? {};
|
|
18
|
+
return {
|
|
19
|
+
id: entityId,
|
|
20
|
+
disabled: true,
|
|
21
|
+
readOnly: true,
|
|
22
|
+
openEntityMode,
|
|
23
|
+
status: "existing",
|
|
24
|
+
values,
|
|
25
|
+
setFieldValue: () => {
|
|
26
|
+
throw new Error("Cannot update values in read-only detail view");
|
|
27
|
+
},
|
|
28
|
+
save: () => {
|
|
29
|
+
throw new Error("Cannot save in read-only detail view");
|
|
30
|
+
},
|
|
31
|
+
submit: () => {
|
|
32
|
+
throw new Error("Cannot submit in read-only detail view");
|
|
33
|
+
},
|
|
34
|
+
collection,
|
|
35
|
+
path,
|
|
36
|
+
row: entity ? rowOfEntity(entity, collection) : void 0,
|
|
37
|
+
savingError: void 0,
|
|
38
|
+
formex: createFormexStub(values)
|
|
39
|
+
};
|
|
40
|
+
}, [
|
|
41
|
+
entityId,
|
|
42
|
+
openEntityMode,
|
|
43
|
+
entity,
|
|
44
|
+
collection,
|
|
45
|
+
path
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A record's values as a page: the collection's `formView.Builder` when it
|
|
50
|
+
* has one, otherwise the generated read-only grid.
|
|
51
|
+
*
|
|
52
|
+
* `RecordDetail` and the CMS's own detail view both draw a record's body
|
|
53
|
+
* here, so a record reads the same in a page of your app as in the admin.
|
|
54
|
+
*/
|
|
55
|
+
function EntityViewBody({ entity, collection, path, formContext, fields, openEntityMode = "full_screen", parentCollectionSlugs = [], parentEntityIds = [], className }) {
|
|
56
|
+
const builderRef = fields ? void 0 : collection.formView?.Builder;
|
|
57
|
+
const FormViewBuilder = builderRef ? resolveComponentRef(builderRef) : void 0;
|
|
58
|
+
if (FormViewBuilder) return /* @__PURE__ */ jsx("div", {
|
|
59
|
+
className: cls("@container/form flex-1 min-w-0 overflow-y-auto flex justify-center items-start", className),
|
|
60
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
61
|
+
className: cls("w-full max-w-3xl @7xl/form:max-w-4xl 2xl:max-w-4xl flex flex-col", openEntityMode === "dialog" ? "pt-5 pb-12 px-6 sm:px-8" : "pt-6 pb-16 px-5 sm:px-8"),
|
|
62
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
|
|
63
|
+
fallback: /* @__PURE__ */ jsx(CircularProgressCenter, {}),
|
|
64
|
+
children: /* @__PURE__ */ jsx(FormViewBuilder, {
|
|
65
|
+
collection,
|
|
66
|
+
parentCollectionSlugs,
|
|
67
|
+
parentEntityIds,
|
|
68
|
+
row: rowOfEntity(entity, collection),
|
|
69
|
+
id: String(entity.id),
|
|
70
|
+
modifiedValues: entity.values,
|
|
71
|
+
formContext
|
|
72
|
+
})
|
|
73
|
+
}) })
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
return /* @__PURE__ */ jsx(EntityViewBinding, {
|
|
77
|
+
entity,
|
|
78
|
+
collection,
|
|
79
|
+
path,
|
|
80
|
+
asPage: true,
|
|
81
|
+
openEntityMode,
|
|
82
|
+
formContext,
|
|
83
|
+
fields,
|
|
84
|
+
className
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { EntityViewBody, useReadOnlyFormContext };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=EntityViewBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityViewBody.js","names":[],"sources":["../../src/components/EntityViewBody.tsx"],"sourcesContent":["import type { ComponentRef } from \"@rebasepro/types\";\nimport type { AdminCollection, EntityCustomViewParams } from \"@rebasepro/cms-types\";\nimport React, { Suspense, useMemo } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport { CircularProgressCenter, cls, ErrorBoundary } from \"@rebasepro/ui\";\nimport { createFormexStub, resolveComponentRef } from \"@rebasepro/app\";\n\nimport type { FormContext } from \"../types/fields\";\nimport { EntityViewBinding } from \"./EntityViewBinding\";\nimport { rowOfEntity } from \"@rebasepro/app\";\n\ntype OpenEntityMode = \"side_panel\" | \"full_screen\" | \"split\" | \"dialog\";\n\n/**\n * The context a read-only record hands what it renders but does not own — an\n * `additionalFields` entry, the collection's `formView.Builder`, a custom\n * entity view, a plugin slot. Every write on it throws: nothing on a page that\n * reads a record may change it. Undefined without an id to read by.\n */\nexport function useReadOnlyFormContext<M extends Record<string, unknown>>({\n entityId,\n entity,\n collection,\n path,\n openEntityMode\n}: {\n entityId?: string | number;\n entity?: Entity<M>;\n collection: AdminCollection<M> | undefined;\n path: string;\n openEntityMode: OpenEntityMode;\n}): FormContext<M> | undefined {\n return useMemo<FormContext<M> | undefined>(() => {\n if (!hasEntityId(entityId) || !collection) return undefined;\n const values = entity?.values ?? ({} as M);\n return {\n id: entityId,\n disabled: true,\n readOnly: true,\n openEntityMode,\n status: \"existing\",\n values,\n setFieldValue: () => {\n throw new Error(\"Cannot update values in read-only detail view\");\n },\n save: () => {\n throw new Error(\"Cannot save in read-only detail view\");\n },\n submit: () => {\n throw new Error(\"Cannot submit in read-only detail view\");\n },\n collection,\n path,\n row: entity ? rowOfEntity(entity, collection) : undefined,\n savingError: undefined,\n formex: createFormexStub<M>(values)\n };\n }, [entityId, openEntityMode, entity, collection, path]);\n}\n\nexport interface EntityViewBodyProps<M extends Record<string, unknown>> {\n entity: Entity<M>;\n collection: AdminCollection<M>;\n path: string;\n /** See {@link useReadOnlyFormContext}. */\n formContext?: FormContext<M>;\n /** See `EntityViewBinding`'s `fields`. Wins over the collection's `formView.Builder`, which cannot be told which fields to draw. */\n fields?: string[];\n openEntityMode?: OpenEntityMode;\n parentCollectionSlugs?: string[];\n parentEntityIds?: string[];\n className?: string;\n}\n\n/**\n * A record's values as a page: the collection's `formView.Builder` when it\n * has one, otherwise the generated read-only grid.\n *\n * `RecordDetail` and the CMS's own detail view both draw a record's body\n * here, so a record reads the same in a page of your app as in the admin.\n */\nexport function EntityViewBody<M extends Record<string, unknown>>({\n entity,\n collection,\n path,\n formContext,\n fields,\n openEntityMode = \"full_screen\",\n parentCollectionSlugs = [],\n parentEntityIds = [],\n className\n}: EntityViewBodyProps<M>) {\n\n const builderRef = fields ? undefined : collection.formView?.Builder;\n const FormViewBuilder = builderRef\n ? resolveComponentRef<EntityCustomViewParams>(builderRef as ComponentRef<EntityCustomViewParams>)\n : undefined;\n\n if (FormViewBuilder) {\n // The Builder replaces the generated display, in the centred column\n // the grid lays itself out in.\n return <div className={cls(\"@container/form flex-1 min-w-0 overflow-y-auto flex justify-center items-start\", className)}>\n <div className={cls(\n // Same widths as the default form (see EntityForm).\n \"w-full max-w-3xl @7xl/form:max-w-4xl 2xl:max-w-4xl flex flex-col\",\n openEntityMode === \"dialog\"\n ? \"pt-5 pb-12 px-6 sm:px-8\"\n : \"pt-6 pb-16 px-5 sm:px-8\"\n )}>\n <ErrorBoundary>\n <Suspense fallback={<CircularProgressCenter/>}>\n <FormViewBuilder\n collection={collection}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n row={rowOfEntity(entity, collection)}\n id={String(entity.id)}\n modifiedValues={entity.values}\n formContext={formContext as FormContext<Record<string, unknown>>}\n />\n </Suspense>\n </ErrorBoundary>\n </div>\n </div>;\n }\n\n return <EntityViewBinding\n entity={entity}\n collection={collection}\n path={path}\n asPage\n openEntityMode={openEntityMode}\n formContext={formContext}\n fields={fields}\n className={className}\n />;\n}\n"],"mappings":";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BAAD;EACK;EACI;EACN;EACN,QAAA;EACgB;EACH;EACL;EACG;CACd,CAAA;AACL"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PreviewSize } from "../types/components/PropertyPreviewProps.js";
|
|
3
|
+
/**
|
|
4
|
+
* Props for {@link FieldValue}.
|
|
5
|
+
*
|
|
6
|
+
* @group Preview components
|
|
7
|
+
*/
|
|
8
|
+
export type FieldValueProps = {
|
|
9
|
+
/** The collection's name (`"orders"`), or a subcollection's full path. */
|
|
10
|
+
collection: string;
|
|
11
|
+
/**
|
|
12
|
+
* The property to draw, by its key in the collection. A belongsTo's
|
|
13
|
+
* foreign key (`"customerId"`, or its column `"customer_id"`) names its
|
|
14
|
+
* relation too.
|
|
15
|
+
*/
|
|
16
|
+
field: string;
|
|
17
|
+
/**
|
|
18
|
+
* The value, as the server sends it: `order.status`, an ISO date string,
|
|
19
|
+
* a belongsTo's foreign key (`order.customerId`). A value in the admin's view model
|
|
20
|
+
* — a `Date`, an `EntityRelation` — is drawn the same.
|
|
21
|
+
*/
|
|
22
|
+
value: unknown;
|
|
23
|
+
/** Defaults to `"medium"`. */
|
|
24
|
+
size?: PreviewSize;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One value of a row, drawn exactly as the admin draws it: an enum as its
|
|
28
|
+
* chip, a date in the property's timezone, a relation as its target's title,
|
|
29
|
+
* an image as its thumbnail, and a property with its own `admin.Preview`
|
|
30
|
+
* through that.
|
|
31
|
+
*
|
|
32
|
+
* A belongsTo arrives as its foreign key: `field="customer"
|
|
33
|
+
* value={order.customerId}` draws the customer's title.
|
|
34
|
+
*
|
|
35
|
+
* Needs the collection registered above it — `<RebaseCMS>`, or a
|
|
36
|
+
* `<CollectionsProvider>` around your page. An unknown collection or field
|
|
37
|
+
* throws, naming it.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const { rows } = useRows("orders", { limit: 20 });
|
|
42
|
+
* return rows.map(order => <div key={String(order.id)}>
|
|
43
|
+
* <FieldValue collection="orders" field="status" value={order.status}/>
|
|
44
|
+
* <FieldValue collection="orders" field="customer" value={order.customerId}/>
|
|
45
|
+
* </div>);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @group Preview components
|
|
49
|
+
*/
|
|
50
|
+
export declare function FieldValue({ collection: path, field: fieldProp, value: rawValue, size }: FieldValueProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useCollectionRegistryController } from "../hooks/navigation/contexts/CollectionRegistryContext.js";
|
|
2
|
+
import { PropertyPreview } from "../preview/PropertyPreview.js";
|
|
3
|
+
import { useNavigationStateController } from "../hooks/navigation/contexts/NavigationStateContext.js";
|
|
4
|
+
import { CollectionsScopeContext, isRegistered } from "./CollectionsScopeContext.js";
|
|
5
|
+
import { useContext, useMemo } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { resolveCollectionRelations, rowToViewModel } from "@rebasepro/common";
|
|
8
|
+
import { toWireKey } from "@rebasepro/utils";
|
|
9
|
+
//#region src/components/FieldValue.tsx
|
|
10
|
+
/**
|
|
11
|
+
* One value of a row, drawn exactly as the admin draws it: an enum as its
|
|
12
|
+
* chip, a date in the property's timezone, a relation as its target's title,
|
|
13
|
+
* an image as its thumbnail, and a property with its own `admin.Preview`
|
|
14
|
+
* through that.
|
|
15
|
+
*
|
|
16
|
+
* A belongsTo arrives as its foreign key: `field="customer"
|
|
17
|
+
* value={order.customerId}` draws the customer's title.
|
|
18
|
+
*
|
|
19
|
+
* Needs the collection registered above it — `<RebaseCMS>`, or a
|
|
20
|
+
* `<CollectionsProvider>` around your page. An unknown collection or field
|
|
21
|
+
* throws, naming it.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const { rows } = useRows("orders", { limit: 20 });
|
|
26
|
+
* return rows.map(order => <div key={String(order.id)}>
|
|
27
|
+
* <FieldValue collection="orders" field="status" value={order.status}/>
|
|
28
|
+
* <FieldValue collection="orders" field="customer" value={order.customerId}/>
|
|
29
|
+
* </div>);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @group Preview components
|
|
33
|
+
*/
|
|
34
|
+
function FieldValue({ collection: path, field: fieldProp, value: rawValue, size = "medium" }) {
|
|
35
|
+
const inScope = useContext(CollectionsScopeContext);
|
|
36
|
+
const collectionRegistry = useCollectionRegistryController();
|
|
37
|
+
const settled = !useNavigationStateController().loading;
|
|
38
|
+
const registered = inScope && (collectionRegistry.initialised || settled) && isRegistered(collectionRegistry.collections, path);
|
|
39
|
+
const collection = useMemo(() => registered ? collectionRegistry.getCollection(path) : void 0, [
|
|
40
|
+
registered,
|
|
41
|
+
collectionRegistry,
|
|
42
|
+
path
|
|
43
|
+
]);
|
|
44
|
+
const field = collection && !collection.properties?.[fieldProp] ? relationOfColumn(collection, fieldProp) ?? fieldProp : fieldProp;
|
|
45
|
+
const property = collection?.properties?.[field];
|
|
46
|
+
const value = useMemo(() => collection && property ? rowToViewModel({ [fieldProp]: rawValue }, path, (slug) => slug === path ? collection : collectionRegistry.getCollection(slug))[field] : void 0, [
|
|
47
|
+
rawValue,
|
|
48
|
+
fieldProp,
|
|
49
|
+
field,
|
|
50
|
+
path,
|
|
51
|
+
property,
|
|
52
|
+
collection,
|
|
53
|
+
collectionRegistry
|
|
54
|
+
]);
|
|
55
|
+
if (!inScope) throw new Error(`<FieldValue collection="${path}">: no collections are registered above it. Render it inside <RebaseCMS>, or wrap your page in a <CollectionsProvider collections={[…]}>.`);
|
|
56
|
+
if (!collection) {
|
|
57
|
+
if (!settled) return null;
|
|
58
|
+
throw new Error(`<FieldValue collection="${path}">: no collection is registered at "${path}".`);
|
|
59
|
+
}
|
|
60
|
+
if (!property) {
|
|
61
|
+
const known = Object.keys(collection.properties ?? {}).join(", ");
|
|
62
|
+
throw new Error(`<FieldValue collection="${path}" field="${fieldProp}">: the collection has no property or foreign key "${fieldProp}". Its properties: ${known}.`);
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ jsx(PropertyPreview, {
|
|
65
|
+
propertyKey: field,
|
|
66
|
+
property,
|
|
67
|
+
value,
|
|
68
|
+
size
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** The relation property whose foreign key is `column`, by the column's name or its wire key. */
|
|
72
|
+
function relationOfColumn(collection, column) {
|
|
73
|
+
for (const [key, relation] of Object.entries(resolveCollectionRelations(collection))) {
|
|
74
|
+
const localKey = "localKey" in relation ? relation.localKey : void 0;
|
|
75
|
+
if (localKey && (localKey === column || toWireKey(localKey) === column) && collection.properties?.[key]) return key;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { FieldValue };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=FieldValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldValue.js","names":[],"sources":["../../src/components/FieldValue.tsx"],"sourcesContent":["import React, { useContext, useMemo } from \"react\";\nimport type { Property } from \"@rebasepro/types\";\nimport { resolveCollectionRelations, rowToViewModel } from \"@rebasepro/common\";\nimport { toWireKey } from \"@rebasepro/utils\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nimport type { PreviewSize } from \"../types/components/PropertyPreviewProps\";\nimport { PropertyPreview } from \"../preview/PropertyPreview\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigationStateController } from \"../hooks/navigation/contexts/NavigationStateContext\";\nimport { CollectionsScopeContext, isRegistered } from \"./CollectionsScopeContext\";\n\n/**\n * Props for {@link FieldValue}.\n *\n * @group Preview components\n */\nexport type FieldValueProps = {\n /** The collection's name (`\"orders\"`), or a subcollection's full path. */\n collection: string;\n /**\n * The property to draw, by its key in the collection. A belongsTo's\n * foreign key (`\"customerId\"`, or its column `\"customer_id\"`) names its\n * relation too.\n */\n field: string;\n /**\n * The value, as the server sends it: `order.status`, an ISO date string,\n * a belongsTo's foreign key (`order.customerId`). A value in the admin's view model\n * — a `Date`, an `EntityRelation` — is drawn the same.\n */\n value: unknown;\n /** Defaults to `\"medium\"`. */\n size?: PreviewSize;\n};\n\n/**\n * One value of a row, drawn exactly as the admin draws it: an enum as its\n * chip, a date in the property's timezone, a relation as its target's title,\n * an image as its thumbnail, and a property with its own `admin.Preview`\n * through that.\n *\n * A belongsTo arrives as its foreign key: `field=\"customer\"\n * value={order.customerId}` draws the customer's title.\n *\n * Needs the collection registered above it — `<RebaseCMS>`, or a\n * `<CollectionsProvider>` around your page. An unknown collection or field\n * throws, naming it.\n *\n * @example\n * ```tsx\n * const { rows } = useRows(\"orders\", { limit: 20 });\n * return rows.map(order => <div key={String(order.id)}>\n * <FieldValue collection=\"orders\" field=\"status\" value={order.status}/>\n * <FieldValue collection=\"orders\" field=\"customer\" value={order.customerId}/>\n * </div>);\n * ```\n *\n * @group Preview components\n */\nexport function FieldValue({ collection: path, field: fieldProp, value: rawValue, size = \"medium\" }: FieldValueProps) {\n const inScope = useContext(CollectionsScopeContext);\n const collectionRegistry = useCollectionRegistryController();\n const navigationState = useNavigationStateController();\n\n const settled = !navigationState.loading;\n const registered = inScope && (collectionRegistry.initialised || settled)\n && isRegistered(collectionRegistry.collections, path);\n // One lookup per registry: each builds a new object.\n const collection = useMemo(\n () => registered ? collectionRegistry.getCollection(path) : undefined,\n [registered, collectionRegistry, path]);\n\n // A foreign-key column names the relation that reads it.\n const field = collection && !collection.properties?.[fieldProp]\n ? relationOfColumn(collection, fieldProp) ?? fieldProp\n : fieldProp;\n const property = collection?.properties?.[field] as Property | undefined;\n // The value in the admin's view model, what `PropertyPreview` reads: a\n // foreign key as the relation, a date as a `Date`, a reference as an\n // `EntityReference`. Read as a one-column row, under the name it was\n // handed by, which is where the conversion looks for it.\n const value = useMemo(\n () => collection && property\n ? rowToViewModel({ [fieldProp]: rawValue }, path, slug => slug === path ? collection : collectionRegistry.getCollection(slug))[field]\n : undefined,\n [rawValue, fieldProp, field, path, property, collection, collectionRegistry]);\n\n if (!inScope) {\n throw new Error(`<FieldValue collection=\"${path}\">: no collections are registered above it. Render it inside <RebaseCMS>, or wrap your page in a <CollectionsProvider collections={[…]}>.`);\n }\n if (!collection) {\n if (!settled) return null;\n throw new Error(`<FieldValue collection=\"${path}\">: no collection is registered at \"${path}\".`);\n }\n if (!property) {\n const known = Object.keys(collection.properties ?? {}).join(\", \");\n throw new Error(`<FieldValue collection=\"${path}\" field=\"${fieldProp}\">: the collection has no property or foreign key \"${fieldProp}\". Its properties: ${known}.`);\n }\n\n return <PropertyPreview propertyKey={field}\n property={property}\n value={value}\n size={size}/>;\n}\n\n/** The relation property whose foreign key is `column`, by the column's name or its wire key. */\nfunction relationOfColumn(collection: AdminCollection, column: string): string | undefined {\n for (const [key, relation] of Object.entries(resolveCollectionRelations(collection))) {\n const localKey = \"localKey\" in relation ? relation.localKey : undefined;\n if (localKey && (localKey === column || toWireKey(localKey) === column) && collection.properties?.[key]) return key;\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,WAAW,EAAE,YAAY,MAAM,OAAO,WAAW,OAAO,UAAU,OAAO,YAA6B;CAClH,MAAM,UAAU,WAAW,uBAAuB;CAClD,MAAM,qBAAqB,gCAAgC;CAG3D,MAAM,UAAU,CAFQ,6BAEP,CAAA,CAAgB;CACjC,MAAM,aAAa,YAAY,mBAAmB,eAAe,YAC1D,aAAa,mBAAmB,aAAa,IAAI;CAExD,MAAM,aAAa,cACT,aAAa,mBAAmB,cAAc,IAAI,IAAI,KAAA,GAC5D;EAAC;EAAY;EAAoB;CAAI,CAAC;CAG1C,MAAM,QAAQ,cAAc,CAAC,WAAW,aAAa,aAC/C,iBAAiB,YAAY,SAAS,KAAK,YAC3C;CACN,MAAM,WAAW,YAAY,aAAa;CAK1C,MAAM,QAAQ,cACJ,cAAc,WACd,eAAe,GAAG,YAAY,SAAS,GAAG,OAAM,SAAQ,SAAS,OAAO,aAAa,mBAAmB,cAAc,IAAI,CAAC,CAAC,CAAC,SAC7H,KAAA,GACN;EAAC;EAAU;EAAW;EAAO;EAAM;EAAU;EAAY;CAAkB,CAAC;CAEhF,IAAI,CAAC,SACD,MAAM,IAAI,MAAM,2BAA2B,KAAK,0IAA0I;CAE9L,IAAI,CAAC,YAAY;EACb,IAAI,CAAC,SAAS,OAAO;EACrB,MAAM,IAAI,MAAM,2BAA2B,KAAK,sCAAsC,KAAK,GAAG;CAClG;CACA,IAAI,CAAC,UAAU;EACX,MAAM,QAAQ,OAAO,KAAK,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;EAChE,MAAM,IAAI,MAAM,2BAA2B,KAAK,WAAW,UAAU,qDAAqD,UAAU,qBAAqB,MAAM,EAAE;CACrK;CAEA,OAAO,oBAAC,iBAAD;EAAiB,aAAa;EACvB;EACH;EACD;CAAM,CAAA;AACpB;;AAGA,SAAS,iBAAiB,YAA6B,QAAoC;CACvF,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,2BAA2B,UAAU,CAAC,GAAG;EAClF,MAAM,WAAW,cAAc,WAAW,SAAS,WAAW,KAAA;EAC9D,IAAI,aAAa,aAAa,UAAU,UAAU,QAAQ,MAAM,WAAW,WAAW,aAAa,MAAM,OAAO;CACpH;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineEntityPreview.js","names":[],"sources":["../../src/components/InlineEntityPreview.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { Entity } from \"@rebasepro/types\";\nimport { cls, LinkIcon, Skeleton, Tooltip } from \"@rebasepro/ui\";\nimport { useAnalyticsController } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nimport { useEntityTitle } from \"../hooks/useEntityDisplay\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\n\nexport type InlineEntityPreviewProps = {\n entity: Entity<any>;\n collection?: AdminCollection;\n /** Overrides the resolved title. */\n label?: string;\n disabled?: boolean;\n /** When set, takes over the click. Otherwise the row opens the side panel. */\n onClick?: (e: React.SyntheticEvent) => void;\n /** Set to false to render text only, with no click target. */\n includeEntityLink?: boolean;\n /** Icon size in px. Defaults to a hair under the surrounding text. */\n iconSize?: number;\n className?: string;\n};\n\nconst inlineMixin = \"inline-flex items-center gap-1 min-w-0 max-w-full align-middle\";\n\n/**\n * An entity rendered as one line of text: a small link glyph that marks it as\n * pointing elsewhere, then the target's title in whatever typography surrounds\n * it.\n *\n * This is what a reference or relation renders as when it is *not* the subject\n * of its slot — nested inside another entity preview, or filling a title slot.\n * The card treatment (image, id, preview properties, side-panel button) only\n * makes sense at the top level; repeating it one level down produces a bordered\n * box inside a bordered box, each with its own action buttons.\n *\n * @group Preview components\n */\nexport function InlineEntityPreview({\n entity,\n collection: collectionProp,\n label,\n disabled,\n onClick,\n includeEntityLink = true,\n iconSize = 12,\n className\n}: InlineEntityPreviewProps) {\n\n const collectionRegistryController = useCollectionRegistryController();\n const analyticsController = useAnalyticsController();\n const sidePanelController = useSidePanel();\n\n const collection = collectionProp ?? collectionRegistryController.getCollection(entity.path);\n\n // The id is the right fallback *here* specifically: this renders a pointer at\n // another record, and a pointer with no label is still followable if it says\n // which record it points at. A page heading makes the opposite choice.\n const { value: title } = useEntityTitle({\n collection: collection as AdminCollection,\n entity,\n enabled: Boolean(collection)\n });\n const resolvedLabel = label ?? title ?? String(entity.id);\n\n const interactive = !disabled && (onClick !== undefined || (includeEntityLink && collection !== undefined));\n\n const handleClick = (event: React.SyntheticEvent) => {\n if (!interactive) return;\n // This sits inside a container with its own click handler (the parent\n // card opens the parent entity); a click here is about the target.\n event.preventDefault();\n event.stopPropagation();\n if (onClick) {\n onClick(event);\n return;\n }\n analyticsController.onAnalyticsEvent?.(\"entity_click_from_reference\", {\n path: entity.path,\n entityId: entity.id\n });\n sidePanelController.open({\n
|
|
1
|
+
{"version":3,"file":"InlineEntityPreview.js","names":[],"sources":["../../src/components/InlineEntityPreview.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { Entity } from \"@rebasepro/types\";\nimport { cls, LinkIcon, Skeleton, Tooltip } from \"@rebasepro/ui\";\nimport { useAnalyticsController } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nimport { useEntityTitle } from \"../hooks/useEntityDisplay\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\n\nexport type InlineEntityPreviewProps = {\n entity: Entity<any>;\n collection?: AdminCollection;\n /** Overrides the resolved title. */\n label?: string;\n disabled?: boolean;\n /** When set, takes over the click. Otherwise the row opens the side panel. */\n onClick?: (e: React.SyntheticEvent) => void;\n /** Set to false to render text only, with no click target. */\n includeEntityLink?: boolean;\n /** Icon size in px. Defaults to a hair under the surrounding text. */\n iconSize?: number;\n className?: string;\n};\n\nconst inlineMixin = \"inline-flex items-center gap-1 min-w-0 max-w-full align-middle\";\n\n/**\n * An entity rendered as one line of text: a small link glyph that marks it as\n * pointing elsewhere, then the target's title in whatever typography surrounds\n * it.\n *\n * This is what a reference or relation renders as when it is *not* the subject\n * of its slot — nested inside another entity preview, or filling a title slot.\n * The card treatment (image, id, preview properties, side-panel button) only\n * makes sense at the top level; repeating it one level down produces a bordered\n * box inside a bordered box, each with its own action buttons.\n *\n * @group Preview components\n */\nexport function InlineEntityPreview({\n entity,\n collection: collectionProp,\n label,\n disabled,\n onClick,\n includeEntityLink = true,\n iconSize = 12,\n className\n}: InlineEntityPreviewProps) {\n\n const collectionRegistryController = useCollectionRegistryController();\n const analyticsController = useAnalyticsController();\n const sidePanelController = useSidePanel();\n\n const collection = collectionProp ?? collectionRegistryController.getCollection(entity.path);\n\n // The id is the right fallback *here* specifically: this renders a pointer at\n // another record, and a pointer with no label is still followable if it says\n // which record it points at. A page heading makes the opposite choice.\n const { value: title } = useEntityTitle({\n collection: collection as AdminCollection,\n entity,\n enabled: Boolean(collection)\n });\n const resolvedLabel = label ?? title ?? String(entity.id);\n\n const interactive = !disabled && (onClick !== undefined || (includeEntityLink && collection !== undefined));\n\n const handleClick = (event: React.SyntheticEvent) => {\n if (!interactive) return;\n // This sits inside a container with its own click handler (the parent\n // card opens the parent entity); a click here is about the target.\n event.preventDefault();\n event.stopPropagation();\n if (onClick) {\n onClick(event);\n return;\n }\n analyticsController.onAnalyticsEvent?.(\"entity_click_from_reference\", {\n path: entity.path,\n entityId: entity.id\n });\n sidePanelController.open({\n id: entity.id,\n path: entity.path,\n collection,\n updateUrl: true\n });\n };\n\n const content = <span\n tabIndex={interactive ? 0 : undefined}\n role={interactive ? \"button\" : undefined}\n // A press on the link does not move the focus. Inside a table cell the\n // focus is what selects the cell, and selecting it re-renders the cell\n // between this press and its click: the click then landed on the new\n // cell and the record never opened. Keyboard focus is unaffected.\n onMouseDown={interactive ? (event) => event.preventDefault() : undefined}\n onClick={interactive ? handleClick : undefined}\n onKeyDown={interactive\n ? (event) => {\n if (event.key === \"Enter\" || event.key === \" \") handleClick(event);\n }\n : undefined}\n className={cls(\n inlineMixin,\n interactive ? \"cursor-pointer hover:underline underline-offset-2\" : \"\",\n className)}>\n <LinkIcon size={iconSize}\n className={\"shrink-0 opacity-40\"}/>\n <span className={\"truncate\"}>{resolvedLabel}</span>\n </span>;\n\n if (!interactive) return content;\n\n return <Tooltip title={`See details for ${resolvedLabel}`}\n asChild={true}>\n {content}\n </Tooltip>;\n}\n\n/**\n * Placeholder shown while the target of an inline reference is being fetched.\n */\nexport function InlineEntityPreviewSkeleton({ className }: { className?: string }) {\n return <span className={cls(inlineMixin, className)}>\n <LinkIcon size={12}\n className={\"shrink-0 opacity-40\"}/>\n <Skeleton className={\"w-20 h-3\"}/>\n </span>;\n}\n\n/**\n * Shown when the target of an inline reference cannot be resolved — a deleted\n * row, or a collection that is not registered. Keeps the line readable instead\n * of dropping an error box into the middle of a card.\n */\nexport function InlineEntityPreviewMissing({\n label,\n tooltip,\n className\n}: { label: string, tooltip?: string, className?: string }) {\n const content = <span\n className={cls(inlineMixin, \"text-text-secondary dark:text-text-secondary-dark\", className)}>\n <LinkIcon size={12}\n className={\"shrink-0 opacity-40\"}/>\n <span className={\"truncate italic\"}>{label}</span>\n </span>;\n if (!tooltip) return content;\n return <Tooltip title={tooltip}\n asChild={true}>{content}</Tooltip>;\n}\n"],"mappings":";;;;;;;;AA0BA,IAAM,cAAc;;;;;;;;;;;;;;AAepB,SAAgB,oBAAoB,EAChC,QACA,YAAY,gBACZ,OACA,UACA,SACA,oBAAoB,MACpB,WAAW,IACX,aACyB;CAEzB,MAAM,+BAA+B,gCAAgC;CACrE,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,sBAAsB,aAAa;CAEzC,MAAM,aAAa,kBAAkB,6BAA6B,cAAc,OAAO,IAAI;CAK3F,MAAM,EAAE,OAAO,UAAU,eAAe;EACxB;EACZ;EACA,SAAS,QAAQ,UAAU;CAC/B,CAAC;CACD,MAAM,gBAAgB,SAAS,SAAS,OAAO,OAAO,EAAE;CAExD,MAAM,cAAc,CAAC,aAAa,YAAY,KAAA,KAAc,qBAAqB,eAAe,KAAA;CAEhG,MAAM,eAAe,UAAgC;EACjD,IAAI,CAAC,aAAa;EAGlB,MAAM,eAAe;EACrB,MAAM,gBAAgB;EACtB,IAAI,SAAS;GACT,QAAQ,KAAK;GACb;EACJ;EACA,oBAAoB,mBAAmB,+BAA+B;GAClE,MAAM,OAAO;GACb,UAAU,OAAO;EACrB,CAAC;EACD,oBAAoB,KAAK;GACrB,IAAI,OAAO;GACX,MAAM,OAAO;GACb;GACA,WAAW;EACf,CAAC;CACL;CAEA,MAAM,UAAU,qBAAC,QAAD;EACZ,UAAU,cAAc,IAAI,KAAA;EAC5B,MAAM,cAAc,WAAW,KAAA;EAK/B,aAAa,eAAe,UAAU,MAAM,eAAe,IAAI,KAAA;EAC/D,SAAS,cAAc,cAAc,KAAA;EACrC,WAAW,eACJ,UAAU;GACT,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK,YAAY,KAAK;EACrE,IACE,KAAA;EACN,WAAW,IACP,aACA,cAAc,sDAAsD,IACpE,SAAS;YAjBD,CAkBZ,oBAAC,UAAD;GAAU,MAAM;GACZ,WAAW;EAAuB,CAAA,GACtC,oBAAC,QAAD;GAAM,WAAW;aAAa;EAAoB,CAAA,CAChD;;CAEN,IAAI,CAAC,aAAa,OAAO;CAEzB,OAAO,oBAAC,SAAD;EAAS,OAAO,mBAAmB;EACtC,SAAS;YACR;CACI,CAAA;AACb;;;;AAKA,SAAgB,4BAA4B,EAAE,aAAqC;CAC/E,OAAO,qBAAC,QAAD;EAAM,WAAW,IAAI,aAAa,SAAS;YAA3C,CACH,oBAAC,UAAD;GAAU,MAAM;GACZ,WAAW;EAAuB,CAAA,GACtC,oBAAC,UAAD,EAAU,WAAW,WAAY,CAAA,CAC/B;;AACV;;;;;;AAOA,SAAgB,2BAA2B,EACvC,OACA,SACA,aACwD;CACxD,MAAM,UAAU,qBAAC,QAAD;EACZ,WAAW,IAAI,aAAa,qDAAqD,SAAS;YAD9E,CAEZ,oBAAC,UAAD;GAAU,MAAM;GACZ,WAAW;EAAuB,CAAA,GACtC,oBAAC,QAAD;GAAM,WAAW;aAAoB;EAAY,CAAA,CAC/C;;CACN,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,oBAAC,SAAD;EAAS,OAAO;EACnB,SAAS;YAAO;CAAiB,CAAA;AACzC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { CenteredView, Typography } from "@rebasepro/ui";
|
|
4
|
+
import { useTranslation } from "@rebasepro/app";
|
|
5
|
+
//#region src/components/PanelNotFound.tsx
|
|
6
|
+
/** What a record panel draws for a collection or record that is not there. */
|
|
7
|
+
function PanelNotFound({ className }) {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
return /* @__PURE__ */ jsx(CenteredView, {
|
|
10
|
+
className,
|
|
11
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
12
|
+
variant: "body2",
|
|
13
|
+
color: "secondary",
|
|
14
|
+
children: t("entity_not_found")
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { PanelNotFound };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=PanelNotFound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PanelNotFound.js","names":[],"sources":["../../src/components/PanelNotFound.tsx"],"sourcesContent":["import React from \"react\";\nimport { CenteredView, Typography } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\n\n/** What a record panel draws for a collection or record that is not there. */\nexport function PanelNotFound({ className }: { className?: string }) {\n const { t } = useTranslation();\n return (\n <CenteredView className={className}>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"entity_not_found\")}\n </Typography>\n </CenteredView>\n );\n}\n"],"mappings":";;;;;;AAKA,SAAgB,cAAc,EAAE,aAAqC;CACjE,MAAM,EAAE,MAAM,eAAe;CAC7B,OACI,oBAAC,cAAD;EAAyB;YACrB,oBAAC,YAAD;GAAY,SAAQ;GAAQ,OAAM;aAC7B,EAAE,kBAAkB;EACb,CAAA;CACF,CAAA;AAEtB"}
|
|
@@ -7,4 +7,4 @@ import type { RebaseCMSConfig } from "@rebasepro/cms-types";
|
|
|
7
7
|
* is auto-wired as a native feature (slots, provider, Studio view) without
|
|
8
8
|
* needing any external plugin.
|
|
9
9
|
*/
|
|
10
|
-
export declare function RebaseCMS({ collections, views, homePage, entityViews, collectionViews, entityActions, collectionEditor, navigationGroupMappings, basePath }: RebaseCMSConfig): null;
|
|
10
|
+
export declare function RebaseCMS({ collections: collectionsProp, views, homePage, entityViews, collectionViews, entityActions, collectionEditor: collectionEditorProp, navigationGroupMappings, basePath }: RebaseCMSConfig): null;
|