@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitListView.js","names":[],"sources":["../../../src/components/CollectionViewBinding/SplitListView.tsx"],"sourcesContent":["\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { CollectionSize, EntityTableController, SelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { EditViewBinding } from \"../EditViewBinding\";\nimport { DetailViewBinding } from \"../DetailViewBinding\";\nimport {\n cls,\n defaultBorderMixin,\n isKeyHandled,\n ResizablePanels\n} from \"@rebasepro/ui\";\nimport { useLargeLayout, UnsavedChangesDialog, useNavigationBlocker, useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate, useLocation } from \"react-router\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { withListState } from \"../../util/view_mode\";\nimport { SplitViewProvider } from \"./SplitViewContext\";\n\nexport type SplitListViewProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n collection: AdminCollection<M>;\n tableController: EntityTableController<M>;\n onEntityClick?: (entity: Entity<M>) => void;\n onNewClick?: () => void;\n selectionController?: SelectionController<M>;\n selectionEnabled?: boolean;\n highlightedEntities?: Entity<M>[];\n emptyComponent?: React.ReactNode;\n onScroll?: (props: {\n scrollDirection: \"forward\" | \"backward\";\n scrollOffset: number;\n scrollUpdateWasRequested: boolean;\n }) => void;\n initialScroll?: number;\n size?: CollectionSize;\n path: string;\n parentCollectionSlugs?: string[], parentEntityIds?: string[];\n /**\n * The entity ID to show in the detail panel.\n * Comes from the URL path (e.g. /c/authors/14 → selectedEntityId = \"14\").\n * When undefined, no detail panel is shown.\n */\n selectedEntityId?: string | number;\n /**\n * When provided, the detail panel will open this tab (e.g. a subcollection slug).\n * Used by the router to pass the subcollection tab from the URL.\n */\n selectedTab?: string;\n /**\n * Toolbar to render above the content in the left panel.\n */\n toolbar?: React.ReactNode;\n /**\n * The collection view to render on the left side.\n */\n children: React.ReactNode;\n};\n\nconst PANEL_SIZE_KEY = \"rebase_split_list_panel_size\";\n\n/**\n * Whether the element accepts text, and therefore owns the keystroke.\n * Covers native fields plus the ARIA roles custom editors expose.\n */\nfunction isTextEntryTarget(target: HTMLElement | null): boolean {\n if (!target) return false;\n const tag = target.tagName;\n if (tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\") return true;\n if (target.isContentEditable) return true;\n return Boolean(target.closest('[contenteditable=\"true\"], [role=\"textbox\"], [role=\"combobox\"], [role=\"searchbox\"]'));\n}\n\n/**\n * Whether a bare letter shortcut may act on this target. Only the list side of\n * the split owns them — inside the detail panel a keystroke belongs to the form.\n */\nfunction isListShortcutTarget(target: HTMLElement | null, detailPanel: HTMLElement | null): boolean {\n if (!target || target === document.body) return true;\n // Focus inside a layer opened above the page — a dialog, a menu, a select\n // list — means the keystroke is that layer's. A modal traps focus, so this\n // is also what keeps a bare `j` from moving the list behind an open dialog.\n if (target.closest('[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"]')) return false;\n return !detailPanel?.contains(target);\n}\n\n/**\n * The list's share of the split, as a percentage, before anyone drags it.\n *\n * The list only has to identify a record — a title, a subtitle and a status\n * chip — while the detail beside it carries the whole record and its rail. At\n * 30% the list was taking width from the side that had four columns of fields\n * to lay out; 26% still was, by about the width of one field.\n *\n * A default, not a constraint: {@link savePanelSize} remembers the drag per\n * collection, so anyone who has already sized this list keeps their size. The\n * drag floor is `minPanelSizePx`, and it holds below ~1100px of split — at that\n * width this percentage is already the floor.\n */\nconst DEFAULT_PANEL_SIZE = 22;\n\nfunction getSavedPanelSize(path: string): number {\n try {\n const saved = localStorage.getItem(`${PANEL_SIZE_KEY}_${path}`);\n if (saved !== null) {\n const val = parseFloat(saved);\n if (!isNaN(val) && val > 0 && val < 100) return val;\n }\n } catch { /* ignore */ }\n return DEFAULT_PANEL_SIZE;\n}\n\nfunction savePanelSize(path: string, size: number) {\n try {\n localStorage.setItem(`${PANEL_SIZE_KEY}_${path}`, size.toString());\n } catch { /* ignore */ }\n}\n\n/**\n * Master-detail split view.\n * Shows the list on the left and the entity edit view on the right.\n *\n * Animation approach:\n * - The list always renders at full width.\n * - When a detail opens, the list shrinks to `panelSize%` and the detail slides in.\n * - On close, the reverse plays.\n *\n * State management:\n * - The selected entity is driven by the URL path (e.g. /c/authors/14).\n * `selectedEntityId` comes from props via RebaseRoute, NOT from internal state.\n * - Clicking a entity navigates to /c/authors/{id} via the standard onEntityClick handler.\n * - Closing the detail navigates back to /c/authors.\n */\nexport function SplitListView<M extends Record<string, unknown> = Record<string, unknown>>({\n collection,\n tableController,\n onEntityClick: externalOnEntityClick,\n onNewClick: externalOnNewClick,\n selectionController,\n selectionEnabled = true,\n highlightedEntities,\n emptyComponent,\n onScroll,\n initialScroll,\n size = \"m\",\n path,\n parentCollectionSlugs, parentEntityIds,\n selectedEntityId,\n selectedTab,\n toolbar,\n children\n}: SplitListViewProps<M>) {\n const { t } = useTranslation();\n const largeLayout = useLargeLayout();\n const collectionRegistryController = useCollectionRegistryController();\n const location = useLocation();\n const isEditMode = location.pathname.endsWith(\"/edit\") || location.pathname.split(\"/\").pop() === \"edit\";\n const navigate = useNavigate();\n const urlController = useUrlController();\n\n const showDetail = selectedEntityId !== undefined;\n\n // ── Unsaved changes ──\n // The detail form lives inside the split layout, so every way out of it\n // (Escape, j/k, clicking another row, the browser back button) is a plain\n // router navigation. A ref — not state — because the blocker predicate must\n // observe the change synchronously, before the navigation it is guarding.\n const dirty = useRef(false);\n const detailPanelRef = useRef<HTMLDivElement>(null);\n const setDirty = useCallback((modified: boolean) => {\n dirty.current = modified;\n }, []);\n\n // The form remounts per entity, so its dirty state must not leak into the\n // next one — and it has to be cleared here rather than left to the next\n // form's own first report, because that form spends the load in a skeleton\n // and a navigation during it would prompt about the record before it.\n //\n // On a *change* of record only, never on this view's own mount: a record\n // arriving from full screen carries its edit back in and opens dirty, and\n // the form says so from its first effect — which runs before this one, being\n // a child's. Clearing unconditionally overwrote that report with `false`,\n // and the way out of the split stopped asking about a live edit.\n const previousEntityId = useRef(selectedEntityId);\n useEffect(() => {\n if (previousEntityId.current === selectedEntityId) return;\n previousEntityId.current = selectedEntityId;\n dirty.current = false;\n }, [selectedEntityId]);\n\n const blocker = useNavigationBlocker(useCallback(({\n currentLocation,\n nextLocation\n }) => {\n if (!dirty.current) return false;\n if (currentLocation.pathname === nextLocation.pathname) return false;\n // Side panel overlays (e.g. following a relation) render above the form\n // and leave it mounted — nothing is lost in either direction.\n const nextHash = nextLocation.hash;\n if (nextHash === \"#side\" || nextHash === \"#new_side\") return false;\n const currentHash = currentLocation.hash;\n if (currentHash === \"#side\" || currentHash === \"#new_side\") return false;\n return true;\n }, []));\n\n // Panel size state with persistence.\n //\n // Written on drag, not on mount. An effect that saved on mount stored\n // {@link DEFAULT_PANEL_SIZE} under this collection's key the first time\n // anyone opened the split — after which the default was frozen in every\n // browser that had ever seen it, and changing it here reached nobody but a\n // new visitor. Only a size someone chose is a size worth remembering.\n const [panelSize, setPanelSize] = useState(() => getSavedPanelSize(path));\n\n const handlePanelSizeChange = useCallback((size: number) => {\n setPanelSize(size);\n savePanelSize(path, size);\n }, [path]);\n\n // ── Animation state ──\n // We track the \"rendered\" entity to keep the detail panel mounted during the exit animation.\n const [renderedEntityId, setRenderedEntityId] = useState<string | number | undefined>(selectedEntityId);\n const [animationPhase, setAnimationPhase] = useState<\"idle\" | \"entering\" | \"entered\" | \"exiting\">(\n selectedEntityId !== undefined ? \"entered\" : \"idle\"\n );\n const animationTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Transition duration (ms) — keep in sync with CSS\n const TRANSITION_DURATION = 150;\n\n useEffect(() => {\n if (animationTimer.current) {\n clearTimeout(animationTimer.current);\n animationTimer.current = null;\n }\n\n if (selectedEntityId !== undefined) {\n // Opening or switching entity\n setRenderedEntityId(selectedEntityId);\n if (animationPhase === \"idle\" || animationPhase === \"exiting\") {\n // Fresh open — trigger enter\n setAnimationPhase(\"entering\");\n // Use requestAnimationFrame to ensure the \"entering\" class is painted\n // before transitioning to \"entered\".\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n setAnimationPhase(\"entered\");\n });\n });\n }\n // If already entered (switching entities), keep \"entered\"\n } else {\n // Closing\n if (animationPhase === \"entered\" || animationPhase === \"entering\") {\n setAnimationPhase(\"exiting\");\n animationTimer.current = setTimeout(() => {\n setAnimationPhase(\"idle\");\n setRenderedEntityId(undefined);\n }, TRANSITION_DURATION);\n }\n }\n\n return () => {\n if (animationTimer.current) clearTimeout(animationTimer.current);\n };\n }, [selectedEntityId]); // Intentionally only depend on selectedEntityId\n\n // Build a URL below this collection, carrying the list's whole URL state —\n // view mode, search, filters and sort — the way the record was opened.\n // The list reads that state back from the URL on every navigation, so a\n // URL carrying only the view mode reset the search box and the filters\n // each time the record was closed or one of its tabs changed.\n const buildUrl = useCallback((subPath: string) => {\n return withListState(urlController.buildUrlCollectionPath(subPath));\n }, [urlController]);\n\n // Close the detail panel: navigate back to the collection path\n const handleCloseDetail = useCallback(() => {\n navigate(buildUrl(path));\n }, [navigate, buildUrl, path]);\n\n // ── Keyboard navigation ──\n const entityIds = useMemo(\n () => tableController.data.map((e: Entity<M>) => e.id),\n [tableController.data]\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n const target = e.target as HTMLElement | null;\n\n // A layer above the record — a dialog, a menu, a select list, the\n // inspector — claims the key it acts on with preventDefault(). Asking\n // the DOM for an open `role=\"dialog\"` instead missed every layer that\n // is not a dialog, so Escape on an open dropdown closed the record too.\n if (isKeyHandled(e)) return;\n\n if (e.key === \"Escape\") {\n if (!selectedEntityId) return;\n // First Escape leaves the field (which may also be dismissing its\n // own dropdown), a second one closes the panel. Closing straight\n // from a focused field would discard an in-progress edit.\n if (isTextEntryTarget(target)) {\n target?.blur();\n e.preventDefault();\n return;\n }\n handleCloseDetail();\n e.preventDefault();\n return;\n }\n\n // Record navigation only belongs to the list side. Inside the detail\n // panel these keys are the form's — arrows move between fields, and a\n // bare letter is input for widgets that aren't native fields (rich\n // text, code editors, comboboxes).\n if (!isListShortcutTarget(target, detailPanelRef.current)) return;\n if (isTextEntryTarget(target)) return;\n\n // Arrow down / j → next entity\n if ((e.key === \"ArrowDown\" || e.key === \"j\") && !e.metaKey && !e.ctrlKey) {\n e.preventDefault();\n if (entityIds.length === 0) return;\n\n if (selectedEntityId === undefined) {\n const firstEntity = tableController.data[0];\n if (firstEntity) externalOnEntityClick?.(firstEntity);\n } else {\n const currentIndex = entityIds.indexOf(selectedEntityId);\n if (currentIndex >= 0 && currentIndex < entityIds.length - 1) {\n const nextEntity = tableController.data[currentIndex + 1];\n if (nextEntity) externalOnEntityClick?.(nextEntity);\n }\n }\n return;\n }\n\n // Arrow up / k → previous entity\n if ((e.key === \"ArrowUp\" || e.key === \"k\") && !e.metaKey && !e.ctrlKey) {\n e.preventDefault();\n if (entityIds.length === 0) return;\n\n if (selectedEntityId === undefined) {\n const lastEntity = tableController.data[tableController.data.length - 1];\n if (lastEntity) externalOnEntityClick?.(lastEntity);\n } else {\n const currentIndex = entityIds.indexOf(selectedEntityId);\n if (currentIndex > 0) {\n const prevEntity = tableController.data[currentIndex - 1];\n if (prevEntity) externalOnEntityClick?.(prevEntity);\n }\n }\n return;\n }\n\n // n → new entity\n if (e.key === \"n\" && !e.metaKey && !e.ctrlKey && !e.altKey) {\n externalOnNewClick?.();\n e.preventDefault();\n return;\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => window.removeEventListener(\"keydown\", handleKeyDown);\n }, [selectedEntityId, handleCloseDetail, externalOnEntityClick, externalOnNewClick, entityIds, tableController.data]);\n\n const usedParentCollectionIds = parentCollectionSlugs ?? collectionRegistryController.getParentCollectionSlugs(path);\n const usedParentEntityIds = parentEntityIds ?? collectionRegistryController.getParentEntityIds(path);\n\n const isDetailVisible = animationPhase !== \"idle\";\n\n // ── Unified Layout: animated split using ResizablePanels ──\n\n const listPanel = (\n <div\n className={cls(\n \"flex flex-col h-full min-w-0 transition-all ease-out w-full\",\n (!largeLayout && isDetailVisible)\n ? \"opacity-0 -translate-x-1/3 pointer-events-none\"\n : \"opacity-100 translate-x-0\"\n )}\n style={{ transitionDuration: `${TRANSITION_DURATION}ms` }}\n >\n {/* Toolbar stays fixed above the scrollable area */}\n {toolbar}\n {/* Scrollable content: title + insights + list rows */}\n <div className=\"flex-1 overflow-y-auto overflow-x-hidden min-h-0\">\n {children}\n </div>\n </div>\n );\n\n const detailPanel = renderedEntityId !== undefined ? (\n <div\n ref={detailPanelRef}\n className={cls(\n \"flex-1 flex flex-col min-w-0 h-full transition-all ease-out w-full\",\n // The record is an object opened beside the list, so it carries\n // its own left edge — the way a card carries its hairline. The\n // resize handle between the panes is transparent; this line is\n // the record's, not a divider hanging in the gap. Side-by-side\n // only: stacked, the record has no left neighbour.\n largeLayout && \"border-l border-hairline\",\n animationPhase === \"entered\"\n ? \"opacity-100 translate-x-0\"\n : (largeLayout ? \"opacity-0 translate-x-8\" : \"opacity-0 translate-x-1/3\")\n )}\n style={{ transitionDuration: `${TRANSITION_DURATION}ms` }}\n >\n <ErrorBoundary>\n {collection.defaultEntityAction === \"view\" && !isEditMode\n ? <DetailViewBinding\n key={String(renderedEntityId)}\n path={path}\n collection={collection as AdminCollection<Record<string, unknown>>}\n entityId={renderedEntityId}\n parentCollectionSlugs={usedParentCollectionIds}\n parentEntityIds={usedParentEntityIds}\n selectedTab={selectedTab}\n layout=\"split\"\n onCloseRequest={handleCloseDetail}\n onEditClick={() => {\n navigate(buildUrl(`${path}/${renderedEntityId}/edit`));\n }}\n onTabChange={(params) => {\n const newSelectedTab = params.selectedTab;\n navigate(buildUrl(\n newSelectedTab\n ? `${path}/${renderedEntityId}/${newSelectedTab}`\n : `${path}/${renderedEntityId}`\n ));\n }}\n />\n : <EditViewBinding\n key={String(renderedEntityId)}\n path={path}\n collection={collection as AdminCollection<Record<string, unknown>>}\n entityId={renderedEntityId}\n parentCollectionSlugs={usedParentCollectionIds}\n parentEntityIds={usedParentEntityIds}\n selectedTab={selectedTab}\n layout=\"split\"\n // The ✕, and where \"save and close\" lands. A plain\n // navigation: `useNavigationBlocker` above already\n // stands between it and an unsaved edit, so the ✕ asks\n // exactly what Escape and the browser's Back ask.\n onCloseRequest={handleCloseDetail}\n onValuesModified={setDirty}\n onSaved={() => {\n setDirty(false);\n navigate(buildUrl(`${path}/${renderedEntityId}`), { replace: true });\n }}\n navigateBack={() => {\n navigate(buildUrl(`${path}/${renderedEntityId}`));\n }}\n onTabChange={(params) => {\n const newSelectedTab = params.selectedTab;\n navigate(buildUrl(\n newSelectedTab\n ? `${path}/${renderedEntityId}/${newSelectedTab}`\n : `${path}/${renderedEntityId}`\n ));\n }}\n />\n }\n </ErrorBoundary>\n </div>\n ) : <></>;\n\n // Closing the list is the full-screen entity route: the same `#full` the\n // entity pane's expand button used, so there is one way to give the record\n // the whole window and one way back out of it.\n const openFullScreen = useCallback(() => {\n if (selectedEntityId === undefined) return;\n const suffix = isEditMode ? \"/edit\" : \"\";\n navigate(`${buildUrl(`${path}/${selectedEntityId}${suffix}`)}#full`);\n }, [navigate, buildUrl, path, selectedEntityId, isEditMode]);\n\n const splitViewController = useMemo(() => ({\n detailOpen: selectedEntityId !== undefined,\n openFullScreen\n }), [selectedEntityId, openFullScreen]);\n\n return (\n <SplitViewProvider value={splitViewController}>\n <ResizablePanels\n dividerAriaLabel={t(\"resize_list\")}\n stacked={!largeLayout}\n firstPanel={listPanel}\n secondPanel={detailPanel}\n showSecondPanel={isDetailVisible}\n panelSizePercent={animationPhase === \"entering\" ? 100 : panelSize}\n onPanelSizeChange={handlePanelSizeChange}\n minPanelSizePx={240}\n />\n\n <UnsavedChangesDialog\n open={blocker?.state === \"blocked\"}\n handleOk={() => {\n dirty.current = false;\n blocker?.proceed?.();\n }}\n handleCancel={() => blocker?.reset?.()}\n body={<>You have unsaved changes in this <b>{collection.singularName ?? collection.name}</b>.</>}/>\n </SplitViewProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,IAAM,iBAAiB;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jB,aAAa,UAAU,IACqB,EAAE,MAAM;CACvE,GAAG;EAAC;EAAU;EAAU;EAAM;EAAkB;CAAU,CAAC;CAO3D,OACI,qBAAC,mBAAD;EAAmB,OANK,eAAe;GACvC,YAAY,qBAAqB,KAAA;GACjC;EACJ,IAAI,CAAC,kBAAkB,cAAc,CAGP;YAA1B,CACI,oBAAC,iBAAD;GACI,kBAAkB,EAAE,aAAa;GACjC,SAAS,CAAC;GACV,YAAY;GACZ,aAAa;GACb,iBAAiB;GACjB,kBAAkB,mBAAmB,aAAa,MAAM;GACxD,mBAAmB;GACnB,gBAAgB;EACnB,CAAA,GAED,oBAAC,sBAAD;GACI,MAAM,SAAS,UAAU;GACzB,gBAAgB;IACZ,MAAM,UAAU;IAChB,SAAS,UAAU;GACvB;GACA,oBAAoB,SAAS,QAAQ;GACrC,MAAM,qBAAA,UAAA,EAAA,UAAA;IAAE;IAAiC,oBAAC,KAAD,EAAA,UAAI,WAAW,gBAAgB,WAAW,KAAQ,CAAA;IAAC;GAAG,EAAA,CAAA;EAAG,CAAA,CACvF;;AAE3B"}
|
|
1
|
+
{"version":3,"file":"SplitListView.js","names":[],"sources":["../../../src/components/CollectionViewBinding/SplitListView.tsx"],"sourcesContent":["\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { Entity } from \"@rebasepro/types\";\nimport { CollectionSize, EntityTableController, EntitySelectionController, AdminCollection } from \"@rebasepro/cms-types\";\nimport { EditViewBinding } from \"../EditViewBinding\";\nimport { DetailViewBinding } from \"../DetailViewBinding\";\nimport {\n cls,\n isKeyHandled,\n SplitView\n} from \"@rebasepro/ui\";\nimport { UnsavedChangesDialog, useNavigationBlocker } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useNavigate, useLocation } from \"react-router\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { withListState } from \"../../util/view_mode\";\nimport { SplitViewProvider } from \"./SplitViewContext\";\n\nexport type SplitListViewProps<M extends Record<string, unknown> = Record<string, unknown>> = {\n collection: AdminCollection<M>;\n tableController: EntityTableController<M>;\n onEntityClick?: (entity: Entity<M>) => void;\n onNewClick?: () => void;\n selectionController?: EntitySelectionController<M>;\n selectionEnabled?: boolean;\n highlightedEntities?: Entity<M>[];\n emptyComponent?: React.ReactNode;\n onScroll?: (props: {\n scrollDirection: \"forward\" | \"backward\";\n scrollOffset: number;\n scrollUpdateWasRequested: boolean;\n }) => void;\n initialScroll?: number;\n size?: CollectionSize;\n path: string;\n parentCollectionSlugs?: string[], parentEntityIds?: string[];\n /**\n * The entity ID to show in the detail panel.\n * Comes from the URL path (e.g. /c/authors/14 → selectedEntityId = \"14\").\n * When undefined, no detail panel is shown.\n */\n selectedEntityId?: string | number;\n /**\n * When provided, the detail panel will open this tab (e.g. a subcollection slug).\n * Used by the router to pass the subcollection tab from the URL.\n */\n selectedTab?: string;\n /**\n * Toolbar to render above the content in the left panel.\n */\n toolbar?: React.ReactNode;\n /**\n * The collection view to render on the left side.\n */\n children: React.ReactNode;\n};\n\nconst PANEL_SIZE_KEY = \"rebase_split_list_panel_size\";\n\n/**\n * Whether the element accepts text, and therefore owns the keystroke.\n * Covers native fields plus the ARIA roles custom editors expose.\n */\nfunction isTextEntryTarget(target: HTMLElement | null): boolean {\n if (!target) return false;\n const tag = target.tagName;\n if (tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\") return true;\n if (target.isContentEditable) return true;\n return Boolean(target.closest('[contenteditable=\"true\"], [role=\"textbox\"], [role=\"combobox\"], [role=\"searchbox\"]'));\n}\n\n/**\n * Whether a bare letter shortcut may act on this target. Only the list side of\n * the split owns them — inside the detail panel a keystroke belongs to the form.\n */\nfunction isListShortcutTarget(target: HTMLElement | null, detailPanel: HTMLElement | null): boolean {\n if (!target || target === document.body) return true;\n // Focus inside a layer opened above the page — a dialog, a menu, a select\n // list — means the keystroke is that layer's. A modal traps focus, so this\n // is also what keeps a bare `j` from moving the list behind an open dialog.\n if (target.closest('[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"]')) return false;\n return !detailPanel?.contains(target);\n}\n\n/**\n * The list's share of the split, as a percentage, before anyone drags it.\n *\n * The list only has to identify a record — a title, a subtitle and a status\n * chip — while the detail beside it carries the whole record and its rail. At\n * 30% the list was taking width from the side that had four columns of fields\n * to lay out; 26% still was, by about the width of one field.\n *\n * A default, not a constraint: {@link savePanelSize} remembers the drag per\n * collection, so anyone who has already sized this list keeps their size. The\n * drag floor is `minPanelSizePx`, and it holds below ~1100px of split — at that\n * width this percentage is already the floor.\n */\nconst DEFAULT_PANEL_SIZE = 22;\n\nfunction getSavedPanelSize(path: string): number {\n try {\n const saved = localStorage.getItem(`${PANEL_SIZE_KEY}_${path}`);\n if (saved !== null) {\n const val = parseFloat(saved);\n if (!isNaN(val) && val > 0 && val < 100) return val;\n }\n } catch { /* ignore */ }\n return DEFAULT_PANEL_SIZE;\n}\n\nfunction savePanelSize(path: string, size: number) {\n try {\n localStorage.setItem(`${PANEL_SIZE_KEY}_${path}`, size.toString());\n } catch { /* ignore */ }\n}\n\n/** The list's floor while it sits beside the record: a title, a subtitle and a status chip still read. */\nconst MIN_LIST_WIDTH = 240;\n\n/**\n * Master-detail split view: the kit's {@link SplitView}, with the list as its\n * master and the record as its detail, wired to the router.\n *\n * The split follows its own width: side by side when the collection view is\n * wide, the record covering the list when it is narrow.\n *\n * Animation approach:\n * - The list always renders at full width.\n * - When a detail opens, the list shrinks to `panelSize%` and the detail slides in.\n * - On close, the reverse plays.\n *\n * State management:\n * - The selected entity is driven by the URL path (e.g. /c/authors/14).\n * `selectedEntityId` comes from props via RebaseRoute, NOT from internal state.\n * - Clicking a entity navigates to /c/authors/{id} via the standard onEntityClick handler.\n * - Closing the detail navigates back to /c/authors.\n */\nexport function SplitListView<M extends Record<string, unknown> = Record<string, unknown>>({\n collection,\n tableController,\n onEntityClick: externalOnEntityClick,\n onNewClick: externalOnNewClick,\n selectionController,\n selectionEnabled = true,\n highlightedEntities,\n emptyComponent,\n onScroll,\n initialScroll,\n size = \"m\",\n path,\n parentCollectionSlugs, parentEntityIds,\n selectedEntityId,\n selectedTab,\n toolbar,\n children\n}: SplitListViewProps<M>) {\n const collectionRegistryController = useCollectionRegistryController();\n const location = useLocation();\n const isEditMode = location.pathname.endsWith(\"/edit\") || location.pathname.split(\"/\").pop() === \"edit\";\n const navigate = useNavigate();\n const urlController = useUrlController();\n\n const showDetail = selectedEntityId !== undefined;\n\n // ── Unsaved changes ──\n // The detail form lives inside the split layout, so every way out of it\n // (Escape, j/k, clicking another row, the browser back button) is a plain\n // router navigation. A ref — not state — because the blocker predicate must\n // observe the change synchronously, before the navigation it is guarding.\n const dirty = useRef(false);\n const detailPanelRef = useRef<HTMLDivElement>(null);\n const setDirty = useCallback((modified: boolean) => {\n dirty.current = modified;\n }, []);\n\n // The form remounts per entity, so its dirty state must not leak into the\n // next one — and it has to be cleared here rather than left to the next\n // form's own first report, because that form spends the load in a skeleton\n // and a navigation during it would prompt about the record before it.\n //\n // On a *change* of record only, never on this view's own mount: a record\n // arriving from full screen carries its edit back in and opens dirty, and\n // the form says so from its first effect — which runs before this one, being\n // a child's. Clearing unconditionally overwrote that report with `false`,\n // and the way out of the split stopped asking about a live edit.\n const previousEntityId = useRef(selectedEntityId);\n useEffect(() => {\n if (previousEntityId.current === selectedEntityId) return;\n previousEntityId.current = selectedEntityId;\n dirty.current = false;\n }, [selectedEntityId]);\n\n const blocker = useNavigationBlocker(useCallback(({\n currentLocation,\n nextLocation\n }) => {\n if (!dirty.current) return false;\n if (currentLocation.pathname === nextLocation.pathname) return false;\n // Side panel overlays (e.g. following a relation) render above the form\n // and leave it mounted — nothing is lost in either direction.\n const nextHash = nextLocation.hash;\n if (nextHash === \"#side\" || nextHash === \"#new_side\") return false;\n const currentHash = currentLocation.hash;\n if (currentHash === \"#side\" || currentHash === \"#new_side\") return false;\n return true;\n }, []));\n\n // Panel size state with persistence.\n //\n // Written on drag, not on mount. An effect that saved on mount stored\n // {@link DEFAULT_PANEL_SIZE} under this collection's key the first time\n // anyone opened the split — after which the default was frozen in every\n // browser that had ever seen it, and changing it here reached nobody but a\n // new visitor. Only a size someone chose is a size worth remembering.\n const [panelSize] = useState(() => getSavedPanelSize(path));\n\n const handlePanelSizeChange = useCallback((size: number) => {\n savePanelSize(path, size);\n }, [path]);\n\n // ── Animation state ──\n // We track the \"rendered\" entity to keep the detail panel mounted during the exit animation.\n const [renderedEntityId, setRenderedEntityId] = useState<string | number | undefined>(selectedEntityId);\n const [animationPhase, setAnimationPhase] = useState<\"idle\" | \"entering\" | \"entered\" | \"exiting\">(\n selectedEntityId !== undefined ? \"entered\" : \"idle\"\n );\n const animationTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Transition duration (ms) — keep in sync with CSS\n const TRANSITION_DURATION = 150;\n\n useEffect(() => {\n if (animationTimer.current) {\n clearTimeout(animationTimer.current);\n animationTimer.current = null;\n }\n\n if (selectedEntityId !== undefined) {\n // Opening or switching entity\n setRenderedEntityId(selectedEntityId);\n if (animationPhase === \"idle\" || animationPhase === \"exiting\") {\n // Fresh open — trigger enter\n setAnimationPhase(\"entering\");\n // Use requestAnimationFrame to ensure the \"entering\" class is painted\n // before transitioning to \"entered\".\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n setAnimationPhase(\"entered\");\n });\n });\n }\n // If already entered (switching entities), keep \"entered\"\n } else {\n // Closing\n if (animationPhase === \"entered\" || animationPhase === \"entering\") {\n setAnimationPhase(\"exiting\");\n animationTimer.current = setTimeout(() => {\n setAnimationPhase(\"idle\");\n setRenderedEntityId(undefined);\n }, TRANSITION_DURATION);\n }\n }\n\n return () => {\n if (animationTimer.current) clearTimeout(animationTimer.current);\n };\n }, [selectedEntityId]); // Intentionally only depend on selectedEntityId\n\n // Build a URL below this collection, carrying the list's whole URL state —\n // view mode, search, filters and sort — the way the record was opened.\n // The list reads that state back from the URL on every navigation, so a\n // URL carrying only the view mode reset the search box and the filters\n // each time the record was closed or one of its tabs changed.\n const buildUrl = useCallback((subPath: string) => {\n return withListState(urlController.buildUrlCollectionPath(subPath));\n }, [urlController]);\n\n // Close the detail panel: navigate back to the collection path\n const handleCloseDetail = useCallback(() => {\n navigate(buildUrl(path));\n }, [navigate, buildUrl, path]);\n\n // ── Keyboard navigation ──\n const entityIds = useMemo(\n () => tableController.data.map((e: Entity<M>) => e.id),\n [tableController.data]\n );\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n const target = e.target as HTMLElement | null;\n\n // A layer above the record — a dialog, a menu, a select list, the\n // inspector — claims the key it acts on with preventDefault(). Asking\n // the DOM for an open `role=\"dialog\"` instead missed every layer that\n // is not a dialog, so Escape on an open dropdown closed the record too.\n if (isKeyHandled(e)) return;\n\n if (e.key === \"Escape\") {\n if (!selectedEntityId) return;\n // First Escape leaves the field (which may also be dismissing its\n // own dropdown), a second one closes the panel. Closing straight\n // from a focused field would discard an in-progress edit.\n if (isTextEntryTarget(target)) {\n target?.blur();\n e.preventDefault();\n return;\n }\n handleCloseDetail();\n e.preventDefault();\n return;\n }\n\n // Record navigation only belongs to the list side. Inside the detail\n // panel these keys are the form's — arrows move between fields, and a\n // bare letter is input for widgets that aren't native fields (rich\n // text, code editors, comboboxes).\n if (!isListShortcutTarget(target, detailPanelRef.current)) return;\n if (isTextEntryTarget(target)) return;\n\n // Arrow down / j → next entity\n if ((e.key === \"ArrowDown\" || e.key === \"j\") && !e.metaKey && !e.ctrlKey) {\n e.preventDefault();\n if (entityIds.length === 0) return;\n\n if (selectedEntityId === undefined) {\n const firstEntity = tableController.data[0];\n if (firstEntity) externalOnEntityClick?.(firstEntity);\n } else {\n const currentIndex = entityIds.indexOf(selectedEntityId);\n if (currentIndex >= 0 && currentIndex < entityIds.length - 1) {\n const nextEntity = tableController.data[currentIndex + 1];\n if (nextEntity) externalOnEntityClick?.(nextEntity);\n }\n }\n return;\n }\n\n // Arrow up / k → previous entity\n if ((e.key === \"ArrowUp\" || e.key === \"k\") && !e.metaKey && !e.ctrlKey) {\n e.preventDefault();\n if (entityIds.length === 0) return;\n\n if (selectedEntityId === undefined) {\n const lastEntity = tableController.data[tableController.data.length - 1];\n if (lastEntity) externalOnEntityClick?.(lastEntity);\n } else {\n const currentIndex = entityIds.indexOf(selectedEntityId);\n if (currentIndex > 0) {\n const prevEntity = tableController.data[currentIndex - 1];\n if (prevEntity) externalOnEntityClick?.(prevEntity);\n }\n }\n return;\n }\n\n // n → new entity\n if (e.key === \"n\" && !e.metaKey && !e.ctrlKey && !e.altKey) {\n externalOnNewClick?.();\n e.preventDefault();\n return;\n }\n };\n\n window.addEventListener(\"keydown\", handleKeyDown);\n return () => window.removeEventListener(\"keydown\", handleKeyDown);\n }, [selectedEntityId, handleCloseDetail, externalOnEntityClick, externalOnNewClick, entityIds, tableController.data]);\n\n const usedParentCollectionIds = parentCollectionSlugs ?? collectionRegistryController.getParentCollectionSlugs(path);\n const usedParentEntityIds = parentEntityIds ?? collectionRegistryController.getParentEntityIds(path);\n\n const isDetailVisible = animationPhase !== \"idle\";\n\n // ── Layout: the kit's SplitView ──\n // What changes with the arrangement is styled off the split's own\n // `data-layout` (`group-data-[layout=stacked]/split:`), so the classes\n // and the split always agree on which one it is.\n\n const listPanel = (\n <div className=\"flex flex-col h-full min-w-0 w-full\">\n {/* Toolbar stays fixed above the scrollable area */}\n {toolbar}\n {/* Scrollable content: title + insights + list rows */}\n <div className=\"flex-1 overflow-y-auto overflow-x-hidden min-h-0\">\n {children}\n </div>\n </div>\n );\n\n const detailPanel = renderedEntityId !== undefined ? (\n <div\n ref={detailPanelRef}\n className={cls(\n \"flex-1 flex flex-col min-w-0 h-full transition-all ease-out w-full\",\n // The record is an object opened beside the list, so it carries\n // its own left edge — the way a card carries its hairline. The\n // resize handle between the panes is transparent; this line is\n // the record's, not a divider hanging in the gap. Side-by-side\n // only: stacked, the record has no left neighbour.\n \"border-l border-hairline group-data-[layout=stacked]/split:border-l-0\",\n animationPhase === \"entered\"\n ? \"opacity-100 translate-x-0\"\n : \"opacity-0 translate-x-8 group-data-[layout=stacked]/split:translate-x-1/3\"\n )}\n style={{ transitionDuration: `${TRANSITION_DURATION}ms` }}\n >\n <ErrorBoundary>\n {collection.defaultEntityAction === \"view\" && !isEditMode\n ? <DetailViewBinding\n key={String(renderedEntityId)}\n path={path}\n collection={collection as AdminCollection<Record<string, unknown>>}\n entityId={renderedEntityId}\n parentCollectionSlugs={usedParentCollectionIds}\n parentEntityIds={usedParentEntityIds}\n selectedTab={selectedTab}\n layout=\"split\"\n onCloseRequest={handleCloseDetail}\n onEditClick={() => {\n navigate(buildUrl(`${path}/${renderedEntityId}/edit`));\n }}\n onTabChange={(params) => {\n const newSelectedTab = params.selectedTab;\n navigate(buildUrl(\n newSelectedTab\n ? `${path}/${renderedEntityId}/${newSelectedTab}`\n : `${path}/${renderedEntityId}`\n ));\n }}\n />\n : <EditViewBinding\n key={String(renderedEntityId)}\n path={path}\n collection={collection as AdminCollection<Record<string, unknown>>}\n entityId={renderedEntityId}\n parentCollectionSlugs={usedParentCollectionIds}\n parentEntityIds={usedParentEntityIds}\n selectedTab={selectedTab}\n layout=\"split\"\n // The ✕, and where \"save and close\" lands. A plain\n // navigation: `useNavigationBlocker` above already\n // stands between it and an unsaved edit, so the ✕ asks\n // exactly what Escape and the browser's Back ask.\n onCloseRequest={handleCloseDetail}\n onValuesModified={setDirty}\n onSaved={() => {\n setDirty(false);\n navigate(buildUrl(`${path}/${renderedEntityId}`), { replace: true });\n }}\n navigateBack={() => {\n navigate(buildUrl(`${path}/${renderedEntityId}`));\n }}\n onTabChange={(params) => {\n const newSelectedTab = params.selectedTab;\n navigate(buildUrl(\n newSelectedTab\n ? `${path}/${renderedEntityId}/${newSelectedTab}`\n : `${path}/${renderedEntityId}`\n ));\n }}\n />\n }\n </ErrorBoundary>\n </div>\n ) : null;\n\n // Closing the list is the full-screen entity route: the same `#full` the\n // entity pane's expand button used, so there is one way to give the record\n // the whole window and one way back out of it.\n const openFullScreen = useCallback(() => {\n if (selectedEntityId === undefined) return;\n const suffix = isEditMode ? \"/edit\" : \"\";\n navigate(`${buildUrl(`${path}/${selectedEntityId}${suffix}`)}#full`);\n }, [navigate, buildUrl, path, selectedEntityId, isEditMode]);\n\n const splitViewController = useMemo(() => ({\n detailOpen: selectedEntityId !== undefined,\n openFullScreen\n }), [selectedEntityId, openFullScreen]);\n\n return (\n <SplitViewProvider value={splitViewController}>\n <SplitView\n className=\"group/split\"\n master={listPanel}\n detail={isDetailVisible ? detailPanel : null}\n defaultMasterPercent={panelSize}\n onMasterPercentChange={handlePanelSizeChange}\n minPaneWidth={MIN_LIST_WIDTH}\n />\n\n <UnsavedChangesDialog\n open={blocker?.state === \"blocked\"}\n handleOk={() => {\n dirty.current = false;\n blocker?.proceed?.();\n }}\n handleCancel={() => blocker?.reset?.()}\n body={<>You have unsaved changes in this <b>{collection.singularName ?? collection.name}</b>.</>}/>\n </SplitViewProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA0DA,IAAM,iBAAiB;;;;;AAMvB,SAAS,kBAAkB,QAAqC;CAC5D,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,MAAM,OAAO;CACnB,IAAI,QAAQ,WAAW,QAAQ,cAAc,QAAQ,UAAU,OAAO;CACtE,IAAI,OAAO,mBAAmB,OAAO;CACrC,OAAO,QAAQ,OAAO,QAAQ,2FAAmF,CAAC;AACtH;;;;;AAMA,SAAS,qBAAqB,QAA4B,aAA0C;CAChG,IAAI,CAAC,UAAU,WAAW,SAAS,MAAM,OAAO;CAIhD,IAAI,OAAO,QAAQ,gFAAwE,GAAG,OAAO;CACrG,OAAO,CAAC,aAAa,SAAS,MAAM;AACxC;;;;;;;;;;;;;;AAeA,IAAM,qBAAqB;AAE3B,SAAS,kBAAkB,MAAsB;CAC7C,IAAI;EACA,MAAM,QAAQ,aAAa,QAAQ,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ionActionsProps, EntitySelectionController, EntityTableController } from "@rebasepro/cms-types";
|
|
3
|
+
/**
|
|
4
|
+
* What the admin's own collection actions (export, the collection editor's
|
|
5
|
+
* gear) are handed: an app's {@link CollectionActionsProps} with the view's
|
|
6
|
+
* controllers in the admin's view model, which they read records from.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export type BuiltInCollectionActionProps<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User, EC extends AdminCollection<M> = AdminCollection<M>> = Omit<CollectionActionsProps<M, USER, EC>, "selectionController" | "tableController"> & {
|
|
11
|
+
selectionController: EntitySelectionController<M>;
|
|
12
|
+
tableController: EntityTableController<M>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import type { PropertyColumnConfig } from "@rebasepro/app";
|
|
3
|
+
/**
|
|
4
|
+
* The table's columns for a view given `fields`: those columns only, in that
|
|
5
|
+
* order. `columns` were laid out with `fields` as the order, so the ones it
|
|
6
|
+
* names come first and in place; what the table appended after them — the
|
|
7
|
+
* properties `fields` leaves out — is dropped. A spread map named by its root
|
|
8
|
+
* keeps the child columns it expands into.
|
|
9
|
+
*/
|
|
10
|
+
export declare function columnsForFields(columns: PropertyColumnConfig[], fields: string[]): PropertyColumnConfig[];
|
|
11
|
+
/**
|
|
12
|
+
* The collection a list, a card or a kanban card is drawn from when the view
|
|
13
|
+
* is given `fields`: only those properties, in that order.
|
|
14
|
+
*
|
|
15
|
+
* Each of those views fills fixed places — a title, an image, a subtitle, a
|
|
16
|
+
* status chip, a date, relation chips, the list's columns — by looking through
|
|
17
|
+
* the collection's properties. Handed only the `fields`, every place picks
|
|
18
|
+
* from them, earlier ones first, and a place none of them fills stays empty.
|
|
19
|
+
* The list's columns are the `fields` the title does not take. A role the
|
|
20
|
+
* collection declares in `display` stays when it names one of the `fields`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function restrictCollectionToFields<M extends Record<string, unknown>>(collection: AdminCollection<M>, fields: string[]): AdminCollection<M>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ROW_ACTIONS_COLUMN } from "@rebasepro/app";
|
|
2
|
+
//#region src/components/CollectionViewBinding/fields.ts
|
|
3
|
+
/** The root property of a column id: `address` for `address.city`. */
|
|
4
|
+
function rootKey(key) {
|
|
5
|
+
const dot = key.indexOf(".");
|
|
6
|
+
return dot === -1 ? key : key.slice(0, dot);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The table's columns for a view given `fields`: those columns only, in that
|
|
10
|
+
* order. `columns` were laid out with `fields` as the order, so the ones it
|
|
11
|
+
* names come first and in place; what the table appended after them — the
|
|
12
|
+
* properties `fields` leaves out — is dropped. A spread map named by its root
|
|
13
|
+
* keeps the child columns it expands into.
|
|
14
|
+
*/
|
|
15
|
+
function columnsForFields(columns, fields) {
|
|
16
|
+
const named = new Set(fields);
|
|
17
|
+
return columns.filter((column) => column.key === ROW_ACTIONS_COLUMN || named.has(column.key) || named.has(rootKey(column.key)));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The collection a list, a card or a kanban card is drawn from when the view
|
|
21
|
+
* is given `fields`: only those properties, in that order.
|
|
22
|
+
*
|
|
23
|
+
* Each of those views fills fixed places — a title, an image, a subtitle, a
|
|
24
|
+
* status chip, a date, relation chips, the list's columns — by looking through
|
|
25
|
+
* the collection's properties. Handed only the `fields`, every place picks
|
|
26
|
+
* from them, earlier ones first, and a place none of them fills stays empty.
|
|
27
|
+
* The list's columns are the `fields` the title does not take. A role the
|
|
28
|
+
* collection declares in `display` stays when it names one of the `fields`.
|
|
29
|
+
*/
|
|
30
|
+
function restrictCollectionToFields(collection, fields) {
|
|
31
|
+
const keys = fields.filter((key, index) => collection.properties[key] !== void 0 && fields.indexOf(key) === index);
|
|
32
|
+
const kept = new Set(keys);
|
|
33
|
+
const properties = Object.fromEntries(keys.map((key) => [key, collection.properties[key]]));
|
|
34
|
+
const display = collection.display ? Object.fromEntries(Object.entries(collection.display).filter(([, source]) => typeof source === "string" && kept.has(rootKey(source)))) : void 0;
|
|
35
|
+
return {
|
|
36
|
+
...collection,
|
|
37
|
+
properties,
|
|
38
|
+
propertiesOrder: keys,
|
|
39
|
+
listProperties: keys,
|
|
40
|
+
previewProperties: keys,
|
|
41
|
+
display
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { columnsForFields, restrictCollectionToFields };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","names":[],"sources":["../../../src/components/CollectionViewBinding/fields.ts"],"sourcesContent":["import type { AdminCollection } from \"@rebasepro/cms-types\";\nimport type { PropertyColumnConfig } from \"@rebasepro/app\";\nimport { ROW_ACTIONS_COLUMN } from \"@rebasepro/app\";\n\n/** The root property of a column id: `address` for `address.city`. */\nfunction rootKey(key: string): string {\n const dot = key.indexOf(\".\");\n return dot === -1 ? key : key.slice(0, dot);\n}\n\n/**\n * The table's columns for a view given `fields`: those columns only, in that\n * order. `columns` were laid out with `fields` as the order, so the ones it\n * names come first and in place; what the table appended after them — the\n * properties `fields` leaves out — is dropped. A spread map named by its root\n * keeps the child columns it expands into.\n */\nexport function columnsForFields(columns: PropertyColumnConfig[], fields: string[]): PropertyColumnConfig[] {\n const named = new Set(fields);\n // `rowActions`' column is the panel's, not a field: it stays, last.\n return columns.filter(column => column.key === ROW_ACTIONS_COLUMN || named.has(column.key) || named.has(rootKey(column.key)));\n}\n\n/**\n * The collection a list, a card or a kanban card is drawn from when the view\n * is given `fields`: only those properties, in that order.\n *\n * Each of those views fills fixed places — a title, an image, a subtitle, a\n * status chip, a date, relation chips, the list's columns — by looking through\n * the collection's properties. Handed only the `fields`, every place picks\n * from them, earlier ones first, and a place none of them fills stays empty.\n * The list's columns are the `fields` the title does not take. A role the\n * collection declares in `display` stays when it names one of the `fields`.\n */\nexport function restrictCollectionToFields<M extends Record<string, unknown>>(\n collection: AdminCollection<M>,\n fields: string[]\n): AdminCollection<M> {\n const keys = fields.filter((key, index) => collection.properties[key] !== undefined && fields.indexOf(key) === index);\n const kept = new Set(keys);\n const properties = Object.fromEntries(keys.map(key => [key, collection.properties[key]]));\n const display = collection.display\n ? Object.fromEntries(Object.entries(collection.display)\n .filter(([, source]) => typeof source === \"string\" && kept.has(rootKey(source))))\n : undefined;\n return {\n ...collection,\n properties,\n propertiesOrder: keys,\n listProperties: keys,\n previewProperties: keys,\n display\n } as AdminCollection<M>;\n}\n"],"mappings":";;;AAKA,SAAS,QAAQ,KAAqB;CAClC,MAAM,MAAM,IAAI,QAAQ,GAAG;CAC3B,OAAO,QAAQ,KAAK,MAAM,IAAI,MAAM,GAAG,GAAG;AAC9C;;;;;;;;AASA,SAAgB,iBAAiB,SAAiC,QAA0C;CACxG,MAAM,QAAQ,IAAI,IAAI,MAAM;CAE5B,OAAO,QAAQ,QAAO,WAAU,OAAO,QAAQ,sBAAsB,MAAM,IAAI,OAAO,GAAG,KAAK,MAAM,IAAI,QAAQ,OAAO,GAAG,CAAC,CAAC;AAChI;;;;;;;;;;;;AAaA,SAAgB,2BACZ,YACA,QACkB;CAClB,MAAM,OAAO,OAAO,QAAQ,KAAK,UAAU,WAAW,WAAW,SAAS,KAAA,KAAa,OAAO,QAAQ,GAAG,MAAM,KAAK;CACpH,MAAM,OAAO,IAAI,IAAI,IAAI;CACzB,MAAM,aAAa,OAAO,YAAY,KAAK,KAAI,QAAO,CAAC,KAAK,WAAW,WAAW,IAAI,CAAC,CAAC;CACxF,MAAM,UAAU,WAAW,UACrB,OAAO,YAAY,OAAO,QAAQ,WAAW,OAAO,CAAC,CAClD,QAAQ,GAAG,YAAY,OAAO,WAAW,YAAY,KAAK,IAAI,QAAQ,MAAM,CAAC,CAAC,CAAC,IAClF,KAAA;CACN,OAAO;EACH,GAAG;EACH;EACA,iBAAiB;EACjB,gBAAgB;EAChB,mBAAmB;EACnB;CACJ;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { CollectionWindow, getRelationIncludeParams, useData, useRebaseContext } from "@rebasepro/app";
|
|
2
|
+
import { CollectionWindow, copyRow, fromWireRow, getRelationIncludeParams, toWireRow, useData, useDataChangeVersion, useRebaseContext } from "@rebasepro/app";
|
|
3
3
|
//#region src/components/CollectionViewBinding/useBoardDataController.tsx
|
|
4
4
|
var DEFAULT_PAGE_SIZE$1 = 20;
|
|
5
5
|
/**
|
|
@@ -85,7 +85,8 @@ function useBoardDataController({ fullPath, collection, columnProperty, columns,
|
|
|
85
85
|
orderProperty,
|
|
86
86
|
searchString,
|
|
87
87
|
filterKey,
|
|
88
|
-
pageSize
|
|
88
|
+
pageSize,
|
|
89
|
+
useDataChangeVersion(resolvedPath, !dataClient.collection(resolvedPath).listen)
|
|
89
90
|
]);
|
|
90
91
|
useEffect(() => {
|
|
91
92
|
return () => {
|
|
@@ -193,18 +194,16 @@ function useBoardDataController({ fullPath, collection, columnProperty, columns,
|
|
|
193
194
|
});
|
|
194
195
|
if (currentCollection.browserCallbacks?.afterRead) try {
|
|
195
196
|
processed = await Promise.all(processed.map(async (entity) => {
|
|
197
|
+
const row = toWireRow(entity.values, currentCollection);
|
|
196
198
|
const processedRow = await currentCollection.browserCallbacks.afterRead({
|
|
197
199
|
collection: currentCollection,
|
|
198
200
|
path: currentResolvedPath,
|
|
199
|
-
row:
|
|
200
|
-
id: entity.id,
|
|
201
|
-
...entity.values
|
|
202
|
-
},
|
|
201
|
+
row: copyRow(row),
|
|
203
202
|
context: currentContext
|
|
204
203
|
});
|
|
205
204
|
return {
|
|
206
205
|
...entity,
|
|
207
|
-
values: processedRow
|
|
206
|
+
values: fromWireRow(entity.values, row, processedRow, currentCollection, currentResolvedPath)
|
|
208
207
|
};
|
|
209
208
|
}));
|
|
210
209
|
} catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBoardDataController.js","names":[],"sources":["../../../src/components/CollectionViewBinding/useBoardDataController.tsx"],"sourcesContent":["\nimport { Entity, FilterValues } from \"@rebasepro/types\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { CollectionWindow, CollectionWindowState, getRelationIncludeParams, useData, useRebaseContext } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nconst DEFAULT_PAGE_SIZE = 20;\n\n/**\n * How long a column waits for its subscription's first payload before reading\n * once over HTTP instead. Long enough that a healthy socket always wins the\n * race, short enough that a dead one does not hold a blank board.\n */\nconst LIVE_FIRST_PAINT_TIMEOUT_MS = 2500;\n\n/**\n * Shallow equality for entity value records.\n * Handles primitives and reference equality for nested values.\n * Avoids JSON.stringify allocation on every comparison.\n */\nfunction shallowEqualValues(\n a: Record<string, unknown> | undefined,\n b: Record<string, unknown> | undefined\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n if (a[key] !== b[key]) return false;\n }\n return true;\n}\n\n/**\n * Data state for a single board column\n */\nexport interface BoardColumnData<M extends Record<string, unknown> = Record<string, unknown>> {\n /** Entities loaded for this column */\n entities: Entity<M>[];\n /** Whether the column is currently loading data */\n loading: boolean;\n /** Whether there are more items to load */\n hasMore: boolean;\n /** Error if loading failed */\n error?: Error;\n /** Total count of entities in this column */\n totalCount?: number;\n}\n\n/**\n * Controller for managing per-column data in a Kanban board\n */\nexport interface BoardDataController<M extends Record<string, unknown> = any, COLUMN extends string = string> {\n /** Data state for each column */\n columnData: Record<COLUMN, BoardColumnData<M>>;\n /** Load more items for a specific column */\n loadMoreColumn: (column: COLUMN) => void;\n /** Refresh data for a specific column */\n refreshColumn: (column: COLUMN) => void;\n /** Refresh all columns */\n refreshAll: () => void;\n /** Update column counts and optionally move item optimistically */\n moveItemOptimistically: (itemId: string, sourceColumn: COLUMN, targetColumn: COLUMN, newValues?: Record<string, any>, newIndex?: number) => void;\n /** Decrement column counts (for optimistic updates when deleting items) */\n decrementColumnCounts: (columnDeltas: Record<COLUMN, number>) => void;\n /** Whether any column is loading */\n loading: boolean;\n /** Any error from any column */\n error?: Error;\n}\n\nexport interface UseBoardDataControllerProps<M extends Record<string, unknown> = Record<string, unknown>> {\n /** Full path to the collection */\n fullPath: string;\n /** The entity collection configuration */\n collection: AdminCollection<M>;\n /** Property key used for column assignment */\n columnProperty: string;\n /** Array of column values (enum values from columnProperty) */\n columns: string[];\n /** Property key used for ordering within columns */\n orderProperty?: string;\n /** Number of items to load per page per column */\n pageSize?: number;\n /** Text search string to filter entities */\n searchString?: string;\n /** Additional filter values */\n filterValues?: FilterValues<string>;\n}\n\n/**\n * Hook that manages per-column data loading for the Kanban board.\n * Each column gets its own independent query to the data source.\n */\nexport function useBoardDataController<M extends Record<string, unknown> = any, COLUMN extends string = string>({\n fullPath,\n collection,\n columnProperty,\n columns,\n orderProperty,\n pageSize = DEFAULT_PAGE_SIZE,\n searchString,\n filterValues\n}: UseBoardDataControllerProps<M>): BoardDataController<M, COLUMN> {\n\n const context = useRebaseContext();\n const dataClient = useData();\n // v4: use fullPath directly instead of resolveIdsFrom\n const resolvedPath = fullPath;\n\n // Stable refs for objects that shouldn't trigger re-subscriptions\n const dataClientRef = useRef(dataClient);\n const collectionRef = useRef(collection);\n const contextRef = useRef(context);\n dataClientRef.current = dataClient;\n collectionRef.current = collection;\n contextRef.current = context;\n\n // Store filter/order params in refs so they're accessible without causing re-subscriptions\n const filterValuesRef = useRef(filterValues);\n const columnPropertyRef = useRef(columnProperty);\n const orderPropertyRef = useRef(orderProperty);\n const searchStringRef = useRef(searchString);\n const resolvedPathRef = useRef(resolvedPath);\n const pageSizeRef = useRef(pageSize);\n pageSizeRef.current = pageSize;\n filterValuesRef.current = filterValues;\n columnPropertyRef.current = columnProperty;\n orderPropertyRef.current = orderProperty;\n searchStringRef.current = searchString;\n resolvedPathRef.current = resolvedPath;\n\n // Track item count per column for pagination\n const [columnItemCounts, setColumnItemCounts] = useState<Record<string, number>>(() => {\n const initial: Record<string, number> = {};\n columns.forEach(col => {\n initial[col] = pageSize;\n });\n return initial;\n });\n\n // Per-column data state\n const [columnData, setColumnData] = useState<Record<string, BoardColumnData<M>>>(() => {\n const initial: Record<string, BoardColumnData<M>> = {};\n columns.forEach(col => {\n initial[col] = {\n entities: [],\n loading: true,\n hasMore: true,\n error: undefined,\n totalCount: undefined\n };\n });\n return initial;\n });\n\n // Track cleanup functions for subscriptions\n const unsubscribersRef = useRef<Record<string, () => void>>({});\n\n // Each column's rows, read a page at a time — see `CollectionWindow`.\n const windowsRef = useRef<Record<string, CollectionWindow<Record<string, unknown>>>>({});\n\n // Flag to prevent race conditions during cleanup\n const isCleaningUpRef = useRef(false);\n\n // Track items that are currently in an optimistic state (awaiting DB sync)\n const pendingItemsRef = useRef<Record<string, { entity: Entity<M>, expectedValues: Record<string, any> }>>({});\n\n // Stable keys for dependency comparison\n const columnsKey = useMemo(() => [...columns].sort().join(\",\"), [columns]);\n const filterKey = useMemo(() => JSON.stringify(filterValues), [filterValues]);\n\n // Track previous column item counts to detect which column changed\n const prevColumnItemCountsRef = useRef<Record<string, number>>(columnItemCounts);\n\n // Version counter to trigger full re-subscription when params change (not just load-more)\n const [subscriptionVersion, setSubscriptionVersion] = useState(0);\n\n // Trigger full re-subscription when key params change\n useEffect(() => {\n setSubscriptionVersion(v => v + 1);\n }, [columnsKey, resolvedPath, columnProperty, orderProperty, searchString, filterKey, pageSize]);\n\n // Cleanup subscriptions on unmount\n useEffect(() => {\n return () => {\n isCleaningUpRef.current = true;\n Object.values(unsubscribersRef.current).forEach(unsub => unsub?.());\n unsubscribersRef.current = {};\n };\n }, []);\n\n /**\n * Check if a column value is excluded by the active filter on the columnProperty.\n * E.g. if the user sets \"Status IN (Open, In Progress)\", this returns true\n * for \"Waiting on Customer\" since that column should show as empty.\n */\n const isColumnExcludedByFilter = useCallback((column: string, filterValues?: FilterValues<string>, colProperty?: string): boolean => {\n if (!filterValues || !colProperty) return false;\n const filterForColumn = filterValues[colProperty as keyof typeof filterValues];\n if (!filterForColumn || !Array.isArray(filterForColumn)) return false;\n\n const [op, val] = filterForColumn as [string, unknown];\n\n if (op === \"==\" && typeof val === \"string\") {\n return column !== val;\n }\n if (op === \"!=\" && typeof val === \"string\") {\n return column === val;\n }\n if (op === \"in\" && Array.isArray(val)) {\n return !val.map(String).includes(column);\n }\n if (op === \"not-in\" && Array.isArray(val)) {\n return val.map(String).includes(column);\n }\n\n return false;\n }, []);\n\n // Helper function to subscribe to a single column - uses refs to avoid dependency issues\n const subscribeToColumn = useCallback((column: string, itemCount: number) => {\n // Skip if we're in the middle of cleanup\n if (isCleaningUpRef.current) return;\n\n const currentDataClient = dataClientRef.current;\n const currentCollection = collectionRef.current;\n const currentContext = contextRef.current;\n const currentFilterValues = filterValuesRef.current;\n const currentColumnProperty = columnPropertyRef.current;\n const currentOrderProperty = orderPropertyRef.current;\n const currentSearchString = searchStringRef.current;\n const currentResolvedPath = resolvedPathRef.current;\n\n // If the column is excluded by the active filter on the column property,\n // set it as empty immediately without querying.\n const excluded = isColumnExcludedByFilter(column, currentFilterValues, currentColumnProperty);\n if (excluded) {\n setColumnData(prev => ({\n ...prev,\n [column]: {\n entities: [],\n loading: false,\n hasMore: false,\n error: undefined,\n totalCount: 0\n }\n }));\n return;\n }\n\n // Build filter map for this column — pass FilterValues directly\n const whereFilter: FilterValues<string> = {\n ...(currentFilterValues ?? {}),\n [currentColumnProperty]: [\"==\", column]\n };\n\n const orderByParam: [string, \"asc\" | \"desc\"] | undefined = currentOrderProperty ? [currentOrderProperty, \"asc\"] : undefined;\n\n // Whether this subscription is still the column's current one. Every\n // answer — live, fallback or one-shot — checks it before it paints:\n // a read issued for the previous search, or for the page size before a\n // load-more, can resolve after the one that replaced it, and it would\n // otherwise overwrite the newer rows. `isCleaningUpRef` cannot say\n // this: it is one flag for the whole board, and the next subscription\n // sets it straight back to false.\n let active = true;\n const isCurrent = () => active && !isCleaningUpRef.current;\n // `afterRead` below is awaited, so two answers can finish out of\n // order; only the latest one paints.\n let updateSequence = 0;\n\n // Mark column as loading\n setColumnData(prev => ({\n ...prev,\n [column]: {\n ...prev[column],\n loading: true,\n error: undefined\n }\n }));\n\n // onUpdate callback\n const onUpdate = async (entities: Entity<M>[], state: Omit<CollectionWindowState, \"rows\">) => {\n if (!isCurrent()) return;\n const sequence = ++updateSequence;\n\n const pendingMap = pendingItemsRef.current;\n\n // Apply pending updates to incoming entities\n const mergedEntities = entities.map(e => {\n const pending = pendingMap[String(e.id)];\n if (pending) {\n // Check if DB entity has caught up to the expected column and order\n const expectedCol = pending.expectedValues[currentColumnProperty];\n const expectedOrder = currentOrderProperty ? pending.expectedValues[currentOrderProperty] : undefined;\n\n let caughtUp = true;\n if (e.values?.[currentColumnProperty] !== expectedCol) {\n caughtUp = false;\n }\n if (currentOrderProperty && e.values?.[currentOrderProperty] !== expectedOrder) {\n caughtUp = false;\n }\n\n if (caughtUp) {\n // DB has caught up, clear pending state\n delete pendingMap[String(e.id)];\n return e; // Use the real DB entity\n }\n\n // DB hasn't caught up, overlay expected values\n return { ...e,\nvalues: { ...e.values,\n...pending.expectedValues } };\n }\n return e;\n });\n\n // Add any pending items that belong to this column but aren't in the incoming entities yet\n // (e.g. backend hasn't moved them to this column yet)\n Object.values(pendingMap).forEach(pending => {\n if (pending.expectedValues[currentColumnProperty] === column) {\n if (!mergedEntities.some(e => String(e.id) === String(pending.entity.id))) {\n mergedEntities.push(pending.entity);\n }\n }\n });\n\n // Always filter in memory to only show entities that belong to this specific column.\n // This is required because text search returns all matches, and the overlay above\n // moves a card dragged out of this column to its new one before the server has.\n let processed = mergedEntities.filter(e => e.values?.[currentColumnProperty] === column);\n\n // Sort locally if orderProperty is defined: pending cards are appended above, and\n // the overlay can change a card's order key, so the order the rows arrived in is\n // not the order to show.\n if (currentOrderProperty) {\n processed = [...processed].sort((a, b) => {\n const valA = a.values?.[currentOrderProperty] as string | undefined | null;\n const valB = b.values?.[currentOrderProperty] as string | undefined | null;\n\n const isAEmpty = valA === undefined || valA === null || valA === \"\";\n const isBEmpty = valB === undefined || valB === null || valB === \"\";\n\n if (isAEmpty && isBEmpty) return 0;\n if (isAEmpty) return 1;\n if (isBEmpty) return -1;\n\n return valA < valB ? -1 : valA > valB ? 1 : 0;\n });\n }\n\n // Apply the panel's own afterRead callbacks if any — `browserCallbacks`,\n // not `callbacks`: the latter already ran on the server before these\n // rows arrived, and running it again here applied it twice.\n // afterRead operates on flat rows; unwrap the Entity view-model\n // before invoking and re-wrap the processed row after.\n if (currentCollection.browserCallbacks?.afterRead) {\n try {\n processed = await Promise.all(\n processed.map(async (entity) => {\n const processedRow = await currentCollection.browserCallbacks!.afterRead!({\n collection: currentCollection,\n path: currentResolvedPath,\n row: { id: entity.id, ...entity.values },\n context: currentContext\n });\n return {\n ...entity,\n values: processedRow as M\n };\n })\n );\n } catch (e) {\n console.error(\"Error in afterRead callback:\", e);\n }\n }\n\n // `afterRead` above is awaited; the subscription may have been\n // replaced in the meantime.\n if (!isCurrent() || sequence !== updateSequence) return;\n\n // More exists until a page comes back short — never \"the rows\n // asked for did not all fit under the read ceiling\". A column\n // whose next page failed stops asking, rather than retrying on\n // every scroll.\n const newHasMore = !state.complete && !state.error;\n\n // Compare with current state — skip update if identical to avoid UI flash\n setColumnData(prev => {\n const existing = prev[column];\n if (existing && !existing.loading && existing.entities.length === processed.length) {\n // Quick structural equality check: same IDs in same order with same values\n let identical = true;\n for (let i = 0; i < processed.length; i++) {\n const a = existing.entities[i];\n const b = processed[i];\n if (a.id !== b.id) {\n identical = false;\n break;\n }\n // Shallow-compare values to avoid JSON.stringify allocations\n // entity.values are flat records from the DB, so shallow suffices\n if (!shallowEqualValues(a.values, b.values)) {\n identical = false;\n break;\n }\n }\n if (identical && existing.hasMore === newHasMore && !state.loading && existing.error === state.error) {\n // Data is the same — return previous reference to prevent re-render\n return prev;\n }\n }\n\n return {\n ...prev,\n [column]: {\n entities: processed,\n loading: state.loading,\n hasMore: newHasMore,\n error: state.error,\n totalCount: prev[column]?.totalCount // Keep existing count\n }\n };\n });\n };\n\n const accessor = currentDataClient.collection(currentResolvedPath);\n\n // Eagerly include relations to avoid N+1 fetches.\n const includeParams = getRelationIncludeParams(currentCollection);\n\n // The column's first page is live; every later page is read by\n // offset, only past the rows already held, and never above the API's\n // read ceiling. The column used to grow one read instead and clamp it\n // at that ceiling, so it said it was finished at 1,000 cards while its\n // own header counted thousands more.\n const collectionWindow = new CollectionWindow({\n accessor,\n query: {\n where: whereFilter,\n orderBy: orderByParam,\n include: includeParams,\n // Read into a local at the top of this function and then used\n // nowhere, in both places it was read. The board took a search\n // term, re-subscribed every column when it changed, and\n // returned the same rows.\n searchString: currentSearchString\n },\n pageSize: pageSizeRef.current,\n target: itemCount,\n // A live subscription that fails is not the same thing as a column\n // with nothing in it, but that is exactly what this used to render:\n // entities cleared, no error surfaced, and a column reading \"No\n // items\" above a header still counting eleven of them. Read once\n // over HTTP instead — the board loses its live updates, not its\n // contents — and only report the failure if that fails too.\n fallbackToFind: true,\n // A subscription that is never going to answer takes the client's\n // full 30s watchdog to say so, and the board spins the whole time.\n // If the socket has not delivered shortly after mount, read once\n // over HTTP and paint that; the live data still wins whenever it\n // arrives. Costs nothing when realtime is healthy.\n firstPaintTimeoutMs: LIVE_FIRST_PAINT_TIMEOUT_MS,\n onChange: (state) => {\n if (!isCurrent()) return;\n if (state.rows) {\n void onUpdate(state.rows as Entity<M>[], state);\n return;\n }\n if (state.error) {\n console.error(`Error loading column ${column}:`, state.error);\n setColumnData(prev => ({\n ...prev,\n [column]: {\n ...prev[column],\n entities: prev[column]?.entities ?? [],\n loading: false,\n hasMore: false,\n error: state.error\n }\n }));\n }\n }\n });\n windowsRef.current[column] = collectionWindow;\n unsubscribersRef.current[column] = () => {\n active = false;\n collectionWindow.dispose();\n if (windowsRef.current[column] === collectionWindow) delete windowsRef.current[column];\n };\n collectionWindow.start();\n }, []); // No dependencies - uses refs for all values\n\n // Main effect for all column subscriptions - runs when subscriptionVersion changes (i.e., key params change)\n useEffect(() => {\n // Mark that we're setting up new subscriptions\n isCleaningUpRef.current = false;\n\n // Clean up all existing subscriptions synchronously\n const existingUnsubscribers = { ...unsubscribersRef.current };\n unsubscribersRef.current = {};\n Object.values(existingUnsubscribers).forEach(unsub => {\n try {\n unsub?.();\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n\n const currentDataClient = dataClientRef.current;\n const currentCollection = collectionRef.current;\n const currentFilterValues = filterValuesRef.current;\n const currentColumnProperty = columnPropertyRef.current;\n const currentSearchString = searchStringRef.current;\n const currentResolvedPath = resolvedPathRef.current;\n const currentColumns = columns;\n const currentColumnItemCounts = columnItemCounts;\n\n // Set by this run's cleanup, so a count issued for the previous search\n // or filter cannot land after the one that replaced it.\n let cancelled = false;\n\n // Small delay to ensure Firestore has cleaned up previous listeners\n const timeoutId = setTimeout(() => {\n if (isCleaningUpRef.current) return;\n\n currentColumns.forEach(column => {\n const itemCount = currentColumnItemCounts[column] ?? pageSize;\n subscribeToColumn(column, itemCount);\n\n // Skip count query for columns excluded by the filter — subscribeToColumn\n // already set them to totalCount: 0.\n if (isColumnExcludedByFilter(column, currentFilterValues, currentColumnProperty)) {\n return;\n }\n\n // Count query for column (for display in column header)\n const accessor = currentDataClient.collection(currentResolvedPath);\n if (accessor.count) {\n\n const whereFilter: FilterValues<string> = {\n ...(currentFilterValues ?? {}),\n [currentColumnProperty]: [\"==\", column]\n };\n\n accessor.count({\n where: whereFilter,\n // Or the column header counts the unsearched collection\n // while the column beneath it shows searched rows.\n searchString: currentSearchString\n }).then(count => {\n if (cancelled || isCleaningUpRef.current) return;\n setColumnData(prev => ({\n ...prev,\n [column]: {\n ...prev[column],\n totalCount: count\n }\n }));\n }).catch(e => {\n console.warn(`Failed to get count for column ${column}:`, e);\n });\n }\n });\n\n // Update the ref after subscribing all\n prevColumnItemCountsRef.current = { ...currentColumnItemCounts };\n }, 0);\n\n return () => {\n cancelled = true;\n clearTimeout(timeoutId);\n isCleaningUpRef.current = true;\n const unsubscribers = { ...unsubscribersRef.current };\n unsubscribersRef.current = {};\n Object.values(unsubscribers).forEach(unsub => {\n try {\n unsub?.();\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n };\n\n }, [subscriptionVersion, subscribeToColumn, pageSize]);\n\n // Track which subscription version last updated the counts\n const lastProcessedVersionRef = useRef(subscriptionVersion);\n\n // Separate effect to handle individual column load-more WITHOUT triggering full re-subscription\n useEffect(() => {\n // If subscriptionVersion changed, the main effect will handle everything\n // Skip this effect to avoid race conditions\n if (subscriptionVersion !== lastProcessedVersionRef.current) {\n lastProcessedVersionRef.current = subscriptionVersion;\n prevColumnItemCountsRef.current = { ...columnItemCounts };\n return;\n }\n\n const prevCounts = prevColumnItemCountsRef.current;\n\n columns.forEach(column => {\n const prevCount = prevCounts[column] ?? pageSize;\n const newCount = columnItemCounts[column] ?? pageSize;\n\n // Only this column asked for more: its window reads the next page,\n // and nothing it already holds is read again.\n if (newCount > prevCount && !isCleaningUpRef.current) {\n windowsRef.current[column]?.setTarget(newCount);\n }\n });\n\n // Update the ref\n prevColumnItemCountsRef.current = { ...columnItemCounts };\n }, [columnItemCounts, columns, pageSize, subscribeToColumn, subscriptionVersion]);\n\n const loadMoreColumn = useCallback((column: COLUMN) => {\n setColumnItemCounts(prev => ({\n ...prev,\n [column]: (prev[column] ?? pageSize) + pageSize\n }));\n }, [pageSize]);\n\n /**\n * Drop the optimistic overlay for the moves matching `predicate`.\n *\n * An entry is otherwise released only when the database \"catches up\" to\n * it, which a refused write never does: the card would stay where it was\n * dropped, on top of whatever the database re-delivers. A refresh is a\n * request for what the database says, so it lets go of them.\n */\n const dropPendingMoves = useCallback((predicate: (expectedValues: Record<string, any>) => boolean) => {\n const pendingMap = pendingItemsRef.current;\n for (const [id, pending] of Object.entries(pendingMap)) {\n if (predicate(pending.expectedValues)) delete pendingMap[id];\n }\n }, []);\n\n const refreshColumn = useCallback((column: COLUMN) => {\n dropPendingMoves(expected => expected[columnPropertyRef.current] === column);\n // Back to one page, and re-subscribed here: the load-more effect only\n // re-subscribes a column whose count went *up*, so resetting the count\n // alone reached nothing.\n setColumnItemCounts(prev => ({\n ...prev,\n [column]: pageSize\n }));\n prevColumnItemCountsRef.current = { ...prevColumnItemCountsRef.current, [column]: pageSize };\n const unsubscribe = unsubscribersRef.current[column];\n delete unsubscribersRef.current[column];\n try {\n unsubscribe?.();\n } catch (e) {\n // Ignore cleanup errors\n }\n setTimeout(() => {\n if (!isCleaningUpRef.current) {\n subscribeToColumn(column, pageSize);\n }\n }, 0);\n }, [pageSize, subscribeToColumn, dropPendingMoves]);\n\n const refreshAll = useCallback(() => {\n dropPendingMoves(() => true);\n const reset: Record<string, number> = {};\n columns.forEach(col => {\n reset[col] = pageSize;\n });\n setColumnItemCounts(reset);\n // A new subscription version re-subscribes and re-counts every column.\n setSubscriptionVersion(v => v + 1);\n }, [columns, pageSize, dropPendingMoves]);\n\n // Optimistic update for when moving an item\n const moveItemOptimistically = useCallback((itemId: string, sourceColumn: COLUMN, targetColumn: COLUMN, newValues?: Record<string, any>, newIndex?: number) => {\n setColumnData(prev => {\n const updated = { ...prev };\n let itemToMove: Entity<M> | undefined;\n\n const sourceEntities = [...(updated[sourceColumn]?.entities || [])];\n const itemIndex = sourceEntities.findIndex(e => String(e.id) === itemId);\n\n if (itemIndex !== -1) {\n itemToMove = sourceEntities[itemIndex];\n sourceEntities.splice(itemIndex, 1);\n }\n\n if (itemToMove) {\n const newValuesMerged = {\n ...itemToMove.values,\n ...(newValues || {})\n };\n\n const updatedEntity = {\n ...itemToMove,\n values: newValuesMerged\n };\n\n // Store in pending items ref\n pendingItemsRef.current[String(updatedEntity.id)] = {\n entity: updatedEntity,\n expectedValues: newValuesMerged\n };\n\n const targetEntities = sourceColumn === targetColumn ? sourceEntities : [...(updated[targetColumn]?.entities || [])];\n\n if (newIndex !== undefined && newIndex >= 0 && newIndex <= targetEntities.length) {\n targetEntities.splice(newIndex, 0, updatedEntity);\n } else {\n targetEntities.push(updatedEntity);\n if (orderPropertyRef.current) {\n const orderProp = orderPropertyRef.current;\n targetEntities.sort((a, b) => {\n const valA = a.values?.[orderProp] as string | undefined | null;\n const valB = b.values?.[orderProp] as string | undefined | null;\n\n // Handle nulls/empty strings to match Postgres NULLS LAST (ASC) behavior\n const isAEmpty = valA === undefined || valA === null || valA === \"\";\n const isBEmpty = valB === undefined || valB === null || valB === \"\";\n\n if (isAEmpty && isBEmpty) return 0;\n if (isAEmpty) return 1; // A is null, B is not -> A goes after B\n if (isBEmpty) return -1; // B is null, A is not -> A goes before B\n\n return valA < valB ? -1 : valA > valB ? 1 : 0;\n });\n }\n }\n\n updated[sourceColumn] = {\n ...updated[sourceColumn],\n entities: sourceColumn === targetColumn ? targetEntities : sourceEntities,\n totalCount: sourceColumn === targetColumn\n ? updated[sourceColumn].totalCount\n : Math.max(0, (updated[sourceColumn].totalCount ?? 0) - 1)\n };\n\n if (sourceColumn !== targetColumn) {\n updated[targetColumn] = {\n ...updated[targetColumn],\n entities: targetEntities,\n totalCount: (updated[targetColumn].totalCount ?? 0) + 1\n };\n }\n\n } else if (sourceColumn !== targetColumn) {\n // If item not found locally but counts need update\n if (updated[sourceColumn]?.totalCount !== undefined) {\n updated[sourceColumn] = {\n ...updated[sourceColumn],\n totalCount: Math.max(0, (updated[sourceColumn].totalCount ?? 0) - 1)\n };\n }\n if (updated[targetColumn]?.totalCount !== undefined) {\n updated[targetColumn] = {\n ...updated[targetColumn],\n totalCount: (updated[targetColumn].totalCount ?? 0) + 1\n };\n }\n }\n\n return updated;\n });\n }, []);\n\n // Optimistic update for column counts when deleting items\n const decrementColumnCounts = useCallback((columnDeltas: Record<COLUMN, number>) => {\n setColumnData(prev => {\n const updated = { ...prev };\n\n for (const [column, delta] of Object.entries(columnDeltas) as [COLUMN, number][]) {\n if (updated[column]?.totalCount !== undefined) {\n updated[column] = {\n ...updated[column],\n totalCount: Math.max(0, (updated[column].totalCount ?? 0) - delta)\n };\n }\n }\n\n return updated;\n });\n }, []);\n\n // Aggregate loading and error state\n const loading = useMemo(() => {\n return Object.values(columnData).some((col) => col.loading);\n }, [columnData]);\n\n const error = useMemo(() => {\n const errors = Object.values(columnData)\n .map((col) => col.error)\n .filter(Boolean);\n return errors[0];\n }, [columnData]);\n\n return useMemo(() => ({\n columnData: columnData as Record<COLUMN, BoardColumnData<M>>,\n loadMoreColumn,\n refreshColumn,\n refreshAll,\n moveItemOptimistically,\n decrementColumnCounts,\n loading,\n error\n }), [\n columnData,\n loadMoreColumn,\n refreshColumn,\n refreshAll,\n moveItemOptimistically,\n decrementColumnCounts,\n loading,\n error\n ]);\n}\n"],"mappings":";;;AAMA,IAAM,sBAAoB;;;;;;AAO1B,IAAM,8BAA8B;;;;;;AAOpC,SAAS,mBACL,GACA,GACO;CACP,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,MAAM,QAAQ,OAAO,KAAK,CAAC;CAC3B,MAAM,QAAQ,OAAO,KAAK,CAAC;CAC3B,IAAI,MAAM,WAAW,MAAM,QAAQ,OAAO;CAC1C,KAAK,MAAM,OAAO,OACd,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;CAElC,OAAO;AACX;;;;;AA+DA,SAAgB,uBAAgG,EAC5G,UACA,YACA,gBACA,SACA,eACA,WAAW,qBACX,cACA,gBAC+D;CAE/D,MAAM,UAAU,iBAAiB;CACjC,MAAM,aAAa,QAAQ;CAE3B,MAAM,eAAe;CAGrB,MAAM,gBAAgB,OAAO,UAAU;CACvC,MAAM,gBAAgB,OAAO,UAAU;CACvC,MAAM,aAAa,OAAO,OAAO;CACjC,cAAc,UAAU;CACxB,cAAc,UAAU;CACxB,WAAW,UAAU;CAGrB,MAAM,kBAAkB,OAAO,YAAY;CAC3C,MA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UAAU,CAAC,CAAC,MAAM,QAAQ,IAAI,OAAO;CAC9D,GAAG,CAAC,UAAU,CAAC;CAEf,MAAM,QAAQ,cAAc;EAIxB,OAHe,OAAO,OAAO,UAAU,CAAC,CACnC,KAAK,QAAQ,IAAI,KAAK,CAAC,CACvB,OAAO,OACL,CAAA,CAAO;CAClB,GAAG,CAAC,UAAU,CAAC;CAEf,OAAO,eAAe;EACN;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IAAI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL"}
|
|
1
|
+
{"version":3,"file":"useBoardDataController.js","names":[],"sources":["../../../src/components/CollectionViewBinding/useBoardDataController.tsx"],"sourcesContent":["\nimport { Entity, FilterValues } from \"@rebasepro/types\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { CollectionWindow, CollectionWindowState, copyRow, fromWireRow, getRelationIncludeParams, toWireRow, useData, useDataChangeVersion, useRebaseContext } from \"@rebasepro/app\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nconst DEFAULT_PAGE_SIZE = 20;\n\n/**\n * How long a column waits for its subscription's first payload before reading\n * once over HTTP instead. Long enough that a healthy socket always wins the\n * race, short enough that a dead one does not hold a blank board.\n */\nconst LIVE_FIRST_PAINT_TIMEOUT_MS = 2500;\n\n/**\n * Shallow equality for entity value records.\n * Handles primitives and reference equality for nested values.\n * Avoids JSON.stringify allocation on every comparison.\n */\nfunction shallowEqualValues(\n a: Record<string, unknown> | undefined,\n b: Record<string, unknown> | undefined\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n if (keysA.length !== keysB.length) return false;\n for (const key of keysA) {\n if (a[key] !== b[key]) return false;\n }\n return true;\n}\n\n/**\n * Data state for a single board column\n */\nexport interface BoardColumnData<M extends Record<string, unknown> = Record<string, unknown>> {\n /** Entities loaded for this column */\n entities: Entity<M>[];\n /** Whether the column is currently loading data */\n loading: boolean;\n /** Whether there are more items to load */\n hasMore: boolean;\n /** Error if loading failed */\n error?: Error;\n /** Total count of entities in this column */\n totalCount?: number;\n}\n\n/**\n * Controller for managing per-column data in a Kanban board\n */\nexport interface BoardDataController<M extends Record<string, unknown> = any, COLUMN extends string = string> {\n /** Data state for each column */\n columnData: Record<COLUMN, BoardColumnData<M>>;\n /** Load more items for a specific column */\n loadMoreColumn: (column: COLUMN) => void;\n /** Refresh data for a specific column */\n refreshColumn: (column: COLUMN) => void;\n /** Refresh all columns */\n refreshAll: () => void;\n /** Update column counts and optionally move item optimistically */\n moveItemOptimistically: (itemId: string, sourceColumn: COLUMN, targetColumn: COLUMN, newValues?: Record<string, any>, newIndex?: number) => void;\n /** Decrement column counts (for optimistic updates when deleting items) */\n decrementColumnCounts: (columnDeltas: Record<COLUMN, number>) => void;\n /** Whether any column is loading */\n loading: boolean;\n /** Any error from any column */\n error?: Error;\n}\n\nexport interface UseBoardDataControllerProps<M extends Record<string, unknown> = Record<string, unknown>> {\n /** Full path to the collection */\n fullPath: string;\n /** The entity collection configuration */\n collection: AdminCollection<M>;\n /** Property key used for column assignment */\n columnProperty: string;\n /** Array of column values (enum values from columnProperty) */\n columns: string[];\n /** Property key used for ordering within columns */\n orderProperty?: string;\n /** Number of items to load per page per column */\n pageSize?: number;\n /** Text search string to filter entities */\n searchString?: string;\n /** Additional filter values */\n filterValues?: FilterValues<string>;\n}\n\n/**\n * Hook that manages per-column data loading for the Kanban board.\n * Each column gets its own independent query to the data source.\n */\nexport function useBoardDataController<M extends Record<string, unknown> = any, COLUMN extends string = string>({\n fullPath,\n collection,\n columnProperty,\n columns,\n orderProperty,\n pageSize = DEFAULT_PAGE_SIZE,\n searchString,\n filterValues\n}: UseBoardDataControllerProps<M>): BoardDataController<M, COLUMN> {\n\n const context = useRebaseContext();\n const dataClient = useData();\n // v4: use fullPath directly instead of resolveIdsFrom\n const resolvedPath = fullPath;\n\n // Stable refs for objects that shouldn't trigger re-subscriptions\n const dataClientRef = useRef(dataClient);\n const collectionRef = useRef(collection);\n const contextRef = useRef(context);\n dataClientRef.current = dataClient;\n collectionRef.current = collection;\n contextRef.current = context;\n\n // Store filter/order params in refs so they're accessible without causing re-subscriptions\n const filterValuesRef = useRef(filterValues);\n const columnPropertyRef = useRef(columnProperty);\n const orderPropertyRef = useRef(orderProperty);\n const searchStringRef = useRef(searchString);\n const resolvedPathRef = useRef(resolvedPath);\n const pageSizeRef = useRef(pageSize);\n pageSizeRef.current = pageSize;\n filterValuesRef.current = filterValues;\n columnPropertyRef.current = columnProperty;\n orderPropertyRef.current = orderProperty;\n searchStringRef.current = searchString;\n resolvedPathRef.current = resolvedPath;\n\n // Track item count per column for pagination\n const [columnItemCounts, setColumnItemCounts] = useState<Record<string, number>>(() => {\n const initial: Record<string, number> = {};\n columns.forEach(col => {\n initial[col] = pageSize;\n });\n return initial;\n });\n\n // Per-column data state\n const [columnData, setColumnData] = useState<Record<string, BoardColumnData<M>>>(() => {\n const initial: Record<string, BoardColumnData<M>> = {};\n columns.forEach(col => {\n initial[col] = {\n entities: [],\n loading: true,\n hasMore: true,\n error: undefined,\n totalCount: undefined\n };\n });\n return initial;\n });\n\n // Track cleanup functions for subscriptions\n const unsubscribersRef = useRef<Record<string, () => void>>({});\n\n // Each column's rows, read a page at a time — see `CollectionWindow`.\n const windowsRef = useRef<Record<string, CollectionWindow<Record<string, unknown>>>>({});\n\n // Flag to prevent race conditions during cleanup\n const isCleaningUpRef = useRef(false);\n\n // Track items that are currently in an optimistic state (awaiting DB sync)\n const pendingItemsRef = useRef<Record<string, { entity: Entity<M>, expectedValues: Record<string, any> }>>({});\n\n // Stable keys for dependency comparison\n const columnsKey = useMemo(() => [...columns].sort().join(\",\"), [columns]);\n const filterKey = useMemo(() => JSON.stringify(filterValues), [filterValues]);\n\n // Track previous column item counts to detect which column changed\n const prevColumnItemCountsRef = useRef<Record<string, number>>(columnItemCounts);\n\n // Version counter to trigger full re-subscription when params change (not just load-more)\n const [subscriptionVersion, setSubscriptionVersion] = useState(0);\n\n // Where the source cannot subscribe, the columns are one read each: they\n // are read again on every write to the collection in this `<Rebase>`.\n const changeVersion = useDataChangeVersion(resolvedPath, !dataClient.collection(resolvedPath).listen);\n\n // Trigger full re-subscription when key params change\n useEffect(() => {\n setSubscriptionVersion(v => v + 1);\n }, [columnsKey, resolvedPath, columnProperty, orderProperty, searchString, filterKey, pageSize, changeVersion]);\n\n // Cleanup subscriptions on unmount\n useEffect(() => {\n return () => {\n isCleaningUpRef.current = true;\n Object.values(unsubscribersRef.current).forEach(unsub => unsub?.());\n unsubscribersRef.current = {};\n };\n }, []);\n\n /**\n * Check if a column value is excluded by the active filter on the columnProperty.\n * E.g. if the user sets \"Status IN (Open, In Progress)\", this returns true\n * for \"Waiting on Customer\" since that column should show as empty.\n */\n const isColumnExcludedByFilter = useCallback((column: string, filterValues?: FilterValues<string>, colProperty?: string): boolean => {\n if (!filterValues || !colProperty) return false;\n const filterForColumn = filterValues[colProperty as keyof typeof filterValues];\n if (!filterForColumn || !Array.isArray(filterForColumn)) return false;\n\n const [op, val] = filterForColumn as [string, unknown];\n\n if (op === \"==\" && typeof val === \"string\") {\n return column !== val;\n }\n if (op === \"!=\" && typeof val === \"string\") {\n return column === val;\n }\n if (op === \"in\" && Array.isArray(val)) {\n return !val.map(String).includes(column);\n }\n if (op === \"not-in\" && Array.isArray(val)) {\n return val.map(String).includes(column);\n }\n\n return false;\n }, []);\n\n // Helper function to subscribe to a single column - uses refs to avoid dependency issues\n const subscribeToColumn = useCallback((column: string, itemCount: number) => {\n // Skip if we're in the middle of cleanup\n if (isCleaningUpRef.current) return;\n\n const currentDataClient = dataClientRef.current;\n const currentCollection = collectionRef.current;\n const currentContext = contextRef.current;\n const currentFilterValues = filterValuesRef.current;\n const currentColumnProperty = columnPropertyRef.current;\n const currentOrderProperty = orderPropertyRef.current;\n const currentSearchString = searchStringRef.current;\n const currentResolvedPath = resolvedPathRef.current;\n\n // If the column is excluded by the active filter on the column property,\n // set it as empty immediately without querying.\n const excluded = isColumnExcludedByFilter(column, currentFilterValues, currentColumnProperty);\n if (excluded) {\n setColumnData(prev => ({\n ...prev,\n [column]: {\n entities: [],\n loading: false,\n hasMore: false,\n error: undefined,\n totalCount: 0\n }\n }));\n return;\n }\n\n // Build filter map for this column — pass FilterValues directly\n const whereFilter: FilterValues<string> = {\n ...(currentFilterValues ?? {}),\n [currentColumnProperty]: [\"==\", column]\n };\n\n const orderByParam: [string, \"asc\" | \"desc\"] | undefined = currentOrderProperty ? [currentOrderProperty, \"asc\"] : undefined;\n\n // Whether this subscription is still the column's current one. Every\n // answer — live, fallback or one-shot — checks it before it paints:\n // a read issued for the previous search, or for the page size before a\n // load-more, can resolve after the one that replaced it, and it would\n // otherwise overwrite the newer rows. `isCleaningUpRef` cannot say\n // this: it is one flag for the whole board, and the next subscription\n // sets it straight back to false.\n let active = true;\n const isCurrent = () => active && !isCleaningUpRef.current;\n // `afterRead` below is awaited, so two answers can finish out of\n // order; only the latest one paints.\n let updateSequence = 0;\n\n // Mark column as loading\n setColumnData(prev => ({\n ...prev,\n [column]: {\n ...prev[column],\n loading: true,\n error: undefined\n }\n }));\n\n // onUpdate callback\n const onUpdate = async (entities: Entity<M>[], state: Omit<CollectionWindowState, \"rows\">) => {\n if (!isCurrent()) return;\n const sequence = ++updateSequence;\n\n const pendingMap = pendingItemsRef.current;\n\n // Apply pending updates to incoming entities\n const mergedEntities = entities.map(e => {\n const pending = pendingMap[String(e.id)];\n if (pending) {\n // Check if DB entity has caught up to the expected column and order\n const expectedCol = pending.expectedValues[currentColumnProperty];\n const expectedOrder = currentOrderProperty ? pending.expectedValues[currentOrderProperty] : undefined;\n\n let caughtUp = true;\n if (e.values?.[currentColumnProperty] !== expectedCol) {\n caughtUp = false;\n }\n if (currentOrderProperty && e.values?.[currentOrderProperty] !== expectedOrder) {\n caughtUp = false;\n }\n\n if (caughtUp) {\n // DB has caught up, clear pending state\n delete pendingMap[String(e.id)];\n return e; // Use the real DB entity\n }\n\n // DB hasn't caught up, overlay expected values\n return { ...e,\nvalues: { ...e.values,\n...pending.expectedValues } };\n }\n return e;\n });\n\n // Add any pending items that belong to this column but aren't in the incoming entities yet\n // (e.g. backend hasn't moved them to this column yet)\n Object.values(pendingMap).forEach(pending => {\n if (pending.expectedValues[currentColumnProperty] === column) {\n if (!mergedEntities.some(e => String(e.id) === String(pending.entity.id))) {\n mergedEntities.push(pending.entity);\n }\n }\n });\n\n // Always filter in memory to only show entities that belong to this specific column.\n // This is required because text search returns all matches, and the overlay above\n // moves a card dragged out of this column to its new one before the server has.\n let processed = mergedEntities.filter(e => e.values?.[currentColumnProperty] === column);\n\n // Sort locally if orderProperty is defined: pending cards are appended above, and\n // the overlay can change a card's order key, so the order the rows arrived in is\n // not the order to show.\n if (currentOrderProperty) {\n processed = [...processed].sort((a, b) => {\n const valA = a.values?.[currentOrderProperty] as string | undefined | null;\n const valB = b.values?.[currentOrderProperty] as string | undefined | null;\n\n const isAEmpty = valA === undefined || valA === null || valA === \"\";\n const isBEmpty = valB === undefined || valB === null || valB === \"\";\n\n if (isAEmpty && isBEmpty) return 0;\n if (isAEmpty) return 1;\n if (isBEmpty) return -1;\n\n return valA < valB ? -1 : valA > valB ? 1 : 0;\n });\n }\n\n // Apply the panel's own afterRead callbacks if any — `browserCallbacks`,\n // not `callbacks`: the latter already ran on the server before these\n // rows arrived, and running it again here applied it twice.\n // afterRead is handed a copy of the row as the server sends it;\n // what it changes, in place or in a new object, is converted back\n // onto the record's values.\n if (currentCollection.browserCallbacks?.afterRead) {\n try {\n processed = await Promise.all(\n processed.map(async (entity) => {\n const row = toWireRow(entity.values, currentCollection);\n const processedRow = await currentCollection.browserCallbacks!.afterRead!({\n collection: currentCollection,\n path: currentResolvedPath,\n row: copyRow(row),\n context: currentContext\n });\n return {\n ...entity,\n values: fromWireRow(entity.values, row, processedRow, currentCollection, currentResolvedPath) as M\n };\n })\n );\n } catch (e) {\n console.error(\"Error in afterRead callback:\", e);\n }\n }\n\n // `afterRead` above is awaited; the subscription may have been\n // replaced in the meantime.\n if (!isCurrent() || sequence !== updateSequence) return;\n\n // More exists until a page comes back short — never \"the rows\n // asked for did not all fit under the read ceiling\". A column\n // whose next page failed stops asking, rather than retrying on\n // every scroll.\n const newHasMore = !state.complete && !state.error;\n\n // Compare with current state — skip update if identical to avoid UI flash\n setColumnData(prev => {\n const existing = prev[column];\n if (existing && !existing.loading && existing.entities.length === processed.length) {\n // Quick structural equality check: same IDs in same order with same values\n let identical = true;\n for (let i = 0; i < processed.length; i++) {\n const a = existing.entities[i];\n const b = processed[i];\n if (a.id !== b.id) {\n identical = false;\n break;\n }\n // Shallow-compare values to avoid JSON.stringify allocations\n // entity.values are flat records from the DB, so shallow suffices\n if (!shallowEqualValues(a.values, b.values)) {\n identical = false;\n break;\n }\n }\n if (identical && existing.hasMore === newHasMore && !state.loading && existing.error === state.error) {\n // Data is the same — return previous reference to prevent re-render\n return prev;\n }\n }\n\n return {\n ...prev,\n [column]: {\n entities: processed,\n loading: state.loading,\n hasMore: newHasMore,\n error: state.error,\n totalCount: prev[column]?.totalCount // Keep existing count\n }\n };\n });\n };\n\n const accessor = currentDataClient.collection(currentResolvedPath);\n\n // Eagerly include relations to avoid N+1 fetches.\n const includeParams = getRelationIncludeParams(currentCollection);\n\n // The column's first page is live; every later page is read by\n // offset, only past the rows already held, and never above the API's\n // read ceiling. The column used to grow one read instead and clamp it\n // at that ceiling, so it said it was finished at 1,000 cards while its\n // own header counted thousands more.\n const collectionWindow = new CollectionWindow({\n accessor,\n query: {\n where: whereFilter,\n orderBy: orderByParam,\n include: includeParams,\n // Read into a local at the top of this function and then used\n // nowhere, in both places it was read. The board took a search\n // term, re-subscribed every column when it changed, and\n // returned the same rows.\n searchString: currentSearchString\n },\n pageSize: pageSizeRef.current,\n target: itemCount,\n // A live subscription that fails is not the same thing as a column\n // with nothing in it, but that is exactly what this used to render:\n // entities cleared, no error surfaced, and a column reading \"No\n // items\" above a header still counting eleven of them. Read once\n // over HTTP instead — the board loses its live updates, not its\n // contents — and only report the failure if that fails too.\n fallbackToFind: true,\n // A subscription that is never going to answer takes the client's\n // full 30s watchdog to say so, and the board spins the whole time.\n // If the socket has not delivered shortly after mount, read once\n // over HTTP and paint that; the live data still wins whenever it\n // arrives. Costs nothing when realtime is healthy.\n firstPaintTimeoutMs: LIVE_FIRST_PAINT_TIMEOUT_MS,\n onChange: (state) => {\n if (!isCurrent()) return;\n if (state.rows) {\n void onUpdate(state.rows as Entity<M>[], state);\n return;\n }\n if (state.error) {\n console.error(`Error loading column ${column}:`, state.error);\n setColumnData(prev => ({\n ...prev,\n [column]: {\n ...prev[column],\n entities: prev[column]?.entities ?? [],\n loading: false,\n hasMore: false,\n error: state.error\n }\n }));\n }\n }\n });\n windowsRef.current[column] = collectionWindow;\n unsubscribersRef.current[column] = () => {\n active = false;\n collectionWindow.dispose();\n if (windowsRef.current[column] === collectionWindow) delete windowsRef.current[column];\n };\n collectionWindow.start();\n }, []); // No dependencies - uses refs for all values\n\n // Main effect for all column subscriptions - runs when subscriptionVersion changes (i.e., key params change)\n useEffect(() => {\n // Mark that we're setting up new subscriptions\n isCleaningUpRef.current = false;\n\n // Clean up all existing subscriptions synchronously\n const existingUnsubscribers = { ...unsubscribersRef.current };\n unsubscribersRef.current = {};\n Object.values(existingUnsubscribers).forEach(unsub => {\n try {\n unsub?.();\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n\n const currentDataClient = dataClientRef.current;\n const currentCollection = collectionRef.current;\n const currentFilterValues = filterValuesRef.current;\n const currentColumnProperty = columnPropertyRef.current;\n const currentSearchString = searchStringRef.current;\n const currentResolvedPath = resolvedPathRef.current;\n const currentColumns = columns;\n const currentColumnItemCounts = columnItemCounts;\n\n // Set by this run's cleanup, so a count issued for the previous search\n // or filter cannot land after the one that replaced it.\n let cancelled = false;\n\n // Small delay to ensure Firestore has cleaned up previous listeners\n const timeoutId = setTimeout(() => {\n if (isCleaningUpRef.current) return;\n\n currentColumns.forEach(column => {\n const itemCount = currentColumnItemCounts[column] ?? pageSize;\n subscribeToColumn(column, itemCount);\n\n // Skip count query for columns excluded by the filter — subscribeToColumn\n // already set them to totalCount: 0.\n if (isColumnExcludedByFilter(column, currentFilterValues, currentColumnProperty)) {\n return;\n }\n\n // Count query for column (for display in column header)\n const accessor = currentDataClient.collection(currentResolvedPath);\n if (accessor.count) {\n\n const whereFilter: FilterValues<string> = {\n ...(currentFilterValues ?? {}),\n [currentColumnProperty]: [\"==\", column]\n };\n\n accessor.count({\n where: whereFilter,\n // Or the column header counts the unsearched collection\n // while the column beneath it shows searched rows.\n searchString: currentSearchString\n }).then(count => {\n if (cancelled || isCleaningUpRef.current) return;\n setColumnData(prev => ({\n ...prev,\n [column]: {\n ...prev[column],\n totalCount: count\n }\n }));\n }).catch(e => {\n console.warn(`Failed to get count for column ${column}:`, e);\n });\n }\n });\n\n // Update the ref after subscribing all\n prevColumnItemCountsRef.current = { ...currentColumnItemCounts };\n }, 0);\n\n return () => {\n cancelled = true;\n clearTimeout(timeoutId);\n isCleaningUpRef.current = true;\n const unsubscribers = { ...unsubscribersRef.current };\n unsubscribersRef.current = {};\n Object.values(unsubscribers).forEach(unsub => {\n try {\n unsub?.();\n } catch (e) {\n // Ignore cleanup errors\n }\n });\n };\n\n }, [subscriptionVersion, subscribeToColumn, pageSize]);\n\n // Track which subscription version last updated the counts\n const lastProcessedVersionRef = useRef(subscriptionVersion);\n\n // Separate effect to handle individual column load-more WITHOUT triggering full re-subscription\n useEffect(() => {\n // If subscriptionVersion changed, the main effect will handle everything\n // Skip this effect to avoid race conditions\n if (subscriptionVersion !== lastProcessedVersionRef.current) {\n lastProcessedVersionRef.current = subscriptionVersion;\n prevColumnItemCountsRef.current = { ...columnItemCounts };\n return;\n }\n\n const prevCounts = prevColumnItemCountsRef.current;\n\n columns.forEach(column => {\n const prevCount = prevCounts[column] ?? pageSize;\n const newCount = columnItemCounts[column] ?? pageSize;\n\n // Only this column asked for more: its window reads the next page,\n // and nothing it already holds is read again.\n if (newCount > prevCount && !isCleaningUpRef.current) {\n windowsRef.current[column]?.setTarget(newCount);\n }\n });\n\n // Update the ref\n prevColumnItemCountsRef.current = { ...columnItemCounts };\n }, [columnItemCounts, columns, pageSize, subscribeToColumn, subscriptionVersion]);\n\n const loadMoreColumn = useCallback((column: COLUMN) => {\n setColumnItemCounts(prev => ({\n ...prev,\n [column]: (prev[column] ?? pageSize) + pageSize\n }));\n }, [pageSize]);\n\n /**\n * Drop the optimistic overlay for the moves matching `predicate`.\n *\n * An entry is otherwise released only when the database \"catches up\" to\n * it, which a refused write never does: the card would stay where it was\n * dropped, on top of whatever the database re-delivers. A refresh is a\n * request for what the database says, so it lets go of them.\n */\n const dropPendingMoves = useCallback((predicate: (expectedValues: Record<string, any>) => boolean) => {\n const pendingMap = pendingItemsRef.current;\n for (const [id, pending] of Object.entries(pendingMap)) {\n if (predicate(pending.expectedValues)) delete pendingMap[id];\n }\n }, []);\n\n const refreshColumn = useCallback((column: COLUMN) => {\n dropPendingMoves(expected => expected[columnPropertyRef.current] === column);\n // Back to one page, and re-subscribed here: the load-more effect only\n // re-subscribes a column whose count went *up*, so resetting the count\n // alone reached nothing.\n setColumnItemCounts(prev => ({\n ...prev,\n [column]: pageSize\n }));\n prevColumnItemCountsRef.current = { ...prevColumnItemCountsRef.current, [column]: pageSize };\n const unsubscribe = unsubscribersRef.current[column];\n delete unsubscribersRef.current[column];\n try {\n unsubscribe?.();\n } catch (e) {\n // Ignore cleanup errors\n }\n setTimeout(() => {\n if (!isCleaningUpRef.current) {\n subscribeToColumn(column, pageSize);\n }\n }, 0);\n }, [pageSize, subscribeToColumn, dropPendingMoves]);\n\n const refreshAll = useCallback(() => {\n dropPendingMoves(() => true);\n const reset: Record<string, number> = {};\n columns.forEach(col => {\n reset[col] = pageSize;\n });\n setColumnItemCounts(reset);\n // A new subscription version re-subscribes and re-counts every column.\n setSubscriptionVersion(v => v + 1);\n }, [columns, pageSize, dropPendingMoves]);\n\n // Optimistic update for when moving an item\n const moveItemOptimistically = useCallback((itemId: string, sourceColumn: COLUMN, targetColumn: COLUMN, newValues?: Record<string, any>, newIndex?: number) => {\n setColumnData(prev => {\n const updated = { ...prev };\n let itemToMove: Entity<M> | undefined;\n\n const sourceEntities = [...(updated[sourceColumn]?.entities || [])];\n const itemIndex = sourceEntities.findIndex(e => String(e.id) === itemId);\n\n if (itemIndex !== -1) {\n itemToMove = sourceEntities[itemIndex];\n sourceEntities.splice(itemIndex, 1);\n }\n\n if (itemToMove) {\n const newValuesMerged = {\n ...itemToMove.values,\n ...(newValues || {})\n };\n\n const updatedEntity = {\n ...itemToMove,\n values: newValuesMerged\n };\n\n // Store in pending items ref\n pendingItemsRef.current[String(updatedEntity.id)] = {\n entity: updatedEntity,\n expectedValues: newValuesMerged\n };\n\n const targetEntities = sourceColumn === targetColumn ? sourceEntities : [...(updated[targetColumn]?.entities || [])];\n\n if (newIndex !== undefined && newIndex >= 0 && newIndex <= targetEntities.length) {\n targetEntities.splice(newIndex, 0, updatedEntity);\n } else {\n targetEntities.push(updatedEntity);\n if (orderPropertyRef.current) {\n const orderProp = orderPropertyRef.current;\n targetEntities.sort((a, b) => {\n const valA = a.values?.[orderProp] as string | undefined | null;\n const valB = b.values?.[orderProp] as string | undefined | null;\n\n // Handle nulls/empty strings to match Postgres NULLS LAST (ASC) behavior\n const isAEmpty = valA === undefined || valA === null || valA === \"\";\n const isBEmpty = valB === undefined || valB === null || valB === \"\";\n\n if (isAEmpty && isBEmpty) return 0;\n if (isAEmpty) return 1; // A is null, B is not -> A goes after B\n if (isBEmpty) return -1; // B is null, A is not -> A goes before B\n\n return valA < valB ? -1 : valA > valB ? 1 : 0;\n });\n }\n }\n\n updated[sourceColumn] = {\n ...updated[sourceColumn],\n entities: sourceColumn === targetColumn ? targetEntities : sourceEntities,\n totalCount: sourceColumn === targetColumn\n ? updated[sourceColumn].totalCount\n : Math.max(0, (updated[sourceColumn].totalCount ?? 0) - 1)\n };\n\n if (sourceColumn !== targetColumn) {\n updated[targetColumn] = {\n ...updated[targetColumn],\n entities: targetEntities,\n totalCount: (updated[targetColumn].totalCount ?? 0) + 1\n };\n }\n\n } else if (sourceColumn !== targetColumn) {\n // If item not found locally but counts need update\n if (updated[sourceColumn]?.totalCount !== undefined) {\n updated[sourceColumn] = {\n ...updated[sourceColumn],\n totalCount: Math.max(0, (updated[sourceColumn].totalCount ?? 0) - 1)\n };\n }\n if (updated[targetColumn]?.totalCount !== undefined) {\n updated[targetColumn] = {\n ...updated[targetColumn],\n totalCount: (updated[targetColumn].totalCount ?? 0) + 1\n };\n }\n }\n\n return updated;\n });\n }, []);\n\n // Optimistic update for column counts when deleting items\n const decrementColumnCounts = useCallback((columnDeltas: Record<COLUMN, number>) => {\n setColumnData(prev => {\n const updated = { ...prev };\n\n for (const [column, delta] of Object.entries(columnDeltas) as [COLUMN, number][]) {\n if (updated[column]?.totalCount !== undefined) {\n updated[column] = {\n ...updated[column],\n totalCount: Math.max(0, (updated[column].totalCount ?? 0) - delta)\n };\n }\n }\n\n return updated;\n });\n }, []);\n\n // Aggregate loading and error state\n const loading = useMemo(() => {\n return Object.values(columnData).some((col) => col.loading);\n }, [columnData]);\n\n const error = useMemo(() => {\n const errors = Object.values(columnData)\n .map((col) => col.error)\n .filter(Boolean);\n return errors[0];\n }, [columnData]);\n\n return useMemo(() => ({\n columnData: columnData as Record<COLUMN, BoardColumnData<M>>,\n loadMoreColumn,\n refreshColumn,\n refreshAll,\n moveItemOptimistically,\n decrementColumnCounts,\n loading,\n error\n }), [\n columnData,\n loadMoreColumn,\n refreshColumn,\n refreshAll,\n moveItemOptimistically,\n decrementColumnCounts,\n loading,\n error\n ]);\n}\n"],"mappings":";;;AAMA,IAAM,sBAAoB;;;;;;AAO1B,IAAM,8BAA8B;;;;;;AAOpC,SAAS,mBACL,GACA,GACO;CACP,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,MAA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pB,GAAG,QAAQ;KACX,YAAY,KAAK,IAAI,IAAI,QAAQ,aAAa,CAAC,cAAc,KAAK,CAAC;IACvE;IAEJ,IAAI,QAAQ,aAAa,EAAE,eAAe,KAAA,GACtC,QAAQ,gBAAgB;KACpB,GAAG,QAAQ;KACX,aAAa,QAAQ,aAAa,CAAC,cAAc,KAAK;IAC1D;GAER;GAEA,OAAO;EACX,CAAC;CACL,GAAG,CAAC,CAAC;CAGL,MAAM,wBAAwB,aAAa,iBAAyC;EAChF,eAAc,SAAQ;GAClB,MAAM,UAAU,EAAE,GAAG,KAAK;GAE1B,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,YAAY,GACrD,IAAI,QAAQ,OAAO,EAAE,eAAe,KAAA,GAChC,QAAQ,UAAU;IACd,GAAG,QAAQ;IACX,YAAY,KAAK,IAAI,IAAI,QAAQ,OAAO,CAAC,cAAc,KAAK,KAAK;GACrE;GAIR,OAAO;EACX,CAAC;CACL,GAAG,CAAC,CAAC;CAGL,MAAM,UAAU,cAAc;EAC1B,OAAO,OAAO,OAAO,UAAU,CAAC,CAAC,MAAM,QAAQ,IAAI,OAAO;CAC9D,GAAG,CAAC,UAAU,CAAC;CAEf,MAAM,QAAQ,cAAc;EAIxB,OAHe,OAAO,OAAO,UAAU,CAAC,CACnC,KAAK,QAAQ,IAAI,KAAK,CAAC,CACvB,OAAO,OACL,CAAA,CAAO;CAClB,GAAG,CAAC,UAAU,CAAC;CAEf,OAAO,eAAe;EACN;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,IAAI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC;AACL"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The width at which a collection view lays itself out large: Tailwind's
|
|
4
|
+
* `lg`, and `@5xl` (64rem) for the container classes that follow it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LARGE_COLLECTION_WIDTH = 1024;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the collection view a part is drawn in is wide enough for its large
|
|
9
|
+
* layout; `undefined` until it has been measured.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CollectionViewLayoutContext: React.Context<boolean | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the collection view this is drawn in is wide enough for its large
|
|
14
|
+
* layout — the frozen id column, labelled toolbar controls, the split side by
|
|
15
|
+
* side. Its own width decides, not the window's: a view in a side panel, a
|
|
16
|
+
* split or a narrow frame is narrow in a wide window. Until the view has been
|
|
17
|
+
* measured, and outside one, the window decides.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useCollectionLargeLayout(): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { useLargeLayout } from "@rebasepro/app";
|
|
3
|
+
//#region src/components/CollectionViewBinding/useCollectionLargeLayout.ts
|
|
4
|
+
/**
|
|
5
|
+
* The width at which a collection view lays itself out large: Tailwind's
|
|
6
|
+
* `lg`, and `@5xl` (64rem) for the container classes that follow it.
|
|
7
|
+
*/
|
|
8
|
+
var LARGE_COLLECTION_WIDTH = 1024;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the collection view a part is drawn in is wide enough for its large
|
|
11
|
+
* layout; `undefined` until it has been measured.
|
|
12
|
+
*/
|
|
13
|
+
var CollectionViewLayoutContext = React.createContext(void 0);
|
|
14
|
+
/**
|
|
15
|
+
* Whether the collection view this is drawn in is wide enough for its large
|
|
16
|
+
* layout — the frozen id column, labelled toolbar controls, the split side by
|
|
17
|
+
* side. Its own width decides, not the window's: a view in a side panel, a
|
|
18
|
+
* split or a narrow frame is narrow in a wide window. Until the view has been
|
|
19
|
+
* measured, and outside one, the window decides.
|
|
20
|
+
*/
|
|
21
|
+
function useCollectionLargeLayout() {
|
|
22
|
+
const windowLarge = useLargeLayout();
|
|
23
|
+
return useContext(CollectionViewLayoutContext) ?? windowLarge;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CollectionViewLayoutContext, LARGE_COLLECTION_WIDTH, useCollectionLargeLayout };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=useCollectionLargeLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCollectionLargeLayout.js","names":[],"sources":["../../../src/components/CollectionViewBinding/useCollectionLargeLayout.ts"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { useLargeLayout } from \"@rebasepro/app\";\n\n/**\n * The width at which a collection view lays itself out large: Tailwind's\n * `lg`, and `@5xl` (64rem) for the container classes that follow it.\n */\nexport const LARGE_COLLECTION_WIDTH = 1024;\n\n/**\n * Whether the collection view a part is drawn in is wide enough for its large\n * layout; `undefined` until it has been measured.\n */\nexport const CollectionViewLayoutContext = React.createContext<boolean | undefined>(undefined);\n\n/**\n * Whether the collection view this is drawn in is wide enough for its large\n * layout — the frozen id column, labelled toolbar controls, the split side by\n * side. Its own width decides, not the window's: a view in a side panel, a\n * split or a narrow frame is narrow in a wide window. Until the view has been\n * measured, and outside one, the window decides.\n */\nexport function useCollectionLargeLayout(): boolean {\n const windowLarge = useLargeLayout();\n const large = useContext(CollectionViewLayoutContext);\n return large ?? windowLarge;\n}\n"],"mappings":";;;;;;;AAOA,IAAa,yBAAyB;;;;;AAMtC,IAAa,8BAA8B,MAAM,cAAmC,KAAA,CAAS;;;;;;;;AAS7F,SAAgB,2BAAoC;CAChD,MAAM,cAAc,eAAe;CAEnC,OADc,WAAW,2BAClB,KAAS;AACpB"}
|