@rebasepro/cms 0.28.1 → 0.29.0-canary.g0e3a0e7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/collection_editor/_cms_internals.d.ts +0 -1
- package/dist/collection_editor/ui/EditorCollectionAction.d.ts +2 -2
- package/dist/collection_editor/ui/EditorCollectionAction.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js +2 -2
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MarkdownPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/StoragePropertyField.js.map +1 -1
- package/dist/components/AdditionalFieldValue.d.ts +9 -3
- package/dist/components/AdditionalFieldValue.js +7 -4
- package/dist/components/AdditionalFieldValue.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +117 -18
- package/dist/components/CollectionPanel.js +115 -37
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +5 -5
- package/dist/components/CollectionTableBinding/CollectionRowActions.js +16 -12
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js +33 -8
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +8 -3
- package/dist/components/CollectionTableBinding/PropertyTableCell.js +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +9 -1
- package/dist/components/CollectionTableBinding/column_utils.js +6 -3
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.d.ts +3 -2
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js +9 -7
- package/dist/components/CollectionTableBinding/internal/CollectionTableToolbar.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +26 -2
- package/dist/components/CollectionTableBinding/internal/common.js +88 -4
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +4 -3
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js +19 -14
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionAddButton.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js +50 -0
- package/dist/components/CollectionViewBinding/CollectionAddButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +11 -3
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -4
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js +5 -3
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +29 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js +112 -0
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +58 -16
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.d.ts +57 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +146 -0
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +22 -26
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +58 -22
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js +81 -1089
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +152 -0
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.d.ts +9 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js +38 -0
- package/dist/components/CollectionViewBinding/CollectionViewDialogs.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.d.ts +13 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js +32 -0
- package/dist/components/CollectionViewBinding/CollectionViewFrame.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.d.ts +14 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js +22 -0
- package/dist/components/CollectionViewBinding/CollectionViewScope.js.map +1 -0
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +2 -2
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js +39 -67
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +28 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js +54 -0
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.d.ts +24 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js +69 -0
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -0
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +7 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.js +34 -23
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.d.ts +17 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +107 -0
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -0
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +15 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js +49 -0
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +35 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js +45 -0
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -0
- package/dist/components/CollectionViewBinding/RowActions.d.ts +40 -0
- package/dist/components/CollectionViewBinding/RowActions.js +60 -0
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -0
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +7 -4
- package/dist/components/CollectionViewBinding/SplitListView.js +20 -21
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/builtin_action_props.d.ts +13 -0
- package/dist/components/CollectionViewBinding/fields.d.ts +22 -0
- package/dist/components/CollectionViewBinding/fields.js +47 -0
- package/dist/components/CollectionViewBinding/fields.js.map +1 -0
- package/dist/components/CollectionViewBinding/useBoardDataController.js +6 -7
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.d.ts +19 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js +28 -0
- package/dist/components/CollectionViewBinding/useCollectionLargeLayout.js.map +1 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +125 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +844 -0
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +20 -0
- package/dist/components/CollectionViewBinding/usePreviewSlots.js +23 -2
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +21 -3
- package/dist/components/CollectionViewBinding/useSelectionController.js +37 -6
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +3 -3
- package/dist/components/CollectionsProvider.js +4 -4
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/CollectionsScopeContext.d.ts +1 -1
- package/dist/components/CollectionsScopeContext.js +1 -1
- package/dist/components/CollectionsScopeContext.js.map +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +2 -2
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +32 -68
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js +5 -4
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -2
- package/dist/components/EditViewBinding.js +25 -15
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.js +8 -5
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +8 -1
- package/dist/components/EntityViewBinding.js +43 -14
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +40 -0
- package/dist/components/EntityViewBody.js +90 -0
- package/dist/components/EntityViewBody.js.map +1 -0
- package/dist/components/FieldValue.d.ts +50 -0
- package/dist/components/FieldValue.js +81 -0
- package/dist/components/FieldValue.js.map +1 -0
- package/dist/components/InlineEntityPreview.js +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PanelNotFound.d.ts +5 -0
- package/dist/components/PanelNotFound.js +21 -0
- package/dist/components/PanelNotFound.js.map +1 -0
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/components/RebaseCMS.js +11 -3
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +9 -3
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RebaseShell.js +10 -5
- package/dist/components/RebaseShell.js.map +1 -1
- package/dist/components/RecordDetail.d.ts +61 -0
- package/dist/components/RecordDetail.js +123 -0
- package/dist/components/RecordDetail.js.map +1 -0
- package/dist/components/RecordForm.d.ts +126 -0
- package/dist/components/{EntityFormPanel.js → RecordForm.js} +64 -36
- package/dist/components/RecordForm.js.map +1 -0
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +47 -17
- package/dist/components/ReferenceTable/SelectionTableBinding.js +89 -53
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +5 -3
- package/dist/components/ReferenceWidget.js +10 -7
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.js +4 -4
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.js +2 -3
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/SelectionStore.d.ts +1 -1
- package/dist/components/SelectableTable/SelectionStore.js +1 -1
- package/dist/components/SelectableTable/SelectionStore.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SidePanelBinding.js +13 -12
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/collection_prop.d.ts +18 -0
- package/dist/components/collection_prop.js +23 -0
- package/dist/components/collection_prop.js.map +1 -0
- package/dist/components/common/default_entity_actions.js +54 -54
- package/dist/components/common/default_entity_actions.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +4 -1
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/components/history/LastEditedByFormAction.d.ts +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/data_export/export/ExportCollectionAction.d.ts +3 -2
- package/dist/data_export/export/ExportCollectionAction.js +4 -3
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +6 -3
- package/dist/data_export/export/additional_fields.js +8 -4
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.js +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityForm.js +252 -150
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js +3 -2
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.d.ts +1 -1
- package/dist/form/EntityFormBinding.js +22 -11
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormField.d.ts +36 -0
- package/dist/form/FormField.js +41 -0
- package/dist/form/FormField.js.map +1 -0
- package/dist/form/FormFieldsContext.d.ts +69 -0
- package/dist/form/FormFieldsContext.js +143 -0
- package/dist/form/FormFieldsContext.js.map +1 -0
- package/dist/form/PropertyFieldBinding.js +4 -4
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/collection_showing.d.ts +8 -0
- package/dist/form/collection_showing.js +29 -0
- package/dist/form/collection_showing.js.map +1 -0
- package/dist/form/components/ErrorFocus.js +2 -1
- package/dist/form/components/ErrorFocus.js.map +1 -1
- package/dist/form/components/FieldBlock.js +3 -1
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +5 -1
- package/dist/form/components/FormRail.js +5 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/FormSections.d.ts +5 -1
- package/dist/form/components/FormSections.js +11 -4
- package/dist/form/components/FormSections.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/form_dom_ids.d.ts +25 -0
- package/dist/form/form_dom_ids.js +42 -0
- package/dist/form/form_dom_ids.js.map +1 -0
- package/dist/form/index.d.ts +3 -1
- package/dist/form/resolve_cell_property.d.ts +5 -0
- package/dist/form/resolve_cell_property.js +22 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +2 -2
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.d.ts +3 -3
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/useResolvedCollections.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +2 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.js +9 -9
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useEntityDisplay.js +6 -4
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useRecordActions.js +2 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useSelectionDialog.d.ts +20 -7
- package/dist/hooks/useSelectionDialog.js +29 -8
- package/dist/hooks/useSelectionDialog.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +15 -9
- package/dist/mcp-view.d.ts +9 -0
- package/dist/mcp-view.js +2 -0
- package/dist/mcp_view/app_modules.d.ts +29 -0
- package/dist/mcp_view/app_modules.js +163 -0
- package/dist/mcp_view/app_modules.js.map +1 -0
- package/dist/mcp_view/bridge.d.ts +90 -0
- package/dist/mcp_view/bridge.js +205 -0
- package/dist/mcp_view/bridge.js.map +1 -0
- package/dist/mcp_view/code_app.d.ts +65 -0
- package/dist/mcp_view/code_app.js +139 -0
- package/dist/mcp_view/code_app.js.map +1 -0
- package/dist/mcp_view/index.d.ts +48 -0
- package/dist/mcp_view/index.js +235 -0
- package/dist/mcp_view/index.js.map +1 -0
- package/dist/mcp_view/payload.d.ts +78 -0
- package/dist/mcp_view/payload.js +155 -0
- package/dist/mcp_view/payload.js.map +1 -0
- package/dist/mcp_view/screen.d.ts +28 -0
- package/dist/mcp_view/screen.js +223 -0
- package/dist/mcp_view/screen.js.map +1 -0
- package/dist/mcp_view/storage_source.d.ts +14 -0
- package/dist/mcp_view/storage_source.js +29 -0
- package/dist/mcp_view/storage_source.js.map +1 -0
- package/dist/mcp_view/store.d.ts +9 -0
- package/dist/mcp_view/store.js +27 -0
- package/dist/mcp_view/store.js.map +1 -0
- package/dist/mcp_view/tool_driver.d.ts +135 -0
- package/dist/mcp_view/tool_driver.js +527 -0
- package/dist/mcp_view/tool_driver.js.map +1 -0
- package/dist/preview/components/DatePreview.d.ts +34 -1
- package/dist/preview/components/DatePreview.js +72 -37
- package/dist/preview/components/DatePreview.js.map +1 -1
- package/dist/routes/RebaseRoute.js +1 -1
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +5 -3
- package/dist/selection/SelectionMenu.js +16 -9
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/index.d.ts +2 -1
- package/dist/selection/resolve_selection.d.ts +61 -7
- package/dist/selection/resolve_selection.js +93 -11
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/types/components/EntityFormProps.d.ts +60 -10
- package/dist/types/fields.d.ts +2 -65
- package/dist/util/dataControllerAdapter.d.ts +8 -0
- package/dist/util/dataControllerAdapter.js +11 -0
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +5 -4
- package/dist/util/navigation_utils.js +6 -6
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +8 -0
- package/dist/util/propertyConfigMapper.js +16 -2
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/package.json +15 -9
- package/recipes/README.md +79 -26
- package/recipes/approval-queue.tsx +79 -0
- package/recipes/bulk-set-status.tsx +23 -17
- package/recipes/calendar-view.tsx +28 -23
- package/recipes/master-detail.tsx +75 -0
- package/recipes/my-preferences.tsx +3 -3
- package/recipes/orders-dashboard.tsx +58 -84
- package/recipes/site-settings.tsx +4 -4
- package/dist/components/EntityFormPanel.d.ts +0 -63
- package/dist/components/EntityFormPanel.js.map +0 -1
|
@@ -9,9 +9,17 @@ import type { Property, Properties } from "@rebasepro/types";
|
|
|
9
9
|
import type { CollectionPropertyConfig } from "@rebasepro/ui";
|
|
10
10
|
/**
|
|
11
11
|
* Convert a single Property to a CollectionPropertyConfig.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
14
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
15
|
+
* removed in a future release.
|
|
12
16
|
*/
|
|
13
17
|
export declare function mapPropertyToConfig(property: Property, key?: string): CollectionPropertyConfig;
|
|
14
18
|
/**
|
|
15
19
|
* Convert a Properties record to a CollectionPropertyConfig record.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
22
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
23
|
+
* removed in a future release.
|
|
16
24
|
*/
|
|
17
25
|
export declare function mapPropertiesToConfigs(properties: Properties): Record<string, CollectionPropertyConfig>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { warnDeprecated } from "@rebasepro/common";
|
|
1
2
|
import { prettifyIdentifier } from "@rebasepro/utils";
|
|
2
3
|
//#region src/util/propertyConfigMapper.ts
|
|
3
4
|
/**
|
|
@@ -19,8 +20,16 @@ var TYPE_MAP = {
|
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Convert a single Property to a CollectionPropertyConfig.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
25
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
26
|
+
* removed in a future release.
|
|
22
27
|
*/
|
|
23
28
|
function mapPropertyToConfig(property, key) {
|
|
29
|
+
warnDeprecated("cms.mapPropertyToConfig", "`mapPropertyToConfig` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.");
|
|
30
|
+
return propertyToConfig(property, key);
|
|
31
|
+
}
|
|
32
|
+
function propertyToConfig(property, key) {
|
|
24
33
|
const base = {
|
|
25
34
|
type: TYPE_MAP[property.type] ?? "string",
|
|
26
35
|
name: property.name ?? (key ? prettifyIdentifier(key) : ""),
|
|
@@ -38,7 +47,7 @@ function mapPropertyToConfig(property, key) {
|
|
|
38
47
|
if (property.email) base.email = true;
|
|
39
48
|
}
|
|
40
49
|
if (property.type === "number" && property.enum) base.enum = mapEnumValues(property.enum);
|
|
41
|
-
if (property.type === "array" && property.of && !Array.isArray(property.of)) base.of =
|
|
50
|
+
if (property.type === "array" && property.of && !Array.isArray(property.of)) base.of = propertyToConfig(property.of, key);
|
|
42
51
|
if (property.type === "map" && property.properties) {
|
|
43
52
|
base.properties = mapPropertiesToConfigs(property.properties);
|
|
44
53
|
if (property.propertiesOrder) base.propertiesOrder = property.propertiesOrder;
|
|
@@ -49,10 +58,15 @@ function mapPropertyToConfig(property, key) {
|
|
|
49
58
|
}
|
|
50
59
|
/**
|
|
51
60
|
* Convert a Properties record to a CollectionPropertyConfig record.
|
|
61
|
+
*
|
|
62
|
+
* @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is
|
|
63
|
+
* deprecated: render the collection with `CollectionPanel` instead. Will be
|
|
64
|
+
* removed in a future release.
|
|
52
65
|
*/
|
|
53
66
|
function mapPropertiesToConfigs(properties) {
|
|
67
|
+
warnDeprecated("cms.mapPropertiesToConfigs", "`mapPropertiesToConfigs` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.");
|
|
54
68
|
const result = {};
|
|
55
|
-
for (const [key, property] of Object.entries(properties)) result[key] =
|
|
69
|
+
for (const [key, property] of Object.entries(properties)) result[key] = propertyToConfig(property, key);
|
|
56
70
|
return result;
|
|
57
71
|
}
|
|
58
72
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propertyConfigMapper.js","names":[],"sources":["../../src/util/propertyConfigMapper.ts"],"sourcesContent":["/**\n * Maps a Rebase `Property` (from @rebasepro/types) to a `CollectionPropertyConfig`\n * (from @rebasepro/ui), stripping all entity-specific fields and keeping only\n * the UI-relevant subset.\n *\n * This is the bridge between the entity-aware and headless layers.\n */\n\nimport type { Property, Properties, EnumValues, EnumValueConfig } from \"@rebasepro/types\";\nimport type { CollectionPropertyConfig, CollectionEnumValueConfig } from \"@rebasepro/ui\";\nimport { prettifyIdentifier } from \"@rebasepro/utils\";\n\n/**\n * Map Rebase property types to headless-supported types.\n * `vector` and `binary` are not directly renderable, so we fall back to `string`.\n */\nconst TYPE_MAP: Record<string, CollectionPropertyConfig[\"type\"]> = {\n string: \"string\",\n number: \"number\",\n boolean: \"boolean\",\n date: \"date\",\n geopoint: \"geopoint\",\n reference: \"reference\",\n relation: \"relation\",\n array: \"array\",\n map: \"map\",\n vector: \"string\", // vectors display as text\n binary: \"string\", // binary displays as text\n};\n\n/**\n * Convert a single Property to a CollectionPropertyConfig.\n */\nexport function mapPropertyToConfig(property: Property, key?: string): CollectionPropertyConfig {\n const base: CollectionPropertyConfig = {\n type: TYPE_MAP[property.type] ?? \"string\",\n // A column header has to say something, and `name` is optional on the\n // property — a headless project has no UI and no reason to invent\n // labels. Falling back to the key is what the collection editor already\n // does when it suggests a name, so a derived label reads the same\n // wherever it appears: `publishDate` -> \"Publish Date\".\n name: property.name ?? (key ? prettifyIdentifier(key) : \"\"),\n description: property.description,\n columnWidth: property.admin?.columnWidth,\n hideFromCollection: property.admin?.hideFromCollection,\n };\n\n // String-specific\n if (property.type === \"string\") {\n if (property.enum) {\n base.enum = mapEnumValues(property.enum);\n }\n if (property.admin?.multiline) base.multiline = true;\n if (property.admin?.previewAsTag) base.previewAsTag = true;\n if (property.admin?.urlPreview) base.url = property.admin.urlPreview;\n if (property.admin?.markdown) base.markdown = true;\n if (property.storage) base.storage = true;\n if (property.email) base.email = true;\n }\n\n // Number-specific\n if (property.type === \"number\" && property.enum) {\n base.enum = mapEnumValues(property.enum);\n }\n\n // Array-specific\n if (property.type === \"array\" && property.of && !Array.isArray(property.of)) {\n base.of =
|
|
1
|
+
{"version":3,"file":"propertyConfigMapper.js","names":[],"sources":["../../src/util/propertyConfigMapper.ts"],"sourcesContent":["/**\n * Maps a Rebase `Property` (from @rebasepro/types) to a `CollectionPropertyConfig`\n * (from @rebasepro/ui), stripping all entity-specific fields and keeping only\n * the UI-relevant subset.\n *\n * This is the bridge between the entity-aware and headless layers.\n */\n\nimport type { Property, Properties, EnumValues, EnumValueConfig } from \"@rebasepro/types\";\nimport type { CollectionPropertyConfig, CollectionEnumValueConfig } from \"@rebasepro/ui\";\nimport { prettifyIdentifier } from \"@rebasepro/utils\";\nimport { warnDeprecated } from \"@rebasepro/common\";\n\n/**\n * Map Rebase property types to headless-supported types.\n * `vector` and `binary` are not directly renderable, so we fall back to `string`.\n */\nconst TYPE_MAP: Record<string, CollectionPropertyConfig[\"type\"]> = {\n string: \"string\",\n number: \"number\",\n boolean: \"boolean\",\n date: \"date\",\n geopoint: \"geopoint\",\n reference: \"reference\",\n relation: \"relation\",\n array: \"array\",\n map: \"map\",\n vector: \"string\", // vectors display as text\n binary: \"string\", // binary displays as text\n};\n\n/**\n * Convert a single Property to a CollectionPropertyConfig.\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function mapPropertyToConfig(property: Property, key?: string): CollectionPropertyConfig {\n warnDeprecated(\n \"cms.mapPropertyToConfig\",\n \"`mapPropertyToConfig` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n return propertyToConfig(property, key);\n}\n\nfunction propertyToConfig(property: Property, key?: string): CollectionPropertyConfig {\n const base: CollectionPropertyConfig = {\n type: TYPE_MAP[property.type] ?? \"string\",\n // A column header has to say something, and `name` is optional on the\n // property — a headless project has no UI and no reason to invent\n // labels. Falling back to the key is what the collection editor already\n // does when it suggests a name, so a derived label reads the same\n // wherever it appears: `publishDate` -> \"Publish Date\".\n name: property.name ?? (key ? prettifyIdentifier(key) : \"\"),\n description: property.description,\n columnWidth: property.admin?.columnWidth,\n hideFromCollection: property.admin?.hideFromCollection,\n };\n\n // String-specific\n if (property.type === \"string\") {\n if (property.enum) {\n base.enum = mapEnumValues(property.enum);\n }\n if (property.admin?.multiline) base.multiline = true;\n if (property.admin?.previewAsTag) base.previewAsTag = true;\n if (property.admin?.urlPreview) base.url = property.admin.urlPreview;\n if (property.admin?.markdown) base.markdown = true;\n if (property.storage) base.storage = true;\n if (property.email) base.email = true;\n }\n\n // Number-specific\n if (property.type === \"number\" && property.enum) {\n base.enum = mapEnumValues(property.enum);\n }\n\n // Array-specific\n if (property.type === \"array\" && property.of && !Array.isArray(property.of)) {\n base.of = propertyToConfig(property.of, key);\n }\n\n // Map-specific\n if (property.type === \"map\" && property.properties) {\n base.properties = mapPropertiesToConfigs(property.properties);\n if (property.propertiesOrder) {\n base.propertiesOrder = property.propertiesOrder;\n }\n }\n\n // Date-specific\n if (property.type === \"date\" && property.mode) {\n base.mode = property.mode;\n }\n\n // Custom preview component\n if (property.admin?.Preview) {\n // The connected wrapper will handle this by injecting via cellRenderer override\n // We don't copy it here because Preview may reference entity-aware components\n }\n\n return base;\n}\n\n/**\n * Convert a Properties record to a CollectionPropertyConfig record.\n *\n * @deprecated It feeds `CollectionView` from `@rebasepro/ui`, which is\n * deprecated: render the collection with `CollectionPanel` instead. Will be\n * removed in a future release.\n */\nexport function mapPropertiesToConfigs(\n properties: Properties\n): Record<string, CollectionPropertyConfig> {\n warnDeprecated(\n \"cms.mapPropertiesToConfigs\",\n \"`mapPropertiesToConfigs` is deprecated, with the `CollectionView` it feeds; render the collection with `CollectionPanel` instead.\"\n );\n const result: Record<string, CollectionPropertyConfig> = {};\n for (const [key, property] of Object.entries(properties)) {\n result[key] = propertyToConfig(property, key);\n }\n return result;\n}\n\n/**\n * Convert Rebase EnumValues to CollectionEnumValueConfig format.\n * Handles both array form (EnumValueConfig[]) and record form.\n */\nfunction mapEnumValues(\n enumValues: EnumValues | undefined\n): Record<string, CollectionEnumValueConfig> | Map<string | number, CollectionEnumValueConfig> | undefined {\n if (!enumValues) return undefined;\n\n // Array form: EnumValueConfig[]\n if (Array.isArray(enumValues)) {\n const result: Record<string, CollectionEnumValueConfig> = {};\n for (const item of enumValues) {\n result[String(item.id)] = normalizeEnumValueConfig(item);\n }\n return result;\n }\n\n // Record form: Record<string | number, string | EnumValueConfig>\n const result: Record<string, CollectionEnumValueConfig> = {};\n for (const [key, value] of Object.entries(enumValues)) {\n result[key] = typeof value === \"string\"\n ? value\n : normalizeEnumValueConfig(value);\n }\n return result;\n}\n\nfunction normalizeEnumValueConfig(config: EnumValueConfig): CollectionEnumValueConfig {\n return {\n label: config.label,\n color: typeof config.color === \"string\" ? config.color : undefined,\n disabled: config.disabled,\n };\n}\n"],"mappings":";;;;;;;AAiBA,IAAM,WAA6D;CAC/D,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,MAAM;CACN,UAAU;CACV,WAAW;CACX,UAAU;CACV,OAAO;CACP,KAAK;CACL,QAAQ;CACR,QAAQ;AACZ;;;;;;;;AASA,SAAgB,oBAAoB,UAAoB,KAAwC;CAC5F,eACI,2BACA,gIACJ;CACA,OAAO,iBAAiB,UAAU,GAAG;AACzC;AAEA,SAAS,iBAAiB,UAAoB,KAAwC;CAClF,MAAM,OAAiC;EACnC,MAAM,SAAS,SAAS,SAAS;EAMjC,MAAM,SAAS,SAAS,MAAM,mBAAmB,GAAG,IAAI;EACxD,aAAa,SAAS;EACtB,aAAa,SAAS,OAAO;EAC7B,oBAAoB,SAAS,OAAO;CACxC;CAGA,IAAI,SAAS,SAAS,UAAU;EAC5B,IAAI,SAAS,MACT,KAAK,OAAO,cAAc,SAAS,IAAI;EAE3C,IAAI,SAAS,OAAO,WAAW,KAAK,YAAY;EAChD,IAAI,SAAS,OAAO,cAAc,KAAK,eAAe;EACtD,IAAI,SAAS,OAAO,YAAY,KAAK,MAAM,SAAS,MAAM;EAC1D,IAAI,SAAS,OAAO,UAAU,KAAK,WAAW;EAC9C,IAAI,SAAS,SAAS,KAAK,UAAU;EACrC,IAAI,SAAS,OAAO,KAAK,QAAQ;CACrC;CAGA,IAAI,SAAS,SAAS,YAAY,SAAS,MACvC,KAAK,OAAO,cAAc,SAAS,IAAI;CAI3C,IAAI,SAAS,SAAS,WAAW,SAAS,MAAM,CAAC,MAAM,QAAQ,SAAS,EAAE,GACtE,KAAK,KAAK,iBAAiB,SAAS,IAAI,GAAG;CAI/C,IAAI,SAAS,SAAS,SAAS,SAAS,YAAY;EAChD,KAAK,aAAa,uBAAuB,SAAS,UAAU;EAC5D,IAAI,SAAS,iBACT,KAAK,kBAAkB,SAAS;CAExC;CAGA,IAAI,SAAS,SAAS,UAAU,SAAS,MACrC,KAAK,OAAO,SAAS;CAIzB,IAAI,SAAS,OAAO,SAAS,CAG7B;CAEA,OAAO;AACX;;;;;;;;AASA,SAAgB,uBACZ,YACwC;CACxC,eACI,8BACA,mIACJ;CACA,MAAM,SAAmD,CAAC;CAC1D,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,UAAU,GACnD,OAAO,OAAO,iBAAiB,UAAU,GAAG;CAEhD,OAAO;AACX;;;;;AAMA,SAAS,cACL,YACuG;CACvG,IAAI,CAAC,YAAY,OAAO,KAAA;CAGxB,IAAI,MAAM,QAAQ,UAAU,GAAG;EAC3B,MAAM,SAAoD,CAAC;EAC3D,KAAK,MAAM,QAAQ,YACf,OAAO,OAAO,KAAK,EAAE,KAAK,yBAAyB,IAAI;EAE3D,OAAO;CACX;CAGA,MAAM,SAAoD,CAAC;CAC3D,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,GAChD,OAAO,OAAO,OAAO,UAAU,WACzB,QACA,yBAAyB,KAAK;CAExC,OAAO;AACX;AAEA,SAAS,yBAAyB,QAAoD;CAClF,OAAO;EACH,OAAO,OAAO;EACd,OAAO,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,KAAA;EACzD,UAAU,OAAO;CACrB;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/cms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0-canary.g0e3a0e7",
|
|
4
4
|
"description": "Rebase CMS — content management views, forms, and routing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rebase",
|
|
@@ -51,6 +51,12 @@
|
|
|
51
51
|
"import": "./dist/editor.js",
|
|
52
52
|
"default": "./dist/editor.js"
|
|
53
53
|
},
|
|
54
|
+
"./mcp-view": {
|
|
55
|
+
"types": "./dist/mcp-view.d.ts",
|
|
56
|
+
"development": "./dist/mcp-view.js",
|
|
57
|
+
"import": "./dist/mcp-view.js",
|
|
58
|
+
"default": "./dist/mcp-view.js"
|
|
59
|
+
},
|
|
54
60
|
"./collection_editor_ui": {
|
|
55
61
|
"types": "./dist/collection_editor_ui.d.ts",
|
|
56
62
|
"development": "./dist/collection_editor_ui.js",
|
|
@@ -93,14 +99,14 @@
|
|
|
93
99
|
"react-use-measure": "^2.1.7",
|
|
94
100
|
"read-excel-file": "^9.3.10",
|
|
95
101
|
"zod": "^4.4.3",
|
|
96
|
-
"@rebasepro/app": "0.
|
|
97
|
-
"@rebasepro/
|
|
98
|
-
"@rebasepro/
|
|
99
|
-
"@rebasepro/cms-types": "0.
|
|
100
|
-
"@rebasepro/inference": "0.
|
|
101
|
-
"@rebasepro/
|
|
102
|
-
"@rebasepro/
|
|
103
|
-
"@rebasepro/
|
|
102
|
+
"@rebasepro/app": "0.29.0-canary.g0e3a0e7",
|
|
103
|
+
"@rebasepro/forms": "0.29.0-canary.g0e3a0e7",
|
|
104
|
+
"@rebasepro/common": "0.29.0-canary.g0e3a0e7",
|
|
105
|
+
"@rebasepro/cms-types": "0.29.0-canary.g0e3a0e7",
|
|
106
|
+
"@rebasepro/inference": "0.29.0-canary.g0e3a0e7",
|
|
107
|
+
"@rebasepro/types": "0.29.0-canary.g0e3a0e7",
|
|
108
|
+
"@rebasepro/utils": "0.29.0-canary.g0e3a0e7",
|
|
109
|
+
"@rebasepro/ui": "0.29.0-canary.g0e3a0e7"
|
|
104
110
|
},
|
|
105
111
|
"peerDependencies": {
|
|
106
112
|
"react": "^19.2.7",
|
package/recipes/README.md
CHANGED
|
@@ -18,22 +18,50 @@ always match the version you have installed.
|
|
|
18
18
|
|
|
19
19
|
| Recipe | What it shows |
|
|
20
20
|
|---|---|
|
|
21
|
-
| [Site settings singleton](site-settings.tsx) | One settings record on its own page, created on first save. A page + `
|
|
21
|
+
| [Site settings singleton](site-settings.tsx) | One settings record on its own page, created on first save. A page + `RecordForm` at a fixed id. |
|
|
22
22
|
| [Per-user preferences](my-preferences.tsx) | Each user edits their own record, keyed by their uid. |
|
|
23
|
-
| [Bulk set status](bulk-set-status.tsx) | A toolbar button that updates every selected row
|
|
23
|
+
| [Bulk set status](bulk-set-status.tsx) | A toolbar button that updates every selected row with `useRowWrites`. |
|
|
24
|
+
| [Approval queue](approval-queue.tsx) | The rows waiting for review, Approve and Reject on every row and card (`entityActions` through `collectionOverrides`), and a live count (`useRowCount`). |
|
|
25
|
+
| [Master-detail](master-detail.tsx) | `SplitView`: a `CollectionPanel` (`fields`, `onRowClick`, `highlightedIds`) beside the picked row's `RecordForm` (`fields`); in a narrow container the form covers the list. |
|
|
24
26
|
| [Calendar view](calendar-view.tsx) | A new view mode for a collection: rows on a month grid. |
|
|
25
|
-
| [Orders dashboard](orders-dashboard.tsx) | A
|
|
27
|
+
| [Orders dashboard](orders-dashboard.tsx) | A total (`useRowCount`) and a count per status (`useAggregate`), drawn with `KpiTile` and `BarChart`; each bar opens the collection filtered to it. |
|
|
26
28
|
| [Custom login screen](custom-login.tsx) | Replacing a built-in screen through `<Rebase components>`. |
|
|
27
29
|
|
|
30
|
+
## Which part for which job
|
|
31
|
+
|
|
32
|
+
| To… | Use |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Show a collection: table, cards, board, its toolbar and record panel | `CollectionPanel`: `fields` for the columns, `where` to narrow it, `orderBy`, `toolbar` (`"compact"`, `"none"`, or composed) |
|
|
35
|
+
| Do something with the row clicked, instead of opening it | `CollectionPanel` `onRowClick(row, id)` |
|
|
36
|
+
| A button on every row or card (Approve, Ship) | `CollectionPanel` `rowActions={(row, id) => <Button…/>}` |
|
|
37
|
+
| Edit one record, or some of its fields | `RecordForm` with `id`, and `fields`, or `FormField` children; `compact` for a side card |
|
|
38
|
+
| Show one record read-only | `RecordDetail` |
|
|
39
|
+
| Show one value of a row in your own JSX | `FieldValue` |
|
|
40
|
+
| A list beside the picked record, folding to drill-down when narrow | `SplitView` (master-detail recipe) |
|
|
41
|
+
| A button on every row and card | `entityActions`: the collection's `admin.entityActions`, or one panel's `collectionOverrides.entityActions` |
|
|
42
|
+
| Read rows, one row, a count or an aggregate | `useRows`, `useRow`, `useRowCount`, `useAggregate` |
|
|
43
|
+
| Create, change or delete rows | `useRowWrites` |
|
|
44
|
+
| KPI figures and charts | `KpiGrid` + `KpiTile`, `ChartCard` + `BarChart` / `TimeSeriesChart`, fed by `useRowCount` / `useAggregate` |
|
|
45
|
+
|
|
28
46
|
## Building blocks
|
|
29
47
|
|
|
30
48
|
Components you render anywhere under `<Rebase>` and a router.
|
|
31
49
|
|
|
32
50
|
| Name | Package | What it is |
|
|
33
51
|
|---|---|---|
|
|
34
|
-
| `CollectionPanel` | `@rebasepro/cms` | A collection's table, cards, board or custom view, with its toolbar, filters and record panel. |
|
|
35
|
-
| `
|
|
52
|
+
| `CollectionPanel` | `@rebasepro/cms` | A collection's table, cards, board or custom view, with its toolbar, filters and record panel. `collection="orders"` names it. `fields` picks what it shows, `where` which rows it holds (as `useRows` takes it, and following state), `orderBy` their order, `rowActions` your JSX on every row and card, `toolbar` replaces or removes its toolbar, `onRowClick` takes the clicked row, as `useRows` reads it, instead of opening it. It sizes to its rows. |
|
|
53
|
+
| `CollectionToolbar` | `@rebasepro/cms` | A collection panel's toolbar, for its `toolbar` prop: the full one, or `start` / `end` holding `CollectionSearchBar`, `CollectionFiltersButton`, `CollectionViewModeToggle` and `CollectionAddButton`. |
|
|
54
|
+
| `RecordForm` | `@rebasepro/cms` | One record's form: loads it, validates, saves. `collection="orders"` names a registered collection; a collection value works too. `FormField` children lay it out your way, and `compact` makes it dense. Given an id no record has yet, it creates it there. `fields` shows some fields, in order; `collectionOverrides` changes the collection for this form only. It validates only the fields it shows. |
|
|
55
|
+
| `FormField` | `@rebasepro/cms` | One field of the record form it sits in, by property name: `<FormField name="status"/>`, inside `RecordForm`, as its children, or a `formView.Builder`. |
|
|
56
|
+
| `RecordDetail` | `@rebasepro/cms` | One record, read-only, drawn as the admin's record page draws it. Takes `fields` and `collectionOverrides` like `RecordForm`, and leaves out what the form leaves out: a field a `conditions.hidden` rule hides for this record, or one the user may not read. |
|
|
57
|
+
| `FieldValue` | `@rebasepro/cms` | One value of a row as the server sends it (`useRows`, `client.data`), drawn as the admin draws it: `<FieldValue collection="orders" field="status" value={order.status}/>`; a belongsTo's foreign key (`field="customer" value={order.customerId}`) draws the related record's title. An enum is its chip, a date is in its timezone, a belongsTo is read from its foreign-key column and shown as its target's title. |
|
|
36
58
|
| `CollectionsProvider` | `@rebasepro/cms` | Makes collections known to the blocks in a page of your own that has no admin shell around it. |
|
|
59
|
+
| `SplitView` | `@rebasepro/ui` | Master beside detail when its own container is wide (768px+), the detail over the master under a back bar when narrow. `master`, `detail` (absent or `false`: the master alone), `selected`, `onClearSelection`, `detailTitle`. Fills its parent, so give the parent a height. |
|
|
60
|
+
| `KpiGrid` | `@rebasepro/ui` | Two to four `KpiTile`s across, as its own width allows. |
|
|
61
|
+
| `KpiTile` | `@rebasepro/ui` | One headline figure: `label`, `value`, `loading`, `error` (an `Error`), and `previous` for the change. |
|
|
62
|
+
| `ChartCard` | `@rebasepro/ui` | A chart's card: `title`, `icon`, `headline`, `action`. |
|
|
63
|
+
| `BarChart` | `@rebasepro/ui` | Categories by size: `bars` (`{ key, label, value }[]`), `onBarClick` makes each bar a button. `loading` / `error` / no bars draw in its place. |
|
|
64
|
+
| `TimeSeriesChart` | `@rebasepro/ui` | Values over time: `series` (`{ id, label, points: { at, value }[] }[]`), `at` a `Date` or an ISO string. |
|
|
37
65
|
| `RebaseAuthGate` | `@rebasepro/cms` | Shows the login screen until someone is signed in, then its children. |
|
|
38
66
|
| `LoginView` | `@rebasepro/app` | The built-in login screen, to frame or reuse. |
|
|
39
67
|
| `Button` | `@rebasepro/ui` | And `Card`, `Typography`, `TextField`, `Select`, `Chip`, `Container`, … — the UI kit the admin is drawn with. Use it so your pages look like the rest. |
|
|
@@ -42,24 +70,29 @@ Components you render anywhere under `<Rebase>` and a router.
|
|
|
42
70
|
|
|
43
71
|
| Name | Package | What it gives you |
|
|
44
72
|
|---|---|---|
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
73
|
+
| `useRows` | `@rebasepro/app` | `useRows("orders", { where, orderBy, limit, searchString })` → `{ rows, total, hasMore, loadMore, loading, error, refresh }`. Rows in the server's shape (see the facts below), kept current after every write. |
|
|
74
|
+
| `useRow` | `@rebasepro/app` | `useRow("orders", id)` → `{ row, loading, error, refresh }`. |
|
|
75
|
+
| `useRowCount` | `@rebasepro/app` | `useRowCount("orders", where)` → `{ count, loading, error }`, counted by the data source. |
|
|
76
|
+
| `useAggregate` | `@rebasepro/app` | `useAggregate("orders", { select: [{ fn: "count" }], groupBy: ["status"], orderBy: ["count", "desc"] })` → `{ result, loading, error }`: one row per group, each aggregate under its alias (`count`, `sum_total`). Computed by the data source; `error` says so where it cannot. |
|
|
77
|
+
| `useRowWrites` | `@rebasepro/app` | `{ create, update, remove, saving, error }`: `update("orders", id, { status: "shipped" })`. Each write is the record form's save: the collection's `browserCallbacks` run, then the server's callbacks and rules, and every view of the collection reads it again. |
|
|
78
|
+
| `useRebaseContext` | `@rebasepro/app` | The context: `context.data.collection("orders").find / findById / create / update / delete`, outside React state. Rows as the hooks return them; a write runs the collection's `browserCallbacks` and refreshes its views, as `useRowWrites` does. |
|
|
79
|
+
| `usePermissions` | `@rebasepro/app` | `canCreate(collection, path)`, `canEdit(collection, path, row)`, `canDelete(collection, path, row)`: what the signed-in user may do, by the collection's rules. |
|
|
48
80
|
| `useAuthController` | `@rebasepro/app` | The signed-in `user` (uid, roles), and sign-in / sign-out. |
|
|
49
81
|
| `useSnackbarController` | `@rebasepro/app` | `open({ type, message })` for a toast. |
|
|
50
|
-
| `useSidePanel` | `@rebasepro/cms` | Open any record in the side panel: `open({ path,
|
|
82
|
+
| `useSidePanel` | `@rebasepro/cms` | Open any record in the side panel: `open({ path, id })`. |
|
|
51
83
|
| `useUrlController` | `@rebasepro/cms` | Admin URLs and navigation: `buildUrlCollectionPath`, `navigate`. |
|
|
52
|
-
| `useCollectionRegistryController` | `@rebasepro/cms` | Look up a collection by slug
|
|
53
|
-
| `resolveSelection` | `@rebasepro/cms` | Turn a table selection — ticked rows or "all matching" — into the rows. |
|
|
84
|
+
| `useCollectionRegistryController` | `@rebasepro/cms` | Look up a collection by slug: `getCollection("orders")`, once `initialised`. |
|
|
85
|
+
| `resolveSelection` | `@rebasepro/cms` | Turn a table selection — ticked rows or "all matching" — into the rows and their ids: `const { rows, ids } = await resolveSelection({ selection, data: context.data, collection })`. |
|
|
86
|
+
| `useElementWidth` | `@rebasepro/ui` | `[ref, width]`: an element's own width, to lay out by its container rather than the window. |
|
|
54
87
|
|
|
55
88
|
## Places
|
|
56
89
|
|
|
57
90
|
| To add… | Put a component in | Recipe |
|
|
58
91
|
|---|---|---|
|
|
59
|
-
| A page | `<RebaseCMS views={[{ slug, name, icon, view }]}>` | site settings, dashboard |
|
|
92
|
+
| A page | `<RebaseCMS views={[{ slug, name, icon, view }]}>` | site settings, dashboard, master-detail |
|
|
60
93
|
| A view mode for a collection | `collectionViews={[{ key, name, Builder }]}` + `admin.customViews: ["key"]` | calendar view |
|
|
61
94
|
| A button in a collection's toolbar | `admin.Actions: [Component]` | bulk set status |
|
|
62
|
-
| A button on a record | `admin.entityActions: [{ key, name, onClick }]` | |
|
|
95
|
+
| A button on a record, and on every row and card | `admin.entityActions: [{ key, name, icon, onClick, collapsed: false }]`, or for one panel `collectionOverrides.entityActions` | approval queue |
|
|
63
96
|
| A tab on a record | `admin.entityViews: [{ key, name, Builder }]` | |
|
|
64
97
|
| How one field is edited or shown | `admin.Field` / `admin.Preview` on the property | |
|
|
65
98
|
| Something beside a built-in part | `<Rebase slots={[{ slot, Component }]}>` (`home.cards`, `form.after`, `collection.toolbar`, …) | |
|
|
@@ -70,29 +103,49 @@ Components you render anywhere under `<Rebase>` and a router.
|
|
|
70
103
|
| Place | Your component receives |
|
|
71
104
|
|---|---|
|
|
72
105
|
| A page (`views`) | Nothing: read what you need with the hooks. It renders inside the admin's router, so `useUrlController().navigate(…)` (or `react-router`) works. |
|
|
73
|
-
| A view mode `Builder` | `CollectionCustomViewParams`: `collection`, `path`, `tableController` (its `
|
|
74
|
-
| `admin.Actions` | `CollectionActionsProps`: `path`, `collection`, `selectionController` (`hasSelection`, `selection`, `clearSelection()`), `tableController`, `openNewDocument(defaults?)`. Turn `selection` into rows with `resolveSelection({ selection,
|
|
75
|
-
| `
|
|
106
|
+
| A view mode `Builder` | `CollectionCustomViewParams`: `collection`, `path`, `tableController` (its `rows` are the rows the toolbar's search and filters select, `ids` their ids at the same positions; `loading`, `error`, …), `onRowClick(row)` to open a row the way the collection opens rows, `selectionController`, `highlightedIds`, `emptyComponent`. |
|
|
107
|
+
| `admin.Actions` | `CollectionActionsProps`: `path`, `collection`, `selectionController` (`hasSelection`, `selection`, `isSelected(id)`, `setSelectedRows(rows)`, `clearSelection()`), `tableController` (`rows`, `ids`), `openNewDocument(defaults?)`. `context`, whose `data` reads rows. Turn `selection` into rows and their ids with `const { rows, ids } = await resolveSelection({ selection, data: context.data, collection })` — it may stand for "every row matching the filter", not only the ticked ones. |
|
|
108
|
+
| `entityActions` `onClick` | `EntityActionClickProps`: `row` (the record, as the server sends it), `id`, `path`, `collection`, `context`, `view` (`"collection"` or `"form"`). |
|
|
109
|
+
| `admin.entityViews` `Builder` | `EntityCustomViewParams`: `collection`, the saved record (`row`) and its id (`id`), both absent while it is being created, the form's values with unsaved edits (`modifiedValues`) and the form (`formContext`). |
|
|
76
110
|
| `"Auth.LoginView"` | `{ authController }`. Sign in with `authController.emailPasswordLogin?.(email, password)` (optional: present when email sign-in is enabled); a failure throws and is also on `authController.authProviderError`. Once `authController.user` is set the admin replaces your screen by itself. |
|
|
77
111
|
| Any other override | The props of the part it replaces; with `wrap: true`, those plus `OriginalComponent`. |
|
|
78
112
|
|
|
79
113
|
## Facts that save a trip to the source
|
|
80
114
|
|
|
81
|
-
- **Rows are
|
|
82
|
-
`
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
`
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
115
|
+
- **Rows are the server's rows** wherever your code asks for them: `useRows`,
|
|
116
|
+
`useRow`, `useRowWrites`' results, `context.data`, `resolveSelection`,
|
|
117
|
+
`CollectionPanel`'s `onRowClick`, `client.data` — and what a collection's
|
|
118
|
+
`browserCallbacks`, its `entityActions`, `admin.display` resolvers,
|
|
119
|
+
`additionalFields`, entity views, a form's `context.row`, a view mode
|
|
120
|
+
`Builder`'s `tableController.rows`, a collection action's selection and the
|
|
121
|
+
slots are handed. A row is a flat object, exactly the table's columns (an
|
|
122
|
+
`id` column as `row.id`, with its type), a date as an ISO string (`"2026-11-08"` for a `columnType:
|
|
123
|
+
"date"` column, a full timestamp otherwise), and a belongsTo relation as its
|
|
124
|
+
foreign-key column (`customerId`). A relation the admin loaded arrives nested
|
|
125
|
+
under its name, as REST's `include` returns it (`row.customer` is the
|
|
126
|
+
customer's row, exactly its columns, beside `customerId`). Draw a value with
|
|
127
|
+
`<FieldValue collection="orders" field="customer" value={row.customerId}/>` rather than
|
|
128
|
+
formatting it yourself.
|
|
129
|
+
- **A row's id is handed beside it**, as a string (a composite key's parts
|
|
130
|
+
joined by `:::`): `id` beside a `row`, and `ids` beside `rows` at the same
|
|
131
|
+
positions — `tableController.ids[i]` is the id of `tableController.rows[i]`;
|
|
132
|
+
a selection and `resolveSelection` hand `{ rows, ids }`. Write and open with
|
|
133
|
+
that id, not `String(row.id)`: a collection keyed by another column has no
|
|
134
|
+
`row.id`.
|
|
135
|
+
- **`where` and `orderBy`** are the same everywhere: `{ status: ["==",
|
|
136
|
+
"paid"], total: [">", 100] }` and `["createdAt", "desc"]`.
|
|
137
|
+
- **An `Entity` is the admin's own record**, handed only to a copy of one of
|
|
138
|
+
its parts (`Collection.Table`, a card). It is `{ id, path, values }`: fields
|
|
139
|
+
are on `entity.values`, and there dates are `Date` objects and a relation an
|
|
140
|
+
`EntityRelation`. `getDatePropertyTimezone(property)` names the zone the
|
|
141
|
+
admin shows any date property in.
|
|
89
142
|
- **Defaults for a new record:** a property's `defaultValue` applies everywhere a
|
|
90
|
-
record is created; `
|
|
143
|
+
record is created; `RecordForm`'s `defaultValues` apply to that form only,
|
|
91
144
|
on top of them.
|
|
92
145
|
- **Enum fields** are `enum: [{ id: "draft", label: "Draft" }, …]` on a string
|
|
93
146
|
property — see `defineCollection` and the collections docs for every property
|
|
94
147
|
option.
|
|
95
|
-
- **A record keyed by its user:** `
|
|
148
|
+
- **A record keyed by its user:** `id={useAuthController().user?.uid}`.
|
|
96
149
|
|
|
97
150
|
The override names are `Shell.AppBar`, `Shell.Drawer`, `HomePage`,
|
|
98
151
|
`HomePage.CollectionCard`, `Auth.LoginView`, `Collection.View`,
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recipe: an approval queue — the rows waiting for review, an Approve and a
|
|
3
|
+
* Reject on every one, and how many are left.
|
|
4
|
+
*
|
|
5
|
+
* The queue is the collection's own panel narrowed to `status == "pending"`
|
|
6
|
+
* with `where`, the filter `useRowCount` takes too, so it has the
|
|
7
|
+
* collection's table, cards, search and record panel for free. The two
|
|
8
|
+
* buttons are the collection's `entityActions`, given for this panel only
|
|
9
|
+
* through `collectionOverrides`: `collapsed: false` draws each as a button on every row of the
|
|
10
|
+
* table and on every card and board card, not inside the ⋮ menu.
|
|
11
|
+
*
|
|
12
|
+
* A decision is one `useRowWrites().update`: the save the record form makes,
|
|
13
|
+
* so the collection's callbacks and security rules apply. The row then no
|
|
14
|
+
* longer matches the filter, and the panel and the `useRowCount` above it read
|
|
15
|
+
* again by themselves.
|
|
16
|
+
*
|
|
17
|
+
* To use it: add `approvalQueueView` to `<RebaseCMS views={[…]}>`. Change
|
|
18
|
+
* `COLLECTION` / `STATUS_FIELD` and the three values to your own.
|
|
19
|
+
*/
|
|
20
|
+
import React, { useMemo } from "react";
|
|
21
|
+
import type { AdminCollection, AppView, EntityAction } from "@rebasepro/cms-types";
|
|
22
|
+
import type { FilterValues } from "@rebasepro/types";
|
|
23
|
+
import { useRowCount, useRowWrites, useSnackbarController } from "@rebasepro/app";
|
|
24
|
+
import { CollectionPanel } from "@rebasepro/cms";
|
|
25
|
+
import { Container, Typography } from "@rebasepro/ui";
|
|
26
|
+
|
|
27
|
+
const COLLECTION = "comments";
|
|
28
|
+
const STATUS_FIELD = "status";
|
|
29
|
+
const PENDING = "pending";
|
|
30
|
+
|
|
31
|
+
/** The rows the queue holds: the panel's filter and the count's. */
|
|
32
|
+
const WAITING: FilterValues<string> = { [STATUS_FIELD]: ["==", PENDING] };
|
|
33
|
+
|
|
34
|
+
export function ApprovalQueue() {
|
|
35
|
+
const { update } = useRowWrites();
|
|
36
|
+
const snackbar = useSnackbarController();
|
|
37
|
+
const { count } = useRowCount(COLLECTION, WAITING);
|
|
38
|
+
|
|
39
|
+
// Memoised: a new object every render would redraw every row.
|
|
40
|
+
const overrides = useMemo<Partial<AdminCollection>>(() => {
|
|
41
|
+
const decide = (name: string, icon: string, status: string): EntityAction => ({
|
|
42
|
+
key: status,
|
|
43
|
+
name,
|
|
44
|
+
icon,
|
|
45
|
+
collapsed: false,
|
|
46
|
+
// An action is handed the row and its id, as `useRows` returns them.
|
|
47
|
+
onClick: async ({ id }) => {
|
|
48
|
+
if (id === undefined) return;
|
|
49
|
+
try {
|
|
50
|
+
await update(COLLECTION, id, { [STATUS_FIELD]: status });
|
|
51
|
+
} catch (error) {
|
|
52
|
+
snackbar.open({ type: "error", message: error instanceof Error ? error.message : String(error) });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
entityActions: [decide("Approve", "Check", "approved"), decide("Reject", "X", "rejected")]
|
|
58
|
+
};
|
|
59
|
+
}, [update, snackbar]);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Container maxWidth={"5xl"} className={"py-8 flex flex-col gap-4 h-full"}>
|
|
63
|
+
<div className={"flex items-baseline gap-3"}>
|
|
64
|
+
<Typography variant={"h4"}>Review queue</Typography>
|
|
65
|
+
<Typography variant={"body2"} color={"secondary"}>
|
|
66
|
+
{count === undefined ? "" : count === 0 ? "Nothing waiting" : `${count} waiting`}
|
|
67
|
+
</Typography>
|
|
68
|
+
</div>
|
|
69
|
+
<CollectionPanel collection={COLLECTION} title={false} where={WAITING} collectionOverrides={overrides} className={"flex-1"}/>
|
|
70
|
+
</Container>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const approvalQueueView: AppView = {
|
|
75
|
+
slug: "review",
|
|
76
|
+
name: "Review queue",
|
|
77
|
+
icon: "ListChecks",
|
|
78
|
+
view: <ApprovalQueue/>
|
|
79
|
+
};
|
|
@@ -5,25 +5,27 @@
|
|
|
5
5
|
* and hands each the selection and the collection's path. This one appears
|
|
6
6
|
* once rows are ticked and archives them: it reads the selection (which may be
|
|
7
7
|
* "every row matching the filter", not just the ticked ones — `resolveSelection`
|
|
8
|
-
* handles both), updates each row
|
|
9
|
-
* selection.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* handles both), updates each row with `useRowWrites`, and clears the
|
|
9
|
+
* selection. Each update is the save the record form makes: the collection's
|
|
10
|
+
* `browserCallbacks` run, then the server's callbacks and security rules, and
|
|
11
|
+
* every view of the collection reads it again. When one is refused, the rows
|
|
12
|
+
* before it are already archived: it says how many, and leaves the rest
|
|
13
|
+
* selected for another try.
|
|
12
14
|
*
|
|
13
15
|
* To use it: `admin: { Actions: [ArchiveSelectedAction] }` on the collection,
|
|
14
16
|
* or copy it and change `FIELD` / `VALUE` / the label.
|
|
15
17
|
*/
|
|
16
18
|
import React, { useState } from "react";
|
|
17
19
|
import type { CollectionActionsProps } from "@rebasepro/cms-types";
|
|
18
|
-
import {
|
|
20
|
+
import { useRowWrites, useSnackbarController } from "@rebasepro/app";
|
|
19
21
|
import { resolveSelection } from "@rebasepro/cms";
|
|
20
22
|
import { Button } from "@rebasepro/ui";
|
|
21
23
|
|
|
22
24
|
const FIELD = "status";
|
|
23
25
|
const VALUE = "archived";
|
|
24
26
|
|
|
25
|
-
export function ArchiveSelectedAction({ path, selectionController }: CollectionActionsProps) {
|
|
26
|
-
const
|
|
27
|
+
export function ArchiveSelectedAction({ path, collection, context, selectionController }: CollectionActionsProps) {
|
|
28
|
+
const { update } = useRowWrites();
|
|
27
29
|
const snackbar = useSnackbarController();
|
|
28
30
|
const [running, setRunning] = useState(false);
|
|
29
31
|
|
|
@@ -31,23 +33,27 @@ export function ArchiveSelectedAction({ path, selectionController }: CollectionA
|
|
|
31
33
|
|
|
32
34
|
const archive = async () => {
|
|
33
35
|
setRunning(true);
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
+
let ids: string[] = [];
|
|
37
|
+
const archived = new Set<string>();
|
|
36
38
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (const
|
|
40
|
-
await
|
|
41
|
-
|
|
39
|
+
// Each row's id comes beside it, whatever the collection is keyed by.
|
|
40
|
+
({ ids } = await resolveSelection({ selection: selectionController.selection, data: context.data, collection }));
|
|
41
|
+
for (const id of ids) {
|
|
42
|
+
await update(path, id, { [FIELD]: VALUE });
|
|
43
|
+
archived.add(id);
|
|
42
44
|
}
|
|
43
45
|
selectionController.clearSelection();
|
|
44
|
-
snackbar.open({ type: "success", message: `Archived ${
|
|
46
|
+
snackbar.open({ type: "success", message: `Archived ${ids.length} row${ids.length === 1 ? "" : "s"}` });
|
|
45
47
|
} catch (error) {
|
|
46
48
|
const reason = error instanceof Error ? error.message : String(error);
|
|
47
|
-
|
|
49
|
+
// The ticked rows not yet archived stay ticked, for another try.
|
|
50
|
+
const { selection } = selectionController;
|
|
51
|
+
if (archived.size > 0 && selection.type === "rows") {
|
|
52
|
+
selectionController.setSelectedRows(selection.rows.filter((_, i) => !archived.has(selection.ids[i])));
|
|
53
|
+
}
|
|
48
54
|
snackbar.open({
|
|
49
55
|
type: "error",
|
|
50
|
-
message:
|
|
56
|
+
message: ids.length > 0 ? `Archived ${archived.size} of ${ids.length} rows. ${reason}` : reason
|
|
51
57
|
});
|
|
52
58
|
} finally {
|
|
53
59
|
setRunning(false);
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A custom view mode sits in the collection's view switcher next to table,
|
|
5
5
|
* cards and board. Its `Builder` is handed the live `tableController`, so the
|
|
6
|
-
* toolbar's search and filters drive it, and `
|
|
7
|
-
*
|
|
6
|
+
* toolbar's search and filters drive it, and `onRowClick`, which opens a row
|
|
7
|
+
* the way the collection opens rows. The rows are the server's: a date is an
|
|
8
|
+
* ISO string, `YYYY-MM-DD` for a date-only column. All this file decides is
|
|
9
|
+
* the layout.
|
|
8
10
|
*
|
|
9
11
|
* To use it:
|
|
10
12
|
* 1. Register it: `<RebaseCMS collectionViews={[calendarView]}>`
|
|
@@ -15,7 +17,6 @@
|
|
|
15
17
|
*/
|
|
16
18
|
import React, { useMemo, useState } from "react";
|
|
17
19
|
import type { CollectionCustomView, CollectionCustomViewParams } from "@rebasepro/cms-types";
|
|
18
|
-
import type { Entity } from "@rebasepro/types";
|
|
19
20
|
import { Button, Typography } from "@rebasepro/ui";
|
|
20
21
|
import { getDatePropertyTimezone } from "@rebasepro/cms";
|
|
21
22
|
|
|
@@ -29,12 +30,16 @@ function dayKey(date: Date): string {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
* The day a stored date falls on, in the zone the admin shows it in:
|
|
33
|
-
* `columnType: "date"` column
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* The day a stored date falls on, in the zone the admin shows it in: the day
|
|
34
|
+
* itself for a `columnType: "date"` column, which arrives as `YYYY-MM-DD`;
|
|
35
|
+
* for a timestamp, its day in the property's `timezone` when it declares
|
|
36
|
+
* one, else the browser's.
|
|
36
37
|
*/
|
|
37
|
-
function storedDayKey(
|
|
38
|
+
function storedDayKey(raw: string, timeZone: string | undefined): string | undefined {
|
|
39
|
+
const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw);
|
|
40
|
+
if (day) return `${Number(day[1])}-${Number(day[2]) - 1}-${Number(day[3])}`;
|
|
41
|
+
const date = new Date(raw);
|
|
42
|
+
if (Number.isNaN(date.getTime())) return undefined;
|
|
38
43
|
if (!timeZone) return dayKey(date);
|
|
39
44
|
const parts = new Intl.DateTimeFormat("en-US", { timeZone, year: "numeric", month: "numeric", day: "numeric" })
|
|
40
45
|
.formatToParts(date);
|
|
@@ -54,7 +59,7 @@ function monthGrid(month: Date): Date[] {
|
|
|
54
59
|
return days;
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
export function CalendarView({ collection, tableController,
|
|
62
|
+
export function CalendarView({ collection, tableController, onRowClick }: CollectionCustomViewParams) {
|
|
58
63
|
const [month, setMonth] = useState(() => {
|
|
59
64
|
const now = new Date();
|
|
60
65
|
return new Date(now.getFullYear(), now.getMonth(), 1);
|
|
@@ -63,18 +68,18 @@ export function CalendarView({ collection, tableController, onEntityClick }: Col
|
|
|
63
68
|
const dateProperty = collection.properties[DATE_FIELD];
|
|
64
69
|
const timeZone = dateProperty?.type === "date" ? getDatePropertyTimezone(dateProperty) : undefined;
|
|
65
70
|
|
|
71
|
+
// Each row with its id, which `tableController.ids` holds at the row's position.
|
|
66
72
|
const byDay = useMemo(() => {
|
|
67
|
-
const map = new Map<string,
|
|
68
|
-
|
|
69
|
-
const raw =
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
73
|
+
const map = new Map<string, { row: Record<string, unknown>; id: string }[]>();
|
|
74
|
+
tableController.rows.forEach((row, i) => {
|
|
75
|
+
const raw = row[DATE_FIELD];
|
|
76
|
+
if (typeof raw !== "string") return;
|
|
77
|
+
const key = storedDayKey(raw, timeZone);
|
|
78
|
+
if (key === undefined) return;
|
|
79
|
+
map.set(key, [...(map.get(key) ?? []), { row, id: tableController.ids[i] }]);
|
|
80
|
+
});
|
|
76
81
|
return map;
|
|
77
|
-
}, [tableController.
|
|
82
|
+
}, [tableController.rows, tableController.ids, timeZone]);
|
|
78
83
|
|
|
79
84
|
const shift = (months: number) => setMonth(m => new Date(m.getFullYear(), m.getMonth() + months, 1));
|
|
80
85
|
|
|
@@ -98,14 +103,14 @@ export function CalendarView({ collection, tableController, onEntityClick }: Col
|
|
|
98
103
|
className={"min-h-24 bg-surface-card p-1 flex flex-col gap-1"
|
|
99
104
|
+ (day.getMonth() === month.getMonth() ? "" : " opacity-40")}>
|
|
100
105
|
<Typography variant={"caption"} color={"secondary"}>{day.getDate()}</Typography>
|
|
101
|
-
{(byDay.get(dayKey(day)) ?? []).map(
|
|
102
|
-
<Button key={
|
|
106
|
+
{(byDay.get(dayKey(day)) ?? []).map(({ row, id }) => (
|
|
107
|
+
<Button key={id}
|
|
103
108
|
variant={"text"}
|
|
104
109
|
size={"smallest"}
|
|
105
110
|
fullWidth
|
|
106
|
-
onClick={() =>
|
|
111
|
+
onClick={() => onRowClick?.(row)}
|
|
107
112
|
className={"justify-start min-w-0"}>
|
|
108
|
-
<span className={"truncate"}>{String(
|
|
113
|
+
<span className={"truncate"}>{String(row[TITLE_FIELD] ?? id)}</span>
|
|
109
114
|
</Button>
|
|
110
115
|
))}
|
|
111
116
|
</div>
|