@rebasepro/cms 0.30.0 → 0.31.0-canary.g902a0ce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/collection_editor/ConfigControllerProvider.js +25 -22
- package/dist/collection_editor/ConfigControllerProvider.js.map +1 -1
- package/dist/collection_editor/firestore_callee.d.ts +10 -0
- package/dist/collection_editor/firestore_callee.js +15 -0
- package/dist/collection_editor/firestore_callee.js.map +1 -0
- package/dist/collection_editor/firestore_edit.d.ts +62 -0
- package/dist/collection_editor/firestore_edit.js +339 -0
- package/dist/collection_editor/firestore_edit.js.map +1 -0
- package/dist/collection_editor/index.d.ts +2 -3
- package/dist/collection_editor/liveSchemaClient.d.ts +44 -22
- package/dist/collection_editor/liveSchemaClient.js +9 -3
- package/dist/collection_editor/liveSchemaClient.js.map +1 -1
- package/dist/collection_editor/property_column.d.ts +86 -0
- package/dist/collection_editor/property_column.js +719 -0
- package/dist/collection_editor/property_column.js.map +1 -0
- package/dist/collection_editor/serializable_types.d.ts +2 -24
- package/dist/collection_editor/serializable_utils.d.ts +1 -1
- package/dist/collection_editor/serializable_utils.js +2 -1
- package/dist/collection_editor/serializable_utils.js.map +1 -1
- package/dist/collection_editor/split_edit.d.ts +106 -0
- package/dist/collection_editor/split_edit.js +564 -0
- package/dist/collection_editor/split_edit.js.map +1 -0
- package/dist/collection_editor/split_edit_error.d.ts +25 -0
- package/dist/collection_editor/split_edit_error.js +35 -0
- package/dist/collection_editor/split_edit_error.js.map +1 -0
- package/dist/collection_editor/types/collection_editor_controller.d.ts +1 -1
- package/dist/collection_editor/types/config_controller.d.ts +67 -1
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +6 -5
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js +44 -12
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js +18 -3
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js +94 -55
- package/dist/collection_editor/ui/collection_editor/CollectionRLSTab.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/CollectionRelationsTab.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/EnumForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js +3 -3
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/KanbanConfigSection.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +2 -3
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyFieldPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/PropertyTree.d.ts +7 -4
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js +15 -5
- package/dist/collection_editor/ui/collection_editor/PropertyTree.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaChangeDialog.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.d.ts +20 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js +74 -0
- package/dist/collection_editor/ui/collection_editor/SchemaEditRefusalView.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportDataPreview.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/CollectionEditorImportMapping.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/import/clean_import_data.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/BlockPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/DateTimePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/EnumPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/MapPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/ReferencePropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RelationPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/RepeatPropertyField.js.map +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/properties/conditions/property_paths.d.ts +1 -1
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.d.ts +34 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js +50 -0
- package/dist/collection_editor/ui/collection_editor/rlsRuleForm.js.map +1 -0
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -2
- package/dist/collection_editor/ui/collection_editor/utils/update_property_for_widget.js.map +1 -1
- package/dist/collection_editor/useDetachRulesConfirmation.d.ts +16 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js +48 -0
- package/dist/collection_editor/useDetachRulesConfirmation.js.map +1 -0
- package/dist/collection_editor/useLiveSchemaEditing.d.ts +2 -2
- package/dist/collection_editor/useLiveSchemaEditing.js +1 -1
- package/dist/collection_editor/useLiveSchemaEditing.js.map +1 -1
- package/dist/collection_editor/useLocalCollectionsConfigController.d.ts +54 -10
- package/dist/collection_editor/useLocalCollectionsConfigController.js +394 -122
- package/dist/collection_editor/useLocalCollectionsConfigController.js.map +1 -1
- package/dist/collection_editor/validateCollectionJson.js.map +1 -1
- package/dist/components/CollectionPanel.d.ts +10 -9
- package/dist/components/CollectionPanel.js +5 -2
- package/dist/components/CollectionPanel.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionRowActions.d.ts +1 -2
- package/dist/components/CollectionTableBinding/CollectionRowActions.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBinding.js.map +1 -1
- package/dist/components/CollectionTableBinding/CollectionTableBindingProps.d.ts +3 -5
- package/dist/components/CollectionTableBinding/PropertyTableCell.d.ts +2 -2
- package/dist/components/CollectionTableBinding/PropertyTableCell.js.map +1 -1
- package/dist/components/CollectionTableBinding/column_utils.d.ts +1 -1
- package/dist/components/CollectionTableBinding/column_utils.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableMultipleRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js +2 -2
- package/dist/components/CollectionTableBinding/fields/TableReferenceField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationField.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js +1 -2
- package/dist/components/CollectionTableBinding/fields/TableRelationField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.d.ts +2 -1
- package/dist/components/CollectionTableBinding/fields/TableRelationSelectorField.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.d.ts +2 -2
- package/dist/components/CollectionTableBinding/fields/TableStorageUpload.js.map +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.d.ts +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js +1 -1
- package/dist/components/CollectionTableBinding/fields/VirtualTableSelect.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/common.d.ts +1 -2
- package/dist/components/CollectionTableBinding/internal/common.js.map +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js +2 -2
- package/dist/components/CollectionTableBinding/internal/popup_field/PopupFormField.js.map +1 -1
- package/dist/components/CollectionTableBinding/table_bindings.d.ts +2 -2
- package/dist/components/CollectionTableBinding/table_bindings.js.map +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.d.ts +1 -1
- package/dist/components/CollectionViewBinding/BoardCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js +9 -5
- package/dist/components/CollectionViewBinding/CollectionBoardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionCardViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionEntityActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionListViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js +1 -1
- package/dist/components/CollectionViewBinding/CollectionToolbar.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewActions.js +2 -4
- package/dist/components/CollectionViewBinding/CollectionViewActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewBinding.d.ts +6 -6
- package/dist/components/CollectionViewBinding/CollectionViewBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewContent.js +1 -2
- package/dist/components/CollectionViewBinding/CollectionViewContent.js.map +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.d.ts +1 -1
- package/dist/components/CollectionViewBinding/CollectionViewStartActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/CustomViewHost.d.ts +1 -2
- package/dist/components/CollectionViewBinding/CustomViewHost.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntitiesCount.js +3 -3
- package/dist/components/CollectionViewBinding/EntitiesCount.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityCardBinding.d.ts +1 -2
- package/dist/components/CollectionViewBinding/EntityCardBinding.js.map +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js +1 -1
- package/dist/components/CollectionViewBinding/EntityIdHeaderWidget.js.map +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js +1 -1
- package/dist/components/CollectionViewBinding/FilterPresetsButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersButton.d.ts +1 -2
- package/dist/components/CollectionViewBinding/FiltersButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.d.ts +1 -1
- package/dist/components/CollectionViewBinding/FiltersDialog.js.map +1 -1
- package/dist/components/CollectionViewBinding/PluginColumnSlots.d.ts +1 -2
- package/dist/components/CollectionViewBinding/PluginColumnSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/RowActions.d.ts +1 -2
- package/dist/components/CollectionViewBinding/RowActions.js.map +1 -1
- package/dist/components/CollectionViewBinding/SortButton.d.ts +1 -1
- package/dist/components/CollectionViewBinding/SortButton.js.map +1 -1
- package/dist/components/CollectionViewBinding/SplitListView.d.ts +1 -2
- package/dist/components/CollectionViewBinding/SplitListView.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js +1 -1
- package/dist/components/CollectionViewBinding/hooks/useCollectionInlineEditor.js.map +1 -1
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.d.ts +1 -2
- package/dist/components/CollectionViewBinding/hooks/useKanbanDragAndDrop.js.map +1 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.d.ts +2 -1
- package/dist/components/CollectionViewBinding/useBoardDataController.js +3 -3
- package/dist/components/CollectionViewBinding/useBoardDataController.js.map +1 -1
- package/dist/components/CollectionViewBinding/useCollectionViewState.d.ts +2 -4
- package/dist/components/CollectionViewBinding/useCollectionViewState.js +14 -19
- package/dist/components/CollectionViewBinding/useCollectionViewState.js.map +1 -1
- package/dist/components/CollectionViewBinding/usePreviewSlots.d.ts +1 -3
- package/dist/components/CollectionViewBinding/usePreviewSlots.js.map +1 -1
- package/dist/components/CollectionViewBinding/useSelectionController.d.ts +1 -2
- package/dist/components/CollectionViewBinding/useSelectionController.js.map +1 -1
- package/dist/components/CollectionsProvider.d.ts +23 -8
- package/dist/components/CollectionsProvider.js +23 -7
- package/dist/components/CollectionsProvider.js.map +1 -1
- package/dist/components/DefaultDrawer.js +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.js +1 -1
- package/dist/components/DeleteEntityDialog.js.map +1 -1
- package/dist/components/DetailViewBinding.js +3 -3
- package/dist/components/DetailViewBinding.js.map +1 -1
- package/dist/components/EditFormActions.js.map +1 -1
- package/dist/components/EditViewBinding.d.ts +2 -1
- package/dist/components/EditViewBinding.js +6 -6
- package/dist/components/EditViewBinding.js.map +1 -1
- package/dist/components/EntityDisplayHeader.d.ts +1 -2
- package/dist/components/EntityDisplayHeader.js.map +1 -1
- package/dist/components/EntityInspector.d.ts +1 -2
- package/dist/components/EntityInspector.js.map +1 -1
- package/dist/components/EntityPreviewBinding.d.ts +1 -1
- package/dist/components/EntityPreviewBinding.js +1 -1
- package/dist/components/EntityPreviewBinding.js.map +1 -1
- package/dist/components/EntityViewBinding.d.ts +1 -1
- package/dist/components/EntityViewBinding.js.map +1 -1
- package/dist/components/EntityViewBody.d.ts +1 -1
- package/dist/components/EntityViewBody.js +3 -4
- package/dist/components/EntityViewBody.js.map +1 -1
- package/dist/components/FieldValue.js +2 -2
- package/dist/components/FieldValue.js.map +1 -1
- package/dist/components/HomePage/ContentHomePage.js +12 -3
- package/dist/components/HomePage/ContentHomePage.js.map +1 -1
- package/dist/components/InlineEntityPreview.d.ts +1 -1
- package/dist/components/InlineEntityPreview.js.map +1 -1
- package/dist/components/PropertyCollectionView.d.ts +2 -2
- package/dist/components/PropertyCollectionView.js.map +1 -1
- package/dist/components/PropertyConfigBadge.js.map +1 -1
- package/dist/components/RebaseCMS.d.ts +22 -3
- package/dist/components/RebaseCMS.js +32 -14
- package/dist/components/RebaseCMS.js.map +1 -1
- package/dist/components/RebaseNavigation.js +106 -31
- package/dist/components/RebaseNavigation.js.map +1 -1
- package/dist/components/RecordDetail.js +4 -1
- package/dist/components/RecordDetail.js.map +1 -1
- package/dist/components/RecordForm.d.ts +5 -5
- package/dist/components/RecordForm.js +5 -2
- package/dist/components/RecordForm.js.map +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.d.ts +2 -2
- package/dist/components/ReferenceTable/SelectionTableBinding.js +1 -1
- package/dist/components/ReferenceTable/SelectionTableBinding.js.map +1 -1
- package/dist/components/ReferenceWidget.d.ts +2 -1
- package/dist/components/ReferenceWidget.js +2 -2
- package/dist/components/ReferenceWidget.js.map +1 -1
- package/dist/components/RelationSelector.d.ts +2 -1
- package/dist/components/RelationSelector.js +2 -3
- package/dist/components/RelationSelector.js.map +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +2 -2
- package/dist/components/SelectableTable/SelectableTable.js.map +1 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.d.ts +2 -1
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js +3 -3
- package/dist/components/SelectableTable/filters/FilterFieldBinding.js.map +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js +2 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js +1 -1
- package/dist/components/SelectableTable/filters/RelationFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +1 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.js.map +1 -1
- package/dist/components/SelectableTable/filters/null_filter.d.ts +1 -3
- package/dist/components/SelectableTable/filters/null_filter.js.map +1 -1
- package/dist/components/SidePanelBinding.js +1 -1
- package/dist/components/SidePanelBinding.js.map +1 -1
- package/dist/components/field_configs.d.ts +1 -2
- package/dist/components/field_configs.js.map +1 -1
- package/dist/components/field_ids.d.ts +1 -1
- package/dist/components/field_ids.js +1 -1
- package/dist/components/field_ids.js.map +1 -1
- package/dist/components/history/EntityHistoryEntry.js.map +1 -1
- package/dist/components/history/EntityHistoryView.d.ts +1 -2
- package/dist/components/history/EntityHistoryView.js +1 -1
- package/dist/components/history/EntityHistoryView.js.map +1 -1
- package/dist/data_export/export/BasicExportAction.d.ts +1 -1
- package/dist/data_export/export/BasicExportAction.js.map +1 -1
- package/dist/data_export/export/ExportCollectionAction.js +2 -2
- package/dist/data_export/export/ExportCollectionAction.js.map +1 -1
- package/dist/data_export/export/additional_fields.d.ts +1 -1
- package/dist/data_export/export/additional_fields.js.map +1 -1
- package/dist/data_export/export/export.d.ts +1 -1
- package/dist/data_export/export/export.js +1 -1
- package/dist/data_export/export/export.js.map +1 -1
- package/dist/data_export/export/fetch_export_data.d.ts +3 -2
- package/dist/data_export/export/fetch_export_data.js.map +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.d.ts +1 -1
- package/dist/data_import/components/DataNewPropertiesMapping.js.map +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.d.ts +1 -1
- package/dist/data_import/components/ImportNewPropertyFieldPreview.js.map +1 -1
- package/dist/data_import/hooks/useImportConfig.js.map +1 -1
- package/dist/data_import/import/ImportCollectionAction.d.ts +2 -2
- package/dist/data_import/import/ImportCollectionAction.js.map +1 -1
- package/dist/data_import/types/column_mapping.d.ts +1 -1
- package/dist/data_import/utils/data.d.ts +1 -2
- package/dist/data_import/utils/data.js +1 -2
- package/dist/data_import/utils/data.js.map +1 -1
- package/dist/data_import/utils/get_import_inference_type.d.ts +1 -1
- package/dist/data_import/utils/get_import_inference_type.js.map +1 -1
- package/dist/data_import/utils/id_column.d.ts +1 -1
- package/dist/data_import/utils/id_column.js.map +1 -1
- package/dist/data_import/utils/import_columns.d.ts +1 -1
- package/dist/data_import/utils/import_columns.js.map +1 -1
- package/dist/data_import/utils/save_entities.d.ts +3 -3
- package/dist/data_import/utils/save_entities.js +1 -1
- package/dist/data_import/utils/save_entities.js.map +1 -1
- package/dist/form/EntityForm.js +2 -1
- package/dist/form/EntityForm.js.map +1 -1
- package/dist/form/EntityFormActions.js.map +1 -1
- package/dist/form/EntityFormBinding.js +2 -2
- package/dist/form/EntityFormBinding.js.map +1 -1
- package/dist/form/FormFieldsContext.d.ts +1 -4
- package/dist/form/FormFieldsContext.js +1 -1
- package/dist/form/FormFieldsContext.js.map +1 -1
- package/dist/form/PropertyFieldBinding.js +6 -8
- package/dist/form/PropertyFieldBinding.js.map +1 -1
- package/dist/form/components/FieldBlock.d.ts +1 -2
- package/dist/form/components/FieldBlock.js.map +1 -1
- package/dist/form/components/FieldHelperText.d.ts +1 -1
- package/dist/form/components/FieldHelperText.js.map +1 -1
- package/dist/form/components/FormRail.d.ts +1 -1
- package/dist/form/components/FormRail.js.map +1 -1
- package/dist/form/components/LocalChangesMenu.d.ts +1 -1
- package/dist/form/components/LocalChangesMenu.js.map +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.js.map +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js +1 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js +2 -2
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BinaryFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/GeopointFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.js +1 -2
- package/dist/form/field_bindings/KeyValueFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/MultipleRelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.js +2 -2
- package/dist/form/field_bindings/ReferenceFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RelationFieldBinding.js +2 -2
- package/dist/form/field_bindings/RelationFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/StorageUploadFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SwitchFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.js.map +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/VectorFieldBinding.js.map +1 -1
- package/dist/form/form_utils.d.ts +3 -3
- package/dist/form/form_utils.js +1 -2
- package/dist/form/form_utils.js.map +1 -1
- package/dist/form/label_placement.d.ts +1 -2
- package/dist/form/label_placement.js.map +1 -1
- package/dist/form/resolve_cell_property.d.ts +1 -2
- package/dist/form/resolve_cell_property.js +1 -1
- package/dist/form/resolve_cell_property.js.map +1 -1
- package/dist/form/resolve_form_properties.d.ts +2 -2
- package/dist/form/resolve_form_properties.js +1 -1
- package/dist/form/resolve_form_properties.js.map +1 -1
- package/dist/form/useClearRestoreValue.d.ts +1 -1
- package/dist/form/useClearRestoreValue.js.map +1 -1
- package/dist/form/validation.d.ts +2 -2
- package/dist/form/validation.js +1 -1
- package/dist/form/validation.js.map +1 -1
- package/dist/hooks/navigation/compose_collections.d.ts +59 -0
- package/dist/hooks/navigation/compose_collections.js +48 -0
- package/dist/hooks/navigation/compose_collections.js.map +1 -0
- package/dist/hooks/navigation/compose_collections_input.d.ts +8 -0
- package/dist/hooks/navigation/compose_collections_input.js +17 -0
- package/dist/hooks/navigation/compose_collections_input.js.map +1 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.js.map +1 -1
- package/dist/hooks/navigation/registered_collection.d.ts +15 -0
- package/dist/hooks/navigation/registered_collection.js +20 -0
- package/dist/hooks/navigation/registered_collection.js.map +1 -0
- package/dist/hooks/navigation/ui_preferences.d.ts +47 -0
- package/dist/hooks/navigation/ui_preferences.js +179 -0
- package/dist/hooks/navigation/ui_preferences.js.map +1 -0
- package/dist/hooks/navigation/useAsyncResolver.d.ts +8 -1
- package/dist/hooks/navigation/useAsyncResolver.js +9 -3
- package/dist/hooks/navigation/useAsyncResolver.js.map +1 -1
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +1 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js +3 -3
- package/dist/hooks/navigation/useBuildCollectionRegistryController.js.map +1 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +9 -5
- package/dist/hooks/navigation/useBuildNavigationStateController.js +2 -1
- package/dist/hooks/navigation/useBuildNavigationStateController.js.map +1 -1
- package/dist/hooks/navigation/useBuildUrlController.d.ts +1 -1
- package/dist/hooks/navigation/useBuildUrlController.js.map +1 -1
- package/dist/hooks/navigation/useNavigationResolution.js +1 -2
- package/dist/hooks/navigation/useNavigationResolution.js.map +1 -1
- package/dist/hooks/navigation/usePanelTables.d.ts +11 -0
- package/dist/hooks/navigation/usePanelTables.js +33 -0
- package/dist/hooks/navigation/usePanelTables.js.map +1 -0
- package/dist/hooks/navigation/useResolvedCollections.d.ts +8 -3
- package/dist/hooks/navigation/useResolvedCollections.js +3 -2
- package/dist/hooks/navigation/useResolvedCollections.js.map +1 -1
- package/dist/hooks/navigation/useResolvedViews.d.ts +1 -2
- package/dist/hooks/navigation/useResolvedViews.js.map +1 -1
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -2
- package/dist/hooks/navigation/useTopLevelNavigation.js.map +1 -1
- package/dist/hooks/navigation/user_preferences_overlay.d.ts +21 -0
- package/dist/hooks/navigation/user_preferences_overlay.js +101 -0
- package/dist/hooks/navigation/user_preferences_overlay.js.map +1 -0
- package/dist/hooks/navigation/utils.js +1 -1
- package/dist/hooks/navigation/utils.js.map +1 -1
- package/dist/hooks/useAdminContext.d.ts +1 -2
- package/dist/hooks/useAdminContext.js.map +1 -1
- package/dist/hooks/useBuildSidePanel.d.ts +1 -2
- package/dist/hooks/useBuildSidePanel.js +2 -1
- package/dist/hooks/useBuildSidePanel.js.map +1 -1
- package/dist/hooks/useChildViewSource.d.ts +1 -1
- package/dist/hooks/useChildViewSource.js +1 -1
- package/dist/hooks/useChildViewSource.js.map +1 -1
- package/dist/hooks/useEntityDisplay.d.ts +1 -2
- package/dist/hooks/useEntityDisplay.js +1 -1
- package/dist/hooks/useEntityDisplay.js.map +1 -1
- package/dist/hooks/useEntityDisplayTitle.d.ts +2 -2
- package/dist/hooks/useEntityDisplayTitle.js.map +1 -1
- package/dist/hooks/useHistory.js +1 -1
- package/dist/hooks/useHistory.js.map +1 -1
- package/dist/hooks/useRecordActions.d.ts +1 -2
- package/dist/hooks/useRecordActions.js.map +1 -1
- package/dist/hooks/useReferencePaths.d.ts +21 -7
- package/dist/hooks/useReferencePaths.js +23 -6
- package/dist/hooks/useReferencePaths.js.map +1 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useResolvedNavigationFrom.js +1 -1
- package/dist/hooks/useResolvedNavigationFrom.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +8 -2
- package/dist/mcp_view/app_modules.d.ts +2 -2
- package/dist/mcp_view/app_modules.js +4 -4
- package/dist/mcp_view/app_modules.js.map +1 -1
- package/dist/mcp_view/index.d.ts +16 -19
- package/dist/mcp_view/index.js +43 -62
- package/dist/mcp_view/index.js.map +1 -1
- package/dist/mcp_view/payload.d.ts +54 -18
- package/dist/mcp_view/payload.js +49 -24
- package/dist/mcp_view/payload.js.map +1 -1
- package/dist/mcp_view/screen.js +11 -11
- package/dist/mcp_view/screen.js.map +1 -1
- package/dist/mcp_view/tool_driver.d.ts +5 -34
- package/dist/mcp_view/tool_driver.js +17 -16
- package/dist/mcp_view/tool_driver.js.map +1 -1
- package/dist/mcp_view/write_review.d.ts +1 -2
- package/dist/mcp_view/write_review.js +1 -1
- package/dist/mcp_view/write_review.js.map +1 -1
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreview.js +4 -3
- package/dist/preview/PropertyPreview.js.map +1 -1
- package/dist/preview/components/ArrayEnumPreview.d.ts +1 -1
- package/dist/preview/components/ArrayEnumPreview.js.map +1 -1
- package/dist/preview/components/BooleanPreview.d.ts +1 -1
- package/dist/preview/components/BooleanPreview.js.map +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.js +1 -1
- package/dist/preview/components/EnumValuesChip.js.map +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.js.map +1 -1
- package/dist/preview/components/RelationPreview.d.ts +1 -1
- package/dist/preview/components/RelationPreview.js.map +1 -1
- package/dist/preview/components/StorageThumbnail.js +2 -1
- package/dist/preview/components/StorageThumbnail.js.map +1 -1
- package/dist/preview/components/UserPreview.d.ts +1 -1
- package/dist/preview/components/UserPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfMapsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js +2 -1
- package/dist/preview/property_previews/ArrayOfRelationsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js +1 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.js.map +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/MapPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js +1 -1
- package/dist/preview/property_previews/NumberPropertyPreview.js.map +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.js.map +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.d.ts +1 -1
- package/dist/preview/property_previews/StringPropertyPreview.js.map +1 -1
- package/dist/preview/util.d.ts +1 -1
- package/dist/preview/util.js.map +1 -1
- package/dist/routes/RebaseRoute.js +2 -2
- package/dist/routes/RebaseRoute.js.map +1 -1
- package/dist/saved_apps/SavedAppsView.d.ts +1 -1
- package/dist/saved_apps/SavedAppsView.js +1 -1
- package/dist/saved_apps/SavedAppsView.js.map +1 -1
- package/dist/selection/SelectionMenu.d.ts +1 -1
- package/dist/selection/SelectionMenu.js.map +1 -1
- package/dist/selection/resolve_selection.d.ts +3 -3
- package/dist/selection/resolve_selection.js +3 -2
- package/dist/selection/resolve_selection.js.map +1 -1
- package/dist/tables/apply_customization.d.ts +65 -0
- package/dist/tables/apply_customization.js +644 -0
- package/dist/tables/apply_customization.js.map +1 -0
- package/dist/tables/column_property.d.ts +64 -0
- package/dist/tables/column_property.js +549 -0
- package/dist/tables/column_property.js.map +1 -0
- package/dist/tables/customize_table.d.ts +39 -0
- package/dist/tables/customize_table.js +247 -0
- package/dist/tables/customize_table.js.map +1 -0
- package/dist/tables/index.d.ts +12 -0
- package/dist/tables/labels.d.ts +18 -0
- package/dist/tables/labels.js +18 -0
- package/dist/tables/labels.js.map +1 -0
- package/dist/tables/project_table.d.ts +79 -0
- package/dist/tables/project_table.js +148 -0
- package/dist/tables/project_table.js.map +1 -0
- package/dist/tables/relations.d.ts +47 -0
- package/dist/tables/relations.js +112 -0
- package/dist/tables/relations.js.map +1 -0
- package/dist/tables/rls.d.ts +39 -0
- package/dist/tables/rls.js +111 -0
- package/dist/tables/rls.js.map +1 -0
- package/dist/tables/update_record.d.ts +32 -0
- package/dist/tables/update_record.js +40 -0
- package/dist/tables/update_record.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/PropertyPreviewProps.d.ts +2 -2
- package/dist/types/fields.d.ts +2 -2
- package/dist/util/dataControllerAdapter.js.map +1 -1
- package/dist/util/entity_pages.d.ts +2 -1
- package/dist/util/entity_pages.js.map +1 -1
- package/dist/util/find_entities_by_ids.d.ts +2 -2
- package/dist/util/find_entities_by_ids.js +1 -1
- package/dist/util/find_entities_by_ids.js.map +1 -1
- package/dist/util/format_collection_date.d.ts +1 -1
- package/dist/util/format_collection_date.js.map +1 -1
- package/dist/util/identity.d.ts +8 -0
- package/dist/util/identity.js +16 -0
- package/dist/util/identity.js.map +1 -0
- package/dist/util/navigation_utils.js +1 -1
- package/dist/util/navigation_utils.js.map +1 -1
- package/dist/util/previews.js +1 -1
- package/dist/util/previews.js.map +1 -1
- package/dist/util/propertyConfigMapper.d.ts +1 -1
- package/dist/util/propertyConfigMapper.js.map +1 -1
- package/dist/util/property_utils.d.ts +1 -3
- package/dist/util/property_utils.js +1 -1
- package/dist/util/property_utils.js.map +1 -1
- package/dist/util/relations.d.ts +18 -0
- package/dist/util/relations.js +32 -0
- package/dist/util/relations.js.map +1 -0
- package/package.json +12 -10
- package/recipes/README.md +4 -4
- package/recipes/my-preferences.tsx +34 -26
- package/recipes/site-settings.tsx +34 -27
- package/dist/collection_editor/collection_wire.d.ts +0 -13
- package/dist/collection_editor/collection_wire.js +0 -49
- package/dist/collection_editor/collection_wire.js.map +0 -1
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +0 -37
- package/dist/collection_editor/useJsonCollectionsConfigController.js +0 -191
- package/dist/collection_editor/useJsonCollectionsConfigController.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCollectionViewState.js","names":[],"sources":["../../../src/components/CollectionViewBinding/useCollectionViewState.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport type { AdditionalFieldDelegate, EntityAction, AdminCollection } from \"@rebasepro/cms-types\";\nimport { Entity } from \"@rebasepro/types\";\nimport {\n CollectionSize,\n EntitySelection,\n TableController,\n PartialCollectionConfig,\n SelectionQuery,\n ViewMode\n} from \"@rebasepro/cms-types\";\nimport { serializeSelectionQuery } from \"../../selection\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useSearchParams } from \"react-router\";\n\nimport { deepEqual as equal, shallowEqual } from \"fast-equals\"\nimport { CollectionRowActions, CollectionTableBinding } from \"../CollectionTableBinding\";\nimport { getEntityChildViews } from \"@rebasepro/common\";\nimport { useCollectionInlineEditor } from \"./hooks/useCollectionInlineEditor\";\nimport { navigateToEntity } from \"../../util/navigation_utils\";\nimport { mergeEntityActions } from \"../../util/entity_actions\";\nimport { resolveCollectionViews, resolveEntityAction } from \"../../util/resolutions\";\nimport { getPropertyInPath } from \"../../util/property_utils\";\nimport {\n OnColumnResizeParams,\n getRedundantChildViewColumnIds,\n useAnalyticsController,\n useAuthController,\n useColumnIds,\n useComponentOverride,\n useCustomizationController,\n useData,\n useDataTableController,\n populateFetchCache,\n usePermissions,\n useScrollRestoration,\n useSlot,\n useTranslation,\n useUserConfigurationPersistence,\n saveEntityWithCallbacks\n} from \"@rebasepro/app\";\nimport { CollectionViewActions } from \"./CollectionViewActions\";\nimport { KanbanPropertyOption } from \"./ViewModeToggle\";\nimport { DefaultCollectionEmptyState } from \"./DefaultCollectionEmptyState\";\nimport {\n ArrowRightToLineIcon,\n Button,\n iconSize,\n VirtualTableColumn\n} from \"@rebasepro/ui\";\nimport { getSubcollectionColumnId } from \"../CollectionTableBinding/internal/common\";\nimport { copyEntityAction, deleteEntityAction, editEntityAction, unlinkEntityAction } from \"../common/default_entity_actions\";\nimport { GetPropertyForProps } from \"../CollectionTableBinding/CollectionTableBindingProps\";\nimport { resolveCellProperty } from \"../../form/resolve_cell_property\";\nimport { useEntitySelectionController } from \"./useSelectionController\";\nimport { addRecentId } from \"./utils\";\nimport { isViewMode, resolveOpenEntityMode, VIEW_MODE_PARAM, VIEW_MODES } from \"../../util/view_mode\";\nimport { mergeDeep } from \"@rebasepro/utils\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../../hooks/useSidePanel\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { useChildViewSource } from \"../../hooks/useChildViewSource\";\nimport { useSelectionDialog } from \"../../hooks/useSelectionDialog\";\nimport { EntityIdHeaderWidget } from \"./EntityIdHeaderWidget\";\nimport { EMPTY_ARRAY, HeaderActionsScope, PluginAddColumnComponents } from \"./PluginColumnSlots\";\nimport type { CollectionViewBindingProps } from \"./CollectionViewBinding\";\nimport { columnsForFields, restrictCollectionToFields } from \"./fields\";\nimport type { EntityActionsScope } from \"./CollectionEntityActions\";\nimport { entityOfRow, entitySelectionControllerOf, rowOfEntity, selectionControllerOf, tableControllerOf } from \"@rebasepro/app\";\n\n/** The collections already warned about a foreign `admin.selectionController`: the warning is said once, not on every render. */\nconst warnedForeignSelection = new Set<string>();\n\n/**\n * Everything a collection view holds and decides: the collection it draws\n * (the registry's copy, the user's saved config and the caller's overrides,\n * in that order), its data and selection controllers, the view mode and\n * sizes, and the handlers its toolbar, views and dialogs call.\n *\n * One hook, so the toolbar, the view switch and the dialogs read the same\n * render's values: they were one component, and each part relies on a\n * decision another part made in the same render.\n */\nexport function useCollectionViewState<M extends Record<string, unknown>>({\n path: pathProp,\n parentCollectionSlugs,\n parentEntityIds,\n // Not state: the composition draws them.\n isSubCollection: _isSubCollection,\n className: _className,\n updateUrl,\n selectedEntityId: selectedEntityIdProp,\n selectedTab,\n collectionOverrides,\n highlightedIds,\n fields,\n viewMode: viewModeProp,\n title,\n onRowClick: onRowClickProp,\n toolbar: _toolbar,\n ...collectionProp\n}: CollectionViewBindingProps<M>) {\n\n const { t } = useTranslation();\n const context = useAdminContext();\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const path = pathProp ?? collectionProp.slug;\n const dataClient = useData();\n const sidePanelController = useSidePanel();\n const authController = useAuthController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const analyticsController = useAnalyticsController();\n const customizationController = useCustomizationController();\n const { canCreate, canEdit, canDelete } = usePermissions();\n\n\n /**\n * Rows shared with other parents through a junction. The parent owns\n * the link, not the row — so the destructive action is a removal from\n * this record, which is what the server performs for such a path.\n */\n const childViewSource = useChildViewSource(path);\n const isLinkedChildView = childViewSource?.kind === \"relation\" && childViewSource.mode === \"linked\";\n const linkedTargetSlug = isLinkedChildView && childViewSource.kind === \"relation\"\n ? childViewSource.targetSlug\n : undefined;\n\n const containerRef = React.useRef<HTMLDivElement>(null);\n\n const scrollRestoration = useScrollRestoration();\n\n // `collectionProp` is a rest object: a new value on every render of this\n // component, even when nothing in it changed. Everything below derives\n // from it — the merged collection, its properties, the table's columns —\n // so an identity-only change rebuilt all of them each render, and\n // `mergeDeep` handed back a fresh `propertiesOrder` array every time,\n // which the sync effect below read as a change and set state for: a\n // render loop, and a table that threw away the column width the user\n // had just dragged. Hold the last rest object that actually differs.\n //\n // Shallow is enough, and is the comparison that fits: a re-render this\n // component causes itself re-spreads the same props, so every value in\n // the new object is the same reference. A render caused from above has\n // already been through this component's own props comparator, which is\n // where a deep difference is decided.\n const collectionPropRef = React.useRef(collectionProp);\n if (!shallowEqual(collectionPropRef.current, collectionProp)) {\n collectionPropRef.current = collectionProp;\n }\n const stableCollectionProp = collectionPropRef.current;\n\n // `fields` by value, for the same reason: a caller writes it as a literal.\n const fieldsRef = React.useRef(fields);\n if (!equal(fieldsRef.current, fields)) fieldsRef.current = fields;\n const stableFields = fieldsRef.current;\n\n const overridesRef = React.useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n\n const collection = useMemo(() => {\n const registryCollection = collectionRegistry.getCollection(path) || stableCollectionProp;\n const userOverride = userConfigPersistence?.getCollectionConfig<M>(path);\n const drawn = (userOverride ? mergeDeep(registryCollection, userOverride) : registryCollection) as AdminCollection<M>;\n return stableOverrides ? { ...drawn, ...stableOverrides } as AdminCollection<M> : drawn;\n }, [stableCollectionProp, path, userConfigPersistence, collectionRegistry, stableOverrides]);\n\n const collectionRef = React.useRef(collection);\n useEffect(() => {\n collectionRef.current = collection;\n }, [collection]);\n\n const canCreateEntities = canCreate(collection, path);\n // By id: the row actions that set it hand an id, and the views compare ids.\n const [highlightedId, setHighlightedId] = useState<string | number | undefined>(undefined);\n const [deleteEntityClicked, setDeleteEntityClicked] = React.useState<Entity<M> | EntitySelection<M> | undefined>(undefined);\n\n const [lastDeleteTimestamp, setLastDeleteTimestamp] = React.useState<number>(0);\n\n // Track recently deleted entities for optimistic Kanban count updates\n const [deletedEntities, setDeletedEntities] = React.useState<Entity<M>[]>([]);\n\n // number of entities in the collection (undefined = loading)\n const [docsCount, setDocsCount] = useState<number | null | undefined>(null);\n\n // Optimistic state for column order to prevent UI flickering during persistence\n const [localPropertiesOrder, setLocalPropertiesOrder] = useState<string[] | undefined>(collection.propertiesOrder);\n\n // Sync local state with collection's propertiesOrder when it changes from\n // external sources. By value, not by identity: the merged collection is\n // rebuilt whenever the user config changes, and an array with the same\n // keys in it is not an external change to follow.\n useEffect(() => {\n setLocalPropertiesOrder(previous => equal(previous, collection.propertiesOrder) ? previous : collection.propertiesOrder);\n }, [collection.propertiesOrder]);\n\n const unselectNavigatedEntity = useCallback(() => {\n const currentSelection = highlightedId;\n setTimeout(() => {\n if (currentSelection === highlightedId)\n setHighlightedId(undefined);\n }, 2400);\n }, [highlightedId]);\n\n // From this render's collection. It was read from `collectionRef`,\n // which an effect updates after the render that reads it, so a change\n // to `inlineEditing` (or to what the user may edit) reached the table\n // one render late — or never, if nothing rendered again.\n const inlineEditingEnabled = canEdit(collection, path, null) &&\n (collection.inlineEditing === undefined || collection.inlineEditing);\n\n const selectionEnabled = collection.selectionEnabled === undefined || collection.selectionEnabled;\n const hoverRow = !inlineEditingEnabled;\n\n // Custom view modes this collection can render: the ones declared\n // inline plus the ones it names by key from the app-level registry.\n // Anything unresolvable is dropped here, once, so every consumer below\n // — the switcher, `enabledViews`, the URL and saved-config checks —\n // agrees on what exists.\n const resolvedCustomViews = useMemo(\n () => resolveCollectionViews(collection.customViews, customizationController.collectionViews),\n [collection.customViews, customizationController]\n );\n\n const customViewKeys = useMemo(\n () => resolvedCustomViews.map((v) => v.key),\n [resolvedCustomViews]\n );\n\n // View mode priority: the caller's `viewMode` > URL > saved user config >\n // collection.defaultViewMode\n const defaultViewMode = isViewMode(collection.defaultViewMode, customViewKeys)\n ? collection.defaultViewMode\n // Covers a `defaultViewMode` naming a custom view that has since\n // been removed from config; without this the collection would open\n // on a mode nothing renders.\n : \"list\";\n const [searchParams, setSearchParams] = useSearchParams();\n\n // Read view from React Router's searchParams (reactive on back/forward).\n // Only for a view that keeps its state in the URL: a record's tab or a\n // panel on a page would otherwise follow — and write — the `__view` of\n // the page around it.\n const urlView = useMemo((): ViewMode | null => {\n if (!updateUrl) return null;\n const v = searchParams.get(VIEW_MODE_PARAM);\n return isViewMode(v, customViewKeys) ? v : null;\n }, [updateUrl, searchParams, customViewKeys]);\n\n // The mode the caller asked for. It wins when the view mounts, over the\n // URL and what the person last picked; once they pick here, theirs does.\n const callerViewMode = isViewMode(viewModeProp, customViewKeys) ? viewModeProp : undefined;\n const pickedViewModeRef = React.useRef(false);\n\n // Get saved view from local persistence.\n //\n // Validated rather than cast: what is stored is whatever the user last\n // picked, and a custom view removed from config since then would come\n // back as a mode nothing renders — a blank panel with a working\n // toolbar above it. An unrecognised value reads as \"nothing saved\",\n // which falls through to the collection default.\n const getSavedView = useCallback((): ViewMode | null => {\n const saved = userConfigPersistence?.getCollectionConfig<M>(path)?.defaultViewMode;\n return isViewMode(saved, customViewKeys) ? saved : null;\n }, [userConfigPersistence, path, customViewKeys]);\n\n const [viewMode, setViewModeState] = useState<ViewMode>(() => {\n // Priority: caller > URL > saved config > collection default\n if (callerViewMode) return callerViewMode;\n if (urlView) return urlView;\n const savedView = getSavedView();\n if (savedView) return savedView;\n return defaultViewMode;\n });\n\n const activeCustomView = useMemo(\n () => resolvedCustomViews.find((v) => v.key === viewMode),\n [resolvedCustomViews, viewMode]\n );\n\n const openEntityMode = resolveOpenEntityMode({\n collection,\n viewMode,\n customView: activeCustomView\n });\n\n // Sync URL with current view on init (if view came from saved config)\n useEffect(() => {\n if (updateUrl && !urlView && viewMode !== defaultViewMode) {\n // View came from saved config but URL doesn't have it - update URL without push\n // Built from `window.location.search`, not React Router's\n // `prev`. The table controller writes the filter, sort and\n // search params with `history.replaceState`, which React Router\n // never observes — so `prev` is a stale snapshot, and merging\n // into it silently dropped whatever it had not seen. Switching\n // view mode after typing a search wiped `search=` from the URL,\n // and the next reload came back unfiltered.\n setSearchParams(() => {\n const next = new URLSearchParams(window.location.search);\n next.set(VIEW_MODE_PARAM, viewMode);\n return next;\n }, { replace: true });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- once, on mount: the mode the view opened in goes into the URL\n }, []);\n\n // Update URL when view mode changes (user action)\n const setViewMode = useCallback((newMode: ViewMode) => {\n setViewModeState(newMode);\n if (!updateUrl) return;\n\n // Update URL with __view param via React Router\n setSearchParams(() => {\n // See the note above: the live URL is the only writer both\n // this and the table controller agree on.\n const next = new URLSearchParams(window.location.search);\n if (newMode === defaultViewMode) {\n next.delete(VIEW_MODE_PARAM);\n } else {\n next.set(VIEW_MODE_PARAM, newMode);\n }\n return next;\n });\n }, [defaultViewMode, setSearchParams, updateUrl]);\n\n // Sync viewMode state when URL changes via back/forward navigation, and\n // when the caller asks for another mode. The URL the view mounted with\n // does not count as a change: the caller's mode won over it at mount.\n const previousUrlViewRef = React.useRef(urlView);\n const previousCallerViewModeRef = React.useRef(callerViewMode);\n useEffect(() => {\n const urlChanged = urlView !== previousUrlViewRef.current;\n previousUrlViewRef.current = urlView;\n if (callerViewMode !== previousCallerViewModeRef.current) {\n previousCallerViewModeRef.current = callerViewMode;\n pickedViewModeRef.current = false;\n }\n const callerDecides = callerViewMode !== undefined && !pickedViewModeRef.current;\n if (urlView && (urlChanged || !callerDecides)) {\n setViewModeState(urlView);\n } else if (callerDecides) {\n setViewModeState(callerViewMode);\n } else {\n const savedView = getSavedView();\n setViewModeState(urlView ?? savedView ?? defaultViewMode);\n }\n }, [urlView, getSavedView, defaultViewMode, callerViewMode]);\n\n // List view size state - controls row height and info density\n const [listSize, setListSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n // Card view size state - controls the grid column count\n const [cardSize, setCardSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n // Table view size state - controls row height\n const [tableSize, setTableSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n // Size for custom views that opted in with `sizeable`. One piece of\n // state for all of them: only the active view reads it, and switching\n // between two sizeable custom views keeping the same density is the\n // less surprising behaviour.\n const [customViewSize, setCustomViewSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n const selectionController = useEntitySelectionController<M>();\n // A caller's own, from `useSelectionController`: the admin drives the\n // controller behind it.\n const callerSelectionController = collection.selectionController\n ? entitySelectionControllerOf<M>(collection.selectionController)\n : undefined;\n if (collection.selectionController && !callerSelectionController && !warnedForeignSelection.has(collection.slug)) {\n warnedForeignSelection.add(collection.slug);\n console.warn(`admin.selectionController of \"${collection.slug}\" was not made by useSelectionController(), so the view keeps its own selection.`);\n }\n const usedSelectionController = callerSelectionController ?? selectionController;\n const {\n selection,\n clearSelection,\n toggleEntitySelection\n } = usedSelectionController;\n\n const tableController = useDataTableController<M>({\n path,\n collection,\n lastDeleteTimestamp,\n scrollRestoration,\n updateUrl,\n // The board reads only the search and filters from it; each of its\n // columns runs its own window. A live first page here would be one\n // more subscription nothing draws.\n enabled: viewMode !== \"kanban\"\n });\n\n const tableKey = React.useRef<string>(Math.random().toString(36));\n const popupCell = tableController.popupCell as {\n id: string;\n propertyKey: Extract<keyof M, string>;\n cellRect?: DOMRect;\n } | undefined;\n\n const onPopupClose = useCallback(() => {\n tableController.setPopupCell?.(undefined);\n }, [tableController.setPopupCell]);\n\n const onEntityClick = useCallback((clickedEntity: Entity<M>) => {\n const collection = collectionRef.current;\n setHighlightedId(clickedEntity.id);\n // The caller's handler takes the row instead of the view opening it.\n if (onRowClickProp) {\n onRowClickProp(rowOfEntity(clickedEntity, collection), String(clickedEntity.id));\n return;\n }\n analyticsController.onAnalyticsEvent?.(\"edit_entity_clicked\", {\n path: clickedEntity.path,\n entityId: clickedEntity.id\n });\n\n if (collection) {\n addRecentId(collection.slug, clickedEntity.id);\n }\n\n const entityPath = path ?? clickedEntity.path;\n // The row on screen is what the record opens with, while its own\n // read catches up — the one row clicked, not every row held.\n populateFetchCache(entityPath, [clickedEntity]);\n navigateToEntity({\n navigation: urlController,\n path: entityPath,\n sidePanelController,\n openEntityMode,\n collection,\n id: clickedEntity.id,\n replace: openEntityMode === \"split\" && selectedEntityIdProp !== undefined\n });\n\n }, [sidePanelController, openEntityMode, selectedEntityIdProp, path, urlController, analyticsController, onRowClickProp]);\n\n // A record created in the side panel or a dialog leaves this view\n // mounted, so it says so the way a delete does: the toolbar counts\n // again, and a table without realtime reads its rows again.\n const onCreatedInPanel = useCallback(() => {\n setLastDeleteTimestamp(Date.now());\n }, []);\n\n /**\n * Attach rows that already exist to this parent.\n *\n * Writing to the row's own address under this parent — `PUT\n * posts/1/tags/5` — is what asserts membership; the backend writes the\n * junction row idempotently. Sending no values keeps it a pure link:\n * the target's own fields are none of this tab's business.\n */\n const linkExistingEntities = useCallback(async (_rows: Record<string, unknown>[], ids: string[]) => {\n const alreadyLinked = new Set(tableController.data.map(e => String(e.id)));\n const toLink = ids.filter(id => !alreadyLinked.has(id));\n if (toLink.length === 0) return;\n\n try {\n await Promise.all(toLink.map(id =>\n saveEntityWithCallbacks<M>({\n path,\n entityId: id,\n values: {} as Partial<M>,\n status: \"existing\",\n collection,\n data: dataClient,\n context\n })\n ));\n setLastDeleteTimestamp(Date.now());\n } catch (e) {\n context.snackbarController?.open({\n type: \"error\",\n message: e instanceof Error ? e.message : String(e)\n });\n }\n }, [dataClient, path, tableController.data, collection, context]);\n\n const selectionDialog = useSelectionDialog<M>({\n // The whole target collection, not this parent's slice of it —\n // otherwise the picker could only ever show rows already linked.\n path: linkedTargetSlug ?? false,\n multiselect: true,\n // On Done, not on every tick: linking is a write, and a row ticked\n // and then unticked must not end up linked.\n onSelectionDone: linkExistingEntities\n });\n\n const openNewDocument = useCallback((defaultValues?: Record<string, unknown>) => {\n const collection = collectionRef.current;\n analyticsController.onAnalyticsEvent?.(\"new_entity_click\", {\n path: path\n });\n navigateToEntity({\n openEntityMode,\n collection,\n id: undefined,\n defaultValues,\n path: path,\n sidePanelController,\n navigation: urlController,\n onClose: unselectNavigatedEntity,\n onSaved: onCreatedInPanel\n });\n }, [path, sidePanelController, openEntityMode, urlController, unselectNavigatedEntity, onCreatedInPanel]);\n\n // The toolbar's \"new\" and a board column's \"add\" open the same form,\n // one of them with values filled in.\n const onNewClick = useCallback(() => openNewDocument(), [openNewDocument]);\n\n const onMultipleDeleteClick = () => {\n analyticsController.onAnalyticsEvent?.(\"multiple_delete_dialog_open\", {\n path: path\n });\n // The selection itself, not rows: in query mode there are no rows to\n // hand over yet. The dialog confirms against the count and reads\n // them only once the user has said yes.\n setDeleteEntityClicked(selection);\n };\n\n const internalOnEntityDelete = (_path: string, entity: Entity<M>) => {\n analyticsController.onAnalyticsEvent?.(\"single_entity_deleted\", {\n path: path\n });\n // Untick rather than filter a list: in query mode the list does not\n // exist, and \"the ones I selected, minus this one\" is precisely an\n // exclusion.\n toggleEntitySelection(entity, false);\n setDeletedEntities(prev => [...prev, entity]);\n setLastDeleteTimestamp(Date.now());\n };\n\n const internalOnMultipleEntitiesDelete = (_path: string, entities: Entity<M>[]) => {\n analyticsController.onAnalyticsEvent?.(\"multiple_entities_deleted\", {\n path: path\n });\n clearSelection();\n setDeleteEntityClicked(undefined);\n setDeletedEntities(prev => [...prev, ...entities]);\n setLastDeleteTimestamp(Date.now());\n };\n\n // What the plugins' slots are handed: the rows, not the admin's records.\n const rowTableController = tableControllerOf(tableController, collection);\n const rowSelectionController = selectionControllerOf(usedSelectionController, collection, path);\n\n const pluginAddColumnComponents = useSlot(\"collection.add-column\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection,\n tableController: rowTableController\n });\n\n const pluginToolbarWidgets = useSlot(\"collection.toolbar\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection: collection,\n tableController: rowTableController,\n selectionController: rowSelectionController\n });\n\n const pluginEmptyStates = useSlot(\"collection.empty-state\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\nparentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection,\n canCreate: canCreateEntities,\n onNewClick\n });\n\n const pluginWidgets = useSlot(\"collection.widgets\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\nparentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection\n });\n\n const onCollectionModifiedForUser = useCallback((path: string, partialCollection: PartialCollectionConfig<M>) => {\n if (userConfigPersistence) {\n const currentStoredConfig = userConfigPersistence.getCollectionConfig(path);\n const updatedConfig = mergeDeep(currentStoredConfig, partialCollection);\n userConfigPersistence.onCollectionModified(path, updatedConfig);\n }\n }, [userConfigPersistence]);\n\n const onColumnResize = useCallback(({\n width,\n key\n }: OnColumnResizeParams) => {\n\n const collection = collectionRef.current;\n // Only for property columns\n if (!getPropertyInPath(collection.properties, key)) return;\n const localCollection = buildPropertyWidthOverwrite(key, width) as PartialCollectionConfig<M>;\n onCollectionModifiedForUser(path, localCollection);\n }, [onCollectionModifiedForUser, path]);\n\n const onListSizeChanged = useCallback((size: CollectionSize) => {\n setListSize(size);\n if (userConfigPersistence)\n onCollectionModifiedForUser(path, { defaultSize: size })\n }, [onCollectionModifiedForUser, path, userConfigPersistence]);\n\n const onTableSizeChanged = useCallback((size: CollectionSize) => {\n setTableSize(size);\n if (userConfigPersistence)\n onCollectionModifiedForUser(path, { defaultSize: size })\n }, [onCollectionModifiedForUser, path, userConfigPersistence]);\n\n // View mode change: update URL + save to local persistence\n const onViewModeChange = useCallback((mode: ViewMode) => {\n analyticsController.onAnalyticsEvent?.(\"view_mode_changed\", {\n path: path,\n from: viewMode,\n to: mode\n });\n pickedViewModeRef.current = true;\n setViewMode(mode);\n // Save to local persistence for next visit\n if (userConfigPersistence) {\n onCollectionModifiedForUser(path, { defaultViewMode: mode } as PartialCollectionConfig<M>);\n }\n }, [setViewMode, userConfigPersistence, onCollectionModifiedForUser, path, analyticsController, viewMode]);\n\n const createEnabled = canCreate(collection, path);\n\n const { onValueChange, uniqueFieldValidator } = useCollectionInlineEditor({\n path,\n collection,\n dataClient,\n context\n });\n\n // In v4, collections are already resolved, so we use collection directly\n const resolvedCollection = collection;\n\n // Compute the effective enabled views:\n // - Start from collection.enabledViews (defaults to every built-in\n // plus every custom view the collection declared)\n // - Drop anything that resolves to nothing renderable\n // - Filter out kanban if no enum properties exist\n const hasEnumProperty = useMemo(() => {\n return Object.values(resolvedCollection.properties).some((p: Property) => p.type === \"string\" && \"enum\" in p && p.enum);\n }, [resolvedCollection.properties]);\n\n const enabledViews: ViewMode[] = useMemo(() => {\n // Declaring a custom view is enough to offer it — a collection\n // should not have to restate the built-ins in `enabledViews` just\n // to add one. Setting `enabledViews` explicitly still wins.\n const configured = collection.enabledViews\n ?? [...VIEW_MODES, ...customViewKeys];\n const renderable = configured.filter(v => isViewMode(v, customViewKeys));\n if (!hasEnumProperty) {\n return renderable.filter(v => v !== \"kanban\");\n }\n return renderable;\n }, [collection.enabledViews, hasEnumProperty, customViewKeys]);\n\n // Compute available enum properties for kanban column selection\n const kanbanPropertyOptions: KanbanPropertyOption[] = useMemo(() => {\n const options: KanbanPropertyOption[] = [];\n const properties = resolvedCollection.properties;\n\n for (const [key, property] of Object.entries(properties)) {\n const prop = property;\n if (prop && prop.type === \"string\" && \"enum\" in prop && prop.enum) {\n options.push({\n key,\n label: prop.name || key\n });\n }\n }\n\n return options;\n }, [resolvedCollection.properties]);\n\n // Get saved kanban property from user config\n const getSavedKanbanProperty = useCallback((): string | undefined => {\n const saved = userConfigPersistence?.getCollectionConfig<M>(path);\n return (saved as Record<string, unknown>)?.kanbanColumnProperty as string | undefined;\n }, [userConfigPersistence, path]);\n\n // Selected kanban property state - priority: saved config > collection default > first available\n const [selectedKanbanProperty, setSelectedKanbanProperty] = useState<string>(() => {\n const saved = getSavedKanbanProperty();\n if (saved && kanbanPropertyOptions.some(o => o.key === saved)) return saved;\n if (collection.kanban?.columnProperty) return collection.kanban.columnProperty;\n return kanbanPropertyOptions[0]?.key ?? \"\";\n });\n\n // Update selected property if options change and current selection is no longer valid\n useEffect(() => {\n if (kanbanPropertyOptions.length > 0 && !kanbanPropertyOptions.some(o => o.key === selectedKanbanProperty)) {\n const saved = getSavedKanbanProperty();\n if (saved && kanbanPropertyOptions.some(o => o.key === saved)) {\n setSelectedKanbanProperty(saved);\n } else if (collection.kanban?.columnProperty && kanbanPropertyOptions.some(o => o.key === collection.kanban?.columnProperty)) {\n setSelectedKanbanProperty(collection.kanban.columnProperty);\n } else {\n setSelectedKanbanProperty(kanbanPropertyOptions[0]?.key ?? \"\");\n }\n }\n }, [kanbanPropertyOptions, selectedKanbanProperty, getSavedKanbanProperty, collection.kanban?.columnProperty]);\n\n // Handle kanban property change\n const onKanbanPropertyChange = useCallback((property: string) => {\n analyticsController.onAnalyticsEvent?.(\"kanban_property_changed\", {\n path: path,\n property\n });\n setSelectedKanbanProperty(property);\n // Save to local persistence\n if (userConfigPersistence) {\n onCollectionModifiedForUser(path, { kanbanColumnProperty: property } as PartialCollectionConfig<M>);\n }\n }, [userConfigPersistence, onCollectionModifiedForUser, path, analyticsController]);\n\n const getPropertyFor = useCallback(({\n propertyKey,\n entity\n }: GetPropertyForProps<M>) => {\n let property: Property | undefined = getPropertyInPath(collection.properties, propertyKey);\n\n // we might not find the property in the collection if combining property builders and map spread\n if (!property) {\n // these 2 properties are coming from the resolved collection with default values\n property = getPropertyInPath(resolvedCollection.properties, propertyKey);\n }\n\n if (!property) return null;\n // A `conditions` rule or a `dynamicProps` result depends on the\n // row, and the inline editor is judged by it as the form is.\n return resolveCellProperty(property, propertyKey, entity as Entity<Record<string, unknown>>, {\n path,\n authController,\n propertyConfigs: customizationController.propertyConfigs\n });\n }, [collection.properties, resolvedCollection.properties, path, authController, customizationController.propertyConfigs]);\n\n // Use a collection with local propertiesOrder for optimistic UI updates\n const collectionWithLocalOrder = useMemo(() => {\n if (localPropertiesOrder && localPropertiesOrder !== resolvedCollection.propertiesOrder) {\n return {\n ...resolvedCollection,\n // Runtime column order, not authored config: these ids come\n // from the user dragging columns and include additional-field\n // and `subcollection:` ids minted below. `propertiesOrder` is\n // typed against the collection's properties for *authoring*,\n // so widening back to that type is the intent here.\n propertiesOrder: localPropertiesOrder as typeof resolvedCollection.propertiesOrder\n };\n }\n return resolvedCollection;\n }, [resolvedCollection, localPropertiesOrder]);\n\n // `fields` lays the columns out in its own order, over the saved one, and\n // drops the rest.\n const columnsCollection = useMemo(() => stableFields\n ? { ...collectionWithLocalOrder, propertiesOrder: stableFields as typeof collectionWithLocalOrder.propertiesOrder }\n : collectionWithLocalOrder, [collectionWithLocalOrder, stableFields]);\n const laidOutColumnIds = useColumnIds(columnsCollection, true);\n const displayedColumnIds = useMemo(\n () => stableFields ? columnsForFields(laidOutColumnIds, stableFields) : laidOutColumnIds,\n [laidOutColumnIds, stableFields]);\n\n // What the list, the cards and the kanban cards are drawn from: the\n // collection, or only its `fields`.\n const viewCollection = useMemo(\n () => stableFields ? restrictCollectionToFields(collection, stableFields) : collection,\n [collection, stableFields]);\n\n const additionalFields = useMemo(() => {\n // Each child view gets a column that jumps to its tab. Keyed by the\n // view's collection slug, which is the relation key — two relations\n // to the same target used to collapse onto one column id here.\n //\n // Except where the relation was declared as a property and so already\n // has a column showing the child rows: the button then repeated that\n // column's heading verbatim. Filtered here as well as in\n // `useColumnIds` so no id is displayed without a delegate to build it,\n // and so the column picker does not offer the one back.\n const redundant = getRedundantChildViewColumnIds(collectionWithLocalOrder);\n const subcollectionsList = getEntityChildViews(collection)\n .map(v => v.collection as AdminCollection)\n .filter(child => !redundant.has(getSubcollectionColumnId(child)));\n const subcollectionColumns: AdditionalFieldDelegate<M, any>[] = subcollectionsList.map((subcollection: AdminCollection) => {\n return {\n key: getSubcollectionColumnId(subcollection),\n name: subcollection.name,\n width: 200,\n dependencies: [],\n Builder: ({ id }) => (\n <Button\n className={\"max-w-full truncate justify-start\"}\n startIcon={<ArrowRightToLineIcon size={iconSize.small}/>}\n onClick={(event: React.MouseEvent) => {\n event.stopPropagation();\n navigateToEntity({\n openEntityMode,\n collection,\n id,\n selectedTab: subcollection.slug,\n path: path,\n navigation: urlController,\n sidePanelController\n })\n }}>\n {subcollection.name}\n </Button>\n )\n };\n }) ?? EMPTY_ARRAY;\n\n return [\n ...(collection.additionalFields ?? EMPTY_ARRAY),\n ...subcollectionColumns\n ];\n }, [collection, collectionWithLocalOrder, path, sidePanelController, openEntityMode, urlController]);\n\n const updateLastDeleteTimestamp = useCallback(() => {\n setLastDeleteTimestamp(Date.now());\n }, []);\n\n const isSplitLayout = openEntityMode === \"split\";\n const isCompact = isSplitLayout && selectedEntityIdProp !== undefined;\n const activeSelectionEnabled = !isCompact && selectionEnabled;\n\n // Edit opens the record — or, where the caller handles clicks, hands it\n // the row the way a click does.\n const editAction = useMemo<EntityAction>(() => onRowClickProp\n ? {\n ...editEntityAction,\n onClick: ({ row, id, path: rowPath }) => {\n if (row && id !== undefined) onEntityClick(entityOfRow(row, id, rowPath ?? path, collection) as Entity<M>);\n }\n }\n : editEntityAction, [onRowClickProp, onEntityClick, path, collection]);\n\n const getActionsForEntity = useCallback(({\n entity,\n customEntityActions\n }: {\n entity?: Entity<M>,\n customEntityActions?: EntityAction[]\n }): EntityAction[] => {\n const deleteEnabled = entity ? canDelete(collection, path, entity.values) : true;\n const disableActions = collection.disableDefaultActions ?? [];\n const actions: EntityAction[] = [];\n if (!disableActions.includes(\"edit\")) {\n actions.push(editAction);\n }\n if (createEnabled && !disableActions.includes(\"copy\"))\n actions.push(copyEntityAction);\n if (deleteEnabled && !disableActions.includes(\"delete\")) {\n // On a junction-backed tab the server removes the link, not the\n // row. Same request either way — this is the button telling the\n // truth about what it will do.\n actions.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);\n }\n if (customEntityActions)\n return mergeEntityActions(actions, customEntityActions);\n return actions;\n }, [canDelete, collection, path, createEnabled, isLinkedChildView, editAction]);\n\n // Handed the table's layout: the table is drawn inside the view's own\n // box, and that box's width is what decides it.\n const getIdColumnWidth = useCallback((largeLayout: boolean) => {\n const entityActions = getActionsForEntity({});\n const collapsedActions = entityActions.filter(a => a.collapsed !== false);\n const uncollapsedActions = entityActions.filter(a => a.collapsed === false);\n const actionsWidth = uncollapsedActions.length * (largeLayout ? 40 : 30);\n return (largeLayout ? (80 + actionsWidth) : (70 + actionsWidth)) + (collapsedActions.length > 0 ? (largeLayout ? 40 : 30) : 0);\n }, [getActionsForEntity]);\n\n const customEntityActions = useMemo(() => (collection.entityActions ?? EMPTY_ARRAY)\n .map(action => resolveEntityAction(action, customizationController.entityActions))\n .filter(Boolean) as EntityAction<M>[], [collection.entityActions, customizationController.entityActions]);\n\n const tableRowActionsBuilder = useCallback(({\n entity,\n size,\n width,\n frozen\n }: {\n entity: Entity<any>,\n size: CollectionSize,\n width: number,\n frozen?: boolean\n }) => {\n\n const isSelected = usedSelectionController.isEntitySelected(entity);\n\n const actions = getActionsForEntity({\n entity,\n customEntityActions\n });\n\n return (\n <CollectionRowActions\n entity={entity}\n width={width}\n frozen={frozen}\n isSelected={isSelected}\n selectionEnabled={activeSelectionEnabled}\n size={size}\n highlightRow={setHighlightedId}\n unhighlightRow={unselectNavigatedEntity}\n collection={collection}\n path={path}\n actions={actions}\n hideId={collection?.hideIdFromCollection}\n onCollectionChange={updateLastDeleteTimestamp}\n selectionController={usedSelectionController}\n openEntityMode={openEntityMode}\n />\n );\n\n // Everything it reads. It listed two of them, so the row actions\n // kept the first collection, actions, open mode and\n // `selectionEnabled` they were built with.\n }, [updateLastDeleteTimestamp, usedSelectionController, customEntityActions, getActionsForEntity,\n activeSelectionEnabled, unselectNavigatedEntity, collection, path, openEntityMode]);\n\n // What the cards and the kanban cards draw a record's actions from.\n const getCardActions = useCallback(\n (entity: Entity<M>) => getActionsForEntity({ entity, customEntityActions }),\n [getActionsForEntity, customEntityActions]);\n const entityActionsScope = useMemo<EntityActionsScope<M>>(() => ({\n getActions: getCardActions,\n collection,\n path,\n openEntityMode,\n selectionController: usedSelectionController,\n onCollectionChange: updateLastDeleteTimestamp,\n highlightRow: setHighlightedId,\n unhighlightRow: unselectNavigatedEntity\n }), [getCardActions, collection, path, openEntityMode, usedSelectionController, updateLastDeleteTimestamp, unselectNavigatedEntity]);\n\n // Built once per change rather than once per render: each of these is a\n // prop of the table (and of the other views), and a new array or a new\n // element on every render of this component re-rendered every row of the\n // table — twice, the second time for the columns the id header widget\n // rebuilt — on each window emit, count arrival and popover toggle.\n // The caller's selection, where it gives one, among the rows held.\n const shownIds = highlightedIds ?? (highlightedId === undefined ? EMPTY_ARRAY : [highlightedId]);\n const shownKey = shownIds.map(String).join(\"\\u0000\");\n const highlightedEntities = useMemo(() => {\n if (shownIds.length === 0) return EMPTY_ARRAY;\n const wanted = new Set(shownIds.map(String));\n const found = tableController.data.filter(entity => wanted.has(String(entity.id)));\n return found.length > 0 ? found : EMPTY_ARRAY;\n // eslint-disable-next-line react-hooks/exhaustive-deps -- by the ids' value (`shownKey`): a caller's inline array is a new one on each render\n }, [shownKey, tableController.data]);\n const idHeaderWidget = useMemo(() => <EntityIdHeaderWidget\n path={path}\n idPath={path}\n collection={collection}\n openEntityMode={openEntityMode}/>, [path, collection, openEntityMode]);\n\n\n // What \"select all matching\" would stand for right now. `docsCount` is\n // the count for exactly this query — the same one the toolbar shows —\n // so the number offered and the number selected cannot disagree.\n const liveSelectionQuery: SelectionQuery<M> = useMemo(() => ({\n path,\n filterValues: tableController.filterValues,\n searchString: tableController.searchString,\n sortBy: tableController.sortBy\n }), [path, tableController.filterValues, tableController.searchString, tableController.sortBy]);\n\n // A query selection is a promise about a *specific* query, and the\n // filter bar stays live while one is held. Letting it follow the filter\n // would mean the rows about to be deleted are not the rows that were\n // counted and agreed to; keeping the stale query would show rows the\n // selection does not cover as ticked. So the selection is dropped, the\n // way a search does in Gmail, and the banner disappears with it.\n const selectionQueryKey = selection.type === \"query\" ? serializeSelectionQuery(selection.query) : undefined;\n const liveQueryKey = serializeSelectionQuery(liveSelectionQuery);\n useEffect(() => {\n if (selectionQueryKey !== undefined && selectionQueryKey !== liveQueryKey)\n clearSelection();\n }, [selectionQueryKey, liveQueryKey, clearSelection]);\n\n const { resolvedSlots } = customizationController;\n\n // Pre-compute header action slot contributions (avoid useSlot inside callback)\n const headerActionContributions = useMemo(() => resolvedSlots\n .filter(s => s.slot === \"collection.header.action\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50)), [resolvedSlots]);\n\n // This render's values, for PluginHeaderActions. Null when no plugin\n // contributes a header action, so the headers have nothing to follow.\n const headerActionsScope = useMemo<HeaderActionsScope | null>(() => headerActionContributions.length > 0\n ? {\n contributions: headerActionContributions,\n path,\n collection: collection as AdminCollection,\n tableController: rowTableController as TableController,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY\n }\n : null, [headerActionContributions, path, collection, rowTableController, parentCollectionSlugs, parentEntityIds]);\n\n // One component type for the life of the view: the plugins' controls\n // reach it through context. A function declared here was a new\n // component type on every render — the table's columns changed with\n // it, and the header remounted whatever the plugins had drawn, closing\n // anything they had open, on every row update.\n const addColumnComponentInternal = pluginAddColumnComponents.length > 0\n ? PluginAddColumnComponents\n : undefined;\n\n const onColumnsOrderChange = useCallback((newColumns: VirtualTableColumn[]) => {\n // Extract property keys from the new column order\n // Filter to only include actual property columns (not frozen columns, not additional fields, etc.)\n // Deduplicate to clean up any previously duplicated keys\n const seenKeys = new Set<string>();\n const newPropertiesOrder = newColumns\n .filter(col => !col.frozen && getPropertyInPath(collection.properties, col.key))\n .map(col => col.key)\n .filter(key => {\n if (seenKeys.has(key)) return false;\n seenKeys.add(key);\n return true;\n });\n\n // Optimistically update local state to prevent UI flickering\n setLocalPropertiesOrder(newPropertiesOrder);\n\n // Call each plugin's onColumnsReorder callback\n if (customizationController?.plugins) {\n customizationController.plugins\n .filter(plugin => plugin.hooks?.onColumnsReorder)\n .forEach(plugin => {\n plugin.hooks!.onColumnsReorder!({\n fullPath: path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection,\n newPropertiesOrder\n });\n });\n }\n\n // Save to user configuration persistence (local storage)\n if (userConfigPersistence) {\n onCollectionModifiedForUser(path, { propertiesOrder: newPropertiesOrder } as PartialCollectionConfig<M>);\n }\n }, [collection, setLocalPropertiesOrder, customizationController, path, parentCollectionSlugs, parentEntityIds, userConfigPersistence, onCollectionModifiedForUser]);\n\n // Popover open state managed at parent level to prevent closing when view changes\n const [viewModePopoverOpen, setViewModePopoverOpen] = useState(false);\n\n\n // Compute plugin-provided error view for collection loading errors\n const pluginErrorViews = useSlot(\"collection.error\", {\n path,\n collection,\n parentCollectionSlugs,\nparentEntityIds,\n error: tableController.dataLoadingError as Error\n });\n const pluginErrorView = tableController.dataLoadingError && pluginErrorViews.length > 0\n ? pluginErrorViews[0]\n : null;\n\n // Shared empty state — plugin slot takes priority, then override, then default\n // \"No results\" is only true of a view the user narrowed: a search, or\n // a filter they can clear. The collection's `fixedFilter` is its\n // scope, not a filter, and a sort never empties a set — counting the\n // declared default `sort` hid \"Create your first entry\" from every\n // empty collection that declares one.\n const isSearching = !!tableController.searchString;\n const fixedFilter = collection.fixedFilter;\n const isFiltered = isSearching || Object.keys(tableController.filterValues ?? {})\n .some(key => !fixedFilter || !(key in fixedFilter));\n const ResolvedEmptyState = useComponentOverride(\"Collection.EmptyState\", DefaultCollectionEmptyState);\n const ResolvedCollectionActions = useComponentOverride(\"Collection.Actions\", CollectionViewActions);\n const ResolvedCollectionTable = useComponentOverride(\"Collection.Table\", CollectionTableBinding) as typeof CollectionTableBinding;\n const emptyComponent = pluginEmptyStates.length > 0\n ? <>{pluginEmptyStates}</>\n : <ResolvedEmptyState\n canCreate={canCreateEntities && !isFiltered}\n onNewClick={onNewClick}\n isSearching={isSearching}\n isFiltered={isFiltered}\n searchString={tableController.searchString ?? \"\"}\n />;\n\n return {\n t,\n containerRef,\n path,\n parentCollectionSlugs,\n parentEntityIds,\n selectedEntityId: selectedEntityIdProp,\n selectedTab,\n collection,\n collectionRef,\n resolvedCollection,\n canCreateEntities,\n highlightedId,\n setHighlightedId,\n deleteEntityClicked,\n setDeleteEntityClicked,\n lastDeleteTimestamp,\n deletedEntities,\n docsCount,\n setDocsCount,\n inlineEditingEnabled,\n selectionEnabled,\n hoverRow,\n resolvedCustomViews,\n viewMode,\n activeCustomView,\n openEntityMode,\n onViewModeChange,\n listSize,\n cardSize,\n setCardSize,\n tableSize,\n customViewSize,\n setCustomViewSize,\n onListSizeChanged,\n onTableSizeChanged,\n usedSelectionController,\n tableController,\n tableKey,\n popupCell,\n onPopupClose,\n onEntityClick,\n onNewClick,\n openNewDocument,\n linkedTargetSlug,\n isLinkedChildView,\n selectionDialog,\n onMultipleDeleteClick,\n internalOnEntityDelete,\n internalOnMultipleEntitiesDelete,\n pluginAddColumnComponents,\n pluginToolbarWidgets,\n pluginWidgets,\n onColumnResize,\n onValueChange,\n uniqueFieldValidator,\n enabledViews,\n kanbanPropertyOptions,\n selectedKanbanProperty,\n onKanbanPropertyChange,\n getPropertyFor,\n displayedColumnIds,\n additionalFields,\n isSplitLayout,\n isCompact,\n activeSelectionEnabled,\n getActionsForEntity,\n getIdColumnWidth,\n customEntityActions,\n tableRowActionsBuilder,\n highlightedEntities,\n idHeaderWidget,\n liveSelectionQuery,\n headerActionsScope,\n addColumnComponentInternal,\n // With `fields` the order is the caller's: columns are not dragged.\n onColumnsOrderChange: stableFields ? undefined : onColumnsOrderChange,\n viewCollection,\n entityActionsScope,\n title,\n viewModePopoverOpen,\n setViewModePopoverOpen,\n pluginErrorView,\n emptyComponent,\n ResolvedCollectionActions,\n ResolvedCollectionTable\n };\n}\n\n/** What {@link useCollectionViewState} returns: one render's state of a collection view. */\nexport type CollectionViewState<M extends Record<string, unknown> = Record<string, unknown>> =\n ReturnType<typeof useCollectionViewState<M>>;\n\nfunction buildPropertyWidthOverwrite(key: string, width: number): PartialCollectionConfig {\n if (key.includes(\".\")) {\n const [parentKey, ...childKey] = key.split(\".\");\n return { properties: { [parentKey]: buildPropertyWidthOverwrite(childKey.join(\".\"), width) } } as PartialCollectionConfig;\n }\n return { properties: { [key]: { admin: { columnWidth: width } } } } as PartialCollectionConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAM,yCAAyB,IAAI,IAAY;;;;;;;;;;;AAY/C,SAAgB,uBAA0D,EACtE,MAAM,UACN,uBACA,iBAEA,iBAAiB,kBACjB,WAAW,YACX,WACA,kBAAkB,sBAClB,aACA,qBACA,gBACA,QACA,UAAU,cACV,OACA,YAAY,gBACZ,SAAS,UACT,GAAG,kBAC2B;CAE9B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,UAAU,gBAAgB;CAChC,MAAM,qBAAqB,gCAAgC;CAC3D,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,OAAO,YAAY,eAAe;CACxC,MAAM,aAAa,QAAQ;CAC3B,MAAM,sBAAsB,aAAa;CACzC,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,wBAAwB,gCAAgC;CAC9D,MAAM,sBAAsB,uBAAuB;CACnD,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,EAAE,WAAW,SAAS,cAAc,eAAe;;;;;;CAQzD,MAAM,kBAAkB,mBAAmB,IAAI;CAC/C,MAAM,oB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Y;EACjD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ;AAMA,SAAS,4BAA4B,KAAa,OAAwC;CACtF,IAAI,IAAI,SAAS,GAAG,GAAG;EACnB,MAAM,CAAC,WAAW,GAAG,YAAY,IAAI,MAAM,GAAG;EAC9C,OAAO,EAAE,YAAY,GAAG,YAAY,4BAA4B,SAAS,KAAK,GAAG,GAAG,KAAK,EAAE,EAAE;CACjG;CACA,OAAO,EAAE,YAAY,GAAG,MAAM,EAAE,OAAO,EAAE,aAAa,MAAM,EAAE,EAAE,EAAE;AACtE"}
|
|
1
|
+
{"version":3,"file":"useCollectionViewState.js","names":[],"sources":["../../../src/components/CollectionViewBinding/useCollectionViewState.tsx"],"sourcesContent":["import type { AdditionalFieldDelegate, EntityAction, AdminCollection, Property } from \"@rebasepro/cms-types\";\nimport {\n CollectionSize,\n EntitySelection,\n TableController,\n SelectionQuery,\n ViewMode,\n getEntityChildViews,\n Entity\n} from \"@rebasepro/cms-types\";\nimport { serializeSelectionQuery } from \"../../selection\";\nimport type { UiFieldPreferences, UiTablePreferences } from \"@rebasepro/types\";\nimport { userPreferencesOverlay } from \"../../hooks/navigation/user_preferences_overlay\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useSearchParams } from \"react-router\";\n\nimport { deepEqual as equal, shallowEqual } from \"fast-equals\"\nimport { CollectionRowActions, CollectionTableBinding } from \"../CollectionTableBinding\";\nimport { useCollectionInlineEditor } from \"./hooks/useCollectionInlineEditor\";\nimport { navigateToEntity } from \"../../util/navigation_utils\";\nimport { mergeEntityActions } from \"../../util/entity_actions\";\nimport { resolveCollectionViews, resolveEntityAction } from \"../../util/resolutions\";\nimport { getPropertyInPath } from \"../../util/property_utils\";\nimport {\n OnColumnResizeParams,\n getRedundantChildViewColumnIds,\n useAnalyticsController,\n useAuthController,\n useColumnIds,\n useComponentOverride,\n useCustomizationController,\n useData,\n useDataTableController,\n populateFetchCache,\n usePermissions,\n useScrollRestoration,\n useSlot,\n useTranslation,\n useUserConfigurationPersistence,\n saveEntityWithCallbacks\n} from \"@rebasepro/app\";\nimport { CollectionViewActions } from \"./CollectionViewActions\";\nimport { KanbanPropertyOption } from \"./ViewModeToggle\";\nimport { DefaultCollectionEmptyState } from \"./DefaultCollectionEmptyState\";\nimport {\n ArrowRightToLineIcon,\n Button,\n iconSize,\n VirtualTableColumn\n} from \"@rebasepro/ui\";\nimport { getSubcollectionColumnId } from \"../CollectionTableBinding/internal/common\";\nimport { copyEntityAction, deleteEntityAction, editEntityAction, unlinkEntityAction } from \"../common/default_entity_actions\";\nimport { GetPropertyForProps } from \"../CollectionTableBinding/CollectionTableBindingProps\";\nimport { resolveCellProperty } from \"../../form/resolve_cell_property\";\nimport { useEntitySelectionController } from \"./useSelectionController\";\nimport { addRecentId } from \"./utils\";\nimport { isViewMode, resolveOpenEntityMode, VIEW_MODE_PARAM, VIEW_MODES } from \"../../util/view_mode\";\nimport { mergeDeep } from \"@rebasepro/utils\";\nimport { useAdminContext } from \"../../hooks/useAdminContext\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../../hooks/useSidePanel\";\nimport { useUrlController } from \"../../hooks/navigation/contexts/UrlContext\";\nimport { useChildViewSource } from \"../../hooks/useChildViewSource\";\nimport { useSelectionDialog } from \"../../hooks/useSelectionDialog\";\nimport { EntityIdHeaderWidget } from \"./EntityIdHeaderWidget\";\nimport { EMPTY_ARRAY, HeaderActionsScope, PluginAddColumnComponents } from \"./PluginColumnSlots\";\nimport type { CollectionViewBindingProps } from \"./CollectionViewBinding\";\nimport { columnsForFields, restrictCollectionToFields } from \"./fields\";\nimport type { EntityActionsScope } from \"./CollectionEntityActions\";\nimport { entityOfRow, entitySelectionControllerOf, rowOfEntity, selectionControllerOf, tableControllerOf } from \"@rebasepro/app\";\n\n/** The collections already warned about a foreign `admin.selectionController`: the warning is said once, not on every render. */\nconst warnedForeignSelection = new Set<string>();\n\n/**\n * Everything a collection view holds and decides: the collection it draws\n * (the registry's copy, the user's saved config and the caller's overrides,\n * in that order), its data and selection controllers, the view mode and\n * sizes, and the handlers its toolbar, views and dialogs call.\n *\n * One hook, so the toolbar, the view switch and the dialogs read the same\n * render's values: they were one component, and each part relies on a\n * decision another part made in the same render.\n */\nexport function useCollectionViewState<M extends Record<string, unknown>>({\n path: pathProp,\n parentCollectionSlugs,\n parentEntityIds,\n // Not state: the composition draws them.\n isSubCollection: _isSubCollection,\n className: _className,\n updateUrl,\n selectedEntityId: selectedEntityIdProp,\n selectedTab,\n collectionOverrides,\n highlightedIds,\n fields,\n viewMode: viewModeProp,\n title,\n onRowClick: onRowClickProp,\n toolbar: _toolbar,\n ...collectionProp\n}: CollectionViewBindingProps<M>) {\n\n const { t } = useTranslation();\n const context = useAdminContext();\n const collectionRegistry = useCollectionRegistryController();\n const urlController = useUrlController();\n const path = pathProp ?? collectionProp.slug;\n const dataClient = useData();\n const sidePanelController = useSidePanel();\n const authController = useAuthController();\n const userConfigPersistence = useUserConfigurationPersistence();\n const analyticsController = useAnalyticsController();\n const customizationController = useCustomizationController();\n const { canCreate, canEdit, canDelete } = usePermissions();\n\n\n /**\n * Rows shared with other parents through a junction. The parent owns\n * the link, not the row — so the destructive action is a removal from\n * this record, which is what the server performs for such a path.\n */\n const childViewSource = useChildViewSource(path);\n const isLinkedChildView = childViewSource?.kind === \"relation\" && childViewSource.mode === \"linked\";\n const linkedTargetSlug = isLinkedChildView && childViewSource.kind === \"relation\"\n ? childViewSource.targetSlug\n : undefined;\n\n const containerRef = React.useRef<HTMLDivElement>(null);\n\n const scrollRestoration = useScrollRestoration();\n\n // `collectionProp` is a rest object: a new value on every render of this\n // component, even when nothing in it changed. Everything below derives\n // from it — the merged collection, its properties, the table's columns —\n // so an identity-only change rebuilt all of them each render, and\n // `mergeDeep` handed back a fresh `propertiesOrder` array every time,\n // which the sync effect below read as a change and set state for: a\n // render loop, and a table that threw away the column width the user\n // had just dragged. Hold the last rest object that actually differs.\n //\n // Shallow is enough, and is the comparison that fits: a re-render this\n // component causes itself re-spreads the same props, so every value in\n // the new object is the same reference. A render caused from above has\n // already been through this component's own props comparator, which is\n // where a deep difference is decided.\n const collectionPropRef = React.useRef(collectionProp);\n if (!shallowEqual(collectionPropRef.current, collectionProp)) {\n collectionPropRef.current = collectionProp;\n }\n const stableCollectionProp = collectionPropRef.current;\n\n // `fields` by value, for the same reason: a caller writes it as a literal.\n const fieldsRef = React.useRef(fields);\n if (!equal(fieldsRef.current, fields)) fieldsRef.current = fields;\n const stableFields = fieldsRef.current;\n\n const overridesRef = React.useRef(collectionOverrides);\n if (!equal(overridesRef.current, collectionOverrides)) overridesRef.current = collectionOverrides;\n const stableOverrides = overridesRef.current;\n\n const collection = useMemo(() => {\n const registryCollection = collectionRegistry.getCollection(path) || stableCollectionProp;\n // The user's own preferences, the composition's last layer.\n const userOverride = userConfigPersistence\n ? userPreferencesOverlay(userConfigPersistence.getTablePreferences(path), new Set(Object.keys(registryCollection.properties ?? {})))\n : undefined;\n const drawn = (userOverride ? mergeDeep(registryCollection, userOverride) : registryCollection) as AdminCollection<M>;\n return stableOverrides ? { ...drawn, ...stableOverrides } as AdminCollection<M> : drawn;\n }, [stableCollectionProp, path, userConfigPersistence, collectionRegistry, stableOverrides]);\n\n const collectionRef = React.useRef(collection);\n useEffect(() => {\n collectionRef.current = collection;\n }, [collection]);\n\n const canCreateEntities = canCreate(collection, path);\n // By id: the row actions that set it hand an id, and the views compare ids.\n const [highlightedId, setHighlightedId] = useState<string | number | undefined>(undefined);\n const [deleteEntityClicked, setDeleteEntityClicked] = React.useState<Entity<M> | EntitySelection<M> | undefined>(undefined);\n\n const [lastDeleteTimestamp, setLastDeleteTimestamp] = React.useState<number>(0);\n\n // Track recently deleted entities for optimistic Kanban count updates\n const [deletedEntities, setDeletedEntities] = React.useState<Entity<M>[]>([]);\n\n // number of entities in the collection (undefined = loading)\n const [docsCount, setDocsCount] = useState<number | null | undefined>(null);\n\n // Optimistic state for column order to prevent UI flickering during persistence\n const [localPropertiesOrder, setLocalPropertiesOrder] = useState<string[] | undefined>(collection.propertiesOrder);\n\n // Sync local state with collection's propertiesOrder when it changes from\n // external sources. By value, not by identity: the merged collection is\n // rebuilt whenever the user config changes, and an array with the same\n // keys in it is not an external change to follow.\n useEffect(() => {\n setLocalPropertiesOrder(previous => equal(previous, collection.propertiesOrder) ? previous : collection.propertiesOrder);\n }, [collection.propertiesOrder]);\n\n const unselectNavigatedEntity = useCallback(() => {\n const currentSelection = highlightedId;\n setTimeout(() => {\n if (currentSelection === highlightedId)\n setHighlightedId(undefined);\n }, 2400);\n }, [highlightedId]);\n\n // From this render's collection. It was read from `collectionRef`,\n // which an effect updates after the render that reads it, so a change\n // to `inlineEditing` (or to what the user may edit) reached the table\n // one render late — or never, if nothing rendered again.\n const inlineEditingEnabled = canEdit(collection, path, null) &&\n (collection.inlineEditing === undefined || collection.inlineEditing);\n\n const selectionEnabled = collection.selectionEnabled === undefined || collection.selectionEnabled;\n const hoverRow = !inlineEditingEnabled;\n\n // Custom view modes this collection can render: the ones declared\n // inline plus the ones it names by key from the app-level registry.\n // Anything unresolvable is dropped here, once, so every consumer below\n // — the switcher, `enabledViews`, the URL and saved-config checks —\n // agrees on what exists.\n const resolvedCustomViews = useMemo(\n () => resolveCollectionViews(collection.customViews, customizationController.collectionViews),\n [collection.customViews, customizationController]\n );\n\n const customViewKeys = useMemo(\n () => resolvedCustomViews.map((v) => v.key),\n [resolvedCustomViews]\n );\n\n // View mode priority: the caller's `viewMode` > URL > saved user config >\n // collection.defaultViewMode\n const defaultViewMode = isViewMode(collection.defaultViewMode, customViewKeys)\n ? collection.defaultViewMode\n // Covers a `defaultViewMode` naming a custom view that has since\n // been removed from config; without this the collection would open\n // on a mode nothing renders.\n : \"list\";\n const [searchParams, setSearchParams] = useSearchParams();\n\n // Read view from React Router's searchParams (reactive on back/forward).\n // Only for a view that keeps its state in the URL: a record's tab or a\n // panel on a page would otherwise follow — and write — the `__view` of\n // the page around it.\n const urlView = useMemo((): ViewMode | null => {\n if (!updateUrl) return null;\n const v = searchParams.get(VIEW_MODE_PARAM);\n return isViewMode(v, customViewKeys) ? v : null;\n }, [updateUrl, searchParams, customViewKeys]);\n\n // The mode the caller asked for. It wins when the view mounts, over the\n // URL and what the person last picked; once they pick here, theirs does.\n const callerViewMode = isViewMode(viewModeProp, customViewKeys) ? viewModeProp : undefined;\n const pickedViewModeRef = React.useRef(false);\n\n // Get saved view from local persistence.\n //\n // Validated rather than cast: what is stored is whatever the user last\n // picked, and a custom view removed from config since then would come\n // back as a mode nothing renders — a blank panel with a working\n // toolbar above it. An unrecognised value reads as \"nothing saved\",\n // which falls through to the collection default.\n const getSavedView = useCallback((): ViewMode | null => {\n const saved = userConfigPersistence?.getTablePreferences(path).defaultViewMode;\n return isViewMode(saved, customViewKeys) ? saved : null;\n }, [userConfigPersistence, path, customViewKeys]);\n\n const [viewMode, setViewModeState] = useState<ViewMode>(() => {\n // Priority: caller > URL > saved config > collection default\n if (callerViewMode) return callerViewMode;\n if (urlView) return urlView;\n const savedView = getSavedView();\n if (savedView) return savedView;\n return defaultViewMode;\n });\n\n const activeCustomView = useMemo(\n () => resolvedCustomViews.find((v) => v.key === viewMode),\n [resolvedCustomViews, viewMode]\n );\n\n const openEntityMode = resolveOpenEntityMode({\n collection,\n viewMode,\n customView: activeCustomView\n });\n\n // Sync URL with current view on init (if view came from saved config)\n useEffect(() => {\n if (updateUrl && !urlView && viewMode !== defaultViewMode) {\n // View came from saved config but URL doesn't have it - update URL without push\n // Built from `window.location.search`, not React Router's\n // `prev`. The table controller writes the filter, sort and\n // search params with `history.replaceState`, which React Router\n // never observes — so `prev` is a stale snapshot, and merging\n // into it silently dropped whatever it had not seen. Switching\n // view mode after typing a search wiped `search=` from the URL,\n // and the next reload came back unfiltered.\n setSearchParams(() => {\n const next = new URLSearchParams(window.location.search);\n next.set(VIEW_MODE_PARAM, viewMode);\n return next;\n }, { replace: true });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- once, on mount: the mode the view opened in goes into the URL\n }, []);\n\n // Update URL when view mode changes (user action)\n const setViewMode = useCallback((newMode: ViewMode) => {\n setViewModeState(newMode);\n if (!updateUrl) return;\n\n // Update URL with __view param via React Router\n setSearchParams(() => {\n // See the note above: the live URL is the only writer both\n // this and the table controller agree on.\n const next = new URLSearchParams(window.location.search);\n if (newMode === defaultViewMode) {\n next.delete(VIEW_MODE_PARAM);\n } else {\n next.set(VIEW_MODE_PARAM, newMode);\n }\n return next;\n });\n }, [defaultViewMode, setSearchParams, updateUrl]);\n\n // Sync viewMode state when URL changes via back/forward navigation, and\n // when the caller asks for another mode. The URL the view mounted with\n // does not count as a change: the caller's mode won over it at mount.\n const previousUrlViewRef = React.useRef(urlView);\n const previousCallerViewModeRef = React.useRef(callerViewMode);\n useEffect(() => {\n const urlChanged = urlView !== previousUrlViewRef.current;\n previousUrlViewRef.current = urlView;\n if (callerViewMode !== previousCallerViewModeRef.current) {\n previousCallerViewModeRef.current = callerViewMode;\n pickedViewModeRef.current = false;\n }\n const callerDecides = callerViewMode !== undefined && !pickedViewModeRef.current;\n if (urlView && (urlChanged || !callerDecides)) {\n setViewModeState(urlView);\n } else if (callerDecides) {\n setViewModeState(callerViewMode);\n } else {\n const savedView = getSavedView();\n setViewModeState(urlView ?? savedView ?? defaultViewMode);\n }\n }, [urlView, getSavedView, defaultViewMode, callerViewMode]);\n\n // List view size state - controls row height and info density\n const [listSize, setListSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n // Card view size state - controls the grid column count\n const [cardSize, setCardSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n // Table view size state - controls row height\n const [tableSize, setTableSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n // Size for custom views that opted in with `sizeable`. One piece of\n // state for all of them: only the active view reads it, and switching\n // between two sizeable custom views keeping the same density is the\n // less surprising behaviour.\n const [customViewSize, setCustomViewSize] = useState<CollectionSize>(collection.defaultSize ?? \"m\");\n\n const selectionController = useEntitySelectionController<M>();\n // A caller's own, from `useSelectionController`: the admin drives the\n // controller behind it.\n const callerSelectionController = collection.selectionController\n ? entitySelectionControllerOf<M>(collection.selectionController)\n : undefined;\n if (collection.selectionController && !callerSelectionController && !warnedForeignSelection.has(collection.slug)) {\n warnedForeignSelection.add(collection.slug);\n console.warn(`admin.selectionController of \"${collection.slug}\" was not made by useSelectionController(), so the view keeps its own selection.`);\n }\n const usedSelectionController = callerSelectionController ?? selectionController;\n const {\n selection,\n clearSelection,\n toggleEntitySelection\n } = usedSelectionController;\n\n const tableController = useDataTableController<M>({\n path,\n collection,\n lastDeleteTimestamp,\n scrollRestoration,\n updateUrl,\n // The board reads only the search and filters from it; each of its\n // columns runs its own window. A live first page here would be one\n // more subscription nothing draws.\n enabled: viewMode !== \"kanban\"\n });\n\n const tableKey = React.useRef<string>(Math.random().toString(36));\n const popupCell = tableController.popupCell as {\n id: string;\n propertyKey: Extract<keyof M, string>;\n cellRect?: DOMRect;\n } | undefined;\n\n const onPopupClose = useCallback(() => {\n tableController.setPopupCell?.(undefined);\n }, [tableController.setPopupCell]);\n\n const onEntityClick = useCallback((clickedEntity: Entity<M>) => {\n const collection = collectionRef.current;\n setHighlightedId(clickedEntity.id);\n // The caller's handler takes the row instead of the view opening it.\n if (onRowClickProp) {\n onRowClickProp(rowOfEntity(clickedEntity, collection), String(clickedEntity.id));\n return;\n }\n analyticsController.onAnalyticsEvent?.(\"edit_entity_clicked\", {\n path: clickedEntity.path,\n entityId: clickedEntity.id\n });\n\n if (collection) {\n addRecentId(collection.slug, clickedEntity.id);\n }\n\n const entityPath = path ?? clickedEntity.path;\n // The row on screen is what the record opens with, while its own\n // read catches up — the one row clicked, not every row held.\n populateFetchCache(entityPath, [clickedEntity]);\n navigateToEntity({\n navigation: urlController,\n path: entityPath,\n sidePanelController,\n openEntityMode,\n collection,\n id: clickedEntity.id,\n replace: openEntityMode === \"split\" && selectedEntityIdProp !== undefined\n });\n\n }, [sidePanelController, openEntityMode, selectedEntityIdProp, path, urlController, analyticsController, onRowClickProp]);\n\n // A record created in the side panel or a dialog leaves this view\n // mounted, so it says so the way a delete does: the toolbar counts\n // again, and a table without realtime reads its rows again.\n const onCreatedInPanel = useCallback(() => {\n setLastDeleteTimestamp(Date.now());\n }, []);\n\n /**\n * Attach rows that already exist to this parent.\n *\n * Writing to the row's own address under this parent — `PUT\n * posts/1/tags/5` — is what asserts membership; the backend writes the\n * junction row idempotently. Sending no values keeps it a pure link:\n * the target's own fields are none of this tab's business.\n */\n const linkExistingEntities = useCallback(async (_rows: Record<string, unknown>[], ids: string[]) => {\n const alreadyLinked = new Set(tableController.data.map(e => String(e.id)));\n const toLink = ids.filter(id => !alreadyLinked.has(id));\n if (toLink.length === 0) return;\n\n try {\n await Promise.all(toLink.map(id =>\n saveEntityWithCallbacks<M>({\n path,\n entityId: id,\n values: {} as Partial<M>,\n status: \"existing\",\n collection,\n data: dataClient,\n context\n })\n ));\n setLastDeleteTimestamp(Date.now());\n } catch (e) {\n context.snackbarController?.open({\n type: \"error\",\n message: e instanceof Error ? e.message : String(e)\n });\n }\n }, [dataClient, path, tableController.data, collection, context]);\n\n const selectionDialog = useSelectionDialog<M>({\n // The whole target collection, not this parent's slice of it —\n // otherwise the picker could only ever show rows already linked.\n path: linkedTargetSlug ?? false,\n multiselect: true,\n // On Done, not on every tick: linking is a write, and a row ticked\n // and then unticked must not end up linked.\n onSelectionDone: linkExistingEntities\n });\n\n const openNewDocument = useCallback((defaultValues?: Record<string, unknown>) => {\n const collection = collectionRef.current;\n analyticsController.onAnalyticsEvent?.(\"new_entity_click\", {\n path: path\n });\n navigateToEntity({\n openEntityMode,\n collection,\n id: undefined,\n defaultValues,\n path: path,\n sidePanelController,\n navigation: urlController,\n onClose: unselectNavigatedEntity,\n onSaved: onCreatedInPanel\n });\n }, [path, sidePanelController, openEntityMode, urlController, unselectNavigatedEntity, onCreatedInPanel]);\n\n // The toolbar's \"new\" and a board column's \"add\" open the same form,\n // one of them with values filled in.\n const onNewClick = useCallback(() => openNewDocument(), [openNewDocument]);\n\n const onMultipleDeleteClick = () => {\n analyticsController.onAnalyticsEvent?.(\"multiple_delete_dialog_open\", {\n path: path\n });\n // The selection itself, not rows: in query mode there are no rows to\n // hand over yet. The dialog confirms against the count and reads\n // them only once the user has said yes.\n setDeleteEntityClicked(selection);\n };\n\n const internalOnEntityDelete = (_path: string, entity: Entity<M>) => {\n analyticsController.onAnalyticsEvent?.(\"single_entity_deleted\", {\n path: path\n });\n // Untick rather than filter a list: in query mode the list does not\n // exist, and \"the ones I selected, minus this one\" is precisely an\n // exclusion.\n toggleEntitySelection(entity, false);\n setDeletedEntities(prev => [...prev, entity]);\n setLastDeleteTimestamp(Date.now());\n };\n\n const internalOnMultipleEntitiesDelete = (_path: string, entities: Entity<M>[]) => {\n analyticsController.onAnalyticsEvent?.(\"multiple_entities_deleted\", {\n path: path\n });\n clearSelection();\n setDeleteEntityClicked(undefined);\n setDeletedEntities(prev => [...prev, ...entities]);\n setLastDeleteTimestamp(Date.now());\n };\n\n // What the plugins' slots are handed: the rows, not the admin's records.\n const rowTableController = tableControllerOf(tableController, collection);\n const rowSelectionController = selectionControllerOf(usedSelectionController, collection, path);\n\n const pluginAddColumnComponents = useSlot(\"collection.add-column\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection,\n tableController: rowTableController\n });\n\n const pluginToolbarWidgets = useSlot(\"collection.toolbar\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection: collection,\n tableController: rowTableController,\n selectionController: rowSelectionController\n });\n\n const pluginEmptyStates = useSlot(\"collection.empty-state\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\nparentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection,\n canCreate: canCreateEntities,\n onNewClick\n });\n\n const pluginWidgets = useSlot(\"collection.widgets\", {\n path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\nparentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection\n });\n\n // The user's preferences for this view, as a delta in `customizeTable`'s\n // names: on the server for a signed-in user, in the browser otherwise.\n const onCollectionModifiedForUser = useCallback((path: string, delta: UiTablePreferences) => {\n userConfigPersistence?.saveTablePreferences(path, delta);\n }, [userConfigPersistence]);\n\n const onColumnResize = useCallback(({\n width,\n key\n }: OnColumnResizeParams) => {\n\n const collection = collectionRef.current;\n // Only for property columns\n if (!getPropertyInPath(collection.properties, key)) return;\n onCollectionModifiedForUser(path, { fields: columnWidthPreference(key, width) });\n }, [onCollectionModifiedForUser, path]);\n\n const onListSizeChanged = useCallback((size: CollectionSize) => {\n setListSize(size);\n if (userConfigPersistence)\n onCollectionModifiedForUser(path, { defaultSize: size })\n }, [onCollectionModifiedForUser, path, userConfigPersistence]);\n\n const onTableSizeChanged = useCallback((size: CollectionSize) => {\n setTableSize(size);\n if (userConfigPersistence)\n onCollectionModifiedForUser(path, { defaultSize: size })\n }, [onCollectionModifiedForUser, path, userConfigPersistence]);\n\n // View mode change: update URL + save to local persistence\n const onViewModeChange = useCallback((mode: ViewMode) => {\n analyticsController.onAnalyticsEvent?.(\"view_mode_changed\", {\n path: path,\n from: viewMode,\n to: mode\n });\n pickedViewModeRef.current = true;\n setViewMode(mode);\n // Save to local persistence for next visit\n if (userConfigPersistence) {\n onCollectionModifiedForUser(path, { defaultViewMode: mode });\n }\n }, [setViewMode, userConfigPersistence, onCollectionModifiedForUser, path, analyticsController, viewMode]);\n\n const createEnabled = canCreate(collection, path);\n\n const { onValueChange, uniqueFieldValidator } = useCollectionInlineEditor({\n path,\n collection,\n dataClient,\n context\n });\n\n // In v4, collections are already resolved, so we use collection directly\n const resolvedCollection = collection;\n\n // Compute the effective enabled views:\n // - Start from collection.enabledViews (defaults to every built-in\n // plus every custom view the collection declared)\n // - Drop anything that resolves to nothing renderable\n // - Filter out kanban if no enum properties exist\n const hasEnumProperty = useMemo(() => {\n return Object.values(resolvedCollection.properties).some((p: Property) => p.type === \"string\" && \"enum\" in p && p.enum);\n }, [resolvedCollection.properties]);\n\n const enabledViews: ViewMode[] = useMemo(() => {\n // Declaring a custom view is enough to offer it — a collection\n // should not have to restate the built-ins in `enabledViews` just\n // to add one. Setting `enabledViews` explicitly still wins.\n const configured = collection.enabledViews\n ?? [...VIEW_MODES, ...customViewKeys];\n const renderable = configured.filter(v => isViewMode(v, customViewKeys));\n if (!hasEnumProperty) {\n return renderable.filter(v => v !== \"kanban\");\n }\n return renderable;\n }, [collection.enabledViews, hasEnumProperty, customViewKeys]);\n\n // Compute available enum properties for kanban column selection\n const kanbanPropertyOptions: KanbanPropertyOption[] = useMemo(() => {\n const options: KanbanPropertyOption[] = [];\n const properties = resolvedCollection.properties;\n\n for (const [key, property] of Object.entries(properties)) {\n const prop = property;\n if (prop && prop.type === \"string\" && \"enum\" in prop && prop.enum) {\n options.push({\n key,\n label: prop.name || key\n });\n }\n }\n\n return options;\n }, [resolvedCollection.properties]);\n\n // Get saved kanban property from user config\n const getSavedKanbanProperty = useCallback((): string | undefined => {\n return userConfigPersistence?.getTablePreferences(path).kanban?.columnField;\n }, [userConfigPersistence, path]);\n\n // Selected kanban property state - priority: saved config > collection default > first available\n const [selectedKanbanProperty, setSelectedKanbanProperty] = useState<string>(() => {\n const saved = getSavedKanbanProperty();\n if (saved && kanbanPropertyOptions.some(o => o.key === saved)) return saved;\n if (collection.kanban?.columnProperty) return collection.kanban.columnProperty;\n return kanbanPropertyOptions[0]?.key ?? \"\";\n });\n\n // Update selected property if options change and current selection is no longer valid\n useEffect(() => {\n if (kanbanPropertyOptions.length > 0 && !kanbanPropertyOptions.some(o => o.key === selectedKanbanProperty)) {\n const saved = getSavedKanbanProperty();\n if (saved && kanbanPropertyOptions.some(o => o.key === saved)) {\n setSelectedKanbanProperty(saved);\n } else if (collection.kanban?.columnProperty && kanbanPropertyOptions.some(o => o.key === collection.kanban?.columnProperty)) {\n setSelectedKanbanProperty(collection.kanban.columnProperty);\n } else {\n setSelectedKanbanProperty(kanbanPropertyOptions[0]?.key ?? \"\");\n }\n }\n }, [kanbanPropertyOptions, selectedKanbanProperty, getSavedKanbanProperty, collection.kanban?.columnProperty]);\n\n // Handle kanban property change\n const onKanbanPropertyChange = useCallback((property: string) => {\n analyticsController.onAnalyticsEvent?.(\"kanban_property_changed\", {\n path: path,\n property\n });\n setSelectedKanbanProperty(property);\n // Save to local persistence\n if (userConfigPersistence) {\n onCollectionModifiedForUser(path, { kanban: { columnField: property } });\n }\n }, [userConfigPersistence, onCollectionModifiedForUser, path, analyticsController]);\n\n const getPropertyFor = useCallback(({\n propertyKey,\n entity\n }: GetPropertyForProps<M>) => {\n let property: Property | undefined = getPropertyInPath(collection.properties, propertyKey);\n\n // we might not find the property in the collection if combining property builders and map spread\n if (!property) {\n // these 2 properties are coming from the resolved collection with default values\n property = getPropertyInPath(resolvedCollection.properties, propertyKey);\n }\n\n if (!property) return null;\n // A `conditions` rule or a `dynamicProps` result depends on the\n // row, and the inline editor is judged by it as the form is.\n return resolveCellProperty(property, propertyKey, entity as Entity<Record<string, unknown>>, {\n path,\n authController,\n propertyConfigs: customizationController.propertyConfigs\n });\n }, [collection.properties, resolvedCollection.properties, path, authController, customizationController.propertyConfigs]);\n\n // Use a collection with local propertiesOrder for optimistic UI updates\n const collectionWithLocalOrder = useMemo(() => {\n if (localPropertiesOrder && localPropertiesOrder !== resolvedCollection.propertiesOrder) {\n return {\n ...resolvedCollection,\n // Runtime column order, not authored config: these ids come\n // from the user dragging columns and include additional-field\n // and `subcollection:` ids minted below. `propertiesOrder` is\n // typed against the collection's properties for *authoring*,\n // so widening back to that type is the intent here.\n propertiesOrder: localPropertiesOrder as typeof resolvedCollection.propertiesOrder\n };\n }\n return resolvedCollection;\n }, [resolvedCollection, localPropertiesOrder]);\n\n // `fields` lays the columns out in its own order, over the saved one, and\n // drops the rest.\n const columnsCollection = useMemo(() => stableFields\n ? { ...collectionWithLocalOrder, propertiesOrder: stableFields as typeof collectionWithLocalOrder.propertiesOrder }\n : collectionWithLocalOrder, [collectionWithLocalOrder, stableFields]);\n const laidOutColumnIds = useColumnIds(columnsCollection, true);\n const displayedColumnIds = useMemo(\n () => stableFields ? columnsForFields(laidOutColumnIds, stableFields) : laidOutColumnIds,\n [laidOutColumnIds, stableFields]);\n\n // What the list, the cards and the kanban cards are drawn from: the\n // collection, or only its `fields`.\n const viewCollection = useMemo(\n () => stableFields ? restrictCollectionToFields(collection, stableFields) : collection,\n [collection, stableFields]);\n\n const additionalFields = useMemo(() => {\n // Each child view gets a column that jumps to its tab. Keyed by the\n // view's collection slug, which is the relation key — two relations\n // to the same target used to collapse onto one column id here.\n //\n // Except where the relation was declared as a property and so already\n // has a column showing the child rows: the button then repeated that\n // column's heading verbatim. Filtered here as well as in\n // `useColumnIds` so no id is displayed without a delegate to build it,\n // and so the column picker does not offer the one back.\n const redundant = getRedundantChildViewColumnIds(collectionWithLocalOrder);\n const subcollectionsList = getEntityChildViews(collection)\n .map(v => v.collection as AdminCollection)\n .filter(child => !redundant.has(getSubcollectionColumnId(child)));\n const subcollectionColumns: AdditionalFieldDelegate<M, any>[] = subcollectionsList.map((subcollection: AdminCollection) => {\n return {\n key: getSubcollectionColumnId(subcollection),\n name: subcollection.name,\n width: 200,\n dependencies: [],\n Builder: ({ id }) => (\n <Button\n className={\"max-w-full truncate justify-start\"}\n startIcon={<ArrowRightToLineIcon size={iconSize.small}/>}\n onClick={(event: React.MouseEvent) => {\n event.stopPropagation();\n navigateToEntity({\n openEntityMode,\n collection,\n id,\n selectedTab: subcollection.slug,\n path: path,\n navigation: urlController,\n sidePanelController\n })\n }}>\n {subcollection.name}\n </Button>\n )\n };\n }) ?? EMPTY_ARRAY;\n\n return [\n ...(collection.additionalFields ?? EMPTY_ARRAY),\n ...subcollectionColumns\n ];\n }, [collection, collectionWithLocalOrder, path, sidePanelController, openEntityMode, urlController]);\n\n const updateLastDeleteTimestamp = useCallback(() => {\n setLastDeleteTimestamp(Date.now());\n }, []);\n\n const isSplitLayout = openEntityMode === \"split\";\n const isCompact = isSplitLayout && selectedEntityIdProp !== undefined;\n const activeSelectionEnabled = !isCompact && selectionEnabled;\n\n // Edit opens the record — or, where the caller handles clicks, hands it\n // the row the way a click does.\n const editAction = useMemo<EntityAction>(() => onRowClickProp\n ? {\n ...editEntityAction,\n onClick: ({ row, id, path: rowPath }) => {\n if (row && id !== undefined) onEntityClick(entityOfRow(row, id, rowPath ?? path, collection) as Entity<M>);\n }\n }\n : editEntityAction, [onRowClickProp, onEntityClick, path, collection]);\n\n const getActionsForEntity = useCallback(({\n entity,\n customEntityActions\n }: {\n entity?: Entity<M>,\n customEntityActions?: EntityAction[]\n }): EntityAction[] => {\n const deleteEnabled = entity ? canDelete(collection, path, entity.values) : true;\n const disableActions = collection.disableDefaultActions ?? [];\n const actions: EntityAction[] = [];\n if (!disableActions.includes(\"edit\")) {\n actions.push(editAction);\n }\n if (createEnabled && !disableActions.includes(\"copy\"))\n actions.push(copyEntityAction);\n if (deleteEnabled && !disableActions.includes(\"delete\")) {\n // On a junction-backed tab the server removes the link, not the\n // row. Same request either way — this is the button telling the\n // truth about what it will do.\n actions.push(isLinkedChildView ? unlinkEntityAction : deleteEntityAction);\n }\n if (customEntityActions)\n return mergeEntityActions(actions, customEntityActions);\n return actions;\n }, [canDelete, collection, path, createEnabled, isLinkedChildView, editAction]);\n\n // Handed the table's layout: the table is drawn inside the view's own\n // box, and that box's width is what decides it.\n const getIdColumnWidth = useCallback((largeLayout: boolean) => {\n const entityActions = getActionsForEntity({});\n const collapsedActions = entityActions.filter(a => a.collapsed !== false);\n const uncollapsedActions = entityActions.filter(a => a.collapsed === false);\n const actionsWidth = uncollapsedActions.length * (largeLayout ? 40 : 30);\n return (largeLayout ? (80 + actionsWidth) : (70 + actionsWidth)) + (collapsedActions.length > 0 ? (largeLayout ? 40 : 30) : 0);\n }, [getActionsForEntity]);\n\n const customEntityActions = useMemo(() => (collection.entityActions ?? EMPTY_ARRAY)\n .map(action => resolveEntityAction(action, customizationController.entityActions))\n .filter(Boolean) as EntityAction<M>[], [collection.entityActions, customizationController.entityActions]);\n\n const tableRowActionsBuilder = useCallback(({\n entity,\n size,\n width,\n frozen\n }: {\n entity: Entity<any>,\n size: CollectionSize,\n width: number,\n frozen?: boolean\n }) => {\n\n const isSelected = usedSelectionController.isEntitySelected(entity);\n\n const actions = getActionsForEntity({\n entity,\n customEntityActions\n });\n\n return (\n <CollectionRowActions\n entity={entity}\n width={width}\n frozen={frozen}\n isSelected={isSelected}\n selectionEnabled={activeSelectionEnabled}\n size={size}\n highlightRow={setHighlightedId}\n unhighlightRow={unselectNavigatedEntity}\n collection={collection}\n path={path}\n actions={actions}\n hideId={collection?.hideIdFromCollection}\n onCollectionChange={updateLastDeleteTimestamp}\n selectionController={usedSelectionController}\n openEntityMode={openEntityMode}\n />\n );\n\n // Everything it reads. It listed two of them, so the row actions\n // kept the first collection, actions, open mode and\n // `selectionEnabled` they were built with.\n }, [updateLastDeleteTimestamp, usedSelectionController, customEntityActions, getActionsForEntity,\n activeSelectionEnabled, unselectNavigatedEntity, collection, path, openEntityMode]);\n\n // What the cards and the kanban cards draw a record's actions from.\n const getCardActions = useCallback(\n (entity: Entity<M>) => getActionsForEntity({ entity, customEntityActions }),\n [getActionsForEntity, customEntityActions]);\n const entityActionsScope = useMemo<EntityActionsScope<M>>(() => ({\n getActions: getCardActions,\n collection,\n path,\n openEntityMode,\n selectionController: usedSelectionController,\n onCollectionChange: updateLastDeleteTimestamp,\n highlightRow: setHighlightedId,\n unhighlightRow: unselectNavigatedEntity\n }), [getCardActions, collection, path, openEntityMode, usedSelectionController, updateLastDeleteTimestamp, unselectNavigatedEntity]);\n\n // Built once per change rather than once per render: each of these is a\n // prop of the table (and of the other views), and a new array or a new\n // element on every render of this component re-rendered every row of the\n // table — twice, the second time for the columns the id header widget\n // rebuilt — on each window emit, count arrival and popover toggle.\n // The caller's selection, where it gives one, among the rows held.\n const shownIds = highlightedIds ?? (highlightedId === undefined ? EMPTY_ARRAY : [highlightedId]);\n const shownKey = shownIds.map(String).join(\"\\u0000\");\n const highlightedEntities = useMemo(() => {\n if (shownIds.length === 0) return EMPTY_ARRAY;\n const wanted = new Set(shownIds.map(String));\n const found = tableController.data.filter(entity => wanted.has(String(entity.id)));\n return found.length > 0 ? found : EMPTY_ARRAY;\n // eslint-disable-next-line react-hooks/exhaustive-deps -- by the ids' value (`shownKey`): a caller's inline array is a new one on each render\n }, [shownKey, tableController.data]);\n const idHeaderWidget = useMemo(() => <EntityIdHeaderWidget\n path={path}\n idPath={path}\n collection={collection}\n openEntityMode={openEntityMode}/>, [path, collection, openEntityMode]);\n\n\n // What \"select all matching\" would stand for right now. `docsCount` is\n // the count for exactly this query — the same one the toolbar shows —\n // so the number offered and the number selected cannot disagree.\n const liveSelectionQuery: SelectionQuery<M> = useMemo(() => ({\n path,\n filterValues: tableController.filterValues,\n searchString: tableController.searchString,\n sortBy: tableController.sortBy\n }), [path, tableController.filterValues, tableController.searchString, tableController.sortBy]);\n\n // A query selection is a promise about a *specific* query, and the\n // filter bar stays live while one is held. Letting it follow the filter\n // would mean the rows about to be deleted are not the rows that were\n // counted and agreed to; keeping the stale query would show rows the\n // selection does not cover as ticked. So the selection is dropped, the\n // way a search does in Gmail, and the banner disappears with it.\n const selectionQueryKey = selection.type === \"query\" ? serializeSelectionQuery(selection.query) : undefined;\n const liveQueryKey = serializeSelectionQuery(liveSelectionQuery);\n useEffect(() => {\n if (selectionQueryKey !== undefined && selectionQueryKey !== liveQueryKey)\n clearSelection();\n }, [selectionQueryKey, liveQueryKey, clearSelection]);\n\n const { resolvedSlots } = customizationController;\n\n // Pre-compute header action slot contributions (avoid useSlot inside callback)\n const headerActionContributions = useMemo(() => resolvedSlots\n .filter(s => s.slot === \"collection.header.action\")\n .sort((a, b) => (a.order ?? 50) - (b.order ?? 50)), [resolvedSlots]);\n\n // This render's values, for PluginHeaderActions. Null when no plugin\n // contributes a header action, so the headers have nothing to follow.\n const headerActionsScope = useMemo<HeaderActionsScope | null>(() => headerActionContributions.length > 0\n ? {\n contributions: headerActionContributions,\n path,\n collection: collection as AdminCollection,\n tableController: rowTableController as TableController,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY\n }\n : null, [headerActionContributions, path, collection, rowTableController, parentCollectionSlugs, parentEntityIds]);\n\n // One component type for the life of the view: the plugins' controls\n // reach it through context. A function declared here was a new\n // component type on every render — the table's columns changed with\n // it, and the header remounted whatever the plugins had drawn, closing\n // anything they had open, on every row update.\n const addColumnComponentInternal = pluginAddColumnComponents.length > 0\n ? PluginAddColumnComponents\n : undefined;\n\n const onColumnsOrderChange = useCallback((newColumns: VirtualTableColumn[]) => {\n // Extract property keys from the new column order\n // Filter to only include actual property columns (not frozen columns, not additional fields, etc.)\n // Deduplicate to clean up any previously duplicated keys\n const seenKeys = new Set<string>();\n const newPropertiesOrder = newColumns\n .filter(col => !col.frozen && getPropertyInPath(collection.properties, col.key))\n .map(col => col.key)\n .filter(key => {\n if (seenKeys.has(key)) return false;\n seenKeys.add(key);\n return true;\n });\n\n // Optimistically update local state to prevent UI flickering\n setLocalPropertiesOrder(newPropertiesOrder);\n\n // Call each plugin's onColumnsReorder callback\n if (customizationController?.plugins) {\n customizationController.plugins\n .filter(plugin => plugin.hooks?.onColumnsReorder)\n .forEach(plugin => {\n plugin.hooks!.onColumnsReorder!({\n fullPath: path,\n parentCollectionSlugs: parentCollectionSlugs ?? EMPTY_ARRAY,\n parentEntityIds: parentEntityIds ?? EMPTY_ARRAY,\n collection,\n newPropertiesOrder\n });\n });\n }\n\n // Save to user configuration persistence (local storage)\n if (userConfigPersistence) {\n onCollectionModifiedForUser(path, { fieldOrder: [...newPropertiesOrder] });\n }\n }, [collection, setLocalPropertiesOrder, customizationController, path, parentCollectionSlugs, parentEntityIds, userConfigPersistence, onCollectionModifiedForUser]);\n\n // Popover open state managed at parent level to prevent closing when view changes\n const [viewModePopoverOpen, setViewModePopoverOpen] = useState(false);\n\n\n // Compute plugin-provided error view for collection loading errors\n const pluginErrorViews = useSlot(\"collection.error\", {\n path,\n collection,\n parentCollectionSlugs,\nparentEntityIds,\n error: tableController.dataLoadingError as Error\n });\n const pluginErrorView = tableController.dataLoadingError && pluginErrorViews.length > 0\n ? pluginErrorViews[0]\n : null;\n\n // Shared empty state — plugin slot takes priority, then override, then default\n // \"No results\" is only true of a view the user narrowed: a search, or\n // a filter they can clear. The collection's `fixedFilter` is its\n // scope, not a filter, and a sort never empties a set — counting the\n // declared default `sort` hid \"Create your first entry\" from every\n // empty collection that declares one.\n const isSearching = !!tableController.searchString;\n const fixedFilter = collection.fixedFilter;\n const isFiltered = isSearching || Object.keys(tableController.filterValues ?? {})\n .some(key => !fixedFilter || !(key in fixedFilter));\n const ResolvedEmptyState = useComponentOverride(\"Collection.EmptyState\", DefaultCollectionEmptyState);\n const ResolvedCollectionActions = useComponentOverride(\"Collection.Actions\", CollectionViewActions);\n const ResolvedCollectionTable = useComponentOverride(\"Collection.Table\", CollectionTableBinding) as typeof CollectionTableBinding;\n const emptyComponent = pluginEmptyStates.length > 0\n ? <>{pluginEmptyStates}</>\n : <ResolvedEmptyState\n canCreate={canCreateEntities && !isFiltered}\n onNewClick={onNewClick}\n isSearching={isSearching}\n isFiltered={isFiltered}\n searchString={tableController.searchString ?? \"\"}\n />;\n\n return {\n t,\n containerRef,\n path,\n parentCollectionSlugs,\n parentEntityIds,\n selectedEntityId: selectedEntityIdProp,\n selectedTab,\n collection,\n collectionRef,\n resolvedCollection,\n canCreateEntities,\n highlightedId,\n setHighlightedId,\n deleteEntityClicked,\n setDeleteEntityClicked,\n lastDeleteTimestamp,\n deletedEntities,\n docsCount,\n setDocsCount,\n inlineEditingEnabled,\n selectionEnabled,\n hoverRow,\n resolvedCustomViews,\n viewMode,\n activeCustomView,\n openEntityMode,\n onViewModeChange,\n listSize,\n cardSize,\n setCardSize,\n tableSize,\n customViewSize,\n setCustomViewSize,\n onListSizeChanged,\n onTableSizeChanged,\n usedSelectionController,\n tableController,\n tableKey,\n popupCell,\n onPopupClose,\n onEntityClick,\n onNewClick,\n openNewDocument,\n linkedTargetSlug,\n isLinkedChildView,\n selectionDialog,\n onMultipleDeleteClick,\n internalOnEntityDelete,\n internalOnMultipleEntitiesDelete,\n pluginAddColumnComponents,\n pluginToolbarWidgets,\n pluginWidgets,\n onColumnResize,\n onValueChange,\n uniqueFieldValidator,\n enabledViews,\n kanbanPropertyOptions,\n selectedKanbanProperty,\n onKanbanPropertyChange,\n getPropertyFor,\n displayedColumnIds,\n additionalFields,\n isSplitLayout,\n isCompact,\n activeSelectionEnabled,\n getActionsForEntity,\n getIdColumnWidth,\n customEntityActions,\n tableRowActionsBuilder,\n highlightedEntities,\n idHeaderWidget,\n liveSelectionQuery,\n headerActionsScope,\n addColumnComponentInternal,\n // With `fields` the order is the caller's: columns are not dragged.\n onColumnsOrderChange: stableFields ? undefined : onColumnsOrderChange,\n viewCollection,\n entityActionsScope,\n title,\n viewModePopoverOpen,\n setViewModePopoverOpen,\n pluginErrorView,\n emptyComponent,\n ResolvedCollectionActions,\n ResolvedCollectionTable\n };\n}\n\n/** What {@link useCollectionViewState} returns: one render's state of a collection view. */\nexport type CollectionViewState<M extends Record<string, unknown> = Record<string, unknown>> =\n ReturnType<typeof useCollectionViewState<M>>;\n\n/** A column's width as a field preference; a nested column (`address.city`) nests under its document's `fields`. */\nfunction columnWidthPreference(key: string, width: number): Record<string, UiFieldPreferences> {\n const [head, ...rest] = key.split(\".\");\n return { [head]: rest.length > 0 ? { fields: columnWidthPreference(rest.join(\".\"), width) } : { columnWidth: width } };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAM,yCAAyB,IAAI,IA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AAqB;CAClG,MAAM,0BAA0B,qBAAqB,oBAAoB,sBAAsB;CAC/F,MAAM,iBAAiB,kBAAkB,SAAS,IAC5C,oBAAA,UAAA,EAAA,UAAG,kBAAoB,CAAA,IACvB,oBAAC,oBAAD;EACE,WAAW,qBAAqB,CAAC;EACrB;EACC;EACD;EACZ,cAAc,gBAAgB,gBAAgB;CACjD,CAAA;CAEL,OAAO;EACH;EACA;EACA;EACA;EACA;EACA,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA,sBAAsB,eAAe,KAAA,IAAY;EACjD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ;;AAOA,SAAS,sBAAsB,KAAa,OAAmD;CAC3F,MAAM,CAAC,MAAM,GAAG,QAAQ,IAAI,MAAM,GAAG;CACrC,OAAO,GAAG,OAAO,KAAK,SAAS,IAAI,EAAE,QAAQ,sBAAsB,KAAK,KAAK,GAAG,GAAG,KAAK,EAAE,IAAI,EAAE,aAAa,MAAM,EAAE;AACzH"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { Property, RelationProperty } from "@rebasepro/types";
|
|
3
|
-
import type { Entity, EntityRelation } from "@rebasepro/types";
|
|
4
2
|
import type { PropertyConfig, AdminCollection, EntityDisplayRole } from "@rebasepro/cms-types";
|
|
5
3
|
import { type FormatCollectionDateOptions } from "../../util/format_collection_date.js";
|
|
6
|
-
import type { AuthController } from "@rebasepro/cms-types";
|
|
4
|
+
import type { AuthController, Property, RelationProperty, EntityRelation, Entity } from "@rebasepro/cms-types";
|
|
7
5
|
import { ChipColorScheme } from "@rebasepro/ui";
|
|
8
6
|
/** Whether an authored relation yields many rows. Derived from its kind. */
|
|
9
7
|
export declare function relationCardinality(relation: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreviewSlots.js","names":[],"sources":["../../../src/components/CollectionViewBinding/usePreviewSlots.ts"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport type { Property, RelationProperty } from \"@rebasepro/types\";\nimport type { Entity, EntityRelation } from \"@rebasepro/types\";\nimport type { PropertyConfig, AdminCollection, EntityDisplayRole } from \"@rebasepro/cms-types\";\nimport { getEntityImagePreviewPropertyKey } from \"@rebasepro/app\";\nimport { getDisplayPropertyKey } from \"@rebasepro/app\";\nimport { getLeadingRelationTitleKey, getTitlePropertyCandidates, looksLikeIdentifierValue } from \"@rebasepro/app\";\nimport { getEntityFromCache } from \"@rebasepro/app\";\nimport { getEntityPreviewKeys } from \"../../util/previews\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { formatCollectionDate, type FormatCollectionDateOptions } from \"../../util/format_collection_date\";\nimport type { AuthController } from \"@rebasepro/cms-types\";\nimport { ChipColorScheme, CHIP_COLORS, CHIP_SEED_KEYS, useUiLabels } from \"@rebasepro/ui\";\nimport { useEntityDisplay } from \"../../hooks/useEntityDisplay\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\nexport function relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\n// ── Slot types ────────────────────────────────────────────────────────\n\n/**\n * A resolved \"slot\": what fills one display role for one record.\n *\n * `property` and `propertyKey` are set when the value was read off the record,\n * and absent when a `display` resolver computed it — a computed title has no\n * column behind it, so there is nothing to render it *as*. Renderers must go\n * through {@link SlotValue}, which makes that choice once: a property renders\n * with its own preview (an enum keeps its coloured chip, a date its format), a\n * computed value renders as text.\n */\nexport interface PreviewSlot {\n property?: Property;\n propertyKey?: string;\n value: unknown;\n /**\n * Which display role this slot fills.\n *\n * Load-bearing for the computed case. Without a property there is nothing to\n * infer from, and \"render it as text\" is right for a title and wrong for an\n * image: a resolver that returned a URL had that URL printed inside the card's\n * image frame. The role is the one thing that distinguishes them, so it\n * travels with the slot rather than being re-derived at each call site.\n */\n role?: EntityDisplayRole;\n}\n\n/**\n * Date slot extends the base with a pre-formatted string.\n */\nexport interface DatePreviewSlot extends PreviewSlot {\n formatted: string;\n}\n\n/**\n * A single resolved relation chip — one item to render as a compact chip.\n * For cardinality:\"one\" relations there will be one chip.\n * For cardinality:\"many\" there can be several (capped for layout stability).\n */\nexport interface RelationChipItem {\n /** Human-readable display text for the chip */\n displayName: string;\n /** Relation ID */\n id: string | number;\n}\n\n/**\n * A resolved relation slot — groups all chips for one relation property.\n */\nexport interface RelationChipSlot {\n /** The relation property definition */\n property: RelationProperty;\n /** The property key on this entity (e.g. \"author\", \"tags\") */\n propertyKey: string;\n /** The relation property's user-facing name (e.g. \"Author\", \"Tags\") */\n label: string;\n /** Resolved chip items (display names extracted from eagerly-loaded data) */\n items: RelationChipItem[];\n /** Total count (for \"many\" relations that exceed the chip cap) */\n totalCount: number;\n /** Deterministic color for this relation property */\n colorScheme: ChipColorScheme;\n}\n\n/**\n * Fixed set of preview slots resolved from any entity + collection.\n *\n * Every view (list, card, board) consumes these same slots and decides\n * which ones to render and how. This eliminates duplicated inference\n * logic across view components.\n */\nexport interface EntityPreviewSlots {\n /** MEDIA — image thumbnail or `undefined` (view falls back to icon) */\n image: PreviewSlot | undefined;\n /** PRIMARY — title / name field */\n title: PreviewSlot | undefined;\n /** SECONDARY — subtitle or short description (first non-title text field) */\n subtitle: PreviewSlot | undefined;\n /** RELATIONS — compact chips for all relation properties (one + many) */\n relations: RelationChipSlot[];\n /** STATUS — enum chip (first enum field that isn't the title) */\n status: PreviewSlot | undefined;\n /** META — date / timestamp */\n date: DatePreviewSlot | undefined;\n /**\n * TAGS — free chips beside the status.\n *\n * Declared only. Every other role has an inference ladder behind it, and\n * this one deliberately does not: there is no \"first enum\" or \"looks like a\n * timestamp\" that means *labels*, so guessing would scatter arbitrary chips\n * across every row of every panel that never asked for them.\n *\n * The role existed on `EntityDisplay` and in `useEntityDisplay` before this\n * field did, which is why a declared `display.tags` resolved correctly and\n * then had nowhere to go.\n */\n tags: PreviewSlot | undefined;\n /** Entity ID (always available) */\n entityId: string | number;\n}\n\n// ── Collection-level slot resolution (entity-independent) ─────────────\n\n/**\n * Resolved property keys per slot. This is the expensive part (walks\n * all properties) so we memoize it at the collection level, not per entity.\n */\nexport interface CollectionSlotKeys {\n titleKey: string | undefined;\n /** Every property that could act as the title, best first (see `getTitlePropertyCandidates`) */\n titleKeyCandidates: string[];\n imageKey: string | undefined;\n subtitleKey: string | undefined;\n relationKeys: string[];\n statusKey: string | undefined;\n dateKey: string | undefined;\n /** Declared only — see {@link EntityPreviewSlots.tags}. */\n tagsKey: string | undefined;\n}\n\n/**\n * Resolve which property key fills each slot for a given collection.\n * Pure function — call inside `useMemo`.\n */\nexport function resolveCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n // One row per entity: when the collection leads with a relation and holds no\n // name of its own, that relation *is* what the row is called. See\n // `getLeadingRelationTitleKey` — the general ranking keeps relations last,\n // which is right for a detail header but leaves a junction row titleless.\n const rankedCandidates = getTitlePropertyCandidates(collection);\n const leadingRelationKey = getLeadingRelationTitleKey(collection);\n const titleKeyCandidates = leadingRelationKey\n ? [leadingRelationKey, ...rankedCandidates.filter(key => key !== leadingRelationKey)]\n : rankedCandidates;\n const titleKey = titleKeyCandidates[0];\n // `getEntityImagePreviewPropertyKey` prefers `display.image` itself, so\n // every caller of it — this, the reference card, the board — agrees.\n const imageKey = getEntityImagePreviewPropertyKey(collection);\n\n // Status: declared, else the first string-enum that isn't the title.\n //\n // Everything below this line is inference — \"the first enum\", \"a key that\n // looks like a timestamp\", \"the longest remaining string\". It is a good\n // guess and it is only a guess, so a collection that states the role wins\n // outright and the ladder is skipped. That is the whole point of\n // `admin.display`: the heuristics stay for the collections that never say\n // anything, and stop overruling the ones that do.\n let statusKey: string | undefined = getDisplayPropertyKey(collection, \"status\");\n\n // 1. Explicitly defined in previewProperties\n if (!statusKey && collection.previewProperties) {\n for (const key of collection.previewProperties) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // 2. Explicitly defined in propertiesOrder\n if (!statusKey && collection.propertiesOrder) {\n for (const key of collection.propertiesOrder) {\n if (typeof key === \"string\" && !key.startsWith(\"subcollection:\")) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n }\n\n // 3. Default automatic inference\n if (!statusKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // Date: declared, else a well-known timestamp field, else any date\n let dateKey: string | undefined = getDisplayPropertyKey(collection, \"date\");\n const dateCandidates = [\"updated_at\", \"updatedAt\", \"modified_at\", \"modifiedAt\", \"created_at\", \"createdAt\"];\n if (!dateKey) {\n for (const candidate of dateCandidates) {\n if (collection.properties[candidate]) {\n dateKey = candidate;\n break;\n }\n }\n }\n if (!dateKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"date\") {\n dateKey = key;\n break;\n }\n }\n }\n\n // Relations: collect relation property keys for chip rendering.\n // When propertiesOrder is explicitly set, skip this — relations will\n // be shown in the developer-defined order, not as separate chips.\n const hasExplicitOrder = !!(collection.propertiesOrder as string[] | undefined);\n const relationKeys: string[] = [];\n if (!hasExplicitOrder) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n // The relation filling the title slot is already the row's headline;\n // repeating it as a chip below says the same thing twice.\n if (p.type === \"relation\" && key !== titleKey) {\n relationKeys.push(key);\n }\n }\n }\n\n // Subtitle: first preview key that isn't title/image/status/date/id.\n // When propertiesOrder is not set, also exclude relation keys (they render as chips).\n // Prefer string fields (especially multiline/description-like) over numbers.\n const excludeKeys = new Set([titleKey, imageKey, statusKey, dateKey, ...relationKeys]);\n const previewKeys = getEntityPreviewKeys(authController, collection, propertyConfigs, undefined, 10)\n .filter(k => !excludeKeys.has(k) && k !== \"id\");\n\n // When propertiesOrder is set, respect the developer-defined order (no re-sorting).\n // When not set, sort: strings first (prefer multiline → good description candidate).\n const sortedPreviewKeys = hasExplicitOrder\n ? previewKeys\n : [...previewKeys].sort((a, b) => {\n const propA = collection.properties[a] as Property | undefined;\n const propB = collection.properties[b] as Property | undefined;\n const scoreA = propA?.type === \"string\" ? (propA.admin?.multiline ? 2 : 1) : 0;\n const scoreB = propB?.type === \"string\" ? (propB.admin?.multiline ? 2 : 1) : 0;\n return scoreB - scoreA;\n });\n const subtitleKey = getDisplayPropertyKey(collection, \"subtitle\")\n ?? (sortedPreviewKeys.length > 0 ? sortedPreviewKeys[0] : undefined);\n\n return { titleKey,\ntitleKeyCandidates,\nimageKey,\nsubtitleKey,\nrelationKeys,\nstatusKey,\ndateKey,\ntagsKey: getDisplayPropertyKey(collection, \"tags\") };\n}\n\n// ── Image place ───────────────────────────────────────────────────────\n\n/**\n * Whether a list row, a card or a kanban card keeps its image place where no\n * property fills it, drawing the collection's icon there. A view given\n * `fields` that leaves every image out keeps none.\n *\n * @internal Provided by the collection view; read through {@link useImagePlace}.\n */\nexport const EmptyImagePlaceContext = React.createContext(true);\n\n/**\n * Whether the rows of the collection view around draw an image place: a\n * property fills it (`imageKey`, from {@link useCollectionSlotKeys}), or the\n * view keeps an empty one with the collection's icon. A view given `fields`\n * that leaves every image out keeps none, so the place takes no room — a copy\n * of a card or a row honours `fields` by drawing its thumbnail only when this\n * says so.\n *\n * @group Components\n */\nexport function useImagePlace(imageKey: string | undefined): boolean {\n return React.useContext(EmptyImagePlaceContext) || imageKey !== undefined;\n}\n\n// ── Image unwrapping helper ───────────────────────────────────────────\n\n/**\n * Unwrap image property + value from potential array-of-images.\n * Returns `{ property, value }` where property is the *inner* property\n * and value is the first element (for arrays) or the raw value.\n */\nfunction resolveImageSlot(\n collection: AdminCollection<Record<string, unknown>>,\n imageKey: string,\n entity: Entity<Record<string, unknown>>\n): PreviewSlot | undefined {\n const imageProperty = collection.properties[imageKey];\n if (!imageProperty) return undefined;\n\n const ofProp = \"of\" in imageProperty ? imageProperty.of : undefined;\n const resolvedProperty = ofProp\n ? (Array.isArray(ofProp) ? ofProp[0] : ofProp)\n : imageProperty;\n\n const rawValue = getValueInPath(entity.values, imageKey);\n const resolvedValue = ofProp\n ? (((rawValue as unknown[]) ?? []).length > 0 ? (rawValue as unknown[])[0] : undefined)\n : rawValue;\n\n if (resolvedValue === undefined || resolvedValue === null) return undefined;\n\n return {\n role: \"image\",\n property: resolvedProperty as Property,\n propertyKey: imageKey,\n value: resolvedValue\n };\n}\n\n// ── Title resolution (entity-level) ───────────────────────────────────\n\n/**\n * Walk the collection's ranked title candidates and return the first one that\n * holds something a person can read for this entity. Candidates are already\n * ordered and free of identifier properties; this only rejects values —\n * empties, and strings that turn out to be an id at runtime.\n */\nfunction resolveEntityTitleKey(\n entity: Entity<Record<string, unknown>>,\n candidates: string[]\n): string | undefined {\n for (const key of candidates) {\n const value = getValueInPath(entity.values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\") {\n if (looksLikeIdentifierValue(value)) continue;\n if (value === String(entity.id)) continue;\n }\n return key;\n }\n return candidates[0];\n}\n\n// ── Hook: collection-level slot keys ──────────────────────────────────\n\n/**\n * Resolves which property key fills each preview slot for a collection.\n * Memoized — only recomputes when the collection definition changes.\n *\n * Use this in the parent list/grid component, then pass the result to\n * `resolveEntitySlots` for each entity row.\n */\nexport function useCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n return useMemo(\n () => resolveCollectionSlotKeys(collection, authController, propertyConfigs),\n [collection, authController, propertyConfigs]\n );\n}\n\n// ── Pure function: entity-level slot resolution ───────────────────────\n\n/**\n * Resolve concrete slot values for a single entity.\n * This is a pure function (no hooks) so it can be called inside\n * `React.memo` render functions or loops without violating hook rules.\n */\nexport function resolveEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys,\n /** How the date slot is written: the relative phrases' language, say. */\n dateOptions?: FormatCollectionDateOptions\n): EntityPreviewSlots {\n const { titleKey, titleKeyCandidates, imageKey, subtitleKey, relationKeys, statusKey, dateKey, tagsKey } = slotKeys;\n\n // Image\n const image = imageKey ? resolveImageSlot(collection, imageKey, entity) : undefined;\n\n // Title — the best-ranked candidate that carries a readable value for THIS\n // entity, so a row whose name is empty (or whose column happens to hold a\n // UUID) falls through to the next candidate instead of showing an id.\n const resolvedTitleKey = resolveEntityTitleKey(entity, titleKeyCandidates ?? (titleKey ? [titleKey] : []));\n let title: PreviewSlot | undefined;\n if (resolvedTitleKey) {\n const prop = collection.properties[resolvedTitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, resolvedTitleKey);\n if (prop) title = { role: \"title\",\nproperty: prop,\npropertyKey: resolvedTitleKey,\nvalue: val };\n }\n\n // Subtitle\n let subtitle: PreviewSlot | undefined;\n if (subtitleKey && subtitleKey !== resolvedTitleKey) {\n const prop = collection.properties[subtitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, subtitleKey);\n if (prop && val !== undefined && val !== null && val !== \"\") {\n subtitle = { role: \"subtitle\",\nproperty: prop,\npropertyKey: subtitleKey,\nvalue: val };\n }\n }\n\n // Relations — resolve chip items for every relation property\n const relations: RelationChipSlot[] = [];\n const MAX_CHIPS_PER_RELATION = 3;\n\n for (const relKey of relationKeys) {\n const prop = collection.properties[relKey] as RelationProperty | undefined;\n if (!prop || prop.type !== \"relation\") continue;\n\n const val = getValueInPath(entity.values, relKey);\n if (val === undefined || val === null) continue;\n\n const items: RelationChipItem[] = [];\n let totalCount = 0;\n\n const isMany = relationCardinality(prop.relation) === \"many\";\n\n if (isMany && Array.isArray(val)) {\n // cardinality:\"many\" → array of EntityRelation\n totalCount = val.length;\n for (let i = 0; i < Math.min(val.length, MAX_CHIPS_PER_RELATION); i++) {\n const rel = val[i];\n if (rel && typeof rel === \"object\") {\n const displayName = resolveRelationDisplayName(rel as EntityRelation, prop);\n const id = (rel as EntityRelation).id ?? i;\n if (displayName) {\n items.push({ displayName,\nid });\n }\n }\n }\n } else if (!isMany && val && typeof val === \"object\") {\n // cardinality:\"one\" → single EntityRelation\n const obj = val as Record<string, unknown>;\n const isRelation = (\"__type\" in obj && obj.__type === \"relation\")\n || (typeof obj.isEntityRelation === \"function\"\n && (obj.isEntityRelation as () => boolean)());\n if (isRelation) {\n const displayName = resolveRelationDisplayName(obj, prop);\n totalCount = 1;\n // An `EntityRelation`'s id, or the wire ref's: a string or a number either way.\n const id = obj.id;\n if (displayName && (typeof id === \"string\" || typeof id === \"number\")) {\n items.push({ displayName,\nid });\n }\n }\n }\n\n if (items.length > 0) {\n const relIndex = relationKeys.indexOf(relKey);\n // Walking the seed keys rather than `Object.values`: the table also\n // holds a bare-hue alias per hue, so raw values would hand the first\n // two relations the same scheme.\n const colorScheme = CHIP_COLORS[CHIP_SEED_KEYS[relIndex % CHIP_SEED_KEYS.length]];\n relations.push({\n property: prop,\n propertyKey: relKey,\n label: prop.name || relKey,\n items,\n totalCount,\n colorScheme\n });\n }\n }\n\n // Status\n let status: PreviewSlot | undefined;\n if (statusKey) {\n const prop = collection.properties[statusKey] as Property | undefined;\n const val = getValueInPath(entity.values, statusKey);\n if (prop && val !== undefined && val !== null) {\n status = { role: \"status\",\nproperty: prop,\npropertyKey: statusKey,\nvalue: val };\n }\n }\n\n // Date\n let date: DatePreviewSlot | undefined;\n if (dateKey) {\n const prop = collection.properties[dateKey] as Property | undefined;\n const val = getValueInPath(entity.values, dateKey);\n if (prop && val !== undefined && val !== null) {\n date = {\n role: \"date\",\n property: prop,\n propertyKey: dateKey,\n value: val,\n formatted: formatCollectionDate(val, prop, dateOptions) ?? String(val)\n };\n }\n }\n\n // Tags — declared only, and empty means absent: an empty array is \"this\n // record has no labels\", which must render as nothing rather than as an\n // empty chip row that shifts every other slot down.\n let tags: PreviewSlot | undefined;\n if (tagsKey) {\n const prop = collection.properties[tagsKey] as Property | undefined;\n const val = getValueInPath(entity.values, tagsKey);\n const empty = val === undefined || val === null || val === \"\"\n || (Array.isArray(val) && val.length === 0);\n if (prop && !empty) {\n tags = { role: \"tags\",\nproperty: prop,\npropertyKey: tagsKey,\nvalue: val };\n }\n }\n\n return {\n image,\n title,\n subtitle,\n relations,\n status,\n date,\n tags,\n entityId: entity.id\n };\n}\n\n// ── Relation display name resolution ─────────────────────────────────\n\n/**\n * Extract a human-readable display name from an eagerly-loaded EntityRelation.\n * Uses the target collection's title property when available, otherwise\n * walks the entity values for the first short string; with neither, the id.\n */\nexport function resolveRelationDisplayName(\n relation: EntityRelation | Record<string, unknown>,\n prop: RelationProperty\n): string | undefined {\n const name = loadedRelationName(relation, prop);\n if (name !== undefined) return name;\n const id = \"id\" in relation ? relation.id : undefined;\n return id !== undefined ? String(id) : undefined;\n}\n\n/**\n * The related row's name from what is already on hand — values loaded with\n * the relation, or the entity cache — and nothing else: no id. A bare\n * foreign key has neither, and its caller fetches the row instead of\n * printing the key as though it were the name.\n */\nexport function loadedRelationName(\n relation: EntityRelation | Record<string, unknown>,\n prop: RelationProperty\n): string | undefined {\n // Support both EntityRelation instances and plain objects\n const data = \"data\" in relation ? (relation as EntityRelation).data : undefined;\n\n // Resolve target collection from either `prop.relation.target()` or `prop.relation?.target()` (inline API)\n let targetCollection: AdminCollection | undefined;\n try {\n const resolved = prop.relation?.target?.() ?? (typeof prop.relation?.target === \"function\" ? prop.relation?.target() : undefined);\n if (resolved && typeof resolved === \"object\") {\n targetCollection = resolved as AdminCollection;\n }\n } catch {\n // Target collection may not be resolvable\n }\n\n // Helper: extract display name from entity values using the target collection\n //\n // This used to carry a ranking of its own — priority keys `name/title/label/\n // displayName`, then the first visible non-id string — which is a *seventh*\n // answer to \"what is this record called\", and one that disagreed with the\n // shared one: it read `titleProperty` with a flat lookup (so a dotted path\n // was ignored), never saw `display.title`, and ranked by key name where the\n // shared ranking excludes identifiers structurally. A chip and the record it\n // points at could therefore be labelled differently on the same screen.\n //\n // What is left here is the part that is genuinely local: a relation carries\n // *eagerly loaded* values, not an entity, so a resolver cannot run against\n // it — a computed title falls back to the ranked property, which is the same\n // thing the list row shows while its own resolver is in flight.\n const extractDisplayName = (values: Record<string, unknown>): string | undefined => {\n if (targetCollection) {\n for (const key of getTitlePropertyCandidates(targetCollection)) {\n const value = getValueInPath(values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\" && looksLikeIdentifierValue(value)) continue;\n return String(value);\n }\n }\n // Generic fallback: walk entity values for any short string.\n for (const [, v] of Object.entries(values)) {\n if (typeof v === \"string\" && v.length > 0 && v.length < 200) {\n return v;\n }\n }\n return undefined;\n };\n\n // 1. Try eagerly-loaded data on the relation object\n if (data && data.values) {\n const result = extractDisplayName(data.values as Record<string, unknown>);\n if (result) return result;\n }\n\n const id = \"id\" in relation ? relation.id : undefined;\n\n // 2. Try the entity cache (sessionStorage) as a fallback\n if (id !== undefined && targetCollection) {\n try {\n const slug = targetCollection.slug ?? (\"table\" in targetCollection ? targetCollection.table : undefined);\n if (slug) {\n const cacheKey = `${slug}/${id}`;\n const cached = getEntityFromCache(cacheKey) as { values?: Record<string, unknown> } | undefined;\n if (cached?.values) {\n const result = extractDisplayName(cached.values);\n if (result) return result;\n }\n }\n } catch {\n // Cache lookup failed — fall through\n }\n }\n\n return undefined;\n}\n\n/**\n * The slots for one record, with `admin.display` resolvers applied.\n *\n * {@link resolveEntitySlots} answers the question from values already in hand —\n * which is everything a slot filled by a property needs, and nothing a slot\n * filled by a *resolver* can use. A computed title may have to be fetched, so it\n * arrives after the first render; this hook is where the two meet.\n *\n * Until a resolver lands, the derived slot shows. That is deliberate: a list of\n * fifty rows must not blank its titles for a beat while fifty promises settle,\n * and the derived answer — the best-ranked property carrying a readable value —\n * is a reasonable thing to be looking at meanwhile. When the resolved value\n * arrives it replaces the slot outright, property and all, because there is no\n * property behind a computed value (see {@link PreviewSlot}).\n *\n * Every role is hooked unconditionally, so the hook order is fixed regardless of\n * what a given collection declares.\n */\nexport function useEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys\n): EntityPreviewSlots {\n\n const relativeTimeLabels = useUiLabels().relativeTime;\n const derived = useMemo(\n () => resolveEntitySlots(entity, collection, slotKeys, { relativeTimeLabels }),\n [entity, collection, slotKeys, relativeTimeLabels]\n );\n\n const params = { collection,\nentity };\n const title = useEntityDisplay<string>(\"title\", params);\n const subtitle = useEntityDisplay<string>(\"subtitle\", params);\n const image = useEntityDisplay<string>(\"image\", params);\n const status = useEntityDisplay<string>(\"status\", params);\n const date = useEntityDisplay<Date | string | number>(\"date\", params);\n const tags = useEntityDisplay<string[] | string>(\"tags\", params);\n\n return useMemo(() => {\n // `source` is set only when the value came from a property, so its\n // absence is exactly the \"this was computed\" signal — no second flag to\n // keep in step with the first.\n // The role travels with the computed slot too. It is the only thing left\n // to say about a value with no property behind it, and `SlotValue` needs\n // it to tell a computed image from a computed title.\n const computed = (\n role: EntityDisplayRole,\n resolved: { value: unknown, source?: unknown }\n ): PreviewSlot | undefined =>\n resolved.value !== undefined && resolved.source === undefined\n ? { role,\nvalue: resolved.value }\n : undefined;\n\n const computedDate = computed(\"date\", date);\n\n return {\n ...derived,\n title: computed(\"title\", title) ?? derived.title,\n subtitle: computed(\"subtitle\", subtitle) ?? derived.subtitle,\n image: computed(\"image\", image) ?? derived.image,\n status: computed(\"status\", status) ?? derived.status,\n date: computedDate\n ? { ...computedDate,\nformatted: formatCollectionDate(computedDate.value, undefined, { relativeTimeLabels }) ?? String(computedDate.value) }\n : derived.date,\n tags: computed(\"tags\", tags) ?? derived.tags\n };\n }, [derived, title, subtitle, image, status, date, tags, relativeTimeLabels]);\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,oBAAoB,UAA2F;CAC3H,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAAU,OAAO;CACxE,OAAO,SAAS;AACpB;;;;;AAgIA,SAAgB,0BACZ,YACA,gBACA,iBACkB;CAKlB,MAAM,mBAAmB,2BAA2B,UAAU;CAC9D,MAAM,qBAAqB,2BAA2B,UAAU;CAChE,MAAM,qBAAqB,qBACrB,CAAC,oBAAoB,GAAG,iBAAiB,QAAO,QAAO,QAAQ,kBAAkB,CAAC,IAClF;CACN,MAAM,WAAW,mBAAmB;CAGpC,MAAM,WAAW,iCAAiC,UAAU;CAU5D,IAAI,YAAgC,sBAAsB,YAAY,QAAQ;CAG9E,IAAI,CAAC,aAAa,WAAW,mBACzB,KAAK,MAAM,OAAO,WAAW,mBAAmB;EAC5C,MAAM,IAAI,WAAW,WAAW;EAChC,IAAI,GAAG,SAAS,YAAY,UAAU,KAAK,EAAE,QAAQ,QAAQ,UAAU;GACnE,YAAY;GACZ;EACJ;CACJ;CAIJ,IAAI,CAAC,aAAa,WAAW;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SAAS,UAAU,KAAA,KAAa,SAAS,WAAW,KAAA,IAC9C;GAAE;GACpB,OAAO,SAAS;EAAM,IACJ,KAAA;EAEV,MAAM,eAAe,SAAS,QAAQ,IAAI;EAE1C,OAAO;GACH,GAAG;GACH,OAAO,SAAS,SAAS,KAAK,KAAK,QAAQ;GAC3C,UAAU,SAAS,YAAY,QAAQ,KAAK,QAAQ;GACpD,OAAO,SAAS,SAAS,KAAK,KAAK,QAAQ;GAC3C,QAAQ,SAAS,UAAU,MAAM,KAAK,QAAQ;GAC9C,MAAM,eACA;IAAE,GAAG;IACvB,WAAW,qBAAqB,aAAa,OAAO,KAAA,GAAW,EAAE,mBAAmB,CAAC,KAAK,OAAO,aAAa,KAAK;GAAE,IACnG,QAAQ;GACd,MAAM,SAAS,QAAQ,IAAI,KAAK,QAAQ;EAC5C;CACJ,GAAG;EAAC;EAAS;EAAO;EAAU;EAAO;EAAQ;EAAM;EAAM;CAAkB,CAAC;AAChF"}
|
|
1
|
+
{"version":3,"file":"usePreviewSlots.js","names":[],"sources":["../../../src/components/CollectionViewBinding/usePreviewSlots.ts"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport type { PropertyConfig, AdminCollection, EntityDisplayRole } from \"@rebasepro/cms-types\";\nimport { getEntityImagePreviewPropertyKey } from \"@rebasepro/app\";\nimport { getDisplayPropertyKey } from \"@rebasepro/app\";\nimport { getLeadingRelationTitleKey, getTitlePropertyCandidates, looksLikeIdentifierValue } from \"@rebasepro/app\";\nimport { getEntityFromCache } from \"@rebasepro/app\";\nimport { getEntityPreviewKeys } from \"../../util/previews\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { formatCollectionDate, type FormatCollectionDateOptions } from \"../../util/format_collection_date\";\nimport type { AuthController, Property, RelationProperty, EntityRelation, Entity } from \"@rebasepro/cms-types\";\nimport { ChipColorScheme, CHIP_COLORS, CHIP_SEED_KEYS, useUiLabels } from \"@rebasepro/ui\";\nimport { useEntityDisplay } from \"../../hooks/useEntityDisplay\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\nexport function relationCardinality(relation: { kind?: string; cardinality?: string } | undefined): \"one\" | \"many\" | undefined {\n if (!relation) return undefined;\n if (relation.kind === \"via\") return relation.cardinality as \"one\" | \"many\" | undefined;\n if (relation.kind === \"hasMany\" || relation.kind === \"manyToMany\") return \"many\";\n if (relation.kind === \"belongsTo\" || relation.kind === \"hasOne\") return \"one\";\n return relation.cardinality as \"one\" | \"many\" | undefined;\n}\n\n\n// ── Slot types ────────────────────────────────────────────────────────\n\n/**\n * A resolved \"slot\": what fills one display role for one record.\n *\n * `property` and `propertyKey` are set when the value was read off the record,\n * and absent when a `display` resolver computed it — a computed title has no\n * column behind it, so there is nothing to render it *as*. Renderers must go\n * through {@link SlotValue}, which makes that choice once: a property renders\n * with its own preview (an enum keeps its coloured chip, a date its format), a\n * computed value renders as text.\n */\nexport interface PreviewSlot {\n property?: Property;\n propertyKey?: string;\n value: unknown;\n /**\n * Which display role this slot fills.\n *\n * Load-bearing for the computed case. Without a property there is nothing to\n * infer from, and \"render it as text\" is right for a title and wrong for an\n * image: a resolver that returned a URL had that URL printed inside the card's\n * image frame. The role is the one thing that distinguishes them, so it\n * travels with the slot rather than being re-derived at each call site.\n */\n role?: EntityDisplayRole;\n}\n\n/**\n * Date slot extends the base with a pre-formatted string.\n */\nexport interface DatePreviewSlot extends PreviewSlot {\n formatted: string;\n}\n\n/**\n * A single resolved relation chip — one item to render as a compact chip.\n * For cardinality:\"one\" relations there will be one chip.\n * For cardinality:\"many\" there can be several (capped for layout stability).\n */\nexport interface RelationChipItem {\n /** Human-readable display text for the chip */\n displayName: string;\n /** Relation ID */\n id: string | number;\n}\n\n/**\n * A resolved relation slot — groups all chips for one relation property.\n */\nexport interface RelationChipSlot {\n /** The relation property definition */\n property: RelationProperty;\n /** The property key on this entity (e.g. \"author\", \"tags\") */\n propertyKey: string;\n /** The relation property's user-facing name (e.g. \"Author\", \"Tags\") */\n label: string;\n /** Resolved chip items (display names extracted from eagerly-loaded data) */\n items: RelationChipItem[];\n /** Total count (for \"many\" relations that exceed the chip cap) */\n totalCount: number;\n /** Deterministic color for this relation property */\n colorScheme: ChipColorScheme;\n}\n\n/**\n * Fixed set of preview slots resolved from any entity + collection.\n *\n * Every view (list, card, board) consumes these same slots and decides\n * which ones to render and how. This eliminates duplicated inference\n * logic across view components.\n */\nexport interface EntityPreviewSlots {\n /** MEDIA — image thumbnail or `undefined` (view falls back to icon) */\n image: PreviewSlot | undefined;\n /** PRIMARY — title / name field */\n title: PreviewSlot | undefined;\n /** SECONDARY — subtitle or short description (first non-title text field) */\n subtitle: PreviewSlot | undefined;\n /** RELATIONS — compact chips for all relation properties (one + many) */\n relations: RelationChipSlot[];\n /** STATUS — enum chip (first enum field that isn't the title) */\n status: PreviewSlot | undefined;\n /** META — date / timestamp */\n date: DatePreviewSlot | undefined;\n /**\n * TAGS — free chips beside the status.\n *\n * Declared only. Every other role has an inference ladder behind it, and\n * this one deliberately does not: there is no \"first enum\" or \"looks like a\n * timestamp\" that means *labels*, so guessing would scatter arbitrary chips\n * across every row of every panel that never asked for them.\n *\n * The role existed on `EntityDisplay` and in `useEntityDisplay` before this\n * field did, which is why a declared `display.tags` resolved correctly and\n * then had nowhere to go.\n */\n tags: PreviewSlot | undefined;\n /** Entity ID (always available) */\n entityId: string | number;\n}\n\n// ── Collection-level slot resolution (entity-independent) ─────────────\n\n/**\n * Resolved property keys per slot. This is the expensive part (walks\n * all properties) so we memoize it at the collection level, not per entity.\n */\nexport interface CollectionSlotKeys {\n titleKey: string | undefined;\n /** Every property that could act as the title, best first (see `getTitlePropertyCandidates`) */\n titleKeyCandidates: string[];\n imageKey: string | undefined;\n subtitleKey: string | undefined;\n relationKeys: string[];\n statusKey: string | undefined;\n dateKey: string | undefined;\n /** Declared only — see {@link EntityPreviewSlots.tags}. */\n tagsKey: string | undefined;\n}\n\n/**\n * Resolve which property key fills each slot for a given collection.\n * Pure function — call inside `useMemo`.\n */\nexport function resolveCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n // One row per entity: when the collection leads with a relation and holds no\n // name of its own, that relation *is* what the row is called. See\n // `getLeadingRelationTitleKey` — the general ranking keeps relations last,\n // which is right for a detail header but leaves a junction row titleless.\n const rankedCandidates = getTitlePropertyCandidates(collection);\n const leadingRelationKey = getLeadingRelationTitleKey(collection);\n const titleKeyCandidates = leadingRelationKey\n ? [leadingRelationKey, ...rankedCandidates.filter(key => key !== leadingRelationKey)]\n : rankedCandidates;\n const titleKey = titleKeyCandidates[0];\n // `getEntityImagePreviewPropertyKey` prefers `display.image` itself, so\n // every caller of it — this, the reference card, the board — agrees.\n const imageKey = getEntityImagePreviewPropertyKey(collection);\n\n // Status: declared, else the first string-enum that isn't the title.\n //\n // Everything below this line is inference — \"the first enum\", \"a key that\n // looks like a timestamp\", \"the longest remaining string\". It is a good\n // guess and it is only a guess, so a collection that states the role wins\n // outright and the ladder is skipped. That is the whole point of\n // `admin.display`: the heuristics stay for the collections that never say\n // anything, and stop overruling the ones that do.\n let statusKey: string | undefined = getDisplayPropertyKey(collection, \"status\");\n\n // 1. Explicitly defined in previewProperties\n if (!statusKey && collection.previewProperties) {\n for (const key of collection.previewProperties) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // 2. Explicitly defined in propertiesOrder\n if (!statusKey && collection.propertiesOrder) {\n for (const key of collection.propertiesOrder) {\n if (typeof key === \"string\" && !key.startsWith(\"subcollection:\")) {\n const p = collection.properties[key] as Property | undefined;\n if (p?.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n }\n\n // 3. Default automatic inference\n if (!statusKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"string\" && \"enum\" in p && p.enum && key !== titleKey) {\n statusKey = key;\n break;\n }\n }\n }\n\n // Date: declared, else a well-known timestamp field, else any date\n let dateKey: string | undefined = getDisplayPropertyKey(collection, \"date\");\n const dateCandidates = [\"updated_at\", \"updatedAt\", \"modified_at\", \"modifiedAt\", \"created_at\", \"createdAt\"];\n if (!dateKey) {\n for (const candidate of dateCandidates) {\n if (collection.properties[candidate]) {\n dateKey = candidate;\n break;\n }\n }\n }\n if (!dateKey) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n if (p.type === \"date\") {\n dateKey = key;\n break;\n }\n }\n }\n\n // Relations: collect relation property keys for chip rendering.\n // When propertiesOrder is explicitly set, skip this — relations will\n // be shown in the developer-defined order, not as separate chips.\n const hasExplicitOrder = !!(collection.propertiesOrder as string[] | undefined);\n const relationKeys: string[] = [];\n if (!hasExplicitOrder) {\n for (const [key, prop] of Object.entries(collection.properties)) {\n const p = prop as Property;\n // The relation filling the title slot is already the row's headline;\n // repeating it as a chip below says the same thing twice.\n if (p.type === \"relation\" && key !== titleKey) {\n relationKeys.push(key);\n }\n }\n }\n\n // Subtitle: first preview key that isn't title/image/status/date/id.\n // When propertiesOrder is not set, also exclude relation keys (they render as chips).\n // Prefer string fields (especially multiline/description-like) over numbers.\n const excludeKeys = new Set([titleKey, imageKey, statusKey, dateKey, ...relationKeys]);\n const previewKeys = getEntityPreviewKeys(authController, collection, propertyConfigs, undefined, 10)\n .filter(k => !excludeKeys.has(k) && k !== \"id\");\n\n // When propertiesOrder is set, respect the developer-defined order (no re-sorting).\n // When not set, sort: strings first (prefer multiline → good description candidate).\n const sortedPreviewKeys = hasExplicitOrder\n ? previewKeys\n : [...previewKeys].sort((a, b) => {\n const propA = collection.properties[a] as Property | undefined;\n const propB = collection.properties[b] as Property | undefined;\n const scoreA = propA?.type === \"string\" ? (propA.admin?.multiline ? 2 : 1) : 0;\n const scoreB = propB?.type === \"string\" ? (propB.admin?.multiline ? 2 : 1) : 0;\n return scoreB - scoreA;\n });\n const subtitleKey = getDisplayPropertyKey(collection, \"subtitle\")\n ?? (sortedPreviewKeys.length > 0 ? sortedPreviewKeys[0] : undefined);\n\n return { titleKey,\ntitleKeyCandidates,\nimageKey,\nsubtitleKey,\nrelationKeys,\nstatusKey,\ndateKey,\ntagsKey: getDisplayPropertyKey(collection, \"tags\") };\n}\n\n// ── Image place ───────────────────────────────────────────────────────\n\n/**\n * Whether a list row, a card or a kanban card keeps its image place where no\n * property fills it, drawing the collection's icon there. A view given\n * `fields` that leaves every image out keeps none.\n *\n * @internal Provided by the collection view; read through {@link useImagePlace}.\n */\nexport const EmptyImagePlaceContext = React.createContext(true);\n\n/**\n * Whether the rows of the collection view around draw an image place: a\n * property fills it (`imageKey`, from {@link useCollectionSlotKeys}), or the\n * view keeps an empty one with the collection's icon. A view given `fields`\n * that leaves every image out keeps none, so the place takes no room — a copy\n * of a card or a row honours `fields` by drawing its thumbnail only when this\n * says so.\n *\n * @group Components\n */\nexport function useImagePlace(imageKey: string | undefined): boolean {\n return React.useContext(EmptyImagePlaceContext) || imageKey !== undefined;\n}\n\n// ── Image unwrapping helper ───────────────────────────────────────────\n\n/**\n * Unwrap image property + value from potential array-of-images.\n * Returns `{ property, value }` where property is the *inner* property\n * and value is the first element (for arrays) or the raw value.\n */\nfunction resolveImageSlot(\n collection: AdminCollection<Record<string, unknown>>,\n imageKey: string,\n entity: Entity<Record<string, unknown>>\n): PreviewSlot | undefined {\n const imageProperty = collection.properties[imageKey];\n if (!imageProperty) return undefined;\n\n const ofProp = \"of\" in imageProperty ? imageProperty.of : undefined;\n const resolvedProperty = ofProp\n ? (Array.isArray(ofProp) ? ofProp[0] : ofProp)\n : imageProperty;\n\n const rawValue = getValueInPath(entity.values, imageKey);\n const resolvedValue = ofProp\n ? (((rawValue as unknown[]) ?? []).length > 0 ? (rawValue as unknown[])[0] : undefined)\n : rawValue;\n\n if (resolvedValue === undefined || resolvedValue === null) return undefined;\n\n return {\n role: \"image\",\n property: resolvedProperty as Property,\n propertyKey: imageKey,\n value: resolvedValue\n };\n}\n\n// ── Title resolution (entity-level) ───────────────────────────────────\n\n/**\n * Walk the collection's ranked title candidates and return the first one that\n * holds something a person can read for this entity. Candidates are already\n * ordered and free of identifier properties; this only rejects values —\n * empties, and strings that turn out to be an id at runtime.\n */\nfunction resolveEntityTitleKey(\n entity: Entity<Record<string, unknown>>,\n candidates: string[]\n): string | undefined {\n for (const key of candidates) {\n const value = getValueInPath(entity.values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\") {\n if (looksLikeIdentifierValue(value)) continue;\n if (value === String(entity.id)) continue;\n }\n return key;\n }\n return candidates[0];\n}\n\n// ── Hook: collection-level slot keys ──────────────────────────────────\n\n/**\n * Resolves which property key fills each preview slot for a collection.\n * Memoized — only recomputes when the collection definition changes.\n *\n * Use this in the parent list/grid component, then pass the result to\n * `resolveEntitySlots` for each entity row.\n */\nexport function useCollectionSlotKeys(\n collection: AdminCollection<Record<string, unknown>>,\n authController: AuthController,\n propertyConfigs: Record<string, PropertyConfig>\n): CollectionSlotKeys {\n return useMemo(\n () => resolveCollectionSlotKeys(collection, authController, propertyConfigs),\n [collection, authController, propertyConfigs]\n );\n}\n\n// ── Pure function: entity-level slot resolution ───────────────────────\n\n/**\n * Resolve concrete slot values for a single entity.\n * This is a pure function (no hooks) so it can be called inside\n * `React.memo` render functions or loops without violating hook rules.\n */\nexport function resolveEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys,\n /** How the date slot is written: the relative phrases' language, say. */\n dateOptions?: FormatCollectionDateOptions\n): EntityPreviewSlots {\n const { titleKey, titleKeyCandidates, imageKey, subtitleKey, relationKeys, statusKey, dateKey, tagsKey } = slotKeys;\n\n // Image\n const image = imageKey ? resolveImageSlot(collection, imageKey, entity) : undefined;\n\n // Title — the best-ranked candidate that carries a readable value for THIS\n // entity, so a row whose name is empty (or whose column happens to hold a\n // UUID) falls through to the next candidate instead of showing an id.\n const resolvedTitleKey = resolveEntityTitleKey(entity, titleKeyCandidates ?? (titleKey ? [titleKey] : []));\n let title: PreviewSlot | undefined;\n if (resolvedTitleKey) {\n const prop = collection.properties[resolvedTitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, resolvedTitleKey);\n if (prop) title = { role: \"title\",\nproperty: prop,\npropertyKey: resolvedTitleKey,\nvalue: val };\n }\n\n // Subtitle\n let subtitle: PreviewSlot | undefined;\n if (subtitleKey && subtitleKey !== resolvedTitleKey) {\n const prop = collection.properties[subtitleKey] as Property | undefined;\n const val = getValueInPath(entity.values, subtitleKey);\n if (prop && val !== undefined && val !== null && val !== \"\") {\n subtitle = { role: \"subtitle\",\nproperty: prop,\npropertyKey: subtitleKey,\nvalue: val };\n }\n }\n\n // Relations — resolve chip items for every relation property\n const relations: RelationChipSlot[] = [];\n const MAX_CHIPS_PER_RELATION = 3;\n\n for (const relKey of relationKeys) {\n const prop = collection.properties[relKey] as RelationProperty | undefined;\n if (!prop || prop.type !== \"relation\") continue;\n\n const val = getValueInPath(entity.values, relKey);\n if (val === undefined || val === null) continue;\n\n const items: RelationChipItem[] = [];\n let totalCount = 0;\n\n const isMany = relationCardinality(prop.relation) === \"many\";\n\n if (isMany && Array.isArray(val)) {\n // cardinality:\"many\" → array of EntityRelation\n totalCount = val.length;\n for (let i = 0; i < Math.min(val.length, MAX_CHIPS_PER_RELATION); i++) {\n const rel = val[i];\n if (rel && typeof rel === \"object\") {\n const displayName = resolveRelationDisplayName(rel as EntityRelation, prop);\n const id = (rel as EntityRelation).id ?? i;\n if (displayName) {\n items.push({ displayName,\nid });\n }\n }\n }\n } else if (!isMany && val && typeof val === \"object\") {\n // cardinality:\"one\" → single EntityRelation\n const obj = val as Record<string, unknown>;\n const isRelation = (\"__type\" in obj && obj.__type === \"relation\")\n || (typeof obj.isEntityRelation === \"function\"\n && (obj.isEntityRelation as () => boolean)());\n if (isRelation) {\n const displayName = resolveRelationDisplayName(obj, prop);\n totalCount = 1;\n // An `EntityRelation`'s id, or the wire ref's: a string or a number either way.\n const id = obj.id;\n if (displayName && (typeof id === \"string\" || typeof id === \"number\")) {\n items.push({ displayName,\nid });\n }\n }\n }\n\n if (items.length > 0) {\n const relIndex = relationKeys.indexOf(relKey);\n // Walking the seed keys rather than `Object.values`: the table also\n // holds a bare-hue alias per hue, so raw values would hand the first\n // two relations the same scheme.\n const colorScheme = CHIP_COLORS[CHIP_SEED_KEYS[relIndex % CHIP_SEED_KEYS.length]];\n relations.push({\n property: prop,\n propertyKey: relKey,\n label: prop.name || relKey,\n items,\n totalCount,\n colorScheme\n });\n }\n }\n\n // Status\n let status: PreviewSlot | undefined;\n if (statusKey) {\n const prop = collection.properties[statusKey] as Property | undefined;\n const val = getValueInPath(entity.values, statusKey);\n if (prop && val !== undefined && val !== null) {\n status = { role: \"status\",\nproperty: prop,\npropertyKey: statusKey,\nvalue: val };\n }\n }\n\n // Date\n let date: DatePreviewSlot | undefined;\n if (dateKey) {\n const prop = collection.properties[dateKey] as Property | undefined;\n const val = getValueInPath(entity.values, dateKey);\n if (prop && val !== undefined && val !== null) {\n date = {\n role: \"date\",\n property: prop,\n propertyKey: dateKey,\n value: val,\n formatted: formatCollectionDate(val, prop, dateOptions) ?? String(val)\n };\n }\n }\n\n // Tags — declared only, and empty means absent: an empty array is \"this\n // record has no labels\", which must render as nothing rather than as an\n // empty chip row that shifts every other slot down.\n let tags: PreviewSlot | undefined;\n if (tagsKey) {\n const prop = collection.properties[tagsKey] as Property | undefined;\n const val = getValueInPath(entity.values, tagsKey);\n const empty = val === undefined || val === null || val === \"\"\n || (Array.isArray(val) && val.length === 0);\n if (prop && !empty) {\n tags = { role: \"tags\",\nproperty: prop,\npropertyKey: tagsKey,\nvalue: val };\n }\n }\n\n return {\n image,\n title,\n subtitle,\n relations,\n status,\n date,\n tags,\n entityId: entity.id\n };\n}\n\n// ── Relation display name resolution ─────────────────────────────────\n\n/**\n * Extract a human-readable display name from an eagerly-loaded EntityRelation.\n * Uses the target collection's title property when available, otherwise\n * walks the entity values for the first short string; with neither, the id.\n */\nexport function resolveRelationDisplayName(\n relation: EntityRelation | Record<string, unknown>,\n prop: RelationProperty\n): string | undefined {\n const name = loadedRelationName(relation, prop);\n if (name !== undefined) return name;\n const id = \"id\" in relation ? relation.id : undefined;\n return id !== undefined ? String(id) : undefined;\n}\n\n/**\n * The related row's name from what is already on hand — values loaded with\n * the relation, or the entity cache — and nothing else: no id. A bare\n * foreign key has neither, and its caller fetches the row instead of\n * printing the key as though it were the name.\n */\nexport function loadedRelationName(\n relation: EntityRelation | Record<string, unknown>,\n prop: RelationProperty\n): string | undefined {\n // Support both EntityRelation instances and plain objects\n const data = \"data\" in relation ? (relation as EntityRelation).data : undefined;\n\n // Resolve target collection from either `prop.relation.target()` or `prop.relation?.target()` (inline API)\n let targetCollection: AdminCollection | undefined;\n try {\n const resolved = prop.relation?.target?.() ?? (typeof prop.relation?.target === \"function\" ? prop.relation?.target() : undefined);\n if (resolved && typeof resolved === \"object\") {\n targetCollection = resolved as AdminCollection;\n }\n } catch {\n // Target collection may not be resolvable\n }\n\n // Helper: extract display name from entity values using the target collection\n //\n // This used to carry a ranking of its own — priority keys `name/title/label/\n // displayName`, then the first visible non-id string — which is a *seventh*\n // answer to \"what is this record called\", and one that disagreed with the\n // shared one: it read `titleProperty` with a flat lookup (so a dotted path\n // was ignored), never saw `display.title`, and ranked by key name where the\n // shared ranking excludes identifiers structurally. A chip and the record it\n // points at could therefore be labelled differently on the same screen.\n //\n // What is left here is the part that is genuinely local: a relation carries\n // *eagerly loaded* values, not an entity, so a resolver cannot run against\n // it — a computed title falls back to the ranked property, which is the same\n // thing the list row shows while its own resolver is in flight.\n const extractDisplayName = (values: Record<string, unknown>): string | undefined => {\n if (targetCollection) {\n for (const key of getTitlePropertyCandidates(targetCollection)) {\n const value = getValueInPath(values, key);\n if (value === undefined || value === null || value === \"\") continue;\n if (typeof value === \"string\" && looksLikeIdentifierValue(value)) continue;\n return String(value);\n }\n }\n // Generic fallback: walk entity values for any short string.\n for (const [, v] of Object.entries(values)) {\n if (typeof v === \"string\" && v.length > 0 && v.length < 200) {\n return v;\n }\n }\n return undefined;\n };\n\n // 1. Try eagerly-loaded data on the relation object\n if (data && data.values) {\n const result = extractDisplayName(data.values as Record<string, unknown>);\n if (result) return result;\n }\n\n const id = \"id\" in relation ? relation.id : undefined;\n\n // 2. Try the entity cache (sessionStorage) as a fallback\n if (id !== undefined && targetCollection) {\n try {\n const slug = targetCollection.slug ?? (\"table\" in targetCollection ? targetCollection.table : undefined);\n if (slug) {\n const cacheKey = `${slug}/${id}`;\n const cached = getEntityFromCache(cacheKey) as { values?: Record<string, unknown> } | undefined;\n if (cached?.values) {\n const result = extractDisplayName(cached.values);\n if (result) return result;\n }\n }\n } catch {\n // Cache lookup failed — fall through\n }\n }\n\n return undefined;\n}\n\n/**\n * The slots for one record, with `admin.display` resolvers applied.\n *\n * {@link resolveEntitySlots} answers the question from values already in hand —\n * which is everything a slot filled by a property needs, and nothing a slot\n * filled by a *resolver* can use. A computed title may have to be fetched, so it\n * arrives after the first render; this hook is where the two meet.\n *\n * Until a resolver lands, the derived slot shows. That is deliberate: a list of\n * fifty rows must not blank its titles for a beat while fifty promises settle,\n * and the derived answer — the best-ranked property carrying a readable value —\n * is a reasonable thing to be looking at meanwhile. When the resolved value\n * arrives it replaces the slot outright, property and all, because there is no\n * property behind a computed value (see {@link PreviewSlot}).\n *\n * Every role is hooked unconditionally, so the hook order is fixed regardless of\n * what a given collection declares.\n */\nexport function useEntitySlots(\n entity: Entity<Record<string, unknown>>,\n collection: AdminCollection<Record<string, unknown>>,\n slotKeys: CollectionSlotKeys\n): EntityPreviewSlots {\n\n const relativeTimeLabels = useUiLabels().relativeTime;\n const derived = useMemo(\n () => resolveEntitySlots(entity, collection, slotKeys, { relativeTimeLabels }),\n [entity, collection, slotKeys, relativeTimeLabels]\n );\n\n const params = { collection,\nentity };\n const title = useEntityDisplay<string>(\"title\", params);\n const subtitle = useEntityDisplay<string>(\"subtitle\", params);\n const image = useEntityDisplay<string>(\"image\", params);\n const status = useEntityDisplay<string>(\"status\", params);\n const date = useEntityDisplay<Date | string | number>(\"date\", params);\n const tags = useEntityDisplay<string[] | string>(\"tags\", params);\n\n return useMemo(() => {\n // `source` is set only when the value came from a property, so its\n // absence is exactly the \"this was computed\" signal — no second flag to\n // keep in step with the first.\n // The role travels with the computed slot too. It is the only thing left\n // to say about a value with no property behind it, and `SlotValue` needs\n // it to tell a computed image from a computed title.\n const computed = (\n role: EntityDisplayRole,\n resolved: { value: unknown, source?: unknown }\n ): PreviewSlot | undefined =>\n resolved.value !== undefined && resolved.source === undefined\n ? { role,\nvalue: resolved.value }\n : undefined;\n\n const computedDate = computed(\"date\", date);\n\n return {\n ...derived,\n title: computed(\"title\", title) ?? derived.title,\n subtitle: computed(\"subtitle\", subtitle) ?? derived.subtitle,\n image: computed(\"image\", image) ?? derived.image,\n status: computed(\"status\", status) ?? derived.status,\n date: computedDate\n ? { ...computedDate,\nformatted: formatCollectionDate(computedDate.value, undefined, { relativeTimeLabels }) ?? String(computedDate.value) }\n : derived.date,\n tags: computed(\"tags\", tags) ?? derived.tags\n };\n }, [derived, title, subtitle, image, status, date, tags, relativeTimeLabels]);\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,oBAAoB,UAA2F;CAC3H,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAAU,OAAO;CACxE,OAAO,SAAS;AACpB;;;;;AAgIA,SAAgB,0BACZ,YACA,gBACA,iBACkB;CAKlB,MAAM,mBAAmB,2BAA2B,UAAU;CAC9D,MAAM,qBAAqB,2BAA2B,UAAU;CAChE,MAAM,qBAAqB,qBACrB,CAAC,oBAAoB,GAAG,iBAAiB,QAAO,QA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AC7E;EAAC;EAAQ;EAAY;EAAU;CAAkB,CACrD;CAEA,MAAM,SAAS;EAAE;EACrB;CAAO;CACH,MAAM,QAAQ,iBAAyB,SAAS,MAAM;CACtD,MAAM,WAAW,iBAAyB,YAAY,MAAM;CAC5D,MAAM,QAAQ,iBAAyB,SAAS,MAAM;CACtD,MAAM,SAAS,iBAAyB,UAAU,MAAM;CACxD,MAAM,OAAO,iBAAyC,QAAQ,MAAM;CACpE,MAAM,OAAO,iBAAoC,QAAQ,MAAM;CAE/D,OAAO,cAAc;EAOjB,MAAM,YACF,MACA,aAEA,SAAS,UAAU,KAAA,KAAa,SAAS,WAAW,KAAA,IAC9C;GAAE;GACpB,OAAO,SAAS;EAAM,IACJ,KAAA;EAEV,MAAM,eAAe,SAAS,QAAQ,IAAI;EAE1C,OAAO;GACH,GAAG;GACH,OAAO,SAAS,SAAS,KAAK,KAAK,QAAQ;GAC3C,UAAU,SAAS,YAAY,QAAQ,KAAK,QAAQ;GACpD,OAAO,SAAS,SAAS,KAAK,KAAK,QAAQ;GAC3C,QAAQ,SAAS,UAAU,MAAM,KAAK,QAAQ;GAC9C,MAAM,eACA;IAAE,GAAG;IACvB,WAAW,qBAAqB,aAAa,OAAO,KAAA,GAAW,EAAE,mBAAmB,CAAC,KAAK,OAAO,aAAa,KAAK;GAAE,IACnG,QAAQ;GACd,MAAM,SAAS,QAAQ,IAAI,KAAK,QAAQ;EAC5C;CACJ,GAAG;EAAC;EAAS;EAAO;EAAU;EAAO;EAAQ;EAAM;EAAM;CAAkB,CAAC;AAChF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig, Entity } from "@rebasepro/types";
|
|
2
|
-
import type { EntitySelectionController, SelectionController } from "@rebasepro/cms-types";
|
|
1
|
+
import type { EntitySelectionController, SelectionController, CollectionConfig, Entity } from "@rebasepro/cms-types";
|
|
3
2
|
export declare function useEntitySelectionController<M extends Record<string, unknown> = Record<string, unknown>>(onSelectionChange?: (entity: Entity<M>, selected: boolean) => void): EntitySelectionController<M>;
|
|
4
3
|
/**
|
|
5
4
|
* A selection of rows in a collection, for a view of it you control: hand it
|